-rw-r--r-- | noncore/multimedia/showimg/showimg.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/multimedia/showimg/showimg.cpp b/noncore/multimedia/showimg/showimg.cpp index 0fbffe7..d6f0733 100644 --- a/noncore/multimedia/showimg/showimg.cpp +++ b/noncore/multimedia/showimg/showimg.cpp @@ -346,385 +346,385 @@ ImageViewer::ImageViewer( QWidget *parent, const char *name, int wFlags ) viewMenuView->insertSeparator(); sss = new QAction( tr( "Scale to Screen"), Resource::loadPixmap( "scale" ), QString::null, 0, this, 0,true); connect( sss, SIGNAL( activated() ), this, SLOT( switchSizeToScreen() ) ); sss->addTo( iconToolBar ); sss->addTo( viewMenuView ); sss->setOn(isSized); viewMenuView->insertSeparator(); a = new QAction( tr( "Fullscreen" ), Resource::loadPixmap( "fullscreen" ), QString::null, 0, this, 0 ); connect( a, SIGNAL( activated() ), this, SLOT( fullScreen() ) ); a->addTo( iconToolBar ); a->addTo( viewMenuView); a = new QAction( tr( "Stop Slideshow" ), Resource::loadPixmap( "quit_icon" ), QString::null, 0, this, 0 ); connect( a, SIGNAL( activated() ), this, SLOT( stopSlideShow() ) ); a->addTo( iconToolBar ); a->addTo( viewMenuView); Config config( "ImageViewer" ); config.setGroup( "SlideShow" ); slideDelay = config.readNumEntry( "Delay", 2); slideRepeat = config.readBoolEntry( "Repeat", FALSE ); slideReverse = config.readBoolEntry("Reverse", FALSE); config.setGroup("Default"); rotateOnLoad = config.readBoolEntry("Rotate", FALSE); fastLoad = config.readBoolEntry("FastLoad", TRUE); slideTimer = new QTimer( this ); connect( slideTimer, SIGNAL(timeout()), this, SLOT(slideUpdate()) ); switchToFileSelector(); setMouseTracking( TRUE ); } ImageViewer::~ImageViewer() { Config cfg("Image Viewer"); cfg.setGroup("Image Viewer"); cfg.writeEntry("ShowThumbnails",(int)showThumbView); cfg.writeEntry("SizeToScreen",(int)isSized); cfg.setGroup( "SlideShow" ); cfg.writeEntry( "Delay", slideDelay); cfg.writeEntry( "Repeat", slideRepeat ); cfg.writeEntry("Reverse", slideReverse); cfg.setGroup("Default"); cfg.writeEntry("Rotate", rotateOnLoad); cfg.writeEntry("FastLoad", fastLoad); delete imagePanel; // in case it is fullscreen } void ImageViewer::help() { } void ImageViewer::settings() { SettingsDialog dlg( this, 0, TRUE ); dlg.setDelay( slideDelay ); dlg.setRepeat( slideRepeat ); dlg.setReverse( slideReverse ); dlg.setRotate(rotateOnLoad); dlg.setFastLoad(fastLoad); if ( QPEApplication::execDialog(&dlg) == QDialog::Accepted ) { qDebug("<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>"); slideDelay = dlg.delay(); slideRepeat = dlg.repeat(); slideReverse = dlg.reverse(); rotateOnLoad = dlg.rotate(); fastLoad = dlg.fastLoad(); Config config( "ImageViewer" ); config.setGroup( "SlideShow" ); config.writeEntry( "Delay", slideDelay ); config.writeEntry( "Repeat", slideRepeat ); config.writeEntry("Reverse", slideReverse); config.setGroup("Default"); config.writeEntry("Rotate", rotateOnLoad); config.writeEntry("FastLoad", fastLoad); } } void ImageViewer::switchSizeToScreen() { isSized=!isSized; sss->setOn(isSized); updateImage(); } void ImageViewer::updateImage() { if ( isSized ) { imagePanel->setPixmap(pmScaled); } else { imagePanel->setPixmap(pm); } } void ImageViewer::switchThumbView() { showThumbView=!showThumbView; viewMenuFile->setItemChecked ( SHOW_THUMBNAILS, showThumbView ); fileSelector->switchView(); } void ImageViewer::switchToFileSelector() { stack->raiseWidget(fileSelector); menuBar->clear(); menuBar->insertItem( tr("File"), fileMenuFile ); menuBar->insertItem( tr("View"), viewMenuFile ); menuBar->insertItem( tr("Options"), optionsMenuFile ); iconToolBar->hide(); imagePanel->disable(); slideShow(false); } void ImageViewer::switchToImageView() { stack->raiseWidget(imagePanel); menuBar->clear(); menuBar->insertItem( tr("File"), fileMenuView ); menuBar->insertItem( tr("View"), viewMenuView ); viewMenuView->setItemEnabled(BLACKANDWHITE,true); iconToolBar->show(); imagePanel->setPosition(0,0); } void ImageViewer::setDocument(const QString& fileref) { delayLoad = fileref; switchToImageView(); QTimer::singleShot( 0, this, SLOT(doDelayedLoad()) ); } void ImageViewer::doDelayedLoad() { show(delayLoad); } void ImageViewer::show() { normalView(); QMainWindow::show(); } void ImageViewer::show(const QString& fileref) { // qDebug("Show "+fileref); bFromDocView = TRUE; closeFileSelector(); DocLnk link(fileref); if ( link.isValid() ) { openFile(link); } else { filename = fileref; updateCaption( fileref ); loadImage( fileref ); } } void ImageViewer::openFile() { MimeTypes types; QStringList image; image << "image/*"; types.insert("Images", image); QString str = OFileDialog::getOpenFileName( 1,QPEApplication::documentDir(),"", types, 0 ); DocLnk link(str); - if ( link.isValid() ) +// if ( link.isValid() ) openFile(link); } void ImageViewer::openFile( const DocLnk &link ) { closeFileSelector(); // DocLnk link(file); qDebug("open "+link.name()); updateCaption( link.name() ); loadImage( link.file() ); if (slideTimer->isActive()) { slideTimer->start(slideDelay * 1000, FALSE); } } void ImageViewer::open() { switchToFileSelector(); } void ImageViewer::closeFileSelector() { switchToImageView(); } void ImageViewer::updateCaption( QString name ) { int sep = name.findRev( '/' ); if ( sep >= 0 ) name = name.mid( sep+1 ); setCaption( name + tr(" - Image Viewer") ); } /* This function loads an image from a file. */ void ImageViewer::loadImage( const char *fileName ) { filename = fileName; if ( filename ) { QApplication::setOverrideCursor( waitCursor ); // this might take time //imagePanel->statusLabel()->setText( tr("Loading image...") ); qApp->processEvents(); bool ok = image.load(filename, 0); if ( ok ) { ok = reconvertImage(); updateImageInfo(filename); } if ( !ok ) { pm.resize(0,0); // couldn't load image update(); } QApplication::restoreOverrideCursor(); // restore original cursor } // fastLoad ? ", Fast" : "", // fastLoad ? QMAX(imagewidth/maxsize, imageheight/maxsize) : 1); // matrix.reset(); rotated90 = FALSE; if (rotateOnLoad) { rotated90 = TRUE; rot90(); // matrix.rotate( -90.0 ); } switchToImageView(); updateImage(); } bool ImageViewer::loadSelected() { bool ok = false; if ( stack->visibleWidget() == fileSelector ) { const DocLnk *link = fileSelector->selected(); if ( link ) { if ( link->file() != filename ) { updateCaption( link->name() ); filename = link->file(); qApp->processEvents(); ok = image.load(filename, 0); if ( ok ) { updateImageInfo(filename); ok = reconvertImage(); } if ( !ok ) pm.resize(0,0); } } } if ( !image.isNull() ) { ok = true; closeFileSelector(); } return ok; } bool ImageViewer::reconvertImage() { bool success = FALSE; if ( image.isNull() ) return FALSE; QApplication::setOverrideCursor( waitCursor ); // this might take time if ( pm.convertFromImage(image /*, conversion_flags */ ) ) { pmScaled = QPixmap(); scale(); success = TRUE; // load successful } else { pm.resize(0,0); // couldn't load image } QApplication::restoreOverrideCursor(); // restore original cursor return success; // TRUE if loaded OK } int ImageViewer::calcHeight() { if ( !isFullScreen ) return imagePanel->paneHeight(); else return qApp->desktop()->height(); } /* This functions scales the pixmap in the member variable "pm" to fit the widget size and puts the resulting pixmap in the member variable "pmScaled". */ void ImageViewer::scale() { int h = calcHeight(); if ( image.isNull() ) return; QApplication::setOverrideCursor( waitCursor ); // this might take time if ( imagePanel->paneWidth() == pm.width() && h == pm.height() ) { // no need to scale if widget pmScaled = pm; // size equals pixmap size } else { double hs = (double)h / (double)image.height(); double ws = (double)imagePanel->paneWidth() / (double)image.width(); double scaleFactor = (hs > ws) ? ws : hs; int smoothW = (int)(scaleFactor * image.width()); int smoothH = (int)(scaleFactor * image.height()); pmScaled.convertFromImage( image.smoothScale( smoothW, smoothH ) /*, conversion_flags */ ); } QApplication::restoreOverrideCursor(); // restore original cursor } /* The resize event handler, if a valid pixmap was loaded it will call scale() to fit the pixmap to the new widget size. */ void ImageViewer::resizeEvent( QResizeEvent * ) { if ( pm.size() == QSize( 0, 0 ) ) // we couldn't load the image return; int h = calcHeight(); if ( imagePanel->paneWidth() != pmScaled.width() || h != pmScaled.height() ) { // if new size, scale(); // scale pmScaled to window } if ( image.hasAlphaBuffer() ) erase(); } void ImageViewer::hFlip() { // matrix.scale( -1.0, 1.0 ); |