author | zecke <zecke> | 2003-10-04 07:23:27 (UTC) |
---|---|---|
committer | zecke <zecke> | 2003-10-04 07:23:27 (UTC) |
commit | 271ba635536db4a9f4ae1e575194d0f388b1c991 (patch) (unidiff) | |
tree | dbd2664b1a6422c6195a3b4eb17b591ff82a4499 | |
parent | a4793f5226e9eb5c8a718cca9335c23530e08b08 (diff) | |
download | opie-271ba635536db4a9f4ae1e575194d0f388b1c991.zip opie-271ba635536db4a9f4ae1e575194d0f388b1c991.tar.gz opie-271ba635536db4a9f4ae1e575194d0f388b1c991.tar.bz2 |
merges of qcopQok
and QPIxmapCache 'calibration' for PDA needs
-rw-r--r-- | library/qpeapplication.cpp | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp index 0e469ae..28fb13a 100644 --- a/library/qpeapplication.cpp +++ b/library/qpeapplication.cpp | |||
@@ -1,2058 +1,2068 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | */ | 19 | */ |
20 | #define QTOPIA_INTERNAL_LANGLIST | 20 | #define QTOPIA_INTERNAL_LANGLIST |
21 | #include <stdlib.h> | 21 | #include <stdlib.h> |
22 | #include <unistd.h> | 22 | #include <unistd.h> |
23 | #include <linux/limits.h> // needed for some toolchains (PATH_MAX) | 23 | #include <linux/limits.h> // needed for some toolchains (PATH_MAX) |
24 | #include <qfile.h> | 24 | #include <qfile.h> |
25 | #include <qqueue.h> | 25 | #include <qqueue.h> |
26 | #ifdef Q_WS_QWS | 26 | #ifdef Q_WS_QWS |
27 | #ifndef QT_NO_COP | 27 | #ifndef QT_NO_COP |
28 | #if QT_VERSION <= 231 | 28 | #if QT_VERSION <= 231 |
29 | #define private public | 29 | #define private public |
30 | #define sendLocally processEvent | 30 | #define sendLocally processEvent |
31 | #include "qcopenvelope_qws.h" | 31 | #include "qcopenvelope_qws.h" |
32 | #undef private | 32 | #undef private |
33 | #else | 33 | #else |
34 | #include "qcopenvelope_qws.h" | 34 | #include "qcopenvelope_qws.h" |
35 | #endif | 35 | #endif |
36 | #endif | 36 | #endif |
37 | #include <qwindowsystem_qws.h> | 37 | #include <qwindowsystem_qws.h> |
38 | #endif | 38 | #endif |
39 | #include <qtextstream.h> | 39 | #include <qtextstream.h> |
40 | #include <qpalette.h> | 40 | #include <qpalette.h> |
41 | #include <qbuffer.h> | 41 | #include <qbuffer.h> |
42 | #include <qptrdict.h> | 42 | #include <qptrdict.h> |
43 | #include <qregexp.h> | 43 | #include <qregexp.h> |
44 | #include <qdir.h> | 44 | #include <qdir.h> |
45 | #include <qlabel.h> | 45 | #include <qlabel.h> |
46 | #include <qdialog.h> | 46 | #include <qdialog.h> |
47 | #include <qdragobject.h> | 47 | #include <qdragobject.h> |
48 | #include <qtextcodec.h> | 48 | #include <qtextcodec.h> |
49 | #include <qevent.h> | 49 | #include <qevent.h> |
50 | #include <qtooltip.h> | 50 | #include <qtooltip.h> |
51 | #include <qsignal.h> | 51 | #include <qsignal.h> |
52 | #include <qmainwindow.h> | 52 | #include <qmainwindow.h> |
53 | #include <qwidgetlist.h> | 53 | #include <qwidgetlist.h> |
54 | #include <qpixmapcache.h> | ||
54 | 55 | ||
55 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 56 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
56 | #define QTOPIA_INTERNAL_INITAPP | 57 | #define QTOPIA_INTERNAL_INITAPP |
57 | #include "qpeapplication.h" | 58 | #include "qpeapplication.h" |
58 | #include "qpestyle.h" | 59 | #include "qpestyle.h" |
59 | #include "styleinterface.h" | 60 | #include "styleinterface.h" |
60 | #if QT_VERSION >= 300 | 61 | #if QT_VERSION >= 300 |
61 | #include <qstylefactory.h> | 62 | #include <qstylefactory.h> |
62 | #else | 63 | #else |
63 | #include <qplatinumstyle.h> | 64 | #include <qplatinumstyle.h> |
64 | #include <qwindowsstyle.h> | 65 | #include <qwindowsstyle.h> |
65 | #include <qmotifstyle.h> | 66 | #include <qmotifstyle.h> |
66 | #include <qmotifplusstyle.h> | 67 | #include <qmotifplusstyle.h> |
67 | #include "lightstyle.h" | 68 | #include "lightstyle.h" |
68 | 69 | ||
69 | #include <qpe/qlibrary.h> | 70 | #include <qpe/qlibrary.h> |
70 | #endif | 71 | #endif |
71 | #include "global.h" | 72 | #include "global.h" |
72 | #include "resource.h" | 73 | #include "resource.h" |
73 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) | 74 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) |
74 | #include "qutfcodec.h" | 75 | #include "qutfcodec.h" |
75 | #endif | 76 | #endif |
76 | #include "config.h" | 77 | #include "config.h" |
77 | #include "network.h" | 78 | #include "network.h" |
78 | #ifdef QWS | 79 | #ifdef QWS |
79 | #include "fontmanager.h" | 80 | #include "fontmanager.h" |
80 | #endif | 81 | #endif |
81 | 82 | ||
82 | #include "alarmserver.h" | 83 | #include "alarmserver.h" |
83 | #include "applnk.h" | 84 | #include "applnk.h" |
84 | #include "qpemenubar.h" | 85 | #include "qpemenubar.h" |
85 | #include "textcodecinterface.h" | 86 | #include "textcodecinterface.h" |
86 | #include "imagecodecinterface.h" | 87 | #include "imagecodecinterface.h" |
87 | 88 | ||
88 | #include <unistd.h> | 89 | #include <unistd.h> |
89 | #include <sys/file.h> | 90 | #include <sys/file.h> |
90 | #include <sys/ioctl.h> | 91 | #include <sys/ioctl.h> |
91 | #include <sys/soundcard.h> | 92 | #include <sys/soundcard.h> |
92 | 93 | ||
93 | #include "qt_override_p.h" | 94 | #include "qt_override_p.h" |
94 | 95 | ||
95 | 96 | ||
96 | class QPEApplicationData | 97 | class QPEApplicationData |
97 | { | 98 | { |
98 | public: | 99 | public: |
99 | QPEApplicationData ( ) | 100 | QPEApplicationData ( ) |
100 | : presstimer( 0 ), presswidget( 0 ), rightpressed( false ), kbgrabbed( false ), | 101 | : presstimer( 0 ), presswidget( 0 ), rightpressed( false ), kbgrabbed( false ), |
101 | notbusysent( false ), preloaded( false ), forceshow( false ), nomaximize( false ), | 102 | notbusysent( false ), preloaded( false ), forceshow( false ), nomaximize( false ), |
102 | keep_running( true ), qpe_main_widget( 0 ), qcopQok( false ) | 103 | keep_running( true ), qcopQok( false ), qpe_main_widget( 0 ) |
103 | 104 | ||
104 | {} | 105 | {} |
105 | 106 | ||
106 | int presstimer; | 107 | int presstimer; |
107 | QWidget* presswidget; | 108 | QWidget* presswidget; |
108 | QPoint presspos; | 109 | QPoint presspos; |
109 | 110 | ||
110 | bool rightpressed : 1; | 111 | bool rightpressed : 1; |
111 | bool kbgrabbed : 1; | 112 | bool kbgrabbed : 1; |
112 | bool notbusysent : 1; | 113 | bool notbusysent : 1; |
113 | bool preloaded : 1; | 114 | bool preloaded : 1; |
114 | bool forceshow : 1; | 115 | bool forceshow : 1; |
115 | bool nomaximize : 1; | 116 | bool nomaximize : 1; |
116 | bool qcopQok : 1; | ||
117 | bool keep_running : 1; | 117 | bool keep_running : 1; |
118 | bool qcopQok : 1; | ||
118 | 119 | ||
119 | 120 | ||
120 | QStringList langs; | 121 | QStringList langs; |
121 | QString appName; | 122 | QString appName; |
122 | struct QCopRec | 123 | struct QCopRec |
123 | { | 124 | { |
124 | QCopRec( const QCString &ch, const QCString &msg, | 125 | QCopRec( const QCString &ch, const QCString &msg, |
125 | const QByteArray &d ) : | 126 | const QByteArray &d ) : |
126 | channel( ch ), message( msg ), data( d ) | 127 | channel( ch ), message( msg ), data( d ) |
127 | { } | 128 | { } |
128 | 129 | ||
129 | QCString channel; | 130 | QCString channel; |
130 | QCString message; | 131 | QCString message; |
131 | QByteArray data; | 132 | QByteArray data; |
132 | }; | 133 | }; |
133 | QWidget* qpe_main_widget; | 134 | QWidget* qpe_main_widget; |
134 | QGuardedPtr<QWidget> lastraised; | 135 | QGuardedPtr<QWidget> lastraised; |
135 | QQueue<QCopRec> qcopq; | 136 | QQueue<QCopRec> qcopq; |
136 | QString styleName; | 137 | QString styleName; |
137 | QString decorationName; | 138 | QString decorationName; |
138 | 139 | ||
139 | void enqueueQCop( const QCString &ch, const QCString &msg, | 140 | void enqueueQCop( const QCString &ch, const QCString &msg, |
140 | const QByteArray &data ) | 141 | const QByteArray &data ) |
141 | { | 142 | { |
142 | qcopq.enqueue( new QCopRec( ch, msg, data ) ); | 143 | qcopq.enqueue( new QCopRec( ch, msg, data ) ); |
143 | } | 144 | } |
144 | void sendQCopQ() | 145 | void sendQCopQ() |
145 | { | 146 | { |
146 | if (!qcopQok ) | 147 | if (!qcopQok ) |
147 | return; | 148 | return; |
148 | 149 | ||
149 | QCopRec * r; | 150 | QCopRec * r; |
150 | 151 | ||
151 | while((r=qcopq.dequeue())) { | 152 | while((r=qcopq.dequeue())) { |
152 | // remove from queue before sending... | 153 | // remove from queue before sending... |
153 | // event loop can come around again before getting | 154 | // event loop can come around again before getting |
154 | // back from sendLocally | 155 | // back from sendLocally |
155 | #ifndef QT_NO_COP | 156 | #ifndef QT_NO_COP |
156 | QCopChannel::sendLocally( r->channel, r->message, r->data ); | 157 | QCopChannel::sendLocally( r->channel, r->message, r->data ); |
157 | #endif | 158 | #endif |
158 | 159 | ||
159 | delete r; | 160 | delete r; |
160 | } | 161 | } |
161 | } | 162 | } |
162 | static void show_mx(QWidget* mw, bool nomaximize, const QString & = QString::null ) | 163 | static void show_mx(QWidget* mw, bool nomaximize, const QString & = QString::null ) |
163 | { | 164 | { |
164 | 165 | ||
165 | // ugly hack, remove that later after finding a sane solution | 166 | // ugly hack, remove that later after finding a sane solution |
166 | // Addendum: Only Sharp currently has models with high resolution but (physically) small displays, | 167 | // Addendum: Only Sharp currently has models with high resolution but (physically) small displays, |
167 | // so this is only useful if QT_QWS_SIMPAD is NOT defined. E.g. SIMpad has 800x600 but has | 168 | // so this is only useful if QT_QWS_SIMPAD is NOT defined. E.g. SIMpad has 800x600 but has |
168 | // a (physically) large enough display to use the small icons | 169 | // a (physically) large enough display to use the small icons |
169 | #ifndef QT_QWS_SIMPAD | 170 | #ifndef QT_QWS_SIMPAD |
170 | if ( QPEApplication::desktop() ->width() >= 600 && ( mw->inherits("QMainWindow") || mw->isA("QMainWindow") ) ) { | 171 | if ( QPEApplication::desktop() ->width() >= 600 && ( mw->inherits("QMainWindow") || mw->isA("QMainWindow") ) ) { |
171 | ( ( QMainWindow* ) mw )->setUsesBigPixmaps( true ); | 172 | ( ( QMainWindow* ) mw )->setUsesBigPixmaps( true ); |
172 | } | 173 | } |
173 | #endif | 174 | #endif |
174 | 175 | ||
175 | if ( mw->layout() && mw->inherits("QDialog") ) { | 176 | if ( mw->layout() && mw->inherits("QDialog") ) { |
176 | QPEApplication::showDialog((QDialog*)mw, nomaximize); | 177 | QPEApplication::showDialog((QDialog*)mw, nomaximize); |
177 | } | 178 | } |
178 | else { | 179 | else { |
179 | #ifdef Q_WS_QWS | 180 | #ifdef Q_WS_QWS |
180 | if ( !nomaximize ) | 181 | if ( !nomaximize ) |
181 | mw->showMaximized(); | 182 | mw->showMaximized(); |
182 | else | 183 | else |
183 | #endif | 184 | #endif |
184 | 185 | ||
185 | mw->show(); | 186 | mw->show(); |
186 | } | 187 | } |
187 | } | 188 | } |
188 | static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) | 189 | static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) |
189 | { | 190 | { |
190 | /* | 191 | /* |
191 | // This works but disable it for now until it is safe to apply | 192 | // This works but disable it for now until it is safe to apply |
192 | // What is does is scan the .desktop files of all the apps for | 193 | // What is does is scan the .desktop files of all the apps for |
193 | // the applnk that has the corresponding argv[0] as this program | 194 | // the applnk that has the corresponding argv[0] as this program |
194 | // then it uses the name stored in the .desktop file as the caption | 195 | // then it uses the name stored in the .desktop file as the caption |
195 | // for the main widget. This saves duplicating translations for | 196 | // for the main widget. This saves duplicating translations for |
196 | // the app name in the program and in the .desktop files. | 197 | // the app name in the program and in the .desktop files. |
197 | 198 | ||
198 | AppLnkSet apps( appsPath ); | 199 | AppLnkSet apps( appsPath ); |
199 | 200 | ||
200 | QList<AppLnk> appsList = apps.children(); | 201 | QList<AppLnk> appsList = apps.children(); |
201 | for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) { | 202 | for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) { |
202 | if ( (*it)->exec() == appName ) { | 203 | if ( (*it)->exec() == appName ) { |
203 | mw->setCaption( (*it)->name() ); | 204 | mw->setCaption( (*it)->name() ); |
204 | return TRUE; | 205 | return TRUE; |
205 | } | 206 | } |
206 | } | 207 | } |
207 | */ | 208 | */ |
208 | return FALSE; | 209 | return FALSE; |
209 | } | 210 | } |
210 | 211 | ||
211 | 212 | ||
212 | void show(QWidget* mw, bool nomax) | 213 | void show(QWidget* mw, bool nomax) |
213 | { | 214 | { |
214 | setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" ); | 215 | setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" ); |
215 | nomaximize = nomax; | 216 | nomaximize = nomax; |
216 | qpe_main_widget = mw; | 217 | qpe_main_widget = mw; |
218 | qcopQok = TRUE; | ||
217 | #ifndef QT_NO_COP | 219 | #ifndef QT_NO_COP |
218 | 220 | ||
219 | sendQCopQ(); | 221 | sendQCopQ(); |
220 | #endif | 222 | #endif |
221 | 223 | ||
222 | if ( preloaded ) { | 224 | if ( preloaded ) { |
223 | if (forceshow) | 225 | if (forceshow) |
224 | show_mx(mw, nomax); | 226 | show_mx(mw, nomax); |
225 | } | 227 | } |
226 | else if ( keep_running ) { | 228 | else if ( keep_running ) { |
227 | show_mx(mw, nomax); | 229 | show_mx(mw, nomax); |
228 | } | 230 | } |
229 | } | 231 | } |
230 | 232 | ||
231 | void loadTextCodecs() | 233 | void loadTextCodecs() |
232 | { | 234 | { |
233 | QString path = QPEApplication::qpeDir() + "/plugins/textcodecs"; | 235 | QString path = QPEApplication::qpeDir() + "/plugins/textcodecs"; |
234 | QDir dir( path, "lib*.so" ); | 236 | QDir dir( path, "lib*.so" ); |
235 | QStringList list; | 237 | QStringList list; |
236 | if ( dir. exists ( )) | 238 | if ( dir. exists ( )) |
237 | list = dir.entryList(); | 239 | list = dir.entryList(); |
238 | QStringList::Iterator it; | 240 | QStringList::Iterator it; |
239 | for ( it = list.begin(); it != list.end(); ++it ) { | 241 | for ( it = list.begin(); it != list.end(); ++it ) { |
240 | TextCodecInterface *iface = 0; | 242 | TextCodecInterface *iface = 0; |
241 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 243 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
242 | if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { | 244 | if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { |
243 | QValueList<int> mibs = iface->mibEnums(); | 245 | QValueList<int> mibs = iface->mibEnums(); |
244 | for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) { | 246 | for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) { |
245 | (void)iface->createForMib(*i); | 247 | (void)iface->createForMib(*i); |
246 | // ### it exists now; need to remember if we can delete it | 248 | // ### it exists now; need to remember if we can delete it |
247 | } | 249 | } |
248 | } | 250 | } |
249 | else { | 251 | else { |
250 | lib->unload(); | 252 | lib->unload(); |
251 | delete lib; | 253 | delete lib; |
252 | } | 254 | } |
253 | } | 255 | } |
254 | } | 256 | } |
255 | 257 | ||
256 | void loadImageCodecs() | 258 | void loadImageCodecs() |
257 | { | 259 | { |
258 | QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs"; | 260 | QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs"; |
259 | QDir dir( path, "lib*.so" ); | 261 | QDir dir( path, "lib*.so" ); |
260 | QStringList list; | 262 | QStringList list; |
261 | if ( dir. exists ( )) | 263 | if ( dir. exists ( )) |
262 | list = dir.entryList(); | 264 | list = dir.entryList(); |
263 | QStringList::Iterator it; | 265 | QStringList::Iterator it; |
264 | for ( it = list.begin(); it != list.end(); ++it ) { | 266 | for ( it = list.begin(); it != list.end(); ++it ) { |
265 | ImageCodecInterface *iface = 0; | 267 | ImageCodecInterface *iface = 0; |
266 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 268 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
267 | if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { | 269 | if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { |
268 | QStringList formats = iface->keys(); | 270 | QStringList formats = iface->keys(); |
269 | for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) { | 271 | for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) { |
270 | (void)iface->installIOHandler(*i); | 272 | (void)iface->installIOHandler(*i); |
271 | // ### it exists now; need to remember if we can delete it | 273 | // ### it exists now; need to remember if we can delete it |
272 | } | 274 | } |
273 | } | 275 | } |
274 | else { | 276 | else { |
275 | lib->unload(); | 277 | lib->unload(); |
276 | delete lib; | 278 | delete lib; |
277 | } | 279 | } |
278 | } | 280 | } |
279 | } | 281 | } |
280 | }; | 282 | }; |
281 | 283 | ||
282 | class ResourceMimeFactory : public QMimeSourceFactory | 284 | class ResourceMimeFactory : public QMimeSourceFactory |
283 | { | 285 | { |
284 | public: | 286 | public: |
285 | ResourceMimeFactory() : resImage( 0 ) | 287 | ResourceMimeFactory() : resImage( 0 ) |
286 | { | 288 | { |
287 | setFilePath( Global::helpPath() ); | 289 | setFilePath( Global::helpPath() ); |
288 | setExtensionType( "html", "text/html;charset=UTF-8" ); | 290 | setExtensionType( "html", "text/html;charset=UTF-8" ); |
289 | } | 291 | } |
290 | ~ResourceMimeFactory() { | 292 | ~ResourceMimeFactory() { |
291 | delete resImage; | 293 | delete resImage; |
292 | } | 294 | } |
293 | 295 | ||
294 | const QMimeSource* data( const QString& abs_name ) const | 296 | const QMimeSource* data( const QString& abs_name ) const |
295 | { | 297 | { |
296 | const QMimeSource * r = QMimeSourceFactory::data( abs_name ); | 298 | const QMimeSource * r = QMimeSourceFactory::data( abs_name ); |
297 | if ( !r ) { | 299 | if ( !r ) { |
298 | int sl = abs_name.length(); | 300 | int sl = abs_name.length(); |
299 | do { | 301 | do { |
300 | sl = abs_name.findRev( '/', sl - 1 ); | 302 | sl = abs_name.findRev( '/', sl - 1 ); |
301 | QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name; | 303 | QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name; |
302 | int dot = name.findRev( '.' ); | 304 | int dot = name.findRev( '.' ); |
303 | if ( dot >= 0 ) | 305 | if ( dot >= 0 ) |
304 | name = name.left( dot ); | 306 | name = name.left( dot ); |
305 | QImage img = Resource::loadImage( name ); | 307 | QImage img = Resource::loadImage( name ); |
306 | if ( !img.isNull() ) { | 308 | if ( !img.isNull() ) { |
307 | delete resImage; | 309 | delete resImage; |
308 | resImage = new QImageDrag( img ); | 310 | resImage = new QImageDrag( img ); |
309 | r = resImage; | 311 | r = resImage; |
310 | } | 312 | } |
311 | } | 313 | } |
312 | while ( !r && sl > 0 ); | 314 | while ( !r && sl > 0 ); |
313 | } | 315 | } |
314 | return r; | 316 | return r; |
315 | } | 317 | } |
316 | private: | 318 | private: |
317 | mutable QImageDrag *resImage; | 319 | mutable QImageDrag *resImage; |
318 | }; | 320 | }; |
319 | 321 | ||
320 | static int& hack(int& i) | 322 | static int& hack(int& i) |
321 | { | 323 | { |
322 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) | 324 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) |
323 | // These should be created, but aren't in Qt 2.3.0 | 325 | // These should be created, but aren't in Qt 2.3.0 |
324 | (void)new QUtf8Codec; | 326 | (void)new QUtf8Codec; |
325 | (void)new QUtf16Codec; | 327 | (void)new QUtf16Codec; |
326 | #endif | 328 | #endif |
327 | return i; | 329 | return i; |
328 | } | 330 | } |
329 | 331 | ||
330 | static int muted = 0; | 332 | static int muted = 0; |
331 | static int micMuted = 0; | 333 | static int micMuted = 0; |
332 | 334 | ||
333 | static void setVolume( int t = 0, int percent = -1 ) | 335 | static void setVolume( int t = 0, int percent = -1 ) |
334 | { | 336 | { |
335 | switch ( t ) { | 337 | switch ( t ) { |
336 | case 0: { | 338 | case 0: { |
337 | Config cfg( "qpe" ); | 339 | Config cfg( "qpe" ); |
338 | cfg.setGroup( "Volume" ); | 340 | cfg.setGroup( "Volume" ); |
339 | if ( percent < 0 ) | 341 | if ( percent < 0 ) |
340 | percent = cfg.readNumEntry( "VolumePercent", 50 ); | 342 | percent = cfg.readNumEntry( "VolumePercent", 50 ); |
341 | int fd = 0; | 343 | int fd = 0; |
342 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 344 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
343 | int vol = muted ? 0 : percent; | 345 | int vol = muted ? 0 : percent; |
344 | // set both channels to same volume | 346 | // set both channels to same volume |
345 | vol |= vol << 8; | 347 | vol |= vol << 8; |
346 | ioctl( fd, MIXER_WRITE( 0 ), &vol ); | 348 | ioctl( fd, MIXER_WRITE( 0 ), &vol ); |
347 | ::close( fd ); | 349 | ::close( fd ); |
348 | } | 350 | } |
349 | } | 351 | } |
350 | break; | 352 | break; |
351 | } | 353 | } |
352 | } | 354 | } |
353 | 355 | ||
354 | static void setMic( int t = 0, int percent = -1 ) | 356 | static void setMic( int t = 0, int percent = -1 ) |
355 | { | 357 | { |
356 | switch ( t ) { | 358 | switch ( t ) { |
357 | case 0: { | 359 | case 0: { |
358 | Config cfg( "qpe" ); | 360 | Config cfg( "qpe" ); |
359 | cfg.setGroup( "Volume" ); | 361 | cfg.setGroup( "Volume" ); |
360 | if ( percent < 0 ) | 362 | if ( percent < 0 ) |
361 | percent = cfg.readNumEntry( "Mic", 50 ); | 363 | percent = cfg.readNumEntry( "Mic", 50 ); |
362 | 364 | ||
363 | int fd = 0; | 365 | int fd = 0; |
364 | int mic = micMuted ? 0 : percent; | 366 | int mic = micMuted ? 0 : percent; |
365 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 367 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
366 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_MIC ), &mic ); | 368 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_MIC ), &mic ); |
367 | ::close( fd ); | 369 | ::close( fd ); |
368 | } | 370 | } |
369 | } | 371 | } |
370 | break; | 372 | break; |
371 | } | 373 | } |
372 | } | 374 | } |
373 | 375 | ||
374 | 376 | ||
375 | static void setBass( int t = 0, int percent = -1 ) | 377 | static void setBass( int t = 0, int percent = -1 ) |
376 | { | 378 | { |
377 | switch ( t ) { | 379 | switch ( t ) { |
378 | case 0: { | 380 | case 0: { |
379 | Config cfg( "qpe" ); | 381 | Config cfg( "qpe" ); |
380 | cfg.setGroup( "Volume" ); | 382 | cfg.setGroup( "Volume" ); |
381 | if ( percent < 0 ) | 383 | if ( percent < 0 ) |
382 | percent = cfg.readNumEntry( "BassPercent", 50 ); | 384 | percent = cfg.readNumEntry( "BassPercent", 50 ); |
383 | 385 | ||
384 | int fd = 0; | 386 | int fd = 0; |
385 | int bass = percent; | 387 | int bass = percent; |
386 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 388 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
387 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_BASS ), &bass ); | 389 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_BASS ), &bass ); |
388 | ::close( fd ); | 390 | ::close( fd ); |
389 | } | 391 | } |
390 | } | 392 | } |
391 | break; | 393 | break; |
392 | } | 394 | } |
393 | } | 395 | } |
394 | 396 | ||
395 | 397 | ||
396 | static void setTreble( int t = 0, int percent = -1 ) | 398 | static void setTreble( int t = 0, int percent = -1 ) |
397 | { | 399 | { |
398 | switch ( t ) { | 400 | switch ( t ) { |
399 | case 0: { | 401 | case 0: { |
400 | Config cfg( "qpe" ); | 402 | Config cfg( "qpe" ); |
401 | cfg.setGroup( "Volume" ); | 403 | cfg.setGroup( "Volume" ); |
402 | if ( percent < 0 ) | 404 | if ( percent < 0 ) |
403 | percent = cfg.readNumEntry( "TreblePercent", 50 ); | 405 | percent = cfg.readNumEntry( "TreblePercent", 50 ); |
404 | 406 | ||
405 | int fd = 0; | 407 | int fd = 0; |
406 | int treble = percent; | 408 | int treble = percent; |
407 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 409 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
408 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_TREBLE ), &treble ); | 410 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_TREBLE ), &treble ); |
409 | ::close( fd ); | 411 | ::close( fd ); |
410 | } | 412 | } |
411 | } | 413 | } |
412 | break; | 414 | break; |
413 | } | 415 | } |
414 | } | 416 | } |
415 | 417 | ||
416 | 418 | ||
417 | /*! | 419 | /*! |
418 | \class QPEApplication qpeapplication.h | 420 | \class QPEApplication qpeapplication.h |
419 | \brief The QPEApplication class implements various system services | 421 | \brief The QPEApplication class implements various system services |
420 | that are available to all Qtopia applications. | 422 | that are available to all Qtopia applications. |
421 | 423 | ||
422 | Simply by using QPEApplication instead of QApplication, a standard Qt | 424 | Simply by using QPEApplication instead of QApplication, a standard Qt |
423 | application becomes a Qtopia application. It automatically follows | 425 | application becomes a Qtopia application. It automatically follows |
424 | style changes, quits and raises, and in the | 426 | style changes, quits and raises, and in the |
425 | case of \link docwidget.html document-oriented\endlink applications, | 427 | case of \link docwidget.html document-oriented\endlink applications, |
426 | changes the currently displayed document in response to the environment. | 428 | changes the currently displayed document in response to the environment. |
427 | 429 | ||
428 | To create a \link docwidget.html document-oriented\endlink | 430 | To create a \link docwidget.html document-oriented\endlink |
429 | application use showMainDocumentWidget(); to create a | 431 | application use showMainDocumentWidget(); to create a |
430 | non-document-oriented application use showMainWidget(). The | 432 | non-document-oriented application use showMainWidget(). The |
431 | keepRunning() function indicates whether the application will | 433 | keepRunning() function indicates whether the application will |
432 | continue running after it's processed the last \link qcop.html | 434 | continue running after it's processed the last \link qcop.html |
433 | QCop\endlink message. This can be changed using setKeepRunning(). | 435 | QCop\endlink message. This can be changed using setKeepRunning(). |
434 | 436 | ||
435 | A variety of signals are emitted when certain events occur, for | 437 | A variety of signals are emitted when certain events occur, for |
436 | example, timeChanged(), clockChanged(), weekChanged(), | 438 | example, timeChanged(), clockChanged(), weekChanged(), |
437 | dateFormatChanged() and volumeChanged(). If the application receives | 439 | dateFormatChanged() and volumeChanged(). If the application receives |
438 | a \link qcop.html QCop\endlink message on the application's | 440 | a \link qcop.html QCop\endlink message on the application's |
439 | QPE/Application/\e{appname} channel, the appMessage() signal is | 441 | QPE/Application/\e{appname} channel, the appMessage() signal is |
440 | emitted. There are also flush() and reload() signals, which | 442 | emitted. There are also flush() and reload() signals, which |
441 | are emitted when synching begins and ends respectively - upon these | 443 | are emitted when synching begins and ends respectively - upon these |
442 | signals, the application should save and reload any data | 444 | signals, the application should save and reload any data |
443 | files that are involved in synching. Most of these signals will initially | 445 | files that are involved in synching. Most of these signals will initially |
444 | be received and unfiltered through the appMessage() signal. | 446 | be received and unfiltered through the appMessage() signal. |
445 | 447 | ||
446 | This class also provides a set of useful static functions. The | 448 | This class also provides a set of useful static functions. The |
447 | qpeDir() and documentDir() functions return the respective paths. | 449 | qpeDir() and documentDir() functions return the respective paths. |
448 | The grabKeyboard() and ungrabKeyboard() functions are used to | 450 | The grabKeyboard() and ungrabKeyboard() functions are used to |
449 | control whether the application takes control of the device's | 451 | control whether the application takes control of the device's |
450 | physical buttons (e.g. application launch keys). The stylus' mode of | 452 | physical buttons (e.g. application launch keys). The stylus' mode of |
451 | operation is set with setStylusOperation() and retrieved with | 453 | operation is set with setStylusOperation() and retrieved with |
452 | stylusOperation(). There are also setInputMethodHint() and | 454 | stylusOperation(). There are also setInputMethodHint() and |
453 | inputMethodHint() functions. | 455 | inputMethodHint() functions. |
454 | 456 | ||
455 | \ingroup qtopiaemb | 457 | \ingroup qtopiaemb |
456 | */ | 458 | */ |
457 | 459 | ||
458 | /*! | 460 | /*! |
459 | \fn void QPEApplication::clientMoused() | 461 | \fn void QPEApplication::clientMoused() |
460 | 462 | ||
461 | \internal | 463 | \internal |
462 | */ | 464 | */ |
463 | 465 | ||
464 | /*! | 466 | /*! |
465 | \fn void QPEApplication::timeChanged(); | 467 | \fn void QPEApplication::timeChanged(); |
466 | This signal is emitted when the time changes outside the normal | 468 | This signal is emitted when the time changes outside the normal |
467 | passage of time, i.e. if the time is set backwards or forwards. | 469 | passage of time, i.e. if the time is set backwards or forwards. |
468 | */ | 470 | */ |
469 | 471 | ||
470 | /*! | 472 | /*! |
471 | \fn void QPEApplication::clockChanged( bool ampm ); | 473 | \fn void QPEApplication::clockChanged( bool ampm ); |
472 | 474 | ||
473 | This signal is emitted when the user changes the clock's style. If | 475 | This signal is emitted when the user changes the clock's style. If |
474 | \a ampm is TRUE, the user wants a 12-hour AM/PM clock, otherwise, | 476 | \a ampm is TRUE, the user wants a 12-hour AM/PM clock, otherwise, |
475 | they want a 24-hour clock. | 477 | they want a 24-hour clock. |
476 | */ | 478 | */ |
477 | 479 | ||
478 | /*! | 480 | /*! |
479 | \fn void QPEApplication::volumeChanged( bool muted ) | 481 | \fn void QPEApplication::volumeChanged( bool muted ) |
480 | 482 | ||
481 | This signal is emitted whenever the mute state is changed. If \a | 483 | This signal is emitted whenever the mute state is changed. If \a |
482 | muted is TRUE, then sound output has been muted. | 484 | muted is TRUE, then sound output has been muted. |
483 | */ | 485 | */ |
484 | 486 | ||
485 | /*! | 487 | /*! |
486 | \fn void QPEApplication::weekChanged( bool startOnMonday ) | 488 | \fn void QPEApplication::weekChanged( bool startOnMonday ) |
487 | 489 | ||
488 | This signal is emitted if the week start day is changed. If \a | 490 | This signal is emitted if the week start day is changed. If \a |
489 | startOnMonday is TRUE then the first day of the week is Monday; if | 491 | startOnMonday is TRUE then the first day of the week is Monday; if |
490 | \a startOnMonday is FALSE then the first day of the week is | 492 | \a startOnMonday is FALSE then the first day of the week is |
491 | Sunday. | 493 | Sunday. |
492 | */ | 494 | */ |
493 | 495 | ||
494 | /*! | 496 | /*! |
495 | \fn void QPEApplication::dateFormatChanged(DateFormat) | 497 | \fn void QPEApplication::dateFormatChanged(DateFormat) |
496 | 498 | ||
497 | This signal is emitted whenever the date format is changed. | 499 | This signal is emitted whenever the date format is changed. |
498 | */ | 500 | */ |
499 | 501 | ||
500 | /*! | 502 | /*! |
501 | \fn void QPEApplication::flush() | 503 | \fn void QPEApplication::flush() |
502 | 504 | ||
503 | ### | 505 | ### |
504 | */ | 506 | */ |
505 | 507 | ||
506 | /*! | 508 | /*! |
507 | \fn void QPEApplication::reload() | 509 | \fn void QPEApplication::reload() |
508 | 510 | ||
509 | */ | 511 | */ |
510 | 512 | ||
511 | 513 | ||
512 | 514 | ||
513 | void QPEApplication::processQCopFile() | 515 | void QPEApplication::processQCopFile() |
514 | { | 516 | { |
515 | QString qcopfn("/tmp/qcop-msg-"); | 517 | QString qcopfn("/tmp/qcop-msg-"); |
516 | qcopfn += d->appName; // append command name | 518 | qcopfn += d->appName; // append command name |
517 | 519 | ||
518 | QFile f(qcopfn); | 520 | QFile f(qcopfn); |
519 | if ( f.open(IO_ReadWrite) ) { | 521 | if ( f.open(IO_ReadWrite) ) { |
520 | #ifndef Q_OS_WIN32 | 522 | #ifndef Q_OS_WIN32 |
521 | flock(f.handle(), LOCK_EX); | 523 | flock(f.handle(), LOCK_EX); |
522 | #endif | 524 | #endif |
523 | QDataStream ds(&f); | 525 | QDataStream ds(&f); |
524 | QCString channel, message; | 526 | QCString channel, message; |
525 | QByteArray data; | 527 | QByteArray data; |
526 | while(!ds.atEnd()) { | 528 | while(!ds.atEnd()) { |
527 | ds >> channel >> message >> data; | 529 | ds >> channel >> message >> data; |
528 | d->enqueueQCop(channel,message,data); | 530 | d->enqueueQCop(channel,message,data); |
529 | } | 531 | } |
530 | ::ftruncate(f.handle(), 0); | 532 | ::ftruncate(f.handle(), 0); |
531 | #ifndef Q_OS_WIN32 | 533 | #ifndef Q_OS_WIN32 |
532 | f.flush(); | 534 | f.flush(); |
533 | flock(f.handle(), LOCK_UN); | 535 | flock(f.handle(), LOCK_UN); |
534 | #endif | 536 | #endif |
535 | } | 537 | } |
536 | #endif | 538 | #endif |
537 | } | 539 | } |
538 | 540 | ||
539 | 541 | ||
540 | /*! | 542 | /*! |
541 | \fn void QPEApplication::appMessage( const QCString& msg, const QByteArray& data ) | 543 | \fn void QPEApplication::appMessage( const QCString& msg, const QByteArray& data ) |
542 | 544 | ||
543 | This signal is emitted when a message is received on this | 545 | This signal is emitted when a message is received on this |
544 | application's QPE/Application/<i>appname</i> \link qcop.html | 546 | application's QPE/Application/<i>appname</i> \link qcop.html |
545 | QCop\endlink channel. | 547 | QCop\endlink channel. |
546 | 548 | ||
547 | The slot to which you connect this signal uses \a msg and \a data | 549 | The slot to which you connect this signal uses \a msg and \a data |
548 | in the following way: | 550 | in the following way: |
549 | 551 | ||
550 | \code | 552 | \code |
551 | void MyWidget::receive( const QCString& msg, const QByteArray& data ) | 553 | void MyWidget::receive( const QCString& msg, const QByteArray& data ) |
552 | { | 554 | { |
553 | QDataStream stream( data, IO_ReadOnly ); | 555 | QDataStream stream( data, IO_ReadOnly ); |
554 | if ( msg == "someMessage(int,int,int)" ) { | 556 | if ( msg == "someMessage(int,int,int)" ) { |
555 | int a,b,c; | 557 | int a,b,c; |
556 | stream >> a >> b >> c; | 558 | stream >> a >> b >> c; |
557 | ... | 559 | ... |
558 | } else if ( msg == "otherMessage(QString)" ) { | 560 | } else if ( msg == "otherMessage(QString)" ) { |
559 | ... | 561 | ... |
560 | } | 562 | } |
561 | } | 563 | } |
562 | \endcode | 564 | \endcode |
563 | 565 | ||
564 | \sa qcop.html | 566 | \sa qcop.html |
565 | Note that messages received here may be processed by qpe application | 567 | Note that messages received here may be processed by qpe application |
566 | and emitted as signals, such as flush() and reload(). | 568 | and emitted as signals, such as flush() and reload(). |
567 | */ | 569 | */ |
568 | 570 | ||
569 | /*! | 571 | /*! |
570 | Constructs a QPEApplication just as you would construct | 572 | Constructs a QPEApplication just as you would construct |
571 | a QApplication, passing \a argc, \a argv, and \a t. | 573 | a QApplication, passing \a argc, \a argv, and \a t. |
572 | 574 | ||
573 | For applications, \a t should be the default, GuiClient. Only | 575 | For applications, \a t should be the default, GuiClient. Only |
574 | the Qtopia server passes GuiServer. | 576 | the Qtopia server passes GuiServer. |
575 | */ | 577 | */ |
576 | QPEApplication::QPEApplication( int & argc, char **argv, Type t ) | 578 | QPEApplication::QPEApplication( int & argc, char **argv, Type t ) |
577 | : QApplication( hack(argc), argv, t ), pidChannel( 0 ) | 579 | : QApplication( hack(argc), argv, t ), pidChannel( 0 ) |
578 | { | 580 | { |
581 | QPixmapCache::setCacheLimit(256); // sensible default for smaller devices. | ||
582 | |||
579 | d = new QPEApplicationData; | 583 | d = new QPEApplicationData; |
580 | d->loadTextCodecs(); | 584 | d->loadTextCodecs(); |
581 | d->loadImageCodecs(); | 585 | d->loadImageCodecs(); |
582 | int dw = desktop() ->width(); | 586 | int dw = desktop() ->width(); |
583 | 587 | ||
584 | if ( dw < 200 ) { | 588 | if ( dw < 200 ) { |
585 | setFont( QFont( "vera", 8 ) ); | 589 | setFont( QFont( "vera", 8 ) ); |
586 | AppLnk::setSmallIconSize( 10 ); | 590 | AppLnk::setSmallIconSize( 10 ); |
587 | AppLnk::setBigIconSize( 28 ); | 591 | AppLnk::setBigIconSize( 28 ); |
588 | } | 592 | } |
589 | #ifndef QT_QWS_SIMPAD | 593 | #ifndef QT_QWS_SIMPAD |
590 | else if ( dw > 600 ) { | 594 | else if ( dw > 600 ) { |
591 | setFont( QFont( "vera", 16 ) ); | 595 | setFont( QFont( "vera", 16 ) ); |
592 | AppLnk::setSmallIconSize( 24 ); | 596 | AppLnk::setSmallIconSize( 24 ); |
593 | AppLnk::setBigIconSize( 48 ); | 597 | AppLnk::setBigIconSize( 48 ); |
594 | } | 598 | } |
595 | #endif | 599 | #endif |
596 | else if ( dw > 200 ) { | 600 | else if ( dw > 200 ) { |
597 | setFont( QFont( "vera", 10 ) ); | 601 | setFont( QFont( "vera", 10 ) ); |
598 | AppLnk::setSmallIconSize( 14 ); | 602 | AppLnk::setSmallIconSize( 14 ); |
599 | AppLnk::setBigIconSize( 32 ); | 603 | AppLnk::setBigIconSize( 32 ); |
600 | } | 604 | } |
601 | 605 | ||
602 | QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory ); | 606 | QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory ); |
603 | 607 | ||
604 | connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) ); | 608 | connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) ); |
605 | 609 | ||
606 | 610 | ||
607 | sysChannel = new QCopChannel( "QPE/System", this ); | 611 | sysChannel = new QCopChannel( "QPE/System", this ); |
608 | connect( sysChannel, SIGNAL( received( const QCString &, const QByteArray & ) ), | 612 | connect( sysChannel, SIGNAL( received( const QCString &, const QByteArray & ) ), |
609 | this, SLOT( systemMessage( const QCString &, const QByteArray & ) ) ); | 613 | this, SLOT( systemMessage( const QCString &, const QByteArray & ) ) ); |
610 | 614 | ||
611 | /* COde now in initapp */ | 615 | /* COde now in initapp */ |
612 | #if 0 | 616 | #if 0 |
613 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 617 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
614 | 618 | ||
615 | QString qcopfn( "/tmp/qcop-msg-" ); | 619 | QString qcopfn( "/tmp/qcop-msg-" ); |
616 | qcopfn += QString( argv[ 0 ] ); // append command name | 620 | qcopfn += QString( argv[ 0 ] ); // append command name |
617 | 621 | ||
618 | QFile f( qcopfn ); | 622 | QFile f( qcopfn ); |
619 | if ( f.open( IO_ReadOnly ) ) { | 623 | if ( f.open( IO_ReadOnly ) ) { |
620 | flock( f.handle(), LOCK_EX ); | 624 | flock( f.handle(), LOCK_EX ); |
621 | } | 625 | } |
622 | 626 | ||
623 | 627 | ||
624 | 628 | ||
625 | QCString channel = QCString( argv[ 0 ] ); | 629 | QCString channel = QCString( argv[ 0 ] ); |
626 | channel.replace( QRegExp( ".*/" ), "" ); | 630 | channel.replace( QRegExp( ".*/" ), "" ); |
627 | d->appName = channel; | 631 | d->appName = channel; |
628 | channel = "QPE/Application/" + channel; | 632 | channel = "QPE/Application/" + channel; |
629 | pidChannel = new QCopChannel( channel, this ); | 633 | pidChannel = new QCopChannel( channel, this ); |
630 | connect( pidChannel, SIGNAL( received( const QCString &, const QByteArray & ) ), | 634 | connect( pidChannel, SIGNAL( received( const QCString &, const QByteArray & ) ), |
631 | this, SLOT( pidMessage( const QCString &, const QByteArray & ) ) ); | 635 | this, SLOT( pidMessage( const QCString &, const QByteArray & ) ) ); |
632 | 636 | ||
633 | if ( f.isOpen() ) { | 637 | if ( f.isOpen() ) { |
634 | d->keep_running = FALSE; | 638 | d->keep_running = FALSE; |
635 | QDataStream ds( &f ); | 639 | QDataStream ds( &f ); |
636 | QCString channel, message; | 640 | QCString channel, message; |
637 | QByteArray data; | 641 | QByteArray data; |
638 | while ( !ds.atEnd() ) { | 642 | while ( !ds.atEnd() ) { |
639 | ds >> channel >> message >> data; | 643 | ds >> channel >> message >> data; |
640 | d->enqueueQCop( channel, message, data ); | 644 | d->enqueueQCop( channel, message, data ); |
641 | } | 645 | } |
642 | 646 | ||
643 | flock( f.handle(), LOCK_UN ); | 647 | flock( f.handle(), LOCK_UN ); |
644 | f.close(); | 648 | f.close(); |
645 | f.remove(); | 649 | f.remove(); |
646 | } | 650 | } |
647 | 651 | ||
648 | for ( int a = 0; a < argc; a++ ) { | 652 | for ( int a = 0; a < argc; a++ ) { |
649 | if ( qstrcmp( argv[ a ], "-preload" ) == 0 ) { | 653 | if ( qstrcmp( argv[ a ], "-preload" ) == 0 ) { |
650 | argv[ a ] = argv[ a + 1 ]; | 654 | argv[ a ] = argv[ a + 1 ]; |
651 | a++; | 655 | a++; |
652 | d->preloaded = TRUE; | 656 | d->preloaded = TRUE; |
653 | argc -= 1; | 657 | argc -= 1; |
654 | } | 658 | } |
655 | else if ( qstrcmp( argv[ a ], "-preload-show" ) == 0 ) { | 659 | else if ( qstrcmp( argv[ a ], "-preload-show" ) == 0 ) { |
656 | argv[ a ] = argv[ a + 1 ]; | 660 | argv[ a ] = argv[ a + 1 ]; |
657 | a++; | 661 | a++; |
658 | d->preloaded = TRUE; | 662 | d->preloaded = TRUE; |
659 | d->forceshow = TRUE; | 663 | d->forceshow = TRUE; |
660 | argc -= 1; | 664 | argc -= 1; |
661 | } | 665 | } |
662 | } | 666 | } |
663 | 667 | ||
664 | /* overide stored arguments */ | 668 | /* overide stored arguments */ |
665 | setArgs( argc, argv ); | 669 | setArgs( argc, argv ); |
666 | 670 | ||
667 | #endif | 671 | #endif |
668 | #else | 672 | #else |
669 | initApp( argc, argv ); | 673 | initApp( argc, argv ); |
670 | #endif | 674 | #endif |
671 | // qwsSetDecoration( new QPEDecoration() ); | 675 | // qwsSetDecoration( new QPEDecoration() ); |
672 | 676 | ||
673 | #ifndef QT_NO_TRANSLATION | 677 | #ifndef QT_NO_TRANSLATION |
674 | 678 | ||
675 | d->langs = Global::languageList(); | 679 | d->langs = Global::languageList(); |
676 | for ( QStringList::ConstIterator it = d->langs.begin(); it != d->langs.end(); ++it ) { | 680 | for ( QStringList::ConstIterator it = d->langs.begin(); it != d->langs.end(); ++it ) { |
677 | QString lang = *it; | 681 | QString lang = *it; |
678 | 682 | ||
679 | installTranslation( lang + "/libopie.qm"); | 683 | installTranslation( lang + "/libopie.qm"); |
680 | installTranslation( lang + "/libqpe.qm" ); | 684 | installTranslation( lang + "/libqpe.qm" ); |
681 | installTranslation( lang + "/" + d->appName + ".qm" ); | 685 | installTranslation( lang + "/" + d->appName + ".qm" ); |
682 | 686 | ||
683 | 687 | ||
684 | //###language/font hack; should look it up somewhere | 688 | //###language/font hack; should look it up somewhere |
685 | #ifdef QWS | 689 | #ifdef QWS |
686 | 690 | ||
687 | if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) { | 691 | if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) { |
688 | QFont fn = FontManager::unicodeFont( FontManager::Proportional ); | 692 | QFont fn = FontManager::unicodeFont( FontManager::Proportional ); |
689 | setFont( fn ); | 693 | setFont( fn ); |
690 | } | 694 | } |
691 | #endif | 695 | #endif |
692 | } | 696 | } |
693 | #endif | 697 | #endif |
694 | 698 | ||
695 | applyStyle(); | 699 | applyStyle(); |
696 | 700 | ||
697 | if ( type() == GuiServer ) { | 701 | if ( type() == GuiServer ) { |
698 | setVolume(); | 702 | setVolume(); |
699 | } | 703 | } |
700 | 704 | ||
701 | installEventFilter( this ); | 705 | installEventFilter( this ); |
702 | 706 | ||
703 | QPEMenuToolFocusManager::initialize(); | 707 | QPEMenuToolFocusManager::initialize(); |
704 | 708 | ||
705 | #ifdef QT_NO_QWS_CURSOR | 709 | #ifdef QT_NO_QWS_CURSOR |
706 | // if we have no cursor, probably don't want tooltips | 710 | // if we have no cursor, probably don't want tooltips |
707 | QToolTip::setEnabled( FALSE ); | 711 | QToolTip::setEnabled( FALSE ); |
708 | #endif | 712 | #endif |
709 | } | 713 | } |
710 | 714 | ||
711 | 715 | ||
712 | #ifdef QTOPIA_INTERNAL_INITAPP | 716 | #ifdef QTOPIA_INTERNAL_INITAPP |
713 | void QPEApplication::initApp( int argc, char **argv ) | 717 | void QPEApplication::initApp( int argc, char **argv ) |
714 | { | 718 | { |
715 | bool initial = pidChannel; // was set to 0 in the initializer | 719 | bool initial = pidChannel; // was set to 0 in the initializer |
716 | delete pidChannel; | 720 | delete pidChannel; |
717 | d->keep_running = TRUE; | 721 | d->keep_running = TRUE; |
718 | d->preloaded = FALSE; | 722 | d->preloaded = FALSE; |
719 | d->forceshow = FALSE; | 723 | d->forceshow = FALSE; |
720 | 724 | ||
721 | QCString channel = QCString(argv[0]); | 725 | QCString channel = QCString(argv[0]); |
722 | 726 | ||
723 | channel.replace(QRegExp(".*/"),""); | 727 | channel.replace(QRegExp(".*/"),""); |
724 | d->appName = channel; | 728 | d->appName = channel; |
725 | 729 | ||
726 | #if QT_VERSION > 235 | 730 | #if QT_VERSION > 235 |
727 | qt_fbdpy->setIdentity( channel ); // In Qt/E 2.3.6 | 731 | qt_fbdpy->setIdentity( channel ); // In Qt/E 2.3.6 |
728 | #endif | 732 | #endif |
729 | 733 | ||
730 | channel = "QPE/Application/" + channel; | 734 | channel = "QPE/Application/" + channel; |
731 | pidChannel = new QCopChannel( channel, this); | 735 | pidChannel = new QCopChannel( channel, this); |
732 | connect( pidChannel, SIGNAL(received(const QCString &, const QByteArray &)), | 736 | connect( pidChannel, SIGNAL(received(const QCString &, const QByteArray &)), |
733 | this, SLOT(pidMessage(const QCString &, const QByteArray &))); | 737 | this, SLOT(pidMessage(const QCString &, const QByteArray &))); |
734 | 738 | ||
735 | if (!initial) { | 739 | if (!initial) { |
736 | processQCopFile(); | 740 | processQCopFile(); |
737 | d->keep_running = d->qcopq.isEmpty(); | 741 | d->keep_running = d->qcopq.isEmpty(); |
738 | } | 742 | } |
739 | 743 | ||
740 | for (int a=0; a<argc; a++) { | 744 | for (int a=0; a<argc; a++) { |
741 | if ( qstrcmp(argv[a],"-preload")==0 ) { | 745 | if ( qstrcmp(argv[a],"-preload")==0 ) { |
742 | argv[a] = argv[a+1]; | 746 | argv[a] = argv[a+1]; |
743 | a++; | 747 | a++; |
744 | d->preloaded = TRUE; | 748 | d->preloaded = TRUE; |
745 | argc-=1; | 749 | argc-=1; |
746 | } else if ( qstrcmp(argv[a],"-preload-show")==0 ) { | 750 | } else if ( qstrcmp(argv[a],"-preload-show")==0 ) { |
747 | argv[a] = argv[a+1]; | 751 | argv[a] = argv[a+1]; |
748 | a++; | 752 | a++; |
749 | d->preloaded = TRUE; | 753 | d->preloaded = TRUE; |
750 | d->forceshow = TRUE; | 754 | d->forceshow = TRUE; |
751 | argc-=1; | 755 | argc-=1; |
752 | } | 756 | } |
753 | } | 757 | } |
754 | 758 | ||
755 | /* overide stored arguments */ | 759 | /* overide stored arguments */ |
756 | setArgs(argc, argv); | 760 | setArgs(argc, argv); |
757 | 761 | ||
758 | /* install translation here */ | 762 | /* install translation here */ |
759 | for ( QStringList::ConstIterator it = d->langs.begin(); it != d->langs.end(); ++it ) | 763 | for ( QStringList::ConstIterator it = d->langs.begin(); it != d->langs.end(); ++it ) |
760 | installTranslation( (*it) + "/" + d->appName + ".qm" ); | 764 | installTranslation( (*it) + "/" + d->appName + ".qm" ); |
761 | } | 765 | } |
762 | #endif | 766 | #endif |
763 | 767 | ||
764 | 768 | ||
765 | static QPtrDict<void>* inputMethodDict = 0; | 769 | static QPtrDict<void>* inputMethodDict = 0; |
766 | static void createInputMethodDict() | 770 | static void createInputMethodDict() |
767 | { | 771 | { |
768 | if ( !inputMethodDict ) | 772 | if ( !inputMethodDict ) |
769 | inputMethodDict = new QPtrDict<void>; | 773 | inputMethodDict = new QPtrDict<void>; |
770 | } | 774 | } |
771 | 775 | ||
772 | /*! | 776 | /*! |
773 | Returns the currently set hint to the system as to whether | 777 | Returns the currently set hint to the system as to whether |
774 | widget \a w has any use for text input methods. | 778 | widget \a w has any use for text input methods. |
775 | 779 | ||
776 | 780 | ||
777 | \sa setInputMethodHint() InputMethodHint | 781 | \sa setInputMethodHint() InputMethodHint |
778 | */ | 782 | */ |
779 | QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w ) | 783 | QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w ) |
780 | { | 784 | { |
781 | if ( inputMethodDict && w ) | 785 | if ( inputMethodDict && w ) |
782 | return ( InputMethodHint ) ( int ) inputMethodDict->find( w ); | 786 | return ( InputMethodHint ) ( int ) inputMethodDict->find( w ); |
783 | return Normal; | 787 | return Normal; |
784 | } | 788 | } |
785 | 789 | ||
786 | /*! | 790 | /*! |
787 | \enum QPEApplication::InputMethodHint | 791 | \enum QPEApplication::InputMethodHint |
788 | 792 | ||
789 | \value Normal the application sometimes needs text input (the default). | 793 | \value Normal the application sometimes needs text input (the default). |
790 | \value AlwaysOff the application never needs text input. | 794 | \value AlwaysOff the application never needs text input. |
791 | \value AlwaysOn the application always needs text input. | 795 | \value AlwaysOn the application always needs text input. |
792 | */ | 796 | */ |
793 | 797 | ||
794 | /*! | 798 | /*! |
795 | Hints to the system that widget \a w has use for text input methods | 799 | Hints to the system that widget \a w has use for text input methods |
796 | as specified by \a mode. | 800 | as specified by \a mode. |
797 | 801 | ||
798 | \sa inputMethodHint() InputMethodHint | 802 | \sa inputMethodHint() InputMethodHint |
799 | */ | 803 | */ |
800 | void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode ) | 804 | void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode ) |
801 | { | 805 | { |
802 | createInputMethodDict(); | 806 | createInputMethodDict(); |
803 | if ( mode == Normal ) { | 807 | if ( mode == Normal ) { |
804 | inputMethodDict->remove | 808 | inputMethodDict->remove |
805 | ( w ); | 809 | ( w ); |
806 | } | 810 | } |
807 | else { | 811 | else { |
808 | inputMethodDict->insert( w, ( void* ) mode ); | 812 | inputMethodDict->insert( w, ( void* ) mode ); |
809 | } | 813 | } |
810 | } | 814 | } |
811 | 815 | ||
812 | class HackDialog : public QDialog | 816 | class HackDialog : public QDialog |
813 | { | 817 | { |
814 | public: | 818 | public: |
815 | void acceptIt() | 819 | void acceptIt() |
816 | { | 820 | { |
817 | accept(); | 821 | accept(); |
818 | } | 822 | } |
819 | void rejectIt() | 823 | void rejectIt() |
820 | { | 824 | { |
821 | reject(); | 825 | reject(); |
822 | } | 826 | } |
823 | }; | 827 | }; |
824 | 828 | ||
825 | 829 | ||
826 | void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key ) | 830 | void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key ) |
827 | { | 831 | { |
828 | // specialised actions for certain widgets. May want to | 832 | // specialised actions for certain widgets. May want to |
829 | // add more stuff here. | 833 | // add more stuff here. |
830 | if ( activePopupWidget() && activePopupWidget() ->inherits( "QListBox" ) | 834 | if ( activePopupWidget() && activePopupWidget() ->inherits( "QListBox" ) |
831 | && activePopupWidget() ->parentWidget() | 835 | && activePopupWidget() ->parentWidget() |
832 | && activePopupWidget() ->parentWidget() ->inherits( "QComboBox" ) ) | 836 | && activePopupWidget() ->parentWidget() ->inherits( "QComboBox" ) ) |
833 | key = Qt::Key_Return; | 837 | key = Qt::Key_Return; |
834 | 838 | ||
835 | if ( activePopupWidget() && activePopupWidget() ->inherits( "QPopupMenu" ) ) | 839 | if ( activePopupWidget() && activePopupWidget() ->inherits( "QPopupMenu" ) ) |
836 | key = Qt::Key_Return; | 840 | key = Qt::Key_Return; |
837 | 841 | ||
838 | #ifdef QWS | 842 | #ifdef QWS |
839 | 843 | ||
840 | ke->simpleData.keycode = key; | 844 | ke->simpleData.keycode = key; |
841 | #endif | 845 | #endif |
842 | } | 846 | } |
843 | 847 | ||
844 | class HackWidget : public QWidget | 848 | class HackWidget : public QWidget |
845 | { | 849 | { |
846 | public: | 850 | public: |
847 | bool needsOk() | 851 | bool needsOk() |
848 | { | 852 | { |
849 | return ( getWState() & WState_Reserved1 ); | 853 | return ( getWState() & WState_Reserved1 ); |
850 | } | 854 | } |
851 | }; | 855 | }; |
852 | 856 | ||
853 | /*! | 857 | /*! |
854 | \internal | 858 | \internal |
855 | */ | 859 | */ |
856 | 860 | ||
857 | #ifdef QWS | 861 | #ifdef QWS |
858 | bool QPEApplication::qwsEventFilter( QWSEvent * e ) | 862 | bool QPEApplication::qwsEventFilter( QWSEvent * e ) |
859 | { | 863 | { |
860 | if ( !d->notbusysent && e->type == QWSEvent::Focus ) { | 864 | if ( !d->notbusysent && e->type == QWSEvent::Focus ) { |
861 | if ( qApp->type() != QApplication::GuiServer ) { | 865 | if ( qApp->type() != QApplication::GuiServer ) { |
862 | QCopEnvelope e( "QPE/System", "notBusy(QString)" ); | 866 | QCopEnvelope e( "QPE/System", "notBusy(QString)" ); |
863 | e << d->appName; | 867 | e << d->appName; |
864 | } | 868 | } |
865 | d->notbusysent = TRUE; | 869 | d->notbusysent = TRUE; |
866 | } | 870 | } |
867 | if ( type() == GuiServer ) { | 871 | if ( type() == GuiServer ) { |
868 | switch ( e->type ) { | 872 | switch ( e->type ) { |
869 | case QWSEvent::Mouse: | 873 | case QWSEvent::Mouse: |
870 | if ( e->asMouse() ->simpleData.state && !QWidget::find( e->window() ) ) | 874 | if ( e->asMouse() ->simpleData.state && !QWidget::find( e->window() ) ) |
871 | emit clientMoused(); | 875 | emit clientMoused(); |
872 | break; | 876 | break; |
873 | default: | 877 | default: |
874 | break; | 878 | break; |
875 | } | 879 | } |
876 | } | 880 | } |
877 | if ( e->type == QWSEvent::Key ) { | 881 | if ( e->type == QWSEvent::Key ) { |
878 | QWSKeyEvent *ke = ( QWSKeyEvent * ) e; | 882 | QWSKeyEvent *ke = ( QWSKeyEvent * ) e; |
879 | if ( ke->simpleData.keycode == Qt::Key_F33 ) { | 883 | if ( ke->simpleData.keycode == Qt::Key_F33 ) { |
880 | // Use special "OK" key to press "OK" on top level widgets | 884 | // Use special "OK" key to press "OK" on top level widgets |
881 | QWidget * active = activeWindow(); | 885 | QWidget * active = activeWindow(); |
882 | QWidget *popup = 0; | 886 | QWidget *popup = 0; |
883 | if ( active && active->isPopup() ) { | 887 | if ( active && active->isPopup() ) { |
884 | popup = active; | 888 | popup = active; |
885 | active = active->parentWidget(); | 889 | active = active->parentWidget(); |
886 | } | 890 | } |
887 | if ( active && ( int ) active->winId() == ke->simpleData.window && | 891 | if ( active && ( int ) active->winId() == ke->simpleData.window && |
888 | !active->testWFlags( WStyle_Customize | WType_Popup | WType_Desktop ) ) { | 892 | !active->testWFlags( WStyle_Customize | WType_Popup | WType_Desktop ) ) { |
889 | if ( ke->simpleData.is_press ) { | 893 | if ( ke->simpleData.is_press ) { |
890 | if ( popup ) | 894 | if ( popup ) |
891 | popup->close(); | 895 | popup->close(); |
892 | if ( active->inherits( "QDialog" ) ) { | 896 | if ( active->inherits( "QDialog" ) ) { |
893 | HackDialog * d = ( HackDialog * ) active; | 897 | HackDialog * d = ( HackDialog * ) active; |
894 | d->acceptIt(); | 898 | d->acceptIt(); |
895 | return TRUE; | 899 | return TRUE; |
896 | } | 900 | } |
897 | else if ( ( ( HackWidget * ) active ) ->needsOk() ) { | 901 | else if ( ( ( HackWidget * ) active ) ->needsOk() ) { |
898 | QSignal s; | 902 | QSignal s; |
899 | s.connect( active, SLOT( accept() ) ); | 903 | s.connect( active, SLOT( accept() ) ); |
900 | s.activate(); | 904 | s.activate(); |
901 | } | 905 | } |
902 | else { | 906 | else { |
903 | // do the same as with the select key: Map to the default action of the widget: | 907 | // do the same as with the select key: Map to the default action of the widget: |
904 | mapToDefaultAction( ke, Qt::Key_Return ); | 908 | mapToDefaultAction( ke, Qt::Key_Return ); |
905 | } | 909 | } |
906 | } | 910 | } |
907 | } | 911 | } |
908 | } | 912 | } |
909 | else if ( ke->simpleData.keycode == Qt::Key_F30 ) { | 913 | else if ( ke->simpleData.keycode == Qt::Key_F30 ) { |
910 | // Use special "select" key to do whatever default action a widget has | 914 | // Use special "select" key to do whatever default action a widget has |
911 | mapToDefaultAction( ke, Qt::Key_Space ); | 915 | mapToDefaultAction( ke, Qt::Key_Space ); |
912 | } | 916 | } |
913 | else if ( ke->simpleData.keycode == Qt::Key_Escape && | 917 | else if ( ke->simpleData.keycode == Qt::Key_Escape && |
914 | ke->simpleData.is_press ) { | 918 | ke->simpleData.is_press ) { |
915 | // Escape key closes app if focus on toplevel | 919 | // Escape key closes app if focus on toplevel |
916 | QWidget * active = activeWindow(); | 920 | QWidget * active = activeWindow(); |
917 | if ( active && active->testWFlags( WType_TopLevel ) && | 921 | if ( active && active->testWFlags( WType_TopLevel ) && |
918 | ( int ) active->winId() == ke->simpleData.window && | 922 | ( int ) active->winId() == ke->simpleData.window && |
919 | !active->testWFlags( WStyle_Dialog | WStyle_Customize | WType_Popup | WType_Desktop ) ) { | 923 | !active->testWFlags( WStyle_Dialog | WStyle_Customize | WType_Popup | WType_Desktop ) ) { |
920 | if ( active->inherits( "QDialog" ) ) { | 924 | if ( active->inherits( "QDialog" ) ) { |
921 | HackDialog * d = ( HackDialog * ) active; | 925 | HackDialog * d = ( HackDialog * ) active; |
922 | d->rejectIt(); | 926 | d->rejectIt(); |
923 | return TRUE; | 927 | return TRUE; |
924 | } | 928 | } |
925 | else if ( strcmp( argv() [ 0 ], "embeddedkonsole" ) != 0 ) { | 929 | else if ( strcmp( argv() [ 0 ], "embeddedkonsole" ) != 0 ) { |
926 | active->close(); | 930 | active->close(); |
927 | } | 931 | } |
928 | } | 932 | } |
929 | } | 933 | } |
930 | else if ( ke->simpleData.keycode >= Qt::Key_F1 && ke->simpleData.keycode <= Qt::Key_F29 ) { | 934 | else if ( ke->simpleData.keycode >= Qt::Key_F1 && ke->simpleData.keycode <= Qt::Key_F29 ) { |
931 | // this should be if ( ODevice::inst ( )-> buttonForKeycode ( ... )) | 935 | // this should be if ( ODevice::inst ( )-> buttonForKeycode ( ... )) |
932 | // but we cannot access libopie function within libqpe :( | 936 | // but we cannot access libopie function within libqpe :( |
933 | 937 | ||
934 | QWidget * active = activeWindow ( ); | 938 | QWidget * active = activeWindow ( ); |
935 | if ( active && ((int) active-> winId ( ) == ke-> simpleData.window )) { | 939 | if ( active && ((int) active-> winId ( ) == ke-> simpleData.window )) { |
936 | if ( d-> kbgrabbed ) { // we grabbed the keyboard | 940 | if ( d-> kbgrabbed ) { // we grabbed the keyboard |
937 | QChar ch ( ke-> simpleData.unicode ); | 941 | QChar ch ( ke-> simpleData.unicode ); |
938 | QKeyEvent qke ( ke-> simpleData. is_press ? QEvent::KeyPress : QEvent::KeyRelease, | 942 | QKeyEvent qke ( ke-> simpleData. is_press ? QEvent::KeyPress : QEvent::KeyRelease, |
939 | ke-> simpleData.keycode, | 943 | ke-> simpleData.keycode, |
940 | ch. latin1 ( ), | 944 | ch. latin1 ( ), |
941 | ke-> simpleData.modifiers, | 945 | ke-> simpleData.modifiers, |
942 | QString ( ch ), | 946 | QString ( ch ), |
943 | ke-> simpleData.is_auto_repeat, 1 ); | 947 | ke-> simpleData.is_auto_repeat, 1 ); |
944 | 948 | ||
945 | QObject *which = QWidget::keyboardGrabber ( ); | 949 | QObject *which = QWidget::keyboardGrabber ( ); |
946 | if ( !which ) | 950 | if ( !which ) |
947 | which = QApplication::focusWidget ( ); | 951 | which = QApplication::focusWidget ( ); |
948 | if ( !which ) | 952 | if ( !which ) |
949 | which = QApplication::activeWindow ( ); | 953 | which = QApplication::activeWindow ( ); |
950 | if ( !which ) | 954 | if ( !which ) |
951 | which = qApp; | 955 | which = qApp; |
952 | 956 | ||
953 | QApplication::sendEvent ( which, &qke ); | 957 | QApplication::sendEvent ( which, &qke ); |
954 | } | 958 | } |
955 | else { // we didn't grab the keyboard, so send the event to the launcher | 959 | else { // we didn't grab the keyboard, so send the event to the launcher |
956 | QCopEnvelope e ( "QPE/Launcher", "deviceButton(int,int,int)" ); | 960 | QCopEnvelope e ( "QPE/Launcher", "deviceButton(int,int,int)" ); |
957 | e << int( ke-> simpleData.keycode ) << int( ke-> simpleData. is_press ) << int( ke-> simpleData.is_auto_repeat ); | 961 | e << int( ke-> simpleData.keycode ) << int( ke-> simpleData. is_press ) << int( ke-> simpleData.is_auto_repeat ); |
958 | } | 962 | } |
959 | } | 963 | } |
960 | return true; | 964 | return true; |
961 | } | 965 | } |
962 | } | 966 | } |
963 | if ( e->type == QWSEvent::Focus ) { | 967 | if ( e->type == QWSEvent::Focus ) { |
964 | QWSFocusEvent * fe = ( QWSFocusEvent* ) e; | 968 | QWSFocusEvent * fe = ( QWSFocusEvent* ) e; |
965 | if ( !fe->simpleData.get_focus ) { | 969 | if ( !fe->simpleData.get_focus ) { |
966 | QWidget * active = activeWindow(); | 970 | QWidget * active = activeWindow(); |
967 | while ( active && active->isPopup() ) { | 971 | while ( active && active->isPopup() ) { |
968 | active->close(); | 972 | active->close(); |
969 | active = activeWindow(); | 973 | active = activeWindow(); |
970 | } | 974 | } |
971 | } | 975 | } |
972 | else { | 976 | else { |
973 | // make sure our modal widget is ALWAYS on top | 977 | // make sure our modal widget is ALWAYS on top |
974 | QWidget *topm = activeModalWidget(); | 978 | QWidget *topm = activeModalWidget(); |
975 | if ( topm ) { | 979 | if ( topm ) { |
976 | topm->raise(); | 980 | topm->raise(); |
977 | } | 981 | } |
978 | } | 982 | } |
979 | if ( fe->simpleData.get_focus && inputMethodDict ) { | 983 | if ( fe->simpleData.get_focus && inputMethodDict ) { |
980 | InputMethodHint m = inputMethodHint( QWidget::find( e->window() ) ); | 984 | InputMethodHint m = inputMethodHint( QWidget::find( e->window() ) ); |
981 | if ( m == AlwaysOff ) | 985 | if ( m == AlwaysOff ) |
982 | Global::hideInputMethod(); | 986 | Global::hideInputMethod(); |
983 | if ( m == AlwaysOn ) | 987 | if ( m == AlwaysOn ) |
984 | Global::showInputMethod(); | 988 | Global::showInputMethod(); |
985 | } | 989 | } |
986 | } | 990 | } |
987 | 991 | ||
988 | 992 | ||
989 | return QApplication::qwsEventFilter( e ); | 993 | return QApplication::qwsEventFilter( e ); |
990 | } | 994 | } |
991 | #endif | 995 | #endif |
992 | 996 | ||
993 | /*! | 997 | /*! |
994 | Destroys the QPEApplication. | 998 | Destroys the QPEApplication. |
995 | */ | 999 | */ |
996 | QPEApplication::~QPEApplication() | 1000 | QPEApplication::~QPEApplication() |
997 | { | 1001 | { |
998 | ungrabKeyboard(); | 1002 | ungrabKeyboard(); |
999 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 1003 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
1000 | // Need to delete QCopChannels early, since the display will | 1004 | // Need to delete QCopChannels early, since the display will |
1001 | // be gone by the time we get to ~QObject(). | 1005 | // be gone by the time we get to ~QObject(). |
1002 | delete sysChannel; | 1006 | delete sysChannel; |
1003 | delete pidChannel; | 1007 | delete pidChannel; |
1004 | #endif | 1008 | #endif |
1005 | 1009 | ||
1006 | delete d; | 1010 | delete d; |
1007 | } | 1011 | } |
1008 | 1012 | ||
1009 | /*! | 1013 | /*! |
1010 | Returns <tt>$OPIEDIR/</tt>. | 1014 | Returns <tt>$OPIEDIR/</tt>. |
1011 | */ | 1015 | */ |
1012 | QString QPEApplication::qpeDir() | 1016 | QString QPEApplication::qpeDir() |
1013 | { | 1017 | { |
1014 | const char * base = getenv( "OPIEDIR" ); | 1018 | const char * base = getenv( "OPIEDIR" ); |
1015 | if ( base ) | 1019 | if ( base ) |
1016 | return QString( base ) + "/"; | 1020 | return QString( base ) + "/"; |
1017 | 1021 | ||
1018 | return QString( "../" ); | 1022 | return QString( "../" ); |
1019 | } | 1023 | } |
1020 | 1024 | ||
1021 | /*! | 1025 | /*! |
1022 | Returns the user's current Document directory. There is a trailing "/". | 1026 | Returns the user's current Document directory. There is a trailing "/". |
1023 | .. well, it does now,, and there's no trailing '/' | 1027 | .. well, it does now,, and there's no trailing '/' |
1024 | */ | 1028 | */ |
1025 | QString QPEApplication::documentDir() | 1029 | QString QPEApplication::documentDir() |
1026 | { | 1030 | { |
1027 | const char* base = getenv( "HOME"); | 1031 | const char* base = getenv( "HOME"); |
1028 | if ( base ) | 1032 | if ( base ) |
1029 | return QString( base ) + "/Documents"; | 1033 | return QString( base ) + "/Documents"; |
1030 | 1034 | ||
1031 | return QString( "../Documents" ); | 1035 | return QString( "../Documents" ); |
1032 | } | 1036 | } |
1033 | 1037 | ||
1034 | static int deforient = -1; | 1038 | static int deforient = -1; |
1035 | 1039 | ||
1036 | /*! | 1040 | /*! |
1037 | \internal | 1041 | \internal |
1038 | */ | 1042 | */ |
1039 | int QPEApplication::defaultRotation() | 1043 | int QPEApplication::defaultRotation() |
1040 | { | 1044 | { |
1041 | if ( deforient < 0 ) { | 1045 | if ( deforient < 0 ) { |
1042 | QString d = getenv( "QWS_DISPLAY" ); | 1046 | QString d = getenv( "QWS_DISPLAY" ); |
1043 | if ( d.contains( "Rot90" ) ) { | 1047 | if ( d.contains( "Rot90" ) ) { |
1044 | deforient = 90; | 1048 | deforient = 90; |
1045 | } | 1049 | } |
1046 | else if ( d.contains( "Rot180" ) ) { | 1050 | else if ( d.contains( "Rot180" ) ) { |
1047 | deforient = 180; | 1051 | deforient = 180; |
1048 | } | 1052 | } |
1049 | else if ( d.contains( "Rot270" ) ) { | 1053 | else if ( d.contains( "Rot270" ) ) { |
1050 | deforient = 270; | 1054 | deforient = 270; |
1051 | } | 1055 | } |
1052 | else { | 1056 | else { |
1053 | deforient = 0; | 1057 | deforient = 0; |
1054 | } | 1058 | } |
1055 | } | 1059 | } |
1056 | return deforient; | 1060 | return deforient; |
1057 | } | 1061 | } |
1058 | 1062 | ||
1059 | /*! | 1063 | /*! |
1060 | \internal | 1064 | \internal |
1061 | */ | 1065 | */ |
1062 | void QPEApplication::setDefaultRotation( int r ) | 1066 | void QPEApplication::setDefaultRotation( int r ) |
1063 | { | 1067 | { |
1064 | if ( qApp->type() == GuiServer ) { | 1068 | if ( qApp->type() == GuiServer ) { |
1065 | deforient = r; | 1069 | deforient = r; |
1066 | setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 ); | 1070 | setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 ); |
1067 | Config config("qpe"); | 1071 | Config config("qpe"); |
1068 | config.setGroup( "Rotation" ); | 1072 | config.setGroup( "Rotation" ); |
1069 | config.writeEntry( "Rot", r ); | 1073 | config.writeEntry( "Rot", r ); |
1070 | } | 1074 | } |
1071 | else { | 1075 | else { |
1072 | #ifndef QT_NO_COP | 1076 | #ifndef QT_NO_COP |
1073 | { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" ); | 1077 | { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" ); |
1074 | e << r; | 1078 | e << r; |
1075 | } | 1079 | } |
1076 | #endif | 1080 | #endif |
1077 | 1081 | ||
1078 | } | 1082 | } |
1079 | } | 1083 | } |
1080 | 1084 | ||
1081 | #include <qgfx_qws.h> | 1085 | #include <qgfx_qws.h> |
1082 | #include <qwindowsystem_qws.h> | 1086 | #include <qwindowsystem_qws.h> |
1083 | #include <qpixmapcache.h> | 1087 | #include <qpixmapcache.h> |
1084 | 1088 | ||
1085 | extern void qws_clearLoadedFonts(); | 1089 | extern void qws_clearLoadedFonts(); |
1086 | 1090 | ||
1087 | void QPEApplication::setCurrentMode( int x, int y, int depth ) | 1091 | void QPEApplication::setCurrentMode( int x, int y, int depth ) |
1088 | { | 1092 | { |
1089 | // Reset the caches | 1093 | // Reset the caches |
1090 | qws_clearLoadedFonts(); | 1094 | qws_clearLoadedFonts(); |
1091 | QPixmapCache::clear(); | 1095 | QPixmapCache::clear(); |
1092 | 1096 | ||
1093 | // Change the screen mode | 1097 | // Change the screen mode |
1094 | qt_screen->setMode(x, y, depth); | 1098 | qt_screen->setMode(x, y, depth); |
1095 | 1099 | ||
1096 | if ( qApp->type() == GuiServer ) { | 1100 | if ( qApp->type() == GuiServer ) { |
1097 | // Reconfigure the GuiServer | 1101 | // Reconfigure the GuiServer |
1098 | qwsServer->beginDisplayReconfigure(); | 1102 | qwsServer->beginDisplayReconfigure(); |
1099 | qwsServer->endDisplayReconfigure(); | 1103 | qwsServer->endDisplayReconfigure(); |
1100 | 1104 | ||
1101 | // Get all the running apps to reset | 1105 | // Get all the running apps to reset |
1102 | QCopEnvelope env( "QPE/System", "reset()" ); | 1106 | QCopEnvelope env( "QPE/System", "reset()" ); |
1103 | } | 1107 | } |
1104 | } | 1108 | } |
1105 | 1109 | ||
1106 | void QPEApplication::reset() { | 1110 | void QPEApplication::reset() { |
1107 | // Reconnect to the screen | 1111 | // Reconnect to the screen |
1108 | qt_screen->disconnect(); | 1112 | qt_screen->disconnect(); |
1109 | qt_screen->connect( QString::null ); | 1113 | qt_screen->connect( QString::null ); |
1110 | 1114 | ||
1111 | // Redraw everything | 1115 | // Redraw everything |
1112 | applyStyle(); | 1116 | applyStyle(); |
1113 | } | 1117 | } |
1114 | 1118 | ||
1115 | /*! | 1119 | /*! |
1116 | \internal | 1120 | \internal |
1117 | */ | 1121 | */ |
1118 | void QPEApplication::applyStyle() | 1122 | void QPEApplication::applyStyle() |
1119 | { | 1123 | { |
1120 | Config config( "qpe" ); | 1124 | Config config( "qpe" ); |
1121 | config.setGroup( "Appearance" ); | 1125 | config.setGroup( "Appearance" ); |
1122 | 1126 | ||
1123 | #if QT_VERSION > 233 | 1127 | #if QT_VERSION > 233 |
1124 | // don't block ourselves ... | 1128 | // don't block ourselves ... |
1125 | Opie::force_appearance = 0; | 1129 | Opie::force_appearance = 0; |
1126 | 1130 | ||
1127 | static QString appname = Opie::binaryName ( ); | 1131 | static QString appname = Opie::binaryName ( ); |
1128 | 1132 | ||
1129 | QStringList ex = config. readListEntry ( "NoStyle", ';' ); | 1133 | QStringList ex = config. readListEntry ( "NoStyle", ';' ); |
1130 | int nostyle = 0; | 1134 | int nostyle = 0; |
1131 | for ( QStringList::Iterator it = ex. begin ( ); it != ex. end ( ); ++it ) { | 1135 | for ( QStringList::Iterator it = ex. begin ( ); it != ex. end ( ); ++it ) { |
1132 | if ( QRegExp (( *it ). mid ( 1 ), false, true ). find ( appname, 0 ) >= 0 ) { | 1136 | if ( QRegExp (( *it ). mid ( 1 ), false, true ). find ( appname, 0 ) >= 0 ) { |
1133 | nostyle = ( *it ). left ( 1 ). toInt ( 0, 32 ); | 1137 | nostyle = ( *it ). left ( 1 ). toInt ( 0, 32 ); |
1134 | break; | 1138 | break; |
1135 | } | 1139 | } |
1136 | } | 1140 | } |
1137 | 1141 | ||
1138 | // Widget style | 1142 | // Widget style |
1139 | QString style = config.readEntry( "Style", "FlatStyle" ); | 1143 | QString style = config.readEntry( "Style", "FlatStyle" ); |
1140 | 1144 | ||
1141 | // don't set a custom style | 1145 | // don't set a custom style |
1142 | if ( nostyle & Opie::Force_Style ) | 1146 | if ( nostyle & Opie::Force_Style ) |
1143 | style = "FlatStyle"; | 1147 | style = "FlatStyle"; |
1144 | 1148 | ||
1145 | internalSetStyle ( style ); | 1149 | internalSetStyle ( style ); |
1146 | 1150 | ||
1147 | // Colors - from /etc/colors/Liquid.scheme | 1151 | // Colors - from /etc/colors/Liquid.scheme |
1148 | QColor bgcolor( config.readEntry( "Background", "#E0E0E0" ) ); | 1152 | QColor bgcolor( config.readEntry( "Background", "#E0E0E0" ) ); |
1149 | QColor btncolor( config.readEntry( "Button", "#96c8fa" ) ); | 1153 | QColor btncolor( config.readEntry( "Button", "#96c8fa" ) ); |
1150 | QPalette pal( btncolor, bgcolor ); | 1154 | QPalette pal( btncolor, bgcolor ); |
1151 | QString color = config.readEntry( "Highlight", "#73adef" ); | 1155 | QString color = config.readEntry( "Highlight", "#73adef" ); |
1152 | pal.setColor( QColorGroup::Highlight, QColor( color ) ); | 1156 | pal.setColor( QColorGroup::Highlight, QColor( color ) ); |
1153 | color = config.readEntry( "HighlightedText", "#FFFFFF" ); | 1157 | color = config.readEntry( "HighlightedText", "#FFFFFF" ); |
1154 | pal.setColor( QColorGroup::HighlightedText, QColor( color ) ); | 1158 | pal.setColor( QColorGroup::HighlightedText, QColor( color ) ); |
1155 | color = config.readEntry( "Text", "#000000" ); | 1159 | color = config.readEntry( "Text", "#000000" ); |
1156 | pal.setColor( QColorGroup::Text, QColor( color ) ); | 1160 | pal.setColor( QColorGroup::Text, QColor( color ) ); |
1157 | color = config.readEntry( "ButtonText", "#000000" ); | 1161 | color = config.readEntry( "ButtonText", "#000000" ); |
1158 | pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) ); | 1162 | pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) ); |
1159 | color = config.readEntry( "Base", "#FFFFFF" ); | 1163 | color = config.readEntry( "Base", "#FFFFFF" ); |
1160 | pal.setColor( QColorGroup::Base, QColor( color ) ); | 1164 | pal.setColor( QColorGroup::Base, QColor( color ) ); |
1161 | 1165 | ||
1162 | pal.setColor( QPalette::Disabled, QColorGroup::Text, | 1166 | pal.setColor( QPalette::Disabled, QColorGroup::Text, |
1163 | pal.color( QPalette::Active, QColorGroup::Background ).dark() ); | 1167 | pal.color( QPalette::Active, QColorGroup::Background ).dark() ); |
1164 | 1168 | ||
1165 | setPalette( pal, TRUE ); | 1169 | setPalette( pal, TRUE ); |
1166 | 1170 | ||
1167 | // Window Decoration | 1171 | // Window Decoration |
1168 | QString dec = config.readEntry( "Decoration", "Flat" ); | 1172 | QString dec = config.readEntry( "Decoration", "Flat" ); |
1169 | 1173 | ||
1170 | // don't set a custom deco | 1174 | // don't set a custom deco |
1171 | if ( nostyle & Opie::Force_Decoration ) | 1175 | if ( nostyle & Opie::Force_Decoration ) |
1172 | dec = ""; | 1176 | dec = ""; |
1173 | 1177 | ||
1174 | //qDebug ( "Setting Deco: %s -- old %s (%d)", dec.latin1(), d-> decorationName.latin1(), nostyle); | 1178 | //qDebug ( "Setting Deco: %s -- old %s (%d)", dec.latin1(), d-> decorationName.latin1(), nostyle); |
1175 | 1179 | ||
1176 | if ( dec != d->decorationName ) { | 1180 | if ( dec != d->decorationName ) { |
1177 | qwsSetDecoration( new QPEDecoration( dec ) ); | 1181 | qwsSetDecoration( new QPEDecoration( dec ) ); |
1178 | d->decorationName = dec; | 1182 | d->decorationName = dec; |
1179 | } | 1183 | } |
1180 | 1184 | ||
1181 | // Font | 1185 | // Font |
1182 | QString ff = config.readEntry( "FontFamily", font().family() ); | 1186 | QString ff = config.readEntry( "FontFamily", font().family() ); |
1183 | int fs = config.readNumEntry( "FontSize", font().pointSize() ); | 1187 | int fs = config.readNumEntry( "FontSize", font().pointSize() ); |
1184 | 1188 | ||
1185 | // don't set a custom font | 1189 | // don't set a custom font |
1186 | if ( nostyle & Opie::Force_Font ) { | 1190 | if ( nostyle & Opie::Force_Font ) { |
1187 | ff = "Vera"; | 1191 | ff = "Vera"; |
1188 | fs = 10; | 1192 | fs = 10; |
1189 | } | 1193 | } |
1190 | 1194 | ||
1191 | setFont ( QFont ( ff, fs ), true ); | 1195 | setFont ( QFont ( ff, fs ), true ); |
1192 | 1196 | ||
1193 | // revert to global blocking policy ... | 1197 | // revert to global blocking policy ... |
1194 | Opie::force_appearance = config. readBoolEntry ( "ForceStyle", false ) ? Opie::Force_All : Opie::Force_None; | 1198 | Opie::force_appearance = config. readBoolEntry ( "ForceStyle", false ) ? Opie::Force_All : Opie::Force_None; |
1195 | Opie::force_appearance &= ~nostyle; | 1199 | Opie::force_appearance &= ~nostyle; |
1196 | #endif | 1200 | #endif |
1197 | } | 1201 | } |
1198 | 1202 | ||
1199 | void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data ) | 1203 | void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data ) |
1200 | { | 1204 | { |
1201 | #ifdef Q_WS_QWS | 1205 | #ifdef Q_WS_QWS |
1202 | QDataStream stream( data, IO_ReadOnly ); | 1206 | QDataStream stream( data, IO_ReadOnly ); |
1203 | if ( msg == "applyStyle()" ) { | 1207 | if ( msg == "applyStyle()" ) { |
1204 | applyStyle(); | 1208 | applyStyle(); |
1205 | } | 1209 | } |
1206 | else if ( msg == "toggleApplicationMenu()" ) { | 1210 | else if ( msg == "toggleApplicationMenu()" ) { |
1207 | QWidget *active = activeWindow ( ); | 1211 | QWidget *active = activeWindow ( ); |
1208 | 1212 | ||
1209 | if ( active ) { | 1213 | if ( active ) { |
1210 | QPEMenuToolFocusManager *man = QPEMenuToolFocusManager::manager ( ); | 1214 | QPEMenuToolFocusManager *man = QPEMenuToolFocusManager::manager ( ); |
1211 | bool oldactive = man-> isActive ( ); | 1215 | bool oldactive = man-> isActive ( ); |
1212 | 1216 | ||
1213 | man-> setActive( !man-> isActive() ); | 1217 | man-> setActive( !man-> isActive() ); |
1214 | 1218 | ||
1215 | if ( !oldactive && !man-> isActive ( )) { // no menubar to toggle -> try O-Menu | 1219 | if ( !oldactive && !man-> isActive ( )) { // no menubar to toggle -> try O-Menu |
1216 | QCopEnvelope e ( "QPE/TaskBar", "toggleStartMenu()" ); | 1220 | QCopEnvelope e ( "QPE/TaskBar", "toggleStartMenu()" ); |
1217 | } | 1221 | } |
1218 | } | 1222 | } |
1219 | } | 1223 | } |
1220 | else if ( msg == "setDefaultRotation(int)" ) { | 1224 | else if ( msg == "setDefaultRotation(int)" ) { |
1221 | if ( type() == GuiServer ) { | 1225 | if ( type() == GuiServer ) { |
1222 | int r; | 1226 | int r; |
1223 | stream >> r; | 1227 | stream >> r; |
1224 | setDefaultRotation( r ); | 1228 | setDefaultRotation( r ); |
1225 | } | 1229 | } |
1226 | } | 1230 | } |
1227 | else if ( msg == "setCurrentMode(int,int,int)" ) { // Added: 2003-06-11 by Tim Ansell <mithro@mithis.net> | 1231 | else if ( msg == "setCurrentMode(int,int,int)" ) { // Added: 2003-06-11 by Tim Ansell <mithro@mithis.net> |
1228 | if ( type() == GuiServer ) { | 1232 | if ( type() == GuiServer ) { |
1229 | int x, y, depth; | 1233 | int x, y, depth; |
1230 | stream >> x; | 1234 | stream >> x; |
1231 | stream >> y; | 1235 | stream >> y; |
1232 | stream >> depth; | 1236 | stream >> depth; |
1233 | setCurrentMode( x, y, depth ); | 1237 | setCurrentMode( x, y, depth ); |
1234 | } | 1238 | } |
1235 | } | 1239 | } |
1236 | else if ( msg == "reset()" ) { | 1240 | else if ( msg == "reset()" ) { |
1237 | if ( type() != GuiServer ) | 1241 | if ( type() != GuiServer ) |
1238 | reset(); | 1242 | reset(); |
1239 | } | 1243 | } |
1240 | else if ( msg == "setCurrentRotation(int)" ) { | 1244 | else if ( msg == "setCurrentRotation(int)" ) { |
1241 | int r; | 1245 | int r; |
1242 | stream >> r; | 1246 | stream >> r; |
1243 | setCurrentRotation( r ); | 1247 | setCurrentRotation( r ); |
1244 | } | 1248 | } |
1245 | else if ( msg == "shutdown()" ) { | 1249 | else if ( msg == "shutdown()" ) { |
1246 | if ( type() == GuiServer ) | 1250 | if ( type() == GuiServer ) |
1247 | shutdown(); | 1251 | shutdown(); |
1248 | } | 1252 | } |
1249 | else if ( msg == "quit()" ) { | 1253 | else if ( msg == "quit()" ) { |
1250 | if ( type() != GuiServer ) | 1254 | if ( type() != GuiServer ) |
1251 | tryQuit(); | 1255 | tryQuit(); |
1252 | } | 1256 | } |
1253 | else if ( msg == "forceQuit()" ) { | 1257 | else if ( msg == "forceQuit()" ) { |
1254 | if ( type() != GuiServer ) | 1258 | if ( type() != GuiServer ) |
1255 | quit(); | 1259 | quit(); |
1256 | } | 1260 | } |
1257 | else if ( msg == "restart()" ) { | 1261 | else if ( msg == "restart()" ) { |
1258 | if ( type() == GuiServer ) | 1262 | if ( type() == GuiServer ) |
1259 | restart(); | 1263 | restart(); |
1260 | } | 1264 | } |
1261 | else if ( msg == "language(QString)" ) { | 1265 | else if ( msg == "language(QString)" ) { |
1262 | if ( type() == GuiServer ) { | 1266 | if ( type() == GuiServer ) { |
1263 | QString l; | 1267 | QString l; |
1264 | stream >> l; | 1268 | stream >> l; |
1265 | QString cl = getenv( "LANG" ); | 1269 | QString cl = getenv( "LANG" ); |
1266 | if ( cl != l ) { | 1270 | if ( cl != l ) { |
1267 | if ( l.isNull() ) | 1271 | if ( l.isNull() ) |
1268 | unsetenv( "LANG" ); | 1272 | unsetenv( "LANG" ); |
1269 | else | 1273 | else |
1270 | setenv( "LANG", l.latin1(), 1 ); | 1274 | setenv( "LANG", l.latin1(), 1 ); |
1271 | restart(); | 1275 | restart(); |
1272 | } | 1276 | } |
1273 | } | 1277 | } |
1274 | } | 1278 | } |
1275 | else if ( msg == "timeChange(QString)" ) { | 1279 | else if ( msg == "timeChange(QString)" ) { |
1276 | QString t; | 1280 | QString t; |
1277 | stream >> t; | 1281 | stream >> t; |
1278 | if ( t.isNull() ) | 1282 | if ( t.isNull() ) |
1279 | unsetenv( "TZ" ); | 1283 | unsetenv( "TZ" ); |
1280 | else | 1284 | else |
1281 | setenv( "TZ", t.latin1(), 1 ); | 1285 | setenv( "TZ", t.latin1(), 1 ); |
1282 | // emit the signal so everyone else knows... | 1286 | // emit the signal so everyone else knows... |
1283 | emit timeChanged(); | 1287 | emit timeChanged(); |
1284 | } | 1288 | } |
1285 | else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) { | 1289 | else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) { |
1286 | if ( type() == GuiServer ) { | 1290 | if ( type() == GuiServer ) { |
1287 | QDateTime when; | 1291 | QDateTime when; |
1288 | QCString channel, message; | 1292 | QCString channel, message; |
1289 | int data; | 1293 | int data; |
1290 | stream >> when >> channel >> message >> data; | 1294 | stream >> when >> channel >> message >> data; |
1291 | AlarmServer::addAlarm( when, channel, message, data ); | 1295 | AlarmServer::addAlarm( when, channel, message, data ); |
1292 | } | 1296 | } |
1293 | } | 1297 | } |
1294 | else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) { | 1298 | else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) { |
1295 | if ( type() == GuiServer ) { | 1299 | if ( type() == GuiServer ) { |
1296 | QDateTime when; | 1300 | QDateTime when; |
1297 | QCString channel, message; | 1301 | QCString channel, message; |
1298 | int data; | 1302 | int data; |
1299 | stream >> when >> channel >> message >> data; | 1303 | stream >> when >> channel >> message >> data; |
1300 | AlarmServer::deleteAlarm( when, channel, message, data ); | 1304 | AlarmServer::deleteAlarm( when, channel, message, data ); |
1301 | } | 1305 | } |
1302 | } | 1306 | } |
1303 | else if ( msg == "clockChange(bool)" ) { | 1307 | else if ( msg == "clockChange(bool)" ) { |
1304 | int tmp; | 1308 | int tmp; |
1305 | stream >> tmp; | 1309 | stream >> tmp; |
1306 | emit clockChanged( tmp ); | 1310 | emit clockChanged( tmp ); |
1307 | } | 1311 | } |
1308 | else if ( msg == "weekChange(bool)" ) { | 1312 | else if ( msg == "weekChange(bool)" ) { |
1309 | int tmp; | 1313 | int tmp; |
1310 | stream >> tmp; | 1314 | stream >> tmp; |
1311 | emit weekChanged( tmp ); | 1315 | emit weekChanged( tmp ); |
1312 | } | 1316 | } |
1313 | else if ( msg == "setDateFormat(DateFormat)" ) { | 1317 | else if ( msg == "setDateFormat(DateFormat)" ) { |
1314 | DateFormat tmp; | 1318 | DateFormat tmp; |
1315 | stream >> tmp; | 1319 | stream >> tmp; |
1316 | emit dateFormatChanged( tmp ); | 1320 | emit dateFormatChanged( tmp ); |
1317 | } | 1321 | } |
1318 | else if ( msg == "setVolume(int,int)" ) { | 1322 | else if ( msg == "setVolume(int,int)" ) { |
1319 | int t, v; | 1323 | int t, v; |
1320 | stream >> t >> v; | 1324 | stream >> t >> v; |
1321 | setVolume( t, v ); | 1325 | setVolume( t, v ); |
1322 | emit volumeChanged( muted ); | 1326 | emit volumeChanged( muted ); |
1323 | } | 1327 | } |
1324 | else if ( msg == "volumeChange(bool)" ) { | 1328 | else if ( msg == "volumeChange(bool)" ) { |
1325 | stream >> muted; | 1329 | stream >> muted; |
1326 | setVolume(); | 1330 | setVolume(); |
1327 | emit volumeChanged( muted ); | 1331 | emit volumeChanged( muted ); |
1328 | } | 1332 | } |
1329 | else if ( msg == "setMic(int,int)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> | 1333 | else if ( msg == "setMic(int,int)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> |
1330 | int t, v; | 1334 | int t, v; |
1331 | stream >> t >> v; | 1335 | stream >> t >> v; |
1332 | setMic( t, v ); | 1336 | setMic( t, v ); |
1333 | emit micChanged( micMuted ); | 1337 | emit micChanged( micMuted ); |
1334 | } | 1338 | } |
1335 | else if ( msg == "micChange(bool)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> | 1339 | else if ( msg == "micChange(bool)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> |
1336 | stream >> micMuted; | 1340 | stream >> micMuted; |
1337 | setMic(); | 1341 | setMic(); |
1338 | emit micChanged( micMuted ); | 1342 | emit micChanged( micMuted ); |
1339 | } | 1343 | } |
1340 | else if ( msg == "setBass(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> | 1344 | else if ( msg == "setBass(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> |
1341 | int t, v; | 1345 | int t, v; |
1342 | stream >> t >> v; | 1346 | stream >> t >> v; |
1343 | setBass( t, v ); | 1347 | setBass( t, v ); |
1344 | } | 1348 | } |
1345 | else if ( msg == "bassChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> | 1349 | else if ( msg == "bassChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> |
1346 | setBass(); | 1350 | setBass(); |
1347 | } | 1351 | } |
1348 | else if ( msg == "setTreble(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> | 1352 | else if ( msg == "setTreble(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> |
1349 | int t, v; | 1353 | int t, v; |
1350 | stream >> t >> v; | 1354 | stream >> t >> v; |
1351 | setTreble( t, v ); | 1355 | setTreble( t, v ); |
1352 | } | 1356 | } |
1353 | else if ( msg == "trebleChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> | 1357 | else if ( msg == "trebleChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> |
1354 | setTreble(); | 1358 | setTreble(); |
1355 | } else if ( msg == "getMarkedText()" ) { | 1359 | } else if ( msg == "getMarkedText()" ) { |
1356 | if ( type() == GuiServer ) { | 1360 | if ( type() == GuiServer ) { |
1357 | const ushort unicode = 'C'-'@'; | 1361 | const ushort unicode = 'C'-'@'; |
1358 | const int scan = Key_C; | 1362 | const int scan = Key_C; |
1359 | qwsServer->processKeyEvent( unicode, scan, ControlButton, TRUE, FALSE ); | 1363 | qwsServer->processKeyEvent( unicode, scan, ControlButton, TRUE, FALSE ); |
1360 | qwsServer->processKeyEvent( unicode, scan, ControlButton, FALSE, FALSE ); | 1364 | qwsServer->processKeyEvent( unicode, scan, ControlButton, FALSE, FALSE ); |
1361 | } | 1365 | } |
1362 | } else if ( msg == "newChannel(QString)") { | 1366 | } else if ( msg == "newChannel(QString)") { |
1363 | QString myChannel = "QPE/Application/" + d->appName; | 1367 | QString myChannel = "QPE/Application/" + d->appName; |
1364 | QString channel; | 1368 | QString channel; |
1365 | stream >> channel; | 1369 | stream >> channel; |
1366 | if (channel == myChannel) { | 1370 | if (channel == myChannel) { |
1367 | processQCopFile(); | 1371 | processQCopFile(); |
1368 | d->sendQCopQ(); | 1372 | d->sendQCopQ(); |
1369 | } | 1373 | } |
1370 | } | 1374 | } |
1371 | 1375 | ||
1372 | 1376 | ||
1373 | #endif | 1377 | #endif |
1374 | } | 1378 | } |
1375 | 1379 | ||
1376 | 1380 | ||
1377 | 1381 | ||
1378 | 1382 | ||
1379 | 1383 | ||
1380 | /*! | 1384 | /*! |
1381 | \internal | 1385 | \internal |
1382 | */ | 1386 | */ |
1383 | bool QPEApplication::raiseAppropriateWindow() | 1387 | bool QPEApplication::raiseAppropriateWindow() |
1384 | { | 1388 | { |
1385 | bool r=FALSE; | 1389 | bool r=FALSE; |
1386 | 1390 | ||
1387 | // 1. Raise the main widget | 1391 | // 1. Raise the main widget |
1388 | QWidget *top = d->qpe_main_widget; | 1392 | QWidget *top = d->qpe_main_widget; |
1389 | if ( !top ) top = mainWidget(); | 1393 | if ( !top ) top = mainWidget(); |
1390 | 1394 | ||
1391 | if ( top && d->keep_running ) { | 1395 | if ( top && d->keep_running ) { |
1392 | if ( top->isVisible() ) | 1396 | if ( top->isVisible() ) |
1393 | r = TRUE; | 1397 | r = TRUE; |
1394 | else if (d->preloaded) { | 1398 | else if (d->preloaded) { |
1395 | // We are preloaded and not visible.. pretend we just started.. | 1399 | // We are preloaded and not visible.. pretend we just started.. |
1396 | #ifndef QT_NO_COP | 1400 | #ifndef QT_NO_COP |
1397 | QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); | 1401 | QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); |
1398 | e << d->appName; | 1402 | e << d->appName; |
1399 | #endif | 1403 | #endif |
1400 | } | 1404 | } |
1401 | 1405 | ||
1402 | d->show_mx(top,d->nomaximize, d->appName); | 1406 | d->show_mx(top,d->nomaximize, d->appName); |
1403 | top->raise(); | 1407 | top->raise(); |
1404 | } | 1408 | } |
1405 | 1409 | ||
1406 | QWidget *topm = activeModalWidget(); | 1410 | QWidget *topm = activeModalWidget(); |
1407 | 1411 | ||
1408 | // 2. Raise any parentless widgets (except top and topm, as they | 1412 | // 2. Raise any parentless widgets (except top and topm, as they |
1409 | // are raised before and after this loop). Order from most | 1413 | // are raised before and after this loop). Order from most |
1410 | // recently raised as deepest to least recently as top, so | 1414 | // recently raised as deepest to least recently as top, so |
1411 | // that repeated calls cycle through widgets. | 1415 | // that repeated calls cycle through widgets. |
1412 | QWidgetList *list = topLevelWidgets(); | 1416 | QWidgetList *list = topLevelWidgets(); |
1413 | if ( list ) { | 1417 | if ( list ) { |
1414 | bool foundlast = FALSE; | 1418 | bool foundlast = FALSE; |
1415 | QWidget* topsub = 0; | 1419 | QWidget* topsub = 0; |
1416 | if ( d->lastraised ) { | 1420 | if ( d->lastraised ) { |
1417 | for (QWidget* w = list->first(); w; w = list->next()) { | 1421 | for (QWidget* w = list->first(); w; w = list->next()) { |
1418 | if ( !w->parentWidget() && w != topm && w->isVisible() && !w->isDesktop() ) { | 1422 | if ( !w->parentWidget() && w != topm && w->isVisible() && !w->isDesktop() ) { |
1419 | if ( w == d->lastraised ) | 1423 | if ( w == d->lastraised ) |
1420 | foundlast = TRUE; | 1424 | foundlast = TRUE; |
1421 | if ( foundlast ) { | 1425 | if ( foundlast ) { |
1422 | w->raise(); | 1426 | w->raise(); |
1423 | topsub = w; | 1427 | topsub = w; |
1424 | } | 1428 | } |
1425 | } | 1429 | } |
1426 | } | 1430 | } |
1427 | } | 1431 | } |
1428 | for (QWidget* w = list->first(); w; w = list->next()) { | 1432 | for (QWidget* w = list->first(); w; w = list->next()) { |
1429 | if ( !w->parentWidget() && w != topm && w->isVisible() && !w->isDesktop() ) { | 1433 | if ( !w->parentWidget() && w != topm && w->isVisible() && !w->isDesktop() ) { |
1430 | if ( w == d->lastraised ) | 1434 | if ( w == d->lastraised ) |
1431 | break; | 1435 | break; |
1432 | w->raise(); | 1436 | w->raise(); |
1433 | topsub = w; | 1437 | topsub = w; |
1434 | } | 1438 | } |
1435 | } | 1439 | } |
1436 | d->lastraised = topsub; | 1440 | d->lastraised = topsub; |
1437 | delete list; | 1441 | delete list; |
1438 | } | 1442 | } |
1439 | 1443 | ||
1440 | // 3. Raise the active modal widget. | 1444 | // 3. Raise the active modal widget. |
1441 | if ( topm && topm != top ) { | 1445 | if ( topm && topm != top ) { |
1442 | topm->show(); | 1446 | topm->show(); |
1443 | topm->raise(); | 1447 | topm->raise(); |
1444 | // If we haven't already handled the fastAppShowing message | 1448 | // If we haven't already handled the fastAppShowing message |
1445 | if (!top && d->preloaded) { | 1449 | if (!top && d->preloaded) { |
1446 | #ifndef QT_NO_COP | 1450 | #ifndef QT_NO_COP |
1447 | QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); | 1451 | QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); |
1448 | e << d->appName; | 1452 | e << d->appName; |
1449 | #endif | 1453 | #endif |
1450 | } | 1454 | } |
1451 | r = FALSE; | 1455 | r = FALSE; |
1452 | } | 1456 | } |
1453 | 1457 | ||
1454 | return r; | 1458 | return r; |
1455 | } | 1459 | } |
1456 | 1460 | ||
1457 | 1461 | ||
1458 | void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data) | 1462 | void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data) |
1459 | { | 1463 | { |
1460 | #ifdef Q_WS_QWS | 1464 | #ifdef Q_WS_QWS |
1461 | 1465 | ||
1462 | if ( msg == "quit()" ) { | 1466 | if ( msg == "quit()" ) { |
1463 | tryQuit(); | 1467 | tryQuit(); |
1464 | } | 1468 | } |
1465 | else if ( msg == "quitIfInvisible()" ) { | 1469 | else if ( msg == "quitIfInvisible()" ) { |
1466 | if ( d->qpe_main_widget && !d->qpe_main_widget->isVisible() ) | 1470 | if ( d->qpe_main_widget && !d->qpe_main_widget->isVisible() ) |
1467 | quit(); | 1471 | quit(); |
1468 | } | 1472 | } |
1469 | else if ( msg == "close()" ) { | 1473 | else if ( msg == "close()" ) { |
1470 | hideOrQuit(); | 1474 | hideOrQuit(); |
1471 | } | 1475 | } |
1472 | else if ( msg == "disablePreload()" ) { | 1476 | else if ( msg == "disablePreload()" ) { |
1473 | d->preloaded = FALSE; | 1477 | d->preloaded = FALSE; |
1474 | d->keep_running = TRUE; | 1478 | d->keep_running = TRUE; |
1475 | /* so that quit will quit */ | 1479 | /* so that quit will quit */ |
1476 | } | 1480 | } |
1477 | else if ( msg == "enablePreload()" ) { | 1481 | else if ( msg == "enablePreload()" ) { |
1478 | if (d->qpe_main_widget) | 1482 | if (d->qpe_main_widget) |
1479 | d->preloaded = TRUE; | 1483 | d->preloaded = TRUE; |
1480 | d->keep_running = TRUE; | 1484 | d->keep_running = TRUE; |
1481 | /* so next quit won't quit */ | 1485 | /* so next quit won't quit */ |
1482 | } | 1486 | } |
1483 | else if ( msg == "raise()" ) { | 1487 | else if ( msg == "raise()" ) { |
1484 | d->keep_running = TRUE; | 1488 | d->keep_running = TRUE; |
1485 | d->notbusysent = FALSE; | 1489 | d->notbusysent = FALSE; |
1486 | raiseAppropriateWindow(); | 1490 | raiseAppropriateWindow(); |
1487 | // Tell the system we're still chugging along... | 1491 | // Tell the system we're still chugging along... |
1488 | QCopEnvelope e("QPE/System", "appRaised(QString)"); | 1492 | QCopEnvelope e("QPE/System", "appRaised(QString)"); |
1489 | e << d->appName; | 1493 | e << d->appName; |
1490 | } | 1494 | } |
1491 | else if ( msg == "flush()" ) { | 1495 | else if ( msg == "flush()" ) { |
1492 | emit flush(); | 1496 | emit flush(); |
1493 | // we need to tell the desktop | 1497 | // we need to tell the desktop |
1494 | QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" ); | 1498 | QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" ); |
1495 | e << d->appName; | 1499 | e << d->appName; |
1496 | } | 1500 | } |
1497 | else if ( msg == "reload()" ) { | 1501 | else if ( msg == "reload()" ) { |
1498 | emit reload(); | 1502 | emit reload(); |
1499 | } | 1503 | } |
1500 | else if ( msg == "setDocument(QString)" ) { | 1504 | else if ( msg == "setDocument(QString)" ) { |
1501 | d->keep_running = TRUE; | 1505 | d->keep_running = TRUE; |
1502 | QDataStream stream( data, IO_ReadOnly ); | 1506 | QDataStream stream( data, IO_ReadOnly ); |
1503 | QString doc; | 1507 | QString doc; |
1504 | stream >> doc; | 1508 | stream >> doc; |
1505 | QWidget *mw = mainWidget(); | 1509 | QWidget *mw = mainWidget(); |
1506 | if ( !mw ) | 1510 | if ( !mw ) |
1507 | mw = d->qpe_main_widget; | 1511 | mw = d->qpe_main_widget; |
1508 | if ( mw ) | 1512 | if ( mw ) |
1509 | Global::setDocument( mw, doc ); | 1513 | Global::setDocument( mw, doc ); |
1510 | 1514 | ||
1511 | } else if ( msg == "QPEProcessQCop()" ) { | 1515 | } else if ( msg == "QPEProcessQCop()" ) { |
1512 | processQCopFile(); | 1516 | processQCopFile(); |
1513 | d->sendQCopQ(); | 1517 | d->sendQCopQ(); |
1514 | }else | 1518 | }else |
1515 | { | 1519 | { |
1516 | bool p = d->keep_running; | 1520 | bool p = d->keep_running; |
1517 | d->keep_running = FALSE; | 1521 | d->keep_running = FALSE; |
1518 | emit appMessage( msg, data); | 1522 | emit appMessage( msg, data); |
1519 | if ( d->keep_running ) { | 1523 | if ( d->keep_running ) { |
1520 | d->notbusysent = FALSE; | 1524 | d->notbusysent = FALSE; |
1521 | raiseAppropriateWindow(); | 1525 | raiseAppropriateWindow(); |
1522 | if ( !p ) { | 1526 | if ( !p ) { |
1523 | // Tell the system we're still chugging along... | 1527 | // Tell the system we're still chugging along... |
1524 | #ifndef QT_NO_COP | 1528 | #ifndef QT_NO_COP |
1525 | QCopEnvelope e("QPE/System", "appRaised(QString)"); | 1529 | QCopEnvelope e("QPE/System", "appRaised(QString)"); |
1526 | e << d->appName; | 1530 | e << d->appName; |
1527 | #endif | 1531 | #endif |
1528 | } | 1532 | } |
1529 | } | 1533 | } |
1530 | if ( p ) | 1534 | if ( p ) |
1531 | d->keep_running = p; | 1535 | d->keep_running = p; |
1532 | } | 1536 | } |
1533 | #endif | 1537 | #endif |
1534 | } | 1538 | } |
1535 | 1539 | ||
1536 | 1540 | ||
1537 | /*! | 1541 | /*! |
1538 | Sets widget \a mw as the mainWidget() and shows it. For small windows, | 1542 | Sets widget \a mw as the mainWidget() and shows it. For small windows, |
1539 | consider passing TRUE for \a nomaximize rather than the default FALSE. | 1543 | consider passing TRUE for \a nomaximize rather than the default FALSE. |
1540 | 1544 | ||
1541 | \sa showMainDocumentWidget() | 1545 | \sa showMainDocumentWidget() |
1542 | */ | 1546 | */ |
1543 | void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize ) | 1547 | void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize ) |
1544 | { | 1548 | { |
1545 | d->show(mw, nomaximize ); | 1549 | d->show(mw, nomaximize ); |
1546 | } | 1550 | } |
1547 | 1551 | ||
1548 | /*! | 1552 | /*! |
1549 | Sets widget \a mw as the mainWidget() and shows it. For small windows, | 1553 | Sets widget \a mw as the mainWidget() and shows it. For small windows, |
1550 | consider passing TRUE for \a nomaximize rather than the default FALSE. | 1554 | consider passing TRUE for \a nomaximize rather than the default FALSE. |
1551 | 1555 | ||
1552 | This calls designates the application as | 1556 | This calls designates the application as |
1553 | a \link docwidget.html document-oriented\endlink application. | 1557 | a \link docwidget.html document-oriented\endlink application. |
1554 | 1558 | ||
1555 | The \a mw widget \e must have this slot: setDocument(const QString&). | 1559 | The \a mw widget \e must have this slot: setDocument(const QString&). |
1556 | 1560 | ||
1557 | \sa showMainWidget() | 1561 | \sa showMainWidget() |
1558 | */ | 1562 | */ |
1559 | void QPEApplication::showMainDocumentWidget( QWidget* mw, bool nomaximize ) | 1563 | void QPEApplication::showMainDocumentWidget( QWidget* mw, bool nomaximize ) |
1560 | { | 1564 | { |
1561 | if ( mw && argc() == 2 ) | 1565 | if ( mw && argc() == 2 ) |
1562 | Global::setDocument( mw, QString::fromUtf8(argv()[1]) ); | 1566 | Global::setDocument( mw, QString::fromUtf8(argv()[1]) ); |
1563 | 1567 | ||
1564 | 1568 | ||
1565 | d->show(mw, nomaximize ); | 1569 | d->show(mw, nomaximize ); |
1566 | } | 1570 | } |
1567 | 1571 | ||
1568 | 1572 | ||
1569 | /*! | 1573 | /*! |
1570 | If an application is started via a \link qcop.html QCop\endlink | 1574 | If an application is started via a \link qcop.html QCop\endlink |
1571 | message, the application will process the \link qcop.html | 1575 | message, the application will process the \link qcop.html |
1572 | QCop\endlink message and then quit. If the application calls this | 1576 | QCop\endlink message and then quit. If the application calls this |
1573 | function while processing a \link qcop.html QCop\endlink message, | 1577 | function while processing a \link qcop.html QCop\endlink message, |
1574 | after processing its outstanding \link qcop.html QCop\endlink | 1578 | after processing its outstanding \link qcop.html QCop\endlink |
1575 | messages the application will start 'properly' and show itself. | 1579 | messages the application will start 'properly' and show itself. |
1576 | 1580 | ||
1577 | \sa keepRunning() | 1581 | \sa keepRunning() |
1578 | */ | 1582 | */ |
1579 | void QPEApplication::setKeepRunning() | 1583 | void QPEApplication::setKeepRunning() |
1580 | { | 1584 | { |
1581 | if ( qApp && qApp->inherits( "QPEApplication" ) ) { | 1585 | if ( qApp && qApp->inherits( "QPEApplication" ) ) { |
1582 | QPEApplication * qpeApp = ( QPEApplication* ) qApp; | 1586 | QPEApplication * qpeApp = ( QPEApplication* ) qApp; |
1583 | qpeApp->d->keep_running = TRUE; | 1587 | qpeApp->d->keep_running = TRUE; |
1584 | } | 1588 | } |
1585 | } | 1589 | } |
1586 | 1590 | ||
1587 | /*! | 1591 | /*! |
1588 | Returns TRUE if the application will quit after processing the | 1592 | Returns TRUE if the application will quit after processing the |
1589 | current list of qcop messages; otherwise returns FALSE. | 1593 | current list of qcop messages; otherwise returns FALSE. |
1590 | 1594 | ||
1591 | \sa setKeepRunning() | 1595 | \sa setKeepRunning() |
1592 | */ | 1596 | */ |
1593 | bool QPEApplication::keepRunning() const | 1597 | bool QPEApplication::keepRunning() const |
1594 | { | 1598 | { |
1595 | return d->keep_running; | 1599 | return d->keep_running; |
1596 | } | 1600 | } |
1597 | 1601 | ||
1598 | /*! | 1602 | /*! |
1599 | \internal | 1603 | \internal |
1600 | */ | 1604 | */ |
1601 | void QPEApplication::internalSetStyle( const QString &style ) | 1605 | void QPEApplication::internalSetStyle( const QString &style ) |
1602 | { | 1606 | { |
1603 | #if QT_VERSION >= 300 | 1607 | #if QT_VERSION >= 300 |
1604 | if ( style == "QPE" ) { | 1608 | if ( style == "QPE" ) { |
1605 | setStyle( new QPEStyle ); | 1609 | setStyle( new QPEStyle ); |
1606 | } | 1610 | } |
1607 | else { | 1611 | else { |
1608 | QStyle *s = QStyleFactory::create( style ); | 1612 | QStyle *s = QStyleFactory::create( style ); |
1609 | if ( s ) | 1613 | if ( s ) |
1610 | setStyle( s ); | 1614 | setStyle( s ); |
1611 | } | 1615 | } |
1612 | #else | 1616 | #else |
1613 | if ( style == "Windows" ) { | 1617 | if ( style == "Windows" ) { |
1614 | setStyle( new QWindowsStyle ); | 1618 | setStyle( new QWindowsStyle ); |
1615 | } | 1619 | } |
1616 | else if ( style == "QPE" ) { | 1620 | else if ( style == "QPE" ) { |
1617 | setStyle( new QPEStyle ); | 1621 | setStyle( new QPEStyle ); |
1618 | } | 1622 | } |
1619 | else if ( style == "Light" ) { | 1623 | else if ( style == "Light" ) { |
1620 | setStyle( new LightStyle ); | 1624 | setStyle( new LightStyle ); |
1621 | } | 1625 | } |
1622 | #ifndef QT_NO_STYLE_PLATINUM | 1626 | #ifndef QT_NO_STYLE_PLATINUM |
1623 | else if ( style == "Platinum" ) { | 1627 | else if ( style == "Platinum" ) { |
1624 | setStyle( new QPlatinumStyle ); | 1628 | setStyle( new QPlatinumStyle ); |
1625 | } | 1629 | } |
1626 | #endif | 1630 | #endif |
1627 | #ifndef QT_NO_STYLE_MOTIF | 1631 | #ifndef QT_NO_STYLE_MOTIF |
1628 | else if ( style == "Motif" ) { | 1632 | else if ( style == "Motif" ) { |
1629 | setStyle( new QMotifStyle ); | 1633 | setStyle( new QMotifStyle ); |
1630 | } | 1634 | } |
1631 | #endif | 1635 | #endif |
1632 | #ifndef QT_NO_STYLE_MOTIFPLUS | 1636 | #ifndef QT_NO_STYLE_MOTIFPLUS |
1633 | else if ( style == "MotifPlus" ) { | 1637 | else if ( style == "MotifPlus" ) { |
1634 | setStyle( new QMotifPlusStyle ); | 1638 | setStyle( new QMotifPlusStyle ); |
1635 | } | 1639 | } |
1636 | #endif | 1640 | #endif |
1637 | 1641 | ||
1638 | else { | 1642 | else { |
1639 | QStyle *sty = 0; | 1643 | QStyle *sty = 0; |
1640 | QString path = QPEApplication::qpeDir ( ) + "/plugins/styles/"; | 1644 | QString path = QPEApplication::qpeDir ( ) + "/plugins/styles/"; |
1641 | 1645 | ||
1642 | if ( style. find ( ".so" ) > 0 ) | 1646 | if ( style. find ( ".so" ) > 0 ) |
1643 | path += style; | 1647 | path += style; |
1644 | else | 1648 | else |
1645 | path = path + "lib" + style. lower ( ) + ".so"; // compatibility | 1649 | path = path + "lib" + style. lower ( ) + ".so"; // compatibility |
1646 | 1650 | ||
1647 | static QLibrary *lastlib = 0; | 1651 | static QLibrary *lastlib = 0; |
1648 | static StyleInterface *lastiface = 0; | 1652 | static StyleInterface *lastiface = 0; |
1649 | 1653 | ||
1650 | QLibrary *lib = new QLibrary ( path ); | 1654 | QLibrary *lib = new QLibrary ( path ); |
1651 | StyleInterface *iface = 0; | 1655 | StyleInterface *iface = 0; |
1652 | 1656 | ||
1653 | if (( lib-> queryInterface ( IID_Style, ( QUnknownInterface ** ) &iface ) == QS_OK ) && iface ) | 1657 | if (( lib-> queryInterface ( IID_Style, ( QUnknownInterface ** ) &iface ) == QS_OK ) && iface ) |
1654 | sty = iface-> style ( ); | 1658 | sty = iface-> style ( ); |
1655 | 1659 | ||
1656 | if ( sty ) { | 1660 | if ( sty ) { |
1657 | setStyle ( sty ); | 1661 | setStyle ( sty ); |
1658 | 1662 | ||
1659 | if ( lastiface ) | 1663 | if ( lastiface ) |
1660 | lastiface-> release ( ); | 1664 | lastiface-> release ( ); |
1661 | lastiface = iface; | 1665 | lastiface = iface; |
1662 | 1666 | ||
1663 | if ( lastlib ) { | 1667 | if ( lastlib ) { |
1664 | lastlib-> unload ( ); | 1668 | lastlib-> unload ( ); |
1665 | delete lastlib; | 1669 | delete lastlib; |
1666 | } | 1670 | } |
1667 | lastlib = lib; | 1671 | lastlib = lib; |
1668 | } | 1672 | } |
1669 | else { | 1673 | else { |
1670 | if ( iface ) | 1674 | if ( iface ) |
1671 | iface-> release ( ); | 1675 | iface-> release ( ); |
1672 | delete lib; | 1676 | delete lib; |
1673 | 1677 | ||
1674 | setStyle ( new LightStyle ( )); | 1678 | setStyle ( new LightStyle ( )); |
1675 | } | 1679 | } |
1676 | } | 1680 | } |
1677 | #endif | 1681 | #endif |
1678 | } | 1682 | } |
1679 | 1683 | ||
1680 | /*! | 1684 | /*! |
1681 | \internal | 1685 | \internal |
1682 | */ | 1686 | */ |
1683 | void QPEApplication::prepareForTermination( bool willrestart ) | 1687 | void QPEApplication::prepareForTermination( bool willrestart ) |
1684 | { | 1688 | { |
1685 | if ( willrestart ) { | 1689 | if ( willrestart ) { |
1686 | // Draw a big wait icon, the image can be altered in later revisions | 1690 | // Draw a big wait icon, the image can be altered in later revisions |
1687 | // QWidget *d = QApplication::desktop(); | 1691 | // QWidget *d = QApplication::desktop(); |
1688 | QImage img = Resource::loadImage( "launcher/new_wait" ); | 1692 | QImage img = Resource::loadImage( "launcher/new_wait" ); |
1689 | QPixmap pix; | 1693 | QPixmap pix; |
1690 | pix.convertFromImage( img.smoothScale( 1 * img.width(), 1 * img.height() ) ); | 1694 | pix.convertFromImage( img.smoothScale( 1 * img.width(), 1 * img.height() ) ); |
1691 | QLabel *lblWait = new QLabel( 0, "wait hack!", QWidget::WStyle_Customize | | 1695 | QLabel *lblWait = new QLabel( 0, "wait hack!", QWidget::WStyle_Customize | |
1692 | QWidget::WStyle_NoBorder | QWidget::WStyle_Tool ); | 1696 | QWidget::WStyle_NoBorder | QWidget::WStyle_Tool ); |
1693 | lblWait->setPixmap( pix ); | 1697 | lblWait->setPixmap( pix ); |
1694 | lblWait->setAlignment( QWidget::AlignCenter ); | 1698 | lblWait->setAlignment( QWidget::AlignCenter ); |
1695 | lblWait->show(); | 1699 | lblWait->show(); |
1696 | lblWait->showMaximized(); | 1700 | lblWait->showMaximized(); |
1697 | } | 1701 | } |
1698 | #ifndef SINGLE_APP | 1702 | #ifndef SINGLE_APP |
1699 | { QCopEnvelope envelope( "QPE/System", "forceQuit()" ); | 1703 | { QCopEnvelope envelope( "QPE/System", "forceQuit()" ); |
1700 | } | 1704 | } |
1701 | processEvents(); // ensure the message goes out. | 1705 | processEvents(); // ensure the message goes out. |
1702 | sleep( 1 ); // You have 1 second to comply. | 1706 | sleep( 1 ); // You have 1 second to comply. |
1703 | #endif | 1707 | #endif |
1704 | } | 1708 | } |
1705 | 1709 | ||
1706 | /*! | 1710 | /*! |
1707 | \internal | 1711 | \internal |
1708 | */ | 1712 | */ |
1709 | void QPEApplication::shutdown() | 1713 | void QPEApplication::shutdown() |
1710 | { | 1714 | { |
1711 | // Implement in server's QPEApplication subclass | 1715 | // Implement in server's QPEApplication subclass |
1712 | } | 1716 | } |
1713 | 1717 | ||
1714 | /*! | 1718 | /*! |
1715 | \internal | 1719 | \internal |
1716 | */ | 1720 | */ |
1717 | void QPEApplication::restart() | 1721 | void QPEApplication::restart() |
1718 | { | 1722 | { |
1719 | // Implement in server's QPEApplication subclass | 1723 | // Implement in server's QPEApplication subclass |
1720 | } | 1724 | } |
1721 | 1725 | ||
1722 | static QPtrDict<void>* stylusDict = 0; | 1726 | static QPtrDict<void>* stylusDict = 0; |
1723 | static void createDict() | 1727 | static void createDict() |
1724 | { | 1728 | { |
1725 | if ( !stylusDict ) | 1729 | if ( !stylusDict ) |
1726 | stylusDict = new QPtrDict<void>; | 1730 | stylusDict = new QPtrDict<void>; |
1727 | } | 1731 | } |
1728 | 1732 | ||
1729 | /*! | 1733 | /*! |
1730 | Returns the current StylusMode for widget \a w. | 1734 | Returns the current StylusMode for widget \a w. |
1731 | 1735 | ||
1732 | \sa setStylusOperation() StylusMode | 1736 | \sa setStylusOperation() StylusMode |
1733 | */ | 1737 | */ |
1734 | QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w ) | 1738 | QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w ) |
1735 | { | 1739 | { |
1736 | if ( stylusDict ) | 1740 | if ( stylusDict ) |
1737 | return ( StylusMode ) ( int ) stylusDict->find( w ); | 1741 | return ( StylusMode ) ( int ) stylusDict->find( w ); |
1738 | return LeftOnly; | 1742 | return LeftOnly; |
1739 | } | 1743 | } |
1740 | 1744 | ||
1741 | /*! | 1745 | /*! |
1742 | \enum QPEApplication::StylusMode | 1746 | \enum QPEApplication::StylusMode |
1743 | 1747 | ||
1744 | \value LeftOnly the stylus only generates LeftButton | 1748 | \value LeftOnly the stylus only generates LeftButton |
1745 | events (the default). | 1749 | events (the default). |
1746 | \value RightOnHold the stylus generates RightButton events | 1750 | \value RightOnHold the stylus generates RightButton events |
1747 | if the user uses the press-and-hold gesture. | 1751 | if the user uses the press-and-hold gesture. |
1748 | 1752 | ||
1749 | \sa setStylusOperation() stylusOperation() | 1753 | \sa setStylusOperation() stylusOperation() |
1750 | */ | 1754 | */ |
1751 | 1755 | ||
1752 | /*! | 1756 | /*! |
1753 | Causes widget \a w to receive mouse events according to the stylus | 1757 | Causes widget \a w to receive mouse events according to the stylus |
1754 | \a mode. | 1758 | \a mode. |
1755 | 1759 | ||
1756 | \sa stylusOperation() StylusMode | 1760 | \sa stylusOperation() StylusMode |
1757 | */ | 1761 | */ |
1758 | void QPEApplication::setStylusOperation( QWidget * w, StylusMode mode ) | 1762 | void QPEApplication::setStylusOperation( QWidget * w, StylusMode mode ) |
1759 | { | 1763 | { |
1760 | createDict(); | 1764 | createDict(); |
1761 | if ( mode == LeftOnly ) { | 1765 | if ( mode == LeftOnly ) { |
1762 | stylusDict->remove | 1766 | stylusDict->remove |
1763 | ( w ); | 1767 | ( w ); |
1764 | w->removeEventFilter( qApp ); | 1768 | w->removeEventFilter( qApp ); |
1765 | } | 1769 | } |
1766 | else { | 1770 | else { |
1767 | stylusDict->insert( w, ( void* ) mode ); | 1771 | stylusDict->insert( w, ( void* ) mode ); |
1768 | connect( w, SIGNAL( destroyed() ), qApp, SLOT( removeSenderFromStylusDict() ) ); | 1772 | connect( w, SIGNAL( destroyed() ), qApp, SLOT( removeSenderFromStylusDict() ) ); |
1769 | w->installEventFilter( qApp ); | 1773 | w->installEventFilter( qApp ); |
1770 | } | 1774 | } |
1771 | } | 1775 | } |
1772 | 1776 | ||
1773 | 1777 | ||
1774 | /*! | 1778 | /*! |
1775 | \reimp | 1779 | \reimp |
1776 | */ | 1780 | */ |
1777 | bool QPEApplication::eventFilter( QObject *o, QEvent *e ) | 1781 | bool QPEApplication::eventFilter( QObject *o, QEvent *e ) |
1778 | { | 1782 | { |
1783 | if ( !o->isWidgetType() ) | ||
1784 | return FALSE; | ||
1785 | |||
1779 | if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) { | 1786 | if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) { |
1780 | QMouseEvent * me = ( QMouseEvent* ) e; | 1787 | QMouseEvent * me = ( QMouseEvent* ) e; |
1781 | StylusMode mode = (StylusMode)(int)stylusDict->find(o); | 1788 | StylusMode mode = (StylusMode)(int)stylusDict->find(o); |
1782 | switch (mode) { | 1789 | switch (mode) { |
1783 | case RightOnHold: | 1790 | case RightOnHold: |
1784 | switch ( me->type() ) { | 1791 | switch ( me->type() ) { |
1785 | case QEvent::MouseButtonPress: | 1792 | case QEvent::MouseButtonPress: |
1786 | if ( me->button() == LeftButton ) { | 1793 | if ( me->button() == LeftButton ) { |
1787 | d->presstimer = startTimer(500); // #### pref. | 1794 | if (!d->presstimer ) |
1795 | d->presstimer = startTimer(500); // #### pref. | ||
1788 | d->presswidget = (QWidget*)o; | 1796 | d->presswidget = (QWidget*)o; |
1789 | d->presspos = me->pos(); | 1797 | d->presspos = me->pos(); |
1790 | d->rightpressed = FALSE; | 1798 | d->rightpressed = FALSE; |
1791 | } | 1799 | } |
1792 | break; | 1800 | break; |
1793 | case QEvent::MouseMove: | 1801 | case QEvent::MouseMove: |
1794 | if (d->presstimer && (me->pos() - d->presspos).manhattanLength() > 8) { | 1802 | if (d->presstimer && (me->pos() - d->presspos).manhattanLength() > 8) { |
1795 | killTimer(d->presstimer); | 1803 | killTimer(d->presstimer); |
1796 | d->presstimer = 0; | 1804 | d->presstimer = 0; |
1797 | } | 1805 | } |
1798 | break; | 1806 | break; |
1799 | case QEvent::MouseButtonRelease: | 1807 | case QEvent::MouseButtonRelease: |
1800 | if ( me->button() == LeftButton ) { | 1808 | if ( me->button() == LeftButton ) { |
1801 | if ( d->presstimer ) { | 1809 | if ( d->presstimer ) { |
1802 | killTimer(d->presstimer); | 1810 | killTimer(d->presstimer); |
1803 | d->presstimer = 0; | 1811 | d->presstimer = 0; |
1804 | } | 1812 | } |
1805 | if ( d->rightpressed && d->presswidget ) { | 1813 | if ( d->rightpressed && d->presswidget ) { |
1806 | // Right released | 1814 | // Right released |
1807 | postEvent( d->presswidget, | 1815 | postEvent( d->presswidget, |
1808 | new QMouseEvent( QEvent::MouseButtonRelease, me->pos(), | 1816 | new QMouseEvent( QEvent::MouseButtonRelease, me->pos(), |
1809 | RightButton, LeftButton + RightButton ) ); | 1817 | RightButton, LeftButton + RightButton ) ); |
1810 | // Left released, off-widget | 1818 | // Left released, off-widget |
1811 | postEvent( d->presswidget, | 1819 | postEvent( d->presswidget, |
1812 | new QMouseEvent( QEvent::MouseMove, QPoint( -1, -1), | 1820 | new QMouseEvent( QEvent::MouseMove, QPoint( -1, -1), |
1813 | LeftButton, LeftButton ) ); | 1821 | LeftButton, LeftButton ) ); |
1814 | postEvent( d->presswidget, | 1822 | postEvent( d->presswidget, |
1815 | new QMouseEvent( QEvent::MouseButtonRelease, QPoint( -1, -1), | 1823 | new QMouseEvent( QEvent::MouseButtonRelease, QPoint( -1, -1), |
1816 | LeftButton, LeftButton ) ); | 1824 | LeftButton, LeftButton ) ); |
1817 | d->rightpressed = FALSE; | 1825 | d->rightpressed = FALSE; |
1818 | return TRUE; // don't send the real Left release | 1826 | return TRUE; // don't send the real Left release |
1819 | } | 1827 | } |
1820 | } | 1828 | } |
1821 | break; | 1829 | break; |
1822 | default: | 1830 | default: |
1823 | break; | 1831 | break; |
1824 | } | 1832 | } |
1825 | break; | 1833 | break; |
1826 | default: | 1834 | default: |
1827 | ; | 1835 | ; |
1828 | } | 1836 | } |
1829 | } | 1837 | } |
1830 | else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { | 1838 | else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { |
1831 | QKeyEvent *ke = (QKeyEvent *)e; | 1839 | QKeyEvent *ke = (QKeyEvent *)e; |
1832 | if ( ke->key() == Key_Enter ) { | 1840 | if ( ke->key() == Key_Enter ) { |
1833 | if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) { | 1841 | if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) { |
1834 | postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ', | 1842 | postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ', |
1835 | ke->state(), " ", ke->isAutoRepeat(), ke->count() ) ); | 1843 | ke->state(), " ", ke->isAutoRepeat(), ke->count() ) ); |
1836 | return TRUE; | 1844 | return TRUE; |
1837 | } | 1845 | } |
1838 | } | 1846 | } |
1839 | } | 1847 | } |
1840 | return FALSE; | 1848 | return FALSE; |
1841 | } | 1849 | } |
1842 | 1850 | ||
1843 | /*! | 1851 | /*! |
1844 | \reimp | 1852 | \reimp |
1845 | */ | 1853 | */ |
1846 | void QPEApplication::timerEvent( QTimerEvent *e ) | 1854 | void QPEApplication::timerEvent( QTimerEvent *e ) |
1847 | { | 1855 | { |
1848 | if ( e->timerId() == d->presstimer && d->presswidget ) { | 1856 | if ( e->timerId() == d->presstimer && d->presswidget ) { |
1849 | // Right pressed | 1857 | // Right pressed |
1850 | postEvent( d->presswidget, | 1858 | postEvent( d->presswidget, |
1851 | new QMouseEvent( QEvent::MouseButtonPress, d->presspos, | 1859 | new QMouseEvent( QEvent::MouseButtonPress, d->presspos, |
1852 | RightButton, LeftButton ) ); | 1860 | RightButton, LeftButton ) ); |
1853 | killTimer( d->presstimer ); | 1861 | killTimer( d->presstimer ); |
1854 | d->presstimer = 0; | 1862 | d->presstimer = 0; |
1855 | d->rightpressed = TRUE; | 1863 | d->rightpressed = TRUE; |
1856 | } | 1864 | } |
1857 | } | 1865 | } |
1858 | 1866 | ||
1859 | void QPEApplication::removeSenderFromStylusDict() | 1867 | void QPEApplication::removeSenderFromStylusDict() |
1860 | { | 1868 | { |
1861 | stylusDict->remove | 1869 | stylusDict->remove |
1862 | ( ( void* ) sender() ); | 1870 | ( ( void* ) sender() ); |
1863 | if ( d->presswidget == sender() ) | 1871 | if ( d->presswidget == sender() ) |
1864 | d->presswidget = 0; | 1872 | d->presswidget = 0; |
1865 | } | 1873 | } |
1866 | 1874 | ||
1867 | /*! | 1875 | /*! |
1868 | \internal | 1876 | \internal |
1869 | */ | 1877 | */ |
1870 | bool QPEApplication::keyboardGrabbed() const | 1878 | bool QPEApplication::keyboardGrabbed() const |
1871 | { | 1879 | { |
1872 | return d->kbgrabbed; | 1880 | return d->kbgrabbed; |
1873 | } | 1881 | } |
1874 | 1882 | ||
1875 | 1883 | ||
1876 | /*! | 1884 | /*! |
1877 | Reverses the effect of grabKeyboard(). This is called automatically | 1885 | Reverses the effect of grabKeyboard(). This is called automatically |
1878 | on program exit. | 1886 | on program exit. |
1879 | */ | 1887 | */ |
1880 | void QPEApplication::ungrabKeyboard() | 1888 | void QPEApplication::ungrabKeyboard() |
1881 | { | 1889 | { |
1882 | ((QPEApplication *) qApp )-> d-> kbgrabbed = false; | 1890 | ((QPEApplication *) qApp )-> d-> kbgrabbed = false; |
1883 | } | 1891 | } |
1884 | 1892 | ||
1885 | /*! | 1893 | /*! |
1886 | Grabs the physical keyboard keys, e.g. the application's launching | 1894 | Grabs the physical keyboard keys, e.g. the application's launching |
1887 | keys. Instead of launching applications when these keys are pressed | 1895 | keys. Instead of launching applications when these keys are pressed |
1888 | the signals emitted are sent to this application instead. Some games | 1896 | the signals emitted are sent to this application instead. Some games |
1889 | programs take over the launch keys in this way to make interaction | 1897 | programs take over the launch keys in this way to make interaction |
1890 | easier. | 1898 | easier. |
1891 | 1899 | ||
1892 | \sa ungrabKeyboard() | 1900 | \sa ungrabKeyboard() |
1893 | */ | 1901 | */ |
1894 | void QPEApplication::grabKeyboard() | 1902 | void QPEApplication::grabKeyboard() |
1895 | { | 1903 | { |
1896 | ((QPEApplication *) qApp )-> d-> kbgrabbed = true; | 1904 | ((QPEApplication *) qApp )-> d-> kbgrabbed = true; |
1897 | } | 1905 | } |
1898 | 1906 | ||
1899 | /*! | 1907 | /*! |
1900 | \reimp | 1908 | \reimp |
1901 | */ | 1909 | */ |
1902 | int QPEApplication::exec() | 1910 | int QPEApplication::exec() |
1903 | { | 1911 | { |
1904 | d->qcopQok = true; | 1912 | d->qcopQok = true; |
1905 | #ifndef QT_NO_COP | 1913 | #ifndef QT_NO_COP |
1906 | d->sendQCopQ(); | 1914 | d->sendQCopQ(); |
1915 | if ( !d->keep_running ) | ||
1916 | processEvents(); // we may have received QCop messages in the meantime. | ||
1907 | #endif | 1917 | #endif |
1908 | 1918 | ||
1909 | if ( d->keep_running ) | 1919 | if ( d->keep_running ) |
1910 | //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() ) | 1920 | //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() ) |
1911 | return QApplication::exec(); | 1921 | return QApplication::exec(); |
1912 | 1922 | ||
1913 | #ifndef QT_NO_COP | 1923 | #ifndef QT_NO_COP |
1914 | 1924 | ||
1915 | { | 1925 | { |
1916 | QCopEnvelope e( "QPE/System", "closing(QString)" ); | 1926 | QCopEnvelope e( "QPE/System", "closing(QString)" ); |
1917 | e << d->appName; | 1927 | e << d->appName; |
1918 | } | 1928 | } |
1919 | #endif | 1929 | #endif |
1920 | processEvents(); | 1930 | processEvents(); |
1921 | return 0; | 1931 | return 0; |
1922 | } | 1932 | } |
1923 | 1933 | ||
1924 | /*! | 1934 | /*! |
1925 | \internal | 1935 | \internal |
1926 | External request for application to quit. Quits if possible without | 1936 | External request for application to quit. Quits if possible without |
1927 | loosing state. | 1937 | loosing state. |
1928 | */ | 1938 | */ |
1929 | void QPEApplication::tryQuit() | 1939 | void QPEApplication::tryQuit() |
1930 | { | 1940 | { |
1931 | if ( activeModalWidget() || strcmp( argv() [ 0 ], "embeddedkonsole" ) == 0 ) | 1941 | if ( activeModalWidget() || strcmp( argv() [ 0 ], "embeddedkonsole" ) == 0 ) |
1932 | return ; // Inside modal loop or konsole. Too hard to save state. | 1942 | return ; // Inside modal loop or konsole. Too hard to save state. |
1933 | #ifndef QT_NO_COP | 1943 | #ifndef QT_NO_COP |
1934 | 1944 | ||
1935 | { | 1945 | { |
1936 | QCopEnvelope e( "QPE/System", "closing(QString)" ); | 1946 | QCopEnvelope e( "QPE/System", "closing(QString)" ); |
1937 | e << d->appName; | 1947 | e << d->appName; |
1938 | } | 1948 | } |
1939 | #endif | 1949 | #endif |
1940 | processEvents(); | 1950 | processEvents(); |
1941 | 1951 | ||
1942 | quit(); | 1952 | quit(); |
1943 | } | 1953 | } |
1944 | 1954 | ||
1945 | /*! | 1955 | /*! |
1946 | \internal | 1956 | \internal |
1947 | */ | 1957 | */ |
1948 | void QPEApplication::installTranslation( const QString& baseName ) { | 1958 | void QPEApplication::installTranslation( const QString& baseName ) { |
1949 | QTranslator* trans = new QTranslator(this); | 1959 | QTranslator* trans = new QTranslator(this); |
1950 | QString tfn = qpeDir() + "/i18n/"+baseName; | 1960 | QString tfn = qpeDir() + "/i18n/"+baseName; |
1951 | if ( trans->load( tfn ) ) | 1961 | if ( trans->load( tfn ) ) |
1952 | installTranslator( trans ); | 1962 | installTranslator( trans ); |
1953 | else | 1963 | else |
1954 | delete trans; | 1964 | delete trans; |
1955 | } | 1965 | } |
1956 | 1966 | ||
1957 | /*! | 1967 | /*! |
1958 | \internal | 1968 | \internal |
1959 | User initiated quit. Makes the window 'Go Away'. If preloaded this means | 1969 | User initiated quit. Makes the window 'Go Away'. If preloaded this means |
1960 | hiding the window. If not it means quitting the application. | 1970 | hiding the window. If not it means quitting the application. |
1961 | As this is user initiated we don't need to check state. | 1971 | As this is user initiated we don't need to check state. |
1962 | */ | 1972 | */ |
1963 | void QPEApplication::hideOrQuit() | 1973 | void QPEApplication::hideOrQuit() |
1964 | { | 1974 | { |
1965 | processEvents(); | 1975 | processEvents(); |
1966 | 1976 | ||
1967 | // If we are a preloaded application we don't actually quit, so emit | 1977 | // If we are a preloaded application we don't actually quit, so emit |
1968 | // a System message indicating we're quasi-closing. | 1978 | // a System message indicating we're quasi-closing. |
1969 | if ( d->preloaded && d->qpe_main_widget ) | 1979 | if ( d->preloaded && d->qpe_main_widget ) |
1970 | #ifndef QT_NO_COP | 1980 | #ifndef QT_NO_COP |
1971 | 1981 | ||
1972 | { | 1982 | { |
1973 | QCopEnvelope e("QPE/System", "fastAppHiding(QString)" ); | 1983 | QCopEnvelope e("QPE/System", "fastAppHiding(QString)" ); |
1974 | e << d->appName; | 1984 | e << d->appName; |
1975 | d->qpe_main_widget->hide(); | 1985 | d->qpe_main_widget->hide(); |
1976 | } | 1986 | } |
1977 | #endif | 1987 | #endif |
1978 | else | 1988 | else |
1979 | quit(); | 1989 | quit(); |
1980 | } | 1990 | } |
1981 | 1991 | ||
1982 | #if (__GNUC__ > 2 ) | 1992 | #if (__GNUC__ > 2 ) |
1983 | extern "C" void __cxa_pure_virtual(); | 1993 | extern "C" void __cxa_pure_virtual(); |
1984 | 1994 | ||
1985 | void __cxa_pure_virtual() | 1995 | void __cxa_pure_virtual() |
1986 | { | 1996 | { |
1987 | fprintf( stderr, "Pure virtual called\n"); | 1997 | fprintf( stderr, "Pure virtual called\n"); |
1988 | abort(); | 1998 | abort(); |
1989 | 1999 | ||
1990 | } | 2000 | } |
1991 | 2001 | ||
1992 | #endif | 2002 | #endif |
1993 | 2003 | ||
1994 | 2004 | ||
1995 | #if defined(QT_QWS_IPAQ) || defined(QT_QWS_SL5XXX) || defined(QT_QWS_RAMSES) | 2005 | #if defined(QT_QWS_IPAQ) || defined(QT_QWS_SL5XXX) || defined(QT_QWS_RAMSES) |
1996 | 2006 | ||
1997 | // The libraries with the skiff package (and possibly others) have | 2007 | // The libraries with the skiff package (and possibly others) have |
1998 | // completely useless implementations of builtin new and delete that | 2008 | // completely useless implementations of builtin new and delete that |
1999 | // use about 50% of your CPU. Here we revert to the simple libc | 2009 | // use about 50% of your CPU. Here we revert to the simple libc |
2000 | // functions. | 2010 | // functions. |
2001 | 2011 | ||
2002 | void* operator new[]( size_t size ) | 2012 | void* operator new[]( size_t size ) |
2003 | { | 2013 | { |
2004 | return malloc( size ); | 2014 | return malloc( size ); |
2005 | } | 2015 | } |
2006 | 2016 | ||
2007 | void* operator new( size_t size ) | 2017 | void* operator new( size_t size ) |
2008 | { | 2018 | { |
2009 | return malloc( size ); | 2019 | return malloc( size ); |
2010 | } | 2020 | } |
2011 | 2021 | ||
2012 | void operator delete[]( void* p ) | 2022 | void operator delete[]( void* p ) |
2013 | { | 2023 | { |
2014 | free( p ); | 2024 | free( p ); |
2015 | } | 2025 | } |
2016 | 2026 | ||
2017 | void operator delete[]( void* p, size_t /*size*/ ) | 2027 | void operator delete[]( void* p, size_t /*size*/ ) |
2018 | { | 2028 | { |
2019 | free( p ); | 2029 | free( p ); |
2020 | } | 2030 | } |
2021 | 2031 | ||
2022 | 2032 | ||
2023 | void operator delete( void* p ) | 2033 | void operator delete( void* p ) |
2024 | { | 2034 | { |
2025 | free( p ); | 2035 | free( p ); |
2026 | } | 2036 | } |
2027 | 2037 | ||
2028 | void operator delete( void* p, size_t /*size*/ ) | 2038 | void operator delete( void* p, size_t /*size*/ ) |
2029 | { | 2039 | { |
2030 | free( p ); | 2040 | free( p ); |
2031 | } | 2041 | } |
2032 | 2042 | ||
2033 | #endif | 2043 | #endif |
2034 | 2044 | ||
2035 | #if ( QT_VERSION <= 230 ) && !defined(SINGLE_APP) | 2045 | #if ( QT_VERSION <= 230 ) && !defined(SINGLE_APP) |
2036 | #include <qwidgetlist.h> | 2046 | #include <qwidgetlist.h> |
2037 | #ifdef QWS | 2047 | #ifdef QWS |
2038 | #include <qgfx_qws.h> | 2048 | #include <qgfx_qws.h> |
2039 | extern QRect qt_maxWindowRect; | 2049 | extern QRect qt_maxWindowRect; |
2040 | void qt_setMaxWindowRect(const QRect& r ) | 2050 | void qt_setMaxWindowRect(const QRect& r ) |
2041 | { | 2051 | { |
2042 | qt_maxWindowRect = qt_screen->mapFromDevice( r, | 2052 | qt_maxWindowRect = qt_screen->mapFromDevice( r, |
2043 | qt_screen->mapToDevice( QSize( qt_screen->width(), qt_screen->height() ) ) ); | 2053 | qt_screen->mapToDevice( QSize( qt_screen->width(), qt_screen->height() ) ) ); |
2044 | // Re-resize any maximized windows | 2054 | // Re-resize any maximized windows |
2045 | QWidgetList* l = QApplication::topLevelWidgets(); | 2055 | QWidgetList* l = QApplication::topLevelWidgets(); |
2046 | if ( l ) { | 2056 | if ( l ) { |
2047 | QWidget * w = l->first(); | 2057 | QWidget * w = l->first(); |
2048 | while ( w ) { | 2058 | while ( w ) { |
2049 | if ( w->isVisible() && w->isMaximized() ) { | 2059 | if ( w->isVisible() && w->isMaximized() ) { |
2050 | w->showMaximized(); | 2060 | w->showMaximized(); |
2051 | } | 2061 | } |
2052 | w = l->next(); | 2062 | w = l->next(); |
2053 | } | 2063 | } |
2054 | delete l; | 2064 | delete l; |
2055 | } | 2065 | } |
2056 | } | 2066 | } |
2057 | #endif | 2067 | #endif |
2058 | #endif | 2068 | #endif |