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,770 +1,774 @@ | |||
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 | } |
@@ -1587,472 +1591,478 @@ void QPEApplication::setKeepRunning() | |||
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 |