summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/graphics/opie-eye/gui/imagescrollview.cpp56
-rw-r--r--noncore/graphics/opie-eye/gui/imagescrollview.h4
-rw-r--r--noncore/graphics/opie-eye/gui/mainwindow.cpp41
-rw-r--r--noncore/graphics/opie-eye/gui/mainwindow.h5
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
@@ -33,10 +33,16 @@ void ImageScrollView::setImage(const QImage&img)
33 _image_data = QImage(); 33 _image_data = QImage();
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}
38 39
39void ImageScrollView::setImage( const QString& path ) { 40void 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}
42 48
@@ -44,9 +50,33 @@ void ImageScrollView::setImage( const QString& path ) {
44void ImageScrollView::init() 50void 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
63void 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
73void 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}
52 82
@@ -182,8 +212,6 @@ void ImageScrollView::rotate_into_data(Rotation r)
182} 212}
183 213
184void ImageScrollView::resizeEvent(QResizeEvent * e) 214void ImageScrollView::generateImage()
185{ 215{
186 odebug << "ImageScrollView resizeEvent" << oendl;
187 QScrollView::resizeEvent(e);
188 Rotation r = Rotate0; 216 Rotation r = Rotate0;
189 if (width()>height()&&_original_data.width()<_original_data.height() || 217 if (width()>height()&&_original_data.width()<_original_data.height() ||
@@ -194,4 +222,5 @@ void ImageScrollView::resizeEvent(QResizeEvent * e)
194 if (scale_to_fit) { 222 if (scale_to_fit) {
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) {
197 _image_data = _original_data; 226 _image_data = _original_data;
@@ -201,6 +230,6 @@ void ImageScrollView::resizeEvent(QResizeEvent * e)
201 } 230 }
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) {
206 _image_data = _original_data; 235 _image_data = _original_data;
@@ -211,4 +240,11 @@ void ImageScrollView::resizeEvent(QResizeEvent * e)
211 resizeContents(_image_data.width(),_image_data.height()); 240 resizeContents(_image_data.width(),_image_data.height());
212 } 241 }
242}
243
244void 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;
214} 250}
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
@@ -22,4 +22,7 @@ public:
22 void setDestructiveClose(); 22 void setDestructiveClose();
23 23
24 void setAutoRotate(bool);
25 void setAutoScale(bool);
26
24 enum Rotation { 27 enum Rotation {
25 Rotate0, 28 Rotate0,
@@ -49,4 +52,5 @@ protected:
49 52
50 void rotate_into_data(Rotation r); 53 void rotate_into_data(Rotation r);
54 void generateImage();
51 55
52protected slots: 56protected slots:
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
@@ -93,4 +93,18 @@ PMainWindow::PMainWindow(QWidget* wid, const char* name, WFlags style)
93 connect( btn, SIGNAL(clicked() ), 93 connect( btn, SIGNAL(clicked() ),
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
96} 110}
@@ -100,4 +114,23 @@ PMainWindow::~PMainWindow() {
100} 114}
101 115
116void PMainWindow::slotRotateToggled(bool how)
117{
118 autoRotate = how;
119 if (m_disp) {
120 m_disp->setAutoRotate(how);
121 }
122}
123
124void 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
103void PMainWindow::slotConfig() { 136void PMainWindow::slotConfig() {
@@ -181,4 +214,9 @@ void PMainWindow::initInfo() {
181void PMainWindow::initDisp() { 214void 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}
184 222
@@ -199,6 +237,7 @@ void PMainWindow::slotShowInfo( const QString& inf ) {
199 237
200void PMainWindow::slotDisplay( const QString& inf ) { 238void 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 );
204 m_stack->raiseWidget( ImageDisplay ); 243 m_stack->raiseWidget( ImageDisplay );
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
@@ -38,4 +38,6 @@ public slots:
38 void slotDisplay( const QString& inf ); 38 void slotDisplay( const QString& inf );
39 void slotReturn(); 39 void slotReturn();
40 void slotRotateToggled(bool);
41 void slotScaleToggled(bool);
40 42
41protected: 43protected:
@@ -54,4 +56,7 @@ private:
54 imageinfo *m_info; 56 imageinfo *m_info;
55 ImageScrollView *m_disp; 57 ImageScrollView *m_disp;
58 bool autoRotate;
59 bool autoScale;
60 QToolButton*rotateButton;
56 61
57 62