-rw-r--r-- | noncore/graphics/opie-eye/gui/imagescrollview.cpp | 212 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/imagescrollview.h | 65 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/imageview.cpp | 3 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/imageview.h | 3 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/mainwindow.cpp | 2 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/mainwindow.h | 3 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/lib/oimagezoomer.cpp | 18 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/lib/oimagezoomer.h | 13 |
8 files changed, 221 insertions, 98 deletions
diff --git a/noncore/graphics/opie-eye/gui/imagescrollview.cpp b/noncore/graphics/opie-eye/gui/imagescrollview.cpp index d034ee0..3bb07a7 100644 --- a/noncore/graphics/opie-eye/gui/imagescrollview.cpp +++ b/noncore/graphics/opie-eye/gui/imagescrollview.cpp | |||
@@ -2,2 +2,4 @@ | |||
2 | 2 | ||
3 | #include "lib/oimagezoomer.h" | ||
4 | |||
3 | #include <opie2/odebug.h> | 5 | #include <opie2/odebug.h> |
@@ -6,4 +8,2 @@ | |||
6 | 8 | ||
7 | using namespace Opie::Core; | ||
8 | |||
9 | #include <qimage.h> | 9 | #include <qimage.h> |
@@ -12,6 +12,25 @@ using namespace Opie::Core; | |||
12 | 12 | ||
13 | ImageScrollView::ImageScrollView( QWidget* parent, const char* name, WFlags f ) | 13 | /* for usage with the bitset */ |
14 | :QScrollView(parent,name,f|Qt::WRepaintNoErase ),_image_data(),_original_data(),scale_to_fit(true), | 14 | #define AUTO_SCALE 0 |
15 | rotate_to_fit(true),show_zoomer(true),first_resize_done(false),m_lastName("") | 15 | #define AUTO_ROTATE 1 |
16 | #define SHOW_ZOOMER 2 | ||
17 | #define FIRST_RESIZE_DONE 3 | ||
18 | #define IMAGE_IS_JPEG 4 | ||
19 | #define IMAGE_SCALED_LOADED 5 | ||
20 | |||
21 | #define SCROLLVIEW_BITSET_SIZE 6 | ||
22 | |||
23 | namespace Opie { | ||
24 | namespace MM { | ||
25 | OImageScrollView::OImageScrollView( QWidget* parent, const char* name, WFlags f ) | ||
26 | :QScrollView(parent,name,f|Qt::WRepaintNoErase ),_image_data(),_original_data(), | ||
27 | m_states(SCROLLVIEW_BITSET_SIZE),m_lastName("") | ||
16 | { | 28 | { |
29 | _zoomer = 0; | ||
30 | m_states[AUTO_SCALE]=true; | ||
31 | m_states[AUTO_ROTATE]=true; | ||
32 | m_states[FIRST_RESIZE_DONE]=false; | ||
33 | m_states[IMAGE_IS_JPEG]=false; | ||
34 | m_states[IMAGE_SCALED_LOADED]=false; | ||
35 | m_states[SHOW_ZOOMER]=true; | ||
17 | init(); | 36 | init(); |
@@ -19,6 +38,13 @@ ImageScrollView::ImageScrollView( QWidget* parent, const char* name, WFlags f ) | |||
19 | 38 | ||
20 | ImageScrollView::ImageScrollView (const QImage&img, QWidget * parent, const char * name, WFlags f,bool always_scale,bool rfit) | 39 | OImageScrollView::OImageScrollView (const QImage&img, QWidget * parent, const char * name, WFlags f,bool always_scale,bool rfit) |
21 | :QScrollView(parent,name,f|Qt::WRepaintNoErase),_image_data(),_original_data(img),scale_to_fit(always_scale), | 40 | :QScrollView(parent,name,f|Qt::WRepaintNoErase),_image_data(),_original_data(img), |
22 | rotate_to_fit(rfit),show_zoomer(true),first_resize_done(false),m_lastName("") | 41 | m_states(SCROLLVIEW_BITSET_SIZE),m_lastName("") |
23 | { | 42 | { |
43 | _zoomer = 0; | ||
44 | m_states[AUTO_SCALE]=always_scale; | ||
45 | m_states[AUTO_ROTATE]=rfit; | ||
46 | m_states[FIRST_RESIZE_DONE]=false; | ||
47 | m_states[IMAGE_IS_JPEG]=false; | ||
48 | m_states[IMAGE_SCALED_LOADED]=false; | ||
49 | m_states[SHOW_ZOOMER]=true; | ||
24 | _original_data.convertDepth(QPixmap::defaultDepth()); | 50 | _original_data.convertDepth(QPixmap::defaultDepth()); |
@@ -28,6 +54,13 @@ ImageScrollView::ImageScrollView (const QImage&img, QWidget * parent, const char | |||
28 | 54 | ||
29 | ImageScrollView::ImageScrollView (const QString&img, QWidget * parent, const char * name, WFlags f,bool always_scale,bool rfit) | 55 | OImageScrollView::OImageScrollView (const QString&img, QWidget * parent, const char * name, WFlags f,bool always_scale,bool rfit) |
30 | :QScrollView(parent,name,f|Qt::WRepaintNoErase),_image_data(),_original_data(),scale_to_fit(always_scale), | 56 | :QScrollView(parent,name,f|Qt::WRepaintNoErase),_image_data(),_original_data(),m_states(SCROLLVIEW_BITSET_SIZE),m_lastName("") |
31 | rotate_to_fit(rfit),show_zoomer(true),first_resize_done(false),m_lastName("") | ||
32 | { | 57 | { |
58 | _zoomer = 0; | ||
59 | m_states.resize(SCROLLVIEW_BITSET_SIZE); | ||
60 | m_states[AUTO_SCALE]=always_scale; | ||
61 | m_states[AUTO_ROTATE]=rfit; | ||
62 | m_states[FIRST_RESIZE_DONE]=false; | ||
63 | m_states[IMAGE_IS_JPEG]=false; | ||
64 | m_states[IMAGE_SCALED_LOADED]=false; | ||
65 | m_states[SHOW_ZOOMER]=true; | ||
33 | init(); | 66 | init(); |
@@ -36,3 +69,3 @@ ImageScrollView::ImageScrollView (const QString&img, QWidget * parent, const cha | |||
36 | 69 | ||
37 | void ImageScrollView::setImage(const QImage&img) | 70 | void OImageScrollView::setImage(const QImage&img) |
38 | { | 71 | { |
@@ -43,5 +76,5 @@ void ImageScrollView::setImage(const QImage&img) | |||
43 | m_lastName = ""; | 76 | m_lastName = ""; |
44 | image_is_jpeg = false; | 77 | setImageIsJpeg(false); |
45 | image_scaled_loaded = false; | 78 | setImageScaledLoaded(false); |
46 | if (first_resize_done) { | 79 | if (FirstResizeDone()) { |
47 | generateImage(); | 80 | generateImage(); |
@@ -50,3 +83,3 @@ void ImageScrollView::setImage(const QImage&img) | |||
50 | 83 | ||
51 | void ImageScrollView::loadJpeg(bool interncall) | 84 | void OImageScrollView::loadJpeg(bool interncall) |
52 | { | 85 | { |
@@ -56,3 +89,3 @@ void ImageScrollView::loadJpeg(bool interncall) | |||
56 | bool real_load = false; | 89 | bool real_load = false; |
57 | if (scale_to_fit) { | 90 | if (AutoScale()) { |
58 | if (!interncall) { | 91 | if (!interncall) { |
@@ -69,3 +102,3 @@ void ImageScrollView::loadJpeg(bool interncall) | |||
69 | iio.setParameters(param.latin1()); | 102 | iio.setParameters(param.latin1()); |
70 | image_scaled_loaded = true; | 103 | setImageScaledLoaded(true); |
71 | real_load = true; | 104 | real_load = true; |
@@ -73,3 +106,3 @@ void ImageScrollView::loadJpeg(bool interncall) | |||
73 | } else { | 106 | } else { |
74 | if (image_scaled_loaded||!interncall) { | 107 | if (ImageScaledLoaded()||!interncall) { |
75 | odebug << "Load jpeg unscaled" << oendl; | 108 | odebug << "Load jpeg unscaled" << oendl; |
@@ -77,3 +110,3 @@ void ImageScrollView::loadJpeg(bool interncall) | |||
77 | } | 110 | } |
78 | image_scaled_loaded = false; | 111 | setImageScaledLoaded(false); |
79 | } | 112 | } |
@@ -91,3 +124,3 @@ void ImageScrollView::loadJpeg(bool interncall) | |||
91 | 124 | ||
92 | void ImageScrollView::setImage( const QString& path ) { | 125 | void OImageScrollView::setImage( const QString& path ) { |
93 | odebug << "load new image " << oendl; | 126 | odebug << "load new image " << oendl; |
@@ -98,3 +131,3 @@ void ImageScrollView::setImage( const QString& path ) { | |||
98 | if (itype == "JPEG") { | 131 | if (itype == "JPEG") { |
99 | image_is_jpeg = true; | 132 | setImageIsJpeg(true); |
100 | loadJpeg(); | 133 | loadJpeg(); |
@@ -104,3 +137,3 @@ void ImageScrollView::setImage( const QString& path ) { | |||
104 | } | 137 | } |
105 | image_is_jpeg = false; | 138 | setImageIsJpeg(false); |
106 | _original_data.load(path); | 139 | _original_data.load(path); |
@@ -114,3 +147,3 @@ void ImageScrollView::setImage( const QString& path ) { | |||
114 | _image_data = QImage(); | 147 | _image_data = QImage(); |
115 | if (first_resize_done) { | 148 | if (FirstResizeDone()) { |
116 | generateImage(); | 149 | generateImage(); |
@@ -120,3 +153,3 @@ void ImageScrollView::setImage( const QString& path ) { | |||
120 | /* should be called every time the QImage changed it content */ | 153 | /* should be called every time the QImage changed it content */ |
121 | void ImageScrollView::init() | 154 | void OImageScrollView::init() |
122 | { | 155 | { |
@@ -131,2 +164,4 @@ void ImageScrollView::init() | |||
131 | this, SLOT(scrollBy(int,int)) ); | 164 | this, SLOT(scrollBy(int,int)) ); |
165 | connect(_zoomer, SIGNAL( zoomArea(int,int)), | ||
166 | this, SLOT(center(int,int)) ); | ||
132 | connect(this,SIGNAL(contentsMoving(int,int)), | 167 | connect(this,SIGNAL(contentsMoving(int,int)), |
@@ -140,9 +175,9 @@ void ImageScrollView::init() | |||
140 | setFocusPolicy(QWidget::StrongFocus); | 175 | setFocusPolicy(QWidget::StrongFocus); |
141 | image_scaled_loaded = false; | 176 | setImageScaledLoaded(false); |
142 | image_is_jpeg = false; | 177 | setImageIsJpeg(false); |
143 | if (first_resize_done) { | 178 | if (FirstResizeDone()) { |
144 | last_rot = Rotate0; | 179 | m_last_rot = Rotate0; |
145 | generateImage(); | 180 | generateImage(); |
146 | } else if (_original_data.size().isValid()) { | 181 | } else if (_original_data.size().isValid()) { |
147 | if (image_fit_into(_original_data.size()) || !show_zoomer) _zoomer->hide(); | 182 | if (image_fit_into(_original_data.size()) || !ShowZoomer()) _zoomer->hide(); |
148 | resizeContents(_original_data.width(),_original_data.height()); | 183 | resizeContents(_original_data.width(),_original_data.height()); |
@@ -151,7 +186,7 @@ void ImageScrollView::init() | |||
151 | 186 | ||
152 | void ImageScrollView::setAutoRotate(bool how) | 187 | void OImageScrollView::setAutoRotate(bool how) |
153 | { | 188 | { |
154 | /* to avoid double repaints */ | 189 | /* to avoid double repaints */ |
155 | if (rotate_to_fit != how) { | 190 | if (AutoRotate() != how) { |
156 | rotate_to_fit = how; | 191 | m_states.setBit(AUTO_ROTATE,how); |
157 | _image_data = QImage(); | 192 | _image_data = QImage(); |
@@ -161,10 +196,15 @@ void ImageScrollView::setAutoRotate(bool how) | |||
161 | 196 | ||
162 | void ImageScrollView::setAutoScale(bool how) | 197 | bool OImageScrollView::AutoRotate()const |
198 | { | ||
199 | return m_states.testBit(AUTO_ROTATE); | ||
200 | } | ||
201 | |||
202 | void OImageScrollView::setAutoScale(bool how) | ||
163 | { | 203 | { |
164 | scale_to_fit = how; | 204 | m_states.setBit(AUTO_SCALE,how); |
165 | if (!how) { | 205 | if (!how) { |
166 | rotate_to_fit = false; | 206 | setAutoRotate(false); |
167 | } | 207 | } |
168 | _image_data = QImage(); | 208 | _image_data = QImage(); |
169 | if (image_is_jpeg && how == false && image_scaled_loaded==true) { | 209 | if (ImageIsJpeg() && how == false && ImageScaledLoaded()==true) { |
170 | loadJpeg(true); | 210 | loadJpeg(true); |
@@ -174,3 +214,8 @@ void ImageScrollView::setAutoScale(bool how) | |||
174 | 214 | ||
175 | ImageScrollView::~ImageScrollView() | 215 | bool OImageScrollView::AutoScale()const |
216 | { | ||
217 | return m_states.testBit(AUTO_SCALE); | ||
218 | } | ||
219 | |||
220 | OImageScrollView::~OImageScrollView() | ||
176 | { | 221 | { |
@@ -178,3 +223,3 @@ ImageScrollView::~ImageScrollView() | |||
178 | 223 | ||
179 | void ImageScrollView::rescaleImage(int w, int h) | 224 | void OImageScrollView::rescaleImage(int w, int h) |
180 | { | 225 | { |
@@ -191,3 +236,3 @@ void ImageScrollView::rescaleImage(int w, int h) | |||
191 | 236 | ||
192 | void ImageScrollView::rotate_into_data(Rotation r) | 237 | void OImageScrollView::rotate_into_data(Rotation r) |
193 | { | 238 | { |
@@ -305,5 +350,6 @@ void ImageScrollView::rotate_into_data(Rotation r) | |||
305 | 350 | ||
306 | void ImageScrollView::generateImage() | 351 | void OImageScrollView::generateImage() |
307 | { | 352 | { |
308 | Rotation r = Rotate0; | 353 | Rotation r = Rotate0; |
354 | if (_original_data.isNull()) return; | ||
309 | { | 355 | { |
@@ -313,3 +359,3 @@ void ImageScrollView::generateImage() | |||
313 | width()<height()&&_original_data.width()>_original_data.height()) { | 359 | width()<height()&&_original_data.width()>_original_data.height()) { |
314 | if (rotate_to_fit) r = Rotate90; | 360 | if (AutoRotate()) r = Rotate90; |
315 | } | 361 | } |
@@ -317,3 +363,3 @@ void ImageScrollView::generateImage() | |||
317 | odebug << " r = " << r << oendl; | 363 | odebug << " r = " << r << oendl; |
318 | if (scale_to_fit) { | 364 | if (AutoScale()) { |
319 | if (!_image_data.size().isValid()||width()>_image_data.width()||height()>_image_data.height()) { | 365 | if (!_image_data.size().isValid()||width()>_image_data.width()||height()>_image_data.height()) { |
@@ -328,3 +374,3 @@ void ImageScrollView::generateImage() | |||
328 | resizeContents(_image_data.width(),_image_data.height()); | 374 | resizeContents(_image_data.width(),_image_data.height()); |
329 | } else if (!first_resize_done||r!=last_rot||_image_data.width()==0) { | 375 | } else if (!FirstResizeDone()||r!=m_last_rot||_image_data.width()==0) { |
330 | if (r==Rotate0) { | 376 | if (r==Rotate0) { |
@@ -334,3 +380,3 @@ void ImageScrollView::generateImage() | |||
334 | } | 380 | } |
335 | last_rot = r; | 381 | m_last_rot = r; |
336 | resizeContents(_image_data.width(),_image_data.height()); | 382 | resizeContents(_image_data.width(),_image_data.height()); |
@@ -349,6 +395,7 @@ void ImageScrollView::generateImage() | |||
349 | */ | 395 | */ |
350 | _zoomer->setGeometry( viewport()->width()-_image_data.width()/2, viewport()->height()-_image_data.height()/2, | 396 | if (_zoomer) { |
351 | _image_data.width()/2, _image_data.height()/2 ); | 397 | _zoomer->setGeometry( viewport()->width()-_image_data.width()/2, viewport()->height()-_image_data.height()/2, |
352 | 398 | _image_data.width()/2, _image_data.height()/2 ); | |
353 | _zoomer->setImage( _image_data ); | 399 | _zoomer->setImage( _image_data ); |
400 | } | ||
354 | /* | 401 | /* |
@@ -363,8 +410,8 @@ void ImageScrollView::generateImage() | |||
363 | 410 | ||
364 | void ImageScrollView::resizeEvent(QResizeEvent * e) | 411 | void OImageScrollView::resizeEvent(QResizeEvent * e) |
365 | { | 412 | { |
366 | odebug << "ImageScrollView resizeEvent" << oendl; | 413 | odebug << "OImageScrollView resizeEvent" << oendl; |
367 | QScrollView::resizeEvent(e); | 414 | QScrollView::resizeEvent(e); |
368 | generateImage(); | 415 | generateImage(); |
369 | first_resize_done = true; | 416 | setFirstResizeDone(true); |
370 | emit viewportSizeChanged( viewport()->size() ); | 417 | emit viewportSizeChanged( viewport()->size() ); |
@@ -373,3 +420,3 @@ void ImageScrollView::resizeEvent(QResizeEvent * e) | |||
373 | 420 | ||
374 | void ImageScrollView::keyPressEvent(QKeyEvent * e) | 421 | void OImageScrollView::keyPressEvent(QKeyEvent * e) |
375 | { | 422 | { |
@@ -396,3 +443,3 @@ void ImageScrollView::keyPressEvent(QKeyEvent * e) | |||
396 | 443 | ||
397 | void ImageScrollView::drawContents(QPainter * p, int clipx, int clipy, int clipw, int cliph) | 444 | void OImageScrollView::drawContents(QPainter * p, int clipx, int clipy, int clipw, int cliph) |
398 | { | 445 | { |
@@ -429,3 +476,3 @@ void ImageScrollView::drawContents(QPainter * p, int clipx, int clipy, int clipw | |||
429 | /* using the real geometry points and not the translated points is wanted! */ | 476 | /* using the real geometry points and not the translated points is wanted! */ |
430 | void ImageScrollView::viewportMouseMoveEvent(QMouseEvent* e) | 477 | void OImageScrollView::viewportMouseMoveEvent(QMouseEvent* e) |
431 | { | 478 | { |
@@ -458,3 +505,3 @@ void ImageScrollView::viewportMouseMoveEvent(QMouseEvent* e) | |||
458 | 505 | ||
459 | void ImageScrollView::contentsMousePressEvent ( QMouseEvent * e) | 506 | void OImageScrollView::contentsMousePressEvent ( QMouseEvent * e) |
460 | { | 507 | { |
@@ -470,3 +517,3 @@ void ImageScrollView::contentsMousePressEvent ( QMouseEvent * e) | |||
470 | 517 | ||
471 | void ImageScrollView::setDestructiveClose() { | 518 | void OImageScrollView::setDestructiveClose() { |
472 | WFlags fl = getWFlags(); | 519 | WFlags fl = getWFlags(); |
@@ -478,3 +525,3 @@ void ImageScrollView::setDestructiveClose() { | |||
478 | 525 | ||
479 | bool ImageScrollView::image_fit_into(const QSize&s ) | 526 | bool OImageScrollView::image_fit_into(const QSize&s ) |
480 | { | 527 | { |
@@ -486,5 +533,5 @@ bool ImageScrollView::image_fit_into(const QSize&s ) | |||
486 | 533 | ||
487 | void ImageScrollView::setShowZoomer(bool how) | 534 | void OImageScrollView::setShowZoomer(bool how) |
488 | { | 535 | { |
489 | show_zoomer = how; | 536 | m_states.setBit(SHOW_ZOOMER,how); |
490 | check_zoomer(); | 537 | check_zoomer(); |
@@ -492,7 +539,13 @@ void ImageScrollView::setShowZoomer(bool how) | |||
492 | 539 | ||
493 | void ImageScrollView::check_zoomer() | 540 | bool OImageScrollView::ShowZoomer()const |
541 | { | ||
542 | return m_states.testBit(SHOW_ZOOMER); | ||
543 | } | ||
544 | |||
545 | void OImageScrollView::check_zoomer() | ||
494 | { | 546 | { |
495 | if ( (!show_zoomer||image_fit_into(_pdata.size()) ) && _zoomer->isVisible()) { | 547 | if (!_zoomer) return; |
548 | if ( (!ShowZoomer()||image_fit_into(_pdata.size()) ) && _zoomer->isVisible()) { | ||
496 | _zoomer->hide(); | 549 | _zoomer->hide(); |
497 | } else if ( show_zoomer && !image_fit_into(_pdata.size()) && _zoomer->isHidden()){ | 550 | } else if ( ShowZoomer() && !image_fit_into(_pdata.size()) && _zoomer->isHidden()){ |
498 | _zoomer->show(); | 551 | _zoomer->show(); |
@@ -500 +553,34 @@ void ImageScrollView::check_zoomer() | |||
500 | } | 553 | } |
554 | |||
555 | bool OImageScrollView::FirstResizeDone()const | ||
556 | { | ||
557 | return m_states.testBit(FIRST_RESIZE_DONE); | ||
558 | } | ||
559 | |||
560 | void OImageScrollView::setFirstResizeDone(bool how) | ||
561 | { | ||
562 | m_states.setBit(FIRST_RESIZE_DONE,how); | ||
563 | } | ||
564 | |||
565 | bool OImageScrollView::ImageIsJpeg()const | ||
566 | { | ||
567 | return m_states.testBit(IMAGE_IS_JPEG); | ||
568 | } | ||
569 | |||
570 | void OImageScrollView::setImageIsJpeg(bool how) | ||
571 | { | ||
572 | m_states.setBit(IMAGE_IS_JPEG,how); | ||
573 | } | ||
574 | |||
575 | bool OImageScrollView::ImageScaledLoaded()const | ||
576 | { | ||
577 | return m_states.testBit(IMAGE_SCALED_LOADED); | ||
578 | } | ||
579 | |||
580 | void OImageScrollView::setImageScaledLoaded(bool how) | ||
581 | { | ||
582 | m_states.setBit(IMAGE_SCALED_LOADED,how); | ||
583 | } | ||
584 | |||
585 | } // namespace MM | ||
586 | } // namespace Opie | ||
diff --git a/noncore/graphics/opie-eye/gui/imagescrollview.h b/noncore/graphics/opie-eye/gui/imagescrollview.h index f6e187d..3d2ea38 100644 --- a/noncore/graphics/opie-eye/gui/imagescrollview.h +++ b/noncore/graphics/opie-eye/gui/imagescrollview.h | |||
@@ -3,4 +3,2 @@ | |||
3 | 3 | ||
4 | #include <lib/oimagezoomer.h> | ||
5 | |||
6 | #include <qscrollview.h> | 4 | #include <qscrollview.h> |
@@ -10,3 +8,3 @@ | |||
10 | #include <qdialog.h> | 8 | #include <qdialog.h> |
11 | 9 | #include <qbitarray.h> | |
12 | 10 | ||
@@ -15,3 +13,7 @@ class QPainter; | |||
15 | 13 | ||
16 | class ImageScrollView:public QScrollView | 14 | namespace Opie { namespace MM { |
15 | |||
16 | class OImageZoomer; | ||
17 | |||
18 | class OImageScrollView:public QScrollView | ||
17 | { | 19 | { |
@@ -19,9 +21,15 @@ class ImageScrollView:public QScrollView | |||
19 | public: | 21 | public: |
20 | ImageScrollView( QWidget* parent, const char* name = 0, WFlags fl = 0 ); | 22 | enum Rotation { |
21 | ImageScrollView (const QImage&, QWidget * parent=0, const char * name=0, WFlags f=0,bool always_scale=false,bool rfit=false ); | 23 | Rotate0, |
22 | ImageScrollView (const QString&, QWidget * parent=0, const char * name=0, WFlags f=0,bool always_scale=false,bool rfit=false ); | 24 | Rotate90, |
23 | virtual ~ImageScrollView(); | 25 | Rotate180, |
26 | Rotate270 | ||
27 | }; | ||
28 | |||
29 | OImageScrollView( QWidget* parent, const char* name = 0, WFlags fl = 0 ); | ||
30 | OImageScrollView (const QImage&, QWidget * parent=0, const char * name=0, WFlags f=0,bool always_scale=false,bool rfit=false ); | ||
31 | OImageScrollView (const QString&, QWidget * parent=0, const char * name=0, WFlags f=0,bool always_scale=false,bool rfit=false ); | ||
32 | virtual ~OImageScrollView(); | ||
33 | |||
24 | 34 | ||
25 | virtual void setImage(const QImage&); | ||
26 | virtual void setImage( const QString& path ); | ||
27 | virtual void setDestructiveClose(); | 35 | virtual void setDestructiveClose(); |
@@ -32,11 +40,12 @@ public: | |||
32 | 40 | ||
33 | enum Rotation { | 41 | virtual bool AutoRotate()const; |
34 | Rotate0, | 42 | virtual bool AutoScale()const; |
35 | Rotate90, | 43 | virtual bool ShowZoomer()const; |
36 | Rotate180, | 44 | |
37 | Rotate270 | 45 | public slots: |
38 | }; | 46 | virtual void setImage(const QImage&); |
47 | virtual void setImage( const QString& path ); | ||
48 | |||
39 | 49 | ||
40 | signals: | 50 | signals: |
41 | void sig_return(); | ||
42 | void imageSizeChanged( const QSize& ); | 51 | void imageSizeChanged( const QSize& ); |
@@ -55,9 +64,5 @@ protected: | |||
55 | 64 | ||
56 | bool scale_to_fit; | 65 | QBitArray m_states; |
57 | bool rotate_to_fit; | 66 | |
58 | bool show_zoomer; | 67 | Rotation m_last_rot; |
59 | bool first_resize_done; | ||
60 | bool image_is_jpeg; | ||
61 | bool image_scaled_loaded; | ||
62 | Rotation last_rot; | ||
63 | QString m_lastName; | 68 | QString m_lastName; |
@@ -71,2 +76,10 @@ protected: | |||
71 | 76 | ||
77 | /* internal bitset manipulation */ | ||
78 | virtual bool ImageIsJpeg()const; | ||
79 | virtual void setImageIsJpeg(bool how); | ||
80 | virtual bool ImageScaledLoaded()const; | ||
81 | virtual void setImageScaledLoaded(bool how); | ||
82 | virtual bool FirstResizeDone()const; | ||
83 | virtual void setFirstResizeDone(bool how); | ||
84 | |||
72 | protected slots: | 85 | protected slots: |
@@ -77,2 +90,6 @@ protected slots: | |||
77 | }; | 90 | }; |
91 | |||
92 | } | ||
93 | } | ||
94 | |||
78 | #endif | 95 | #endif |
diff --git a/noncore/graphics/opie-eye/gui/imageview.cpp b/noncore/graphics/opie-eye/gui/imageview.cpp index 2078b19..db3ae74 100644 --- a/noncore/graphics/opie-eye/gui/imageview.cpp +++ b/noncore/graphics/opie-eye/gui/imageview.cpp | |||
@@ -11,3 +11,3 @@ using namespace Opie::Core; | |||
11 | ImageView::ImageView(Opie::Core::OConfig *cfg, QWidget* parent, const char* name, WFlags fl ) | 11 | ImageView::ImageView(Opie::Core::OConfig *cfg, QWidget* parent, const char* name, WFlags fl ) |
12 | : ImageScrollView(parent,name,fl) | 12 | : Opie::MM::OImageScrollView(parent,name,fl) |
13 | { | 13 | { |
@@ -45,3 +45,2 @@ void ImageView::initKeys() | |||
45 | lst.append( Opie::Core::OKeyPair::rightArrowKey() ); | 45 | lst.append( Opie::Core::OKeyPair::rightArrowKey() ); |
46 | lst.append( Opie::Core::OKeyPair::returnKey() ); | ||
47 | 46 | ||
diff --git a/noncore/graphics/opie-eye/gui/imageview.h b/noncore/graphics/opie-eye/gui/imageview.h index 87e2b32..e4f899a 100644 --- a/noncore/graphics/opie-eye/gui/imageview.h +++ b/noncore/graphics/opie-eye/gui/imageview.h | |||
@@ -13,3 +13,3 @@ namespace Opie { | |||
13 | 13 | ||
14 | class ImageView:public ImageScrollView | 14 | class ImageView:public Opie::MM::OImageScrollView |
15 | { | 15 | { |
@@ -28,3 +28,2 @@ signals: | |||
28 | void dispImageInfo(const QString&); | 28 | void dispImageInfo(const QString&); |
29 | void sig_return(); | ||
30 | 29 | ||
diff --git a/noncore/graphics/opie-eye/gui/mainwindow.cpp b/noncore/graphics/opie-eye/gui/mainwindow.cpp index e5921d8..09f562a 100644 --- a/noncore/graphics/opie-eye/gui/mainwindow.cpp +++ b/noncore/graphics/opie-eye/gui/mainwindow.cpp | |||
@@ -5,2 +5,3 @@ | |||
5 | #include "mainwindow.h" | 5 | #include "mainwindow.h" |
6 | #include "imageview.h" | ||
6 | 7 | ||
@@ -9,3 +10,2 @@ | |||
9 | #include "imageinfoui.h" | 10 | #include "imageinfoui.h" |
10 | #include "imageview.h" | ||
11 | #include "viewmodebutton.h" | 11 | #include "viewmodebutton.h" |
diff --git a/noncore/graphics/opie-eye/gui/mainwindow.h b/noncore/graphics/opie-eye/gui/mainwindow.h index e9b16d0..adb5dc2 100644 --- a/noncore/graphics/opie-eye/gui/mainwindow.h +++ b/noncore/graphics/opie-eye/gui/mainwindow.h | |||
@@ -23,5 +23,6 @@ namespace Core{ | |||
23 | 23 | ||
24 | class ImageView; | ||
24 | class PIconView; | 25 | class PIconView; |
25 | class imageinfo; | 26 | class imageinfo; |
26 | class ImageView; | 27 | |
27 | class PMainWindow : public QMainWindow { | 28 | class PMainWindow : public QMainWindow { |
diff --git a/noncore/graphics/opie-eye/lib/oimagezoomer.cpp b/noncore/graphics/opie-eye/lib/oimagezoomer.cpp index 00b93e2..d1eec67 100644 --- a/noncore/graphics/opie-eye/lib/oimagezoomer.cpp +++ b/noncore/graphics/opie-eye/lib/oimagezoomer.cpp | |||
@@ -2,2 +2,4 @@ | |||
2 | 2 | ||
3 | #include <opie2/odebug.h> | ||
4 | |||
3 | #include <qimage.h> | 5 | #include <qimage.h> |
@@ -88,2 +90,3 @@ OImageZoomer::~OImageZoomer() { | |||
88 | void OImageZoomer::init() { | 90 | void OImageZoomer::init() { |
91 | m_mevent = false; | ||
89 | setFrameStyle( Panel | Sunken ); | 92 | setFrameStyle( Panel | Sunken ); |
@@ -197,4 +200,15 @@ void OImageZoomer::drawContents( QPainter* p ) { | |||
197 | 200 | ||
198 | void OImageZoomer::mousePressEvent( QMouseEvent* ) { | 201 | void OImageZoomer::mousePressEvent( QMouseEvent*ev) { |
199 | m_mouseX = m_mouseY = -1; | 202 | m_mouseX = m_mouseY = -1; |
203 | m_mevent = true; | ||
204 | } | ||
205 | |||
206 | void OImageZoomer::mouseReleaseEvent( QMouseEvent*ev) { | ||
207 | if (!m_mevent) return; | ||
208 | int mx, my; | ||
209 | mx = ev->x(); | ||
210 | my = ev->y(); | ||
211 | int diffx = (mx) * m_imgSize.width() / width(); | ||
212 | int diffy = (my) * m_imgSize.height() / height(); | ||
213 | emit zoomArea(diffx,diffy); | ||
200 | } | 214 | } |
@@ -207,2 +221,3 @@ void OImageZoomer::mouseMoveEvent( QMouseEvent* ev ) { | |||
207 | if ( m_mouseX != -1 && m_mouseY != -1 ) { | 221 | if ( m_mouseX != -1 && m_mouseY != -1 ) { |
222 | m_mevent = false; | ||
208 | int diffx = ( mx - m_mouseX ) * m_imgSize.width() / width(); | 223 | int diffx = ( mx - m_mouseX ) * m_imgSize.width() / width(); |
@@ -210,3 +225,2 @@ void OImageZoomer::mouseMoveEvent( QMouseEvent* ev ) { | |||
210 | emit zoomAreaRel( diffx, diffy ); | 225 | emit zoomAreaRel( diffx, diffy ); |
211 | emit zoomArea(m_visPt.x()+diffx, m_visPt.y()+diffy ); | ||
212 | } | 226 | } |
diff --git a/noncore/graphics/opie-eye/lib/oimagezoomer.h b/noncore/graphics/opie-eye/lib/oimagezoomer.h index 2516c61..0b356c9 100644 --- a/noncore/graphics/opie-eye/lib/oimagezoomer.h +++ b/noncore/graphics/opie-eye/lib/oimagezoomer.h | |||
@@ -73,3 +73,4 @@ signals: | |||
73 | * Here you get absolute coordinates. | 73 | * Here you get absolute coordinates. |
74 | * This slot will be emitted from within the mouseMoveEvent of this widget. | 74 | * This slot will be emitted from within the mouseReleaseEvent of this widget. |
75 | * if no mouse move where done. | ||
75 | * So you may not delete this widget | 76 | * So you may not delete this widget |
@@ -100,3 +101,3 @@ protected: | |||
100 | */ | 101 | */ |
101 | void mousePressEvent( QMouseEvent* ev ); | 102 | virtual void mousePressEvent( QMouseEvent* ev ); |
102 | /** | 103 | /** |
@@ -105,3 +106,8 @@ protected: | |||
105 | */ | 106 | */ |
106 | void mouseMoveEvent( QMouseEvent* ev ); | 107 | virtual void mouseMoveEvent( QMouseEvent* ev ); |
108 | /** | ||
109 | * make sure to call these if you reimplement | ||
110 | * @internal | ||
111 | */ | ||
112 | virtual void mouseReleaseEvent( QMouseEvent* ev ); | ||
107 | 113 | ||
@@ -116,2 +122,3 @@ private: | |||
116 | int m_mouseX, m_mouseY; | 122 | int m_mouseX, m_mouseY; |
123 | bool m_mevent; | ||
117 | }; | 124 | }; |