author | alwin <alwin> | 2004-04-13 21:44:12 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-04-13 21:44:12 (UTC) |
commit | e61f3d63c310e4e560bc38f41c1390f246b5f670 (patch) (unidiff) | |
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 | |||
@@ -1,52 +1,52 @@ | |||
1 | #include "imagescrollview.h" | 1 | #include "imagescrollview.h" |
2 | 2 | ||
3 | #include <opie2/odebug.h> | 3 | #include <opie2/odebug.h> |
4 | 4 | ||
5 | using namespace Opie::Core; | 5 | using namespace Opie::Core; |
6 | 6 | ||
7 | #include <qimage.h> | 7 | #include <qimage.h> |
8 | #include <qlayout.h> | 8 | #include <qlayout.h> |
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); |
23 | init(); | 23 | init(); |
24 | } | 24 | } |
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); |
32 | } | 32 | } |
33 | 33 | ||
34 | void ImageScrollView::setImage(const QImage&img) | 34 | void ImageScrollView::setImage(const QImage&img) |
35 | { | 35 | { |
36 | _image_data = QImage(); | 36 | _image_data = QImage(); |
37 | _original_data=img; | 37 | _original_data=img; |
38 | _original_data.convertDepth(QPixmap::defaultDepth()); | 38 | _original_data.convertDepth(QPixmap::defaultDepth()); |
39 | _original_data.setAlphaBuffer(false); | 39 | _original_data.setAlphaBuffer(false); |
40 | m_lastName = ""; | 40 | m_lastName = ""; |
41 | if (first_resize_done) { | 41 | if (first_resize_done) { |
42 | generateImage(); | 42 | generateImage(); |
43 | } | 43 | } |
44 | } | 44 | } |
45 | 45 | ||
46 | void ImageScrollView::setImage( const QString& path ) { | 46 | void ImageScrollView::setImage( const QString& path ) { |
47 | odebug << "load new image " << oendl; | 47 | odebug << "load new image " << oendl; |
48 | if (m_lastName == path) return; | 48 | if (m_lastName == path) return; |
49 | m_lastName = path; | 49 | m_lastName = path; |
50 | _original_data.load(path); | 50 | _original_data.load(path); |
51 | _original_data.convertDepth(QPixmap::defaultDepth()); | 51 | _original_data.convertDepth(QPixmap::defaultDepth()); |
52 | _original_data.setAlphaBuffer(false); | 52 | _original_data.setAlphaBuffer(false); |
@@ -59,50 +59,50 @@ void ImageScrollView::setImage( const QString& path ) { | |||
59 | /* should be called every time the QImage changed it content */ | 59 | /* should be called every time the QImage changed it content */ |
60 | void ImageScrollView::init() | 60 | void ImageScrollView::init() |
61 | { | 61 | { |
62 | odebug << "init " << oendl; | 62 | odebug << "init " << oendl; |
63 | 63 | ||
64 | /* | 64 | /* |
65 | * create the zoomer | 65 | * create the zoomer |
66 | * and connect ther various signals | 66 | * and connect ther various signals |
67 | */ | 67 | */ |
68 | _zoomer = new Opie::MM::OImageZoomer( this, "The Zoomer" ); | 68 | _zoomer = new Opie::MM::OImageZoomer( this, "The Zoomer" ); |
69 | connect(_zoomer, SIGNAL( zoomAreaRel(int,int)), | 69 | connect(_zoomer, SIGNAL( zoomAreaRel(int,int)), |
70 | this, SLOT(scrollBy(int,int)) ); | 70 | this, SLOT(scrollBy(int,int)) ); |
71 | connect(this,SIGNAL(contentsMoving(int,int)), | 71 | connect(this,SIGNAL(contentsMoving(int,int)), |
72 | _zoomer, (SLOT(setVisiblePoint(int,int))) ); | 72 | _zoomer, (SLOT(setVisiblePoint(int,int))) ); |
73 | connect(this,SIGNAL(imageSizeChanged(const QSize&)), | 73 | connect(this,SIGNAL(imageSizeChanged(const QSize&)), |
74 | _zoomer, SLOT(setImageSize(const QSize&)) ); | 74 | _zoomer, SLOT(setImageSize(const QSize&)) ); |
75 | connect(this,SIGNAL(viewportSizeChanged(const QSize&)), | 75 | connect(this,SIGNAL(viewportSizeChanged(const QSize&)), |
76 | _zoomer, SLOT(setViewPortSize(const QSize&)) ); | 76 | _zoomer, SLOT(setViewPortSize(const QSize&)) ); |
77 | 77 | ||
78 | viewport()->setBackgroundColor(white); | 78 | viewport()->setBackgroundColor(white); |
79 | setFocusPolicy(QWidget::StrongFocus); | 79 | setFocusPolicy(QWidget::StrongFocus); |
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 | } |
88 | 88 | ||
89 | void ImageScrollView::setAutoRotate(bool how) | 89 | void ImageScrollView::setAutoRotate(bool how) |
90 | { | 90 | { |
91 | /* to avoid double repaints */ | 91 | /* to avoid double repaints */ |
92 | if (rotate_to_fit != how) { | 92 | if (rotate_to_fit != how) { |
93 | rotate_to_fit = how; | 93 | rotate_to_fit = how; |
94 | _image_data = QImage(); | 94 | _image_data = QImage(); |
95 | generateImage(); | 95 | generateImage(); |
96 | } | 96 | } |
97 | } | 97 | } |
98 | 98 | ||
99 | void ImageScrollView::setAutoScale(bool how) | 99 | void ImageScrollView::setAutoScale(bool how) |
100 | { | 100 | { |
101 | scale_to_fit = how; | 101 | scale_to_fit = how; |
102 | if (!how) { | 102 | if (!how) { |
103 | rotate_to_fit = false; | 103 | rotate_to_fit = false; |
104 | } | 104 | } |
105 | _image_data = QImage(); | 105 | _image_data = QImage(); |
106 | generateImage(); | 106 | generateImage(); |
107 | } | 107 | } |
108 | 108 | ||
@@ -245,74 +245,77 @@ void ImageScrollView::generateImage() | |||
245 | if (rotate_to_fit) r = Rotate90; | 245 | if (rotate_to_fit) r = Rotate90; |
246 | } | 246 | } |
247 | odebug << " r = " << r << oendl; | 247 | odebug << " r = " << r << oendl; |
248 | if (scale_to_fit) { | 248 | if (scale_to_fit) { |
249 | if (!_image_data.size().isValid()||width()>_image_data.width()||height()>_image_data.height()) { | 249 | if (!_image_data.size().isValid()||width()>_image_data.width()||height()>_image_data.height()) { |
250 | odebug << "Rescaling data" << oendl; | 250 | odebug << "Rescaling data" << oendl; |
251 | if (r==Rotate0) { | 251 | if (r==Rotate0) { |
252 | _image_data = _original_data; | 252 | _image_data = _original_data; |
253 | } else { | 253 | } else { |
254 | rotate_into_data(r); | 254 | rotate_into_data(r); |
255 | } | 255 | } |
256 | } | 256 | } |
257 | rescaleImage(width(),height()); | 257 | rescaleImage(width(),height()); |
258 | resizeContents(_image_data.width(),_image_data.height()); | 258 | resizeContents(_image_data.width(),_image_data.height()); |
259 | } else if (!first_resize_done||r!=last_rot||_image_data.width()==0) { | 259 | } else if (!first_resize_done||r!=last_rot||_image_data.width()==0) { |
260 | if (r==Rotate0) { | 260 | if (r==Rotate0) { |
261 | _image_data = _original_data; | 261 | _image_data = _original_data; |
262 | } else { | 262 | } else { |
263 | rotate_into_data(r); | 263 | rotate_into_data(r); |
264 | } | 264 | } |
265 | last_rot = r; | 265 | last_rot = r; |
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 | */ |
280 | _image_data=QImage(); | 287 | _image_data=QImage(); |
281 | } | 288 | } |
282 | 289 | ||
283 | void ImageScrollView::resizeEvent(QResizeEvent * e) | 290 | void ImageScrollView::resizeEvent(QResizeEvent * e) |
284 | { | 291 | { |
285 | odebug << "ImageScrollView resizeEvent" << oendl; | 292 | odebug << "ImageScrollView resizeEvent" << oendl; |
286 | QScrollView::resizeEvent(e); | 293 | QScrollView::resizeEvent(e); |
287 | generateImage(); | 294 | generateImage(); |
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) |
298 | { | 301 | { |
299 | if (!e) return; | 302 | if (!e) return; |
300 | int dx = horizontalScrollBar()->lineStep(); | 303 | int dx = horizontalScrollBar()->lineStep(); |
301 | int dy = verticalScrollBar()->lineStep(); | 304 | int dy = verticalScrollBar()->lineStep(); |
302 | if (e->key()==Qt::Key_Right) { | 305 | if (e->key()==Qt::Key_Right) { |
303 | scrollBy(dx,0); | 306 | scrollBy(dx,0); |
304 | e->accept(); | 307 | e->accept(); |
305 | } else if (e->key()==Qt::Key_Left) { | 308 | } else if (e->key()==Qt::Key_Left) { |
306 | scrollBy(0-dx,0); | 309 | scrollBy(0-dx,0); |
307 | e->accept(); | 310 | e->accept(); |
308 | } else if (e->key()==Qt::Key_Up) { | 311 | } else if (e->key()==Qt::Key_Up) { |
309 | scrollBy(0,0-dy); | 312 | scrollBy(0,0-dy); |
310 | e->accept(); | 313 | e->accept(); |
311 | } else if (e->key()==Qt::Key_Down) { | 314 | } else if (e->key()==Qt::Key_Down) { |
312 | scrollBy(0,dy); | 315 | scrollBy(0,dy); |
313 | e->accept(); | 316 | e->accept(); |
314 | } else { | 317 | } else { |
315 | e->ignore(); | 318 | e->ignore(); |
316 | } | 319 | } |
317 | QScrollView::keyPressEvent(e); | 320 | QScrollView::keyPressEvent(e); |
318 | } | 321 | } |
@@ -377,24 +380,47 @@ void ImageScrollView::viewportMouseMoveEvent(QMouseEvent* e) | |||
377 | } | 380 | } |
378 | _mouseStartPosX=mx; | 381 | _mouseStartPosX=mx; |
379 | _mouseStartPosY=my; | 382 | _mouseStartPosY=my; |
380 | } | 383 | } |
381 | 384 | ||
382 | void ImageScrollView::contentsMousePressEvent ( QMouseEvent * e) | 385 | void ImageScrollView::contentsMousePressEvent ( QMouseEvent * e) |
383 | { | 386 | { |
384 | odebug << " X and Y " << e->x() << " " << e->y() << oendl; | 387 | odebug << " X and Y " << e->x() << " " << e->y() << oendl; |
385 | /* this marks the beginning of a possible mouse move. Due internal reasons of QT | 388 | /* this marks the beginning of a possible mouse move. Due internal reasons of QT |
386 | the geometry values here may real differ from that set in MoveEvent (I don't know | 389 | the geometry values here may real differ from that set in MoveEvent (I don't know |
387 | why). For getting them in real context, we use the first move-event to set the start | 390 | why). For getting them in real context, we use the first move-event to set the start |
388 | position ;) | 391 | position ;) |
389 | */ | 392 | */ |
390 | _mouseStartPosX = -1; | 393 | _mouseStartPosX = -1; |
391 | _mouseStartPosY = -1; | 394 | _mouseStartPosY = -1; |
392 | } | 395 | } |
393 | 396 | ||
394 | void ImageScrollView::setDestructiveClose() { | 397 | void ImageScrollView::setDestructiveClose() { |
395 | WFlags fl = getWFlags(); | 398 | WFlags fl = getWFlags(); |
396 | /* clear it just in case */ | 399 | /* clear it just in case */ |
397 | fl &= ~WDestructiveClose; | 400 | fl &= ~WDestructiveClose; |
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 | |||
@@ -7,65 +7,69 @@ | |||
7 | #include <qimage.h> | 7 | #include <qimage.h> |
8 | #include <qpixmap.h> | 8 | #include <qpixmap.h> |
9 | #include <qstring.h> | 9 | #include <qstring.h> |
10 | #include <qdialog.h> | 10 | #include <qdialog.h> |
11 | 11 | ||
12 | 12 | ||
13 | 13 | ||
14 | class QPainter; | 14 | class QPainter; |
15 | 15 | ||
16 | class ImageScrollView:public QScrollView | 16 | class ImageScrollView:public QScrollView |
17 | { | 17 | { |
18 | Q_OBJECT | 18 | Q_OBJECT |
19 | public: | 19 | public: |
20 | ImageScrollView( QWidget* parent, const char* name = 0, WFlags fl = 0 ); | 20 | ImageScrollView( QWidget* parent, const char* name = 0, WFlags fl = 0 ); |
21 | ImageScrollView (const QImage&, QWidget * parent=0, const char * name=0, WFlags f=0,bool always_scale=false,bool rfit=false ); | 21 | ImageScrollView (const QImage&, QWidget * parent=0, const char * name=0, WFlags f=0,bool always_scale=false,bool rfit=false ); |
22 | ImageScrollView (const QString&, QWidget * parent=0, const char * name=0, WFlags f=0,bool always_scale=false,bool rfit=false ); | 22 | ImageScrollView (const QString&, QWidget * parent=0, const char * name=0, WFlags f=0,bool always_scale=false,bool rfit=false ); |
23 | virtual ~ImageScrollView(); | 23 | virtual ~ImageScrollView(); |
24 | 24 | ||
25 | virtual void setImage(const QImage&); | 25 | virtual void setImage(const QImage&); |
26 | virtual void setImage( const QString& path ); | 26 | virtual void setImage( const QString& path ); |
27 | virtual void setDestructiveClose(); | 27 | virtual void setDestructiveClose(); |
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, |
34 | Rotate90, | 35 | Rotate90, |
35 | Rotate180, | 36 | Rotate180, |
36 | Rotate270 | 37 | Rotate270 |
37 | }; | 38 | }; |
38 | 39 | ||
39 | signals: | 40 | signals: |
40 | void sig_return(); | 41 | void sig_return(); |
41 | void imageSizeChanged( const QSize& ); | 42 | void imageSizeChanged( const QSize& ); |
42 | void viewportSizeChanged( const QSize& ); | 43 | void viewportSizeChanged( const QSize& ); |
43 | 44 | ||
44 | protected: | 45 | protected: |
45 | virtual void drawContents ( QPainter * p, int clipx, int clipy, int clipw, int cliph ); | 46 | virtual void drawContents ( QPainter * p, int clipx, int clipy, int clipw, int cliph ); |
46 | void init(); | 47 | void init(); |
47 | 48 | ||
48 | Opie::MM::OImageZoomer *_zoomer; | 49 | Opie::MM::OImageZoomer *_zoomer; |
49 | QImage _image_data; | 50 | QImage _image_data; |
50 | QImage _original_data; | 51 | QImage _original_data; |
51 | QPixmap _pdata; | 52 | QPixmap _pdata; |
52 | 53 | ||
53 | int _mouseStartPosX,_mouseStartPosY; | 54 | int _mouseStartPosX,_mouseStartPosY; |
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; |
60 | virtual void rescaleImage(int w, int h); | 62 | virtual void rescaleImage(int w, int h); |
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); |
67 | virtual void contentsMousePressEvent ( QMouseEvent * e); | 71 | virtual void contentsMousePressEvent ( QMouseEvent * e); |
68 | virtual void resizeEvent(QResizeEvent * e); | 72 | virtual void resizeEvent(QResizeEvent * e); |
69 | virtual void keyPressEvent(QKeyEvent * e); | 73 | virtual void keyPressEvent(QKeyEvent * e); |
70 | }; | 74 | }; |
71 | #endif | 75 | #endif |
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 | |||
@@ -85,54 +85,68 @@ PMainWindow::PMainWindow(QWidget* wid, const char* name, WFlags style) | |||
85 | btn = new QToolButton( bar ); | 85 | btn = new QToolButton( bar ); |
86 | btn->setIconSet( Resource::loadIconSet( "trash" ) ); | 86 | btn->setIconSet( Resource::loadIconSet( "trash" ) ); |
87 | connect( btn, SIGNAL(clicked() ), | 87 | connect( btn, SIGNAL(clicked() ), |
88 | m_view, SLOT(slotTrash() ) ); | 88 | m_view, SLOT(slotTrash() ) ); |
89 | 89 | ||
90 | btn = new QToolButton( bar ); | 90 | btn = new QToolButton( bar ); |
91 | btn->setIconSet( Resource::loadIconSet( "SettingsIcon" ) ); | 91 | btn->setIconSet( Resource::loadIconSet( "SettingsIcon" ) ); |
92 | connect( btn, SIGNAL(clicked() ), | 92 | connect( btn, SIGNAL(clicked() ), |
93 | this, SLOT(slotConfig() ) ); | 93 | this, SLOT(slotConfig() ) ); |
94 | 94 | ||
95 | rotateButton = new QToolButton(bar); | 95 | rotateButton = new QToolButton(bar); |
96 | rotateButton->setIconSet( Resource::loadIconSet( "rotate" ) ); | 96 | rotateButton->setIconSet( Resource::loadIconSet( "rotate" ) ); |
97 | rotateButton->setToggleButton(true); | 97 | rotateButton->setToggleButton(true); |
98 | rotateButton->setOn(true); | 98 | rotateButton->setOn(true); |
99 | connect(rotateButton,SIGNAL(toggled(bool)),this,SLOT(slotRotateToggled(bool))); | 99 | connect(rotateButton,SIGNAL(toggled(bool)),this,SLOT(slotRotateToggled(bool))); |
100 | autoRotate = true; | 100 | autoRotate = true; |
101 | 101 | ||
102 | btn = new QToolButton(bar); | 102 | btn = new QToolButton(bar); |
103 | btn->setIconSet( Resource::loadIconSet( "1to1" ) ); | 103 | btn->setIconSet( Resource::loadIconSet( "1to1" ) ); |
104 | btn->setToggleButton(true); | 104 | btn->setToggleButton(true); |
105 | btn->setOn(false); | 105 | btn->setOn(false); |
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; |
118 | if (m_disp) { | 132 | if (m_disp) { |
119 | m_disp->setAutoRotate(how); | 133 | m_disp->setAutoRotate(how); |
120 | } | 134 | } |
121 | } | 135 | } |
122 | 136 | ||
123 | void PMainWindow::slotScaleToggled(bool how) | 137 | void PMainWindow::slotScaleToggled(bool how) |
124 | { | 138 | { |
125 | autoScale = !how; | 139 | autoScale = !how; |
126 | if (m_disp) { | 140 | if (m_disp) { |
127 | m_disp->setAutoScale(autoScale); | 141 | m_disp->setAutoScale(autoScale); |
128 | } | 142 | } |
129 | if (!autoScale && autoRotate) { | 143 | if (!autoScale && autoRotate) { |
130 | rotateButton->setOn(false); | 144 | rotateButton->setOn(false); |
131 | } | 145 | } |
132 | rotateButton->setEnabled(!how); | 146 | rotateButton->setEnabled(!how); |
133 | } | 147 | } |
134 | 148 | ||
135 | void PMainWindow::slotConfig() { | 149 | void PMainWindow::slotConfig() { |
136 | /* | 150 | /* |
137 | * have a tab with the possible views | 151 | * have a tab with the possible views |
138 | * a tab for globals image cache size.. scaled loading | 152 | * a tab for globals image cache size.. scaled loading |
@@ -210,48 +224,49 @@ void PMainWindow::slotConfig() { | |||
210 | */ | 224 | */ |
211 | template<class T> | 225 | template<class T> |
212 | void PMainWindow::initT( const char* name, T** ptr, int id) { | 226 | void PMainWindow::initT( const char* name, T** ptr, int id) { |
213 | if ( *ptr ) { | 227 | if ( *ptr ) { |
214 | (*ptr)->disconnect(this, SLOT(slotReturn())); | 228 | (*ptr)->disconnect(this, SLOT(slotReturn())); |
215 | (*ptr)->setDestructiveClose(); | 229 | (*ptr)->setDestructiveClose(); |
216 | m_stack->removeWidget( *ptr ); | 230 | m_stack->removeWidget( *ptr ); |
217 | } | 231 | } |
218 | *ptr = new T(m_cfg, m_stack, name ); | 232 | *ptr = new T(m_cfg, m_stack, name ); |
219 | m_stack->addWidget( *ptr, id ); | 233 | m_stack->addWidget( *ptr, id ); |
220 | 234 | ||
221 | connect(*ptr, SIGNAL(sig_return()), | 235 | connect(*ptr, SIGNAL(sig_return()), |
222 | this,SLOT(slotReturn())); | 236 | this,SLOT(slotReturn())); |
223 | 237 | ||
224 | } | 238 | } |
225 | void PMainWindow::initInfo() { | 239 | void PMainWindow::initInfo() { |
226 | initT<imageinfo>( "Image Info", &m_info, ImageInfo ); | 240 | initT<imageinfo>( "Image Info", &m_info, ImageInfo ); |
227 | connect(m_info,SIGNAL(dispImage(const QString&)),this,SLOT(slotDisplay(const QString&))); | 241 | connect(m_info,SIGNAL(dispImage(const QString&)),this,SLOT(slotDisplay(const QString&))); |
228 | } | 242 | } |
229 | void PMainWindow::initDisp() { | 243 | void PMainWindow::initDisp() { |
230 | initT<ImageView>( "Image ScrollView", &m_disp, ImageDisplay ); | 244 | initT<ImageView>( "Image ScrollView", &m_disp, ImageDisplay ); |
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 | } |
237 | 252 | ||
238 | /** | 253 | /** |
239 | * With big Screen the plan could be to 'detach' the image | 254 | * With big Screen the plan could be to 'detach' the image |
240 | * window if visible and to create a ne wone | 255 | * window if visible and to create a ne wone |
241 | * init* already supports it but I make no use of it for | 256 | * init* already supports it but I make no use of it for |
242 | * now. We set filename and raise | 257 | * now. We set filename and raise |
243 | * | 258 | * |
244 | * ### FIXME and talk to alwin | 259 | * ### FIXME and talk to alwin |
245 | */ | 260 | */ |
246 | void PMainWindow::slotShowInfo( const QString& inf ) { | 261 | void PMainWindow::slotShowInfo( const QString& inf ) { |
247 | if ( !m_info ) { | 262 | if ( !m_info ) { |
248 | initInfo(); | 263 | initInfo(); |
249 | } | 264 | } |
250 | m_info->setPath( inf ); | 265 | m_info->setPath( inf ); |
251 | m_stack->raiseWidget( ImageInfo ); | 266 | m_stack->raiseWidget( ImageInfo ); |
252 | } | 267 | } |
253 | 268 | ||
254 | void PMainWindow::slotDisplay( const QString& inf ) { | 269 | void PMainWindow::slotDisplay( const QString& inf ) { |
255 | if ( !m_disp ) { | 270 | if ( !m_disp ) { |
256 | initDisp(); | 271 | initDisp(); |
257 | } | 272 | } |
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 | |||
@@ -20,51 +20,53 @@ namespace Core{ | |||
20 | class OKeyConfigManager; | 20 | class OKeyConfigManager; |
21 | } | 21 | } |
22 | } | 22 | } |
23 | 23 | ||
24 | class PIconView; | 24 | class PIconView; |
25 | class imageinfo; | 25 | class imageinfo; |
26 | class ImageView; | 26 | class ImageView; |
27 | class PMainWindow : public QMainWindow { | 27 | class PMainWindow : public QMainWindow { |
28 | Q_OBJECT | 28 | Q_OBJECT |
29 | enum Views { IconView, ImageInfo, ImageDisplay }; | 29 | enum Views { IconView, ImageInfo, ImageDisplay }; |
30 | public: | 30 | public: |
31 | static QString appName() { return QString::fromLatin1("opie-eye" ); } | 31 | static QString appName() { return QString::fromLatin1("opie-eye" ); } |
32 | PMainWindow(QWidget*, const char*, WFlags ); | 32 | PMainWindow(QWidget*, const char*, WFlags ); |
33 | ~PMainWindow(); | 33 | ~PMainWindow(); |
34 | 34 | ||
35 | signals: | 35 | signals: |
36 | void configChanged(); | 36 | void configChanged(); |
37 | 37 | ||
38 | public slots: | 38 | public slots: |
39 | void slotShowInfo( const QString& inf ); | 39 | void slotShowInfo( const QString& inf ); |
40 | void slotDisplay( const QString& inf ); | 40 | void slotDisplay( const QString& inf ); |
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: |
47 | void raiseIconView(); | 48 | void raiseIconView(); |
48 | void closeEvent( QCloseEvent* ); | 49 | void closeEvent( QCloseEvent* ); |
49 | 50 | ||
50 | private: | 51 | private: |
51 | template<class T> void initT( const char* name, T**, int ); | 52 | template<class T> void initT( const char* name, T**, int ); |
52 | void initInfo(); | 53 | void initInfo(); |
53 | void initDisp(); | 54 | void initDisp(); |
54 | 55 | ||
55 | private: | 56 | private: |
56 | Opie::Core::OConfig *m_cfg; | 57 | Opie::Core::OConfig *m_cfg; |
57 | Opie::Ui::OWidgetStack *m_stack; | 58 | Opie::Ui::OWidgetStack *m_stack; |
58 | PIconView* m_view; | 59 | PIconView* m_view; |
59 | imageinfo *m_info; | 60 | imageinfo *m_info; |
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 | ||
66 | private slots: | 68 | private slots: |
67 | void slotConfig(); | 69 | void slotConfig(); |
68 | }; | 70 | }; |
69 | 71 | ||
70 | #endif | 72 | #endif |