-rw-r--r-- | library/qpeapplication.cpp | 322 |
1 files changed, 230 insertions, 92 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp index dff8235..187a7e2 100644 --- a/library/qpeapplication.cpp +++ b/library/qpeapplication.cpp | |||
@@ -61,23 +61,23 @@ | |||
61 | #define FBIOBLANK 0x4611 | 61 | #define FBIOBLANK 0x4611 |
62 | 62 | ||
63 | 63 | ||
64 | #include <qsignal.h> | 64 | #include <qsignal.h> |
65 | #include "qpeapplication.h" | 65 | #include "qpeapplication.h" |
66 | #include "qpestyle.h" | 66 | #include "qpestyle.h" |
67 | #include "styleinterface.h" | ||
67 | #if QT_VERSION >= 300 | 68 | #if QT_VERSION >= 300 |
68 | #include <qstylefactory.h> | 69 | #include <qstylefactory.h> |
69 | #else | 70 | #else |
70 | #include <qplatinumstyle.h> | 71 | #include <qplatinumstyle.h> |
71 | #include <qwindowsstyle.h> | 72 | #include <qwindowsstyle.h> |
72 | #include <qmotifstyle.h> | 73 | #include <qmotifstyle.h> |
73 | #include <qmotifplusstyle.h> | 74 | #include <qmotifplusstyle.h> |
74 | #include "lightstyle.h" | 75 | #include "lightstyle.h" |
75 | 76 | ||
76 | #include <qpe/qlibrary.h> | 77 | #include <qpe/qlibrary.h> |
77 | #include <dlfcn.h> | ||
78 | #endif | 78 | #endif |
79 | #include "global.h" | 79 | #include "global.h" |
80 | #include "resource.h" | 80 | #include "resource.h" |
81 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) | 81 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) |
82 | #include "qutfcodec.h" | 82 | #include "qutfcodec.h" |
83 | #endif | 83 | #endif |
@@ -102,13 +102,14 @@ | |||
102 | #include <sys/types.h> | 102 | #include <sys/types.h> |
103 | #include <sys/stat.h> | 103 | #include <sys/stat.h> |
104 | #endif | 104 | #endif |
105 | #include <stdlib.h> | 105 | #include <stdlib.h> |
106 | 106 | ||
107 | 107 | ||
108 | class QPEApplicationData { | 108 | class QPEApplicationData |
109 | { | ||
109 | public: | 110 | public: |
110 | QPEApplicationData() : presstimer(0), presswidget(0), rightpressed(FALSE), | 111 | QPEApplicationData() : presstimer(0), presswidget(0), rightpressed(FALSE), |
111 | kbgrabber(0), kbregrab(FALSE), notbusysent(FALSE), preloaded(FALSE), | 112 | kbgrabber(0), kbregrab(FALSE), notbusysent(FALSE), preloaded(FALSE), |
112 | forceshow(FALSE), nomaximize(FALSE), qpe_main_widget(0), | 113 | forceshow(FALSE), nomaximize(FALSE), qpe_main_widget(0), |
113 | keep_running(TRUE) | 114 | keep_running(TRUE) |
114 | { | 115 | { |
@@ -120,16 +121,18 @@ public: | |||
120 | QPoint presspos; | 121 | QPoint presspos; |
121 | bool rightpressed; | 122 | bool rightpressed; |
122 | int kbgrabber; | 123 | int kbgrabber; |
123 | bool kbregrab; | 124 | bool kbregrab; |
124 | bool notbusysent; | 125 | bool notbusysent; |
125 | QString appName; | 126 | QString appName; |
126 | struct QCopRec { | 127 | struct QCopRec |
128 | { | ||
127 | QCopRec(const QCString &ch, const QCString &msg, | 129 | QCopRec(const QCString &ch, const QCString &msg, |
128 | const QByteArray &d) : | 130 | const QByteArray &d) : |
129 | channel(ch), message(msg), data(d) { } | 131 | channel( ch ), message( msg ), data( d ) |
132 | { } | ||
130 | 133 | ||
131 | QCString channel; | 134 | QCString channel; |
132 | QCString message; | 135 | QCString message; |
133 | QByteArray data; | 136 | QByteArray data; |
134 | }; | 137 | }; |
135 | bool preloaded; | 138 | bool preloaded; |
@@ -150,13 +153,14 @@ public: | |||
150 | for (QListIterator<QCopRec> it(qcopq); (r=it.current()); ++it) | 153 | for (QListIterator<QCopRec> it(qcopq); (r=it.current()); ++it) |
151 | QCopChannel::sendLocally(r->channel,r->message,r->data); | 154 | QCopChannel::sendLocally(r->channel,r->message,r->data); |
152 | qcopq.clear(); | 155 | qcopq.clear(); |
153 | } | 156 | } |
154 | }; | 157 | }; |
155 | 158 | ||
156 | class ResourceMimeFactory : public QMimeSourceFactory { | 159 | class ResourceMimeFactory : public QMimeSourceFactory |
160 | { | ||
157 | public: | 161 | public: |
158 | ResourceMimeFactory() | 162 | ResourceMimeFactory() |
159 | { | 163 | { |
160 | setFilePath( Global::helpPath() ); | 164 | setFilePath( Global::helpPath() ); |
161 | setExtensionType("html","text/html;charset=UTF-8"); | 165 | setExtensionType("html","text/html;charset=UTF-8"); |
162 | } | 166 | } |
@@ -172,13 +176,14 @@ public: | |||
172 | int dot = name.findRev('.'); | 176 | int dot = name.findRev('.'); |
173 | if ( dot >= 0 ) | 177 | if ( dot >= 0 ) |
174 | name = name.left(dot); | 178 | name = name.left(dot); |
175 | QImage img = Resource::loadImage(name); | 179 | QImage img = Resource::loadImage(name); |
176 | if ( !img.isNull() ) | 180 | if ( !img.isNull() ) |
177 | r = new QImageDrag(img); | 181 | r = new QImageDrag(img); |
178 | } while (!r && sl>0); | 182 | } |
183 | while ( !r && sl > 0 ); | ||
179 | } | 184 | } |
180 | return r; | 185 | return r; |
181 | } | 186 | } |
182 | }; | 187 | }; |
183 | 188 | ||
184 | static int muted=0; | 189 | static int muted=0; |
@@ -197,13 +202,14 @@ static void setVolume(int t=0, int percent=-1) | |||
197 | int vol = muted ? 0 : percent; | 202 | int vol = muted ? 0 : percent; |
198 | // set both channels to same volume | 203 | // set both channels to same volume |
199 | vol |= vol << 8; | 204 | vol |= vol << 8; |
200 | ioctl(fd, MIXER_WRITE(0), &vol); | 205 | ioctl(fd, MIXER_WRITE(0), &vol); |
201 | ::close(fd); | 206 | ::close(fd); |
202 | } | 207 | } |
203 | } break; | 208 | } |
209 | break; | ||
204 | } | 210 | } |
205 | } | 211 | } |
206 | 212 | ||
207 | static void setMic(int t=0, int percent=-1) | 213 | static void setMic(int t=0, int percent=-1) |
208 | { | 214 | { |
209 | switch (t) { | 215 | switch (t) { |
@@ -216,35 +222,39 @@ static void setMic(int t=0, int percent=-1) | |||
216 | int fd = 0; | 222 | int fd = 0; |
217 | int mic = micMuted ? 0 : percent; | 223 | int mic = micMuted ? 0 : percent; |
218 | if ((fd = open("/dev/mixer", O_RDWR))>=0) { | 224 | if ((fd = open("/dev/mixer", O_RDWR))>=0) { |
219 | ioctl(fd, MIXER_WRITE(SOUND_MIXER_MIC), &mic); | 225 | ioctl(fd, MIXER_WRITE(SOUND_MIXER_MIC), &mic); |
220 | ::close(fd); | 226 | ::close(fd); |
221 | } | 227 | } |
222 | } break; | 228 | } |
229 | break; | ||
223 | } | 230 | } |
224 | } | 231 | } |
225 | 232 | ||
226 | int qpe_sysBrightnessSteps() | 233 | int qpe_sysBrightnessSteps() |
227 | { | 234 | { |
228 | #if defined(QT_QWS_IPAQ) | 235 | #if defined(QT_QWS_IPAQ) |
229 | return 255; | 236 | return 255; |
230 | #elif defined(QT_QWS_EBX) | 237 | #elif defined(QT_QWS_EBX) |
238 | |||
231 | return 4; | 239 | return 4; |
232 | #else | 240 | #else |
241 | |||
233 | return 255; // ? | 242 | return 255; // ? |
234 | #endif | 243 | #endif |
235 | } | 244 | } |
236 | 245 | ||
237 | 246 | ||
238 | static int& hack(int& i) | 247 | static int& hack(int& i) |
239 | { | 248 | { |
240 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) | 249 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) |
241 | // These should be created, but aren't in Qt 2.3.0 | 250 | // These should be created, but aren't in Qt 2.3.0 |
242 | (void)new QUtf8Codec; | 251 | (void)new QUtf8Codec; |
243 | (void)new QUtf16Codec; | 252 | (void)new QUtf16Codec; |
244 | #endif | 253 | #endif |
254 | |||
245 | return i; | 255 | return i; |
246 | } | 256 | } |
247 | 257 | ||
248 | static bool forced_off = FALSE; | 258 | static bool forced_off = FALSE; |
249 | static int curbl=-1; | 259 | static int curbl=-1; |
250 | 260 | ||
@@ -283,36 +293,44 @@ static void setBacklight(int bright) | |||
283 | if ( QFile::exists("/usr/bin/bl") ) { | 293 | if ( QFile::exists("/usr/bin/bl") ) { |
284 | QString cmd = "/usr/bin/bl 1 "; | 294 | QString cmd = "/usr/bin/bl 1 "; |
285 | cmd += bright<=0 ? "0 " : "1 "; | 295 | cmd += bright<=0 ? "0 " : "1 "; |
286 | cmd += QString::number(bright); | 296 | cmd += QString::number(bright); |
287 | system(cmd.latin1()); | 297 | system(cmd.latin1()); |
288 | #if defined(QT_QWS_EBX) | 298 | #if defined(QT_QWS_EBX) |
289 | } else if ( QFile::exists("/dev/fl") ) { | 299 | |
300 | } | ||
301 | else if ( QFile::exists( "/dev/fl" ) ) { | ||
290 | #define FL_IOCTL_STEP_CONTRAST 100 | 302 | #define FL_IOCTL_STEP_CONTRAST 100 |
291 | int fd = open("/dev/fl", O_WRONLY); | 303 | int fd = open("/dev/fl", O_WRONLY); |
292 | if (fd >= 0 ) { | 304 | if (fd >= 0 ) { |
293 | int steps = qpe_sysBrightnessSteps(); | 305 | int steps = qpe_sysBrightnessSteps(); |
294 | int bl = ( bright * steps + 127 ) / 255; | 306 | int bl = ( bright * steps + 127 ) / 255; |
295 | if ( bright && !bl ) bl = 1; | 307 | if ( bright && !bl ) |
308 | bl = 1; | ||
296 | bl = ioctl(fd, FL_IOCTL_STEP_CONTRAST, bl); | 309 | bl = ioctl(fd, FL_IOCTL_STEP_CONTRAST, bl); |
297 | close(fd); | 310 | close(fd); |
298 | } | 311 | } |
299 | } | 312 | } |
300 | #elif defined(QT_QWS_IPAQ) | 313 | #elif defined(QT_QWS_IPAQ) |
301 | } else if ( QFile::exists("/dev/ts") || QFile::exists("/dev/h3600_ts") ) { | 314 | |
315 | } | ||
316 | else if ( QFile::exists( "/dev/ts" ) || QFile::exists( "/dev/h3600_ts" ) ) | ||
317 | { | ||
302 | typedef struct { | 318 | typedef struct { |
303 | unsigned char mode; | 319 | unsigned char mode; |
304 | unsigned char pwr; | 320 | unsigned char pwr; |
305 | unsigned char brightness; | 321 | unsigned char brightness; |
306 | } FLITE_IN; | 322 | } |
323 | FLITE_IN; | ||
307 | # ifndef FLITE_ON | 324 | # ifndef FLITE_ON |
308 | # ifndef _LINUX_IOCTL_H | 325 | # ifndef _LINUX_IOCTL_H |
309 | # include <linux/ioctl.h> | 326 | # include <linux/ioctl.h> |
310 | # endif | 327 | # endif |
311 | # define FLITE_ON _IOW('f', 7, FLITE_IN) | 328 | # define FLITE_ON _IOW('f', 7, FLITE_IN) |
312 | # endif | 329 | # endif |
330 | |||
313 | int fd; | 331 | int fd; |
314 | if ( QFile::exists("/dev/ts") ) | 332 | if ( QFile::exists("/dev/ts") ) |
315 | fd = open("/dev/ts", O_WRONLY); | 333 | fd = open("/dev/ts", O_WRONLY); |
316 | else | 334 | else |
317 | fd = open("/dev/h3600_ts", O_WRONLY); | 335 | fd = open("/dev/h3600_ts", O_WRONLY); |
318 | if (fd >= 0 ) { | 336 | if (fd >= 0 ) { |
@@ -326,13 +344,15 @@ static void setBacklight(int bright) | |||
326 | } | 344 | } |
327 | #endif | 345 | #endif |
328 | #endif | 346 | #endif |
329 | curbl = bright; | 347 | curbl = bright; |
330 | } | 348 | } |
331 | 349 | ||
332 | void qpe_setBacklight(int bright) { setBacklight(bright); } | 350 | void qpe_setBacklight( int bright ) { |
351 | setBacklight( bright ); | ||
352 | } | ||
333 | 353 | ||
334 | static bool dim_on = FALSE; | 354 | static bool dim_on = FALSE; |
335 | static bool lightoff_on = FALSE; | 355 | static bool lightoff_on = FALSE; |
336 | static int disable_suspend = 100; | 356 | static int disable_suspend = 100; |
337 | 357 | ||
338 | static bool powerOnline() | 358 | static bool powerOnline() |
@@ -355,21 +375,28 @@ public: | |||
355 | { | 375 | { |
356 | int fd; | 376 | int fd; |
357 | 377 | ||
358 | LcdOn = TRUE; | 378 | LcdOn = TRUE; |
359 | // Make sure the LCD is in fact on, (if opie was killed while the LCD is off it would still be off) | 379 | // Make sure the LCD is in fact on, (if opie was killed while the LCD is off it would still be off) |
360 | fd=open("/dev/fb0",O_RDWR); | 380 | fd=open("/dev/fb0",O_RDWR); |
361 | if (fd != -1) { ioctl(fd,FBIOBLANK,VESA_NO_BLANKING); close(fd); } | 381 | if ( fd != -1 ) { |
382 | ioctl( fd, FBIOBLANK, VESA_NO_BLANKING ); | ||
383 | close( fd ); | ||
384 | } | ||
362 | } | 385 | } |
363 | void restore() | 386 | void restore() |
364 | { | 387 | { |
365 | if (!LcdOn) // We must have turned it off | 388 | if (!LcdOn) // We must have turned it off |
366 | { | 389 | { |
367 | int fd; | 390 | int fd; |
368 | fd=open("/dev/fb0",O_RDWR); | 391 | fd=open("/dev/fb0",O_RDWR); |
369 | if (fd != -1) { ioctl(fd,FBIOBLANK,VESA_NO_BLANKING); close(fd); } | 392 | if ( fd != -1 ) |
393 | { | ||
394 | ioctl( fd, FBIOBLANK, VESA_NO_BLANKING ); | ||
395 | close( fd ); | ||
396 | } | ||
370 | } | 397 | } |
371 | setBacklight(-1); | 398 | setBacklight(-1); |
372 | } | 399 | } |
373 | bool save(int level) | 400 | bool save(int level) |
374 | { | 401 | { |
375 | int fd; | 402 | int fd; |
@@ -391,13 +418,17 @@ public: | |||
391 | case 2: | 418 | case 2: |
392 | Config config( "qpe" ); | 419 | Config config( "qpe" ); |
393 | config.setGroup( "Screensaver" ); | 420 | config.setGroup( "Screensaver" ); |
394 | if (config.readNumEntry("LcdOffOnly",0) != 0) // We're only turning off the LCD | 421 | if (config.readNumEntry("LcdOffOnly",0) != 0) // We're only turning off the LCD |
395 | { | 422 | { |
396 | fd=open("/dev/fb0",O_RDWR); | 423 | fd=open("/dev/fb0",O_RDWR); |
397 | if (fd != -1) { ioctl(fd,FBIOBLANK,VESA_POWERDOWN); close(fd); } | 424 | if ( fd != -1 ) |
425 | { | ||
426 | ioctl( fd, FBIOBLANK, VESA_POWERDOWN ); | ||
427 | close( fd ); | ||
428 | } | ||
398 | LcdOn = FALSE; | 429 | LcdOn = FALSE; |
399 | } | 430 | } |
400 | else // We're going to suspend the whole machine | 431 | else // We're going to suspend the whole machine |
401 | { | 432 | { |
402 | if ( disable_suspend > 2 && !powerOnline() && !networkOnline() ) { | 433 | if ( disable_suspend > 2 && !powerOnline() && !networkOnline() ) { |
403 | QWSServer::sendKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE ); | 434 | QWSServer::sendKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE ); |
@@ -569,13 +600,14 @@ QPEApplication::QPEApplication( int& argc, char **argv, Type t ) | |||
569 | for (int a=0; a<argc; a++) { | 600 | for (int a=0; a<argc; a++) { |
570 | if ( qstrcmp(argv[a],"-preload")==0 ) { | 601 | if ( qstrcmp(argv[a],"-preload")==0 ) { |
571 | argv[a] = argv[a+1]; | 602 | argv[a] = argv[a+1]; |
572 | a++; | 603 | a++; |
573 | d->preloaded = TRUE; | 604 | d->preloaded = TRUE; |
574 | argc-=1; | 605 | argc-=1; |
575 | } else if ( qstrcmp(argv[a],"-preload-show")==0 ) { | 606 | } |
607 | else if ( qstrcmp( argv[ a ], "-preload-show" ) == 0 ) { | ||
576 | argv[a] = argv[a+1]; | 608 | argv[a] = argv[a+1]; |
577 | a++; | 609 | a++; |
578 | d->preloaded = TRUE; | 610 | d->preloaded = TRUE; |
579 | d->forceshow = TRUE; | 611 | d->forceshow = TRUE; |
580 | argc-=1; | 612 | argc-=1; |
581 | } | 613 | } |
@@ -586,12 +618,13 @@ QPEApplication::QPEApplication( int& argc, char **argv, Type t ) | |||
586 | 618 | ||
587 | #endif | 619 | #endif |
588 | 620 | ||
589 | qwsSetDecoration( new QPEDecoration() ); | 621 | qwsSetDecoration( new QPEDecoration() ); |
590 | 622 | ||
591 | #ifndef QT_NO_TRANSLATION | 623 | #ifndef QT_NO_TRANSLATION |
624 | |||
592 | QStringList langs = Global::languageList(); | 625 | QStringList langs = Global::languageList(); |
593 | for (QStringList::ConstIterator it = langs.begin(); it!=langs.end(); ++it) { | 626 | for (QStringList::ConstIterator it = langs.begin(); it!=langs.end(); ++it) { |
594 | QString lang = *it; | 627 | QString lang = *it; |
595 | 628 | ||
596 | QTranslator * trans; | 629 | QTranslator * trans; |
597 | QString tfn; | 630 | QString tfn; |
@@ -685,23 +718,31 @@ QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget* w ) | |||
685 | \sa inputMethodHint() | 718 | \sa inputMethodHint() |
686 | */ | 719 | */ |
687 | void QPEApplication::setInputMethodHint( QWidget* w, InputMethodHint mode ) | 720 | void QPEApplication::setInputMethodHint( QWidget* w, InputMethodHint mode ) |
688 | { | 721 | { |
689 | createInputMethodDict(); | 722 | createInputMethodDict(); |
690 | if ( mode == Normal ) { | 723 | if ( mode == Normal ) { |
691 | inputMethodDict->remove(w); | 724 | inputMethodDict->remove |
692 | } else { | 725 | ( w ); |
726 | } | ||
727 | else { | ||
693 | inputMethodDict->insert(w,(void*)mode); | 728 | inputMethodDict->insert(w,(void*)mode); |
694 | } | 729 | } |
695 | } | 730 | } |
696 | 731 | ||
697 | class HackDialog : public QDialog | 732 | class HackDialog : public QDialog |
698 | { | 733 | { |
699 | public: | 734 | public: |
700 | void acceptIt() { accept(); } | 735 | void acceptIt() |
701 | void rejectIt() { reject(); } | 736 | { |
737 | accept(); | ||
738 | } | ||
739 | void rejectIt() | ||
740 | { | ||
741 | reject(); | ||
742 | } | ||
702 | }; | 743 | }; |
703 | 744 | ||
704 | 745 | ||
705 | void QPEApplication::mapToDefaultAction( QWSKeyEvent *ke, int key ) | 746 | void QPEApplication::mapToDefaultAction( QWSKeyEvent *ke, int key ) |
706 | { | 747 | { |
707 | // specialised actions for certain widgets. May want to | 748 | // specialised actions for certain widgets. May want to |
@@ -718,13 +759,15 @@ void QPEApplication::mapToDefaultAction( QWSKeyEvent *ke, int key ) | |||
718 | } | 759 | } |
719 | 760 | ||
720 | class HackWidget : public QWidget | 761 | class HackWidget : public QWidget |
721 | { | 762 | { |
722 | public: | 763 | public: |
723 | bool needsOk() | 764 | bool needsOk() |
724 | { return (getWState() & WState_Reserved1 ); } | 765 | { |
766 | return ( getWState() & WState_Reserved1 ); | ||
767 | } | ||
725 | }; | 768 | }; |
726 | 769 | ||
727 | /*! | 770 | /*! |
728 | \internal | 771 | \internal |
729 | */ | 772 | */ |
730 | bool QPEApplication::qwsEventFilter( QWSEvent *e ) | 773 | bool QPEApplication::qwsEventFilter( QWSEvent *e ) |
@@ -761,48 +804,54 @@ bool QPEApplication::qwsEventFilter( QWSEvent *e ) | |||
761 | if ( popup ) | 804 | if ( popup ) |
762 | popup->close(); | 805 | popup->close(); |
763 | if ( active->inherits( "QDialog" ) ) { | 806 | if ( active->inherits( "QDialog" ) ) { |
764 | HackDialog *d = (HackDialog *)active; | 807 | HackDialog *d = (HackDialog *)active; |
765 | d->acceptIt(); | 808 | d->acceptIt(); |
766 | return TRUE; | 809 | return TRUE; |
767 | } else if ( ((HackWidget *)active)->needsOk() ) { | 810 | } |
811 | else if ( ( ( HackWidget * ) active ) ->needsOk() ) { | ||
768 | QSignal s; | 812 | QSignal s; |
769 | s.connect( active, SLOT( accept() ) ); | 813 | s.connect( active, SLOT( accept() ) ); |
770 | s.activate(); | 814 | s.activate(); |
771 | } else { | 815 | } |
816 | else { | ||
772 | // do the same as with the select key: Map to the default action of the widget: | 817 | // do the same as with the select key: Map to the default action of the widget: |
773 | mapToDefaultAction( ke, Qt::Key_Return ); | 818 | mapToDefaultAction( ke, Qt::Key_Return ); |
774 | } | 819 | } |
775 | } | 820 | } |
776 | } | 821 | } |
777 | } else if ( ke->simpleData.keycode == Qt::Key_F30 ) { | 822 | } |
823 | else if ( ke->simpleData.keycode == Qt::Key_F30 ) { | ||
778 | // Use special "select" key to do whatever default action a widget has | 824 | // Use special "select" key to do whatever default action a widget has |
779 | mapToDefaultAction( ke, Qt::Key_Space ); | 825 | mapToDefaultAction( ke, Qt::Key_Space ); |
780 | } else if ( ke->simpleData.keycode == Qt::Key_Escape && | 826 | } |
827 | else if ( ke->simpleData.keycode == Qt::Key_Escape && | ||
781 | ke->simpleData.is_press ) { | 828 | ke->simpleData.is_press ) { |
782 | // Escape key closes app if focus on toplevel | 829 | // Escape key closes app if focus on toplevel |
783 | QWidget *active = activeWindow(); | 830 | QWidget *active = activeWindow(); |
784 | if ( active && active->testWFlags( WType_TopLevel ) && | 831 | if ( active && active->testWFlags( WType_TopLevel ) && |
785 | (int)active->winId() == ke->simpleData.window && | 832 | (int)active->winId() == ke->simpleData.window && |
786 | !active->testWFlags( WStyle_Dialog|WStyle_Customize|WType_Popup|WType_Desktop )) { | 833 | !active->testWFlags( WStyle_Dialog|WStyle_Customize|WType_Popup|WType_Desktop )) { |
787 | if ( active->inherits( "QDialog" ) ) { | 834 | if ( active->inherits( "QDialog" ) ) { |
788 | HackDialog *d = (HackDialog *)active; | 835 | HackDialog *d = (HackDialog *)active; |
789 | d->rejectIt(); | 836 | d->rejectIt(); |
790 | return TRUE; | 837 | return TRUE; |
791 | } else if ( strcmp( argv()[0], "embeddedkonsole") != 0 ) { | 838 | } |
839 | else if ( strcmp( argv() [ 0 ], "embeddedkonsole" ) != 0 ) { | ||
792 | active->close(); | 840 | active->close(); |
793 | } | 841 | } |
794 | } | 842 | } |
795 | } | 843 | } |
796 | 844 | ||
797 | #if QT_VERSION < 231 | 845 | #if QT_VERSION < 231 |
798 | // Filter out the F4/Launcher key from apps | 846 | // Filter out the F4/Launcher key from apps |
799 | // ### The launcher key may not always be F4 on all devices | 847 | // ### The launcher key may not always be F4 on all devices |
800 | if ( ((QWSKeyEvent *)e)->simpleData.keycode == Qt::Key_F4 ) | 848 | if ( ((QWSKeyEvent *)e)->simpleData.keycode == Qt::Key_F4 ) |
801 | return TRUE; | 849 | return TRUE; |
802 | #endif | 850 | #endif |
851 | |||
803 | } | 852 | } |
804 | if ( e->type == QWSEvent::Focus ) { | 853 | if ( e->type == QWSEvent::Focus ) { |
805 | QWSFocusEvent *fe = (QWSFocusEvent*)e; | 854 | QWSFocusEvent *fe = (QWSFocusEvent*)e; |
806 | QWidget* nfw = QWidget::find(e->window()); | 855 | QWidget* nfw = QWidget::find(e->window()); |
807 | if ( !fe->simpleData.get_focus ) { | 856 | if ( !fe->simpleData.get_focus ) { |
808 | QWidget *active = activeWindow(); | 857 | QWidget *active = activeWindow(); |
@@ -811,13 +860,14 @@ bool QPEApplication::qwsEventFilter( QWSEvent *e ) | |||
811 | active = activeWindow(); | 860 | active = activeWindow(); |
812 | } | 861 | } |
813 | if ( !nfw && d->kbgrabber == 2 ) { | 862 | if ( !nfw && d->kbgrabber == 2 ) { |
814 | ungrabKeyboard(); | 863 | ungrabKeyboard(); |
815 | d->kbregrab = TRUE; // want kb back when we're active | 864 | d->kbregrab = TRUE; // want kb back when we're active |
816 | } | 865 | } |
817 | } else { | 866 | } |
867 | else { | ||
818 | // make sure our modal widget is ALWAYS on top | 868 | // make sure our modal widget is ALWAYS on top |
819 | QWidget *topm = activeModalWidget(); | 869 | QWidget *topm = activeModalWidget(); |
820 | if ( topm ) { | 870 | if ( topm ) { |
821 | topm->raise(); | 871 | topm->raise(); |
822 | } | 872 | } |
823 | if ( d->kbregrab ) { | 873 | if ( d->kbregrab ) { |
@@ -845,12 +895,13 @@ QPEApplication::~QPEApplication() | |||
845 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 895 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
846 | // Need to delete QCopChannels early, since the display will | 896 | // Need to delete QCopChannels early, since the display will |
847 | // be gone by the time we get to ~QObject(). | 897 | // be gone by the time we get to ~QObject(). |
848 | delete sysChannel; | 898 | delete sysChannel; |
849 | delete pidChannel; | 899 | delete pidChannel; |
850 | #endif | 900 | #endif |
901 | |||
851 | delete d; | 902 | delete d; |
852 | } | 903 | } |
853 | 904 | ||
854 | /*! | 905 | /*! |
855 | Returns <tt>$OPIEDIR/</tt>. | 906 | Returns <tt>$OPIEDIR/</tt>. |
856 | */ | 907 | */ |
@@ -883,17 +934,20 @@ static int deforient=-1; | |||
883 | int QPEApplication::defaultRotation() | 934 | int QPEApplication::defaultRotation() |
884 | { | 935 | { |
885 | if ( deforient < 0 ) { | 936 | if ( deforient < 0 ) { |
886 | QString d = getenv("QWS_DISPLAY"); | 937 | QString d = getenv("QWS_DISPLAY"); |
887 | if ( d.contains("Rot90") ) { | 938 | if ( d.contains("Rot90") ) { |
888 | deforient = 90; | 939 | deforient = 90; |
889 | } else if ( d.contains("Rot180") ) { | 940 | } |
941 | else if ( d.contains( "Rot180" ) ) { | ||
890 | deforient = 180; | 942 | deforient = 180; |
891 | } else if ( d.contains("Rot270") ) { | 943 | } |
944 | else if ( d.contains( "Rot270" ) ) { | ||
892 | deforient = 270; | 945 | deforient = 270; |
893 | } else { | 946 | } |
947 | else { | ||
894 | deforient=0; | 948 | deforient=0; |
895 | } | 949 | } |
896 | } | 950 | } |
897 | return deforient; | 951 | return deforient; |
898 | } | 952 | } |
899 | 953 | ||
@@ -902,13 +956,14 @@ int QPEApplication::defaultRotation() | |||
902 | */ | 956 | */ |
903 | void QPEApplication::setDefaultRotation(int r) | 957 | void QPEApplication::setDefaultRotation(int r) |
904 | { | 958 | { |
905 | if ( qApp->type() == GuiServer ) { | 959 | if ( qApp->type() == GuiServer ) { |
906 | deforient = r; | 960 | deforient = r; |
907 | setenv("QWS_DISPLAY", QString("Transformed:Rot%1:0").arg(r).latin1(), 1); | 961 | setenv("QWS_DISPLAY", QString("Transformed:Rot%1:0").arg(r).latin1(), 1); |
908 | } else { | 962 | } |
963 | else { | ||
909 | QCopEnvelope("QPE/System", "setDefaultRotation(int)") << r; | 964 | QCopEnvelope("QPE/System", "setDefaultRotation(int)") << r; |
910 | } | 965 | } |
911 | } | 966 | } |
912 | 967 | ||
913 | /*! | 968 | /*! |
914 | \internal | 969 | \internal |
@@ -947,138 +1002,161 @@ void QPEApplication::applyStyle() | |||
947 | void QPEApplication::systemMessage( const QCString &msg, const QByteArray &data) | 1002 | void QPEApplication::systemMessage( const QCString &msg, const QByteArray &data) |
948 | { | 1003 | { |
949 | #ifdef Q_WS_QWS | 1004 | #ifdef Q_WS_QWS |
950 | QDataStream stream( data, IO_ReadOnly ); | 1005 | QDataStream stream( data, IO_ReadOnly ); |
951 | if ( msg == "applyStyle()" ) { | 1006 | if ( msg == "applyStyle()" ) { |
952 | applyStyle(); | 1007 | applyStyle(); |
953 | } else if ( msg == "setScreenSaverInterval(int)" ) { | 1008 | } |
1009 | else if ( msg == "setScreenSaverInterval(int)" ) { | ||
954 | if ( type() == GuiServer ) { | 1010 | if ( type() == GuiServer ) { |
955 | int time; | 1011 | int time; |
956 | stream >> time; | 1012 | stream >> time; |
957 | setScreenSaverInterval(time); | 1013 | setScreenSaverInterval(time); |
958 | } | 1014 | } |
959 | } else if ( msg == "setScreenSaverIntervals(int,int,int)" ) { | 1015 | } |
1016 | else if ( msg == "setScreenSaverIntervals(int,int,int)" ) { | ||
960 | if ( type() == GuiServer ) { | 1017 | if ( type() == GuiServer ) { |
961 | int t1,t2,t3; | 1018 | int t1,t2,t3; |
962 | stream >> t1 >> t2 >> t3; | 1019 | stream >> t1 >> t2 >> t3; |
963 | setScreenSaverIntervals(t1,t2,t3); | 1020 | setScreenSaverIntervals(t1,t2,t3); |
964 | } | 1021 | } |
965 | } else if ( msg == "setBacklight(int)" ) { | 1022 | } |
1023 | else if ( msg == "setBacklight(int)" ) { | ||
966 | if ( type() == GuiServer ) { | 1024 | if ( type() == GuiServer ) { |
967 | int bright; | 1025 | int bright; |
968 | stream >> bright; | 1026 | stream >> bright; |
969 | setBacklight(bright); | 1027 | setBacklight(bright); |
970 | } | 1028 | } |
971 | } else if ( msg == "setDefaultRotation(int)" ) { | 1029 | } |
1030 | else if ( msg == "setDefaultRotation(int)" ) { | ||
972 | if ( type() == GuiServer ) { | 1031 | if ( type() == GuiServer ) { |
973 | int r; | 1032 | int r; |
974 | stream >> r; | 1033 | stream >> r; |
975 | setDefaultRotation(r); | 1034 | setDefaultRotation(r); |
976 | } | 1035 | } |
977 | } else if ( msg == "shutdown()" ) { | 1036 | } |
1037 | else if ( msg == "shutdown()" ) { | ||
978 | if ( type() == GuiServer ) | 1038 | if ( type() == GuiServer ) |
979 | shutdown(); | 1039 | shutdown(); |
980 | } else if ( msg == "quit()" ) { | 1040 | } |
1041 | else if ( msg == "quit()" ) { | ||
981 | if ( type() != GuiServer ) | 1042 | if ( type() != GuiServer ) |
982 | tryQuit(); | 1043 | tryQuit(); |
983 | } else if ( msg == "forceQuit()" ) { | 1044 | } |
1045 | else if ( msg == "forceQuit()" ) { | ||
984 | if ( type() != GuiServer ) | 1046 | if ( type() != GuiServer ) |
985 | quit(); | 1047 | quit(); |
986 | } else if ( msg == "restart()" ) { | 1048 | } |
1049 | else if ( msg == "restart()" ) { | ||
987 | if ( type() == GuiServer ) | 1050 | if ( type() == GuiServer ) |
988 | restart(); | 1051 | restart(); |
989 | } else if ( msg == "grabKeyboard(QString)" ) { | 1052 | } |
1053 | else if ( msg == "grabKeyboard(QString)" ) { | ||
990 | QString who; | 1054 | QString who; |
991 | stream >> who; | 1055 | stream >> who; |
992 | if ( who.isEmpty() ) | 1056 | if ( who.isEmpty() ) |
993 | d->kbgrabber = 0; | 1057 | d->kbgrabber = 0; |
994 | else if ( who != d->appName ) | 1058 | else if ( who != d->appName ) |
995 | d->kbgrabber = 1; | 1059 | d->kbgrabber = 1; |
996 | else | 1060 | else |
997 | d->kbgrabber = 2; | 1061 | d->kbgrabber = 2; |
998 | } else if ( msg == "language(QString)" ) { | 1062 | } |
1063 | else if ( msg == "language(QString)" ) { | ||
999 | if ( type() == GuiServer ) { | 1064 | if ( type() == GuiServer ) { |
1000 | QString l; | 1065 | QString l; |
1001 | stream >> l; | 1066 | stream >> l; |
1002 | QString cl = getenv("LANG"); | 1067 | QString cl = getenv("LANG"); |
1003 | if ( cl != l ) { | 1068 | if ( cl != l ) { |
1004 | if ( l.isNull() ) | 1069 | if ( l.isNull() ) |
1005 | unsetenv( "LANG" ); | 1070 | unsetenv( "LANG" ); |
1006 | else | 1071 | else |
1007 | setenv( "LANG", l.latin1(), 1 ); | 1072 | setenv( "LANG", l.latin1(), 1 ); |
1008 | restart(); | 1073 | restart(); |
1009 | } | 1074 | } |
1010 | } | 1075 | } |
1011 | } else if ( msg == "timeChange(QString)" ) { | 1076 | } |
1077 | else if ( msg == "timeChange(QString)" ) { | ||
1012 | QString t; | 1078 | QString t; |
1013 | stream >> t; | 1079 | stream >> t; |
1014 | if ( t.isNull() ) | 1080 | if ( t.isNull() ) |
1015 | unsetenv( "TZ" ); | 1081 | unsetenv( "TZ" ); |
1016 | else | 1082 | else |
1017 | setenv( "TZ", t.latin1(), 1 ); | 1083 | setenv( "TZ", t.latin1(), 1 ); |
1018 | // emit the signal so everyone else knows... | 1084 | // emit the signal so everyone else knows... |
1019 | emit timeChanged(); | 1085 | emit timeChanged(); |
1020 | } else if ( msg == "execute(QString)" ) { | 1086 | } |
1087 | else if ( msg == "execute(QString)" ) { | ||
1021 | if ( type() == GuiServer ) { | 1088 | if ( type() == GuiServer ) { |
1022 | QString t; | 1089 | QString t; |
1023 | stream >> t; | 1090 | stream >> t; |
1024 | Global::execute( t ); | 1091 | Global::execute( t ); |
1025 | } | 1092 | } |
1026 | } else if ( msg == "execute(QString,QString)" ) { | 1093 | } |
1094 | else if ( msg == "execute(QString,QString)" ) { | ||
1027 | if ( type() == GuiServer ) { | 1095 | if ( type() == GuiServer ) { |
1028 | QString t,d; | 1096 | QString t,d; |
1029 | stream >> t >> d; | 1097 | stream >> t >> d; |
1030 | Global::execute( t, d ); | 1098 | Global::execute( t, d ); |
1031 | } | 1099 | } |
1032 | } else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) { | 1100 | } |
1101 | else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) { | ||
1033 | if ( type() == GuiServer ) { | 1102 | if ( type() == GuiServer ) { |
1034 | QDateTime when; | 1103 | QDateTime when; |
1035 | QCString channel, message; | 1104 | QCString channel, message; |
1036 | int data; | 1105 | int data; |
1037 | stream >> when >> channel >> message >> data; | 1106 | stream >> when >> channel >> message >> data; |
1038 | AlarmServer::addAlarm( when, channel, message, data ); | 1107 | AlarmServer::addAlarm( when, channel, message, data ); |
1039 | } | 1108 | } |
1040 | } else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) { | 1109 | } |
1110 | else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) { | ||
1041 | if ( type() == GuiServer ) { | 1111 | if ( type() == GuiServer ) { |
1042 | QDateTime when; | 1112 | QDateTime when; |
1043 | QCString channel, message; | 1113 | QCString channel, message; |
1044 | int data; | 1114 | int data; |
1045 | stream >> when >> channel >> message >> data; | 1115 | stream >> when >> channel >> message >> data; |
1046 | AlarmServer::deleteAlarm( when, channel, message, data ); | 1116 | AlarmServer::deleteAlarm( when, channel, message, data ); |
1047 | } | 1117 | } |
1048 | } else if ( msg == "clockChange(bool)" ) { | 1118 | } |
1119 | else if ( msg == "clockChange(bool)" ) { | ||
1049 | int tmp; | 1120 | int tmp; |
1050 | stream >> tmp; | 1121 | stream >> tmp; |
1051 | emit clockChanged( tmp ); | 1122 | emit clockChanged( tmp ); |
1052 | } else if ( msg == "weekChange(bool)" ) { | 1123 | } |
1124 | else if ( msg == "weekChange(bool)" ) { | ||
1053 | int tmp; | 1125 | int tmp; |
1054 | stream >> tmp; | 1126 | stream >> tmp; |
1055 | emit weekChanged( tmp ); | 1127 | emit weekChanged( tmp ); |
1056 | } else if ( msg == "setDateFormat(DateFormat)" ) { | 1128 | } |
1129 | else if ( msg == "setDateFormat(DateFormat)" ) { | ||
1057 | DateFormat tmp; | 1130 | DateFormat tmp; |
1058 | stream >> tmp; | 1131 | stream >> tmp; |
1059 | emit dateFormatChanged( tmp ); | 1132 | emit dateFormatChanged( tmp ); |
1060 | } else if ( msg == "setVolume(int,int)" ) { | 1133 | } |
1134 | else if ( msg == "setVolume(int,int)" ) { | ||
1061 | int t,v; | 1135 | int t,v; |
1062 | stream >> t >> v; | 1136 | stream >> t >> v; |
1063 | setVolume(t,v); | 1137 | setVolume(t,v); |
1064 | emit volumeChanged( muted ); | 1138 | emit volumeChanged( muted ); |
1065 | } else if ( msg == "volumeChange(bool)" ) { | 1139 | } |
1140 | else if ( msg == "volumeChange(bool)" ) { | ||
1066 | stream >> muted; | 1141 | stream >> muted; |
1067 | setVolume(); | 1142 | setVolume(); |
1068 | emit volumeChanged( muted ); | 1143 | emit volumeChanged( muted ); |
1069 | } else if ( msg == "setMic(int,int)") { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> | 1144 | } |
1145 | else if ( msg == "setMic(int,int)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> | ||
1070 | int t,v; | 1146 | int t,v; |
1071 | stream >> t >> v; | 1147 | stream >> t >> v; |
1072 | setMic(t,v); | 1148 | setMic(t,v); |
1073 | emit micChanged( micMuted ); | 1149 | emit micChanged( micMuted ); |
1074 | } else if ( msg == "micChange(bool)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> | 1150 | } |
1151 | else if ( msg == "micChange(bool)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> | ||
1075 | stream >> micMuted; | 1152 | stream >> micMuted; |
1076 | setMic(); | 1153 | setMic(); |
1077 | emit micChanged( micMuted ); | 1154 | emit micChanged( micMuted ); |
1078 | } else if ( msg == "setScreenSaverMode(int)" ) { | 1155 | } |
1156 | else if ( msg == "setScreenSaverMode(int)" ) { | ||
1079 | if ( type() == GuiServer ) { | 1157 | if ( type() == GuiServer ) { |
1080 | int old = disable_suspend; | 1158 | int old = disable_suspend; |
1081 | stream >> disable_suspend; | 1159 | stream >> disable_suspend; |
1082 | //qDebug("setScreenSaverMode(%d)", disable_suspend ); | 1160 | //qDebug("setScreenSaverMode(%d)", disable_suspend ); |
1083 | if ( disable_suspend > old ) | 1161 | if ( disable_suspend > old ) |
1084 | setScreenSaverInterval( -1 ); | 1162 | setScreenSaverInterval( -1 ); |
@@ -1093,21 +1171,24 @@ void QPEApplication::systemMessage( const QCString &msg, const QByteArray &data) | |||
1093 | bool QPEApplication::raiseAppropriateWindow() | 1171 | bool QPEApplication::raiseAppropriateWindow() |
1094 | { | 1172 | { |
1095 | bool r=FALSE; | 1173 | bool r=FALSE; |
1096 | // ########## raise()ing main window should raise and set active | 1174 | // ########## raise()ing main window should raise and set active |
1097 | // ########## it and then all childen. This belongs in Qt/Embedded | 1175 | // ########## it and then all childen. This belongs in Qt/Embedded |
1098 | QWidget *top = d->qpe_main_widget; | 1176 | QWidget *top = d->qpe_main_widget; |
1099 | if ( !top ) top =mainWidget(); | 1177 | if ( !top ) |
1178 | top = mainWidget(); | ||
1100 | if ( top && d->keep_running ) { | 1179 | if ( top && d->keep_running ) { |
1101 | if ( top->isVisible() ) | 1180 | if ( top->isVisible() ) |
1102 | r = TRUE; | 1181 | r = TRUE; |
1103 | #ifdef Q_WS_QWS | 1182 | #ifdef Q_WS_QWS |
1183 | |||
1104 | if ( !d->nomaximize ) | 1184 | if ( !d->nomaximize ) |
1105 | top->showMaximized(); | 1185 | top->showMaximized(); |
1106 | else | 1186 | else |
1107 | #endif | 1187 | #endif |
1188 | |||
1108 | top->show(); | 1189 | top->show(); |
1109 | top->raise(); | 1190 | top->raise(); |
1110 | top->setActiveWindow(); | 1191 | top->setActiveWindow(); |
1111 | } | 1192 | } |
1112 | QWidget *topm = activeModalWidget(); | 1193 | QWidget *topm = activeModalWidget(); |
1113 | if ( topm && topm != top ) { | 1194 | if ( topm && topm != top ) { |
@@ -1122,50 +1203,60 @@ bool QPEApplication::raiseAppropriateWindow() | |||
1122 | void QPEApplication::pidMessage( const QCString &msg, const QByteArray & data) | 1203 | void QPEApplication::pidMessage( const QCString &msg, const QByteArray & data) |
1123 | { | 1204 | { |
1124 | #ifdef Q_WS_QWS | 1205 | #ifdef Q_WS_QWS |
1125 | 1206 | ||
1126 | if ( msg == "quit()" ) { | 1207 | if ( msg == "quit()" ) { |
1127 | tryQuit(); | 1208 | tryQuit(); |
1128 | } else if ( msg == "quitIfInvisible()" ) { | 1209 | } |
1210 | else if ( msg == "quitIfInvisible()" ) { | ||
1129 | if ( d->qpe_main_widget && !d->qpe_main_widget->isVisible() ) | 1211 | if ( d->qpe_main_widget && !d->qpe_main_widget->isVisible() ) |
1130 | quit(); | 1212 | quit(); |
1131 | } else if ( msg == "close()" ) { | 1213 | } |
1214 | else if ( msg == "close()" ) { | ||
1132 | hideOrQuit(); | 1215 | hideOrQuit(); |
1133 | } else if ( msg == "disablePreload()" ) { | 1216 | } |
1217 | else if ( msg == "disablePreload()" ) { | ||
1134 | d->preloaded = FALSE; | 1218 | d->preloaded = FALSE; |
1135 | d->keep_running = TRUE; | 1219 | d->keep_running = TRUE; |
1136 | /* so that quit will quit */ | 1220 | /* so that quit will quit */ |
1137 | } else if ( msg == "enablePreload()" ) { | 1221 | } |
1222 | else if ( msg == "enablePreload()" ) { | ||
1138 | d->preloaded = TRUE; | 1223 | d->preloaded = TRUE; |
1139 | d->keep_running = TRUE; | 1224 | d->keep_running = TRUE; |
1140 | /* so next quit won't quit */ | 1225 | /* so next quit won't quit */ |
1141 | } else if ( msg == "raise()" ) { | 1226 | } |
1227 | else if ( msg == "raise()" ) { | ||
1142 | d->keep_running = TRUE; | 1228 | d->keep_running = TRUE; |
1143 | d->notbusysent = FALSE; | 1229 | d->notbusysent = FALSE; |
1144 | raiseAppropriateWindow(); | 1230 | raiseAppropriateWindow(); |
1145 | } else if ( msg == "flush()" ) { | 1231 | } |
1232 | else if ( msg == "flush()" ) { | ||
1146 | emit flush(); | 1233 | emit flush(); |
1147 | // we need to tell the desktop | 1234 | // we need to tell the desktop |
1148 | QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" ); | 1235 | QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" ); |
1149 | e << d->appName; | 1236 | e << d->appName; |
1150 | } else if ( msg == "reload()" ) { | 1237 | } |
1238 | else if ( msg == "reload()" ) { | ||
1151 | emit reload(); | 1239 | emit reload(); |
1152 | } else if ( msg == "setDocument(QString)" ) { | 1240 | } |
1241 | else if ( msg == "setDocument(QString)" ) { | ||
1153 | d->keep_running = TRUE; | 1242 | d->keep_running = TRUE; |
1154 | QDataStream stream( data, IO_ReadOnly ); | 1243 | QDataStream stream( data, IO_ReadOnly ); |
1155 | QString doc; | 1244 | QString doc; |
1156 | stream >> doc; | 1245 | stream >> doc; |
1157 | QWidget *mw = mainWidget(); | 1246 | QWidget *mw = mainWidget(); |
1158 | if ( !mw ) | 1247 | if ( !mw ) |
1159 | mw = d->qpe_main_widget; | 1248 | mw = d->qpe_main_widget; |
1160 | if ( mw ) | 1249 | if ( mw ) |
1161 | Global::setDocument( mw, doc ); | 1250 | Global::setDocument( mw, doc ); |
1162 | } else if ( msg == "nextView()" ) { | 1251 | } |
1252 | else if ( msg == "nextView()" ) { | ||
1163 | if ( raiseAppropriateWindow() ) | 1253 | if ( raiseAppropriateWindow() ) |
1164 | emit appMessage( msg, data); | 1254 | emit appMessage( msg, data); |
1165 | } else { | 1255 | } |
1256 | else { | ||
1166 | emit appMessage( msg, data); | 1257 | emit appMessage( msg, data); |
1167 | } | 1258 | } |
1168 | #endif | 1259 | #endif |
1169 | } | 1260 | } |
1170 | 1261 | ||
1171 | 1262 | ||
@@ -1210,20 +1301,23 @@ void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize ) | |||
1210 | if(d->forceshow) { | 1301 | if(d->forceshow) { |
1211 | #ifdef Q_WS_QWS | 1302 | #ifdef Q_WS_QWS |
1212 | if ( !nomaximize ) | 1303 | if ( !nomaximize ) |
1213 | mw->showMaximized(); | 1304 | mw->showMaximized(); |
1214 | else | 1305 | else |
1215 | #endif | 1306 | #endif |
1307 | |||
1216 | mw->show(); | 1308 | mw->show(); |
1217 | } | 1309 | } |
1218 | } else if ( d->keep_running ) { | 1310 | } |
1311 | else if ( d->keep_running ) { | ||
1219 | #ifdef Q_WS_QWS | 1312 | #ifdef Q_WS_QWS |
1220 | if ( !nomaximize ) | 1313 | if ( !nomaximize ) |
1221 | mw->showMaximized(); | 1314 | mw->showMaximized(); |
1222 | else | 1315 | else |
1223 | #endif | 1316 | #endif |
1317 | |||
1224 | mw->show(); | 1318 | mw->show(); |
1225 | } | 1319 | } |
1226 | } | 1320 | } |
1227 | 1321 | ||
1228 | /*! | 1322 | /*! |
1229 | Sets \a mw as the mainWidget() and shows it. For small windows, | 1323 | Sets \a mw as the mainWidget() and shows it. For small windows, |
@@ -1249,20 +1343,23 @@ void QPEApplication::showMainDocumentWidget( QWidget* mw, bool nomaximize ) | |||
1249 | if(d->forceshow) { | 1343 | if(d->forceshow) { |
1250 | #ifdef Q_WS_QWS | 1344 | #ifdef Q_WS_QWS |
1251 | if ( !nomaximize ) | 1345 | if ( !nomaximize ) |
1252 | mw->showMaximized(); | 1346 | mw->showMaximized(); |
1253 | else | 1347 | else |
1254 | #endif | 1348 | #endif |
1349 | |||
1255 | mw->show(); | 1350 | mw->show(); |
1256 | } | 1351 | } |
1257 | } else if ( d->keep_running ) { | 1352 | } |
1353 | else if ( d->keep_running ) { | ||
1258 | #ifdef Q_WS_QWS | 1354 | #ifdef Q_WS_QWS |
1259 | if ( !nomaximize ) | 1355 | if ( !nomaximize ) |
1260 | mw->showMaximized(); | 1356 | mw->showMaximized(); |
1261 | else | 1357 | else |
1262 | #endif | 1358 | #endif |
1359 | |||
1263 | mw->show(); | 1360 | mw->show(); |
1264 | } | 1361 | } |
1265 | } | 1362 | } |
1266 | 1363 | ||
1267 | 1364 | ||
1268 | /*! | 1365 | /*! |
@@ -1298,22 +1395,26 @@ bool QPEApplication::keepRunning() const | |||
1298 | */ | 1395 | */ |
1299 | void QPEApplication::internalSetStyle( const QString &style ) | 1396 | void QPEApplication::internalSetStyle( const QString &style ) |
1300 | { | 1397 | { |
1301 | #if QT_VERSION >= 300 | 1398 | #if QT_VERSION >= 300 |
1302 | if ( style == "QPE" ) { | 1399 | if ( style == "QPE" ) { |
1303 | setStyle( new QPEStyle ); | 1400 | setStyle( new QPEStyle ); |
1304 | } else { | 1401 | } |
1402 | else { | ||
1305 | QStyle *s = QStyleFactory::create(style); | 1403 | QStyle *s = QStyleFactory::create(style); |
1306 | if ( s ) setStyle(s); | 1404 | if ( s ) |
1405 | setStyle( s ); | ||
1307 | } | 1406 | } |
1308 | #else | 1407 | #else |
1309 | if ( style == "Windows" ) { | 1408 | if ( style == "Windows" ) { |
1310 | setStyle( new QWindowsStyle ); | 1409 | setStyle( new QWindowsStyle ); |
1311 | } else if ( style == "QPE" ) { | 1410 | } |
1411 | else if ( style == "QPE" ) { | ||
1312 | setStyle( new QPEStyle ); | 1412 | setStyle( new QPEStyle ); |
1313 | } else if ( style == "Light" ) { | 1413 | } |
1414 | else if ( style == "Light" ) { | ||
1314 | setStyle( new LightStyle ); | 1415 | setStyle( new LightStyle ); |
1315 | } | 1416 | } |
1316 | #ifndef QT_NO_STYLE_PLATINUM | 1417 | #ifndef QT_NO_STYLE_PLATINUM |
1317 | else if ( style == "Platinum" ) { | 1418 | else if ( style == "Platinum" ) { |
1318 | setStyle( new QPlatinumStyle ); | 1419 | setStyle( new QPlatinumStyle ); |
1319 | } | 1420 | } |
@@ -1328,59 +1429,92 @@ void QPEApplication::internalSetStyle( const QString &style ) | |||
1328 | setStyle( new QMotifPlusStyle ); | 1429 | setStyle( new QMotifPlusStyle ); |
1329 | } | 1430 | } |
1330 | #endif | 1431 | #endif |
1331 | 1432 | ||
1332 | // HACK for Qt2 only | 1433 | // HACK for Qt2 only |
1333 | else { | 1434 | else { |
1435 | QStyle *sty = 0; | ||
1436 | QString path = QPEApplication::qpeDir ( ) + "/plugins/styles/lib" + style. lower ( ) + ".so"; | ||
1437 | |||
1438 | static QLibrary *lastlib = 0; | ||
1439 | static StyleInterface *lastiface = 0; | ||
1440 | |||
1441 | QLibrary *lib = new QLibrary ( path ); | ||
1442 | StyleInterface *iface = 0; | ||
1443 | |||
1444 | if ( lib-> queryInterface ( IID_Style, ( QUnknownInterface ** ) &iface ) == QS_OK ) | ||
1445 | sty = iface-> create ( ); | ||
1446 | |||
1447 | if ( sty ) { | ||
1448 | setStyle ( sty ); | ||
1449 | |||
1450 | qDebug ( "Got Style: %p -- iface: %p, lib: %p\n", sty, iface, lib ); | ||
1451 | |||
1452 | if ( lastiface ) | ||
1453 | lastiface-> release ( ); | ||
1454 | lastiface = iface; | ||
1455 | |||
1456 | |||
1457 | if ( lastlib ) { | ||
1458 | lastlib-> unload ( ); | ||
1459 | delete lastlib; | ||
1460 | } | ||
1461 | lastlib = lib; | ||
1462 | } | ||
1463 | else { | ||
1464 | if ( iface ) | ||
1465 | iface-> release ( ); | ||
1466 | delete lib; | ||
1467 | |||
1468 | setStyle ( new QPEStyle ( )); | ||
1469 | } | ||
1470 | |||
1471 | #if 0 | ||
1334 | // style == "Liquid Style (libliquid.so)" (or "Windows XP (libxp.so)" | 1472 | // style == "Liquid Style (libliquid.so)" (or "Windows XP (libxp.so)" |
1335 | 1473 | ||
1336 | int p2 = style. findRev ( ']' ); | 1474 | int p2 = style. findRev ( ']' ); |
1337 | int p1 = style. findRev ( '[' ); | 1475 | int p1 = style. findRev ( '[' ); |
1338 | QString style2; | 1476 | QString style2; |
1339 | 1477 | ||
1340 | if (( p1 > 0 ) && ( p2 > 0 ) && (( p1 + 1 ) < p2 )) | 1478 | if (( p1 > 0 ) && ( p2 > 0 ) && (( p1 + 1 ) < p2 )) |
1341 | style2 = "lib" + style. mid ( p1 + 1, p2 - p1 - 1 ). lower ( ) + ".so"; | 1479 | style2 = "lib" + style. mid ( p1 + 1, p2 - p1 - 1 ). lower ( ) + ".so"; |
1342 | else | 1480 | else |
1343 | style2 = "lib" + style. lower ( ) + ".so"; | 1481 | style2 = "lib" + style. lower ( ) + ".so"; |
1344 | 1482 | ||
1345 | // static QLibrary *currentlib = 0; | 1483 | static QLibrary *currentlib = 0; |
1346 | static void *currentlib = 0; | ||
1347 | 1484 | ||
1348 | QString path = QPEApplication::qpeDir ( ) + "/plugins/styles/" + style2; | 1485 | QString path = QPEApplication::qpeDir ( ) + "/plugins/styles/" + style2; |
1349 | 1486 | ||
1350 | do { // try/catch simulation | 1487 | do { // try/catch simulation |
1351 | // QLibrary *lib = new QLibrary ( path, QLibrary::Immediately ); | 1488 | QLibrary *lib = new QLibrary ( path, QLibrary::Immediately ); |
1352 | void *lib = ::dlopen ( path. local8Bit ( ), RTLD_LAZY | RTLD_GLOBAL ); | ||
1353 | 1489 | ||
1354 | if ( lib ) { | 1490 | if ( lib ) { |
1355 | //QStyle * (*fpa) ( ) = (QStyle * (*) ( )) lib-> resolve ( "allocate" ); | 1491 | QStyle * ( *fpa ) ( ) = ( QStyle * ( * ) ( ) ) lib-> resolve ( "allocate" ); |
1356 | QStyle * (*fpa) ( ) = (QStyle * (*) ( )) ::dlsym ( lib, "allocate" ); | ||
1357 | 1492 | ||
1358 | if ( fpa ) { | 1493 | if ( fpa ) { |
1359 | QStyle *sty = ( *fpa ) ( ); | 1494 | QStyle *sty = ( *fpa ) ( ); |
1360 | 1495 | ||
1361 | if ( sty ) { | 1496 | if ( sty ) { |
1362 | setStyle ( sty ); | 1497 | setStyle ( sty ); |
1363 | 1498 | ||
1364 | if ( currentlib ) { | 1499 | if ( currentlib ) |
1365 | //delete currentlib; | 1500 | delete currentlib; |
1366 | ::dlclose ( currentlib ); | ||
1367 | } | ||
1368 | currentlib = lib; | 1501 | currentlib = lib; |
1369 | 1502 | ||
1370 | break; | 1503 | break; |
1371 | } | 1504 | } |
1372 | } | 1505 | } |
1373 | //delete lib; | 1506 | delete lib; |
1374 | ::dlclose ( lib ); | ||
1375 | } | 1507 | } |
1376 | } while ( false ); | ||
1377 | } | 1508 | } |
1509 | while ( false ); | ||
1378 | // HACK for Qt2 only | 1510 | // HACK for Qt2 only |
1379 | #endif | 1511 | #endif |
1380 | } | 1512 | } |
1513 | #endif | ||
1514 | } | ||
1381 | 1515 | ||
1382 | /*! | 1516 | /*! |
1383 | \internal | 1517 | \internal |
1384 | */ | 1518 | */ |
1385 | void QPEApplication::prepareForTermination(bool willrestart) | 1519 | void QPEApplication::prepareForTermination(bool willrestart) |
1386 | { | 1520 | { |
@@ -1395,13 +1529,14 @@ void QPEApplication::prepareForTermination(bool willrestart) | |||
1395 | lblWait->setPixmap( pix ); | 1529 | lblWait->setPixmap( pix ); |
1396 | lblWait->setAlignment( QWidget::AlignCenter ); | 1530 | lblWait->setAlignment( QWidget::AlignCenter ); |
1397 | lblWait->show(); | 1531 | lblWait->show(); |
1398 | lblWait->showMaximized(); | 1532 | lblWait->showMaximized(); |
1399 | } | 1533 | } |
1400 | #ifndef SINGLE_APP | 1534 | #ifndef SINGLE_APP |
1401 | { QCopEnvelope envelope("QPE/System", "forceQuit()"); } | 1535 | { QCopEnvelope envelope( "QPE/System", "forceQuit()" ); |
1536 | } | ||
1402 | processEvents(); // ensure the message goes out. | 1537 | processEvents(); // ensure the message goes out. |
1403 | sleep(1); // You have 1 second to comply. | 1538 | sleep(1); // You have 1 second to comply. |
1404 | #endif | 1539 | #endif |
1405 | } | 1540 | } |
1406 | 1541 | ||
1407 | /*! | 1542 | /*! |
@@ -1456,15 +1591,17 @@ QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w ) | |||
1456 | \sa stylusOperation() | 1591 | \sa stylusOperation() |
1457 | */ | 1592 | */ |
1458 | void QPEApplication::setStylusOperation( QWidget* w, StylusMode mode ) | 1593 | void QPEApplication::setStylusOperation( QWidget* w, StylusMode mode ) |
1459 | { | 1594 | { |
1460 | createDict(); | 1595 | createDict(); |
1461 | if ( mode == LeftOnly ) { | 1596 | if ( mode == LeftOnly ) { |
1462 | stylusDict->remove(w); | 1597 | stylusDict->remove |
1598 | ( w ); | ||
1463 | w->removeEventFilter(qApp); | 1599 | w->removeEventFilter(qApp); |
1464 | } else { | 1600 | } |
1601 | else { | ||
1465 | stylusDict->insert(w,(void*)mode); | 1602 | stylusDict->insert(w,(void*)mode); |
1466 | connect(w,SIGNAL(destroyed()),qApp,SLOT(removeSenderFromStylusDict())); | 1603 | connect(w,SIGNAL(destroyed()),qApp,SLOT(removeSenderFromStylusDict())); |
1467 | w->installEventFilter(qApp); | 1604 | w->installEventFilter(qApp); |
1468 | } | 1605 | } |
1469 | } | 1606 | } |
1470 | 1607 | ||
@@ -1513,13 +1650,14 @@ bool QPEApplication::eventFilter( QObject *o, QEvent *e ) | |||
1513 | } | 1650 | } |
1514 | break; | 1651 | break; |
1515 | default: | 1652 | default: |
1516 | ; | 1653 | ; |
1517 | } | 1654 | } |
1518 | } | 1655 | } |
1519 | } else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { | 1656 | } |
1657 | else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { | ||
1520 | QKeyEvent *ke = (QKeyEvent *)e; | 1658 | QKeyEvent *ke = (QKeyEvent *)e; |
1521 | if ( ke->key() == Key_Enter ) { | 1659 | if ( ke->key() == Key_Enter ) { |
1522 | if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) { | 1660 | if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) { |
1523 | postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ', | 1661 | postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ', |
1524 | ke->state(), " ", ke->isAutoRepeat(), ke->count() ) ); | 1662 | ke->state(), " ", ke->isAutoRepeat(), ke->count() ) ); |
1525 | return TRUE; | 1663 | return TRUE; |
@@ -1545,13 +1683,14 @@ void QPEApplication::timerEvent( QTimerEvent *e ) | |||
1545 | d->rightpressed = TRUE; | 1683 | d->rightpressed = TRUE; |
1546 | } | 1684 | } |
1547 | } | 1685 | } |
1548 | 1686 | ||
1549 | void QPEApplication::removeSenderFromStylusDict() | 1687 | void QPEApplication::removeSenderFromStylusDict() |
1550 | { | 1688 | { |
1551 | stylusDict->remove((void*)sender()); | 1689 | stylusDict->remove |
1690 | ( ( void* ) sender() ); | ||
1552 | if ( d->presswidget == sender() ) | 1691 | if ( d->presswidget == sender() ) |
1553 | d->presswidget = 0; | 1692 | d->presswidget = 0; |
1554 | } | 1693 | } |
1555 | 1694 | ||
1556 | /*! | 1695 | /*! |
1557 | \internal | 1696 | \internal |
@@ -1701,14 +1840,13 @@ void qt_setMaxWindowRect(const QRect& r) | |||
1701 | qt_screen->mapToDevice(QSize(qt_screen->width(),qt_screen->height()))); | 1840 | qt_screen->mapToDevice(QSize(qt_screen->width(),qt_screen->height()))); |
1702 | // Re-resize any maximized windows | 1841 | // Re-resize any maximized windows |
1703 | QWidgetList* l = QApplication::topLevelWidgets(); | 1842 | QWidgetList* l = QApplication::topLevelWidgets(); |
1704 | if ( l ) { | 1843 | if ( l ) { |
1705 | QWidget *w = l->first(); | 1844 | QWidget *w = l->first(); |
1706 | while ( w ) { | 1845 | while ( w ) { |
1707 | if ( w->isVisible() && w->isMaximized() ) | 1846 | if ( w->isVisible() && w->isMaximized() ) { |
1708 | { | ||
1709 | w->showMaximized(); | 1847 | w->showMaximized(); |
1710 | } | 1848 | } |
1711 | w = l->next(); | 1849 | w = l->next(); |
1712 | } | 1850 | } |
1713 | delete l; | 1851 | delete l; |
1714 | } | 1852 | } |