-rw-r--r-- | library/qpeapplication.cpp | 152 |
1 files changed, 125 insertions, 27 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp index d1a7cd2..b1b7ed4 100644 --- a/library/qpeapplication.cpp +++ b/library/qpeapplication.cpp | |||
@@ -6,96 +6,99 @@ | |||
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | ** $Id$ | 19 | ** $Id$ |
20 | ** | 20 | ** |
21 | **********************************************************************/ | 21 | **********************************************************************/ |
22 | #define QTOPIA_INTERNAL_LANGLIST | 22 | #define QTOPIA_INTERNAL_LANGLIST |
23 | #include <stdlib.h> | 23 | #include <stdlib.h> |
24 | #include <unistd.h> | 24 | #include <unistd.h> |
25 | #include <linux/limits.h> // needed for some toolchains (PATH_MAX) | 25 | #include <linux/limits.h> // needed for some toolchains (PATH_MAX) |
26 | #include <qfile.h> | 26 | #include <qfile.h> |
27 | #ifdef Q_WS_QWS | 27 | #ifdef Q_WS_QWS |
28 | #ifndef QT_NO_COP | 28 | #ifndef QT_NO_COP |
29 | #if QT_VERSION <= 231 | 29 | #if QT_VERSION <= 231 |
30 | #define private public | 30 | #define private public |
31 | #define sendLocally processEvent | 31 | #define sendLocally processEvent |
32 | #include "qcopenvelope_qws.h" | 32 | #include "qcopenvelope_qws.h" |
33 | #undef private | 33 | #undef private |
34 | #else | 34 | #else |
35 | #include "qcopenvelope_qws.h" | 35 | #include "qcopenvelope_qws.h" |
36 | #endif | 36 | #endif |
37 | #endif | 37 | #endif |
38 | #include <qwindowsystem_qws.h> | 38 | #include <qwindowsystem_qws.h> |
39 | #endif | 39 | #endif |
40 | #include <qtextstream.h> | 40 | #include <qtextstream.h> |
41 | #include <qpalette.h> | 41 | #include <qpalette.h> |
42 | #include <qbuffer.h> | 42 | #include <qbuffer.h> |
43 | #include <qptrdict.h> | 43 | #include <qptrdict.h> |
44 | #include <qregexp.h> | 44 | #include <qregexp.h> |
45 | #include <qdir.h> | 45 | #include <qdir.h> |
46 | #include <qlabel.h> | 46 | #include <qlabel.h> |
47 | #include <qdialog.h> | 47 | #include <qdialog.h> |
48 | #include <qdragobject.h> | 48 | #include <qdragobject.h> |
49 | #include <qtextcodec.h> | 49 | #include <qtextcodec.h> |
50 | #include <qevent.h> | 50 | #include <qevent.h> |
51 | #include <qtooltip.h> | 51 | #include <qtooltip.h> |
52 | #include <qsignal.h> | 52 | #include <qsignal.h> |
53 | #include <qmainwindow.h> | 53 | #include <qmainwindow.h> |
54 | |||
55 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | ||
56 | #define QTOPIA_INTERNAL_INITAPP | ||
54 | #include "qpeapplication.h" | 57 | #include "qpeapplication.h" |
55 | #include "qpestyle.h" | 58 | #include "qpestyle.h" |
56 | #include "styleinterface.h" | 59 | #include "styleinterface.h" |
57 | #if QT_VERSION >= 300 | 60 | #if QT_VERSION >= 300 |
58 | #include <qstylefactory.h> | 61 | #include <qstylefactory.h> |
59 | #else | 62 | #else |
60 | #include <qplatinumstyle.h> | 63 | #include <qplatinumstyle.h> |
61 | #include <qwindowsstyle.h> | 64 | #include <qwindowsstyle.h> |
62 | #include <qmotifstyle.h> | 65 | #include <qmotifstyle.h> |
63 | #include <qmotifplusstyle.h> | 66 | #include <qmotifplusstyle.h> |
64 | #include "lightstyle.h" | 67 | #include "lightstyle.h" |
65 | 68 | ||
66 | #include <qpe/qlibrary.h> | 69 | #include <qpe/qlibrary.h> |
67 | #endif | 70 | #endif |
68 | #include "global.h" | 71 | #include "global.h" |
69 | #include "resource.h" | 72 | #include "resource.h" |
70 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) | 73 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) |
71 | #include "qutfcodec.h" | 74 | #include "qutfcodec.h" |
72 | #endif | 75 | #endif |
73 | #include "config.h" | 76 | #include "config.h" |
74 | #include "network.h" | 77 | #include "network.h" |
75 | #ifdef QWS | 78 | #ifdef QWS |
76 | #include "fontmanager.h" | 79 | #include "fontmanager.h" |
77 | #endif | 80 | #endif |
78 | 81 | ||
79 | #include "alarmserver.h" | 82 | #include "alarmserver.h" |
80 | #include "applnk.h" | 83 | #include "applnk.h" |
81 | #include "qpemenubar.h" | 84 | #include "qpemenubar.h" |
82 | #include "textcodecinterface.h" | 85 | #include "textcodecinterface.h" |
83 | #include "imagecodecinterface.h" | 86 | #include "imagecodecinterface.h" |
84 | 87 | ||
85 | #include <unistd.h> | 88 | #include <unistd.h> |
86 | #include <sys/file.h> | 89 | #include <sys/file.h> |
87 | #include <sys/ioctl.h> | 90 | #include <sys/ioctl.h> |
88 | #include <sys/soundcard.h> | 91 | #include <sys/soundcard.h> |
89 | 92 | ||
90 | #include "qt_override_p.h" | 93 | #include "qt_override_p.h" |
91 | 94 | ||
92 | 95 | ||
93 | class QPEApplicationData | 96 | class QPEApplicationData |
94 | { | 97 | { |
95 | public: | 98 | public: |
96 | QPEApplicationData ( ) | 99 | QPEApplicationData ( ) |
97 | : presstimer( 0 ), presswidget( 0 ), rightpressed( false ), kbgrabbed( false ), | 100 | : presstimer( 0 ), presswidget( 0 ), rightpressed( false ), kbgrabbed( false ), |
98 | notbusysent( false ), preloaded( false ), forceshow( false ), nomaximize( false ), | 101 | notbusysent( false ), preloaded( false ), forceshow( false ), nomaximize( false ), |
99 | keep_running( true ), qpe_main_widget( 0 ) | 102 | keep_running( true ), qpe_main_widget( 0 ) |
100 | 103 | ||
101 | { | 104 | { |
@@ -260,96 +263,106 @@ public: | |||
260 | else { | 263 | else { |
261 | lib->unload(); | 264 | lib->unload(); |
262 | delete lib; | 265 | delete lib; |
263 | } | 266 | } |
264 | } | 267 | } |
265 | } | 268 | } |
266 | QString styleName; | 269 | QString styleName; |
267 | QString decorationName; | 270 | QString decorationName; |
268 | }; | 271 | }; |
269 | 272 | ||
270 | class ResourceMimeFactory : public QMimeSourceFactory | 273 | class ResourceMimeFactory : public QMimeSourceFactory |
271 | { | 274 | { |
272 | public: | 275 | public: |
273 | ResourceMimeFactory() : resImage( 0 ) | 276 | ResourceMimeFactory() : resImage( 0 ) |
274 | { | 277 | { |
275 | setFilePath( Global::helpPath() ); | 278 | setFilePath( Global::helpPath() ); |
276 | setExtensionType( "html", "text/html;charset=UTF-8" ); | 279 | setExtensionType( "html", "text/html;charset=UTF-8" ); |
277 | } | 280 | } |
278 | ~ResourceMimeFactory() { | 281 | ~ResourceMimeFactory() { |
279 | delete resImage; | 282 | delete resImage; |
280 | } | 283 | } |
281 | 284 | ||
282 | const QMimeSource* data( const QString& abs_name ) const | 285 | const QMimeSource* data( const QString& abs_name ) const |
283 | { | 286 | { |
284 | const QMimeSource * r = QMimeSourceFactory::data( abs_name ); | 287 | const QMimeSource * r = QMimeSourceFactory::data( abs_name ); |
285 | if ( !r ) { | 288 | if ( !r ) { |
286 | int sl = abs_name.length(); | 289 | int sl = abs_name.length(); |
287 | do { | 290 | do { |
288 | sl = abs_name.findRev( '/', sl - 1 ); | 291 | sl = abs_name.findRev( '/', sl - 1 ); |
289 | QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name; | 292 | QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name; |
290 | int dot = name.findRev( '.' ); | 293 | int dot = name.findRev( '.' ); |
291 | if ( dot >= 0 ) | 294 | if ( dot >= 0 ) |
292 | name = name.left( dot ); | 295 | name = name.left( dot ); |
293 | QImage img = Resource::loadImage( name ); | 296 | QImage img = Resource::loadImage( name ); |
294 | if ( !img.isNull() ) { | 297 | if ( !img.isNull() ) { |
295 | delete resImage; | 298 | delete resImage; |
296 | resImage = new QImageDrag( img ); | 299 | resImage = new QImageDrag( img ); |
297 | r = resImage; | 300 | r = resImage; |
298 | } | 301 | } |
299 | } | 302 | } |
300 | while ( !r && sl > 0 ); | 303 | while ( !r && sl > 0 ); |
301 | } | 304 | } |
302 | return r; | 305 | return r; |
303 | } | 306 | } |
304 | private: | 307 | private: |
305 | mutable QImageDrag *resImage; | 308 | mutable QImageDrag *resImage; |
306 | }; | 309 | }; |
307 | 310 | ||
311 | static int& hack(int& i) | ||
312 | { | ||
313 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) | ||
314 | // These should be created, but aren't in Qt 2.3.0 | ||
315 | (void)new QUtf8Codec; | ||
316 | (void)new QUtf16Codec; | ||
317 | #endif | ||
318 | return i; | ||
319 | } | ||
320 | |||
308 | static int muted = 0; | 321 | static int muted = 0; |
309 | static int micMuted = 0; | 322 | static int micMuted = 0; |
310 | 323 | ||
311 | static void setVolume( int t = 0, int percent = -1 ) | 324 | static void setVolume( int t = 0, int percent = -1 ) |
312 | { | 325 | { |
313 | switch ( t ) { | 326 | switch ( t ) { |
314 | case 0: { | 327 | case 0: { |
315 | Config cfg( "qpe" ); | 328 | Config cfg( "qpe" ); |
316 | cfg.setGroup( "Volume" ); | 329 | cfg.setGroup( "Volume" ); |
317 | if ( percent < 0 ) | 330 | if ( percent < 0 ) |
318 | percent = cfg.readNumEntry( "VolumePercent", 50 ); | 331 | percent = cfg.readNumEntry( "VolumePercent", 50 ); |
319 | int fd = 0; | 332 | int fd = 0; |
320 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 333 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
321 | int vol = muted ? 0 : percent; | 334 | int vol = muted ? 0 : percent; |
322 | // set both channels to same volume | 335 | // set both channels to same volume |
323 | vol |= vol << 8; | 336 | vol |= vol << 8; |
324 | ioctl( fd, MIXER_WRITE( 0 ), &vol ); | 337 | ioctl( fd, MIXER_WRITE( 0 ), &vol ); |
325 | ::close( fd ); | 338 | ::close( fd ); |
326 | } | 339 | } |
327 | } | 340 | } |
328 | break; | 341 | break; |
329 | } | 342 | } |
330 | } | 343 | } |
331 | 344 | ||
332 | static void setMic( int t = 0, int percent = -1 ) | 345 | static void setMic( int t = 0, int percent = -1 ) |
333 | { | 346 | { |
334 | switch ( t ) { | 347 | switch ( t ) { |
335 | case 0: { | 348 | case 0: { |
336 | Config cfg( "qpe" ); | 349 | Config cfg( "qpe" ); |
337 | cfg.setGroup( "Volume" ); | 350 | cfg.setGroup( "Volume" ); |
338 | if ( percent < 0 ) | 351 | if ( percent < 0 ) |
339 | percent = cfg.readNumEntry( "Mic", 50 ); | 352 | percent = cfg.readNumEntry( "Mic", 50 ); |
340 | 353 | ||
341 | int fd = 0; | 354 | int fd = 0; |
342 | int mic = micMuted ? 0 : percent; | 355 | int mic = micMuted ? 0 : percent; |
343 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 356 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
344 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_MIC ), &mic ); | 357 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_MIC ), &mic ); |
345 | ::close( fd ); | 358 | ::close( fd ); |
346 | } | 359 | } |
347 | } | 360 | } |
348 | break; | 361 | break; |
349 | } | 362 | } |
350 | } | 363 | } |
351 | 364 | ||
352 | 365 | ||
353 | static void setBass( int t = 0, int percent = -1 ) | 366 | static void setBass( int t = 0, int percent = -1 ) |
354 | { | 367 | { |
355 | switch ( t ) { | 368 | switch ( t ) { |
@@ -441,260 +454,341 @@ static void setTreble( int t = 0, int percent = -1 ) | |||
441 | 454 | ||
442 | /*! | 455 | /*! |
443 | \fn void QPEApplication::timeChanged(); | 456 | \fn void QPEApplication::timeChanged(); |
444 | This signal is emitted when the time changes outside the normal | 457 | This signal is emitted when the time changes outside the normal |
445 | passage of time, i.e. if the time is set backwards or forwards. | 458 | passage of time, i.e. if the time is set backwards or forwards. |
446 | */ | 459 | */ |
447 | 460 | ||
448 | /*! | 461 | /*! |
449 | \fn void QPEApplication::clockChanged( bool ampm ); | 462 | \fn void QPEApplication::clockChanged( bool ampm ); |
450 | 463 | ||
451 | This signal is emitted when the user changes the clock's style. If | 464 | This signal is emitted when the user changes the clock's style. If |
452 | \a ampm is TRUE, the user wants a 12-hour AM/PM clock, otherwise, | 465 | \a ampm is TRUE, the user wants a 12-hour AM/PM clock, otherwise, |
453 | they want a 24-hour clock. | 466 | they want a 24-hour clock. |
454 | */ | 467 | */ |
455 | 468 | ||
456 | /*! | 469 | /*! |
457 | \fn void QPEApplication::volumeChanged( bool muted ) | 470 | \fn void QPEApplication::volumeChanged( bool muted ) |
458 | 471 | ||
459 | This signal is emitted whenever the mute state is changed. If \a | 472 | This signal is emitted whenever the mute state is changed. If \a |
460 | muted is TRUE, then sound output has been muted. | 473 | muted is TRUE, then sound output has been muted. |
461 | */ | 474 | */ |
462 | 475 | ||
463 | /*! | 476 | /*! |
464 | \fn void QPEApplication::weekChanged( bool startOnMonday ) | 477 | \fn void QPEApplication::weekChanged( bool startOnMonday ) |
465 | 478 | ||
466 | This signal is emitted if the week start day is changed. If \a | 479 | This signal is emitted if the week start day is changed. If \a |
467 | startOnMonday is TRUE then the first day of the week is Monday; if | 480 | startOnMonday is TRUE then the first day of the week is Monday; if |
468 | \a startOnMonday is FALSE then the first day of the week is | 481 | \a startOnMonday is FALSE then the first day of the week is |
469 | Sunday. | 482 | Sunday. |
470 | */ | 483 | */ |
471 | 484 | ||
472 | /*! | 485 | /*! |
473 | \fn void QPEApplication::dateFormatChanged(DateFormat) | 486 | \fn void QPEApplication::dateFormatChanged(DateFormat) |
474 | 487 | ||
475 | This signal is emitted whenever the date format is changed. | 488 | This signal is emitted whenever the date format is changed. |
476 | */ | 489 | */ |
477 | 490 | ||
478 | /*! | 491 | /*! |
479 | \fn void QPEApplication::flush() | 492 | \fn void QPEApplication::flush() |
480 | 493 | ||
481 | ### | 494 | ### |
482 | */ | 495 | */ |
483 | 496 | ||
484 | /*! | 497 | /*! |
485 | \fn void QPEApplication::reload() | 498 | \fn void QPEApplication::reload() |
486 | 499 | ||
487 | */ | 500 | */ |
488 | 501 | ||
502 | |||
503 | |||
504 | void QPEApplication::processQCopFile() | ||
505 | { | ||
506 | QString qcopfn("/tmp/qcop-msg-"); | ||
507 | qcopfn += d->appName; // append command name | ||
508 | |||
509 | QFile f(qcopfn); | ||
510 | if ( f.open(IO_ReadWrite) ) { | ||
511 | #ifndef Q_OS_WIN32 | ||
512 | flock(f.handle(), LOCK_EX); | ||
513 | #endif | ||
514 | QDataStream ds(&f); | ||
515 | QCString channel, message; | ||
516 | QByteArray data; | ||
517 | while(!ds.atEnd()) { | ||
518 | ds >> channel >> message >> data; | ||
519 | d->enqueueQCop(channel,message,data); | ||
520 | } | ||
521 | ::ftruncate(f.handle(), 0); | ||
522 | #ifndef Q_OS_WIN32 | ||
523 | f.flush(); | ||
524 | flock(f.handle(), LOCK_UN); | ||
525 | #endif | ||
526 | } | ||
527 | #endif | ||
528 | } | ||
529 | |||
530 | |||
489 | /*! | 531 | /*! |
490 | \fn void QPEApplication::appMessage( const QCString& msg, const QByteArray& data ) | 532 | \fn void QPEApplication::appMessage( const QCString& msg, const QByteArray& data ) |
491 | 533 | ||
492 | This signal is emitted when a message is received on this | 534 | This signal is emitted when a message is received on this |
493 | application's QPE/Application/<i>appname</i> \link qcop.html | 535 | application's QPE/Application/<i>appname</i> \link qcop.html |
494 | QCop\endlink channel. | 536 | QCop\endlink channel. |
495 | 537 | ||
496 | The slot to which you connect this signal uses \a msg and \a data | 538 | The slot to which you connect this signal uses \a msg and \a data |
497 | in the following way: | 539 | in the following way: |
498 | 540 | ||
499 | \code | 541 | \code |
500 | void MyWidget::receive( const QCString& msg, const QByteArray& data ) | 542 | void MyWidget::receive( const QCString& msg, const QByteArray& data ) |
501 | { | 543 | { |
502 | QDataStream stream( data, IO_ReadOnly ); | 544 | QDataStream stream( data, IO_ReadOnly ); |
503 | if ( msg == "someMessage(int,int,int)" ) { | 545 | if ( msg == "someMessage(int,int,int)" ) { |
504 | int a,b,c; | 546 | int a,b,c; |
505 | stream >> a >> b >> c; | 547 | stream >> a >> b >> c; |
506 | ... | 548 | ... |
507 | } else if ( msg == "otherMessage(QString)" ) { | 549 | } else if ( msg == "otherMessage(QString)" ) { |
508 | ... | 550 | ... |
509 | } | 551 | } |
510 | } | 552 | } |
511 | \endcode | 553 | \endcode |
512 | 554 | ||
513 | \sa qcop.html | 555 | \sa qcop.html |
514 | Note that messages received here may be processed by qpe application | 556 | Note that messages received here may be processed by qpe application |
515 | and emitted as signals, such as flush() and reload(). | 557 | and emitted as signals, such as flush() and reload(). |
516 | */ | 558 | */ |
517 | 559 | ||
518 | /*! | 560 | /*! |
519 | Constructs a QPEApplication just as you would construct | 561 | Constructs a QPEApplication just as you would construct |
520 | a QApplication, passing \a argc, \a argv, and \a t. | 562 | a QApplication, passing \a argc, \a argv, and \a t. |
521 | 563 | ||
522 | For applications, \a t should be the default, GuiClient. Only | 564 | For applications, \a t should be the default, GuiClient. Only |
523 | the Qtopia server passes GuiServer. | 565 | the Qtopia server passes GuiServer. |
524 | */ | 566 | */ |
525 | QPEApplication::QPEApplication( int & argc, char **argv, Type t ) | 567 | QPEApplication::QPEApplication( int & argc, char **argv, Type t ) |
526 | : QApplication( argc, argv, t ) | 568 | : QApplication( hack(argc), argv, t ), pidChannel( 0 ) |
527 | { | 569 | { |
528 | d = new QPEApplicationData; | 570 | d = new QPEApplicationData; |
529 | d->loadTextCodecs(); | 571 | d->loadTextCodecs(); |
530 | d->loadImageCodecs(); | 572 | d->loadImageCodecs(); |
531 | int dw = desktop() ->width(); | 573 | int dw = desktop() ->width(); |
532 | 574 | ||
533 | if ( dw < 200 ) { | 575 | if ( dw < 200 ) { |
534 | setFont( QFont( "vera", 8 ) ); | 576 | setFont( QFont( "vera", 8 ) ); |
535 | AppLnk::setSmallIconSize( 10 ); | 577 | AppLnk::setSmallIconSize( 10 ); |
536 | AppLnk::setBigIconSize( 28 ); | 578 | AppLnk::setBigIconSize( 28 ); |
537 | } | 579 | } |
538 | #ifndef QT_QWS_SIMPAD | 580 | #ifndef QT_QWS_SIMPAD |
539 | else if ( dw > 600 ) { | 581 | else if ( dw > 600 ) { |
540 | setFont( QFont( "vera", 16 ) ); | 582 | setFont( QFont( "vera", 16 ) ); |
541 | AppLnk::setSmallIconSize( 24 ); | 583 | AppLnk::setSmallIconSize( 24 ); |
542 | AppLnk::setBigIconSize( 48 ); | 584 | AppLnk::setBigIconSize( 48 ); |
543 | } | 585 | } |
544 | #endif | 586 | #endif |
545 | else if ( dw > 200 ) { | 587 | else if ( dw > 200 ) { |
546 | setFont( QFont( "vera", 10 ) ); | 588 | setFont( QFont( "vera", 10 ) ); |
547 | AppLnk::setSmallIconSize( 14 ); | 589 | AppLnk::setSmallIconSize( 14 ); |
548 | AppLnk::setBigIconSize( 32 ); | 590 | AppLnk::setBigIconSize( 32 ); |
549 | } | 591 | } |
550 | 592 | ||
551 | QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory ); | 593 | QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory ); |
552 | 594 | ||
553 | connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) ); | 595 | connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) ); |
596 | |||
597 | |||
598 | sysChannel = new QCopChannel( "QPE/System", this ); | ||
599 | connect( sysChannel, SIGNAL( received( const QCString &, const QByteArray & ) ), | ||
600 | this, SLOT( systemMessage( const QCString &, const QByteArray & ) ) ); | ||
601 | |||
602 | /* COde now in initapp */ | ||
603 | #if 0 | ||
554 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 604 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
555 | 605 | ||
556 | QString qcopfn( "/tmp/qcop-msg-" ); | 606 | QString qcopfn( "/tmp/qcop-msg-" ); |
557 | qcopfn += QString( argv[ 0 ] ); // append command name | 607 | qcopfn += QString( argv[ 0 ] ); // append command name |
558 | 608 | ||
559 | QFile f( qcopfn ); | 609 | QFile f( qcopfn ); |
560 | if ( f.open( IO_ReadOnly ) ) { | 610 | if ( f.open( IO_ReadOnly ) ) { |
561 | flock( f.handle(), LOCK_EX ); | 611 | flock( f.handle(), LOCK_EX ); |
562 | } | 612 | } |
563 | 613 | ||
564 | sysChannel = new QCopChannel( "QPE/System", this ); | 614 | |
565 | connect( sysChannel, SIGNAL( received( const QCString &, const QByteArray & ) ), | ||
566 | this, SLOT( systemMessage( const QCString &, const QByteArray & ) ) ); | ||
567 | 615 | ||
568 | QCString channel = QCString( argv[ 0 ] ); | 616 | QCString channel = QCString( argv[ 0 ] ); |
569 | channel.replace( QRegExp( ".*/" ), "" ); | 617 | channel.replace( QRegExp( ".*/" ), "" ); |
570 | d->appName = channel; | 618 | d->appName = channel; |
571 | channel = "QPE/Application/" + channel; | 619 | channel = "QPE/Application/" + channel; |
572 | pidChannel = new QCopChannel( channel, this ); | 620 | pidChannel = new QCopChannel( channel, this ); |
573 | connect( pidChannel, SIGNAL( received( const QCString &, const QByteArray & ) ), | 621 | connect( pidChannel, SIGNAL( received( const QCString &, const QByteArray & ) ), |
574 | this, SLOT( pidMessage( const QCString &, const QByteArray & ) ) ); | 622 | this, SLOT( pidMessage( const QCString &, const QByteArray & ) ) ); |
575 | 623 | ||
576 | if ( f.isOpen() ) { | 624 | if ( f.isOpen() ) { |
577 | d->keep_running = FALSE; | 625 | d->keep_running = FALSE; |
578 | QDataStream ds( &f ); | 626 | QDataStream ds( &f ); |
579 | QCString channel, message; | 627 | QCString channel, message; |
580 | QByteArray data; | 628 | QByteArray data; |
581 | while ( !ds.atEnd() ) { | 629 | while ( !ds.atEnd() ) { |
582 | ds >> channel >> message >> data; | 630 | ds >> channel >> message >> data; |
583 | d->enqueueQCop( channel, message, data ); | 631 | d->enqueueQCop( channel, message, data ); |
584 | } | 632 | } |
585 | 633 | ||
586 | flock( f.handle(), LOCK_UN ); | 634 | flock( f.handle(), LOCK_UN ); |
587 | f.close(); | 635 | f.close(); |
588 | f.remove(); | 636 | f.remove(); |
589 | } | 637 | } |
590 | 638 | ||
591 | for ( int a = 0; a < argc; a++ ) { | 639 | for ( int a = 0; a < argc; a++ ) { |
592 | if ( qstrcmp( argv[ a ], "-preload" ) == 0 ) { | 640 | if ( qstrcmp( argv[ a ], "-preload" ) == 0 ) { |
593 | argv[ a ] = argv[ a + 1 ]; | 641 | argv[ a ] = argv[ a + 1 ]; |
594 | a++; | 642 | a++; |
595 | d->preloaded = TRUE; | 643 | d->preloaded = TRUE; |
596 | argc -= 1; | 644 | argc -= 1; |
597 | } | 645 | } |
598 | else if ( qstrcmp( argv[ a ], "-preload-show" ) == 0 ) { | 646 | else if ( qstrcmp( argv[ a ], "-preload-show" ) == 0 ) { |
599 | argv[ a ] = argv[ a + 1 ]; | 647 | argv[ a ] = argv[ a + 1 ]; |
600 | a++; | 648 | a++; |
601 | d->preloaded = TRUE; | 649 | d->preloaded = TRUE; |
602 | d->forceshow = TRUE; | 650 | d->forceshow = TRUE; |
603 | argc -= 1; | 651 | argc -= 1; |
604 | } | 652 | } |
605 | } | 653 | } |
606 | 654 | ||
607 | /* overide stored arguments */ | 655 | /* overide stored arguments */ |
608 | setArgs( argc, argv ); | 656 | setArgs( argc, argv ); |
609 | 657 | ||
610 | #endif | 658 | #endif |
611 | 659 | #else | |
660 | initApp( argc, argv ); | ||
661 | #endif | ||
612 | // qwsSetDecoration( new QPEDecoration() ); | 662 | // qwsSetDecoration( new QPEDecoration() ); |
613 | 663 | ||
614 | #ifndef QT_NO_TRANSLATION | 664 | #ifndef QT_NO_TRANSLATION |
615 | 665 | ||
616 | QStringList langs = Global::languageList(); | 666 | QStringList langs = Global::languageList(); |
617 | for ( QStringList::ConstIterator it = langs.begin(); it != langs.end(); ++it ) { | 667 | for ( QStringList::ConstIterator it = langs.begin(); it != langs.end(); ++it ) { |
618 | QString lang = *it; | 668 | QString lang = *it; |
619 | 669 | ||
620 | installTranslation( lang + "/libopie.qm"); | 670 | installTranslation( lang + "/libopie.qm"); |
621 | installTranslation( lang + "/libqpe.qm" ); | 671 | installTranslation( lang + "/libqpe.qm" ); |
622 | installTranslation( lang + "/" + d->appName + ".qm" ); | 672 | installTranslation( lang + "/" + d->appName + ".qm" ); |
623 | 673 | ||
624 | 674 | ||
625 | //###language/font hack; should look it up somewhere | 675 | //###language/font hack; should look it up somewhere |
626 | #ifdef QWS | 676 | #ifdef QWS |
627 | 677 | ||
628 | if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) { | 678 | if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) { |
629 | QFont fn = FontManager::unicodeFont( FontManager::Proportional ); | 679 | QFont fn = FontManager::unicodeFont( FontManager::Proportional ); |
630 | setFont( fn ); | 680 | setFont( fn ); |
631 | } | 681 | } |
632 | #endif | 682 | #endif |
633 | 683 | } | |
634 | } | ||
635 | #endif | 684 | #endif |
636 | 685 | ||
637 | applyStyle(); | 686 | applyStyle(); |
638 | 687 | ||
639 | if ( type() == GuiServer ) { | 688 | if ( type() == GuiServer ) { |
640 | setVolume(); | 689 | setVolume(); |
641 | } | 690 | } |
642 | 691 | ||
643 | installEventFilter( this ); | 692 | installEventFilter( this ); |
644 | 693 | ||
645 | QPEMenuToolFocusManager::initialize(); | 694 | QPEMenuToolFocusManager::initialize(); |
646 | 695 | ||
647 | #ifdef QT_NO_QWS_CURSOR | 696 | #ifdef QT_NO_QWS_CURSOR |
648 | // if we have no cursor, probably don't want tooltips | 697 | // if we have no cursor, probably don't want tooltips |
649 | QToolTip::setEnabled( FALSE ); | 698 | QToolTip::setEnabled( FALSE ); |
650 | #endif | 699 | #endif |
651 | } | 700 | } |
652 | 701 | ||
702 | |||
703 | #ifdef QTOPIA_INTERNAL_INITAPP | ||
704 | void QPEApplication::initApp( int argc, char **argv ) | ||
705 | { | ||
706 | delete pidChannel; | ||
707 | d->keep_running = TRUE; | ||
708 | d->preloaded = FALSE; | ||
709 | d->forceshow = FALSE; | ||
710 | |||
711 | QCString channel = QCString(argv[0]); | ||
712 | |||
713 | channel.replace(QRegExp(".*/"),""); | ||
714 | d->appName = channel; | ||
715 | |||
716 | qt_fbdpy->setIdentity( channel ); // In Qt/E 2.3.6 | ||
717 | |||
718 | channel = "QPE/Application/" + channel; | ||
719 | pidChannel = new QCopChannel( channel, this); | ||
720 | connect( pidChannel, SIGNAL(received(const QCString &, const QByteArray &)), | ||
721 | this, SLOT(pidMessage(const QCString &, const QByteArray &))); | ||
722 | |||
723 | processQCopFile(); | ||
724 | d->keep_running = d->qcopq.isEmpty(); | ||
725 | |||
726 | for (int a=0; a<argc; a++) { | ||
727 | if ( qstrcmp(argv[a],"-preload")==0 ) { | ||
728 | argv[a] = argv[a+1]; | ||
729 | a++; | ||
730 | d->preloaded = TRUE; | ||
731 | argc-=1; | ||
732 | } else if ( qstrcmp(argv[a],"-preload-show")==0 ) { | ||
733 | argv[a] = argv[a+1]; | ||
734 | a++; | ||
735 | d->preloaded = TRUE; | ||
736 | d->forceshow = TRUE; | ||
737 | argc-=1; | ||
738 | } | ||
739 | } | ||
740 | |||
741 | /* overide stored arguments */ | ||
742 | setArgs(argc, argv); | ||
743 | } | ||
744 | #endif | ||
745 | |||
746 | |||
653 | static QPtrDict<void>* inputMethodDict = 0; | 747 | static QPtrDict<void>* inputMethodDict = 0; |
654 | static void createInputMethodDict() | 748 | static void createInputMethodDict() |
655 | { | 749 | { |
656 | if ( !inputMethodDict ) | 750 | if ( !inputMethodDict ) |
657 | inputMethodDict = new QPtrDict<void>; | 751 | inputMethodDict = new QPtrDict<void>; |
658 | } | 752 | } |
659 | 753 | ||
660 | /*! | 754 | /*! |
661 | Returns the currently set hint to the system as to whether | 755 | Returns the currently set hint to the system as to whether |
662 | widget \a w has any use for text input methods. | 756 | widget \a w has any use for text input methods. |
663 | 757 | ||
664 | 758 | ||
665 | \sa setInputMethodHint() InputMethodHint | 759 | \sa setInputMethodHint() InputMethodHint |
666 | */ | 760 | */ |
667 | QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w ) | 761 | QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w ) |
668 | { | 762 | { |
669 | if ( inputMethodDict && w ) | 763 | if ( inputMethodDict && w ) |
670 | return ( InputMethodHint ) ( int ) inputMethodDict->find( w ); | 764 | return ( InputMethodHint ) ( int ) inputMethodDict->find( w ); |
671 | return Normal; | 765 | return Normal; |
672 | } | 766 | } |
673 | 767 | ||
674 | /*! | 768 | /*! |
675 | \enum QPEApplication::InputMethodHint | 769 | \enum QPEApplication::InputMethodHint |
676 | 770 | ||
677 | \value Normal the application sometimes needs text input (the default). | 771 | \value Normal the application sometimes needs text input (the default). |
678 | \value AlwaysOff the application never needs text input. | 772 | \value AlwaysOff the application never needs text input. |
679 | \value AlwaysOn the application always needs text input. | 773 | \value AlwaysOn the application always needs text input. |
680 | */ | 774 | */ |
681 | 775 | ||
682 | /*! | 776 | /*! |
683 | Hints to the system that widget \a w has use for text input methods | 777 | Hints to the system that widget \a w has use for text input methods |
684 | as specified by \a mode. | 778 | as specified by \a mode. |
685 | 779 | ||
686 | \sa inputMethodHint() InputMethodHint | 780 | \sa inputMethodHint() InputMethodHint |
687 | */ | 781 | */ |
688 | void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode ) | 782 | void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode ) |
689 | { | 783 | { |
690 | createInputMethodDict(); | 784 | createInputMethodDict(); |
691 | if ( mode == Normal ) { | 785 | if ( mode == Normal ) { |
692 | inputMethodDict->remove | 786 | inputMethodDict->remove |
693 | ( w ); | 787 | ( w ); |
694 | } | 788 | } |
695 | else { | 789 | else { |
696 | inputMethodDict->insert( w, ( void* ) mode ); | 790 | inputMethodDict->insert( w, ( void* ) mode ); |
697 | } | 791 | } |
698 | } | 792 | } |
699 | 793 | ||
700 | class HackDialog : public QDialog | 794 | class HackDialog : public QDialog |
@@ -1079,279 +1173,283 @@ void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data | |||
1079 | setDefaultRotation( r ); | 1173 | setDefaultRotation( r ); |
1080 | } | 1174 | } |
1081 | } | 1175 | } |
1082 | else if ( msg == "setCurrentRotation(int)" ) { | 1176 | else if ( msg == "setCurrentRotation(int)" ) { |
1083 | int r; | 1177 | int r; |
1084 | stream >> r; | 1178 | stream >> r; |
1085 | setCurrentRotation( r ); | 1179 | setCurrentRotation( r ); |
1086 | } | 1180 | } |
1087 | else if ( msg == "shutdown()" ) { | 1181 | else if ( msg == "shutdown()" ) { |
1088 | if ( type() == GuiServer ) | 1182 | if ( type() == GuiServer ) |
1089 | shutdown(); | 1183 | shutdown(); |
1090 | } | 1184 | } |
1091 | else if ( msg == "quit()" ) { | 1185 | else if ( msg == "quit()" ) { |
1092 | if ( type() != GuiServer ) | 1186 | if ( type() != GuiServer ) |
1093 | tryQuit(); | 1187 | tryQuit(); |
1094 | } | 1188 | } |
1095 | else if ( msg == "forceQuit()" ) { | 1189 | else if ( msg == "forceQuit()" ) { |
1096 | if ( type() != GuiServer ) | 1190 | if ( type() != GuiServer ) |
1097 | quit(); | 1191 | quit(); |
1098 | } | 1192 | } |
1099 | else if ( msg == "restart()" ) { | 1193 | else if ( msg == "restart()" ) { |
1100 | if ( type() == GuiServer ) | 1194 | if ( type() == GuiServer ) |
1101 | restart(); | 1195 | restart(); |
1102 | } | 1196 | } |
1103 | else if ( msg == "language(QString)" ) { | 1197 | else if ( msg == "language(QString)" ) { |
1104 | if ( type() == GuiServer ) { | 1198 | if ( type() == GuiServer ) { |
1105 | QString l; | 1199 | QString l; |
1106 | stream >> l; | 1200 | stream >> l; |
1107 | QString cl = getenv( "LANG" ); | 1201 | QString cl = getenv( "LANG" ); |
1108 | if ( cl != l ) { | 1202 | if ( cl != l ) { |
1109 | if ( l.isNull() ) | 1203 | if ( l.isNull() ) |
1110 | unsetenv( "LANG" ); | 1204 | unsetenv( "LANG" ); |
1111 | else | 1205 | else |
1112 | setenv( "LANG", l.latin1(), 1 ); | 1206 | setenv( "LANG", l.latin1(), 1 ); |
1113 | restart(); | 1207 | restart(); |
1114 | } | 1208 | } |
1115 | } | 1209 | } |
1116 | } | 1210 | } |
1117 | else if ( msg == "timeChange(QString)" ) { | 1211 | else if ( msg == "timeChange(QString)" ) { |
1118 | QString t; | 1212 | QString t; |
1119 | stream >> t; | 1213 | stream >> t; |
1120 | if ( t.isNull() ) | 1214 | if ( t.isNull() ) |
1121 | unsetenv( "TZ" ); | 1215 | unsetenv( "TZ" ); |
1122 | else | 1216 | else |
1123 | setenv( "TZ", t.latin1(), 1 ); | 1217 | setenv( "TZ", t.latin1(), 1 ); |
1124 | // emit the signal so everyone else knows... | 1218 | // emit the signal so everyone else knows... |
1125 | emit timeChanged(); | 1219 | emit timeChanged(); |
1126 | } | 1220 | } |
1127 | else if ( msg == "execute(QString)" ) { | ||
1128 | if ( type() == GuiServer ) { | ||
1129 | QString t; | ||
1130 | stream >> t; | ||
1131 | Global::execute( t ); | ||
1132 | } | ||
1133 | } | ||
1134 | else if ( msg == "execute(QString,QString)" ) { | ||
1135 | if ( type() == GuiServer ) { | ||
1136 | QString t, d; | ||
1137 | stream >> t >> d; | ||
1138 | Global::execute( t, d ); | ||
1139 | } | ||
1140 | } | ||
1141 | else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) { | 1221 | else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) { |
1142 | if ( type() == GuiServer ) { | 1222 | if ( type() == GuiServer ) { |
1143 | QDateTime when; | 1223 | QDateTime when; |
1144 | QCString channel, message; | 1224 | QCString channel, message; |
1145 | int data; | 1225 | int data; |
1146 | stream >> when >> channel >> message >> data; | 1226 | stream >> when >> channel >> message >> data; |
1147 | AlarmServer::addAlarm( when, channel, message, data ); | 1227 | AlarmServer::addAlarm( when, channel, message, data ); |
1148 | } | 1228 | } |
1149 | } | 1229 | } |
1150 | else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) { | 1230 | else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) { |
1151 | if ( type() == GuiServer ) { | 1231 | if ( type() == GuiServer ) { |
1152 | QDateTime when; | 1232 | QDateTime when; |
1153 | QCString channel, message; | 1233 | QCString channel, message; |
1154 | int data; | 1234 | int data; |
1155 | stream >> when >> channel >> message >> data; | 1235 | stream >> when >> channel >> message >> data; |
1156 | AlarmServer::deleteAlarm( when, channel, message, data ); | 1236 | AlarmServer::deleteAlarm( when, channel, message, data ); |
1157 | } | 1237 | } |
1158 | } | 1238 | } |
1159 | else if ( msg == "clockChange(bool)" ) { | 1239 | else if ( msg == "clockChange(bool)" ) { |
1160 | int tmp; | 1240 | int tmp; |
1161 | stream >> tmp; | 1241 | stream >> tmp; |
1162 | emit clockChanged( tmp ); | 1242 | emit clockChanged( tmp ); |
1163 | } | 1243 | } |
1164 | else if ( msg == "weekChange(bool)" ) { | 1244 | else if ( msg == "weekChange(bool)" ) { |
1165 | int tmp; | 1245 | int tmp; |
1166 | stream >> tmp; | 1246 | stream >> tmp; |
1167 | emit weekChanged( tmp ); | 1247 | emit weekChanged( tmp ); |
1168 | } | 1248 | } |
1169 | else if ( msg == "setDateFormat(DateFormat)" ) { | 1249 | else if ( msg == "setDateFormat(DateFormat)" ) { |
1170 | DateFormat tmp; | 1250 | DateFormat tmp; |
1171 | stream >> tmp; | 1251 | stream >> tmp; |
1172 | emit dateFormatChanged( tmp ); | 1252 | emit dateFormatChanged( tmp ); |
1173 | } | 1253 | } |
1174 | else if ( msg == "setVolume(int,int)" ) { | 1254 | else if ( msg == "setVolume(int,int)" ) { |
1175 | int t, v; | 1255 | int t, v; |
1176 | stream >> t >> v; | 1256 | stream >> t >> v; |
1177 | setVolume( t, v ); | 1257 | setVolume( t, v ); |
1178 | emit volumeChanged( muted ); | 1258 | emit volumeChanged( muted ); |
1179 | } | 1259 | } |
1180 | else if ( msg == "volumeChange(bool)" ) { | 1260 | else if ( msg == "volumeChange(bool)" ) { |
1181 | stream >> muted; | 1261 | stream >> muted; |
1182 | setVolume(); | 1262 | setVolume(); |
1183 | emit volumeChanged( muted ); | 1263 | emit volumeChanged( muted ); |
1184 | } | 1264 | } |
1185 | else if ( msg == "setMic(int,int)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> | 1265 | else if ( msg == "setMic(int,int)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> |
1186 | int t, v; | 1266 | int t, v; |
1187 | stream >> t >> v; | 1267 | stream >> t >> v; |
1188 | setMic( t, v ); | 1268 | setMic( t, v ); |
1189 | emit micChanged( micMuted ); | 1269 | emit micChanged( micMuted ); |
1190 | } | 1270 | } |
1191 | else if ( msg == "micChange(bool)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> | 1271 | else if ( msg == "micChange(bool)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> |
1192 | stream >> micMuted; | 1272 | stream >> micMuted; |
1193 | setMic(); | 1273 | setMic(); |
1194 | emit micChanged( micMuted ); | 1274 | emit micChanged( micMuted ); |
1195 | } | 1275 | } |
1196 | else if ( msg == "setBass(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> | 1276 | else if ( msg == "setBass(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> |
1197 | int t, v; | 1277 | int t, v; |
1198 | stream >> t >> v; | 1278 | stream >> t >> v; |
1199 | setBass( t, v ); | 1279 | setBass( t, v ); |
1200 | } | 1280 | } |
1201 | else if ( msg == "bassChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> | 1281 | else if ( msg == "bassChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> |
1202 | setBass(); | 1282 | setBass(); |
1203 | } | 1283 | } |
1204 | else if ( msg == "setTreble(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> | 1284 | else if ( msg == "setTreble(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> |
1205 | int t, v; | 1285 | int t, v; |
1206 | stream >> t >> v; | 1286 | stream >> t >> v; |
1207 | setTreble( t, v ); | 1287 | setTreble( t, v ); |
1208 | } | 1288 | } |
1209 | else if ( msg == "trebleChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> | 1289 | else if ( msg == "trebleChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> |
1210 | setTreble(); | 1290 | setTreble(); |
1291 | } else if ( msg == "getMarkedText()" ) { | ||
1292 | if ( type() == GuiServer ) { | ||
1293 | const ushort unicode = 'C'-'@'; | ||
1294 | const int scan = Key_C; | ||
1295 | qwsServer->processKeyEvent( unicode, scan, ControlButton, TRUE, FALSE ); | ||
1296 | qwsServer->processKeyEvent( unicode, scan, ControlButton, FALSE, FALSE ); | ||
1297 | } | ||
1298 | } else if ( msg == "newChannel(QString)") { | ||
1299 | QString myChannel = "QPE/Application/" + d->appName; | ||
1300 | QString channel; | ||
1301 | stream >> channel; | ||
1302 | if (channel == myChannel) { | ||
1303 | processQCopFile(); | ||
1304 | d->sendQCopQ(); | ||
1211 | } | 1305 | } |
1212 | 1306 | } | |
1213 | 1307 | ||
1214 | 1308 | ||
1215 | #endif | 1309 | #endif |
1216 | } | 1310 | } |
1217 | 1311 | ||
1218 | /*! | 1312 | /*! |
1219 | \internal | 1313 | \internal |
1220 | */ | 1314 | */ |
1221 | bool QPEApplication::raiseAppropriateWindow() | 1315 | bool QPEApplication::raiseAppropriateWindow() |
1222 | { | 1316 | { |
1223 | bool r = FALSE; | 1317 | bool r = FALSE; |
1224 | // ########## raise()ing main window should raise and set active | 1318 | // ########## raise()ing main window should raise and set active |
1225 | // ########## it and then all childen. This belongs in Qt/Embedded | 1319 | // ########## it and then all childen. This belongs in Qt/Embedded |
1226 | QWidget *top = d->qpe_main_widget; | 1320 | QWidget *top = d->qpe_main_widget; |
1227 | if ( !top ) | 1321 | if ( !top ) |
1228 | top = mainWidget(); | 1322 | top = mainWidget(); |
1229 | if ( top && d->keep_running ) { | 1323 | if ( top && d->keep_running ) { |
1230 | if ( top->isVisible() ) | 1324 | if ( top->isVisible() ) |
1231 | r = TRUE; | 1325 | r = TRUE; |
1232 | else if (d->preloaded) { | 1326 | else if (d->preloaded) { |
1233 | // We are preloaded and not visible.. pretend we just started.. | 1327 | // We are preloaded and not visible.. pretend we just started.. |
1234 | QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); | 1328 | QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); |
1235 | e << d->appName; | 1329 | e << d->appName; |
1236 | } | 1330 | } |
1237 | 1331 | ||
1238 | d->show_mx(top, d->nomaximize); | 1332 | d->show_mx(top, d->nomaximize); |
1239 | top->raise(); | 1333 | top->raise(); |
1240 | top->setActiveWindow(); | 1334 | top->setActiveWindow(); |
1241 | } | 1335 | } |
1242 | QWidget *topm = activeModalWidget(); | 1336 | QWidget *topm = activeModalWidget(); |
1243 | if ( topm && topm != top ) { | 1337 | if ( topm && topm != top ) { |
1244 | topm->show(); | 1338 | topm->show(); |
1245 | topm->raise(); | 1339 | topm->raise(); |
1246 | topm->setActiveWindow(); | 1340 | topm->setActiveWindow(); |
1247 | // If we haven't already handled the fastAppShowing message | 1341 | // If we haven't already handled the fastAppShowing message |
1248 | if (!top && d->preloaded) { | 1342 | if (!top && d->preloaded) { |
1249 | QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); | 1343 | QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); |
1250 | e << d->appName; | 1344 | e << d->appName; |
1251 | } | 1345 | } |
1252 | r = FALSE; | 1346 | r = FALSE; |
1253 | } | 1347 | } |
1254 | return r; | 1348 | return r; |
1255 | } | 1349 | } |
1256 | 1350 | ||
1257 | void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data) | 1351 | void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data) |
1258 | { | 1352 | { |
1259 | #ifdef Q_WS_QWS | 1353 | #ifdef Q_WS_QWS |
1260 | 1354 | ||
1261 | if ( msg == "quit()" ) { | 1355 | if ( msg == "quit()" ) { |
1262 | tryQuit(); | 1356 | tryQuit(); |
1263 | } | 1357 | } |
1264 | else if ( msg == "quitIfInvisible()" ) { | 1358 | else if ( msg == "quitIfInvisible()" ) { |
1265 | if ( d->qpe_main_widget && !d->qpe_main_widget->isVisible() ) | 1359 | if ( d->qpe_main_widget && !d->qpe_main_widget->isVisible() ) |
1266 | quit(); | 1360 | quit(); |
1267 | } | 1361 | } |
1268 | else if ( msg == "close()" ) { | 1362 | else if ( msg == "close()" ) { |
1269 | hideOrQuit(); | 1363 | hideOrQuit(); |
1270 | } | 1364 | } |
1271 | else if ( msg == "disablePreload()" ) { | 1365 | else if ( msg == "disablePreload()" ) { |
1272 | d->preloaded = FALSE; | 1366 | d->preloaded = FALSE; |
1273 | d->keep_running = TRUE; | 1367 | d->keep_running = TRUE; |
1274 | /* so that quit will quit */ | 1368 | /* so that quit will quit */ |
1275 | } | 1369 | } |
1276 | else if ( msg == "enablePreload()" ) { | 1370 | else if ( msg == "enablePreload()" ) { |
1277 | if (d->qpe_main_widget) | 1371 | if (d->qpe_main_widget) |
1278 | d->preloaded = TRUE; | 1372 | d->preloaded = TRUE; |
1279 | d->keep_running = TRUE; | 1373 | d->keep_running = TRUE; |
1280 | /* so next quit won't quit */ | 1374 | /* so next quit won't quit */ |
1281 | } | 1375 | } |
1282 | else if ( msg == "raise()" ) { | 1376 | else if ( msg == "raise()" ) { |
1283 | d->keep_running = TRUE; | 1377 | d->keep_running = TRUE; |
1284 | d->notbusysent = FALSE; | 1378 | d->notbusysent = FALSE; |
1285 | raiseAppropriateWindow(); | 1379 | raiseAppropriateWindow(); |
1286 | // Tell the system we're still chugging along... | 1380 | // Tell the system we're still chugging along... |
1287 | QCopEnvelope e("QPE/System", "appRaised(QString)"); | 1381 | QCopEnvelope e("QPE/System", "appRaised(QString)"); |
1288 | e << d->appName; | 1382 | e << d->appName; |
1289 | } | 1383 | } |
1290 | else if ( msg == "flush()" ) { | 1384 | else if ( msg == "flush()" ) { |
1291 | emit flush(); | 1385 | emit flush(); |
1292 | // we need to tell the desktop | 1386 | // we need to tell the desktop |
1293 | QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" ); | 1387 | QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" ); |
1294 | e << d->appName; | 1388 | e << d->appName; |
1295 | } | 1389 | } |
1296 | else if ( msg == "reload()" ) { | 1390 | else if ( msg == "reload()" ) { |
1297 | emit reload(); | 1391 | emit reload(); |
1298 | } | 1392 | } |
1299 | else if ( msg == "setDocument(QString)" ) { | 1393 | else if ( msg == "setDocument(QString)" ) { |
1300 | d->keep_running = TRUE; | 1394 | d->keep_running = TRUE; |
1301 | QDataStream stream( data, IO_ReadOnly ); | 1395 | QDataStream stream( data, IO_ReadOnly ); |
1302 | QString doc; | 1396 | QString doc; |
1303 | stream >> doc; | 1397 | stream >> doc; |
1304 | QWidget *mw = mainWidget(); | 1398 | QWidget *mw = mainWidget(); |
1305 | if ( !mw ) | 1399 | if ( !mw ) |
1306 | mw = d->qpe_main_widget; | 1400 | mw = d->qpe_main_widget; |
1307 | if ( mw ) | 1401 | if ( mw ) |
1308 | Global::setDocument( mw, doc ); | 1402 | Global::setDocument( mw, doc ); |
1309 | } else { | 1403 | } else if ( msg == "QPEProcessQCop()" ) { |
1404 | processQCopFile(); | ||
1405 | d->sendQCopQ(); | ||
1406 | } | ||
1407 | { | ||
1310 | bool p = d->keep_running; | 1408 | bool p = d->keep_running; |
1311 | d->keep_running = FALSE; | 1409 | d->keep_running = FALSE; |
1312 | emit appMessage( msg, data); | 1410 | emit appMessage( msg, data); |
1313 | if ( d->keep_running ) { | 1411 | if ( d->keep_running ) { |
1314 | d->notbusysent = FALSE; | 1412 | d->notbusysent = FALSE; |
1315 | raiseAppropriateWindow(); | 1413 | raiseAppropriateWindow(); |
1316 | if ( !p ) { | 1414 | if ( !p ) { |
1317 | // Tell the system we're still chugging along... | 1415 | // Tell the system we're still chugging along... |
1318 | #ifndef QT_NO_COP | 1416 | #ifndef QT_NO_COP |
1319 | QCopEnvelope e("QPE/System", "appRaised(QString)"); | 1417 | QCopEnvelope e("QPE/System", "appRaised(QString)"); |
1320 | e << d->appName; | 1418 | e << d->appName; |
1321 | #endif | 1419 | #endif |
1322 | } | 1420 | } |
1323 | } | 1421 | } |
1324 | if ( p ) | 1422 | if ( p ) |
1325 | d->keep_running = p; | 1423 | d->keep_running = p; |
1326 | } | 1424 | } |
1327 | #endif | 1425 | #endif |
1328 | } | 1426 | } |
1329 | 1427 | ||
1330 | 1428 | ||
1331 | /*! | 1429 | /*! |
1332 | Sets widget \a mw as the mainWidget() and shows it. For small windows, | 1430 | Sets widget \a mw as the mainWidget() and shows it. For small windows, |
1333 | consider passing TRUE for \a nomaximize rather than the default FALSE. | 1431 | consider passing TRUE for \a nomaximize rather than the default FALSE. |
1334 | 1432 | ||
1335 | \sa showMainDocumentWidget() | 1433 | \sa showMainDocumentWidget() |
1336 | */ | 1434 | */ |
1337 | void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize ) | 1435 | void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize ) |
1338 | { | 1436 | { |
1339 | d->show(mw, nomaximize ); | 1437 | d->show(mw, nomaximize ); |
1340 | } | 1438 | } |
1341 | 1439 | ||
1342 | /*! | 1440 | /*! |
1343 | Sets widget \a mw as the mainWidget() and shows it. For small windows, | 1441 | Sets widget \a mw as the mainWidget() and shows it. For small windows, |
1344 | consider passing TRUE for \a nomaximize rather than the default FALSE. | 1442 | consider passing TRUE for \a nomaximize rather than the default FALSE. |
1345 | 1443 | ||
1346 | This calls designates the application as | 1444 | This calls designates the application as |
1347 | a \link docwidget.html document-oriented\endlink application. | 1445 | a \link docwidget.html document-oriented\endlink application. |
1348 | 1446 | ||
1349 | The \a mw widget \e must have this slot: setDocument(const QString&). | 1447 | The \a mw widget \e must have this slot: setDocument(const QString&). |
1350 | 1448 | ||
1351 | \sa showMainWidget() | 1449 | \sa showMainWidget() |
1352 | */ | 1450 | */ |
1353 | void QPEApplication::showMainDocumentWidget( QWidget* mw, bool nomaximize ) | 1451 | void QPEApplication::showMainDocumentWidget( QWidget* mw, bool nomaximize ) |
1354 | { | 1452 | { |
1355 | if ( mw && argc() == 2 ) | 1453 | if ( mw && argc() == 2 ) |
1356 | Global::setDocument( mw, QString::fromUtf8(argv()[1]) ); | 1454 | Global::setDocument( mw, QString::fromUtf8(argv()[1]) ); |
1357 | 1455 | ||