author | alwin <alwin> | 2004-04-13 21:44:12 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-04-13 21:44:12 (UTC) |
commit | e61f3d63c310e4e560bc38f41c1390f246b5f670 (patch) (side-by-side diff) | |
tree | 2403a3b3ba1a47e6122d259b6b761f45c37f504d | |
parent | 482750c5b2494b7b2b94c13bf4743349b67d188a (diff) | |
download | opie-e61f3d63c310e4e560bc38f41c1390f246b5f670.zip opie-e61f3d63c310e4e560bc38f41c1390f246b5f670.tar.gz opie-e61f3d63c310e4e560bc38f41c1390f246b5f670.tar.bz2 |
zoomer widget better integrated, size of it depends on the size of the displayed image,
may switched off by user and so on.
-rw-r--r-- | noncore/graphics/opie-eye/gui/imagescrollview.cpp | 44 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/imagescrollview.h | 4 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/mainwindow.cpp | 15 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/mainwindow.h | 2 |
4 files changed, 56 insertions, 9 deletions
diff --git a/noncore/graphics/opie-eye/gui/imagescrollview.cpp b/noncore/graphics/opie-eye/gui/imagescrollview.cpp index 5b12258..2f16d82 100644 --- a/noncore/graphics/opie-eye/gui/imagescrollview.cpp +++ b/noncore/graphics/opie-eye/gui/imagescrollview.cpp @@ -10,5 +10,5 @@ using namespace Opie::Core; ImageScrollView::ImageScrollView( QWidget* parent, const char* name, WFlags f ) :QScrollView(parent,name,f|Qt::WRepaintNoErase ),_image_data(),_original_data(),scale_to_fit(true), - rotate_to_fit(true),first_resize_done(false),m_lastName("") + rotate_to_fit(true),show_zoomer(true),first_resize_done(false),m_lastName("") { init(); @@ -17,5 +17,5 @@ ImageScrollView::ImageScrollView( QWidget* parent, const char* name, WFlags f ) ImageScrollView::ImageScrollView (const QImage&img, QWidget * parent, const char * name, WFlags f,bool always_scale,bool rfit) :QScrollView(parent,name,f|Qt::WRepaintNoErase),_image_data(),_original_data(img),scale_to_fit(always_scale), - rotate_to_fit(rfit),first_resize_done(false),m_lastName("") + rotate_to_fit(rfit),show_zoomer(true),first_resize_done(false),m_lastName("") { _original_data.convertDepth(QPixmap::defaultDepth()); @@ -26,5 +26,5 @@ ImageScrollView::ImageScrollView (const QImage&img, QWidget * parent, const char ImageScrollView::ImageScrollView (const QString&img, QWidget * parent, const char * name, WFlags f,bool always_scale,bool rfit) :QScrollView(parent,name,f|Qt::WRepaintNoErase),_image_data(),_original_data(),scale_to_fit(always_scale), - rotate_to_fit(rfit),first_resize_done(false),m_lastName("") + rotate_to_fit(rfit),show_zoomer(true),first_resize_done(false),m_lastName("") { init(); @@ -81,6 +81,6 @@ void ImageScrollView::init() last_rot = Rotate0; generateImage(); - odebug << "reinit display " << oendl; } else if (_original_data.size().isValid()) { + if (image_fit_into(_original_data.size()) || !show_zoomer) _zoomer->hide(); resizeContents(_original_data.width(),_original_data.height()); } @@ -268,11 +268,18 @@ void ImageScrollView::generateImage() _pdata.convertFromImage(_image_data); + /* * update the zoomer */ + check_zoomer(); emit imageSizeChanged( _image_data.size() ); rescaleImage( 128, 128 ); - _zoomer->setImage( _image_data ); + /* + * move scrollbar + */ + _zoomer->setGeometry( viewport()->width()-_image_data.width()/2, viewport()->height()-_image_data.height()/2, + _image_data.width()/2, _image_data.height()/2 ); + _zoomer->setImage( _image_data ); /* * invalidate @@ -289,8 +296,4 @@ void ImageScrollView::resizeEvent(QResizeEvent * e) emit viewportSizeChanged( viewport()->size() ); - /* - * move scrollbar - */ - _zoomer->setGeometry( viewport()->width()-100, viewport()->height()-50, 100, 50 ); } @@ -399,2 +402,25 @@ void ImageScrollView::setDestructiveClose() { setWFlags( fl ); } + +bool ImageScrollView::image_fit_into(const QSize&s ) +{ + if (s.width()>width()||s.height()>height()) { + return false; + } + return true; +} + +void ImageScrollView::setShowZoomer(bool how) +{ + show_zoomer = how; + check_zoomer(); +} + +void ImageScrollView::check_zoomer() +{ + if ( (!show_zoomer||image_fit_into(_pdata.size()) ) && _zoomer->isVisible()) { + _zoomer->hide(); + } else if ( show_zoomer && !image_fit_into(_pdata.size()) && _zoomer->isHidden()){ + _zoomer->show(); + } +} diff --git a/noncore/graphics/opie-eye/gui/imagescrollview.h b/noncore/graphics/opie-eye/gui/imagescrollview.h index 1b25103..e209dfb 100644 --- a/noncore/graphics/opie-eye/gui/imagescrollview.h +++ b/noncore/graphics/opie-eye/gui/imagescrollview.h @@ -29,4 +29,5 @@ public: virtual void setAutoRotate(bool); virtual void setAutoScale(bool); + virtual void setShowZoomer(bool); enum Rotation { @@ -55,4 +56,5 @@ protected: bool scale_to_fit; bool rotate_to_fit; + bool show_zoomer; bool first_resize_done; Rotation last_rot; @@ -62,4 +64,6 @@ protected: virtual void rotate_into_data(Rotation r); virtual void generateImage(); + bool image_fit_into(const QSize&s); + void check_zoomer(); protected slots: diff --git a/noncore/graphics/opie-eye/gui/mainwindow.cpp b/noncore/graphics/opie-eye/gui/mainwindow.cpp index 3650493..ef23f79 100644 --- a/noncore/graphics/opie-eye/gui/mainwindow.cpp +++ b/noncore/graphics/opie-eye/gui/mainwindow.cpp @@ -107,4 +107,10 @@ PMainWindow::PMainWindow(QWidget* wid, const char* name, WFlags style) 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))); + zoomerOn = true; } @@ -113,4 +119,12 @@ PMainWindow::~PMainWindow() { } +void PMainWindow::slotZoomerToggled(bool how) +{ + zoomerOn = how; + if (m_disp) { + m_disp->setShowZoomer(zoomerOn); + } +} + void PMainWindow::slotRotateToggled(bool how) { @@ -232,4 +246,5 @@ void PMainWindow::initDisp() { m_disp->setAutoScale(autoScale); m_disp->setAutoRotate(autoRotate); + m_disp->setShowZoomer(zoomerOn); connect(m_disp,SIGNAL(dispImageInfo(const QString&)),this,SLOT(slotShowInfo(const QString&))); } diff --git a/noncore/graphics/opie-eye/gui/mainwindow.h b/noncore/graphics/opie-eye/gui/mainwindow.h index 59dba30..e9b16d0 100644 --- a/noncore/graphics/opie-eye/gui/mainwindow.h +++ b/noncore/graphics/opie-eye/gui/mainwindow.h @@ -42,4 +42,5 @@ public slots: void slotRotateToggled(bool); void slotScaleToggled(bool); + void slotZoomerToggled(bool); void setDocument( const QString& ); @@ -61,4 +62,5 @@ private: bool autoRotate; bool autoScale; + bool zoomerOn; QToolButton*rotateButton; |