-rw-r--r-- | noncore/multimedia/showimg/main.cpp | 10 | ||||
-rw-r--r-- | noncore/multimedia/showimg/showimg.cpp | 90 | ||||
-rw-r--r-- | noncore/multimedia/showimg/showimg.h | 1 | ||||
-rw-r--r-- | noncore/multimedia/showimg/showimg.pro | 4 |
4 files changed, 50 insertions, 55 deletions
diff --git a/noncore/multimedia/showimg/main.cpp b/noncore/multimedia/showimg/main.cpp index c28cc85..efb1c68 100644 --- a/noncore/multimedia/showimg/main.cpp +++ b/noncore/multimedia/showimg/main.cpp @@ -17,17 +17,11 @@ ** not clear to you. ** **********************************************************************/ #include "showimg.h" #include <qpe/qpeapplication.h> -int main( int argc, char **argv ) -{ - QPEApplication a( argc, argv ); - - ImageViewer w(0, "new window", Qt::WResizeNoErase ); - a.showMainDocumentWidget(&w); +#include <opie/oapplicationfactory.h> - return a.exec(); -} +OPIE_EXPORT_APP( OApplicationFactory<ImageViewer> )
\ No newline at end of file diff --git a/noncore/multimedia/showimg/showimg.cpp b/noncore/multimedia/showimg/showimg.cpp index d6f0733..56bdecf 100644 --- a/noncore/multimedia/showimg/showimg.cpp +++ b/noncore/multimedia/showimg/showimg.cpp @@ -21,17 +21,17 @@ // // Full-screen and rotation options contributed by Robert Wittams <robert@wittams.com> // #include "showimg.h" #include "ImageFileSelector.h" #include "settingsdialog.h" - + #include <opie/ofiledialog.h> #include <qpe/qpeapplication.h> #include <qpe/config.h> #include <qpe/resource.h> #include <qpe/fileselector.h> #include <qpe/applnk.h> #include <qfileinfo.h> @@ -70,21 +70,21 @@ ControlsDialog::ControlsDialog(const QString &caption,QImage image,int *brightne QGridLayout *gl= new QGridLayout(this,2,2,4,4); pixmap =new ImageWidget(this);; QPixmap pm; pm.convertFromImage(img); pixmap->setPixmap(pm); pixmap->setMinimumSize(pm.width(),pm.height()); - gl->addMultiCellWidget(pixmap,0,0,0,2,AlignCenter); + gl->addMultiCellWidget(pixmap,0,0,0,2,AlignCenter); QLabel *l=new QLabel(tr("Brightness")+":",this); - gl->addWidget(l,1,0,AlignLeft); - spb=new QSpinBox(-100,100,2,this); - gl->addWidget(spb,1,1,AlignRight); + gl->addWidget(l,1,0,AlignLeft); + spb=new QSpinBox(-100,100,2,this); + gl->addWidget(spb,1,1,AlignRight); spb->setValue(0); connect(spb,SIGNAL(valueChanged(int)),this, SLOT(bValueChanged(int))); } void ControlsDialog::bValueChanged(int value) @@ -97,68 +97,70 @@ void ControlsDialog::bValueChanged(int value) pixmap->setPixmap(pm); pixmap->repaint(false); } void ControlsDialog::accept() { - *b=spb->value(); + *b=spb->value(); done(1); } //=========================================================================== InfoDialog::InfoDialog(const QString &caption, const QStringList text,QWidget *parent) : QDialog(parent,0,true) { setCaption(caption); if ( parent ) { setPalette(parent->palette()); } - const char *labels[]={"File Name","Format","File Size","Size","Colors","Alpha"}; + + + QString labels[]={ tr("File Name"),tr("Format"),tr("File Size"),tr("Size"),tr("Colors"),tr("Alpha") }; setMinimumSize(180,80); int num=ImageViewer::LAST+1; if ( text[ImageViewer::ALPHA].isEmpty() ) num--; QGridLayout *gl= new QGridLayout(this,num,2,4,2); QLabel *l; int count=0; for ( int i=0;i<num;i++ ) { if ( i==1 ) { QFrame *frm=new QFrame(this); frm->setFrameStyle(QFrame::HLine|QFrame::Sunken); - gl->addMultiCellWidget(frm,i,i,0,1); + gl->addMultiCellWidget(frm,i,i,0,1); } else { - l=new QLabel(tr(labels[count])+":",this); - gl->addWidget(l,i,0,AlignLeft); + l=new QLabel( tr( labels[count] )+":",this); + gl->addWidget(l,i,0,AlignLeft); l=new QLabel(text[count],this); gl->addWidget(l,i,1,AlignRight); count++; } - } + } } void InfoDialog::displayInfo(const QString &caption, const QStringList text, QWidget *parent) { InfoDialog *dlg=new InfoDialog(caption,text,parent); dlg->exec(); delete dlg; -} +} //=========================================================================== ImagePane::ImagePane( QWidget *parent ) : QWidget( parent ) { vb = new QVBoxLayout( this ); @@ -205,17 +207,17 @@ void ImageWidget::paintEvent( QPaintEvent *e ) void ImageWidget::mouseReleaseEvent(QMouseEvent *) { emit clicked(); } //=========================================================================== ImageViewer::ImageViewer( QWidget *parent, const char *name, int wFlags ) -: QMainWindow( parent, name, wFlags ), filename( 0 ), bFromDocView( FALSE ) +: QMainWindow( parent, name, WResizeNoErase ), filename( 0 ), bFromDocView( FALSE ) { setCaption( tr("Image Viewer") ); setIcon( Resource::loadPixmap( "ImageViewer" ) ); Config cfg("Image Viewer"); cfg.setGroup("Image Viewer"); @@ -236,21 +238,21 @@ ImageViewer::ImageViewer( QWidget *parent, const char *name, int wFlags ) fileMenuFile = new QPopupMenu(this); //menuBarmenubarFile->insertItem( tr("File"), fileMenu ); fileMenuFile->insertItem(tr("Open"), this, SLOT(openFile()), 0); viewMenuFile = new QPopupMenu( this ); - //menubarFile->insertItem( tr("View"), viewMenu ); + //menubarFile->insertItem( tr("View"), viewMenu ); viewMenuFile->insertItem( tr("Thumbnail View"), this, SLOT(switchThumbView()), 0, SHOW_THUMBNAILS ); - - viewMenuFile->setItemChecked ( SHOW_THUMBNAILS, showThumbView ); + + viewMenuFile->setItemChecked ( SHOW_THUMBNAILS, showThumbView ); optionsMenuFile = new QPopupMenu( this); //menubarFile->insertItem( tr("Options"),optionsMenu ); slideAction = new QAction( tr( "Slide show" ), Resource::loadIconSet( "slideshow" ), QString::null, 0, this, 0 ); @@ -264,48 +266,48 @@ ImageViewer::ImageViewer( QWidget *parent, const char *name, int wFlags ) optionsMenuFile->insertSeparator(); optionsMenuFile->insertItem( tr("Preferences.."), this, SLOT(settings()), 0); // optionsMenuFile->insertItem( tr("Help"), this, SLOT(help()), 0); QStrList fmt = QImage::outputFormats(); fileMenuView = new QPopupMenu( this ); - //menubarView->insertItem( tr("File"),fileMenu ); + //menubarView->insertItem( tr("File"),fileMenu ); fileMenuView->insertItem( tr("Image Info ..."),this, SLOT(displayInfoDialog()),0 ); - fileMenuView->insertSeparator(); + fileMenuView->insertSeparator(); viewMenuView = new QPopupMenu(this ); - viewMenuView->setCheckable ( true ); + viewMenuView->setCheckable ( true ); - //menubarView->insertItem( tr("View"),viewMenu ); + //menubarView->insertItem( tr("View"),viewMenu ); viewMenuView->insertItem(tr("Horizontal flip"), this, SLOT(hFlip()), 0); viewMenuView->insertItem(tr("Vertical flip"), this, SLOT(vFlip()), 0); stack = new QWidgetStack( this ); stack->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); setCentralWidget( stack ); - imagePanel = new ImagePane( stack ); + imagePanel = new ImagePane( stack ); connect(imagePanel, SIGNAL(clicked()), this, SLOT(normalView())); ImageFileSelector::CURRENT_VIEW cv; if(showThumbView) cv=ImageFileSelector::THUMBNAIL; else cv=ImageFileSelector::DETAILED; qDebug("cv = %d",cv); - fileSelector = new ImageFileSelector( cv,stack, "fs"); - + fileSelector = new ImageFileSelector( cv,stack, "fs"); + //switchThumbView(); - + //fileSelector = new ImageFileSelector("image/*", stack, "fs"); //fileSelector->setNewVisible(FALSE); //fileSelector->setCloseVisible(FALSE); connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( closeFileSelector() ) ); connect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( openFile( const DocLnk & ) ) ); @@ -314,17 +316,17 @@ ImageViewer::ImageViewer( QWidget *parent, const char *name, int wFlags ) iconToolBar = new QPEToolBar(this); QAction *a; a = new QAction( tr( "Open ..." ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 ); connect( a, SIGNAL( activated() ), this, SLOT( open() ) ); a->addTo( fileMenuView); - a->addTo( iconToolBar ); + a->addTo( iconToolBar ); a = new QAction( tr( "Rotate 90"), Resource::loadPixmap( "rotate90" ), QString::null, 0, this, 0); connect( a, SIGNAL( activated() ), this, SLOT( rot90() ) ); a->addTo( iconToolBar ); a->addTo( viewMenuView ); a = new QAction( tr( "Rotate 180" ), Resource::loadPixmap( "repeat" ), QString::null, 0, this, 0 ); @@ -346,17 +348,17 @@ 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); + 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); @@ -377,26 +379,26 @@ ImageViewer::ImageViewer( QWidget *parent, const char *name, int wFlags ) 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 ); + 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); @@ -458,17 +460,17 @@ void ImageViewer::updateImage() } 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 ); @@ -492,17 +494,17 @@ void ImageViewer::switchToImageView() imagePanel->setPosition(0,0); } void ImageViewer::setDocument(const QString& fileref) { delayLoad = fileref; - switchToImageView(); + switchToImageView(); QTimer::singleShot( 0, this, SLOT(doDelayedLoad()) ); } void ImageViewer::doDelayedLoad() { show(delayLoad); } @@ -527,17 +529,17 @@ void ImageViewer::show(const QString& 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() ) openFile(link); } void ImageViewer::openFile( const DocLnk &link ) @@ -545,27 +547,27 @@ 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(); + switchToImageView(); } void ImageViewer::updateCaption( QString name ) { int sep = name.findRev( '/' ); if ( sep >= 0 ) name = name.mid( sep+1 ); setCaption( name + tr(" - Image Viewer") ); @@ -577,41 +579,41 @@ void ImageViewer::updateCaption( QString name ) 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); + 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(); + rot90(); // matrix.rotate( -90.0 ); } - + switchToImageView(); updateImage(); } bool ImageViewer::loadSelected() { bool ok = false; @@ -620,20 +622,20 @@ bool ImageViewer::loadSelected() const DocLnk *link = fileSelector->selected(); if ( link ) { if ( link->file() != filename ) { updateCaption( link->name() ); filename = link->file(); qApp->processEvents(); - ok = image.load(filename, 0); + ok = image.load(filename, 0); if ( ok ) { - updateImageInfo(filename); + updateImageInfo(filename); ok = reconvertImage(); } if ( !ok ) pm.resize(0,0); } } } if ( !image.isNull() ) @@ -722,17 +724,17 @@ void ImageViewer::resizeEvent( QResizeEvent * ) if ( image.hasAlphaBuffer() ) erase(); } void ImageViewer::hFlip() { // matrix.scale( -1.0, 1.0 ); - + setImage(image.mirror(TRUE,FALSE)); } void ImageViewer::vFlip() { // matrix.scale( 1.0, -1.0 ); setImage(image.mirror(FALSE,TRUE)); } @@ -802,17 +804,17 @@ void ImageViewer::displayInfoDialog() } void ImageViewer::normalView() { if ( !imagePanel->parentWidget() ) { isFullScreen = FALSE; stack->addWidget( imagePanel, 1 ); - switchToImageView(); + switchToImageView(); if ( isSized ) scale(); updateImage(); } } @@ -837,30 +839,30 @@ void ImageViewer::fullScreen() imagePanel->showFullScreen(); } } void ImageViewer::setImage(const QImage& newimage) { image = newimage; reconvertImage(); - updateImage(); + updateImage(); } void ImageViewer::updateImageInfo(QString &filePath) { for ( int i=0;i<LAST;i++ ) { imageInfo[i]=""; } imageInfo[FORMAT]=QImage::imageFormat (filePath ); QFileInfo fi(filePath); - imageInfo[PATH]=fi.fileName(); + imageInfo[PATH]=fi.fileName(); imageInfo[FILE_SIZE]=QString::number(fi.size())+" (bytes)"; QString message("%1x%2"); imageInfo[SIZE]=QString("%1x%2"); imageInfo[SIZE]=imageInfo[SIZE].arg(image.width()).arg(image.height()); if ( image.numColors() > 0 ) { imageInfo[COLORS]=tr("%1 colors").arg(image.numColors()); } diff --git a/noncore/multimedia/showimg/showimg.h b/noncore/multimedia/showimg/showimg.h index 8555ff0..abbd976 100644 --- a/noncore/multimedia/showimg/showimg.h +++ b/noncore/multimedia/showimg/showimg.h @@ -153,16 +153,17 @@ private slots: void imageClicked(); }; class ImageViewer : public QMainWindow { Q_OBJECT public: + static QString appName() { return QString::fromLatin1("showimg"); } ImageViewer( QWidget *parent=0, const char *name=0, int wFlags=0 ); ~ImageViewer(); void loadImage( const char *fileName ); void show(const QString& fileref); void show(); diff --git a/noncore/multimedia/showimg/showimg.pro b/noncore/multimedia/showimg/showimg.pro index d369e62..e8d753b 100644 --- a/noncore/multimedia/showimg/showimg.pro +++ b/noncore/multimedia/showimg/showimg.pro @@ -1,11 +1,9 @@ -TEMPLATE = app -CONFIG += qt warn_on release -DESTDIR = $(OPIEDIR)/bin +CONFIG += qt warn_on release quick-app HEADERS = showimg.h ImageFileSelector.h settingsdialog.h settingsdialogbase.h SOURCES = main.cpp showimg.cpp ImageFileSelector.cpp settingsdialog.cpp settingsdialogbase.cpp TARGET = showimg INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include LIBS += -lqpe -lopie TRANSLATIONS = ../../../i18n/de/showimg.ts \ |