author | alwin <alwin> | 2004-04-20 14:08:54 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-04-20 14:08:54 (UTC) |
commit | ccba33667c0152cb58a6d0502170b388889571c9 (patch) (side-by-side diff) | |
tree | 435da693facffec996bcaa8d8ae500c773794d7f | |
parent | 135990877f009bd05f00b064a1a255be3e5ab087 (diff) | |
download | opie-ccba33667c0152cb58a6d0502170b388889571c9.zip opie-ccba33667c0152cb58a6d0502170b388889571c9.tar.gz opie-ccba33667c0152cb58a6d0502170b388889571c9.tar.bz2 |
keys in imageview handled via keyconfig manager again
-rw-r--r-- | noncore/graphics/opie-eye/gui/imageview.cpp | 34 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/imageview.h | 8 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/mainwindow.cpp | 18 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/mainwindow.h | 3 |
4 files changed, 38 insertions, 25 deletions
diff --git a/noncore/graphics/opie-eye/gui/imageview.cpp b/noncore/graphics/opie-eye/gui/imageview.cpp index ee4b0a1..88a8bc6 100644 --- a/noncore/graphics/opie-eye/gui/imageview.cpp +++ b/noncore/graphics/opie-eye/gui/imageview.cpp @@ -15,71 +15,73 @@ ImageView::ImageView(Opie::Core::OConfig *cfg, QWidget* parent, const char* name m_cfg = cfg; m_isFullScreen = false; initKeys(); } ImageView::~ImageView() { 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_N,0)); - lst.append( Opie::Core::OKeyPair(Qt::Key_P,0)); - lst.append( Opie::Core::OKeyPair(Qt::Key_F,0)); + 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("Switch to next image"), "imageshownext", + Resource::loadPixmap("forward"), ShowNext, + Opie::Core::OKeyPair(Qt::Key_N,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_N) slotDispNext(); - if (e->key()==Qt::Key_P) slotDispPrev(); - if (e->key()==Qt::Key_F) emit toggleFullScreen(); if (e->key()==Qt::Key_Escape && fullScreen()) emit hideMe(); } -void ImageView::slotDispNext() -{ - emit dispNext(); -} - -void ImageView::slotDispPrev() -{ - emit dispPrev(); -} - void ImageView::slotShowImageInfo() { emit dispImageInfo(m_lastName); } diff --git a/noncore/graphics/opie-eye/gui/imageview.h b/noncore/graphics/opie-eye/gui/imageview.h index 75f798c..6bf930f 100644 --- a/noncore/graphics/opie-eye/gui/imageview.h +++ b/noncore/graphics/opie-eye/gui/imageview.h @@ -1,48 +1,50 @@ #ifndef _IMAGE_VIEW_H #define _IMAGE_VIEW_H #include <opie2/oimagescrollview.h> namespace Opie { namespace Core { class OConfig; class OKeyConfigManager; } } class ImageView:public Opie::MM::OImageScrollView { Q_OBJECT enum ActionIds { ViewInfo, - FullScreen + FullScreen, + ShowNext, + ShowPrevious, + Zoomer, }; 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){m_isFullScreen = how;} bool fullScreen(){return m_isFullScreen;} signals: void dispImageInfo(const QString&); void dispNext(); void dispPrev(); void toggleFullScreen(); void hideMe(); + void toggleZoomer(); protected: Opie::Core::OConfig * m_cfg; Opie::Core::OKeyConfigManager*m_viewManager; void initKeys(); bool m_isFullScreen:1; protected slots: virtual void slotShowImageInfo(); - virtual void slotDispNext(); - virtual void slotDispPrev(); virtual void keyReleaseEvent(QKeyEvent * e); }; #endif diff --git a/noncore/graphics/opie-eye/gui/mainwindow.cpp b/noncore/graphics/opie-eye/gui/mainwindow.cpp index a90231b..0484f73 100644 --- a/noncore/graphics/opie-eye/gui/mainwindow.cpp +++ b/noncore/graphics/opie-eye/gui/mainwindow.cpp @@ -106,76 +106,83 @@ PMainWindow::PMainWindow(QWidget* wid, const char* name, WFlags style) prevButton = new QToolButton(bar); prevButton->setIconSet( Resource::loadIconSet( "back" ) ); connect(prevButton,SIGNAL(clicked()),m_view,SLOT(slotShowPrev())); nextButton = new QToolButton(bar); nextButton->setIconSet( Resource::loadIconSet( "forward" ) ); connect(nextButton,SIGNAL(clicked()),m_view,SLOT(slotShowNext())); rotateButton = new QToolButton(bar); rotateButton->setIconSet( Resource::loadIconSet( "rotate" ) ); rotateButton->setToggleButton(true); if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) { rotateButton->setOn(true); autoRotate = true; prevButton->hide(); nextButton->hide(); } else { rotateButton->setOn(false); autoRotate = false; } connect(rotateButton,SIGNAL(toggled(bool)),this,SLOT(slotRotateToggled(bool))); btn = new QToolButton(bar); btn->setIconSet( Resource::loadIconSet( "1to1" ) ); btn->setToggleButton(true); btn->setOn(false); connect(btn,SIGNAL(toggled(bool)),this,SLOT(slotScaleToggled(bool))); autoScale = true; - btn = new QToolButton(bar); - btn->setIconSet( Resource::loadIconSet( "mag" ) ); - btn->setToggleButton(true); - btn->setOn(true); - connect(btn,SIGNAL(toggled(bool)),this,SLOT(slotZoomerToggled(bool))); + zoomButton = new QToolButton(bar); + zoomButton->setIconSet( Resource::loadIconSet( "mag" ) ); + zoomButton->setToggleButton(true); + zoomButton->setOn(true); + connect(zoomButton,SIGNAL(toggled(bool)),this,SLOT(slotZoomerToggled(bool))); zoomerOn = true; } PMainWindow::~PMainWindow() { odebug << "Shutting down" << oendl; } +void PMainWindow::slotToggleZoomer() +{ + if (!m_disp) return; + bool cur = zoomButton->isOn(); + zoomButton->setOn(!cur); +} + void PMainWindow::slotZoomerToggled(bool how) { zoomerOn = how; if (m_disp) { m_disp->setShowZoomer(zoomerOn); } } void PMainWindow::slotRotateToggled(bool how) { autoRotate = how; if (m_disp) { m_disp->setAutoRotate(how); } } void PMainWindow::slotScaleToggled(bool how) { autoScale = !how; if (!how) { autoRotate = how; } if (m_disp) { m_disp->setAutoScaleRotate(autoScale,autoRotate); } if (!autoScale) { rotateButton->setOn(false); } rotateButton->setEnabled(!how); } void PMainWindow::slotConfig() { @@ -258,64 +265,65 @@ 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())); } } 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); m_disp->reparent(0,QPoint(0,0)); m_disp->setVScrollBarMode(QScrollView::AlwaysOff); m_disp->setHScrollBarMode(QScrollView::AlwaysOff); m_disp->resize(qApp->desktop()->width(), qApp->desktop()->height()); m_disp->showFullScreen(); } else { odebug << "window" << oendl; 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()); } } } /** diff --git a/noncore/graphics/opie-eye/gui/mainwindow.h b/noncore/graphics/opie-eye/gui/mainwindow.h index d238763..e51a3ff 100644 --- a/noncore/graphics/opie-eye/gui/mainwindow.h +++ b/noncore/graphics/opie-eye/gui/mainwindow.h @@ -14,61 +14,62 @@ namespace Opie { namespace Ui{ class OWidgetStack; } namespace Core{ class OKeyConfigManager; } } class ImageView; class PIconView; class imageinfo; class PMainWindow : public QMainWindow { Q_OBJECT enum Views { IconView, ImageInfo, ImageDisplay }; public: static QString appName() { return QString::fromLatin1("opie-eye" ); } PMainWindow(QWidget*, const char*, WFlags ); ~PMainWindow(); signals: void configChanged(); public slots: void slotShowInfo( const QString& inf ); void slotDisplay( const QString& inf ); void slotReturn(); void slotRotateToggled(bool); void slotScaleToggled(bool); void slotZoomerToggled(bool); + void slotToggleZoomer(); void setDocument( const QString& ); virtual void slotToggleFullScreen(); protected slots: void raiseIconView(); void closeEvent( QCloseEvent* ); private: template<class T> void initT( const char* name, T**, int ); void initInfo(); void initDisp(); private: Opie::Core::OConfig *m_cfg; Opie::Ui::OWidgetStack *m_stack; PIconView* m_view; imageinfo *m_info; ImageView *m_disp; bool autoRotate; bool autoScale; bool zoomerOn; QToolButton*rotateButton,*upButton,*fsButton,*viewModeButton; - QToolButton*nextButton,*prevButton; + QToolButton*nextButton,*prevButton,*zoomButton; private slots: void slotConfig(); }; #endif |