Diffstat (limited to 'noncore/graphics/opie-eye/gui/mainwindow.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/graphics/opie-eye/gui/mainwindow.cpp | 47 |
1 files changed, 35 insertions, 12 deletions
diff --git a/noncore/graphics/opie-eye/gui/mainwindow.cpp b/noncore/graphics/opie-eye/gui/mainwindow.cpp index f443ccb..295f93f 100644 --- a/noncore/graphics/opie-eye/gui/mainwindow.cpp +++ b/noncore/graphics/opie-eye/gui/mainwindow.cpp | |||
@@ -25,48 +25,50 @@ | |||
25 | #include <qpe/ir.h> | 25 | #include <qpe/ir.h> |
26 | #include <qpe/storage.h> | 26 | #include <qpe/storage.h> |
27 | #include <qpe/applnk.h> | 27 | #include <qpe/applnk.h> |
28 | 28 | ||
29 | #include <qtoolbar.h> | 29 | #include <qtoolbar.h> |
30 | #include <qtoolbutton.h> | 30 | #include <qtoolbutton.h> |
31 | #include <qlayout.h> | 31 | #include <qlayout.h> |
32 | #include <qdialog.h> | 32 | #include <qdialog.h> |
33 | #include <qmap.h> | 33 | #include <qmap.h> |
34 | #include <qtimer.h> | 34 | #include <qtimer.h> |
35 | #include <qframe.h> | 35 | #include <qframe.h> |
36 | #include <qmenubar.h> | 36 | #include <qmenubar.h> |
37 | #include <qaction.h> | 37 | #include <qaction.h> |
38 | 38 | ||
39 | //OPIE_EXPORT_APP_V2( Opie::Core::OApplicationFactory<PMainWindow>,"Opie Eye" ) | 39 | //OPIE_EXPORT_APP_V2( Opie::Core::OApplicationFactory<PMainWindow>,"Opie Eye" ) |
40 | OPIE_EXPORT_APP( Opie::Core::OApplicationFactory<PMainWindow>) | 40 | OPIE_EXPORT_APP( Opie::Core::OApplicationFactory<PMainWindow>) |
41 | 41 | ||
42 | PMainWindow::PMainWindow(QWidget* wid, const char* name, WFlags style) | 42 | PMainWindow::PMainWindow(QWidget* wid, const char* name, WFlags style) |
43 | : QMainWindow( wid, name, style ), m_info( 0 ), m_disp( 0 ) | 43 | : QMainWindow( wid, name, style ), m_info( 0 ), m_disp( 0 ) |
44 | { | 44 | { |
45 | setCaption( QObject::tr("Opie Eye Caramba" ) ); | 45 | setCaption( QObject::tr("Opie Eye Caramba" ) ); |
46 | m_cfg = new Opie::Core::OConfig("opie-eye"); | 46 | m_cfg = new Opie::Core::OConfig("opie-eye"); |
47 | m_cfg->setGroup("main" ); | 47 | m_cfg->setGroup("main" ); |
48 | readConfig(); | 48 | readConfig(); |
49 | m_setDocCalled = false; | ||
50 | m_polishDone = false; | ||
49 | 51 | ||
50 | m_storage = new StorageInfo(); | 52 | m_storage = new StorageInfo(); |
51 | connect(m_storage, SIGNAL(disksChanged() ), | 53 | connect(m_storage, SIGNAL(disksChanged() ), |
52 | this, SLOT( dirChanged() ) ); | 54 | this, SLOT( dirChanged() ) ); |
53 | 55 | ||
54 | m_stack = new Opie::Ui::OWidgetStack( this ); | 56 | m_stack = new Opie::Ui::OWidgetStack( this ); |
55 | setCentralWidget( m_stack ); | 57 | setCentralWidget( m_stack ); |
56 | 58 | ||
57 | m_view = new PIconView( m_stack, m_cfg ); | 59 | m_view = new PIconView( m_stack, m_cfg ); |
58 | m_stack->addWidget( m_view, IconView ); | 60 | m_stack->addWidget( m_view, IconView ); |
59 | m_stack->raiseWidget( IconView ); | 61 | m_stack->raiseWidget( IconView ); |
60 | 62 | ||
61 | connect(m_view, SIGNAL(sig_display(const QString&)), | 63 | connect(m_view, SIGNAL(sig_display(const QString&)), |
62 | this, SLOT(slotDisplay(const QString&))); | 64 | this, SLOT(slotDisplay(const QString&))); |
63 | connect(m_view, SIGNAL(sig_showInfo(const QString&)), | 65 | connect(m_view, SIGNAL(sig_showInfo(const QString&)), |
64 | this, SLOT(slotShowInfo(const QString&)) ); | 66 | this, SLOT(slotShowInfo(const QString&)) ); |
65 | connect(this,SIGNAL(changeListMode(int)),m_view,SLOT(slotChangeMode(int))); | 67 | connect(this,SIGNAL(changeListMode(int)),m_view,SLOT(slotChangeMode(int))); |
66 | 68 | ||
67 | m_stack->forceMode(Opie::Ui::OWidgetStack::NoForce); | 69 | m_stack->forceMode(Opie::Ui::OWidgetStack::NoForce); |
68 | 70 | ||
69 | listviewMenu = 0; | 71 | listviewMenu = 0; |
70 | /* setup menu and toolbar */ | 72 | /* setup menu and toolbar */ |
71 | setupActions(); | 73 | setupActions(); |
72 | setupToolbar(); | 74 | setupToolbar(); |
@@ -398,75 +400,77 @@ void PMainWindow::raiseIconView() { | |||
398 | m_aShowInfo->setEnabled(true); | 400 | m_aShowInfo->setEnabled(true); |
399 | m_aViewfile->setEnabled(true); | 401 | m_aViewfile->setEnabled(true); |
400 | m_aStartSlide->setEnabled(true); | 402 | m_aStartSlide->setEnabled(true); |
401 | fsButton->show(); | 403 | fsButton->show(); |
402 | } | 404 | } |
403 | if (m_disp && m_disp->fullScreen() && m_disp->isVisible()) { | 405 | if (m_disp && m_disp->fullScreen() && m_disp->isVisible()) { |
404 | m_disp->stopSlide(); | 406 | m_disp->stopSlide(); |
405 | m_disp->hide(); | 407 | m_disp->hide(); |
406 | } | 408 | } |
407 | m_stack->raiseWidget( IconView ); | 409 | m_stack->raiseWidget( IconView ); |
408 | setUpdatesEnabled(true); | 410 | setUpdatesEnabled(true); |
409 | repaint(); | 411 | repaint(); |
410 | } | 412 | } |
411 | 413 | ||
412 | void PMainWindow::slotReturn() { | 414 | void PMainWindow::slotReturn() { |
413 | raiseIconView(); | 415 | raiseIconView(); |
414 | } | 416 | } |
415 | 417 | ||
416 | 418 | ||
417 | void PMainWindow::closeEvent( QCloseEvent* ev ) { | 419 | void PMainWindow::closeEvent( QCloseEvent* ev ) { |
418 | /* | 420 | /* |
419 | * return from view | 421 | * return from view |
420 | * or properly quit | 422 | * or properly quit |
421 | */ | 423 | */ |
422 | if ( m_stack->visibleWidget() == m_info || | 424 | if (!m_setDocCalled) { |
423 | m_stack->visibleWidget() == m_disp ) { | 425 | if ( m_stack->visibleWidget() == m_info || |
424 | ev->ignore(); | 426 | m_stack->visibleWidget() == m_disp ) { |
425 | raiseIconView(); | 427 | ev->ignore(); |
426 | return; | 428 | raiseIconView(); |
429 | return; | ||
430 | } | ||
427 | } | 431 | } |
428 | if (m_disp && m_disp->fullScreen()) { | 432 | if (m_disp && m_disp->fullScreen()) { |
429 | /* otherwise opie-eye crashes in bigscreen mode! */ | 433 | /* otherwise opie-eye crashes in bigscreen mode! */ |
430 | m_disp->reparent(0,QPoint(0,0)); | 434 | m_disp->reparent(0,QPoint(0,0)); |
431 | m_stack->addWidget(m_disp,ImageDisplay); | 435 | m_stack->addWidget(m_disp,ImageDisplay); |
432 | } | 436 | } |
433 | ev->accept(); | 437 | ev->accept(); |
434 | QTimer::singleShot(0, qApp, SLOT(closeAllWindows())); | 438 | QTimer::singleShot(0, qApp, SLOT(closeAllWindows())); |
435 | } | 439 | } |
436 | 440 | ||
437 | void PMainWindow::setDocument( const QString& showImg ) | 441 | void PMainWindow::setDocument( const QString& showImg ) |
438 | { | 442 | { |
439 | bool first_start = m_disp==0; | ||
440 | |||
441 | QString file = showImg; | 443 | QString file = showImg; |
442 | DocLnk lnk(showImg); | 444 | DocLnk lnk(showImg); |
443 | if (lnk.isValid() ) | 445 | if (lnk.isValid() ) |
444 | file = lnk.file(); | 446 | file = lnk.file(); |
445 | slotDisplay( file ); | 447 | slotDisplay( file ); |
446 | if (first_start && m_aFullScreen->isOn()) { | 448 | #if 0 |
449 | if (!m_polishDone) { | ||
447 | QTimer::singleShot(0,this,SLOT(check_view_fullscreen())); | 450 | QTimer::singleShot(0,this,SLOT(check_view_fullscreen())); |
448 | } | 451 | } |
452 | #endif | ||
449 | } | 453 | } |
450 | 454 | ||
451 | void PMainWindow::check_view_fullscreen() | 455 | void PMainWindow::check_view_fullscreen() |
452 | { | 456 | { |
453 | if (!m_view) return; | 457 | if (!m_view) return; |
454 | if (!m_view->hasFocus()&&m_aFullScreen->isOn()) { | 458 | if (!m_view->hasFocus()&&m_aFullScreen->isOn()) { |
455 | qwsDisplay()->requestFocus( m_disp->winId(), TRUE); | 459 | qwsDisplay()->requestFocus( m_disp->winId(), TRUE); |
456 | } | 460 | } |
457 | } | 461 | } |
458 | 462 | ||
459 | void PMainWindow::slotSelectDir(int id) | 463 | void PMainWindow::slotSelectDir(int id) |
460 | { | 464 | { |
461 | emit changeDir( m_dev[fsMenu->text(id )] ); | 465 | emit changeDir( m_dev[fsMenu->text(id )] ); |
462 | } | 466 | } |
463 | 467 | ||
464 | void PMainWindow::dirChanged() | 468 | void PMainWindow::dirChanged() |
465 | { | 469 | { |
466 | fsMenu->clear(); | 470 | fsMenu->clear(); |
467 | m_dev.clear(); | 471 | m_dev.clear(); |
468 | 472 | ||
469 | /* home dir, too */ | 473 | /* home dir, too */ |
470 | QString f = getenv( "HOME" ); | 474 | QString f = getenv( "HOME" ); |
471 | if (!f.isEmpty()) { | 475 | if (!f.isEmpty()) { |
472 | m_dev.insert("Home directory",f); | 476 | m_dev.insert("Home directory",f); |
@@ -668,43 +672,62 @@ void PMainWindow::setupMenu() | |||
668 | if ( m_aBeam ) { | 672 | if ( m_aBeam ) { |
669 | fileMenu->insertSeparator(); | 673 | fileMenu->insertSeparator(); |
670 | m_aBeam->addTo( fileMenu ); | 674 | m_aBeam->addTo( fileMenu ); |
671 | } | 675 | } |
672 | fileMenu->insertSeparator(); | 676 | fileMenu->insertSeparator(); |
673 | m_aTrash->addTo(fileMenu); | 677 | m_aTrash->addTo(fileMenu); |
674 | 678 | ||
675 | listviewMenu = new QPopupMenu(dispMenu); | 679 | listviewMenu = new QPopupMenu(dispMenu); |
676 | dispMenu->insertItem(Resource::loadIconSet("opie-eye/opie-eye-thumb"),tr("Listview mode"),listviewMenu); | 680 | dispMenu->insertItem(Resource::loadIconSet("opie-eye/opie-eye-thumb"),tr("Listview mode"),listviewMenu); |
677 | m_gListViewMode->addTo(listviewMenu); | 681 | m_gListViewMode->addTo(listviewMenu); |
678 | dispMenu->insertSeparator(); | 682 | dispMenu->insertSeparator(); |
679 | m_aFullScreen->addTo(dispMenu); | 683 | m_aFullScreen->addTo(dispMenu); |
680 | m_gDisplayType->addTo(dispMenu); | 684 | m_gDisplayType->addTo(dispMenu); |
681 | dispMenu->insertSeparator(); | 685 | dispMenu->insertSeparator(); |
682 | m_gPrevNext->addTo(dispMenu); | 686 | m_gPrevNext->addTo(dispMenu); |
683 | 687 | ||
684 | m_aSetup->addTo(settingsMenu); | 688 | m_aSetup->addTo(settingsMenu); |
685 | m_aHideToolbar->addTo(settingsMenu); | 689 | m_aHideToolbar->addTo(settingsMenu); |
686 | } | 690 | } |
687 | 691 | ||
688 | void PMainWindow::listviewselected(QAction*which) | 692 | void PMainWindow::listviewselected(QAction*which) |
689 | { | 693 | { |
690 | if (!which || which->isOn()==false) return; | 694 | if (!which || which->isOn()==false) return; |
691 | int val = 1; | 695 | int val = 1; |
692 | // QString name; | ||
693 | 696 | ||
694 | if (which==m_aDirName) { | 697 | if (which==m_aDirName) { |
695 | val = 3; | 698 | val = 3; |
696 | // name = "opie-eye/opie-eye-textview"; | ||
697 | } else if (which==m_aDirShort) { | 699 | } else if (which==m_aDirShort) { |
698 | val = 2; | 700 | val = 2; |
699 | // name = "opie-eye/opie-eye-thumbonly"; | ||
700 | } else if (which==m_aDirLong) { | 701 | } else if (which==m_aDirLong) { |
701 | val = 1; | 702 | val = 1; |
702 | // name = "opie-eye/opie-eye-thumb"; | ||
703 | } | 703 | } |
704 | emit changeListMode(val); | 704 | emit changeListMode(val); |
705 | } | 705 | } |
706 | 706 | ||
707 | void PMainWindow::readConfig() | 707 | void PMainWindow::readConfig() |
708 | { | 708 | { |
709 | autoSave =m_cfg->readBoolEntry("savestatus",true); | 709 | autoSave =m_cfg->readBoolEntry("savestatus",true); |
710 | } | 710 | } |
711 | |||
712 | void PMainWindow::polish() | ||
713 | { | ||
714 | if (m_disp) { | ||
715 | odebug << "======================\n" | ||
716 | << "Called via setdocument\n" | ||
717 | << "======================" << oendl; | ||
718 | m_setDocCalled = true; | ||
719 | m_view->setDoccalled(true); | ||
720 | m_disp->setCloseIfHide(true); | ||
721 | } else { | ||
722 | m_setDocCalled = false; | ||
723 | m_view->setDoccalled(false); | ||
724 | } | ||
725 | m_polishDone = true; | ||
726 | QMainWindow::polish(); | ||
727 | if (m_setDocCalled) { | ||
728 | if (m_aFullScreen->isOn()) { | ||
729 | QTimer::singleShot(0,this,SLOT(check_view_fullscreen())); | ||
730 | } else if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) { | ||
731 | } | ||
732 | } | ||
733 | } | ||