summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/graphics/opie-eye/gui/imagescrollview.cpp44
-rw-r--r--noncore/graphics/opie-eye/gui/imagescrollview.h4
-rw-r--r--noncore/graphics/opie-eye/gui/mainwindow.cpp15
-rw-r--r--noncore/graphics/opie-eye/gui/mainwindow.h2
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;
10ImageScrollView::ImageScrollView( QWidget* parent, const char* name, WFlags f ) 10ImageScrollView::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();
@@ -17,5 +17,5 @@ ImageScrollView::ImageScrollView( QWidget* parent, const char* name, WFlags f )
17ImageScrollView::ImageScrollView (const QImage&img, QWidget * parent, const char * name, WFlags f,bool always_scale,bool rfit) 17ImageScrollView::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());
@@ -26,5 +26,5 @@ ImageScrollView::ImageScrollView (const QImage&img, QWidget * parent, const char
26ImageScrollView::ImageScrollView (const QString&img, QWidget * parent, const char * name, WFlags f,bool always_scale,bool rfit) 26ImageScrollView::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();
@@ -81,6 +81,6 @@ void ImageScrollView::init()
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 }
@@ -267,12 +267,19 @@ void ImageScrollView::generateImage()
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
@@ -289,8 +296,4 @@ void ImageScrollView::resizeEvent(QResizeEvent * e)
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
@@ -399,2 +402,25 @@ void ImageScrollView::setDestructiveClose() {
399 setWFlags( fl ); 402 setWFlags( fl );
400} 403}
404
405bool 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
413void ImageScrollView::setShowZoomer(bool how)
414{
415 show_zoomer = how;
416 check_zoomer();
417}
418
419void 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
@@ -29,4 +29,5 @@ public:
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 {
@@ -55,4 +56,5 @@ protected:
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;
@@ -62,4 +64,6 @@ protected:
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
65protected slots: 69protected 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)
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
@@ -113,4 +119,12 @@ PMainWindow::~PMainWindow() {
113} 119}
114 120
121void PMainWindow::slotZoomerToggled(bool how)
122{
123 zoomerOn = how;
124 if (m_disp) {
125 m_disp->setShowZoomer(zoomerOn);
126 }
127}
128
115void PMainWindow::slotRotateToggled(bool how) 129void PMainWindow::slotRotateToggled(bool how)
116{ 130{
@@ -232,4 +246,5 @@ void PMainWindow::initDisp() {
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 }
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:
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
@@ -61,4 +62,5 @@ private:
61 bool autoRotate; 62 bool autoRotate;
62 bool autoScale; 63 bool autoScale;
64 bool zoomerOn;
63 QToolButton*rotateButton; 65 QToolButton*rotateButton;
64 66