-rw-r--r-- | library/qpeapplication.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp index 19e99f2..dcc1001 100644 --- a/library/qpeapplication.cpp +++ b/library/qpeapplication.cpp | |||
@@ -1186,1105 +1186,1105 @@ bool QPEApplication::qwsEventFilter( QWSEvent * e ) | |||
1186 | } | 1186 | } |
1187 | if ( fe->simpleData.get_focus && inputMethodDict ) { | 1187 | if ( fe->simpleData.get_focus && inputMethodDict ) { |
1188 | InputMethodHint m = inputMethodHint( QWidget::find( e->window() ) ); | 1188 | InputMethodHint m = inputMethodHint( QWidget::find( e->window() ) ); |
1189 | if ( m == AlwaysOff ) | 1189 | if ( m == AlwaysOff ) |
1190 | Global::hideInputMethod(); | 1190 | Global::hideInputMethod(); |
1191 | if ( m == AlwaysOn ) | 1191 | if ( m == AlwaysOn ) |
1192 | Global::showInputMethod(); | 1192 | Global::showInputMethod(); |
1193 | } | 1193 | } |
1194 | } | 1194 | } |
1195 | 1195 | ||
1196 | 1196 | ||
1197 | return QApplication::qwsEventFilter( e ); | 1197 | return QApplication::qwsEventFilter( e ); |
1198 | } | 1198 | } |
1199 | #endif | 1199 | #endif |
1200 | 1200 | ||
1201 | /*! | 1201 | /*! |
1202 | Destroys the QPEApplication. | 1202 | Destroys the QPEApplication. |
1203 | */ | 1203 | */ |
1204 | QPEApplication::~QPEApplication() | 1204 | QPEApplication::~QPEApplication() |
1205 | { | 1205 | { |
1206 | ungrabKeyboard(); | 1206 | ungrabKeyboard(); |
1207 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 1207 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
1208 | // Need to delete QCopChannels early, since the display will | 1208 | // Need to delete QCopChannels early, since the display will |
1209 | // be gone by the time we get to ~QObject(). | 1209 | // be gone by the time we get to ~QObject(). |
1210 | delete sysChannel; | 1210 | delete sysChannel; |
1211 | delete pidChannel; | 1211 | delete pidChannel; |
1212 | #endif | 1212 | #endif |
1213 | 1213 | ||
1214 | #ifdef OPIE_WITHROHFEEDBACK | 1214 | #ifdef OPIE_WITHROHFEEDBACK |
1215 | if( d->RoH ) | 1215 | if( d->RoH ) |
1216 | delete d->RoH; | 1216 | delete d->RoH; |
1217 | #endif | 1217 | #endif |
1218 | delete d; | 1218 | delete d; |
1219 | } | 1219 | } |
1220 | 1220 | ||
1221 | /*! | 1221 | /*! |
1222 | Returns <tt>$OPIEDIR/</tt>. | 1222 | Returns <tt>$OPIEDIR/</tt>. |
1223 | */ | 1223 | */ |
1224 | QString QPEApplication::qpeDir() | 1224 | QString QPEApplication::qpeDir() |
1225 | { | 1225 | { |
1226 | QString base, dir; | 1226 | QString base, dir; |
1227 | 1227 | ||
1228 | if (getenv( "OPIEDIR" )) | 1228 | if (getenv( "OPIEDIR" )) |
1229 | base = QString(getenv("OPIEDIR")).stripWhiteSpace(); | 1229 | base = QString(getenv("OPIEDIR")).stripWhiteSpace(); |
1230 | if ( !base.isNull() && (base.length() > 0 )){ | 1230 | if ( !base.isNull() && (base.length() > 0 )){ |
1231 | #ifdef Q_OS_WIN32 | 1231 | #ifdef Q_OS_WIN32 |
1232 | QString temp(base); | 1232 | QString temp(base); |
1233 | if (temp[(int)temp.length()-1] != QDir::separator()) | 1233 | if (temp[(int)temp.length()-1] != QDir::separator()) |
1234 | temp.append(QDir::separator()); | 1234 | temp.append(QDir::separator()); |
1235 | dir = temp; | 1235 | dir = temp; |
1236 | #else | 1236 | #else |
1237 | dir = QString( base ) + "/"; | 1237 | dir = QString( base ) + "/"; |
1238 | #endif | 1238 | #endif |
1239 | }else{ | 1239 | }else{ |
1240 | dir = QString( ".." ) + QDir::separator(); | 1240 | dir = QString( ".." ) + QDir::separator(); |
1241 | } | 1241 | } |
1242 | 1242 | ||
1243 | return dir; | 1243 | return dir; |
1244 | } | 1244 | } |
1245 | 1245 | ||
1246 | /*! | 1246 | /*! |
1247 | Returns the user's current Document directory. There is a trailing "/". | 1247 | Returns the user's current Document directory. There is a trailing "/". |
1248 | .. well, it does now,, and there's no trailing '/' | 1248 | .. well, it does now,, and there's no trailing '/' |
1249 | */ | 1249 | */ |
1250 | QString QPEApplication::documentDir() | 1250 | QString QPEApplication::documentDir() |
1251 | { | 1251 | { |
1252 | const char* base = getenv( "HOME"); | 1252 | const char* base = getenv( "HOME"); |
1253 | if ( base ) | 1253 | if ( base ) |
1254 | return QString( base ) + "/Documents"; | 1254 | return QString( base ) + "/Documents"; |
1255 | 1255 | ||
1256 | return QString( "../Documents" ); | 1256 | return QString( "../Documents" ); |
1257 | } | 1257 | } |
1258 | 1258 | ||
1259 | static int deforient = -1; | 1259 | static int deforient = -1; |
1260 | 1260 | ||
1261 | /*! | 1261 | /*! |
1262 | \internal | 1262 | \internal |
1263 | */ | 1263 | */ |
1264 | int QPEApplication::defaultRotation() | 1264 | int QPEApplication::defaultRotation() |
1265 | { | 1265 | { |
1266 | if ( deforient < 0 ) { | 1266 | if ( deforient < 0 ) { |
1267 | QString d = getenv( "QWS_DISPLAY" ); | 1267 | QString d = getenv( "QWS_DISPLAY" ); |
1268 | if ( d.contains( "Rot90" ) ) { | 1268 | if ( d.contains( "Rot90" ) ) { |
1269 | deforient = 90; | 1269 | deforient = 90; |
1270 | } | 1270 | } |
1271 | else if ( d.contains( "Rot180" ) ) { | 1271 | else if ( d.contains( "Rot180" ) ) { |
1272 | deforient = 180; | 1272 | deforient = 180; |
1273 | } | 1273 | } |
1274 | else if ( d.contains( "Rot270" ) ) { | 1274 | else if ( d.contains( "Rot270" ) ) { |
1275 | deforient = 270; | 1275 | deforient = 270; |
1276 | } | 1276 | } |
1277 | else { | 1277 | else { |
1278 | deforient = 0; | 1278 | deforient = 0; |
1279 | } | 1279 | } |
1280 | } | 1280 | } |
1281 | return deforient; | 1281 | return deforient; |
1282 | } | 1282 | } |
1283 | 1283 | ||
1284 | /*! | 1284 | /*! |
1285 | \internal | 1285 | \internal |
1286 | */ | 1286 | */ |
1287 | void QPEApplication::setDefaultRotation( int r ) | 1287 | void QPEApplication::setDefaultRotation( int r ) |
1288 | { | 1288 | { |
1289 | if ( qApp->type() == GuiServer ) { | 1289 | if ( qApp->type() == GuiServer ) { |
1290 | deforient = r; | 1290 | deforient = r; |
1291 | int j = 0; | 1291 | int j = 0; |
1292 | QCString old = getenv( "QWS_DISPLAY" ) ? getenv( "QWS_DISPLAY" ) : "Transformed"; | 1292 | QCString old = getenv( "QWS_DISPLAY" ) ? getenv( "QWS_DISPLAY" ) : "Transformed"; |
1293 | QString driver( old.left( ( ( j = old.find( ':' ) ) >= 0 ) ? j : old.size() ).data() ); | 1293 | QString driver( old.left( ( ( j = old.find( ':' ) ) >= 0 ) ? j : old.size() ).data() ); |
1294 | setenv( "QWS_DISPLAY", QString( "%1:Rot%2:0" ).arg(driver).arg( r ).latin1(), 1 ); | 1294 | setenv( "QWS_DISPLAY", QString( "%1:Rot%2:0" ).arg(driver).arg( r ).latin1(), 1 ); |
1295 | Config config("qpe"); | 1295 | Config config("qpe"); |
1296 | config.setGroup( "Rotation" ); | 1296 | config.setGroup( "Rotation" ); |
1297 | config.writeEntry( "Rot", r ); | 1297 | config.writeEntry( "Rot", r ); |
1298 | } | 1298 | } |
1299 | else { | 1299 | else { |
1300 | #ifndef QT_NO_COP | 1300 | #ifndef QT_NO_COP |
1301 | { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" ); | 1301 | { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" ); |
1302 | e << r; | 1302 | e << r; |
1303 | } | 1303 | } |
1304 | #endif | 1304 | #endif |
1305 | 1305 | ||
1306 | } | 1306 | } |
1307 | } | 1307 | } |
1308 | 1308 | ||
1309 | #include <qgfx_qws.h> | 1309 | #include <qgfx_qws.h> |
1310 | #include <qwindowsystem_qws.h> | 1310 | #include <qwindowsystem_qws.h> |
1311 | 1311 | ||
1312 | #if QT_VERSION > 236 | 1312 | #if QT_VERSION > 236 |
1313 | extern void qws_clearLoadedFonts(); | 1313 | extern void qws_clearLoadedFonts(); |
1314 | #endif | 1314 | #endif |
1315 | 1315 | ||
1316 | void QPEApplication::setCurrentMode( int x, int y, int depth ) | 1316 | void QPEApplication::setCurrentMode( int x, int y, int depth ) |
1317 | { | 1317 | { |
1318 | // Reset the caches | 1318 | // Reset the caches |
1319 | #if QT_VERSION > 236 | 1319 | #if QT_VERSION > 236 |
1320 | qws_clearLoadedFonts(); | 1320 | qws_clearLoadedFonts(); |
1321 | #endif | 1321 | #endif |
1322 | QPixmapCache::clear(); | 1322 | QPixmapCache::clear(); |
1323 | 1323 | ||
1324 | // Change the screen mode | 1324 | // Change the screen mode |
1325 | qt_screen->setMode(x, y, depth); | 1325 | qt_screen->setMode(x, y, depth); |
1326 | 1326 | ||
1327 | if ( qApp->type() == GuiServer ) { | 1327 | if ( qApp->type() == GuiServer ) { |
1328 | #if QT_VERSION > 236 | 1328 | #if QT_VERSION > 236 |
1329 | // Reconfigure the GuiServer | 1329 | // Reconfigure the GuiServer |
1330 | qwsServer->beginDisplayReconfigure(); | 1330 | qwsServer->beginDisplayReconfigure(); |
1331 | qwsServer->endDisplayReconfigure(); | 1331 | qwsServer->endDisplayReconfigure(); |
1332 | #endif | 1332 | #endif |
1333 | // Get all the running apps to reset | 1333 | // Get all the running apps to reset |
1334 | QCopEnvelope env( "QPE/System", "reset()" ); | 1334 | QCopEnvelope env( "QPE/System", "reset()" ); |
1335 | } | 1335 | } |
1336 | } | 1336 | } |
1337 | 1337 | ||
1338 | void QPEApplication::reset() { | 1338 | void QPEApplication::reset() { |
1339 | // Reconnect to the screen | 1339 | // Reconnect to the screen |
1340 | qt_screen->disconnect(); | 1340 | qt_screen->disconnect(); |
1341 | qt_screen->connect( QString::null ); | 1341 | qt_screen->connect( QString::null ); |
1342 | 1342 | ||
1343 | // Redraw everything | 1343 | // Redraw everything |
1344 | applyStyle(); | 1344 | applyStyle(); |
1345 | } | 1345 | } |
1346 | 1346 | ||
1347 | #if (QT_VERSION < 238) && defined Q_OS_MACX | 1347 | #if (QT_VERSION < 238) && defined Q_OS_MACX |
1348 | bool qt_left_hand_scrollbars = false; | 1348 | bool qt_left_hand_scrollbars = false; |
1349 | #else | 1349 | #else |
1350 | extern bool qt_left_hand_scrollbars QPE_WEAK_SYMBOL; | 1350 | extern bool qt_left_hand_scrollbars QPE_WEAK_SYMBOL; |
1351 | #endif | 1351 | #endif |
1352 | 1352 | ||
1353 | /*! | 1353 | /*! |
1354 | \internal | 1354 | \internal |
1355 | */ | 1355 | */ |
1356 | void QPEApplication::applyStyle() | 1356 | void QPEApplication::applyStyle() |
1357 | { | 1357 | { |
1358 | Config config( "qpe" ); | 1358 | Config config( "qpe" ); |
1359 | config.setGroup( "Appearance" ); | 1359 | config.setGroup( "Appearance" ); |
1360 | 1360 | ||
1361 | #if QT_VERSION > 233 | 1361 | #if QT_VERSION > 233 |
1362 | // Widget style | 1362 | // Widget style |
1363 | QString style = config.readEntry( "Style", "FlatStyle" ); | 1363 | QString style = config.readEntry( "Style", "FlatStyle" ); |
1364 | 1364 | ||
1365 | internalSetStyle ( style ); | 1365 | internalSetStyle ( style ); |
1366 | 1366 | ||
1367 | // Colors - from /etc/colors/Liquid.scheme | 1367 | // Colors - from /etc/colors/Liquid.scheme |
1368 | QColor bgcolor( config.readEntry( "Background", "#E0E0E0" ) ); | 1368 | QColor bgcolor( config.readEntry( "Background", "#E0E0E0" ) ); |
1369 | QColor btncolor( config.readEntry( "Button", "#96c8fa" ) ); | 1369 | QColor btncolor( config.readEntry( "Button", "#96c8fa" ) ); |
1370 | QPalette pal( btncolor, bgcolor ); | 1370 | QPalette pal( btncolor, bgcolor ); |
1371 | QString color = config.readEntry( "Highlight", "#73adef" ); | 1371 | QString color = config.readEntry( "Highlight", "#73adef" ); |
1372 | pal.setColor( QColorGroup::Highlight, QColor( color ) ); | 1372 | pal.setColor( QColorGroup::Highlight, QColor( color ) ); |
1373 | color = config.readEntry( "HighlightedText", "#FFFFFF" ); | 1373 | color = config.readEntry( "HighlightedText", "#FFFFFF" ); |
1374 | pal.setColor( QColorGroup::HighlightedText, QColor( color ) ); | 1374 | pal.setColor( QColorGroup::HighlightedText, QColor( color ) ); |
1375 | color = config.readEntry( "Text", "#000000" ); | 1375 | color = config.readEntry( "Text", "#000000" ); |
1376 | pal.setColor( QColorGroup::Text, QColor( color ) ); | 1376 | pal.setColor( QColorGroup::Text, QColor( color ) ); |
1377 | color = config.readEntry( "ButtonText", "#000000" ); | 1377 | color = config.readEntry( "ButtonText", "#000000" ); |
1378 | pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) ); | 1378 | pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) ); |
1379 | color = config.readEntry( "Base", "#FFFFFF" ); | 1379 | color = config.readEntry( "Base", "#FFFFFF" ); |
1380 | pal.setColor( QColorGroup::Base, QColor( color ) ); | 1380 | pal.setColor( QColorGroup::Base, QColor( color ) ); |
1381 | 1381 | ||
1382 | pal.setColor( QPalette::Disabled, QColorGroup::Text, | 1382 | pal.setColor( QPalette::Disabled, QColorGroup::Text, |
1383 | pal.color( QPalette::Active, QColorGroup::Background ).dark() ); | 1383 | pal.color( QPalette::Active, QColorGroup::Background ).dark() ); |
1384 | 1384 | ||
1385 | setPalette( pal, TRUE ); | 1385 | setPalette( pal, TRUE ); |
1386 | 1386 | ||
1387 | 1387 | ||
1388 | // Set the ScrollBar on the 'right' side but only if the weak symbol is present | 1388 | // Set the ScrollBar on the 'right' side but only if the weak symbol is present |
1389 | if (&qt_left_hand_scrollbars ) | 1389 | if (&qt_left_hand_scrollbars ) |
1390 | qt_left_hand_scrollbars = config.readBoolEntry( "LeftHand", false ); | 1390 | qt_left_hand_scrollbars = config.readBoolEntry( "LeftHand", false ); |
1391 | 1391 | ||
1392 | // Window Decoration | 1392 | // Window Decoration |
1393 | QString dec = config.readEntry( "Decoration", "Flat" ); | 1393 | QString dec = config.readEntry( "Decoration", "Flat" ); |
1394 | 1394 | ||
1395 | if ( dec != d->decorationName ) { | 1395 | if ( dec != d->decorationName ) { |
1396 | qwsSetDecoration( new QPEDecoration( dec ) ); | 1396 | qwsSetDecoration( new QPEDecoration( dec ) ); |
1397 | d->decorationName = dec; | 1397 | d->decorationName = dec; |
1398 | } | 1398 | } |
1399 | 1399 | ||
1400 | // Font | 1400 | // Font |
1401 | QString ff = config.readEntry( "FontFamily", font().family() ); | 1401 | QString ff = config.readEntry( "FontFamily", font().family() ); |
1402 | int fs = config.readNumEntry( "FontSize", font().pointSize() ); | 1402 | int fs = config.readNumEntry( "FontSize", font().pointSize() ); |
1403 | 1403 | ||
1404 | setFont ( QFont ( ff, fs ), true ); | 1404 | setFont ( QFont ( ff, fs ), true ); |
1405 | #endif | 1405 | #endif |
1406 | } | 1406 | } |
1407 | 1407 | ||
1408 | void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data ) | 1408 | void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data ) |
1409 | { | 1409 | { |
1410 | #ifdef Q_WS_QWS | 1410 | #ifdef Q_WS_QWS |
1411 | QDataStream stream( data, IO_ReadOnly ); | 1411 | QDataStream stream( data, IO_ReadOnly ); |
1412 | if ( msg == "applyStyle()" ) { | 1412 | if ( msg == "applyStyle()" ) { |
1413 | applyStyle(); | 1413 | applyStyle(); |
1414 | } | 1414 | } |
1415 | else if ( msg == "toggleApplicationMenu()" ) { | 1415 | else if ( msg == "toggleApplicationMenu()" ) { |
1416 | QWidget *active = activeWindow ( ); | 1416 | QWidget *active = activeWindow ( ); |
1417 | 1417 | ||
1418 | if ( active ) { | 1418 | if ( active ) { |
1419 | QPEMenuToolFocusManager *man = QPEMenuToolFocusManager::manager ( ); | 1419 | QPEMenuToolFocusManager *man = QPEMenuToolFocusManager::manager ( ); |
1420 | bool oldactive = man-> isActive ( ); | 1420 | bool oldactive = man-> isActive ( ); |
1421 | 1421 | ||
1422 | man-> setActive( !man-> isActive() ); | 1422 | man-> setActive( !man-> isActive() ); |
1423 | 1423 | ||
1424 | if ( !oldactive && !man-> isActive ( )) { // no menubar to toggle -> try O-Menu | 1424 | if ( !oldactive && !man-> isActive ( )) { // no menubar to toggle -> try O-Menu |
1425 | QCopEnvelope e ( "QPE/TaskBar", "toggleStartMenu()" ); | 1425 | QCopEnvelope e ( "QPE/TaskBar", "toggleStartMenu()" ); |
1426 | } | 1426 | } |
1427 | } | 1427 | } |
1428 | } | 1428 | } |
1429 | else if ( msg == "setDefaultRotation(int)" ) { | 1429 | else if ( msg == "setDefaultRotation(int)" ) { |
1430 | if ( type() == GuiServer ) { | 1430 | if ( type() == GuiServer ) { |
1431 | int r; | 1431 | int r; |
1432 | stream >> r; | 1432 | stream >> r; |
1433 | setDefaultRotation( r ); | 1433 | setDefaultRotation( r ); |
1434 | } | 1434 | } |
1435 | } | 1435 | } |
1436 | else if ( msg == "setCurrentMode(int,int,int)" ) { // Added: 2003-06-11 by Tim Ansell <mithro@mithis.net> | 1436 | else if ( msg == "setCurrentMode(int,int,int)" ) { // Added: 2003-06-11 by Tim Ansell <mithro@mithis.net> |
1437 | if ( type() == GuiServer ) { | 1437 | if ( type() == GuiServer ) { |
1438 | int x, y, depth; | 1438 | int x, y, depth; |
1439 | stream >> x; | 1439 | stream >> x; |
1440 | stream >> y; | 1440 | stream >> y; |
1441 | stream >> depth; | 1441 | stream >> depth; |
1442 | setCurrentMode( x, y, depth ); | 1442 | setCurrentMode( x, y, depth ); |
1443 | } | 1443 | } |
1444 | } | 1444 | } |
1445 | else if ( msg == "reset()" ) { | 1445 | else if ( msg == "reset()" ) { |
1446 | if ( type() != GuiServer ) | 1446 | if ( type() != GuiServer ) |
1447 | reset(); | 1447 | reset(); |
1448 | } | 1448 | } |
1449 | else if ( msg == "setCurrentRotation(int)" ) { | 1449 | else if ( msg == "setCurrentRotation(int)" ) { |
1450 | int r; | 1450 | int r; |
1451 | stream >> r; | 1451 | stream >> r; |
1452 | setCurrentRotation( r ); | 1452 | setCurrentRotation( r ); |
1453 | } | 1453 | } |
1454 | else if ( msg == "shutdown()" ) { | 1454 | else if ( msg == "shutdown()" ) { |
1455 | if ( type() == GuiServer ) | 1455 | if ( type() == GuiServer ) |
1456 | shutdown(); | 1456 | shutdown(); |
1457 | } | 1457 | } |
1458 | else if ( msg == "quit()" ) { | 1458 | else if ( msg == "quit()" ) { |
1459 | if ( type() != GuiServer ) | 1459 | if ( type() != GuiServer ) |
1460 | tryQuit(); | 1460 | tryQuit(); |
1461 | } | 1461 | } |
1462 | else if ( msg == "forceQuit()" ) { | 1462 | else if ( msg == "forceQuit()" ) { |
1463 | if ( type() != GuiServer ) | 1463 | if ( type() != GuiServer ) |
1464 | quit(); | 1464 | quit(); |
1465 | } | 1465 | } |
1466 | else if ( msg == "restart()" ) { | 1466 | else if ( msg == "restart()" ) { |
1467 | if ( type() == GuiServer ) | 1467 | if ( type() == GuiServer ) |
1468 | restart(); | 1468 | restart(); |
1469 | } | 1469 | } |
1470 | else if ( msg == "language(QString)" ) { | 1470 | else if ( msg == "language(QString)" ) { |
1471 | if ( type() == GuiServer ) { | 1471 | if ( type() == GuiServer ) { |
1472 | QString l; | 1472 | QString l; |
1473 | stream >> l; | 1473 | stream >> l; |
1474 | QString cl = getenv( "LANG" ); | 1474 | QString cl = getenv( "LANG" ); |
1475 | if ( cl != l ) { | 1475 | if ( cl != l ) { |
1476 | if ( l.isNull() ) | 1476 | if ( l.isNull() ) |
1477 | unsetenv( "LANG" ); | 1477 | unsetenv( "LANG" ); |
1478 | else | 1478 | else |
1479 | setenv( "LANG", l.latin1(), 1 ); | 1479 | setenv( "LANG", l.latin1(), 1 ); |
1480 | restart(); | 1480 | restart(); |
1481 | } | 1481 | } |
1482 | } | 1482 | } |
1483 | } | 1483 | } |
1484 | else if ( msg == "timeChange(QString)" ) { | 1484 | else if ( msg == "timeChange(QString)" ) { |
1485 | QString t; | 1485 | QString t; |
1486 | stream >> t; | 1486 | stream >> t; |
1487 | if ( t.isNull() ) | 1487 | if ( t.isNull() ) |
1488 | unsetenv( "TZ" ); | 1488 | unsetenv( "TZ" ); |
1489 | else | 1489 | else |
1490 | setenv( "TZ", t.latin1(), 1 ); | 1490 | setenv( "TZ", t.latin1(), 1 ); |
1491 | // emit the signal so everyone else knows... | 1491 | // emit the signal so everyone else knows... |
1492 | emit timeChanged(); | 1492 | emit timeChanged(); |
1493 | } | 1493 | } |
1494 | else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) { | 1494 | else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) { |
1495 | if ( type() == GuiServer ) { | 1495 | if ( type() == GuiServer ) { |
1496 | QDateTime when; | 1496 | QDateTime when; |
1497 | QCString channel, message; | 1497 | QCString channel, message; |
1498 | int data; | 1498 | int data; |
1499 | stream >> when >> channel >> message >> data; | 1499 | stream >> when >> channel >> message >> data; |
1500 | AlarmServer::addAlarm( when, channel, message, data ); | 1500 | AlarmServer::addAlarm( when, channel, message, data ); |
1501 | } | 1501 | } |
1502 | } | 1502 | } |
1503 | else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) { | 1503 | else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) { |
1504 | if ( type() == GuiServer ) { | 1504 | if ( type() == GuiServer ) { |
1505 | QDateTime when; | 1505 | QDateTime when; |
1506 | QCString channel, message; | 1506 | QCString channel, message; |
1507 | int data; | 1507 | int data; |
1508 | stream >> when >> channel >> message >> data; | 1508 | stream >> when >> channel >> message >> data; |
1509 | AlarmServer::deleteAlarm( when, channel, message, data ); | 1509 | AlarmServer::deleteAlarm( when, channel, message, data ); |
1510 | } | 1510 | } |
1511 | } | 1511 | } |
1512 | else if ( msg == "clockChange(bool)" ) { | 1512 | else if ( msg == "clockChange(bool)" ) { |
1513 | int tmp; | 1513 | int tmp; |
1514 | stream >> tmp; | 1514 | stream >> tmp; |
1515 | emit clockChanged( tmp ); | 1515 | emit clockChanged( tmp ); |
1516 | } | 1516 | } |
1517 | else if ( msg == "weekChange(bool)" ) { | 1517 | else if ( msg == "weekChange(bool)" ) { |
1518 | int tmp; | 1518 | int tmp; |
1519 | stream >> tmp; | 1519 | stream >> tmp; |
1520 | emit weekChanged( tmp ); | 1520 | emit weekChanged( tmp ); |
1521 | } | 1521 | } |
1522 | else if ( msg == "setDateFormat(DateFormat)" ) { | 1522 | else if ( msg == "setDateFormat(DateFormat)" ) { |
1523 | DateFormat tmp; | 1523 | DateFormat tmp; |
1524 | stream >> tmp; | 1524 | stream >> tmp; |
1525 | emit dateFormatChanged( tmp ); | 1525 | emit dateFormatChanged( tmp ); |
1526 | } | 1526 | } |
1527 | else if ( msg == "setVolume(int,int)" ) { | 1527 | else if ( msg == "setVolume(int,int)" ) { |
1528 | int t, v; | 1528 | int t, v; |
1529 | stream >> t >> v; | 1529 | stream >> t >> v; |
1530 | setVolume( t, v ); | 1530 | setVolume( t, v ); |
1531 | emit volumeChanged( muted ); | 1531 | emit volumeChanged( muted ); |
1532 | } | 1532 | } |
1533 | else if ( msg == "volumeChange(bool)" ) { | 1533 | else if ( msg == "volumeChange(bool)" ) { |
1534 | stream >> muted; | 1534 | stream >> muted; |
1535 | setVolume(); | 1535 | setVolume(); |
1536 | emit volumeChanged( muted ); | 1536 | emit volumeChanged( muted ); |
1537 | } | 1537 | } |
1538 | else if ( msg == "setMic(int,int)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> | 1538 | else if ( msg == "setMic(int,int)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> |
1539 | int t, v; | 1539 | int t, v; |
1540 | stream >> t >> v; | 1540 | stream >> t >> v; |
1541 | setMic( t, v ); | 1541 | setMic( t, v ); |
1542 | emit micChanged( micMuted ); | 1542 | emit micChanged( micMuted ); |
1543 | } | 1543 | } |
1544 | else if ( msg == "micChange(bool)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> | 1544 | else if ( msg == "micChange(bool)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> |
1545 | stream >> micMuted; | 1545 | stream >> micMuted; |
1546 | setMic(); | 1546 | setMic(); |
1547 | emit micChanged( micMuted ); | 1547 | emit micChanged( micMuted ); |
1548 | } | 1548 | } |
1549 | else if ( msg == "setBass(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> | 1549 | else if ( msg == "setBass(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> |
1550 | int t, v; | 1550 | int t, v; |
1551 | stream >> t >> v; | 1551 | stream >> t >> v; |
1552 | setBass( t, v ); | 1552 | setBass( t, v ); |
1553 | } | 1553 | } |
1554 | else if ( msg == "bassChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> | 1554 | else if ( msg == "bassChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> |
1555 | setBass(); | 1555 | setBass(); |
1556 | } | 1556 | } |
1557 | else if ( msg == "setTreble(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> | 1557 | else if ( msg == "setTreble(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> |
1558 | int t, v; | 1558 | int t, v; |
1559 | stream >> t >> v; | 1559 | stream >> t >> v; |
1560 | setTreble( t, v ); | 1560 | setTreble( t, v ); |
1561 | } | 1561 | } |
1562 | else if ( msg == "trebleChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> | 1562 | else if ( msg == "trebleChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> |
1563 | setTreble(); | 1563 | setTreble(); |
1564 | } else if ( msg == "getMarkedText()" ) { | 1564 | } else if ( msg == "getMarkedText()" ) { |
1565 | if ( type() == GuiServer ) { | 1565 | if ( type() == GuiServer ) { |
1566 | const ushort unicode = 'C'-'@'; | 1566 | const ushort unicode = 'C'-'@'; |
1567 | const int scan = Key_C; | 1567 | const int scan = Key_C; |
1568 | qwsServer->processKeyEvent( unicode, scan, ControlButton, TRUE, FALSE ); | 1568 | qwsServer->processKeyEvent( unicode, scan, ControlButton, TRUE, FALSE ); |
1569 | qwsServer->processKeyEvent( unicode, scan, ControlButton, FALSE, FALSE ); | 1569 | qwsServer->processKeyEvent( unicode, scan, ControlButton, FALSE, FALSE ); |
1570 | } | 1570 | } |
1571 | } else if ( msg == "newChannel(QString)") { | 1571 | } else if ( msg == "newChannel(QString)") { |
1572 | QString myChannel = "QPE/Application/" + d->appName; | 1572 | QString myChannel = "QPE/Application/" + d->appName; |
1573 | QString channel; | 1573 | QString channel; |
1574 | stream >> channel; | 1574 | stream >> channel; |
1575 | if (channel == myChannel) { | 1575 | if (channel == myChannel) { |
1576 | processQCopFile(); | 1576 | processQCopFile(); |
1577 | d->sendQCopQ(); | 1577 | d->sendQCopQ(); |
1578 | } | 1578 | } |
1579 | } | 1579 | } |
1580 | 1580 | ||
1581 | 1581 | ||
1582 | #endif | 1582 | #endif |
1583 | } | 1583 | } |
1584 | 1584 | ||
1585 | 1585 | ||
1586 | 1586 | ||
1587 | 1587 | ||
1588 | 1588 | ||
1589 | /*! | 1589 | /*! |
1590 | \internal | 1590 | \internal |
1591 | */ | 1591 | */ |
1592 | bool QPEApplication::raiseAppropriateWindow() | 1592 | bool QPEApplication::raiseAppropriateWindow() |
1593 | { | 1593 | { |
1594 | bool r=FALSE; | 1594 | bool r=FALSE; |
1595 | 1595 | ||
1596 | // 1. Raise the main widget | 1596 | // 1. Raise the main widget |
1597 | QWidget *top = d->qpe_main_widget; | 1597 | QWidget *top = d->qpe_main_widget; |
1598 | if ( !top ) top = mainWidget(); | 1598 | if ( !top ) top = mainWidget(); |
1599 | 1599 | ||
1600 | if ( top && d->keep_running ) { | 1600 | if ( top && d->keep_running ) { |
1601 | if ( top->isVisible() ) | 1601 | if ( top->isVisible() ) |
1602 | r = TRUE; | 1602 | r = TRUE; |
1603 | else if (d->preloaded) { | 1603 | else if (d->preloaded) { |
1604 | // We are preloaded and not visible.. pretend we just started.. | 1604 | // We are preloaded and not visible.. pretend we just started.. |
1605 | #ifndef QT_NO_COP | 1605 | #ifndef QT_NO_COP |
1606 | QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); | 1606 | QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); |
1607 | e << d->appName; | 1607 | e << d->appName; |
1608 | #endif | 1608 | #endif |
1609 | } | 1609 | } |
1610 | 1610 | ||
1611 | d->show_mx(top,d->nomaximize, d->appName); | 1611 | d->show_mx(top,d->nomaximize, d->appName); |
1612 | top->raise(); | 1612 | top->raise(); |
1613 | } | 1613 | } |
1614 | 1614 | ||
1615 | QWidget *topm = activeModalWidget(); | 1615 | QWidget *topm = activeModalWidget(); |
1616 | 1616 | ||
1617 | // 2. Raise any parentless widgets (except top and topm, as they | 1617 | // 2. Raise any parentless widgets (except top and topm, as they |
1618 | // are raised before and after this loop). Order from most | 1618 | // are raised before and after this loop). Order from most |
1619 | // recently raised as deepest to least recently as top, so | 1619 | // recently raised as deepest to least recently as top, so |
1620 | // that repeated calls cycle through widgets. | 1620 | // that repeated calls cycle through widgets. |
1621 | QWidgetList *list = topLevelWidgets(); | 1621 | QWidgetList *list = topLevelWidgets(); |
1622 | if ( list ) { | 1622 | if ( list ) { |
1623 | bool foundlast = FALSE; | 1623 | bool foundlast = FALSE; |
1624 | QWidget* topsub = 0; | 1624 | QWidget* topsub = 0; |
1625 | if ( d->lastraised ) { | 1625 | if ( d->lastraised ) { |
1626 | for (QWidget* w = list->first(); w; w = list->next()) { | 1626 | for (QWidget* w = list->first(); w; w = list->next()) { |
1627 | if ( !w->parentWidget() && w != topm && w->isVisible() && !w->isDesktop() ) { | 1627 | if ( !w->parentWidget() && w != topm && w->isVisible() && !w->isDesktop() ) { |
1628 | if ( w == d->lastraised ) | 1628 | if ( w == d->lastraised ) |
1629 | foundlast = TRUE; | 1629 | foundlast = TRUE; |
1630 | if ( foundlast ) { | 1630 | if ( foundlast ) { |
1631 | w->raise(); | 1631 | w->raise(); |
1632 | topsub = w; | 1632 | topsub = w; |
1633 | } | 1633 | } |
1634 | } | 1634 | } |
1635 | } | 1635 | } |
1636 | } | 1636 | } |
1637 | for (QWidget* w = list->first(); w; w = list->next()) { | 1637 | for (QWidget* w = list->first(); w; w = list->next()) { |
1638 | if ( !w->parentWidget() && w != topm && w->isVisible() && !w->isDesktop() ) { | 1638 | if ( !w->parentWidget() && w != topm && w->isVisible() && !w->isDesktop() ) { |
1639 | if ( w == d->lastraised ) | 1639 | if ( w == d->lastraised ) |
1640 | break; | 1640 | break; |
1641 | w->raise(); | 1641 | w->raise(); |
1642 | topsub = w; | 1642 | topsub = w; |
1643 | } | 1643 | } |
1644 | } | 1644 | } |
1645 | d->lastraised = topsub; | 1645 | d->lastraised = topsub; |
1646 | delete list; | 1646 | delete list; |
1647 | } | 1647 | } |
1648 | 1648 | ||
1649 | // 3. Raise the active modal widget. | 1649 | // 3. Raise the active modal widget. |
1650 | if ( topm ) { | 1650 | if ( topm ) { |
1651 | topm->show(); | 1651 | topm->show(); |
1652 | topm->raise(); | 1652 | topm->raise(); |
1653 | // If we haven't already handled the fastAppShowing message | 1653 | // If we haven't already handled the fastAppShowing message |
1654 | if (!top && d->preloaded) { | 1654 | if (!top && d->preloaded) { |
1655 | #ifndef QT_NO_COP | 1655 | #ifndef QT_NO_COP |
1656 | QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); | 1656 | QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); |
1657 | e << d->appName; | 1657 | e << d->appName; |
1658 | #endif | 1658 | #endif |
1659 | } | 1659 | } |
1660 | r = FALSE; | 1660 | r = FALSE; |
1661 | } | 1661 | } |
1662 | 1662 | ||
1663 | return r; | 1663 | return r; |
1664 | } | 1664 | } |
1665 | 1665 | ||
1666 | 1666 | ||
1667 | void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data) | 1667 | void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data) |
1668 | { | 1668 | { |
1669 | #ifdef Q_WS_QWS | 1669 | #ifdef Q_WS_QWS |
1670 | 1670 | ||
1671 | if ( msg == "quit()" ) { | 1671 | if ( msg == "quit()" ) { |
1672 | tryQuit(); | 1672 | tryQuit(); |
1673 | } | 1673 | } |
1674 | else if ( msg == "quitIfInvisible()" ) { | 1674 | else if ( msg == "quitIfInvisible()" ) { |
1675 | if ( d->qpe_main_widget && !d->qpe_main_widget->isVisible() ) | 1675 | if ( d->qpe_main_widget && !d->qpe_main_widget->isVisible() ) |
1676 | quit(); | 1676 | quit(); |
1677 | } | 1677 | } |
1678 | else if ( msg == "close()" ) { | 1678 | else if ( msg == "close()" ) { |
1679 | hideOrQuit(); | 1679 | hideOrQuit(); |
1680 | } | 1680 | } |
1681 | else if ( msg == "disablePreload()" ) { | 1681 | else if ( msg == "disablePreload()" ) { |
1682 | d->preloaded = FALSE; | 1682 | d->preloaded = FALSE; |
1683 | d->keep_running = TRUE; | 1683 | d->keep_running = TRUE; |
1684 | /* so that quit will quit */ | 1684 | /* so that quit will quit */ |
1685 | } | 1685 | } |
1686 | else if ( msg == "enablePreload()" ) { | 1686 | else if ( msg == "enablePreload()" ) { |
1687 | if (d->qpe_main_widget) | 1687 | if (d->qpe_main_widget) |
1688 | d->preloaded = TRUE; | 1688 | d->preloaded = TRUE; |
1689 | d->keep_running = TRUE; | 1689 | d->keep_running = TRUE; |
1690 | /* so next quit won't quit */ | 1690 | /* so next quit won't quit */ |
1691 | } | 1691 | } |
1692 | else if ( msg == "raise()" ) { | 1692 | else if ( msg == "raise()" ) { |
1693 | d->keep_running = TRUE; | 1693 | d->keep_running = TRUE; |
1694 | d->notbusysent = FALSE; | 1694 | d->notbusysent = FALSE; |
1695 | raiseAppropriateWindow(); | 1695 | raiseAppropriateWindow(); |
1696 | // Tell the system we're still chugging along... | 1696 | // Tell the system we're still chugging along... |
1697 | QCopEnvelope e("QPE/System", "appRaised(QString)"); | 1697 | QCopEnvelope e("QPE/System", "appRaised(QString)"); |
1698 | e << d->appName; | 1698 | e << d->appName; |
1699 | } | 1699 | } |
1700 | else if ( msg == "flush()" ) { | 1700 | else if ( msg == "flush()" ) { |
1701 | emit flush(); | 1701 | emit flush(); |
1702 | // we need to tell the desktop | 1702 | // we need to tell the desktop |
1703 | QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" ); | 1703 | QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" ); |
1704 | e << d->appName; | 1704 | e << d->appName; |
1705 | } | 1705 | } |
1706 | else if ( msg == "reload()" ) { | 1706 | else if ( msg == "reload()" ) { |
1707 | emit reload(); | 1707 | emit reload(); |
1708 | } | 1708 | } |
1709 | else if ( msg == "setDocument(QString)" ) { | 1709 | else if ( msg == "setDocument(QString)" ) { |
1710 | d->keep_running = TRUE; | 1710 | d->keep_running = TRUE; |
1711 | QDataStream stream( data, IO_ReadOnly ); | 1711 | QDataStream stream( data, IO_ReadOnly ); |
1712 | QString doc; | 1712 | QString doc; |
1713 | stream >> doc; | 1713 | stream >> doc; |
1714 | QWidget *mw = mainWidget(); | 1714 | QWidget *mw = mainWidget(); |
1715 | if ( !mw ) | 1715 | if ( !mw ) |
1716 | mw = d->qpe_main_widget; | 1716 | mw = d->qpe_main_widget; |
1717 | if ( mw ) | 1717 | if ( mw ) |
1718 | Global::setDocument( mw, doc ); | 1718 | Global::setDocument( mw, doc ); |
1719 | 1719 | ||
1720 | } else if ( msg == "QPEProcessQCop()" ) { | 1720 | } else if ( msg == "QPEProcessQCop()" ) { |
1721 | processQCopFile(); | 1721 | processQCopFile(); |
1722 | d->sendQCopQ(); | 1722 | d->sendQCopQ(); |
1723 | }else | 1723 | }else |
1724 | { | 1724 | { |
1725 | bool p = d->keep_running; | 1725 | bool p = d->keep_running; |
1726 | d->keep_running = FALSE; | 1726 | d->keep_running = FALSE; |
1727 | emit appMessage( msg, data); | 1727 | emit appMessage( msg, data); |
1728 | if ( d->keep_running ) { | 1728 | if ( d->keep_running ) { |
1729 | d->notbusysent = FALSE; | 1729 | d->notbusysent = FALSE; |
1730 | raiseAppropriateWindow(); | 1730 | raiseAppropriateWindow(); |
1731 | if ( !p ) { | 1731 | if ( !p ) { |
1732 | // Tell the system we're still chugging along... | 1732 | // Tell the system we're still chugging along... |
1733 | #ifndef QT_NO_COP | 1733 | #ifndef QT_NO_COP |
1734 | QCopEnvelope e("QPE/System", "appRaised(QString)"); | 1734 | QCopEnvelope e("QPE/System", "appRaised(QString)"); |
1735 | e << d->appName; | 1735 | e << d->appName; |
1736 | #endif | 1736 | #endif |
1737 | } | 1737 | } |
1738 | } | 1738 | } |
1739 | if ( p ) | 1739 | if ( p ) |
1740 | d->keep_running = p; | 1740 | d->keep_running = p; |
1741 | } | 1741 | } |
1742 | #endif | 1742 | #endif |
1743 | } | 1743 | } |
1744 | 1744 | ||
1745 | 1745 | ||
1746 | /*! | 1746 | /*! |
1747 | Sets widget \a mw as the mainWidget() and shows it. For small windows, | 1747 | Sets widget \a mw as the mainWidget() and shows it. For small windows, |
1748 | consider passing TRUE for \a nomaximize rather than the default FALSE. | 1748 | consider passing TRUE for \a nomaximize rather than the default FALSE. |
1749 | 1749 | ||
1750 | \sa showMainDocumentWidget() | 1750 | \sa showMainDocumentWidget() |
1751 | */ | 1751 | */ |
1752 | void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize ) | 1752 | void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize ) |
1753 | { | 1753 | { |
1754 | // setMainWidget(mw); this breaks FastLoading because lastWindowClose() would quit | 1754 | // setMainWidget(mw); this breaks FastLoading because lastWindowClose() would quit |
1755 | d->show(mw, nomaximize ); | 1755 | d->show(mw, nomaximize ); |
1756 | } | 1756 | } |
1757 | 1757 | ||
1758 | /*! | 1758 | /*! |
1759 | Sets widget \a mw as the mainWidget() and shows it. For small windows, | 1759 | Sets widget \a mw as the mainWidget() and shows it. For small windows, |
1760 | consider passing TRUE for \a nomaximize rather than the default FALSE. | 1760 | consider passing TRUE for \a nomaximize rather than the default FALSE. |
1761 | 1761 | ||
1762 | This calls designates the application as | 1762 | This calls designates the application as |
1763 | a \link docwidget.html document-oriented\endlink application. | 1763 | a \link docwidget.html document-oriented\endlink application. |
1764 | 1764 | ||
1765 | The \a mw widget \e must have this slot: setDocument(const QString&). | 1765 | The \a mw widget \e must have this slot: setDocument(const QString&). |
1766 | 1766 | ||
1767 | \sa showMainWidget() | 1767 | \sa showMainWidget() |
1768 | */ | 1768 | */ |
1769 | void QPEApplication::showMainDocumentWidget( QWidget* mw, bool nomaximize ) | 1769 | void QPEApplication::showMainDocumentWidget( QWidget* mw, bool nomaximize ) |
1770 | { | 1770 | { |
1771 | if ( mw && argc() == 2 ) | 1771 | if ( mw && argc() == 2 ) |
1772 | Global::setDocument( mw, QString::fromUtf8(argv()[1]) ); | 1772 | Global::setDocument( mw, QString::fromUtf8(argv()[1]) ); |
1773 | 1773 | ||
1774 | 1774 | ||
1775 | // setMainWidget(mw); see above | 1775 | // setMainWidget(mw); see above |
1776 | d->show(mw, nomaximize ); | 1776 | d->show(mw, nomaximize ); |
1777 | } | 1777 | } |
1778 | 1778 | ||
1779 | 1779 | ||
1780 | /*! | 1780 | /*! |
1781 | If an application is started via a \link qcop.html QCop\endlink | 1781 | If an application is started via a \link qcop.html QCop\endlink |
1782 | message, the application will process the \link qcop.html | 1782 | message, the application will process the \link qcop.html |
1783 | QCop\endlink message and then quit. If the application calls this | 1783 | QCop\endlink message and then quit. If the application calls this |
1784 | function while processing a \link qcop.html QCop\endlink message, | 1784 | function while processing a \link qcop.html QCop\endlink message, |
1785 | after processing its outstanding \link qcop.html QCop\endlink | 1785 | after processing its outstanding \link qcop.html QCop\endlink |
1786 | messages the application will start 'properly' and show itself. | 1786 | messages the application will start 'properly' and show itself. |
1787 | 1787 | ||
1788 | \sa keepRunning() | 1788 | \sa keepRunning() |
1789 | */ | 1789 | */ |
1790 | void QPEApplication::setKeepRunning() | 1790 | void QPEApplication::setKeepRunning() |
1791 | { | 1791 | { |
1792 | if ( qApp && qApp->inherits( "QPEApplication" ) ) { | 1792 | if ( qApp && qApp->inherits( "QPEApplication" ) ) { |
1793 | QPEApplication * qpeApp = ( QPEApplication* ) qApp; | 1793 | QPEApplication * qpeApp = ( QPEApplication* ) qApp; |
1794 | qpeApp->d->keep_running = TRUE; | 1794 | qpeApp->d->keep_running = TRUE; |
1795 | } | 1795 | } |
1796 | } | 1796 | } |
1797 | 1797 | ||
1798 | /*! | 1798 | /*! |
1799 | Returns TRUE if the application will quit after processing the | 1799 | Returns TRUE if the application will quit after processing the |
1800 | current list of qcop messages; otherwise returns FALSE. | 1800 | current list of qcop messages; otherwise returns FALSE. |
1801 | 1801 | ||
1802 | \sa setKeepRunning() | 1802 | \sa setKeepRunning() |
1803 | */ | 1803 | */ |
1804 | bool QPEApplication::keepRunning() const | 1804 | bool QPEApplication::keepRunning() const |
1805 | { | 1805 | { |
1806 | return d->keep_running; | 1806 | return d->keep_running; |
1807 | } | 1807 | } |
1808 | 1808 | ||
1809 | /*! | 1809 | /*! |
1810 | \internal | 1810 | \internal |
1811 | */ | 1811 | */ |
1812 | void QPEApplication::internalSetStyle( const QString &style ) | 1812 | void QPEApplication::internalSetStyle( const QString &style ) |
1813 | { | 1813 | { |
1814 | #if QT_VERSION >= 0x030000 | 1814 | #if QT_VERSION >= 0x030000 |
1815 | if ( style == "QPE" ) { | 1815 | if ( style == "QPE" ) { |
1816 | setStyle( new QPEStyle ); | 1816 | setStyle( new QPEStyle ); |
1817 | } | 1817 | } |
1818 | else { | 1818 | else { |
1819 | QStyle *s = QStyleFactory::create( style ); | 1819 | QStyle *s = QStyleFactory::create( style ); |
1820 | if ( s ) | 1820 | if ( s ) |
1821 | setStyle( s ); | 1821 | setStyle( s ); |
1822 | } | 1822 | } |
1823 | #else | 1823 | #else |
1824 | if ( style == "Windows" ) { | 1824 | if ( style == "Windows" ) { |
1825 | setStyle( new QWindowsStyle ); | 1825 | setStyle( new QWindowsStyle ); |
1826 | } | 1826 | } |
1827 | else if ( style == "QPE" ) { | 1827 | else if ( style == "QPE" ) { |
1828 | setStyle( new QPEStyle ); | 1828 | setStyle( new QPEStyle ); |
1829 | } | 1829 | } |
1830 | else if ( style == "Light" ) { | 1830 | else if ( style == "Light" ) { |
1831 | setStyle( new LightStyle ); | 1831 | setStyle( new LightStyle ); |
1832 | } | 1832 | } |
1833 | #ifndef QT_NO_STYLE_PLATINUM | 1833 | #ifndef QT_NO_STYLE_PLATINUM |
1834 | else if ( style == "Platinum" ) { | 1834 | else if ( style == "Platinum" ) { |
1835 | setStyle( new QPlatinumStyle ); | 1835 | setStyle( new QPlatinumStyle ); |
1836 | } | 1836 | } |
1837 | #endif | 1837 | #endif |
1838 | #ifndef QT_NO_STYLE_MOTIF | 1838 | #ifndef QT_NO_STYLE_MOTIF |
1839 | else if ( style == "Motif" ) { | 1839 | else if ( style == "Motif" ) { |
1840 | setStyle( new QMotifStyle ); | 1840 | setStyle( new QMotifStyle ); |
1841 | } | 1841 | } |
1842 | #endif | 1842 | #endif |
1843 | #ifndef QT_NO_STYLE_MOTIFPLUS | 1843 | #ifndef QT_NO_STYLE_MOTIFPLUS |
1844 | else if ( style == "MotifPlus" ) { | 1844 | else if ( style == "MotifPlus" ) { |
1845 | setStyle( new QMotifPlusStyle ); | 1845 | setStyle( new QMotifPlusStyle ); |
1846 | } | 1846 | } |
1847 | #endif | 1847 | #endif |
1848 | 1848 | ||
1849 | else { | 1849 | else { |
1850 | QStyle *sty = 0; | 1850 | QStyle *sty = 0; |
1851 | QString path = QPEApplication::qpeDir ( ) + "plugins/styles/"; | 1851 | QString path = QPEApplication::qpeDir ( ) + "plugins/styles/"; |
1852 | 1852 | ||
1853 | #ifdef Q_OS_MACX | 1853 | #ifdef Q_OS_MACX |
1854 | if ( style. find ( ".dylib" ) > 0 ) | 1854 | if ( style. find ( ".dylib" ) > 0 ) |
1855 | path += style; | 1855 | path += style; |
1856 | else | 1856 | else |
1857 | path = path + "lib" + style. lower ( ) + ".dylib"; // compatibility | 1857 | path = path + "lib" + style. lower ( ) + ".dylib"; // compatibility |
1858 | #else | 1858 | #else |
1859 | if ( style. find ( ".so" ) > 0 ) | 1859 | if ( style. find ( ".so" ) > 0 ) |
1860 | path += style; | 1860 | path += style; |
1861 | else | 1861 | else |
1862 | path = path + "lib" + style. lower ( ) + ".so"; // compatibility | 1862 | path = path + "lib" + style. lower ( ) + ".so"; // compatibility |
1863 | #endif | 1863 | #endif |
1864 | static QLibrary *lastlib = 0; | 1864 | static QLibrary *lastlib = 0; |
1865 | static StyleInterface *lastiface = 0; | 1865 | static StyleInterface *lastiface = 0; |
1866 | 1866 | ||
1867 | QLibrary *lib = new QLibrary ( path ); | 1867 | QLibrary *lib = new QLibrary ( path ); |
1868 | StyleInterface *iface = 0; | 1868 | StyleInterface *iface = 0; |
1869 | 1869 | ||
1870 | if (( lib-> queryInterface ( IID_Style, ( QUnknownInterface ** ) &iface ) == QS_OK ) && iface ) | 1870 | if (( lib-> queryInterface ( IID_Style, ( QUnknownInterface ** ) &iface ) == QS_OK ) && iface ) |
1871 | sty = iface-> style ( ); | 1871 | sty = iface-> style ( ); |
1872 | 1872 | ||
1873 | if ( sty ) { | 1873 | if ( sty ) { |
1874 | setStyle ( sty ); | 1874 | setStyle ( sty ); |
1875 | 1875 | ||
1876 | if ( lastiface ) | 1876 | if ( lastiface ) |
1877 | lastiface-> release ( ); | 1877 | lastiface-> release ( ); |
1878 | lastiface = iface; | 1878 | lastiface = iface; |
1879 | 1879 | ||
1880 | if ( lastlib ) { | 1880 | if ( lastlib ) { |
1881 | lastlib-> unload ( ); | 1881 | lastlib-> unload ( ); |
1882 | delete lastlib; | 1882 | delete lastlib; |
1883 | } | 1883 | } |
1884 | lastlib = lib; | 1884 | lastlib = lib; |
1885 | } | 1885 | } |
1886 | else { | 1886 | else { |
1887 | if ( iface ) | 1887 | if ( iface ) |
1888 | iface-> release ( ); | 1888 | iface-> release ( ); |
1889 | delete lib; | 1889 | delete lib; |
1890 | 1890 | ||
1891 | setStyle ( new LightStyle ( )); | 1891 | setStyle ( new LightStyle ( )); |
1892 | } | 1892 | } |
1893 | } | 1893 | } |
1894 | #endif | 1894 | #endif |
1895 | } | 1895 | } |
1896 | 1896 | ||
1897 | /*! | 1897 | /*! |
1898 | \internal | 1898 | \internal |
1899 | */ | 1899 | */ |
1900 | void QPEApplication::prepareForTermination( bool willrestart ) | 1900 | void QPEApplication::prepareForTermination( bool willrestart ) |
1901 | { | 1901 | { |
1902 | if ( willrestart ) { | 1902 | if ( willrestart ) { |
1903 | QLabel *lblWait = new QLabel( tr( "Please wait..." ), 0, "wait hack", QWidget::WStyle_Customize | | 1903 | QLabel *lblWait = new QLabel( tr( "Please wait..." ), 0, "wait hack", QWidget::WStyle_Customize | |
1904 | QWidget::WStyle_NoBorder | QWidget::WStyle_Tool ); | 1904 | QWidget::WStyle_NoBorder | QWidget::WStyle_Tool ); |
1905 | lblWait->setAlignment( QWidget::AlignCenter ); | 1905 | lblWait->setAlignment( QWidget::AlignCenter ); |
1906 | lblWait->show(); | 1906 | lblWait->show(); |
1907 | lblWait->showMaximized(); | 1907 | lblWait->showMaximized(); |
1908 | } | 1908 | } |
1909 | { QCopEnvelope envelope( "QPE/System", "forceQuit()" ); | 1909 | { QCopEnvelope envelope( "QPE/System", "forceQuit()" ); |
1910 | } | 1910 | } |
1911 | processEvents(); // ensure the message goes out. | 1911 | processEvents(); // ensure the message goes out. |
1912 | } | 1912 | } |
1913 | 1913 | ||
1914 | /*! | 1914 | /*! |
1915 | \internal | 1915 | \internal |
1916 | */ | 1916 | */ |
1917 | void QPEApplication::shutdown() | 1917 | void QPEApplication::shutdown() |
1918 | { | 1918 | { |
1919 | // Implement in server's QPEApplication subclass | 1919 | // Implement in server's QPEApplication subclass |
1920 | } | 1920 | } |
1921 | 1921 | ||
1922 | /*! | 1922 | /*! |
1923 | \internal | 1923 | \internal |
1924 | */ | 1924 | */ |
1925 | void QPEApplication::restart() | 1925 | void QPEApplication::restart() |
1926 | { | 1926 | { |
1927 | // Implement in server's QPEApplication subclass | 1927 | // Implement in server's QPEApplication subclass |
1928 | } | 1928 | } |
1929 | 1929 | ||
1930 | static QPtrDict<void>* stylusDict = 0; | 1930 | static QPtrDict<void>* stylusDict = 0; |
1931 | static void createDict() | 1931 | static void createDict() |
1932 | { | 1932 | { |
1933 | if ( !stylusDict ) | 1933 | if ( !stylusDict ) |
1934 | stylusDict = new QPtrDict<void>; | 1934 | stylusDict = new QPtrDict<void>; |
1935 | } | 1935 | } |
1936 | 1936 | ||
1937 | /*! | 1937 | /*! |
1938 | Returns the current StylusMode for widget \a w. | 1938 | Returns the current StylusMode for widget \a w. |
1939 | 1939 | ||
1940 | \sa setStylusOperation() StylusMode | 1940 | \sa setStylusOperation() StylusMode |
1941 | */ | 1941 | */ |
1942 | QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w ) | 1942 | QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w ) |
1943 | { | 1943 | { |
1944 | if ( stylusDict ) | 1944 | if ( stylusDict ) |
1945 | return ( StylusMode ) ( int ) stylusDict->find( w ); | 1945 | return ( StylusMode ) ( int ) stylusDict->find( w ); |
1946 | return LeftOnly; | 1946 | return LeftOnly; |
1947 | } | 1947 | } |
1948 | 1948 | ||
1949 | /*! | 1949 | /*! |
1950 | \enum QPEApplication::StylusMode | 1950 | \enum QPEApplication::StylusMode |
1951 | 1951 | ||
1952 | \value LeftOnly the stylus only generates LeftButton | 1952 | \value LeftOnly the stylus only generates LeftButton |
1953 | events (the default). | 1953 | events (the default). |
1954 | \value RightOnHold the stylus generates RightButton events | 1954 | \value RightOnHold the stylus generates RightButton events |
1955 | if the user uses the press-and-hold gesture. | 1955 | if the user uses the press-and-hold gesture. |
1956 | 1956 | ||
1957 | \sa setStylusOperation() stylusOperation() | 1957 | \sa setStylusOperation() stylusOperation() |
1958 | */ | 1958 | */ |
1959 | 1959 | ||
1960 | /*! | 1960 | /*! |
1961 | Causes widget \a w to receive mouse events according to the stylus | 1961 | Causes widget \a w to receive mouse events according to the stylus |
1962 | \a mode. | 1962 | \a mode. |
1963 | 1963 | ||
1964 | \sa stylusOperation() StylusMode | 1964 | \sa stylusOperation() StylusMode |
1965 | */ | 1965 | */ |
1966 | void QPEApplication::setStylusOperation( QWidget * w, StylusMode mode ) | 1966 | void QPEApplication::setStylusOperation( QWidget * w, StylusMode mode ) |
1967 | { | 1967 | { |
1968 | createDict(); | 1968 | createDict(); |
1969 | if ( mode == LeftOnly ) { | 1969 | if ( mode == LeftOnly ) { |
1970 | stylusDict->remove | 1970 | stylusDict->remove |
1971 | ( w ); | 1971 | ( w ); |
1972 | w->removeEventFilter( qApp ); | 1972 | w->removeEventFilter( qApp ); |
1973 | } | 1973 | } |
1974 | else { | 1974 | else { |
1975 | stylusDict->insert( w, ( void* ) mode ); | 1975 | stylusDict->insert( w, ( void* ) mode ); |
1976 | connect( w, SIGNAL( destroyed() ), qApp, SLOT( removeSenderFromStylusDict() ) ); | 1976 | connect( w, SIGNAL( destroyed() ), qApp, SLOT( removeSenderFromStylusDict() ) ); |
1977 | w->installEventFilter( qApp ); | 1977 | w->installEventFilter( qApp ); |
1978 | } | 1978 | } |
1979 | } | 1979 | } |
1980 | 1980 | ||
1981 | 1981 | ||
1982 | /*! | 1982 | /*! |
1983 | \reimp | 1983 | \reimp |
1984 | */ | 1984 | */ |
1985 | bool QPEApplication::eventFilter( QObject *o, QEvent *e ) | 1985 | bool QPEApplication::eventFilter( QObject *o, QEvent *e ) |
1986 | { | 1986 | { |
1987 | if ( !o->isWidgetType() ) | 1987 | if ( !o->isWidgetType() ) |
1988 | return FALSE; | 1988 | return FALSE; |
1989 | 1989 | ||
1990 | if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) { | 1990 | if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) { |
1991 | QMouseEvent * me = ( QMouseEvent* ) e; | 1991 | QMouseEvent * me = ( QMouseEvent* ) e; |
1992 | StylusMode mode = (StylusMode)(int)stylusDict->find(o); | 1992 | StylusMode mode = (StylusMode)(int)stylusDict->find(o); |
1993 | switch (mode) { | 1993 | switch (mode) { |
1994 | case RightOnHold: | 1994 | case RightOnHold: |
1995 | switch ( me->type() ) { | 1995 | switch ( me->type() ) { |
1996 | case QEvent::MouseButtonPress: | 1996 | case QEvent::MouseButtonPress: |
1997 | if ( me->button() == LeftButton ) { | 1997 | if ( me->button() == LeftButton ) { |
1998 | static long Pref = 500; // #### pref. | 1998 | static long Pref = 500; // #### pref. |
1999 | d->presswidget = (QWidget*)o; | 1999 | d->presswidget = (QWidget*)o; |
2000 | d->presspos = me->pos(); | 2000 | d->presspos = me->pos(); |
2001 | d->rightpressed = FALSE; | 2001 | d->rightpressed = FALSE; |
2002 | #ifdef OPIE_WITHROHFEEDBACK | 2002 | #ifdef OPIE_WITHROHFEEDBACK |
2003 | if( ! d->RoH ) | 2003 | if( ! d->RoH ) |
2004 | d->RoH = new Opie::Internal::RoHFeedback; | 2004 | d->RoH = new Opie::Internal::RoHFeedback; |
2005 | 2005 | ||
2006 | d->RoH->init( me->globalPos(), d->presswidget ); | 2006 | d->RoH->init( me->globalPos(), d->presswidget ); |
2007 | Pref = d->RoH->delay(); | 2007 | Pref = d->RoH->delay(); |
2008 | 2008 | ||
2009 | #endif | 2009 | #endif |
2010 | if (!d->presstimer ) | 2010 | if (!d->presstimer ) |
2011 | d->presstimer = startTimer( Pref ); // #### pref. | 2011 | d->presstimer = startTimer( Pref ); // #### pref. |
2012 | 2012 | ||
2013 | } | 2013 | } |
2014 | break; | 2014 | break; |
2015 | case QEvent::MouseMove: | 2015 | case QEvent::MouseMove: |
2016 | if (d->presstimer && (me->pos() - d->presspos).manhattanLength() > 8) { | 2016 | if (d->presstimer && (me->pos() - d->presspos).manhattanLength() > 8) { |
2017 | killTimer(d->presstimer); | 2017 | killTimer(d->presstimer); |
2018 | #ifdef OPIE_WITHROHFEEDBACK | 2018 | #ifdef OPIE_WITHROHFEEDBACK |
2019 | d->RoH->stop(); | 2019 | d->RoH->stop(); |
2020 | #endif | 2020 | #endif |
2021 | d->presstimer = 0; | 2021 | d->presstimer = 0; |
2022 | } | 2022 | } |
2023 | break; | 2023 | break; |
2024 | case QEvent::MouseButtonRelease: | 2024 | case QEvent::MouseButtonRelease: |
2025 | if ( me->button() == LeftButton ) { | 2025 | if ( me->button() == LeftButton ) { |
2026 | if ( d->presstimer ) { | 2026 | if ( d->presstimer ) { |
2027 | killTimer(d->presstimer); | 2027 | killTimer(d->presstimer); |
2028 | #ifdef OPIE_WITHROHFEEDBACK | 2028 | #ifdef OPIE_WITHROHFEEDBACK |
2029 | d->RoH->stop( ); | 2029 | d->RoH->stop( ); |
2030 | #endif | 2030 | #endif |
2031 | d->presstimer = 0; | 2031 | d->presstimer = 0; |
2032 | } | 2032 | } |
2033 | if ( d->rightpressed && d->presswidget ) { | 2033 | if ( d->rightpressed && d->presswidget ) { |
2034 | printf( "Send ButtonRelease\n" ); | 2034 | printf( "Send ButtonRelease\n" ); |
2035 | // Right released | 2035 | // Right released |
2036 | postEvent( d->presswidget, | 2036 | postEvent( d->presswidget, |
2037 | new QMouseEvent( QEvent::MouseButtonRelease, me->pos(), | 2037 | new QMouseEvent( QEvent::MouseButtonRelease, me->pos(), |
2038 | RightButton, LeftButton + RightButton ) ); | 2038 | RightButton, LeftButton + RightButton ) ); |
2039 | // Left released, off-widget | 2039 | // Left released, off-widget |
2040 | postEvent( d->presswidget, | 2040 | postEvent( d->presswidget, |
2041 | new QMouseEvent( QEvent::MouseMove, QPoint( -1, -1), | 2041 | new QMouseEvent( QEvent::MouseMove, QPoint( -1, -1), |
2042 | LeftButton, LeftButton ) ); | 2042 | LeftButton, LeftButton ) ); |
2043 | postEvent( d->presswidget, | 2043 | postEvent( d->presswidget, |
2044 | new QMouseEvent( QEvent::MouseButtonRelease, QPoint( -1, -1), | 2044 | new QMouseEvent( QEvent::MouseButtonRelease, QPoint( -1, -1), |
2045 | LeftButton, LeftButton ) ); | 2045 | LeftButton, LeftButton ) ); |
2046 | d->rightpressed = FALSE; | 2046 | d->rightpressed = FALSE; |
2047 | return TRUE; // don't send the real Left release | 2047 | return TRUE; // don't send the real Left release |
2048 | } | 2048 | } |
2049 | } | 2049 | } |
2050 | break; | 2050 | break; |
2051 | default: | 2051 | default: |
2052 | break; | 2052 | break; |
2053 | } | 2053 | } |
2054 | break; | 2054 | break; |
2055 | default: | 2055 | default: |
2056 | ; | 2056 | ; |
2057 | } | 2057 | } |
2058 | } | 2058 | } |
2059 | else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { | 2059 | else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { |
2060 | QKeyEvent *ke = (QKeyEvent *)e; | 2060 | QKeyEvent *ke = (QKeyEvent *)e; |
2061 | if ( ke->key() == Key_Enter ) { | 2061 | if ( ke->key() == Key_Enter ) { |
2062 | if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) { | 2062 | if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) { |
2063 | postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ', | 2063 | postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ', |
2064 | ke->state(), " ", ke->isAutoRepeat(), ke->count() ) ); | 2064 | ke->state(), " ", ke->isAutoRepeat(), ke->count() ) ); |
2065 | return TRUE; | 2065 | return TRUE; |
2066 | } | 2066 | } |
2067 | } | 2067 | } |
2068 | } | 2068 | } |
2069 | return FALSE; | 2069 | return FALSE; |
2070 | } | 2070 | } |
2071 | 2071 | ||
2072 | /*! | 2072 | /*! |
2073 | \reimp | 2073 | \reimp |
2074 | */ | 2074 | */ |
2075 | void QPEApplication::timerEvent( QTimerEvent *e ) | 2075 | void QPEApplication::timerEvent( QTimerEvent *e ) |
2076 | { | 2076 | { |
2077 | if ( e->timerId() == d->presstimer && d->presswidget ) { | 2077 | if ( e->timerId() == d->presstimer && d->presswidget ) { |
2078 | 2078 | ||
2079 | // Right pressed | 2079 | // Right pressed |
2080 | postEvent( d->presswidget, | 2080 | postEvent( d->presswidget, |
2081 | new QMouseEvent( QEvent::MouseButtonPress, d->presspos, | 2081 | new QMouseEvent( QEvent::MouseButtonPress, d->presspos, |
2082 | RightButton, LeftButton ) ); | 2082 | RightButton, LeftButton ) ); |
2083 | killTimer( d->presstimer ); | 2083 | killTimer( d->presstimer ); |
2084 | d->presstimer = 0; | 2084 | d->presstimer = 0; |
2085 | d->rightpressed = TRUE; | 2085 | d->rightpressed = TRUE; |
2086 | #ifdef OPIE_WITHROHFEEDBACK | 2086 | #ifdef OPIE_WITHROHFEEDBACK |
2087 | d->RoH->stop(); | 2087 | d->RoH->stop(); |
2088 | #endif | 2088 | #endif |
2089 | } | 2089 | } |
2090 | } | 2090 | } |
2091 | 2091 | ||
2092 | void QPEApplication::removeSenderFromStylusDict() | 2092 | void QPEApplication::removeSenderFromStylusDict() |
2093 | { | 2093 | { |
2094 | stylusDict->remove | 2094 | stylusDict->remove |
2095 | ( ( void* ) sender() ); | 2095 | ( ( void* ) sender() ); |
2096 | if ( d->presswidget == sender() ) | 2096 | if ( d->presswidget == sender() ) |
2097 | d->presswidget = 0; | 2097 | d->presswidget = 0; |
2098 | } | 2098 | } |
2099 | 2099 | ||
2100 | /*! | 2100 | /*! |
2101 | \internal | 2101 | \internal |
2102 | */ | 2102 | */ |
2103 | bool QPEApplication::keyboardGrabbed() const | 2103 | bool QPEApplication::keyboardGrabbed() const |
2104 | { | 2104 | { |
2105 | return d->kbgrabbed; | 2105 | return d->kbgrabbed; |
2106 | } | 2106 | } |
2107 | 2107 | ||
2108 | 2108 | ||
2109 | /*! | 2109 | /*! |
2110 | Reverses the effect of grabKeyboard(). This is called automatically | 2110 | Reverses the effect of grabKeyboard(). This is called automatically |
2111 | on program exit. | 2111 | on program exit. |
2112 | */ | 2112 | */ |
2113 | void QPEApplication::ungrabKeyboard() | 2113 | void QPEApplication::ungrabKeyboard() |
2114 | { | 2114 | { |
2115 | ((QPEApplication *) qApp )-> d-> kbgrabbed = false; | 2115 | ((QPEApplication *) qApp )-> d-> kbgrabbed = false; |
2116 | } | 2116 | } |
2117 | 2117 | ||
2118 | /*! | 2118 | /*! |
2119 | Grabs the physical keyboard keys, e.g. the application's launching | 2119 | Grabs the physical keyboard keys, e.g. the application's launching |
2120 | keys. Instead of launching applications when these keys are pressed | 2120 | keys. Instead of launching applications when these keys are pressed |
2121 | the signals emitted are sent to this application instead. Some games | 2121 | the signals emitted are sent to this application instead. Some games |
2122 | programs take over the launch keys in this way to make interaction | 2122 | programs take over the launch keys in this way to make interaction |
2123 | easier. | 2123 | easier. |
2124 | 2124 | ||
2125 | \sa ungrabKeyboard() | 2125 | \sa ungrabKeyboard() |
2126 | */ | 2126 | */ |
2127 | void QPEApplication::grabKeyboard() | 2127 | void QPEApplication::grabKeyboard() |
2128 | { | 2128 | { |
2129 | ((QPEApplication *) qApp )-> d-> kbgrabbed = true; | 2129 | ((QPEApplication *) qApp )-> d-> kbgrabbed = true; |
2130 | } | 2130 | } |
2131 | 2131 | ||
2132 | /*! | 2132 | /*! |
2133 | \reimp | 2133 | \reimp |
2134 | */ | 2134 | */ |
2135 | int QPEApplication::exec() | 2135 | int QPEApplication::exec() |
2136 | { | 2136 | { |
2137 | d->qcopQok = true; | 2137 | d->qcopQok = true; |
2138 | #ifndef QT_NO_COP | 2138 | #ifndef QT_NO_COP |
2139 | d->sendQCopQ(); | 2139 | d->sendQCopQ(); |
2140 | if ( !d->keep_running ) | 2140 | if ( !d->keep_running ) |
2141 | processEvents(); // we may have received QCop messages in the meantime. | 2141 | processEvents(); // we may have received QCop messages in the meantime. |
2142 | #endif | 2142 | #endif |
2143 | 2143 | ||
2144 | if ( d->keep_running ) | 2144 | if ( d->keep_running ) |
2145 | //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() ) | 2145 | //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() ) |
2146 | return QApplication::exec(); | 2146 | return QApplication::exec(); |
2147 | 2147 | ||
2148 | #ifndef QT_NO_COP | 2148 | #ifndef QT_NO_COP |
2149 | 2149 | ||
2150 | { | 2150 | { |
2151 | QCopEnvelope e( "QPE/System", "closing(QString)" ); | 2151 | QCopEnvelope e( "QPE/System", "closing(QString)" ); |
2152 | e << d->appName; | 2152 | e << d->appName; |
2153 | } | 2153 | } |
2154 | #endif | 2154 | #endif |
2155 | processEvents(); | 2155 | processEvents(); |
2156 | return 0; | 2156 | return 0; |
2157 | } | 2157 | } |
2158 | 2158 | ||
2159 | /*! | 2159 | /*! |
2160 | \internal | 2160 | \internal |
2161 | External request for application to quit. Quits if possible without | 2161 | External request for application to quit. Quits if possible without |
2162 | loosing state. | 2162 | loosing state. |
2163 | */ | 2163 | */ |
2164 | void QPEApplication::tryQuit() | 2164 | void QPEApplication::tryQuit() |
2165 | { | 2165 | { |
2166 | if ( activeModalWidget() ) | 2166 | if ( activeModalWidget() ) |
2167 | return ; // Inside modal loop or konsole. Too hard to save state. | 2167 | return ; // Inside modal loop or konsole. Too hard to save state. |
2168 | #ifndef QT_NO_COP | 2168 | #ifndef QT_NO_COP |
2169 | 2169 | ||
2170 | { | 2170 | { |
2171 | QCopEnvelope e( "QPE/System", "closing(QString)" ); | 2171 | QCopEnvelope e( "QPE/System", "closing(QString)" ); |
2172 | e << d->appName; | 2172 | e << d->appName; |
2173 | } | 2173 | } |
2174 | #endif | 2174 | #endif |
2175 | if ( d->keep_running ) | 2175 | if ( d->keep_running ) |
2176 | d->store_widget_rect(d->qpe_main_widget, d->appName); | 2176 | d->store_widget_rect(d->qpe_main_widget, d->appName); |
2177 | processEvents(); | 2177 | processEvents(); |
2178 | 2178 | ||
2179 | quit(); | 2179 | quit(); |
2180 | } | 2180 | } |
2181 | 2181 | ||
2182 | 2182 | ||
2183 | /*! | 2183 | /*! |
2184 | \internal | 2184 | \internal |
2185 | User initiated quit. Makes the window 'Go Away'. If preloaded this means | 2185 | User initiated quit. Makes the window 'Go Away'. If preloaded this means |
2186 | hiding the window. If not it means quitting the application. | 2186 | hiding the window. If not it means quitting the application. |
2187 | As this is user initiated we don't need to check state. | 2187 | As this is user initiated we don't need to check state. |
2188 | */ | 2188 | */ |
2189 | void QPEApplication::hideOrQuit() | 2189 | void QPEApplication::hideOrQuit() |
2190 | { | 2190 | { |
2191 | if ( d->keep_running ) | 2191 | if ( d->keep_running ) |
2192 | d->store_widget_rect(d->qpe_main_widget, d->appName); | 2192 | d->store_widget_rect(d->qpe_main_widget, d->appName); |
2193 | processEvents(); | 2193 | processEvents(); |
2194 | 2194 | ||
2195 | // If we are a preloaded application we don't actually quit, so emit | 2195 | // If we are a preloaded application we don't actually quit, so emit |
2196 | // a System message indicating we're quasi-closing. | 2196 | // a System message indicating we're quasi-closing. |
2197 | if ( d->preloaded && d->qpe_main_widget ) | 2197 | if ( d->preloaded && d->qpe_main_widget ) |
2198 | #ifndef QT_NO_COP | 2198 | #ifndef QT_NO_COP |
2199 | 2199 | ||
2200 | { | 2200 | { |
2201 | QCopEnvelope e("QPE/System", "fastAppHiding(QString)" ); | 2201 | QCopEnvelope e("QPE/System", "fastAppHiding(QString)" ); |
2202 | e << d->appName; | 2202 | e << d->appName; |
2203 | d->qpe_main_widget->hide(); | 2203 | d->qpe_main_widget->hide(); |
2204 | } | 2204 | } |
2205 | #endif | 2205 | #endif |
2206 | else | 2206 | else |
2207 | quit(); | 2207 | quit(); |
2208 | } | 2208 | } |
2209 | 2209 | ||
2210 | #if (__GNUC__ > 2 ) | 2210 | #if (__GNUC__ > 2 ) && !defined(_OS_MACX_) |
2211 | extern "C" void __cxa_pure_virtual(); | 2211 | extern "C" void __cxa_pure_virtual(); |
2212 | 2212 | ||
2213 | void __cxa_pure_virtual() | 2213 | void __cxa_pure_virtual() |
2214 | { | 2214 | { |
2215 | fprintf( stderr, "Pure virtual called\n"); | 2215 | fprintf( stderr, "Pure virtual called\n"); |
2216 | abort(); | 2216 | abort(); |
2217 | 2217 | ||
2218 | } | 2218 | } |
2219 | 2219 | ||
2220 | #endif | 2220 | #endif |
2221 | 2221 | ||
2222 | 2222 | ||
2223 | #if defined(OPIE_NEW_MALLOC) | 2223 | #if defined(OPIE_NEW_MALLOC) |
2224 | 2224 | ||
2225 | // The libraries with the skiff package (and possibly others) have | 2225 | // The libraries with the skiff package (and possibly others) have |
2226 | // completely useless implementations of builtin new and delete that | 2226 | // completely useless implementations of builtin new and delete that |
2227 | // use about 50% of your CPU. Here we revert to the simple libc | 2227 | // use about 50% of your CPU. Here we revert to the simple libc |
2228 | // functions. | 2228 | // functions. |
2229 | 2229 | ||
2230 | void* operator new[]( size_t size ) | 2230 | void* operator new[]( size_t size ) |
2231 | { | 2231 | { |
2232 | return malloc( size ); | 2232 | return malloc( size ); |
2233 | } | 2233 | } |
2234 | 2234 | ||
2235 | void* operator new( size_t size ) | 2235 | void* operator new( size_t size ) |
2236 | { | 2236 | { |
2237 | return malloc( size ); | 2237 | return malloc( size ); |
2238 | } | 2238 | } |
2239 | 2239 | ||
2240 | void operator delete[]( void* p ) | 2240 | void operator delete[]( void* p ) |
2241 | { | 2241 | { |
2242 | if ( p ) | 2242 | if ( p ) |
2243 | free( p ); | 2243 | free( p ); |
2244 | } | 2244 | } |
2245 | 2245 | ||
2246 | void operator delete[]( void* p, size_t /*size*/ ) | 2246 | void operator delete[]( void* p, size_t /*size*/ ) |
2247 | { | 2247 | { |
2248 | if ( p ) | 2248 | if ( p ) |
2249 | free( p ); | 2249 | free( p ); |
2250 | } | 2250 | } |
2251 | 2251 | ||
2252 | 2252 | ||
2253 | void operator delete( void* p ) | 2253 | void operator delete( void* p ) |
2254 | { | 2254 | { |
2255 | if ( p ) | 2255 | if ( p ) |
2256 | free( p ); | 2256 | free( p ); |
2257 | } | 2257 | } |
2258 | 2258 | ||
2259 | void operator delete( void* p, size_t /*size*/ ) | 2259 | void operator delete( void* p, size_t /*size*/ ) |
2260 | { | 2260 | { |
2261 | if ( p ) | 2261 | if ( p ) |
2262 | free( p ); | 2262 | free( p ); |
2263 | } | 2263 | } |
2264 | 2264 | ||
2265 | #endif | 2265 | #endif |
2266 | 2266 | ||
2267 | #if ( QT_VERSION <= 230 ) && !defined(SINGLE_APP) | 2267 | #if ( QT_VERSION <= 230 ) && !defined(SINGLE_APP) |
2268 | #include <qwidgetlist.h> | 2268 | #include <qwidgetlist.h> |
2269 | #ifdef QWS | 2269 | #ifdef QWS |
2270 | #include <qgfx_qws.h> | 2270 | #include <qgfx_qws.h> |
2271 | extern QRect qt_maxWindowRect; | 2271 | extern QRect qt_maxWindowRect; |
2272 | void qt_setMaxWindowRect(const QRect& r ) | 2272 | void qt_setMaxWindowRect(const QRect& r ) |
2273 | { | 2273 | { |
2274 | qt_maxWindowRect = qt_screen->mapFromDevice( r, | 2274 | qt_maxWindowRect = qt_screen->mapFromDevice( r, |
2275 | qt_screen->mapToDevice( QSize( qt_screen->width(), qt_screen->height() ) ) ); | 2275 | qt_screen->mapToDevice( QSize( qt_screen->width(), qt_screen->height() ) ) ); |
2276 | // Re-resize any maximized windows | 2276 | // Re-resize any maximized windows |
2277 | QWidgetList* l = QApplication::topLevelWidgets(); | 2277 | QWidgetList* l = QApplication::topLevelWidgets(); |
2278 | if ( l ) { | 2278 | if ( l ) { |
2279 | QWidget * w = l->first(); | 2279 | QWidget * w = l->first(); |
2280 | while ( w ) { | 2280 | while ( w ) { |
2281 | if ( w->isVisible() && w->isMaximized() ) { | 2281 | if ( w->isVisible() && w->isMaximized() ) { |
2282 | w->showMaximized(); | 2282 | w->showMaximized(); |
2283 | } | 2283 | } |
2284 | w = l->next(); | 2284 | w = l->next(); |
2285 | } | 2285 | } |
2286 | delete l; | 2286 | delete l; |
2287 | } | 2287 | } |
2288 | } | 2288 | } |
2289 | #endif | 2289 | #endif |
2290 | #endif | 2290 | #endif |