summaryrefslogtreecommitdiff
path: root/library/qpeapplication.cpp
Unidiff
Diffstat (limited to 'library/qpeapplication.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--library/qpeapplication.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp
index 5f61c0c..cf437da 100644
--- a/library/qpeapplication.cpp
+++ b/library/qpeapplication.cpp
@@ -1,452 +1,452 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19** $Id$ 19** $Id$
20** 20**
21**********************************************************************/ 21**********************************************************************/
22#define QTOPIA_INTERNAL_LANGLIST 22#define QTOPIA_INTERNAL_LANGLIST
23#include <stdlib.h> 23#include <stdlib.h>
24#include <unistd.h> 24#include <unistd.h>
25#include <qfile.h> 25#include <qfile.h>
26#ifdef Q_WS_QWS 26#ifdef Q_WS_QWS
27#ifndef QT_NO_COP 27#ifndef QT_NO_COP
28#if QT_VERSION <= 231 28#if QT_VERSION <= 231
29#define private public 29#define private public
30#define sendLocally processEvent 30#define sendLocally processEvent
31#include "qcopenvelope_qws.h" 31#include "qcopenvelope_qws.h"
32#undef private 32#undef private
33#else 33#else
34#include "qcopenvelope_qws.h" 34#include "qcopenvelope_qws.h"
35#endif 35#endif
36#endif 36#endif
37#include <qwindowsystem_qws.h> 37#include <qwindowsystem_qws.h>
38#endif 38#endif
39#include <qtextstream.h> 39#include <qtextstream.h>
40#include <qpalette.h> 40#include <qpalette.h>
41#include <qbuffer.h> 41#include <qbuffer.h>
42#include <qptrdict.h> 42#include <qptrdict.h>
43#include <qregexp.h> 43#include <qregexp.h>
44#include <qdir.h> 44#include <qdir.h>
45#include <qlabel.h> 45#include <qlabel.h>
46#include <qdialog.h> 46#include <qdialog.h>
47#include <qdragobject.h> 47#include <qdragobject.h>
48#include <qevent.h> 48#include <qevent.h>
49#include <qtooltip.h> 49#include <qtooltip.h>
50#include <qsignal.h> 50#include <qsignal.h>
51#include <linux/fb.h> 51#include <linux/fb.h>
52 52
53#include <qsignal.h> 53#include <qsignal.h>
54#include "qpeapplication.h" 54#include "qpeapplication.h"
55#include "qpestyle.h" 55#include "qpestyle.h"
56#if QT_VERSION >= 300 56#if QT_VERSION >= 300
57#include <qstylefactory.h> 57#include <qstylefactory.h>
58#else 58#else
59#include <qplatinumstyle.h> 59#include <qplatinumstyle.h>
60#include <qwindowsstyle.h> 60#include <qwindowsstyle.h>
61#include <qmotifstyle.h> 61#include <qmotifstyle.h>
62#include <qmotifplusstyle.h> 62#include <qmotifplusstyle.h>
63#include "lightstyle.h" 63#include "lightstyle.h"
64#endif 64#endif
65#include "global.h" 65#include "global.h"
66#include "resource.h" 66#include "resource.h"
67#if QT_VERSION <= 230 && defined(QT_NO_CODECS) 67#if QT_VERSION <= 230 && defined(QT_NO_CODECS)
68#include "qutfcodec.h" 68#include "qutfcodec.h"
69#endif 69#endif
70#include "config.h" 70#include "config.h"
71#include "network.h" 71#include "network.h"
72#include "fontmanager.h" 72#include "fontmanager.h"
73#include "power.h" 73#include "power.h"
74#include "alarmserver.h" 74#include "alarmserver.h"
75#include "applnk.h" 75#include "applnk.h"
76#include "qpemenubar.h" 76#include "qpemenubar.h"
77 77
78#include <unistd.h> 78#include <unistd.h>
79#include <sys/file.h> 79#include <sys/file.h>
80#include <sys/ioctl.h> 80#include <sys/ioctl.h>
81#include <sys/soundcard.h> 81#include <sys/soundcard.h>
82 82
83// for setBacklight() 83// for setBacklight()
84#if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) 84#if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX)
85#include <linux/fb.h> 85#include <linux/fb.h>
86#include <sys/types.h> 86#include <sys/types.h>
87#include <sys/stat.h> 87#include <sys/stat.h>
88#endif 88#endif
89#include <stdlib.h> 89#include <stdlib.h>
90 90
91 91
92class QPEApplicationData { 92class QPEApplicationData {
93public: 93public:
94 QPEApplicationData() : presstimer(0), presswidget(0), rightpressed(FALSE), 94 QPEApplicationData() : presstimer(0), presswidget(0), rightpressed(FALSE),
95 kbgrabber(0), kbregrab(FALSE), notbusysent(FALSE), preloaded(FALSE), 95 kbgrabber(0), kbregrab(FALSE), notbusysent(FALSE), preloaded(FALSE),
96 forceshow(FALSE), nomaximize(FALSE), qpe_main_widget(0), 96 forceshow(FALSE), nomaximize(FALSE), qpe_main_widget(0),
97 keep_running(TRUE) 97 keep_running(TRUE)
98 { 98 {
99 qcopq.setAutoDelete(TRUE); 99 qcopq.setAutoDelete(TRUE);
100 } 100 }
101 101
102 int presstimer; 102 int presstimer;
103 QWidget* presswidget; 103 QWidget* presswidget;
104 QPoint presspos; 104 QPoint presspos;
105 bool rightpressed; 105 bool rightpressed;
106 int kbgrabber; 106 int kbgrabber;
107 bool kbregrab; 107 bool kbregrab;
108 bool notbusysent; 108 bool notbusysent;
109 QString appName; 109 QString appName;
110 struct QCopRec { 110 struct QCopRec {
111 QCopRec(const QCString &ch, const QCString &msg, 111 QCopRec(const QCString &ch, const QCString &msg,
112 const QByteArray &d) : 112 const QByteArray &d) :
113 channel(ch), message(msg), data(d) { } 113 channel(ch), message(msg), data(d) { }
114 114
115 QCString channel; 115 QCString channel;
116 QCString message; 116 QCString message;
117 QByteArray data; 117 QByteArray data;
118 }; 118 };
119 bool preloaded; 119 bool preloaded;
120 bool forceshow; 120 bool forceshow;
121 bool nomaximize; 121 bool nomaximize;
122 QWidget* qpe_main_widget; 122 QWidget* qpe_main_widget;
123 bool keep_running; 123 bool keep_running;
124 QList<QCopRec> qcopq; 124 QList<QCopRec> qcopq;
125 125
126 void enqueueQCop(const QCString &ch, const QCString &msg, 126 void enqueueQCop(const QCString &ch, const QCString &msg,
127 const QByteArray &data) 127 const QByteArray &data)
128 { 128 {
129 qcopq.append(new QCopRec(ch,msg,data)); 129 qcopq.append(new QCopRec(ch,msg,data));
130 } 130 }
131 void sendQCopQ() 131 void sendQCopQ()
132 { 132 {
133 QCopRec* r; 133 QCopRec* r;
134 for (QListIterator<QCopRec> it(qcopq); (r=it.current()); ++it) 134 for (QListIterator<QCopRec> it(qcopq); (r=it.current()); ++it)
135 QCopChannel::sendLocally(r->channel,r->message,r->data); 135 QCopChannel::sendLocally(r->channel,r->message,r->data);
136 qcopq.clear(); 136 qcopq.clear();
137 } 137 }
138}; 138};
139 139
140class ResourceMimeFactory : public QMimeSourceFactory { 140class ResourceMimeFactory : public QMimeSourceFactory {
141public: 141public:
142 ResourceMimeFactory() 142 ResourceMimeFactory()
143 { 143 {
144 setFilePath( Global::helpPath() ); 144 setFilePath( Global::helpPath() );
145 setExtensionType("html","text/html;charset=UTF-8"); 145 setExtensionType("html","text/html;charset=UTF-8");
146 } 146 }
147 147
148 const QMimeSource* data(const QString& abs_name) const 148 const QMimeSource* data(const QString& abs_name) const
149 { 149 {
150 const QMimeSource* r = QMimeSourceFactory::data(abs_name); 150 const QMimeSource* r = QMimeSourceFactory::data(abs_name);
151 if ( !r ) { 151 if ( !r ) {
152 int sl = abs_name.length(); 152 int sl = abs_name.length();
153 do { 153 do {
154 sl = abs_name.findRev('/',sl-1); 154 sl = abs_name.findRev('/',sl-1);
155 QString name = sl>=0 ? abs_name.mid(sl+1) : abs_name; 155 QString name = sl>=0 ? abs_name.mid(sl+1) : abs_name;
156 int dot = name.findRev('.'); 156 int dot = name.findRev('.');
157 if ( dot >= 0 ) 157 if ( dot >= 0 )
158 name = name.left(dot); 158 name = name.left(dot);
159 QImage img = Resource::loadImage(name); 159 QImage img = Resource::loadImage(name);
160 if ( !img.isNull() ) 160 if ( !img.isNull() )
161 r = new QImageDrag(img); 161 r = new QImageDrag(img);
162 } while (!r && sl>0); 162 } while (!r && sl>0);
163 } 163 }
164 return r; 164 return r;
165 } 165 }
166}; 166};
167 167
168static int muted=0; 168static int muted=0;
169static int micMuted=0; 169static int micMuted=0;
170 170
171static void setVolume(int t=0, int percent=-1) 171static void setVolume(int t=0, int percent=-1)
172{ 172{
173 switch (t) { 173 switch (t) {
174 case 0: { 174 case 0: {
175 Config cfg("Sound"); 175 Config cfg("qpe");
176 cfg.setGroup("System"); 176 cfg.setGroup("Volume");
177 if ( percent < 0 ) 177 if ( percent < 0 )
178 percent = cfg.readNumEntry("Volume",50); 178 percent = cfg.readNumEntry("VolumePercent",50);
179 int fd = 0; 179 int fd = 0;
180 if ((fd = open("/dev/mixer", O_RDWR))>=0) { 180 if ((fd = open("/dev/mixer", O_RDWR))>=0) {
181 int vol = muted ? 0 : percent; 181 int vol = muted ? 0 : percent;
182 // set both channels to same volume 182 // set both channels to same volume
183 vol |= vol << 8; 183 vol |= vol << 8;
184 ioctl(fd, MIXER_WRITE(0), &vol); 184 ioctl(fd, MIXER_WRITE(0), &vol);
185 ::close(fd); 185 ::close(fd);
186 } 186 }
187 } break; 187 } break;
188 } 188 }
189} 189}
190 190
191static void setMic(int t=0, int percent=-1) 191static void setMic(int t=0, int percent=-1)
192{ 192{
193 switch (t) { 193 switch (t) {
194 case 0: { 194 case 0: {
195 Config cfg("Sound"); 195 Config cfg("qpe");
196 cfg.setGroup("System"); 196 cfg.setGroup("Volume");
197 if ( percent < 0 ) 197 if ( percent < 0 )
198 percent = cfg.readNumEntry("Mic",50); 198 percent = cfg.readNumEntry("Mic",50);
199 199
200 int fd = 0; 200 int fd = 0;
201 int mic = micMuted ? 0 : percent; 201 int mic = micMuted ? 0 : percent;
202 if ((fd = open("/dev/mixer", O_RDWR))>=0) { 202 if ((fd = open("/dev/mixer", O_RDWR))>=0) {
203 ioctl(fd, MIXER_WRITE(SOUND_MIXER_MIC), &mic); 203 ioctl(fd, MIXER_WRITE(SOUND_MIXER_MIC), &mic);
204 ::close(fd); 204 ::close(fd);
205 } 205 }
206 } break; 206 } break;
207 } 207 }
208} 208}
209 209
210int qpe_sysBrightnessSteps() 210int qpe_sysBrightnessSteps()
211{ 211{
212#if defined(QT_QWS_IPAQ) 212#if defined(QT_QWS_IPAQ)
213 return 255; 213 return 255;
214#elif defined(QT_QWS_EBX) 214#elif defined(QT_QWS_EBX)
215 return 4; 215 return 4;
216#else 216#else
217 return 255; // ? 217 return 255; // ?
218#endif 218#endif
219} 219}
220 220
221 221
222static int& hack(int& i) 222static int& hack(int& i)
223{ 223{
224#if QT_VERSION <= 230 && defined(QT_NO_CODECS) 224#if QT_VERSION <= 230 && defined(QT_NO_CODECS)
225 // These should be created, but aren't in Qt 2.3.0 225 // These should be created, but aren't in Qt 2.3.0
226 (void)new QUtf8Codec; 226 (void)new QUtf8Codec;
227 (void)new QUtf16Codec; 227 (void)new QUtf16Codec;
228#endif 228#endif
229 return i; 229 return i;
230} 230}
231 231
232static bool forced_off = FALSE; 232static bool forced_off = FALSE;
233static int curbl=-1; 233static int curbl=-1;
234 234
235static int backlight() 235static int backlight()
236{ 236{
237 if ( curbl == -1 ) { 237 if ( curbl == -1 ) {
238 // Read from config 238 // Read from config
239 Config config( "qpe" ); 239 Config config( "qpe" );
240 config.setGroup( "Screensaver" ); 240 config.setGroup( "Screensaver" );
241 curbl = config.readNumEntry("Brightness",255); 241 curbl = config.readNumEntry("Brightness",255);
242 } 242 }
243 return curbl; 243 return curbl;
244} 244}
245 245
246static void setBacklight(int bright) 246static void setBacklight(int bright)
247{ 247{
248 if ( bright == -3 ) { 248 if ( bright == -3 ) {
249 // Forced on 249 // Forced on
250 forced_off = FALSE; 250 forced_off = FALSE;
251 bright = -1; 251 bright = -1;
252 } 252 }
253 if ( forced_off && bright != -2 ) 253 if ( forced_off && bright != -2 )
254 return; 254 return;
255 if ( bright == -2 ) { 255 if ( bright == -2 ) {
256 // Toggle between off and on 256 // Toggle between off and on
257 bright = curbl ? 0 : -1; 257 bright = curbl ? 0 : -1;
258 forced_off = !bright; 258 forced_off = !bright;
259 } 259 }
260 if ( bright == -1 ) { 260 if ( bright == -1 ) {
261 // Read from config 261 // Read from config
262 Config config( "qpe" ); 262 Config config( "qpe" );
263 config.setGroup( "Screensaver" ); 263 config.setGroup( "Screensaver" );
264 bright = config.readNumEntry("Brightness",255); 264 bright = config.readNumEntry("Brightness",255);
265 } 265 }
266#if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) 266#if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX)
267 if ( QFile::exists("/usr/bin/bl") ) { 267 if ( QFile::exists("/usr/bin/bl") ) {
268 QString cmd = "/usr/bin/bl 1 "; 268 QString cmd = "/usr/bin/bl 1 ";
269 cmd += bright<=0 ? "0 " : "1 "; 269 cmd += bright<=0 ? "0 " : "1 ";
270 cmd += QString::number(bright); 270 cmd += QString::number(bright);
271 system(cmd.latin1()); 271 system(cmd.latin1());
272#if defined(QT_QWS_EBX) 272#if defined(QT_QWS_EBX)
273 } else if ( QFile::exists("/dev/fl") ) { 273 } else if ( QFile::exists("/dev/fl") ) {
274#define FL_IOCTL_STEP_CONTRAST 100 274#define FL_IOCTL_STEP_CONTRAST 100
275 int fd = open("/dev/fl", O_WRONLY); 275 int fd = open("/dev/fl", O_WRONLY);
276 if (fd >= 0 ) { 276 if (fd >= 0 ) {
277 int steps = qpe_sysBrightnessSteps(); 277 int steps = qpe_sysBrightnessSteps();
278 int bl = ( bright * steps + 127 ) / 255; 278 int bl = ( bright * steps + 127 ) / 255;
279 if ( bright && !bl ) bl = 1; 279 if ( bright && !bl ) bl = 1;
280 bl = ioctl(fd, FL_IOCTL_STEP_CONTRAST, bl); 280 bl = ioctl(fd, FL_IOCTL_STEP_CONTRAST, bl);
281 close(fd); 281 close(fd);
282 } 282 }
283 } 283 }
284#elif defined(QT_QWS_IPAQ) 284#elif defined(QT_QWS_IPAQ)
285 } else if ( QFile::exists("/dev/ts") || QFile::exists("/dev/h3600_ts") ) { 285 } else if ( QFile::exists("/dev/ts") || QFile::exists("/dev/h3600_ts") ) {
286 typedef struct { 286 typedef struct {
287 unsigned char mode; 287 unsigned char mode;
288 unsigned char pwr; 288 unsigned char pwr;
289 unsigned char brightness; 289 unsigned char brightness;
290 } FLITE_IN; 290 } FLITE_IN;
291# ifndef FLITE_ON 291# ifndef FLITE_ON
292# ifndef _LINUX_IOCTL_H 292# ifndef _LINUX_IOCTL_H
293# include <linux/ioctl.h> 293# include <linux/ioctl.h>
294# endif 294# endif
295# define FLITE_ON _IOW('f', 7, FLITE_IN) 295# define FLITE_ON _IOW('f', 7, FLITE_IN)
296# endif 296# endif
297 int fd; 297 int fd;
298 if ( QFile::exists("/dev/ts") ) 298 if ( QFile::exists("/dev/ts") )
299 fd = open("/dev/ts", O_WRONLY); 299 fd = open("/dev/ts", O_WRONLY);
300 else 300 else
301 fd = open("/dev/h3600_ts", O_WRONLY); 301 fd = open("/dev/h3600_ts", O_WRONLY);
302 if (fd >= 0 ) { 302 if (fd >= 0 ) {
303 FLITE_IN bl; 303 FLITE_IN bl;
304 bl.mode = 1; 304 bl.mode = 1;
305 bl.pwr = bright ? 1 : 0; 305 bl.pwr = bright ? 1 : 0;
306 bl.brightness = bright; 306 bl.brightness = bright;
307 ioctl(fd, FLITE_ON, &bl); 307 ioctl(fd, FLITE_ON, &bl);
308 close(fd); 308 close(fd);
309 } 309 }
310 } 310 }
311#endif 311#endif
312#endif 312#endif
313 curbl = bright; 313 curbl = bright;
314} 314}
315 315
316void qpe_setBacklight(int bright) { setBacklight(bright); } 316void qpe_setBacklight(int bright) { setBacklight(bright); }
317 317
318static bool dim_on = FALSE; 318static bool dim_on = FALSE;
319static bool lightoff_on = FALSE; 319static bool lightoff_on = FALSE;
320static int disable_suspend = 100; 320static int disable_suspend = 100;
321 321
322static bool powerOnline() 322static bool powerOnline()
323{ 323{
324 return PowerStatusManager::readStatus().acStatus() == PowerStatus::Online; 324 return PowerStatusManager::readStatus().acStatus() == PowerStatus::Online;
325} 325}
326 326
327static bool networkOnline() 327static bool networkOnline()
328{ 328{
329 return Network::networkOnline(); 329 return Network::networkOnline();
330} 330}
331 331
332class QPEScreenSaver : public QWSScreenSaver 332class QPEScreenSaver : public QWSScreenSaver
333{ 333{
334private: 334private:
335 int LcdOn; 335 int LcdOn;
336 336
337public: 337public:
338 QPEScreenSaver() 338 QPEScreenSaver()
339 { 339 {
340 int fd; 340 int fd;
341 341
342 LcdOn = TRUE; 342 LcdOn = TRUE;
343 // Make sure the LCD is in fact on, (if opie was killed while the LCD is off it would still be off) 343 // Make sure the LCD is in fact on, (if opie was killed while the LCD is off it would still be off)
344 fd=open("/dev/fb0",O_RDWR); 344 fd=open("/dev/fb0",O_RDWR);
345 if (fd != -1) { ioctl(fd,FBIOBLANK,VESA_NO_BLANKING); close(fd); } 345 if (fd != -1) { ioctl(fd,FBIOBLANK,VESA_NO_BLANKING); close(fd); }
346 } 346 }
347 void restore() 347 void restore()
348 { 348 {
349 if (!LcdOn) // We must have turned it off 349 if (!LcdOn) // We must have turned it off
350 { 350 {
351 int fd; 351 int fd;
352 fd=open("/dev/fb0",O_RDWR); 352 fd=open("/dev/fb0",O_RDWR);
353 if (fd != -1) { ioctl(fd,FBIOBLANK,VESA_NO_BLANKING); close(fd); } 353 if (fd != -1) { ioctl(fd,FBIOBLANK,VESA_NO_BLANKING); close(fd); }
354 } 354 }
355 setBacklight(-1); 355 setBacklight(-1);
356 } 356 }
357 bool save(int level) 357 bool save(int level)
358 { 358 {
359 int fd; 359 int fd;
360 360
361 switch ( level ) { 361 switch ( level ) {
362 case 0: 362 case 0:
363 if ( disable_suspend > 0 && dim_on ) { 363 if ( disable_suspend > 0 && dim_on ) {
364 if (backlight() > 1) 364 if (backlight() > 1)
365 setBacklight(1); // lowest non-off 365 setBacklight(1); // lowest non-off
366 } 366 }
367 return TRUE; 367 return TRUE;
368 break; 368 break;
369 case 1: 369 case 1:
370 if ( disable_suspend > 1 && lightoff_on ) { 370 if ( disable_suspend > 1 && lightoff_on ) {
371 setBacklight(0); // off 371 setBacklight(0); // off
372 } 372 }
373 return TRUE; 373 return TRUE;
374 break; 374 break;
375 case 2: 375 case 2:
376 Config config( "qpe" ); 376 Config config( "qpe" );
377 config.setGroup( "Screensaver" ); 377 config.setGroup( "Screensaver" );
378 if (config.readNumEntry("LcdOffOnly",0) != 0) // We're only turning off the LCD 378 if (config.readNumEntry("LcdOffOnly",0) != 0) // We're only turning off the LCD
379 { 379 {
380 fd=open("/dev/fb0",O_RDWR); 380 fd=open("/dev/fb0",O_RDWR);
381 if (fd != -1) { ioctl(fd,FBIOBLANK,VESA_POWERDOWN); close(fd); } 381 if (fd != -1) { ioctl(fd,FBIOBLANK,VESA_POWERDOWN); close(fd); }
382 LcdOn = FALSE; 382 LcdOn = FALSE;
383 } 383 }
384 else // We're going to suspend the whole machine 384 else // We're going to suspend the whole machine
385 { 385 {
386 if ( disable_suspend > 2 && !powerOnline() && !networkOnline() ) { 386 if ( disable_suspend > 2 && !powerOnline() && !networkOnline() ) {
387 QWSServer::sendKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE ); 387 QWSServer::sendKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE );
388 return TRUE; 388 return TRUE;
389 } 389 }
390 } 390 }
391 break; 391 break;
392 } 392 }
393 return FALSE; 393 return FALSE;
394 } 394 }
395}; 395};
396 396
397static int ssi(int interval, Config &config, const QString &enable, const QString& value, int def) 397static int ssi(int interval, Config &config, const QString &enable, const QString& value, int def)
398{ 398{
399 if ( !enable.isEmpty() && config.readNumEntry(enable,0) == 0 ) 399 if ( !enable.isEmpty() && config.readNumEntry(enable,0) == 0 )
400 return 0; 400 return 0;
401 401
402 if ( interval < 0 ) { 402 if ( interval < 0 ) {
403 // Restore screen blanking and power saving state 403 // Restore screen blanking and power saving state
404 interval = config.readNumEntry( value, def ); 404 interval = config.readNumEntry( value, def );
405 } 405 }
406 return interval; 406 return interval;
407} 407}
408 408
409static void setScreenSaverIntervals(int i1, int i2, int i3) 409static void setScreenSaverIntervals(int i1, int i2, int i3)
410{ 410{
411 Config config( "qpe" ); 411 Config config( "qpe" );
412 config.setGroup( "Screensaver" ); 412 config.setGroup( "Screensaver" );
413 413
414 int v[4]; 414 int v[4];
415 i1 = ssi(i1, config, "Dim","Interval_Dim", 30); 415 i1 = ssi(i1, config, "Dim","Interval_Dim", 30);
416 i2 = ssi(i2, config, "LightOff","Interval_LightOff", 20); 416 i2 = ssi(i2, config, "LightOff","Interval_LightOff", 20);
417 i3 = ssi(i3, config, "","Interval", 60); 417 i3 = ssi(i3, config, "","Interval", 60);
418 418
419 //qDebug("screen saver intervals: %d %d %d", i1, i2, i3); 419 //qDebug("screen saver intervals: %d %d %d", i1, i2, i3);
420 420
421 v[0] = QMAX( 1000*i1, 100); 421 v[0] = QMAX( 1000*i1, 100);
422 v[1] = QMAX( 1000*i2, 100); 422 v[1] = QMAX( 1000*i2, 100);
423 v[2] = QMAX( 1000*i3, 100); 423 v[2] = QMAX( 1000*i3, 100);
424 v[3] = 0; 424 v[3] = 0;
425 dim_on = ( (i1 != 0) ? config.readNumEntry("Dim",1) : FALSE ); 425 dim_on = ( (i1 != 0) ? config.readNumEntry("Dim",1) : FALSE );
426 lightoff_on = ( (i2 != 0 ) ? config.readNumEntry("LightOff",1) : FALSE ); 426 lightoff_on = ( (i2 != 0 ) ? config.readNumEntry("LightOff",1) : FALSE );
427 if ( !i1 && !i2 && !i3 ) 427 if ( !i1 && !i2 && !i3 )
428 QWSServer::setScreenSaverInterval(0); 428 QWSServer::setScreenSaverInterval(0);
429 else 429 else
430 QWSServer::setScreenSaverIntervals(v); 430 QWSServer::setScreenSaverIntervals(v);
431} 431}
432 432
433static void setScreenSaverInterval(int interval) 433static void setScreenSaverInterval(int interval)
434{ 434{
435 setScreenSaverIntervals(-1,-1,interval); 435 setScreenSaverIntervals(-1,-1,interval);
436} 436}
437 437
438 438
439/*! 439/*!
440 \class QPEApplication qpeapplication.h 440 \class QPEApplication qpeapplication.h
441 \brief The QPEApplication class implements various system services 441 \brief The QPEApplication class implements various system services
442 that are available to all Qtopia applications. 442 that are available to all Qtopia applications.
443 443
444 Simply by using QPEApplication instead of QApplication, a plain Qt 444 Simply by using QPEApplication instead of QApplication, a plain Qt
445 application becomes a Qtopia application. It automatically follows 445 application becomes a Qtopia application. It automatically follows
446 style changes, quits and raises, and in the 446 style changes, quits and raises, and in the
447 case of \link docwidget.html document-oriented\endlink applications, 447 case of \link docwidget.html document-oriented\endlink applications,
448 changes the current displayed document in response to the environment. 448 changes the current displayed document in response to the environment.
449*/ 449*/
450 450
451/*! 451/*!
452 \fn void QPEApplication::clientMoused() 452 \fn void QPEApplication::clientMoused()