-rw-r--r-- | noncore/graphics/opie-eye/gui/imageview.cpp | 45 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/imageview.h | 11 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/mainwindow.cpp | 3 |
3 files changed, 19 insertions, 40 deletions
diff --git a/noncore/graphics/opie-eye/gui/imageview.cpp b/noncore/graphics/opie-eye/gui/imageview.cpp index 5b00dea..03f3c1c 100644 --- a/noncore/graphics/opie-eye/gui/imageview.cpp +++ b/noncore/graphics/opie-eye/gui/imageview.cpp @@ -1,185 +1,168 @@ #include "imageview.h" #include <opie2/odebug.h> #include <opie2/oconfig.h> #include <opie2/okeyconfigwidget.h> #include <qpe/resource.h> #include <qpe/qpeapplication.h> #include <qpopupmenu.h> using namespace Opie::Core; ImageView::ImageView(Opie::Core::OConfig *cfg, QWidget* parent, const char* name, WFlags fl ) : Opie::MM::OImageScrollView(parent,name,fl) { m_viewManager = 0; - m_focus_out = false; - block_next_focus = true; + focus_in_count = 0; m_cfg = cfg; m_isFullScreen = false; + m_ignore_next_in = false; QPEApplication::setStylusOperation(viewport(),QPEApplication::RightOnHold); initKeys(); } ImageView::~ImageView() { odebug << "Delete Imageview" << oendl; if (m_viewManager) { delete m_viewManager; } } Opie::Core::OKeyConfigManager* ImageView::manager() { if (!m_viewManager) { initKeys(); } return m_viewManager; } void ImageView::initKeys() { odebug << "init imageview keys" << oendl; if (!m_cfg) { m_cfg = new Opie::Core::OConfig("phunkview"); m_cfg->setGroup("image_view_keys" ); } Opie::Core::OKeyPair::List lst; lst.append( Opie::Core::OKeyPair::upArrowKey() ); lst.append( Opie::Core::OKeyPair::downArrowKey() ); lst.append( Opie::Core::OKeyPair::leftArrowKey() ); lst.append( Opie::Core::OKeyPair::rightArrowKey() ); lst.append( Opie::Core::OKeyPair(Qt::Key_Escape,0)); m_viewManager = new Opie::Core::OKeyConfigManager(m_cfg, "image_view_keys", lst, false,this, "image_view_keys" ); m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("View Image Info"), "imageviewinfo", Resource::loadPixmap("1to1"), ViewInfo, Opie::Core::OKeyPair(Qt::Key_I,0), this, SLOT(slotShowImageInfo()))); m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle autorotate"), "imageautorotate", Resource::loadPixmap("rotate"), Autorotate, Opie::Core::OKeyPair(Qt::Key_R,0), this, SIGNAL(toggleAutorotate()))); m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle autoscale"), "imageautoscale", Resource::loadPixmap("1to1"), Autoscale, Opie::Core::OKeyPair(Qt::Key_S,0), this, SIGNAL(toggleAutoscale()))); m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Switch to next image"), "imageshownext", Resource::loadPixmap("forward"), ShowNext, Opie::Core::OKeyPair(Qt::Key_Return,0), this, SIGNAL(dispNext()))); m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Switch to previous image"), "imageshowprev", Resource::loadPixmap("back"), ShowPrevious, Opie::Core::OKeyPair(Qt::Key_P,0), this, SIGNAL(dispPrev()))); m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle fullscreen"), "imagefullscreen", Resource::loadPixmap("fullscreen"), FullScreen, Opie::Core::OKeyPair(Qt::Key_F,0), this, SIGNAL(toggleFullScreen()))); m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle thumbnail"), "imagezoomer", Resource::loadPixmap("mag"), Zoomer, Opie::Core::OKeyPair(Qt::Key_T,0), this, SIGNAL(toggleZoomer()))); m_viewManager->handleWidget( this ); m_viewManager->load(); } void ImageView::keyReleaseEvent(QKeyEvent * e) { if (!e || e->state()!=0) { return; } if (e->key()==Qt::Key_Escape && fullScreen()) emit hideMe(); } void ImageView::slotShowImageInfo() { emit dispImageInfo(m_lastName); } void ImageView::contentsMousePressEvent ( QMouseEvent * e) { if (e->button()==1) { return OImageScrollView::contentsMousePressEvent(e); } -// if (!fullScreen()) return; odebug << "Popup " << oendl; QPopupMenu *m = new QPopupMenu(0); if (!m) return; bool old = fullScreen(); m->insertItem(tr("Toggle fullscreen"),this, SIGNAL(toggleFullScreen())); if (fullScreen()) { m->insertSeparator(); m->insertItem(tr("Previous image"),this,SIGNAL(dispPrev())); m->insertItem(tr("Next image"),this,SIGNAL(dispNext())); m->insertSeparator(); m->insertItem(tr("Toggle autoscale"),this, SIGNAL(toggleAutoscale())); m->insertItem(tr("Toggle autorotate"),this, SIGNAL(toggleAutorotate())); m->insertItem(tr("Toggle thumbnail"),this, SIGNAL(toggleZoomer())); } m->setFocus(); m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); delete m; - /* if we were fullScreen() and must overlap the taskbar again */ - if (fullScreen() && old) { - enableFullscreen(); - } } void ImageView::setFullScreen(bool how) { m_isFullScreen = how; } void ImageView::focusInEvent(QFocusEvent *) { // Always do it here, no matter the size. - odebug << "Focus in" << oendl; -} - -void ImageView::focusOutEvent(QFocusEvent *) -{ - odebug << "Focus out" << oendl; + odebug << "Focus in (view)" << oendl; + //if (fullScreen()) parentWidget()->showNormal(); + if (m_ignore_next_in){m_ignore_next_in=false;return;} + if (fullScreen()) enableFullscreen(); } void ImageView::enableFullscreen() { // This call is needed because showFullScreen won't work // correctly if the widget already considers itself to be fullscreen. + if (!fullScreen()) return; + if (m_ignore_next_in) {m_ignore_next_in = false;return;} + setUpdatesEnabled(false); - odebug << "showNormal();" << oendl; parentWidget()->showNormal(); - odebug << "showNormal(); done " << oendl; // This is needed because showNormal() forcefully changes the window // style to WSTyle_TopLevel. - odebug << " reparent(0, WStyle_Customize | WStyle_NoBorder, QPoint(0,0));" << oendl; parentWidget()->reparent(0, WStyle_Customize | WStyle_NoBorder, QPoint(0,0)); - odebug << " reparent(0, WStyle_Customize | WStyle_NoBorder, QPoint(0,0)); done" << oendl; // Enable fullscreen. - odebug << "showFullScreen();" << oendl; + /* this is the trick - I don't now why, but after a showFullScreen QTE toggles the focus + * so we must block it here! */ + m_ignore_next_in = true; parentWidget()->showFullScreen(); - odebug << "showFullScreen(); done" << oendl; setUpdatesEnabled(true); } -void ImageWidget::show() -{ - QWidget::show(); -} - -void ImageWidget::hide() -{ - QWidget::hide(); -} - ImageWidget::ImageWidget(QWidget * parent, const char * name, WFlags f) : QWidget(parent,name,f) { - // Make sure size is correct - setFixedSize(qApp->desktop()->size()); + // Make sure size is correct + setFixedSize(qApp->desktop()->size()); } diff --git a/noncore/graphics/opie-eye/gui/imageview.h b/noncore/graphics/opie-eye/gui/imageview.h index 5f15bc9..f3c37b5 100644 --- a/noncore/graphics/opie-eye/gui/imageview.h +++ b/noncore/graphics/opie-eye/gui/imageview.h @@ -1,80 +1,77 @@ #ifndef _IMAGE_VIEW_H #define _IMAGE_VIEW_H #include <opie2/oimagescrollview.h> #include <qwidget.h> namespace Opie { namespace Core { class OConfig; class OKeyConfigManager; } } class ImageView:public Opie::MM::OImageScrollView { Q_OBJECT enum ActionIds { ViewInfo, FullScreen, ShowNext, ShowPrevious, Zoomer, Autorotate, Autoscale }; public: ImageView(Opie::Core::OConfig *cfg, QWidget* parent, const char* name = 0, WFlags fl = 0 ); virtual ~ImageView(); Opie::Core::OKeyConfigManager* manager(); void setFullScreen(bool how); - virtual void enableFullscreen(); bool fullScreen(){return m_isFullScreen;} + virtual void enableFullscreen(); signals: void dispImageInfo(const QString&); void dispNext(); void dispPrev(); void toggleFullScreen(); void hideMe(); void toggleZoomer(); void toggleAutoscale(); void toggleAutorotate(); protected: Opie::Core::OConfig * m_cfg; Opie::Core::OKeyConfigManager*m_viewManager; void initKeys(); bool m_isFullScreen:1; - bool m_focus_out:1; - bool block_next_focus:1; - + bool m_ignore_next_in:1; + int focus_in_count; virtual void focusInEvent ( QFocusEvent * ); - virtual void focusOutEvent ( QFocusEvent * ); + protected slots: virtual void slotShowImageInfo(); virtual void keyReleaseEvent(QKeyEvent * e); virtual void contentsMousePressEvent ( QMouseEvent * e); }; class ImageWidget:public QWidget { Q_OBJECT public: ImageWidget(QWidget * parent=0, const char * name=0, WFlags f = WStyle_Customize | WStyle_NoBorder); virtual ~ImageWidget(){}; protected: public slots: - virtual void show(); - virtual void hide(); protected slots: }; #endif diff --git a/noncore/graphics/opie-eye/gui/mainwindow.cpp b/noncore/graphics/opie-eye/gui/mainwindow.cpp index fa1680c..cdaf34c 100644 --- a/noncore/graphics/opie-eye/gui/mainwindow.cpp +++ b/noncore/graphics/opie-eye/gui/mainwindow.cpp @@ -209,249 +209,248 @@ void PMainWindow::slotConfig() { * have a tab with the possible views * a tab for globals image cache size.. scaled loading * and one tab for the KeyConfigs */ QDialog dlg(this, 0, true); dlg.setCaption( tr("Phunk View - Config" ) ); QHBoxLayout *lay = new QHBoxLayout(&dlg); Opie::Ui::OTabWidget *wid = new Opie::Ui::OTabWidget(&dlg ); lay->addWidget( wid ); ViewMap *vM = viewMap(); ViewMap::Iterator _it = vM->begin(); QMap<PDirView*, QWidget*> lst; for( ; _it != vM->end(); ++_it ) { PDirView *view = (_it.data())(*m_cfg); PInterfaceInfo *inf = view->interfaceInfo(); QWidget *_wid = inf->configWidget( *m_cfg ); if (!_wid) continue; _wid->reparent(wid, QPoint() ); lst.insert( view, _wid ); wid->addTab( _wid, "fileopen", inf->name() ); } /* * Add the KeyConfigWidget */ Opie::Ui::OKeyConfigWidget* keyWid = new Opie::Ui::OKeyConfigWidget( wid, "key config" ); keyWid->setChangeMode( Opie::Ui::OKeyConfigWidget::Queue ); keyWid->insert( tr("Browser Keyboard Actions"), m_view->manager() ); if ( !m_info ) { initInfo(); } keyWid->insert( tr("Imageinfo Keyboard Actions"), m_info->manager() ); if ( !m_disp ) { initDisp(); } keyWid->insert( tr("Imageview Keyboard Actions"), m_disp->manager() ); keyWid->load(); wid->addTab( keyWid, QString::fromLatin1("AppsIcon" ), tr("Keyboard Configuration") ); bool act = ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ); /* * clean up *apply changes */ QMap<PDirView*, QWidget*>::Iterator it; for ( it = lst.begin(); it != lst.end(); ++it ) { if ( act ) it.key()->interfaceInfo()->writeConfig(it.data(), *m_cfg); delete it.key(); } if ( act ) { m_view->resetView(); keyWid->save(); m_disp->manager()->save(); m_info->manager()->save(); m_view->manager()->save(); } delete keyWid; } /* * create a new image info component * and detach the current one * we will make the other delete on exit */ template<class T> void PMainWindow::initT( const char* name, T** ptr, int id) { if ( *ptr ) { (*ptr)->disconnect(this, SLOT(slotReturn())); (*ptr)->setDestructiveClose(); m_stack->removeWidget( *ptr ); } *ptr = new T(m_cfg, m_stack, name ); m_stack->addWidget( *ptr, id ); connect(*ptr, SIGNAL(sig_return()), this,SLOT(slotReturn())); } void PMainWindow::initInfo() { initT<imageinfo>( "Image Info", &m_info, ImageInfo ); connect(m_info,SIGNAL(dispImage(const QString&)),this,SLOT(slotDisplay(const QString&))); } void PMainWindow::initDisp() { initT<ImageView>( "Image ScrollView", &m_disp, ImageDisplay ); if (m_disp) { if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) { m_disp->setMinimumSize(QApplication::desktop()->size()/2); } m_disp->setAutoScale(autoScale); m_disp->setAutoRotate(autoRotate); m_disp->setShowZoomer(zoomerOn); m_disp->setBackgroundColor(white); connect(m_disp,SIGNAL(dispImageInfo(const QString&)),this,SLOT(slotShowInfo(const QString&))); connect(m_disp,SIGNAL(dispNext()),m_view,SLOT(slotShowNext())); connect(m_disp,SIGNAL(dispPrev()),m_view,SLOT(slotShowPrev())); connect(m_disp,SIGNAL(toggleFullScreen()),this,SLOT(slotToggleFullScreen())); connect(m_disp,SIGNAL(hideMe()),this,SLOT(raiseIconView())); connect(m_disp,SIGNAL(toggleZoomer()),this,SLOT(slotToggleZoomer())); connect(m_disp,SIGNAL(toggleAutoscale()),this,SLOT(slotToggleAutoscale())); connect(m_disp,SIGNAL(toggleAutorotate()),this,SLOT(slotToggleAutorotate())); } } void PMainWindow::slotToggleFullScreen() { odebug << "Toggle full " << oendl; if (!m_disp) return; bool current = !m_disp->fullScreen(); m_disp->setFullScreen(current); odebug << "Current = " << current << oendl; if (current) { odebug << "full" << oendl; m_disp->setBackgroundColor(black); if (!tFrame) { tFrame = new ImageWidget(0,0,WStyle_Customize|WStyle_NoBorder); tFrame->resize(qApp->desktop()->width(), qApp->desktop()->height()); tFrame->setMinimumSize(qApp->desktop()->width(), qApp->desktop()->height()); } m_disp->reparent(tFrame,QPoint(0,0)); m_disp->setVScrollBarMode(QScrollView::AlwaysOff); m_disp->setHScrollBarMode(QScrollView::AlwaysOff); m_disp->resize(qApp->desktop()->width(), qApp->desktop()->height()); tFrame->showFullScreen(); } else { setUpdatesEnabled(false); odebug << "window" << oendl; m_disp->reparent(0,QPoint(0,0)); m_disp->showNormal(); /* don't forget it! */ tFrame->hide(); m_disp->setBackgroundColor(white); m_stack->addWidget(m_disp,ImageDisplay); m_disp->setVScrollBarMode(QScrollView::Auto); m_disp->setHScrollBarMode(QScrollView::Auto); m_stack->raiseWidget(m_disp); if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) { m_disp->resize(m_disp->minimumSize()); } setUpdatesEnabled(true); } } /** * With big Screen the plan could be to 'detach' the image * window if visible and to create a ne wone * init* already supports it but I make no use of it for * now. We set filename and raise * * ### FIXME and talk to alwin */ void PMainWindow::slotShowInfo( const QString& inf ) { if (m_disp && m_disp->fullScreen() && m_disp->isVisible()) { return; } if ( !m_info ) { initInfo(); } m_info->setPath( inf ); if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) { prevButton->hide(); nextButton->hide(); upButton->hide(); fsButton->hide(); viewModeButton->hide(); } m_stack->raiseWidget( ImageInfo ); } void PMainWindow::slotDisplay( const QString& inf ) { if ( !m_disp ) { initDisp(); } m_disp->setImage( inf ); if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) { prevButton->show(); nextButton->show(); upButton->hide(); fsButton->hide(); viewModeButton->hide(); } if (m_disp->fullScreen()) { -// tFrame->showFullScreen(); - m_disp->enableFullscreen(); + tFrame->show();//FullScreen(); } else { m_stack->raiseWidget( ImageDisplay ); } } void PMainWindow::slotReturn() { raiseIconView(); } void PMainWindow::closeEvent( QCloseEvent* ev ) { /* * return from view * or properly quit */ if ( m_stack->visibleWidget() == m_info || m_stack->visibleWidget() == m_disp ) { ev->ignore(); raiseIconView(); return; } if (m_disp && m_disp->fullScreen()) { /* otherwise opie-eye crashes in bigscreen mode! */ m_disp->reparent(0,QPoint(0,0)); m_stack->addWidget(m_disp,ImageDisplay); } ev->accept(); QTimer::singleShot(0, qApp, SLOT(closeAllWindows())); } void PMainWindow::raiseIconView() { setUpdatesEnabled(false); if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) { prevButton->hide(); nextButton->hide(); upButton->show(); fsButton->show(); viewModeButton->show(); } if (m_disp && m_disp->fullScreen() && m_disp->isVisible()) { tFrame->hide(); } m_stack->raiseWidget( IconView ); setUpdatesEnabled(true); repaint(); } void PMainWindow::setDocument( const QString& showImg ) { QString file = showImg; DocLnk lnk(showImg); if (lnk.isValid() ) file = lnk.file(); slotDisplay( file ); } |