-rw-r--r-- | noncore/graphics/opie-eye/gui/imagescrollview.cpp | 56 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/imagescrollview.h | 4 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/mainwindow.cpp | 41 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/mainwindow.h | 5 |
4 files changed, 95 insertions, 11 deletions
diff --git a/noncore/graphics/opie-eye/gui/imagescrollview.cpp b/noncore/graphics/opie-eye/gui/imagescrollview.cpp index 7d83e29..ee20f40 100644 --- a/noncore/graphics/opie-eye/gui/imagescrollview.cpp +++ b/noncore/graphics/opie-eye/gui/imagescrollview.cpp | |||
@@ -34,4 +34,5 @@ void ImageScrollView::setImage(const QImage&img) | |||
34 | _original_data=img; | 34 | _original_data=img; |
35 | first_resize_done = false; | 35 | if (first_resize_done) { |
36 | init(); | 36 | generateImage(); |
37 | } | ||
37 | } | 38 | } |
@@ -39,3 +40,8 @@ void ImageScrollView::setImage(const QImage&img) | |||
39 | void ImageScrollView::setImage( const QString& path ) { | 40 | void ImageScrollView::setImage( const QString& path ) { |
40 | 41 | odebug << "load new image " << oendl; | |
42 | _original_data.load(path); | ||
43 | _image_data = QImage(); | ||
44 | if (first_resize_done) { | ||
45 | generateImage(); | ||
46 | } | ||
41 | } | 47 | } |
@@ -45,7 +51,31 @@ void ImageScrollView::init() | |||
45 | { | 51 | { |
52 | odebug << "init " << oendl; | ||
46 | viewport()->setBackgroundColor(white); | 53 | viewport()->setBackgroundColor(white); |
47 | if (_original_data.size().isValid()) { | 54 | if (first_resize_done) { |
55 | last_rot = Rotate0; | ||
56 | generateImage(); | ||
57 | odebug << "reinit display " << oendl; | ||
58 | } else if (_original_data.size().isValid()) { | ||
48 | resizeContents(_original_data.width(),_original_data.height()); | 59 | resizeContents(_original_data.width(),_original_data.height()); |
49 | } | 60 | } |
50 | last_rot = Rotate0; | 61 | } |
62 | |||
63 | void ImageScrollView::setAutoRotate(bool how) | ||
64 | { | ||
65 | /* to avoid double repaints */ | ||
66 | if (rotate_to_fit != how) { | ||
67 | rotate_to_fit = how; | ||
68 | _image_data = QImage(); | ||
69 | generateImage(); | ||
70 | } | ||
71 | } | ||
72 | |||
73 | void ImageScrollView::setAutoScale(bool how) | ||
74 | { | ||
75 | scale_to_fit = how; | ||
76 | if (!how) { | ||
77 | rotate_to_fit = false; | ||
78 | } | ||
79 | _image_data = QImage(); | ||
80 | generateImage(); | ||
51 | } | 81 | } |
@@ -183,6 +213,4 @@ void ImageScrollView::rotate_into_data(Rotation r) | |||
183 | 213 | ||
184 | void ImageScrollView::resizeEvent(QResizeEvent * e) | 214 | void ImageScrollView::generateImage() |
185 | { | 215 | { |
186 | odebug << "ImageScrollView resizeEvent" << oendl; | ||
187 | QScrollView::resizeEvent(e); | ||
188 | Rotation r = Rotate0; | 216 | Rotation r = Rotate0; |
@@ -195,2 +223,3 @@ void ImageScrollView::resizeEvent(QResizeEvent * e) | |||
195 | if (!_image_data.size().isValid()||width()>_image_data.width()||height()>_image_data.height()) { | 223 | if (!_image_data.size().isValid()||width()>_image_data.width()||height()>_image_data.height()) { |
224 | odebug << "Rescaling data" << oendl; | ||
196 | if (r==Rotate0) { | 225 | if (r==Rotate0) { |
@@ -202,4 +231,4 @@ void ImageScrollView::resizeEvent(QResizeEvent * e) | |||
202 | rescaleImage(width(),height()); | 231 | rescaleImage(width(),height()); |
203 | resizeContents(width()-10,height()-10); | 232 | resizeContents(_image_data.width(),_image_data.height()); |
204 | } else if (!first_resize_done||r!=last_rot) { | 233 | } else if (!first_resize_done||r!=last_rot||_image_data.width()==0) { |
205 | if (r==Rotate0) { | 234 | if (r==Rotate0) { |
@@ -212,2 +241,9 @@ void ImageScrollView::resizeEvent(QResizeEvent * e) | |||
212 | } | 241 | } |
242 | } | ||
243 | |||
244 | void ImageScrollView::resizeEvent(QResizeEvent * e) | ||
245 | { | ||
246 | odebug << "ImageScrollView resizeEvent" << oendl; | ||
247 | QScrollView::resizeEvent(e); | ||
248 | generateImage(); | ||
213 | first_resize_done = true; | 249 | first_resize_done = true; |
diff --git a/noncore/graphics/opie-eye/gui/imagescrollview.h b/noncore/graphics/opie-eye/gui/imagescrollview.h index 864a015..dcf54ce 100644 --- a/noncore/graphics/opie-eye/gui/imagescrollview.h +++ b/noncore/graphics/opie-eye/gui/imagescrollview.h | |||
@@ -23,2 +23,5 @@ public: | |||
23 | 23 | ||
24 | void setAutoRotate(bool); | ||
25 | void setAutoScale(bool); | ||
26 | |||
24 | enum Rotation { | 27 | enum Rotation { |
@@ -50,2 +53,3 @@ protected: | |||
50 | void rotate_into_data(Rotation r); | 53 | void rotate_into_data(Rotation r); |
54 | void generateImage(); | ||
51 | 55 | ||
diff --git a/noncore/graphics/opie-eye/gui/mainwindow.cpp b/noncore/graphics/opie-eye/gui/mainwindow.cpp index 7f384bd..88acd59 100644 --- a/noncore/graphics/opie-eye/gui/mainwindow.cpp +++ b/noncore/graphics/opie-eye/gui/mainwindow.cpp | |||
@@ -94,2 +94,16 @@ PMainWindow::PMainWindow(QWidget* wid, const char* name, WFlags style) | |||
94 | this, SLOT(slotConfig() ) ); | 94 | this, SLOT(slotConfig() ) ); |
95 | |||
96 | rotateButton = new QToolButton(bar); | ||
97 | rotateButton->setIconSet( Resource::loadIconSet( "rotate" ) ); | ||
98 | rotateButton->setToggleButton(true); | ||
99 | rotateButton->setOn(true); | ||
100 | connect(rotateButton,SIGNAL(toggled(bool)),this,SLOT(slotRotateToggled(bool))); | ||
101 | autoRotate = true; | ||
102 | |||
103 | btn = new QToolButton(bar); | ||
104 | btn->setIconSet( Resource::loadIconSet( "1to1" ) ); | ||
105 | btn->setToggleButton(true); | ||
106 | btn->setOn(false); | ||
107 | connect(btn,SIGNAL(toggled(bool)),this,SLOT(slotScaleToggled(bool))); | ||
108 | autoScale = true; | ||
95 | 109 | ||
@@ -101,2 +115,21 @@ PMainWindow::~PMainWindow() { | |||
101 | 115 | ||
116 | void PMainWindow::slotRotateToggled(bool how) | ||
117 | { | ||
118 | autoRotate = how; | ||
119 | if (m_disp) { | ||
120 | m_disp->setAutoRotate(how); | ||
121 | } | ||
122 | } | ||
123 | |||
124 | void PMainWindow::slotScaleToggled(bool how) | ||
125 | { | ||
126 | autoScale = !how; | ||
127 | if (m_disp) { | ||
128 | m_disp->setAutoScale(autoScale); | ||
129 | } | ||
130 | if (!autoScale && autoRotate) { | ||
131 | rotateButton->setOn(false); | ||
132 | } | ||
133 | rotateButton->setEnabled(!how); | ||
134 | } | ||
102 | 135 | ||
@@ -182,2 +215,7 @@ void PMainWindow::initDisp() { | |||
182 | initT<ImageScrollView>( "Image ScrollView", &m_disp, ImageDisplay ); | 215 | initT<ImageScrollView>( "Image ScrollView", &m_disp, ImageDisplay ); |
216 | if (m_disp) { | ||
217 | m_disp->setAutoScale(autoScale); | ||
218 | m_disp->setAutoRotate(autoRotate); | ||
219 | } | ||
220 | |||
183 | } | 221 | } |
@@ -200,4 +238,5 @@ void PMainWindow::slotShowInfo( const QString& inf ) { | |||
200 | void PMainWindow::slotDisplay( const QString& inf ) { | 238 | void PMainWindow::slotDisplay( const QString& inf ) { |
201 | if ( !m_disp ) | 239 | if ( !m_disp ) { |
202 | initDisp(); | 240 | initDisp(); |
241 | } | ||
203 | m_disp->setImage( inf ); | 242 | m_disp->setImage( inf ); |
diff --git a/noncore/graphics/opie-eye/gui/mainwindow.h b/noncore/graphics/opie-eye/gui/mainwindow.h index 35116ae..6debf7f 100644 --- a/noncore/graphics/opie-eye/gui/mainwindow.h +++ b/noncore/graphics/opie-eye/gui/mainwindow.h | |||
@@ -39,2 +39,4 @@ public slots: | |||
39 | void slotReturn(); | 39 | void slotReturn(); |
40 | void slotRotateToggled(bool); | ||
41 | void slotScaleToggled(bool); | ||
40 | 42 | ||
@@ -55,2 +57,5 @@ private: | |||
55 | ImageScrollView *m_disp; | 57 | ImageScrollView *m_disp; |
58 | bool autoRotate; | ||
59 | bool autoScale; | ||
60 | QToolButton*rotateButton; | ||
56 | 61 | ||