-rw-r--r-- | library/qpeapplication.cpp | 3 |
1 files changed, 0 insertions, 3 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp index 4c93111..b5dff3a 100644 --- a/library/qpeapplication.cpp +++ b/library/qpeapplication.cpp | |||
@@ -913,834 +913,831 @@ void QPEApplication::applyStyle() | |||
913 | // don't block ourselves ... | 913 | // don't block ourselves ... |
914 | Opie::force_appearance = 0; | 914 | Opie::force_appearance = 0; |
915 | 915 | ||
916 | static QString appname = Opie::binaryName ( ); | 916 | static QString appname = Opie::binaryName ( ); |
917 | 917 | ||
918 | QStringList ex = config. readListEntry ( "NoStyle", ';' ); | 918 | QStringList ex = config. readListEntry ( "NoStyle", ';' ); |
919 | int nostyle = 0; | 919 | int nostyle = 0; |
920 | for ( QStringList::Iterator it = ex. begin ( ); it != ex. end ( ); ++it ) { | 920 | for ( QStringList::Iterator it = ex. begin ( ); it != ex. end ( ); ++it ) { |
921 | if ( QRegExp (( *it ). mid ( 1 ), false, true ). find ( appname, 0 ) >= 0 ) { | 921 | if ( QRegExp (( *it ). mid ( 1 ), false, true ). find ( appname, 0 ) >= 0 ) { |
922 | nostyle = ( *it ). left ( 1 ). toInt ( 0, 32 ); | 922 | nostyle = ( *it ). left ( 1 ). toInt ( 0, 32 ); |
923 | break; | 923 | break; |
924 | } | 924 | } |
925 | } | 925 | } |
926 | 926 | ||
927 | // Widget style | 927 | // Widget style |
928 | QString style = config.readEntry( "Style", "Light" ); | 928 | QString style = config.readEntry( "Style", "Light" ); |
929 | 929 | ||
930 | // don't set a custom style | 930 | // don't set a custom style |
931 | if ( nostyle & Opie::Force_Style ) | 931 | if ( nostyle & Opie::Force_Style ) |
932 | style = "Light"; | 932 | style = "Light"; |
933 | 933 | ||
934 | internalSetStyle ( style ); | 934 | internalSetStyle ( style ); |
935 | 935 | ||
936 | // Colors | 936 | // Colors |
937 | QColor bgcolor( config.readEntry( "Background", "#E5E1D5" ) ); | 937 | QColor bgcolor( config.readEntry( "Background", "#E5E1D5" ) ); |
938 | QColor btncolor( config.readEntry( "Button", "#D6CDBB" ) ); | 938 | QColor btncolor( config.readEntry( "Button", "#D6CDBB" ) ); |
939 | QPalette pal( btncolor, bgcolor ); | 939 | QPalette pal( btncolor, bgcolor ); |
940 | QString color = config.readEntry( "Highlight", "#800000" ); | 940 | QString color = config.readEntry( "Highlight", "#800000" ); |
941 | pal.setColor( QColorGroup::Highlight, QColor( color ) ); | 941 | pal.setColor( QColorGroup::Highlight, QColor( color ) ); |
942 | color = config.readEntry( "HighlightedText", "#FFFFFF" ); | 942 | color = config.readEntry( "HighlightedText", "#FFFFFF" ); |
943 | pal.setColor( QColorGroup::HighlightedText, QColor( color ) ); | 943 | pal.setColor( QColorGroup::HighlightedText, QColor( color ) ); |
944 | color = config.readEntry( "Text", "#000000" ); | 944 | color = config.readEntry( "Text", "#000000" ); |
945 | pal.setColor( QColorGroup::Text, QColor( color ) ); | 945 | pal.setColor( QColorGroup::Text, QColor( color ) ); |
946 | color = config.readEntry( "ButtonText", "#000000" ); | 946 | color = config.readEntry( "ButtonText", "#000000" ); |
947 | pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) ); | 947 | pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) ); |
948 | color = config.readEntry( "Base", "#FFFFFF" ); | 948 | color = config.readEntry( "Base", "#FFFFFF" ); |
949 | pal.setColor( QColorGroup::Base, QColor( color ) ); | 949 | pal.setColor( QColorGroup::Base, QColor( color ) ); |
950 | 950 | ||
951 | pal.setColor( QPalette::Disabled, QColorGroup::Text, | 951 | pal.setColor( QPalette::Disabled, QColorGroup::Text, |
952 | pal.color( QPalette::Active, QColorGroup::Background ).dark() ); | 952 | pal.color( QPalette::Active, QColorGroup::Background ).dark() ); |
953 | 953 | ||
954 | setPalette( pal, TRUE ); | 954 | setPalette( pal, TRUE ); |
955 | 955 | ||
956 | // Window Decoration | 956 | // Window Decoration |
957 | QString dec = config.readEntry( "Decoration", "Qtopia" ); | 957 | QString dec = config.readEntry( "Decoration", "Qtopia" ); |
958 | 958 | ||
959 | // don't set a custom deco | 959 | // don't set a custom deco |
960 | if ( nostyle & Opie::Force_Decoration ) | 960 | if ( nostyle & Opie::Force_Decoration ) |
961 | dec = ""; | 961 | dec = ""; |
962 | 962 | ||
963 | //qDebug ( "Setting Deco: %s -- old %s (%d)", dec.latin1(), d-> decorationName.latin1(), nostyle); | 963 | //qDebug ( "Setting Deco: %s -- old %s (%d)", dec.latin1(), d-> decorationName.latin1(), nostyle); |
964 | 964 | ||
965 | if ( dec != d->decorationName ) { | 965 | if ( dec != d->decorationName ) { |
966 | qwsSetDecoration( new QPEDecoration( dec ) ); | 966 | qwsSetDecoration( new QPEDecoration( dec ) ); |
967 | d->decorationName = dec; | 967 | d->decorationName = dec; |
968 | } | 968 | } |
969 | 969 | ||
970 | // Font | 970 | // Font |
971 | QString ff = config.readEntry( "FontFamily", font().family() ); | 971 | QString ff = config.readEntry( "FontFamily", font().family() ); |
972 | int fs = config.readNumEntry( "FontSize", font().pointSize() ); | 972 | int fs = config.readNumEntry( "FontSize", font().pointSize() ); |
973 | 973 | ||
974 | // don't set a custom font | 974 | // don't set a custom font |
975 | if ( nostyle & Opie::Force_Font ) { | 975 | if ( nostyle & Opie::Force_Font ) { |
976 | ff = "Helvetica"; | 976 | ff = "Helvetica"; |
977 | fs = 10; | 977 | fs = 10; |
978 | } | 978 | } |
979 | 979 | ||
980 | setFont ( QFont ( ff, fs ), true ); | 980 | setFont ( QFont ( ff, fs ), true ); |
981 | 981 | ||
982 | // revert to global blocking policy ... | 982 | // revert to global blocking policy ... |
983 | Opie::force_appearance = config. readBoolEntry ( "ForceStyle", false ) ? Opie::Force_All : Opie::Force_None; | 983 | Opie::force_appearance = config. readBoolEntry ( "ForceStyle", false ) ? Opie::Force_All : Opie::Force_None; |
984 | Opie::force_appearance &= ~nostyle; | 984 | Opie::force_appearance &= ~nostyle; |
985 | } | 985 | } |
986 | 986 | ||
987 | void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data ) | 987 | void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data ) |
988 | { | 988 | { |
989 | #ifdef Q_WS_QWS | 989 | #ifdef Q_WS_QWS |
990 | QDataStream stream( data, IO_ReadOnly ); | 990 | QDataStream stream( data, IO_ReadOnly ); |
991 | if ( msg == "applyStyle()" ) { | 991 | if ( msg == "applyStyle()" ) { |
992 | applyStyle(); | 992 | applyStyle(); |
993 | } | 993 | } |
994 | else if ( msg == "setDefaultRotation(int)" ) { | 994 | else if ( msg == "setDefaultRotation(int)" ) { |
995 | if ( type() == GuiServer ) { | 995 | if ( type() == GuiServer ) { |
996 | int r; | 996 | int r; |
997 | stream >> r; | 997 | stream >> r; |
998 | setDefaultRotation( r ); | 998 | setDefaultRotation( r ); |
999 | } | 999 | } |
1000 | } | 1000 | } |
1001 | else if ( msg == "shutdown()" ) { | 1001 | else if ( msg == "shutdown()" ) { |
1002 | if ( type() == GuiServer ) | 1002 | if ( type() == GuiServer ) |
1003 | shutdown(); | 1003 | shutdown(); |
1004 | } | 1004 | } |
1005 | else if ( msg == "quit()" ) { | 1005 | else if ( msg == "quit()" ) { |
1006 | if ( type() != GuiServer ) | 1006 | if ( type() != GuiServer ) |
1007 | tryQuit(); | 1007 | tryQuit(); |
1008 | } | 1008 | } |
1009 | else if ( msg == "forceQuit()" ) { | 1009 | else if ( msg == "forceQuit()" ) { |
1010 | if ( type() != GuiServer ) | 1010 | if ( type() != GuiServer ) |
1011 | quit(); | 1011 | quit(); |
1012 | } | 1012 | } |
1013 | else if ( msg == "restart()" ) { | 1013 | else if ( msg == "restart()" ) { |
1014 | if ( type() == GuiServer ) | 1014 | if ( type() == GuiServer ) |
1015 | restart(); | 1015 | restart(); |
1016 | } | 1016 | } |
1017 | else if ( msg == "grabKeyboard(QString)" ) { | 1017 | else if ( msg == "grabKeyboard(QString)" ) { |
1018 | QString who; | 1018 | QString who; |
1019 | stream >> who; | 1019 | stream >> who; |
1020 | if ( who.isEmpty() ) | 1020 | if ( who.isEmpty() ) |
1021 | d->kbgrabber = 0; | 1021 | d->kbgrabber = 0; |
1022 | else if ( who != d->appName ) | 1022 | else if ( who != d->appName ) |
1023 | d->kbgrabber = 1; | 1023 | d->kbgrabber = 1; |
1024 | else | 1024 | else |
1025 | d->kbgrabber = 2; | 1025 | d->kbgrabber = 2; |
1026 | } | 1026 | } |
1027 | else if ( msg == "language(QString)" ) { | 1027 | else if ( msg == "language(QString)" ) { |
1028 | if ( type() == GuiServer ) { | 1028 | if ( type() == GuiServer ) { |
1029 | QString l; | 1029 | QString l; |
1030 | stream >> l; | 1030 | stream >> l; |
1031 | QString cl = getenv( "LANG" ); | 1031 | QString cl = getenv( "LANG" ); |
1032 | if ( cl != l ) { | 1032 | if ( cl != l ) { |
1033 | if ( l.isNull() ) | 1033 | if ( l.isNull() ) |
1034 | unsetenv( "LANG" ); | 1034 | unsetenv( "LANG" ); |
1035 | else | 1035 | else |
1036 | setenv( "LANG", l.latin1(), 1 ); | 1036 | setenv( "LANG", l.latin1(), 1 ); |
1037 | restart(); | 1037 | restart(); |
1038 | } | 1038 | } |
1039 | } | 1039 | } |
1040 | } | 1040 | } |
1041 | else if ( msg == "timeChange(QString)" ) { | 1041 | else if ( msg == "timeChange(QString)" ) { |
1042 | QString t; | 1042 | QString t; |
1043 | stream >> t; | 1043 | stream >> t; |
1044 | if ( t.isNull() ) | 1044 | if ( t.isNull() ) |
1045 | unsetenv( "TZ" ); | 1045 | unsetenv( "TZ" ); |
1046 | else | 1046 | else |
1047 | setenv( "TZ", t.latin1(), 1 ); | 1047 | setenv( "TZ", t.latin1(), 1 ); |
1048 | // emit the signal so everyone else knows... | 1048 | // emit the signal so everyone else knows... |
1049 | emit timeChanged(); | 1049 | emit timeChanged(); |
1050 | } | 1050 | } |
1051 | else if ( msg == "execute(QString)" ) { | 1051 | else if ( msg == "execute(QString)" ) { |
1052 | if ( type() == GuiServer ) { | 1052 | if ( type() == GuiServer ) { |
1053 | QString t; | 1053 | QString t; |
1054 | stream >> t; | 1054 | stream >> t; |
1055 | Global::execute( t ); | 1055 | Global::execute( t ); |
1056 | } | 1056 | } |
1057 | } | 1057 | } |
1058 | else if ( msg == "execute(QString,QString)" ) { | 1058 | else if ( msg == "execute(QString,QString)" ) { |
1059 | if ( type() == GuiServer ) { | 1059 | if ( type() == GuiServer ) { |
1060 | QString t, d; | 1060 | QString t, d; |
1061 | stream >> t >> d; | 1061 | stream >> t >> d; |
1062 | Global::execute( t, d ); | 1062 | Global::execute( t, d ); |
1063 | } | 1063 | } |
1064 | } | 1064 | } |
1065 | else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) { | 1065 | else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) { |
1066 | if ( type() == GuiServer ) { | 1066 | if ( type() == GuiServer ) { |
1067 | QDateTime when; | 1067 | QDateTime when; |
1068 | QCString channel, message; | 1068 | QCString channel, message; |
1069 | int data; | 1069 | int data; |
1070 | stream >> when >> channel >> message >> data; | 1070 | stream >> when >> channel >> message >> data; |
1071 | AlarmServer::addAlarm( when, channel, message, data ); | 1071 | AlarmServer::addAlarm( when, channel, message, data ); |
1072 | } | 1072 | } |
1073 | } | 1073 | } |
1074 | else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) { | 1074 | else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) { |
1075 | if ( type() == GuiServer ) { | 1075 | if ( type() == GuiServer ) { |
1076 | QDateTime when; | 1076 | QDateTime when; |
1077 | QCString channel, message; | 1077 | QCString channel, message; |
1078 | int data; | 1078 | int data; |
1079 | stream >> when >> channel >> message >> data; | 1079 | stream >> when >> channel >> message >> data; |
1080 | AlarmServer::deleteAlarm( when, channel, message, data ); | 1080 | AlarmServer::deleteAlarm( when, channel, message, data ); |
1081 | } | 1081 | } |
1082 | } | 1082 | } |
1083 | else if ( msg == "clockChange(bool)" ) { | 1083 | else if ( msg == "clockChange(bool)" ) { |
1084 | int tmp; | 1084 | int tmp; |
1085 | stream >> tmp; | 1085 | stream >> tmp; |
1086 | emit clockChanged( tmp ); | 1086 | emit clockChanged( tmp ); |
1087 | } | 1087 | } |
1088 | else if ( msg == "weekChange(bool)" ) { | 1088 | else if ( msg == "weekChange(bool)" ) { |
1089 | int tmp; | 1089 | int tmp; |
1090 | stream >> tmp; | 1090 | stream >> tmp; |
1091 | emit weekChanged( tmp ); | 1091 | emit weekChanged( tmp ); |
1092 | } | 1092 | } |
1093 | else if ( msg == "setDateFormat(DateFormat)" ) { | 1093 | else if ( msg == "setDateFormat(DateFormat)" ) { |
1094 | DateFormat tmp; | 1094 | DateFormat tmp; |
1095 | stream >> tmp; | 1095 | stream >> tmp; |
1096 | emit dateFormatChanged( tmp ); | 1096 | emit dateFormatChanged( tmp ); |
1097 | } | 1097 | } |
1098 | else if ( msg == "setVolume(int,int)" ) { | 1098 | else if ( msg == "setVolume(int,int)" ) { |
1099 | int t, v; | 1099 | int t, v; |
1100 | stream >> t >> v; | 1100 | stream >> t >> v; |
1101 | setVolume( t, v ); | 1101 | setVolume( t, v ); |
1102 | emit volumeChanged( muted ); | 1102 | emit volumeChanged( muted ); |
1103 | } | 1103 | } |
1104 | else if ( msg == "volumeChange(bool)" ) { | 1104 | else if ( msg == "volumeChange(bool)" ) { |
1105 | stream >> muted; | 1105 | stream >> muted; |
1106 | setVolume(); | 1106 | setVolume(); |
1107 | emit volumeChanged( muted ); | 1107 | emit volumeChanged( muted ); |
1108 | } | 1108 | } |
1109 | else if ( msg == "setMic(int,int)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> | 1109 | else if ( msg == "setMic(int,int)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> |
1110 | int t, v; | 1110 | int t, v; |
1111 | stream >> t >> v; | 1111 | stream >> t >> v; |
1112 | setMic( t, v ); | 1112 | setMic( t, v ); |
1113 | emit micChanged( micMuted ); | 1113 | emit micChanged( micMuted ); |
1114 | } | 1114 | } |
1115 | else if ( msg == "micChange(bool)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> | 1115 | else if ( msg == "micChange(bool)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> |
1116 | stream >> micMuted; | 1116 | stream >> micMuted; |
1117 | setMic(); | 1117 | setMic(); |
1118 | emit micChanged( micMuted ); | 1118 | emit micChanged( micMuted ); |
1119 | } | 1119 | } |
1120 | #endif | 1120 | #endif |
1121 | } | 1121 | } |
1122 | 1122 | ||
1123 | /*! | 1123 | /*! |
1124 | \internal | 1124 | \internal |
1125 | */ | 1125 | */ |
1126 | bool QPEApplication::raiseAppropriateWindow() | 1126 | bool QPEApplication::raiseAppropriateWindow() |
1127 | { | 1127 | { |
1128 | bool r = FALSE; | 1128 | bool r = FALSE; |
1129 | // ########## raise()ing main window should raise and set active | 1129 | // ########## raise()ing main window should raise and set active |
1130 | // ########## it and then all childen. This belongs in Qt/Embedded | 1130 | // ########## it and then all childen. This belongs in Qt/Embedded |
1131 | QWidget *top = d->qpe_main_widget; | 1131 | QWidget *top = d->qpe_main_widget; |
1132 | if ( !top ) | 1132 | if ( !top ) |
1133 | top = mainWidget(); | 1133 | top = mainWidget(); |
1134 | if ( top && d->keep_running ) { | 1134 | if ( top && d->keep_running ) { |
1135 | if ( top->isVisible() ) | 1135 | if ( top->isVisible() ) |
1136 | r = TRUE; | 1136 | r = TRUE; |
1137 | else if (d->preloaded) { | 1137 | else if (d->preloaded) { |
1138 | // We are preloaded and not visible.. pretend we just started.. | 1138 | // We are preloaded and not visible.. pretend we just started.. |
1139 | QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); | 1139 | QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); |
1140 | e << d->appName; | 1140 | e << d->appName; |
1141 | } | 1141 | } |
1142 | 1142 | ||
1143 | d->show_mx(top, d->nomaximize); | 1143 | d->show_mx(top, d->nomaximize); |
1144 | top->raise(); | 1144 | top->raise(); |
1145 | top->setActiveWindow(); | 1145 | top->setActiveWindow(); |
1146 | } | 1146 | } |
1147 | QWidget *topm = activeModalWidget(); | 1147 | QWidget *topm = activeModalWidget(); |
1148 | if ( topm && topm != top ) { | 1148 | if ( topm && topm != top ) { |
1149 | topm->show(); | 1149 | topm->show(); |
1150 | topm->raise(); | 1150 | topm->raise(); |
1151 | topm->setActiveWindow(); | 1151 | topm->setActiveWindow(); |
1152 | // If we haven't already handled the fastAppShowing message | 1152 | // If we haven't already handled the fastAppShowing message |
1153 | if (!top && d->preloaded) { | 1153 | if (!top && d->preloaded) { |
1154 | QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); | 1154 | QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); |
1155 | e << d->appName; | 1155 | e << d->appName; |
1156 | } | 1156 | } |
1157 | r = FALSE; | 1157 | r = FALSE; |
1158 | } | 1158 | } |
1159 | return r; | 1159 | return r; |
1160 | } | 1160 | } |
1161 | 1161 | ||
1162 | void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data) | 1162 | void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data) |
1163 | { | 1163 | { |
1164 | #ifdef Q_WS_QWS | 1164 | #ifdef Q_WS_QWS |
1165 | 1165 | ||
1166 | if ( msg == "quit()" ) { | 1166 | if ( msg == "quit()" ) { |
1167 | tryQuit(); | 1167 | tryQuit(); |
1168 | } | 1168 | } |
1169 | else if ( msg == "quitIfInvisible()" ) { | 1169 | else if ( msg == "quitIfInvisible()" ) { |
1170 | if ( d->qpe_main_widget && !d->qpe_main_widget->isVisible() ) | 1170 | if ( d->qpe_main_widget && !d->qpe_main_widget->isVisible() ) |
1171 | quit(); | 1171 | quit(); |
1172 | } | 1172 | } |
1173 | else if ( msg == "close()" ) { | 1173 | else if ( msg == "close()" ) { |
1174 | hideOrQuit(); | 1174 | hideOrQuit(); |
1175 | } | 1175 | } |
1176 | else if ( msg == "disablePreload()" ) { | 1176 | else if ( msg == "disablePreload()" ) { |
1177 | d->preloaded = FALSE; | 1177 | d->preloaded = FALSE; |
1178 | d->keep_running = TRUE; | 1178 | d->keep_running = TRUE; |
1179 | /* so that quit will quit */ | 1179 | /* so that quit will quit */ |
1180 | } | 1180 | } |
1181 | else if ( msg == "enablePreload()" ) { | 1181 | else if ( msg == "enablePreload()" ) { |
1182 | if (d->qpe_main_widget) | 1182 | if (d->qpe_main_widget) |
1183 | d->preloaded = TRUE; | 1183 | d->preloaded = TRUE; |
1184 | d->keep_running = TRUE; | 1184 | d->keep_running = TRUE; |
1185 | /* so next quit won't quit */ | 1185 | /* so next quit won't quit */ |
1186 | } | 1186 | } |
1187 | else if ( msg == "raise()" ) { | 1187 | else if ( msg == "raise()" ) { |
1188 | d->keep_running = TRUE; | 1188 | d->keep_running = TRUE; |
1189 | d->notbusysent = FALSE; | 1189 | d->notbusysent = FALSE; |
1190 | raiseAppropriateWindow(); | 1190 | raiseAppropriateWindow(); |
1191 | // Tell the system we're still chugging along... | 1191 | // Tell the system we're still chugging along... |
1192 | QCopEnvelope e("QPE/System", "appRaised(QString)"); | 1192 | QCopEnvelope e("QPE/System", "appRaised(QString)"); |
1193 | e << d->appName; | 1193 | e << d->appName; |
1194 | } | 1194 | } |
1195 | else if ( msg == "flush()" ) { | 1195 | else if ( msg == "flush()" ) { |
1196 | emit flush(); | 1196 | emit flush(); |
1197 | // we need to tell the desktop | 1197 | // we need to tell the desktop |
1198 | QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" ); | 1198 | QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" ); |
1199 | e << d->appName; | 1199 | e << d->appName; |
1200 | } | 1200 | } |
1201 | else if ( msg == "reload()" ) { | 1201 | else if ( msg == "reload()" ) { |
1202 | emit reload(); | 1202 | emit reload(); |
1203 | } | 1203 | } |
1204 | else if ( msg == "setDocument(QString)" ) { | 1204 | else if ( msg == "setDocument(QString)" ) { |
1205 | d->keep_running = TRUE; | 1205 | d->keep_running = TRUE; |
1206 | QDataStream stream( data, IO_ReadOnly ); | 1206 | QDataStream stream( data, IO_ReadOnly ); |
1207 | QString doc; | 1207 | QString doc; |
1208 | stream >> doc; | 1208 | stream >> doc; |
1209 | QWidget *mw = mainWidget(); | 1209 | QWidget *mw = mainWidget(); |
1210 | if ( !mw ) | 1210 | if ( !mw ) |
1211 | mw = d->qpe_main_widget; | 1211 | mw = d->qpe_main_widget; |
1212 | if ( mw ) | 1212 | if ( mw ) |
1213 | Global::setDocument( mw, doc ); | 1213 | Global::setDocument( mw, doc ); |
1214 | } | 1214 | } |
1215 | else if ( msg == "nextView()" ) { | 1215 | else if ( msg == "nextView()" ) { |
1216 | qDebug("got nextView()"); | 1216 | qDebug("got nextView()"); |
1217 | /* | 1217 | /* |
1218 | if ( raiseAppropriateWindow() ) | 1218 | if ( raiseAppropriateWindow() ) |
1219 | */ | 1219 | */ |
1220 | emit appMessage( msg, data); | 1220 | emit appMessage( msg, data); |
1221 | } | 1221 | } |
1222 | else { | 1222 | else { |
1223 | emit appMessage( msg, data); | 1223 | emit appMessage( msg, data); |
1224 | } | 1224 | } |
1225 | 1225 | ||
1226 | #endif | 1226 | #endif |
1227 | } | 1227 | } |
1228 | 1228 | ||
1229 | 1229 | ||
1230 | /*! | 1230 | /*! |
1231 | Sets widget \a mw as the mainWidget() and shows it. For small windows, | 1231 | Sets widget \a mw as the mainWidget() and shows it. For small windows, |
1232 | consider passing TRUE for \a nomaximize rather than the default FALSE. | 1232 | consider passing TRUE for \a nomaximize rather than the default FALSE. |
1233 | 1233 | ||
1234 | \sa showMainDocumentWidget() | 1234 | \sa showMainDocumentWidget() |
1235 | */ | 1235 | */ |
1236 | void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize ) | 1236 | void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize ) |
1237 | { | 1237 | { |
1238 | d->show(mw, nomaximize ); | 1238 | d->show(mw, nomaximize ); |
1239 | } | 1239 | } |
1240 | 1240 | ||
1241 | /*! | 1241 | /*! |
1242 | Sets widget \a mw as the mainWidget() and shows it. For small windows, | 1242 | Sets widget \a mw as the mainWidget() and shows it. For small windows, |
1243 | consider passing TRUE for \a nomaximize rather than the default FALSE. | 1243 | consider passing TRUE for \a nomaximize rather than the default FALSE. |
1244 | 1244 | ||
1245 | This calls designates the application as | 1245 | This calls designates the application as |
1246 | a \link docwidget.html document-oriented\endlink application. | 1246 | a \link docwidget.html document-oriented\endlink application. |
1247 | 1247 | ||
1248 | The \a mw widget \e must have this slot: setDocument(const QString&). | 1248 | The \a mw widget \e must have this slot: setDocument(const QString&). |
1249 | 1249 | ||
1250 | \sa showMainWidget() | 1250 | \sa showMainWidget() |
1251 | */ | 1251 | */ |
1252 | void QPEApplication::showMainDocumentWidget( QWidget* mw, bool nomaximize ) | 1252 | void QPEApplication::showMainDocumentWidget( QWidget* mw, bool nomaximize ) |
1253 | { | 1253 | { |
1254 | if ( mw && argc() == 2 ) | 1254 | if ( mw && argc() == 2 ) |
1255 | Global::setDocument( mw, QString::fromUtf8(argv()[1]) ); | 1255 | Global::setDocument( mw, QString::fromUtf8(argv()[1]) ); |
1256 | 1256 | ||
1257 | d->show(mw, nomaximize ); | 1257 | d->show(mw, nomaximize ); |
1258 | } | 1258 | } |
1259 | 1259 | ||
1260 | 1260 | ||
1261 | /*! | 1261 | /*! |
1262 | If an application is started via a \link qcop.html QCop\endlink | 1262 | If an application is started via a \link qcop.html QCop\endlink |
1263 | message, the application will process the \link qcop.html | 1263 | message, the application will process the \link qcop.html |
1264 | QCop\endlink message and then quit. If the application calls this | 1264 | QCop\endlink message and then quit. If the application calls this |
1265 | function while processing a \link qcop.html QCop\endlink message, | 1265 | function while processing a \link qcop.html QCop\endlink message, |
1266 | after processing its outstanding \link qcop.html QCop\endlink | 1266 | after processing its outstanding \link qcop.html QCop\endlink |
1267 | messages the application will start 'properly' and show itself. | 1267 | messages the application will start 'properly' and show itself. |
1268 | 1268 | ||
1269 | \sa keepRunning() | 1269 | \sa keepRunning() |
1270 | */ | 1270 | */ |
1271 | void QPEApplication::setKeepRunning() | 1271 | void QPEApplication::setKeepRunning() |
1272 | { | 1272 | { |
1273 | if ( qApp && qApp->inherits( "QPEApplication" ) ) { | 1273 | if ( qApp && qApp->inherits( "QPEApplication" ) ) { |
1274 | QPEApplication * qpeApp = ( QPEApplication* ) qApp; | 1274 | QPEApplication * qpeApp = ( QPEApplication* ) qApp; |
1275 | qpeApp->d->keep_running = TRUE; | 1275 | qpeApp->d->keep_running = TRUE; |
1276 | } | 1276 | } |
1277 | } | 1277 | } |
1278 | 1278 | ||
1279 | /*! | 1279 | /*! |
1280 | Returns TRUE if the application will quit after processing the | 1280 | Returns TRUE if the application will quit after processing the |
1281 | current list of qcop messages; otherwise returns FALSE. | 1281 | current list of qcop messages; otherwise returns FALSE. |
1282 | 1282 | ||
1283 | \sa setKeepRunning() | 1283 | \sa setKeepRunning() |
1284 | */ | 1284 | */ |
1285 | bool QPEApplication::keepRunning() const | 1285 | bool QPEApplication::keepRunning() const |
1286 | { | 1286 | { |
1287 | return d->keep_running; | 1287 | return d->keep_running; |
1288 | } | 1288 | } |
1289 | 1289 | ||
1290 | /*! | 1290 | /*! |
1291 | \internal | 1291 | \internal |
1292 | */ | 1292 | */ |
1293 | void QPEApplication::internalSetStyle( const QString &style ) | 1293 | void QPEApplication::internalSetStyle( const QString &style ) |
1294 | { | 1294 | { |
1295 | #if QT_VERSION >= 300 | 1295 | #if QT_VERSION >= 300 |
1296 | if ( style == "QPE" ) { | 1296 | if ( style == "QPE" ) { |
1297 | setStyle( new QPEStyle ); | 1297 | setStyle( new QPEStyle ); |
1298 | } | 1298 | } |
1299 | else { | 1299 | else { |
1300 | QStyle *s = QStyleFactory::create( style ); | 1300 | QStyle *s = QStyleFactory::create( style ); |
1301 | if ( s ) | 1301 | if ( s ) |
1302 | setStyle( s ); | 1302 | setStyle( s ); |
1303 | } | 1303 | } |
1304 | #else | 1304 | #else |
1305 | if ( style == "Windows" ) { | 1305 | if ( style == "Windows" ) { |
1306 | setStyle( new QWindowsStyle ); | 1306 | setStyle( new QWindowsStyle ); |
1307 | } | 1307 | } |
1308 | else if ( style == "QPE" ) { | 1308 | else if ( style == "QPE" ) { |
1309 | setStyle( new QPEStyle ); | 1309 | setStyle( new QPEStyle ); |
1310 | } | 1310 | } |
1311 | else if ( style == "Light" ) { | 1311 | else if ( style == "Light" ) { |
1312 | setStyle( new LightStyle ); | 1312 | setStyle( new LightStyle ); |
1313 | } | 1313 | } |
1314 | #ifndef QT_NO_STYLE_PLATINUM | 1314 | #ifndef QT_NO_STYLE_PLATINUM |
1315 | else if ( style == "Platinum" ) { | 1315 | else if ( style == "Platinum" ) { |
1316 | setStyle( new QPlatinumStyle ); | 1316 | setStyle( new QPlatinumStyle ); |
1317 | } | 1317 | } |
1318 | #endif | 1318 | #endif |
1319 | #ifndef QT_NO_STYLE_MOTIF | 1319 | #ifndef QT_NO_STYLE_MOTIF |
1320 | else if ( style == "Motif" ) { | 1320 | else if ( style == "Motif" ) { |
1321 | setStyle( new QMotifStyle ); | 1321 | setStyle( new QMotifStyle ); |
1322 | } | 1322 | } |
1323 | #endif | 1323 | #endif |
1324 | #ifndef QT_NO_STYLE_MOTIFPLUS | 1324 | #ifndef QT_NO_STYLE_MOTIFPLUS |
1325 | else if ( style == "MotifPlus" ) { | 1325 | else if ( style == "MotifPlus" ) { |
1326 | setStyle( new QMotifPlusStyle ); | 1326 | setStyle( new QMotifPlusStyle ); |
1327 | } | 1327 | } |
1328 | #endif | 1328 | #endif |
1329 | 1329 | ||
1330 | else { | 1330 | else { |
1331 | QStyle *sty = 0; | 1331 | QStyle *sty = 0; |
1332 | QString path = QPEApplication::qpeDir ( ) + "/plugins/styles/"; | 1332 | QString path = QPEApplication::qpeDir ( ) + "/plugins/styles/"; |
1333 | 1333 | ||
1334 | if ( style. find ( ".so" ) > 0 ) | 1334 | if ( style. find ( ".so" ) > 0 ) |
1335 | path += style; | 1335 | path += style; |
1336 | else | 1336 | else |
1337 | path = path + "lib" + style. lower ( ) + ".so"; // compatibility | 1337 | path = path + "lib" + style. lower ( ) + ".so"; // compatibility |
1338 | 1338 | ||
1339 | static QLibrary *lastlib = 0; | 1339 | static QLibrary *lastlib = 0; |
1340 | static StyleInterface *lastiface = 0; | 1340 | static StyleInterface *lastiface = 0; |
1341 | 1341 | ||
1342 | QLibrary *lib = new QLibrary ( path ); | 1342 | QLibrary *lib = new QLibrary ( path ); |
1343 | StyleInterface *iface = 0; | 1343 | StyleInterface *iface = 0; |
1344 | 1344 | ||
1345 | if (( lib-> queryInterface ( IID_Style, ( QUnknownInterface ** ) &iface ) == QS_OK ) && iface ) | 1345 | if (( lib-> queryInterface ( IID_Style, ( QUnknownInterface ** ) &iface ) == QS_OK ) && iface ) |
1346 | sty = iface-> style ( ); | 1346 | sty = iface-> style ( ); |
1347 | 1347 | ||
1348 | if ( sty ) { | 1348 | if ( sty ) { |
1349 | setStyle ( sty ); | 1349 | setStyle ( sty ); |
1350 | 1350 | ||
1351 | if ( lastiface ) | 1351 | if ( lastiface ) |
1352 | lastiface-> release ( ); | 1352 | lastiface-> release ( ); |
1353 | lastiface = iface; | 1353 | lastiface = iface; |
1354 | 1354 | ||
1355 | if ( lastlib ) { | 1355 | if ( lastlib ) { |
1356 | lastlib-> unload ( ); | 1356 | lastlib-> unload ( ); |
1357 | delete lastlib; | 1357 | delete lastlib; |
1358 | } | 1358 | } |
1359 | lastlib = lib; | 1359 | lastlib = lib; |
1360 | } | 1360 | } |
1361 | else { | 1361 | else { |
1362 | if ( iface ) | 1362 | if ( iface ) |
1363 | iface-> release ( ); | 1363 | iface-> release ( ); |
1364 | delete lib; | 1364 | delete lib; |
1365 | 1365 | ||
1366 | setStyle ( new LightStyle ( )); | 1366 | setStyle ( new LightStyle ( )); |
1367 | } | 1367 | } |
1368 | } | 1368 | } |
1369 | #endif | 1369 | #endif |
1370 | } | 1370 | } |
1371 | 1371 | ||
1372 | /*! | 1372 | /*! |
1373 | \internal | 1373 | \internal |
1374 | */ | 1374 | */ |
1375 | void QPEApplication::prepareForTermination( bool willrestart ) | 1375 | void QPEApplication::prepareForTermination( bool willrestart ) |
1376 | { | 1376 | { |
1377 | if ( willrestart ) { | 1377 | if ( willrestart ) { |
1378 | // Draw a big wait icon, the image can be altered in later revisions | 1378 | // Draw a big wait icon, the image can be altered in later revisions |
1379 | // QWidget *d = QApplication::desktop(); | 1379 | // QWidget *d = QApplication::desktop(); |
1380 | QImage img = Resource::loadImage( "launcher/new_wait" ); | 1380 | QImage img = Resource::loadImage( "launcher/new_wait" ); |
1381 | QPixmap pix; | 1381 | QPixmap pix; |
1382 | pix.convertFromImage( img.smoothScale( 1 * img.width(), 1 * img.height() ) ); | 1382 | pix.convertFromImage( img.smoothScale( 1 * img.width(), 1 * img.height() ) ); |
1383 | QLabel *lblWait = new QLabel( 0, "wait hack!", QWidget::WStyle_Customize | | 1383 | QLabel *lblWait = new QLabel( 0, "wait hack!", QWidget::WStyle_Customize | |
1384 | QWidget::WStyle_NoBorder | QWidget::WStyle_Tool ); | 1384 | QWidget::WStyle_NoBorder | QWidget::WStyle_Tool ); |
1385 | lblWait->setPixmap( pix ); | 1385 | lblWait->setPixmap( pix ); |
1386 | lblWait->setAlignment( QWidget::AlignCenter ); | 1386 | lblWait->setAlignment( QWidget::AlignCenter ); |
1387 | lblWait->show(); | 1387 | lblWait->show(); |
1388 | lblWait->showMaximized(); | 1388 | lblWait->showMaximized(); |
1389 | } | 1389 | } |
1390 | #ifndef SINGLE_APP | 1390 | #ifndef SINGLE_APP |
1391 | { QCopEnvelope envelope( "QPE/System", "forceQuit()" ); | 1391 | { QCopEnvelope envelope( "QPE/System", "forceQuit()" ); |
1392 | } | 1392 | } |
1393 | processEvents(); // ensure the message goes out. | 1393 | processEvents(); // ensure the message goes out. |
1394 | sleep( 1 ); // You have 1 second to comply. | 1394 | sleep( 1 ); // You have 1 second to comply. |
1395 | #endif | 1395 | #endif |
1396 | } | 1396 | } |
1397 | 1397 | ||
1398 | /*! | 1398 | /*! |
1399 | \internal | 1399 | \internal |
1400 | */ | 1400 | */ |
1401 | void QPEApplication::shutdown() | 1401 | void QPEApplication::shutdown() |
1402 | { | 1402 | { |
1403 | // Implement in server's QPEApplication subclass | 1403 | // Implement in server's QPEApplication subclass |
1404 | } | 1404 | } |
1405 | 1405 | ||
1406 | /*! | 1406 | /*! |
1407 | \internal | 1407 | \internal |
1408 | */ | 1408 | */ |
1409 | void QPEApplication::restart() | 1409 | void QPEApplication::restart() |
1410 | { | 1410 | { |
1411 | // Implement in server's QPEApplication subclass | 1411 | // Implement in server's QPEApplication subclass |
1412 | } | 1412 | } |
1413 | 1413 | ||
1414 | static QPtrDict<void>* stylusDict = 0; | 1414 | static QPtrDict<void>* stylusDict = 0; |
1415 | static void createDict() | 1415 | static void createDict() |
1416 | { | 1416 | { |
1417 | if ( !stylusDict ) | 1417 | if ( !stylusDict ) |
1418 | stylusDict = new QPtrDict<void>; | 1418 | stylusDict = new QPtrDict<void>; |
1419 | } | 1419 | } |
1420 | 1420 | ||
1421 | /*! | 1421 | /*! |
1422 | Returns the current StylusMode for widget \a w. | 1422 | Returns the current StylusMode for widget \a w. |
1423 | 1423 | ||
1424 | \sa setStylusOperation() StylusMode | 1424 | \sa setStylusOperation() StylusMode |
1425 | */ | 1425 | */ |
1426 | QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w ) | 1426 | QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w ) |
1427 | { | 1427 | { |
1428 | if ( stylusDict ) | 1428 | if ( stylusDict ) |
1429 | return ( StylusMode ) ( int ) stylusDict->find( w ); | 1429 | return ( StylusMode ) ( int ) stylusDict->find( w ); |
1430 | return LeftOnly; | 1430 | return LeftOnly; |
1431 | } | 1431 | } |
1432 | 1432 | ||
1433 | /*! | 1433 | /*! |
1434 | \enum QPEApplication::StylusMode | 1434 | \enum QPEApplication::StylusMode |
1435 | 1435 | ||
1436 | \value LeftOnly the stylus only generates LeftButton | 1436 | \value LeftOnly the stylus only generates LeftButton |
1437 | events (the default). | 1437 | events (the default). |
1438 | \value RightOnHold the stylus generates RightButton events | 1438 | \value RightOnHold the stylus generates RightButton events |
1439 | if the user uses the press-and-hold gesture. | 1439 | if the user uses the press-and-hold gesture. |
1440 | 1440 | ||
1441 | \sa setStylusOperation() stylusOperation() | 1441 | \sa setStylusOperation() stylusOperation() |
1442 | */ | 1442 | */ |
1443 | 1443 | ||
1444 | /*! | 1444 | /*! |
1445 | Causes widget \a w to receive mouse events according to the stylus | 1445 | Causes widget \a w to receive mouse events according to the stylus |
1446 | \a mode. | 1446 | \a mode. |
1447 | 1447 | ||
1448 | \sa stylusOperation() StylusMode | 1448 | \sa stylusOperation() StylusMode |
1449 | */ | 1449 | */ |
1450 | void QPEApplication::setStylusOperation( QWidget * w, StylusMode mode ) | 1450 | void QPEApplication::setStylusOperation( QWidget * w, StylusMode mode ) |
1451 | { | 1451 | { |
1452 | createDict(); | 1452 | createDict(); |
1453 | if ( mode == LeftOnly ) { | 1453 | if ( mode == LeftOnly ) { |
1454 | stylusDict->remove | 1454 | stylusDict->remove |
1455 | ( w ); | 1455 | ( w ); |
1456 | w->removeEventFilter( qApp ); | 1456 | w->removeEventFilter( qApp ); |
1457 | } | 1457 | } |
1458 | else { | 1458 | else { |
1459 | stylusDict->insert( w, ( void* ) mode ); | 1459 | stylusDict->insert( w, ( void* ) mode ); |
1460 | connect( w, SIGNAL( destroyed() ), qApp, SLOT( removeSenderFromStylusDict() ) ); | 1460 | connect( w, SIGNAL( destroyed() ), qApp, SLOT( removeSenderFromStylusDict() ) ); |
1461 | w->installEventFilter( qApp ); | 1461 | w->installEventFilter( qApp ); |
1462 | } | 1462 | } |
1463 | } | 1463 | } |
1464 | 1464 | ||
1465 | 1465 | ||
1466 | /*! | 1466 | /*! |
1467 | \reimp | 1467 | \reimp |
1468 | */ | 1468 | */ |
1469 | bool QPEApplication::eventFilter( QObject *o, QEvent *e ) | 1469 | bool QPEApplication::eventFilter( QObject *o, QEvent *e ) |
1470 | { | 1470 | { |
1471 | if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) { | 1471 | if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) { |
1472 | QMouseEvent * me = ( QMouseEvent* ) e; | 1472 | QMouseEvent * me = ( QMouseEvent* ) e; |
1473 | StylusMode mode = (StylusMode)(int)stylusDict->find(o); | 1473 | StylusMode mode = (StylusMode)(int)stylusDict->find(o); |
1474 | switch (mode) { | 1474 | switch (mode) { |
1475 | case RightOnHold: | 1475 | case RightOnHold: |
1476 | switch ( me->type() ) { | 1476 | switch ( me->type() ) { |
1477 | case QEvent::MouseButtonPress: | 1477 | case QEvent::MouseButtonPress: |
1478 | if ( me->button() == LeftButton ) { | 1478 | if ( me->button() == LeftButton ) { |
1479 | d->presstimer = startTimer(500); // #### pref. | 1479 | d->presstimer = startTimer(500); // #### pref. |
1480 | d->presswidget = (QWidget*)o; | 1480 | d->presswidget = (QWidget*)o; |
1481 | d->presspos = me->pos(); | 1481 | d->presspos = me->pos(); |
1482 | d->rightpressed = FALSE; | 1482 | d->rightpressed = FALSE; |
1483 | } | 1483 | } |
1484 | break; | 1484 | break; |
1485 | case QEvent::MouseMove: | 1485 | case QEvent::MouseMove: |
1486 | if (d->presstimer && (me->pos() - d->presspos).manhattanLength() > 8) { | 1486 | if (d->presstimer && (me->pos() - d->presspos).manhattanLength() > 8) { |
1487 | killTimer(d->presstimer); | 1487 | killTimer(d->presstimer); |
1488 | d->presstimer = 0; | 1488 | d->presstimer = 0; |
1489 | } | 1489 | } |
1490 | break; | 1490 | break; |
1491 | case QEvent::MouseButtonRelease: | 1491 | case QEvent::MouseButtonRelease: |
1492 | if ( me->button() == LeftButton ) { | 1492 | if ( me->button() == LeftButton ) { |
1493 | if ( d->presstimer ) { | 1493 | if ( d->presstimer ) { |
1494 | killTimer(d->presstimer); | 1494 | killTimer(d->presstimer); |
1495 | d->presstimer = 0; | 1495 | d->presstimer = 0; |
1496 | } | 1496 | } |
1497 | if ( d->rightpressed && d->presswidget ) { | 1497 | if ( d->rightpressed && d->presswidget ) { |
1498 | // Right released | 1498 | // Right released |
1499 | postEvent( d->presswidget, | 1499 | postEvent( d->presswidget, |
1500 | new QMouseEvent( QEvent::MouseButtonRelease, me->pos(), | 1500 | new QMouseEvent( QEvent::MouseButtonRelease, me->pos(), |
1501 | RightButton, LeftButton + RightButton ) ); | 1501 | RightButton, LeftButton + RightButton ) ); |
1502 | // Left released, off-widget | 1502 | // Left released, off-widget |
1503 | postEvent( d->presswidget, | 1503 | postEvent( d->presswidget, |
1504 | new QMouseEvent( QEvent::MouseMove, QPoint( -1, -1), | 1504 | new QMouseEvent( QEvent::MouseMove, QPoint( -1, -1), |
1505 | LeftButton, LeftButton ) ); | 1505 | LeftButton, LeftButton ) ); |
1506 | postEvent( d->presswidget, | 1506 | postEvent( d->presswidget, |
1507 | new QMouseEvent( QEvent::MouseButtonRelease, QPoint( -1, -1), | 1507 | new QMouseEvent( QEvent::MouseButtonRelease, QPoint( -1, -1), |
1508 | LeftButton, LeftButton ) ); | 1508 | LeftButton, LeftButton ) ); |
1509 | d->rightpressed = FALSE; | 1509 | d->rightpressed = FALSE; |
1510 | return TRUE; // don't send the real Left release | 1510 | return TRUE; // don't send the real Left release |
1511 | } | 1511 | } |
1512 | } | 1512 | } |
1513 | break; | 1513 | break; |
1514 | default: | 1514 | default: |
1515 | break; | 1515 | break; |
1516 | } | 1516 | } |
1517 | break; | 1517 | break; |
1518 | default: | 1518 | default: |
1519 | ; | 1519 | ; |
1520 | } | 1520 | } |
1521 | } | 1521 | } |
1522 | else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { | 1522 | else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { |
1523 | QKeyEvent *ke = (QKeyEvent *)e; | 1523 | QKeyEvent *ke = (QKeyEvent *)e; |
1524 | if ( ke->key() == Key_Enter ) { | 1524 | if ( ke->key() == Key_Enter ) { |
1525 | if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) { | 1525 | if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) { |
1526 | postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ', | 1526 | postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ', |
1527 | ke->state(), " ", ke->isAutoRepeat(), ke->count() ) ); | 1527 | ke->state(), " ", ke->isAutoRepeat(), ke->count() ) ); |
1528 | return TRUE; | 1528 | return TRUE; |
1529 | } | 1529 | } |
1530 | } | 1530 | } |
1531 | } | 1531 | } |
1532 | return FALSE; | 1532 | return FALSE; |
1533 | } | 1533 | } |
1534 | 1534 | ||
1535 | /*! | 1535 | /*! |
1536 | \reimp | 1536 | \reimp |
1537 | */ | 1537 | */ |
1538 | void QPEApplication::timerEvent( QTimerEvent *e ) | 1538 | void QPEApplication::timerEvent( QTimerEvent *e ) |
1539 | { | 1539 | { |
1540 | if ( e->timerId() == d->presstimer && d->presswidget ) { | 1540 | if ( e->timerId() == d->presstimer && d->presswidget ) { |
1541 | // Right pressed | 1541 | // Right pressed |
1542 | postEvent( d->presswidget, | 1542 | postEvent( d->presswidget, |
1543 | new QMouseEvent( QEvent::MouseButtonPress, d->presspos, | 1543 | new QMouseEvent( QEvent::MouseButtonPress, d->presspos, |
1544 | RightButton, LeftButton ) ); | 1544 | RightButton, LeftButton ) ); |
1545 | killTimer( d->presstimer ); | 1545 | killTimer( d->presstimer ); |
1546 | d->presstimer = 0; | 1546 | d->presstimer = 0; |
1547 | d->rightpressed = TRUE; | 1547 | d->rightpressed = TRUE; |
1548 | } | 1548 | } |
1549 | } | 1549 | } |
1550 | 1550 | ||
1551 | void QPEApplication::removeSenderFromStylusDict() | 1551 | void QPEApplication::removeSenderFromStylusDict() |
1552 | { | 1552 | { |
1553 | stylusDict->remove | 1553 | stylusDict->remove |
1554 | ( ( void* ) sender() ); | 1554 | ( ( void* ) sender() ); |
1555 | if ( d->presswidget == sender() ) | 1555 | if ( d->presswidget == sender() ) |
1556 | d->presswidget = 0; | 1556 | d->presswidget = 0; |
1557 | } | 1557 | } |
1558 | 1558 | ||
1559 | /*! | 1559 | /*! |
1560 | \internal | 1560 | \internal |
1561 | */ | 1561 | */ |
1562 | bool QPEApplication::keyboardGrabbed() const | 1562 | bool QPEApplication::keyboardGrabbed() const |
1563 | { | 1563 | { |
1564 | return d->kbgrabber; | 1564 | return d->kbgrabber; |
1565 | } | 1565 | } |
1566 | 1566 | ||
1567 | 1567 | ||
1568 | /*! | 1568 | /*! |
1569 | Reverses the effect of grabKeyboard(). This is called automatically | 1569 | Reverses the effect of grabKeyboard(). This is called automatically |
1570 | on program exit. | 1570 | on program exit. |
1571 | */ | 1571 | */ |
1572 | void QPEApplication::ungrabKeyboard() | 1572 | void QPEApplication::ungrabKeyboard() |
1573 | { | 1573 | { |
1574 | QPEApplicationData * d = ( ( QPEApplication* ) qApp ) ->d; | 1574 | QPEApplicationData * d = ( ( QPEApplication* ) qApp ) ->d; |
1575 | if ( d->kbgrabber == 2 ) { | 1575 | if ( d->kbgrabber == 2 ) { |
1576 | #ifndef QT_NO_COP | 1576 | #ifndef QT_NO_COP |
1577 | QCopEnvelope e( "QPE/System", "grabKeyboard(QString)" ); | 1577 | QCopEnvelope e( "QPE/System", "grabKeyboard(QString)" ); |
1578 | e << QString::null; | 1578 | e << QString::null; |
1579 | #endif | 1579 | #endif |
1580 | 1580 | ||
1581 | d->kbregrab = FALSE; | 1581 | d->kbregrab = FALSE; |
1582 | d->kbgrabber = 0; | 1582 | d->kbgrabber = 0; |
1583 | } | 1583 | } |
1584 | } | 1584 | } |
1585 | 1585 | ||
1586 | /*! | 1586 | /*! |
1587 | Grabs the physical keyboard keys, e.g. the application's launching | 1587 | Grabs the physical keyboard keys, e.g. the application's launching |
1588 | keys. Instead of launching applications when these keys are pressed | 1588 | keys. Instead of launching applications when these keys are pressed |
1589 | the signals emitted are sent to this application instead. Some games | 1589 | the signals emitted are sent to this application instead. Some games |
1590 | programs take over the launch keys in this way to make interaction | 1590 | programs take over the launch keys in this way to make interaction |
1591 | easier. | 1591 | easier. |
1592 | 1592 | ||
1593 | \sa ungrabKeyboard() | 1593 | \sa ungrabKeyboard() |
1594 | */ | 1594 | */ |
1595 | void QPEApplication::grabKeyboard() | 1595 | void QPEApplication::grabKeyboard() |
1596 | { | 1596 | { |
1597 | QPEApplicationData * d = ( ( QPEApplication* ) qApp ) ->d; | 1597 | QPEApplicationData * d = ( ( QPEApplication* ) qApp ) ->d; |
1598 | if ( qApp->type() == QApplication::GuiServer ) | 1598 | if ( qApp->type() == QApplication::GuiServer ) |
1599 | d->kbgrabber = 0; | 1599 | d->kbgrabber = 0; |
1600 | else { | 1600 | else { |
1601 | #ifndef QT_NO_COP | 1601 | #ifndef QT_NO_COP |
1602 | QCopEnvelope e( "QPE/System", "grabKeyboard(QString)" ); | 1602 | QCopEnvelope e( "QPE/System", "grabKeyboard(QString)" ); |
1603 | e << d->appName; | 1603 | e << d->appName; |
1604 | #endif | 1604 | #endif |
1605 | 1605 | ||
1606 | d->kbgrabber = 2; // me | 1606 | d->kbgrabber = 2; // me |
1607 | } | 1607 | } |
1608 | } | 1608 | } |
1609 | 1609 | ||
1610 | /*! | 1610 | /*! |
1611 | \reimp | 1611 | \reimp |
1612 | */ | 1612 | */ |
1613 | int QPEApplication::exec() | 1613 | int QPEApplication::exec() |
1614 | { | 1614 | { |
1615 | #ifndef QT_NO_COP | 1615 | #ifndef QT_NO_COP |
1616 | d->sendQCopQ(); | 1616 | d->sendQCopQ(); |
1617 | #endif | 1617 | #endif |
1618 | 1618 | ||
1619 | if ( d->keep_running ) | 1619 | if ( d->keep_running ) |
1620 | //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() ) | 1620 | //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() ) |
1621 | return QApplication::exec(); | 1621 | return QApplication::exec(); |
1622 | 1622 | ||
1623 | #ifndef QT_NO_COP | 1623 | #ifndef QT_NO_COP |
1624 | 1624 | ||
1625 | { | 1625 | { |
1626 | QCopEnvelope e( "QPE/System", "closing(QString)" ); | 1626 | QCopEnvelope e( "QPE/System", "closing(QString)" ); |
1627 | e << d->appName; | 1627 | e << d->appName; |
1628 | } | 1628 | } |
1629 | #endif | 1629 | #endif |
1630 | processEvents(); | 1630 | processEvents(); |
1631 | return 0; | 1631 | return 0; |
1632 | } | 1632 | } |
1633 | 1633 | ||
1634 | /*! | 1634 | /*! |
1635 | \internal | 1635 | \internal |
1636 | External request for application to quit. Quits if possible without | 1636 | External request for application to quit. Quits if possible without |
1637 | loosing state. | 1637 | loosing state. |
1638 | */ | 1638 | */ |
1639 | void QPEApplication::tryQuit() | 1639 | void QPEApplication::tryQuit() |
1640 | { | 1640 | { |
1641 | if ( activeModalWidget() || strcmp( argv() [ 0 ], "embeddedkonsole" ) == 0 ) | 1641 | if ( activeModalWidget() || strcmp( argv() [ 0 ], "embeddedkonsole" ) == 0 ) |
1642 | return ; // Inside modal loop or konsole. Too hard to save state. | 1642 | return ; // Inside modal loop or konsole. Too hard to save state. |
1643 | #ifndef QT_NO_COP | 1643 | #ifndef QT_NO_COP |
1644 | 1644 | ||
1645 | { | 1645 | { |
1646 | QCopEnvelope e( "QPE/System", "closing(QString)" ); | 1646 | QCopEnvelope e( "QPE/System", "closing(QString)" ); |
1647 | e << d->appName; | 1647 | e << d->appName; |
1648 | } | 1648 | } |
1649 | #endif | 1649 | #endif |
1650 | processEvents(); | 1650 | processEvents(); |
1651 | 1651 | ||
1652 | quit(); | 1652 | quit(); |
1653 | } | 1653 | } |
1654 | 1654 | ||
1655 | /*! | 1655 | /*! |
1656 | \internal | 1656 | \internal |
1657 | User initiated quit. Makes the window 'Go Away'. If preloaded this means | 1657 | User initiated quit. Makes the window 'Go Away'. If preloaded this means |
1658 | hiding the window. If not it means quitting the application. | 1658 | hiding the window. If not it means quitting the application. |
1659 | As this is user initiated we don't need to check state. | 1659 | As this is user initiated we don't need to check state. |
1660 | */ | 1660 | */ |
1661 | void QPEApplication::hideOrQuit() | 1661 | void QPEApplication::hideOrQuit() |
1662 | { | 1662 | { |
1663 | processEvents(); | 1663 | processEvents(); |
1664 | 1664 | ||
1665 | // If we are a preloaded application we don't actually quit, so emit | 1665 | // If we are a preloaded application we don't actually quit, so emit |
1666 | // a System message indicating we're quasi-closing. | 1666 | // a System message indicating we're quasi-closing. |
1667 | if ( d->preloaded && d->qpe_main_widget ) | 1667 | if ( d->preloaded && d->qpe_main_widget ) |
1668 | #ifndef QT_NO_COP | 1668 | #ifndef QT_NO_COP |
1669 | 1669 | ||
1670 | { | 1670 | { |
1671 | QCopEnvelope e("QPE/System", "fastAppHiding(QString)" ); | 1671 | QCopEnvelope e("QPE/System", "fastAppHiding(QString)" ); |
1672 | e << d->appName; | 1672 | e << d->appName; |
1673 | d->qpe_main_widget->hide(); | 1673 | d->qpe_main_widget->hide(); |
1674 | } | 1674 | } |
1675 | #endif | 1675 | #endif |
1676 | else | 1676 | else |
1677 | quit(); | 1677 | quit(); |
1678 | } | 1678 | } |
1679 | 1679 | ||
1680 | 1680 | ||
1681 | // These 6 stubs below need 1.5K in the binary and besides that - | ||
1682 | // we are not using ancient toolchains anymore - sandman | ||
1683 | |||
1684 | #if defined(QT_QWS_IPAQ) || defined(QT_QWS_SHARP) | 1681 | #if defined(QT_QWS_IPAQ) || defined(QT_QWS_SHARP) |
1685 | 1682 | ||
1686 | // The libraries with the skiff package (and possibly others) have | 1683 | // The libraries with the skiff package (and possibly others) have |
1687 | // completely useless implementations of builtin new and delete that | 1684 | // completely useless implementations of builtin new and delete that |
1688 | // use about 50% of your CPU. Here we revert to the simple libc | 1685 | // use about 50% of your CPU. Here we revert to the simple libc |
1689 | // functions. | 1686 | // functions. |
1690 | 1687 | ||
1691 | void* operator new[]( size_t size ) | 1688 | void* operator new[]( size_t size ) |
1692 | { | 1689 | { |
1693 | return malloc( size ); | 1690 | return malloc( size ); |
1694 | } | 1691 | } |
1695 | 1692 | ||
1696 | void* operator new( size_t size ) | 1693 | void* operator new( size_t size ) |
1697 | { | 1694 | { |
1698 | return malloc( size ); | 1695 | return malloc( size ); |
1699 | } | 1696 | } |
1700 | 1697 | ||
1701 | void operator delete[]( void* p ) | 1698 | void operator delete[]( void* p ) |
1702 | { | 1699 | { |
1703 | free( p ); | 1700 | free( p ); |
1704 | } | 1701 | } |
1705 | 1702 | ||
1706 | void operator delete[]( void* p, size_t /*size*/ ) | 1703 | void operator delete[]( void* p, size_t /*size*/ ) |
1707 | { | 1704 | { |
1708 | free( p ); | 1705 | free( p ); |
1709 | } | 1706 | } |
1710 | 1707 | ||
1711 | void operator delete( void* p ) | 1708 | void operator delete( void* p ) |
1712 | { | 1709 | { |
1713 | free( p ); | 1710 | free( p ); |
1714 | } | 1711 | } |
1715 | 1712 | ||
1716 | void operator delete( void* p, size_t /*size*/ ) | 1713 | void operator delete( void* p, size_t /*size*/ ) |
1717 | { | 1714 | { |
1718 | free( p ); | 1715 | free( p ); |
1719 | } | 1716 | } |
1720 | 1717 | ||
1721 | #endif | 1718 | #endif |
1722 | 1719 | ||
1723 | #if ( QT_VERSION <= 230 ) && !defined(SINGLE_APP) | 1720 | #if ( QT_VERSION <= 230 ) && !defined(SINGLE_APP) |
1724 | #include <qwidgetlist.h> | 1721 | #include <qwidgetlist.h> |
1725 | #ifdef QWS | 1722 | #ifdef QWS |
1726 | #include <qgfx_qws.h> | 1723 | #include <qgfx_qws.h> |
1727 | extern QRect qt_maxWindowRect; | 1724 | extern QRect qt_maxWindowRect; |
1728 | void qt_setMaxWindowRect(const QRect& r ) | 1725 | void qt_setMaxWindowRect(const QRect& r ) |
1729 | { | 1726 | { |
1730 | qt_maxWindowRect = qt_screen->mapFromDevice( r, | 1727 | qt_maxWindowRect = qt_screen->mapFromDevice( r, |
1731 | qt_screen->mapToDevice( QSize( qt_screen->width(), qt_screen->height() ) ) ); | 1728 | qt_screen->mapToDevice( QSize( qt_screen->width(), qt_screen->height() ) ) ); |
1732 | // Re-resize any maximized windows | 1729 | // Re-resize any maximized windows |
1733 | QWidgetList* l = QApplication::topLevelWidgets(); | 1730 | QWidgetList* l = QApplication::topLevelWidgets(); |
1734 | if ( l ) { | 1731 | if ( l ) { |
1735 | QWidget * w = l->first(); | 1732 | QWidget * w = l->first(); |
1736 | while ( w ) { | 1733 | while ( w ) { |
1737 | if ( w->isVisible() && w->isMaximized() ) { | 1734 | if ( w->isVisible() && w->isMaximized() ) { |
1738 | w->showMaximized(); | 1735 | w->showMaximized(); |
1739 | } | 1736 | } |
1740 | w = l->next(); | 1737 | w = l->next(); |
1741 | } | 1738 | } |
1742 | delete l; | 1739 | delete l; |
1743 | } | 1740 | } |
1744 | } | 1741 | } |
1745 | #endif | 1742 | #endif |
1746 | #endif | 1743 | #endif |