summaryrefslogtreecommitdiff
path: root/library/qpeapplication.cpp
Unidiff
Diffstat (limited to 'library/qpeapplication.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--library/qpeapplication.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp
index 533d7bd..e92b4dd 100644
--- a/library/qpeapplication.cpp
+++ b/library/qpeapplication.cpp
@@ -966,521 +966,526 @@ void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data
966 Global::execute( t ); 966 Global::execute( t );
967 } 967 }
968 } else if ( msg == "execute(QString,QString)" ) { 968 } else if ( msg == "execute(QString,QString)" ) {
969 if ( type() == GuiServer ) { 969 if ( type() == GuiServer ) {
970 QString t, d; 970 QString t, d;
971 stream >> t >> d; 971 stream >> t >> d;
972 Global::execute( t, d ); 972 Global::execute( t, d );
973 } 973 }
974 } else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) { 974 } else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) {
975 if ( type() == GuiServer ) { 975 if ( type() == GuiServer ) {
976 QDateTime when; 976 QDateTime when;
977 QCString channel, message; 977 QCString channel, message;
978 int data; 978 int data;
979 stream >> when >> channel >> message >> data; 979 stream >> when >> channel >> message >> data;
980 AlarmServer::addAlarm( when, channel, message, data ); 980 AlarmServer::addAlarm( when, channel, message, data );
981 } 981 }
982 } else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) { 982 } else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) {
983 if ( type() == GuiServer ) { 983 if ( type() == GuiServer ) {
984 QDateTime when; 984 QDateTime when;
985 QCString channel, message; 985 QCString channel, message;
986 int data; 986 int data;
987 stream >> when >> channel >> message >> data; 987 stream >> when >> channel >> message >> data;
988 AlarmServer::deleteAlarm( when, channel, message, data ); 988 AlarmServer::deleteAlarm( when, channel, message, data );
989 } 989 }
990 } else if ( msg == "clockChange(bool)" ) { 990 } else if ( msg == "clockChange(bool)" ) {
991 int tmp; 991 int tmp;
992 stream >> tmp; 992 stream >> tmp;
993 emit clockChanged( tmp ); 993 emit clockChanged( tmp );
994 } else if ( msg == "weekChange(bool)" ) { 994 } else if ( msg == "weekChange(bool)" ) {
995 int tmp; 995 int tmp;
996 stream >> tmp; 996 stream >> tmp;
997 emit weekChanged( tmp ); 997 emit weekChanged( tmp );
998 } else if ( msg == "setDateFormat(DateFormat)" ) { 998 } else if ( msg == "setDateFormat(DateFormat)" ) {
999 DateFormat tmp; 999 DateFormat tmp;
1000 stream >> tmp; 1000 stream >> tmp;
1001 emit dateFormatChanged( tmp ); 1001 emit dateFormatChanged( tmp );
1002 } else if ( msg == "setVolume(int,int)" ) { 1002 } else if ( msg == "setVolume(int,int)" ) {
1003 int t, v; 1003 int t, v;
1004 stream >> t >> v; 1004 stream >> t >> v;
1005 setVolume( t, v ); 1005 setVolume( t, v );
1006 emit volumeChanged( muted ); 1006 emit volumeChanged( muted );
1007 } else if ( msg == "volumeChange(bool)" ) { 1007 } else if ( msg == "volumeChange(bool)" ) {
1008 stream >> muted; 1008 stream >> muted;
1009 setVolume(); 1009 setVolume();
1010 emit volumeChanged( muted ); 1010 emit volumeChanged( muted );
1011 } else if ( msg == "setMic(int,int)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> 1011 } else if ( msg == "setMic(int,int)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com>
1012 int t, v; 1012 int t, v;
1013 stream >> t >> v; 1013 stream >> t >> v;
1014 setMic( t, v ); 1014 setMic( t, v );
1015 emit micChanged( micMuted ); 1015 emit micChanged( micMuted );
1016 } else if ( msg == "micChange(bool)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> 1016 } else if ( msg == "micChange(bool)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com>
1017 stream >> micMuted; 1017 stream >> micMuted;
1018 setMic(); 1018 setMic();
1019 emit micChanged( micMuted ); 1019 emit micChanged( micMuted );
1020 } 1020 }
1021#endif 1021#endif
1022} 1022}
1023 1023
1024/*! 1024/*!
1025 \internal 1025 \internal
1026*/ 1026*/
1027bool QPEApplication::raiseAppropriateWindow() 1027bool QPEApplication::raiseAppropriateWindow()
1028{ 1028{
1029 bool r=FALSE; 1029 bool r=FALSE;
1030 // ########## raise()ing main window should raise and set active 1030 // ########## raise()ing main window should raise and set active
1031 // ########## it and then all childen. This belongs in Qt/Embedded 1031 // ########## it and then all childen. This belongs in Qt/Embedded
1032 QWidget *top = d->qpe_main_widget; 1032 QWidget *top = d->qpe_main_widget;
1033 if ( !top ) top =mainWidget(); 1033 if ( !top ) top =mainWidget();
1034 if ( top && d->keep_running ) { 1034 if ( top && d->keep_running ) {
1035 if ( top->isVisible() ) 1035 if ( top->isVisible() )
1036 r = TRUE; 1036 r = TRUE;
1037 else if (d->preloaded) { 1037 else if (d->preloaded) {
1038 // We are preloaded and not visible.. pretend we just started.. 1038 // We are preloaded and not visible.. pretend we just started..
1039 QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); 1039 QCopEnvelope e("QPE/System", "fastAppShowing(QString)");
1040 e << d->appName; 1040 e << d->appName;
1041 } 1041 }
1042 1042
1043 d->show_mx(top,d->nomaximize); 1043 d->show_mx(top,d->nomaximize);
1044 top->raise(); 1044 top->raise();
1045 top->setActiveWindow(); 1045 top->setActiveWindow();
1046 } 1046 }
1047 QWidget *topm = activeModalWidget(); 1047 QWidget *topm = activeModalWidget();
1048 if ( topm && topm != top ) { 1048 if ( topm && topm != top ) {
1049 topm->show(); 1049 topm->show();
1050 topm->raise(); 1050 topm->raise();
1051 topm->setActiveWindow(); 1051 topm->setActiveWindow();
1052 // If we haven't already handled the fastAppShowing message 1052 // If we haven't already handled the fastAppShowing message
1053 if (!top && d->preloaded) { 1053 if (!top && d->preloaded) {
1054 QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); 1054 QCopEnvelope e("QPE/System", "fastAppShowing(QString)");
1055 e << d->appName; 1055 e << d->appName;
1056 } 1056 }
1057 r = FALSE; 1057 r = FALSE;
1058 } 1058 }
1059 return r; 1059 return r;
1060} 1060}
1061 1061
1062void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data) 1062void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data)
1063{ 1063{
1064#ifdef Q_WS_QWS 1064#ifdef Q_WS_QWS
1065 1065
1066 if ( msg == "quit()" ) { 1066 if ( msg == "quit()" ) {
1067 tryQuit(); 1067 tryQuit();
1068 } else if ( msg == "quitIfInvisible()" ) { 1068 } else if ( msg == "quitIfInvisible()" ) {
1069 if ( d->qpe_main_widget && !d->qpe_main_widget->isVisible() ) 1069 if ( d->qpe_main_widget && !d->qpe_main_widget->isVisible() )
1070 quit(); 1070 quit();
1071 } else if ( msg == "close()" ) { 1071 } else if ( msg == "close()" ) {
1072 hideOrQuit(); 1072 hideOrQuit();
1073 } else if ( msg == "disablePreload()" ) { 1073 } else if ( msg == "disablePreload()" ) {
1074 d->preloaded = FALSE; 1074 d->preloaded = FALSE;
1075 d->keep_running = TRUE; 1075 d->keep_running = TRUE;
1076 /* so that quit will quit */ 1076 /* so that quit will quit */
1077 } else if ( msg == "enablePreload()" ) { 1077 } else if ( msg == "enablePreload()" ) {
1078 if (d->qpe_main_widget) 1078 if (d->qpe_main_widget)
1079 d->preloaded = TRUE; 1079 d->preloaded = TRUE;
1080 d->keep_running = TRUE; 1080 d->keep_running = TRUE;
1081 /* so next quit won't quit */ 1081 /* so next quit won't quit */
1082 } else if ( msg == "raise()" ) { 1082 } else if ( msg == "raise()" ) {
1083 d->keep_running = TRUE; 1083 d->keep_running = TRUE;
1084 d->notbusysent = FALSE; 1084 d->notbusysent = FALSE;
1085 raiseAppropriateWindow(); 1085 raiseAppropriateWindow();
1086 // Tell the system we're still chugging along... 1086 // Tell the system we're still chugging along...
1087 QCopEnvelope e("QPE/System", "appRaised(QString)"); 1087 QCopEnvelope e("QPE/System", "appRaised(QString)");
1088 e << d->appName; 1088 e << d->appName;
1089 } else if ( msg == "flush()" ) { 1089 } else if ( msg == "flush()" ) {
1090 emit flush(); 1090 emit flush();
1091 // we need to tell the desktop 1091 // we need to tell the desktop
1092 QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" ); 1092 QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" );
1093 e << d->appName; 1093 e << d->appName;
1094 } else if ( msg == "reload()" ) { 1094 } else if ( msg == "reload()" ) {
1095 emit reload(); 1095 emit reload();
1096 } else if ( msg == "setDocument(QString)" ) { 1096 } else if ( msg == "setDocument(QString)" ) {
1097 d->keep_running = TRUE; 1097 d->keep_running = TRUE;
1098 QDataStream stream( data, IO_ReadOnly ); 1098 QDataStream stream( data, IO_ReadOnly );
1099 QString doc; 1099 QString doc;
1100 stream >> doc; 1100 stream >> doc;
1101 QWidget *mw = mainWidget(); 1101 QWidget *mw = mainWidget();
1102 if ( !mw ) 1102 if ( !mw )
1103 mw = d->qpe_main_widget; 1103 mw = d->qpe_main_widget;
1104 if ( mw ) 1104 if ( mw )
1105 Global::setDocument( mw, doc ); 1105 Global::setDocument( mw, doc );
1106 } else if ( msg == "nextView()" ) { 1106 } else if ( msg == "nextView()" ) {
1107 qDebug("got nextView()"); 1107 qDebug("got nextView()");
1108/* 1108/*
1109 if ( raiseAppropriateWindow() ) 1109 if ( raiseAppropriateWindow() )
1110*/ 1110*/
1111 emit appMessage( msg, data); 1111 emit appMessage( msg, data);
1112 } else { 1112 } else {
1113 emit appMessage( msg, data); 1113 emit appMessage( msg, data);
1114 } 1114 }
1115 1115
1116#endif 1116#endif
1117} 1117}
1118 1118
1119 1119
1120/*! 1120/*!
1121 Sets widget \a mw as the mainWidget() and shows it. For small windows, 1121 Sets widget \a mw as the mainWidget() and shows it. For small windows,
1122 consider passing TRUE for \a nomaximize rather than the default FALSE. 1122 consider passing TRUE for \a nomaximize rather than the default FALSE.
1123 1123
1124 \sa showMainDocumentWidget() 1124 \sa showMainDocumentWidget()
1125*/ 1125*/
1126void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize ) 1126void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize )
1127{ 1127{
1128 d->show(mw,nomaximize ); 1128 d->show(mw,nomaximize );
1129} 1129}
1130 1130
1131/*! 1131/*!
1132 Sets widget \a mw as the mainWidget() and shows it. For small windows, 1132 Sets widget \a mw as the mainWidget() and shows it. For small windows,
1133 consider passing TRUE for \a nomaximize rather than the default FALSE. 1133 consider passing TRUE for \a nomaximize rather than the default FALSE.
1134 1134
1135 This calls designates the application as 1135 This calls designates the application as
1136 a \link docwidget.html document-oriented\endlink application. 1136 a \link docwidget.html document-oriented\endlink application.
1137 1137
1138 The \a mw widget \e must have this slot: setDocument(const QString&). 1138 The \a mw widget \e must have this slot: setDocument(const QString&).
1139 1139
1140 \sa showMainWidget() 1140 \sa showMainWidget()
1141*/ 1141*/
1142void QPEApplication::showMainDocumentWidget( QWidget* mw, bool nomaximize ) 1142void QPEApplication::showMainDocumentWidget( QWidget* mw, bool nomaximize )
1143{ 1143{
1144 if ( mw && argc() == 2 ) 1144 if ( mw && argc() == 2 )
1145 Global::setDocument( mw, QString::fromUtf8(argv()[1]) ); 1145 Global::setDocument( mw, QString::fromUtf8(argv()[1]) );
1146 1146
1147 d->show(mw, nomaximize ); 1147 d->show(mw, nomaximize );
1148} 1148}
1149 1149
1150 1150
1151/*! 1151/*!
1152 If an application is started via a \link qcop.html QCop\endlink 1152 If an application is started via a \link qcop.html QCop\endlink
1153 message, the application will process the \link qcop.html 1153 message, the application will process the \link qcop.html
1154 QCop\endlink message and then quit. If the application calls this 1154 QCop\endlink message and then quit. If the application calls this
1155 function while processing a \link qcop.html QCop\endlink message, 1155 function while processing a \link qcop.html QCop\endlink message,
1156 after processing its outstanding \link qcop.html QCop\endlink 1156 after processing its outstanding \link qcop.html QCop\endlink
1157 messages the application will start 'properly' and show itself. 1157 messages the application will start 'properly' and show itself.
1158 1158
1159 \sa keepRunning() 1159 \sa keepRunning()
1160*/ 1160*/
1161void QPEApplication::setKeepRunning() 1161void QPEApplication::setKeepRunning()
1162{ 1162{
1163 if ( qApp && qApp->inherits( "QPEApplication" ) ) { 1163 if ( qApp && qApp->inherits( "QPEApplication" ) ) {
1164 QPEApplication * qpeApp = ( QPEApplication* ) qApp; 1164 QPEApplication * qpeApp = ( QPEApplication* ) qApp;
1165 qpeApp->d->keep_running = TRUE; 1165 qpeApp->d->keep_running = TRUE;
1166 } 1166 }
1167} 1167}
1168 1168
1169/*! 1169/*!
1170 Returns TRUE if the application will quit after processing the 1170 Returns TRUE if the application will quit after processing the
1171 current list of qcop messages; otherwise returns FALSE. 1171 current list of qcop messages; otherwise returns FALSE.
1172 1172
1173 \sa setKeepRunning() 1173 \sa setKeepRunning()
1174*/ 1174*/
1175bool QPEApplication::keepRunning() const 1175bool QPEApplication::keepRunning() const
1176{ 1176{
1177 return d->keep_running; 1177 return d->keep_running;
1178} 1178}
1179 1179
1180/*! 1180/*!
1181 \internal 1181 \internal
1182*/ 1182*/
1183void QPEApplication::internalSetStyle( const QString &style ) 1183void QPEApplication::internalSetStyle( const QString &style )
1184{ 1184{
1185#if QT_VERSION >= 300 1185#if QT_VERSION >= 300
1186 if ( style == "QPE" ) { 1186 if ( style == "QPE" ) {
1187 setStyle( new QPEStyle ); 1187 setStyle( new QPEStyle );
1188 } 1188 }
1189 else { 1189 else {
1190 QStyle *s = QStyleFactory::create( style ); 1190 QStyle *s = QStyleFactory::create( style );
1191 if ( s ) 1191 if ( s )
1192 setStyle( s ); 1192 setStyle( s );
1193 } 1193 }
1194#else 1194#else
1195 if ( style == "Windows" ) { 1195 if ( style == "Windows" ) {
1196 setStyle( new QWindowsStyle ); 1196 setStyle( new QWindowsStyle );
1197 } 1197 }
1198 else if ( style == "QPE" ) { 1198 else if ( style == "QPE" ) {
1199 setStyle( new QPEStyle ); 1199 setStyle( new QPEStyle );
1200 } 1200 }
1201 else if ( style == "Light" ) { 1201 else if ( style == "Light" ) {
1202 setStyle( new LightStyle ); 1202 setStyle( new LightStyle );
1203 } 1203 }
1204#ifndef QT_NO_STYLE_PLATINUM 1204#ifndef QT_NO_STYLE_PLATINUM
1205 else if ( style == "Platinum" ) { 1205 else if ( style == "Platinum" ) {
1206 setStyle( new QPlatinumStyle ); 1206 setStyle( new QPlatinumStyle );
1207 } 1207 }
1208#endif 1208#endif
1209#ifndef QT_NO_STYLE_MOTIF 1209#ifndef QT_NO_STYLE_MOTIF
1210 else if ( style == "Motif" ) { 1210 else if ( style == "Motif" ) {
1211 setStyle( new QMotifStyle ); 1211 setStyle( new QMotifStyle );
1212 } 1212 }
1213#endif 1213#endif
1214#ifndef QT_NO_STYLE_MOTIFPLUS 1214#ifndef QT_NO_STYLE_MOTIFPLUS
1215 else if ( style == "MotifPlus" ) { 1215 else if ( style == "MotifPlus" ) {
1216 setStyle( new QMotifPlusStyle ); 1216 setStyle( new QMotifPlusStyle );
1217 } 1217 }
1218#endif 1218#endif
1219 1219
1220 else { 1220 else {
1221 QStyle *sty = 0; 1221 QStyle *sty = 0;
1222 QString path = QPEApplication::qpeDir ( ) + "/plugins/styles/lib" + style. lower ( ) + ".so"; 1222 QString path = QPEApplication::qpeDir ( ) + "/plugins/styles/";
1223
1224 if ( style. find ( ".so" ) > 0 )
1225 path += style;
1226 else
1227 path = path + "lib" + style. lower ( ) + ".so"; // compatibility
1223 1228
1224 static QLibrary *lastlib = 0; 1229 static QLibrary *lastlib = 0;
1225 static StyleInterface *lastiface = 0; 1230 static StyleInterface *lastiface = 0;
1226 1231
1227 QLibrary *lib = new QLibrary ( path ); 1232 QLibrary *lib = new QLibrary ( path );
1228 StyleInterface *iface = 0; 1233 StyleInterface *iface = 0;
1229 1234
1230 if ( lib-> queryInterface ( IID_Style, ( QUnknownInterface ** ) &iface ) == QS_OK ) 1235 if (( lib-> queryInterface ( IID_Style, ( QUnknownInterface ** ) &iface ) == QS_OK ) && iface )
1231 sty = iface-> create ( ); 1236 sty = iface-> create ( );
1232 1237
1233 if ( sty ) { 1238 if ( sty ) {
1234 setStyle ( sty ); 1239 setStyle ( sty );
1235 1240
1236 if ( lastiface ) 1241 if ( lastiface )
1237 lastiface-> release ( ); 1242 lastiface-> release ( );
1238 lastiface = iface; 1243 lastiface = iface;
1239 1244
1240 if ( lastlib ) { 1245 if ( lastlib ) {
1241 lastlib-> unload ( ); 1246 lastlib-> unload ( );
1242 delete lastlib; 1247 delete lastlib;
1243 } 1248 }
1244 lastlib = lib; 1249 lastlib = lib;
1245 } 1250 }
1246 else { 1251 else {
1247 if ( iface ) 1252 if ( iface )
1248 iface-> release ( ); 1253 iface-> release ( );
1249 delete lib; 1254 delete lib;
1250 1255
1251 setStyle ( new QPEStyle ( )); 1256 setStyle ( new QPEStyle ( ));
1252 } 1257 }
1253 } 1258 }
1254#endif 1259#endif
1255} 1260}
1256 1261
1257/*! 1262/*!
1258 \internal 1263 \internal
1259*/ 1264*/
1260void QPEApplication::prepareForTermination( bool willrestart ) 1265void QPEApplication::prepareForTermination( bool willrestart )
1261{ 1266{
1262 if ( willrestart ) { 1267 if ( willrestart ) {
1263 // Draw a big wait icon, the image can be altered in later revisions 1268 // Draw a big wait icon, the image can be altered in later revisions
1264 // QWidget *d = QApplication::desktop(); 1269 // QWidget *d = QApplication::desktop();
1265 QImage img = Resource::loadImage( "launcher/new_wait" ); 1270 QImage img = Resource::loadImage( "launcher/new_wait" );
1266 QPixmap pix; 1271 QPixmap pix;
1267 pix.convertFromImage( img.smoothScale( 1 * img.width(), 1 * img.height() ) ); 1272 pix.convertFromImage( img.smoothScale( 1 * img.width(), 1 * img.height() ) );
1268 QLabel *lblWait = new QLabel( 0, "wait hack!", QWidget::WStyle_Customize | 1273 QLabel *lblWait = new QLabel( 0, "wait hack!", QWidget::WStyle_Customize |
1269 QWidget::WStyle_NoBorder | QWidget::WStyle_Tool ); 1274 QWidget::WStyle_NoBorder | QWidget::WStyle_Tool );
1270 lblWait->setPixmap( pix ); 1275 lblWait->setPixmap( pix );
1271 lblWait->setAlignment( QWidget::AlignCenter ); 1276 lblWait->setAlignment( QWidget::AlignCenter );
1272 lblWait->show(); 1277 lblWait->show();
1273 lblWait->showMaximized(); 1278 lblWait->showMaximized();
1274 } 1279 }
1275#ifndef SINGLE_APP 1280#ifndef SINGLE_APP
1276 { QCopEnvelope envelope( "QPE/System", "forceQuit()" ); 1281 { QCopEnvelope envelope( "QPE/System", "forceQuit()" );
1277 } 1282 }
1278 processEvents(); // ensure the message goes out. 1283 processEvents(); // ensure the message goes out.
1279 sleep( 1 ); // You have 1 second to comply. 1284 sleep( 1 ); // You have 1 second to comply.
1280#endif 1285#endif
1281} 1286}
1282 1287
1283/*! 1288/*!
1284 \internal 1289 \internal
1285*/ 1290*/
1286void QPEApplication::shutdown() 1291void QPEApplication::shutdown()
1287{ 1292{
1288 // Implement in server's QPEApplication subclass 1293 // Implement in server's QPEApplication subclass
1289} 1294}
1290 1295
1291/*! 1296/*!
1292 \internal 1297 \internal
1293*/ 1298*/
1294void QPEApplication::restart() 1299void QPEApplication::restart()
1295{ 1300{
1296 // Implement in server's QPEApplication subclass 1301 // Implement in server's QPEApplication subclass
1297} 1302}
1298 1303
1299static QPtrDict<void>* stylusDict = 0; 1304static QPtrDict<void>* stylusDict = 0;
1300static void createDict() 1305static void createDict()
1301{ 1306{
1302 if ( !stylusDict ) 1307 if ( !stylusDict )
1303 stylusDict = new QPtrDict<void>; 1308 stylusDict = new QPtrDict<void>;
1304} 1309}
1305 1310
1306/*! 1311/*!
1307 Returns the current StylusMode for widget \a w. 1312 Returns the current StylusMode for widget \a w.
1308 1313
1309 \sa setStylusOperation() StylusMode 1314 \sa setStylusOperation() StylusMode
1310*/ 1315*/
1311QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w ) 1316QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w )
1312{ 1317{
1313 if ( stylusDict ) 1318 if ( stylusDict )
1314 return ( StylusMode ) ( int ) stylusDict->find( w ); 1319 return ( StylusMode ) ( int ) stylusDict->find( w );
1315 return LeftOnly; 1320 return LeftOnly;
1316} 1321}
1317 1322
1318/*! 1323/*!
1319 \enum QPEApplication::StylusMode 1324 \enum QPEApplication::StylusMode
1320 1325
1321 \value LeftOnly the stylus only generates LeftButton 1326 \value LeftOnly the stylus only generates LeftButton
1322 events (the default). 1327 events (the default).
1323 \value RightOnHold the stylus generates RightButton events 1328 \value RightOnHold the stylus generates RightButton events
1324 if the user uses the press-and-hold gesture. 1329 if the user uses the press-and-hold gesture.
1325 1330
1326 \sa setStylusOperation() stylusOperation() 1331 \sa setStylusOperation() stylusOperation()
1327*/ 1332*/
1328 1333
1329/*! 1334/*!
1330 Causes widget \a w to receive mouse events according to the stylus 1335 Causes widget \a w to receive mouse events according to the stylus
1331 \a mode. 1336 \a mode.
1332 1337
1333 \sa stylusOperation() StylusMode 1338 \sa stylusOperation() StylusMode
1334*/ 1339*/
1335void QPEApplication::setStylusOperation( QWidget * w, StylusMode mode ) 1340void QPEApplication::setStylusOperation( QWidget * w, StylusMode mode )
1336{ 1341{
1337 createDict(); 1342 createDict();
1338 if ( mode == LeftOnly ) { 1343 if ( mode == LeftOnly ) {
1339 stylusDict->remove 1344 stylusDict->remove
1340 ( w ); 1345 ( w );
1341 w->removeEventFilter( qApp ); 1346 w->removeEventFilter( qApp );
1342 } 1347 }
1343 else { 1348 else {
1344 stylusDict->insert( w, ( void* ) mode ); 1349 stylusDict->insert( w, ( void* ) mode );
1345 connect( w, SIGNAL( destroyed() ), qApp, SLOT( removeSenderFromStylusDict() ) ); 1350 connect( w, SIGNAL( destroyed() ), qApp, SLOT( removeSenderFromStylusDict() ) );
1346 w->installEventFilter( qApp ); 1351 w->installEventFilter( qApp );
1347 } 1352 }
1348} 1353}
1349 1354
1350 1355
1351/*! 1356/*!
1352 \reimp 1357 \reimp
1353*/ 1358*/
1354bool QPEApplication::eventFilter( QObject *o, QEvent *e ) 1359bool QPEApplication::eventFilter( QObject *o, QEvent *e )
1355{ 1360{
1356 if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) { 1361 if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) {
1357 QMouseEvent * me = ( QMouseEvent* ) e; 1362 QMouseEvent * me = ( QMouseEvent* ) e;
1358 StylusMode mode = (StylusMode)(int)stylusDict->find(o); 1363 StylusMode mode = (StylusMode)(int)stylusDict->find(o);
1359 switch (mode) { 1364 switch (mode) {
1360 case RightOnHold: 1365 case RightOnHold:
1361 switch ( me->type() ) { 1366 switch ( me->type() ) {
1362 case QEvent::MouseButtonPress: 1367 case QEvent::MouseButtonPress:
1363 if ( me->button() == LeftButton ) { 1368 if ( me->button() == LeftButton ) {
1364 d->presstimer = startTimer(500); // #### pref. 1369 d->presstimer = startTimer(500); // #### pref.
1365 d->presswidget = (QWidget*)o; 1370 d->presswidget = (QWidget*)o;
1366 d->presspos = me->pos(); 1371 d->presspos = me->pos();
1367 d->rightpressed = FALSE; 1372 d->rightpressed = FALSE;
1368 } 1373 }
1369 break; 1374 break;
1370 case QEvent::MouseMove: 1375 case QEvent::MouseMove:
1371 if (d->presstimer && (me->pos()-d->presspos).manhattanLength() > 8) { 1376 if (d->presstimer && (me->pos()-d->presspos).manhattanLength() > 8) {
1372 killTimer(d->presstimer); 1377 killTimer(d->presstimer);
1373 d->presstimer = 0; 1378 d->presstimer = 0;
1374 } 1379 }
1375 break; 1380 break;
1376 case QEvent::MouseButtonRelease: 1381 case QEvent::MouseButtonRelease:
1377 if ( me->button() == LeftButton ) { 1382 if ( me->button() == LeftButton ) {
1378 if ( d->presstimer ) { 1383 if ( d->presstimer ) {
1379 killTimer(d->presstimer); 1384 killTimer(d->presstimer);
1380 d->presstimer = 0; 1385 d->presstimer = 0;
1381 } 1386 }
1382 if ( d->rightpressed && d->presswidget ) { 1387 if ( d->rightpressed && d->presswidget ) {
1383 // Right released 1388 // Right released
1384 postEvent( d->presswidget, 1389 postEvent( d->presswidget,
1385 new QMouseEvent( QEvent::MouseButtonRelease, me->pos(), 1390 new QMouseEvent( QEvent::MouseButtonRelease, me->pos(),
1386 RightButton, LeftButton+RightButton ) ); 1391 RightButton, LeftButton+RightButton ) );
1387 // Left released, off-widget 1392 // Left released, off-widget
1388 postEvent( d->presswidget, 1393 postEvent( d->presswidget,
1389 new QMouseEvent( QEvent::MouseMove, QPoint(-1,-1), 1394 new QMouseEvent( QEvent::MouseMove, QPoint(-1,-1),
1390 LeftButton, LeftButton ) ); 1395 LeftButton, LeftButton ) );
1391 postEvent( d->presswidget, 1396 postEvent( d->presswidget,
1392 new QMouseEvent( QEvent::MouseButtonRelease, QPoint(-1,-1), 1397 new QMouseEvent( QEvent::MouseButtonRelease, QPoint(-1,-1),
1393 LeftButton, LeftButton ) ); 1398 LeftButton, LeftButton ) );
1394 d->rightpressed = FALSE; 1399 d->rightpressed = FALSE;
1395 return TRUE; // don't send the real Left release 1400 return TRUE; // don't send the real Left release
1396 } 1401 }
1397 } 1402 }
1398 break; 1403 break;
1399 default: 1404 default:
1400 break; 1405 break;
1401 } 1406 }
1402 break; 1407 break;
1403 default: 1408 default:
1404 ; 1409 ;
1405 } 1410 }
1406 }else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { 1411 }else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) {
1407 QKeyEvent *ke = (QKeyEvent *)e; 1412 QKeyEvent *ke = (QKeyEvent *)e;
1408 if ( ke->key() == Key_Enter ) { 1413 if ( ke->key() == Key_Enter ) {
1409 if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) { 1414 if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) {
1410 postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ', 1415 postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ',
1411 ke->state(), " ", ke->isAutoRepeat(), ke->count() ) ); 1416 ke->state(), " ", ke->isAutoRepeat(), ke->count() ) );
1412 return TRUE; 1417 return TRUE;
1413 } 1418 }
1414 } 1419 }
1415 } 1420 }
1416 return FALSE; 1421 return FALSE;
1417} 1422}
1418 1423
1419/*! 1424/*!
1420 \reimp 1425 \reimp
1421*/ 1426*/
1422void QPEApplication::timerEvent( QTimerEvent *e ) 1427void QPEApplication::timerEvent( QTimerEvent *e )
1423{ 1428{
1424 if ( e->timerId() == d->presstimer && d->presswidget ) { 1429 if ( e->timerId() == d->presstimer && d->presswidget ) {
1425 // Right pressed 1430 // Right pressed
1426 postEvent( d->presswidget, 1431 postEvent( d->presswidget,
1427 new QMouseEvent( QEvent::MouseButtonPress, d->presspos, 1432 new QMouseEvent( QEvent::MouseButtonPress, d->presspos,
1428 RightButton, LeftButton ) ); 1433 RightButton, LeftButton ) );
1429 killTimer( d->presstimer ); 1434 killTimer( d->presstimer );
1430 d->presstimer = 0; 1435 d->presstimer = 0;
1431 d->rightpressed = TRUE; 1436 d->rightpressed = TRUE;
1432 } 1437 }
1433} 1438}
1434 1439
1435void QPEApplication::removeSenderFromStylusDict() 1440void QPEApplication::removeSenderFromStylusDict()
1436{ 1441{
1437 stylusDict->remove 1442 stylusDict->remove
1438 ( ( void* ) sender() ); 1443 ( ( void* ) sender() );
1439 if ( d->presswidget == sender() ) 1444 if ( d->presswidget == sender() )
1440 d->presswidget = 0; 1445 d->presswidget = 0;
1441} 1446}
1442 1447
1443/*! 1448/*!
1444 \internal 1449 \internal
1445*/ 1450*/
1446bool QPEApplication::keyboardGrabbed() const 1451bool QPEApplication::keyboardGrabbed() const
1447{ 1452{
1448 return d->kbgrabber; 1453 return d->kbgrabber;
1449} 1454}
1450 1455
1451 1456
1452/*! 1457/*!
1453 Reverses the effect of grabKeyboard(). This is called automatically 1458 Reverses the effect of grabKeyboard(). This is called automatically
1454 on program exit. 1459 on program exit.
1455*/ 1460*/
1456void QPEApplication::ungrabKeyboard() 1461void QPEApplication::ungrabKeyboard()
1457{ 1462{
1458 QPEApplicationData * d = ( ( QPEApplication* ) qApp ) ->d; 1463 QPEApplicationData * d = ( ( QPEApplication* ) qApp ) ->d;
1459 if ( d->kbgrabber == 2 ) { 1464 if ( d->kbgrabber == 2 ) {
1460#ifndef QT_NO_COP 1465#ifndef QT_NO_COP
1461 QCopEnvelope e( "QPE/System", "grabKeyboard(QString)" ); 1466 QCopEnvelope e( "QPE/System", "grabKeyboard(QString)" );
1462 e << QString::null; 1467 e << QString::null;
1463#endif 1468#endif
1464 d->kbregrab = FALSE; 1469 d->kbregrab = FALSE;
1465 d->kbgrabber = 0; 1470 d->kbgrabber = 0;
1466 } 1471 }
1467} 1472}
1468 1473
1469/*! 1474/*!
1470 Grabs the physical keyboard keys, e.g. the application's launching 1475 Grabs the physical keyboard keys, e.g. the application's launching
1471 keys. Instead of launching applications when these keys are pressed 1476 keys. Instead of launching applications when these keys are pressed
1472 the signals emitted are sent to this application instead. Some games 1477 the signals emitted are sent to this application instead. Some games
1473 programs take over the launch keys in this way to make interaction 1478 programs take over the launch keys in this way to make interaction
1474 easier. 1479 easier.
1475 1480
1476 \sa ungrabKeyboard() 1481 \sa ungrabKeyboard()
1477*/ 1482*/
1478void QPEApplication::grabKeyboard() 1483void QPEApplication::grabKeyboard()
1479{ 1484{
1480 QPEApplicationData * d = ( ( QPEApplication* ) qApp ) ->d; 1485 QPEApplicationData * d = ( ( QPEApplication* ) qApp ) ->d;
1481 if ( qApp->type() == QApplication::GuiServer ) 1486 if ( qApp->type() == QApplication::GuiServer )
1482 d->kbgrabber = 0; 1487 d->kbgrabber = 0;
1483 else { 1488 else {
1484#ifndef QT_NO_COP 1489#ifndef QT_NO_COP
1485 QCopEnvelope e( "QPE/System", "grabKeyboard(QString)" ); 1490 QCopEnvelope e( "QPE/System", "grabKeyboard(QString)" );
1486 e << d->appName; 1491 e << d->appName;