-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 | |||
@@ -88,3 +88,4 @@ | |||
88 | 88 | ||
89 | class QPEApplicationData { | 89 | class QPEApplicationData |
90 | { | ||
90 | public: | 91 | public: |
@@ -101,11 +102,16 @@ public: | |||
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 | ||
@@ -115,7 +121,11 @@ public: | |||
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; |
@@ -127,5 +137,7 @@ public: | |||
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 ) |
@@ -133,8 +145,11 @@ public: | |||
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 |
@@ -144,2 +159,3 @@ public: | |||
144 | #endif | 159 | #endif |
160 | |||
145 | mw->show(); | 161 | mw->show(); |
@@ -177,4 +193,6 @@ public: | |||
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 ) { |
@@ -182,3 +200,4 @@ public: | |||
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); |
@@ -202,3 +221,4 @@ public: | |||
202 | } | 221 | } |
203 | } else { | 222 | } |
223 | else { | ||
204 | lib->unload(); | 224 | lib->unload(); |
@@ -224,3 +244,4 @@ public: | |||
224 | } | 244 | } |
225 | } else { | 245 | } |
246 | else { | ||
226 | lib->unload(); | 247 | lib->unload(); |
@@ -234,3 +255,4 @@ public: | |||
234 | 255 | ||
235 | class ResourceMimeFactory : public QMimeSourceFactory { | 256 | class ResourceMimeFactory : public QMimeSourceFactory |
257 | { | ||
236 | public: | 258 | public: |
@@ -450,3 +472,4 @@ QPEApplication::QPEApplication( int & argc, char **argv, Type t ) | |||
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 ) ); |
@@ -454,3 +477,4 @@ QPEApplication::QPEApplication( int & argc, char **argv, Type t ) | |||
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 ) ); |
@@ -549,2 +573,3 @@ QPEApplication::QPEApplication( int & argc, char **argv, Type t ) | |||
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" ) { |
@@ -554,2 +579,3 @@ QPEApplication::QPEApplication( int & argc, char **argv, Type t ) | |||
554 | #endif | 579 | #endif |
580 | |||
555 | } | 581 | } |
@@ -623,4 +649,10 @@ class HackDialog : public QDialog | |||
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 | }; |
@@ -641,2 +673,3 @@ void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key ) | |||
641 | #ifdef QWS | 673 | #ifdef QWS |
674 | |||
642 | ke->simpleData.keycode = key; | 675 | ke->simpleData.keycode = key; |
@@ -649,3 +682,5 @@ public: | |||
649 | bool needsOk() | 682 | bool needsOk() |
650 | { return ( getWState() & WState_Reserved1 ); } | 683 | { |
684 | return ( getWState() & WState_Reserved1 ); | ||
685 | } | ||
651 | }; | 686 | }; |
@@ -709,3 +744,4 @@ bool QPEApplication::qwsEventFilter( QWSEvent * e ) | |||
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 |
@@ -853,6 +889,10 @@ void QPEApplication::setDefaultRotation( int r ) | |||
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 | } |
@@ -912,3 +952,4 @@ void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data | |||
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 ) { |
@@ -918,15 +959,20 @@ void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data | |||
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; |
@@ -939,3 +985,4 @@ void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data | |||
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 ) { |
@@ -952,3 +999,4 @@ void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data | |||
952 | } | 999 | } |
953 | } else if ( msg == "timeChange(QString)" ) { | 1000 | } |
1001 | else if ( msg == "timeChange(QString)" ) { | ||
954 | QString t; | 1002 | QString t; |
@@ -961,3 +1009,4 @@ void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data | |||
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 ) { |
@@ -967,3 +1016,4 @@ void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data | |||
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 ) { |
@@ -973,3 +1023,4 @@ void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data | |||
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 ) { |
@@ -981,3 +1032,4 @@ void QPEApplication::systemMessage( const QCString& msg, const QByteArray& 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 ) { |
@@ -989,3 +1041,4 @@ void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data | |||
989 | } | 1041 | } |
990 | } else if ( msg == "clockChange(bool)" ) { | 1042 | } |
1043 | else if ( msg == "clockChange(bool)" ) { | ||
991 | int tmp; | 1044 | int tmp; |
@@ -993,3 +1046,4 @@ void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data | |||
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; |
@@ -997,3 +1051,4 @@ void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data | |||
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; |
@@ -1001,3 +1056,4 @@ void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data | |||
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; |
@@ -1006,3 +1062,4 @@ void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data | |||
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; |
@@ -1010,3 +1067,4 @@ void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data | |||
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; |
@@ -1015,3 +1073,4 @@ void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data | |||
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; |
@@ -1032,3 +1091,4 @@ bool QPEApplication::raiseAppropriateWindow() | |||
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 ) { |
@@ -1067,8 +1127,11 @@ void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data) | |||
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; |
@@ -1076,3 +1139,4 @@ void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data) | |||
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) |
@@ -1081,3 +1145,4 @@ void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data) | |||
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; |
@@ -1088,3 +1153,4 @@ void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data) | |||
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(); |
@@ -1093,5 +1159,7 @@ void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data) | |||
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; |
@@ -1105,3 +1173,4 @@ void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data) | |||
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()"); |
@@ -1111,3 +1180,4 @@ void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data) | |||
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); |
@@ -1410,3 +1480,4 @@ bool QPEApplication::eventFilter( QObject *o, QEvent *e ) | |||
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; |
@@ -1468,2 +1539,3 @@ void QPEApplication::ungrabKeyboard() | |||
1468 | #endif | 1539 | #endif |
1540 | |||
1469 | d->kbregrab = FALSE; | 1541 | d->kbregrab = FALSE; |
@@ -1492,2 +1564,3 @@ void QPEApplication::grabKeyboard() | |||
1492 | #endif | 1564 | #endif |
1565 | |||
1493 | d->kbgrabber = 2; // me | 1566 | d->kbgrabber = 2; // me |
@@ -1504,2 +1577,3 @@ int QPEApplication::exec() | |||
1504 | #endif | 1577 | #endif |
1578 | |||
1505 | if ( d->keep_running ) | 1579 | if ( d->keep_running ) |
@@ -1509,2 +1583,3 @@ int QPEApplication::exec() | |||
1509 | #ifndef QT_NO_COP | 1583 | #ifndef QT_NO_COP |
1584 | |||
1510 | { | 1585 | { |
@@ -1528,2 +1603,3 @@ void QPEApplication::tryQuit() | |||
1528 | #ifndef QT_NO_COP | 1603 | #ifndef QT_NO_COP |
1604 | |||
1529 | { | 1605 | { |
@@ -1552,2 +1628,3 @@ void QPEApplication::hideOrQuit() | |||
1552 | #ifndef QT_NO_COP | 1628 | #ifndef QT_NO_COP |
1629 | |||
1553 | { | 1630 | { |