summaryrefslogtreecommitdiff
path: root/library/qpeapplication.cpp
authorllornkcor <llornkcor>2002-04-17 12:56:38 (UTC)
committer llornkcor <llornkcor>2002-04-17 12:56:38 (UTC)
commitb382414bf0446b6facd11d35df5dc097edbd5396 (patch) (unidiff)
tree26e44ad8ad14e70681189703b4e422e2cd37225e /library/qpeapplication.cpp
parent4db3abc59c27022211222187a48eb649460c5432 (diff)
downloadopie-b382414bf0446b6facd11d35df5dc097edbd5396.zip
opie-b382414bf0446b6facd11d35df5dc097edbd5396.tar.gz
opie-b382414bf0446b6facd11d35df5dc097edbd5396.tar.bz2
added #include <linux/fb.h>
Diffstat (limited to 'library/qpeapplication.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--library/qpeapplication.cpp1219
1 files changed, 611 insertions, 608 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp
index ba9db71..5f61c0c 100644
--- a/library/qpeapplication.cpp
+++ b/library/qpeapplication.cpp
@@ -48,6 +48,9 @@
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>
52
53#include <qsignal.h>
51#include "qpeapplication.h" 54#include "qpeapplication.h"
52#include "qpestyle.h" 55#include "qpestyle.h"
53#if QT_VERSION >= 300 56#if QT_VERSION >= 300
@@ -89,11 +92,11 @@
89class QPEApplicationData { 92class QPEApplicationData {
90public: 93public:
91 QPEApplicationData() : presstimer(0), presswidget(0), rightpressed(FALSE), 94 QPEApplicationData() : presstimer(0), presswidget(0), rightpressed(FALSE),
92 kbgrabber(0), kbregrab(FALSE), notbusysent(FALSE), preloaded(FALSE), 95 kbgrabber(0), kbregrab(FALSE), notbusysent(FALSE), preloaded(FALSE),
93 forceshow(FALSE), nomaximize(FALSE), qpe_main_widget(0), 96 forceshow(FALSE), nomaximize(FALSE), qpe_main_widget(0),
94 keep_running(TRUE) 97 keep_running(TRUE)
95 { 98 {
96 qcopq.setAutoDelete(TRUE); 99 qcopq.setAutoDelete(TRUE);
97 } 100 }
98 101
99 int presstimer; 102 int presstimer;
@@ -105,13 +108,13 @@ public:
105 bool notbusysent; 108 bool notbusysent;
106 QString appName; 109 QString appName;
107 struct QCopRec { 110 struct QCopRec {
108 QCopRec(const QCString &ch, const QCString &msg, 111 QCopRec(const QCString &ch, const QCString &msg,
109 const QByteArray &d) : 112 const QByteArray &d) :
110 channel(ch), message(msg), data(d) { } 113 channel(ch), message(msg), data(d) { }
111 114
112 QCString channel; 115 QCString channel;
113 QCString message; 116 QCString message;
114 QByteArray data; 117 QByteArray data;
115 }; 118 };
116 bool preloaded; 119 bool preloaded;
117 bool forceshow; 120 bool forceshow;
@@ -123,14 +126,14 @@ public:
123 void enqueueQCop(const QCString &ch, const QCString &msg, 126 void enqueueQCop(const QCString &ch, const QCString &msg,
124 const QByteArray &data) 127 const QByteArray &data)
125 { 128 {
126 qcopq.append(new QCopRec(ch,msg,data)); 129 qcopq.append(new QCopRec(ch,msg,data));
127 } 130 }
128 void sendQCopQ() 131 void sendQCopQ()
129 { 132 {
130 QCopRec* r; 133 QCopRec* r;
131 for (QListIterator<QCopRec> it(qcopq); (r=it.current()); ++it) 134 for (QListIterator<QCopRec> it(qcopq); (r=it.current()); ++it)
132 QCopChannel::sendLocally(r->channel,r->message,r->data); 135 QCopChannel::sendLocally(r->channel,r->message,r->data);
133 qcopq.clear(); 136 qcopq.clear();
134 } 137 }
135}; 138};
136 139
@@ -138,27 +141,27 @@ class ResourceMimeFactory : public QMimeSourceFactory {
138public: 141public:
139 ResourceMimeFactory() 142 ResourceMimeFactory()
140 { 143 {
141 setFilePath( Global::helpPath() ); 144 setFilePath( Global::helpPath() );
142 setExtensionType("html","text/html;charset=UTF-8"); 145 setExtensionType("html","text/html;charset=UTF-8");
143 } 146 }
144 147
145 const QMimeSource* data(const QString& abs_name) const 148 const QMimeSource* data(const QString& abs_name) const
146 { 149 {
147 const QMimeSource* r = QMimeSourceFactory::data(abs_name); 150 const QMimeSource* r = QMimeSourceFactory::data(abs_name);
148 if ( !r ) { 151 if ( !r ) {
149 int sl = abs_name.length(); 152 int sl = abs_name.length();
150 do { 153 do {
151 sl = abs_name.findRev('/',sl-1); 154 sl = abs_name.findRev('/',sl-1);
152 QString name = sl>=0 ? abs_name.mid(sl+1) : abs_name; 155 QString name = sl>=0 ? abs_name.mid(sl+1) : abs_name;
153 int dot = name.findRev('.'); 156 int dot = name.findRev('.');
154 if ( dot >= 0 ) 157 if ( dot >= 0 )
155 name = name.left(dot); 158 name = name.left(dot);
156 QImage img = Resource::loadImage(name); 159 QImage img = Resource::loadImage(name);
157 if ( !img.isNull() ) 160 if ( !img.isNull() )
158 r = new QImageDrag(img); 161 r = new QImageDrag(img);
159 } while (!r && sl>0); 162 } while (!r && sl>0);
160 } 163 }
161 return r; 164 return r;
162 } 165 }
163}; 166};
164 167
@@ -169,18 +172,18 @@ static void setVolume(int t=0, int percent=-1)
169{ 172{
170 switch (t) { 173 switch (t) {
171 case 0: { 174 case 0: {
172 Config cfg("Sound"); 175 Config cfg("Sound");
173 cfg.setGroup("System"); 176 cfg.setGroup("System");
174 if ( percent < 0 ) 177 if ( percent < 0 )
175 percent = cfg.readNumEntry("Volume",50); 178 percent = cfg.readNumEntry("Volume",50);
176 int fd = 0; 179 int fd = 0;
177 if ((fd = open("/dev/mixer", O_RDWR))>=0) { 180 if ((fd = open("/dev/mixer", O_RDWR))>=0) {
178 int vol = muted ? 0 : percent; 181 int vol = muted ? 0 : percent;
179 // set both channels to same volume 182 // set both channels to same volume
180 vol |= vol << 8; 183 vol |= vol << 8;
181 ioctl(fd, MIXER_WRITE(0), &vol); 184 ioctl(fd, MIXER_WRITE(0), &vol);
182 ::close(fd); 185 ::close(fd);
183 } 186 }
184 } break; 187 } break;
185 } 188 }
186} 189}
@@ -189,17 +192,17 @@ static void setMic(int t=0, int percent=-1)
189{ 192{
190 switch (t) { 193 switch (t) {
191 case 0: { 194 case 0: {
192 Config cfg("Sound"); 195 Config cfg("Sound");
193 cfg.setGroup("System"); 196 cfg.setGroup("System");
194 if ( percent < 0 ) 197 if ( percent < 0 )
195 percent = cfg.readNumEntry("Mic",50); 198 percent = cfg.readNumEntry("Mic",50);
196 199
197 int fd = 0; 200 int fd = 0;
198 int mic = micMuted ? 0 : percent; 201 int mic = micMuted ? 0 : percent;
199 if ((fd = open("/dev/mixer", O_RDWR))>=0) { 202 if ((fd = open("/dev/mixer", O_RDWR))>=0) {
200 ioctl(fd, MIXER_WRITE(SOUND_MIXER_MIC), &mic); 203 ioctl(fd, MIXER_WRITE(SOUND_MIXER_MIC), &mic);
201 ::close(fd); 204 ::close(fd);
202 } 205 }
203 } break; 206 } break;
204 } 207 }
205} 208}
@@ -232,10 +235,10 @@ static int curbl=-1;
232static int backlight() 235static int backlight()
233{ 236{
234 if ( curbl == -1 ) { 237 if ( curbl == -1 ) {
235 // Read from config 238 // Read from config
236 Config config( "qpe" ); 239 Config config( "qpe" );
237 config.setGroup( "Screensaver" ); 240 config.setGroup( "Screensaver" );
238 curbl = config.readNumEntry("Brightness",255); 241 curbl = config.readNumEntry("Brightness",255);
239 } 242 }
240 return curbl; 243 return curbl;
241} 244}
@@ -243,67 +246,67 @@ static int backlight()
243static void setBacklight(int bright) 246static void setBacklight(int bright)
244{ 247{
245 if ( bright == -3 ) { 248 if ( bright == -3 ) {
246 // Forced on 249 // Forced on
247 forced_off = FALSE; 250 forced_off = FALSE;
248 bright = -1; 251 bright = -1;
249 } 252 }
250 if ( forced_off && bright != -2 ) 253 if ( forced_off && bright != -2 )
251 return; 254 return;
252 if ( bright == -2 ) { 255 if ( bright == -2 ) {
253 // Toggle between off and on 256 // Toggle between off and on
254 bright = curbl ? 0 : -1; 257 bright = curbl ? 0 : -1;
255 forced_off = !bright; 258 forced_off = !bright;
256 } 259 }
257 if ( bright == -1 ) { 260 if ( bright == -1 ) {
258 // Read from config 261 // Read from config
259 Config config( "qpe" ); 262 Config config( "qpe" );
260 config.setGroup( "Screensaver" ); 263 config.setGroup( "Screensaver" );
261 bright = config.readNumEntry("Brightness",255); 264 bright = config.readNumEntry("Brightness",255);
262 } 265 }
263#if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) 266#if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX)
264 if ( QFile::exists("/usr/bin/bl") ) { 267 if ( QFile::exists("/usr/bin/bl") ) {
265 QString cmd = "/usr/bin/bl 1 "; 268 QString cmd = "/usr/bin/bl 1 ";
266 cmd += bright<=0 ? "0 " : "1 "; 269 cmd += bright<=0 ? "0 " : "1 ";
267 cmd += QString::number(bright); 270 cmd += QString::number(bright);
268 system(cmd.latin1()); 271 system(cmd.latin1());
269#if defined(QT_QWS_EBX) 272#if defined(QT_QWS_EBX)
270 } else if ( QFile::exists("/dev/fl") ) { 273 } else if ( QFile::exists("/dev/fl") ) {
271#define FL_IOCTL_STEP_CONTRAST 100 274#define FL_IOCTL_STEP_CONTRAST 100
272 int fd = open("/dev/fl", O_WRONLY); 275 int fd = open("/dev/fl", O_WRONLY);
273 if (fd >= 0 ) { 276 if (fd >= 0 ) {
274 int steps = qpe_sysBrightnessSteps(); 277 int steps = qpe_sysBrightnessSteps();
275 int bl = ( bright * steps + 127 ) / 255; 278 int bl = ( bright * steps + 127 ) / 255;
276 if ( bright && !bl ) bl = 1; 279 if ( bright && !bl ) bl = 1;
277 bl = ioctl(fd, FL_IOCTL_STEP_CONTRAST, bl); 280 bl = ioctl(fd, FL_IOCTL_STEP_CONTRAST, bl);
278 close(fd); 281 close(fd);
279 } 282 }
280 } 283 }
281#elif defined(QT_QWS_IPAQ) 284#elif defined(QT_QWS_IPAQ)
282 } else if ( QFile::exists("/dev/ts") || QFile::exists("/dev/h3600_ts") ) { 285 } else if ( QFile::exists("/dev/ts") || QFile::exists("/dev/h3600_ts") ) {
283 typedef struct { 286 typedef struct {
284 unsigned char mode; 287 unsigned char mode;
285 unsigned char pwr; 288 unsigned char pwr;
286 unsigned char brightness; 289 unsigned char brightness;
287 } FLITE_IN; 290 } FLITE_IN;
288# ifndef FLITE_ON 291# ifndef FLITE_ON
289# ifndef _LINUX_IOCTL_H 292# ifndef _LINUX_IOCTL_H
290# include <linux/ioctl.h> 293# include <linux/ioctl.h>
291# endif 294# endif
292# define FLITE_ON _IOW('f', 7, FLITE_IN) 295# define FLITE_ON _IOW('f', 7, FLITE_IN)
293# endif 296# endif
294 int fd; 297 int fd;
295 if ( QFile::exists("/dev/ts") ) 298 if ( QFile::exists("/dev/ts") )
296 fd = open("/dev/ts", O_WRONLY); 299 fd = open("/dev/ts", O_WRONLY);
297 else 300 else
298 fd = open("/dev/h3600_ts", O_WRONLY); 301 fd = open("/dev/h3600_ts", O_WRONLY);
299 if (fd >= 0 ) { 302 if (fd >= 0 ) {
300 FLITE_IN bl; 303 FLITE_IN bl;
301 bl.mode = 1; 304 bl.mode = 1;
302 bl.pwr = bright ? 1 : 0; 305 bl.pwr = bright ? 1 : 0;
303 bl.brightness = bright; 306 bl.brightness = bright;
304 ioctl(fd, FLITE_ON, &bl); 307 ioctl(fd, FLITE_ON, &bl);
305 close(fd); 308 close(fd);
306 } 309 }
307 } 310 }
308#endif 311#endif
309#endif 312#endif
@@ -343,62 +346,62 @@ public:
343 } 346 }
344 void restore() 347 void restore()
345 { 348 {
346 if (!LcdOn) // We must have turned it off 349 if (!LcdOn) // We must have turned it off
347 { 350 {
348 int fd; 351 int fd;
349 fd=open("/dev/fb0",O_RDWR); 352 fd=open("/dev/fb0",O_RDWR);
350 if (fd != -1) { ioctl(fd,FBIOBLANK,VESA_NO_BLANKING); close(fd); } 353 if (fd != -1) { ioctl(fd,FBIOBLANK,VESA_NO_BLANKING); close(fd); }
351 } 354 }
352 setBacklight(-1); 355 setBacklight(-1);
353 } 356 }
354 bool save(int level) 357 bool save(int level)
355 { 358 {
356 int fd; 359 int fd;
357 360
358 switch ( level ) { 361 switch ( level ) {
359 case 0: 362 case 0:
360 if ( disable_suspend > 0 && dim_on ) { 363 if ( disable_suspend > 0 && dim_on ) {
361 if (backlight() > 1) 364 if (backlight() > 1)
362 setBacklight(1); // lowest non-off 365 setBacklight(1); // lowest non-off
363 } 366 }
364 return TRUE; 367 return TRUE;
365 break; 368 break;
366 case 1: 369 case 1:
367 if ( disable_suspend > 1 && lightoff_on ) { 370 if ( disable_suspend > 1 && lightoff_on ) {
368 setBacklight(0); // off 371 setBacklight(0); // off
369 } 372 }
370 return TRUE; 373 return TRUE;
371 break; 374 break;
372 case 2: 375 case 2:
373 Config config( "qpe" ); 376 Config config( "qpe" );
374 config.setGroup( "Screensaver" ); 377 config.setGroup( "Screensaver" );
375 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
376 { 379 {
377 fd=open("/dev/fb0",O_RDWR); 380 fd=open("/dev/fb0",O_RDWR);
378 if (fd != -1) { ioctl(fd,FBIOBLANK,VESA_POWERDOWN); close(fd); } 381 if (fd != -1) { ioctl(fd,FBIOBLANK,VESA_POWERDOWN); close(fd); }
379 LcdOn = FALSE; 382 LcdOn = FALSE;
380 } 383 }
381 else // We're going to suspend the whole machine 384 else // We're going to suspend the whole machine
382 { 385 {
383 if ( disable_suspend > 2 && !powerOnline() && !networkOnline() ) { 386 if ( disable_suspend > 2 && !powerOnline() && !networkOnline() ) {
384 QWSServer::sendKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE ); 387 QWSServer::sendKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE );
385 return TRUE; 388 return TRUE;
386 } 389 }
387 } 390 }
388 break; 391 break;
389 } 392 }
390 return FALSE; 393 return FALSE;
391 } 394 }
392}; 395};
393 396
394static 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)
395{ 398{
396 if ( !enable.isEmpty() && config.readNumEntry(enable,0) == 0 ) 399 if ( !enable.isEmpty() && config.readNumEntry(enable,0) == 0 )
397 return 0; 400 return 0;
398 401
399 if ( interval < 0 ) { 402 if ( interval < 0 ) {
400 // Restore screen blanking and power saving state 403 // Restore screen blanking and power saving state
401 interval = config.readNumEntry( value, def ); 404 interval = config.readNumEntry( value, def );
402 } 405 }
403 return interval; 406 return interval;
404} 407}
@@ -422,9 +425,9 @@ static void setScreenSaverIntervals(int i1, int i2, int i3)
422 dim_on = ( (i1 != 0) ? config.readNumEntry("Dim",1) : FALSE ); 425 dim_on = ( (i1 != 0) ? config.readNumEntry("Dim",1) : FALSE );
423 lightoff_on = ( (i2 != 0 ) ? config.readNumEntry("LightOff",1) : FALSE ); 426 lightoff_on = ( (i2 != 0 ) ? config.readNumEntry("LightOff",1) : FALSE );
424 if ( !i1 && !i2 && !i3 ) 427 if ( !i1 && !i2 && !i3 )
425 QWSServer::setScreenSaverInterval(0); 428 QWSServer::setScreenSaverInterval(0);
426 else 429 else
427 QWSServer::setScreenSaverIntervals(v); 430 QWSServer::setScreenSaverIntervals(v);
428} 431}
429 432
430static void setScreenSaverInterval(int interval) 433static void setScreenSaverInterval(int interval)
@@ -478,14 +481,14 @@ static void setScreenSaverInterval(int interval)
478\code 481\code
479 void MyWidget::receive( const QCString& msg, const QByteArray& data ) 482 void MyWidget::receive( const QCString& msg, const QByteArray& data )
480 { 483 {
481 QDataStream stream( data, IO_ReadOnly ); 484 QDataStream stream( data, IO_ReadOnly );
482 if ( msg == "someMessage(int,int,int)" ) { 485 if ( msg == "someMessage(int,int,int)" ) {
483 int a,b,c; 486 int a,b,c;
484 stream >> a >> b >> c; 487 stream >> a >> b >> c;
485 ... 488 ...
486 } else if ( msg == "otherMessage(QString)" ) { 489 } else if ( msg == "otherMessage(QString)" ) {
487 ... 490 ...
488 } 491 }
489 } 492 }
490\endcode 493\endcode
491 494
@@ -501,9 +504,9 @@ QPEApplication::QPEApplication( int& argc, char **argv, Type t )
501{ 504{
502 int dw = desktop()->width(); 505 int dw = desktop()->width();
503 if ( dw < 200 ) { 506 if ( dw < 200 ) {
504 setFont( QFont( "helvetica", 8 ) ); 507 setFont( QFont( "helvetica", 8 ) );
505 AppLnk::setSmallIconSize(10); 508 AppLnk::setSmallIconSize(10);
506 AppLnk::setBigIconSize(28); 509 AppLnk::setBigIconSize(28);
507 } 510 }
508 511
509 d = new QPEApplicationData; 512 d = new QPEApplicationData;
@@ -517,12 +520,12 @@ QPEApplication::QPEApplication( int& argc, char **argv, Type t )
517 520
518 QFile f(qcopfn); 521 QFile f(qcopfn);
519 if ( f.open(IO_ReadOnly) ) { 522 if ( f.open(IO_ReadOnly) ) {
520 flock(f.handle(), LOCK_EX); 523 flock(f.handle(), LOCK_EX);
521 } 524 }
522 525
523 sysChannel = new QCopChannel( "QPE/System", this ); 526 sysChannel = new QCopChannel( "QPE/System", this );
524 connect( sysChannel, SIGNAL(received(const QCString &, const QByteArray &)), 527 connect( sysChannel, SIGNAL(received(const QCString &, const QByteArray &)),
525 this, SLOT(systemMessage( const QCString &, const QByteArray &)) ); 528 this, SLOT(systemMessage( const QCString &, const QByteArray &)) );
526 529
527 QCString channel = QCString(argv[0]); 530 QCString channel = QCString(argv[0]);
528 channel.replace(QRegExp(".*/"),""); 531 channel.replace(QRegExp(".*/"),"");
@@ -530,36 +533,36 @@ QPEApplication::QPEApplication( int& argc, char **argv, Type t )
530 channel = "QPE/Application/" + channel; 533 channel = "QPE/Application/" + channel;
531 pidChannel = new QCopChannel( channel, this); 534 pidChannel = new QCopChannel( channel, this);
532 connect( pidChannel, SIGNAL(received(const QCString &, const QByteArray &)), 535 connect( pidChannel, SIGNAL(received(const QCString &, const QByteArray &)),
533 this, SLOT(pidMessage(const QCString &, const QByteArray &))); 536 this, SLOT(pidMessage(const QCString &, const QByteArray &)));
534 537
535 if ( f.isOpen() ) { 538 if ( f.isOpen() ) {
536 d->keep_running = FALSE; 539 d->keep_running = FALSE;
537 QDataStream ds(&f); 540 QDataStream ds(&f);
538 QCString channel, message; 541 QCString channel, message;
539 QByteArray data; 542 QByteArray data;
540 while(!ds.atEnd()) { 543 while(!ds.atEnd()) {
541 ds >> channel >> message >> data; 544 ds >> channel >> message >> data;
542 d->enqueueQCop(channel,message,data); 545 d->enqueueQCop(channel,message,data);
543 } 546 }
544 547
545 flock(f.handle(), LOCK_UN); 548 flock(f.handle(), LOCK_UN);
546 f.close(); 549 f.close();
547 f.remove(); 550 f.remove();
548 } 551 }
549 552
550 for (int a=0; a<argc; a++) { 553 for (int a=0; a<argc; a++) {
551 if ( qstrcmp(argv[a],"-preload")==0 ) { 554 if ( qstrcmp(argv[a],"-preload")==0 ) {
552 argv[a] = argv[a+1]; 555 argv[a] = argv[a+1];
553 a++; 556 a++;
554 d->preloaded = TRUE; 557 d->preloaded = TRUE;
555 argc-=1; 558 argc-=1;
556 } else if ( qstrcmp(argv[a],"-preload-show")==0 ) { 559 } else if ( qstrcmp(argv[a],"-preload-show")==0 ) {
557 argv[a] = argv[a+1]; 560 argv[a] = argv[a+1];
558 a++; 561 a++;
559 d->preloaded = TRUE; 562 d->preloaded = TRUE;
560 d->forceshow = TRUE; 563 d->forceshow = TRUE;
561 argc-=1; 564 argc-=1;
562 } 565 }
563 } 566 }
564 567
565 /* overide stored arguments */ 568 /* overide stored arguments */
@@ -572,39 +575,39 @@ QPEApplication::QPEApplication( int& argc, char **argv, Type t )
572#ifndef QT_NO_TRANSLATION 575#ifndef QT_NO_TRANSLATION
573 QStringList langs = Global::languageList(); 576 QStringList langs = Global::languageList();
574 for (QStringList::ConstIterator it = langs.begin(); it!=langs.end(); ++it) { 577 for (QStringList::ConstIterator it = langs.begin(); it!=langs.end(); ++it) {
575 QString lang = *it; 578 QString lang = *it;
576 579
577 QTranslator * trans; 580 QTranslator * trans;
578 QString tfn; 581 QString tfn;
579 582
580 trans = new QTranslator(this); 583 trans = new QTranslator(this);
581 tfn = qpeDir()+"/i18n/"+lang+"/libqpe.qm"; 584 tfn = qpeDir()+"/i18n/"+lang+"/libqpe.qm";
582 if ( trans->load( tfn )) 585 if ( trans->load( tfn ))
583 installTranslator( trans ); 586 installTranslator( trans );
584 else 587 else
585 delete trans; 588 delete trans;
586 589
587 trans = new QTranslator(this); 590 trans = new QTranslator(this);
588 tfn = qpeDir()+"/i18n/"+lang+"/"+d->appName+".qm"; 591 tfn = qpeDir()+"/i18n/"+lang+"/"+d->appName+".qm";
589 if ( trans->load( tfn )) 592 if ( trans->load( tfn ))
590 installTranslator( trans ); 593 installTranslator( trans );
591 else 594 else
592 delete trans; 595 delete trans;
593 596
594 //###language/font hack; should look it up somewhere 597 //###language/font hack; should look it up somewhere
595 if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) { 598 if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) {
596 QFont fn = FontManager::unicodeFont( FontManager::Proportional ); 599 QFont fn = FontManager::unicodeFont( FontManager::Proportional );
597 setFont( fn ); 600 setFont( fn );
598 } 601 }
599 } 602 }
600#endif 603#endif
601 604
602 applyStyle(); 605 applyStyle();
603 606
604 if ( type() == GuiServer ) { 607 if ( type() == GuiServer ) {
605 setScreenSaverInterval(-1); 608 setScreenSaverInterval(-1);
606 setVolume(); 609 setVolume();
607 QWSServer::setScreenSaver(new QPEScreenSaver); 610 QWSServer::setScreenSaver(new QPEScreenSaver);
608 } 611 }
609 612
610 installEventFilter( this ); 613 installEventFilter( this );
@@ -621,7 +624,7 @@ static QPtrDict<void>* inputMethodDict=0;
621static void createInputMethodDict() 624static void createInputMethodDict()
622{ 625{
623 if ( !inputMethodDict ) 626 if ( !inputMethodDict )
624 inputMethodDict = new QPtrDict<void>; 627 inputMethodDict = new QPtrDict<void>;
625} 628}
626 629
627/*! 630/*!
@@ -633,7 +636,7 @@ static void createInputMethodDict()
633QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget* w ) 636QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget* w )
634{ 637{
635 if ( inputMethodDict && w ) 638 if ( inputMethodDict && w )
636 return (InputMethodHint)(int)inputMethodDict->find(w); 639 return (InputMethodHint)(int)inputMethodDict->find(w);
637 return Normal; 640 return Normal;
638} 641}
639 642
@@ -655,9 +658,9 @@ void QPEApplication::setInputMethodHint( QWidget* w, InputMethodHint mode )
655{ 658{
656 createInputMethodDict(); 659 createInputMethodDict();
657 if ( mode == Normal ) { 660 if ( mode == Normal ) {
658 inputMethodDict->remove(w); 661 inputMethodDict->remove(w);
659 } else { 662 } else {
660 inputMethodDict->insert(w,(void*)mode); 663 inputMethodDict->insert(w,(void*)mode);
661 } 664 }
662} 665}
663 666
@@ -674,12 +677,12 @@ void QPEApplication::mapToDefaultAction( QWSKeyEvent *ke, int key )
674 // specialised actions for certain widgets. May want to 677 // specialised actions for certain widgets. May want to
675 // add more stuff here. 678 // add more stuff here.
676 if ( activePopupWidget() && activePopupWidget()->inherits( "QListBox" ) 679 if ( activePopupWidget() && activePopupWidget()->inherits( "QListBox" )
677 && activePopupWidget()->parentWidget() 680 && activePopupWidget()->parentWidget()
678 && activePopupWidget()->parentWidget()->inherits( "QComboBox" ) ) 681 && activePopupWidget()->parentWidget()->inherits( "QComboBox" ) )
679 key = Qt::Key_Return; 682 key = Qt::Key_Return;
680 683
681 if ( activePopupWidget() && activePopupWidget()->inherits( "QPopupMenu" ) ) 684 if ( activePopupWidget() && activePopupWidget()->inherits( "QPopupMenu" ) )
682 key = Qt::Key_Return; 685 key = Qt::Key_Return;
683 686
684 ke->simpleData.keycode = key; 687 ke->simpleData.keycode = key;
685} 688}
@@ -697,108 +700,108 @@ public:
697bool QPEApplication::qwsEventFilter( QWSEvent *e ) 700bool QPEApplication::qwsEventFilter( QWSEvent *e )
698{ 701{
699 if ( !d->notbusysent && e->type == QWSEvent::Focus ) { 702 if ( !d->notbusysent && e->type == QWSEvent::Focus ) {
700 if ( qApp->type() != QApplication::GuiServer ) { 703 if ( qApp->type() != QApplication::GuiServer ) {
701 QCopEnvelope e("QPE/System", "notBusy(QString)" ); 704 QCopEnvelope e("QPE/System", "notBusy(QString)" );
702 e << d->appName; 705 e << d->appName;
703 } 706 }
704 d->notbusysent=TRUE; 707 d->notbusysent=TRUE;
705 } 708 }
706 if ( type() == GuiServer ) { 709 if ( type() == GuiServer ) {
707 switch ( e->type ) { 710 switch ( e->type ) {
708 case QWSEvent::Mouse: 711 case QWSEvent::Mouse:
709 if ( e->asMouse()->simpleData.state && !QWidget::find(e->window()) ) 712 if ( e->asMouse()->simpleData.state && !QWidget::find(e->window()) )
710 emit clientMoused(); 713 emit clientMoused();
711 } 714 }
712 } 715 }
713 if ( e->type == QWSEvent::Key ) { 716 if ( e->type == QWSEvent::Key ) {
714 if ( d->kbgrabber == 1 ) 717 if ( d->kbgrabber == 1 )
715 return TRUE; 718 return TRUE;
716 QWSKeyEvent *ke = (QWSKeyEvent *)e; 719 QWSKeyEvent *ke = (QWSKeyEvent *)e;
717 if ( ke->simpleData.keycode == Qt::Key_F33 ) { 720 if ( ke->simpleData.keycode == Qt::Key_F33 ) {
718 // Use special "OK" key to press "OK" on top level widgets 721 // Use special "OK" key to press "OK" on top level widgets
719 QWidget *active = activeWindow(); 722 QWidget *active = activeWindow();
720 QWidget *popup = 0; 723 QWidget *popup = 0;
721 if ( active && active->isPopup() ) { 724 if ( active && active->isPopup() ) {
722 popup = active; 725 popup = active;
723 active = active->parentWidget(); 726 active = active->parentWidget();
724 } 727 }
725 if ( active && (int)active->winId() == ke->simpleData.window && 728 if ( active && (int)active->winId() == ke->simpleData.window &&
726 !active->testWFlags( WStyle_Customize|WType_Popup|WType_Desktop )) { 729 !active->testWFlags( WStyle_Customize|WType_Popup|WType_Desktop )) {
727 if ( ke->simpleData.is_press ) { 730 if ( ke->simpleData.is_press ) {
728 if ( popup ) 731 if ( popup )
729 popup->close(); 732 popup->close();
730 if ( active->inherits( "QDialog" ) ) { 733 if ( active->inherits( "QDialog" ) ) {
731 HackDialog *d = (HackDialog *)active; 734 HackDialog *d = (HackDialog *)active;
732 d->acceptIt(); 735 d->acceptIt();
733 return TRUE; 736 return TRUE;
734 } else if ( ((HackWidget *)active)->needsOk() ) { 737 } else if ( ((HackWidget *)active)->needsOk() ) {
735 QSignal s; 738 QSignal s;
736 s.connect( active, SLOT( accept() ) ); 739 s.connect( active, SLOT( accept() ) );
737 s.activate(); 740 s.activate();
738 } else { 741 } else {
739 // do the same as with the select key: Map to the default action of the widget: 742 // do the same as with the select key: Map to the default action of the widget:
740 mapToDefaultAction( ke, Qt::Key_Return ); 743 mapToDefaultAction( ke, Qt::Key_Return );
741 } 744 }
742 } 745 }
743 } 746 }
744 } else if ( ke->simpleData.keycode == Qt::Key_F30 ) { 747 } else if ( ke->simpleData.keycode == Qt::Key_F30 ) {
745 // Use special "select" key to do whatever default action a widget has 748 // Use special "select" key to do whatever default action a widget has
746 mapToDefaultAction( ke, Qt::Key_Space ); 749 mapToDefaultAction( ke, Qt::Key_Space );
747 } else if ( ke->simpleData.keycode == Qt::Key_Escape && 750 } else if ( ke->simpleData.keycode == Qt::Key_Escape &&
748 ke->simpleData.is_press ) { 751 ke->simpleData.is_press ) {
749 // Escape key closes app if focus on toplevel 752 // Escape key closes app if focus on toplevel
750 QWidget *active = activeWindow(); 753 QWidget *active = activeWindow();
751 if ( active && active->testWFlags( WType_TopLevel ) && 754 if ( active && active->testWFlags( WType_TopLevel ) &&
752 (int)active->winId() == ke->simpleData.window && 755 (int)active->winId() == ke->simpleData.window &&
753 !active->testWFlags( WStyle_Dialog|WStyle_Customize|WType_Popup|WType_Desktop )) { 756 !active->testWFlags( WStyle_Dialog|WStyle_Customize|WType_Popup|WType_Desktop )) {
754 if ( active->inherits( "QDialog" ) ) { 757 if ( active->inherits( "QDialog" ) ) {
755 HackDialog *d = (HackDialog *)active; 758 HackDialog *d = (HackDialog *)active;
756 d->rejectIt(); 759 d->rejectIt();
757 return TRUE; 760 return TRUE;
758 } else if ( strcmp( argv()[0], "embeddedkonsole") != 0 ) { 761 } else if ( strcmp( argv()[0], "embeddedkonsole") != 0 ) {
759 active->close(); 762 active->close();
760 } 763 }
761 } 764 }
762 } 765 }
763 766
764#if QT_VERSION < 231 767#if QT_VERSION < 231
765 // Filter out the F4/Launcher key from apps 768 // Filter out the F4/Launcher key from apps
766 // ### The launcher key may not always be F4 on all devices 769 // ### The launcher key may not always be F4 on all devices
767 if ( ((QWSKeyEvent *)e)->simpleData.keycode == Qt::Key_F4 ) 770 if ( ((QWSKeyEvent *)e)->simpleData.keycode == Qt::Key_F4 )
768 return TRUE; 771 return TRUE;
769#endif 772#endif
770 } 773 }
771 if ( e->type == QWSEvent::Focus ) { 774 if ( e->type == QWSEvent::Focus ) {
772 QWSFocusEvent *fe = (QWSFocusEvent*)e; 775 QWSFocusEvent *fe = (QWSFocusEvent*)e;
773 QWidget* nfw = QWidget::find(e->window()); 776 QWidget* nfw = QWidget::find(e->window());
774 if ( !fe->simpleData.get_focus ) { 777 if ( !fe->simpleData.get_focus ) {
775 QWidget *active = activeWindow(); 778 QWidget *active = activeWindow();
776 while ( active && active->isPopup() ) { 779 while ( active && active->isPopup() ) {
777 active->close(); 780 active->close();
778 active = activeWindow(); 781 active = activeWindow();
779 } 782 }
780 if ( !nfw && d->kbgrabber == 2 ) { 783 if ( !nfw && d->kbgrabber == 2 ) {
781 ungrabKeyboard(); 784 ungrabKeyboard();
782 d->kbregrab = TRUE; // want kb back when we're active 785 d->kbregrab = TRUE; // want kb back when we're active
783 } 786 }
784 } else { 787 } else {
785 // make sure our modal widget is ALWAYS on top 788 // make sure our modal widget is ALWAYS on top
786 QWidget *topm = activeModalWidget(); 789 QWidget *topm = activeModalWidget();
787 if ( topm ) { 790 if ( topm ) {
788 topm->raise(); 791 topm->raise();
789 } 792 }
790 if ( d->kbregrab ) { 793 if ( d->kbregrab ) {
791 grabKeyboard(); 794 grabKeyboard();
792 d->kbregrab = FALSE; 795 d->kbregrab = FALSE;
793 } 796 }
794 } 797 }
795 if ( fe->simpleData.get_focus && inputMethodDict ) { 798 if ( fe->simpleData.get_focus && inputMethodDict ) {
796 InputMethodHint m = inputMethodHint( QWidget::find(e->window()) ); 799 InputMethodHint m = inputMethodHint( QWidget::find(e->window()) );
797 if ( m == AlwaysOff ) 800 if ( m == AlwaysOff )
798 Global::hideInputMethod(); 801 Global::hideInputMethod();
799 if ( m == AlwaysOn ) 802 if ( m == AlwaysOn )
800 Global::showInputMethod(); 803 Global::showInputMethod();
801 } 804 }
802 } 805 }
803 return QApplication::qwsEventFilter( e ); 806 return QApplication::qwsEventFilter( e );
804} 807}
@@ -825,7 +828,7 @@ QString QPEApplication::qpeDir()
825{ 828{
826 const char *base = getenv( "OPIEDIR" ); 829 const char *base = getenv( "OPIEDIR" );
827 if ( base ) 830 if ( base )
828 return QString( base ) + "/"; 831 return QString( base ) + "/";
829 832
830 return QString( "../" ); 833 return QString( "../" );
831} 834}
@@ -837,7 +840,7 @@ QString QPEApplication::documentDir()
837{ 840{
838 const char *base = getenv( "HOME" ); 841 const char *base = getenv( "HOME" );
839 if ( base ) 842 if ( base )
840 return QString( base ) + "/Documents/"; 843 return QString( base ) + "/Documents/";
841 844
842 return QString( "../Documents/" ); 845 return QString( "../Documents/" );
843} 846}
@@ -850,16 +853,16 @@ static int deforient=-1;
850int QPEApplication::defaultRotation() 853int QPEApplication::defaultRotation()
851{ 854{
852 if ( deforient < 0 ) { 855 if ( deforient < 0 ) {
853 QString d = getenv("QWS_DISPLAY"); 856 QString d = getenv("QWS_DISPLAY");
854 if ( d.contains("Rot90") ) { 857 if ( d.contains("Rot90") ) {
855 deforient = 90; 858 deforient = 90;
856 } else if ( d.contains("Rot180") ) { 859 } else if ( d.contains("Rot180") ) {
857 deforient = 180; 860 deforient = 180;
858 } else if ( d.contains("Rot270") ) { 861 } else if ( d.contains("Rot270") ) {
859 deforient = 270; 862 deforient = 270;
860 } else { 863 } else {
861 deforient=0; 864 deforient=0;
862 } 865 }
863 } 866 }
864 return deforient; 867 return deforient;
865} 868}
@@ -870,10 +873,10 @@ int QPEApplication::defaultRotation()
870void QPEApplication::setDefaultRotation(int r) 873void QPEApplication::setDefaultRotation(int r)
871{ 874{
872 if ( qApp->type() == GuiServer ) { 875 if ( qApp->type() == GuiServer ) {
873 deforient = r; 876 deforient = r;
874 setenv("QWS_DISPLAY", QString("Transformed:Rot%1:0").arg(r).latin1(), 1); 877 setenv("QWS_DISPLAY", QString("Transformed:Rot%1:0").arg(r).latin1(), 1);
875 } else { 878 } else {
876 QCopEnvelope("QPE/System", "setDefaultRotation(int)") << r; 879 QCopEnvelope("QPE/System", "setDefaultRotation(int)") << r;
877 } 880 }
878} 881}
879 882
@@ -906,7 +909,7 @@ void QPEApplication::applyStyle()
906 pal.setColor( QColorGroup::Base, QColor(color) ); 909 pal.setColor( QColorGroup::Base, QColor(color) );
907 910
908 pal.setColor( QPalette::Disabled, QColorGroup::Text, 911 pal.setColor( QPalette::Disabled, QColorGroup::Text,
909 pal.color(QPalette::Active, QColorGroup::Background).dark() ); 912 pal.color(QPalette::Active, QColorGroup::Background).dark() );
910 913
911 setPalette( pal, TRUE ); 914 setPalette( pal, TRUE );
912} 915}
@@ -916,141 +919,141 @@ void QPEApplication::systemMessage( const QCString &msg, const QByteArray &data)
916#ifdef Q_WS_QWS 919#ifdef Q_WS_QWS
917 QDataStream stream( data, IO_ReadOnly ); 920 QDataStream stream( data, IO_ReadOnly );
918 if ( msg == "applyStyle()" ) { 921 if ( msg == "applyStyle()" ) {
919 applyStyle(); 922 applyStyle();
920 } else if ( msg == "setScreenSaverInterval(int)" ) { 923 } else if ( msg == "setScreenSaverInterval(int)" ) {
921 if ( type() == GuiServer ) { 924 if ( type() == GuiServer ) {
922 int time; 925 int time;
923 stream >> time; 926 stream >> time;
924 setScreenSaverInterval(time); 927 setScreenSaverInterval(time);
925 } 928 }
926 } else if ( msg == "setScreenSaverIntervals(int,int,int)" ) { 929 } else if ( msg == "setScreenSaverIntervals(int,int,int)" ) {
927 if ( type() == GuiServer ) { 930 if ( type() == GuiServer ) {
928 int t1,t2,t3; 931 int t1,t2,t3;
929 stream >> t1 >> t2 >> t3; 932 stream >> t1 >> t2 >> t3;
930 setScreenSaverIntervals(t1,t2,t3); 933 setScreenSaverIntervals(t1,t2,t3);
931 } 934 }
932 } else if ( msg == "setBacklight(int)" ) { 935 } else if ( msg == "setBacklight(int)" ) {
933 if ( type() == GuiServer ) { 936 if ( type() == GuiServer ) {
934 int bright; 937 int bright;
935 stream >> bright; 938 stream >> bright;
936 setBacklight(bright); 939 setBacklight(bright);
937 } 940 }
938 } else if ( msg == "setDefaultRotation(int)" ) { 941 } else if ( msg == "setDefaultRotation(int)" ) {
939 if ( type() == GuiServer ) { 942 if ( type() == GuiServer ) {
940 int r; 943 int r;
941 stream >> r; 944 stream >> r;
942 setDefaultRotation(r); 945 setDefaultRotation(r);
943 } 946 }
944 } else if ( msg == "shutdown()" ) { 947 } else if ( msg == "shutdown()" ) {
945 if ( type() == GuiServer ) 948 if ( type() == GuiServer )
946 shutdown(); 949 shutdown();
947 } else if ( msg == "quit()" ) { 950 } else if ( msg == "quit()" ) {
948 if ( type() != GuiServer ) 951 if ( type() != GuiServer )
949 tryQuit(); 952 tryQuit();
950 } else if ( msg == "forceQuit()" ) { 953 } else if ( msg == "forceQuit()" ) {
951 if ( type() != GuiServer ) 954 if ( type() != GuiServer )
952 quit(); 955 quit();
953 } else if ( msg == "restart()" ) { 956 } else if ( msg == "restart()" ) {
954 if ( type() == GuiServer ) 957 if ( type() == GuiServer )
955 restart(); 958 restart();
956 } else if ( msg == "grabKeyboard(QString)" ) { 959 } else if ( msg == "grabKeyboard(QString)" ) {
957 QString who; 960 QString who;
958 stream >> who; 961 stream >> who;
959 if ( who.isEmpty() ) 962 if ( who.isEmpty() )
960 d->kbgrabber = 0; 963 d->kbgrabber = 0;
961 else if ( who != d->appName ) 964 else if ( who != d->appName )
962 d->kbgrabber = 1; 965 d->kbgrabber = 1;
963 else 966 else
964 d->kbgrabber = 2; 967 d->kbgrabber = 2;
965 } else if ( msg == "language(QString)" ) { 968 } else if ( msg == "language(QString)" ) {
966 if ( type() == GuiServer ) { 969 if ( type() == GuiServer ) {
967 QString l; 970 QString l;
968 stream >> l; 971 stream >> l;
969 QString cl = getenv("LANG"); 972 QString cl = getenv("LANG");
970 if ( cl != l ) { 973 if ( cl != l ) {
971 if ( l.isNull() ) 974 if ( l.isNull() )
972 unsetenv( "LANG" ); 975 unsetenv( "LANG" );
973 else 976 else
974 setenv( "LANG", l.latin1(), 1 ); 977 setenv( "LANG", l.latin1(), 1 );
975 restart(); 978 restart();
976 } 979 }
977 } 980 }
978 } else if ( msg == "timeChange(QString)" ) { 981 } else if ( msg == "timeChange(QString)" ) {
979 QString t; 982 QString t;
980 stream >> t; 983 stream >> t;
981 if ( t.isNull() ) 984 if ( t.isNull() )
982 unsetenv( "TZ" ); 985 unsetenv( "TZ" );
983 else 986 else
984 setenv( "TZ", t.latin1(), 1 ); 987 setenv( "TZ", t.latin1(), 1 );
985 // emit the signal so everyone else knows... 988 // emit the signal so everyone else knows...
986 emit timeChanged(); 989 emit timeChanged();
987 } else if ( msg == "execute(QString)" ) { 990 } else if ( msg == "execute(QString)" ) {
988 if ( type() == GuiServer ) { 991 if ( type() == GuiServer ) {
989 QString t; 992 QString t;
990 stream >> t; 993 stream >> t;
991 Global::execute( t ); 994 Global::execute( t );
992 } 995 }
993 } else if ( msg == "execute(QString,QString)" ) { 996 } else if ( msg == "execute(QString,QString)" ) {
994 if ( type() == GuiServer ) { 997 if ( type() == GuiServer ) {
995 QString t,d; 998 QString t,d;
996 stream >> t >> d; 999 stream >> t >> d;
997 Global::execute( t, d ); 1000 Global::execute( t, d );
998 } 1001 }
999 } else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) { 1002 } else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) {
1000 if ( type() == GuiServer ) { 1003 if ( type() == GuiServer ) {
1001 QDateTime when; 1004 QDateTime when;
1002 QCString channel, message; 1005 QCString channel, message;
1003 int data; 1006 int data;
1004 stream >> when >> channel >> message >> data; 1007 stream >> when >> channel >> message >> data;
1005 AlarmServer::addAlarm( when, channel, message, data ); 1008 AlarmServer::addAlarm( when, channel, message, data );
1006 } 1009 }
1007 } else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) { 1010 } else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) {
1008 if ( type() == GuiServer ) { 1011 if ( type() == GuiServer ) {
1009 QDateTime when; 1012 QDateTime when;
1010 QCString channel, message; 1013 QCString channel, message;
1011 int data; 1014 int data;
1012 stream >> when >> channel >> message >> data; 1015 stream >> when >> channel >> message >> data;
1013 AlarmServer::deleteAlarm( when, channel, message, data ); 1016 AlarmServer::deleteAlarm( when, channel, message, data );
1014 } 1017 }
1015 } else if ( msg == "clockChange(bool)" ) { 1018 } else if ( msg == "clockChange(bool)" ) {
1016 int tmp; 1019 int tmp;
1017 stream >> tmp; 1020 stream >> tmp;
1018 emit clockChanged( tmp ); 1021 emit clockChanged( tmp );
1019 } else if ( msg == "weekChange(bool)" ) { 1022 } else if ( msg == "weekChange(bool)" ) {
1020 int tmp; 1023 int tmp;
1021 stream >> tmp; 1024 stream >> tmp;
1022 emit weekChanged( tmp ); 1025 emit weekChanged( tmp );
1023 } else if ( msg == "setDateFormat(DateFormat)" ) { 1026 } else if ( msg == "setDateFormat(DateFormat)" ) {
1024 DateFormat tmp; 1027 DateFormat tmp;
1025 stream >> tmp; 1028 stream >> tmp;
1026 emit dateFormatChanged( tmp ); 1029 emit dateFormatChanged( tmp );
1027 } else if ( msg == "setVolume(int,int)" ) { 1030 } else if ( msg == "setVolume(int,int)" ) {
1028 int t,v; 1031 int t,v;
1029 stream >> t >> v; 1032 stream >> t >> v;
1030 setVolume(t,v); 1033 setVolume(t,v);
1031 emit volumeChanged( muted ); 1034 emit volumeChanged( muted );
1032 } else if ( msg == "volumeChange(bool)" ) { 1035 } else if ( msg == "volumeChange(bool)" ) {
1033 stream >> muted; 1036 stream >> muted;
1034 setVolume(); 1037 setVolume();
1035 emit volumeChanged( muted ); 1038 emit volumeChanged( muted );
1036 } else if ( msg == "setMic(int,int)") { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> 1039 } else if ( msg == "setMic(int,int)") { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com>
1037 int t,v; 1040 int t,v;
1038 stream >> t >> v; 1041 stream >> t >> v;
1039 setMic(t,v); 1042 setMic(t,v);
1040 emit micChanged( micMuted ); 1043 emit micChanged( micMuted );
1041 } else if ( msg == "micChange(bool)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> 1044 } else if ( msg == "micChange(bool)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com>
1042 stream >> micMuted; 1045 stream >> micMuted;
1043 setMic(); 1046 setMic();
1044 emit micChanged( micMuted ); 1047 emit micChanged( micMuted );
1045 } else if ( msg == "setScreenSaverMode(int)" ) { 1048 } else if ( msg == "setScreenSaverMode(int)" ) {
1046 if ( type() == GuiServer ) { 1049 if ( type() == GuiServer ) {
1047 int old = disable_suspend; 1050 int old = disable_suspend;
1048 stream >> disable_suspend; 1051 stream >> disable_suspend;
1049 //qDebug("setScreenSaverMode(%d)", disable_suspend ); 1052 //qDebug("setScreenSaverMode(%d)", disable_suspend );
1050 if ( disable_suspend > old ) 1053 if ( disable_suspend > old )
1051 setScreenSaverInterval( -1 ); 1054 setScreenSaverInterval( -1 );
1052 } 1055 }
1053 } 1056 }
1054#endif 1057#endif
1055} 1058}
1056 1059
@@ -1065,23 +1068,23 @@ bool QPEApplication::raiseAppropriateWindow()
1065 QWidget *top = d->qpe_main_widget; 1068 QWidget *top = d->qpe_main_widget;
1066 if ( !top ) top =mainWidget(); 1069 if ( !top ) top =mainWidget();
1067 if ( top && d->keep_running ) { 1070 if ( top && d->keep_running ) {
1068 if ( top->isVisible() ) 1071 if ( top->isVisible() )
1069 r = TRUE; 1072 r = TRUE;
1070#ifdef Q_WS_QWS 1073#ifdef Q_WS_QWS
1071 if ( !d->nomaximize ) 1074 if ( !d->nomaximize )
1072 top->showMaximized(); 1075 top->showMaximized();
1073 else 1076 else
1074#endif 1077#endif
1075 top->show(); 1078 top->show();
1076 top->raise(); 1079 top->raise();
1077 top->setActiveWindow(); 1080 top->setActiveWindow();
1078 } 1081 }
1079 QWidget *topm = activeModalWidget(); 1082 QWidget *topm = activeModalWidget();
1080 if ( topm && topm != top ) { 1083 if ( topm && topm != top ) {
1081 topm->show(); 1084 topm->show();
1082 topm->raise(); 1085 topm->raise();
1083 topm->setActiveWindow(); 1086 topm->setActiveWindow();
1084 r = FALSE; 1087 r = FALSE;
1085 } 1088 }
1086 return r; 1089 return r;
1087} 1090}
@@ -1091,46 +1094,46 @@ void QPEApplication::pidMessage( const QCString &msg, const QByteArray & data)
1091#ifdef Q_WS_QWS 1094#ifdef Q_WS_QWS
1092 1095
1093 if ( msg == "quit()" ) { 1096 if ( msg == "quit()" ) {
1094 tryQuit(); 1097 tryQuit();
1095 } else if ( msg == "quitIfInvisible()" ) { 1098 } else if ( msg == "quitIfInvisible()" ) {
1096 if ( d->qpe_main_widget && !d->qpe_main_widget->isVisible() ) 1099 if ( d->qpe_main_widget && !d->qpe_main_widget->isVisible() )
1097 quit(); 1100 quit();
1098 } else if ( msg == "close()" ) { 1101 } else if ( msg == "close()" ) {
1099 hideOrQuit(); 1102 hideOrQuit();
1100 } else if ( msg == "disablePreload()" ) { 1103 } else if ( msg == "disablePreload()" ) {
1101 d->preloaded = FALSE; 1104 d->preloaded = FALSE;
1102 d->keep_running = TRUE; 1105 d->keep_running = TRUE;
1103 /* so that quit will quit */ 1106 /* so that quit will quit */
1104 } else if ( msg == "enablePreload()" ) { 1107 } else if ( msg == "enablePreload()" ) {
1105 d->preloaded = TRUE; 1108 d->preloaded = TRUE;
1106 d->keep_running = TRUE; 1109 d->keep_running = TRUE;
1107 /* so next quit won't quit */ 1110 /* so next quit won't quit */
1108 } else if ( msg == "raise()" ) { 1111 } else if ( msg == "raise()" ) {
1109 d->keep_running = TRUE; 1112 d->keep_running = TRUE;
1110 d->notbusysent = FALSE; 1113 d->notbusysent = FALSE;
1111 raiseAppropriateWindow(); 1114 raiseAppropriateWindow();
1112 } else if ( msg == "flush()" ) { 1115 } else if ( msg == "flush()" ) {
1113 emit flush(); 1116 emit flush();
1114 // we need to tell the desktop 1117 // we need to tell the desktop
1115 QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" ); 1118 QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" );
1116 e << d->appName; 1119 e << d->appName;
1117 } else if ( msg == "reload()" ) { 1120 } else if ( msg == "reload()" ) {
1118 emit reload(); 1121 emit reload();
1119 } else if ( msg == "setDocument(QString)" ) { 1122 } else if ( msg == "setDocument(QString)" ) {
1120 d->keep_running = TRUE; 1123 d->keep_running = TRUE;
1121 QDataStream stream( data, IO_ReadOnly ); 1124 QDataStream stream( data, IO_ReadOnly );
1122 QString doc; 1125 QString doc;
1123 stream >> doc; 1126 stream >> doc;
1124 QWidget *mw = mainWidget(); 1127 QWidget *mw = mainWidget();
1125 if ( !mw ) 1128 if ( !mw )
1126 mw = d->qpe_main_widget; 1129 mw = d->qpe_main_widget;
1127 if ( mw ) 1130 if ( mw )
1128 Global::setDocument( mw, doc ); 1131 Global::setDocument( mw, doc );
1129 } else if ( msg == "nextView()" ) { 1132 } else if ( msg == "nextView()" ) {
1130 if ( raiseAppropriateWindow() ) 1133 if ( raiseAppropriateWindow() )
1131 emit appMessage( msg, data); 1134 emit appMessage( msg, data);
1132 } else { 1135 } else {
1133 emit appMessage( msg, data); 1136 emit appMessage( msg, data);
1134 } 1137 }
1135#endif 1138#endif
1136} 1139}
@@ -1150,10 +1153,10 @@ static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appNa
1150 1153
1151 QList<AppLnk> appsList = apps.children(); 1154 QList<AppLnk> appsList = apps.children();
1152 for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) { 1155 for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) {
1153 if ( (*it)->exec() == appName ) { 1156 if ( (*it)->exec() == appName ) {
1154 mw->setCaption( (*it)->name() ); 1157 mw->setCaption( (*it)->name() );
1155 return TRUE; 1158 return TRUE;
1156 } 1159 }
1157 } 1160 }
1158*/ 1161*/
1159 return FALSE; 1162 return FALSE;
@@ -1174,21 +1177,21 @@ void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize )
1174 d->qpe_main_widget = mw; 1177 d->qpe_main_widget = mw;
1175 d->sendQCopQ(); 1178 d->sendQCopQ();
1176 if ( d->preloaded ) { 1179 if ( d->preloaded ) {
1177 if(d->forceshow) { 1180 if(d->forceshow) {
1178#ifdef Q_WS_QWS 1181#ifdef Q_WS_QWS
1179 if ( !nomaximize ) 1182 if ( !nomaximize )
1180 mw->showMaximized(); 1183 mw->showMaximized();
1181 else 1184 else
1182#endif 1185#endif
1183 mw->show(); 1186 mw->show();
1184 } 1187 }
1185 } else if ( d->keep_running ) { 1188 } else if ( d->keep_running ) {
1186#ifdef Q_WS_QWS 1189#ifdef Q_WS_QWS
1187 if ( !nomaximize ) 1190 if ( !nomaximize )
1188 mw->showMaximized(); 1191 mw->showMaximized();
1189 else 1192 else
1190#endif 1193#endif
1191 mw->show(); 1194 mw->show();
1192 } 1195 }
1193} 1196}
1194 1197
@@ -1208,26 +1211,26 @@ void QPEApplication::showMainDocumentWidget( QWidget* mw, bool nomaximize )
1208 setWidgetCaptionFromAppName( mw, d->appName, qpeDir() + "apps" ); 1211 setWidgetCaptionFromAppName( mw, d->appName, qpeDir() + "apps" );
1209 1212
1210 if ( mw && argc() == 2 ) 1213 if ( mw && argc() == 2 )
1211 Global::setDocument( mw, QString::fromUtf8(argv()[1]) ); 1214 Global::setDocument( mw, QString::fromUtf8(argv()[1]) );
1212 d->nomaximize = nomaximize; 1215 d->nomaximize = nomaximize;
1213 d->qpe_main_widget = mw; 1216 d->qpe_main_widget = mw;
1214 d->sendQCopQ(); 1217 d->sendQCopQ();
1215 if ( d->preloaded ) { 1218 if ( d->preloaded ) {
1216 if(d->forceshow) { 1219 if(d->forceshow) {
1217#ifdef Q_WS_QWS 1220#ifdef Q_WS_QWS
1218 if ( !nomaximize ) 1221 if ( !nomaximize )
1219 mw->showMaximized(); 1222 mw->showMaximized();
1220 else 1223 else
1221#endif 1224#endif
1222 mw->show(); 1225 mw->show();
1223 } 1226 }
1224 } else if ( d->keep_running ) { 1227 } else if ( d->keep_running ) {
1225#ifdef Q_WS_QWS 1228#ifdef Q_WS_QWS
1226 if ( !nomaximize ) 1229 if ( !nomaximize )
1227 mw->showMaximized(); 1230 mw->showMaximized();
1228 else 1231 else
1229#endif 1232#endif
1230 mw->show(); 1233 mw->show();
1231 } 1234 }
1232} 1235}
1233 1236
@@ -1244,8 +1247,8 @@ void QPEApplication::showMainDocumentWidget( QWidget* mw, bool nomaximize )
1244void QPEApplication::setKeepRunning() 1247void QPEApplication::setKeepRunning()
1245{ 1248{
1246 if ( qApp && qApp->inherits( "QPEApplication" ) ) { 1249 if ( qApp && qApp->inherits( "QPEApplication" ) ) {
1247 QPEApplication *qpeApp = (QPEApplication*)qApp; 1250 QPEApplication *qpeApp = (QPEApplication*)qApp;
1248 qpeApp->d->keep_running = TRUE; 1251 qpeApp->d->keep_running = TRUE;
1249 } 1252 }
1250} 1253}
1251 1254
@@ -1267,32 +1270,32 @@ void QPEApplication::internalSetStyle( const QString &style )
1267{ 1270{
1268#if QT_VERSION >= 300 1271#if QT_VERSION >= 300
1269 if ( style == "QPE" ) { 1272 if ( style == "QPE" ) {
1270 setStyle( new QPEStyle ); 1273 setStyle( new QPEStyle );
1271 } else { 1274 } else {
1272 QStyle *s = QStyleFactory::create(style); 1275 QStyle *s = QStyleFactory::create(style);
1273 if ( s ) setStyle(s); 1276 if ( s ) setStyle(s);
1274 } 1277 }
1275#else 1278#else
1276 if ( style == "Windows" ) { 1279 if ( style == "Windows" ) {
1277 setStyle( new QWindowsStyle ); 1280 setStyle( new QWindowsStyle );
1278 } else if ( style == "QPE" ) { 1281 } else if ( style == "QPE" ) {
1279 setStyle( new QPEStyle ); 1282 setStyle( new QPEStyle );
1280 } else if ( style == "Light" ) { 1283 } else if ( style == "Light" ) {
1281 setStyle( new LightStyle ); 1284 setStyle( new LightStyle );
1282 } 1285 }
1283#ifndef QT_NO_STYLE_PLATINUM 1286#ifndef QT_NO_STYLE_PLATINUM
1284 else if ( style == "Platinum" ) { 1287 else if ( style == "Platinum" ) {
1285 setStyle( new QPlatinumStyle ); 1288 setStyle( new QPlatinumStyle );
1286 } 1289 }
1287#endif 1290#endif
1288#ifndef QT_NO_STYLE_MOTIF 1291#ifndef QT_NO_STYLE_MOTIF
1289 else if ( style == "Motif" ) { 1292 else if ( style == "Motif" ) {
1290 setStyle( new QMotifStyle ); 1293 setStyle( new QMotifStyle );
1291 } 1294 }
1292#endif 1295#endif
1293#ifndef QT_NO_STYLE_MOTIFPLUS 1296#ifndef QT_NO_STYLE_MOTIFPLUS
1294 else if ( style == "MotifPlus" ) { 1297 else if ( style == "MotifPlus" ) {
1295 setStyle( new QMotifPlusStyle ); 1298 setStyle( new QMotifPlusStyle );
1296 } 1299 }
1297#endif 1300#endif
1298#endif 1301#endif
@@ -1304,17 +1307,17 @@ void QPEApplication::internalSetStyle( const QString &style )
1304void QPEApplication::prepareForTermination(bool willrestart) 1307void QPEApplication::prepareForTermination(bool willrestart)
1305{ 1308{
1306 if ( willrestart ) { 1309 if ( willrestart ) {
1307 // Draw a big wait icon, the image can be altered in later revisions 1310 // Draw a big wait icon, the image can be altered in later revisions
1308 //QWidget *d = QApplication::desktop(); 1311// QWidget *d = QApplication::desktop();
1309 QImage img = Resource::loadImage( "launcher/new_wait" ); 1312 QImage img = Resource::loadImage( "launcher/new_wait" );
1310 QPixmap pix; 1313 QPixmap pix;
1311 pix.convertFromImage(img.smoothScale(1*img.width(), 1*img.height())); 1314 pix.convertFromImage(img.smoothScale(1*img.width(), 1*img.height()));
1312 QLabel *lblWait = new QLabel(0, "wait hack!", QWidget::WStyle_Customize | 1315 QLabel *lblWait = new QLabel(0, "wait hack!", QWidget::WStyle_Customize |
1313 QWidget::WStyle_NoBorder | QWidget::WStyle_Tool ); 1316 QWidget::WStyle_NoBorder | QWidget::WStyle_Tool );
1314 lblWait->setPixmap( pix ); 1317 lblWait->setPixmap( pix );
1315 lblWait->setAlignment( QWidget::AlignCenter ); 1318 lblWait->setAlignment( QWidget::AlignCenter );
1316 lblWait->show(); 1319 lblWait->show();
1317 lblWait->showMaximized(); 1320 lblWait->showMaximized();
1318 } 1321 }
1319#ifndef SINGLE_APP 1322#ifndef SINGLE_APP
1320 { QCopEnvelope envelope("QPE/System", "forceQuit()"); } 1323 { QCopEnvelope envelope("QPE/System", "forceQuit()"); }
@@ -1343,7 +1346,7 @@ static QPtrDict<void>* stylusDict=0;
1343static void createDict() 1346static void createDict()
1344{ 1347{
1345 if ( !stylusDict ) 1348 if ( !stylusDict )
1346 stylusDict = new QPtrDict<void>; 1349 stylusDict = new QPtrDict<void>;
1347} 1350}
1348 1351
1349/*! 1352/*!
@@ -1354,7 +1357,7 @@ static void createDict()
1354QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w ) 1357QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w )
1355{ 1358{
1356 if ( stylusDict ) 1359 if ( stylusDict )
1357 return (StylusMode)(int)stylusDict->find(w); 1360 return (StylusMode)(int)stylusDict->find(w);
1358 return LeftOnly; 1361 return LeftOnly;
1359} 1362}
1360 1363
@@ -1362,9 +1365,9 @@ QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w )
1362 \enum QPEApplication::StylusMode 1365 \enum QPEApplication::StylusMode
1363 1366
1364 \value LeftOnly the stylus only generates LeftButton 1367 \value LeftOnly the stylus only generates LeftButton
1365 events (the default). 1368 events (the default).
1366 \value RightOnHold the stylus generates RightButton events 1369 \value RightOnHold the stylus generates RightButton events
1367 if the user uses the press-and-hold gesture. 1370 if the user uses the press-and-hold gesture.
1368 1371
1369 See setStylusOperation(). 1372 See setStylusOperation().
1370*/ 1373*/
@@ -1378,12 +1381,12 @@ void QPEApplication::setStylusOperation( QWidget* w, StylusMode mode )
1378{ 1381{
1379 createDict(); 1382 createDict();
1380 if ( mode == LeftOnly ) { 1383 if ( mode == LeftOnly ) {
1381 stylusDict->remove(w); 1384 stylusDict->remove(w);
1382 w->removeEventFilter(qApp); 1385 w->removeEventFilter(qApp);
1383 } else { 1386 } else {
1384 stylusDict->insert(w,(void*)mode); 1387 stylusDict->insert(w,(void*)mode);
1385 connect(w,SIGNAL(destroyed()),qApp,SLOT(removeSenderFromStylusDict())); 1388 connect(w,SIGNAL(destroyed()),qApp,SLOT(removeSenderFromStylusDict()));
1386 w->installEventFilter(qApp); 1389 w->installEventFilter(qApp);
1387 } 1390 }
1388} 1391}
1389 1392
@@ -1394,56 +1397,56 @@ void QPEApplication::setStylusOperation( QWidget* w, StylusMode mode )
1394bool QPEApplication::eventFilter( QObject *o, QEvent *e ) 1397bool QPEApplication::eventFilter( QObject *o, QEvent *e )
1395{ 1398{
1396 if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) { 1399 if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) {
1397 QMouseEvent* me = (QMouseEvent*)e; 1400 QMouseEvent* me = (QMouseEvent*)e;
1398 if ( me->button() == LeftButton ) { 1401 if ( me->button() == LeftButton ) {
1399 StylusMode mode = (StylusMode)(int)stylusDict->find(o); 1402 StylusMode mode = (StylusMode)(int)stylusDict->find(o);
1400 switch (mode) { 1403 switch (mode) {
1401 case RightOnHold: 1404 case RightOnHold:
1402 switch ( me->type() ) { 1405 switch ( me->type() ) {
1403 case QEvent::MouseButtonPress: 1406 case QEvent::MouseButtonPress:
1404 d->presstimer = startTimer(500); // #### pref. 1407 d->presstimer = startTimer(500); // #### pref.
1405 d->presswidget = (QWidget*)o; 1408 d->presswidget = (QWidget*)o;
1406 d->presspos = me->pos(); 1409 d->presspos = me->pos();
1407 d->rightpressed = FALSE; 1410 d->rightpressed = FALSE;
1408 break; 1411 break;
1409 case QEvent::MouseButtonRelease: 1412 case QEvent::MouseButtonRelease:
1410 if ( d->presstimer ) { 1413 if ( d->presstimer ) {
1411 killTimer(d->presstimer); 1414 killTimer(d->presstimer);
1412 d->presstimer = 0; 1415 d->presstimer = 0;
1413 } 1416 }
1414 if ( d->rightpressed && d->presswidget ) { 1417 if ( d->rightpressed && d->presswidget ) {
1415 // Right released 1418 // Right released
1416 postEvent( d->presswidget, 1419 postEvent( d->presswidget,
1417 new QMouseEvent( QEvent::MouseButtonRelease, me->pos(), 1420 new QMouseEvent( QEvent::MouseButtonRelease, me->pos(),
1418 RightButton, LeftButton+RightButton ) ); 1421 RightButton, LeftButton+RightButton ) );
1419 // Left released, off-widget 1422 // Left released, off-widget
1420 postEvent( d->presswidget, 1423 postEvent( d->presswidget,
1421 new QMouseEvent( QEvent::MouseMove, QPoint(-1,-1), 1424 new QMouseEvent( QEvent::MouseMove, QPoint(-1,-1),
1422 LeftButton, LeftButton ) ); 1425 LeftButton, LeftButton ) );
1423 postEvent( d->presswidget, 1426 postEvent( d->presswidget,
1424 new QMouseEvent( QEvent::MouseButtonRelease, QPoint(-1,-1), 1427 new QMouseEvent( QEvent::MouseButtonRelease, QPoint(-1,-1),
1425 LeftButton, LeftButton ) ); 1428 LeftButton, LeftButton ) );
1426 d->rightpressed = FALSE; 1429 d->rightpressed = FALSE;
1427 return TRUE; // don't send the real Left release 1430 return TRUE; // don't send the real Left release
1428 } 1431 }
1429 break; 1432 break;
1430 default: 1433 default:
1431 break; 1434 break;
1432 } 1435 }
1433 break; 1436 break;
1434 default: 1437 default:
1435 ; 1438 ;
1436 } 1439 }
1437 } 1440 }
1438 } else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { 1441 } else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) {
1439 QKeyEvent *ke = (QKeyEvent *)e; 1442 QKeyEvent *ke = (QKeyEvent *)e;
1440 if ( ke->key() == Key_Enter ) { 1443 if ( ke->key() == Key_Enter ) {
1441 if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) { 1444 if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) {
1442 postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ', 1445 postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ',
1443 ke->state(), " ", ke->isAutoRepeat(), ke->count() ) ); 1446 ke->state(), " ", ke->isAutoRepeat(), ke->count() ) );
1444 return TRUE; 1447 return TRUE;
1445 } 1448 }
1446 } 1449 }
1447 } 1450 }
1448 1451
1449 return FALSE; 1452 return FALSE;
@@ -1455,13 +1458,13 @@ bool QPEApplication::eventFilter( QObject *o, QEvent *e )
1455void QPEApplication::timerEvent( QTimerEvent *e ) 1458void QPEApplication::timerEvent( QTimerEvent *e )
1456{ 1459{
1457 if ( e->timerId() == d->presstimer && d->presswidget ) { 1460 if ( e->timerId() == d->presstimer && d->presswidget ) {
1458 // Right pressed 1461 // Right pressed
1459 postEvent( d->presswidget, 1462 postEvent( d->presswidget,
1460 new QMouseEvent( QEvent::MouseButtonPress, d->presspos, 1463 new QMouseEvent( QEvent::MouseButtonPress, d->presspos,
1461 RightButton, LeftButton ) ); 1464 RightButton, LeftButton ) );
1462 killTimer( d->presstimer ); 1465 killTimer( d->presstimer );
1463 d->presstimer = 0; 1466 d->presstimer = 0;
1464 d->rightpressed = TRUE; 1467 d->rightpressed = TRUE;
1465 } 1468 }
1466} 1469}
1467 1470
@@ -1469,7 +1472,7 @@ void QPEApplication::removeSenderFromStylusDict()
1469{ 1472{
1470 stylusDict->remove((void*)sender()); 1473 stylusDict->remove((void*)sender());
1471 if ( d->presswidget == sender() ) 1474 if ( d->presswidget == sender() )
1472 d->presswidget = 0; 1475 d->presswidget = 0;
1473} 1476}
1474 1477
1475/*! 1478/*!
@@ -1489,10 +1492,10 @@ void QPEApplication::ungrabKeyboard()
1489{ 1492{
1490 QPEApplicationData* d = ((QPEApplication*)qApp)->d; 1493 QPEApplicationData* d = ((QPEApplication*)qApp)->d;
1491 if ( d->kbgrabber == 2 ) { 1494 if ( d->kbgrabber == 2 ) {
1492 QCopEnvelope e("QPE/System", "grabKeyboard(QString)" ); 1495 QCopEnvelope e("QPE/System", "grabKeyboard(QString)" );
1493 e << QString::null; 1496 e << QString::null;
1494 d->kbregrab = FALSE; 1497 d->kbregrab = FALSE;
1495 d->kbgrabber = 0; 1498 d->kbgrabber = 0;
1496 } 1499 }
1497} 1500}
1498 1501
@@ -1507,11 +1510,11 @@ void QPEApplication::grabKeyboard()
1507{ 1510{
1508 QPEApplicationData* d = ((QPEApplication*)qApp)->d; 1511 QPEApplicationData* d = ((QPEApplication*)qApp)->d;
1509 if ( qApp->type() == QApplication::GuiServer ) 1512 if ( qApp->type() == QApplication::GuiServer )
1510 d->kbgrabber = 0; 1513 d->kbgrabber = 0;
1511 else { 1514 else {
1512 QCopEnvelope e("QPE/System", "grabKeyboard(QString)" ); 1515 QCopEnvelope e("QPE/System", "grabKeyboard(QString)" );
1513 e << d->appName; 1516 e << d->appName;
1514 d->kbgrabber = 2; // me 1517 d->kbgrabber = 2; // me
1515 } 1518 }
1516} 1519}
1517 1520
@@ -1522,8 +1525,8 @@ int QPEApplication::exec()
1522{ 1525{
1523 d->sendQCopQ(); 1526 d->sendQCopQ();
1524 if ( d->keep_running) 1527 if ( d->keep_running)
1525 //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() ) 1528 //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() )
1526 return QApplication::exec(); 1529 return QApplication::exec();
1527 1530
1528 { 1531 {
1529 QCopEnvelope e("QPE/System", "closing(QString)" ); 1532 QCopEnvelope e("QPE/System", "closing(QString)" );
@@ -1541,7 +1544,7 @@ int QPEApplication::exec()
1541void QPEApplication::tryQuit() 1544void QPEApplication::tryQuit()
1542{ 1545{
1543 if ( activeModalWidget() || strcmp( argv()[0], "embeddedkonsole") == 0 ) 1546 if ( activeModalWidget() || strcmp( argv()[0], "embeddedkonsole") == 0 )
1544 return; // Inside modal loop or konsole. Too hard to save state. 1547 return; // Inside modal loop or konsole. Too hard to save state.
1545 { 1548 {
1546 QCopEnvelope e("QPE/System", "closing(QString)" ); 1549 QCopEnvelope e("QPE/System", "closing(QString)" );
1547 e << d->appName; 1550 e << d->appName;
@@ -1566,9 +1569,9 @@ void QPEApplication::hideOrQuit()
1566 } 1569 }
1567 processEvents(); 1570 processEvents();
1568 if ( d->preloaded && d->qpe_main_widget ) 1571 if ( d->preloaded && d->qpe_main_widget )
1569 d->qpe_main_widget->hide(); 1572 d->qpe_main_widget->hide();
1570 else 1573 else
1571 quit(); 1574 quit();
1572} 1575}
1573 1576
1574#if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) 1577#if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX)
@@ -1617,7 +1620,7 @@ extern QRect qt_maxWindowRect;
1617void qt_setMaxWindowRect(const QRect& r) 1620void qt_setMaxWindowRect(const QRect& r)
1618{ 1621{
1619 qt_maxWindowRect = qt_screen->mapFromDevice(r, 1622 qt_maxWindowRect = qt_screen->mapFromDevice(r,
1620 qt_screen->mapToDevice(QSize(qt_screen->width(),qt_screen->height()))); 1623 qt_screen->mapToDevice(QSize(qt_screen->width(),qt_screen->height())));
1621 // Re-resize any maximized windows 1624 // Re-resize any maximized windows
1622 QWidgetList* l = QApplication::topLevelWidgets(); 1625 QWidgetList* l = QApplication::topLevelWidgets();
1623 if ( l ) { 1626 if ( l ) {