author | sandman <sandman> | 2002-10-13 16:06:24 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-10-13 16:06:24 (UTC) |
commit | 92aabc976e4a8e58d7db0bba42cb8d0f3ebe8982 (patch) (unidiff) | |
tree | e16b9cd59d51c8f1e159d830cb5c18ec4cd9420a /library | |
parent | cb816d85c54242f8958ff77fba334b43be0dcb3d (diff) | |
download | opie-92aabc976e4a8e58d7db0bba42cb8d0f3ebe8982.zip opie-92aabc976e4a8e58d7db0bba42cb8d0f3ebe8982.tar.gz opie-92aabc976e4a8e58d7db0bba42cb8d0f3ebe8982.tar.bz2 |
reformated with astyle (this may not be everybodys prefered style, but IMHO
it's better than the mess before..)
-rw-r--r-- | library/qpeapplication.cpp | 189 |
1 files changed, 133 insertions, 56 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp index f65f3ab..2432b65 100644 --- a/library/qpeapplication.cpp +++ b/library/qpeapplication.cpp | |||
@@ -83,68 +83,84 @@ | |||
83 | #include <unistd.h> | 83 | #include <unistd.h> |
84 | #include <sys/file.h> | 84 | #include <sys/file.h> |
85 | #include <sys/ioctl.h> | 85 | #include <sys/ioctl.h> |
86 | #include <sys/soundcard.h> | 86 | #include <sys/soundcard.h> |
87 | 87 | ||
88 | 88 | ||
89 | class QPEApplicationData { | 89 | class QPEApplicationData |
90 | { | ||
90 | public: | 91 | public: |
91 | QPEApplicationData() : presstimer( 0 ), presswidget( 0 ), rightpressed( FALSE ), | 92 | QPEApplicationData() : presstimer( 0 ), presswidget( 0 ), rightpressed( FALSE ), |
92 | kbgrabber( 0 ), kbregrab( FALSE ), notbusysent( FALSE ), preloaded( FALSE ), | 93 | kbgrabber( 0 ), kbregrab( FALSE ), notbusysent( FALSE ), preloaded( FALSE ), |
93 | forceshow( FALSE ), nomaximize( FALSE ), qpe_main_widget( 0 ), | 94 | forceshow( FALSE ), nomaximize( FALSE ), qpe_main_widget( 0 ), |
94 | keep_running( TRUE ) | 95 | keep_running( TRUE ) |
95 | { | 96 | { |
96 | qcopq.setAutoDelete( TRUE ); | 97 | qcopq.setAutoDelete( TRUE ); |
97 | } | 98 | } |
98 | 99 | ||
99 | int presstimer; | 100 | int presstimer; |
100 | QWidget* presswidget; | 101 | QWidget* presswidget; |
101 | QPoint presspos; | 102 | QPoint presspos; |
102 | bool rightpressed : 1; // AEH why not use uint foobar :1; if it's tt style -zecke | 103 | bool rightpressed : |
104 | 1; // AEH why not use uint foobar :1; if it's tt style -zecke | ||
103 | int kbgrabber; | 105 | int kbgrabber; |
104 | bool kbregrab : 1; | 106 | bool kbregrab : |
105 | bool notbusysent : 1; | 107 | 1; |
108 | bool notbusysent : | ||
109 | 1; | ||
106 | QString appName; | 110 | QString appName; |
107 | struct QCopRec { | 111 | struct QCopRec |
112 | { | ||
108 | QCopRec( const QCString &ch, const QCString &msg, | 113 | QCopRec( const QCString &ch, const QCString &msg, |
109 | const QByteArray &d ) : | 114 | const QByteArray &d ) : |
110 | channel( ch ), message( msg ), data( d ) { } | 115 | channel( ch ), message( msg ), data( d ) |
116 | { } | ||
111 | 117 | ||
112 | QCString channel; | 118 | QCString channel; |
113 | QCString message; | 119 | QCString message; |
114 | QByteArray data; | 120 | QByteArray data; |
115 | }; | 121 | }; |
116 | bool preloaded : 1; | 122 | bool preloaded : |
117 | bool forceshow : 1; | 123 | 1; |
118 | bool nomaximize : 1; | 124 | bool forceshow : |
125 | 1; | ||
126 | bool nomaximize : | ||
127 | 1; | ||
119 | QWidget* qpe_main_widget; | 128 | QWidget* qpe_main_widget; |
120 | bool keep_running : 1; | 129 | bool keep_running : |
130 | 1; | ||
121 | QList<QCopRec> qcopq; | 131 | QList<QCopRec> qcopq; |
122 | 132 | ||
123 | void enqueueQCop( const QCString &ch, const QCString &msg, | 133 | void enqueueQCop( const QCString &ch, const QCString &msg, |
124 | const QByteArray &data ) | 134 | const QByteArray &data ) |
125 | { | 135 | { |
126 | qcopq.append( new QCopRec( ch, msg, data ) ); | 136 | qcopq.append( new QCopRec( ch, msg, data ) ); |
127 | } | 137 | } |
128 | void sendQCopQ() { | 138 | void sendQCopQ() |
139 | { | ||
129 | QCopRec * r; | 140 | QCopRec * r; |
130 | #ifndef QT_NO_COP | 141 | #ifndef QT_NO_COP |
142 | |||
131 | for ( QListIterator<QCopRec> it( qcopq ); ( r = it.current() ); ++it ) | 143 | for ( QListIterator<QCopRec> it( qcopq ); ( r = it.current() ); ++it ) |
132 | QCopChannel::sendLocally( r->channel, r->message, r->data ); | 144 | QCopChannel::sendLocally( r->channel, r->message, r->data ); |
133 | #endif | 145 | #endif |
146 | |||
134 | qcopq.clear(); | 147 | qcopq.clear(); |
135 | } | 148 | } |
136 | static void show_mx(QWidget* mw, bool nomaximize) { | 149 | static void show_mx(QWidget* mw, bool nomaximize) |
150 | { | ||
137 | if ( mw->layout() && mw->inherits("QDialog") ) { | 151 | if ( mw->layout() && mw->inherits("QDialog") ) { |
138 | QPEApplication::showDialog((QDialog*)mw,nomaximize); | 152 | QPEApplication::showDialog((QDialog*)mw,nomaximize); |
139 | } else { | 153 | } |
154 | else { | ||
140 | #ifdef Q_WS_QWS | 155 | #ifdef Q_WS_QWS |
141 | if ( !nomaximize ) | 156 | if ( !nomaximize ) |
142 | mw->showMaximized(); | 157 | mw->showMaximized(); |
143 | else | 158 | else |
144 | #endif | 159 | #endif |
160 | |||
145 | mw->show(); | 161 | mw->show(); |
146 | } | 162 | } |
147 | } | 163 | } |
148 | static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) | 164 | static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) |
149 | { | 165 | { |
150 | /* | 166 | /* |
@@ -172,18 +188,21 @@ public: | |||
172 | void show(QWidget* mw, bool nomax) | 188 | void show(QWidget* mw, bool nomax) |
173 | { | 189 | { |
174 | setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" ); | 190 | setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" ); |
175 | nomaximize = nomax; | 191 | nomaximize = nomax; |
176 | qpe_main_widget = mw; | 192 | qpe_main_widget = mw; |
177 | #ifndef QT_NO_COP | 193 | #ifndef QT_NO_COP |
194 | |||
178 | sendQCopQ(); | 195 | sendQCopQ(); |
179 | #endif | 196 | #endif |
197 | |||
180 | if ( preloaded ) { | 198 | if ( preloaded ) { |
181 | if(forceshow) | 199 | if(forceshow) |
182 | show_mx(mw,nomax); | 200 | show_mx(mw,nomax); |
183 | } else if ( keep_running ) { | 201 | } |
202 | else if ( keep_running ) { | ||
184 | show_mx(mw,nomax); | 203 | show_mx(mw,nomax); |
185 | } | 204 | } |
186 | } | 205 | } |
187 | 206 | ||
188 | void loadTextCodecs() | 207 | void loadTextCodecs() |
189 | { | 208 | { |
@@ -197,13 +216,14 @@ public: | |||
197 | if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { | 216 | if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { |
198 | QValueList<int> mibs = iface->mibEnums(); | 217 | QValueList<int> mibs = iface->mibEnums(); |
199 | for (QValueList<int>::ConstIterator i=mibs.begin(); i!=mibs.end(); ++i) { | 218 | for (QValueList<int>::ConstIterator i=mibs.begin(); i!=mibs.end(); ++i) { |
200 | (void)iface->createForMib(*i); | 219 | (void)iface->createForMib(*i); |
201 | // ### it exists now; need to remember if we can delete it | 220 | // ### it exists now; need to remember if we can delete it |
202 | } | 221 | } |
203 | } else { | 222 | } |
223 | else { | ||
204 | lib->unload(); | 224 | lib->unload(); |
205 | delete lib; | 225 | delete lib; |
206 | } | 226 | } |
207 | } | 227 | } |
208 | } | 228 | } |
209 | 229 | ||
@@ -219,23 +239,25 @@ public: | |||
219 | if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { | 239 | if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { |
220 | QStringList formats = iface->keys(); | 240 | QStringList formats = iface->keys(); |
221 | for (QStringList::ConstIterator i=formats.begin(); i!=formats.end(); ++i) { | 241 | for (QStringList::ConstIterator i=formats.begin(); i!=formats.end(); ++i) { |
222 | (void)iface->installIOHandler(*i); | 242 | (void)iface->installIOHandler(*i); |
223 | // ### it exists now; need to remember if we can delete it | 243 | // ### it exists now; need to remember if we can delete it |
224 | } | 244 | } |
225 | } else { | 245 | } |
246 | else { | ||
226 | lib->unload(); | 247 | lib->unload(); |
227 | delete lib; | 248 | delete lib; |
228 | } | 249 | } |
229 | } | 250 | } |
230 | } | 251 | } |
231 | QString styleName; | 252 | QString styleName; |
232 | QString decorationName; | 253 | QString decorationName; |
233 | }; | 254 | }; |
234 | 255 | ||
235 | class ResourceMimeFactory : public QMimeSourceFactory { | 256 | class ResourceMimeFactory : public QMimeSourceFactory |
257 | { | ||
236 | public: | 258 | public: |
237 | ResourceMimeFactory() | 259 | ResourceMimeFactory() |
238 | { | 260 | { |
239 | setFilePath( Global::helpPath() ); | 261 | setFilePath( Global::helpPath() ); |
240 | setExtensionType( "html", "text/html;charset=UTF-8" ); | 262 | setExtensionType( "html", "text/html;charset=UTF-8" ); |
241 | } | 263 | } |
@@ -445,17 +467,19 @@ QPEApplication::QPEApplication( int & argc, char **argv, Type t ) | |||
445 | int dw = desktop() ->width(); | 467 | int dw = desktop() ->width(); |
446 | qWarning( "Width %d", dw ); | 468 | qWarning( "Width %d", dw ); |
447 | if ( dw < 200 ) { | 469 | if ( dw < 200 ) { |
448 | setFont( QFont( "helvetica", 8 ) ); | 470 | setFont( QFont( "helvetica", 8 ) ); |
449 | AppLnk::setSmallIconSize( 10 ); | 471 | AppLnk::setSmallIconSize( 10 ); |
450 | AppLnk::setBigIconSize( 28 ); | 472 | AppLnk::setBigIconSize( 28 ); |
451 | }else if ( dw > 600 ) { | 473 | } |
474 | else if ( dw > 600 ) { | ||
452 | setFont( QFont( "helvetica", 12 ) ); | 475 | setFont( QFont( "helvetica", 12 ) ); |
453 | AppLnk::setSmallIconSize( 24 ); | 476 | AppLnk::setSmallIconSize( 24 ); |
454 | AppLnk::setBigIconSize( 48 ); | 477 | AppLnk::setBigIconSize( 48 ); |
455 | }else if ( dw > 200 ) { | 478 | } |
479 | else if ( dw > 200 ) { | ||
456 | setFont( QFont( "helvetica", 12 ) ); | 480 | setFont( QFont( "helvetica", 12 ) ); |
457 | AppLnk::setSmallIconSize( 16 ); | 481 | AppLnk::setSmallIconSize( 16 ); |
458 | AppLnk::setBigIconSize( 32 ); | 482 | AppLnk::setBigIconSize( 32 ); |
459 | } | 483 | } |
460 | 484 | ||
461 | 485 | ||
@@ -544,17 +568,19 @@ QPEApplication::QPEApplication( int & argc, char **argv, Type t ) | |||
544 | installTranslator( trans ); | 568 | installTranslator( trans ); |
545 | else | 569 | else |
546 | delete trans; | 570 | delete trans; |
547 | 571 | ||
548 | //###language/font hack; should look it up somewhere | 572 | //###language/font hack; should look it up somewhere |
549 | #ifdef QWS | 573 | #ifdef QWS |
574 | |||
550 | if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) { | 575 | if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) { |
551 | QFont fn = FontManager::unicodeFont( FontManager::Proportional ); | 576 | QFont fn = FontManager::unicodeFont( FontManager::Proportional ); |
552 | setFont( fn ); | 577 | setFont( fn ); |
553 | } | 578 | } |
554 | #endif | 579 | #endif |
580 | |||
555 | } | 581 | } |
556 | #endif | 582 | #endif |
557 | 583 | ||
558 | applyStyle(); | 584 | applyStyle(); |
559 | 585 | ||
560 | if ( type() == GuiServer ) { | 586 | if ( type() == GuiServer ) { |
@@ -618,14 +644,20 @@ void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode ) | |||
618 | } | 644 | } |
619 | } | 645 | } |
620 | 646 | ||
621 | class HackDialog : public QDialog | 647 | class HackDialog : public QDialog |
622 | { | 648 | { |
623 | public: | 649 | public: |
624 | void acceptIt() { accept(); } | 650 | void acceptIt() |
625 | void rejectIt() { reject(); } | 651 | { |
652 | accept(); | ||
653 | } | ||
654 | void rejectIt() | ||
655 | { | ||
656 | reject(); | ||
657 | } | ||
626 | }; | 658 | }; |
627 | 659 | ||
628 | 660 | ||
629 | void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key ) | 661 | void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key ) |
630 | { | 662 | { |
631 | // specialised actions for certain widgets. May want to | 663 | // specialised actions for certain widgets. May want to |
@@ -636,21 +668,24 @@ void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key ) | |||
636 | key = Qt::Key_Return; | 668 | key = Qt::Key_Return; |
637 | 669 | ||
638 | if ( activePopupWidget() && activePopupWidget() ->inherits( "QPopupMenu" ) ) | 670 | if ( activePopupWidget() && activePopupWidget() ->inherits( "QPopupMenu" ) ) |
639 | key = Qt::Key_Return; | 671 | key = Qt::Key_Return; |
640 | 672 | ||
641 | #ifdef QWS | 673 | #ifdef QWS |
674 | |||
642 | ke->simpleData.keycode = key; | 675 | ke->simpleData.keycode = key; |
643 | #endif | 676 | #endif |
644 | } | 677 | } |
645 | 678 | ||
646 | class HackWidget : public QWidget | 679 | class HackWidget : public QWidget |
647 | { | 680 | { |
648 | public: | 681 | public: |
649 | bool needsOk() | 682 | bool needsOk() |
650 | { return ( getWState() & WState_Reserved1 ); } | 683 | { |
684 | return ( getWState() & WState_Reserved1 ); | ||
685 | } | ||
651 | }; | 686 | }; |
652 | 687 | ||
653 | /*! | 688 | /*! |
654 | \internal | 689 | \internal |
655 | */ | 690 | */ |
656 | 691 | ||
@@ -704,13 +739,14 @@ bool QPEApplication::qwsEventFilter( QWSEvent * e ) | |||
704 | else { | 739 | else { |
705 | // do the same as with the select key: Map to the default action of the widget: | 740 | // do the same as with the select key: Map to the default action of the widget: |
706 | mapToDefaultAction( ke, Qt::Key_Return ); | 741 | mapToDefaultAction( ke, Qt::Key_Return ); |
707 | } | 742 | } |
708 | } | 743 | } |
709 | } | 744 | } |
710 | } else if ( ke->simpleData.keycode == Qt::Key_F30 ) { | 745 | } |
746 | else if ( ke->simpleData.keycode == Qt::Key_F30 ) { | ||
711 | // Use special "select" key to do whatever default action a widget has | 747 | // Use special "select" key to do whatever default action a widget has |
712 | mapToDefaultAction( ke, Qt::Key_Space ); | 748 | mapToDefaultAction( ke, Qt::Key_Space ); |
713 | } | 749 | } |
714 | else if ( ke->simpleData.keycode == Qt::Key_Escape && | 750 | else if ( ke->simpleData.keycode == Qt::Key_Escape && |
715 | ke->simpleData.is_press ) { | 751 | ke->simpleData.is_press ) { |
716 | // Escape key closes app if focus on toplevel | 752 | // Escape key closes app if focus on toplevel |
@@ -848,16 +884,20 @@ void QPEApplication::setDefaultRotation( int r ) | |||
848 | if ( qApp->type() == GuiServer ) { | 884 | if ( qApp->type() == GuiServer ) { |
849 | deforient = r; | 885 | deforient = r; |
850 | setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 ); | 886 | setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 ); |
851 | Config config("qpe"); | 887 | Config config("qpe"); |
852 | config.setGroup( "Rotation" ); | 888 | config.setGroup( "Rotation" ); |
853 | config.writeEntry( "Screen", getenv("QWS_DISPLAY") ); | 889 | config.writeEntry( "Screen", getenv("QWS_DISPLAY") ); |
854 | } else { | 890 | } |
891 | else { | ||
855 | #ifndef QT_NO_COP | 892 | #ifndef QT_NO_COP |
856 | { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" ); e << r; } | 893 | { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" ); |
894 | e << r; | ||
895 | } | ||
857 | #endif | 896 | #endif |
897 | |||
858 | } | 898 | } |
859 | } | 899 | } |
860 | 900 | ||
861 | /*! | 901 | /*! |
862 | \internal | 902 | \internal |
863 | */ | 903 | */ |
@@ -907,116 +947,135 @@ void QPEApplication::applyStyle() | |||
907 | void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data ) | 947 | void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data ) |
908 | { | 948 | { |
909 | #ifdef Q_WS_QWS | 949 | #ifdef Q_WS_QWS |
910 | QDataStream stream( data, IO_ReadOnly ); | 950 | QDataStream stream( data, IO_ReadOnly ); |
911 | if ( msg == "applyStyle()" ) { | 951 | if ( msg == "applyStyle()" ) { |
912 | applyStyle(); | 952 | applyStyle(); |
913 | } else if ( msg == "setDefaultRotation(int)" ) { | 953 | } |
954 | else if ( msg == "setDefaultRotation(int)" ) { | ||
914 | if ( type() == GuiServer ) { | 955 | if ( type() == GuiServer ) { |
915 | int r; | 956 | int r; |
916 | stream >> r; | 957 | stream >> r; |
917 | setDefaultRotation( r ); | 958 | setDefaultRotation( r ); |
918 | } | 959 | } |
919 | } else if ( msg == "shutdown()" ) { | 960 | } |
961 | else if ( msg == "shutdown()" ) { | ||
920 | if ( type() == GuiServer ) | 962 | if ( type() == GuiServer ) |
921 | shutdown(); | 963 | shutdown(); |
922 | } else if ( msg == "quit()" ) { | 964 | } |
965 | else if ( msg == "quit()" ) { | ||
923 | if ( type() != GuiServer ) | 966 | if ( type() != GuiServer ) |
924 | tryQuit(); | 967 | tryQuit(); |
925 | } else if ( msg == "forceQuit()" ) { | 968 | } |
969 | else if ( msg == "forceQuit()" ) { | ||
926 | if ( type() != GuiServer ) | 970 | if ( type() != GuiServer ) |
927 | quit(); | 971 | quit(); |
928 | } else if ( msg == "restart()" ) { | 972 | } |
973 | else if ( msg == "restart()" ) { | ||
929 | if ( type() == GuiServer ) | 974 | if ( type() == GuiServer ) |
930 | restart(); | 975 | restart(); |
931 | } else if ( msg == "grabKeyboard(QString)" ) { | 976 | } |
977 | else if ( msg == "grabKeyboard(QString)" ) { | ||
932 | QString who; | 978 | QString who; |
933 | stream >> who; | 979 | stream >> who; |
934 | if ( who.isEmpty() ) | 980 | if ( who.isEmpty() ) |
935 | d->kbgrabber = 0; | 981 | d->kbgrabber = 0; |
936 | else if ( who != d->appName ) | 982 | else if ( who != d->appName ) |
937 | d->kbgrabber = 1; | 983 | d->kbgrabber = 1; |
938 | else | 984 | else |
939 | d->kbgrabber = 2; | 985 | d->kbgrabber = 2; |
940 | } else if ( msg == "language(QString)" ) { | 986 | } |
987 | else if ( msg == "language(QString)" ) { | ||
941 | if ( type() == GuiServer ) { | 988 | if ( type() == GuiServer ) { |
942 | QString l; | 989 | QString l; |
943 | stream >> l; | 990 | stream >> l; |
944 | QString cl = getenv( "LANG" ); | 991 | QString cl = getenv( "LANG" ); |
945 | if ( cl != l ) { | 992 | if ( cl != l ) { |
946 | if ( l.isNull() ) | 993 | if ( l.isNull() ) |
947 | unsetenv( "LANG" ); | 994 | unsetenv( "LANG" ); |
948 | else | 995 | else |
949 | setenv( "LANG", l.latin1(), 1 ); | 996 | setenv( "LANG", l.latin1(), 1 ); |
950 | restart(); | 997 | restart(); |
951 | } | 998 | } |
952 | } | 999 | } |
953 | } else if ( msg == "timeChange(QString)" ) { | 1000 | } |
1001 | else if ( msg == "timeChange(QString)" ) { | ||
954 | QString t; | 1002 | QString t; |
955 | stream >> t; | 1003 | stream >> t; |
956 | if ( t.isNull() ) | 1004 | if ( t.isNull() ) |
957 | unsetenv( "TZ" ); | 1005 | unsetenv( "TZ" ); |
958 | else | 1006 | else |
959 | setenv( "TZ", t.latin1(), 1 ); | 1007 | setenv( "TZ", t.latin1(), 1 ); |
960 | // emit the signal so everyone else knows... | 1008 | // emit the signal so everyone else knows... |
961 | emit timeChanged(); | 1009 | emit timeChanged(); |
962 | } else if ( msg == "execute(QString)" ) { | 1010 | } |
1011 | else if ( msg == "execute(QString)" ) { | ||
963 | if ( type() == GuiServer ) { | 1012 | if ( type() == GuiServer ) { |
964 | QString t; | 1013 | QString t; |
965 | stream >> t; | 1014 | stream >> t; |
966 | Global::execute( t ); | 1015 | Global::execute( t ); |
967 | } | 1016 | } |
968 | } else if ( msg == "execute(QString,QString)" ) { | 1017 | } |
1018 | else if ( msg == "execute(QString,QString)" ) { | ||
969 | if ( type() == GuiServer ) { | 1019 | if ( type() == GuiServer ) { |
970 | QString t, d; | 1020 | QString t, d; |
971 | stream >> t >> d; | 1021 | stream >> t >> d; |
972 | Global::execute( t, d ); | 1022 | Global::execute( t, d ); |
973 | } | 1023 | } |
974 | } else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) { | 1024 | } |
1025 | else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) { | ||
975 | if ( type() == GuiServer ) { | 1026 | if ( type() == GuiServer ) { |
976 | QDateTime when; | 1027 | QDateTime when; |
977 | QCString channel, message; | 1028 | QCString channel, message; |
978 | int data; | 1029 | int data; |
979 | stream >> when >> channel >> message >> data; | 1030 | stream >> when >> channel >> message >> data; |
980 | AlarmServer::addAlarm( when, channel, message, data ); | 1031 | AlarmServer::addAlarm( when, channel, message, data ); |
981 | } | 1032 | } |
982 | } else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) { | 1033 | } |
1034 | else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) { | ||
983 | if ( type() == GuiServer ) { | 1035 | if ( type() == GuiServer ) { |
984 | QDateTime when; | 1036 | QDateTime when; |
985 | QCString channel, message; | 1037 | QCString channel, message; |
986 | int data; | 1038 | int data; |
987 | stream >> when >> channel >> message >> data; | 1039 | stream >> when >> channel >> message >> data; |
988 | AlarmServer::deleteAlarm( when, channel, message, data ); | 1040 | AlarmServer::deleteAlarm( when, channel, message, data ); |
989 | } | 1041 | } |
990 | } else if ( msg == "clockChange(bool)" ) { | 1042 | } |
1043 | else if ( msg == "clockChange(bool)" ) { | ||
991 | int tmp; | 1044 | int tmp; |
992 | stream >> tmp; | 1045 | stream >> tmp; |
993 | emit clockChanged( tmp ); | 1046 | emit clockChanged( tmp ); |
994 | } else if ( msg == "weekChange(bool)" ) { | 1047 | } |
1048 | else if ( msg == "weekChange(bool)" ) { | ||
995 | int tmp; | 1049 | int tmp; |
996 | stream >> tmp; | 1050 | stream >> tmp; |
997 | emit weekChanged( tmp ); | 1051 | emit weekChanged( tmp ); |
998 | } else if ( msg == "setDateFormat(DateFormat)" ) { | 1052 | } |
1053 | else if ( msg == "setDateFormat(DateFormat)" ) { | ||
999 | DateFormat tmp; | 1054 | DateFormat tmp; |
1000 | stream >> tmp; | 1055 | stream >> tmp; |
1001 | emit dateFormatChanged( tmp ); | 1056 | emit dateFormatChanged( tmp ); |
1002 | } else if ( msg == "setVolume(int,int)" ) { | 1057 | } |
1058 | else if ( msg == "setVolume(int,int)" ) { | ||
1003 | int t, v; | 1059 | int t, v; |
1004 | stream >> t >> v; | 1060 | stream >> t >> v; |
1005 | setVolume( t, v ); | 1061 | setVolume( t, v ); |
1006 | emit volumeChanged( muted ); | 1062 | emit volumeChanged( muted ); |
1007 | } else if ( msg == "volumeChange(bool)" ) { | 1063 | } |
1064 | else if ( msg == "volumeChange(bool)" ) { | ||
1008 | stream >> muted; | 1065 | stream >> muted; |
1009 | setVolume(); | 1066 | setVolume(); |
1010 | emit volumeChanged( muted ); | 1067 | emit volumeChanged( muted ); |
1011 | } else if ( msg == "setMic(int,int)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> | 1068 | } |
1069 | else if ( msg == "setMic(int,int)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> | ||
1012 | int t, v; | 1070 | int t, v; |
1013 | stream >> t >> v; | 1071 | stream >> t >> v; |
1014 | setMic( t, v ); | 1072 | setMic( t, v ); |
1015 | emit micChanged( micMuted ); | 1073 | emit micChanged( micMuted ); |
1016 | } else if ( msg == "micChange(bool)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> | 1074 | } |
1075 | else if ( msg == "micChange(bool)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> | ||
1017 | stream >> micMuted; | 1076 | stream >> micMuted; |
1018 | setMic(); | 1077 | setMic(); |
1019 | emit micChanged( micMuted ); | 1078 | emit micChanged( micMuted ); |
1020 | } | 1079 | } |
1021 | #endif | 1080 | #endif |
1022 | } | 1081 | } |
@@ -1027,13 +1086,14 @@ void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data | |||
1027 | bool QPEApplication::raiseAppropriateWindow() | 1086 | bool QPEApplication::raiseAppropriateWindow() |
1028 | { | 1087 | { |
1029 | bool r=FALSE; | 1088 | bool r=FALSE; |
1030 | // ########## raise()ing main window should raise and set active | 1089 | // ########## raise()ing main window should raise and set active |
1031 | // ########## it and then all childen. This belongs in Qt/Embedded | 1090 | // ########## it and then all childen. This belongs in Qt/Embedded |
1032 | QWidget *top = d->qpe_main_widget; | 1091 | QWidget *top = d->qpe_main_widget; |
1033 | if ( !top ) top =mainWidget(); | 1092 | if ( !top ) |
1093 | top = mainWidget(); | ||
1034 | if ( top && d->keep_running ) { | 1094 | if ( top && d->keep_running ) { |
1035 | if ( top->isVisible() ) | 1095 | if ( top->isVisible() ) |
1036 | r = TRUE; | 1096 | r = TRUE; |
1037 | else if (d->preloaded) { | 1097 | else if (d->preloaded) { |
1038 | // We are preloaded and not visible.. pretend we just started.. | 1098 | // We are preloaded and not visible.. pretend we just started.. |
1039 | QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); | 1099 | QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); |
@@ -1062,57 +1122,67 @@ bool QPEApplication::raiseAppropriateWindow() | |||
1062 | void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data) | 1122 | void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data) |
1063 | { | 1123 | { |
1064 | #ifdef Q_WS_QWS | 1124 | #ifdef Q_WS_QWS |
1065 | 1125 | ||
1066 | if ( msg == "quit()" ) { | 1126 | if ( msg == "quit()" ) { |
1067 | tryQuit(); | 1127 | tryQuit(); |
1068 | } else if ( msg == "quitIfInvisible()" ) { | 1128 | } |
1129 | else if ( msg == "quitIfInvisible()" ) { | ||
1069 | if ( d->qpe_main_widget && !d->qpe_main_widget->isVisible() ) | 1130 | if ( d->qpe_main_widget && !d->qpe_main_widget->isVisible() ) |
1070 | quit(); | 1131 | quit(); |
1071 | } else if ( msg == "close()" ) { | 1132 | } |
1133 | else if ( msg == "close()" ) { | ||
1072 | hideOrQuit(); | 1134 | hideOrQuit(); |
1073 | } else if ( msg == "disablePreload()" ) { | 1135 | } |
1136 | else if ( msg == "disablePreload()" ) { | ||
1074 | d->preloaded = FALSE; | 1137 | d->preloaded = FALSE; |
1075 | d->keep_running = TRUE; | 1138 | d->keep_running = TRUE; |
1076 | /* so that quit will quit */ | 1139 | /* so that quit will quit */ |
1077 | } else if ( msg == "enablePreload()" ) { | 1140 | } |
1141 | else if ( msg == "enablePreload()" ) { | ||
1078 | if (d->qpe_main_widget) | 1142 | if (d->qpe_main_widget) |
1079 | d->preloaded = TRUE; | 1143 | d->preloaded = TRUE; |
1080 | d->keep_running = TRUE; | 1144 | d->keep_running = TRUE; |
1081 | /* so next quit won't quit */ | 1145 | /* so next quit won't quit */ |
1082 | } else if ( msg == "raise()" ) { | 1146 | } |
1147 | else if ( msg == "raise()" ) { | ||
1083 | d->keep_running = TRUE; | 1148 | d->keep_running = TRUE; |
1084 | d->notbusysent = FALSE; | 1149 | d->notbusysent = FALSE; |
1085 | raiseAppropriateWindow(); | 1150 | raiseAppropriateWindow(); |
1086 | // Tell the system we're still chugging along... | 1151 | // Tell the system we're still chugging along... |
1087 | QCopEnvelope e("QPE/System", "appRaised(QString)"); | 1152 | QCopEnvelope e("QPE/System", "appRaised(QString)"); |
1088 | e << d->appName; | 1153 | e << d->appName; |
1089 | } else if ( msg == "flush()" ) { | 1154 | } |
1155 | else if ( msg == "flush()" ) { | ||
1090 | emit flush(); | 1156 | emit flush(); |
1091 | // we need to tell the desktop | 1157 | // we need to tell the desktop |
1092 | QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" ); | 1158 | QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" ); |
1093 | e << d->appName; | 1159 | e << d->appName; |
1094 | } else if ( msg == "reload()" ) { | 1160 | } |
1161 | else if ( msg == "reload()" ) { | ||
1095 | emit reload(); | 1162 | emit reload(); |
1096 | } else if ( msg == "setDocument(QString)" ) { | 1163 | } |
1164 | else if ( msg == "setDocument(QString)" ) { | ||
1097 | d->keep_running = TRUE; | 1165 | d->keep_running = TRUE; |
1098 | QDataStream stream( data, IO_ReadOnly ); | 1166 | QDataStream stream( data, IO_ReadOnly ); |
1099 | QString doc; | 1167 | QString doc; |
1100 | stream >> doc; | 1168 | stream >> doc; |
1101 | QWidget *mw = mainWidget(); | 1169 | QWidget *mw = mainWidget(); |
1102 | if ( !mw ) | 1170 | if ( !mw ) |
1103 | mw = d->qpe_main_widget; | 1171 | mw = d->qpe_main_widget; |
1104 | if ( mw ) | 1172 | if ( mw ) |
1105 | Global::setDocument( mw, doc ); | 1173 | Global::setDocument( mw, doc ); |
1106 | } else if ( msg == "nextView()" ) { | 1174 | } |
1175 | else if ( msg == "nextView()" ) { | ||
1107 | qDebug("got nextView()"); | 1176 | qDebug("got nextView()"); |
1108 | /* | 1177 | /* |
1109 | if ( raiseAppropriateWindow() ) | 1178 | if ( raiseAppropriateWindow() ) |
1110 | */ | 1179 | */ |
1111 | emit appMessage( msg, data); | 1180 | emit appMessage( msg, data); |
1112 | } else { | 1181 | } |
1182 | else { | ||
1113 | emit appMessage( msg, data); | 1183 | emit appMessage( msg, data); |
1114 | } | 1184 | } |
1115 | 1185 | ||
1116 | #endif | 1186 | #endif |
1117 | } | 1187 | } |
1118 | 1188 | ||
@@ -1405,13 +1475,14 @@ bool QPEApplication::eventFilter( QObject *o, QEvent *e ) | |||
1405 | break; | 1475 | break; |
1406 | } | 1476 | } |
1407 | break; | 1477 | break; |
1408 | default: | 1478 | default: |
1409 | ; | 1479 | ; |
1410 | } | 1480 | } |
1411 | }else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { | 1481 | } |
1482 | else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { | ||
1412 | QKeyEvent *ke = (QKeyEvent *)e; | 1483 | QKeyEvent *ke = (QKeyEvent *)e; |
1413 | if ( ke->key() == Key_Enter ) { | 1484 | if ( ke->key() == Key_Enter ) { |
1414 | if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) { | 1485 | if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) { |
1415 | postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ', | 1486 | postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ', |
1416 | ke->state(), " ", ke->isAutoRepeat(), ke->count() ) ); | 1487 | ke->state(), " ", ke->isAutoRepeat(), ke->count() ) ); |
1417 | return TRUE; | 1488 | return TRUE; |
@@ -1463,12 +1534,13 @@ void QPEApplication::ungrabKeyboard() | |||
1463 | QPEApplicationData * d = ( ( QPEApplication* ) qApp ) ->d; | 1534 | QPEApplicationData * d = ( ( QPEApplication* ) qApp ) ->d; |
1464 | if ( d->kbgrabber == 2 ) { | 1535 | if ( d->kbgrabber == 2 ) { |
1465 | #ifndef QT_NO_COP | 1536 | #ifndef QT_NO_COP |
1466 | QCopEnvelope e( "QPE/System", "grabKeyboard(QString)" ); | 1537 | QCopEnvelope e( "QPE/System", "grabKeyboard(QString)" ); |
1467 | e << QString::null; | 1538 | e << QString::null; |
1468 | #endif | 1539 | #endif |
1540 | |||
1469 | d->kbregrab = FALSE; | 1541 | d->kbregrab = FALSE; |
1470 | d->kbgrabber = 0; | 1542 | d->kbgrabber = 0; |
1471 | } | 1543 | } |
1472 | } | 1544 | } |
1473 | 1545 | ||
1474 | /*! | 1546 | /*! |
@@ -1487,29 +1559,32 @@ void QPEApplication::grabKeyboard() | |||
1487 | d->kbgrabber = 0; | 1559 | d->kbgrabber = 0; |
1488 | else { | 1560 | else { |
1489 | #ifndef QT_NO_COP | 1561 | #ifndef QT_NO_COP |
1490 | QCopEnvelope e( "QPE/System", "grabKeyboard(QString)" ); | 1562 | QCopEnvelope e( "QPE/System", "grabKeyboard(QString)" ); |
1491 | e << d->appName; | 1563 | e << d->appName; |
1492 | #endif | 1564 | #endif |
1565 | |||
1493 | d->kbgrabber = 2; // me | 1566 | d->kbgrabber = 2; // me |
1494 | } | 1567 | } |
1495 | } | 1568 | } |
1496 | 1569 | ||
1497 | /*! | 1570 | /*! |
1498 | \reimp | 1571 | \reimp |
1499 | */ | 1572 | */ |
1500 | int QPEApplication::exec() | 1573 | int QPEApplication::exec() |
1501 | { | 1574 | { |
1502 | #ifndef QT_NO_COP | 1575 | #ifndef QT_NO_COP |
1503 | d->sendQCopQ(); | 1576 | d->sendQCopQ(); |
1504 | #endif | 1577 | #endif |
1578 | |||
1505 | if ( d->keep_running ) | 1579 | if ( d->keep_running ) |
1506 | //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() ) | 1580 | //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() ) |
1507 | return QApplication::exec(); | 1581 | return QApplication::exec(); |
1508 | 1582 | ||
1509 | #ifndef QT_NO_COP | 1583 | #ifndef QT_NO_COP |
1584 | |||
1510 | { | 1585 | { |
1511 | QCopEnvelope e( "QPE/System", "closing(QString)" ); | 1586 | QCopEnvelope e( "QPE/System", "closing(QString)" ); |
1512 | e << d->appName; | 1587 | e << d->appName; |
1513 | } | 1588 | } |
1514 | #endif | 1589 | #endif |
1515 | processEvents(); | 1590 | processEvents(); |
@@ -1523,12 +1598,13 @@ int QPEApplication::exec() | |||
1523 | */ | 1598 | */ |
1524 | void QPEApplication::tryQuit() | 1599 | void QPEApplication::tryQuit() |
1525 | { | 1600 | { |
1526 | if ( activeModalWidget() || strcmp( argv() [ 0 ], "embeddedkonsole" ) == 0 ) | 1601 | if ( activeModalWidget() || strcmp( argv() [ 0 ], "embeddedkonsole" ) == 0 ) |
1527 | return ; // Inside modal loop or konsole. Too hard to save state. | 1602 | return ; // Inside modal loop or konsole. Too hard to save state. |
1528 | #ifndef QT_NO_COP | 1603 | #ifndef QT_NO_COP |
1604 | |||
1529 | { | 1605 | { |
1530 | QCopEnvelope e( "QPE/System", "closing(QString)" ); | 1606 | QCopEnvelope e( "QPE/System", "closing(QString)" ); |
1531 | e << d->appName; | 1607 | e << d->appName; |
1532 | } | 1608 | } |
1533 | #endif | 1609 | #endif |
1534 | processEvents(); | 1610 | processEvents(); |
@@ -1547,12 +1623,13 @@ void QPEApplication::hideOrQuit() | |||
1547 | processEvents(); | 1623 | processEvents(); |
1548 | 1624 | ||
1549 | // If we are a preloaded application we don't actually quit, so emit | 1625 | // If we are a preloaded application we don't actually quit, so emit |
1550 | // a System message indicating we're quasi-closing. | 1626 | // a System message indicating we're quasi-closing. |
1551 | if ( d->preloaded && d->qpe_main_widget ) | 1627 | if ( d->preloaded && d->qpe_main_widget ) |
1552 | #ifndef QT_NO_COP | 1628 | #ifndef QT_NO_COP |
1629 | |||
1553 | { | 1630 | { |
1554 | QCopEnvelope e("QPE/System", "fastAppHiding(QString)" ); | 1631 | QCopEnvelope e("QPE/System", "fastAppHiding(QString)" ); |
1555 | e << d->appName; | 1632 | e << d->appName; |
1556 | d->qpe_main_widget->hide(); | 1633 | d->qpe_main_widget->hide(); |
1557 | } | 1634 | } |
1558 | #endif | 1635 | #endif |