-rw-r--r-- | library/qpeapplication.cpp | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp index 149e6bb..71ec5b3 100644 --- a/library/qpeapplication.cpp +++ b/library/qpeapplication.cpp | |||
@@ -1006,241 +1006,287 @@ QString QPEApplication::qpeDir() | |||
1006 | 1006 | ||
1007 | return QString( "../" ); | 1007 | return QString( "../" ); |
1008 | } | 1008 | } |
1009 | 1009 | ||
1010 | /*! | 1010 | /*! |
1011 | Returns the user's current Document directory. There is a trailing "/". | 1011 | Returns the user's current Document directory. There is a trailing "/". |
1012 | .. well, it does now,, and there's no trailing '/' | 1012 | .. well, it does now,, and there's no trailing '/' |
1013 | */ | 1013 | */ |
1014 | QString QPEApplication::documentDir() | 1014 | QString QPEApplication::documentDir() |
1015 | { | 1015 | { |
1016 | const char* base = getenv( "HOME"); | 1016 | const char* base = getenv( "HOME"); |
1017 | if ( base ) | 1017 | if ( base ) |
1018 | return QString( base ) + "/Documents"; | 1018 | return QString( base ) + "/Documents"; |
1019 | 1019 | ||
1020 | return QString( "../Documents" ); | 1020 | return QString( "../Documents" ); |
1021 | } | 1021 | } |
1022 | 1022 | ||
1023 | static int deforient = -1; | 1023 | static int deforient = -1; |
1024 | 1024 | ||
1025 | /*! | 1025 | /*! |
1026 | \internal | 1026 | \internal |
1027 | */ | 1027 | */ |
1028 | int QPEApplication::defaultRotation() | 1028 | int QPEApplication::defaultRotation() |
1029 | { | 1029 | { |
1030 | if ( deforient < 0 ) { | 1030 | if ( deforient < 0 ) { |
1031 | QString d = getenv( "QWS_DISPLAY" ); | 1031 | QString d = getenv( "QWS_DISPLAY" ); |
1032 | if ( d.contains( "Rot90" ) ) { | 1032 | if ( d.contains( "Rot90" ) ) { |
1033 | deforient = 90; | 1033 | deforient = 90; |
1034 | } | 1034 | } |
1035 | else if ( d.contains( "Rot180" ) ) { | 1035 | else if ( d.contains( "Rot180" ) ) { |
1036 | deforient = 180; | 1036 | deforient = 180; |
1037 | } | 1037 | } |
1038 | else if ( d.contains( "Rot270" ) ) { | 1038 | else if ( d.contains( "Rot270" ) ) { |
1039 | deforient = 270; | 1039 | deforient = 270; |
1040 | } | 1040 | } |
1041 | else { | 1041 | else { |
1042 | deforient = 0; | 1042 | deforient = 0; |
1043 | } | 1043 | } |
1044 | } | 1044 | } |
1045 | return deforient; | 1045 | return deforient; |
1046 | } | 1046 | } |
1047 | 1047 | ||
1048 | /*! | 1048 | /*! |
1049 | \internal | 1049 | \internal |
1050 | */ | 1050 | */ |
1051 | void QPEApplication::setDefaultRotation( int r ) | 1051 | void QPEApplication::setDefaultRotation( int r ) |
1052 | { | 1052 | { |
1053 | if ( qApp->type() == GuiServer ) { | 1053 | if ( qApp->type() == GuiServer ) { |
1054 | deforient = r; | 1054 | deforient = r; |
1055 | setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 ); | 1055 | setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 ); |
1056 | Config config("qpe"); | 1056 | Config config("qpe"); |
1057 | config.setGroup( "Rotation" ); | 1057 | config.setGroup( "Rotation" ); |
1058 | config.writeEntry( "Rot", r ); | 1058 | config.writeEntry( "Rot", r ); |
1059 | } | 1059 | } |
1060 | else { | 1060 | else { |
1061 | #ifndef QT_NO_COP | 1061 | #ifndef QT_NO_COP |
1062 | { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" ); | 1062 | { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" ); |
1063 | e << r; | 1063 | e << r; |
1064 | } | 1064 | } |
1065 | #endif | 1065 | #endif |
1066 | 1066 | ||
1067 | } | 1067 | } |
1068 | } | 1068 | } |
1069 | 1069 | ||
1070 | #include <qgfx_qws.h> | ||
1071 | #include <qwindowsystem_qws.h> | ||
1072 | #include <qpixmapcache.h> | ||
1073 | |||
1074 | extern void qws_clearLoadedFonts(); | ||
1075 | |||
1076 | inline void QPEApplication::setCurrentMode( int x, int y, int depth ) | ||
1077 | { | ||
1078 | // Reset the caches | ||
1079 | qws_clearLoadedFonts(); | ||
1080 | QPixmapCache::clear(); | ||
1081 | |||
1082 | // Change the screen mode | ||
1083 | qt_screen->setMode(x, y, depth); | ||
1084 | |||
1085 | if ( qApp->type() == GuiServer ) { | ||
1086 | // Reconfigure the GuiServer | ||
1087 | qwsServer->beginDisplayReconfigure(); | ||
1088 | qwsServer->endDisplayReconfigure(); | ||
1089 | |||
1090 | // Get all the running apps to reset | ||
1091 | QCopEnvelope env( "QPE/System", "reset()" ); | ||
1092 | } | ||
1093 | } | ||
1094 | |||
1095 | inline void QPEApplication::reset() { | ||
1096 | // Reconnect to the screen | ||
1097 | qt_screen->disconnect(); | ||
1098 | qt_screen->connect( QString::null ); | ||
1099 | |||
1100 | // Redraw everything | ||
1101 | applyStyle(); | ||
1102 | } | ||
1070 | 1103 | ||
1071 | /*! | 1104 | /*! |
1072 | \internal | 1105 | \internal |
1073 | */ | 1106 | */ |
1074 | void QPEApplication::applyStyle() | 1107 | void QPEApplication::applyStyle() |
1075 | { | 1108 | { |
1076 | Config config( "qpe" ); | 1109 | Config config( "qpe" ); |
1077 | config.setGroup( "Appearance" ); | 1110 | config.setGroup( "Appearance" ); |
1078 | 1111 | ||
1079 | #if QT_VERSION > 233 | 1112 | #if QT_VERSION > 233 |
1080 | // don't block ourselves ... | 1113 | // don't block ourselves ... |
1081 | Opie::force_appearance = 0; | 1114 | Opie::force_appearance = 0; |
1082 | 1115 | ||
1083 | static QString appname = Opie::binaryName ( ); | 1116 | static QString appname = Opie::binaryName ( ); |
1084 | 1117 | ||
1085 | QStringList ex = config. readListEntry ( "NoStyle", ';' ); | 1118 | QStringList ex = config. readListEntry ( "NoStyle", ';' ); |
1086 | int nostyle = 0; | 1119 | int nostyle = 0; |
1087 | for ( QStringList::Iterator it = ex. begin ( ); it != ex. end ( ); ++it ) { | 1120 | for ( QStringList::Iterator it = ex. begin ( ); it != ex. end ( ); ++it ) { |
1088 | if ( QRegExp (( *it ). mid ( 1 ), false, true ). find ( appname, 0 ) >= 0 ) { | 1121 | if ( QRegExp (( *it ). mid ( 1 ), false, true ). find ( appname, 0 ) >= 0 ) { |
1089 | nostyle = ( *it ). left ( 1 ). toInt ( 0, 32 ); | 1122 | nostyle = ( *it ). left ( 1 ). toInt ( 0, 32 ); |
1090 | break; | 1123 | break; |
1091 | } | 1124 | } |
1092 | } | 1125 | } |
1093 | 1126 | ||
1094 | // Widget style | 1127 | // Widget style |
1095 | QString style = config.readEntry( "Style", "FlatStyle" ); | 1128 | QString style = config.readEntry( "Style", "FlatStyle" ); |
1096 | 1129 | ||
1097 | // don't set a custom style | 1130 | // don't set a custom style |
1098 | if ( nostyle & Opie::Force_Style ) | 1131 | if ( nostyle & Opie::Force_Style ) |
1099 | style = "FlatStyle"; | 1132 | style = "FlatStyle"; |
1100 | 1133 | ||
1101 | internalSetStyle ( style ); | 1134 | internalSetStyle ( style ); |
1102 | 1135 | ||
1103 | // Colors - from /etc/colors/Liquid.scheme | 1136 | // Colors - from /etc/colors/Liquid.scheme |
1104 | QColor bgcolor( config.readEntry( "Background", "#E0E0E0" ) ); | 1137 | QColor bgcolor( config.readEntry( "Background", "#E0E0E0" ) ); |
1105 | QColor btncolor( config.readEntry( "Button", "#96c8fa" ) ); | 1138 | QColor btncolor( config.readEntry( "Button", "#96c8fa" ) ); |
1106 | QPalette pal( btncolor, bgcolor ); | 1139 | QPalette pal( btncolor, bgcolor ); |
1107 | QString color = config.readEntry( "Highlight", "#73adef" ); | 1140 | QString color = config.readEntry( "Highlight", "#73adef" ); |
1108 | pal.setColor( QColorGroup::Highlight, QColor( color ) ); | 1141 | pal.setColor( QColorGroup::Highlight, QColor( color ) ); |
1109 | color = config.readEntry( "HighlightedText", "#FFFFFF" ); | 1142 | color = config.readEntry( "HighlightedText", "#FFFFFF" ); |
1110 | pal.setColor( QColorGroup::HighlightedText, QColor( color ) ); | 1143 | pal.setColor( QColorGroup::HighlightedText, QColor( color ) ); |
1111 | color = config.readEntry( "Text", "#000000" ); | 1144 | color = config.readEntry( "Text", "#000000" ); |
1112 | pal.setColor( QColorGroup::Text, QColor( color ) ); | 1145 | pal.setColor( QColorGroup::Text, QColor( color ) ); |
1113 | color = config.readEntry( "ButtonText", "#000000" ); | 1146 | color = config.readEntry( "ButtonText", "#000000" ); |
1114 | pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) ); | 1147 | pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) ); |
1115 | color = config.readEntry( "Base", "#FFFFFF" ); | 1148 | color = config.readEntry( "Base", "#FFFFFF" ); |
1116 | pal.setColor( QColorGroup::Base, QColor( color ) ); | 1149 | pal.setColor( QColorGroup::Base, QColor( color ) ); |
1117 | 1150 | ||
1118 | pal.setColor( QPalette::Disabled, QColorGroup::Text, | 1151 | pal.setColor( QPalette::Disabled, QColorGroup::Text, |
1119 | pal.color( QPalette::Active, QColorGroup::Background ).dark() ); | 1152 | pal.color( QPalette::Active, QColorGroup::Background ).dark() ); |
1120 | 1153 | ||
1121 | setPalette( pal, TRUE ); | 1154 | setPalette( pal, TRUE ); |
1122 | 1155 | ||
1123 | // Window Decoration | 1156 | // Window Decoration |
1124 | QString dec = config.readEntry( "Decoration", "Flat" ); | 1157 | QString dec = config.readEntry( "Decoration", "Flat" ); |
1125 | 1158 | ||
1126 | // don't set a custom deco | 1159 | // don't set a custom deco |
1127 | if ( nostyle & Opie::Force_Decoration ) | 1160 | if ( nostyle & Opie::Force_Decoration ) |
1128 | dec = ""; | 1161 | dec = ""; |
1129 | 1162 | ||
1130 | //qDebug ( "Setting Deco: %s -- old %s (%d)", dec.latin1(), d-> decorationName.latin1(), nostyle); | 1163 | //qDebug ( "Setting Deco: %s -- old %s (%d)", dec.latin1(), d-> decorationName.latin1(), nostyle); |
1131 | 1164 | ||
1132 | if ( dec != d->decorationName ) { | 1165 | if ( dec != d->decorationName ) { |
1133 | qwsSetDecoration( new QPEDecoration( dec ) ); | 1166 | qwsSetDecoration( new QPEDecoration( dec ) ); |
1134 | d->decorationName = dec; | 1167 | d->decorationName = dec; |
1135 | } | 1168 | } |
1136 | 1169 | ||
1137 | // Font | 1170 | // Font |
1138 | QString ff = config.readEntry( "FontFamily", font().family() ); | 1171 | QString ff = config.readEntry( "FontFamily", font().family() ); |
1139 | int fs = config.readNumEntry( "FontSize", font().pointSize() ); | 1172 | int fs = config.readNumEntry( "FontSize", font().pointSize() ); |
1140 | 1173 | ||
1141 | // don't set a custom font | 1174 | // don't set a custom font |
1142 | if ( nostyle & Opie::Force_Font ) { | 1175 | if ( nostyle & Opie::Force_Font ) { |
1143 | ff = "Vera"; | 1176 | ff = "Vera"; |
1144 | fs = 10; | 1177 | fs = 10; |
1145 | } | 1178 | } |
1146 | 1179 | ||
1147 | setFont ( QFont ( ff, fs ), true ); | 1180 | setFont ( QFont ( ff, fs ), true ); |
1148 | 1181 | ||
1149 | // revert to global blocking policy ... | 1182 | // revert to global blocking policy ... |
1150 | Opie::force_appearance = config. readBoolEntry ( "ForceStyle", false ) ? Opie::Force_All : Opie::Force_None; | 1183 | Opie::force_appearance = config. readBoolEntry ( "ForceStyle", false ) ? Opie::Force_All : Opie::Force_None; |
1151 | Opie::force_appearance &= ~nostyle; | 1184 | Opie::force_appearance &= ~nostyle; |
1152 | #endif | 1185 | #endif |
1153 | } | 1186 | } |
1154 | 1187 | ||
1155 | void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data ) | 1188 | void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data ) |
1156 | { | 1189 | { |
1157 | #ifdef Q_WS_QWS | 1190 | #ifdef Q_WS_QWS |
1158 | QDataStream stream( data, IO_ReadOnly ); | 1191 | QDataStream stream( data, IO_ReadOnly ); |
1159 | if ( msg == "applyStyle()" ) { | 1192 | if ( msg == "applyStyle()" ) { |
1160 | applyStyle(); | 1193 | applyStyle(); |
1161 | } | 1194 | } |
1162 | else if ( msg == "toggleApplicationMenu()" ) { | 1195 | else if ( msg == "toggleApplicationMenu()" ) { |
1163 | QWidget *active = activeWindow ( ); | 1196 | QWidget *active = activeWindow ( ); |
1164 | 1197 | ||
1165 | if ( active ) { | 1198 | if ( active ) { |
1166 | QPEMenuToolFocusManager *man = QPEMenuToolFocusManager::manager ( ); | 1199 | QPEMenuToolFocusManager *man = QPEMenuToolFocusManager::manager ( ); |
1167 | bool oldactive = man-> isActive ( ); | 1200 | bool oldactive = man-> isActive ( ); |
1168 | 1201 | ||
1169 | man-> setActive( !man-> isActive() ); | 1202 | man-> setActive( !man-> isActive() ); |
1170 | 1203 | ||
1171 | if ( !oldactive && !man-> isActive ( )) { // no menubar to toggle -> try O-Menu | 1204 | if ( !oldactive && !man-> isActive ( )) { // no menubar to toggle -> try O-Menu |
1172 | QCopEnvelope e ( "QPE/TaskBar", "toggleStartMenu()" ); | 1205 | QCopEnvelope e ( "QPE/TaskBar", "toggleStartMenu()" ); |
1173 | } | 1206 | } |
1174 | } | 1207 | } |
1175 | } | 1208 | } |
1176 | else if ( msg == "setDefaultRotation(int)" ) { | 1209 | else if ( msg == "setDefaultRotation(int)" ) { |
1177 | if ( type() == GuiServer ) { | 1210 | if ( type() == GuiServer ) { |
1178 | int r; | 1211 | int r; |
1179 | stream >> r; | 1212 | stream >> r; |
1180 | setDefaultRotation( r ); | 1213 | setDefaultRotation( r ); |
1181 | } | 1214 | } |
1182 | } | 1215 | } |
1216 | else if ( msg == "setCurrentMode(int,int,int)" ) { // Added: 2003-06-11 by Tim Ansell <mithro@mithis.net> | ||
1217 | if ( type() == GuiServer ) { | ||
1218 | int x, y, depth; | ||
1219 | stream >> x; | ||
1220 | stream >> y; | ||
1221 | stream >> depth; | ||
1222 | setCurrentMode( x, y, depth ); | ||
1223 | } | ||
1224 | } | ||
1225 | else if ( msg == "reset()" ) { | ||
1226 | if ( type() != GuiServer ) | ||
1227 | reset(); | ||
1228 | } | ||
1183 | else if ( msg == "setCurrentRotation(int)" ) { | 1229 | else if ( msg == "setCurrentRotation(int)" ) { |
1184 | int r; | 1230 | int r; |
1185 | stream >> r; | 1231 | stream >> r; |
1186 | setCurrentRotation( r ); | 1232 | setCurrentRotation( r ); |
1187 | } | 1233 | } |
1188 | else if ( msg == "shutdown()" ) { | 1234 | else if ( msg == "shutdown()" ) { |
1189 | if ( type() == GuiServer ) | 1235 | if ( type() == GuiServer ) |
1190 | shutdown(); | 1236 | shutdown(); |
1191 | } | 1237 | } |
1192 | else if ( msg == "quit()" ) { | 1238 | else if ( msg == "quit()" ) { |
1193 | if ( type() != GuiServer ) | 1239 | if ( type() != GuiServer ) |
1194 | tryQuit(); | 1240 | tryQuit(); |
1195 | } | 1241 | } |
1196 | else if ( msg == "forceQuit()" ) { | 1242 | else if ( msg == "forceQuit()" ) { |
1197 | if ( type() != GuiServer ) | 1243 | if ( type() != GuiServer ) |
1198 | quit(); | 1244 | quit(); |
1199 | } | 1245 | } |
1200 | else if ( msg == "restart()" ) { | 1246 | else if ( msg == "restart()" ) { |
1201 | if ( type() == GuiServer ) | 1247 | if ( type() == GuiServer ) |
1202 | restart(); | 1248 | restart(); |
1203 | } | 1249 | } |
1204 | else if ( msg == "language(QString)" ) { | 1250 | else if ( msg == "language(QString)" ) { |
1205 | if ( type() == GuiServer ) { | 1251 | if ( type() == GuiServer ) { |
1206 | QString l; | 1252 | QString l; |
1207 | stream >> l; | 1253 | stream >> l; |
1208 | QString cl = getenv( "LANG" ); | 1254 | QString cl = getenv( "LANG" ); |
1209 | if ( cl != l ) { | 1255 | if ( cl != l ) { |
1210 | if ( l.isNull() ) | 1256 | if ( l.isNull() ) |
1211 | unsetenv( "LANG" ); | 1257 | unsetenv( "LANG" ); |
1212 | else | 1258 | else |
1213 | setenv( "LANG", l.latin1(), 1 ); | 1259 | setenv( "LANG", l.latin1(), 1 ); |
1214 | restart(); | 1260 | restart(); |
1215 | } | 1261 | } |
1216 | } | 1262 | } |
1217 | } | 1263 | } |
1218 | else if ( msg == "timeChange(QString)" ) { | 1264 | else if ( msg == "timeChange(QString)" ) { |
1219 | QString t; | 1265 | QString t; |
1220 | stream >> t; | 1266 | stream >> t; |
1221 | if ( t.isNull() ) | 1267 | if ( t.isNull() ) |
1222 | unsetenv( "TZ" ); | 1268 | unsetenv( "TZ" ); |
1223 | else | 1269 | else |
1224 | setenv( "TZ", t.latin1(), 1 ); | 1270 | setenv( "TZ", t.latin1(), 1 ); |
1225 | // emit the signal so everyone else knows... | 1271 | // emit the signal so everyone else knows... |
1226 | emit timeChanged(); | 1272 | emit timeChanged(); |
1227 | } | 1273 | } |
1228 | else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) { | 1274 | else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) { |
1229 | if ( type() == GuiServer ) { | 1275 | if ( type() == GuiServer ) { |
1230 | QDateTime when; | 1276 | QDateTime when; |
1231 | QCString channel, message; | 1277 | QCString channel, message; |
1232 | int data; | 1278 | int data; |
1233 | stream >> when >> channel >> message >> data; | 1279 | stream >> when >> channel >> message >> data; |
1234 | AlarmServer::addAlarm( when, channel, message, data ); | 1280 | AlarmServer::addAlarm( when, channel, message, data ); |
1235 | } | 1281 | } |
1236 | } | 1282 | } |
1237 | else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) { | 1283 | else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) { |
1238 | if ( type() == GuiServer ) { | 1284 | if ( type() == GuiServer ) { |
1239 | QDateTime when; | 1285 | QDateTime when; |
1240 | QCString channel, message; | 1286 | QCString channel, message; |
1241 | int data; | 1287 | int data; |
1242 | stream >> when >> channel >> message >> data; | 1288 | stream >> when >> channel >> message >> data; |
1243 | AlarmServer::deleteAlarm( when, channel, message, data ); | 1289 | AlarmServer::deleteAlarm( when, channel, message, data ); |
1244 | } | 1290 | } |
1245 | } | 1291 | } |
1246 | else if ( msg == "clockChange(bool)" ) { | 1292 | else if ( msg == "clockChange(bool)" ) { |