/*************************************************************************** * Copyright (C) 2004 by Johan Maes - ON4QZ * * on4qz@telenet.be * * http://users.telenet.be/on4qz * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #include "zoomwindow.h" #include #include #include #include #include #include "qsstvglobal.h" #include "imageview.h" #include #include #include zoomWindow::zoomWindow(QWidget* parent, const char* name): zoomForm( parent, name, TRUE) { } zoomWindow::~zoomWindow() { originalImage.reset(); //free storage } void zoomWindow::zoom(QImage *ipm) { readSettings(); originalImage=ipm->copy(); slotSliderMoved(zoomScale); } void zoomWindow::readSettings() { QSettings qSettings(QSettings::Ini); qSettings.beginGroup(APP_KEY+"/ZOOM/"); int windowWidth = qSettings.readNumEntry("zoomWindowWidth", 460 ); int windowHeight = qSettings.readNumEntry("zoomWindowHeight", 530 ); int windowX = qSettings.readNumEntry( "zoomWindowX", -1 ); int windowY = qSettings.readNumEntry( "zoomWindowY", -1 ); resize( windowWidth, windowHeight ); if ( windowX != -1 || windowY != -1 ) move( windowX, windowY ); zoomScale=qSettings.readNumEntry("zoomScale", 3 ); qSettings.endGroup(); slotSetParams(); } void zoomWindow::writeSettings() { QSettings qSettings(QSettings::Ini); qSettings.beginGroup(APP_KEY+"/RX/"); qSettings.writeEntry( "zoomWindowWidth", width() ); qSettings.writeEntry( "zoomWindowHeight", height() ); qSettings.writeEntry( "zoomWindowX", x() ); qSettings.writeEntry( "zoomWindowY", y() ); qSettings.writeEntry("zoomScale",zoomScale); qSettings.endGroup(); } void zoomWindow::slotSetParams() { zoomSlider->setValue(zoomScale); } void zoomWindow::slotSliderMoved(int v) { int w,h; w=originalImage.width(); h=originalImage.height(); zoomScale=v; switch(v) { case 0: w/=4; h/=4; break; case 1: w/=3; h/=3; break; case 2: w/=2; h/=2; break; case 3: break; case 4: w*=2; h*=2; break; case 5: w*=3; h*=3; break; case 6: w*=4; h*=4; break; default: break; } zoomFrame->setNewSize(w,h); zoomFrame->showImage(&originalImage); } void zoomWindow::slotClose() { close(); } void zoomWindow::closeEvent(QCloseEvent *e) { writeSettings(); e->accept(); }