-rw-r--r-- | library/qpeapplication.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp index a55f5f9..c154689 100644 --- a/library/qpeapplication.cpp +++ b/library/qpeapplication.cpp | |||
@@ -898,711 +898,711 @@ void QPEApplication::systemMessage( const QCString &msg, const QByteArray &data) | |||
898 | } | 898 | } |
899 | } else if ( msg == "setScreenSaverIntervals(int,int,int)" ) { | 899 | } else if ( msg == "setScreenSaverIntervals(int,int,int)" ) { |
900 | if ( type() == GuiServer ) { | 900 | if ( type() == GuiServer ) { |
901 | int t1,t2,t3; | 901 | int t1,t2,t3; |
902 | stream >> t1 >> t2 >> t3; | 902 | stream >> t1 >> t2 >> t3; |
903 | setScreenSaverIntervals(t1,t2,t3); | 903 | setScreenSaverIntervals(t1,t2,t3); |
904 | } | 904 | } |
905 | } else if ( msg == "setBacklight(int)" ) { | 905 | } else if ( msg == "setBacklight(int)" ) { |
906 | if ( type() == GuiServer ) { | 906 | if ( type() == GuiServer ) { |
907 | int bright; | 907 | int bright; |
908 | stream >> bright; | 908 | stream >> bright; |
909 | setBacklight(bright); | 909 | setBacklight(bright); |
910 | } | 910 | } |
911 | } else if ( msg == "setDefaultRotation(int)" ) { | 911 | } else if ( msg == "setDefaultRotation(int)" ) { |
912 | if ( type() == GuiServer ) { | 912 | if ( type() == GuiServer ) { |
913 | int r; | 913 | int r; |
914 | stream >> r; | 914 | stream >> r; |
915 | setDefaultRotation(r); | 915 | setDefaultRotation(r); |
916 | } | 916 | } |
917 | } else if ( msg == "shutdown()" ) { | 917 | } else if ( msg == "shutdown()" ) { |
918 | if ( type() == GuiServer ) | 918 | if ( type() == GuiServer ) |
919 | shutdown(); | 919 | shutdown(); |
920 | } else if ( msg == "quit()" ) { | 920 | } else if ( msg == "quit()" ) { |
921 | if ( type() != GuiServer ) | 921 | if ( type() != GuiServer ) |
922 | tryQuit(); | 922 | tryQuit(); |
923 | } else if ( msg == "forceQuit()" ) { | 923 | } else if ( msg == "forceQuit()" ) { |
924 | if ( type() != GuiServer ) | 924 | if ( type() != GuiServer ) |
925 | quit(); | 925 | quit(); |
926 | } else if ( msg == "restart()" ) { | 926 | } else if ( msg == "restart()" ) { |
927 | if ( type() == GuiServer ) | 927 | if ( type() == GuiServer ) |
928 | restart(); | 928 | restart(); |
929 | } else if ( msg == "grabKeyboard(QString)" ) { | 929 | } else if ( msg == "grabKeyboard(QString)" ) { |
930 | QString who; | 930 | QString who; |
931 | stream >> who; | 931 | stream >> who; |
932 | if ( who.isEmpty() ) | 932 | if ( who.isEmpty() ) |
933 | d->kbgrabber = 0; | 933 | d->kbgrabber = 0; |
934 | else if ( who != d->appName ) | 934 | else if ( who != d->appName ) |
935 | d->kbgrabber = 1; | 935 | d->kbgrabber = 1; |
936 | else | 936 | else |
937 | d->kbgrabber = 2; | 937 | d->kbgrabber = 2; |
938 | } else if ( msg == "language(QString)" ) { | 938 | } else if ( msg == "language(QString)" ) { |
939 | if ( type() == GuiServer ) { | 939 | if ( type() == GuiServer ) { |
940 | QString l; | 940 | QString l; |
941 | stream >> l; | 941 | stream >> l; |
942 | QString cl = getenv("LANG"); | 942 | QString cl = getenv("LANG"); |
943 | if ( cl != l ) { | 943 | if ( cl != l ) { |
944 | if ( l.isNull() ) | 944 | if ( l.isNull() ) |
945 | unsetenv( "LANG" ); | 945 | unsetenv( "LANG" ); |
946 | else | 946 | else |
947 | setenv( "LANG", l.latin1(), 1 ); | 947 | setenv( "LANG", l.latin1(), 1 ); |
948 | restart(); | 948 | restart(); |
949 | } | 949 | } |
950 | } | 950 | } |
951 | } else if ( msg == "timeChange(QString)" ) { | 951 | } else if ( msg == "timeChange(QString)" ) { |
952 | QString t; | 952 | QString t; |
953 | stream >> t; | 953 | stream >> t; |
954 | if ( t.isNull() ) | 954 | if ( t.isNull() ) |
955 | unsetenv( "TZ" ); | 955 | unsetenv( "TZ" ); |
956 | else | 956 | else |
957 | setenv( "TZ", t.latin1(), 1 ); | 957 | setenv( "TZ", t.latin1(), 1 ); |
958 | // emit the signal so everyone else knows... | 958 | // emit the signal so everyone else knows... |
959 | emit timeChanged(); | 959 | emit timeChanged(); |
960 | } else if ( msg == "execute(QString)" ) { | 960 | } else if ( msg == "execute(QString)" ) { |
961 | if ( type() == GuiServer ) { | 961 | if ( type() == GuiServer ) { |
962 | QString t; | 962 | QString t; |
963 | stream >> t; | 963 | stream >> t; |
964 | Global::execute( t ); | 964 | Global::execute( t ); |
965 | } | 965 | } |
966 | } else if ( msg == "execute(QString,QString)" ) { | 966 | } else if ( msg == "execute(QString,QString)" ) { |
967 | if ( type() == GuiServer ) { | 967 | if ( type() == GuiServer ) { |
968 | QString t,d; | 968 | QString t,d; |
969 | stream >> t >> d; | 969 | stream >> t >> d; |
970 | Global::execute( t, d ); | 970 | Global::execute( t, d ); |
971 | } | 971 | } |
972 | } else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) { | 972 | } else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) { |
973 | if ( type() == GuiServer ) { | 973 | if ( type() == GuiServer ) { |
974 | QDateTime when; | 974 | QDateTime when; |
975 | QCString channel, message; | 975 | QCString channel, message; |
976 | int data; | 976 | int data; |
977 | stream >> when >> channel >> message >> data; | 977 | stream >> when >> channel >> message >> data; |
978 | AlarmServer::addAlarm( when, channel, message, data ); | 978 | AlarmServer::addAlarm( when, channel, message, data ); |
979 | } | 979 | } |
980 | } else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) { | 980 | } else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) { |
981 | if ( type() == GuiServer ) { | 981 | if ( type() == GuiServer ) { |
982 | QDateTime when; | 982 | QDateTime when; |
983 | QCString channel, message; | 983 | QCString channel, message; |
984 | int data; | 984 | int data; |
985 | stream >> when >> channel >> message >> data; | 985 | stream >> when >> channel >> message >> data; |
986 | AlarmServer::deleteAlarm( when, channel, message, data ); | 986 | AlarmServer::deleteAlarm( when, channel, message, data ); |
987 | } | 987 | } |
988 | } else if ( msg == "clockChange(bool)" ) { | 988 | } else if ( msg == "clockChange(bool)" ) { |
989 | int tmp; | 989 | int tmp; |
990 | stream >> tmp; | 990 | stream >> tmp; |
991 | emit clockChanged( tmp ); | 991 | emit clockChanged( tmp ); |
992 | } else if ( msg == "weekChange(bool)" ) { | 992 | } else if ( msg == "weekChange(bool)" ) { |
993 | int tmp; | 993 | int tmp; |
994 | stream >> tmp; | 994 | stream >> tmp; |
995 | emit weekChanged( tmp ); | 995 | emit weekChanged( tmp ); |
996 | } else if ( msg == "setDateFormat(DateFormat)" ) { | 996 | } else if ( msg == "setDateFormat(DateFormat)" ) { |
997 | DateFormat tmp; | 997 | DateFormat tmp; |
998 | stream >> tmp; | 998 | stream >> tmp; |
999 | emit dateFormatChanged( tmp ); | 999 | emit dateFormatChanged( tmp ); |
1000 | } else if ( msg == "setVolume(int,int)" ) { | 1000 | } else if ( msg == "setVolume(int,int)" ) { |
1001 | int t,v; | 1001 | int t,v; |
1002 | stream >> t >> v; | 1002 | stream >> t >> v; |
1003 | setVolume(t,v); | 1003 | setVolume(t,v); |
1004 | emit volumeChanged( muted ); | 1004 | emit volumeChanged( muted ); |
1005 | } else if ( msg == "volumeChange(bool)" ) { | 1005 | } else if ( msg == "volumeChange(bool)" ) { |
1006 | stream >> muted; | 1006 | stream >> muted; |
1007 | setVolume(); | 1007 | setVolume(); |
1008 | emit volumeChanged( muted ); | 1008 | emit volumeChanged( muted ); |
1009 | } else if ( msg == "setMic(int,int)") { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> | 1009 | } else if ( msg == "setMic(int,int)") { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> |
1010 | int t,v; | 1010 | int t,v; |
1011 | stream >> t >> v; | 1011 | stream >> t >> v; |
1012 | setMic(t,v); | 1012 | setMic(t,v); |
1013 | emit micChanged( micMuted ); | 1013 | emit micChanged( micMuted ); |
1014 | } else if ( msg == "micChange(bool)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> | 1014 | } else if ( msg == "micChange(bool)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> |
1015 | stream >> micMuted; | 1015 | stream >> micMuted; |
1016 | setMic(); | 1016 | setMic(); |
1017 | emit micChanged( micMuted ); | 1017 | emit micChanged( micMuted ); |
1018 | } else if ( msg == "setScreenSaverMode(int)" ) { | 1018 | } else if ( msg == "setScreenSaverMode(int)" ) { |
1019 | if ( type() == GuiServer ) { | 1019 | if ( type() == GuiServer ) { |
1020 | int old = disable_suspend; | 1020 | int old = disable_suspend; |
1021 | stream >> disable_suspend; | 1021 | stream >> disable_suspend; |
1022 | //qDebug("setScreenSaverMode(%d)", disable_suspend ); | 1022 | //qDebug("setScreenSaverMode(%d)", disable_suspend ); |
1023 | if ( disable_suspend > old ) | 1023 | if ( disable_suspend > old ) |
1024 | setScreenSaverInterval( -1 ); | 1024 | setScreenSaverInterval( -1 ); |
1025 | } | 1025 | } |
1026 | } | 1026 | } |
1027 | #endif | 1027 | #endif |
1028 | } | 1028 | } |
1029 | 1029 | ||
1030 | /*! | 1030 | /*! |
1031 | \internal | 1031 | \internal |
1032 | */ | 1032 | */ |
1033 | bool QPEApplication::raiseAppropriateWindow() | 1033 | bool QPEApplication::raiseAppropriateWindow() |
1034 | { | 1034 | { |
1035 | bool r=FALSE; | 1035 | bool r=FALSE; |
1036 | // ########## raise()ing main window should raise and set active | 1036 | // ########## raise()ing main window should raise and set active |
1037 | // ########## it and then all childen. This belongs in Qt/Embedded | 1037 | // ########## it and then all childen. This belongs in Qt/Embedded |
1038 | QWidget *top = d->qpe_main_widget; | 1038 | QWidget *top = d->qpe_main_widget; |
1039 | if ( !top ) top =mainWidget(); | 1039 | if ( !top ) top =mainWidget(); |
1040 | if ( top && d->keep_running ) { | 1040 | if ( top && d->keep_running ) { |
1041 | if ( top->isVisible() ) | 1041 | if ( top->isVisible() ) |
1042 | r = TRUE; | 1042 | r = TRUE; |
1043 | #ifdef Q_WS_QWS | 1043 | #ifdef Q_WS_QWS |
1044 | if ( !d->nomaximize ) | 1044 | if ( !d->nomaximize ) |
1045 | top->showMaximized(); | 1045 | top->showMaximized(); |
1046 | else | 1046 | else |
1047 | #endif | 1047 | #endif |
1048 | top->show(); | 1048 | top->show(); |
1049 | top->raise(); | 1049 | top->raise(); |
1050 | top->setActiveWindow(); | 1050 | top->setActiveWindow(); |
1051 | } | 1051 | } |
1052 | QWidget *topm = activeModalWidget(); | 1052 | QWidget *topm = activeModalWidget(); |
1053 | if ( topm && topm != top ) { | 1053 | if ( topm && topm != top ) { |
1054 | topm->show(); | 1054 | topm->show(); |
1055 | topm->raise(); | 1055 | topm->raise(); |
1056 | topm->setActiveWindow(); | 1056 | topm->setActiveWindow(); |
1057 | r = FALSE; | 1057 | r = FALSE; |
1058 | } | 1058 | } |
1059 | return r; | 1059 | return r; |
1060 | } | 1060 | } |
1061 | 1061 | ||
1062 | void QPEApplication::pidMessage( const QCString &msg, const QByteArray & data) | 1062 | void QPEApplication::pidMessage( const QCString &msg, const QByteArray & data) |
1063 | { | 1063 | { |
1064 | #ifdef Q_WS_QWS | 1064 | #ifdef Q_WS_QWS |
1065 | 1065 | ||
1066 | if ( msg == "quit()" ) { | 1066 | if ( msg == "quit()" ) { |
1067 | tryQuit(); | 1067 | tryQuit(); |
1068 | } else if ( msg == "quitIfInvisible()" ) { | 1068 | } else if ( msg == "quitIfInvisible()" ) { |
1069 | if ( d->qpe_main_widget && !d->qpe_main_widget->isVisible() ) | 1069 | if ( d->qpe_main_widget && !d->qpe_main_widget->isVisible() ) |
1070 | quit(); | 1070 | quit(); |
1071 | } else if ( msg == "close()" ) { | 1071 | } else if ( msg == "close()" ) { |
1072 | hideOrQuit(); | 1072 | hideOrQuit(); |
1073 | } else if ( msg == "disablePreload()" ) { | 1073 | } else if ( msg == "disablePreload()" ) { |
1074 | d->preloaded = FALSE; | 1074 | d->preloaded = FALSE; |
1075 | d->keep_running = TRUE; | 1075 | d->keep_running = TRUE; |
1076 | /* so that quit will quit */ | 1076 | /* so that quit will quit */ |
1077 | } else if ( msg == "enablePreload()" ) { | 1077 | } else if ( msg == "enablePreload()" ) { |
1078 | d->preloaded = TRUE; | 1078 | d->preloaded = TRUE; |
1079 | d->keep_running = TRUE; | 1079 | d->keep_running = TRUE; |
1080 | /* so next quit won't quit */ | 1080 | /* so next quit won't quit */ |
1081 | } else if ( msg == "raise()" ) { | 1081 | } else if ( msg == "raise()" ) { |
1082 | d->keep_running = TRUE; | 1082 | d->keep_running = TRUE; |
1083 | d->notbusysent = FALSE; | 1083 | d->notbusysent = FALSE; |
1084 | raiseAppropriateWindow(); | 1084 | raiseAppropriateWindow(); |
1085 | } else if ( msg == "flush()" ) { | 1085 | } else if ( msg == "flush()" ) { |
1086 | emit flush(); | 1086 | emit flush(); |
1087 | // we need to tell the desktop | 1087 | // we need to tell the desktop |
1088 | QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" ); | 1088 | QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" ); |
1089 | e << d->appName; | 1089 | e << d->appName; |
1090 | } else if ( msg == "reload()" ) { | 1090 | } else if ( msg == "reload()" ) { |
1091 | emit reload(); | 1091 | emit reload(); |
1092 | } else if ( msg == "setDocument(QString)" ) { | 1092 | } else if ( msg == "setDocument(QString)" ) { |
1093 | d->keep_running = TRUE; | 1093 | d->keep_running = TRUE; |
1094 | QDataStream stream( data, IO_ReadOnly ); | 1094 | QDataStream stream( data, IO_ReadOnly ); |
1095 | QString doc; | 1095 | QString doc; |
1096 | stream >> doc; | 1096 | stream >> doc; |
1097 | QWidget *mw = mainWidget(); | 1097 | QWidget *mw = mainWidget(); |
1098 | if ( !mw ) | 1098 | if ( !mw ) |
1099 | mw = d->qpe_main_widget; | 1099 | mw = d->qpe_main_widget; |
1100 | if ( mw ) | 1100 | if ( mw ) |
1101 | Global::setDocument( mw, doc ); | 1101 | Global::setDocument( mw, doc ); |
1102 | } else if ( msg == "nextView()" ) { | 1102 | } else if ( msg == "nextView()" ) { |
1103 | if ( raiseAppropriateWindow() ) | 1103 | if ( raiseAppropriateWindow() ) |
1104 | emit appMessage( msg, data); | 1104 | emit appMessage( msg, data); |
1105 | } else { | 1105 | } else { |
1106 | emit appMessage( msg, data); | 1106 | emit appMessage( msg, data); |
1107 | } | 1107 | } |
1108 | #endif | 1108 | #endif |
1109 | } | 1109 | } |
1110 | 1110 | ||
1111 | 1111 | ||
1112 | static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) | 1112 | static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) |
1113 | { | 1113 | { |
1114 | /* | 1114 | /* |
1115 | // This works but disable it for now until it is safe to apply | 1115 | // This works but disable it for now until it is safe to apply |
1116 | // What is does is scan the .desktop files of all the apps for | 1116 | // What is does is scan the .desktop files of all the apps for |
1117 | // the applnk that has the corresponding argv[0] as this program | 1117 | // the applnk that has the corresponding argv[0] as this program |
1118 | // then it uses the name stored in the .desktop file as the caption | 1118 | // then it uses the name stored in the .desktop file as the caption |
1119 | // for the main widget. This saves duplicating translations for | 1119 | // for the main widget. This saves duplicating translations for |
1120 | // the app name in the program and in the .desktop files. | 1120 | // the app name in the program and in the .desktop files. |
1121 | 1121 | ||
1122 | AppLnkSet apps( appsPath ); | 1122 | AppLnkSet apps( appsPath ); |
1123 | 1123 | ||
1124 | QList<AppLnk> appsList = apps.children(); | 1124 | QList<AppLnk> appsList = apps.children(); |
1125 | for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) { | 1125 | for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) { |
1126 | if ( (*it)->exec() == appName ) { | 1126 | if ( (*it)->exec() == appName ) { |
1127 | mw->setCaption( (*it)->name() ); | 1127 | mw->setCaption( (*it)->name() ); |
1128 | return TRUE; | 1128 | return TRUE; |
1129 | } | 1129 | } |
1130 | } | 1130 | } |
1131 | */ | 1131 | */ |
1132 | return FALSE; | 1132 | return FALSE; |
1133 | } | 1133 | } |
1134 | 1134 | ||
1135 | 1135 | ||
1136 | /*! | 1136 | /*! |
1137 | Sets \a mw as the mainWidget() and shows it. For small windows, | 1137 | Sets \a mw as the mainWidget() and shows it. For small windows, |
1138 | consider passing TRUE for \a nomaximize rather than the default FALSE. | 1138 | consider passing TRUE for \a nomaximize rather than the default FALSE. |
1139 | 1139 | ||
1140 | \sa showMainDocumentWidget() | 1140 | \sa showMainDocumentWidget() |
1141 | */ | 1141 | */ |
1142 | void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize ) | 1142 | void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize ) |
1143 | { | 1143 | { |
1144 | setWidgetCaptionFromAppName( mw, d->appName, qpeDir() + "apps" ); | 1144 | setWidgetCaptionFromAppName( mw, d->appName, qpeDir() + "apps" ); |
1145 | 1145 | ||
1146 | d->nomaximize = nomaximize; | 1146 | d->nomaximize = nomaximize; |
1147 | d->qpe_main_widget = mw; | 1147 | d->qpe_main_widget = mw; |
1148 | d->sendQCopQ(); | 1148 | d->sendQCopQ(); |
1149 | if ( d->preloaded ) { | 1149 | if ( d->preloaded ) { |
1150 | if(d->forceshow) { | 1150 | if(d->forceshow) { |
1151 | #ifdef Q_WS_QWS | 1151 | #ifdef Q_WS_QWS |
1152 | if ( !nomaximize ) | 1152 | if ( !nomaximize ) |
1153 | mw->showMaximized(); | 1153 | mw->showMaximized(); |
1154 | else | 1154 | else |
1155 | #endif | 1155 | #endif |
1156 | mw->show(); | 1156 | mw->show(); |
1157 | } | 1157 | } |
1158 | } else if ( d->keep_running ) { | 1158 | } else if ( d->keep_running ) { |
1159 | #ifdef Q_WS_QWS | 1159 | #ifdef Q_WS_QWS |
1160 | if ( !nomaximize ) | 1160 | if ( !nomaximize ) |
1161 | mw->showMaximized(); | 1161 | mw->showMaximized(); |
1162 | else | 1162 | else |
1163 | #endif | 1163 | #endif |
1164 | mw->show(); | 1164 | mw->show(); |
1165 | } | 1165 | } |
1166 | } | 1166 | } |
1167 | 1167 | ||
1168 | /*! | 1168 | /*! |
1169 | Sets \a mw as the mainWidget() and shows it. For small windows, | 1169 | Sets \a mw as the mainWidget() and shows it. For small windows, |
1170 | consider passing TRUE for \a nomaximize rather than the default FALSE. | 1170 | consider passing TRUE for \a nomaximize rather than the default FALSE. |
1171 | 1171 | ||
1172 | This calls designates the application as | 1172 | This calls designates the application as |
1173 | a \link docwidget.html document-oriented\endlink application. | 1173 | a \link docwidget.html document-oriented\endlink application. |
1174 | 1174 | ||
1175 | The \a mw widget must have a slot: setDocument(const QString&). | 1175 | The \a mw widget must have a slot: setDocument(const QString&). |
1176 | 1176 | ||
1177 | \sa showMainWidget() | 1177 | \sa showMainWidget() |
1178 | */ | 1178 | */ |
1179 | void QPEApplication::showMainDocumentWidget( QWidget* mw, bool nomaximize ) | 1179 | void QPEApplication::showMainDocumentWidget( QWidget* mw, bool nomaximize ) |
1180 | { | 1180 | { |
1181 | setWidgetCaptionFromAppName( mw, d->appName, qpeDir() + "apps" ); | 1181 | setWidgetCaptionFromAppName( mw, d->appName, qpeDir() + "apps" ); |
1182 | 1182 | ||
1183 | if ( mw && argc() == 2 ) | 1183 | if ( mw && argc() == 2 ) |
1184 | Global::setDocument( mw, QString::fromUtf8(argv()[1]) ); | 1184 | Global::setDocument( mw, QString::fromUtf8(argv()[1]) ); |
1185 | d->nomaximize = nomaximize; | 1185 | d->nomaximize = nomaximize; |
1186 | d->qpe_main_widget = mw; | 1186 | d->qpe_main_widget = mw; |
1187 | d->sendQCopQ(); | 1187 | d->sendQCopQ(); |
1188 | if ( d->preloaded ) { | 1188 | if ( d->preloaded ) { |
1189 | if(d->forceshow) { | 1189 | if(d->forceshow) { |
1190 | #ifdef Q_WS_QWS | 1190 | #ifdef Q_WS_QWS |
1191 | if ( !nomaximize ) | 1191 | if ( !nomaximize ) |
1192 | mw->showMaximized(); | 1192 | mw->showMaximized(); |
1193 | else | 1193 | else |
1194 | #endif | 1194 | #endif |
1195 | mw->show(); | 1195 | mw->show(); |
1196 | } | 1196 | } |
1197 | } else if ( d->keep_running ) { | 1197 | } else if ( d->keep_running ) { |
1198 | #ifdef Q_WS_QWS | 1198 | #ifdef Q_WS_QWS |
1199 | if ( !nomaximize ) | 1199 | if ( !nomaximize ) |
1200 | mw->showMaximized(); | 1200 | mw->showMaximized(); |
1201 | else | 1201 | else |
1202 | #endif | 1202 | #endif |
1203 | mw->show(); | 1203 | mw->show(); |
1204 | } | 1204 | } |
1205 | } | 1205 | } |
1206 | 1206 | ||
1207 | 1207 | ||
1208 | /*! | 1208 | /*! |
1209 | Sets that the application should continue running after processing | 1209 | Sets that the application should continue running after processing |
1210 | qcop messages. Normally if an application is started via a qcop message, | 1210 | qcop messages. Normally if an application is started via a qcop message, |
1211 | the application will process the qcop message and then quit. If while | 1211 | the application will process the qcop message and then quit. If while |
1212 | processing the qcop message it calls this function, then the application | 1212 | processing the qcop message it calls this function, then the application |
1213 | will show and start proper once it has finished processing qcop messages. | 1213 | will show and start proper once it has finished processing qcop messages. |
1214 | 1214 | ||
1215 | \sa keepRunning() | 1215 | \sa keepRunning() |
1216 | */ | 1216 | */ |
1217 | void QPEApplication::setKeepRunning() | 1217 | void QPEApplication::setKeepRunning() |
1218 | { | 1218 | { |
1219 | if ( qApp && qApp->inherits( "QPEApplication" ) ) { | 1219 | if ( qApp && qApp->inherits( "QPEApplication" ) ) { |
1220 | QPEApplication *qpeApp = (QPEApplication*)qApp; | 1220 | QPEApplication *qpeApp = (QPEApplication*)qApp; |
1221 | qpeApp->d->keep_running = TRUE; | 1221 | qpeApp->d->keep_running = TRUE; |
1222 | } | 1222 | } |
1223 | } | 1223 | } |
1224 | 1224 | ||
1225 | /*! | 1225 | /*! |
1226 | Returns whether the application will quit after processing the current | 1226 | Returns whether the application will quit after processing the current |
1227 | list of qcop messages. | 1227 | list of qcop messages. |
1228 | 1228 | ||
1229 | \sa setKeepRunning() | 1229 | \sa setKeepRunning() |
1230 | */ | 1230 | */ |
1231 | bool QPEApplication::keepRunning() const | 1231 | bool QPEApplication::keepRunning() const |
1232 | { | 1232 | { |
1233 | return d->keep_running; | 1233 | return d->keep_running; |
1234 | } | 1234 | } |
1235 | 1235 | ||
1236 | /*! | 1236 | /*! |
1237 | \internal | 1237 | \internal |
1238 | */ | 1238 | */ |
1239 | void QPEApplication::internalSetStyle( const QString &style ) | 1239 | void QPEApplication::internalSetStyle( const QString &style ) |
1240 | { | 1240 | { |
1241 | #if QT_VERSION >= 300 | 1241 | #if QT_VERSION >= 300 |
1242 | if ( style == "QPE" ) { | 1242 | if ( style == "QPE" ) { |
1243 | setStyle( new QPEStyle ); | 1243 | setStyle( new QPEStyle ); |
1244 | } else { | 1244 | } else { |
1245 | QStyle *s = QStyleFactory::create(style); | 1245 | QStyle *s = QStyleFactory::create(style); |
1246 | if ( s ) setStyle(s); | 1246 | if ( s ) setStyle(s); |
1247 | } | 1247 | } |
1248 | #else | 1248 | #else |
1249 | if ( style == "Windows" ) { | 1249 | if ( style == "Windows" ) { |
1250 | setStyle( new QWindowsStyle ); | 1250 | setStyle( new QWindowsStyle ); |
1251 | } else if ( style == "QPE" ) { | 1251 | } else if ( style == "QPE" ) { |
1252 | setStyle( new QPEStyle ); | 1252 | setStyle( new QPEStyle ); |
1253 | } else if ( style == "Light" ) { | 1253 | } else if ( style == "Light" ) { |
1254 | setStyle( new LightStyle ); | 1254 | setStyle( new LightStyle ); |
1255 | } | 1255 | } |
1256 | #ifndef QT_NO_STYLE_PLATINUM | 1256 | #ifndef QT_NO_STYLE_PLATINUM |
1257 | else if ( style == "Platinum" ) { | 1257 | else if ( style == "Platinum" ) { |
1258 | setStyle( new QPlatinumStyle ); | 1258 | setStyle( new QPlatinumStyle ); |
1259 | } | 1259 | } |
1260 | #endif | 1260 | #endif |
1261 | #ifndef QT_NO_STYLE_MOTIF | 1261 | #ifndef QT_NO_STYLE_MOTIF |
1262 | else if ( style == "Motif" ) { | 1262 | else if ( style == "Motif" ) { |
1263 | setStyle( new QMotifStyle ); | 1263 | setStyle( new QMotifStyle ); |
1264 | } | 1264 | } |
1265 | #endif | 1265 | #endif |
1266 | #ifndef QT_NO_STYLE_MOTIFPLUS | 1266 | #ifndef QT_NO_STYLE_MOTIFPLUS |
1267 | else if ( style == "MotifPlus" ) { | 1267 | else if ( style == "MotifPlus" ) { |
1268 | setStyle( new QMotifPlusStyle ); | 1268 | setStyle( new QMotifPlusStyle ); |
1269 | } | 1269 | } |
1270 | #endif | 1270 | #endif |
1271 | #endif | 1271 | #endif |
1272 | } | 1272 | } |
1273 | 1273 | ||
1274 | /*! | 1274 | /*! |
1275 | \internal | 1275 | \internal |
1276 | */ | 1276 | */ |
1277 | void QPEApplication::prepareForTermination(bool willrestart) | 1277 | void QPEApplication::prepareForTermination(bool willrestart) |
1278 | { | 1278 | { |
1279 | if ( willrestart ) { | 1279 | if ( willrestart ) { |
1280 | // Draw a big wait icon, the image can be altered in later revisions | 1280 | // Draw a big wait icon, the image can be altered in later revisions |
1281 | //QWidget *d = QApplication::desktop(); | 1281 | //QWidget *d = QApplication::desktop(); |
1282 | QImage img = Resource::loadImage( "wait" ); | 1282 | QImage img = Resource::loadImage( "launcher/new_wait" ); |
1283 | QPixmap pix; | 1283 | QPixmap pix; |
1284 | pix.convertFromImage(img.smoothScale(3*img.width(), 3*img.height())); | 1284 | pix.convertFromImage(img.smoothScale(1*img.width(), 1*img.height())); |
1285 | QLabel *lblWait = new QLabel(0, "wait hack!", QWidget::WStyle_Customize | | 1285 | QLabel *lblWait = new QLabel(0, "wait hack!", QWidget::WStyle_Customize | |
1286 | QWidget::WStyle_NoBorder | QWidget::WStyle_Tool ); | 1286 | QWidget::WStyle_NoBorder | QWidget::WStyle_Tool ); |
1287 | lblWait->setPixmap( pix ); | 1287 | lblWait->setPixmap( pix ); |
1288 | lblWait->setAlignment( QWidget::AlignCenter ); | 1288 | lblWait->setAlignment( QWidget::AlignCenter ); |
1289 | lblWait->show(); | 1289 | lblWait->show(); |
1290 | lblWait->showMaximized(); | 1290 | lblWait->showMaximized(); |
1291 | } | 1291 | } |
1292 | #ifndef SINGLE_APP | 1292 | #ifndef SINGLE_APP |
1293 | { QCopEnvelope envelope("QPE/System", "forceQuit()"); } | 1293 | { QCopEnvelope envelope("QPE/System", "forceQuit()"); } |
1294 | processEvents(); // ensure the message goes out. | 1294 | processEvents(); // ensure the message goes out. |
1295 | sleep(1); // You have 1 second to comply. | 1295 | sleep(1); // You have 1 second to comply. |
1296 | #endif | 1296 | #endif |
1297 | } | 1297 | } |
1298 | 1298 | ||
1299 | /*! | 1299 | /*! |
1300 | \internal | 1300 | \internal |
1301 | */ | 1301 | */ |
1302 | void QPEApplication::shutdown() | 1302 | void QPEApplication::shutdown() |
1303 | { | 1303 | { |
1304 | // Implement in server's QPEApplication subclass | 1304 | // Implement in server's QPEApplication subclass |
1305 | } | 1305 | } |
1306 | 1306 | ||
1307 | /*! | 1307 | /*! |
1308 | \internal | 1308 | \internal |
1309 | */ | 1309 | */ |
1310 | void QPEApplication::restart() | 1310 | void QPEApplication::restart() |
1311 | { | 1311 | { |
1312 | // Implement in server's QPEApplication subclass | 1312 | // Implement in server's QPEApplication subclass |
1313 | } | 1313 | } |
1314 | 1314 | ||
1315 | static QPtrDict<void>* stylusDict=0; | 1315 | static QPtrDict<void>* stylusDict=0; |
1316 | static void createDict() | 1316 | static void createDict() |
1317 | { | 1317 | { |
1318 | if ( !stylusDict ) | 1318 | if ( !stylusDict ) |
1319 | stylusDict = new QPtrDict<void>; | 1319 | stylusDict = new QPtrDict<void>; |
1320 | } | 1320 | } |
1321 | 1321 | ||
1322 | /*! | 1322 | /*! |
1323 | Returns the current StylusMode for \a w. | 1323 | Returns the current StylusMode for \a w. |
1324 | 1324 | ||
1325 | \sa setStylusOperation() | 1325 | \sa setStylusOperation() |
1326 | */ | 1326 | */ |
1327 | QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w ) | 1327 | QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w ) |
1328 | { | 1328 | { |
1329 | if ( stylusDict ) | 1329 | if ( stylusDict ) |
1330 | return (StylusMode)(int)stylusDict->find(w); | 1330 | return (StylusMode)(int)stylusDict->find(w); |
1331 | return LeftOnly; | 1331 | return LeftOnly; |
1332 | } | 1332 | } |
1333 | 1333 | ||
1334 | /*! | 1334 | /*! |
1335 | \enum QPEApplication::StylusMode | 1335 | \enum QPEApplication::StylusMode |
1336 | 1336 | ||
1337 | \value LeftOnly the stylus only generates LeftButton | 1337 | \value LeftOnly the stylus only generates LeftButton |
1338 | events (the default). | 1338 | events (the default). |
1339 | \value RightOnHold the stylus generates RightButton events | 1339 | \value RightOnHold the stylus generates RightButton events |
1340 | if the user uses the press-and-hold gesture. | 1340 | if the user uses the press-and-hold gesture. |
1341 | 1341 | ||
1342 | See setStylusOperation(). | 1342 | See setStylusOperation(). |
1343 | */ | 1343 | */ |
1344 | 1344 | ||
1345 | /*! | 1345 | /*! |
1346 | Causes \a w to receive mouse events according to \a mode. | 1346 | Causes \a w to receive mouse events according to \a mode. |
1347 | 1347 | ||
1348 | \sa stylusOperation() | 1348 | \sa stylusOperation() |
1349 | */ | 1349 | */ |
1350 | void QPEApplication::setStylusOperation( QWidget* w, StylusMode mode ) | 1350 | void QPEApplication::setStylusOperation( QWidget* w, StylusMode mode ) |
1351 | { | 1351 | { |
1352 | createDict(); | 1352 | createDict(); |
1353 | if ( mode == LeftOnly ) { | 1353 | if ( mode == LeftOnly ) { |
1354 | stylusDict->remove(w); | 1354 | stylusDict->remove(w); |
1355 | w->removeEventFilter(qApp); | 1355 | w->removeEventFilter(qApp); |
1356 | } else { | 1356 | } else { |
1357 | stylusDict->insert(w,(void*)mode); | 1357 | stylusDict->insert(w,(void*)mode); |
1358 | connect(w,SIGNAL(destroyed()),qApp,SLOT(removeSenderFromStylusDict())); | 1358 | connect(w,SIGNAL(destroyed()),qApp,SLOT(removeSenderFromStylusDict())); |
1359 | w->installEventFilter(qApp); | 1359 | w->installEventFilter(qApp); |
1360 | } | 1360 | } |
1361 | } | 1361 | } |
1362 | 1362 | ||
1363 | 1363 | ||
1364 | /*! | 1364 | /*! |
1365 | \reimp | 1365 | \reimp |
1366 | */ | 1366 | */ |
1367 | bool QPEApplication::eventFilter( QObject *o, QEvent *e ) | 1367 | bool QPEApplication::eventFilter( QObject *o, QEvent *e ) |
1368 | { | 1368 | { |
1369 | if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) { | 1369 | if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) { |
1370 | QMouseEvent* me = (QMouseEvent*)e; | 1370 | QMouseEvent* me = (QMouseEvent*)e; |
1371 | if ( me->button() == LeftButton ) { | 1371 | if ( me->button() == LeftButton ) { |
1372 | StylusMode mode = (StylusMode)(int)stylusDict->find(o); | 1372 | StylusMode mode = (StylusMode)(int)stylusDict->find(o); |
1373 | switch (mode) { | 1373 | switch (mode) { |
1374 | case RightOnHold: | 1374 | case RightOnHold: |
1375 | switch ( me->type() ) { | 1375 | switch ( me->type() ) { |
1376 | case QEvent::MouseButtonPress: | 1376 | case QEvent::MouseButtonPress: |
1377 | d->presstimer = startTimer(500); // #### pref. | 1377 | d->presstimer = startTimer(500); // #### pref. |
1378 | d->presswidget = (QWidget*)o; | 1378 | d->presswidget = (QWidget*)o; |
1379 | d->presspos = me->pos(); | 1379 | d->presspos = me->pos(); |
1380 | d->rightpressed = FALSE; | 1380 | d->rightpressed = FALSE; |
1381 | break; | 1381 | break; |
1382 | case QEvent::MouseButtonRelease: | 1382 | case QEvent::MouseButtonRelease: |
1383 | if ( d->presstimer ) { | 1383 | if ( d->presstimer ) { |
1384 | killTimer(d->presstimer); | 1384 | killTimer(d->presstimer); |
1385 | d->presstimer = 0; | 1385 | d->presstimer = 0; |
1386 | } | 1386 | } |
1387 | if ( d->rightpressed && d->presswidget ) { | 1387 | if ( d->rightpressed && d->presswidget ) { |
1388 | // Right released | 1388 | // Right released |
1389 | postEvent( d->presswidget, | 1389 | postEvent( d->presswidget, |
1390 | new QMouseEvent( QEvent::MouseButtonRelease, me->pos(), | 1390 | new QMouseEvent( QEvent::MouseButtonRelease, me->pos(), |
1391 | RightButton, LeftButton+RightButton ) ); | 1391 | RightButton, LeftButton+RightButton ) ); |
1392 | // Left released, off-widget | 1392 | // Left released, off-widget |
1393 | postEvent( d->presswidget, | 1393 | postEvent( d->presswidget, |
1394 | new QMouseEvent( QEvent::MouseMove, QPoint(-1,-1), | 1394 | new QMouseEvent( QEvent::MouseMove, QPoint(-1,-1), |
1395 | LeftButton, LeftButton ) ); | 1395 | LeftButton, LeftButton ) ); |
1396 | postEvent( d->presswidget, | 1396 | postEvent( d->presswidget, |
1397 | new QMouseEvent( QEvent::MouseButtonRelease, QPoint(-1,-1), | 1397 | new QMouseEvent( QEvent::MouseButtonRelease, QPoint(-1,-1), |
1398 | LeftButton, LeftButton ) ); | 1398 | LeftButton, LeftButton ) ); |
1399 | d->rightpressed = FALSE; | 1399 | d->rightpressed = FALSE; |
1400 | return TRUE; // don't send the real Left release | 1400 | return TRUE; // don't send the real Left release |
1401 | } | 1401 | } |
1402 | break; | 1402 | break; |
1403 | default: | 1403 | default: |
1404 | break; | 1404 | break; |
1405 | } | 1405 | } |
1406 | break; | 1406 | break; |
1407 | default: | 1407 | default: |
1408 | ; | 1408 | ; |
1409 | } | 1409 | } |
1410 | } | 1410 | } |
1411 | } else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { | 1411 | } else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { |
1412 | QKeyEvent *ke = (QKeyEvent *)e; | 1412 | QKeyEvent *ke = (QKeyEvent *)e; |
1413 | if ( ke->key() == Key_Enter ) { | 1413 | if ( ke->key() == Key_Enter ) { |
1414 | if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) { | 1414 | if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) { |
1415 | postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ', | 1415 | postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ', |
1416 | ke->state(), " ", ke->isAutoRepeat(), ke->count() ) ); | 1416 | ke->state(), " ", ke->isAutoRepeat(), ke->count() ) ); |
1417 | return TRUE; | 1417 | return TRUE; |
1418 | } | 1418 | } |
1419 | } | 1419 | } |
1420 | } | 1420 | } |
1421 | 1421 | ||
1422 | return FALSE; | 1422 | return FALSE; |
1423 | } | 1423 | } |
1424 | 1424 | ||
1425 | /*! | 1425 | /*! |
1426 | \reimp | 1426 | \reimp |
1427 | */ | 1427 | */ |
1428 | void QPEApplication::timerEvent( QTimerEvent *e ) | 1428 | void QPEApplication::timerEvent( QTimerEvent *e ) |
1429 | { | 1429 | { |
1430 | if ( e->timerId() == d->presstimer && d->presswidget ) { | 1430 | if ( e->timerId() == d->presstimer && d->presswidget ) { |
1431 | // Right pressed | 1431 | // Right pressed |
1432 | postEvent( d->presswidget, | 1432 | postEvent( d->presswidget, |
1433 | new QMouseEvent( QEvent::MouseButtonPress, d->presspos, | 1433 | new QMouseEvent( QEvent::MouseButtonPress, d->presspos, |
1434 | RightButton, LeftButton ) ); | 1434 | RightButton, LeftButton ) ); |
1435 | killTimer( d->presstimer ); | 1435 | killTimer( d->presstimer ); |
1436 | d->presstimer = 0; | 1436 | d->presstimer = 0; |
1437 | d->rightpressed = TRUE; | 1437 | d->rightpressed = TRUE; |
1438 | } | 1438 | } |
1439 | } | 1439 | } |
1440 | 1440 | ||
1441 | void QPEApplication::removeSenderFromStylusDict() | 1441 | void QPEApplication::removeSenderFromStylusDict() |
1442 | { | 1442 | { |
1443 | stylusDict->remove((void*)sender()); | 1443 | stylusDict->remove((void*)sender()); |
1444 | if ( d->presswidget == sender() ) | 1444 | if ( d->presswidget == sender() ) |
1445 | d->presswidget = 0; | 1445 | d->presswidget = 0; |
1446 | } | 1446 | } |
1447 | 1447 | ||
1448 | /*! | 1448 | /*! |
1449 | \internal | 1449 | \internal |
1450 | */ | 1450 | */ |
1451 | bool QPEApplication::keyboardGrabbed() const | 1451 | bool QPEApplication::keyboardGrabbed() const |
1452 | { | 1452 | { |
1453 | return d->kbgrabber; | 1453 | return d->kbgrabber; |
1454 | } | 1454 | } |
1455 | 1455 | ||
1456 | 1456 | ||
1457 | /*! | 1457 | /*! |
1458 | Reverses the effect of grabKeyboard(). This is called automatically | 1458 | Reverses the effect of grabKeyboard(). This is called automatically |
1459 | on program exit. | 1459 | on program exit. |
1460 | */ | 1460 | */ |
1461 | void QPEApplication::ungrabKeyboard() | 1461 | void QPEApplication::ungrabKeyboard() |
1462 | { | 1462 | { |
1463 | QPEApplicationData* d = ((QPEApplication*)qApp)->d; | 1463 | QPEApplicationData* d = ((QPEApplication*)qApp)->d; |
1464 | if ( d->kbgrabber == 2 ) { | 1464 | if ( d->kbgrabber == 2 ) { |
1465 | QCopEnvelope e("QPE/System", "grabKeyboard(QString)" ); | 1465 | QCopEnvelope e("QPE/System", "grabKeyboard(QString)" ); |
1466 | e << QString::null; | 1466 | e << QString::null; |
1467 | d->kbregrab = FALSE; | 1467 | d->kbregrab = FALSE; |
1468 | d->kbgrabber = 0; | 1468 | d->kbgrabber = 0; |
1469 | } | 1469 | } |
1470 | } | 1470 | } |
1471 | 1471 | ||
1472 | /*! | 1472 | /*! |
1473 | Grabs the keyboard such that the system's application launching | 1473 | Grabs the keyboard such that the system's application launching |
1474 | keys no longer work, and instead they are receivable by this | 1474 | keys no longer work, and instead they are receivable by this |
1475 | application. | 1475 | application. |
1476 | 1476 | ||
1477 | \sa ungrabKeyboard() | 1477 | \sa ungrabKeyboard() |
1478 | */ | 1478 | */ |
1479 | void QPEApplication::grabKeyboard() | 1479 | void QPEApplication::grabKeyboard() |
1480 | { | 1480 | { |
1481 | QPEApplicationData* d = ((QPEApplication*)qApp)->d; | 1481 | QPEApplicationData* d = ((QPEApplication*)qApp)->d; |
1482 | if ( qApp->type() == QApplication::GuiServer ) | 1482 | if ( qApp->type() == QApplication::GuiServer ) |
1483 | d->kbgrabber = 0; | 1483 | d->kbgrabber = 0; |
1484 | else { | 1484 | else { |
1485 | QCopEnvelope e("QPE/System", "grabKeyboard(QString)" ); | 1485 | QCopEnvelope e("QPE/System", "grabKeyboard(QString)" ); |
1486 | e << d->appName; | 1486 | e << d->appName; |
1487 | d->kbgrabber = 2; // me | 1487 | d->kbgrabber = 2; // me |
1488 | } | 1488 | } |
1489 | } | 1489 | } |
1490 | 1490 | ||
1491 | /*! | 1491 | /*! |
1492 | \reimp | 1492 | \reimp |
1493 | */ | 1493 | */ |
1494 | int QPEApplication::exec() | 1494 | int QPEApplication::exec() |
1495 | { | 1495 | { |
1496 | d->sendQCopQ(); | 1496 | d->sendQCopQ(); |
1497 | if ( d->keep_running) | 1497 | if ( d->keep_running) |
1498 | //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() ) | 1498 | //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() ) |
1499 | return QApplication::exec(); | 1499 | return QApplication::exec(); |
1500 | 1500 | ||
1501 | { | 1501 | { |
1502 | QCopEnvelope e("QPE/System", "closing(QString)" ); | 1502 | QCopEnvelope e("QPE/System", "closing(QString)" ); |
1503 | e << d->appName; | 1503 | e << d->appName; |
1504 | } | 1504 | } |
1505 | processEvents(); | 1505 | processEvents(); |
1506 | return 0; | 1506 | return 0; |
1507 | } | 1507 | } |
1508 | 1508 | ||
1509 | /*! | 1509 | /*! |
1510 | \internal | 1510 | \internal |
1511 | External request for application to quit. Quits if possible without | 1511 | External request for application to quit. Quits if possible without |
1512 | loosing state. | 1512 | loosing state. |
1513 | */ | 1513 | */ |
1514 | void QPEApplication::tryQuit() | 1514 | void QPEApplication::tryQuit() |
1515 | { | 1515 | { |
1516 | if ( activeModalWidget() || strcmp( argv()[0], "embeddedkonsole") == 0 ) | 1516 | if ( activeModalWidget() || strcmp( argv()[0], "embeddedkonsole") == 0 ) |
1517 | return; // Inside modal loop or konsole. Too hard to save state. | 1517 | return; // Inside modal loop or konsole. Too hard to save state. |
1518 | { | 1518 | { |
1519 | QCopEnvelope e("QPE/System", "closing(QString)" ); | 1519 | QCopEnvelope e("QPE/System", "closing(QString)" ); |
1520 | e << d->appName; | 1520 | e << d->appName; |
1521 | } | 1521 | } |
1522 | processEvents(); | 1522 | processEvents(); |
1523 | 1523 | ||
1524 | quit(); | 1524 | quit(); |
1525 | } | 1525 | } |
1526 | 1526 | ||
1527 | /*! | 1527 | /*! |
1528 | \internal | 1528 | \internal |
1529 | User initiated quit. Makes the window 'Go Away'. If preloaded this means | 1529 | User initiated quit. Makes the window 'Go Away'. If preloaded this means |
1530 | hiding the window. If not it means quitting the application. | 1530 | hiding the window. If not it means quitting the application. |
1531 | As this is user initiated we don't need to check state. | 1531 | As this is user initiated we don't need to check state. |
1532 | */ | 1532 | */ |
1533 | void QPEApplication::hideOrQuit() | 1533 | void QPEApplication::hideOrQuit() |
1534 | { | 1534 | { |
1535 | // notify of our demise :) | 1535 | // notify of our demise :) |
1536 | { | 1536 | { |
1537 | QCopEnvelope e("QPE/System", "closing(QString)" ); | 1537 | QCopEnvelope e("QPE/System", "closing(QString)" ); |
1538 | e << d->appName; | 1538 | e << d->appName; |
1539 | } | 1539 | } |
1540 | processEvents(); | 1540 | processEvents(); |
1541 | if ( d->preloaded && d->qpe_main_widget ) | 1541 | if ( d->preloaded && d->qpe_main_widget ) |
1542 | d->qpe_main_widget->hide(); | 1542 | d->qpe_main_widget->hide(); |
1543 | else | 1543 | else |
1544 | quit(); | 1544 | quit(); |
1545 | } | 1545 | } |
1546 | 1546 | ||
1547 | #if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) | 1547 | #if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) |
1548 | 1548 | ||
1549 | // The libraries with the skiff package (and possibly others) have | 1549 | // The libraries with the skiff package (and possibly others) have |
1550 | // completely useless implementations of builtin new and delete that | 1550 | // completely useless implementations of builtin new and delete that |
1551 | // use about 50% of your CPU. Here we revert to the simple libc | 1551 | // use about 50% of your CPU. Here we revert to the simple libc |
1552 | // functions. | 1552 | // functions. |
1553 | 1553 | ||
1554 | void* operator new[](size_t size) | 1554 | void* operator new[](size_t size) |
1555 | { | 1555 | { |
1556 | return malloc(size); | 1556 | return malloc(size); |
1557 | } | 1557 | } |
1558 | 1558 | ||
1559 | void* operator new(size_t size) | 1559 | void* operator new(size_t size) |
1560 | { | 1560 | { |
1561 | return malloc(size); | 1561 | return malloc(size); |
1562 | } | 1562 | } |
1563 | 1563 | ||
1564 | void operator delete[](void* p) | 1564 | void operator delete[](void* p) |
1565 | { | 1565 | { |
1566 | free(p); | 1566 | free(p); |
1567 | } | 1567 | } |
1568 | 1568 | ||
1569 | void operator delete[](void* p, size_t /*size*/) | 1569 | void operator delete[](void* p, size_t /*size*/) |
1570 | { | 1570 | { |
1571 | free(p); | 1571 | free(p); |
1572 | } | 1572 | } |
1573 | 1573 | ||
1574 | void operator delete(void* p) | 1574 | void operator delete(void* p) |
1575 | { | 1575 | { |
1576 | free(p); | 1576 | free(p); |
1577 | } | 1577 | } |
1578 | 1578 | ||
1579 | void operator delete(void* p, size_t /*size*/) | 1579 | void operator delete(void* p, size_t /*size*/) |
1580 | { | 1580 | { |
1581 | free(p); | 1581 | free(p); |
1582 | } | 1582 | } |
1583 | 1583 | ||
1584 | #endif | 1584 | #endif |
1585 | 1585 | ||
1586 | #if ( QT_VERSION <= 230 ) && !defined(SINGLE_APP) | 1586 | #if ( QT_VERSION <= 230 ) && !defined(SINGLE_APP) |
1587 | #include <qwidgetlist.h> | 1587 | #include <qwidgetlist.h> |
1588 | #include <qgfx_qws.h> | 1588 | #include <qgfx_qws.h> |
1589 | extern QRect qt_maxWindowRect; | 1589 | extern QRect qt_maxWindowRect; |
1590 | void qt_setMaxWindowRect(const QRect& r) | 1590 | void qt_setMaxWindowRect(const QRect& r) |
1591 | { | 1591 | { |
1592 | qt_maxWindowRect = qt_screen->mapFromDevice(r, | 1592 | qt_maxWindowRect = qt_screen->mapFromDevice(r, |
1593 | qt_screen->mapToDevice(QSize(qt_screen->width(),qt_screen->height()))); | 1593 | qt_screen->mapToDevice(QSize(qt_screen->width(),qt_screen->height()))); |
1594 | // Re-resize any maximized windows | 1594 | // Re-resize any maximized windows |
1595 | QWidgetList* l = QApplication::topLevelWidgets(); | 1595 | QWidgetList* l = QApplication::topLevelWidgets(); |
1596 | if ( l ) { | 1596 | if ( l ) { |
1597 | QWidget *w = l->first(); | 1597 | QWidget *w = l->first(); |
1598 | while ( w ) { | 1598 | while ( w ) { |
1599 | if ( w->isVisible() && w->isMaximized() ) | 1599 | if ( w->isVisible() && w->isMaximized() ) |
1600 | { | 1600 | { |
1601 | w->showMaximized(); | 1601 | w->showMaximized(); |
1602 | } | 1602 | } |
1603 | w = l->next(); | 1603 | w = l->next(); |
1604 | } | 1604 | } |
1605 | delete l; | 1605 | delete l; |
1606 | } | 1606 | } |
1607 | } | 1607 | } |
1608 | #endif | 1608 | #endif |