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 | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/noncore/graphics/opie-eye/gui/mainwindow.cpp b/noncore/graphics/opie-eye/gui/mainwindow.cpp index e532867..3a89dfd 100644 --- a/noncore/graphics/opie-eye/gui/mainwindow.cpp +++ b/noncore/graphics/opie-eye/gui/mainwindow.cpp | |||
@@ -10,40 +10,43 @@ | |||
10 | #include "imageinfoui.h" | 10 | #include "imageinfoui.h" |
11 | #include "viewmodebutton.h" | 11 | #include "viewmodebutton.h" |
12 | #include "basesetup.h" | 12 | #include "basesetup.h" |
13 | 13 | ||
14 | #include <iface/ifaceinfo.h> | 14 | #include <iface/ifaceinfo.h> |
15 | #include <iface/dirview.h> | 15 | #include <iface/dirview.h> |
16 | 16 | ||
17 | #include <opie2/odebug.h> | 17 | #include <opie2/odebug.h> |
18 | #include <opie2/owidgetstack.h> | 18 | #include <opie2/owidgetstack.h> |
19 | #include <opie2/oapplicationfactory.h> | 19 | #include <opie2/oapplicationfactory.h> |
20 | #include <opie2/otabwidget.h> | 20 | #include <opie2/otabwidget.h> |
21 | #include <opie2/okeyconfigwidget.h> | 21 | #include <opie2/okeyconfigwidget.h> |
22 | #include <opie2/owait.h> | ||
23 | #include <opie2/oapplication.h> | ||
22 | 24 | ||
23 | #include <qpe/resource.h> | 25 | #include <qpe/resource.h> |
24 | #include <qpe/config.h> | 26 | #include <qpe/config.h> |
25 | #include <qpe/ir.h> | 27 | #include <qpe/ir.h> |
26 | #include <qpe/storage.h> | 28 | #include <qpe/storage.h> |
27 | #include <qpe/applnk.h> | 29 | #include <qpe/applnk.h> |
28 | 30 | ||
29 | #include <qtoolbar.h> | 31 | #include <qtoolbar.h> |
30 | #include <qtoolbutton.h> | 32 | #include <qtoolbutton.h> |
31 | #include <qlayout.h> | 33 | #include <qlayout.h> |
32 | #include <qdialog.h> | 34 | #include <qdialog.h> |
33 | #include <qmap.h> | 35 | #include <qmap.h> |
34 | #include <qtimer.h> | 36 | #include <qtimer.h> |
35 | #include <qframe.h> | 37 | #include <qframe.h> |
36 | #include <qmenubar.h> | 38 | #include <qmenubar.h> |
37 | #include <qaction.h> | 39 | #include <qaction.h> |
40 | #include <qspinbox.h> | ||
38 | 41 | ||
39 | //OPIE_EXPORT_APP_V2( Opie::Core::OApplicationFactory<PMainWindow>,"Opie Eye" ) | 42 | //OPIE_EXPORT_APP_V2( Opie::Core::OApplicationFactory<PMainWindow>,"Opie Eye" ) |
40 | OPIE_EXPORT_APP( Opie::Core::OApplicationFactory<PMainWindow>) | 43 | OPIE_EXPORT_APP( Opie::Core::OApplicationFactory<PMainWindow>) |
41 | 44 | ||
42 | PMainWindow::PMainWindow(QWidget* wid, const char* name, WFlags style) | 45 | PMainWindow::PMainWindow(QWidget* wid, const char* name, WFlags style) |
43 | : QMainWindow( wid, name, style ), m_info( 0 ), m_disp( 0 ) | 46 | : QMainWindow( wid, name, style ), m_info( 0 ), m_disp( 0 ) |
44 | { | 47 | { |
45 | setCaption( QObject::tr("Opie Eye" ) ); | 48 | setCaption( QObject::tr("Opie Eye" ) ); |
46 | m_cfg = new Opie::Core::OConfig("opie-eye"); | 49 | m_cfg = new Opie::Core::OConfig("opie-eye"); |
47 | m_cfg->setGroup("main" ); | 50 | m_cfg->setGroup("main" ); |
48 | readConfig(); | 51 | readConfig(); |
49 | m_setDocCalled = false; | 52 | m_setDocCalled = false; |
@@ -217,24 +220,27 @@ void PMainWindow::slotConfig() { | |||
217 | m_view->resetView(); | 220 | m_view->resetView(); |
218 | readConfig(); | 221 | readConfig(); |
219 | } | 222 | } |
220 | delete keyWid; | 223 | delete keyWid; |
221 | 224 | ||
222 | m_stack->raiseWidget(w); | 225 | m_stack->raiseWidget(w); |
223 | if (remdisp) { | 226 | if (remdisp) { |
224 | m_disp->hide(); | 227 | m_disp->hide(); |
225 | } | 228 | } |
226 | if (reminfo) { | 229 | if (reminfo) { |
227 | m_info->hide(); | 230 | m_info->hide(); |
228 | } | 231 | } |
232 | if (m_disp) { | ||
233 | m_disp->setIntensity(m_Intensity,true); | ||
234 | } | ||
229 | } | 235 | } |
230 | 236 | ||
231 | /* | 237 | /* |
232 | * create a new image info component | 238 | * create a new image info component |
233 | * and detach the current one | 239 | * and detach the current one |
234 | * we will make the other delete on exit | 240 | * we will make the other delete on exit |
235 | */ | 241 | */ |
236 | template<class T> | 242 | template<class T> |
237 | void PMainWindow::initT( const char* name, T** ptr, int id) { | 243 | void PMainWindow::initT( const char* name, T** ptr, int id) { |
238 | if ( *ptr ) { | 244 | if ( *ptr ) { |
239 | (*ptr)->disconnect(this, SLOT(slotReturn())); | 245 | (*ptr)->disconnect(this, SLOT(slotReturn())); |
240 | (*ptr)->setDestructiveClose(); | 246 | (*ptr)->setDestructiveClose(); |
@@ -360,29 +366,47 @@ void PMainWindow::slotShowInfo( const QString& inf ) { | |||
360 | } | 366 | } |
361 | m_aNext->setEnabled(false); | 367 | m_aNext->setEnabled(false); |
362 | m_aPrevious->setEnabled(false); | 368 | m_aPrevious->setEnabled(false); |
363 | m_aDirUp->setEnabled(false); | 369 | m_aDirUp->setEnabled(false); |
364 | m_aShowInfo->setEnabled(false); | 370 | m_aShowInfo->setEnabled(false); |
365 | m_aViewfile->setEnabled(true); | 371 | m_aViewfile->setEnabled(true); |
366 | m_aStartSlide->setEnabled(false); | 372 | m_aStartSlide->setEnabled(false); |
367 | m_stack->raiseWidget( ImageInfo ); | 373 | m_stack->raiseWidget( ImageInfo ); |
368 | } | 374 | } |
369 | 375 | ||
370 | void PMainWindow::slotDisplay( const QString& inf ) { | 376 | void PMainWindow::slotDisplay( const QString& inf ) { |
371 | bool nwindow = false; | 377 | bool nwindow = false; |
378 | bool disp_hack = false; | ||
379 | int lb; | ||
380 | if (m_disp && m_disp->fullScreen()) { | ||
381 | lb = m_disp->Intensity(); | ||
382 | delete m_disp; | ||
383 | m_disp = 0; | ||
384 | |||
385 | disp_hack = true; | ||
386 | } | ||
372 | if ( !m_disp ) { | 387 | if ( !m_disp ) { |
373 | nwindow = true; | 388 | nwindow = true; |
374 | initDisp(); | 389 | initDisp(); |
390 | m_disp->setIntensity((disp_hack?lb:m_Intensity)); | ||
375 | } | 391 | } |
392 | m_setCurrentBrightness->setEnabled(true); | ||
393 | |||
394 | Opie::Ui::OWait wdlg; | ||
395 | wdlg.setTimerLength(30); | ||
396 | wdlg.show(); | ||
397 | //qApp->processEvents(20); | ||
376 | m_disp->setImage( inf ); | 398 | m_disp->setImage( inf ); |
399 | wdlg.hide(); | ||
400 | //qApp->processEvents(20); | ||
377 | if (m_SmallWindow) { | 401 | if (m_SmallWindow) { |
378 | if (m_gPrevNext->isEnabled()==false) { | 402 | if (m_gPrevNext->isEnabled()==false) { |
379 | m_gPrevNext->addTo(toolBar); | 403 | m_gPrevNext->addTo(toolBar); |
380 | fsButton->hide(); | 404 | fsButton->hide(); |
381 | } | 405 | } |
382 | } | 406 | } |
383 | m_gPrevNext->setEnabled(true); | 407 | m_gPrevNext->setEnabled(true); |
384 | m_aDirUp->setEnabled(false); | 408 | m_aDirUp->setEnabled(false); |
385 | m_aShowInfo->setEnabled(true); | 409 | m_aShowInfo->setEnabled(true); |
386 | m_aViewfile->setEnabled(false); | 410 | m_aViewfile->setEnabled(false); |
387 | m_aStartSlide->setEnabled(false); | 411 | m_aStartSlide->setEnabled(false); |
388 | 412 | ||
@@ -621,24 +645,37 @@ void PMainWindow::setupActions() | |||
621 | m_gDisplayType->insert(m_aZoomer); | 645 | m_gDisplayType->insert(m_aZoomer); |
622 | 646 | ||
623 | m_hGroup = new QActionGroup(this,"actioncollection",false); | 647 | m_hGroup = new QActionGroup(this,"actioncollection",false); |
624 | m_hGroup->insert(m_aFullScreen); | 648 | m_hGroup->insert(m_aFullScreen); |
625 | 649 | ||
626 | if (!m_SmallWindow) { | 650 | if (!m_SmallWindow) { |
627 | m_aForceSmall = new QAction(tr("Dont show seperate windows"),Resource::loadIconSet( "AppsIcon" ), 0, 0, this, 0, true); | 651 | m_aForceSmall = new QAction(tr("Dont show seperate windows"),Resource::loadIconSet( "AppsIcon" ), 0, 0, this, 0, true); |
628 | m_aForceSmall->setToggleAction(true); | 652 | m_aForceSmall->setToggleAction(true); |
629 | connect(m_aForceSmall,SIGNAL(toggled(bool)),this,SLOT(slotForceSmall(bool))); | 653 | connect(m_aForceSmall,SIGNAL(toggled(bool)),this,SLOT(slotForceSmall(bool))); |
630 | } else { | 654 | } else { |
631 | m_aForceSmall = 0; | 655 | m_aForceSmall = 0; |
632 | } | 656 | } |
657 | m_setCurrentBrightness = new QAction(tr("Display brightness..."), 0, 0, this, 0, false); | ||
658 | connect(m_setCurrentBrightness,SIGNAL(activated()),this,SLOT(setupBrightness())); | ||
659 | } | ||
660 | |||
661 | void PMainWindow::setupBrightness() | ||
662 | { | ||
663 | if (!m_disp) { | ||
664 | return; | ||
665 | } | ||
666 | int lb = m_disp->Intensity(); | ||
667 | if (Valuebox(0,-255,255,lb,lb)) { | ||
668 | m_disp->setIntensity(lb,true); | ||
669 | } | ||
633 | } | 670 | } |
634 | 671 | ||
635 | void PMainWindow::setupToolbar() | 672 | void PMainWindow::setupToolbar() |
636 | { | 673 | { |
637 | toolBar = new QToolBar( this ); | 674 | toolBar = new QToolBar( this ); |
638 | addToolBar(toolBar); | 675 | addToolBar(toolBar); |
639 | toolBar->setHorizontalStretchable( true ); | 676 | toolBar->setHorizontalStretchable( true ); |
640 | setToolBarsMovable( false ); | 677 | setToolBarsMovable( false ); |
641 | m_aDirUp->addTo( toolBar ); | 678 | m_aDirUp->addTo( toolBar ); |
642 | 679 | ||
643 | fsButton = new PFileSystem( toolBar ); | 680 | fsButton = new PFileSystem( toolBar ); |
644 | connect( fsButton, SIGNAL( changeDir( const QString& ) ), | 681 | connect( fsButton, SIGNAL( changeDir( const QString& ) ), |
@@ -689,24 +726,26 @@ void PMainWindow::setupMenu() | |||
689 | } | 726 | } |
690 | fileMenu->insertSeparator(); | 727 | fileMenu->insertSeparator(); |
691 | m_aTrash->addTo(fileMenu); | 728 | m_aTrash->addTo(fileMenu); |
692 | 729 | ||
693 | listviewMenu = new QPopupMenu(dispMenu); | 730 | listviewMenu = new QPopupMenu(dispMenu); |
694 | dispMenu->insertItem(Resource::loadIconSet("opie-eye/opie-eye-thumb"),tr("Listview mode"),listviewMenu); | 731 | dispMenu->insertItem(Resource::loadIconSet("opie-eye/opie-eye-thumb"),tr("Listview mode"),listviewMenu); |
695 | m_gListViewMode->addTo(listviewMenu); | 732 | m_gListViewMode->addTo(listviewMenu); |
696 | dispMenu->insertSeparator(); | 733 | dispMenu->insertSeparator(); |
697 | m_aFullScreen->addTo(dispMenu); | 734 | m_aFullScreen->addTo(dispMenu); |
698 | m_gDisplayType->addTo(dispMenu); | 735 | m_gDisplayType->addTo(dispMenu); |
699 | dispMenu->insertSeparator(); | 736 | dispMenu->insertSeparator(); |
700 | m_gPrevNext->addTo(dispMenu); | 737 | m_gPrevNext->addTo(dispMenu); |
738 | m_setCurrentBrightness->addTo(dispMenu); | ||
739 | m_setCurrentBrightness->setEnabled(false); | ||
701 | if (m_aForceSmall) { | 740 | if (m_aForceSmall) { |
702 | dispMenu->insertSeparator(); | 741 | dispMenu->insertSeparator(); |
703 | m_aForceSmall->addTo(dispMenu); | 742 | m_aForceSmall->addTo(dispMenu); |
704 | } | 743 | } |
705 | 744 | ||
706 | m_aSetup->addTo(settingsMenu); | 745 | m_aSetup->addTo(settingsMenu); |
707 | m_aHideToolbar->addTo(settingsMenu); | 746 | m_aHideToolbar->addTo(settingsMenu); |
708 | } | 747 | } |
709 | 748 | ||
710 | void PMainWindow::listviewselected(QAction*which) | 749 | void PMainWindow::listviewselected(QAction*which) |
711 | { | 750 | { |
712 | if (!which || which->isOn()==false) return; | 751 | if (!which || which->isOn()==false) return; |
@@ -716,24 +755,25 @@ void PMainWindow::listviewselected(QAction*which) | |||
716 | val = 3; | 755 | val = 3; |
717 | } else if (which==m_aDirShort) { | 756 | } else if (which==m_aDirShort) { |
718 | val = 2; | 757 | val = 2; |
719 | } else if (which==m_aDirLong) { | 758 | } else if (which==m_aDirLong) { |
720 | val = 1; | 759 | val = 1; |
721 | } | 760 | } |
722 | emit changeListMode(val); | 761 | emit changeListMode(val); |
723 | } | 762 | } |
724 | 763 | ||
725 | void PMainWindow::readConfig() | 764 | void PMainWindow::readConfig() |
726 | { | 765 | { |
727 | autoSave =m_cfg->readBoolEntry("savestatus",true); | 766 | autoSave =m_cfg->readBoolEntry("savestatus",true); |
767 | m_Intensity = m_cfg->readNumEntry("intensity",0); | ||
728 | } | 768 | } |
729 | 769 | ||
730 | void PMainWindow::polish() | 770 | void PMainWindow::polish() |
731 | { | 771 | { |
732 | if (m_disp) { | 772 | if (m_disp) { |
733 | odebug << "======================\n" | 773 | odebug << "======================\n" |
734 | << "Called via setdocument\n" | 774 | << "Called via setdocument\n" |
735 | << "======================" << oendl; | 775 | << "======================" << oendl; |
736 | m_setDocCalled = true; | 776 | m_setDocCalled = true; |
737 | m_view->setDoccalled(true); | 777 | m_view->setDoccalled(true); |
738 | m_disp->setCloseIfHide(true); | 778 | m_disp->setCloseIfHide(true); |
739 | } else { | 779 | } else { |
@@ -755,12 +795,40 @@ void PMainWindow::slotForceSmall(bool how) | |||
755 | odebug << "Disable separate windows: " << how << oendl; | 795 | odebug << "Disable separate windows: " << how << oendl; |
756 | if (m_stack) { | 796 | if (m_stack) { |
757 | if (how) { | 797 | if (how) { |
758 | m_stack->forceMode(Opie::Ui::OWidgetStack::SmallScreen); | 798 | m_stack->forceMode(Opie::Ui::OWidgetStack::SmallScreen); |
759 | } else { | 799 | } else { |
760 | m_stack->forceMode(Opie::Ui::OWidgetStack::NoForce); | 800 | m_stack->forceMode(Opie::Ui::OWidgetStack::NoForce); |
761 | } | 801 | } |
762 | } | 802 | } |
763 | if (autoSave) { | 803 | if (autoSave) { |
764 | m_cfg->writeEntry("dontshowseperate",how); | 804 | m_cfg->writeEntry("dontshowseperate",how); |
765 | } | 805 | } |
766 | } | 806 | } |
807 | |||
808 | bool PMainWindow::Valuebox(QWidget*parent,int min, int max, int current,int&store) | ||
809 | { | ||
810 | QDialog dlg(parent,"brightnessbox",true); | ||
811 | QVBoxLayout * m_MainLayout; | ||
812 | QGridLayout * m_IntensityLayout; | ||
813 | QSpinBox * m_Intensity; | ||
814 | QLabel * m_IntensityLabel; | ||
815 | |||
816 | m_MainLayout = new QVBoxLayout( &dlg, 11, 6, "m_MainLayout"); | ||
817 | m_IntensityLayout = new QGridLayout( 0, 1, 1, 0, 6, "m_IntensityLayout"); | ||
818 | m_Intensity = new QSpinBox( &dlg, "m_Intensity" ); | ||
819 | m_Intensity->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Fixed)); | ||
820 | m_Intensity->setButtonSymbols( QSpinBox::PlusMinus ); | ||
821 | m_Intensity->setMaxValue( max ); | ||
822 | m_Intensity->setMinValue(min); | ||
823 | m_Intensity->setValue( current ); | ||
824 | m_IntensityLayout->addWidget( m_Intensity, 0, 1 ); | ||
825 | m_IntensityLabel = new QLabel( &dlg, "m_IntensityLabel" ); | ||
826 | m_IntensityLabel->setText(QObject::tr("Display brightness:")); | ||
827 | m_IntensityLayout->addWidget(m_IntensityLabel, 0, 0 ); | ||
828 | m_MainLayout->addLayout(m_IntensityLayout); | ||
829 | if (dlg.exec()) { | ||
830 | store = m_Intensity->value(); | ||
831 | return true; | ||
832 | } | ||
833 | return false; | ||
834 | } | ||