author | alwin <alwin> | 2004-04-20 22:58:27 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-04-20 22:58:27 (UTC) |
commit | c61b410ba0051c266501933f7f675291684613f8 (patch) (side-by-side diff) | |
tree | 2bdb8278bb271bcb305652dea528709735b0a08d | |
parent | 4348554f74290f477af9a338cdabf363883c9472 (diff) | |
download | opie-c61b410ba0051c266501933f7f675291684613f8.zip opie-c61b410ba0051c266501933f7f675291684613f8.tar.gz opie-c61b410ba0051c266501933f7f675291684613f8.tar.bz2 |
some gui stuff - fullscreen now works better on smallscreen, bigscreen
has some more problems...
-rw-r--r-- | noncore/graphics/opie-eye/gui/imageview.cpp | 46 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/imageview.h | 8 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/mainwindow.cpp | 63 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/mainwindow.h | 5 |
4 files changed, 105 insertions, 17 deletions
diff --git a/noncore/graphics/opie-eye/gui/imageview.cpp b/noncore/graphics/opie-eye/gui/imageview.cpp index 88a8bc6..5b34ca2 100644 --- a/noncore/graphics/opie-eye/gui/imageview.cpp +++ b/noncore/graphics/opie-eye/gui/imageview.cpp @@ -1,87 +1,131 @@ #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_cfg = cfg; m_isFullScreen = 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_N,0), + 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; +#if 0 + // doesn't work right (repainting problems) + odebug << "Popup " << oendl; + QPopupMenu *m = new QPopupMenu(0); + if (!m) return; + m->insertItem(tr("Previous image"),ShowPrevious); + m->insertItem(tr("Next image"),ShowNext); + m->insertSeparator(); + m->insertItem(tr("Toggle fullscreen"),FullScreen); + m->insertItem(tr("Toggle autoscale"),Autoscale); + m->insertItem(tr("Toggle autorotate"),Autorotate); + m->insertItem(tr("Toggle thumbnail"),Zoomer); + m->setFocus(); + m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); + delete m; + parentWidget()->showFullScreen(); +#endif +} + +void ImageView::setFullScreen(bool how) +{ + m_isFullScreen = how; +} diff --git a/noncore/graphics/opie-eye/gui/imageview.h b/noncore/graphics/opie-eye/gui/imageview.h index 6bf930f..445bee9 100644 --- a/noncore/graphics/opie-eye/gui/imageview.h +++ b/noncore/graphics/opie-eye/gui/imageview.h @@ -1,50 +1,56 @@ #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, 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){m_isFullScreen = how;} + void setFullScreen(bool how); bool fullScreen(){return m_isFullScreen;} 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; protected slots: virtual void slotShowImageInfo(); virtual void keyReleaseEvent(QKeyEvent * e); + virtual void contentsMousePressEvent ( QMouseEvent * e); }; + #endif diff --git a/noncore/graphics/opie-eye/gui/mainwindow.cpp b/noncore/graphics/opie-eye/gui/mainwindow.cpp index 0484f73..a784f5b 100644 --- a/noncore/graphics/opie-eye/gui/mainwindow.cpp +++ b/noncore/graphics/opie-eye/gui/mainwindow.cpp @@ -9,60 +9,61 @@ #include "filesystem.h" #include "imageinfoui.h" #include "viewmodebutton.h" #include <iface/ifaceinfo.h> #include <iface/dirview.h> #include <opie2/odebug.h> #include <opie2/owidgetstack.h> #include <opie2/oapplicationfactory.h> #include <opie2/otabwidget.h> #include <opie2/okeyconfigwidget.h> #include <qpe/resource.h> #include <qpe/config.h> #include <qpe/ir.h> #include <qpe/applnk.h> #include <qtoolbar.h> #include <qtoolbutton.h> #include <qlayout.h> #include <qdialog.h> #include <qmap.h> #include <qtimer.h> - +#include <qframe.h> OPIE_EXPORT_APP_V2( Opie::Core::OApplicationFactory<PMainWindow>,"Opie Eye" ) PMainWindow::PMainWindow(QWidget* wid, const char* name, WFlags style) : QMainWindow( wid, name, style ), m_info( 0 ), m_disp( 0 ) { setCaption( QObject::tr("Opie Eye Caramba" ) ); m_cfg = new Opie::Core::OConfig("phunkview"); m_cfg->setGroup("Zecke_view" ); + tFrame = 0; // qDebug( "Process-wide OApplication object @ %0x", oApp ); /* * Initialize ToolBar and IconView * And Connect Them */ QToolBar *bar = new QToolBar( this ); bar->setHorizontalStretchable( true ); setToolBarsMovable( false ); m_stack = new Opie::Ui::OWidgetStack( this ); setCentralWidget( m_stack ); m_view = new PIconView( m_stack, m_cfg ); m_stack->addWidget( m_view, IconView ); m_stack->raiseWidget( IconView ); connect(m_view, SIGNAL(sig_display(const QString&)), this, SLOT(slotDisplay(const QString&))); connect(m_view, SIGNAL(sig_showInfo(const QString&)), this, SLOT(slotShowInfo(const QString&)) ); m_stack->forceMode(Opie::Ui::OWidgetStack::NoForce); upButton = new QToolButton( bar ); upButton->setIconSet( Resource::loadIconSet( "up" ) ); @@ -107,82 +108,99 @@ 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))); + scaleButton = new QToolButton(bar); + scaleButton->setIconSet( Resource::loadIconSet( "1to1" ) ); + scaleButton->setToggleButton(true); + scaleButton->setOn(false); + connect(scaleButton,SIGNAL(toggled(bool)),this,SLOT(slotScaleToggled(bool))); autoScale = true; 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; + if (tFrame) delete tFrame; + odebug << "Shutting down done" << 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::slotToggleAutorotate() +{ + if (!m_disp) return; + if (!rotateButton->isEnabled()) return; + bool cur = rotateButton->isOn(); + rotateButton->setOn(!cur); +} + +void PMainWindow::slotToggleAutoscale() +{ + if (!m_disp) return; + bool cur = scaleButton->isOn(); + scaleButton->setOn(!cur); +} + 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() { @@ -274,142 +292,159 @@ void PMainWindow::initT( const char* name, T** ptr, int 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); - m_disp->reparent(0,QPoint(0,0)); + if (!tFrame) { + tFrame = new QWidget(0,0,WType_TopLevel|WStyle_NoBorder|WStyle_StaysOnTop); + 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()); - m_disp->showFullScreen(); + tFrame->showFullScreen(); } else { 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()); } } } /** * 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(); } - if (m_disp && m_disp->fullScreen() && m_disp->isVisible()) { - m_disp->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()) { - m_disp->show(); + tFrame->setActiveWindow(); + tFrame->showFullScreen(); } 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 ) { - raiseIconView(); 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() { 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()) { - m_disp->hide(); + tFrame->hide(); } m_stack->raiseWidget( IconView ); } void PMainWindow::setDocument( const QString& showImg ) { QString file = showImg; DocLnk lnk(showImg); if (lnk.isValid() ) file = lnk.file(); slotDisplay( file ); } diff --git a/noncore/graphics/opie-eye/gui/mainwindow.h b/noncore/graphics/opie-eye/gui/mainwindow.h index e51a3ff..1f90f9f 100644 --- a/noncore/graphics/opie-eye/gui/mainwindow.h +++ b/noncore/graphics/opie-eye/gui/mainwindow.h @@ -23,53 +23,56 @@ namespace Core{ 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 slotToggleAutorotate(); + void slotToggleAutoscale(); 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; + QWidget*tFrame; QToolButton*rotateButton,*upButton,*fsButton,*viewModeButton; - QToolButton*nextButton,*prevButton,*zoomButton; + QToolButton*nextButton,*prevButton,*zoomButton,*scaleButton; private slots: void slotConfig(); }; #endif |