summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--library/qpeapplication.cpp189
1 files changed, 133 insertions, 56 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp
index f65f3ab..2432b65 100644
--- a/library/qpeapplication.cpp
+++ b/library/qpeapplication.cpp
@@ -87,5 +87,6 @@
87 87
88 88
89class QPEApplicationData { 89class QPEApplicationData
90{
90public: 91public:
91 QPEApplicationData() : presstimer( 0 ), presswidget( 0 ), rightpressed( FALSE ), 92 QPEApplicationData() : presstimer( 0 ), presswidget( 0 ), rightpressed( FALSE ),
@@ -100,13 +101,18 @@ public:
100 QWidget* presswidget; 101 QWidget* presswidget;
101 QPoint presspos; 102 QPoint presspos;
102 bool rightpressed : 1; // AEH why not use uint foobar :1; if it's tt style -zecke 103bool rightpressed :
104 1; // AEH why not use uint foobar :1; if it's tt style -zecke
103 int kbgrabber; 105 int kbgrabber;
104 bool kbregrab : 1; 106bool kbregrab :
105 bool notbusysent : 1; 107 1;
108bool notbusysent :
109 1;
106 QString appName; 110 QString appName;
107 struct QCopRec { 111 struct QCopRec
112 {
108 QCopRec( const QCString &ch, const QCString &msg, 113 QCopRec( const QCString &ch, const QCString &msg,
109 const QByteArray &d ) : 114 const QByteArray &d ) :
110 channel( ch ), message( msg ), data( d ) { } 115 channel( ch ), message( msg ), data( d )
116 { }
111 117
112 QCString channel; 118 QCString channel;
@@ -114,9 +120,13 @@ public:
114 QByteArray data; 120 QByteArray data;
115 }; 121 };
116 bool preloaded : 1; 122bool preloaded :
117 bool forceshow : 1; 123 1;
118 bool nomaximize : 1; 124bool forceshow :
125 1;
126bool nomaximize :
127 1;
119 QWidget* qpe_main_widget; 128 QWidget* qpe_main_widget;
120 bool keep_running : 1; 129bool keep_running :
130 1;
121 QList<QCopRec> qcopq; 131 QList<QCopRec> qcopq;
122 132
@@ -126,16 +136,21 @@ public:
126 qcopq.append( new QCopRec( ch, msg, data ) ); 136 qcopq.append( new QCopRec( ch, msg, data ) );
127 } 137 }
128 void sendQCopQ() { 138 void sendQCopQ()
139 {
129 QCopRec * r; 140 QCopRec * r;
130#ifndef QT_NO_COP 141#ifndef QT_NO_COP
142
131 for ( QListIterator<QCopRec> it( qcopq ); ( r = it.current() ); ++it ) 143 for ( QListIterator<QCopRec> it( qcopq ); ( r = it.current() ); ++it )
132 QCopChannel::sendLocally( r->channel, r->message, r->data ); 144 QCopChannel::sendLocally( r->channel, r->message, r->data );
133#endif 145#endif
146
134 qcopq.clear(); 147 qcopq.clear();
135 } 148 }
136 static void show_mx(QWidget* mw, bool nomaximize) { 149 static void show_mx(QWidget* mw, bool nomaximize)
150 {
137 if ( mw->layout() && mw->inherits("QDialog") ) { 151 if ( mw->layout() && mw->inherits("QDialog") ) {
138 QPEApplication::showDialog((QDialog*)mw,nomaximize); 152 QPEApplication::showDialog((QDialog*)mw,nomaximize);
139 } else { 153 }
154 else {
140#ifdef Q_WS_QWS 155#ifdef Q_WS_QWS
141 if ( !nomaximize ) 156 if ( !nomaximize )
@@ -143,4 +158,5 @@ public:
143 else 158 else
144#endif 159#endif
160
145 mw->show(); 161 mw->show();
146 } 162 }
@@ -176,10 +192,13 @@ public:
176 qpe_main_widget = mw; 192 qpe_main_widget = mw;
177#ifndef QT_NO_COP 193#ifndef QT_NO_COP
194
178 sendQCopQ(); 195 sendQCopQ();
179#endif 196#endif
197
180 if ( preloaded ) { 198 if ( preloaded ) {
181 if(forceshow) 199 if(forceshow)
182 show_mx(mw,nomax); 200 show_mx(mw,nomax);
183 } else if ( keep_running ) { 201 }
202 else if ( keep_running ) {
184 show_mx(mw,nomax); 203 show_mx(mw,nomax);
185 } 204 }
@@ -201,5 +220,6 @@ public:
201 // ### it exists now; need to remember if we can delete it 220 // ### it exists now; need to remember if we can delete it
202 } 221 }
203 } else { 222 }
223 else {
204 lib->unload(); 224 lib->unload();
205 delete lib; 225 delete lib;
@@ -223,5 +243,6 @@ public:
223 // ### it exists now; need to remember if we can delete it 243 // ### it exists now; need to remember if we can delete it
224 } 244 }
225 } else { 245 }
246 else {
226 lib->unload(); 247 lib->unload();
227 delete lib; 248 delete lib;
@@ -233,5 +254,6 @@ public:
233}; 254};
234 255
235class ResourceMimeFactory : public QMimeSourceFactory { 256class ResourceMimeFactory : public QMimeSourceFactory
257{
236public: 258public:
237 ResourceMimeFactory() 259 ResourceMimeFactory()
@@ -449,9 +471,11 @@ QPEApplication::QPEApplication( int & argc, char **argv, Type t )
449 AppLnk::setSmallIconSize( 10 ); 471 AppLnk::setSmallIconSize( 10 );
450 AppLnk::setBigIconSize( 28 ); 472 AppLnk::setBigIconSize( 28 );
451 }else if ( dw > 600 ) { 473 }
474 else if ( dw > 600 ) {
452 setFont( QFont( "helvetica", 12 ) ); 475 setFont( QFont( "helvetica", 12 ) );
453 AppLnk::setSmallIconSize( 24 ); 476 AppLnk::setSmallIconSize( 24 );
454 AppLnk::setBigIconSize( 48 ); 477 AppLnk::setBigIconSize( 48 );
455 }else if ( dw > 200 ) { 478 }
479 else if ( dw > 200 ) {
456 setFont( QFont( "helvetica", 12 ) ); 480 setFont( QFont( "helvetica", 12 ) );
457 AppLnk::setSmallIconSize( 16 ); 481 AppLnk::setSmallIconSize( 16 );
@@ -548,4 +572,5 @@ QPEApplication::QPEApplication( int & argc, char **argv, Type t )
548 //###language/font hack; should look it up somewhere 572 //###language/font hack; should look it up somewhere
549#ifdef QWS 573#ifdef QWS
574
550 if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) { 575 if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) {
551 QFont fn = FontManager::unicodeFont( FontManager::Proportional ); 576 QFont fn = FontManager::unicodeFont( FontManager::Proportional );
@@ -553,4 +578,5 @@ QPEApplication::QPEApplication( int & argc, char **argv, Type t )
553 } 578 }
554#endif 579#endif
580
555 } 581 }
556#endif 582#endif
@@ -622,6 +648,12 @@ class HackDialog : public QDialog
622{ 648{
623public: 649public:
624 void acceptIt() { accept(); } 650 void acceptIt()
625 void rejectIt() { reject(); } 651 {
652 accept();
653 }
654 void rejectIt()
655 {
656 reject();
657 }
626}; 658};
627 659
@@ -640,4 +672,5 @@ void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key )
640 672
641#ifdef QWS 673#ifdef QWS
674
642 ke->simpleData.keycode = key; 675 ke->simpleData.keycode = key;
643#endif 676#endif
@@ -648,5 +681,7 @@ class HackWidget : public QWidget
648public: 681public:
649 bool needsOk() 682 bool needsOk()
650 { return ( getWState() & WState_Reserved1 ); } 683 {
684 return ( getWState() & WState_Reserved1 );
685 }
651}; 686};
652 687
@@ -708,5 +743,6 @@ bool QPEApplication::qwsEventFilter( QWSEvent * e )
708 } 743 }
709 } 744 }
710 } else if ( ke->simpleData.keycode == Qt::Key_F30 ) { 745 }
746 else if ( ke->simpleData.keycode == Qt::Key_F30 ) {
711 // Use special "select" key to do whatever default action a widget has 747 // Use special "select" key to do whatever default action a widget has
712 mapToDefaultAction( ke, Qt::Key_Space ); 748 mapToDefaultAction( ke, Qt::Key_Space );
@@ -852,8 +888,12 @@ void QPEApplication::setDefaultRotation( int r )
852 config.setGroup( "Rotation" ); 888 config.setGroup( "Rotation" );
853 config.writeEntry( "Screen", getenv("QWS_DISPLAY") ); 889 config.writeEntry( "Screen", getenv("QWS_DISPLAY") );
854 } else { 890 }
891 else {
855#ifndef QT_NO_COP 892#ifndef QT_NO_COP
856 { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" ); e << r; } 893 { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" );
894 e << r;
895 }
857#endif 896#endif
897
858 } 898 }
859} 899}
@@ -911,5 +951,6 @@ void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data
911 if ( msg == "applyStyle()" ) { 951 if ( msg == "applyStyle()" ) {
912 applyStyle(); 952 applyStyle();
913 } else if ( msg == "setDefaultRotation(int)" ) { 953 }
954 else if ( msg == "setDefaultRotation(int)" ) {
914 if ( type() == GuiServer ) { 955 if ( type() == GuiServer ) {
915 int r; 956 int r;
@@ -917,17 +958,22 @@ void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data
917 setDefaultRotation( r ); 958 setDefaultRotation( r );
918 } 959 }
919 } else if ( msg == "shutdown()" ) { 960 }
961 else if ( msg == "shutdown()" ) {
920 if ( type() == GuiServer ) 962 if ( type() == GuiServer )
921 shutdown(); 963 shutdown();
922 } else if ( msg == "quit()" ) { 964 }
965 else if ( msg == "quit()" ) {
923 if ( type() != GuiServer ) 966 if ( type() != GuiServer )
924 tryQuit(); 967 tryQuit();
925 } else if ( msg == "forceQuit()" ) { 968 }
969 else if ( msg == "forceQuit()" ) {
926 if ( type() != GuiServer ) 970 if ( type() != GuiServer )
927 quit(); 971 quit();
928 } else if ( msg == "restart()" ) { 972 }
973 else if ( msg == "restart()" ) {
929 if ( type() == GuiServer ) 974 if ( type() == GuiServer )
930 restart(); 975 restart();
931 } else if ( msg == "grabKeyboard(QString)" ) { 976 }
977 else if ( msg == "grabKeyboard(QString)" ) {
932 QString who; 978 QString who;
933 stream >> who; 979 stream >> who;
@@ -938,5 +984,6 @@ void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data
938 else 984 else
939 d->kbgrabber = 2; 985 d->kbgrabber = 2;
940 } else if ( msg == "language(QString)" ) { 986 }
987 else if ( msg == "language(QString)" ) {
941 if ( type() == GuiServer ) { 988 if ( type() == GuiServer ) {
942 QString l; 989 QString l;
@@ -951,5 +998,6 @@ void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data
951 } 998 }
952 } 999 }
953 } else if ( msg == "timeChange(QString)" ) { 1000 }
1001 else if ( msg == "timeChange(QString)" ) {
954 QString t; 1002 QString t;
955 stream >> t; 1003 stream >> t;
@@ -960,5 +1008,6 @@ void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data
960 // emit the signal so everyone else knows... 1008 // emit the signal so everyone else knows...
961 emit timeChanged(); 1009 emit timeChanged();
962 } else if ( msg == "execute(QString)" ) { 1010 }
1011 else if ( msg == "execute(QString)" ) {
963 if ( type() == GuiServer ) { 1012 if ( type() == GuiServer ) {
964 QString t; 1013 QString t;
@@ -966,5 +1015,6 @@ void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data
966 Global::execute( t ); 1015 Global::execute( t );
967 } 1016 }
968 } else if ( msg == "execute(QString,QString)" ) { 1017 }
1018 else if ( msg == "execute(QString,QString)" ) {
969 if ( type() == GuiServer ) { 1019 if ( type() == GuiServer ) {
970 QString t, d; 1020 QString t, d;
@@ -972,5 +1022,6 @@ void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data
972 Global::execute( t, d ); 1022 Global::execute( t, d );
973 } 1023 }
974 } else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) { 1024 }
1025 else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) {
975 if ( type() == GuiServer ) { 1026 if ( type() == GuiServer ) {
976 QDateTime when; 1027 QDateTime when;
@@ -980,5 +1031,6 @@ void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data
980 AlarmServer::addAlarm( when, channel, message, data ); 1031 AlarmServer::addAlarm( when, channel, message, data );
981 } 1032 }
982 } else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) { 1033 }
1034 else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) {
983 if ( type() == GuiServer ) { 1035 if ( type() == GuiServer ) {
984 QDateTime when; 1036 QDateTime when;
@@ -988,31 +1040,38 @@ void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data
988 AlarmServer::deleteAlarm( when, channel, message, data ); 1040 AlarmServer::deleteAlarm( when, channel, message, data );
989 } 1041 }
990 } else if ( msg == "clockChange(bool)" ) { 1042 }
1043 else if ( msg == "clockChange(bool)" ) {
991 int tmp; 1044 int tmp;
992 stream >> tmp; 1045 stream >> tmp;
993 emit clockChanged( tmp ); 1046 emit clockChanged( tmp );
994 } else if ( msg == "weekChange(bool)" ) { 1047 }
1048 else if ( msg == "weekChange(bool)" ) {
995 int tmp; 1049 int tmp;
996 stream >> tmp; 1050 stream >> tmp;
997 emit weekChanged( tmp ); 1051 emit weekChanged( tmp );
998 } else if ( msg == "setDateFormat(DateFormat)" ) { 1052 }
1053 else if ( msg == "setDateFormat(DateFormat)" ) {
999 DateFormat tmp; 1054 DateFormat tmp;
1000 stream >> tmp; 1055 stream >> tmp;
1001 emit dateFormatChanged( tmp ); 1056 emit dateFormatChanged( tmp );
1002 } else if ( msg == "setVolume(int,int)" ) { 1057 }
1058 else if ( msg == "setVolume(int,int)" ) {
1003 int t, v; 1059 int t, v;
1004 stream >> t >> v; 1060 stream >> t >> v;
1005 setVolume( t, v ); 1061 setVolume( t, v );
1006 emit volumeChanged( muted ); 1062 emit volumeChanged( muted );
1007 } else if ( msg == "volumeChange(bool)" ) { 1063 }
1064 else if ( msg == "volumeChange(bool)" ) {
1008 stream >> muted; 1065 stream >> muted;
1009 setVolume(); 1066 setVolume();
1010 emit volumeChanged( muted ); 1067 emit volumeChanged( muted );
1011 } else if ( msg == "setMic(int,int)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> 1068 }
1069 else if ( msg == "setMic(int,int)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com>
1012 int t, v; 1070 int t, v;
1013 stream >> t >> v; 1071 stream >> t >> v;
1014 setMic( t, v ); 1072 setMic( t, v );
1015 emit micChanged( micMuted ); 1073 emit micChanged( micMuted );
1016 } else if ( msg == "micChange(bool)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> 1074 }
1075 else if ( msg == "micChange(bool)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com>
1017 stream >> micMuted; 1076 stream >> micMuted;
1018 setMic(); 1077 setMic();
@@ -1031,5 +1090,6 @@ bool QPEApplication::raiseAppropriateWindow()
1031 // ########## it and then all childen. This belongs in Qt/Embedded 1090 // ########## it and then all childen. This belongs in Qt/Embedded
1032 QWidget *top = d->qpe_main_widget; 1091 QWidget *top = d->qpe_main_widget;
1033 if ( !top ) top =mainWidget(); 1092 if ( !top )
1093 top = mainWidget();
1034 if ( top && d->keep_running ) { 1094 if ( top && d->keep_running ) {
1035 if ( top->isVisible() ) 1095 if ( top->isVisible() )
@@ -1066,19 +1126,24 @@ void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data)
1066 if ( msg == "quit()" ) { 1126 if ( msg == "quit()" ) {
1067 tryQuit(); 1127 tryQuit();
1068 } else if ( msg == "quitIfInvisible()" ) { 1128 }
1129 else if ( msg == "quitIfInvisible()" ) {
1069 if ( d->qpe_main_widget && !d->qpe_main_widget->isVisible() ) 1130 if ( d->qpe_main_widget && !d->qpe_main_widget->isVisible() )
1070 quit(); 1131 quit();
1071 } else if ( msg == "close()" ) { 1132 }
1133 else if ( msg == "close()" ) {
1072 hideOrQuit(); 1134 hideOrQuit();
1073 } else if ( msg == "disablePreload()" ) { 1135 }
1136 else if ( msg == "disablePreload()" ) {
1074 d->preloaded = FALSE; 1137 d->preloaded = FALSE;
1075 d->keep_running = TRUE; 1138 d->keep_running = TRUE;
1076 /* so that quit will quit */ 1139 /* so that quit will quit */
1077 } else if ( msg == "enablePreload()" ) { 1140 }
1141 else if ( msg == "enablePreload()" ) {
1078 if (d->qpe_main_widget) 1142 if (d->qpe_main_widget)
1079 d->preloaded = TRUE; 1143 d->preloaded = TRUE;
1080 d->keep_running = TRUE; 1144 d->keep_running = TRUE;
1081 /* so next quit won't quit */ 1145 /* so next quit won't quit */
1082 } else if ( msg == "raise()" ) { 1146 }
1147 else if ( msg == "raise()" ) {
1083 d->keep_running = TRUE; 1148 d->keep_running = TRUE;
1084 d->notbusysent = FALSE; 1149 d->notbusysent = FALSE;
@@ -1087,12 +1152,15 @@ void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data)
1087 QCopEnvelope e("QPE/System", "appRaised(QString)"); 1152 QCopEnvelope e("QPE/System", "appRaised(QString)");
1088 e << d->appName; 1153 e << d->appName;
1089 } else if ( msg == "flush()" ) { 1154 }
1155 else if ( msg == "flush()" ) {
1090 emit flush(); 1156 emit flush();
1091 // we need to tell the desktop 1157 // we need to tell the desktop
1092 QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" ); 1158 QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" );
1093 e << d->appName; 1159 e << d->appName;
1094 } else if ( msg == "reload()" ) { 1160 }
1161 else if ( msg == "reload()" ) {
1095 emit reload(); 1162 emit reload();
1096 } else if ( msg == "setDocument(QString)" ) { 1163 }
1164 else if ( msg == "setDocument(QString)" ) {
1097 d->keep_running = TRUE; 1165 d->keep_running = TRUE;
1098 QDataStream stream( data, IO_ReadOnly ); 1166 QDataStream stream( data, IO_ReadOnly );
@@ -1104,5 +1172,6 @@ void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data)
1104 if ( mw ) 1172 if ( mw )
1105 Global::setDocument( mw, doc ); 1173 Global::setDocument( mw, doc );
1106 } else if ( msg == "nextView()" ) { 1174 }
1175 else if ( msg == "nextView()" ) {
1107 qDebug("got nextView()"); 1176 qDebug("got nextView()");
1108/* 1177/*
@@ -1110,5 +1179,6 @@ void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data)
1110*/ 1179*/
1111 emit appMessage( msg, data); 1180 emit appMessage( msg, data);
1112 } else { 1181 }
1182 else {
1113 emit appMessage( msg, data); 1183 emit appMessage( msg, data);
1114 } 1184 }
@@ -1409,5 +1479,6 @@ bool QPEApplication::eventFilter( QObject *o, QEvent *e )
1409 ; 1479 ;
1410 } 1480 }
1411 }else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { 1481 }
1482 else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) {
1412 QKeyEvent *ke = (QKeyEvent *)e; 1483 QKeyEvent *ke = (QKeyEvent *)e;
1413 if ( ke->key() == Key_Enter ) { 1484 if ( ke->key() == Key_Enter ) {
@@ -1467,4 +1538,5 @@ void QPEApplication::ungrabKeyboard()
1467 e << QString::null; 1538 e << QString::null;
1468#endif 1539#endif
1540
1469 d->kbregrab = FALSE; 1541 d->kbregrab = FALSE;
1470 d->kbgrabber = 0; 1542 d->kbgrabber = 0;
@@ -1491,4 +1563,5 @@ void QPEApplication::grabKeyboard()
1491 e << d->appName; 1563 e << d->appName;
1492#endif 1564#endif
1565
1493 d->kbgrabber = 2; // me 1566 d->kbgrabber = 2; // me
1494 } 1567 }
@@ -1503,4 +1576,5 @@ int QPEApplication::exec()
1503 d->sendQCopQ(); 1576 d->sendQCopQ();
1504#endif 1577#endif
1578
1505 if ( d->keep_running ) 1579 if ( d->keep_running )
1506 //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() ) 1580 //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() )
@@ -1508,4 +1582,5 @@ int QPEApplication::exec()
1508 1582
1509#ifndef QT_NO_COP 1583#ifndef QT_NO_COP
1584
1510 { 1585 {
1511 QCopEnvelope e( "QPE/System", "closing(QString)" ); 1586 QCopEnvelope e( "QPE/System", "closing(QString)" );
@@ -1527,4 +1602,5 @@ void QPEApplication::tryQuit()
1527 return ; // Inside modal loop or konsole. Too hard to save state. 1602 return ; // Inside modal loop or konsole. Too hard to save state.
1528#ifndef QT_NO_COP 1603#ifndef QT_NO_COP
1604
1529 { 1605 {
1530 QCopEnvelope e( "QPE/System", "closing(QString)" ); 1606 QCopEnvelope e( "QPE/System", "closing(QString)" );
@@ -1551,4 +1627,5 @@ void QPEApplication::hideOrQuit()
1551 if ( d->preloaded && d->qpe_main_widget ) 1627 if ( d->preloaded && d->qpe_main_widget )
1552#ifndef QT_NO_COP 1628#ifndef QT_NO_COP
1629
1553 { 1630 {
1554 QCopEnvelope e("QPE/System", "fastAppHiding(QString)" ); 1631 QCopEnvelope e("QPE/System", "fastAppHiding(QString)" );