Diffstat (limited to 'noncore/multimedia/showimg/showimg.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/multimedia/showimg/showimg.cpp | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/noncore/multimedia/showimg/showimg.cpp b/noncore/multimedia/showimg/showimg.cpp index 696a57b..24377ed 100644 --- a/noncore/multimedia/showimg/showimg.cpp +++ b/noncore/multimedia/showimg/showimg.cpp | |||
@@ -5,65 +5,67 @@ | |||
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | // | 21 | // |
22 | // Full-screen and rotation options contributed by Robert Wittams <robert@wittams.com> | 22 | // Full-screen and rotation options contributed by Robert Wittams <robert@wittams.com> |
23 | // | 23 | // |
24 | 24 | ||
25 | #include "showimg.h" | 25 | #include "showimg.h" |
26 | #include "ImageFileSelector.h" | 26 | #include "ImageFileSelector.h" |
27 | #include "settingsdialog.h" | 27 | #include "settingsdialog.h" |
28 | 28 | ||
29 | 29 | /* OPIE */ | |
30 | #include <opie2/odebug.h> | ||
30 | #include <opie2/ofiledialog.h> | 31 | #include <opie2/ofiledialog.h> |
31 | |||
32 | #include <qpe/qpeapplication.h> | 32 | #include <qpe/qpeapplication.h> |
33 | #include <qpe/config.h> | 33 | #include <qpe/config.h> |
34 | #include <qpe/resource.h> | 34 | #include <qpe/resource.h> |
35 | #include <qtoolbar.h> | 35 | using namespace Opie::Core; |
36 | using namespace Opie::Ui; | ||
36 | 37 | ||
38 | /* QT */ | ||
39 | #include <qtoolbar.h> | ||
37 | #include <qaction.h> | 40 | #include <qaction.h> |
38 | #include <qfiledialog.h> | 41 | #include <qfiledialog.h> |
39 | #include <qmenubar.h> | 42 | #include <qmenubar.h> |
40 | #include <qspinbox.h> | 43 | #include <qspinbox.h> |
41 | 44 | ||
45 | /* STD */ | ||
42 | #include <math.h> | 46 | #include <math.h> |
43 | 47 | ||
44 | |||
45 | using namespace Opie::Ui; | ||
46 | ControlsDialog::ControlsDialog(const QString &caption,QImage image,int *brightness,QWidget *parent) | 48 | ControlsDialog::ControlsDialog(const QString &caption,QImage image,int *brightness,QWidget *parent) |
47 | : QDialog(parent,0,true) | 49 | : QDialog(parent,0,true) |
48 | { | 50 | { |
49 | setCaption(caption); | 51 | setCaption(caption); |
50 | 52 | ||
51 | if ( parent ) { | 53 | if ( parent ) { |
52 | setPalette(parent->palette()); | 54 | setPalette(parent->palette()); |
53 | } | 55 | } |
54 | 56 | ||
55 | b=brightness; | 57 | b=brightness; |
56 | img=image; | 58 | img=image; |
57 | 59 | ||
58 | setMinimumSize(140,80); | 60 | setMinimumSize(140,80); |
59 | 61 | ||
60 | QGridLayout *gl= new QGridLayout(this,2,2,4,4); | 62 | QGridLayout *gl= new QGridLayout(this,2,2,4,4); |
61 | 63 | ||
62 | pixmap =new ImageWidget(this);; | 64 | pixmap =new ImageWidget(this);; |
63 | QPixmap pm; | 65 | QPixmap pm; |
64 | pm.convertFromImage(img); | 66 | pm.convertFromImage(img); |
65 | pixmap->setPixmap(pm); | 67 | pixmap->setPixmap(pm); |
66 | pixmap->setMinimumSize(pm.width(),pm.height()); | 68 | pixmap->setMinimumSize(pm.width(),pm.height()); |
67 | gl->addMultiCellWidget(pixmap,0,0,0,2,AlignCenter); | 69 | gl->addMultiCellWidget(pixmap,0,0,0,2,AlignCenter); |
68 | QLabel *l=new QLabel(tr("Brightness")+":",this); | 70 | QLabel *l=new QLabel(tr("Brightness")+":",this); |
69 | gl->addWidget(l,1,0,AlignLeft); | 71 | gl->addWidget(l,1,0,AlignLeft); |
@@ -265,49 +267,49 @@ ImageViewer::ImageViewer( QWidget *parent, const char *name, int /*wFlags*/ ) | |||
265 | fileMenuView->insertSeparator(); | 267 | fileMenuView->insertSeparator(); |
266 | 268 | ||
267 | viewMenuView = new QPopupMenu(this ); | 269 | viewMenuView = new QPopupMenu(this ); |
268 | viewMenuView->setCheckable ( true ); | 270 | viewMenuView->setCheckable ( true ); |
269 | 271 | ||
270 | //menubarView->insertItem( tr("View"),viewMenu ); | 272 | //menubarView->insertItem( tr("View"),viewMenu ); |
271 | viewMenuView->insertItem(tr("Horizontal flip"), this, SLOT(hFlip()), 0); | 273 | viewMenuView->insertItem(tr("Horizontal flip"), this, SLOT(hFlip()), 0); |
272 | viewMenuView->insertItem(tr("Vertical flip"), this, SLOT(vFlip()), 0); | 274 | viewMenuView->insertItem(tr("Vertical flip"), this, SLOT(vFlip()), 0); |
273 | 275 | ||
274 | stack = new QWidgetStack( this ); | 276 | stack = new QWidgetStack( this ); |
275 | stack->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); | 277 | stack->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); |
276 | setCentralWidget( stack ); | 278 | setCentralWidget( stack ); |
277 | 279 | ||
278 | 280 | ||
279 | imagePanel = new ImagePane( stack ); | 281 | imagePanel = new ImagePane( stack ); |
280 | connect(imagePanel, SIGNAL(clicked()), this, SLOT(normalView())); | 282 | connect(imagePanel, SIGNAL(clicked()), this, SLOT(normalView())); |
281 | 283 | ||
282 | 284 | ||
283 | ImageFileSelector::CURRENT_VIEW cv; | 285 | ImageFileSelector::CURRENT_VIEW cv; |
284 | if(showThumbView) | 286 | if(showThumbView) |
285 | cv=ImageFileSelector::THUMBNAIL; | 287 | cv=ImageFileSelector::THUMBNAIL; |
286 | else | 288 | else |
287 | cv=ImageFileSelector::DETAILED; | 289 | cv=ImageFileSelector::DETAILED; |
288 | 290 | ||
289 | qDebug("cv = %d",cv); | 291 | odebug << "cv = " << cv << "" << oendl; |
290 | 292 | ||
291 | fileSelector = new ImageFileSelector( cv,stack, "fs"); | 293 | fileSelector = new ImageFileSelector( cv,stack, "fs"); |
292 | 294 | ||
293 | //switchThumbView(); | 295 | //switchThumbView(); |
294 | 296 | ||
295 | 297 | ||
296 | //fileSelector = new ImageFileSelector("image/*", stack, "fs"); | 298 | //fileSelector = new ImageFileSelector("image/*", stack, "fs"); |
297 | //fileSelector->setNewVisible(FALSE); | 299 | //fileSelector->setNewVisible(FALSE); |
298 | //fileSelector->setCloseVisible(FALSE); | 300 | //fileSelector->setCloseVisible(FALSE); |
299 | connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( closeFileSelector() ) ); | 301 | connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( closeFileSelector() ) ); |
300 | connect( fileSelector, SIGNAL( fileSelected(const DocLnk&) ), | 302 | connect( fileSelector, SIGNAL( fileSelected(const DocLnk&) ), |
301 | this, SLOT( openFile(const DocLnk&) ) ); | 303 | this, SLOT( openFile(const DocLnk&) ) ); |
302 | 304 | ||
303 | imageList = fileSelector->fileList(); | 305 | imageList = fileSelector->fileList(); |
304 | slideAction->setEnabled( imageList.count() != 0); | 306 | slideAction->setEnabled( imageList.count() != 0); |
305 | 307 | ||
306 | iconToolBar = new QToolBar(this); | 308 | iconToolBar = new QToolBar(this); |
307 | 309 | ||
308 | QAction *a; | 310 | QAction *a; |
309 | 311 | ||
310 | a = new QAction( tr( "Open ..." ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 ); | 312 | a = new QAction( tr( "Open ..." ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 ); |
311 | connect( a, SIGNAL( activated() ), this, SLOT( open() ) ); | 313 | connect( a, SIGNAL( activated() ), this, SLOT( open() ) ); |
312 | a->addTo( fileMenuView); | 314 | a->addTo( fileMenuView); |
313 | a->addTo( iconToolBar ); | 315 | a->addTo( iconToolBar ); |
@@ -392,49 +394,49 @@ ImageViewer::~ImageViewer() | |||
392 | cfg.writeEntry("Reverse", slideReverse); | 394 | cfg.writeEntry("Reverse", slideReverse); |
393 | 395 | ||
394 | cfg.setGroup("Default"); | 396 | cfg.setGroup("Default"); |
395 | cfg.writeEntry("Rotate", rotateOnLoad); | 397 | cfg.writeEntry("Rotate", rotateOnLoad); |
396 | cfg.writeEntry("FastLoad", fastLoad); | 398 | cfg.writeEntry("FastLoad", fastLoad); |
397 | 399 | ||
398 | delete imagePanel; // in case it is fullscreen | 400 | delete imagePanel; // in case it is fullscreen |
399 | } | 401 | } |
400 | 402 | ||
401 | void ImageViewer::help() { | 403 | void ImageViewer::help() { |
402 | 404 | ||
403 | } | 405 | } |
404 | 406 | ||
405 | 407 | ||
406 | void ImageViewer::settings() | 408 | void ImageViewer::settings() |
407 | { | 409 | { |
408 | SettingsDialog dlg( this, 0, TRUE ); | 410 | SettingsDialog dlg( this, 0, TRUE ); |
409 | dlg.setDelay( slideDelay ); | 411 | dlg.setDelay( slideDelay ); |
410 | dlg.setRepeat( slideRepeat ); | 412 | dlg.setRepeat( slideRepeat ); |
411 | dlg.setReverse( slideReverse ); | 413 | dlg.setReverse( slideReverse ); |
412 | dlg.setRotate(rotateOnLoad); | 414 | dlg.setRotate(rotateOnLoad); |
413 | dlg.setFastLoad(fastLoad); | 415 | dlg.setFastLoad(fastLoad); |
414 | 416 | ||
415 | if ( QPEApplication::execDialog(&dlg) == QDialog::Accepted ) { | 417 | if ( QPEApplication::execDialog(&dlg) == QDialog::Accepted ) { |
416 | qDebug("<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>"); | 418 | odebug << "<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>" << oendl; |
417 | slideDelay = dlg.delay(); | 419 | slideDelay = dlg.delay(); |
418 | slideRepeat = dlg.repeat(); | 420 | slideRepeat = dlg.repeat(); |
419 | slideReverse = dlg.reverse(); | 421 | slideReverse = dlg.reverse(); |
420 | rotateOnLoad = dlg.rotate(); | 422 | rotateOnLoad = dlg.rotate(); |
421 | fastLoad = dlg.fastLoad(); | 423 | fastLoad = dlg.fastLoad(); |
422 | 424 | ||
423 | Config config( "ImageViewer" ); | 425 | Config config( "ImageViewer" ); |
424 | config.setGroup( "SlideShow" ); | 426 | config.setGroup( "SlideShow" ); |
425 | config.writeEntry( "Delay", slideDelay ); | 427 | config.writeEntry( "Delay", slideDelay ); |
426 | config.writeEntry( "Repeat", slideRepeat ); | 428 | config.writeEntry( "Repeat", slideRepeat ); |
427 | config.writeEntry("Reverse", slideReverse); | 429 | config.writeEntry("Reverse", slideReverse); |
428 | 430 | ||
429 | config.setGroup("Default"); | 431 | config.setGroup("Default"); |
430 | config.writeEntry("Rotate", rotateOnLoad); | 432 | config.writeEntry("Rotate", rotateOnLoad); |
431 | config.writeEntry("FastLoad", fastLoad); | 433 | config.writeEntry("FastLoad", fastLoad); |
432 | } | 434 | } |
433 | } | 435 | } |
434 | 436 | ||
435 | void ImageViewer::switchSizeToScreen() | 437 | void ImageViewer::switchSizeToScreen() |
436 | { | 438 | { |
437 | isSized=!isSized; | 439 | isSized=!isSized; |
438 | sss->setOn(isSized); | 440 | sss->setOn(isSized); |
439 | updateImage(); | 441 | updateImage(); |
440 | } | 442 | } |
@@ -484,79 +486,79 @@ void ImageViewer::switchToImageView() | |||
484 | 486 | ||
485 | } | 487 | } |
486 | 488 | ||
487 | 489 | ||
488 | void ImageViewer::setDocument(const QString& fileref) | 490 | void ImageViewer::setDocument(const QString& fileref) |
489 | { | 491 | { |
490 | delayLoad = fileref; | 492 | delayLoad = fileref; |
491 | switchToImageView(); | 493 | switchToImageView(); |
492 | QTimer::singleShot( 0, this, SLOT(doDelayedLoad()) ); | 494 | QTimer::singleShot( 0, this, SLOT(doDelayedLoad()) ); |
493 | } | 495 | } |
494 | 496 | ||
495 | void ImageViewer::doDelayedLoad() | 497 | void ImageViewer::doDelayedLoad() |
496 | { | 498 | { |
497 | show(delayLoad); | 499 | show(delayLoad); |
498 | } | 500 | } |
499 | 501 | ||
500 | void ImageViewer::show() | 502 | void ImageViewer::show() |
501 | { | 503 | { |
502 | normalView(); | 504 | normalView(); |
503 | QMainWindow::show(); | 505 | QMainWindow::show(); |
504 | } | 506 | } |
505 | 507 | ||
506 | void ImageViewer::show(const QString& fileref) | 508 | void ImageViewer::show(const QString& fileref) |
507 | { | 509 | { |
508 | // qDebug("Show "+fileref); | 510 | // odebug << "Show "+fileref << oendl; |
509 | bFromDocView = TRUE; | 511 | bFromDocView = TRUE; |
510 | closeFileSelector(); | 512 | closeFileSelector(); |
511 | DocLnk link(fileref); | 513 | DocLnk link(fileref); |
512 | if ( link.isValid() ) { | 514 | if ( link.isValid() ) { |
513 | openFile(link); | 515 | openFile(link); |
514 | } else { | 516 | } else { |
515 | filename = fileref; | 517 | filename = fileref; |
516 | updateCaption( fileref ); | 518 | updateCaption( fileref ); |
517 | loadImage( fileref ); | 519 | loadImage( fileref ); |
518 | } | 520 | } |
519 | } | 521 | } |
520 | 522 | ||
521 | void ImageViewer::openFile() { | 523 | void ImageViewer::openFile() { |
522 | MimeTypes types; | 524 | MimeTypes types; |
523 | QStringList image; | 525 | QStringList image; |
524 | image << "image/*"; | 526 | image << "image/*"; |
525 | types.insert("Images", image); | 527 | types.insert("Images", image); |
526 | 528 | ||
527 | QString str = OFileDialog::getOpenFileName( 1,QPEApplication::documentDir(),"", types, 0 ); | 529 | QString str = OFileDialog::getOpenFileName( 1,QPEApplication::documentDir(),"", types, 0 ); |
528 | DocLnk link(str); | 530 | DocLnk link(str); |
529 | // if ( link.isValid() ) | 531 | // if ( link.isValid() ) |
530 | openFile(link); | 532 | openFile(link); |
531 | 533 | ||
532 | } | 534 | } |
533 | 535 | ||
534 | void ImageViewer::openFile( const DocLnk &link ) | 536 | void ImageViewer::openFile( const DocLnk &link ) |
535 | { | 537 | { |
536 | closeFileSelector(); | 538 | closeFileSelector(); |
537 | // DocLnk link(file); | 539 | // DocLnk link(file); |
538 | qDebug("open "+link.name()); | 540 | odebug << "open "+link.name() << oendl; |
539 | updateCaption( link.name() ); | 541 | updateCaption( link.name() ); |
540 | loadImage( link.file() ); | 542 | loadImage( link.file() ); |
541 | if (slideTimer->isActive()) { | 543 | if (slideTimer->isActive()) { |
542 | slideTimer->start(slideDelay * 1000, FALSE); | 544 | slideTimer->start(slideDelay * 1000, FALSE); |
543 | } | 545 | } |
544 | 546 | ||
545 | } | 547 | } |
546 | 548 | ||
547 | void ImageViewer::open() | 549 | void ImageViewer::open() |
548 | { | 550 | { |
549 | switchToFileSelector(); | 551 | switchToFileSelector(); |
550 | } | 552 | } |
551 | 553 | ||
552 | void ImageViewer::closeFileSelector() | 554 | void ImageViewer::closeFileSelector() |
553 | { | 555 | { |
554 | switchToImageView(); | 556 | switchToImageView(); |
555 | } | 557 | } |
556 | 558 | ||
557 | void ImageViewer::updateCaption( QString name ) | 559 | void ImageViewer::updateCaption( QString name ) |
558 | { | 560 | { |
559 | int sep = name.findRev( '/' ); | 561 | int sep = name.findRev( '/' ); |
560 | if ( sep >= 0 ) | 562 | if ( sep >= 0 ) |
561 | name = name.mid( sep+1 ); | 563 | name = name.mid( sep+1 ); |
562 | setCaption( name + tr(" - Image Viewer") ); | 564 | setCaption( name + tr(" - Image Viewer") ); |