-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 | |||
@@ -9,14 +9,14 @@ using namespace Opie::Core; | |||
9 | 9 | ||
10 | ImageScrollView::ImageScrollView( QWidget* parent, const char* name, WFlags f ) | 10 | ImageScrollView::ImageScrollView( QWidget* parent, const char* name, WFlags f ) |
11 | :QScrollView(parent,name,f|Qt::WRepaintNoErase ),_image_data(),_original_data(),scale_to_fit(true), | 11 | :QScrollView(parent,name,f|Qt::WRepaintNoErase ),_image_data(),_original_data(),scale_to_fit(true), |
12 | rotate_to_fit(true),first_resize_done(false),m_lastName("") | 12 | rotate_to_fit(true),show_zoomer(true),first_resize_done(false),m_lastName("") |
13 | { | 13 | { |
14 | init(); | 14 | init(); |
15 | } | 15 | } |
16 | 16 | ||
17 | ImageScrollView::ImageScrollView (const QImage&img, QWidget * parent, const char * name, WFlags f,bool always_scale,bool rfit) | 17 | ImageScrollView::ImageScrollView (const QImage&img, QWidget * parent, const char * name, WFlags f,bool always_scale,bool rfit) |
18 | :QScrollView(parent,name,f|Qt::WRepaintNoErase),_image_data(),_original_data(img),scale_to_fit(always_scale), | 18 | :QScrollView(parent,name,f|Qt::WRepaintNoErase),_image_data(),_original_data(img),scale_to_fit(always_scale), |
19 | rotate_to_fit(rfit),first_resize_done(false),m_lastName("") | 19 | rotate_to_fit(rfit),show_zoomer(true),first_resize_done(false),m_lastName("") |
20 | { | 20 | { |
21 | _original_data.convertDepth(QPixmap::defaultDepth()); | 21 | _original_data.convertDepth(QPixmap::defaultDepth()); |
22 | _original_data.setAlphaBuffer(false); | 22 | _original_data.setAlphaBuffer(false); |
@@ -25,7 +25,7 @@ ImageScrollView::ImageScrollView (const QImage&img, QWidget * parent, const char | |||
25 | 25 | ||
26 | ImageScrollView::ImageScrollView (const QString&img, QWidget * parent, const char * name, WFlags f,bool always_scale,bool rfit) | 26 | ImageScrollView::ImageScrollView (const QString&img, QWidget * parent, const char * name, WFlags f,bool always_scale,bool rfit) |
27 | :QScrollView(parent,name,f|Qt::WRepaintNoErase),_image_data(),_original_data(),scale_to_fit(always_scale), | 27 | :QScrollView(parent,name,f|Qt::WRepaintNoErase),_image_data(),_original_data(),scale_to_fit(always_scale), |
28 | rotate_to_fit(rfit),first_resize_done(false),m_lastName("") | 28 | rotate_to_fit(rfit),show_zoomer(true),first_resize_done(false),m_lastName("") |
29 | { | 29 | { |
30 | init(); | 30 | init(); |
31 | setImage(img); | 31 | setImage(img); |
@@ -80,8 +80,8 @@ void ImageScrollView::init() | |||
80 | if (first_resize_done) { | 80 | if (first_resize_done) { |
81 | last_rot = Rotate0; | 81 | last_rot = Rotate0; |
82 | generateImage(); | 82 | generateImage(); |
83 | odebug << "reinit display " << oendl; | ||
84 | } else if (_original_data.size().isValid()) { | 83 | } else if (_original_data.size().isValid()) { |
84 | if (image_fit_into(_original_data.size()) || !show_zoomer) _zoomer->hide(); | ||
85 | resizeContents(_original_data.width(),_original_data.height()); | 85 | resizeContents(_original_data.width(),_original_data.height()); |
86 | } | 86 | } |
87 | } | 87 | } |
@@ -266,14 +266,21 @@ void ImageScrollView::generateImage() | |||
266 | resizeContents(_image_data.width(),_image_data.height()); | 266 | resizeContents(_image_data.width(),_image_data.height()); |
267 | } | 267 | } |
268 | _pdata.convertFromImage(_image_data); | 268 | _pdata.convertFromImage(_image_data); |
269 | |||
269 | 270 | ||
270 | /* | 271 | /* |
271 | * update the zoomer | 272 | * update the zoomer |
272 | */ | 273 | */ |
274 | check_zoomer(); | ||
273 | emit imageSizeChanged( _image_data.size() ); | 275 | emit imageSizeChanged( _image_data.size() ); |
274 | rescaleImage( 128, 128 ); | 276 | rescaleImage( 128, 128 ); |
277 | /* | ||
278 | * move scrollbar | ||
279 | */ | ||
280 | _zoomer->setGeometry( viewport()->width()-_image_data.width()/2, viewport()->height()-_image_data.height()/2, | ||
281 | _image_data.width()/2, _image_data.height()/2 ); | ||
282 | |||
275 | _zoomer->setImage( _image_data ); | 283 | _zoomer->setImage( _image_data ); |
276 | |||
277 | /* | 284 | /* |
278 | * invalidate | 285 | * invalidate |
279 | */ | 286 | */ |
@@ -288,10 +295,6 @@ void ImageScrollView::resizeEvent(QResizeEvent * e) | |||
288 | first_resize_done = true; | 295 | first_resize_done = true; |
289 | emit viewportSizeChanged( viewport()->size() ); | 296 | emit viewportSizeChanged( viewport()->size() ); |
290 | 297 | ||
291 | /* | ||
292 | * move scrollbar | ||
293 | */ | ||
294 | _zoomer->setGeometry( viewport()->width()-100, viewport()->height()-50, 100, 50 ); | ||
295 | } | 298 | } |
296 | 299 | ||
297 | void ImageScrollView::keyPressEvent(QKeyEvent * e) | 300 | void ImageScrollView::keyPressEvent(QKeyEvent * e) |
@@ -398,3 +401,26 @@ void ImageScrollView::setDestructiveClose() { | |||
398 | fl |= WDestructiveClose; | 401 | fl |= WDestructiveClose; |
399 | setWFlags( fl ); | 402 | setWFlags( fl ); |
400 | } | 403 | } |
404 | |||
405 | bool ImageScrollView::image_fit_into(const QSize&s ) | ||
406 | { | ||
407 | if (s.width()>width()||s.height()>height()) { | ||
408 | return false; | ||
409 | } | ||
410 | return true; | ||
411 | } | ||
412 | |||
413 | void ImageScrollView::setShowZoomer(bool how) | ||
414 | { | ||
415 | show_zoomer = how; | ||
416 | check_zoomer(); | ||
417 | } | ||
418 | |||
419 | void ImageScrollView::check_zoomer() | ||
420 | { | ||
421 | if ( (!show_zoomer||image_fit_into(_pdata.size()) ) && _zoomer->isVisible()) { | ||
422 | _zoomer->hide(); | ||
423 | } else if ( show_zoomer && !image_fit_into(_pdata.size()) && _zoomer->isHidden()){ | ||
424 | _zoomer->show(); | ||
425 | } | ||
426 | } | ||
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 | |||
@@ -28,6 +28,7 @@ public: | |||
28 | 28 | ||
29 | virtual void setAutoRotate(bool); | 29 | virtual void setAutoRotate(bool); |
30 | virtual void setAutoScale(bool); | 30 | virtual void setAutoScale(bool); |
31 | virtual void setShowZoomer(bool); | ||
31 | 32 | ||
32 | enum Rotation { | 33 | enum Rotation { |
33 | Rotate0, | 34 | Rotate0, |
@@ -54,6 +55,7 @@ protected: | |||
54 | 55 | ||
55 | bool scale_to_fit; | 56 | bool scale_to_fit; |
56 | bool rotate_to_fit; | 57 | bool rotate_to_fit; |
58 | bool show_zoomer; | ||
57 | bool first_resize_done; | 59 | bool first_resize_done; |
58 | Rotation last_rot; | 60 | Rotation last_rot; |
59 | QString m_lastName; | 61 | QString m_lastName; |
@@ -61,6 +63,8 @@ protected: | |||
61 | 63 | ||
62 | virtual void rotate_into_data(Rotation r); | 64 | virtual void rotate_into_data(Rotation r); |
63 | virtual void generateImage(); | 65 | virtual void generateImage(); |
66 | bool image_fit_into(const QSize&s); | ||
67 | void check_zoomer(); | ||
64 | 68 | ||
65 | protected slots: | 69 | protected slots: |
66 | virtual void viewportMouseMoveEvent(QMouseEvent* e); | 70 | virtual void viewportMouseMoveEvent(QMouseEvent* e); |
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 | |||
@@ -106,12 +106,26 @@ PMainWindow::PMainWindow(QWidget* wid, const char* name, WFlags style) | |||
106 | connect(btn,SIGNAL(toggled(bool)),this,SLOT(slotScaleToggled(bool))); | 106 | connect(btn,SIGNAL(toggled(bool)),this,SLOT(slotScaleToggled(bool))); |
107 | autoScale = true; | 107 | autoScale = true; |
108 | 108 | ||
109 | btn = new QToolButton(bar); | ||
110 | btn->setIconSet( Resource::loadIconSet( "mag" ) ); | ||
111 | btn->setToggleButton(true); | ||
112 | btn->setOn(true); | ||
113 | connect(btn,SIGNAL(toggled(bool)),this,SLOT(slotZoomerToggled(bool))); | ||
114 | zoomerOn = true; | ||
109 | } | 115 | } |
110 | 116 | ||
111 | PMainWindow::~PMainWindow() { | 117 | PMainWindow::~PMainWindow() { |
112 | odebug << "Shutting down" << oendl; | 118 | odebug << "Shutting down" << oendl; |
113 | } | 119 | } |
114 | 120 | ||
121 | void PMainWindow::slotZoomerToggled(bool how) | ||
122 | { | ||
123 | zoomerOn = how; | ||
124 | if (m_disp) { | ||
125 | m_disp->setShowZoomer(zoomerOn); | ||
126 | } | ||
127 | } | ||
128 | |||
115 | void PMainWindow::slotRotateToggled(bool how) | 129 | void PMainWindow::slotRotateToggled(bool how) |
116 | { | 130 | { |
117 | autoRotate = how; | 131 | autoRotate = how; |
@@ -231,6 +245,7 @@ void PMainWindow::initDisp() { | |||
231 | if (m_disp) { | 245 | if (m_disp) { |
232 | m_disp->setAutoScale(autoScale); | 246 | m_disp->setAutoScale(autoScale); |
233 | m_disp->setAutoRotate(autoRotate); | 247 | m_disp->setAutoRotate(autoRotate); |
248 | m_disp->setShowZoomer(zoomerOn); | ||
234 | connect(m_disp,SIGNAL(dispImageInfo(const QString&)),this,SLOT(slotShowInfo(const QString&))); | 249 | connect(m_disp,SIGNAL(dispImageInfo(const QString&)),this,SLOT(slotShowInfo(const QString&))); |
235 | } | 250 | } |
236 | } | 251 | } |
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 | |||
@@ -41,6 +41,7 @@ public slots: | |||
41 | void slotReturn(); | 41 | void slotReturn(); |
42 | void slotRotateToggled(bool); | 42 | void slotRotateToggled(bool); |
43 | void slotScaleToggled(bool); | 43 | void slotScaleToggled(bool); |
44 | void slotZoomerToggled(bool); | ||
44 | void setDocument( const QString& ); | 45 | void setDocument( const QString& ); |
45 | 46 | ||
46 | protected: | 47 | protected: |
@@ -60,6 +61,7 @@ private: | |||
60 | ImageView *m_disp; | 61 | ImageView *m_disp; |
61 | bool autoRotate; | 62 | bool autoRotate; |
62 | bool autoScale; | 63 | bool autoScale; |
64 | bool zoomerOn; | ||
63 | QToolButton*rotateButton; | 65 | QToolButton*rotateButton; |
64 | 66 | ||
65 | 67 | ||