author | alwin <alwin> | 2005-03-02 12:05:55 (UTC) |
---|---|---|
committer | alwin <alwin> | 2005-03-02 12:05:55 (UTC) |
commit | b9d921e98946ee787ec995f44eb1b937d669b430 (patch) (side-by-side diff) | |
tree | 7136aa32ca3d90c0b03ec21f855f32b7536eb339 | |
parent | 374cb9f45664c307ab7d0ed88fea5e76631518d9 (diff) | |
download | opie-b9d921e98946ee787ec995f44eb1b937d669b430.zip opie-b9d921e98946ee787ec995f44eb1b937d669b430.tar.gz opie-b9d921e98946ee787ec995f44eb1b937d669b430.tar.bz2 |
fixed some problems in bigscreen mode and when rotating
-rw-r--r-- | noncore/graphics/opie-eye/gui/imageview.cpp | 37 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/imageview.h | 7 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/mainwindow.cpp | 22 |
3 files changed, 55 insertions, 11 deletions
diff --git a/noncore/graphics/opie-eye/gui/imageview.cpp b/noncore/graphics/opie-eye/gui/imageview.cpp index ac6474c..03df321 100644 --- a/noncore/graphics/opie-eye/gui/imageview.cpp +++ b/noncore/graphics/opie-eye/gui/imageview.cpp @@ -1,62 +1,92 @@ #include "imageview.h" #include <opie2/odebug.h> #include <opie2/oconfig.h> #include <opie2/okeyconfigwidget.h> #include <qpe/resource.h> #include <qpe/qpeapplication.h> +#include <qpe/qcopenvelope_qws.h> + #include <qpopupmenu.h> #include <qtimer.h> #include <qaction.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; focus_in_count = 0; m_cfg = cfg; m_isFullScreen = false; m_ignore_next_in = false; m_slideTimer = 0; QPEApplication::setStylusOperation(viewport(),QPEApplication::RightOnHold); initKeys(); m_slideValue = 5; m_gDisplayType = 0; m_gPrevNext = 0; m_hGroup = 0; + m_Rotated = false; closeIfHide = false; + int min = QApplication::desktop()->size().width()>QApplication::desktop()->size().height()? + QApplication::desktop()->size().height():QApplication::desktop()->size().width(); + if (min>320) { + // bigscreen + setMinimumSize(min/3,min/3); + } else { + setMinimumSize(10,10); + } + m_sysChannel = new QCopChannel( "QPE/System", this ); + connect( m_sysChannel, SIGNAL( received(const QCString&,const QByteArray&) ), + this, SLOT( systemMessage(const QCString&,const QByteArray&) ) ); +} + +void ImageView::systemMessage( const QCString& msg, const QByteArray& data ) +{ + int _newrotation; + QDataStream stream( data, IO_ReadOnly ); + odebug << "received system message: " << msg << oendl; + if ( msg == "setCurrentRotation(int)" ) + { + stream >> _newrotation; + odebug << "received setCurrentRotation(" << _newrotation << ")" << oendl; + if (!fullScreen()) { + m_rotation = _newrotation; + return; + } + } } void ImageView::setMenuActions(QActionGroup*hGroup,QActionGroup*nextprevGroup, QActionGroup*disptypeGroup) { m_gDisplayType = disptypeGroup; m_gPrevNext = nextprevGroup; m_hGroup = hGroup; } ImageView::~ImageView() { odebug << "Destructor imageview" << oendl; delete m_viewManager; } Opie::Core::OKeyConfigManager* ImageView::manager() { if (!m_viewManager) { initKeys(); } return m_viewManager; } void ImageView::startSlide(int value) { if (!m_slideTimer) { m_slideTimer = new QTimer(this); } m_slideValue=value; connect(m_slideTimer,SIGNAL(timeout()),SLOT(nextSlide())); /* this "+1" is one millisecond. with that we can setup a slideshowvalue of 0. eg "as fast as possible". @@ -150,102 +180,103 @@ void ImageView::initKeys() void ImageView::keyReleaseEvent(QKeyEvent * e) { if (!e || e->state()!=0) { return; } if (e->key()==Qt::Key_Escape) { if (fullScreen()) { emit hideMe(); } if (closeIfHide) { QTimer::singleShot(0, qApp, SLOT(closeAllWindows())); } } } void ImageView::setCloseIfHide(bool how) { closeIfHide = how; } void ImageView::slotShowImageInfo() { emit dispImageInfo(m_lastName); } void ImageView::contentsMousePressEvent ( QMouseEvent * e) { if (e->button()==1) { return OImageScrollView::contentsMousePressEvent(e); } odebug << "Popup " << oendl; - QPopupMenu *m = new QPopupMenu(0); + QPopupMenu *m = new QPopupMenu(this); if (!m) return; if (m_hGroup) { m_hGroup->addTo(m); } if (fullScreen()) { if (m_gPrevNext) { m->insertSeparator(); m_gPrevNext->addTo(m); } if (m_gDisplayType) { m->insertSeparator(); m_gDisplayType->addTo(m); } } m->setFocus(); m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); if (m_hGroup) { m_hGroup->removeFrom(m); } if (m_gPrevNext) { m_gPrevNext->removeFrom(m); } if (m_gDisplayType) { m_gDisplayType->removeFrom(m); } delete m; } void ImageView::setFullScreen(bool how,bool force) { m_isFullScreen = how; if (how) { m_ignore_next_in = true; - setFixedSize(qApp->desktop()->size()); +// setFixedSize(qApp->desktop()->size()); + setGeometry(0,0,qApp->desktop()->size().width(),qApp->desktop()->size().height()); if (force) showFullScreen(); } else { - setMinimumSize(10,10); +// setMinimumSize(10,10); } } void ImageView::focusInEvent(QFocusEvent *) { // Always do it here, no matter the size. 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::hide() { if (fullScreen()) { m_ignore_next_in = true; showNormal(); } QWidget::hide(); } void ImageView::enableFullscreen() { if (!fullScreen()) return; if (m_ignore_next_in) {m_ignore_next_in = false;return;} setUpdatesEnabled(false); // This is needed because showNormal() forcefully changes the window // style to WSTyle_TopLevel. reparent(0, WStyle_Customize | WStyle_NoBorder, QPoint(0,0)); // Enable fullscreen. /* this is the trick - I don't now why, but after a showFullScreen QTE toggles the focus * so we must block it here! */ diff --git a/noncore/graphics/opie-eye/gui/imageview.h b/noncore/graphics/opie-eye/gui/imageview.h index f1067bb..e8c8df7 100644 --- a/noncore/graphics/opie-eye/gui/imageview.h +++ b/noncore/graphics/opie-eye/gui/imageview.h @@ -1,78 +1,85 @@ #ifndef _IMAGE_VIEW_H #define _IMAGE_VIEW_H #include <opie2/oimagescrollview.h> #include <qwidget.h> class QTimer; class QActionGroup; class QAction; +class QCopChannel; + 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,bool force=true); bool fullScreen(){return m_isFullScreen;} virtual void enableFullscreen(); void stopSlide(); void setMenuActions(QActionGroup*hGroup,QActionGroup*nextprevGroup, QActionGroup*disptypeGroup); void setCloseIfHide(bool); 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_ignore_next_in:1; + bool m_Rotated:1; + int focus_in_count; QTimer*m_slideTimer; int m_slideValue; virtual void focusInEvent ( QFocusEvent * ); QActionGroup *m_gDisplayType,*m_gPrevNext,*m_hGroup; bool closeIfHide:1; + QCopChannel* m_sysChannel; + int m_rotation; public slots: virtual void hide(); virtual void startSlide(int); virtual void nextSlide(); + virtual void systemMessage( const QCString&, const QByteArray& ); 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 7570ee3..90e2e99 100644 --- a/noncore/graphics/opie-eye/gui/mainwindow.cpp +++ b/noncore/graphics/opie-eye/gui/mainwindow.cpp @@ -226,130 +226,136 @@ void PMainWindow::slotConfig() { } } /* * 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->setMinimumSize(QApplication::desktop()->size()/2); } m_disp->setMenuActions(m_hGroup,m_gPrevNext,m_gDisplayType); m_disp->setAutoScale(!m_aUnscaled->isOn()); m_disp->setAutoRotate(m_aAutoRotate->isOn()); m_disp->setShowZoomer(m_aZoomer->isOn()); 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())); connect(m_view,SIGNAL(sig_startslide(int)),m_disp,SLOT(startSlide(int))); slotFullScreenToggled(m_aFullScreen->isOn()); } } void PMainWindow::slotToggleFullScreen() { bool current = !m_aFullScreen->isOn(); m_aFullScreen->setOn(current); } void PMainWindow::slotFullScreenButton(bool current) { if (autoSave) { m_cfg->writeEntry("fullscreen",current); } if (!m_disp) return; if (m_disp->isVisible()) { setupViewWindow(current, true); } } void PMainWindow::setupViewWindow(bool current, bool forceDisplay) { - if (!m_disp) return; + if (!m_disp) { + return; + } if (current) { m_disp->setBackgroundColor(black); m_disp->reparent(0, WStyle_Customize | WStyle_NoBorder, QPoint(0,0)); m_disp->setVScrollBarMode(QScrollView::AlwaysOff); m_disp->setHScrollBarMode(QScrollView::AlwaysOff); m_disp->resize(qApp->desktop()->width(), qApp->desktop()->height()); + m_disp->setFullScreen(current,forceDisplay); } else { setUpdatesEnabled(false); if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) { - m_disp->setMinimumSize(QApplication::desktop()->size()/2); + + //m_disp->setMinimumSize(QApplication::desktop()->size()/2); } else { - m_disp->setMinimumSize(10,10); + //m_disp->setMinimumSize(10,10); } if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) { - m_disp->reparent(0,QPoint(50,50)); + m_disp->reparent(0,QPoint(10,10)); } else { m_disp->reparent(0,QPoint(0,0)); } m_disp->setBackgroundColor(white); m_stack->addWidget(m_disp,ImageDisplay); m_disp->setVScrollBarMode(QScrollView::Auto); m_disp->setHScrollBarMode(QScrollView::Auto); - if (forceDisplay || m_disp->isVisible()) - m_stack->raiseWidget(m_disp); if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) { - m_disp->resize(m_disp->minimumSize()); + m_disp->setGeometry(30,30,QApplication::desktop()->width()-60,QApplication::desktop()->height()-60); + } + if (forceDisplay || m_disp->isVisible()) { + m_stack->raiseWidget(m_disp); + m_disp->setFocus(); } setUpdatesEnabled(true); } m_disp->setFullScreen(current,forceDisplay); } void PMainWindow::slotFullScreenToggled(bool current) { setupViewWindow(current,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) { m_aNext->removeFrom(toolBar); m_aPrevious->removeFrom(toolBar); m_aNext->setEnabled(false); m_aPrevious->setEnabled(false); |