summaryrefslogtreecommitdiff
authorharlekin <harlekin>2002-03-22 18:16:38 (UTC)
committer harlekin <harlekin>2002-03-22 18:16:38 (UTC)
commita6f3ce177ac43ec2cf91f96cfd11713126e29407 (patch) (unidiff)
tree023664192c19117e524892fea4ec98b49dc55826
parentda1430c6bd5fee39a19b294017848b95198217af (diff)
downloadopie-a6f3ce177ac43ec2cf91f96cfd11713126e29407.zip
opie-a6f3ce177ac43ec2cf91f96cfd11713126e29407.tar.gz
opie-a6f3ce177ac43ec2cf91f96cfd11713126e29407.tar.bz2
different splash
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--library/qpeapplication.cpp4
-rw-r--r--pics/launcher/new_wait.pngbin0 -> 1904 bytes
2 files changed, 2 insertions, 2 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp
index a55f5f9..c154689 100644
--- a/library/qpeapplication.cpp
+++ b/library/qpeapplication.cpp
@@ -1,1608 +1,1608 @@
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 "qpeapplication.h" 51#include "qpeapplication.h"
52#include "qpestyle.h" 52#include "qpestyle.h"
53#if QT_VERSION >= 300 53#if QT_VERSION >= 300
54#include <qstylefactory.h> 54#include <qstylefactory.h>
55#else 55#else
56#include <qplatinumstyle.h> 56#include <qplatinumstyle.h>
57#include <qwindowsstyle.h> 57#include <qwindowsstyle.h>
58#include <qmotifstyle.h> 58#include <qmotifstyle.h>
59#include <qmotifplusstyle.h> 59#include <qmotifplusstyle.h>
60#include "lightstyle.h" 60#include "lightstyle.h"
61#endif 61#endif
62#include "global.h" 62#include "global.h"
63#include "resource.h" 63#include "resource.h"
64#if QT_VERSION <= 230 && defined(QT_NO_CODECS) 64#if QT_VERSION <= 230 && defined(QT_NO_CODECS)
65#include "qutfcodec.h" 65#include "qutfcodec.h"
66#endif 66#endif
67#include "config.h" 67#include "config.h"
68#include "network.h" 68#include "network.h"
69#include "fontmanager.h" 69#include "fontmanager.h"
70#include "power.h" 70#include "power.h"
71#include "alarmserver.h" 71#include "alarmserver.h"
72#include "applnk.h" 72#include "applnk.h"
73#include "qpemenubar.h" 73#include "qpemenubar.h"
74 74
75#include <unistd.h> 75#include <unistd.h>
76#include <sys/file.h> 76#include <sys/file.h>
77#include <sys/ioctl.h> 77#include <sys/ioctl.h>
78#include <sys/soundcard.h> 78#include <sys/soundcard.h>
79 79
80// for setBacklight() 80// for setBacklight()
81#if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) 81#if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX)
82#include <linux/fb.h> 82#include <linux/fb.h>
83#include <sys/types.h> 83#include <sys/types.h>
84#include <sys/stat.h> 84#include <sys/stat.h>
85#endif 85#endif
86#include <stdlib.h> 86#include <stdlib.h>
87 87
88 88
89class QPEApplicationData { 89class QPEApplicationData {
90public: 90public:
91 QPEApplicationData() : presstimer(0), presswidget(0), rightpressed(FALSE), 91 QPEApplicationData() : presstimer(0), presswidget(0), rightpressed(FALSE),
92 kbgrabber(0), kbregrab(FALSE), notbusysent(FALSE), preloaded(FALSE), 92 kbgrabber(0), kbregrab(FALSE), notbusysent(FALSE), preloaded(FALSE),
93 forceshow(FALSE), nomaximize(FALSE), qpe_main_widget(0), 93 forceshow(FALSE), nomaximize(FALSE), qpe_main_widget(0),
94 keep_running(TRUE) 94 keep_running(TRUE)
95 { 95 {
96 qcopq.setAutoDelete(TRUE); 96 qcopq.setAutoDelete(TRUE);
97 } 97 }
98 98
99 int presstimer; 99 int presstimer;
100 QWidget* presswidget; 100 QWidget* presswidget;
101 QPoint presspos; 101 QPoint presspos;
102 bool rightpressed; 102 bool rightpressed;
103 int kbgrabber; 103 int kbgrabber;
104 bool kbregrab; 104 bool kbregrab;
105 bool notbusysent; 105 bool notbusysent;
106 QString appName; 106 QString appName;
107 struct QCopRec { 107 struct QCopRec {
108 QCopRec(const QCString &ch, const QCString &msg, 108 QCopRec(const QCString &ch, const QCString &msg,
109 const QByteArray &d) : 109 const QByteArray &d) :
110 channel(ch), message(msg), data(d) { } 110 channel(ch), message(msg), data(d) { }
111 111
112 QCString channel; 112 QCString channel;
113 QCString message; 113 QCString message;
114 QByteArray data; 114 QByteArray data;
115 }; 115 };
116 bool preloaded; 116 bool preloaded;
117 bool forceshow; 117 bool forceshow;
118 bool nomaximize; 118 bool nomaximize;
119 QWidget* qpe_main_widget; 119 QWidget* qpe_main_widget;
120 bool keep_running; 120 bool keep_running;
121 QList<QCopRec> qcopq; 121 QList<QCopRec> qcopq;
122 122
123 void enqueueQCop(const QCString &ch, const QCString &msg, 123 void enqueueQCop(const QCString &ch, const QCString &msg,
124 const QByteArray &data) 124 const QByteArray &data)
125 { 125 {
126 qcopq.append(new QCopRec(ch,msg,data)); 126 qcopq.append(new QCopRec(ch,msg,data));
127 } 127 }
128 void sendQCopQ() 128 void sendQCopQ()
129 { 129 {
130 QCopRec* r; 130 QCopRec* r;
131 for (QListIterator<QCopRec> it(qcopq); (r=it.current()); ++it) 131 for (QListIterator<QCopRec> it(qcopq); (r=it.current()); ++it)
132 QCopChannel::sendLocally(r->channel,r->message,r->data); 132 QCopChannel::sendLocally(r->channel,r->message,r->data);
133 qcopq.clear(); 133 qcopq.clear();
134 } 134 }
135}; 135};
136 136
137class ResourceMimeFactory : public QMimeSourceFactory { 137class ResourceMimeFactory : public QMimeSourceFactory {
138public: 138public:
139 ResourceMimeFactory() 139 ResourceMimeFactory()
140 { 140 {
141 setFilePath( Global::helpPath() ); 141 setFilePath( Global::helpPath() );
142 setExtensionType("html","text/html;charset=UTF-8"); 142 setExtensionType("html","text/html;charset=UTF-8");
143 } 143 }
144 144
145 const QMimeSource* data(const QString& abs_name) const 145 const QMimeSource* data(const QString& abs_name) const
146 { 146 {
147 const QMimeSource* r = QMimeSourceFactory::data(abs_name); 147 const QMimeSource* r = QMimeSourceFactory::data(abs_name);
148 if ( !r ) { 148 if ( !r ) {
149 int sl = abs_name.length(); 149 int sl = abs_name.length();
150 do { 150 do {
151 sl = abs_name.findRev('/',sl-1); 151 sl = abs_name.findRev('/',sl-1);
152 QString name = sl>=0 ? abs_name.mid(sl+1) : abs_name; 152 QString name = sl>=0 ? abs_name.mid(sl+1) : abs_name;
153 int dot = name.findRev('.'); 153 int dot = name.findRev('.');
154 if ( dot >= 0 ) 154 if ( dot >= 0 )
155 name = name.left(dot); 155 name = name.left(dot);
156 QImage img = Resource::loadImage(name); 156 QImage img = Resource::loadImage(name);
157 if ( !img.isNull() ) 157 if ( !img.isNull() )
158 r = new QImageDrag(img); 158 r = new QImageDrag(img);
159 } while (!r && sl>0); 159 } while (!r && sl>0);
160 } 160 }
161 return r; 161 return r;
162 } 162 }
163}; 163};
164 164
165static int muted=0; 165static int muted=0;
166static int micMuted=0; 166static int micMuted=0;
167 167
168static void setVolume(int t=0, int percent=-1) 168static void setVolume(int t=0, int percent=-1)
169{ 169{
170 switch (t) { 170 switch (t) {
171 case 0: { 171 case 0: {
172 Config cfg("Sound"); 172 Config cfg("Sound");
173 cfg.setGroup("System"); 173 cfg.setGroup("System");
174 if ( percent < 0 ) 174 if ( percent < 0 )
175 percent = cfg.readNumEntry("Volume",50); 175 percent = cfg.readNumEntry("Volume",50);
176 int fd = 0; 176 int fd = 0;
177 if ((fd = open("/dev/mixer", O_RDWR))>=0) { 177 if ((fd = open("/dev/mixer", O_RDWR))>=0) {
178 int vol = muted ? 0 : percent; 178 int vol = muted ? 0 : percent;
179 // set both channels to same volume 179 // set both channels to same volume
180 vol |= vol << 8; 180 vol |= vol << 8;
181 ioctl(fd, MIXER_WRITE(0), &vol); 181 ioctl(fd, MIXER_WRITE(0), &vol);
182 ::close(fd); 182 ::close(fd);
183 } 183 }
184 } break; 184 } break;
185 } 185 }
186} 186}
187 187
188static void setMic(int t=0, int percent=-1) 188static void setMic(int t=0, int percent=-1)
189{ 189{
190 switch (t) { 190 switch (t) {
191 case 0: { 191 case 0: {
192 Config cfg("Sound"); 192 Config cfg("Sound");
193 cfg.setGroup("System"); 193 cfg.setGroup("System");
194 if ( percent < 0 ) 194 if ( percent < 0 )
195 percent = cfg.readNumEntry("Mic",50); 195 percent = cfg.readNumEntry("Mic",50);
196 196
197 int fd = 0; 197 int fd = 0;
198 int mic = micMuted ? 0 : percent; 198 int mic = micMuted ? 0 : percent;
199 if ((fd = open("/dev/mixer", O_RDWR))>=0) { 199 if ((fd = open("/dev/mixer", O_RDWR))>=0) {
200 ioctl(fd, MIXER_WRITE(SOUND_MIXER_MIC), &mic); 200 ioctl(fd, MIXER_WRITE(SOUND_MIXER_MIC), &mic);
201 ::close(fd); 201 ::close(fd);
202 } 202 }
203 } break; 203 } break;
204 } 204 }
205} 205}
206 206
207int qpe_sysBrightnessSteps() 207int qpe_sysBrightnessSteps()
208{ 208{
209#if defined(QT_QWS_IPAQ) 209#if defined(QT_QWS_IPAQ)
210 return 255; 210 return 255;
211#elif defined(QT_QWS_EBX) 211#elif defined(QT_QWS_EBX)
212 return 4; 212 return 4;
213#else 213#else
214 return 255; // ? 214 return 255; // ?
215#endif 215#endif
216} 216}
217 217
218 218
219static int& hack(int& i) 219static int& hack(int& i)
220{ 220{
221#if QT_VERSION <= 230 && defined(QT_NO_CODECS) 221#if QT_VERSION <= 230 && defined(QT_NO_CODECS)
222 // These should be created, but aren't in Qt 2.3.0 222 // These should be created, but aren't in Qt 2.3.0
223 (void)new QUtf8Codec; 223 (void)new QUtf8Codec;
224 (void)new QUtf16Codec; 224 (void)new QUtf16Codec;
225#endif 225#endif
226 return i; 226 return i;
227} 227}
228 228
229static bool forced_off = FALSE; 229static bool forced_off = FALSE;
230static int curbl=-1; 230static int curbl=-1;
231 231
232static int backlight() 232static int backlight()
233{ 233{
234 if ( curbl == -1 ) { 234 if ( curbl == -1 ) {
235 // Read from config 235 // Read from config
236 Config config( "qpe" ); 236 Config config( "qpe" );
237 config.setGroup( "Screensaver" ); 237 config.setGroup( "Screensaver" );
238 curbl = config.readNumEntry("Brightness",255); 238 curbl = config.readNumEntry("Brightness",255);
239 } 239 }
240 return curbl; 240 return curbl;
241} 241}
242 242
243static void setBacklight(int bright) 243static void setBacklight(int bright)
244{ 244{
245 if ( bright == -3 ) { 245 if ( bright == -3 ) {
246 // Forced on 246 // Forced on
247 forced_off = FALSE; 247 forced_off = FALSE;
248 bright = -1; 248 bright = -1;
249 } 249 }
250 if ( forced_off && bright != -2 ) 250 if ( forced_off && bright != -2 )
251 return; 251 return;
252 if ( bright == -2 ) { 252 if ( bright == -2 ) {
253 // Toggle between off and on 253 // Toggle between off and on
254 bright = curbl ? 0 : -1; 254 bright = curbl ? 0 : -1;
255 forced_off = !bright; 255 forced_off = !bright;
256 } 256 }
257 if ( bright == -1 ) { 257 if ( bright == -1 ) {
258 // Read from config 258 // Read from config
259 Config config( "qpe" ); 259 Config config( "qpe" );
260 config.setGroup( "Screensaver" ); 260 config.setGroup( "Screensaver" );
261 bright = config.readNumEntry("Brightness",255); 261 bright = config.readNumEntry("Brightness",255);
262 } 262 }
263#if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) 263#if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX)
264 if ( QFile::exists("/usr/bin/bl") ) { 264 if ( QFile::exists("/usr/bin/bl") ) {
265 QString cmd = "/usr/bin/bl 1 "; 265 QString cmd = "/usr/bin/bl 1 ";
266 cmd += bright<=0 ? "0 " : "1 "; 266 cmd += bright<=0 ? "0 " : "1 ";
267 cmd += QString::number(bright); 267 cmd += QString::number(bright);
268 system(cmd.latin1()); 268 system(cmd.latin1());
269#if defined(QT_QWS_EBX) 269#if defined(QT_QWS_EBX)
270 } else if ( QFile::exists("/dev/fl") ) { 270 } else if ( QFile::exists("/dev/fl") ) {
271#define FL_IOCTL_STEP_CONTRAST 100 271#define FL_IOCTL_STEP_CONTRAST 100
272 int fd = open("/dev/fl", O_WRONLY); 272 int fd = open("/dev/fl", O_WRONLY);
273 if (fd >= 0 ) { 273 if (fd >= 0 ) {
274 int steps = qpe_sysBrightnessSteps(); 274 int steps = qpe_sysBrightnessSteps();
275 int bl = ( bright * steps + 127 ) / 255; 275 int bl = ( bright * steps + 127 ) / 255;
276 if ( bright && !bl ) bl = 1; 276 if ( bright && !bl ) bl = 1;
277 bl = ioctl(fd, FL_IOCTL_STEP_CONTRAST, bl); 277 bl = ioctl(fd, FL_IOCTL_STEP_CONTRAST, bl);
278 close(fd); 278 close(fd);
279 } 279 }
280 } 280 }
281#elif defined(QT_QWS_IPAQ) 281#elif defined(QT_QWS_IPAQ)
282 } else if ( QFile::exists("/dev/ts") || QFile::exists("/dev/h3600_ts") ) { 282 } else if ( QFile::exists("/dev/ts") || QFile::exists("/dev/h3600_ts") ) {
283 typedef struct { 283 typedef struct {
284 unsigned char mode; 284 unsigned char mode;
285 unsigned char pwr; 285 unsigned char pwr;
286 unsigned char brightness; 286 unsigned char brightness;
287 } FLITE_IN; 287 } FLITE_IN;
288# ifndef FLITE_ON 288# ifndef FLITE_ON
289# ifndef _LINUX_IOCTL_H 289# ifndef _LINUX_IOCTL_H
290# include <linux/ioctl.h> 290# include <linux/ioctl.h>
291# endif 291# endif
292# define FLITE_ON _IOW('f', 7, FLITE_IN) 292# define FLITE_ON _IOW('f', 7, FLITE_IN)
293# endif 293# endif
294 int fd; 294 int fd;
295 if ( QFile::exists("/dev/ts") ) 295 if ( QFile::exists("/dev/ts") )
296 fd = open("/dev/ts", O_WRONLY); 296 fd = open("/dev/ts", O_WRONLY);
297 else 297 else
298 fd = open("/dev/h3600_ts", O_WRONLY); 298 fd = open("/dev/h3600_ts", O_WRONLY);
299 if (fd >= 0 ) { 299 if (fd >= 0 ) {
300 FLITE_IN bl; 300 FLITE_IN bl;
301 bl.mode = 1; 301 bl.mode = 1;
302 bl.pwr = bright ? 1 : 0; 302 bl.pwr = bright ? 1 : 0;
303 bl.brightness = bright; 303 bl.brightness = bright;
304 ioctl(fd, FLITE_ON, &bl); 304 ioctl(fd, FLITE_ON, &bl);
305 close(fd); 305 close(fd);
306 } 306 }
307 } 307 }
308#endif 308#endif
309#endif 309#endif
310 curbl = bright; 310 curbl = bright;
311} 311}
312 312
313void qpe_setBacklight(int bright) { setBacklight(bright); } 313void qpe_setBacklight(int bright) { setBacklight(bright); }
314 314
315static bool dim_on = FALSE; 315static bool dim_on = FALSE;
316static bool lightoff_on = FALSE; 316static bool lightoff_on = FALSE;
317static int disable_suspend = 100; 317static int disable_suspend = 100;
318 318
319static bool powerOnline() 319static bool powerOnline()
320{ 320{
321 return PowerStatusManager::readStatus().acStatus() == PowerStatus::Online; 321 return PowerStatusManager::readStatus().acStatus() == PowerStatus::Online;
322} 322}
323 323
324static bool networkOnline() 324static bool networkOnline()
325{ 325{
326 return Network::networkOnline(); 326 return Network::networkOnline();
327} 327}
328 328
329class QPEScreenSaver : public QWSScreenSaver 329class QPEScreenSaver : public QWSScreenSaver
330{ 330{
331 331
332public: 332public:
333 QPEScreenSaver() 333 QPEScreenSaver()
334 { 334 {
335 } 335 }
336 void restore() 336 void restore()
337 { 337 {
338 setBacklight(-1); 338 setBacklight(-1);
339 } 339 }
340 bool save(int level) 340 bool save(int level)
341 { 341 {
342 switch ( level ) { 342 switch ( level ) {
343 case 0: 343 case 0:
344 if ( disable_suspend > 0 && dim_on ) { 344 if ( disable_suspend > 0 && dim_on ) {
345 if (backlight() > 1) 345 if (backlight() > 1)
346 setBacklight(1); // lowest non-off 346 setBacklight(1); // lowest non-off
347 } 347 }
348 return TRUE; 348 return TRUE;
349 break; 349 break;
350 case 1: 350 case 1:
351 if ( disable_suspend > 1 && lightoff_on ) { 351 if ( disable_suspend > 1 && lightoff_on ) {
352 setBacklight(0); // off 352 setBacklight(0); // off
353 } 353 }
354 return TRUE; 354 return TRUE;
355 break; 355 break;
356 case 2: 356 case 2:
357 if ( disable_suspend > 2 && !powerOnline() && !networkOnline() ) { 357 if ( disable_suspend > 2 && !powerOnline() && !networkOnline() ) {
358 QWSServer::sendKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE ); 358 QWSServer::sendKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE );
359 return TRUE; 359 return TRUE;
360 } 360 }
361 break; 361 break;
362 } 362 }
363 return FALSE; 363 return FALSE;
364 } 364 }
365}; 365};
366 366
367static int ssi(int interval, Config &config, const QString &enable, const QString& value, int def) 367static int ssi(int interval, Config &config, const QString &enable, const QString& value, int def)
368{ 368{
369 if ( !enable.isEmpty() && config.readNumEntry(enable,0) == 0 ) 369 if ( !enable.isEmpty() && config.readNumEntry(enable,0) == 0 )
370 return 0; 370 return 0;
371 371
372 if ( interval < 0 ) { 372 if ( interval < 0 ) {
373 // Restore screen blanking and power saving state 373 // Restore screen blanking and power saving state
374 interval = config.readNumEntry( value, def ); 374 interval = config.readNumEntry( value, def );
375 } 375 }
376 return interval; 376 return interval;
377} 377}
378 378
379static void setScreenSaverIntervals(int i1, int i2, int i3) 379static void setScreenSaverIntervals(int i1, int i2, int i3)
380{ 380{
381 Config config( "qpe" ); 381 Config config( "qpe" );
382 config.setGroup( "Screensaver" ); 382 config.setGroup( "Screensaver" );
383 383
384 int v[4]; 384 int v[4];
385 i1 = ssi(i1, config, "Dim","Interval_Dim", 30); 385 i1 = ssi(i1, config, "Dim","Interval_Dim", 30);
386 i2 = ssi(i2, config, "LightOff","Interval_LightOff", 20); 386 i2 = ssi(i2, config, "LightOff","Interval_LightOff", 20);
387 i3 = ssi(i3, config, "","Interval", 60); 387 i3 = ssi(i3, config, "","Interval", 60);
388 388
389 //qDebug("screen saver intervals: %d %d %d", i1, i2, i3); 389 //qDebug("screen saver intervals: %d %d %d", i1, i2, i3);
390 390
391 v[0] = QMAX( 1000*i1, 100); 391 v[0] = QMAX( 1000*i1, 100);
392 v[1] = QMAX( 1000*i2, 100); 392 v[1] = QMAX( 1000*i2, 100);
393 v[2] = QMAX( 1000*i3, 100); 393 v[2] = QMAX( 1000*i3, 100);
394 v[3] = 0; 394 v[3] = 0;
395 dim_on = ( (i1 != 0) ? config.readNumEntry("Dim",1) : FALSE ); 395 dim_on = ( (i1 != 0) ? config.readNumEntry("Dim",1) : FALSE );
396 lightoff_on = ( (i2 != 0 ) ? config.readNumEntry("LightOff",1) : FALSE ); 396 lightoff_on = ( (i2 != 0 ) ? config.readNumEntry("LightOff",1) : FALSE );
397 if ( !i1 && !i2 && !i3 ) 397 if ( !i1 && !i2 && !i3 )
398 QWSServer::setScreenSaverInterval(0); 398 QWSServer::setScreenSaverInterval(0);
399 else 399 else
400 QWSServer::setScreenSaverIntervals(v); 400 QWSServer::setScreenSaverIntervals(v);
401} 401}
402 402
403static void setScreenSaverInterval(int interval) 403static void setScreenSaverInterval(int interval)
404{ 404{
405 setScreenSaverIntervals(-1,-1,interval); 405 setScreenSaverIntervals(-1,-1,interval);
406} 406}
407 407
408 408
409/*! 409/*!
410 \class QPEApplication qpeapplication.h 410 \class QPEApplication qpeapplication.h
411 \brief The QPEApplication class implements various system services 411 \brief The QPEApplication class implements various system services
412 that are available to all Qtopia applications. 412 that are available to all Qtopia applications.
413 413
414 Simply by using QPEApplication instead of QApplication, a plain Qt 414 Simply by using QPEApplication instead of QApplication, a plain Qt
415 application becomes a Qtopia application. It automatically follows 415 application becomes a Qtopia application. It automatically follows
416 style changes, quits and raises, and in the 416 style changes, quits and raises, and in the
417 case of \link docwidget.html document-oriented\endlink applications, 417 case of \link docwidget.html document-oriented\endlink applications,
418 changes the current displayed document in response to the environment. 418 changes the current displayed document in response to the environment.
419*/ 419*/
420 420
421/*! 421/*!
422 \fn void QPEApplication::clientMoused() 422 \fn void QPEApplication::clientMoused()
423 423
424 \internal 424 \internal
425*/ 425*/
426 426
427/*! 427/*!
428 \fn void QPEApplication::timeChanged(); 428 \fn void QPEApplication::timeChanged();
429 429
430 This signal is emitted when the time jumps forward or backwards 430 This signal is emitted when the time jumps forward or backwards
431 by more than the normal passage of time. 431 by more than the normal passage of time.
432*/ 432*/
433 433
434/*! 434/*!
435 \fn void QPEApplication::clockChanged( bool ampm ); 435 \fn void QPEApplication::clockChanged( bool ampm );
436 436
437 This signal is emitted when the user changes the style 437 This signal is emitted when the user changes the style
438 of clock. If \a ampm is TRUE, the user wants a 12-hour 438 of clock. If \a ampm is TRUE, the user wants a 12-hour
439 AM/PM close, otherwise, they want a 24-hour clock. 439 AM/PM close, otherwise, they want a 24-hour clock.
440*/ 440*/
441 441
442/*! 442/*!
443 \fn void QPEApplication::appMessage( const QCString& msg, const QByteArray& data ) 443 \fn void QPEApplication::appMessage( const QCString& msg, const QByteArray& data )
444 444
445 This signal is emitted when a message is received on the 445 This signal is emitted when a message is received on the
446 QPE/Application/<i>appname</i> QCop channel for this application. 446 QPE/Application/<i>appname</i> QCop channel for this application.
447 447
448 The slot to which you connect this signal uses \a msg and \a data 448 The slot to which you connect this signal uses \a msg and \a data
449 in the following way: 449 in the following way:
450 450
451\code 451\code
452 void MyWidget::receive( const QCString& msg, const QByteArray& data ) 452 void MyWidget::receive( const QCString& msg, const QByteArray& data )
453 { 453 {
454 QDataStream stream( data, IO_ReadOnly ); 454 QDataStream stream( data, IO_ReadOnly );
455 if ( msg == "someMessage(int,int,int)" ) { 455 if ( msg == "someMessage(int,int,int)" ) {
456 int a,b,c; 456 int a,b,c;
457 stream >> a >> b >> c; 457 stream >> a >> b >> c;
458 ... 458 ...
459 } else if ( msg == "otherMessage(QString)" ) { 459 } else if ( msg == "otherMessage(QString)" ) {
460 ... 460 ...
461 } 461 }
462 } 462 }
463\endcode 463\endcode
464 464
465 \sa qcop.html 465 \sa qcop.html
466*/ 466*/
467 467
468/*! 468/*!
469 Constructs a QPEApplication just as you would construct 469 Constructs a QPEApplication just as you would construct
470 a QApplication, passing \a argc, \a argv, and \a t. 470 a QApplication, passing \a argc, \a argv, and \a t.
471*/ 471*/
472QPEApplication::QPEApplication( int& argc, char **argv, Type t ) 472QPEApplication::QPEApplication( int& argc, char **argv, Type t )
473 : QApplication( hack(argc), argv, t ) 473 : QApplication( hack(argc), argv, t )
474{ 474{
475 int dw = desktop()->width(); 475 int dw = desktop()->width();
476 if ( dw < 200 ) { 476 if ( dw < 200 ) {
477 setFont( QFont( "helvetica", 8 ) ); 477 setFont( QFont( "helvetica", 8 ) );
478 AppLnk::setSmallIconSize(10); 478 AppLnk::setSmallIconSize(10);
479 AppLnk::setBigIconSize(28); 479 AppLnk::setBigIconSize(28);
480 } 480 }
481 481
482 d = new QPEApplicationData; 482 d = new QPEApplicationData;
483 QMimeSourceFactory::setDefaultFactory(new ResourceMimeFactory); 483 QMimeSourceFactory::setDefaultFactory(new ResourceMimeFactory);
484 484
485 connect(this, SIGNAL(lastWindowClosed()), this, SLOT(hideOrQuit())); 485 connect(this, SIGNAL(lastWindowClosed()), this, SLOT(hideOrQuit()));
486#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 486#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
487 487
488 QString qcopfn("/tmp/qcop-msg-"); 488 QString qcopfn("/tmp/qcop-msg-");
489 qcopfn += QString(argv[0]); // append command name 489 qcopfn += QString(argv[0]); // append command name
490 490
491 QFile f(qcopfn); 491 QFile f(qcopfn);
492 if ( f.open(IO_ReadOnly) ) { 492 if ( f.open(IO_ReadOnly) ) {
493 flock(f.handle(), LOCK_EX); 493 flock(f.handle(), LOCK_EX);
494 } 494 }
495 495
496 sysChannel = new QCopChannel( "QPE/System", this ); 496 sysChannel = new QCopChannel( "QPE/System", this );
497 connect( sysChannel, SIGNAL(received(const QCString &, const QByteArray &)), 497 connect( sysChannel, SIGNAL(received(const QCString &, const QByteArray &)),
498 this, SLOT(systemMessage( const QCString &, const QByteArray &)) ); 498 this, SLOT(systemMessage( const QCString &, const QByteArray &)) );
499 499
500 QCString channel = QCString(argv[0]); 500 QCString channel = QCString(argv[0]);
501 channel.replace(QRegExp(".*/"),""); 501 channel.replace(QRegExp(".*/"),"");
502 d->appName = channel; 502 d->appName = channel;
503 channel = "QPE/Application/" + channel; 503 channel = "QPE/Application/" + channel;
504 pidChannel = new QCopChannel( channel, this); 504 pidChannel = new QCopChannel( channel, this);
505 connect( pidChannel, SIGNAL(received(const QCString &, const QByteArray &)), 505 connect( pidChannel, SIGNAL(received(const QCString &, const QByteArray &)),
506 this, SLOT(pidMessage(const QCString &, const QByteArray &))); 506 this, SLOT(pidMessage(const QCString &, const QByteArray &)));
507 507
508 if ( f.isOpen() ) { 508 if ( f.isOpen() ) {
509 d->keep_running = FALSE; 509 d->keep_running = FALSE;
510 QDataStream ds(&f); 510 QDataStream ds(&f);
511 QCString channel, message; 511 QCString channel, message;
512 QByteArray data; 512 QByteArray data;
513 while(!ds.atEnd()) { 513 while(!ds.atEnd()) {
514 ds >> channel >> message >> data; 514 ds >> channel >> message >> data;
515 d->enqueueQCop(channel,message,data); 515 d->enqueueQCop(channel,message,data);
516 } 516 }
517 517
518 flock(f.handle(), LOCK_UN); 518 flock(f.handle(), LOCK_UN);
519 f.close(); 519 f.close();
520 f.remove(); 520 f.remove();
521 } 521 }
522 522
523 for (int a=0; a<argc; a++) { 523 for (int a=0; a<argc; a++) {
524 if ( qstrcmp(argv[a],"-preload")==0 ) { 524 if ( qstrcmp(argv[a],"-preload")==0 ) {
525 argv[a] = argv[a+1]; 525 argv[a] = argv[a+1];
526 a++; 526 a++;
527 d->preloaded = TRUE; 527 d->preloaded = TRUE;
528 argc-=1; 528 argc-=1;
529 } else if ( qstrcmp(argv[a],"-preload-show")==0 ) { 529 } else if ( qstrcmp(argv[a],"-preload-show")==0 ) {
530 argv[a] = argv[a+1]; 530 argv[a] = argv[a+1];
531 a++; 531 a++;
532 d->preloaded = TRUE; 532 d->preloaded = TRUE;
533 d->forceshow = TRUE; 533 d->forceshow = TRUE;
534 argc-=1; 534 argc-=1;
535 } 535 }
536 } 536 }
537 537
538 /* overide stored arguments */ 538 /* overide stored arguments */
539 setArgs(argc, argv); 539 setArgs(argc, argv);
540 540
541#endif 541#endif
542 542
543 qwsSetDecoration( new QPEDecoration() ); 543 qwsSetDecoration( new QPEDecoration() );
544 544
545#ifndef QT_NO_TRANSLATION 545#ifndef QT_NO_TRANSLATION
546 QStringList langs = Global::languageList(); 546 QStringList langs = Global::languageList();
547 for (QStringList::ConstIterator it = langs.begin(); it!=langs.end(); ++it) { 547 for (QStringList::ConstIterator it = langs.begin(); it!=langs.end(); ++it) {
548 QString lang = *it; 548 QString lang = *it;
549 549
550 QTranslator * trans; 550 QTranslator * trans;
551 QString tfn; 551 QString tfn;
552 552
553 trans = new QTranslator(this); 553 trans = new QTranslator(this);
554 tfn = qpeDir()+"/i18n/"+lang+"/libqpe.qm"; 554 tfn = qpeDir()+"/i18n/"+lang+"/libqpe.qm";
555 if ( trans->load( tfn )) 555 if ( trans->load( tfn ))
556 installTranslator( trans ); 556 installTranslator( trans );
557 else 557 else
558 delete trans; 558 delete trans;
559 559
560 trans = new QTranslator(this); 560 trans = new QTranslator(this);
561 tfn = qpeDir()+"/i18n/"+lang+"/"+d->appName+".qm"; 561 tfn = qpeDir()+"/i18n/"+lang+"/"+d->appName+".qm";
562 if ( trans->load( tfn )) 562 if ( trans->load( tfn ))
563 installTranslator( trans ); 563 installTranslator( trans );
564 else 564 else
565 delete trans; 565 delete trans;
566 566
567 //###language/font hack; should look it up somewhere 567 //###language/font hack; should look it up somewhere
568 if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) { 568 if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) {
569 QFont fn = FontManager::unicodeFont( FontManager::Proportional ); 569 QFont fn = FontManager::unicodeFont( FontManager::Proportional );
570 setFont( fn ); 570 setFont( fn );
571 } 571 }
572 } 572 }
573#endif 573#endif
574 574
575 applyStyle(); 575 applyStyle();
576 576
577 if ( type() == GuiServer ) { 577 if ( type() == GuiServer ) {
578 setScreenSaverInterval(-1); 578 setScreenSaverInterval(-1);
579 setVolume(); 579 setVolume();
580 QWSServer::setScreenSaver(new QPEScreenSaver); 580 QWSServer::setScreenSaver(new QPEScreenSaver);
581 } 581 }
582 582
583 installEventFilter( this ); 583 installEventFilter( this );
584 584
585 QPEMenuToolFocusManager::initialize(); 585 QPEMenuToolFocusManager::initialize();
586 586
587#ifdef QT_NO_QWS_CURSOR 587#ifdef QT_NO_QWS_CURSOR
588 // if we have no cursor, probably don't want tooltips 588 // if we have no cursor, probably don't want tooltips
589 QToolTip::setEnabled( FALSE ); 589 QToolTip::setEnabled( FALSE );
590#endif 590#endif
591} 591}
592 592
593static QPtrDict<void>* inputMethodDict=0; 593static QPtrDict<void>* inputMethodDict=0;
594static void createInputMethodDict() 594static void createInputMethodDict()
595{ 595{
596 if ( !inputMethodDict ) 596 if ( !inputMethodDict )
597 inputMethodDict = new QPtrDict<void>; 597 inputMethodDict = new QPtrDict<void>;
598} 598}
599 599
600/*! 600/*!
601 Returns the currently set hint to the system as to whether 601 Returns the currently set hint to the system as to whether
602 \a w has any use for text input methods. 602 \a w has any use for text input methods.
603 603
604 \sa setInputMethodHint() 604 \sa setInputMethodHint()
605*/ 605*/
606QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget* w ) 606QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget* w )
607{ 607{
608 if ( inputMethodDict && w ) 608 if ( inputMethodDict && w )
609 return (InputMethodHint)(int)inputMethodDict->find(w); 609 return (InputMethodHint)(int)inputMethodDict->find(w);
610 return Normal; 610 return Normal;
611} 611}
612 612
613/*! 613/*!
614 \enum QPEApplication::InputMethodHint 614 \enum QPEApplication::InputMethodHint
615 615
616 \value Normal the application sometimes needs text input (the default). 616 \value Normal the application sometimes needs text input (the default).
617 \value AlwaysOff the application never needs text input. 617 \value AlwaysOff the application never needs text input.
618 \value AlwaysOn the application always needs text input. 618 \value AlwaysOn the application always needs text input.
619*/ 619*/
620 620
621/*! 621/*!
622 Hints to the system that \a w has use for text input methods 622 Hints to the system that \a w has use for text input methods
623 as specified by \a mode. 623 as specified by \a mode.
624 624
625 \sa inputMethodHint() 625 \sa inputMethodHint()
626*/ 626*/
627void QPEApplication::setInputMethodHint( QWidget* w, InputMethodHint mode ) 627void QPEApplication::setInputMethodHint( QWidget* w, InputMethodHint mode )
628{ 628{
629 createInputMethodDict(); 629 createInputMethodDict();
630 if ( mode == Normal ) { 630 if ( mode == Normal ) {
631 inputMethodDict->remove(w); 631 inputMethodDict->remove(w);
632 } else { 632 } else {
633 inputMethodDict->insert(w,(void*)mode); 633 inputMethodDict->insert(w,(void*)mode);
634 } 634 }
635} 635}
636 636
637class HackDialog : public QDialog 637class HackDialog : public QDialog
638{ 638{
639public: 639public:
640 void acceptIt() { accept(); } 640 void acceptIt() { accept(); }
641 void rejectIt() { reject(); } 641 void rejectIt() { reject(); }
642}; 642};
643 643
644 644
645void QPEApplication::mapToDefaultAction( QWSKeyEvent *ke, int key ) 645void QPEApplication::mapToDefaultAction( QWSKeyEvent *ke, int key )
646{ 646{
647 // specialised actions for certain widgets. May want to 647 // specialised actions for certain widgets. May want to
648 // add more stuff here. 648 // add more stuff here.
649 if ( activePopupWidget() && activePopupWidget()->inherits( "QListBox" ) 649 if ( activePopupWidget() && activePopupWidget()->inherits( "QListBox" )
650 && activePopupWidget()->parentWidget() 650 && activePopupWidget()->parentWidget()
651 && activePopupWidget()->parentWidget()->inherits( "QComboBox" ) ) 651 && activePopupWidget()->parentWidget()->inherits( "QComboBox" ) )
652 key = Qt::Key_Return; 652 key = Qt::Key_Return;
653 653
654 if ( activePopupWidget() && activePopupWidget()->inherits( "QPopupMenu" ) ) 654 if ( activePopupWidget() && activePopupWidget()->inherits( "QPopupMenu" ) )
655 key = Qt::Key_Return; 655 key = Qt::Key_Return;
656 656
657 ke->simpleData.keycode = key; 657 ke->simpleData.keycode = key;
658} 658}
659 659
660class HackWidget : public QWidget 660class HackWidget : public QWidget
661{ 661{
662public: 662public:
663 bool needsOk() 663 bool needsOk()
664 { return (getWState() & WState_Reserved1 ); } 664 { return (getWState() & WState_Reserved1 ); }
665}; 665};
666 666
667/*! 667/*!
668 \internal 668 \internal
669*/ 669*/
670bool QPEApplication::qwsEventFilter( QWSEvent *e ) 670bool QPEApplication::qwsEventFilter( QWSEvent *e )
671{ 671{
672 if ( !d->notbusysent && e->type == QWSEvent::Focus ) { 672 if ( !d->notbusysent && e->type == QWSEvent::Focus ) {
673 if ( qApp->type() != QApplication::GuiServer ) { 673 if ( qApp->type() != QApplication::GuiServer ) {
674 QCopEnvelope e("QPE/System", "notBusy(QString)" ); 674 QCopEnvelope e("QPE/System", "notBusy(QString)" );
675 e << d->appName; 675 e << d->appName;
676 } 676 }
677 d->notbusysent=TRUE; 677 d->notbusysent=TRUE;
678 } 678 }
679 if ( type() == GuiServer ) { 679 if ( type() == GuiServer ) {
680 switch ( e->type ) { 680 switch ( e->type ) {
681 case QWSEvent::Mouse: 681 case QWSEvent::Mouse:
682 if ( e->asMouse()->simpleData.state && !QWidget::find(e->window()) ) 682 if ( e->asMouse()->simpleData.state && !QWidget::find(e->window()) )
683 emit clientMoused(); 683 emit clientMoused();
684 } 684 }
685 } 685 }
686 if ( e->type == QWSEvent::Key ) { 686 if ( e->type == QWSEvent::Key ) {
687 if ( d->kbgrabber == 1 ) 687 if ( d->kbgrabber == 1 )
688 return TRUE; 688 return TRUE;
689 QWSKeyEvent *ke = (QWSKeyEvent *)e; 689 QWSKeyEvent *ke = (QWSKeyEvent *)e;
690 if ( ke->simpleData.keycode == Qt::Key_F33 ) { 690 if ( ke->simpleData.keycode == Qt::Key_F33 ) {
691 // Use special "OK" key to press "OK" on top level widgets 691 // Use special "OK" key to press "OK" on top level widgets
692 QWidget *active = activeWindow(); 692 QWidget *active = activeWindow();
693 QWidget *popup = 0; 693 QWidget *popup = 0;
694 if ( active && active->isPopup() ) { 694 if ( active && active->isPopup() ) {
695 popup = active; 695 popup = active;
696 active = active->parentWidget(); 696 active = active->parentWidget();
697 } 697 }
698 if ( active && (int)active->winId() == ke->simpleData.window && 698 if ( active && (int)active->winId() == ke->simpleData.window &&
699 !active->testWFlags( WStyle_Customize|WType_Popup|WType_Desktop )) { 699 !active->testWFlags( WStyle_Customize|WType_Popup|WType_Desktop )) {
700 if ( ke->simpleData.is_press ) { 700 if ( ke->simpleData.is_press ) {
701 if ( popup ) 701 if ( popup )
702 popup->close(); 702 popup->close();
703 if ( active->inherits( "QDialog" ) ) { 703 if ( active->inherits( "QDialog" ) ) {
704 HackDialog *d = (HackDialog *)active; 704 HackDialog *d = (HackDialog *)active;
705 d->acceptIt(); 705 d->acceptIt();
706 return TRUE; 706 return TRUE;
707 } else if ( ((HackWidget *)active)->needsOk() ) { 707 } else if ( ((HackWidget *)active)->needsOk() ) {
708 QSignal s; 708 QSignal s;
709 s.connect( active, SLOT( accept() ) ); 709 s.connect( active, SLOT( accept() ) );
710 s.activate(); 710 s.activate();
711 } else { 711 } else {
712 // do the same as with the select key: Map to the default action of the widget: 712 // do the same as with the select key: Map to the default action of the widget:
713 mapToDefaultAction( ke, Qt::Key_Return ); 713 mapToDefaultAction( ke, Qt::Key_Return );
714 } 714 }
715 } 715 }
716 } 716 }
717 } else if ( ke->simpleData.keycode == Qt::Key_F30 ) { 717 } else if ( ke->simpleData.keycode == Qt::Key_F30 ) {
718 // Use special "select" key to do whatever default action a widget has 718 // Use special "select" key to do whatever default action a widget has
719 mapToDefaultAction( ke, Qt::Key_Space ); 719 mapToDefaultAction( ke, Qt::Key_Space );
720 } else if ( ke->simpleData.keycode == Qt::Key_Escape && 720 } else if ( ke->simpleData.keycode == Qt::Key_Escape &&
721 ke->simpleData.is_press ) { 721 ke->simpleData.is_press ) {
722 // Escape key closes app if focus on toplevel 722 // Escape key closes app if focus on toplevel
723 QWidget *active = activeWindow(); 723 QWidget *active = activeWindow();
724 if ( active && active->testWFlags( WType_TopLevel ) && 724 if ( active && active->testWFlags( WType_TopLevel ) &&
725 (int)active->winId() == ke->simpleData.window && 725 (int)active->winId() == ke->simpleData.window &&
726 !active->testWFlags( WStyle_Dialog|WStyle_Customize|WType_Popup|WType_Desktop )) { 726 !active->testWFlags( WStyle_Dialog|WStyle_Customize|WType_Popup|WType_Desktop )) {
727 if ( active->inherits( "QDialog" ) ) { 727 if ( active->inherits( "QDialog" ) ) {
728 HackDialog *d = (HackDialog *)active; 728 HackDialog *d = (HackDialog *)active;
729 d->rejectIt(); 729 d->rejectIt();
730 return TRUE; 730 return TRUE;
731 } else if ( strcmp( argv()[0], "embeddedkonsole") != 0 ) { 731 } else if ( strcmp( argv()[0], "embeddedkonsole") != 0 ) {
732 active->close(); 732 active->close();
733 } 733 }
734 } 734 }
735 } 735 }
736 736
737#if QT_VERSION < 231 737#if QT_VERSION < 231
738 // Filter out the F4/Launcher key from apps 738 // Filter out the F4/Launcher key from apps
739 // ### The launcher key may not always be F4 on all devices 739 // ### The launcher key may not always be F4 on all devices
740 if ( ((QWSKeyEvent *)e)->simpleData.keycode == Qt::Key_F4 ) 740 if ( ((QWSKeyEvent *)e)->simpleData.keycode == Qt::Key_F4 )
741 return TRUE; 741 return TRUE;
742#endif 742#endif
743 } 743 }
744 if ( e->type == QWSEvent::Focus ) { 744 if ( e->type == QWSEvent::Focus ) {
745 QWSFocusEvent *fe = (QWSFocusEvent*)e; 745 QWSFocusEvent *fe = (QWSFocusEvent*)e;
746 QWidget* nfw = QWidget::find(e->window()); 746 QWidget* nfw = QWidget::find(e->window());
747 if ( !fe->simpleData.get_focus ) { 747 if ( !fe->simpleData.get_focus ) {
748 QWidget *active = activeWindow(); 748 QWidget *active = activeWindow();
749 while ( active && active->isPopup() ) { 749 while ( active && active->isPopup() ) {
750 active->close(); 750 active->close();
751 active = activeWindow(); 751 active = activeWindow();
752 } 752 }
753 if ( !nfw && d->kbgrabber == 2 ) { 753 if ( !nfw && d->kbgrabber == 2 ) {
754 ungrabKeyboard(); 754 ungrabKeyboard();
755 d->kbregrab = TRUE; // want kb back when we're active 755 d->kbregrab = TRUE; // want kb back when we're active
756 } 756 }
757 } else { 757 } else {
758 // make sure our modal widget is ALWAYS on top 758 // make sure our modal widget is ALWAYS on top
759 QWidget *topm = activeModalWidget(); 759 QWidget *topm = activeModalWidget();
760 if ( topm ) { 760 if ( topm ) {
761 topm->raise(); 761 topm->raise();
762 } 762 }
763 if ( d->kbregrab ) { 763 if ( d->kbregrab ) {
764 grabKeyboard(); 764 grabKeyboard();
765 d->kbregrab = FALSE; 765 d->kbregrab = FALSE;
766 } 766 }
767 } 767 }
768 if ( fe->simpleData.get_focus && inputMethodDict ) { 768 if ( fe->simpleData.get_focus && inputMethodDict ) {
769 InputMethodHint m = inputMethodHint( QWidget::find(e->window()) ); 769 InputMethodHint m = inputMethodHint( QWidget::find(e->window()) );
770 if ( m == AlwaysOff ) 770 if ( m == AlwaysOff )
771 Global::hideInputMethod(); 771 Global::hideInputMethod();
772 if ( m == AlwaysOn ) 772 if ( m == AlwaysOn )
773 Global::showInputMethod(); 773 Global::showInputMethod();
774 } 774 }
775 } 775 }
776 return QApplication::qwsEventFilter( e ); 776 return QApplication::qwsEventFilter( e );
777} 777}
778 778
779/*! 779/*!
780 Destroys the QPEApplication. 780 Destroys the QPEApplication.
781*/ 781*/
782QPEApplication::~QPEApplication() 782QPEApplication::~QPEApplication()
783{ 783{
784 ungrabKeyboard(); 784 ungrabKeyboard();
785#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 785#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
786 // Need to delete QCopChannels early, since the display will 786 // Need to delete QCopChannels early, since the display will
787 // be gone by the time we get to ~QObject(). 787 // be gone by the time we get to ~QObject().
788 delete sysChannel; 788 delete sysChannel;
789 delete pidChannel; 789 delete pidChannel;
790#endif 790#endif
791 delete d; 791 delete d;
792} 792}
793 793
794/*! 794/*!
795 Returns <tt>$OPIEDIR/</tt>. 795 Returns <tt>$OPIEDIR/</tt>.
796*/ 796*/
797QString QPEApplication::qpeDir() 797QString QPEApplication::qpeDir()
798{ 798{
799 const char *base = getenv( "OPIEDIR" ); 799 const char *base = getenv( "OPIEDIR" );
800 if ( base ) 800 if ( base )
801 return QString( base ) + "/"; 801 return QString( base ) + "/";
802 802
803 return QString( "../" ); 803 return QString( "../" );
804} 804}
805 805
806/*! 806/*!
807 Returns the user's current Document directory. There is a trailing "/". 807 Returns the user's current Document directory. There is a trailing "/".
808*/ 808*/
809QString QPEApplication::documentDir() 809QString QPEApplication::documentDir()
810{ 810{
811 const char *base = getenv( "HOME" ); 811 const char *base = getenv( "HOME" );
812 if ( base ) 812 if ( base )
813 return QString( base ) + "/Documents/"; 813 return QString( base ) + "/Documents/";
814 814
815 return QString( "../Documents/" ); 815 return QString( "../Documents/" );
816} 816}
817 817
818static int deforient=-1; 818static int deforient=-1;
819 819
820/*! 820/*!
821 \internal 821 \internal
822*/ 822*/
823int QPEApplication::defaultRotation() 823int QPEApplication::defaultRotation()
824{ 824{
825 if ( deforient < 0 ) { 825 if ( deforient < 0 ) {
826 QString d = getenv("QWS_DISPLAY"); 826 QString d = getenv("QWS_DISPLAY");
827 if ( d.contains("Rot90") ) { 827 if ( d.contains("Rot90") ) {
828 deforient = 90; 828 deforient = 90;
829 } else if ( d.contains("Rot180") ) { 829 } else if ( d.contains("Rot180") ) {
830 deforient = 180; 830 deforient = 180;
831 } else if ( d.contains("Rot270") ) { 831 } else if ( d.contains("Rot270") ) {
832 deforient = 270; 832 deforient = 270;
833 } else { 833 } else {
834 deforient=0; 834 deforient=0;
835 } 835 }
836 } 836 }
837 return deforient; 837 return deforient;
838} 838}
839 839
840/*! 840/*!
841 \internal 841 \internal
842*/ 842*/
843void QPEApplication::setDefaultRotation(int r) 843void QPEApplication::setDefaultRotation(int r)
844{ 844{
845 if ( qApp->type() == GuiServer ) { 845 if ( qApp->type() == GuiServer ) {
846 deforient = r; 846 deforient = r;
847 setenv("QWS_DISPLAY", QString("Transformed:Rot%1:0").arg(r).latin1(), 1); 847 setenv("QWS_DISPLAY", QString("Transformed:Rot%1:0").arg(r).latin1(), 1);
848 } else { 848 } else {
849 QCopEnvelope("QPE/System", "setDefaultRotation(int)") << r; 849 QCopEnvelope("QPE/System", "setDefaultRotation(int)") << r;
850 } 850 }
851} 851}
852 852
853/*! 853/*!
854 \internal 854 \internal
855*/ 855*/
856void QPEApplication::applyStyle() 856void QPEApplication::applyStyle()
857{ 857{
858 Config config( "qpe" ); 858 Config config( "qpe" );
859 859
860 config.setGroup( "Appearance" ); 860 config.setGroup( "Appearance" );
861 861
862 // Widget style 862 // Widget style
863 QString style = config.readEntry( "Style", "Light" ); 863 QString style = config.readEntry( "Style", "Light" );
864 internalSetStyle( style ); 864 internalSetStyle( style );
865 865
866 // Colors 866 // Colors
867 QColor bgcolor( config.readEntry( "Background", "#E5E1D5" ) ); 867 QColor bgcolor( config.readEntry( "Background", "#E5E1D5" ) );
868 QColor btncolor( config.readEntry( "Button", "#D6CDBB" ) ); 868 QColor btncolor( config.readEntry( "Button", "#D6CDBB" ) );
869 QPalette pal( btncolor, bgcolor ); 869 QPalette pal( btncolor, bgcolor );
870 QString color = config.readEntry( "Highlight", "#800000" ); 870 QString color = config.readEntry( "Highlight", "#800000" );
871 pal.setColor( QColorGroup::Highlight, QColor(color) ); 871 pal.setColor( QColorGroup::Highlight, QColor(color) );
872 color = config.readEntry( "HighlightedText", "#FFFFFF" ); 872 color = config.readEntry( "HighlightedText", "#FFFFFF" );
873 pal.setColor( QColorGroup::HighlightedText, QColor(color) ); 873 pal.setColor( QColorGroup::HighlightedText, QColor(color) );
874 color = config.readEntry( "Text", "#000000" ); 874 color = config.readEntry( "Text", "#000000" );
875 pal.setColor( QColorGroup::Text, QColor(color) ); 875 pal.setColor( QColorGroup::Text, QColor(color) );
876 color = config.readEntry( "ButtonText", "#000000" ); 876 color = config.readEntry( "ButtonText", "#000000" );
877 pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor(color) ); 877 pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor(color) );
878 color = config.readEntry( "Base", "#FFFFFF" ); 878 color = config.readEntry( "Base", "#FFFFFF" );
879 pal.setColor( QColorGroup::Base, QColor(color) ); 879 pal.setColor( QColorGroup::Base, QColor(color) );
880 880
881 pal.setColor( QPalette::Disabled, QColorGroup::Text, 881 pal.setColor( QPalette::Disabled, QColorGroup::Text,
882 pal.color(QPalette::Active, QColorGroup::Background).dark() ); 882 pal.color(QPalette::Active, QColorGroup::Background).dark() );
883 883
884 setPalette( pal, TRUE ); 884 setPalette( pal, TRUE );
885} 885}
886 886
887void QPEApplication::systemMessage( const QCString &msg, const QByteArray &data) 887void QPEApplication::systemMessage( const QCString &msg, const QByteArray &data)
888{ 888{
889#ifdef Q_WS_QWS 889#ifdef Q_WS_QWS
890 QDataStream stream( data, IO_ReadOnly ); 890 QDataStream stream( data, IO_ReadOnly );
891 if ( msg == "applyStyle()" ) { 891 if ( msg == "applyStyle()" ) {
892 applyStyle(); 892 applyStyle();
893 } else if ( msg == "setScreenSaverInterval(int)" ) { 893 } else if ( msg == "setScreenSaverInterval(int)" ) {
894 if ( type() == GuiServer ) { 894 if ( type() == GuiServer ) {
895 int time; 895 int time;
896 stream >> time; 896 stream >> time;
897 setScreenSaverInterval(time); 897 setScreenSaverInterval(time);
898 } 898 }
899 } else if ( msg == "setScreenSaverIntervals(int,int,int)" ) { 899 } else if ( msg == "setScreenSaverIntervals(int,int,int)" ) {
900 if ( type() == GuiServer ) { 900 if ( type() == GuiServer ) {
901 int t1,t2,t3; 901 int t1,t2,t3;
902 stream >> t1 >> t2 >> t3; 902 stream >> t1 >> t2 >> t3;
903 setScreenSaverIntervals(t1,t2,t3); 903 setScreenSaverIntervals(t1,t2,t3);
904 } 904 }
905 } else if ( msg == "setBacklight(int)" ) { 905 } else if ( msg == "setBacklight(int)" ) {
906 if ( type() == GuiServer ) { 906 if ( type() == GuiServer ) {
907 int bright; 907 int bright;
908 stream >> bright; 908 stream >> bright;
909 setBacklight(bright); 909 setBacklight(bright);
910 } 910 }
911 } else if ( msg == "setDefaultRotation(int)" ) { 911 } else if ( msg == "setDefaultRotation(int)" ) {
912 if ( type() == GuiServer ) { 912 if ( type() == GuiServer ) {
913 int r; 913 int r;
914 stream >> r; 914 stream >> r;
915 setDefaultRotation(r); 915 setDefaultRotation(r);
916 } 916 }
917 } else if ( msg == "shutdown()" ) { 917 } else if ( msg == "shutdown()" ) {
918 if ( type() == GuiServer ) 918 if ( type() == GuiServer )
919 shutdown(); 919 shutdown();
920 } else if ( msg == "quit()" ) { 920 } else if ( msg == "quit()" ) {
921 if ( type() != GuiServer ) 921 if ( type() != GuiServer )
922 tryQuit(); 922 tryQuit();
923 } else if ( msg == "forceQuit()" ) { 923 } else if ( msg == "forceQuit()" ) {
924 if ( type() != GuiServer ) 924 if ( type() != GuiServer )
925 quit(); 925 quit();
926 } else if ( msg == "restart()" ) { 926 } else if ( msg == "restart()" ) {
927 if ( type() == GuiServer ) 927 if ( type() == GuiServer )
928 restart(); 928 restart();
929 } else if ( msg == "grabKeyboard(QString)" ) { 929 } else if ( msg == "grabKeyboard(QString)" ) {
930 QString who; 930 QString who;
931 stream >> who; 931 stream >> who;
932 if ( who.isEmpty() ) 932 if ( who.isEmpty() )
933 d->kbgrabber = 0; 933 d->kbgrabber = 0;
934 else if ( who != d->appName ) 934 else if ( who != d->appName )
935 d->kbgrabber = 1; 935 d->kbgrabber = 1;
936 else 936 else
937 d->kbgrabber = 2; 937 d->kbgrabber = 2;
938 } else if ( msg == "language(QString)" ) { 938 } else if ( msg == "language(QString)" ) {
939 if ( type() == GuiServer ) { 939 if ( type() == GuiServer ) {
940 QString l; 940 QString l;
941 stream >> l; 941 stream >> l;
942 QString cl = getenv("LANG"); 942 QString cl = getenv("LANG");
943 if ( cl != l ) { 943 if ( cl != l ) {
944 if ( l.isNull() ) 944 if ( l.isNull() )
945 unsetenv( "LANG" ); 945 unsetenv( "LANG" );
946 else 946 else
947 setenv( "LANG", l.latin1(), 1 ); 947 setenv( "LANG", l.latin1(), 1 );
948 restart(); 948 restart();
949 } 949 }
950 } 950 }
951 } else if ( msg == "timeChange(QString)" ) { 951 } else if ( msg == "timeChange(QString)" ) {
952 QString t; 952 QString t;
953 stream >> t; 953 stream >> t;
954 if ( t.isNull() ) 954 if ( t.isNull() )
955 unsetenv( "TZ" ); 955 unsetenv( "TZ" );
956 else 956 else
957 setenv( "TZ", t.latin1(), 1 ); 957 setenv( "TZ", t.latin1(), 1 );
958 // emit the signal so everyone else knows... 958 // emit the signal so everyone else knows...
959 emit timeChanged(); 959 emit timeChanged();
960 } else if ( msg == "execute(QString)" ) { 960 } else if ( msg == "execute(QString)" ) {
961 if ( type() == GuiServer ) { 961 if ( type() == GuiServer ) {
962 QString t; 962 QString t;
963 stream >> t; 963 stream >> t;
964 Global::execute( t ); 964 Global::execute( t );
965 } 965 }
966 } else if ( msg == "execute(QString,QString)" ) { 966 } else if ( msg == "execute(QString,QString)" ) {
967 if ( type() == GuiServer ) { 967 if ( type() == GuiServer ) {
968 QString t,d; 968 QString t,d;
969 stream >> t >> d; 969 stream >> t >> d;
970 Global::execute( t, d ); 970 Global::execute( t, d );
971 } 971 }
972 } else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) { 972 } else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) {
973 if ( type() == GuiServer ) { 973 if ( type() == GuiServer ) {
974 QDateTime when; 974 QDateTime when;
975 QCString channel, message; 975 QCString channel, message;
976 int data; 976 int data;
977 stream >> when >> channel >> message >> data; 977 stream >> when >> channel >> message >> data;
978 AlarmServer::addAlarm( when, channel, message, data ); 978 AlarmServer::addAlarm( when, channel, message, data );
979 } 979 }
980 } else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) { 980 } else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) {
981 if ( type() == GuiServer ) { 981 if ( type() == GuiServer ) {
982 QDateTime when; 982 QDateTime when;
983 QCString channel, message; 983 QCString channel, message;
984 int data; 984 int data;
985 stream >> when >> channel >> message >> data; 985 stream >> when >> channel >> message >> data;
986 AlarmServer::deleteAlarm( when, channel, message, data ); 986 AlarmServer::deleteAlarm( when, channel, message, data );
987 } 987 }
988 } else if ( msg == "clockChange(bool)" ) { 988 } else if ( msg == "clockChange(bool)" ) {
989 int tmp; 989 int tmp;
990 stream >> tmp; 990 stream >> tmp;
991 emit clockChanged( tmp ); 991 emit clockChanged( tmp );
992 } else if ( msg == "weekChange(bool)" ) { 992 } else if ( msg == "weekChange(bool)" ) {
993 int tmp; 993 int tmp;
994 stream >> tmp; 994 stream >> tmp;
995 emit weekChanged( tmp ); 995 emit weekChanged( tmp );
996 } else if ( msg == "setDateFormat(DateFormat)" ) { 996 } else if ( msg == "setDateFormat(DateFormat)" ) {
997 DateFormat tmp; 997 DateFormat tmp;
998 stream >> tmp; 998 stream >> tmp;
999 emit dateFormatChanged( tmp ); 999 emit dateFormatChanged( tmp );
1000 } else if ( msg == "setVolume(int,int)" ) { 1000 } else if ( msg == "setVolume(int,int)" ) {
1001 int t,v; 1001 int t,v;
1002 stream >> t >> v; 1002 stream >> t >> v;
1003 setVolume(t,v); 1003 setVolume(t,v);
1004 emit volumeChanged( muted ); 1004 emit volumeChanged( muted );
1005 } else if ( msg == "volumeChange(bool)" ) { 1005 } else if ( msg == "volumeChange(bool)" ) {
1006 stream >> muted; 1006 stream >> muted;
1007 setVolume(); 1007 setVolume();
1008 emit volumeChanged( muted ); 1008 emit volumeChanged( muted );
1009 } else if ( msg == "setMic(int,int)") { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> 1009 } else if ( msg == "setMic(int,int)") { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com>
1010 int t,v; 1010 int t,v;
1011 stream >> t >> v; 1011 stream >> t >> v;
1012 setMic(t,v); 1012 setMic(t,v);
1013 emit micChanged( micMuted ); 1013 emit micChanged( micMuted );
1014 } else if ( msg == "micChange(bool)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> 1014 } else if ( msg == "micChange(bool)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com>
1015 stream >> micMuted; 1015 stream >> micMuted;
1016 setMic(); 1016 setMic();
1017 emit micChanged( micMuted ); 1017 emit micChanged( micMuted );
1018 } else if ( msg == "setScreenSaverMode(int)" ) { 1018 } else if ( msg == "setScreenSaverMode(int)" ) {
1019 if ( type() == GuiServer ) { 1019 if ( type() == GuiServer ) {
1020 int old = disable_suspend; 1020 int old = disable_suspend;
1021 stream >> disable_suspend; 1021 stream >> disable_suspend;
1022 //qDebug("setScreenSaverMode(%d)", disable_suspend ); 1022 //qDebug("setScreenSaverMode(%d)", disable_suspend );
1023 if ( disable_suspend > old ) 1023 if ( disable_suspend > old )
1024 setScreenSaverInterval( -1 ); 1024 setScreenSaverInterval( -1 );
1025 } 1025 }
1026 } 1026 }
1027#endif 1027#endif
1028} 1028}
1029 1029
1030/*! 1030/*!
1031 \internal 1031 \internal
1032*/ 1032*/
1033bool QPEApplication::raiseAppropriateWindow() 1033bool QPEApplication::raiseAppropriateWindow()
1034{ 1034{
1035 bool r=FALSE; 1035 bool r=FALSE;
1036 // ########## raise()ing main window should raise and set active 1036 // ########## raise()ing main window should raise and set active
1037 // ########## it and then all childen. This belongs in Qt/Embedded 1037 // ########## it and then all childen. This belongs in Qt/Embedded
1038 QWidget *top = d->qpe_main_widget; 1038 QWidget *top = d->qpe_main_widget;
1039 if ( !top ) top =mainWidget(); 1039 if ( !top ) top =mainWidget();
1040 if ( top && d->keep_running ) { 1040 if ( top && d->keep_running ) {
1041 if ( top->isVisible() ) 1041 if ( top->isVisible() )
1042 r = TRUE; 1042 r = TRUE;
1043#ifdef Q_WS_QWS 1043#ifdef Q_WS_QWS
1044 if ( !d->nomaximize ) 1044 if ( !d->nomaximize )
1045 top->showMaximized(); 1045 top->showMaximized();
1046 else 1046 else
1047#endif 1047#endif
1048 top->show(); 1048 top->show();
1049 top->raise(); 1049 top->raise();
1050 top->setActiveWindow(); 1050 top->setActiveWindow();
1051 } 1051 }
1052 QWidget *topm = activeModalWidget(); 1052 QWidget *topm = activeModalWidget();
1053 if ( topm && topm != top ) { 1053 if ( topm && topm != top ) {
1054 topm->show(); 1054 topm->show();
1055 topm->raise(); 1055 topm->raise();
1056 topm->setActiveWindow(); 1056 topm->setActiveWindow();
1057 r = FALSE; 1057 r = FALSE;
1058 } 1058 }
1059 return r; 1059 return r;
1060} 1060}
1061 1061
1062void QPEApplication::pidMessage( const QCString &msg, const QByteArray & data) 1062void QPEApplication::pidMessage( const QCString &msg, const QByteArray & data)
1063{ 1063{
1064#ifdef Q_WS_QWS 1064#ifdef Q_WS_QWS
1065 1065
1066 if ( msg == "quit()" ) { 1066 if ( msg == "quit()" ) {
1067 tryQuit(); 1067 tryQuit();
1068 } else if ( msg == "quitIfInvisible()" ) { 1068 } else if ( msg == "quitIfInvisible()" ) {
1069 if ( d->qpe_main_widget && !d->qpe_main_widget->isVisible() ) 1069 if ( d->qpe_main_widget && !d->qpe_main_widget->isVisible() )
1070 quit(); 1070 quit();
1071 } else if ( msg == "close()" ) { 1071 } else if ( msg == "close()" ) {
1072 hideOrQuit(); 1072 hideOrQuit();
1073 } else if ( msg == "disablePreload()" ) { 1073 } else if ( msg == "disablePreload()" ) {
1074 d->preloaded = FALSE; 1074 d->preloaded = FALSE;
1075 d->keep_running = TRUE; 1075 d->keep_running = TRUE;
1076 /* so that quit will quit */ 1076 /* so that quit will quit */
1077 } else if ( msg == "enablePreload()" ) { 1077 } else if ( msg == "enablePreload()" ) {
1078 d->preloaded = TRUE; 1078 d->preloaded = TRUE;
1079 d->keep_running = TRUE; 1079 d->keep_running = TRUE;
1080 /* so next quit won't quit */ 1080 /* so next quit won't quit */
1081 } else if ( msg == "raise()" ) { 1081 } else if ( msg == "raise()" ) {
1082 d->keep_running = TRUE; 1082 d->keep_running = TRUE;
1083 d->notbusysent = FALSE; 1083 d->notbusysent = FALSE;
1084 raiseAppropriateWindow(); 1084 raiseAppropriateWindow();
1085 } else if ( msg == "flush()" ) { 1085 } else if ( msg == "flush()" ) {
1086 emit flush(); 1086 emit flush();
1087 // we need to tell the desktop 1087 // we need to tell the desktop
1088 QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" ); 1088 QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" );
1089 e << d->appName; 1089 e << d->appName;
1090 } else if ( msg == "reload()" ) { 1090 } else if ( msg == "reload()" ) {
1091 emit reload(); 1091 emit reload();
1092 } else if ( msg == "setDocument(QString)" ) { 1092 } else if ( msg == "setDocument(QString)" ) {
1093 d->keep_running = TRUE; 1093 d->keep_running = TRUE;
1094 QDataStream stream( data, IO_ReadOnly ); 1094 QDataStream stream( data, IO_ReadOnly );
1095 QString doc; 1095 QString doc;
1096 stream >> doc; 1096 stream >> doc;
1097 QWidget *mw = mainWidget(); 1097 QWidget *mw = mainWidget();
1098 if ( !mw ) 1098 if ( !mw )
1099 mw = d->qpe_main_widget; 1099 mw = d->qpe_main_widget;
1100 if ( mw ) 1100 if ( mw )
1101 Global::setDocument( mw, doc ); 1101 Global::setDocument( mw, doc );
1102 } else if ( msg == "nextView()" ) { 1102 } else if ( msg == "nextView()" ) {
1103 if ( raiseAppropriateWindow() ) 1103 if ( raiseAppropriateWindow() )
1104 emit appMessage( msg, data); 1104 emit appMessage( msg, data);
1105 } else { 1105 } else {
1106 emit appMessage( msg, data); 1106 emit appMessage( msg, data);
1107 } 1107 }
1108#endif 1108#endif
1109} 1109}
1110 1110
1111 1111
1112static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) 1112static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ )
1113{ 1113{
1114/* 1114/*
1115 // This works but disable it for now until it is safe to apply 1115 // This works but disable it for now until it is safe to apply
1116 // What is does is scan the .desktop files of all the apps for 1116 // What is does is scan the .desktop files of all the apps for
1117 // the applnk that has the corresponding argv[0] as this program 1117 // the applnk that has the corresponding argv[0] as this program
1118 // then it uses the name stored in the .desktop file as the caption 1118 // then it uses the name stored in the .desktop file as the caption
1119 // for the main widget. This saves duplicating translations for 1119 // for the main widget. This saves duplicating translations for
1120 // the app name in the program and in the .desktop files. 1120 // the app name in the program and in the .desktop files.
1121 1121
1122 AppLnkSet apps( appsPath ); 1122 AppLnkSet apps( appsPath );
1123 1123
1124 QList<AppLnk> appsList = apps.children(); 1124 QList<AppLnk> appsList = apps.children();
1125 for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) { 1125 for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) {
1126 if ( (*it)->exec() == appName ) { 1126 if ( (*it)->exec() == appName ) {
1127 mw->setCaption( (*it)->name() ); 1127 mw->setCaption( (*it)->name() );
1128 return TRUE; 1128 return TRUE;
1129 } 1129 }
1130 } 1130 }
1131*/ 1131*/
1132 return FALSE; 1132 return FALSE;
1133} 1133}
1134 1134
1135 1135
1136/*! 1136/*!
1137 Sets \a mw as the mainWidget() and shows it. For small windows, 1137 Sets \a mw as the mainWidget() and shows it. For small windows,
1138 consider passing TRUE for \a nomaximize rather than the default FALSE. 1138 consider passing TRUE for \a nomaximize rather than the default FALSE.
1139 1139
1140 \sa showMainDocumentWidget() 1140 \sa showMainDocumentWidget()
1141*/ 1141*/
1142void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize ) 1142void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize )
1143{ 1143{
1144 setWidgetCaptionFromAppName( mw, d->appName, qpeDir() + "apps" ); 1144 setWidgetCaptionFromAppName( mw, d->appName, qpeDir() + "apps" );
1145 1145
1146 d->nomaximize = nomaximize; 1146 d->nomaximize = nomaximize;
1147 d->qpe_main_widget = mw; 1147 d->qpe_main_widget = mw;
1148 d->sendQCopQ(); 1148 d->sendQCopQ();
1149 if ( d->preloaded ) { 1149 if ( d->preloaded ) {
1150 if(d->forceshow) { 1150 if(d->forceshow) {
1151#ifdef Q_WS_QWS 1151#ifdef Q_WS_QWS
1152 if ( !nomaximize ) 1152 if ( !nomaximize )
1153 mw->showMaximized(); 1153 mw->showMaximized();
1154 else 1154 else
1155#endif 1155#endif
1156 mw->show(); 1156 mw->show();
1157 } 1157 }
1158 } else if ( d->keep_running ) { 1158 } else if ( d->keep_running ) {
1159#ifdef Q_WS_QWS 1159#ifdef Q_WS_QWS
1160 if ( !nomaximize ) 1160 if ( !nomaximize )
1161 mw->showMaximized(); 1161 mw->showMaximized();
1162 else 1162 else
1163#endif 1163#endif
1164 mw->show(); 1164 mw->show();
1165 } 1165 }
1166} 1166}
1167 1167
1168/*! 1168/*!
1169 Sets \a mw as the mainWidget() and shows it. For small windows, 1169 Sets \a mw as the mainWidget() and shows it. For small windows,
1170 consider passing TRUE for \a nomaximize rather than the default FALSE. 1170 consider passing TRUE for \a nomaximize rather than the default FALSE.
1171 1171
1172 This calls designates the application as 1172 This calls designates the application as
1173 a \link docwidget.html document-oriented\endlink application. 1173 a \link docwidget.html document-oriented\endlink application.
1174 1174
1175 The \a mw widget must have a slot: setDocument(const QString&). 1175 The \a mw widget must have a slot: setDocument(const QString&).
1176 1176
1177 \sa showMainWidget() 1177 \sa showMainWidget()
1178*/ 1178*/
1179void QPEApplication::showMainDocumentWidget( QWidget* mw, bool nomaximize ) 1179void QPEApplication::showMainDocumentWidget( QWidget* mw, bool nomaximize )
1180{ 1180{
1181 setWidgetCaptionFromAppName( mw, d->appName, qpeDir() + "apps" ); 1181 setWidgetCaptionFromAppName( mw, d->appName, qpeDir() + "apps" );
1182 1182
1183 if ( mw && argc() == 2 ) 1183 if ( mw && argc() == 2 )
1184 Global::setDocument( mw, QString::fromUtf8(argv()[1]) ); 1184 Global::setDocument( mw, QString::fromUtf8(argv()[1]) );
1185 d->nomaximize = nomaximize; 1185 d->nomaximize = nomaximize;
1186 d->qpe_main_widget = mw; 1186 d->qpe_main_widget = mw;
1187 d->sendQCopQ(); 1187 d->sendQCopQ();
1188 if ( d->preloaded ) { 1188 if ( d->preloaded ) {
1189 if(d->forceshow) { 1189 if(d->forceshow) {
1190#ifdef Q_WS_QWS 1190#ifdef Q_WS_QWS
1191 if ( !nomaximize ) 1191 if ( !nomaximize )
1192 mw->showMaximized(); 1192 mw->showMaximized();
1193 else 1193 else
1194#endif 1194#endif
1195 mw->show(); 1195 mw->show();
1196 } 1196 }
1197 } else if ( d->keep_running ) { 1197 } else if ( d->keep_running ) {
1198#ifdef Q_WS_QWS 1198#ifdef Q_WS_QWS
1199 if ( !nomaximize ) 1199 if ( !nomaximize )
1200 mw->showMaximized(); 1200 mw->showMaximized();
1201 else 1201 else
1202#endif 1202#endif
1203 mw->show(); 1203 mw->show();
1204 } 1204 }
1205} 1205}
1206 1206
1207 1207
1208/*! 1208/*!
1209 Sets that the application should continue running after processing 1209 Sets that the application should continue running after processing
1210 qcop messages. Normally if an application is started via a qcop message, 1210 qcop messages. Normally if an application is started via a qcop message,
1211 the application will process the qcop message and then quit. If while 1211 the application will process the qcop message and then quit. If while
1212 processing the qcop message it calls this function, then the application 1212 processing the qcop message it calls this function, then the application
1213 will show and start proper once it has finished processing qcop messages. 1213 will show and start proper once it has finished processing qcop messages.
1214 1214
1215 \sa keepRunning() 1215 \sa keepRunning()
1216*/ 1216*/
1217void QPEApplication::setKeepRunning() 1217void QPEApplication::setKeepRunning()
1218{ 1218{
1219 if ( qApp && qApp->inherits( "QPEApplication" ) ) { 1219 if ( qApp && qApp->inherits( "QPEApplication" ) ) {
1220 QPEApplication *qpeApp = (QPEApplication*)qApp; 1220 QPEApplication *qpeApp = (QPEApplication*)qApp;
1221 qpeApp->d->keep_running = TRUE; 1221 qpeApp->d->keep_running = TRUE;
1222 } 1222 }
1223} 1223}
1224 1224
1225/*! 1225/*!
1226 Returns whether the application will quit after processing the current 1226 Returns whether the application will quit after processing the current
1227 list of qcop messages. 1227 list of qcop messages.
1228 1228
1229 \sa setKeepRunning() 1229 \sa setKeepRunning()
1230*/ 1230*/
1231bool QPEApplication::keepRunning() const 1231bool QPEApplication::keepRunning() const
1232{ 1232{
1233 return d->keep_running; 1233 return d->keep_running;
1234} 1234}
1235 1235
1236/*! 1236/*!
1237 \internal 1237 \internal
1238*/ 1238*/
1239void QPEApplication::internalSetStyle( const QString &style ) 1239void QPEApplication::internalSetStyle( const QString &style )
1240{ 1240{
1241#if QT_VERSION >= 300 1241#if QT_VERSION >= 300
1242 if ( style == "QPE" ) { 1242 if ( style == "QPE" ) {
1243 setStyle( new QPEStyle ); 1243 setStyle( new QPEStyle );
1244 } else { 1244 } else {
1245 QStyle *s = QStyleFactory::create(style); 1245 QStyle *s = QStyleFactory::create(style);
1246 if ( s ) setStyle(s); 1246 if ( s ) setStyle(s);
1247 } 1247 }
1248#else 1248#else
1249 if ( style == "Windows" ) { 1249 if ( style == "Windows" ) {
1250 setStyle( new QWindowsStyle ); 1250 setStyle( new QWindowsStyle );
1251 } else if ( style == "QPE" ) { 1251 } else if ( style == "QPE" ) {
1252 setStyle( new QPEStyle ); 1252 setStyle( new QPEStyle );
1253 } else if ( style == "Light" ) { 1253 } else if ( style == "Light" ) {
1254 setStyle( new LightStyle ); 1254 setStyle( new LightStyle );
1255 } 1255 }
1256#ifndef QT_NO_STYLE_PLATINUM 1256#ifndef QT_NO_STYLE_PLATINUM
1257 else if ( style == "Platinum" ) { 1257 else if ( style == "Platinum" ) {
1258 setStyle( new QPlatinumStyle ); 1258 setStyle( new QPlatinumStyle );
1259 } 1259 }
1260#endif 1260#endif
1261#ifndef QT_NO_STYLE_MOTIF 1261#ifndef QT_NO_STYLE_MOTIF
1262 else if ( style == "Motif" ) { 1262 else if ( style == "Motif" ) {
1263 setStyle( new QMotifStyle ); 1263 setStyle( new QMotifStyle );
1264 } 1264 }
1265#endif 1265#endif
1266#ifndef QT_NO_STYLE_MOTIFPLUS 1266#ifndef QT_NO_STYLE_MOTIFPLUS
1267 else if ( style == "MotifPlus" ) { 1267 else if ( style == "MotifPlus" ) {
1268 setStyle( new QMotifPlusStyle ); 1268 setStyle( new QMotifPlusStyle );
1269 } 1269 }
1270#endif 1270#endif
1271#endif 1271#endif
1272} 1272}
1273 1273
1274/*! 1274/*!
1275 \internal 1275 \internal
1276*/ 1276*/
1277void QPEApplication::prepareForTermination(bool willrestart) 1277void QPEApplication::prepareForTermination(bool willrestart)
1278{ 1278{
1279 if ( willrestart ) { 1279 if ( willrestart ) {
1280 // Draw a big wait icon, the image can be altered in later revisions 1280 // Draw a big wait icon, the image can be altered in later revisions
1281 //QWidget *d = QApplication::desktop(); 1281 //QWidget *d = QApplication::desktop();
1282 QImage img = Resource::loadImage( "wait" ); 1282 QImage img = Resource::loadImage( "launcher/new_wait" );
1283 QPixmap pix; 1283 QPixmap pix;
1284 pix.convertFromImage(img.smoothScale(3*img.width(), 3*img.height())); 1284 pix.convertFromImage(img.smoothScale(1*img.width(), 1*img.height()));
1285 QLabel *lblWait = new QLabel(0, "wait hack!", QWidget::WStyle_Customize | 1285 QLabel *lblWait = new QLabel(0, "wait hack!", QWidget::WStyle_Customize |
1286 QWidget::WStyle_NoBorder | QWidget::WStyle_Tool ); 1286 QWidget::WStyle_NoBorder | QWidget::WStyle_Tool );
1287 lblWait->setPixmap( pix ); 1287 lblWait->setPixmap( pix );
1288 lblWait->setAlignment( QWidget::AlignCenter ); 1288 lblWait->setAlignment( QWidget::AlignCenter );
1289 lblWait->show(); 1289 lblWait->show();
1290 lblWait->showMaximized(); 1290 lblWait->showMaximized();
1291 } 1291 }
1292#ifndef SINGLE_APP 1292#ifndef SINGLE_APP
1293 { QCopEnvelope envelope("QPE/System", "forceQuit()"); } 1293 { QCopEnvelope envelope("QPE/System", "forceQuit()"); }
1294 processEvents(); // ensure the message goes out. 1294 processEvents(); // ensure the message goes out.
1295 sleep(1); // You have 1 second to comply. 1295 sleep(1); // You have 1 second to comply.
1296#endif 1296#endif
1297} 1297}
1298 1298
1299/*! 1299/*!
1300 \internal 1300 \internal
1301*/ 1301*/
1302void QPEApplication::shutdown() 1302void QPEApplication::shutdown()
1303{ 1303{
1304 // Implement in server's QPEApplication subclass 1304 // Implement in server's QPEApplication subclass
1305} 1305}
1306 1306
1307/*! 1307/*!
1308 \internal 1308 \internal
1309*/ 1309*/
1310void QPEApplication::restart() 1310void QPEApplication::restart()
1311{ 1311{
1312 // Implement in server's QPEApplication subclass 1312 // Implement in server's QPEApplication subclass
1313} 1313}
1314 1314
1315static QPtrDict<void>* stylusDict=0; 1315static QPtrDict<void>* stylusDict=0;
1316static void createDict() 1316static void createDict()
1317{ 1317{
1318 if ( !stylusDict ) 1318 if ( !stylusDict )
1319 stylusDict = new QPtrDict<void>; 1319 stylusDict = new QPtrDict<void>;
1320} 1320}
1321 1321
1322/*! 1322/*!
1323 Returns the current StylusMode for \a w. 1323 Returns the current StylusMode for \a w.
1324 1324
1325 \sa setStylusOperation() 1325 \sa setStylusOperation()
1326*/ 1326*/
1327QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w ) 1327QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w )
1328{ 1328{
1329 if ( stylusDict ) 1329 if ( stylusDict )
1330 return (StylusMode)(int)stylusDict->find(w); 1330 return (StylusMode)(int)stylusDict->find(w);
1331 return LeftOnly; 1331 return LeftOnly;
1332} 1332}
1333 1333
1334/*! 1334/*!
1335 \enum QPEApplication::StylusMode 1335 \enum QPEApplication::StylusMode
1336 1336
1337 \value LeftOnly the stylus only generates LeftButton 1337 \value LeftOnly the stylus only generates LeftButton
1338 events (the default). 1338 events (the default).
1339 \value RightOnHold the stylus generates RightButton events 1339 \value RightOnHold the stylus generates RightButton events
1340 if the user uses the press-and-hold gesture. 1340 if the user uses the press-and-hold gesture.
1341 1341
1342 See setStylusOperation(). 1342 See setStylusOperation().
1343*/ 1343*/
1344 1344
1345/*! 1345/*!
1346 Causes \a w to receive mouse events according to \a mode. 1346 Causes \a w to receive mouse events according to \a mode.
1347 1347
1348 \sa stylusOperation() 1348 \sa stylusOperation()
1349*/ 1349*/
1350void QPEApplication::setStylusOperation( QWidget* w, StylusMode mode ) 1350void QPEApplication::setStylusOperation( QWidget* w, StylusMode mode )
1351{ 1351{
1352 createDict(); 1352 createDict();
1353 if ( mode == LeftOnly ) { 1353 if ( mode == LeftOnly ) {
1354 stylusDict->remove(w); 1354 stylusDict->remove(w);
1355 w->removeEventFilter(qApp); 1355 w->removeEventFilter(qApp);
1356 } else { 1356 } else {
1357 stylusDict->insert(w,(void*)mode); 1357 stylusDict->insert(w,(void*)mode);
1358 connect(w,SIGNAL(destroyed()),qApp,SLOT(removeSenderFromStylusDict())); 1358 connect(w,SIGNAL(destroyed()),qApp,SLOT(removeSenderFromStylusDict()));
1359 w->installEventFilter(qApp); 1359 w->installEventFilter(qApp);
1360 } 1360 }
1361} 1361}
1362 1362
1363 1363
1364/*! 1364/*!
1365 \reimp 1365 \reimp
1366*/ 1366*/
1367bool QPEApplication::eventFilter( QObject *o, QEvent *e ) 1367bool QPEApplication::eventFilter( QObject *o, QEvent *e )
1368{ 1368{
1369 if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) { 1369 if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) {
1370 QMouseEvent* me = (QMouseEvent*)e; 1370 QMouseEvent* me = (QMouseEvent*)e;
1371 if ( me->button() == LeftButton ) { 1371 if ( me->button() == LeftButton ) {
1372 StylusMode mode = (StylusMode)(int)stylusDict->find(o); 1372 StylusMode mode = (StylusMode)(int)stylusDict->find(o);
1373 switch (mode) { 1373 switch (mode) {
1374 case RightOnHold: 1374 case RightOnHold:
1375 switch ( me->type() ) { 1375 switch ( me->type() ) {
1376 case QEvent::MouseButtonPress: 1376 case QEvent::MouseButtonPress:
1377 d->presstimer = startTimer(500); // #### pref. 1377 d->presstimer = startTimer(500); // #### pref.
1378 d->presswidget = (QWidget*)o; 1378 d->presswidget = (QWidget*)o;
1379 d->presspos = me->pos(); 1379 d->presspos = me->pos();
1380 d->rightpressed = FALSE; 1380 d->rightpressed = FALSE;
1381 break; 1381 break;
1382 case QEvent::MouseButtonRelease: 1382 case QEvent::MouseButtonRelease:
1383 if ( d->presstimer ) { 1383 if ( d->presstimer ) {
1384 killTimer(d->presstimer); 1384 killTimer(d->presstimer);
1385 d->presstimer = 0; 1385 d->presstimer = 0;
1386 } 1386 }
1387 if ( d->rightpressed && d->presswidget ) { 1387 if ( d->rightpressed && d->presswidget ) {
1388 // Right released 1388 // Right released
1389 postEvent( d->presswidget, 1389 postEvent( d->presswidget,
1390 new QMouseEvent( QEvent::MouseButtonRelease, me->pos(), 1390 new QMouseEvent( QEvent::MouseButtonRelease, me->pos(),
1391 RightButton, LeftButton+RightButton ) ); 1391 RightButton, LeftButton+RightButton ) );
1392 // Left released, off-widget 1392 // Left released, off-widget
1393 postEvent( d->presswidget, 1393 postEvent( d->presswidget,
1394 new QMouseEvent( QEvent::MouseMove, QPoint(-1,-1), 1394 new QMouseEvent( QEvent::MouseMove, QPoint(-1,-1),
1395 LeftButton, LeftButton ) ); 1395 LeftButton, LeftButton ) );
1396 postEvent( d->presswidget, 1396 postEvent( d->presswidget,
1397 new QMouseEvent( QEvent::MouseButtonRelease, QPoint(-1,-1), 1397 new QMouseEvent( QEvent::MouseButtonRelease, QPoint(-1,-1),
1398 LeftButton, LeftButton ) ); 1398 LeftButton, LeftButton ) );
1399 d->rightpressed = FALSE; 1399 d->rightpressed = FALSE;
1400 return TRUE; // don't send the real Left release 1400 return TRUE; // don't send the real Left release
1401 } 1401 }
1402 break; 1402 break;
1403 default: 1403 default:
1404 break; 1404 break;
1405 } 1405 }
1406 break; 1406 break;
1407 default: 1407 default:
1408 ; 1408 ;
1409 } 1409 }
1410 } 1410 }
1411 } else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { 1411 } else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) {
1412 QKeyEvent *ke = (QKeyEvent *)e; 1412 QKeyEvent *ke = (QKeyEvent *)e;
1413 if ( ke->key() == Key_Enter ) { 1413 if ( ke->key() == Key_Enter ) {
1414 if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) { 1414 if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) {
1415 postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ', 1415 postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ',
1416 ke->state(), " ", ke->isAutoRepeat(), ke->count() ) ); 1416 ke->state(), " ", ke->isAutoRepeat(), ke->count() ) );
1417 return TRUE; 1417 return TRUE;
1418 } 1418 }
1419 } 1419 }
1420 } 1420 }
1421 1421
1422 return FALSE; 1422 return FALSE;
1423} 1423}
1424 1424
1425/*! 1425/*!
1426 \reimp 1426 \reimp
1427*/ 1427*/
1428void QPEApplication::timerEvent( QTimerEvent *e ) 1428void QPEApplication::timerEvent( QTimerEvent *e )
1429{ 1429{
1430 if ( e->timerId() == d->presstimer && d->presswidget ) { 1430 if ( e->timerId() == d->presstimer && d->presswidget ) {
1431 // Right pressed 1431 // Right pressed
1432 postEvent( d->presswidget, 1432 postEvent( d->presswidget,
1433 new QMouseEvent( QEvent::MouseButtonPress, d->presspos, 1433 new QMouseEvent( QEvent::MouseButtonPress, d->presspos,
1434 RightButton, LeftButton ) ); 1434 RightButton, LeftButton ) );
1435 killTimer( d->presstimer ); 1435 killTimer( d->presstimer );
1436 d->presstimer = 0; 1436 d->presstimer = 0;
1437 d->rightpressed = TRUE; 1437 d->rightpressed = TRUE;
1438 } 1438 }
1439} 1439}
1440 1440
1441void QPEApplication::removeSenderFromStylusDict() 1441void QPEApplication::removeSenderFromStylusDict()
1442{ 1442{
1443 stylusDict->remove((void*)sender()); 1443 stylusDict->remove((void*)sender());
1444 if ( d->presswidget == sender() ) 1444 if ( d->presswidget == sender() )
1445 d->presswidget = 0; 1445 d->presswidget = 0;
1446} 1446}
1447 1447
1448/*! 1448/*!
1449 \internal 1449 \internal
1450*/ 1450*/
1451bool QPEApplication::keyboardGrabbed() const 1451bool QPEApplication::keyboardGrabbed() const
1452{ 1452{
1453 return d->kbgrabber; 1453 return d->kbgrabber;
1454} 1454}
1455 1455
1456 1456
1457/*! 1457/*!
1458 Reverses the effect of grabKeyboard(). This is called automatically 1458 Reverses the effect of grabKeyboard(). This is called automatically
1459 on program exit. 1459 on program exit.
1460*/ 1460*/
1461void QPEApplication::ungrabKeyboard() 1461void QPEApplication::ungrabKeyboard()
1462{ 1462{
1463 QPEApplicationData* d = ((QPEApplication*)qApp)->d; 1463 QPEApplicationData* d = ((QPEApplication*)qApp)->d;
1464 if ( d->kbgrabber == 2 ) { 1464 if ( d->kbgrabber == 2 ) {
1465 QCopEnvelope e("QPE/System", "grabKeyboard(QString)" ); 1465 QCopEnvelope e("QPE/System", "grabKeyboard(QString)" );
1466 e << QString::null; 1466 e << QString::null;
1467 d->kbregrab = FALSE; 1467 d->kbregrab = FALSE;
1468 d->kbgrabber = 0; 1468 d->kbgrabber = 0;
1469 } 1469 }
1470} 1470}
1471 1471
1472/*! 1472/*!
1473 Grabs the keyboard such that the system's application launching 1473 Grabs the keyboard such that the system's application launching
1474 keys no longer work, and instead they are receivable by this 1474 keys no longer work, and instead they are receivable by this
1475 application. 1475 application.
1476 1476
1477 \sa ungrabKeyboard() 1477 \sa ungrabKeyboard()
1478*/ 1478*/
1479void QPEApplication::grabKeyboard() 1479void QPEApplication::grabKeyboard()
1480{ 1480{
1481 QPEApplicationData* d = ((QPEApplication*)qApp)->d; 1481 QPEApplicationData* d = ((QPEApplication*)qApp)->d;
1482 if ( qApp->type() == QApplication::GuiServer ) 1482 if ( qApp->type() == QApplication::GuiServer )
1483 d->kbgrabber = 0; 1483 d->kbgrabber = 0;
1484 else { 1484 else {
1485 QCopEnvelope e("QPE/System", "grabKeyboard(QString)" ); 1485 QCopEnvelope e("QPE/System", "grabKeyboard(QString)" );
1486 e << d->appName; 1486 e << d->appName;
1487 d->kbgrabber = 2; // me 1487 d->kbgrabber = 2; // me
1488 } 1488 }
1489} 1489}
1490 1490
1491/*! 1491/*!
1492 \reimp 1492 \reimp
1493*/ 1493*/
1494int QPEApplication::exec() 1494int QPEApplication::exec()
1495{ 1495{
1496 d->sendQCopQ(); 1496 d->sendQCopQ();
1497 if ( d->keep_running) 1497 if ( d->keep_running)
1498 //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() ) 1498 //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() )
1499 return QApplication::exec(); 1499 return QApplication::exec();
1500 1500
1501 { 1501 {
1502 QCopEnvelope e("QPE/System", "closing(QString)" ); 1502 QCopEnvelope e("QPE/System", "closing(QString)" );
1503 e << d->appName; 1503 e << d->appName;
1504 } 1504 }
1505 processEvents(); 1505 processEvents();
1506 return 0; 1506 return 0;
1507} 1507}
1508 1508
1509/*! 1509/*!
1510 \internal 1510 \internal
1511 External request for application to quit. Quits if possible without 1511 External request for application to quit. Quits if possible without
1512 loosing state. 1512 loosing state.
1513*/ 1513*/
1514void QPEApplication::tryQuit() 1514void QPEApplication::tryQuit()
1515{ 1515{
1516 if ( activeModalWidget() || strcmp( argv()[0], "embeddedkonsole") == 0 ) 1516 if ( activeModalWidget() || strcmp( argv()[0], "embeddedkonsole") == 0 )
1517 return; // Inside modal loop or konsole. Too hard to save state. 1517 return; // Inside modal loop or konsole. Too hard to save state.
1518 { 1518 {
1519 QCopEnvelope e("QPE/System", "closing(QString)" ); 1519 QCopEnvelope e("QPE/System", "closing(QString)" );
1520 e << d->appName; 1520 e << d->appName;
1521 } 1521 }
1522 processEvents(); 1522 processEvents();
1523 1523
1524 quit(); 1524 quit();
1525} 1525}
1526 1526
1527/*! 1527/*!
1528 \internal 1528 \internal
1529 User initiated quit. Makes the window 'Go Away'. If preloaded this means 1529 User initiated quit. Makes the window 'Go Away'. If preloaded this means
1530 hiding the window. If not it means quitting the application. 1530 hiding the window. If not it means quitting the application.
1531 As this is user initiated we don't need to check state. 1531 As this is user initiated we don't need to check state.
1532*/ 1532*/
1533void QPEApplication::hideOrQuit() 1533void QPEApplication::hideOrQuit()
1534{ 1534{
1535 // notify of our demise :) 1535 // notify of our demise :)
1536 { 1536 {
1537 QCopEnvelope e("QPE/System", "closing(QString)" ); 1537 QCopEnvelope e("QPE/System", "closing(QString)" );
1538 e << d->appName; 1538 e << d->appName;
1539 } 1539 }
1540 processEvents(); 1540 processEvents();
1541 if ( d->preloaded && d->qpe_main_widget ) 1541 if ( d->preloaded && d->qpe_main_widget )
1542 d->qpe_main_widget->hide(); 1542 d->qpe_main_widget->hide();
1543 else 1543 else
1544 quit(); 1544 quit();
1545} 1545}
1546 1546
1547#if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) 1547#if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX)
1548 1548
1549// The libraries with the skiff package (and possibly others) have 1549// The libraries with the skiff package (and possibly others) have
1550// completely useless implementations of builtin new and delete that 1550// completely useless implementations of builtin new and delete that
1551// use about 50% of your CPU. Here we revert to the simple libc 1551// use about 50% of your CPU. Here we revert to the simple libc
1552// functions. 1552// functions.
1553 1553
1554void* operator new[](size_t size) 1554void* operator new[](size_t size)
1555{ 1555{
1556 return malloc(size); 1556 return malloc(size);
1557} 1557}
1558 1558
1559void* operator new(size_t size) 1559void* operator new(size_t size)
1560{ 1560{
1561 return malloc(size); 1561 return malloc(size);
1562} 1562}
1563 1563
1564void operator delete[](void* p) 1564void operator delete[](void* p)
1565{ 1565{
1566 free(p); 1566 free(p);
1567} 1567}
1568 1568
1569void operator delete[](void* p, size_t /*size*/) 1569void operator delete[](void* p, size_t /*size*/)
1570{ 1570{
1571 free(p); 1571 free(p);
1572} 1572}
1573 1573
1574void operator delete(void* p) 1574void operator delete(void* p)
1575{ 1575{
1576 free(p); 1576 free(p);
1577} 1577}
1578 1578
1579void operator delete(void* p, size_t /*size*/) 1579void operator delete(void* p, size_t /*size*/)
1580{ 1580{
1581 free(p); 1581 free(p);
1582} 1582}
1583 1583
1584#endif 1584#endif
1585 1585
1586#if ( QT_VERSION <= 230 ) && !defined(SINGLE_APP) 1586#if ( QT_VERSION <= 230 ) && !defined(SINGLE_APP)
1587#include <qwidgetlist.h> 1587#include <qwidgetlist.h>
1588#include <qgfx_qws.h> 1588#include <qgfx_qws.h>
1589extern QRect qt_maxWindowRect; 1589extern QRect qt_maxWindowRect;
1590void qt_setMaxWindowRect(const QRect& r) 1590void qt_setMaxWindowRect(const QRect& r)
1591{ 1591{
1592 qt_maxWindowRect = qt_screen->mapFromDevice(r, 1592 qt_maxWindowRect = qt_screen->mapFromDevice(r,
1593 qt_screen->mapToDevice(QSize(qt_screen->width(),qt_screen->height()))); 1593 qt_screen->mapToDevice(QSize(qt_screen->width(),qt_screen->height())));
1594 // Re-resize any maximized windows 1594 // Re-resize any maximized windows
1595 QWidgetList* l = QApplication::topLevelWidgets(); 1595 QWidgetList* l = QApplication::topLevelWidgets();
1596 if ( l ) { 1596 if ( l ) {
1597 QWidget *w = l->first(); 1597 QWidget *w = l->first();
1598 while ( w ) { 1598 while ( w ) {
1599 if ( w->isVisible() && w->isMaximized() ) 1599 if ( w->isVisible() && w->isMaximized() )
1600 { 1600 {
1601 w->showMaximized(); 1601 w->showMaximized();
1602 } 1602 }
1603 w = l->next(); 1603 w = l->next();
1604 } 1604 }
1605 delete l; 1605 delete l;
1606 } 1606 }
1607} 1607}
1608#endif 1608#endif
diff --git a/pics/launcher/new_wait.png b/pics/launcher/new_wait.png
new file mode 100644
index 0000000..ef65056
--- a/dev/null
+++ b/pics/launcher/new_wait.png
Binary files differ