author | llornkcor <llornkcor> | 2002-09-25 16:26:19 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-09-25 16:26:19 (UTC) |
commit | d44c455b86d6cccbc497e3e8d8aa399096eff7db (patch) (unidiff) | |
tree | 8dd582c828f21ff11a99800159df2b982dbfcc48 | |
parent | a546a6ea143da9244a06f1e40829254e8bf4dc8f (diff) | |
download | opie-d44c455b86d6cccbc497e3e8d8aa399096eff7db.zip opie-d44c455b86d6cccbc497e3e8d8aa399096eff7db.tar.gz opie-d44c455b86d6cccbc497e3e8d8aa399096eff7db.tar.bz2 |
fix qpeDir() to return users dir, not qpeDir.. duh
-rw-r--r-- | library/qpeapplication.cpp | 543 |
1 files changed, 272 insertions, 271 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp index c107a08..bdf67b9 100644 --- a/library/qpeapplication.cpp +++ b/library/qpeapplication.cpp | |||
@@ -85,183 +85,183 @@ | |||
85 | #include <sys/ioctl.h> | 85 | #include <sys/ioctl.h> |
86 | #include <sys/soundcard.h> | 86 | #include <sys/soundcard.h> |
87 | 87 | ||
88 | 88 | ||
89 | class QPEApplicationData { | 89 | class QPEApplicationData { |
90 | public: | 90 | public: |
91 | QPEApplicationData() : presstimer( 0 ), presswidget( 0 ), rightpressed( FALSE ), | 91 | QPEApplicationData() : presstimer( 0 ), presswidget( 0 ), rightpressed( FALSE ), |
92 | kbgrabber( 0 ), kbregrab( FALSE ), notbusysent( FALSE ), preloaded( FALSE ), | 92 | kbgrabber( 0 ), kbregrab( FALSE ), notbusysent( FALSE ), preloaded( FALSE ), |
93 | forceshow( FALSE ), nomaximize( FALSE ), qpe_main_widget( 0 ), | 93 | forceshow( FALSE ), nomaximize( FALSE ), qpe_main_widget( 0 ), |
94 | keep_running( TRUE ) | 94 | keep_running( TRUE ) |
95 | { | 95 | { |
96 | qcopq.setAutoDelete( TRUE ); | 96 | qcopq.setAutoDelete( TRUE ); |
97 | } | 97 | } |
98 | 98 | ||
99 | int presstimer; | 99 | int presstimer; |
100 | QWidget* presswidget; | 100 | QWidget* presswidget; |
101 | QPoint presspos; | 101 | QPoint presspos; |
102 | bool rightpressed : 1; // AEH why not use uint foobar :1; if it's tt style -zecke | 102 | bool rightpressed : 1; // AEH why not use uint foobar :1; if it's tt style -zecke |
103 | int kbgrabber; | 103 | int kbgrabber; |
104 | bool kbregrab : 1; | 104 | bool kbregrab : 1; |
105 | bool notbusysent : 1; | 105 | bool notbusysent : 1; |
106 | QString appName; | 106 | QString appName; |
107 | struct QCopRec { | 107 | struct QCopRec { |
108 | QCopRec( const QCString &ch, const QCString &msg, | 108 | QCopRec( const QCString &ch, const QCString &msg, |
109 | const QByteArray &d ) : | 109 | const QByteArray &d ) : |
110 | channel( ch ), message( msg ), data( d ) { } | 110 | channel( ch ), message( msg ), data( d ) { } |
111 | 111 | ||
112 | QCString channel; | 112 | QCString channel; |
113 | QCString message; | 113 | QCString message; |
114 | QByteArray data; | 114 | QByteArray data; |
115 | }; | 115 | }; |
116 | bool preloaded : 1; | 116 | bool preloaded : 1; |
117 | bool forceshow : 1; | 117 | bool forceshow : 1; |
118 | bool nomaximize : 1; | 118 | bool nomaximize : 1; |
119 | QWidget* qpe_main_widget; | 119 | QWidget* qpe_main_widget; |
120 | bool keep_running : 1; | 120 | bool keep_running : 1; |
121 | QList<QCopRec> qcopq; | 121 | QList<QCopRec> qcopq; |
122 | 122 | ||
123 | void enqueueQCop( const QCString &ch, const QCString &msg, | 123 | void enqueueQCop( const QCString &ch, const QCString &msg, |
124 | const QByteArray &data ) | 124 | const QByteArray &data ) |
125 | { | 125 | { |
126 | qcopq.append( new QCopRec( ch, msg, data ) ); | 126 | qcopq.append( new QCopRec( ch, msg, data ) ); |
127 | } | 127 | } |
128 | void sendQCopQ() { | 128 | void sendQCopQ() { |
129 | QCopRec * r; | 129 | QCopRec * r; |
130 | #ifndef QT_NO_COP | 130 | #ifndef QT_NO_COP |
131 | for ( QListIterator<QCopRec> it( qcopq ); ( r = it.current() ); ++it ) | 131 | for ( QListIterator<QCopRec> it( qcopq ); ( r = it.current() ); ++it ) |
132 | QCopChannel::sendLocally( r->channel, r->message, r->data ); | 132 | QCopChannel::sendLocally( r->channel, r->message, r->data ); |
133 | #endif | 133 | #endif |
134 | qcopq.clear(); | 134 | qcopq.clear(); |
135 | } | 135 | } |
136 | static void show_mx(QWidget* mw, bool nomaximize) { | 136 | static void show_mx(QWidget* mw, bool nomaximize) { |
137 | if ( mw->layout() && mw->inherits("QDialog") ) { | 137 | if ( mw->layout() && mw->inherits("QDialog") ) { |
138 | QPEApplication::showDialog((QDialog*)mw,nomaximize); | 138 | QPEApplication::showDialog((QDialog*)mw,nomaximize); |
139 | } else { | 139 | } else { |
140 | #ifdef Q_WS_QWS | 140 | #ifdef Q_WS_QWS |
141 | if ( !nomaximize ) | 141 | if ( !nomaximize ) |
142 | mw->showMaximized(); | 142 | mw->showMaximized(); |
143 | else | 143 | else |
144 | #endif | 144 | #endif |
145 | mw->show(); | 145 | mw->show(); |
146 | } | 146 | } |
147 | } | 147 | } |
148 | static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) | 148 | static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) |
149 | { | 149 | { |
150 | /* | 150 | /* |
151 | // This works but disable it for now until it is safe to apply | 151 | // This works but disable it for now until it is safe to apply |
152 | // What is does is scan the .desktop files of all the apps for | 152 | // What is does is scan the .desktop files of all the apps for |
153 | // the applnk that has the corresponding argv[0] as this program | 153 | // the applnk that has the corresponding argv[0] as this program |
154 | // then it uses the name stored in the .desktop file as the caption | 154 | // then it uses the name stored in the .desktop file as the caption |
155 | // for the main widget. This saves duplicating translations for | 155 | // for the main widget. This saves duplicating translations for |
156 | // the app name in the program and in the .desktop files. | 156 | // the app name in the program and in the .desktop files. |
157 | 157 | ||
158 | AppLnkSet apps( appsPath ); | 158 | AppLnkSet apps( appsPath ); |
159 | 159 | ||
160 | QList<AppLnk> appsList = apps.children(); | 160 | QList<AppLnk> appsList = apps.children(); |
161 | for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) { | 161 | for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) { |
162 | if ( (*it)->exec() == appName ) { | 162 | if ( (*it)->exec() == appName ) { |
163 | mw->setCaption( (*it)->name() ); | 163 | mw->setCaption( (*it)->name() ); |
164 | return TRUE; | 164 | return TRUE; |
165 | } | 165 | } |
166 | } | 166 | } |
167 | */ | 167 | */ |
168 | return FALSE; | 168 | return FALSE; |
169 | } | 169 | } |
170 | 170 | ||
171 | 171 | ||
172 | void show(QWidget* mw, bool nomax) | 172 | void show(QWidget* mw, bool nomax) |
173 | { | 173 | { |
174 | setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" ); | 174 | setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" ); |
175 | nomaximize = nomax; | 175 | nomaximize = nomax; |
176 | qpe_main_widget = mw; | 176 | qpe_main_widget = mw; |
177 | #ifndef QT_NO_COP | 177 | #ifndef QT_NO_COP |
178 | sendQCopQ(); | 178 | sendQCopQ(); |
179 | #endif | 179 | #endif |
180 | if ( preloaded ) { | 180 | if ( preloaded ) { |
181 | if(forceshow) | 181 | if(forceshow) |
182 | show_mx(mw,nomax); | 182 | show_mx(mw,nomax); |
183 | } else if ( keep_running ) { | 183 | } else if ( keep_running ) { |
184 | show_mx(mw,nomax); | 184 | show_mx(mw,nomax); |
185 | } | 185 | } |
186 | } | 186 | } |
187 | 187 | ||
188 | void loadTextCodecs() | 188 | void loadTextCodecs() |
189 | { | 189 | { |
190 | QString path = QPEApplication::qpeDir() + "/plugins/textcodecs"; | 190 | QString path = QPEApplication::qpeDir() + "/plugins/textcodecs"; |
191 | QDir dir( path, "lib*.so" ); | 191 | QDir dir( path, "lib*.so" ); |
192 | QStringList list = dir.entryList(); | 192 | QStringList list = dir.entryList(); |
193 | QStringList::Iterator it; | 193 | QStringList::Iterator it; |
194 | for ( it = list.begin(); it != list.end(); ++it ) { | 194 | for ( it = list.begin(); it != list.end(); ++it ) { |
195 | TextCodecInterface *iface = 0; | 195 | TextCodecInterface *iface = 0; |
196 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 196 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
197 | if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { | 197 | if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { |
198 | QValueList<int> mibs = iface->mibEnums(); | 198 | QValueList<int> mibs = iface->mibEnums(); |
199 | for (QValueList<int>::ConstIterator i=mibs.begin(); i!=mibs.end(); ++i) { | 199 | for (QValueList<int>::ConstIterator i=mibs.begin(); i!=mibs.end(); ++i) { |
200 | (void)iface->createForMib(*i); | 200 | (void)iface->createForMib(*i); |
201 | // ### it exists now; need to remember if we can delete it | 201 | // ### it exists now; need to remember if we can delete it |
202 | } | 202 | } |
203 | } else { | 203 | } else { |
204 | lib->unload(); | 204 | lib->unload(); |
205 | delete lib; | 205 | delete lib; |
206 | } | 206 | } |
207 | } | 207 | } |
208 | } | 208 | } |
209 | 209 | ||
210 | void loadImageCodecs() | 210 | void loadImageCodecs() |
211 | { | 211 | { |
212 | QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs"; | 212 | QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs"; |
213 | QDir dir( path, "lib*.so" ); | 213 | QDir dir( path, "lib*.so" ); |
214 | QStringList list = dir.entryList(); | 214 | QStringList list = dir.entryList(); |
215 | QStringList::Iterator it; | 215 | QStringList::Iterator it; |
216 | for ( it = list.begin(); it != list.end(); ++it ) { | 216 | for ( it = list.begin(); it != list.end(); ++it ) { |
217 | ImageCodecInterface *iface = 0; | 217 | ImageCodecInterface *iface = 0; |
218 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 218 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
219 | if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { | 219 | if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { |
220 | QStringList formats = iface->keys(); | 220 | QStringList formats = iface->keys(); |
221 | for (QStringList::ConstIterator i=formats.begin(); i!=formats.end(); ++i) { | 221 | for (QStringList::ConstIterator i=formats.begin(); i!=formats.end(); ++i) { |
222 | (void)iface->installIOHandler(*i); | 222 | (void)iface->installIOHandler(*i); |
223 | // ### it exists now; need to remember if we can delete it | 223 | // ### it exists now; need to remember if we can delete it |
224 | } | 224 | } |
225 | } else { | 225 | } else { |
226 | lib->unload(); | 226 | lib->unload(); |
227 | delete lib; | 227 | delete lib; |
228 | } | 228 | } |
229 | } | 229 | } |
230 | } | 230 | } |
231 | QString styleName; | 231 | QString styleName; |
232 | QString decorationName; | 232 | QString decorationName; |
233 | }; | 233 | }; |
234 | 234 | ||
235 | class ResourceMimeFactory : public QMimeSourceFactory { | 235 | class ResourceMimeFactory : public QMimeSourceFactory { |
236 | public: | 236 | public: |
237 | ResourceMimeFactory() | 237 | ResourceMimeFactory() |
238 | { | 238 | { |
239 | setFilePath( Global::helpPath() ); | 239 | setFilePath( Global::helpPath() ); |
240 | setExtensionType( "html", "text/html;charset=UTF-8" ); | 240 | setExtensionType( "html", "text/html;charset=UTF-8" ); |
241 | } | 241 | } |
242 | 242 | ||
243 | const QMimeSource* data( const QString& abs_name ) const | 243 | const QMimeSource* data( const QString& abs_name ) const |
244 | { | 244 | { |
245 | const QMimeSource * r = QMimeSourceFactory::data( abs_name ); | 245 | const QMimeSource * r = QMimeSourceFactory::data( abs_name ); |
246 | if ( !r ) { | 246 | if ( !r ) { |
247 | int sl = abs_name.length(); | 247 | int sl = abs_name.length(); |
248 | do { | 248 | do { |
249 | sl = abs_name.findRev( '/', sl - 1 ); | 249 | sl = abs_name.findRev( '/', sl - 1 ); |
250 | QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name; | 250 | QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name; |
251 | int dot = name.findRev( '.' ); | 251 | int dot = name.findRev( '.' ); |
252 | if ( dot >= 0 ) | 252 | if ( dot >= 0 ) |
253 | name = name.left( dot ); | 253 | name = name.left( dot ); |
254 | QImage img = Resource::loadImage( name ); | 254 | QImage img = Resource::loadImage( name ); |
255 | if ( !img.isNull() ) | 255 | if ( !img.isNull() ) |
256 | r = new QImageDrag( img ); | 256 | r = new QImageDrag( img ); |
257 | } | 257 | } |
258 | while ( !r && sl > 0 ); | 258 | while ( !r && sl > 0 ); |
259 | } | 259 | } |
260 | return r; | 260 | return r; |
261 | } | 261 | } |
262 | }; | 262 | }; |
263 | 263 | ||
264 | static int muted = 0; | 264 | static int muted = 0; |
265 | static int micMuted = 0; | 265 | static int micMuted = 0; |
266 | 266 | ||
267 | static void setVolume( int t = 0, int percent = -1 ) | 267 | static void setVolume( int t = 0, int percent = -1 ) |
@@ -517,13 +517,13 @@ QPEApplication::QPEApplication( int & argc, char **argv, Type t ) | |||
517 | 517 | ||
518 | /* overide stored arguments */ | 518 | /* overide stored arguments */ |
519 | setArgs( argc, argv ); | 519 | setArgs( argc, argv ); |
520 | 520 | ||
521 | #endif | 521 | #endif |
522 | 522 | ||
523 | //qwsSetDecoration( new QPEDecoration() ); | 523 | // qwsSetDecoration( new QPEDecoration() ); |
524 | 524 | ||
525 | #ifndef QT_NO_TRANSLATION | 525 | #ifndef QT_NO_TRANSLATION |
526 | 526 | ||
527 | QStringList langs = Global::languageList(); | 527 | QStringList langs = Global::languageList(); |
528 | for ( QStringList::ConstIterator it = langs.begin(); it != langs.end(); ++it ) { | 528 | for ( QStringList::ConstIterator it = langs.begin(); it != langs.end(); ++it ) { |
529 | QString lang = *it; | 529 | QString lang = *it; |
@@ -542,18 +542,18 @@ QPEApplication::QPEApplication( int & argc, char **argv, Type t ) | |||
542 | tfn = qpeDir() + "/i18n/" + lang + "/" + d->appName + ".qm"; | 542 | tfn = qpeDir() + "/i18n/" + lang + "/" + d->appName + ".qm"; |
543 | if ( trans->load( tfn ) ) | 543 | if ( trans->load( tfn ) ) |
544 | installTranslator( trans ); | 544 | installTranslator( trans ); |
545 | else | 545 | else |
546 | delete trans; | 546 | delete trans; |
547 | 547 | ||
548 | //###language/font hack; should look it up somewhere | 548 | //###language/font hack; should look it up somewhere |
549 | #ifdef QWS | 549 | #ifdef QWS |
550 | if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) { | 550 | if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) { |
551 | QFont fn = FontManager::unicodeFont( FontManager::Proportional ); | 551 | QFont fn = FontManager::unicodeFont( FontManager::Proportional ); |
552 | setFont( fn ); | 552 | setFont( fn ); |
553 | } | 553 | } |
554 | #endif | 554 | #endif |
555 | } | 555 | } |
556 | #endif | 556 | #endif |
557 | 557 | ||
558 | applyStyle(); | 558 | applyStyle(); |
559 | 559 | ||
@@ -801,16 +801,17 @@ QString QPEApplication::qpeDir() | |||
801 | 801 | ||
802 | return QString( "../" ); | 802 | return QString( "../" ); |
803 | } | 803 | } |
804 | 804 | ||
805 | /*! | 805 | /*! |
806 | Returns the user's current Document directory. There is a trailing "/". | 806 | Returns the user's current Document directory. There is a trailing "/". |
807 | .. well, it does now,, and there's no trailing '/' | ||
807 | */ | 808 | */ |
808 | QString QPEApplication::documentDir() | 809 | QString QPEApplication::documentDir() |
809 | { | 810 | { |
810 | return QString( qpeDir() + "Documents"); | 811 | return QString( QDir::homeDirPath() + "/Documents"); |
811 | } | 812 | } |
812 | 813 | ||
813 | static int deforient = -1; | 814 | static int deforient = -1; |
814 | 815 | ||
815 | /*! | 816 | /*! |
816 | \internal | 817 | \internal |
@@ -855,39 +856,39 @@ void QPEApplication::setDefaultRotation( int r ) | |||
855 | 856 | ||
856 | /*! | 857 | /*! |
857 | \internal | 858 | \internal |
858 | */ | 859 | */ |
859 | void QPEApplication::applyStyle() | 860 | void QPEApplication::applyStyle() |
860 | { | 861 | { |
861 | Config config( "qpe" ); | 862 | Config config( "qpe" ); |
862 | 863 | ||
863 | config.setGroup( "Appearance" ); | 864 | config.setGroup( "Appearance" ); |
864 | 865 | ||
865 | // Widget style | 866 | // Widget style |
866 | QString style = config.readEntry( "Style", "Light" ); | 867 | QString style = config.readEntry( "Style", "Light" ); |
867 | internalSetStyle( style ); | 868 | internalSetStyle( style ); |
868 | 869 | ||
869 | // Colors | 870 | // Colors |
870 | QColor bgcolor( config.readEntry( "Background", "#E5E1D5" ) ); | 871 | QColor bgcolor( config.readEntry( "Background", "#E5E1D5" ) ); |
871 | QColor btncolor( config.readEntry( "Button", "#D6CDBB" ) ); | 872 | QColor btncolor( config.readEntry( "Button", "#D6CDBB" ) ); |
872 | QPalette pal( btncolor, bgcolor ); | 873 | QPalette pal( btncolor, bgcolor ); |
873 | QString color = config.readEntry( "Highlight", "#800000" ); | 874 | QString color = config.readEntry( "Highlight", "#800000" ); |
874 | pal.setColor( QColorGroup::Highlight, QColor( color ) ); | 875 | pal.setColor( QColorGroup::Highlight, QColor( color ) ); |
875 | color = config.readEntry( "HighlightedText", "#FFFFFF" ); | 876 | color = config.readEntry( "HighlightedText", "#FFFFFF" ); |
876 | pal.setColor( QColorGroup::HighlightedText, QColor( color ) ); | 877 | pal.setColor( QColorGroup::HighlightedText, QColor( color ) ); |
877 | color = config.readEntry( "Text", "#000000" ); | 878 | color = config.readEntry( "Text", "#000000" ); |
878 | pal.setColor( QColorGroup::Text, QColor( color ) ); | 879 | pal.setColor( QColorGroup::Text, QColor( color ) ); |
879 | color = config.readEntry( "ButtonText", "#000000" ); | 880 | color = config.readEntry( "ButtonText", "#000000" ); |
880 | pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) ); | 881 | pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) ); |
881 | color = config.readEntry( "Base", "#FFFFFF" ); | 882 | color = config.readEntry( "Base", "#FFFFFF" ); |
882 | pal.setColor( QColorGroup::Base, QColor( color ) ); | 883 | pal.setColor( QColorGroup::Base, QColor( color ) ); |
883 | 884 | ||
884 | pal.setColor( QPalette::Disabled, QColorGroup::Text, | 885 | pal.setColor( QPalette::Disabled, QColorGroup::Text, |
885 | pal.color( QPalette::Active, QColorGroup::Background ).dark() ); | 886 | pal.color( QPalette::Active, QColorGroup::Background ).dark() ); |
886 | 887 | ||
887 | setPalette( pal, TRUE ); | 888 | setPalette( pal, TRUE ); |
888 | 889 | ||
889 | // Window Decoration | 890 | // Window Decoration |
890 | QString dec = config.readEntry( "Decoration", "Qtopia" ); | 891 | QString dec = config.readEntry( "Decoration", "Qtopia" ); |
891 | if ( dec != d->decorationName ) { | 892 | if ( dec != d->decorationName ) { |
892 | qwsSetDecoration( new QPEDecoration( dec ) ); | 893 | qwsSetDecoration( new QPEDecoration( dec ) ); |
893 | d->decorationName = dec; | 894 | d->decorationName = dec; |
@@ -1024,91 +1025,91 @@ bool QPEApplication::raiseAppropriateWindow() | |||
1024 | bool r=FALSE; | 1025 | bool r=FALSE; |
1025 | // ########## raise()ing main window should raise and set active | 1026 | // ########## raise()ing main window should raise and set active |
1026 | // ########## it and then all childen. This belongs in Qt/Embedded | 1027 | // ########## it and then all childen. This belongs in Qt/Embedded |
1027 | QWidget *top = d->qpe_main_widget; | 1028 | QWidget *top = d->qpe_main_widget; |
1028 | if ( !top ) top =mainWidget(); | 1029 | if ( !top ) top =mainWidget(); |
1029 | if ( top && d->keep_running ) { | 1030 | if ( top && d->keep_running ) { |
1030 | if ( top->isVisible() ) | 1031 | if ( top->isVisible() ) |
1031 | r = TRUE; | 1032 | r = TRUE; |
1032 | else if (d->preloaded) { | 1033 | else if (d->preloaded) { |
1033 | // We are preloaded and not visible.. pretend we just started.. | 1034 | // We are preloaded and not visible.. pretend we just started.. |
1034 | QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); | 1035 | QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); |
1035 | e << d->appName; | 1036 | e << d->appName; |
1036 | } | 1037 | } |
1037 | 1038 | ||
1038 | d->show_mx(top,d->nomaximize); | 1039 | d->show_mx(top,d->nomaximize); |
1039 | top->raise(); | 1040 | top->raise(); |
1040 | top->setActiveWindow(); | 1041 | top->setActiveWindow(); |
1041 | } | 1042 | } |
1042 | QWidget *topm = activeModalWidget(); | 1043 | QWidget *topm = activeModalWidget(); |
1043 | if ( topm && topm != top ) { | 1044 | if ( topm && topm != top ) { |
1044 | topm->show(); | 1045 | topm->show(); |
1045 | topm->raise(); | 1046 | topm->raise(); |
1046 | topm->setActiveWindow(); | 1047 | topm->setActiveWindow(); |
1047 | // If we haven't already handled the fastAppShowing message | 1048 | // If we haven't already handled the fastAppShowing message |
1048 | if (!top && d->preloaded) { | 1049 | if (!top && d->preloaded) { |
1049 | QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); | 1050 | QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); |
1050 | e << d->appName; | 1051 | e << d->appName; |
1051 | } | 1052 | } |
1052 | r = FALSE; | 1053 | r = FALSE; |
1053 | } | 1054 | } |
1054 | return r; | 1055 | return r; |
1055 | } | 1056 | } |
1056 | 1057 | ||
1057 | void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data) | 1058 | void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data) |
1058 | { | 1059 | { |
1059 | #ifdef Q_WS_QWS | 1060 | #ifdef Q_WS_QWS |
1060 | 1061 | ||
1061 | if ( msg == "quit()" ) { | 1062 | if ( msg == "quit()" ) { |
1062 | tryQuit(); | 1063 | tryQuit(); |
1063 | } else if ( msg == "quitIfInvisible()" ) { | 1064 | } else if ( msg == "quitIfInvisible()" ) { |
1064 | if ( d->qpe_main_widget && !d->qpe_main_widget->isVisible() ) | 1065 | if ( d->qpe_main_widget && !d->qpe_main_widget->isVisible() ) |
1065 | quit(); | 1066 | quit(); |
1066 | } else if ( msg == "close()" ) { | 1067 | } else if ( msg == "close()" ) { |
1067 | hideOrQuit(); | 1068 | hideOrQuit(); |
1068 | } else if ( msg == "disablePreload()" ) { | 1069 | } else if ( msg == "disablePreload()" ) { |
1069 | d->preloaded = FALSE; | 1070 | d->preloaded = FALSE; |
1070 | d->keep_running = TRUE; | 1071 | d->keep_running = TRUE; |
1071 | /* so that quit will quit */ | 1072 | /* so that quit will quit */ |
1072 | } else if ( msg == "enablePreload()" ) { | 1073 | } else if ( msg == "enablePreload()" ) { |
1073 | if (d->qpe_main_widget) | 1074 | if (d->qpe_main_widget) |
1074 | d->preloaded = TRUE; | 1075 | d->preloaded = TRUE; |
1075 | d->keep_running = TRUE; | 1076 | d->keep_running = TRUE; |
1076 | /* so next quit won't quit */ | 1077 | /* so next quit won't quit */ |
1077 | } else if ( msg == "raise()" ) { | 1078 | } else if ( msg == "raise()" ) { |
1078 | d->keep_running = TRUE; | 1079 | d->keep_running = TRUE; |
1079 | d->notbusysent = FALSE; | 1080 | d->notbusysent = FALSE; |
1080 | raiseAppropriateWindow(); | 1081 | raiseAppropriateWindow(); |
1081 | // Tell the system we're still chugging along... | 1082 | // Tell the system we're still chugging along... |
1082 | QCopEnvelope e("QPE/System", "appRaised(QString)"); | 1083 | QCopEnvelope e("QPE/System", "appRaised(QString)"); |
1083 | e << d->appName; | 1084 | e << d->appName; |
1084 | } else if ( msg == "flush()" ) { | 1085 | } else if ( msg == "flush()" ) { |
1085 | emit flush(); | 1086 | emit flush(); |
1086 | // we need to tell the desktop | 1087 | // we need to tell the desktop |
1087 | QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" ); | 1088 | QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" ); |
1088 | e << d->appName; | 1089 | e << d->appName; |
1089 | } else if ( msg == "reload()" ) { | 1090 | } else if ( msg == "reload()" ) { |
1090 | emit reload(); | 1091 | emit reload(); |
1091 | } else if ( msg == "setDocument(QString)" ) { | 1092 | } else if ( msg == "setDocument(QString)" ) { |
1092 | d->keep_running = TRUE; | 1093 | d->keep_running = TRUE; |
1093 | QDataStream stream( data, IO_ReadOnly ); | 1094 | QDataStream stream( data, IO_ReadOnly ); |
1094 | QString doc; | 1095 | QString doc; |
1095 | stream >> doc; | 1096 | stream >> doc; |
1096 | QWidget *mw = mainWidget(); | 1097 | QWidget *mw = mainWidget(); |
1097 | if ( !mw ) | 1098 | if ( !mw ) |
1098 | mw = d->qpe_main_widget; | 1099 | mw = d->qpe_main_widget; |
1099 | if ( mw ) | 1100 | if ( mw ) |
1100 | Global::setDocument( mw, doc ); | 1101 | Global::setDocument( mw, doc ); |
1101 | } else if ( msg == "nextView()" ) { | 1102 | } else if ( msg == "nextView()" ) { |
1102 | qDebug("got nextView()"); | 1103 | qDebug("got nextView()"); |
1103 | /* | 1104 | /* |
1104 | if ( raiseAppropriateWindow() ) | 1105 | if ( raiseAppropriateWindow() ) |
1105 | */ | 1106 | */ |
1106 | emit appMessage( msg, data); | 1107 | emit appMessage( msg, data); |
1107 | } else { | 1108 | } else { |
1108 | emit appMessage( msg, data); | 1109 | emit appMessage( msg, data); |
1109 | } | 1110 | } |
1110 | 1111 | ||
1111 | #endif | 1112 | #endif |
1112 | } | 1113 | } |
1113 | 1114 | ||
1114 | 1115 | ||
@@ -1166,13 +1167,13 @@ void QPEApplication::setKeepRunning() | |||
1166 | current list of qcop messages; otherwise returns FALSE. | 1167 | current list of qcop messages; otherwise returns FALSE. |
1167 | 1168 | ||
1168 | \sa setKeepRunning() | 1169 | \sa setKeepRunning() |
1169 | */ | 1170 | */ |
1170 | bool QPEApplication::keepRunning() const | 1171 | bool QPEApplication::keepRunning() const |
1171 | { | 1172 | { |
1172 | return d->keep_running; | 1173 | return d->keep_running; |
1173 | } | 1174 | } |
1174 | 1175 | ||
1175 | /*! | 1176 | /*! |
1176 | \internal | 1177 | \internal |
1177 | */ | 1178 | */ |
1178 | void QPEApplication::internalSetStyle( const QString &style ) | 1179 | void QPEApplication::internalSetStyle( const QString &style ) |
@@ -1348,68 +1349,68 @@ void QPEApplication::setStylusOperation( QWidget * w, StylusMode mode ) | |||
1348 | */ | 1349 | */ |
1349 | bool QPEApplication::eventFilter( QObject *o, QEvent *e ) | 1350 | bool QPEApplication::eventFilter( QObject *o, QEvent *e ) |
1350 | { | 1351 | { |
1351 | if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) { | 1352 | if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) { |
1352 | QMouseEvent * me = ( QMouseEvent* ) e; | 1353 | QMouseEvent * me = ( QMouseEvent* ) e; |
1353 | StylusMode mode = (StylusMode)(int)stylusDict->find(o); | 1354 | StylusMode mode = (StylusMode)(int)stylusDict->find(o); |
1354 | switch (mode) { | 1355 | switch (mode) { |
1355 | case RightOnHold: | 1356 | case RightOnHold: |
1356 | switch ( me->type() ) { | 1357 | switch ( me->type() ) { |
1357 | case QEvent::MouseButtonPress: | 1358 | case QEvent::MouseButtonPress: |
1358 | if ( me->button() == LeftButton ) { | 1359 | if ( me->button() == LeftButton ) { |
1359 | d->presstimer = startTimer(500); // #### pref. | 1360 | d->presstimer = startTimer(500); // #### pref. |
1360 | d->presswidget = (QWidget*)o; | 1361 | d->presswidget = (QWidget*)o; |
1361 | d->presspos = me->pos(); | 1362 | d->presspos = me->pos(); |
1362 | d->rightpressed = FALSE; | 1363 | d->rightpressed = FALSE; |
1363 | } | 1364 | } |
1364 | break; | 1365 | break; |
1365 | case QEvent::MouseMove: | 1366 | case QEvent::MouseMove: |
1366 | if (d->presstimer && (me->pos()-d->presspos).manhattanLength() > 8) { | 1367 | if (d->presstimer && (me->pos()-d->presspos).manhattanLength() > 8) { |
1367 | killTimer(d->presstimer); | 1368 | killTimer(d->presstimer); |
1368 | d->presstimer = 0; | 1369 | d->presstimer = 0; |
1369 | } | 1370 | } |
1370 | break; | 1371 | break; |
1371 | case QEvent::MouseButtonRelease: | 1372 | case QEvent::MouseButtonRelease: |
1372 | if ( me->button() == LeftButton ) { | 1373 | if ( me->button() == LeftButton ) { |
1373 | if ( d->presstimer ) { | 1374 | if ( d->presstimer ) { |
1374 | killTimer(d->presstimer); | 1375 | killTimer(d->presstimer); |
1375 | d->presstimer = 0; | 1376 | d->presstimer = 0; |
1376 | } | 1377 | } |
1377 | if ( d->rightpressed && d->presswidget ) { | 1378 | if ( d->rightpressed && d->presswidget ) { |
1378 | // Right released | 1379 | // Right released |
1379 | postEvent( d->presswidget, | 1380 | postEvent( d->presswidget, |
1380 | new QMouseEvent( QEvent::MouseButtonRelease, me->pos(), | 1381 | new QMouseEvent( QEvent::MouseButtonRelease, me->pos(), |
1381 | RightButton, LeftButton+RightButton ) ); | 1382 | RightButton, LeftButton+RightButton ) ); |
1382 | // Left released, off-widget | 1383 | // Left released, off-widget |
1383 | postEvent( d->presswidget, | 1384 | postEvent( d->presswidget, |
1384 | new QMouseEvent( QEvent::MouseMove, QPoint(-1,-1), | 1385 | new QMouseEvent( QEvent::MouseMove, QPoint(-1,-1), |
1385 | LeftButton, LeftButton ) ); | 1386 | LeftButton, LeftButton ) ); |
1386 | postEvent( d->presswidget, | 1387 | postEvent( d->presswidget, |
1387 | new QMouseEvent( QEvent::MouseButtonRelease, QPoint(-1,-1), | 1388 | new QMouseEvent( QEvent::MouseButtonRelease, QPoint(-1,-1), |
1388 | LeftButton, LeftButton ) ); | 1389 | LeftButton, LeftButton ) ); |
1389 | d->rightpressed = FALSE; | 1390 | d->rightpressed = FALSE; |
1390 | return TRUE; // don't send the real Left release | 1391 | return TRUE; // don't send the real Left release |
1391 | } | 1392 | } |
1392 | } | 1393 | } |
1393 | break; | 1394 | break; |
1394 | default: | 1395 | default: |
1395 | break; | 1396 | break; |
1396 | } | 1397 | } |
1397 | break; | 1398 | break; |
1398 | default: | 1399 | default: |
1399 | ; | 1400 | ; |
1400 | } | 1401 | } |
1401 | }else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { | 1402 | }else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { |
1402 | QKeyEvent *ke = (QKeyEvent *)e; | 1403 | QKeyEvent *ke = (QKeyEvent *)e; |
1403 | if ( ke->key() == Key_Enter ) { | 1404 | if ( ke->key() == Key_Enter ) { |
1404 | if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) { | 1405 | if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) { |
1405 | postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ', | 1406 | postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ', |
1406 | ke->state(), " ", ke->isAutoRepeat(), ke->count() ) ); | 1407 | ke->state(), " ", ke->isAutoRepeat(), ke->count() ) ); |
1407 | return TRUE; | 1408 | return TRUE; |
1408 | } | 1409 | } |
1409 | } | 1410 | } |
1410 | } | 1411 | } |
1411 | return FALSE; | 1412 | return FALSE; |
1412 | } | 1413 | } |
1413 | 1414 | ||
1414 | /*! | 1415 | /*! |
1415 | \reimp | 1416 | \reimp |
@@ -1427,13 +1428,13 @@ void QPEApplication::timerEvent( QTimerEvent *e ) | |||
1427 | } | 1428 | } |
1428 | } | 1429 | } |
1429 | 1430 | ||
1430 | void QPEApplication::removeSenderFromStylusDict() | 1431 | void QPEApplication::removeSenderFromStylusDict() |
1431 | { | 1432 | { |
1432 | stylusDict->remove | 1433 | stylusDict->remove |
1433 | ( ( void* ) sender() ); | 1434 | ( ( void* ) sender() ); |
1434 | if ( d->presswidget == sender() ) | 1435 | if ( d->presswidget == sender() ) |
1435 | d->presswidget = 0; | 1436 | d->presswidget = 0; |
1436 | } | 1437 | } |
1437 | 1438 | ||
1438 | /*! | 1439 | /*! |
1439 | \internal | 1440 | \internal |
@@ -1538,15 +1539,15 @@ void QPEApplication::hideOrQuit() | |||
1538 | 1539 | ||
1539 | // If we are a preloaded application we don't actually quit, so emit | 1540 | // If we are a preloaded application we don't actually quit, so emit |
1540 | // a System message indicating we're quasi-closing. | 1541 | // a System message indicating we're quasi-closing. |
1541 | if ( d->preloaded && d->qpe_main_widget ) | 1542 | if ( d->preloaded && d->qpe_main_widget ) |
1542 | #ifndef QT_NO_COP | 1543 | #ifndef QT_NO_COP |
1543 | { | 1544 | { |
1544 | QCopEnvelope e("QPE/System", "fastAppHiding(QString)" ); | 1545 | QCopEnvelope e("QPE/System", "fastAppHiding(QString)" ); |
1545 | e << d->appName; | 1546 | e << d->appName; |
1546 | d->qpe_main_widget->hide(); | 1547 | d->qpe_main_widget->hide(); |
1547 | } | 1548 | } |
1548 | #endif | 1549 | #endif |
1549 | else | 1550 | else |
1550 | quit(); | 1551 | quit(); |
1551 | } | 1552 | } |
1552 | 1553 | ||