author | alwin <alwin> | 2004-04-05 22:09:25 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-04-05 22:09:25 (UTC) |
commit | 266b184c615022484b988e1638be768b11c0c19b (patch) (unidiff) | |
tree | b2560b3a64c49db414fa950fc3ef4670e25cd5ca | |
parent | 930abeed35ee6dd3aaec491f13d400f825b9d9d1 (diff) | |
download | opie-266b184c615022484b988e1638be768b11c0c19b.zip opie-266b184c615022484b988e1638be768b11c0c19b.tar.gz opie-266b184c615022484b988e1638be768b11c0c19b.tar.bz2 |
yeah - autoresize and autoscale now have toggle-buttons and the image display
respect these buttons
ToDo:
find a good way for prescaled loading of images if autoScale is on (in respect
to autorotate and so on)
-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 | |||
@@ -1,296 +1,332 @@ | |||
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) | 12 | rotate_to_fit(true),first_resize_done(false) |
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) | 19 | rotate_to_fit(rfit),first_resize_done(false) |
20 | { | 20 | { |
21 | init(); | 21 | init(); |
22 | } | 22 | } |
23 | 23 | ||
24 | ImageScrollView::ImageScrollView (const QString&img, QWidget * parent, const char * name, WFlags f,bool always_scale,bool rfit) | 24 | ImageScrollView::ImageScrollView (const QString&img, QWidget * parent, const char * name, WFlags f,bool always_scale,bool rfit) |
25 | :QScrollView(parent,name,f|Qt::WRepaintNoErase),_image_data(),_original_data(img),scale_to_fit(always_scale), | 25 | :QScrollView(parent,name,f|Qt::WRepaintNoErase),_image_data(),_original_data(img),scale_to_fit(always_scale), |
26 | rotate_to_fit(rfit),first_resize_done(false) | 26 | rotate_to_fit(rfit),first_resize_done(false) |
27 | { | 27 | { |
28 | init(); | 28 | init(); |
29 | } | 29 | } |
30 | 30 | ||
31 | void ImageScrollView::setImage(const QImage&img) | 31 | void ImageScrollView::setImage(const QImage&img) |
32 | { | 32 | { |
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 | ||
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 | } |
42 | 48 | ||
43 | /* should be called every time the QImage changed it content */ | 49 | /* should be called every time the QImage changed it content */ |
44 | void ImageScrollView::init() | 50 | 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 | } |
52 | 82 | ||
53 | ImageScrollView::~ImageScrollView() | 83 | ImageScrollView::~ImageScrollView() |
54 | { | 84 | { |
55 | } | 85 | } |
56 | 86 | ||
57 | void ImageScrollView::rescaleImage(int w, int h) | 87 | void ImageScrollView::rescaleImage(int w, int h) |
58 | { | 88 | { |
59 | if (_image_data.width()==w && _image_data.height()==h) { | 89 | if (_image_data.width()==w && _image_data.height()==h) { |
60 | return; | 90 | return; |
61 | } | 91 | } |
62 | double hs = (double)h / (double)_image_data.height() ; | 92 | double hs = (double)h / (double)_image_data.height() ; |
63 | double ws = (double)w / (double)_image_data.width() ; | 93 | double ws = (double)w / (double)_image_data.width() ; |
64 | double scaleFactor = (hs > ws) ? ws : hs; | 94 | double scaleFactor = (hs > ws) ? ws : hs; |
65 | int smoothW = (int)(scaleFactor * _image_data.width()); | 95 | int smoothW = (int)(scaleFactor * _image_data.width()); |
66 | int smoothH = (int)(scaleFactor * _image_data.height()); | 96 | int smoothH = (int)(scaleFactor * _image_data.height()); |
67 | _image_data = _image_data.smoothScale(smoothW,smoothH); | 97 | _image_data = _image_data.smoothScale(smoothW,smoothH); |
68 | } | 98 | } |
69 | 99 | ||
70 | void ImageScrollView::rotate_into_data(Rotation r) | 100 | void ImageScrollView::rotate_into_data(Rotation r) |
71 | { | 101 | { |
72 | /* realy - we must do this that way, 'cause when acting direct on _image_data the app will | 102 | /* realy - we must do this that way, 'cause when acting direct on _image_data the app will |
73 | segfault :( */ | 103 | segfault :( */ |
74 | QImage dest; | 104 | QImage dest; |
75 | int x, y; | 105 | int x, y; |
76 | if ( _original_data.depth() > 8 ) | 106 | if ( _original_data.depth() > 8 ) |
77 | { | 107 | { |
78 | unsigned int *srcData, *destData; | 108 | unsigned int *srcData, *destData; |
79 | switch ( r ) | 109 | switch ( r ) |
80 | { | 110 | { |
81 | case Rotate90: | 111 | case Rotate90: |
82 | dest.create(_original_data.height(), _original_data.width(), _original_data.depth()); | 112 | dest.create(_original_data.height(), _original_data.width(), _original_data.depth()); |
83 | for ( y=0; y < _original_data.height(); ++y ) | 113 | for ( y=0; y < _original_data.height(); ++y ) |
84 | { | 114 | { |
85 | srcData = (unsigned int *)_original_data.scanLine(y); | 115 | srcData = (unsigned int *)_original_data.scanLine(y); |
86 | for ( x=0; x < _original_data.width(); ++x ) | 116 | for ( x=0; x < _original_data.width(); ++x ) |
87 | { | 117 | { |
88 | destData = (unsigned int *)dest.scanLine(x); | 118 | destData = (unsigned int *)dest.scanLine(x); |
89 | destData[_original_data.height()-y-1] = srcData[x]; | 119 | destData[_original_data.height()-y-1] = srcData[x]; |
90 | } | 120 | } |
91 | } | 121 | } |
92 | break; | 122 | break; |
93 | case Rotate180: | 123 | case Rotate180: |
94 | dest.create(_original_data.width(), _original_data.height(), _original_data.depth()); | 124 | dest.create(_original_data.width(), _original_data.height(), _original_data.depth()); |
95 | for ( y=0; y < _original_data.height(); ++y ) | 125 | for ( y=0; y < _original_data.height(); ++y ) |
96 | { | 126 | { |
97 | srcData = (unsigned int *)_original_data.scanLine(y); | 127 | srcData = (unsigned int *)_original_data.scanLine(y); |
98 | destData = (unsigned int *)dest.scanLine(_original_data.height()-y-1); | 128 | destData = (unsigned int *)dest.scanLine(_original_data.height()-y-1); |
99 | for ( x=0; x < _original_data.width(); ++x ) | 129 | for ( x=0; x < _original_data.width(); ++x ) |
100 | destData[_original_data.width()-x-1] = srcData[x]; | 130 | destData[_original_data.width()-x-1] = srcData[x]; |
101 | } | 131 | } |
102 | break; | 132 | break; |
103 | case Rotate270: | 133 | case Rotate270: |
104 | dest.create(_original_data.height(), _original_data.width(), _original_data.depth()); | 134 | dest.create(_original_data.height(), _original_data.width(), _original_data.depth()); |
105 | for ( y=0; y < _original_data.height(); ++y ) | 135 | for ( y=0; y < _original_data.height(); ++y ) |
106 | { | 136 | { |
107 | srcData = (unsigned int *)_original_data.scanLine(y); | 137 | srcData = (unsigned int *)_original_data.scanLine(y); |
108 | for ( x=0; x < _original_data.width(); ++x ) | 138 | for ( x=0; x < _original_data.width(); ++x ) |
109 | { | 139 | { |
110 | destData = (unsigned int *)dest.scanLine(_original_data.width()-x-1); | 140 | destData = (unsigned int *)dest.scanLine(_original_data.width()-x-1); |
111 | destData[y] = srcData[x]; | 141 | destData[y] = srcData[x]; |
112 | } | 142 | } |
113 | } | 143 | } |
114 | break; | 144 | break; |
115 | default: | 145 | default: |
116 | dest = _original_data; | 146 | dest = _original_data; |
117 | break; | 147 | break; |
118 | } | 148 | } |
119 | } | 149 | } |
120 | else | 150 | else |
121 | { | 151 | { |
122 | unsigned char *srcData, *destData; | 152 | unsigned char *srcData, *destData; |
123 | unsigned int *srcTable, *destTable; | 153 | unsigned int *srcTable, *destTable; |
124 | switch ( r ) | 154 | switch ( r ) |
125 | { | 155 | { |
126 | case Rotate90: | 156 | case Rotate90: |
127 | dest.create(_original_data.height(), _original_data.width(), _original_data.depth()); | 157 | dest.create(_original_data.height(), _original_data.width(), _original_data.depth()); |
128 | dest.setNumColors(_original_data.numColors()); | 158 | dest.setNumColors(_original_data.numColors()); |
129 | srcTable = (unsigned int *)_original_data.colorTable(); | 159 | srcTable = (unsigned int *)_original_data.colorTable(); |
130 | destTable = (unsigned int *)dest.colorTable(); | 160 | destTable = (unsigned int *)dest.colorTable(); |
131 | for ( x=0; x < _original_data.numColors(); ++x ) | 161 | for ( x=0; x < _original_data.numColors(); ++x ) |
132 | destTable[x] = srcTable[x]; | 162 | destTable[x] = srcTable[x]; |
133 | for ( y=0; y < _original_data.height(); ++y ) | 163 | for ( y=0; y < _original_data.height(); ++y ) |
134 | { | 164 | { |
135 | srcData = (unsigned char *)_original_data.scanLine(y); | 165 | srcData = (unsigned char *)_original_data.scanLine(y); |
136 | for ( x=0; x < _original_data.width(); ++x ) | 166 | for ( x=0; x < _original_data.width(); ++x ) |
137 | { | 167 | { |
138 | destData = (unsigned char *)dest.scanLine(x); | 168 | destData = (unsigned char *)dest.scanLine(x); |
139 | destData[_original_data.height()-y-1] = srcData[x]; | 169 | destData[_original_data.height()-y-1] = srcData[x]; |
140 | } | 170 | } |
141 | } | 171 | } |
142 | break; | 172 | break; |
143 | case Rotate180: | 173 | case Rotate180: |
144 | dest.create(_original_data.width(), _original_data.height(), _original_data.depth()); | 174 | dest.create(_original_data.width(), _original_data.height(), _original_data.depth()); |
145 | dest.setNumColors(_original_data.numColors()); | 175 | dest.setNumColors(_original_data.numColors()); |
146 | srcTable = (unsigned int *)_original_data.colorTable(); | 176 | srcTable = (unsigned int *)_original_data.colorTable(); |
147 | destTable = (unsigned int *)dest.colorTable(); | 177 | destTable = (unsigned int *)dest.colorTable(); |
148 | for ( x=0; x < _original_data.numColors(); ++x ) | 178 | for ( x=0; x < _original_data.numColors(); ++x ) |
149 | destTable[x] = srcTable[x]; | 179 | destTable[x] = srcTable[x]; |
150 | for ( y=0; y < _original_data.height(); ++y ) | 180 | for ( y=0; y < _original_data.height(); ++y ) |
151 | { | 181 | { |
152 | srcData = (unsigned char *)_original_data.scanLine(y); | 182 | srcData = (unsigned char *)_original_data.scanLine(y); |
153 | destData = (unsigned char *)dest.scanLine(_original_data.height()-y-1); | 183 | destData = (unsigned char *)dest.scanLine(_original_data.height()-y-1); |
154 | for ( x=0; x < _original_data.width(); ++x ) | 184 | for ( x=0; x < _original_data.width(); ++x ) |
155 | destData[_original_data.width()-x-1] = srcData[x]; | 185 | destData[_original_data.width()-x-1] = srcData[x]; |
156 | } | 186 | } |
157 | break; | 187 | break; |
158 | case Rotate270: | 188 | case Rotate270: |
159 | dest.create(_original_data.height(), _original_data.width(), _original_data.depth()); | 189 | dest.create(_original_data.height(), _original_data.width(), _original_data.depth()); |
160 | dest.setNumColors(_original_data.numColors()); | 190 | dest.setNumColors(_original_data.numColors()); |
161 | srcTable = (unsigned int *)_original_data.colorTable(); | 191 | srcTable = (unsigned int *)_original_data.colorTable(); |
162 | destTable = (unsigned int *)dest.colorTable(); | 192 | destTable = (unsigned int *)dest.colorTable(); |
163 | for ( x=0; x < _original_data.numColors(); ++x ) | 193 | for ( x=0; x < _original_data.numColors(); ++x ) |
164 | destTable[x] = srcTable[x]; | 194 | destTable[x] = srcTable[x]; |
165 | for ( y=0; y < _original_data.height(); ++y ) | 195 | for ( y=0; y < _original_data.height(); ++y ) |
166 | { | 196 | { |
167 | srcData = (unsigned char *)_original_data.scanLine(y); | 197 | srcData = (unsigned char *)_original_data.scanLine(y); |
168 | for ( x=0; x < _original_data.width(); ++x ) | 198 | for ( x=0; x < _original_data.width(); ++x ) |
169 | { | 199 | { |
170 | destData = (unsigned char *)dest.scanLine(_original_data.width()-x-1); | 200 | destData = (unsigned char *)dest.scanLine(_original_data.width()-x-1); |
171 | destData[y] = srcData[x]; | 201 | destData[y] = srcData[x]; |
172 | } | 202 | } |
173 | } | 203 | } |
174 | break; | 204 | break; |
175 | default: | 205 | default: |
176 | dest = _original_data; | 206 | dest = _original_data; |
177 | break; | 207 | break; |
178 | } | 208 | } |
179 | 209 | ||
180 | } | 210 | } |
181 | _image_data = dest; | 211 | _image_data = dest; |
182 | } | 212 | } |
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; |
189 | if (width()>height()&&_original_data.width()<_original_data.height() || | 217 | if (width()>height()&&_original_data.width()<_original_data.height() || |
190 | width()<height()&&_original_data.width()>_original_data.height()) { | 218 | width()<height()&&_original_data.width()>_original_data.height()) { |
191 | if (rotate_to_fit) r = Rotate90; | 219 | if (rotate_to_fit) r = Rotate90; |
192 | } | 220 | } |
193 | odebug << " r = " << r << oendl; | 221 | odebug << " r = " << r << oendl; |
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; |
198 | } else { | 227 | } else { |
199 | rotate_into_data(r); | 228 | rotate_into_data(r); |
200 | } | 229 | } |
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; |
207 | } else { | 236 | } else { |
208 | rotate_into_data(r); | 237 | rotate_into_data(r); |
209 | } | 238 | } |
210 | last_rot = r; | 239 | last_rot = r; |
211 | resizeContents(_image_data.width(),_image_data.height()); | 240 | resizeContents(_image_data.width(),_image_data.height()); |
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; |
214 | } | 250 | } |
215 | 251 | ||
216 | void ImageScrollView::drawContents(QPainter * p, int clipx, int clipy, int clipw, int cliph) | 252 | void ImageScrollView::drawContents(QPainter * p, int clipx, int clipy, int clipw, int cliph) |
217 | { | 253 | { |
218 | int w = clipw; | 254 | int w = clipw; |
219 | int h = cliph; | 255 | int h = cliph; |
220 | int x = clipx; | 256 | int x = clipx; |
221 | int y = clipy; | 257 | int y = clipy; |
222 | bool erase = false; | 258 | bool erase = false; |
223 | 259 | ||
224 | if (!_image_data.size().isValid()) { | 260 | if (!_image_data.size().isValid()) { |
225 | p->fillRect(clipx,clipy,clipw,cliph,white); | 261 | p->fillRect(clipx,clipy,clipw,cliph,white); |
226 | return; | 262 | return; |
227 | } | 263 | } |
228 | if (w>_image_data.width()) { | 264 | if (w>_image_data.width()) { |
229 | w=_image_data.width(); | 265 | w=_image_data.width(); |
230 | x = 0; | 266 | x = 0; |
231 | erase = true; | 267 | erase = true; |
232 | } else if (x+w>_image_data.width()){ | 268 | } else if (x+w>_image_data.width()){ |
233 | x = _image_data.width()-w; | 269 | x = _image_data.width()-w; |
234 | } | 270 | } |
235 | if (h>_image_data.height()) { | 271 | if (h>_image_data.height()) { |
236 | h=_image_data.height(); | 272 | h=_image_data.height(); |
237 | y = 0; | 273 | y = 0; |
238 | erase = true; | 274 | erase = true; |
239 | } else if (y+h>_image_data.height()){ | 275 | } else if (y+h>_image_data.height()){ |
240 | y = _image_data.height()-h; | 276 | y = _image_data.height()-h; |
241 | } | 277 | } |
242 | if (erase||_image_data.hasAlphaBuffer()) { | 278 | if (erase||_image_data.hasAlphaBuffer()) { |
243 | p->fillRect(clipx,clipy,clipw,cliph,white); | 279 | p->fillRect(clipx,clipy,clipw,cliph,white); |
244 | } | 280 | } |
245 | p->drawImage(clipx,clipy,_image_data,x,y,w,h); | 281 | p->drawImage(clipx,clipy,_image_data,x,y,w,h); |
246 | } | 282 | } |
247 | 283 | ||
248 | /* using the real geometry points and not the translated points is wanted! */ | 284 | /* using the real geometry points and not the translated points is wanted! */ |
249 | void ImageScrollView::viewportMouseMoveEvent(QMouseEvent* e) | 285 | void ImageScrollView::viewportMouseMoveEvent(QMouseEvent* e) |
250 | { | 286 | { |
251 | int mx, my; | 287 | int mx, my; |
252 | mx = e->x(); | 288 | mx = e->x(); |
253 | my = e->y(); | 289 | my = e->y(); |
254 | int diffx = _mouseStartPosX-mx; | 290 | int diffx = _mouseStartPosX-mx; |
255 | int diffy = _mouseStartPosY-my; | 291 | int diffy = _mouseStartPosY-my; |
256 | scrollBy(diffx,diffy); | 292 | scrollBy(diffx,diffy); |
257 | _mouseStartPosX=mx; | 293 | _mouseStartPosX=mx; |
258 | _mouseStartPosY=my; | 294 | _mouseStartPosY=my; |
259 | } | 295 | } |
260 | 296 | ||
261 | void ImageScrollView::contentsMouseReleaseEvent ( QMouseEvent * e) | 297 | void ImageScrollView::contentsMouseReleaseEvent ( QMouseEvent * e) |
262 | { | 298 | { |
263 | _mouseStartPosX = e->x(); | 299 | _mouseStartPosX = e->x(); |
264 | _mouseStartPosY = e->y(); | 300 | _mouseStartPosY = e->y(); |
265 | } | 301 | } |
266 | 302 | ||
267 | void ImageScrollView::contentsMousePressEvent ( QMouseEvent * e) | 303 | void ImageScrollView::contentsMousePressEvent ( QMouseEvent * e) |
268 | { | 304 | { |
269 | _mouseStartPosX = e->x(); | 305 | _mouseStartPosX = e->x(); |
270 | _mouseStartPosY = e->y(); | 306 | _mouseStartPosY = e->y(); |
271 | } | 307 | } |
272 | 308 | ||
273 | void ImageScrollView::setDestructiveClose() { | 309 | void ImageScrollView::setDestructiveClose() { |
274 | WFlags fl = getWFlags(); | 310 | WFlags fl = getWFlags(); |
275 | /* clear it just in case */ | 311 | /* clear it just in case */ |
276 | fl &= ~WDestructiveClose; | 312 | fl &= ~WDestructiveClose; |
277 | fl |= WDestructiveClose; | 313 | fl |= WDestructiveClose; |
278 | setWFlags( fl ); | 314 | setWFlags( fl ); |
279 | } | 315 | } |
280 | 316 | ||
281 | 317 | ||
282 | /* for testing */ | 318 | /* for testing */ |
283 | ImageDlg::ImageDlg(const QString&fname,QWidget * parent, const char * name) | 319 | ImageDlg::ImageDlg(const QString&fname,QWidget * parent, const char * name) |
284 | :QDialog(parent,name,true,WStyle_ContextHelp) | 320 | :QDialog(parent,name,true,WStyle_ContextHelp) |
285 | { | 321 | { |
286 | QVBoxLayout*dlglayout = new QVBoxLayout(this); | 322 | QVBoxLayout*dlglayout = new QVBoxLayout(this); |
287 | dlglayout->setSpacing(2); | 323 | dlglayout->setSpacing(2); |
288 | dlglayout->setMargin(1); | 324 | dlglayout->setMargin(1); |
289 | ImageScrollView*inf = new ImageScrollView(fname,this); | 325 | ImageScrollView*inf = new ImageScrollView(fname,this); |
290 | dlglayout->addWidget(inf); | 326 | dlglayout->addWidget(inf); |
291 | odebug << "Imagedlg constructor end" << oendl; | 327 | odebug << "Imagedlg constructor end" << oendl; |
292 | } | 328 | } |
293 | 329 | ||
294 | ImageDlg::~ImageDlg() | 330 | ImageDlg::~ImageDlg() |
295 | { | 331 | { |
296 | } | 332 | } |
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 | |||
@@ -1,68 +1,72 @@ | |||
1 | #ifndef _IMAGE_SCROLL_VIEW_H | 1 | #ifndef _IMAGE_SCROLL_VIEW_H |
2 | #define _IMAGE_SCROLL_VIEW_H | 2 | #define _IMAGE_SCROLL_VIEW_H |
3 | 3 | ||
4 | #include <qscrollview.h> | 4 | #include <qscrollview.h> |
5 | #include <qimage.h> | 5 | #include <qimage.h> |
6 | #include <qstring.h> | 6 | #include <qstring.h> |
7 | #include <qdialog.h> | 7 | #include <qdialog.h> |
8 | 8 | ||
9 | class QPainter; | 9 | class QPainter; |
10 | 10 | ||
11 | class ImageScrollView:public QScrollView | 11 | class ImageScrollView:public QScrollView |
12 | { | 12 | { |
13 | Q_OBJECT | 13 | Q_OBJECT |
14 | public: | 14 | public: |
15 | ImageScrollView( QWidget* parent, const char* name = 0, WFlags fl = 0 ); | 15 | ImageScrollView( QWidget* parent, const char* name = 0, WFlags fl = 0 ); |
16 | ImageScrollView (const QImage&, QWidget * parent=0, const char * name=0, WFlags f=0,bool always_scale=false,bool rfit=false ); | 16 | ImageScrollView (const QImage&, QWidget * parent=0, const char * name=0, WFlags f=0,bool always_scale=false,bool rfit=false ); |
17 | ImageScrollView (const QString&, QWidget * parent=0, const char * name=0, WFlags f=0,bool always_scale=false,bool rfit=false ); | 17 | ImageScrollView (const QString&, QWidget * parent=0, const char * name=0, WFlags f=0,bool always_scale=false,bool rfit=false ); |
18 | virtual ~ImageScrollView(); | 18 | virtual ~ImageScrollView(); |
19 | 19 | ||
20 | void setImage(const QImage&); | 20 | void setImage(const QImage&); |
21 | void setImage( const QString& path ); | 21 | void setImage( const QString& path ); |
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, |
26 | Rotate90, | 29 | Rotate90, |
27 | Rotate180, | 30 | Rotate180, |
28 | Rotate270 | 31 | Rotate270 |
29 | }; | 32 | }; |
30 | 33 | ||
31 | signals: | 34 | signals: |
32 | void sig_return(); | 35 | void sig_return(); |
33 | 36 | ||
34 | protected: | 37 | protected: |
35 | virtual void drawContents ( QPainter * p, int clipx, int clipy, int clipw, int cliph ); | 38 | virtual void drawContents ( QPainter * p, int clipx, int clipy, int clipw, int cliph ); |
36 | void init(); | 39 | void init(); |
37 | 40 | ||
38 | QImage _image_data; | 41 | QImage _image_data; |
39 | QImage _original_data; | 42 | QImage _original_data; |
40 | 43 | ||
41 | int _mouseStartPosX,_mouseStartPosY; | 44 | int _mouseStartPosX,_mouseStartPosY; |
42 | 45 | ||
43 | bool scale_to_fit; | 46 | bool scale_to_fit; |
44 | bool rotate_to_fit; | 47 | bool rotate_to_fit; |
45 | bool first_resize_done; | 48 | bool first_resize_done; |
46 | Rotation last_rot; | 49 | Rotation last_rot; |
47 | 50 | ||
48 | void rescaleImage(int w, int h); | 51 | void rescaleImage(int w, int h); |
49 | 52 | ||
50 | void rotate_into_data(Rotation r); | 53 | void rotate_into_data(Rotation r); |
54 | void generateImage(); | ||
51 | 55 | ||
52 | protected slots: | 56 | protected slots: |
53 | virtual void viewportMouseMoveEvent(QMouseEvent* e); | 57 | virtual void viewportMouseMoveEvent(QMouseEvent* e); |
54 | virtual void contentsMousePressEvent ( QMouseEvent * e); | 58 | virtual void contentsMousePressEvent ( QMouseEvent * e); |
55 | virtual void contentsMouseReleaseEvent ( QMouseEvent * e); | 59 | virtual void contentsMouseReleaseEvent ( QMouseEvent * e); |
56 | virtual void resizeEvent(QResizeEvent * e); | 60 | virtual void resizeEvent(QResizeEvent * e); |
57 | }; | 61 | }; |
58 | 62 | ||
59 | /* for testing */ | 63 | /* for testing */ |
60 | class ImageDlg:public QDialog | 64 | class ImageDlg:public QDialog |
61 | { | 65 | { |
62 | Q_OBJECT | 66 | Q_OBJECT |
63 | public: | 67 | public: |
64 | ImageDlg(const QString&,QWidget * parent=0, const char * name=0); | 68 | ImageDlg(const QString&,QWidget * parent=0, const char * name=0); |
65 | virtual ~ImageDlg(); | 69 | virtual ~ImageDlg(); |
66 | }; | 70 | }; |
67 | 71 | ||
68 | #endif | 72 | #endif |
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 | |||
@@ -1,229 +1,268 @@ | |||
1 | /* | 1 | /* |
2 | * GPLv2 zecke@handhelds.org | 2 | * GPLv2 zecke@handhelds.org |
3 | * No WArranty... | 3 | * No WArranty... |
4 | */ | 4 | */ |
5 | #include "mainwindow.h" | 5 | #include "mainwindow.h" |
6 | 6 | ||
7 | #include "iconview.h" | 7 | #include "iconview.h" |
8 | #include "filesystem.h" | 8 | #include "filesystem.h" |
9 | #include "imageinfoui.h" | 9 | #include "imageinfoui.h" |
10 | #include "imagescrollview.h" | 10 | #include "imagescrollview.h" |
11 | 11 | ||
12 | #include <iface/ifaceinfo.h> | 12 | #include <iface/ifaceinfo.h> |
13 | #include <iface/dirview.h> | 13 | #include <iface/dirview.h> |
14 | 14 | ||
15 | #include <opie2/odebug.h> | 15 | #include <opie2/odebug.h> |
16 | #include <opie2/owidgetstack.h> | 16 | #include <opie2/owidgetstack.h> |
17 | #include <opie2/oapplicationfactory.h> | 17 | #include <opie2/oapplicationfactory.h> |
18 | #include <opie2/otabwidget.h> | 18 | #include <opie2/otabwidget.h> |
19 | #include <opie2/okeyconfigwidget.h> | 19 | #include <opie2/okeyconfigwidget.h> |
20 | 20 | ||
21 | 21 | ||
22 | #include <qpe/resource.h> | 22 | #include <qpe/resource.h> |
23 | #include <qpe/config.h> | 23 | #include <qpe/config.h> |
24 | #include <qpe/ir.h> | 24 | #include <qpe/ir.h> |
25 | 25 | ||
26 | #include <qtoolbar.h> | 26 | #include <qtoolbar.h> |
27 | #include <qtoolbutton.h> | 27 | #include <qtoolbutton.h> |
28 | #include <qlayout.h> | 28 | #include <qlayout.h> |
29 | #include <qdialog.h> | 29 | #include <qdialog.h> |
30 | #include <qmap.h> | 30 | #include <qmap.h> |
31 | #include <qtimer.h> | 31 | #include <qtimer.h> |
32 | 32 | ||
33 | 33 | ||
34 | 34 | ||
35 | 35 | ||
36 | OPIE_EXPORT_APP( Opie::Core::OApplicationFactory<PMainWindow> ) | 36 | OPIE_EXPORT_APP( Opie::Core::OApplicationFactory<PMainWindow> ) |
37 | 37 | ||
38 | PMainWindow::PMainWindow(QWidget* wid, const char* name, WFlags style) | 38 | PMainWindow::PMainWindow(QWidget* wid, const char* name, WFlags style) |
39 | : QMainWindow( wid, name, style ), m_info( 0 ), m_disp( 0 ) | 39 | : QMainWindow( wid, name, style ), m_info( 0 ), m_disp( 0 ) |
40 | { | 40 | { |
41 | setCaption( QObject::tr("Opie Eye Caramba" ) ); | 41 | setCaption( QObject::tr("Opie Eye Caramba" ) ); |
42 | m_cfg = new Opie::Core::OConfig("phunkview"); | 42 | m_cfg = new Opie::Core::OConfig("phunkview"); |
43 | m_cfg->setGroup("Zecke_view" ); | 43 | m_cfg->setGroup("Zecke_view" ); |
44 | 44 | ||
45 | 45 | ||
46 | /* | 46 | /* |
47 | * Initialize ToolBar and IconView | 47 | * Initialize ToolBar and IconView |
48 | * And Connect Them | 48 | * And Connect Them |
49 | */ | 49 | */ |
50 | QToolBar *bar = new QToolBar( this ); | 50 | QToolBar *bar = new QToolBar( this ); |
51 | bar->setHorizontalStretchable( true ); | 51 | bar->setHorizontalStretchable( true ); |
52 | setToolBarsMovable( false ); | 52 | setToolBarsMovable( false ); |
53 | 53 | ||
54 | m_stack = new Opie::Ui::OWidgetStack( this ); | 54 | m_stack = new Opie::Ui::OWidgetStack( this ); |
55 | setCentralWidget( m_stack ); | 55 | setCentralWidget( m_stack ); |
56 | 56 | ||
57 | m_view = new PIconView( m_stack, m_cfg ); | 57 | m_view = new PIconView( m_stack, m_cfg ); |
58 | m_stack->addWidget( m_view, IconView ); | 58 | m_stack->addWidget( m_view, IconView ); |
59 | m_stack->raiseWidget( IconView ); | 59 | m_stack->raiseWidget( IconView ); |
60 | connect(m_view, SIGNAL(sig_display(const QString&)), | 60 | connect(m_view, SIGNAL(sig_display(const QString&)), |
61 | this, SLOT(slotDisplay(const QString&))); | 61 | this, SLOT(slotDisplay(const QString&))); |
62 | connect(m_view, SIGNAL(sig_showInfo(const QString&)), | 62 | connect(m_view, SIGNAL(sig_showInfo(const QString&)), |
63 | this, SLOT(slotShowInfo(const QString&)) ); | 63 | this, SLOT(slotShowInfo(const QString&)) ); |
64 | 64 | ||
65 | QToolButton *btn = new QToolButton( bar ); | 65 | QToolButton *btn = new QToolButton( bar ); |
66 | btn->setIconSet( Resource::loadIconSet( "up" ) ); | 66 | btn->setIconSet( Resource::loadIconSet( "up" ) ); |
67 | connect( btn, SIGNAL(clicked()), | 67 | connect( btn, SIGNAL(clicked()), |
68 | m_view, SLOT(slotDirUp()) ); | 68 | m_view, SLOT(slotDirUp()) ); |
69 | 69 | ||
70 | btn = new PFileSystem( bar ); | 70 | btn = new PFileSystem( bar ); |
71 | connect( btn, SIGNAL( changeDir( const QString& ) ), | 71 | connect( btn, SIGNAL( changeDir( const QString& ) ), |
72 | m_view, SLOT(slotChangeDir( const QString& ) ) ); | 72 | m_view, SLOT(slotChangeDir( const QString& ) ) ); |
73 | 73 | ||
74 | btn = new QToolButton( bar ); | 74 | btn = new QToolButton( bar ); |
75 | btn->setIconSet( Resource::loadIconSet( "edit" ) ); | 75 | btn->setIconSet( Resource::loadIconSet( "edit" ) ); |
76 | connect( btn, SIGNAL(clicked()), | 76 | connect( btn, SIGNAL(clicked()), |
77 | m_view, SLOT(slotRename()) ); | 77 | m_view, SLOT(slotRename()) ); |
78 | 78 | ||
79 | if ( Ir::supported() ) { | 79 | if ( Ir::supported() ) { |
80 | btn = new QToolButton( bar ); | 80 | btn = new QToolButton( bar ); |
81 | btn->setIconSet( Resource::loadIconSet( "beam" ) ); | 81 | btn->setIconSet( Resource::loadIconSet( "beam" ) ); |
82 | connect( btn, SIGNAL(clicked()), | 82 | connect( btn, SIGNAL(clicked()), |
83 | m_view, SLOT(slotBeam()) ); | 83 | m_view, SLOT(slotBeam()) ); |
84 | } | 84 | } |
85 | 85 | ||
86 | btn = new QToolButton( bar ); | 86 | btn = new QToolButton( bar ); |
87 | btn->setIconSet( Resource::loadIconSet( "trash" ) ); | 87 | btn->setIconSet( Resource::loadIconSet( "trash" ) ); |
88 | connect( btn, SIGNAL(clicked() ), | 88 | connect( btn, SIGNAL(clicked() ), |
89 | m_view, SLOT(slotTrash() ) ); | 89 | m_view, SLOT(slotTrash() ) ); |
90 | 90 | ||
91 | btn = new QToolButton( bar ); | 91 | btn = new QToolButton( bar ); |
92 | btn->setIconSet( Resource::loadIconSet( "SettingsIcon" ) ); | 92 | btn->setIconSet( Resource::loadIconSet( "SettingsIcon" ) ); |
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 | } |
97 | 111 | ||
98 | PMainWindow::~PMainWindow() { | 112 | PMainWindow::~PMainWindow() { |
99 | odebug << "Shutting down" << oendl; | 113 | odebug << "Shutting down" << oendl; |
100 | } | 114 | } |
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 | ||
103 | void PMainWindow::slotConfig() { | 136 | void PMainWindow::slotConfig() { |
104 | /* | 137 | /* |
105 | * have a tab with the possible views | 138 | * have a tab with the possible views |
106 | * a tab for globals image cache size.. scaled loading | 139 | * a tab for globals image cache size.. scaled loading |
107 | * and one tab for the KeyConfigs | 140 | * and one tab for the KeyConfigs |
108 | */ | 141 | */ |
109 | QDialog dlg(this, 0, true); | 142 | QDialog dlg(this, 0, true); |
110 | dlg.setCaption( tr("Phunk View - Config" ) ); | 143 | dlg.setCaption( tr("Phunk View - Config" ) ); |
111 | 144 | ||
112 | QHBoxLayout *lay = new QHBoxLayout(&dlg); | 145 | QHBoxLayout *lay = new QHBoxLayout(&dlg); |
113 | Opie::Ui::OTabWidget *wid = new Opie::Ui::OTabWidget(&dlg ); | 146 | Opie::Ui::OTabWidget *wid = new Opie::Ui::OTabWidget(&dlg ); |
114 | lay->addWidget( wid ); | 147 | lay->addWidget( wid ); |
115 | ViewMap *vM = viewMap(); | 148 | ViewMap *vM = viewMap(); |
116 | ViewMap::Iterator _it = vM->begin(); | 149 | ViewMap::Iterator _it = vM->begin(); |
117 | QMap<PDirView*, QWidget*> lst; | 150 | QMap<PDirView*, QWidget*> lst; |
118 | 151 | ||
119 | for( ; _it != vM->end(); ++_it ) { | 152 | for( ; _it != vM->end(); ++_it ) { |
120 | PDirView *view = (_it.data())(*m_cfg); | 153 | PDirView *view = (_it.data())(*m_cfg); |
121 | PInterfaceInfo *inf = view->interfaceInfo(); | 154 | PInterfaceInfo *inf = view->interfaceInfo(); |
122 | QWidget *_wid = inf->configWidget( *m_cfg ); | 155 | QWidget *_wid = inf->configWidget( *m_cfg ); |
123 | _wid->reparent(wid, QPoint() ); | 156 | _wid->reparent(wid, QPoint() ); |
124 | lst.insert( view, _wid ); | 157 | lst.insert( view, _wid ); |
125 | wid->addTab( _wid, "fileopen", inf->name() ); | 158 | wid->addTab( _wid, "fileopen", inf->name() ); |
126 | } | 159 | } |
127 | 160 | ||
128 | /* | 161 | /* |
129 | * Add the KeyConfigWidget | 162 | * Add the KeyConfigWidget |
130 | */ | 163 | */ |
131 | Opie::Ui::OKeyConfigWidget* keyWid = new Opie::Ui::OKeyConfigWidget( wid, "key config" ); | 164 | Opie::Ui::OKeyConfigWidget* keyWid = new Opie::Ui::OKeyConfigWidget( wid, "key config" ); |
132 | keyWid->setChangeMode( Opie::Ui::OKeyConfigWidget::Queue ); | 165 | keyWid->setChangeMode( Opie::Ui::OKeyConfigWidget::Queue ); |
133 | keyWid->insert( tr("Browser Keyboard Actions"), m_view->manager() ); | 166 | keyWid->insert( tr("Browser Keyboard Actions"), m_view->manager() ); |
134 | keyWid->load(); | 167 | keyWid->load(); |
135 | wid->addTab( keyWid, QString::fromLatin1("AppsIcon" ), tr("Keyboard Configuration") ); | 168 | wid->addTab( keyWid, QString::fromLatin1("AppsIcon" ), tr("Keyboard Configuration") ); |
136 | 169 | ||
137 | 170 | ||
138 | bool act = ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ); | 171 | bool act = ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ); |
139 | 172 | ||
140 | /* | 173 | /* |
141 | * clean up | 174 | * clean up |
142 | *apply changes | 175 | *apply changes |
143 | */ | 176 | */ |
144 | 177 | ||
145 | QMap<PDirView*, QWidget*>::Iterator it; | 178 | QMap<PDirView*, QWidget*>::Iterator it; |
146 | for ( it = lst.begin(); it != lst.end(); ++it ) { | 179 | for ( it = lst.begin(); it != lst.end(); ++it ) { |
147 | if ( act ) | 180 | if ( act ) |
148 | it.key()->interfaceInfo()->writeConfig(it.data(), *m_cfg); | 181 | it.key()->interfaceInfo()->writeConfig(it.data(), *m_cfg); |
149 | delete it.key(); | 182 | delete it.key(); |
150 | } | 183 | } |
151 | 184 | ||
152 | 185 | ||
153 | if ( act ) { | 186 | if ( act ) { |
154 | m_view->resetView(); | 187 | m_view->resetView(); |
155 | keyWid->save(); | 188 | keyWid->save(); |
156 | } | 189 | } |
157 | } | 190 | } |
158 | 191 | ||
159 | /* | 192 | /* |
160 | * create a new image info component | 193 | * create a new image info component |
161 | * and detach the current one | 194 | * and detach the current one |
162 | * we will make the other delete on exit | 195 | * we will make the other delete on exit |
163 | */ | 196 | */ |
164 | template<class T> | 197 | template<class T> |
165 | void PMainWindow::initT( const char* name, T** ptr, int id) { | 198 | void PMainWindow::initT( const char* name, T** ptr, int id) { |
166 | if ( *ptr ) { | 199 | if ( *ptr ) { |
167 | (*ptr)->disconnect(this, SLOT(slotReturn())); | 200 | (*ptr)->disconnect(this, SLOT(slotReturn())); |
168 | (*ptr)->setDestructiveClose(); | 201 | (*ptr)->setDestructiveClose(); |
169 | m_stack->removeWidget( *ptr ); | 202 | m_stack->removeWidget( *ptr ); |
170 | } | 203 | } |
171 | *ptr = new T( m_stack, name ); | 204 | *ptr = new T( m_stack, name ); |
172 | m_stack->addWidget( *ptr, id ); | 205 | m_stack->addWidget( *ptr, id ); |
173 | 206 | ||
174 | connect(*ptr, SIGNAL(sig_return()), | 207 | connect(*ptr, SIGNAL(sig_return()), |
175 | this,SLOT(slotReturn())); | 208 | this,SLOT(slotReturn())); |
176 | 209 | ||
177 | } | 210 | } |
178 | void PMainWindow::initInfo() { | 211 | void PMainWindow::initInfo() { |
179 | initT<imageinfo>( "Image Info", &m_info, ImageInfo ); | 212 | initT<imageinfo>( "Image Info", &m_info, ImageInfo ); |
180 | } | 213 | } |
181 | void PMainWindow::initDisp() { | 214 | 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 | } |
184 | 222 | ||
185 | /** | 223 | /** |
186 | * With big Screen the plan could be to 'detach' the image | 224 | * With big Screen the plan could be to 'detach' the image |
187 | * window if visible and to create a ne wone | 225 | * window if visible and to create a ne wone |
188 | * init* already supports it but I make no use of it for | 226 | * init* already supports it but I make no use of it for |
189 | * now. We set filename and raise | 227 | * now. We set filename and raise |
190 | * | 228 | * |
191 | * ### FIXME and talk to alwin | 229 | * ### FIXME and talk to alwin |
192 | */ | 230 | */ |
193 | void PMainWindow::slotShowInfo( const QString& inf ) { | 231 | void PMainWindow::slotShowInfo( const QString& inf ) { |
194 | if ( !m_info ) | 232 | if ( !m_info ) |
195 | initInfo(); | 233 | initInfo(); |
196 | m_info->setPath( inf ); | 234 | m_info->setPath( inf ); |
197 | m_stack->raiseWidget( ImageInfo ); | 235 | m_stack->raiseWidget( ImageInfo ); |
198 | } | 236 | } |
199 | 237 | ||
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 ); |
204 | m_stack->raiseWidget( ImageDisplay ); | 243 | m_stack->raiseWidget( ImageDisplay ); |
205 | } | 244 | } |
206 | 245 | ||
207 | void PMainWindow::slotReturn() { | 246 | void PMainWindow::slotReturn() { |
208 | raiseIconView(); | 247 | raiseIconView(); |
209 | } | 248 | } |
210 | 249 | ||
211 | 250 | ||
212 | void PMainWindow::closeEvent( QCloseEvent* ev ) { | 251 | void PMainWindow::closeEvent( QCloseEvent* ev ) { |
213 | /* | 252 | /* |
214 | * return from view | 253 | * return from view |
215 | * or properly quit | 254 | * or properly quit |
216 | */ | 255 | */ |
217 | if ( m_stack->visibleWidget() == m_info || | 256 | if ( m_stack->visibleWidget() == m_info || |
218 | m_stack->visibleWidget() == m_disp ) { | 257 | m_stack->visibleWidget() == m_disp ) { |
219 | raiseIconView(); | 258 | raiseIconView(); |
220 | ev->ignore(); | 259 | ev->ignore(); |
221 | return; | 260 | return; |
222 | } | 261 | } |
223 | ev->accept(); | 262 | ev->accept(); |
224 | QTimer::singleShot(0, qApp, SLOT(closeAllWindows())); | 263 | QTimer::singleShot(0, qApp, SLOT(closeAllWindows())); |
225 | } | 264 | } |
226 | 265 | ||
227 | void PMainWindow::raiseIconView() { | 266 | void PMainWindow::raiseIconView() { |
228 | m_stack->raiseWidget( IconView ); | 267 | m_stack->raiseWidget( IconView ); |
229 | } | 268 | } |
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 | |||
@@ -1,62 +1,67 @@ | |||
1 | /* | 1 | /* |
2 | * GPLv2 zecke@handhelds.org | 2 | * GPLv2 zecke@handhelds.org |
3 | * No WArranty... | 3 | * No WArranty... |
4 | */ | 4 | */ |
5 | 5 | ||
6 | #ifndef PHUNK_MAIN_WINDOW_H | 6 | #ifndef PHUNK_MAIN_WINDOW_H |
7 | #define PHUNK_MAIN_WINDOW_H | 7 | #define PHUNK_MAIN_WINDOW_H |
8 | 8 | ||
9 | #include <opie2/oconfig.h> | 9 | #include <opie2/oconfig.h> |
10 | 10 | ||
11 | #include <qmainwindow.h> | 11 | #include <qmainwindow.h> |
12 | 12 | ||
13 | 13 | ||
14 | 14 | ||
15 | namespace Opie { | 15 | namespace Opie { |
16 | namespace Ui{ | 16 | namespace Ui{ |
17 | class OKeyConfigManager; | 17 | class OKeyConfigManager; |
18 | class OWidgetStack; | 18 | class OWidgetStack; |
19 | } | 19 | } |
20 | } | 20 | } |
21 | 21 | ||
22 | class PIconView; | 22 | class PIconView; |
23 | class imageinfo; | 23 | class imageinfo; |
24 | class ImageScrollView; | 24 | class ImageScrollView; |
25 | class PMainWindow : public QMainWindow { | 25 | class PMainWindow : public QMainWindow { |
26 | Q_OBJECT | 26 | Q_OBJECT |
27 | enum Views { IconView, ImageInfo, ImageDisplay }; | 27 | enum Views { IconView, ImageInfo, ImageDisplay }; |
28 | public: | 28 | public: |
29 | static QString appName() { return QString::fromLatin1("opie-eye" ); } | 29 | static QString appName() { return QString::fromLatin1("opie-eye" ); } |
30 | PMainWindow(QWidget*, const char*, WFlags ); | 30 | PMainWindow(QWidget*, const char*, WFlags ); |
31 | ~PMainWindow(); | 31 | ~PMainWindow(); |
32 | 32 | ||
33 | signals: | 33 | signals: |
34 | void configChanged(); | 34 | void configChanged(); |
35 | 35 | ||
36 | public slots: | 36 | public slots: |
37 | void slotShowInfo( const QString& inf ); | 37 | void slotShowInfo( const QString& inf ); |
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 | ||
41 | protected: | 43 | protected: |
42 | void raiseIconView(); | 44 | void raiseIconView(); |
43 | void closeEvent( QCloseEvent* ); | 45 | void closeEvent( QCloseEvent* ); |
44 | 46 | ||
45 | private: | 47 | private: |
46 | template<class T> void initT( const char* name, T**, int ); | 48 | template<class T> void initT( const char* name, T**, int ); |
47 | void initInfo(); | 49 | void initInfo(); |
48 | void initDisp(); | 50 | void initDisp(); |
49 | 51 | ||
50 | private: | 52 | private: |
51 | Opie::Core::OConfig *m_cfg; | 53 | Opie::Core::OConfig *m_cfg; |
52 | Opie::Ui::OWidgetStack *m_stack; | 54 | Opie::Ui::OWidgetStack *m_stack; |
53 | PIconView* m_view; | 55 | PIconView* m_view; |
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 | ||
58 | private slots: | 63 | private slots: |
59 | void slotConfig(); | 64 | void slotConfig(); |
60 | }; | 65 | }; |
61 | 66 | ||
62 | #endif | 67 | #endif |