summaryrefslogtreecommitdiff
authoralwin <alwin>2005-03-24 21:13:40 (UTC)
committer alwin <alwin>2005-03-24 21:13:40 (UTC)
commitb6fc9840f4fe9bad392167c49dbcfa2acda9ed21 (patch) (unidiff)
tree1d7d1225a9c440f5d0608d8901dfd151db8a6f1c
parent1e6c3181dcc7ec4edbe99db0d886ce7a9c483056 (diff)
downloadopie-b6fc9840f4fe9bad392167c49dbcfa2acda9ed21.zip
opie-b6fc9840f4fe9bad392167c49dbcfa2acda9ed21.tar.gz
opie-b6fc9840f4fe9bad392167c49dbcfa2acda9ed21.tar.bz2
last bugfixes on opie-eye an imagescrollview. Seems that now all is working
as it should.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiemm/oimagescrollview.cpp5
-rw-r--r--noncore/graphics/opie-eye/gui/imageview.cpp5
-rw-r--r--noncore/graphics/opie-eye/gui/mainwindow.cpp13
3 files changed, 15 insertions, 8 deletions
diff --git a/libopie2/opiemm/oimagescrollview.cpp b/libopie2/opiemm/oimagescrollview.cpp
index 10da823..76f50e1 100644
--- a/libopie2/opiemm/oimagescrollview.cpp
+++ b/libopie2/opiemm/oimagescrollview.cpp
@@ -1,674 +1,677 @@
1#include "oimagescrollview.h" 1#include "oimagescrollview.h"
2 2
3#include <opie2/oimagezoomer.h> 3#include <opie2/oimagezoomer.h>
4#include <opie2/odebug.h> 4#include <opie2/odebug.h>
5#include <opie2/oapplication.h> 5#include <opie2/oapplication.h>
6#include <opie2/owait.h> 6#include <opie2/owait.h>
7#include <opie2/opieexif.h> 7#include <opie2/opieexif.h>
8 8
9#include <qimage.h> 9#include <qimage.h>
10#include <qlayout.h> 10#include <qlayout.h>
11 11
12/* for usage with the bitset */ 12/* for usage with the bitset */
13#define AUTO_SCALE 0 13#define AUTO_SCALE 0
14#define AUTO_ROTATE 1 14#define AUTO_ROTATE 1
15#define SHOW_ZOOMER 2 15#define SHOW_ZOOMER 2
16#define FIRST_RESIZE_DONE 3 16#define FIRST_RESIZE_DONE 3
17#define IMAGE_IS_JPEG 4 17#define IMAGE_IS_JPEG 4
18#define IMAGE_SCALED_LOADED 5 18#define IMAGE_SCALED_LOADED 5
19 19
20#define SCROLLVIEW_BITSET_SIZE 6 20#define SCROLLVIEW_BITSET_SIZE 6
21 21
22namespace Opie { 22namespace Opie {
23namespace MM { 23namespace MM {
24OImageScrollView::OImageScrollView( QWidget* parent, const char* name, WFlags f ) 24OImageScrollView::OImageScrollView( QWidget* parent, const char* name, WFlags f )
25 :QScrollView(parent,name,f|Qt::WRepaintNoErase ),_image_data(),_original_data(), 25 :QScrollView(parent,name,f|Qt::WRepaintNoErase ),_image_data(),_original_data(),
26 m_states(SCROLLVIEW_BITSET_SIZE),m_lastName("") 26 m_states(SCROLLVIEW_BITSET_SIZE),m_lastName("")
27{ 27{
28 _zoomer = 0; 28 _zoomer = 0;
29 m_states[AUTO_SCALE]=true; 29 m_states[AUTO_SCALE]=true;
30 m_states[AUTO_ROTATE]=true; 30 m_states[AUTO_ROTATE]=true;
31 m_states[FIRST_RESIZE_DONE]=false; 31 m_states[FIRST_RESIZE_DONE]=false;
32 m_states[IMAGE_IS_JPEG]=false; 32 m_states[IMAGE_IS_JPEG]=false;
33 m_states[IMAGE_SCALED_LOADED]=false; 33 m_states[IMAGE_SCALED_LOADED]=false;
34 m_states[SHOW_ZOOMER]=true; 34 m_states[SHOW_ZOOMER]=true;
35 _newImage = true; 35 _newImage = true;
36 init(); 36 init();
37} 37}
38 38
39OImageScrollView::OImageScrollView (const QImage&img, QWidget * parent, const char * name, WFlags f,bool always_scale,bool rfit) 39OImageScrollView::OImageScrollView (const QImage&img, QWidget * parent, const char * name, WFlags f,bool always_scale,bool rfit)
40 :QScrollView(parent,name,f|Qt::WRepaintNoErase),_image_data(),_original_data(img), 40 :QScrollView(parent,name,f|Qt::WRepaintNoErase),_image_data(),_original_data(img),
41 m_states(SCROLLVIEW_BITSET_SIZE),m_lastName("") 41 m_states(SCROLLVIEW_BITSET_SIZE),m_lastName("")
42{ 42{
43 _zoomer = 0; 43 _zoomer = 0;
44 m_states[AUTO_SCALE]=always_scale; 44 m_states[AUTO_SCALE]=always_scale;
45 m_states[AUTO_ROTATE]=rfit; 45 m_states[AUTO_ROTATE]=rfit;
46 m_states[FIRST_RESIZE_DONE]=false; 46 m_states[FIRST_RESIZE_DONE]=false;
47 m_states[IMAGE_IS_JPEG]=false; 47 m_states[IMAGE_IS_JPEG]=false;
48 m_states[IMAGE_SCALED_LOADED]=false; 48 m_states[IMAGE_SCALED_LOADED]=false;
49 m_states[SHOW_ZOOMER]=true; 49 m_states[SHOW_ZOOMER]=true;
50 _original_data.convertDepth(QPixmap::defaultDepth()); 50 _original_data.convertDepth(QPixmap::defaultDepth());
51 _original_data.setAlphaBuffer(false); 51 _original_data.setAlphaBuffer(false);
52 _newImage = true; 52 _newImage = true;
53 init(); 53 init();
54} 54}
55 55
56OImageScrollView::OImageScrollView (const QString&img, QWidget * parent, const char * name, WFlags f,bool always_scale,bool rfit) 56OImageScrollView::OImageScrollView (const QString&img, QWidget * parent, const char * name, WFlags f,bool always_scale,bool rfit)
57 :QScrollView(parent,name,f|Qt::WRepaintNoErase),_image_data(),_original_data(),m_states(SCROLLVIEW_BITSET_SIZE),m_lastName("") 57 :QScrollView(parent,name,f|Qt::WRepaintNoErase),_image_data(),_original_data(),m_states(SCROLLVIEW_BITSET_SIZE),m_lastName("")
58{ 58{
59 _zoomer = 0; 59 _zoomer = 0;
60 m_states.resize(SCROLLVIEW_BITSET_SIZE); 60 m_states.resize(SCROLLVIEW_BITSET_SIZE);
61 m_states[AUTO_SCALE]=always_scale; 61 m_states[AUTO_SCALE]=always_scale;
62 m_states[AUTO_ROTATE]=rfit; 62 m_states[AUTO_ROTATE]=rfit;
63 m_states[FIRST_RESIZE_DONE]=false; 63 m_states[FIRST_RESIZE_DONE]=false;
64 m_states[IMAGE_IS_JPEG]=false; 64 m_states[IMAGE_IS_JPEG]=false;
65 m_states[IMAGE_SCALED_LOADED]=false; 65 m_states[IMAGE_SCALED_LOADED]=false;
66 m_states[SHOW_ZOOMER]=true; 66 m_states[SHOW_ZOOMER]=true;
67 _newImage = true; 67 _newImage = true;
68 init(); 68 init();
69 setImage(img); 69 setImage(img);
70} 70}
71 71
72void OImageScrollView::setImage(const QImage&img) 72void OImageScrollView::setImage(const QImage&img)
73{ 73{
74 _image_data = QImage(); 74 _image_data = QImage();
75 _original_data=img; 75 _original_data=img;
76 _original_data.convertDepth(QPixmap::defaultDepth()); 76 _original_data.convertDepth(QPixmap::defaultDepth());
77 _original_data.setAlphaBuffer(false); 77 _original_data.setAlphaBuffer(false);
78 m_lastName = ""; 78 m_lastName = "";
79 setImageIsJpeg(false); 79 setImageIsJpeg(false);
80 setImageScaledLoaded(false); 80 setImageScaledLoaded(false);
81 _newImage = true; 81 _newImage = true;
82 if (FirstResizeDone()) { 82 if (FirstResizeDone()) {
83 generateImage(); 83 generateImage();
84 } 84 }
85} 85}
86 86
87void OImageScrollView::loadJpeg(bool interncall) 87void OImageScrollView::loadJpeg(bool interncall)
88{ 88{
89 if (m_lastName.isEmpty()) return; 89 if (m_lastName.isEmpty()) return;
90 QImageIO iio( m_lastName, 0l ); 90 QImageIO iio( m_lastName, 0l );
91 QString param; 91 QString param;
92 bool real_load = false; 92 bool real_load = false;
93 _newImage = true; 93 _newImage = true;
94 if (AutoScale()) { 94 if (AutoScale()) {
95 if (!interncall) { 95 if (!interncall) {
96 ExifData xf; 96 ExifData xf;
97 bool scanned = xf.scan(m_lastName); 97 bool scanned = xf.scan(m_lastName);
98 int wid, hei; 98 int wid, hei;
99 wid = QApplication::desktop()->width(); 99 wid = QApplication::desktop()->width();
100 hei = QApplication::desktop()->height(); 100 hei = QApplication::desktop()->height();
101 if (hei>wid) { 101 if (hei>wid) {
102 wid = hei; 102 wid = hei;
103 } else { 103 } else {
104 hei = wid; 104 hei = wid;
105 } 105 }
106 if ( (scanned && (wid<xf.getWidth()||hei<xf.getHeight()))||!scanned ) { 106 if ( (scanned && (wid<xf.getWidth()||hei<xf.getHeight()))||!scanned ) {
107 param = QString( "Fast Shrink( 3 ) Scale( %1, %2, ScaleMin)" ).arg( wid ).arg( hei ); 107 param = QString( "Fast Shrink( 3 ) Scale( %1, %2, ScaleMin)" ).arg( wid ).arg( hei );
108 iio.setParameters(param.latin1()); 108 iio.setParameters(param.latin1());
109 setImageScaledLoaded(true); 109 setImageScaledLoaded(true);
110 } 110 }
111 111
112 real_load = true; 112 real_load = true;
113 } 113 }
114 } else { 114 } else {
115 if (ImageScaledLoaded()||!interncall) { 115 if (ImageScaledLoaded()||!interncall) {
116 real_load = true; 116 real_load = true;
117 } 117 }
118 setImageScaledLoaded(false); 118 setImageScaledLoaded(false);
119 } 119 }
120 if (real_load) { 120 if (real_load) {
121 _original_data = iio.read() ? iio.image() : QImage(); 121 _original_data = iio.read() ? iio.image() : QImage();
122 } 122 }
123} 123}
124 124
125void OImageScrollView::setImage( const QString& path ) { 125void OImageScrollView::setImage( const QString& path ) {
126 if (m_lastName == path) return; 126 if (m_lastName == path) return;
127 m_lastName = path; 127 m_lastName = path;
128 _newImage = true; 128 _newImage = true;
129 _original_data = QImage(); 129 _original_data = QImage();
130 QString itype = QImage::imageFormat(m_lastName); 130 QString itype = QImage::imageFormat(m_lastName);
131 if (itype == "JPEG") { 131 if (itype == "JPEG") {
132 setImageIsJpeg(true); 132 setImageIsJpeg(true);
133 loadJpeg(); 133 loadJpeg();
134 } else { 134 } else {
135 setImageIsJpeg(false); 135 setImageIsJpeg(false);
136 _original_data.load(path); 136 _original_data.load(path);
137 _original_data.convertDepth(QPixmap::defaultDepth()); 137 _original_data.convertDepth(QPixmap::defaultDepth());
138 _original_data.setAlphaBuffer(false); 138 _original_data.setAlphaBuffer(false);
139 } 139 }
140 _image_data = QImage(); 140 _image_data = QImage();
141 if (FirstResizeDone()) { 141 if (FirstResizeDone()) {
142 generateImage(); 142 generateImage();
143 if (isVisible()) viewport()->repaint(true); 143 if (isVisible()) viewport()->repaint(true);
144 } 144 }
145} 145}
146 146
147/* should be called every time the QImage changed it content */ 147/* should be called every time the QImage changed it content */
148void OImageScrollView::init() 148void OImageScrollView::init()
149{ 149{
150 /* 150 /*
151 * create the zoomer 151 * create the zoomer
152 * and connect ther various signals 152 * and connect ther various signals
153 */ 153 */
154 _zoomer = new Opie::MM::OImageZoomer( this, "The Zoomer" ); 154 _zoomer = new Opie::MM::OImageZoomer( this, "The Zoomer" );
155 connect(_zoomer, SIGNAL( zoomAreaRel(int,int)), 155 connect(_zoomer, SIGNAL( zoomAreaRel(int,int)),
156 this, SLOT(scrollBy(int,int)) ); 156 this, SLOT(scrollBy(int,int)) );
157 connect(_zoomer, SIGNAL( zoomArea(int,int)), 157 connect(_zoomer, SIGNAL( zoomArea(int,int)),
158 this, SLOT(center(int,int)) ); 158 this, SLOT(center(int,int)) );
159 connect(this,SIGNAL(contentsMoving(int,int)), 159 connect(this,SIGNAL(contentsMoving(int,int)),
160 _zoomer, (SLOT(setVisiblePoint(int,int))) ); 160 _zoomer, (SLOT(setVisiblePoint(int,int))) );
161 connect(this,SIGNAL(imageSizeChanged(const QSize&)), 161 connect(this,SIGNAL(imageSizeChanged(const QSize&)),
162 _zoomer, SLOT(setImageSize(const QSize&)) ); 162 _zoomer, SLOT(setImageSize(const QSize&)) );
163 connect(this,SIGNAL(viewportSizeChanged(const QSize&)), 163 connect(this,SIGNAL(viewportSizeChanged(const QSize&)),
164 _zoomer, SLOT(setViewPortSize(const QSize&)) ); 164 _zoomer, SLOT(setViewPortSize(const QSize&)) );
165 165
166 setBackgroundColor(white); 166 setBackgroundColor(white);
167 setFocusPolicy(QWidget::StrongFocus); 167 setFocusPolicy(QWidget::StrongFocus);
168 setImageScaledLoaded(false); 168 setImageScaledLoaded(false);
169 setImageIsJpeg(false); 169 setImageIsJpeg(false);
170 if (FirstResizeDone()) { 170 if (FirstResizeDone()) {
171 m_last_rot = Rotate0; 171 m_last_rot = Rotate0;
172 generateImage(); 172 generateImage();
173 } else if (_original_data.size().isValid()) { 173 } else if (_original_data.size().isValid()) {
174 if (image_fit_into(_original_data.size()) || !ShowZoomer()) _zoomer->hide(); 174 if (image_fit_into(_original_data.size()) || !ShowZoomer()) _zoomer->hide();
175 resizeContents(_original_data.width(),_original_data.height()); 175 resizeContents(_original_data.width(),_original_data.height());
176 } 176 }
177 _intensity = 0; 177 _intensity = 0;
178} 178}
179 179
180void OImageScrollView::setAutoRotate(bool how) 180void OImageScrollView::setAutoRotate(bool how)
181{ 181{
182 /* to avoid double repaints */ 182 /* to avoid double repaints */
183 if (AutoRotate() != how) { 183 if (AutoRotate() != how) {
184 m_states.setBit(AUTO_ROTATE,how); 184 m_states.setBit(AUTO_ROTATE,how);
185 _image_data = QImage(); 185 _image_data = QImage();
186 generateImage(); 186 generateImage();
187 } 187 }
188} 188}
189 189
190bool OImageScrollView::AutoRotate()const 190bool OImageScrollView::AutoRotate()const
191{ 191{
192 return m_states.testBit(AUTO_ROTATE); 192 return m_states.testBit(AUTO_ROTATE);
193} 193}
194 194
195void OImageScrollView::setAutoScaleRotate(bool scale, bool rotate) 195void OImageScrollView::setAutoScaleRotate(bool scale, bool rotate)
196{ 196{
197 m_states.setBit(AUTO_ROTATE,rotate); 197 m_states.setBit(AUTO_ROTATE,rotate);
198 setAutoScale(scale); 198 setAutoScale(scale);
199} 199}
200 200
201void OImageScrollView::setAutoScale(bool how) 201void OImageScrollView::setAutoScale(bool how)
202{ 202{
203 m_states.setBit(AUTO_SCALE,how); 203 m_states.setBit(AUTO_SCALE,how);
204 _image_data = QImage(); 204 _image_data = QImage();
205 if (ImageIsJpeg() && how == false && ImageScaledLoaded()==true) { 205 if (ImageIsJpeg() && how == false && ImageScaledLoaded()==true) {
206 loadJpeg(true); 206 loadJpeg(true);
207 } 207 }
208 _newImage = true;
208 generateImage(); 209 generateImage();
209} 210}
210 211
211bool OImageScrollView::AutoScale()const 212bool OImageScrollView::AutoScale()const
212{ 213{
213 return m_states.testBit(AUTO_SCALE); 214 return m_states.testBit(AUTO_SCALE);
214} 215}
215 216
216OImageScrollView::~OImageScrollView() 217OImageScrollView::~OImageScrollView()
217{ 218{
218} 219}
219 220
220void OImageScrollView::rescaleImage(int w, int h) 221void OImageScrollView::rescaleImage(int w, int h)
221{ 222{
222 if (_image_data.width()==w && _image_data.height()==h) { 223 if (_image_data.width()==w && _image_data.height()==h) {
223 return; 224 return;
224 } 225 }
225 double hs = (double)h / (double)_image_data.height() ; 226 double hs = (double)h / (double)_image_data.height() ;
226 double ws = (double)w / (double)_image_data.width() ; 227 double ws = (double)w / (double)_image_data.width() ;
227 double scaleFactor = (hs > ws) ? ws : hs; 228 double scaleFactor = (hs > ws) ? ws : hs;
228 int smoothW = (int)(scaleFactor * _image_data.width()); 229 int smoothW = (int)(scaleFactor * _image_data.width());
229 int smoothH = (int)(scaleFactor * _image_data.height()); 230 int smoothH = (int)(scaleFactor * _image_data.height());
230 _image_data = _image_data.smoothScale(smoothW,smoothH); 231 _image_data = _image_data.smoothScale(smoothW,smoothH);
231} 232}
232 233
233void OImageScrollView::rotate_into_data(Rotation r) 234void OImageScrollView::rotate_into_data(Rotation r)
234{ 235{
235 /* realy - we must do this that way, 'cause when acting direct on _image_data the app will 236 /* realy - we must do this that way, 'cause when acting direct on _image_data the app will
236 segfault :( */ 237 segfault :( */
237 QImage dest; 238 QImage dest;
238 int x, y; 239 int x, y;
239 if ( _original_data.depth() > 8 ) 240 if ( _original_data.depth() > 8 )
240 { 241 {
241 unsigned int *srcData, *destData; 242 unsigned int *srcData, *destData;
242 switch ( r ) 243 switch ( r )
243 { 244 {
244 case Rotate90: 245 case Rotate90:
245 dest.create(_original_data.height(), _original_data.width(), _original_data.depth()); 246 dest.create(_original_data.height(), _original_data.width(), _original_data.depth());
246 for ( y=0; y < _original_data.height(); ++y ) 247 for ( y=0; y < _original_data.height(); ++y )
247 { 248 {
248 srcData = (unsigned int *)_original_data.scanLine(y); 249 srcData = (unsigned int *)_original_data.scanLine(y);
249 for ( x=0; x < _original_data.width(); ++x ) 250 for ( x=0; x < _original_data.width(); ++x )
250 { 251 {
251 destData = (unsigned int *)dest.scanLine(x); 252 destData = (unsigned int *)dest.scanLine(x);
252 destData[_original_data.height()-y-1] = srcData[x]; 253 destData[_original_data.height()-y-1] = srcData[x];
253 } 254 }
254 } 255 }
255 break; 256 break;
256 case Rotate180: 257 case Rotate180:
257 dest.create(_original_data.width(), _original_data.height(), _original_data.depth()); 258 dest.create(_original_data.width(), _original_data.height(), _original_data.depth());
258 for ( y=0; y < _original_data.height(); ++y ) 259 for ( y=0; y < _original_data.height(); ++y )
259 { 260 {
260 srcData = (unsigned int *)_original_data.scanLine(y); 261 srcData = (unsigned int *)_original_data.scanLine(y);
261 destData = (unsigned int *)dest.scanLine(_original_data.height()-y-1); 262 destData = (unsigned int *)dest.scanLine(_original_data.height()-y-1);
262 for ( x=0; x < _original_data.width(); ++x ) 263 for ( x=0; x < _original_data.width(); ++x )
263 destData[_original_data.width()-x-1] = srcData[x]; 264 destData[_original_data.width()-x-1] = srcData[x];
264 } 265 }
265 break; 266 break;
266 case Rotate270: 267 case Rotate270:
267 dest.create(_original_data.height(), _original_data.width(), _original_data.depth()); 268 dest.create(_original_data.height(), _original_data.width(), _original_data.depth());
268 for ( y=0; y < _original_data.height(); ++y ) 269 for ( y=0; y < _original_data.height(); ++y )
269 { 270 {
270 srcData = (unsigned int *)_original_data.scanLine(y); 271 srcData = (unsigned int *)_original_data.scanLine(y);
271 for ( x=0; x < _original_data.width(); ++x ) 272 for ( x=0; x < _original_data.width(); ++x )
272 { 273 {
273 destData = (unsigned int *)dest.scanLine(_original_data.width()-x-1); 274 destData = (unsigned int *)dest.scanLine(_original_data.width()-x-1);
274 destData[y] = srcData[x]; 275 destData[y] = srcData[x];
275 } 276 }
276 } 277 }
277 break; 278 break;
278 default: 279 default:
279 dest = _original_data; 280 dest = _original_data;
280 break; 281 break;
281 } 282 }
282 } 283 }
283 else 284 else
284 { 285 {
285 unsigned char *srcData, *destData; 286 unsigned char *srcData, *destData;
286 unsigned int *srcTable, *destTable; 287 unsigned int *srcTable, *destTable;
287 switch ( r ) 288 switch ( r )
288 { 289 {
289 case Rotate90: 290 case Rotate90:
290 dest.create(_original_data.height(), _original_data.width(), _original_data.depth()); 291 dest.create(_original_data.height(), _original_data.width(), _original_data.depth());
291 dest.setNumColors(_original_data.numColors()); 292 dest.setNumColors(_original_data.numColors());
292 srcTable = (unsigned int *)_original_data.colorTable(); 293 srcTable = (unsigned int *)_original_data.colorTable();
293 destTable = (unsigned int *)dest.colorTable(); 294 destTable = (unsigned int *)dest.colorTable();
294 for ( x=0; x < _original_data.numColors(); ++x ) 295 for ( x=0; x < _original_data.numColors(); ++x )
295 destTable[x] = srcTable[x]; 296 destTable[x] = srcTable[x];
296 for ( y=0; y < _original_data.height(); ++y ) 297 for ( y=0; y < _original_data.height(); ++y )
297 { 298 {
298 srcData = (unsigned char *)_original_data.scanLine(y); 299 srcData = (unsigned char *)_original_data.scanLine(y);
299 for ( x=0; x < _original_data.width(); ++x ) 300 for ( x=0; x < _original_data.width(); ++x )
300 { 301 {
301 destData = (unsigned char *)dest.scanLine(x); 302 destData = (unsigned char *)dest.scanLine(x);
302 destData[_original_data.height()-y-1] = srcData[x]; 303 destData[_original_data.height()-y-1] = srcData[x];
303 } 304 }
304 } 305 }
305 break; 306 break;
306 case Rotate180: 307 case Rotate180:
307 dest.create(_original_data.width(), _original_data.height(), _original_data.depth()); 308 dest.create(_original_data.width(), _original_data.height(), _original_data.depth());
308 dest.setNumColors(_original_data.numColors()); 309 dest.setNumColors(_original_data.numColors());
309 srcTable = (unsigned int *)_original_data.colorTable(); 310 srcTable = (unsigned int *)_original_data.colorTable();
310 destTable = (unsigned int *)dest.colorTable(); 311 destTable = (unsigned int *)dest.colorTable();
311 for ( x=0; x < _original_data.numColors(); ++x ) 312 for ( x=0; x < _original_data.numColors(); ++x )
312 destTable[x] = srcTable[x]; 313 destTable[x] = srcTable[x];
313 for ( y=0; y < _original_data.height(); ++y ) 314 for ( y=0; y < _original_data.height(); ++y )
314 { 315 {
315 srcData = (unsigned char *)_original_data.scanLine(y); 316 srcData = (unsigned char *)_original_data.scanLine(y);
316 destData = (unsigned char *)dest.scanLine(_original_data.height()-y-1); 317 destData = (unsigned char *)dest.scanLine(_original_data.height()-y-1);
317 for ( x=0; x < _original_data.width(); ++x ) 318 for ( x=0; x < _original_data.width(); ++x )
318 destData[_original_data.width()-x-1] = srcData[x]; 319 destData[_original_data.width()-x-1] = srcData[x];
319 } 320 }
320 break; 321 break;
321 case Rotate270: 322 case Rotate270:
322 dest.create(_original_data.height(), _original_data.width(), _original_data.depth()); 323 dest.create(_original_data.height(), _original_data.width(), _original_data.depth());
323 dest.setNumColors(_original_data.numColors()); 324 dest.setNumColors(_original_data.numColors());
324 srcTable = (unsigned int *)_original_data.colorTable(); 325 srcTable = (unsigned int *)_original_data.colorTable();
325 destTable = (unsigned int *)dest.colorTable(); 326 destTable = (unsigned int *)dest.colorTable();
326 for ( x=0; x < _original_data.numColors(); ++x ) 327 for ( x=0; x < _original_data.numColors(); ++x )
327 destTable[x] = srcTable[x]; 328 destTable[x] = srcTable[x];
328 for ( y=0; y < _original_data.height(); ++y ) 329 for ( y=0; y < _original_data.height(); ++y )
329 { 330 {
330 srcData = (unsigned char *)_original_data.scanLine(y); 331 srcData = (unsigned char *)_original_data.scanLine(y);
331 for ( x=0; x < _original_data.width(); ++x ) 332 for ( x=0; x < _original_data.width(); ++x )
332 { 333 {
333 destData = (unsigned char *)dest.scanLine(_original_data.width()-x-1); 334 destData = (unsigned char *)dest.scanLine(_original_data.width()-x-1);
334 destData[y] = srcData[x]; 335 destData[y] = srcData[x];
335 } 336 }
336 } 337 }
337 break; 338 break;
338 default: 339 default:
339 dest = _original_data; 340 dest = _original_data;
340 break; 341 break;
341 } 342 }
342 343
343 } 344 }
344 _newImage = true; 345 _newImage = true;
345 _image_data = dest; 346 _image_data = dest;
346} 347}
347 348
348// yes - sorry - it is NOT gamma it is just BRIGHTNESS. Alwin 349// yes - sorry - it is NOT gamma it is just BRIGHTNESS. Alwin
349void OImageScrollView::apply_gamma(int aValue) 350void OImageScrollView::apply_gamma(int aValue)
350{ 351{
351 if (!_image_data.size().isValid()) return; 352 if (aValue==0 || !_image_data.size().isValid()) return;
352 float percent = ((float)aValue/100.0); 353 float percent = ((float)aValue/100.0);
354 /* make sure working on a copy */
355 _image_data.detach();
353 356
354 int segColors = _image_data.depth() > 8 ? 256 : _image_data.numColors(); 357 int segColors = _image_data.depth() > 8 ? 256 : _image_data.numColors();
355 /* must be - otherwise it displays some ... strange colors */ 358 /* must be - otherwise it displays some ... strange colors */
356 if (segColors<256) segColors=256; 359 if (segColors<256) segColors=256;
357 360
358 unsigned char *segTbl = new unsigned char[segColors]; 361 unsigned char *segTbl = new unsigned char[segColors];
359 int pixels = _image_data.depth()>8?_image_data.width()*_image_data.height() : _image_data.numColors(); 362 int pixels = _image_data.depth()>8?_image_data.width()*_image_data.height() : _image_data.numColors();
360 363
361 364
362 bool brighten = (percent >= 0); 365 bool brighten = (percent >= 0);
363 if ( percent < 0 ) { 366 if ( percent < 0 ) {
364 percent = -percent; 367 percent = -percent;
365 } 368 }
366 369
367 unsigned int *data = _image_data.depth() > 8 ? (unsigned int *)_image_data.bits() : 370 unsigned int *data = _image_data.depth() > 8 ? (unsigned int *)_image_data.bits() :
368 (unsigned int *)_image_data.colorTable(); 371 (unsigned int *)_image_data.colorTable();
369 372
370 int tmp = 0; 373 int tmp = 0;
371 374
372 if (brighten) { 375 if (brighten) {
373 for ( int i=0; i < segColors; ++i ) 376 for ( int i=0; i < segColors; ++i )
374 { 377 {
375 tmp = (int)(i*percent); 378 tmp = (int)(i*percent);
376 if ( tmp > 255 ) 379 if ( tmp > 255 )
377 tmp = 255; 380 tmp = 255;
378 segTbl[i] = tmp; 381 segTbl[i] = tmp;
379 } 382 }
380 } else { 383 } else {
381 for ( int i=0; i < segColors; ++i ) 384 for ( int i=0; i < segColors; ++i )
382 { 385 {
383 tmp = (int)(i*percent); 386 tmp = (int)(i*percent);
384 if ( tmp < 0 ) 387 if ( tmp < 0 )
385 tmp = 0; 388 tmp = 0;
386 segTbl[i] = tmp; 389 segTbl[i] = tmp;
387 } 390 }
388 } 391 }
389 if (brighten) { 392 if (brighten) {
390 for ( int i=0; i < pixels; ++i ) 393 for ( int i=0; i < pixels; ++i )
391 { 394 {
392 int r = qRed(data[i]); 395 int r = qRed(data[i]);
393 int g = qGreen(data[i]); 396 int g = qGreen(data[i]);
394 int b = qBlue(data[i]); 397 int b = qBlue(data[i]);
395 int a = qAlpha(data[i]); 398 int a = qAlpha(data[i]);
396 r = r + segTbl[r] > 255 ? 255 : r + segTbl[r]; 399 r = r + segTbl[r] > 255 ? 255 : r + segTbl[r];
397 g = g + segTbl[g] > 255 ? 255 : g + segTbl[g]; 400 g = g + segTbl[g] > 255 ? 255 : g + segTbl[g];
398 b = b + segTbl[b] > 255 ? 255 : b + segTbl[b]; 401 b = b + segTbl[b] > 255 ? 255 : b + segTbl[b];
399 data[i] = qRgba(r, g, b,a); 402 data[i] = qRgba(r, g, b,a);
400 } 403 }
401 } else { 404 } else {
402 for ( int i=0; i < pixels; ++i ) 405 for ( int i=0; i < pixels; ++i )
403 { 406 {
404 int r = qRed(data[i]); 407 int r = qRed(data[i]);
405 int g = qGreen(data[i]); 408 int g = qGreen(data[i]);
406 int b = qBlue(data[i]); 409 int b = qBlue(data[i]);
407 int a = qAlpha(data[i]); 410 int a = qAlpha(data[i]);
408 r = r - segTbl[r] < 0 ? 0 : r - segTbl[r]; 411 r = r - segTbl[r] < 0 ? 0 : r - segTbl[r];
409 g = g - segTbl[g] < 0 ? 0 : g - segTbl[g]; 412 g = g - segTbl[g] < 0 ? 0 : g - segTbl[g];
410 b = b - segTbl[b] < 0 ? 0 : b - segTbl[b]; 413 b = b - segTbl[b] < 0 ? 0 : b - segTbl[b];
411 data[i] = qRgba(r, g, b, a); 414 data[i] = qRgba(r, g, b, a);
412 } 415 }
413 } 416 }
414 delete [] segTbl; 417 delete [] segTbl;
415} 418}
416 419
417const int OImageScrollView::Intensity()const 420const int OImageScrollView::Intensity()const
418{ 421{
419 return _intensity; 422 return _intensity;
420} 423}
421 424
422int OImageScrollView::setIntensity(int value,bool reload) 425int OImageScrollView::setIntensity(int value,bool reload)
423{ 426{
424 int oldi = _intensity; 427 int oldi = _intensity;
425 _intensity = value; 428 _intensity = value;
426 if (!_pdata.size().isValid()) { 429 if (!_pdata.size().isValid()) {
427 return _intensity; 430 return _intensity;
428 } 431 }
429 432
430 if (!reload) { 433 if (!reload) {
431 _image_data = _pdata.convertToImage(); 434 _image_data = _pdata.convertToImage();
432 apply_gamma(_intensity-oldi); 435 apply_gamma(_intensity-oldi);
433 _pdata.convertFromImage(_image_data); 436 _pdata.convertFromImage(_image_data);
434 /* 437 /*
435 * invalidate 438 * invalidate
436 */ 439 */
437 _image_data=QImage(); 440 _image_data=QImage();
438 if (isVisible()) { 441 if (isVisible()) {
439 updateContents(contentsX(),contentsY(),width(),height()); 442 updateContents(contentsX(),contentsY(),width(),height());
440 } 443 }
441 } else { 444 } else {
442 _newImage = true; 445 _newImage = true;
443 generateImage(); 446 generateImage();
444 } 447 }
445 return _intensity; 448 return _intensity;
446} 449}
447 450
448void OImageScrollView::generateImage() 451void OImageScrollView::generateImage()
449{ 452{
450 Rotation r = Rotate0; 453 Rotation r = Rotate0;
451 _pdata = QPixmap(); 454 _pdata = QPixmap();
452 if (_original_data.isNull()) { 455 if (_original_data.isNull()) {
453 emit imageSizeChanged( _image_data.size() ); 456 emit imageSizeChanged( _image_data.size() );
454 if (_zoomer) _zoomer->setImage( _image_data ); 457 if (_zoomer) _zoomer->setImage( _image_data );
455 return; 458 return;
456 } 459 }
457 if (width()>height()&&_original_data.width()<_original_data.height() || 460 if (width()>height()&&_original_data.width()<_original_data.height() ||
458 width()<height()&&_original_data.width()>_original_data.height()) { 461 width()<height()&&_original_data.width()>_original_data.height()) {
459 if (AutoRotate()) r = Rotate90; 462 if (AutoRotate()) r = Rotate90;
460 } 463 }
461 464
462 int twidth,theight; 465 int twidth,theight;
463 if (AutoScale() && (_original_data.width()>width() || _original_data.height() > height()) ) { 466 if (AutoScale() && (_original_data.width()>width() || _original_data.height() > height()) ) {
464 if (!_image_data.size().isValid()||width()>_image_data.width()||height()>_image_data.height()) { 467 if (!_image_data.size().isValid()||width()>_image_data.width()||height()>_image_data.height()) {
465 if (r==Rotate0) { 468 if (r==Rotate0) {
466 _image_data = _original_data; 469 _image_data = _original_data;
467 } else { 470 } else {
468 rotate_into_data(r); 471 rotate_into_data(r);
469 } 472 }
470 _newImage = true; 473 _newImage = true;
471 } 474 }
472 rescaleImage(width(),height()); 475 rescaleImage(width(),height());
473 } else if (!FirstResizeDone()||r!=m_last_rot||_image_data.width()==0) { 476 } else if (!FirstResizeDone()||r!=m_last_rot||_image_data.width()==0) {
474 if (r==Rotate0) { 477 if (r==Rotate0) {
475 _image_data = _original_data; 478 _image_data = _original_data;
476 } else { 479 } else {
477 rotate_into_data(r); 480 rotate_into_data(r);
478 } 481 }
479 m_last_rot = r; 482 m_last_rot = r;
480 } 483 }
481 484
482 if (_newImage) { 485 if (_newImage) {
483 apply_gamma(_intensity); 486 apply_gamma(_intensity);
484 _newImage = false; 487 _newImage = false;
485 } 488 }
486 489
487 _pdata.convertFromImage(_image_data); 490 _pdata.convertFromImage(_image_data);
488 twidth = _image_data.width(); 491 twidth = _image_data.width();
489 theight = _image_data.height(); 492 theight = _image_data.height();
490 493
491 /* 494 /*
492 * update the zoomer 495 * update the zoomer
493 */ 496 */
494 check_zoomer(); 497 check_zoomer();
495 emit imageSizeChanged( _image_data.size() ); 498 emit imageSizeChanged( _image_data.size() );
496 rescaleImage( 128, 128 ); 499 rescaleImage( 128, 128 );
497 resizeContents(twidth,theight); 500 resizeContents(twidth,theight);
498 /* 501 /*
499 * move scrollbar 502 * move scrollbar
500 */ 503 */
501 if (_zoomer) { 504 if (_zoomer) {
502 _zoomer->setGeometry( viewport()->width()-_image_data.width()/2, viewport()->height()-_image_data.height()/2, 505 _zoomer->setGeometry( viewport()->width()-_image_data.width()/2, viewport()->height()-_image_data.height()/2,
503 _image_data.width()/2, _image_data.height()/2 ); 506 _image_data.width()/2, _image_data.height()/2 );
504 _zoomer->setImage( _image_data ); 507 _zoomer->setImage( _image_data );
505 } 508 }
506 /* 509 /*
507 * invalidate 510 * invalidate
508 */ 511 */
509 _image_data=QImage(); 512 _image_data=QImage();
510 if (isVisible()) { 513 if (isVisible()) {
511 updateContents(contentsX(),contentsY(),width(),height()); 514 updateContents(contentsX(),contentsY(),width(),height());
512 } 515 }
513} 516}
514 517
515void OImageScrollView::resizeEvent(QResizeEvent * e) 518void OImageScrollView::resizeEvent(QResizeEvent * e)
516{ 519{
517 QScrollView::resizeEvent(e); 520 QScrollView::resizeEvent(e);
518 if (e->oldSize()==e->size()||!isUpdatesEnabled ()) return; 521 if (e->oldSize()==e->size()||!isUpdatesEnabled ()) return;
519 generateImage(); 522 generateImage();
520 setFirstResizeDone(true); 523 setFirstResizeDone(true);
521 emit viewportSizeChanged( viewport()->size() ); 524 emit viewportSizeChanged( viewport()->size() );
522 525
523} 526}
524 527
525void OImageScrollView::keyPressEvent(QKeyEvent * e) 528void OImageScrollView::keyPressEvent(QKeyEvent * e)
526{ 529{
527 if (!e) return; 530 if (!e) return;
528 int dx = horizontalScrollBar()->lineStep(); 531 int dx = horizontalScrollBar()->lineStep();
529 int dy = verticalScrollBar()->lineStep(); 532 int dy = verticalScrollBar()->lineStep();
530 if (e->key()==Qt::Key_Right) { 533 if (e->key()==Qt::Key_Right) {
531 scrollBy(dx,0); 534 scrollBy(dx,0);
532 e->accept(); 535 e->accept();
533 } else if (e->key()==Qt::Key_Left) { 536 } else if (e->key()==Qt::Key_Left) {
534 scrollBy(0-dx,0); 537 scrollBy(0-dx,0);
535 e->accept(); 538 e->accept();
536 } else if (e->key()==Qt::Key_Up) { 539 } else if (e->key()==Qt::Key_Up) {
537 scrollBy(0,0-dy); 540 scrollBy(0,0-dy);
538 e->accept(); 541 e->accept();
539 } else if (e->key()==Qt::Key_Down) { 542 } else if (e->key()==Qt::Key_Down) {
540 scrollBy(0,dy); 543 scrollBy(0,dy);
541 e->accept(); 544 e->accept();
542 } else { 545 } else {
543 e->ignore(); 546 e->ignore();
544 } 547 }
545 QScrollView::keyPressEvent(e); 548 QScrollView::keyPressEvent(e);
546} 549}
547 550
548void OImageScrollView::drawContents(QPainter * p, int clipx, int clipy, int clipw, int cliph) 551void OImageScrollView::drawContents(QPainter * p, int clipx, int clipy, int clipw, int cliph)
549{ 552{
550 if (!_pdata.size().isValid()) { 553 if (!_pdata.size().isValid()) {
551 p->fillRect(clipx,clipy,clipw,cliph, backgroundColor()); 554 p->fillRect(clipx,clipy,clipw,cliph, backgroundColor());
552 return; 555 return;
553 } 556 }
554 557
555 int w = clipw; 558 int w = clipw;
556 int h = cliph; 559 int h = cliph;
557 int x = clipx; 560 int x = clipx;
558 int y = clipy; 561 int y = clipy;
559 bool erase = false; 562 bool erase = false;
560 563
561 if (w>_pdata.width()) { 564 if (w>_pdata.width()) {
562 w = _pdata.width()-x; 565 w = _pdata.width()-x;
563 erase=true; 566 erase=true;
564 } 567 }
565 if (h>_pdata.height()) { 568 if (h>_pdata.height()) {
566 h = _pdata.height()-y; 569 h = _pdata.height()-y;
567 erase=true; 570 erase=true;
568 } 571 }
569 if (!erase && (clipy+cliph>_pdata.height()||clipx+clipw>_pdata.width())) { 572 if (!erase && (clipy+cliph>_pdata.height()||clipx+clipw>_pdata.width())) {
570 erase = true; 573 erase = true;
571 } 574 }
572 if (erase||_original_data.hasAlphaBuffer()) { 575 if (erase||_original_data.hasAlphaBuffer()) {
573 p->fillRect(clipx,clipy,clipw,cliph, backgroundColor()); 576 p->fillRect(clipx,clipy,clipw,cliph, backgroundColor());
574 } 577 }
575 if (w>0 && h>0&&x<_pdata.width()&&y<_pdata.height()) { 578 if (w>0 && h>0&&x<_pdata.width()&&y<_pdata.height()) {
576 p->drawPixmap(clipx,clipy,_pdata,x,y,w,h); 579 p->drawPixmap(clipx,clipy,_pdata,x,y,w,h);
577 } 580 }
578} 581}
579 582
580/* using the real geometry points and not the translated points is wanted! */ 583/* using the real geometry points and not the translated points is wanted! */
581void OImageScrollView::viewportMouseMoveEvent(QMouseEvent* e) 584void OImageScrollView::viewportMouseMoveEvent(QMouseEvent* e)
582{ 585{
583 int mx, my; 586 int mx, my;
584 mx = e->x(); 587 mx = e->x();
585 my = e->y(); 588 my = e->y();
586 if (_mouseStartPosX!=-1 && _mouseStartPosY!=-1) { 589 if (_mouseStartPosX!=-1 && _mouseStartPosY!=-1) {
587 int diffx = _mouseStartPosX-mx; 590 int diffx = _mouseStartPosX-mx;
588 int diffy = _mouseStartPosY-my; 591 int diffy = _mouseStartPosY-my;
589 scrollBy(diffx,diffy); 592 scrollBy(diffx,diffy);
590 } 593 }
591 _mouseStartPosX=mx; 594 _mouseStartPosX=mx;
592 _mouseStartPosY=my; 595 _mouseStartPosY=my;
593} 596}
594 597
595void OImageScrollView::contentsMousePressEvent ( QMouseEvent * e) 598void OImageScrollView::contentsMousePressEvent ( QMouseEvent * e)
596{ 599{
597 /* this marks the beginning of a possible mouse move. Due internal reasons of QT 600 /* this marks the beginning of a possible mouse move. Due internal reasons of QT
598 the geometry values here may real differ from that set in MoveEvent (I don't know 601 the geometry values here may real differ from that set in MoveEvent (I don't know
599 why). For getting them in real context, we use the first move-event to set the start 602 why). For getting them in real context, we use the first move-event to set the start
600 position ;) 603 position ;)
601 */ 604 */
602 _mouseStartPosX = -1; 605 _mouseStartPosX = -1;
603 _mouseStartPosY = -1; 606 _mouseStartPosY = -1;
604} 607}
605 608
606void OImageScrollView::setDestructiveClose() { 609void OImageScrollView::setDestructiveClose() {
607 WFlags fl = getWFlags(); 610 WFlags fl = getWFlags();
608 /* clear it just in case */ 611 /* clear it just in case */
609 fl &= ~WDestructiveClose; 612 fl &= ~WDestructiveClose;
610 fl |= WDestructiveClose; 613 fl |= WDestructiveClose;
611 setWFlags( fl ); 614 setWFlags( fl );
612} 615}
613 616
614bool OImageScrollView::image_fit_into(const QSize&s ) 617bool OImageScrollView::image_fit_into(const QSize&s )
615{ 618{
616 if (s.width()>width()||s.height()>height()) { 619 if (s.width()>width()||s.height()>height()) {
617 return false; 620 return false;
618 } 621 }
619 return true; 622 return true;
620} 623}
621 624
622void OImageScrollView::setShowZoomer(bool how) 625void OImageScrollView::setShowZoomer(bool how)
623{ 626{
624 m_states.setBit(SHOW_ZOOMER,how); 627 m_states.setBit(SHOW_ZOOMER,how);
625 check_zoomer(); 628 check_zoomer();
626} 629}
627 630
628bool OImageScrollView::ShowZoomer()const 631bool OImageScrollView::ShowZoomer()const
629{ 632{
630 return m_states.testBit(SHOW_ZOOMER); 633 return m_states.testBit(SHOW_ZOOMER);
631} 634}
632 635
633void OImageScrollView::check_zoomer() 636void OImageScrollView::check_zoomer()
634{ 637{
635 if (!_zoomer) return; 638 if (!_zoomer) return;
636 if ( (!ShowZoomer()||image_fit_into(_pdata.size()) ) && _zoomer->isVisible()) { 639 if ( (!ShowZoomer()||image_fit_into(_pdata.size()) ) && _zoomer->isVisible()) {
637 _zoomer->hide(); 640 _zoomer->hide();
638 } else if ( ShowZoomer() && !image_fit_into(_pdata.size()) && _zoomer->isHidden()){ 641 } else if ( ShowZoomer() && !image_fit_into(_pdata.size()) && _zoomer->isHidden()){
639 _zoomer->show(); 642 _zoomer->show();
640 } 643 }
641} 644}
642 645
643bool OImageScrollView::FirstResizeDone()const 646bool OImageScrollView::FirstResizeDone()const
644{ 647{
645 return m_states.testBit(FIRST_RESIZE_DONE); 648 return m_states.testBit(FIRST_RESIZE_DONE);
646} 649}
647 650
648void OImageScrollView::setFirstResizeDone(bool how) 651void OImageScrollView::setFirstResizeDone(bool how)
649{ 652{
650 m_states.setBit(FIRST_RESIZE_DONE,how); 653 m_states.setBit(FIRST_RESIZE_DONE,how);
651} 654}
652 655
653bool OImageScrollView::ImageIsJpeg()const 656bool OImageScrollView::ImageIsJpeg()const
654{ 657{
655 return m_states.testBit(IMAGE_IS_JPEG); 658 return m_states.testBit(IMAGE_IS_JPEG);
656} 659}
657 660
658void OImageScrollView::setImageIsJpeg(bool how) 661void OImageScrollView::setImageIsJpeg(bool how)
659{ 662{
660 m_states.setBit(IMAGE_IS_JPEG,how); 663 m_states.setBit(IMAGE_IS_JPEG,how);
661} 664}
662 665
663bool OImageScrollView::ImageScaledLoaded()const 666bool OImageScrollView::ImageScaledLoaded()const
664{ 667{
665 return m_states.testBit(IMAGE_SCALED_LOADED); 668 return m_states.testBit(IMAGE_SCALED_LOADED);
666} 669}
667 670
668void OImageScrollView::setImageScaledLoaded(bool how) 671void OImageScrollView::setImageScaledLoaded(bool how)
669{ 672{
670 m_states.setBit(IMAGE_SCALED_LOADED,how); 673 m_states.setBit(IMAGE_SCALED_LOADED,how);
671} 674}
672 675
673} // namespace MM 676} // namespace MM
674} // namespace Opie 677} // namespace Opie
diff --git a/noncore/graphics/opie-eye/gui/imageview.cpp b/noncore/graphics/opie-eye/gui/imageview.cpp
index 994fe12..b919ca8 100644
--- a/noncore/graphics/opie-eye/gui/imageview.cpp
+++ b/noncore/graphics/opie-eye/gui/imageview.cpp
@@ -1,321 +1,318 @@
1#include "imageview.h" 1#include "imageview.h"
2 2
3#include <opie2/odebug.h> 3#include <opie2/odebug.h>
4#include <opie2/oconfig.h> 4#include <opie2/oconfig.h>
5#include <opie2/okeyconfigwidget.h> 5#include <opie2/okeyconfigwidget.h>
6 6
7#include <qpe/resource.h> 7#include <qpe/resource.h>
8#include <qpe/qpeapplication.h> 8#include <qpe/qpeapplication.h>
9#include <qpe/qcopenvelope_qws.h> 9#include <qpe/qcopenvelope_qws.h>
10 10
11#include <qpopupmenu.h> 11#include <qpopupmenu.h>
12#include <qtimer.h> 12#include <qtimer.h>
13#include <qaction.h> 13#include <qaction.h>
14 14
15using namespace Opie::Core; 15using namespace Opie::Core;
16 16
17ImageView::ImageView(Opie::Core::OConfig *cfg, QWidget* parent, const char* name, WFlags fl ) 17ImageView::ImageView(Opie::Core::OConfig *cfg, QWidget* parent, const char* name, WFlags fl )
18 : Opie::MM::OImageScrollView(parent,name,fl) 18 : Opie::MM::OImageScrollView(parent,name,fl)
19{ 19{
20 m_viewManager = 0; 20 m_viewManager = 0;
21 focus_in_count = 0; 21 focus_in_count = 0;
22 m_cfg = cfg; 22 m_cfg = cfg;
23 m_isFullScreen = false; 23 m_isFullScreen = false;
24 m_ignore_next_in = false; 24 m_ignore_next_in = false;
25 m_slideTimer = 0; 25 m_slideTimer = 0;
26 QPEApplication::setStylusOperation(viewport(),QPEApplication::RightOnHold); 26 QPEApplication::setStylusOperation(viewport(),QPEApplication::RightOnHold);
27 initKeys(); 27 initKeys();
28 m_slideValue = 5; 28 m_slideValue = 5;
29 m_gDisplayType = 0; 29 m_gDisplayType = 0;
30 m_gPrevNext = 0; 30 m_gPrevNext = 0;
31 m_hGroup = 0; 31 m_hGroup = 0;
32 m_gBright = 0; 32 m_gBright = 0;
33 m_Rotated = false; 33 m_Rotated = false;
34 closeIfHide = false; 34 closeIfHide = false;
35 int min = QApplication::desktop()->size().width()>QApplication::desktop()->size().height()? 35 int min = QApplication::desktop()->size().width()>QApplication::desktop()->size().height()?
36 QApplication::desktop()->size().height():QApplication::desktop()->size().width(); 36 QApplication::desktop()->size().height():QApplication::desktop()->size().width();
37 if (min>320) { 37 if (min>320) {
38 // bigscreen 38 // bigscreen
39 setMinimumSize(min/3,min/3); 39 setMinimumSize(min/3,min/3);
40 } else { 40 } else {
41 setMinimumSize(10,10); 41 setMinimumSize(10,10);
42 } 42 }
43 connect(this,SIGNAL(incBrightness()),this,SLOT(slotIncBrightness())); 43 connect(this,SIGNAL(incBrightness()),this,SLOT(slotIncBrightness()));
44 connect(this,SIGNAL(decBrightness()),this,SLOT(slotDecBrightness())); 44 connect(this,SIGNAL(decBrightness()),this,SLOT(slotDecBrightness()));
45 45
46 m_sysChannel = new QCopChannel( "QPE/System", this ); 46 m_sysChannel = new QCopChannel( "QPE/System", this );
47 connect( m_sysChannel, SIGNAL( received(const QCString&,const QByteArray&) ), 47 connect( m_sysChannel, SIGNAL( received(const QCString&,const QByteArray&) ),
48 this, SLOT( systemMessage(const QCString&,const QByteArray&) ) ); 48 this, SLOT( systemMessage(const QCString&,const QByteArray&) ) );
49 setKeyCompression(true);
49} 50}
50 51
51void ImageView::slotIncBrightness() 52void ImageView::slotIncBrightness()
52{ 53{
53 int lb = Intensity()+5; 54 int lb = Intensity()+5;
54 if (lb>100) lb=100; 55 if (lb>100) lb=100;
55 setIntensity(lb,true); 56 setIntensity(lb,true);
56} 57}
57 58
58void ImageView::slotDecBrightness() 59void ImageView::slotDecBrightness()
59{ 60{
60 int lb = Intensity()-5; 61 int lb = Intensity()-5;
61 if (lb<-100) lb=-100; 62 if (lb<-100) lb=-100;
62 setIntensity(lb,true); 63 setIntensity(lb,true);
63} 64}
64 65
65void ImageView::systemMessage( const QCString& msg, const QByteArray& data ) 66void ImageView::systemMessage( const QCString& msg, const QByteArray& data )
66{ 67{
67 int _newrotation; 68 int _newrotation;
68 QDataStream stream( data, IO_ReadOnly ); 69 QDataStream stream( data, IO_ReadOnly );
69 odebug << "received system message: " << msg << oendl;
70 if ( msg == "setCurrentRotation(int)" ) 70 if ( msg == "setCurrentRotation(int)" )
71 { 71 {
72 stream >> _newrotation; 72 stream >> _newrotation;
73 odebug << "received setCurrentRotation(" << _newrotation << ")" << oendl;
74 if (!fullScreen()) { 73 if (!fullScreen()) {
75 m_rotation = _newrotation; 74 m_rotation = _newrotation;
76 return; 75 return;
77 } 76 }
78 } 77 }
79} 78}
80 79
81void ImageView::setMenuActions(QActionGroup*hGroup,QActionGroup*nextprevGroup, QActionGroup*disptypeGroup,QActionGroup*brightGroup) 80void ImageView::setMenuActions(QActionGroup*hGroup,QActionGroup*nextprevGroup, QActionGroup*disptypeGroup,QActionGroup*brightGroup)
82{ 81{
83 m_gDisplayType = disptypeGroup; 82 m_gDisplayType = disptypeGroup;
84 m_gPrevNext = nextprevGroup; 83 m_gPrevNext = nextprevGroup;
85 m_hGroup = hGroup; 84 m_hGroup = hGroup;
86 m_gBright = brightGroup; 85 m_gBright = brightGroup;
87} 86}
88 87
89ImageView::~ImageView() 88ImageView::~ImageView()
90{ 89{
91 odebug << "Destructor imageview" << oendl; 90 odebug << "Destructor imageview" << oendl;
92 delete m_viewManager; 91 delete m_viewManager;
93} 92}
94 93
95Opie::Core::OKeyConfigManager* ImageView::manager() 94Opie::Core::OKeyConfigManager* ImageView::manager()
96{ 95{
97 if (!m_viewManager) { 96 if (!m_viewManager) {
98 initKeys(); 97 initKeys();
99 } 98 }
100 return m_viewManager; 99 return m_viewManager;
101} 100}
102 101
103void ImageView::startSlide(int value) 102void ImageView::startSlide(int value)
104{ 103{
105 if (!m_slideTimer) { 104 if (!m_slideTimer) {
106 m_slideTimer = new QTimer(this); 105 m_slideTimer = new QTimer(this);
107 } 106 }
108 m_slideValue=value; 107 m_slideValue=value;
109 connect(m_slideTimer,SIGNAL(timeout()),SLOT(nextSlide())); 108 connect(m_slideTimer,SIGNAL(timeout()),SLOT(nextSlide()));
110 /* this "+1" is one millisecond. with that we can setup a slideshowvalue 109 /* this "+1" is one millisecond. with that we can setup a slideshowvalue
111 of 0. eg "as fast as possible". 110 of 0. eg "as fast as possible".
112 */ 111 */
113 m_slideTimer->start(m_slideValue*1000+1,true); 112 m_slideTimer->start(m_slideValue*1000+1,true);
114} 113}
115 114
116void ImageView::stopSlide() 115void ImageView::stopSlide()
117{ 116{
118 if (!m_slideTimer) { 117 if (!m_slideTimer) {
119 return; 118 return;
120 } 119 }
121 m_slideTimer->stop(); 120 m_slideTimer->stop();
122 delete m_slideTimer; 121 delete m_slideTimer;
123 m_slideTimer = 0; 122 m_slideTimer = 0;
124} 123}
125 124
126void ImageView::nextSlide() 125void ImageView::nextSlide()
127{ 126{
128 if (!m_slideTimer) { 127 if (!m_slideTimer) {
129 return; 128 return;
130 } 129 }
131#if 0 130#if 0
132 if (isHidden()) { 131 if (isHidden()) {
133 delete m_slideTimer; 132 delete m_slideTimer;
134 m_slideTimer = 0; 133 m_slideTimer = 0;
135 return; 134 return;
136 } 135 }
137#endif 136#endif
138 emit dispNext(); 137 emit dispNext();
139 m_slideTimer->start(m_slideValue*1000,true); 138 m_slideTimer->start(m_slideValue*1000,true);
140} 139}
141void ImageView::initKeys() 140void ImageView::initKeys()
142{ 141{
143 odebug << "init imageview keys" << oendl; 142 odebug << "init imageview keys" << oendl;
144 if (!m_cfg) { 143 if (!m_cfg) {
145 m_cfg = new Opie::Core::OConfig("opie-eye"); 144 m_cfg = new Opie::Core::OConfig("opie-eye");
146 m_cfg->setGroup("image_view_keys" ); 145 m_cfg->setGroup("image_view_keys" );
147 } 146 }
148 Opie::Core::OKeyPair::List lst; 147 Opie::Core::OKeyPair::List lst;
149 lst.append( Opie::Core::OKeyPair::upArrowKey() ); 148 lst.append( Opie::Core::OKeyPair::upArrowKey() );
150 lst.append( Opie::Core::OKeyPair::downArrowKey() ); 149 lst.append( Opie::Core::OKeyPair::downArrowKey() );
151 lst.append( Opie::Core::OKeyPair::leftArrowKey() ); 150 lst.append( Opie::Core::OKeyPair::leftArrowKey() );
152 lst.append( Opie::Core::OKeyPair::rightArrowKey() ); 151 lst.append( Opie::Core::OKeyPair::rightArrowKey() );
153 lst.append( Opie::Core::OKeyPair(Qt::Key_Escape,0)); 152 lst.append( Opie::Core::OKeyPair(Qt::Key_Escape,0));
154 153
155 m_viewManager = new Opie::Core::OKeyConfigManager(m_cfg, "image_view_keys", 154 m_viewManager = new Opie::Core::OKeyConfigManager(m_cfg, "image_view_keys",
156 lst, false,this, "image_view_keys" ); 155 lst, false,this, "image_view_keys" );
157 156
158 /** 157 /**
159 * Handle KeyEvents when they're pressed. This avoids problems 158 * Handle KeyEvents when they're pressed. This avoids problems
160 * with 'double next' on Return. 159 * with 'double next' on Return.
161 * The Return press would switch to this view and the return 160 * The Return press would switch to this view and the return
162 * release would emit the dispNext Signal. 161 * release would emit the dispNext Signal.
163 */ 162 */
164 m_viewManager->setEventMask( Opie::Core::OKeyConfigManager::MaskPressed ); 163 m_viewManager->setEventMask( Opie::Core::OKeyConfigManager::MaskPressed );
165 164
166 m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("View Image Info"), "imageviewinfo", 165 m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("View Image Info"), "imageviewinfo",
167 Resource::loadPixmap("1to1"), ViewInfo, 166 Resource::loadPixmap("1to1"), ViewInfo,
168 Opie::Core::OKeyPair(Qt::Key_I,0), 167 Opie::Core::OKeyPair(Qt::Key_I,0),
169 this, SLOT(slotShowImageInfo()))); 168 this, SLOT(slotShowImageInfo())));
170 169
171 m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle autorotate"), "imageautorotate", 170 m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle autorotate"), "imageautorotate",
172 Resource::loadPixmap("rotate"), Autorotate, 171 Resource::loadPixmap("rotate"), Autorotate,
173 Opie::Core::OKeyPair(Qt::Key_R,0), 172 Opie::Core::OKeyPair(Qt::Key_R,0),
174 this, SIGNAL(toggleAutorotate()))); 173 this, SIGNAL(toggleAutorotate())));
175 m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle autoscale"), "imageautoscale", 174 m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle autoscale"), "imageautoscale",
176 Resource::loadPixmap("1to1"), Autoscale, 175 Resource::loadPixmap("1to1"), Autoscale,
177 Opie::Core::OKeyPair(Qt::Key_S,0), 176 Opie::Core::OKeyPair(Qt::Key_S,0),
178 this, SIGNAL(toggleAutoscale()))); 177 this, SIGNAL(toggleAutoscale())));
179 178
180 m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Switch to next image"), "imageshownext", 179 m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Switch to next image"), "imageshownext",
181 Resource::loadPixmap("forward"), ShowNext, 180 Resource::loadPixmap("forward"), ShowNext,
182 Opie::Core::OKeyPair(Qt::Key_Return,0), 181 Opie::Core::OKeyPair(Qt::Key_Return,0),
183 this, SIGNAL(dispNext()))); 182 this, SIGNAL(dispNext())));
184 m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Switch to previous image"), "imageshowprev", 183 m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Switch to previous image"), "imageshowprev",
185 Resource::loadPixmap("back"), ShowPrevious, 184 Resource::loadPixmap("back"), ShowPrevious,
186 Opie::Core::OKeyPair(Qt::Key_P,0), 185 Opie::Core::OKeyPair(Qt::Key_P,0),
187 this, SIGNAL(dispPrev()))); 186 this, SIGNAL(dispPrev())));
188 m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle fullscreen"), "imagefullscreen", 187 m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle fullscreen"), "imagefullscreen",
189 Resource::loadPixmap("fullscreen"), FullScreen, 188 Resource::loadPixmap("fullscreen"), FullScreen,
190 Opie::Core::OKeyPair(Qt::Key_F,0), 189 Opie::Core::OKeyPair(Qt::Key_F,0),
191 this, SIGNAL(toggleFullScreen()))); 190 this, SIGNAL(toggleFullScreen())));
192 m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle thumbnail"), "imagezoomer", 191 m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle thumbnail"), "imagezoomer",
193 Resource::loadPixmap("mag"), Zoomer, 192 Resource::loadPixmap("mag"), Zoomer,
194 Opie::Core::OKeyPair(Qt::Key_T,0), 193 Opie::Core::OKeyPair(Qt::Key_T,0),
195 this, SIGNAL(toggleZoomer()))); 194 this, SIGNAL(toggleZoomer())));
196 195
197 m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Increase brightness"), "incbrightness", 196 m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Increase brightness"), "incbrightness",
198 Resource::loadPixmap("up"), Incbrightness, 197 Resource::loadPixmap("up"), Incbrightness,
199 Opie::Core::OKeyPair(Qt::Key_B,0), 198 Opie::Core::OKeyPair(Qt::Key_B,0),
200 this, SIGNAL(incBrightness()))); 199 this, SIGNAL(incBrightness())));
201 m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Decrease brightness"), "decbrightness", 200 m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Decrease brightness"), "decbrightness",
202 Resource::loadPixmap("down"), Decbrightness, 201 Resource::loadPixmap("down"), Decbrightness,
203 Opie::Core::OKeyPair(Qt::Key_D,0), 202 Opie::Core::OKeyPair(Qt::Key_D,0),
204 this, SIGNAL(decBrightness()))); 203 this, SIGNAL(decBrightness())));
205 m_viewManager->handleWidget( this ); 204 m_viewManager->handleWidget( this );
206 m_viewManager->load(); 205 m_viewManager->load();
207} 206}
208 207
209void ImageView::keyReleaseEvent(QKeyEvent * e) 208void ImageView::keyReleaseEvent(QKeyEvent * e)
210{ 209{
211 if (!e || e->state()!=0) { 210 if (!e || e->state()!=0) {
212 return; 211 return;
213 } 212 }
214 if (e->key()==Qt::Key_Escape) { 213 if (e->key()==Qt::Key_Escape) {
215 if (fullScreen()) { 214 if (fullScreen()) {
216 emit hideMe(); 215 emit hideMe();
217 } 216 }
218 if (closeIfHide) { 217 if (closeIfHide) {
219 QTimer::singleShot(0, qApp, SLOT(closeAllWindows())); 218 QTimer::singleShot(0, qApp, SLOT(closeAllWindows()));
220 } 219 }
221 } 220 }
222} 221}
223 222
224void ImageView::setCloseIfHide(bool how) 223void ImageView::setCloseIfHide(bool how)
225{ 224{
226 closeIfHide = how; 225 closeIfHide = how;
227} 226}
228 227
229void ImageView::slotShowImageInfo() 228void ImageView::slotShowImageInfo()
230{ 229{
231 emit dispImageInfo(m_lastName); 230 emit dispImageInfo(m_lastName);
232} 231}
233 232
234void ImageView::contentsMousePressEvent ( QMouseEvent * e) 233void ImageView::contentsMousePressEvent ( QMouseEvent * e)
235{ 234{
236 if (e->button()==1) { 235 if (e->button()==1) {
237 return OImageScrollView::contentsMousePressEvent(e); 236 return OImageScrollView::contentsMousePressEvent(e);
238 } 237 }
239 odebug << "Popup " << oendl;
240 QPopupMenu *m = new QPopupMenu(this); 238 QPopupMenu *m = new QPopupMenu(this);
241 if (!m) return; 239 if (!m) return;
242 if (m_hGroup) { 240 if (m_hGroup) {
243 m_hGroup->addTo(m); 241 m_hGroup->addTo(m);
244 } 242 }
245 if (fullScreen()) { 243 if (fullScreen()) {
246 if (m_gPrevNext) { 244 if (m_gPrevNext) {
247 m->insertSeparator(); 245 m->insertSeparator();
248 m_gPrevNext->addTo(m); 246 m_gPrevNext->addTo(m);
249 } 247 }
250 if (m_gDisplayType) { 248 if (m_gDisplayType) {
251 m->insertSeparator(); 249 m->insertSeparator();
252 m_gDisplayType->addTo(m); 250 m_gDisplayType->addTo(m);
253 } 251 }
254 if (m_gBright) { 252 if (m_gBright) {
255 m->insertSeparator(); 253 m->insertSeparator();
256 m_gBright->addTo(m); 254 m_gBright->addTo(m);
257 } 255 }
258 } 256 }
259 m->setFocus(); 257 m->setFocus();
260 m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); 258 m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) );
261 if (m_hGroup) { 259 if (m_hGroup) {
262 m_hGroup->removeFrom(m); 260 m_hGroup->removeFrom(m);
263 } 261 }
264 if (m_gPrevNext) { 262 if (m_gPrevNext) {
265 m_gPrevNext->removeFrom(m); 263 m_gPrevNext->removeFrom(m);
266 } 264 }
267 if (m_gDisplayType) { 265 if (m_gDisplayType) {
268 m_gDisplayType->removeFrom(m); 266 m_gDisplayType->removeFrom(m);
269 } 267 }
270 if (m_gBright) { 268 if (m_gBright) {
271 m_gBright->removeFrom(m); 269 m_gBright->removeFrom(m);
272 } 270 }
273 delete m; 271 delete m;
274} 272}
275 273
276void ImageView::setFullScreen(bool how,bool force) 274void ImageView::setFullScreen(bool how,bool force)
277{ 275{
278 m_isFullScreen = how; 276 m_isFullScreen = how;
279 if (how) { 277 if (how) {
280 m_ignore_next_in = true; 278 m_ignore_next_in = true;
281// setFixedSize(qApp->desktop()->size()); 279// setFixedSize(qApp->desktop()->size());
282 setGeometry(0,0,qApp->desktop()->size().width(),qApp->desktop()->size().height()); 280 setGeometry(0,0,qApp->desktop()->size().width(),qApp->desktop()->size().height());
283 if (force) showFullScreen(); 281 if (force) showFullScreen();
284 } else { 282 } else {
285// setMinimumSize(10,10); 283// setMinimumSize(10,10);
286 } 284 }
287} 285}
288 286
289void ImageView::focusInEvent(QFocusEvent *) 287void ImageView::focusInEvent(QFocusEvent *)
290{ 288{
291 // Always do it here, no matter the size. 289 // Always do it here, no matter the size.
292 odebug << "Focus in (view)" << oendl;
293 //if (fullScreen()) parentWidget()->showNormal(); 290 //if (fullScreen()) parentWidget()->showNormal();
294 if (m_ignore_next_in){m_ignore_next_in=false;return;} 291 if (m_ignore_next_in){m_ignore_next_in=false;return;}
295 if (fullScreen()) enableFullscreen(); 292 if (fullScreen()) enableFullscreen();
296} 293}
297 294
298void ImageView::hide() 295void ImageView::hide()
299{ 296{
300 if (fullScreen()) { 297 if (fullScreen()) {
301 m_ignore_next_in = true; 298 m_ignore_next_in = true;
302 showNormal(); 299 showNormal();
303 } 300 }
304 QWidget::hide(); 301 QWidget::hide();
305} 302}
306void ImageView::enableFullscreen() 303void ImageView::enableFullscreen()
307{ 304{
308 if (!fullScreen()) return; 305 if (!fullScreen()) return;
309 if (m_ignore_next_in) {m_ignore_next_in = false;return;} 306 if (m_ignore_next_in) {m_ignore_next_in = false;return;}
310 307
311 setUpdatesEnabled(false); 308 setUpdatesEnabled(false);
312 // This is needed because showNormal() forcefully changes the window 309 // This is needed because showNormal() forcefully changes the window
313 // style to WSTyle_TopLevel. 310 // style to WSTyle_TopLevel.
314 reparent(0, WStyle_Customize | WStyle_NoBorderEx, QPoint(0,0)); 311 reparent(0, WStyle_Customize | WStyle_NoBorderEx, QPoint(0,0));
315 // Enable fullscreen. 312 // Enable fullscreen.
316 /* this is the trick - I don't now why, but after a showFullScreen QTE toggles the focus 313 /* this is the trick - I don't now why, but after a showFullScreen QTE toggles the focus
317 * so we must block it here! */ 314 * so we must block it here! */
318 m_ignore_next_in = true; 315 m_ignore_next_in = true;
319 showFullScreen(); 316 showFullScreen();
320 setUpdatesEnabled(true); 317 setUpdatesEnabled(true);
321} 318}
diff --git a/noncore/graphics/opie-eye/gui/mainwindow.cpp b/noncore/graphics/opie-eye/gui/mainwindow.cpp
index 4ee252f..3efbb53 100644
--- a/noncore/graphics/opie-eye/gui/mainwindow.cpp
+++ b/noncore/graphics/opie-eye/gui/mainwindow.cpp
@@ -1,833 +1,840 @@
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#include "imageview.h" 6#include "imageview.h"
7 7
8#include "iconview.h" 8#include "iconview.h"
9#include "filesystem.h" 9#include "filesystem.h"
10#include "imageinfoui.h" 10#include "imageinfoui.h"
11#include "viewmodebutton.h" 11#include "viewmodebutton.h"
12#include "basesetup.h" 12#include "basesetup.h"
13 13
14#include <iface/ifaceinfo.h> 14#include <iface/ifaceinfo.h>
15#include <iface/dirview.h> 15#include <iface/dirview.h>
16 16
17#include <opie2/odebug.h> 17#include <opie2/odebug.h>
18#include <opie2/owidgetstack.h> 18#include <opie2/owidgetstack.h>
19#include <opie2/oapplicationfactory.h> 19#include <opie2/oapplicationfactory.h>
20#include <opie2/otabwidget.h> 20#include <opie2/otabwidget.h>
21#include <opie2/okeyconfigwidget.h> 21#include <opie2/okeyconfigwidget.h>
22#include <opie2/owait.h> 22#include <opie2/owait.h>
23#include <opie2/oapplication.h> 23#include <opie2/oapplication.h>
24 24
25#include <qpe/resource.h> 25#include <qpe/resource.h>
26#include <qpe/config.h> 26#include <qpe/config.h>
27#include <qpe/ir.h> 27#include <qpe/ir.h>
28#include <qpe/storage.h> 28#include <qpe/storage.h>
29#include <qpe/applnk.h> 29#include <qpe/applnk.h>
30 30
31#include <qtoolbar.h> 31#include <qtoolbar.h>
32#include <qtoolbutton.h> 32#include <qtoolbutton.h>
33#include <qlayout.h> 33#include <qlayout.h>
34#include <qdialog.h> 34#include <qdialog.h>
35#include <qmap.h> 35#include <qmap.h>
36#include <qtimer.h> 36#include <qtimer.h>
37#include <qframe.h> 37#include <qframe.h>
38#include <qmenubar.h> 38#include <qmenubar.h>
39#include <qaction.h> 39#include <qaction.h>
40#include <qspinbox.h> 40#include <qspinbox.h>
41 41
42//OPIE_EXPORT_APP_V2( Opie::Core::OApplicationFactory<PMainWindow>,"Opie Eye" ) 42//OPIE_EXPORT_APP_V2( Opie::Core::OApplicationFactory<PMainWindow>,"Opie Eye" )
43OPIE_EXPORT_APP( Opie::Core::OApplicationFactory<PMainWindow>) 43OPIE_EXPORT_APP( Opie::Core::OApplicationFactory<PMainWindow>)
44 44
45PMainWindow::PMainWindow(QWidget* wid, const char* name, WFlags style) 45PMainWindow::PMainWindow(QWidget* wid, const char* name, WFlags style)
46 : QMainWindow( wid, name, style ), m_info( 0 ), m_disp( 0 ) 46 : QMainWindow( wid, name, style ), m_info( 0 ), m_disp( 0 )
47{ 47{
48 setCaption( QObject::tr("Opie Eye" ) ); 48 setCaption( QObject::tr("Opie Eye" ) );
49 m_cfg = new Opie::Core::OConfig("opie-eye"); 49 m_cfg = new Opie::Core::OConfig("opie-eye");
50 m_cfg->setGroup("main" ); 50 m_cfg->setGroup("main" );
51 readConfig(); 51 readConfig();
52 m_setDocCalled = false; 52 m_setDocCalled = false;
53 m_polishDone = false; 53 m_polishDone = false;
54 m_SmallWindow = QApplication::desktop()->size().width()<330; 54 m_SmallWindow = QApplication::desktop()->size().width()<330;
55 55
56 m_storage = new StorageInfo(); 56 m_storage = new StorageInfo();
57 connect(m_storage, SIGNAL(disksChanged() ), 57 connect(m_storage, SIGNAL(disksChanged() ),
58 this, SLOT( dirChanged() ) ); 58 this, SLOT( dirChanged() ) );
59 59
60 m_stack = new Opie::Ui::OWidgetStack( this ); 60 m_stack = new Opie::Ui::OWidgetStack( this );
61 setCentralWidget( m_stack ); 61 setCentralWidget( m_stack );
62 62
63 m_view = new PIconView( m_stack, m_cfg ); 63 m_view = new PIconView( m_stack, m_cfg );
64 m_stack->addWidget( m_view, IconView ); 64 m_stack->addWidget( m_view, IconView );
65 m_stack->raiseWidget( IconView ); 65 m_stack->raiseWidget( IconView );
66 66
67 connect(m_view, SIGNAL(sig_display(const QString&)), 67 connect(m_view, SIGNAL(sig_display(const QString&)),
68 this, SLOT(slotDisplay(const QString&))); 68 this, SLOT(slotDisplay(const QString&)));
69 connect(m_view, SIGNAL(sig_showInfo(const QString&)), 69 connect(m_view, SIGNAL(sig_showInfo(const QString&)),
70 this, SLOT(slotShowInfo(const QString&)) ); 70 this, SLOT(slotShowInfo(const QString&)) );
71 connect(this,SIGNAL(changeListMode(int)),m_view,SLOT(slotChangeMode(int))); 71 connect(this,SIGNAL(changeListMode(int)),m_view,SLOT(slotChangeMode(int)));
72 72
73 listviewMenu = 0; 73 listviewMenu = 0;
74 /* setup menu and toolbar */ 74 /* setup menu and toolbar */
75 setupActions(); 75 setupActions();
76 setupToolbar(); 76 setupToolbar();
77 setupMenu(); 77 setupMenu();
78 m_aHideToolbar->setOn(m_cfg->readBoolEntry("showtoolbar",true)); 78 m_aHideToolbar->setOn(m_cfg->readBoolEntry("showtoolbar",true));
79 m_aAutoRotate->setEnabled(!m_aUnscaled->isOn()); 79 m_aAutoRotate->setEnabled(!m_aUnscaled->isOn());
80 if (m_aForceSmall) { 80 if (m_aForceSmall) {
81 m_aForceSmall->setOn(m_cfg->readBoolEntry("dontshowseperate",true)); 81 m_aForceSmall->setOn(m_cfg->readBoolEntry("dontshowseperate",true));
82 } 82 }
83 odebug << "mainwindow constructor done" << oendl; 83 odebug << "mainwindow constructor done" << oendl;
84} 84}
85 85
86PMainWindow::~PMainWindow() { 86PMainWindow::~PMainWindow() {
87} 87}
88 88
89void PMainWindow::slotToggleZoomer() 89void PMainWindow::slotToggleZoomer()
90{ 90{
91 m_aZoomer->setOn(!m_aZoomer->isOn()); 91 m_aZoomer->setOn(!m_aZoomer->isOn());
92} 92}
93 93
94void PMainWindow::slotZoomerToggled(bool how) 94void PMainWindow::slotZoomerToggled(bool how)
95{ 95{
96 if (m_disp) { 96 if (m_disp) {
97 m_disp->setShowZoomer(how); 97 m_disp->setShowZoomer(how);
98 } 98 }
99 if (autoSave) { 99 if (autoSave) {
100 m_cfg->writeEntry("zoomeron",how); 100 m_cfg->writeEntry("zoomeron",how);
101 } 101 }
102} 102}
103 103
104void PMainWindow::slotToggleAutorotate() 104void PMainWindow::slotToggleAutorotate()
105{ 105{
106 if (!m_aAutoRotate->isEnabled()) return; 106 if (!m_aAutoRotate->isEnabled()) return;
107 m_aAutoRotate->setOn(!m_aAutoRotate->isOn()); 107 m_aAutoRotate->setOn(!m_aAutoRotate->isOn());
108} 108}
109 109
110void PMainWindow::slotToggleAutoscale() 110void PMainWindow::slotToggleAutoscale()
111{ 111{
112 m_aUnscaled->setOn(!m_aUnscaled->isOn()); 112 m_aUnscaled->setOn(!m_aUnscaled->isOn());
113} 113}
114 114
115void PMainWindow::slotRotateToggled(bool how) 115void PMainWindow::slotRotateToggled(bool how)
116{ 116{
117 if (autoSave) { 117 if (autoSave) {
118 m_cfg->writeEntry("autorotate",how); 118 m_cfg->writeEntry("autorotate",how);
119 } 119 }
120 if (m_disp) { 120 if (m_disp) {
121 m_disp->setAutoScaleRotate(!m_aUnscaled->isOn(),how); 121 m_disp->setAutoScaleRotate(!m_aUnscaled->isOn(),how);
122 } 122 }
123} 123}
124 124
125void PMainWindow::slotScaleToggled(bool how) 125void PMainWindow::slotScaleToggled(bool how)
126{ 126{
127 if (autoSave) { 127 if (autoSave) {
128 m_cfg->writeEntry("unscaled",how); 128 m_cfg->writeEntry("unscaled",how);
129 } 129 }
130 odebug << "Unscaled: " << m_aUnscaled->isOn() << oendl; 130 odebug << "Unscaled: " << m_aUnscaled->isOn() << oendl;
131 odebug << "How: " << how << oendl; 131 odebug << "How: " << how << oendl;
132 if (how) { 132 if (how) {
133 m_aAutoRotate->setOn(false); 133 m_aAutoRotate->setOn(false);
134 } 134 }
135 if (m_disp) { 135 if (m_disp) {
136 m_disp->setAutoScaleRotate(!m_aUnscaled->isOn(),m_aAutoRotate->isOn()); 136 m_disp->setAutoScaleRotate(!m_aUnscaled->isOn(),m_aAutoRotate->isOn());
137 } 137 }
138 m_aAutoRotate->setEnabled(!how); 138 m_aAutoRotate->setEnabled(!how);
139 odebug << "Autorotate: " << m_aAutoRotate->isOn() << oendl; 139 odebug << "Autorotate: " << m_aAutoRotate->isOn() << oendl;
140} 140}
141 141
142void PMainWindow::slotConfig() { 142void PMainWindow::slotConfig() {
143 /* 143 /*
144 * have a tab with the possible views 144 * have a tab with the possible views
145 * a tab for globals image cache size.. scaled loading 145 * a tab for globals image cache size.. scaled loading
146 * and one tab for the KeyConfigs 146 * and one tab for the KeyConfigs
147 */ 147 */
148 QDialog dlg(this, 0, true); 148 QDialog dlg(this, 0, true);
149 dlg.setCaption( tr("Opie Eye - Config" ) ); 149 dlg.setCaption( tr("Opie Eye - Config" ) );
150 150
151 QHBoxLayout *lay = new QHBoxLayout(&dlg); 151 QHBoxLayout *lay = new QHBoxLayout(&dlg);
152 Opie::Ui::OTabWidget *wid = new Opie::Ui::OTabWidget(&dlg ); 152 Opie::Ui::OTabWidget *wid = new Opie::Ui::OTabWidget(&dlg );
153 lay->addWidget( wid ); 153 lay->addWidget( wid );
154 154
155 BaseSetup*bSetup = new BaseSetup(m_cfg,wid); 155 BaseSetup*bSetup = new BaseSetup(m_cfg,wid);
156 wid->addTab(bSetup,"SettingsIcon","Basics setup"); 156 wid->addTab(bSetup,"SettingsIcon","Basics setup");
157 157
158 ViewMap *vM = viewMap(); 158 ViewMap *vM = viewMap();
159 ViewMap::Iterator _it = vM->begin(); 159 ViewMap::Iterator _it = vM->begin();
160 QMap<PDirView*, QWidget*> lst; 160 QMap<PDirView*, QWidget*> lst;
161 161
162 for( ; _it != vM->end(); ++_it ) { 162 for( ; _it != vM->end(); ++_it ) {
163 PDirView *view = (_it.data())(*m_cfg); 163 PDirView *view = (_it.data())(*m_cfg);
164 PInterfaceInfo *inf = view->interfaceInfo(); 164 PInterfaceInfo *inf = view->interfaceInfo();
165 QWidget *_wid = inf->configWidget( *m_cfg ); 165 QWidget *_wid = inf->configWidget( *m_cfg );
166 if (!_wid) continue; 166 if (!_wid) continue;
167 _wid->reparent(wid, QPoint() ); 167 _wid->reparent(wid, QPoint() );
168 lst.insert( view, _wid ); 168 lst.insert( view, _wid );
169 wid->addTab( _wid, "fileopen", inf->name() ); 169 wid->addTab( _wid, "fileopen", inf->name() );
170 } 170 }
171 171
172/* 172/*
173 * Add the KeyConfigWidget 173 * Add the KeyConfigWidget
174 */ 174 */
175 Opie::Ui::OKeyConfigWidget* keyWid = new Opie::Ui::OKeyConfigWidget( wid, "key config" ); 175 Opie::Ui::OKeyConfigWidget* keyWid = new Opie::Ui::OKeyConfigWidget( wid, "key config" );
176 keyWid->setChangeMode( Opie::Ui::OKeyConfigWidget::Queue ); 176 keyWid->setChangeMode( Opie::Ui::OKeyConfigWidget::Queue );
177 keyWid->insert( tr("Browser Keyboard Actions"), m_view->manager() ); 177 keyWid->insert( tr("Browser Keyboard Actions"), m_view->manager() );
178 QWidget*w = m_stack->visibleWidget(); 178 QWidget*w = m_stack->visibleWidget();
179 179
180 bool reminfo = false; 180 bool reminfo = false;
181 if ( !m_info ) { 181 if ( !m_info ) {
182 reminfo = true; 182 reminfo = true;
183 initInfo(); 183 initInfo();
184 m_info->hide(); 184 m_info->hide();
185 } 185 }
186 keyWid->insert( tr("Imageinfo Keyboard Actions"), m_info->manager() ); 186 keyWid->insert( tr("Imageinfo Keyboard Actions"), m_info->manager() );
187 187
188 bool remdisp = false; 188 bool remdisp = false;
189 if ( !m_disp ) { 189 if ( !m_disp ) {
190 remdisp = true; 190 remdisp = true;
191 initDisp(); 191 initDisp();
192 m_disp->hide(); 192 m_disp->hide();
193 } 193 }
194 keyWid->insert( tr("Imageview Keyboard Actions"), m_disp->manager() ); 194 keyWid->insert( tr("Imageview Keyboard Actions"), m_disp->manager() );
195 195
196 keyWid->load(); 196 keyWid->load();
197 wid->addTab( keyWid, QString::fromLatin1("AppsIcon" ), tr("Keyboard Configuration") ); 197 wid->addTab( keyWid, QString::fromLatin1("AppsIcon" ), tr("Keyboard Configuration") );
198 wid->setCurrentTab(0); 198 wid->setCurrentTab(0);
199 bool act = ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ); 199 bool act = ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted );
200 200
201/* 201/*
202 * clean up 202 * clean up
203 *apply changes 203 *apply changes
204 */ 204 */
205 205
206 QMap<PDirView*, QWidget*>::Iterator it; 206 QMap<PDirView*, QWidget*>::Iterator it;
207 for ( it = lst.begin(); it != lst.end(); ++it ) { 207 for ( it = lst.begin(); it != lst.end(); ++it ) {
208 if ( act ) 208 if ( act )
209 it.key()->interfaceInfo()->writeConfig(it.data(), *m_cfg); 209 it.key()->interfaceInfo()->writeConfig(it.data(), *m_cfg);
210 delete it.key(); 210 delete it.key();
211 } 211 }
212 212
213 213
214 if ( act ) { 214 if ( act ) {
215 keyWid->save(); 215 keyWid->save();
216 m_disp->manager()->save(); 216 m_disp->manager()->save();
217 m_info->manager()->save(); 217 m_info->manager()->save();
218 m_view->manager()->save(); 218 m_view->manager()->save();
219 bSetup->save_values(); 219 bSetup->save_values();
220 m_view->resetView(); 220 m_view->resetView();
221 readConfig(); 221 readConfig();
222 } 222 }
223 delete keyWid; 223 delete keyWid;
224 224
225 m_stack->raiseWidget(w); 225 m_stack->raiseWidget(w);
226 if (remdisp) { 226 if (remdisp) {
227 m_disp->hide(); 227 m_disp->hide();
228 } 228 }
229 if (reminfo) { 229 if (reminfo) {
230 m_info->hide(); 230 m_info->hide();
231 } 231 }
232 if (m_disp) { 232 if (m_disp) {
233 m_disp->setIntensity(m_Intensity,true); 233 m_disp->setIntensity(m_Intensity,true);
234 } 234 }
235} 235}
236 236
237/* 237/*
238 * create a new image info component 238 * create a new image info component
239 * and detach the current one 239 * and detach the current one
240 * we will make the other delete on exit 240 * we will make the other delete on exit
241 */ 241 */
242template<class T> 242template<class T>
243void PMainWindow::initT( const char* name, T** ptr, int id) { 243void PMainWindow::initT( const char* name, T** ptr, int id) {
244 if ( *ptr ) { 244 if ( *ptr ) {
245 (*ptr)->disconnect(this, SLOT(slotReturn())); 245 (*ptr)->disconnect(this, SLOT(slotReturn()));
246 (*ptr)->setDestructiveClose(); 246 (*ptr)->setDestructiveClose();
247 m_stack->removeWidget( *ptr ); 247 m_stack->removeWidget( *ptr );
248 } 248 }
249 *ptr = new T(m_cfg, m_stack, name ); 249 *ptr = new T(m_cfg, m_stack, name );
250 m_stack->addWidget( *ptr, id ); 250 m_stack->addWidget( *ptr, id );
251 251
252 connect(*ptr, SIGNAL(sig_return()), 252 connect(*ptr, SIGNAL(sig_return()),
253 this,SLOT(slotReturn())); 253 this,SLOT(slotReturn()));
254 254
255} 255}
256 256
257void PMainWindow::initInfo() { 257void PMainWindow::initInfo() {
258 initT<imageinfo>( "Image Info", &m_info, ImageInfo ); 258 initT<imageinfo>( "Image Info", &m_info, ImageInfo );
259 connect(m_info,SIGNAL(dispImage(const QString&)),this,SLOT(slotDisplay(const QString&))); 259 connect(m_info,SIGNAL(dispImage(const QString&)),this,SLOT(slotDisplay(const QString&)));
260} 260}
261 261
262void PMainWindow::initDisp() { 262void PMainWindow::initDisp() {
263 initT<ImageView>( "Image ScrollView", &m_disp, ImageDisplay ); 263 initT<ImageView>( "Image ScrollView", &m_disp, ImageDisplay );
264 if (m_disp) { 264 if (m_disp) {
265// if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) { 265// if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) {
266 //m_disp->setMinimumSize(QApplication::desktop()->size()/2); 266 //m_disp->setMinimumSize(QApplication::desktop()->size()/2);
267// } 267// }
268 m_disp->setMenuActions(m_hGroup,m_gPrevNext,m_gDisplayType,m_hBright); 268 m_disp->setMenuActions(m_hGroup,m_gPrevNext,m_gDisplayType,m_hBright);
269 m_disp->setAutoScale(!m_aUnscaled->isOn()); 269 m_disp->setAutoScale(!m_aUnscaled->isOn());
270 m_disp->setAutoRotate(m_aAutoRotate->isOn()); 270 m_disp->setAutoRotate(m_aAutoRotate->isOn());
271 m_disp->setShowZoomer(m_aZoomer->isOn()); 271 m_disp->setShowZoomer(m_aZoomer->isOn());
272 m_disp->setBackgroundColor(white); 272 m_disp->setBackgroundColor(white);
273 connect(m_disp,SIGNAL(dispImageInfo(const QString&)),this,SLOT(slotShowInfo(const QString&))); 273 connect(m_disp,SIGNAL(dispImageInfo(const QString&)),this,SLOT(slotShowInfo(const QString&)));
274 connect(m_disp,SIGNAL(dispNext()),m_view,SLOT(slotShowNext())); 274 connect(m_disp,SIGNAL(dispNext()),m_view,SLOT(slotShowNext()));
275 connect(m_disp,SIGNAL(dispPrev()),m_view,SLOT(slotShowPrev())); 275 connect(m_disp,SIGNAL(dispPrev()),m_view,SLOT(slotShowPrev()));
276 connect(m_disp,SIGNAL(toggleFullScreen()),this,SLOT(slotToggleFullScreen())); 276 connect(m_disp,SIGNAL(toggleFullScreen()),this,SLOT(slotToggleFullScreen()));
277 connect(m_disp,SIGNAL(hideMe()),this,SLOT(raiseIconView())); 277 connect(m_disp,SIGNAL(hideMe()),this,SLOT(raiseIconView()));
278 connect(m_disp,SIGNAL(toggleZoomer()),this,SLOT(slotToggleZoomer())); 278 connect(m_disp,SIGNAL(toggleZoomer()),this,SLOT(slotToggleZoomer()));
279 connect(m_disp,SIGNAL(toggleAutoscale()),this,SLOT(slotToggleAutoscale())); 279 connect(m_disp,SIGNAL(toggleAutoscale()),this,SLOT(slotToggleAutoscale()));
280 connect(m_disp,SIGNAL(toggleAutorotate()),this,SLOT(slotToggleAutorotate())); 280 connect(m_disp,SIGNAL(toggleAutorotate()),this,SLOT(slotToggleAutorotate()));
281 connect(m_view,SIGNAL(sig_startslide(int)),m_disp,SLOT(startSlide(int))); 281 connect(m_view,SIGNAL(sig_startslide(int)),m_disp,SLOT(startSlide(int)));
282 connect(m_IncBrightness,SIGNAL(activated()),m_disp,SLOT(slotIncBrightness())); 282 connect(m_IncBrightness,SIGNAL(activated()),m_disp,SLOT(slotIncBrightness()));
283 connect(m_DecBrightness,SIGNAL(activated()),m_disp,SLOT(slotDecBrightness())); 283 connect(m_DecBrightness,SIGNAL(activated()),m_disp,SLOT(slotDecBrightness()));
284 slotFullScreenToggled(m_aFullScreen->isOn()); 284 slotFullScreenToggled(m_aFullScreen->isOn());
285 } 285 }
286} 286}
287 287
288void PMainWindow::slotToggleFullScreen() 288void PMainWindow::slotToggleFullScreen()
289{ 289{
290 bool current = !m_aFullScreen->isOn(); 290 bool current = !m_aFullScreen->isOn();
291 m_aFullScreen->setOn(current); 291 m_aFullScreen->setOn(current);
292} 292}
293 293
294void PMainWindow::slotFullScreenButton(bool current) 294void PMainWindow::slotFullScreenButton(bool current)
295{ 295{
296 if (autoSave) { 296 if (autoSave) {
297 m_cfg->writeEntry("fullscreen",current); 297 m_cfg->writeEntry("fullscreen",current);
298 } 298 }
299 if (!m_disp) return; 299 if (!m_disp) return;
300 if (m_disp->isVisible()) { 300 if (m_disp->isVisible()) {
301 setupViewWindow(current, true); 301 setupViewWindow(current, true);
302 } 302 }
303} 303}
304 304
305void PMainWindow::setupViewWindow(bool current, bool forceDisplay) 305void PMainWindow::setupViewWindow(bool current, bool forceDisplay)
306{ 306{
307 if (!m_disp) { 307 if (!m_disp) {
308 return; 308 return;
309 } 309 }
310 if (current) { 310 if (current) {
311 m_disp->setBackgroundColor(black); 311 m_disp->setBackgroundColor(black);
312 m_disp->reparent(0, WStyle_Customize | WStyle_NoBorderEx, QPoint(0,0)); 312 m_disp->reparent(0, WStyle_Customize | WStyle_NoBorderEx, QPoint(0,0));
313 m_disp->setVScrollBarMode(QScrollView::AlwaysOff); 313 m_disp->setVScrollBarMode(QScrollView::AlwaysOff);
314 m_disp->setHScrollBarMode(QScrollView::AlwaysOff); 314 m_disp->setHScrollBarMode(QScrollView::AlwaysOff);
315 m_disp->resize(qApp->desktop()->width(), qApp->desktop()->height()); 315 m_disp->resize(qApp->desktop()->width(), qApp->desktop()->height());
316 m_disp->setFullScreen(current,forceDisplay); 316 m_disp->setFullScreen(current,forceDisplay);
317 } else { 317 } else {
318 setUpdatesEnabled(false); 318 setUpdatesEnabled(false);
319#if 0 319#if 0
320 if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) { 320 if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) {
321 321
322 //m_disp->setMinimumSize(QApplication::desktop()->size()/2); 322 //m_disp->setMinimumSize(QApplication::desktop()->size()/2);
323 } else { 323 } else {
324 //m_disp->setMinimumSize(10,10); 324 //m_disp->setMinimumSize(10,10);
325 } 325 }
326#endif 326#endif
327 m_disp->setBackgroundColor(white); 327 m_disp->setBackgroundColor(white);
328 m_stack->addWidget(m_disp,ImageDisplay); 328 m_stack->addWidget(m_disp,ImageDisplay);
329 m_disp->setVScrollBarMode(QScrollView::Auto); 329 m_disp->setVScrollBarMode(QScrollView::Auto);
330 m_disp->setHScrollBarMode(QScrollView::Auto); 330 m_disp->setHScrollBarMode(QScrollView::Auto);
331 if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) { 331 if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) {
332 m_disp->setGeometry(30,30,QApplication::desktop()->width()-60,QApplication::desktop()->height()-60); 332 m_disp->setGeometry(30,30,QApplication::desktop()->width()-60,QApplication::desktop()->height()-60);
333 } 333 }
334 if (forceDisplay || m_disp->isVisible()) { 334 if (forceDisplay || m_disp->isVisible()) {
335 m_stack->raiseWidget(m_disp); 335 m_stack->raiseWidget(m_disp);
336 m_disp->setFocus(); 336 m_disp->setFocus();
337 } 337 }
338 setUpdatesEnabled(true); 338 setUpdatesEnabled(true);
339 } 339 }
340 m_disp->setFullScreen(current,forceDisplay); 340 m_disp->setFullScreen(current,forceDisplay);
341} 341}
342 342
343void PMainWindow::slotFullScreenToggled(bool current) 343void PMainWindow::slotFullScreenToggled(bool current)
344{ 344{
345 setupViewWindow(current,true); 345 setupViewWindow(current,true);
346} 346}
347 347
348/** 348/**
349 * With big Screen the plan could be to 'detach' the image 349 * With big Screen the plan could be to 'detach' the image
350 * window if visible and to create a ne wone 350 * window if visible and to create a ne wone
351 * init* already supports it but I make no use of it for 351 * init* already supports it but I make no use of it for
352 * now. We set filename and raise 352 * now. We set filename and raise
353 * 353 *
354 * ### FIXME and talk to alwin 354 * ### FIXME and talk to alwin
355 */ 355 */
356void PMainWindow::slotShowInfo( const QString& inf ) { 356void PMainWindow::slotShowInfo( const QString& inf ) {
357 if (m_disp && m_disp->fullScreen() && m_disp->isVisible()) { 357 if (m_disp && m_disp->fullScreen() && m_disp->isVisible()) {
358 return; 358 return;
359 } 359 }
360 if ( !m_info ) { 360 if ( !m_info ) {
361 initInfo(); 361 initInfo();
362 } 362 }
363 m_info->setPath( inf ); 363 m_info->setPath( inf );
364 if (m_SmallWindow) { 364 if (m_SmallWindow) {
365 m_aNext->removeFrom(toolBar); 365 m_aNext->removeFrom(toolBar);
366 m_aPrevious->removeFrom(toolBar); 366 m_aPrevious->removeFrom(toolBar);
367 fsButton->hide(); 367 fsButton->hide();
368 } 368 }
369 m_aNext->setEnabled(false); 369 m_aNext->setEnabled(false);
370 m_aPrevious->setEnabled(false); 370 m_aPrevious->setEnabled(false);
371 m_aDirUp->setEnabled(false); 371 m_aDirUp->setEnabled(false);
372 m_aShowInfo->setEnabled(false); 372 m_aShowInfo->setEnabled(false);
373 m_aViewfile->setEnabled(true); 373 m_aViewfile->setEnabled(true);
374 m_aStartSlide->setEnabled(false); 374 m_aStartSlide->setEnabled(false);
375 m_stack->raiseWidget( ImageInfo ); 375 m_stack->raiseWidget( ImageInfo );
376} 376}
377 377
378void PMainWindow::slotDisplay( const QString& inf ) { 378void PMainWindow::slotDisplay( const QString& inf ) {
379 bool nwindow = false; 379 bool nwindow = false;
380 if ( !m_disp ) { 380 if ( !m_disp ) {
381 nwindow = true; 381 nwindow = true;
382 initDisp(); 382 initDisp();
383 m_disp->setIntensity(m_Intensity); 383 m_disp->setIntensity(m_Intensity);
384 m_setCurrentBrightness->setEnabled(true); 384 m_setCurrentBrightness->setEnabled(true);
385 m_hBright->setEnabled(true); 385 m_hBright->setEnabled(true);
386 } 386 }
387 m_disp->setImage( inf ); 387 m_disp->setImage( inf );
388 if (m_SmallWindow) { 388 if (m_SmallWindow) {
389 if (m_gPrevNext->isEnabled()==false) { 389 if (m_gPrevNext->isEnabled()==false) {
390 m_gPrevNext->addTo(toolBar); 390 m_gPrevNext->addTo(toolBar);
391 fsButton->hide(); 391 fsButton->hide();
392 } 392 }
393 } 393 }
394 m_gPrevNext->setEnabled(true); 394 m_gPrevNext->setEnabled(true);
395 m_aDirUp->setEnabled(false); 395 m_aDirUp->setEnabled(false);
396 m_aShowInfo->setEnabled(true); 396 m_aShowInfo->setEnabled(true);
397 m_aViewfile->setEnabled(false); 397 m_aViewfile->setEnabled(false);
398 m_aStartSlide->setEnabled(false); 398 m_aStartSlide->setEnabled(false);
399 399
400 if (!nwindow && m_disp->fullScreen()!=m_aFullScreen->isOn()) { 400 if (!nwindow && m_disp->fullScreen()!=m_aFullScreen->isOn()) {
401 slotFullScreenToggled(m_aFullScreen->isOn()); 401 slotFullScreenToggled(m_aFullScreen->isOn());
402 } 402 }
403 if (m_disp->fullScreen()) { 403 if (m_disp->fullScreen()) {
404 if (!m_disp->isVisible()) { 404 if (!m_disp->isVisible()) {
405 m_disp->showFullScreen(); 405 m_disp->showFullScreen();
406 qwsDisplay()->requestFocus( m_disp->winId(), TRUE); 406 qwsDisplay()->requestFocus( m_disp->winId(), TRUE);
407 } 407 }
408 } else { 408 } else {
409 m_stack->raiseWidget( ImageDisplay ); 409 m_stack->raiseWidget( ImageDisplay );
410 } 410 }
411} 411}
412 412
413void PMainWindow::raiseIconView() { 413void PMainWindow::raiseIconView() {
414 setUpdatesEnabled(false); 414 setUpdatesEnabled(false);
415 if (m_SmallWindow) { 415 if (m_SmallWindow) {
416 m_gPrevNext->removeFrom(toolBar); 416 m_gPrevNext->removeFrom(toolBar);
417 fsButton->show(); 417 fsButton->show();
418 } 418 }
419 m_gPrevNext->setEnabled(false); 419 m_gPrevNext->setEnabled(false);
420 m_aDirUp->setEnabled(true); 420 m_aDirUp->setEnabled(true);
421 m_aShowInfo->setEnabled(true); 421 m_aShowInfo->setEnabled(true);
422 m_aViewfile->setEnabled(true); 422 m_aViewfile->setEnabled(true);
423 m_aStartSlide->setEnabled(true); 423 m_aStartSlide->setEnabled(true);
424 424
425 if (m_disp && m_disp->fullScreen() && m_disp->isVisible()) { 425 if (m_disp && m_disp->fullScreen() && m_disp->isVisible()) {
426 m_disp->stopSlide(); 426 m_disp->stopSlide();
427 m_disp->hide(); 427 m_disp->hide();
428 } 428 }
429 m_stack->raiseWidget( IconView ); 429 m_stack->raiseWidget( IconView );
430 setUpdatesEnabled(true); 430 setUpdatesEnabled(true);
431 repaint(); 431 repaint();
432} 432}
433 433
434void PMainWindow::slotReturn() { 434void PMainWindow::slotReturn() {
435 raiseIconView(); 435 raiseIconView();
436} 436}
437 437
438 438
439void PMainWindow::closeEvent( QCloseEvent* ev ) { 439void PMainWindow::closeEvent( QCloseEvent* ev ) {
440 /* 440 /*
441 * return from view 441 * return from view
442 * or properly quit 442 * or properly quit
443 */ 443 */
444 if (!m_setDocCalled) { 444 if (!m_setDocCalled) {
445 if ( m_stack->visibleWidget() == m_info || 445 if ( m_stack->visibleWidget() == m_info ||
446 m_stack->visibleWidget() == m_disp ) { 446 m_stack->visibleWidget() == m_disp ) {
447 ev->ignore(); 447 ev->ignore();
448 raiseIconView(); 448 raiseIconView();
449 return; 449 return;
450 } 450 }
451 } 451 }
452 if (m_disp && m_disp->fullScreen()) { 452 if (m_disp && m_disp->fullScreen()) {
453 /* otherwise opie-eye crashes in bigscreen mode! */ 453 /* otherwise opie-eye crashes in bigscreen mode! */
454 m_disp->reparent(0,QPoint(0,0)); 454 m_disp->reparent(0,QPoint(0,0));
455 m_stack->addWidget(m_disp,ImageDisplay); 455 m_stack->addWidget(m_disp,ImageDisplay);
456 } 456 }
457 ev->accept(); 457 ev->accept();
458 QTimer::singleShot(0, qApp, SLOT(closeAllWindows())); 458 QTimer::singleShot(0, qApp, SLOT(closeAllWindows()));
459} 459}
460 460
461void PMainWindow::setDocument( const QString& showImg ) 461void PMainWindow::setDocument( const QString& showImg )
462{ 462{
463 QString file = showImg; 463 QString file = showImg;
464 DocLnk lnk(showImg); 464 DocLnk lnk(showImg);
465 if (lnk.isValid() ) 465 if (lnk.isValid() )
466 file = lnk.file(); 466 file = lnk.file();
467 slotDisplay( file ); 467 slotDisplay( file );
468#if 0 468#if 0
469 if (!m_polishDone) { 469 if (!m_polishDone) {
470 QTimer::singleShot(0,this,SLOT(check_view_fullscreen())); 470 QTimer::singleShot(0,this,SLOT(check_view_fullscreen()));
471 } 471 }
472#endif 472#endif
473} 473}
474 474
475void PMainWindow::check_view_fullscreen() 475void PMainWindow::check_view_fullscreen()
476{ 476{
477 if (!m_view) return; 477 if (!m_view) return;
478 if (!m_view->hasFocus()&&m_aFullScreen->isOn()) { 478 if (!m_view->hasFocus()&&m_aFullScreen->isOn()) {
479 qwsDisplay()->requestFocus( m_disp->winId(), TRUE); 479 qwsDisplay()->requestFocus( m_disp->winId(), TRUE);
480 } 480 }
481} 481}
482 482
483void PMainWindow::slotSelectDir(int id) 483void PMainWindow::slotSelectDir(int id)
484{ 484{
485 emit changeDir( m_dev[fsMenu->text(id )] ); 485 emit changeDir( m_dev[fsMenu->text(id )] );
486} 486}
487 487
488void PMainWindow::dirChanged() 488void PMainWindow::dirChanged()
489{ 489{
490 fsMenu->clear(); 490 fsMenu->clear();
491 m_dev.clear(); 491 m_dev.clear();
492 492
493 /* home dir, too */ 493 /* home dir, too */
494 QString f = getenv( "HOME" ); 494 QString f = getenv( "HOME" );
495 if (!f.isEmpty()) { 495 if (!f.isEmpty()) {
496 m_dev.insert("Home directory",f); 496 m_dev.insert("Home directory",f);
497 fsMenu->insertItem("Home directory"); 497 fsMenu->insertItem("Home directory");
498 } 498 }
499 const QList<FileSystem> &fs = m_storage->fileSystems(); 499 const QList<FileSystem> &fs = m_storage->fileSystems();
500 QListIterator<FileSystem> it(fs ); 500 QListIterator<FileSystem> it(fs );
501 for ( ; it.current(); ++it ) { 501 for ( ; it.current(); ++it ) {
502 const QString disk = (*it)->name(); 502 const QString disk = (*it)->name();
503 const QString path = (*it)->path(); 503 const QString path = (*it)->path();
504 m_dev.insert( disk, path ); 504 m_dev.insert( disk, path );
505 fsMenu->insertItem( disk ); 505 fsMenu->insertItem( disk );
506 } 506 }
507} 507}
508 508
509void PMainWindow::showToolbar(bool how) 509void PMainWindow::showToolbar(bool how)
510{ 510{
511 if (!how) toolBar->hide(); 511 if (!how) toolBar->hide();
512 else toolBar->show(); 512 else toolBar->show();
513 if (autoSave) { 513 if (autoSave) {
514 m_cfg->writeEntry("showtoolbar",how); 514 m_cfg->writeEntry("showtoolbar",how);
515 } 515 }
516} 516}
517 517
518void PMainWindow::setupActions() 518void PMainWindow::setupActions()
519{ 519{
520 m_aDirUp = new QAction( tr( "Go dir up" ), Resource::loadIconSet( "up" ), 0, 0, this, 0, true ); 520 m_aDirUp = new QAction( tr( "Go dir up" ), Resource::loadIconSet( "up" ), 0, 0, this, 0, true );
521 m_aDirUp->setToggleAction(false); 521 m_aDirUp->setToggleAction(false);
522 connect(m_aDirUp,SIGNAL(activated()),m_view,SLOT(slotDirUp())); 522 connect(m_aDirUp,SIGNAL(activated()),m_view,SLOT(slotDirUp()));
523 523
524 if ( Ir::supported() ) { 524 if ( Ir::supported() ) {
525 m_aBeam = new QAction( tr( "Beam file" ), Resource::loadIconSet( "beam" ),0, 0, this, 0, true ); 525 m_aBeam = new QAction( tr( "Beam file" ), Resource::loadIconSet( "beam" ),0, 0, this, 0, true );
526 m_aBeam->setToggleAction(false); 526 m_aBeam->setToggleAction(false);
527 connect(m_aBeam,SIGNAL(activated()),m_view,SLOT(slotBeam())); 527 connect(m_aBeam,SIGNAL(activated()),m_view,SLOT(slotBeam()));
528 } else { 528 } else {
529 m_aBeam = 0; 529 m_aBeam = 0;
530 } 530 }
531 531
532 m_aShowInfo = new QAction( tr( "Show imageinfo" ), Resource::loadIconSet( "edit" ), 0, 0, this, 0, true ); 532 m_aShowInfo = new QAction( tr( "Show imageinfo" ), Resource::loadIconSet( "edit" ), 0, 0, this, 0, true );
533 m_aShowInfo->setToggleAction(false); 533 m_aShowInfo->setToggleAction(false);
534 connect(m_aShowInfo,SIGNAL(activated()),m_view,SLOT(slotImageInfo())); 534 connect(m_aShowInfo,SIGNAL(activated()),m_view,SLOT(slotImageInfo()));
535 535
536 m_aTrash = new QAction( tr( "Delete file" ), Resource::loadIconSet("trash"), 0, 0, this, 0, true ); 536 m_aTrash = new QAction( tr( "Delete file" ), Resource::loadIconSet("trash"), 0, 0, this, 0, true );
537 m_aTrash->setToggleAction(false); 537 m_aTrash->setToggleAction(false);
538 connect(m_aTrash,SIGNAL(activated()),m_view,SLOT(slotTrash())); 538 connect(m_aTrash,SIGNAL(activated()),m_view,SLOT(slotTrash()));
539 539
540 m_aViewfile = new QAction( tr( "Display image" ), Resource::loadIconSet("mag"), 0, 0, this, 0, true ); 540 m_aViewfile = new QAction( tr( "Display image" ), Resource::loadIconSet("mag"), 0, 0, this, 0, true );
541 m_aViewfile->setToggleAction(false); 541 m_aViewfile->setToggleAction(false);
542 connect(m_aViewfile,SIGNAL(activated()),m_view,SLOT(slotShowImage())); 542 connect(m_aViewfile,SIGNAL(activated()),m_view,SLOT(slotShowImage()));
543 543
544 m_aStartSlide = new QAction( tr( "Start slideshow" ), Resource::loadIconSet("play"),0, 0, this, 0, true ); 544 m_aStartSlide = new QAction( tr( "Start slideshow" ), Resource::loadIconSet("play"),0, 0, this, 0, true );
545 m_aStartSlide->setToggleAction(false); 545 m_aStartSlide->setToggleAction(false);
546 connect(m_aStartSlide,SIGNAL(activated()),m_view,SLOT(slotStartSlide())); 546 connect(m_aStartSlide,SIGNAL(activated()),m_view,SLOT(slotStartSlide()));
547 547
548 m_aHideToolbar = new QAction( tr( "Show toolbar" ), Resource::loadIconSet( "UtilsIcon" ), 0, 0, this, 0, true ); 548 m_aHideToolbar = new QAction( tr( "Show toolbar" ), Resource::loadIconSet( "UtilsIcon" ), 0, 0, this, 0, true );
549 m_aHideToolbar->setOn (true); 549 m_aHideToolbar->setOn (true);
550 connect(m_aHideToolbar,SIGNAL(toggled(bool)),this,SLOT(showToolbar(bool))); 550 connect(m_aHideToolbar,SIGNAL(toggled(bool)),this,SLOT(showToolbar(bool)));
551 551
552 m_aSetup = new QAction( tr( "Settings" ), Resource::loadIconSet("SettingsIcon"), 0, 0, this, 0, true ); 552 m_aSetup = new QAction( tr( "Settings" ), Resource::loadIconSet("SettingsIcon"), 0, 0, this, 0, true );
553 m_aSetup->setToggleAction(false); 553 m_aSetup->setToggleAction(false);
554 connect(m_aSetup,SIGNAL(activated()),this,SLOT(slotConfig())); 554 connect(m_aSetup,SIGNAL(activated()),this,SLOT(slotConfig()));
555 555
556 m_gListViewMode = new QActionGroup(this,"Select listmode",true); 556 m_gListViewMode = new QActionGroup(this,"Select listmode",true);
557 connect(m_gListViewMode,SIGNAL(selected(QAction*)),this,SLOT(listviewselected(QAction*))); 557 connect(m_gListViewMode,SIGNAL(selected(QAction*)),this,SLOT(listviewselected(QAction*)));
558 558
559 m_aDirLong = new QAction( tr( "Thumbnail and Imageinfo" ),Resource::loadIconSet("opie-eye/opie-eye-thumb"), 0, 0, this, 0, true ); 559 m_aDirLong = new QAction( tr( "Thumbnail and Imageinfo" ),Resource::loadIconSet("opie-eye/opie-eye-thumb"), 0, 0, this, 0, true );
560 m_aDirLong->setToggleAction(true); 560 m_aDirLong->setToggleAction(true);
561 m_aDirShort = new QAction( tr( "Thumbnail and name" ),Resource::loadIconSet("opie-eye/opie-eye-thumbonly"), 0, 0, this, 0, true ); 561 m_aDirShort = new QAction( tr( "Thumbnail and name" ),Resource::loadIconSet("opie-eye/opie-eye-thumbonly"), 0, 0, this, 0, true );
562 m_aDirShort->setToggleAction(true); 562 m_aDirShort->setToggleAction(true);
563 m_aDirName = new QAction( tr( "Name only" ), Resource::loadIconSet("opie-eye/opie-eye-textview"),0, 0, this, 0, true ); 563 m_aDirName = new QAction( tr( "Name only" ), Resource::loadIconSet("opie-eye/opie-eye-textview"),0, 0, this, 0, true );
564 m_aDirName->setToggleAction(true); 564 m_aDirName->setToggleAction(true);
565 int mode = m_cfg->readNumEntry("ListViewMode", 1); 565 int mode = m_cfg->readNumEntry("ListViewMode", 1);
566 if (mode < 1 || mode>3) mode = 1; 566 if (mode < 1 || mode>3) mode = 1;
567 switch (mode) { 567 switch (mode) {
568 case 3: 568 case 3:
569 m_aDirName->setOn(true); 569 m_aDirName->setOn(true);
570 break; 570 break;
571 case 2: 571 case 2:
572 m_aDirShort->setOn(true); 572 m_aDirShort->setOn(true);
573 break; 573 break;
574 case 1: 574 case 1:
575 default: 575 default:
576 m_aDirLong->setOn(true); 576 m_aDirLong->setOn(true);
577 } 577 }
578 m_gListViewMode->insert(m_aDirLong); 578 m_gListViewMode->insert(m_aDirLong);
579 m_gListViewMode->insert(m_aDirShort); 579 m_gListViewMode->insert(m_aDirShort);
580 m_gListViewMode->insert(m_aDirName); 580 m_gListViewMode->insert(m_aDirName);
581 581
582 m_gPrevNext = new QActionGroup(this,"imageprevnext",false); 582 m_gPrevNext = new QActionGroup(this,"imageprevnext",false);
583 m_aNext = new QAction( tr( "Next image" ), Resource::loadIconSet("forward"), 0, 0, this, 0, true ); 583 m_aNext = new QAction( tr( "Next image" ), Resource::loadIconSet("forward"), 0, 0, this, 0, true );
584 m_aNext->setToggleAction(false); 584 m_aNext->setToggleAction(false);
585 connect(m_aNext,SIGNAL(activated()),m_view,SLOT(slotShowNext())); 585 connect(m_aNext,SIGNAL(activated()),m_view,SLOT(slotShowNext()));
586 m_aPrevious = new QAction( tr( "Previous image" ), Resource::loadIconSet("back"), 0, 0, this, 0, true ); 586 m_aPrevious = new QAction( tr( "Previous image" ), Resource::loadIconSet("back"), 0, 0, this, 0, true );
587 m_aPrevious->setToggleAction(false); 587 m_aPrevious->setToggleAction(false);
588 connect(m_aPrevious,SIGNAL(activated()),m_view,SLOT(slotShowPrev())); 588 connect(m_aPrevious,SIGNAL(activated()),m_view,SLOT(slotShowPrev()));
589 m_gPrevNext->insert(m_aPrevious); 589 m_gPrevNext->insert(m_aPrevious);
590 m_gPrevNext->insert(m_aNext); 590 m_gPrevNext->insert(m_aNext);
591 591
592 m_aFullScreen = new QAction( tr( "Show images fullscreen" ), 592 m_aFullScreen = new QAction( tr( "Show images fullscreen" ),
593 Resource::loadIconSet("fullscreen"), 0, 0, this, 0, true ); 593 Resource::loadIconSet("fullscreen"), 0, 0, this, 0, true );
594 m_aFullScreen->setToggleAction(true); 594 m_aFullScreen->setToggleAction(true);
595 if (autoSave) { 595 if (autoSave) {
596 m_aFullScreen->setOn(m_cfg->readBoolEntry("fullscreen",false)); 596 m_aFullScreen->setOn(m_cfg->readBoolEntry("fullscreen",false));
597 } else { 597 } else {
598 m_aFullScreen->setOn(false); 598 m_aFullScreen->setOn(false);
599 } 599 }
600 connect(m_aFullScreen,SIGNAL(toggled(bool)),this,SLOT(slotFullScreenButton(bool))); 600 connect(m_aFullScreen,SIGNAL(toggled(bool)),this,SLOT(slotFullScreenButton(bool)));
601 601
602 m_gDisplayType = new QActionGroup(this,"imagedisplaytype",false); 602 m_gDisplayType = new QActionGroup(this,"imagedisplaytype",false);
603 m_aAutoRotate = new QAction( tr( "Auto rotate images" ), Resource::loadIconSet( "rotate" ), 0, 0, this, 0, true ); 603 m_aAutoRotate = new QAction( tr( "Auto rotate images" ), Resource::loadIconSet( "rotate" ), 0, 0, this, 0, true );
604 m_aAutoRotate->setToggleAction(true); 604 m_aAutoRotate->setToggleAction(true);
605 605
606 if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) { 606 if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) {
607 m_aAutoRotate->setOn(true); 607 m_aAutoRotate->setOn(true);
608 } else { 608 } else {
609 m_aAutoRotate->setOn(false); 609 m_aAutoRotate->setOn(false);
610 } 610 }
611 if (autoSave) { 611 if (autoSave) {
612 m_aAutoRotate->setOn(m_cfg->readBoolEntry("autorotate",m_aAutoRotate->isOn())); 612 m_aAutoRotate->setOn(m_cfg->readBoolEntry("autorotate",m_aAutoRotate->isOn()));
613 } 613 }
614 connect(m_aAutoRotate,SIGNAL(toggled(bool)),this,SLOT(slotRotateToggled(bool))); 614 connect(m_aAutoRotate,SIGNAL(toggled(bool)),this,SLOT(slotRotateToggled(bool)));
615 615
616 m_aUnscaled = new QAction( tr( "Show images unscaled" ), Resource::loadIconSet( "1to1" ), 0, 0, this, 0, true ); 616 m_aUnscaled = new QAction( tr( "Show images unscaled" ), Resource::loadIconSet( "1to1" ), 0, 0, this, 0, true );
617 m_aUnscaled->setToggleAction(true); 617 m_aUnscaled->setToggleAction(true);
618 connect(m_aUnscaled,SIGNAL(toggled(bool)),this,SLOT(slotScaleToggled(bool))); 618 connect(m_aUnscaled,SIGNAL(toggled(bool)),this,SLOT(slotScaleToggled(bool)));
619 if (autoSave) { 619 if (autoSave) {
620 m_aUnscaled->setOn(m_cfg->readBoolEntry("unscaled",false)); 620 m_aUnscaled->setOn(m_cfg->readBoolEntry("unscaled",false));
621 } else { 621 } else {
622 m_aUnscaled->setOn(false); 622 m_aUnscaled->setOn(false);
623 } 623 }
624 624
625 m_aZoomer = new QAction( tr( "Show zoomer window when unscaled" ), Resource::loadIconSet( "mag" ), 0, 0, this, 0, true ); 625 m_aZoomer = new QAction( tr( "Show zoomer window when unscaled" ), Resource::loadIconSet( "mag" ), 0, 0, this, 0, true );
626 m_aZoomer->setToggleAction(true); 626 m_aZoomer->setToggleAction(true);
627 if (autoSave) { 627 if (autoSave) {
628 m_aZoomer->setOn(m_cfg->readBoolEntry("zoomeron",true)); 628 m_aZoomer->setOn(m_cfg->readBoolEntry("zoomeron",true));
629 } else { 629 } else {
630 m_aZoomer->setOn (true); 630 m_aZoomer->setOn (true);
631 } 631 }
632 connect(m_aZoomer,SIGNAL(toggled(bool)),this,SLOT(slotZoomerToggled(bool))); 632 connect(m_aZoomer,SIGNAL(toggled(bool)),this,SLOT(slotZoomerToggled(bool)));
633 m_gDisplayType->insert(m_aAutoRotate); 633 m_gDisplayType->insert(m_aAutoRotate);
634 m_gDisplayType->insert(m_aUnscaled); 634 m_gDisplayType->insert(m_aUnscaled);
635 m_gDisplayType->insert(m_aZoomer); 635 m_gDisplayType->insert(m_aZoomer);
636 636
637 m_hGroup = new QActionGroup(this,"actioncollection",false); 637 m_hGroup = new QActionGroup(this,"actioncollection",false);
638 m_hGroup->insert(m_aFullScreen); 638 m_hGroup->insert(m_aFullScreen);
639 639
640 if (!m_SmallWindow) { 640 if (!m_SmallWindow) {
641 m_aForceSmall = new QAction(tr("Dont show seperate windows"),Resource::loadIconSet( "AppsIcon" ), 0, 0, this, 0, true); 641 m_aForceSmall = new QAction(tr("Dont show seperate windows"),Resource::loadIconSet( "AppsIcon" ), 0, 0, this, 0, true);
642 m_aForceSmall->setToggleAction(true); 642 m_aForceSmall->setToggleAction(true);
643 connect(m_aForceSmall,SIGNAL(toggled(bool)),this,SLOT(slotForceSmall(bool))); 643 connect(m_aForceSmall,SIGNAL(toggled(bool)),this,SLOT(slotForceSmall(bool)));
644 } else { 644 } else {
645 m_aForceSmall = 0; 645 m_aForceSmall = 0;
646 } 646 }
647 m_setCurrentBrightness = new QAction(tr("Display brightness..."), 0, 0, this, 0, false); 647 m_setCurrentBrightness = new QAction(tr("Display brightness..."), 0, 0, this, 0, false);
648 connect(m_setCurrentBrightness,SIGNAL(activated()),this,SLOT(setupBrightness())); 648 connect(m_setCurrentBrightness,SIGNAL(activated()),this,SLOT(setupBrightness()));
649 m_IncBrightness = new QAction(tr("Increase brightness by 5"),Resource::loadIconSet( "up" ),0, 0, this, 0, false); 649 m_IncBrightness = new QAction(tr("Increase brightness by 5"),Resource::loadIconSet( "up" ),0, 0, this, 0, false);
650 m_DecBrightness = new QAction(tr("Decrease brightness by 5"),Resource::loadIconSet( "down" ),0, 0, this, 0, false); 650 m_DecBrightness = new QAction(tr("Decrease brightness by 5"),Resource::loadIconSet( "down" ),0, 0, this, 0, false);
651 m_hBright = new QActionGroup(this,"actioncollection",false), 651 m_hBright = new QActionGroup(this,"actioncollection",false),
652 m_hBright->insert(m_setCurrentBrightness);
652 m_hBright->insert(m_IncBrightness); 653 m_hBright->insert(m_IncBrightness);
653 m_hBright->insert(m_DecBrightness); 654 m_hBright->insert(m_DecBrightness);
654} 655}
655 656
656void PMainWindow::setupBrightness() 657void PMainWindow::setupBrightness()
657{ 658{
658 if (!m_disp) { 659 if (!m_disp) {
659 return; 660 return;
660 } 661 }
662 bool reshow=false;
663 if (m_disp->isVisible()&&m_disp->fullScreen()) {
664 m_disp->hide();
665 reshow = true;
666 }
661 int lb = m_disp->Intensity(); 667 int lb = m_disp->Intensity();
662 if (Valuebox(0,-100,100,lb,lb)) { 668 if (Valuebox(0,-100,100,lb,lb)) {
663 m_disp->setIntensity(lb,true); 669 m_disp->setIntensity(lb,true);
664 } 670 }
671 if (reshow) {
672 m_disp->showFullScreen();
673 qwsDisplay()->requestFocus( m_disp->winId(), TRUE);
674 }
665} 675}
666 676
667void PMainWindow::setupToolbar() 677void PMainWindow::setupToolbar()
668{ 678{
669 toolBar = new QToolBar( this ); 679 toolBar = new QToolBar( this );
670 addToolBar(toolBar); 680 addToolBar(toolBar);
671 toolBar->setHorizontalStretchable( true ); 681 toolBar->setHorizontalStretchable( true );
672 setToolBarsMovable( false ); 682 setToolBarsMovable( false );
673 m_aDirUp->addTo( toolBar ); 683 m_aDirUp->addTo( toolBar );
674 684
675 fsButton = new PFileSystem( toolBar ); 685 fsButton = new PFileSystem( toolBar );
676 connect( fsButton, SIGNAL( changeDir( const QString& ) ), 686 connect( fsButton, SIGNAL( changeDir( const QString& ) ),
677 m_view, SLOT(slotChangeDir( const QString& ) ) ); 687 m_view, SLOT(slotChangeDir( const QString& ) ) );
678 connect( this, SIGNAL( changeDir( const QString& ) ), 688 connect( this, SIGNAL( changeDir( const QString& ) ),
679 m_view, SLOT(slotChangeDir( const QString& ) ) ); 689 m_view, SLOT(slotChangeDir( const QString& ) ) );
680 690
681 if (m_aBeam) { 691 if (m_aBeam) {
682 m_aBeam->addTo( toolBar ); 692 m_aBeam->addTo( toolBar );
683 } 693 }
684 m_aShowInfo->addTo(toolBar); 694 m_aShowInfo->addTo(toolBar);
685 m_aTrash->addTo(toolBar); 695 m_aTrash->addTo(toolBar);
686// m_aSetup->addTo(toolBar);
687 696
688 m_gDisplayType->addTo(toolBar); 697 m_gDisplayType->addTo(toolBar);
689 698
690 if (!m_SmallWindow) { 699 if (!m_SmallWindow) {
691 m_gPrevNext->addTo(toolBar); 700 m_gPrevNext->addTo(toolBar);
692 } else { 701 } else {
693 m_gPrevNext->setEnabled(false); 702 m_gPrevNext->setEnabled(false);
694 } 703 }
695} 704}
696 705
697void PMainWindow::setupMenu() 706void PMainWindow::setupMenu()
698{ 707{
699 fileMenu = new QPopupMenu( menuBar() ); 708 fileMenu = new QPopupMenu( menuBar() );
700 menuBar()->insertItem( tr( "File" ), fileMenu ); 709 menuBar()->insertItem( tr( "File" ), fileMenu );
701 dispMenu = new QPopupMenu( menuBar() ); 710 dispMenu = new QPopupMenu( menuBar() );
702 menuBar()->insertItem( tr( "Show" ), dispMenu ); 711 menuBar()->insertItem( tr( "Show" ), dispMenu );
703 settingsMenu = new QPopupMenu( menuBar() ); 712 settingsMenu = new QPopupMenu( menuBar() );
704 menuBar()->insertItem( tr( "Settings" ), settingsMenu ); 713 menuBar()->insertItem( tr( "Settings" ), settingsMenu );
705 714
706 m_aViewfile->addTo(fileMenu); 715 m_aViewfile->addTo(fileMenu);
707 m_aShowInfo->addTo(fileMenu); 716 m_aShowInfo->addTo(fileMenu);
708 m_aStartSlide->addTo(fileMenu); 717 m_aStartSlide->addTo(fileMenu);
709 718
710 fileMenu->insertSeparator(); 719 fileMenu->insertSeparator();
711 m_aDirUp->addTo( fileMenu ); 720 m_aDirUp->addTo( fileMenu );
712 721
713 fsMenu = new QPopupMenu(fileMenu); 722 fsMenu = new QPopupMenu(fileMenu);
714 fileMenu->insertItem(Resource::loadIconSet( "cardmon/pcmcia" ),tr("Select filesystem"),fsMenu); 723 fileMenu->insertItem(Resource::loadIconSet( "cardmon/pcmcia" ),tr("Select filesystem"),fsMenu);
715 connect( fsMenu, SIGNAL( activated( int ) ), this, SLOT(slotSelectDir( int ) ) ); 724 connect( fsMenu, SIGNAL( activated( int ) ), this, SLOT(slotSelectDir( int ) ) );
716 dirChanged(); 725 dirChanged();
717 726
718 if ( m_aBeam ) { 727 if ( m_aBeam ) {
719 fileMenu->insertSeparator(); 728 fileMenu->insertSeparator();
720 m_aBeam->addTo( fileMenu ); 729 m_aBeam->addTo( fileMenu );
721 } 730 }
722 fileMenu->insertSeparator(); 731 fileMenu->insertSeparator();
723 m_aTrash->addTo(fileMenu); 732 m_aTrash->addTo(fileMenu);
724 733
725 listviewMenu = new QPopupMenu(dispMenu); 734 listviewMenu = new QPopupMenu(dispMenu);
726 dispMenu->insertItem(Resource::loadIconSet("opie-eye/opie-eye-thumb"),tr("Listview mode"),listviewMenu); 735 dispMenu->insertItem(Resource::loadIconSet("opie-eye/opie-eye-thumb"),tr("Listview mode"),listviewMenu);
727 m_gListViewMode->addTo(listviewMenu); 736 m_gListViewMode->addTo(listviewMenu);
728 dispMenu->insertSeparator(); 737 dispMenu->insertSeparator();
729 m_aFullScreen->addTo(dispMenu); 738 m_aFullScreen->addTo(dispMenu);
730 m_gDisplayType->addTo(dispMenu); 739 m_gDisplayType->addTo(dispMenu);
731 dispMenu->insertSeparator(); 740 dispMenu->insertSeparator();
732 m_gPrevNext->addTo(dispMenu); 741 m_gPrevNext->addTo(dispMenu);
733 m_setCurrentBrightness->addTo(dispMenu);
734 m_setCurrentBrightness->setEnabled(false);
735 dispMenu->insertSeparator(); 742 dispMenu->insertSeparator();
736 m_hBright->addTo(dispMenu); 743 m_hBright->addTo(dispMenu);
737 m_hBright->setEnabled(false); 744 m_hBright->setEnabled(false);
738 745
739 if (m_aForceSmall) { 746 if (m_aForceSmall) {
740 dispMenu->insertSeparator(); 747 dispMenu->insertSeparator();
741 m_aForceSmall->addTo(dispMenu); 748 m_aForceSmall->addTo(dispMenu);
742 } 749 }
743 750
744 m_aSetup->addTo(settingsMenu); 751 m_aSetup->addTo(settingsMenu);
745 m_aHideToolbar->addTo(settingsMenu); 752 m_aHideToolbar->addTo(settingsMenu);
746} 753}
747 754
748void PMainWindow::listviewselected(QAction*which) 755void PMainWindow::listviewselected(QAction*which)
749{ 756{
750 if (!which || which->isOn()==false) return; 757 if (!which || which->isOn()==false) return;
751 int val = 1; 758 int val = 1;
752 759
753 if (which==m_aDirName) { 760 if (which==m_aDirName) {
754 val = 3; 761 val = 3;
755 } else if (which==m_aDirShort) { 762 } else if (which==m_aDirShort) {
756 val = 2; 763 val = 2;
757 } else if (which==m_aDirLong) { 764 } else if (which==m_aDirLong) {
758 val = 1; 765 val = 1;
759 } 766 }
760 emit changeListMode(val); 767 emit changeListMode(val);
761} 768}
762 769
763void PMainWindow::readConfig() 770void PMainWindow::readConfig()
764{ 771{
765 autoSave =m_cfg->readBoolEntry("savestatus",true); 772 autoSave =m_cfg->readBoolEntry("savestatus",true);
766 m_Intensity = m_cfg->readNumEntry("intensity",0); 773 m_Intensity = m_cfg->readNumEntry("intensity",0);
767} 774}
768 775
769void PMainWindow::polish() 776void PMainWindow::polish()
770{ 777{
771 if (m_disp) { 778 if (m_disp) {
772 odebug << "======================\n" 779 odebug << "======================\n"
773 << "Called via setdocument\n" 780 << "Called via setdocument\n"
774 << "======================" << oendl; 781 << "======================" << oendl;
775 m_setDocCalled = true; 782 m_setDocCalled = true;
776 m_view->setDoccalled(true); 783 m_view->setDoccalled(true);
777 m_disp->setCloseIfHide(true); 784 m_disp->setCloseIfHide(true);
778 } else { 785 } else {
779 m_setDocCalled = false; 786 m_setDocCalled = false;
780 m_view->setDoccalled(false); 787 m_view->setDoccalled(false);
781 } 788 }
782 m_polishDone = true; 789 m_polishDone = true;
783 QMainWindow::polish(); 790 QMainWindow::polish();
784 if (m_setDocCalled) { 791 if (m_setDocCalled) {
785 if (m_aFullScreen->isOn()) { 792 if (m_aFullScreen->isOn()) {
786 QTimer::singleShot(0,this,SLOT(check_view_fullscreen())); 793 QTimer::singleShot(0,this,SLOT(check_view_fullscreen()));
787 } else if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) { 794 } else if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) {
788 } 795 }
789 } 796 }
790} 797}
791 798
792void PMainWindow::slotForceSmall(bool how) 799void PMainWindow::slotForceSmall(bool how)
793{ 800{
794 odebug << "Disable separate windows: " << how << oendl; 801 odebug << "Disable separate windows: " << how << oendl;
795 if (m_stack) { 802 if (m_stack) {
796 if (how) { 803 if (how) {
797 m_stack->forceMode(Opie::Ui::OWidgetStack::SmallScreen); 804 m_stack->forceMode(Opie::Ui::OWidgetStack::SmallScreen);
798 } else { 805 } else {
799 m_stack->forceMode(Opie::Ui::OWidgetStack::NoForce); 806 m_stack->forceMode(Opie::Ui::OWidgetStack::NoForce);
800 } 807 }
801 } 808 }
802 if (autoSave) { 809 if (autoSave) {
803 m_cfg->writeEntry("dontshowseperate",how); 810 m_cfg->writeEntry("dontshowseperate",how);
804 } 811 }
805} 812}
806 813
807bool PMainWindow::Valuebox(QWidget*parent,int min, int max, int current,int&store) 814bool PMainWindow::Valuebox(QWidget*parent,int min, int max, int current,int&store)
808{ 815{
809 QDialog dlg(parent,"brightnessbox",true); 816 QDialog dlg(parent,"brightnessbox",true);
810 QVBoxLayout * m_MainLayout; 817 QVBoxLayout * m_MainLayout;
811 QGridLayout * m_IntensityLayout; 818 QGridLayout * m_IntensityLayout;
812 QSpinBox * m_Intensity; 819 QSpinBox * m_Intensity;
813 QLabel * m_IntensityLabel; 820 QLabel * m_IntensityLabel;
814 821
815 m_MainLayout = new QVBoxLayout( &dlg, 11, 6, "m_MainLayout"); 822 m_MainLayout = new QVBoxLayout( &dlg, 11, 6, "m_MainLayout");
816 m_IntensityLayout = new QGridLayout( 0, 1, 1, 0, 6, "m_IntensityLayout"); 823 m_IntensityLayout = new QGridLayout( 0, 1, 1, 0, 6, "m_IntensityLayout");
817 m_Intensity = new QSpinBox( &dlg, "m_Intensity" ); 824 m_Intensity = new QSpinBox( &dlg, "m_Intensity" );
818 m_Intensity->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Fixed)); 825 m_Intensity->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Fixed));
819 m_Intensity->setButtonSymbols( QSpinBox::PlusMinus ); 826 m_Intensity->setButtonSymbols( QSpinBox::PlusMinus );
820 m_Intensity->setMaxValue( max ); 827 m_Intensity->setMaxValue( max );
821 m_Intensity->setMinValue(min); 828 m_Intensity->setMinValue(min);
822 m_Intensity->setValue( current ); 829 m_Intensity->setValue( current );
823 m_IntensityLayout->addWidget( m_Intensity, 0, 1 ); 830 m_IntensityLayout->addWidget( m_Intensity, 0, 1 );
824 m_IntensityLabel = new QLabel( &dlg, "m_IntensityLabel" ); 831 m_IntensityLabel = new QLabel( &dlg, "m_IntensityLabel" );
825 m_IntensityLabel->setText(QObject::tr("Display brightness:")); 832 m_IntensityLabel->setText(QObject::tr("Display brightness:"));
826 m_IntensityLayout->addWidget(m_IntensityLabel, 0, 0 ); 833 m_IntensityLayout->addWidget(m_IntensityLabel, 0, 0 );
827 m_MainLayout->addLayout(m_IntensityLayout); 834 m_MainLayout->addLayout(m_IntensityLayout);
828 if (dlg.exec()) { 835 if (dlg.exec()) {
829 store = m_Intensity->value(); 836 store = m_Intensity->value();
830 return true; 837 return true;
831 } 838 }
832 return false; 839 return false;
833} 840}