author | zecke <zecke> | 2003-10-02 19:50:57 (UTC) |
---|---|---|
committer | zecke <zecke> | 2003-10-02 19:50:57 (UTC) |
commit | a5622a23c3083e1ff8a526713aed6a36aaf7a5bd (patch) (unidiff) | |
tree | a11dd920c777ebceee2026e573d4e0111875174c | |
parent | b262f4cbe41c144c472f17996a8739952464e00c (diff) | |
download | opie-a5622a23c3083e1ff8a526713aed6a36aaf7a5bd.zip opie-a5622a23c3083e1ff8a526713aed6a36aaf7a5bd.tar.gz opie-a5622a23c3083e1ff8a526713aed6a36aaf7a5bd.tar.bz2 |
Move the #ifdef so that the code actually compiles if the expression
is not true
-rw-r--r-- | library/qpeapplication.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp index 98af70a..0e469ae 100644 --- a/library/qpeapplication.cpp +++ b/library/qpeapplication.cpp | |||
@@ -1,922 +1,923 @@ | |||
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 | 54 | ||
55 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 55 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
56 | #define QTOPIA_INTERNAL_INITAPP | 56 | #define QTOPIA_INTERNAL_INITAPP |
57 | #include "qpeapplication.h" | 57 | #include "qpeapplication.h" |
58 | #include "qpestyle.h" | 58 | #include "qpestyle.h" |
59 | #include "styleinterface.h" | 59 | #include "styleinterface.h" |
60 | #if QT_VERSION >= 300 | 60 | #if QT_VERSION >= 300 |
61 | #include <qstylefactory.h> | 61 | #include <qstylefactory.h> |
62 | #else | 62 | #else |
63 | #include <qplatinumstyle.h> | 63 | #include <qplatinumstyle.h> |
64 | #include <qwindowsstyle.h> | 64 | #include <qwindowsstyle.h> |
65 | #include <qmotifstyle.h> | 65 | #include <qmotifstyle.h> |
66 | #include <qmotifplusstyle.h> | 66 | #include <qmotifplusstyle.h> |
67 | #include "lightstyle.h" | 67 | #include "lightstyle.h" |
68 | 68 | ||
69 | #include <qpe/qlibrary.h> | 69 | #include <qpe/qlibrary.h> |
70 | #endif | 70 | #endif |
71 | #include "global.h" | 71 | #include "global.h" |
72 | #include "resource.h" | 72 | #include "resource.h" |
73 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) | 73 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) |
74 | #include "qutfcodec.h" | 74 | #include "qutfcodec.h" |
75 | #endif | 75 | #endif |
76 | #include "config.h" | 76 | #include "config.h" |
77 | #include "network.h" | 77 | #include "network.h" |
78 | #ifdef QWS | 78 | #ifdef QWS |
79 | #include "fontmanager.h" | 79 | #include "fontmanager.h" |
80 | #endif | 80 | #endif |
81 | 81 | ||
82 | #include "alarmserver.h" | 82 | #include "alarmserver.h" |
83 | #include "applnk.h" | 83 | #include "applnk.h" |
84 | #include "qpemenubar.h" | 84 | #include "qpemenubar.h" |
85 | #include "textcodecinterface.h" | 85 | #include "textcodecinterface.h" |
86 | #include "imagecodecinterface.h" | 86 | #include "imagecodecinterface.h" |
87 | 87 | ||
88 | #include <unistd.h> | 88 | #include <unistd.h> |
89 | #include <sys/file.h> | 89 | #include <sys/file.h> |
90 | #include <sys/ioctl.h> | 90 | #include <sys/ioctl.h> |
91 | #include <sys/soundcard.h> | 91 | #include <sys/soundcard.h> |
92 | 92 | ||
93 | #include "qt_override_p.h" | 93 | #include "qt_override_p.h" |
94 | 94 | ||
95 | 95 | ||
96 | class QPEApplicationData | 96 | class QPEApplicationData |
97 | { | 97 | { |
98 | public: | 98 | public: |
99 | QPEApplicationData ( ) | 99 | QPEApplicationData ( ) |
100 | : presstimer( 0 ), presswidget( 0 ), rightpressed( false ), kbgrabbed( false ), | 100 | : presstimer( 0 ), presswidget( 0 ), rightpressed( false ), kbgrabbed( false ), |
101 | notbusysent( false ), preloaded( false ), forceshow( false ), nomaximize( false ), | 101 | notbusysent( false ), preloaded( false ), forceshow( false ), nomaximize( false ), |
102 | keep_running( true ), qpe_main_widget( 0 ), qcopQok( false ) | 102 | keep_running( true ), qpe_main_widget( 0 ), qcopQok( false ) |
103 | 103 | ||
104 | {} | 104 | {} |
105 | 105 | ||
106 | int presstimer; | 106 | int presstimer; |
107 | QWidget* presswidget; | 107 | QWidget* presswidget; |
108 | QPoint presspos; | 108 | QPoint presspos; |
109 | 109 | ||
110 | bool rightpressed : 1; | 110 | bool rightpressed : 1; |
111 | bool kbgrabbed : 1; | 111 | bool kbgrabbed : 1; |
112 | bool notbusysent : 1; | 112 | bool notbusysent : 1; |
113 | bool preloaded : 1; | 113 | bool preloaded : 1; |
114 | bool forceshow : 1; | 114 | bool forceshow : 1; |
115 | bool nomaximize : 1; | 115 | bool nomaximize : 1; |
116 | bool qcopQok : 1; | 116 | bool qcopQok : 1; |
117 | bool keep_running : 1; | 117 | bool keep_running : 1; |
118 | 118 | ||
119 | 119 | ||
120 | QStringList langs; | 120 | QStringList langs; |
121 | QString appName; | 121 | QString appName; |
122 | struct QCopRec | 122 | struct QCopRec |
123 | { | 123 | { |
124 | QCopRec( const QCString &ch, const QCString &msg, | 124 | QCopRec( const QCString &ch, const QCString &msg, |
125 | const QByteArray &d ) : | 125 | const QByteArray &d ) : |
126 | channel( ch ), message( msg ), data( d ) | 126 | channel( ch ), message( msg ), data( d ) |
127 | { } | 127 | { } |
128 | 128 | ||
129 | QCString channel; | 129 | QCString channel; |
130 | QCString message; | 130 | QCString message; |
131 | QByteArray data; | 131 | QByteArray data; |
132 | }; | 132 | }; |
133 | QWidget* qpe_main_widget; | 133 | QWidget* qpe_main_widget; |
134 | QGuardedPtr<QWidget> lastraised; | 134 | QGuardedPtr<QWidget> lastraised; |
135 | QQueue<QCopRec> qcopq; | 135 | QQueue<QCopRec> qcopq; |
136 | QString styleName; | 136 | QString styleName; |
137 | QString decorationName; | 137 | QString decorationName; |
138 | 138 | ||
139 | void enqueueQCop( const QCString &ch, const QCString &msg, | 139 | void enqueueQCop( const QCString &ch, const QCString &msg, |
140 | const QByteArray &data ) | 140 | const QByteArray &data ) |
141 | { | 141 | { |
142 | qcopq.enqueue( new QCopRec( ch, msg, data ) ); | 142 | qcopq.enqueue( new QCopRec( ch, msg, data ) ); |
143 | } | 143 | } |
144 | void sendQCopQ() | 144 | void sendQCopQ() |
145 | { | 145 | { |
146 | if (!qcopQok ) | 146 | if (!qcopQok ) |
147 | return; | 147 | return; |
148 | 148 | ||
149 | QCopRec * r; | 149 | QCopRec * r; |
150 | #ifndef QT_NO_COP | 150 | |
151 | while((r=qcopq.dequeue())) { | 151 | while((r=qcopq.dequeue())) { |
152 | // remove from queue before sending... | 152 | // remove from queue before sending... |
153 | // event loop can come around again before getting | 153 | // event loop can come around again before getting |
154 | // back from sendLocally | 154 | // back from sendLocally |
155 | #ifndef QT_NO_COP | ||
155 | QCopChannel::sendLocally( r->channel, r->message, r->data ); | 156 | QCopChannel::sendLocally( r->channel, r->message, r->data ); |
156 | #endif | 157 | #endif |
157 | 158 | ||
158 | delete r; | 159 | delete r; |
159 | } | 160 | } |
160 | } | 161 | } |
161 | static void show_mx(QWidget* mw, bool nomaximize, const QString & = QString::null ) | 162 | static void show_mx(QWidget* mw, bool nomaximize, const QString & = QString::null ) |
162 | { | 163 | { |
163 | 164 | ||
164 | // ugly hack, remove that later after finding a sane solution | 165 | // ugly hack, remove that later after finding a sane solution |
165 | // Addendum: Only Sharp currently has models with high resolution but (physically) small displays, | 166 | // Addendum: Only Sharp currently has models with high resolution but (physically) small displays, |
166 | // so this is only useful if QT_QWS_SIMPAD is NOT defined. E.g. SIMpad has 800x600 but has | 167 | // so this is only useful if QT_QWS_SIMPAD is NOT defined. E.g. SIMpad has 800x600 but has |
167 | // a (physically) large enough display to use the small icons | 168 | // a (physically) large enough display to use the small icons |
168 | #ifndef QT_QWS_SIMPAD | 169 | #ifndef QT_QWS_SIMPAD |
169 | if ( QPEApplication::desktop() ->width() >= 600 && ( mw->inherits("QMainWindow") || mw->isA("QMainWindow") ) ) { | 170 | if ( QPEApplication::desktop() ->width() >= 600 && ( mw->inherits("QMainWindow") || mw->isA("QMainWindow") ) ) { |
170 | ( ( QMainWindow* ) mw )->setUsesBigPixmaps( true ); | 171 | ( ( QMainWindow* ) mw )->setUsesBigPixmaps( true ); |
171 | } | 172 | } |
172 | #endif | 173 | #endif |
173 | 174 | ||
174 | if ( mw->layout() && mw->inherits("QDialog") ) { | 175 | if ( mw->layout() && mw->inherits("QDialog") ) { |
175 | QPEApplication::showDialog((QDialog*)mw, nomaximize); | 176 | QPEApplication::showDialog((QDialog*)mw, nomaximize); |
176 | } | 177 | } |
177 | else { | 178 | else { |
178 | #ifdef Q_WS_QWS | 179 | #ifdef Q_WS_QWS |
179 | if ( !nomaximize ) | 180 | if ( !nomaximize ) |
180 | mw->showMaximized(); | 181 | mw->showMaximized(); |
181 | else | 182 | else |
182 | #endif | 183 | #endif |
183 | 184 | ||
184 | mw->show(); | 185 | mw->show(); |
185 | } | 186 | } |
186 | } | 187 | } |
187 | static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) | 188 | static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) |
188 | { | 189 | { |
189 | /* | 190 | /* |
190 | // This works but disable it for now until it is safe to apply | 191 | // This works but disable it for now until it is safe to apply |
191 | // What is does is scan the .desktop files of all the apps for | 192 | // What is does is scan the .desktop files of all the apps for |
192 | // the applnk that has the corresponding argv[0] as this program | 193 | // the applnk that has the corresponding argv[0] as this program |
193 | // then it uses the name stored in the .desktop file as the caption | 194 | // then it uses the name stored in the .desktop file as the caption |
194 | // for the main widget. This saves duplicating translations for | 195 | // for the main widget. This saves duplicating translations for |
195 | // the app name in the program and in the .desktop files. | 196 | // the app name in the program and in the .desktop files. |
196 | 197 | ||
197 | AppLnkSet apps( appsPath ); | 198 | AppLnkSet apps( appsPath ); |
198 | 199 | ||
199 | QList<AppLnk> appsList = apps.children(); | 200 | QList<AppLnk> appsList = apps.children(); |
200 | for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) { | 201 | for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) { |
201 | if ( (*it)->exec() == appName ) { | 202 | if ( (*it)->exec() == appName ) { |
202 | mw->setCaption( (*it)->name() ); | 203 | mw->setCaption( (*it)->name() ); |
203 | return TRUE; | 204 | return TRUE; |
204 | } | 205 | } |
205 | } | 206 | } |
206 | */ | 207 | */ |
207 | return FALSE; | 208 | return FALSE; |
208 | } | 209 | } |
209 | 210 | ||
210 | 211 | ||
211 | void show(QWidget* mw, bool nomax) | 212 | void show(QWidget* mw, bool nomax) |
212 | { | 213 | { |
213 | setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" ); | 214 | setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" ); |
214 | nomaximize = nomax; | 215 | nomaximize = nomax; |
215 | qpe_main_widget = mw; | 216 | qpe_main_widget = mw; |
216 | #ifndef QT_NO_COP | 217 | #ifndef QT_NO_COP |
217 | 218 | ||
218 | sendQCopQ(); | 219 | sendQCopQ(); |
219 | #endif | 220 | #endif |
220 | 221 | ||
221 | if ( preloaded ) { | 222 | if ( preloaded ) { |
222 | if (forceshow) | 223 | if (forceshow) |
223 | show_mx(mw, nomax); | 224 | show_mx(mw, nomax); |
224 | } | 225 | } |
225 | else if ( keep_running ) { | 226 | else if ( keep_running ) { |
226 | show_mx(mw, nomax); | 227 | show_mx(mw, nomax); |
227 | } | 228 | } |
228 | } | 229 | } |
229 | 230 | ||
230 | void loadTextCodecs() | 231 | void loadTextCodecs() |
231 | { | 232 | { |
232 | QString path = QPEApplication::qpeDir() + "/plugins/textcodecs"; | 233 | QString path = QPEApplication::qpeDir() + "/plugins/textcodecs"; |
233 | QDir dir( path, "lib*.so" ); | 234 | QDir dir( path, "lib*.so" ); |
234 | QStringList list; | 235 | QStringList list; |
235 | if ( dir. exists ( )) | 236 | if ( dir. exists ( )) |
236 | list = dir.entryList(); | 237 | list = dir.entryList(); |
237 | QStringList::Iterator it; | 238 | QStringList::Iterator it; |
238 | for ( it = list.begin(); it != list.end(); ++it ) { | 239 | for ( it = list.begin(); it != list.end(); ++it ) { |
239 | TextCodecInterface *iface = 0; | 240 | TextCodecInterface *iface = 0; |
240 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 241 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
241 | if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { | 242 | if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { |
242 | QValueList<int> mibs = iface->mibEnums(); | 243 | QValueList<int> mibs = iface->mibEnums(); |
243 | for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) { | 244 | for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) { |
244 | (void)iface->createForMib(*i); | 245 | (void)iface->createForMib(*i); |
245 | // ### it exists now; need to remember if we can delete it | 246 | // ### it exists now; need to remember if we can delete it |
246 | } | 247 | } |
247 | } | 248 | } |
248 | else { | 249 | else { |
249 | lib->unload(); | 250 | lib->unload(); |
250 | delete lib; | 251 | delete lib; |
251 | } | 252 | } |
252 | } | 253 | } |
253 | } | 254 | } |
254 | 255 | ||
255 | void loadImageCodecs() | 256 | void loadImageCodecs() |
256 | { | 257 | { |
257 | QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs"; | 258 | QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs"; |
258 | QDir dir( path, "lib*.so" ); | 259 | QDir dir( path, "lib*.so" ); |
259 | QStringList list; | 260 | QStringList list; |
260 | if ( dir. exists ( )) | 261 | if ( dir. exists ( )) |
261 | list = dir.entryList(); | 262 | list = dir.entryList(); |
262 | QStringList::Iterator it; | 263 | QStringList::Iterator it; |
263 | for ( it = list.begin(); it != list.end(); ++it ) { | 264 | for ( it = list.begin(); it != list.end(); ++it ) { |
264 | ImageCodecInterface *iface = 0; | 265 | ImageCodecInterface *iface = 0; |
265 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 266 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
266 | if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { | 267 | if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { |
267 | QStringList formats = iface->keys(); | 268 | QStringList formats = iface->keys(); |
268 | for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) { | 269 | for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) { |
269 | (void)iface->installIOHandler(*i); | 270 | (void)iface->installIOHandler(*i); |
270 | // ### it exists now; need to remember if we can delete it | 271 | // ### it exists now; need to remember if we can delete it |
271 | } | 272 | } |
272 | } | 273 | } |
273 | else { | 274 | else { |
274 | lib->unload(); | 275 | lib->unload(); |
275 | delete lib; | 276 | delete lib; |
276 | } | 277 | } |
277 | } | 278 | } |
278 | } | 279 | } |
279 | }; | 280 | }; |
280 | 281 | ||
281 | class ResourceMimeFactory : public QMimeSourceFactory | 282 | class ResourceMimeFactory : public QMimeSourceFactory |
282 | { | 283 | { |
283 | public: | 284 | public: |
284 | ResourceMimeFactory() : resImage( 0 ) | 285 | ResourceMimeFactory() : resImage( 0 ) |
285 | { | 286 | { |
286 | setFilePath( Global::helpPath() ); | 287 | setFilePath( Global::helpPath() ); |
287 | setExtensionType( "html", "text/html;charset=UTF-8" ); | 288 | setExtensionType( "html", "text/html;charset=UTF-8" ); |
288 | } | 289 | } |
289 | ~ResourceMimeFactory() { | 290 | ~ResourceMimeFactory() { |
290 | delete resImage; | 291 | delete resImage; |
291 | } | 292 | } |
292 | 293 | ||
293 | const QMimeSource* data( const QString& abs_name ) const | 294 | const QMimeSource* data( const QString& abs_name ) const |
294 | { | 295 | { |
295 | const QMimeSource * r = QMimeSourceFactory::data( abs_name ); | 296 | const QMimeSource * r = QMimeSourceFactory::data( abs_name ); |
296 | if ( !r ) { | 297 | if ( !r ) { |
297 | int sl = abs_name.length(); | 298 | int sl = abs_name.length(); |
298 | do { | 299 | do { |
299 | sl = abs_name.findRev( '/', sl - 1 ); | 300 | sl = abs_name.findRev( '/', sl - 1 ); |
300 | QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name; | 301 | QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name; |
301 | int dot = name.findRev( '.' ); | 302 | int dot = name.findRev( '.' ); |
302 | if ( dot >= 0 ) | 303 | if ( dot >= 0 ) |
303 | name = name.left( dot ); | 304 | name = name.left( dot ); |
304 | QImage img = Resource::loadImage( name ); | 305 | QImage img = Resource::loadImage( name ); |
305 | if ( !img.isNull() ) { | 306 | if ( !img.isNull() ) { |
306 | delete resImage; | 307 | delete resImage; |
307 | resImage = new QImageDrag( img ); | 308 | resImage = new QImageDrag( img ); |
308 | r = resImage; | 309 | r = resImage; |
309 | } | 310 | } |
310 | } | 311 | } |
311 | while ( !r && sl > 0 ); | 312 | while ( !r && sl > 0 ); |
312 | } | 313 | } |
313 | return r; | 314 | return r; |
314 | } | 315 | } |
315 | private: | 316 | private: |
316 | mutable QImageDrag *resImage; | 317 | mutable QImageDrag *resImage; |
317 | }; | 318 | }; |
318 | 319 | ||
319 | static int& hack(int& i) | 320 | static int& hack(int& i) |
320 | { | 321 | { |
321 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) | 322 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) |
322 | // These should be created, but aren't in Qt 2.3.0 | 323 | // These should be created, but aren't in Qt 2.3.0 |
323 | (void)new QUtf8Codec; | 324 | (void)new QUtf8Codec; |
324 | (void)new QUtf16Codec; | 325 | (void)new QUtf16Codec; |
325 | #endif | 326 | #endif |
326 | return i; | 327 | return i; |
327 | } | 328 | } |
328 | 329 | ||
329 | static int muted = 0; | 330 | static int muted = 0; |
330 | static int micMuted = 0; | 331 | static int micMuted = 0; |
331 | 332 | ||
332 | static void setVolume( int t = 0, int percent = -1 ) | 333 | static void setVolume( int t = 0, int percent = -1 ) |
333 | { | 334 | { |
334 | switch ( t ) { | 335 | switch ( t ) { |
335 | case 0: { | 336 | case 0: { |
336 | Config cfg( "qpe" ); | 337 | Config cfg( "qpe" ); |
337 | cfg.setGroup( "Volume" ); | 338 | cfg.setGroup( "Volume" ); |
338 | if ( percent < 0 ) | 339 | if ( percent < 0 ) |
339 | percent = cfg.readNumEntry( "VolumePercent", 50 ); | 340 | percent = cfg.readNumEntry( "VolumePercent", 50 ); |
340 | int fd = 0; | 341 | int fd = 0; |
341 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 342 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
342 | int vol = muted ? 0 : percent; | 343 | int vol = muted ? 0 : percent; |
343 | // set both channels to same volume | 344 | // set both channels to same volume |
344 | vol |= vol << 8; | 345 | vol |= vol << 8; |
345 | ioctl( fd, MIXER_WRITE( 0 ), &vol ); | 346 | ioctl( fd, MIXER_WRITE( 0 ), &vol ); |
346 | ::close( fd ); | 347 | ::close( fd ); |
347 | } | 348 | } |
348 | } | 349 | } |
349 | break; | 350 | break; |
350 | } | 351 | } |
351 | } | 352 | } |
352 | 353 | ||
353 | static void setMic( int t = 0, int percent = -1 ) | 354 | static void setMic( int t = 0, int percent = -1 ) |
354 | { | 355 | { |
355 | switch ( t ) { | 356 | switch ( t ) { |
356 | case 0: { | 357 | case 0: { |
357 | Config cfg( "qpe" ); | 358 | Config cfg( "qpe" ); |
358 | cfg.setGroup( "Volume" ); | 359 | cfg.setGroup( "Volume" ); |
359 | if ( percent < 0 ) | 360 | if ( percent < 0 ) |
360 | percent = cfg.readNumEntry( "Mic", 50 ); | 361 | percent = cfg.readNumEntry( "Mic", 50 ); |
361 | 362 | ||
362 | int fd = 0; | 363 | int fd = 0; |
363 | int mic = micMuted ? 0 : percent; | 364 | int mic = micMuted ? 0 : percent; |
364 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 365 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
365 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_MIC ), &mic ); | 366 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_MIC ), &mic ); |
366 | ::close( fd ); | 367 | ::close( fd ); |
367 | } | 368 | } |
368 | } | 369 | } |
369 | break; | 370 | break; |
370 | } | 371 | } |
371 | } | 372 | } |
372 | 373 | ||
373 | 374 | ||
374 | static void setBass( int t = 0, int percent = -1 ) | 375 | static void setBass( int t = 0, int percent = -1 ) |
375 | { | 376 | { |
376 | switch ( t ) { | 377 | switch ( t ) { |
377 | case 0: { | 378 | case 0: { |
378 | Config cfg( "qpe" ); | 379 | Config cfg( "qpe" ); |
379 | cfg.setGroup( "Volume" ); | 380 | cfg.setGroup( "Volume" ); |
380 | if ( percent < 0 ) | 381 | if ( percent < 0 ) |
381 | percent = cfg.readNumEntry( "BassPercent", 50 ); | 382 | percent = cfg.readNumEntry( "BassPercent", 50 ); |
382 | 383 | ||
383 | int fd = 0; | 384 | int fd = 0; |
384 | int bass = percent; | 385 | int bass = percent; |
385 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 386 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
386 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_BASS ), &bass ); | 387 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_BASS ), &bass ); |
387 | ::close( fd ); | 388 | ::close( fd ); |
388 | } | 389 | } |
389 | } | 390 | } |
390 | break; | 391 | break; |
391 | } | 392 | } |
392 | } | 393 | } |
393 | 394 | ||
394 | 395 | ||
395 | static void setTreble( int t = 0, int percent = -1 ) | 396 | static void setTreble( int t = 0, int percent = -1 ) |
396 | { | 397 | { |
397 | switch ( t ) { | 398 | switch ( t ) { |
398 | case 0: { | 399 | case 0: { |
399 | Config cfg( "qpe" ); | 400 | Config cfg( "qpe" ); |
400 | cfg.setGroup( "Volume" ); | 401 | cfg.setGroup( "Volume" ); |
401 | if ( percent < 0 ) | 402 | if ( percent < 0 ) |
402 | percent = cfg.readNumEntry( "TreblePercent", 50 ); | 403 | percent = cfg.readNumEntry( "TreblePercent", 50 ); |
403 | 404 | ||
404 | int fd = 0; | 405 | int fd = 0; |
405 | int treble = percent; | 406 | int treble = percent; |
406 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 407 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
407 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_TREBLE ), &treble ); | 408 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_TREBLE ), &treble ); |
408 | ::close( fd ); | 409 | ::close( fd ); |
409 | } | 410 | } |
410 | } | 411 | } |
411 | break; | 412 | break; |
412 | } | 413 | } |
413 | } | 414 | } |
414 | 415 | ||
415 | 416 | ||
416 | /*! | 417 | /*! |
417 | \class QPEApplication qpeapplication.h | 418 | \class QPEApplication qpeapplication.h |
418 | \brief The QPEApplication class implements various system services | 419 | \brief The QPEApplication class implements various system services |
419 | that are available to all Qtopia applications. | 420 | that are available to all Qtopia applications. |
420 | 421 | ||
421 | Simply by using QPEApplication instead of QApplication, a standard Qt | 422 | Simply by using QPEApplication instead of QApplication, a standard Qt |
422 | application becomes a Qtopia application. It automatically follows | 423 | application becomes a Qtopia application. It automatically follows |
423 | style changes, quits and raises, and in the | 424 | style changes, quits and raises, and in the |
424 | case of \link docwidget.html document-oriented\endlink applications, | 425 | case of \link docwidget.html document-oriented\endlink applications, |
425 | changes the currently displayed document in response to the environment. | 426 | changes the currently displayed document in response to the environment. |
426 | 427 | ||
427 | To create a \link docwidget.html document-oriented\endlink | 428 | To create a \link docwidget.html document-oriented\endlink |
428 | application use showMainDocumentWidget(); to create a | 429 | application use showMainDocumentWidget(); to create a |
429 | non-document-oriented application use showMainWidget(). The | 430 | non-document-oriented application use showMainWidget(). The |
430 | keepRunning() function indicates whether the application will | 431 | keepRunning() function indicates whether the application will |
431 | continue running after it's processed the last \link qcop.html | 432 | continue running after it's processed the last \link qcop.html |
432 | QCop\endlink message. This can be changed using setKeepRunning(). | 433 | QCop\endlink message. This can be changed using setKeepRunning(). |
433 | 434 | ||
434 | A variety of signals are emitted when certain events occur, for | 435 | A variety of signals are emitted when certain events occur, for |
435 | example, timeChanged(), clockChanged(), weekChanged(), | 436 | example, timeChanged(), clockChanged(), weekChanged(), |
436 | dateFormatChanged() and volumeChanged(). If the application receives | 437 | dateFormatChanged() and volumeChanged(). If the application receives |
437 | a \link qcop.html QCop\endlink message on the application's | 438 | a \link qcop.html QCop\endlink message on the application's |
438 | QPE/Application/\e{appname} channel, the appMessage() signal is | 439 | QPE/Application/\e{appname} channel, the appMessage() signal is |
439 | emitted. There are also flush() and reload() signals, which | 440 | emitted. There are also flush() and reload() signals, which |
440 | are emitted when synching begins and ends respectively - upon these | 441 | are emitted when synching begins and ends respectively - upon these |
441 | signals, the application should save and reload any data | 442 | signals, the application should save and reload any data |
442 | files that are involved in synching. Most of these signals will initially | 443 | files that are involved in synching. Most of these signals will initially |
443 | be received and unfiltered through the appMessage() signal. | 444 | be received and unfiltered through the appMessage() signal. |
444 | 445 | ||
445 | This class also provides a set of useful static functions. The | 446 | This class also provides a set of useful static functions. The |
446 | qpeDir() and documentDir() functions return the respective paths. | 447 | qpeDir() and documentDir() functions return the respective paths. |
447 | The grabKeyboard() and ungrabKeyboard() functions are used to | 448 | The grabKeyboard() and ungrabKeyboard() functions are used to |
448 | control whether the application takes control of the device's | 449 | control whether the application takes control of the device's |
449 | physical buttons (e.g. application launch keys). The stylus' mode of | 450 | physical buttons (e.g. application launch keys). The stylus' mode of |
450 | operation is set with setStylusOperation() and retrieved with | 451 | operation is set with setStylusOperation() and retrieved with |
451 | stylusOperation(). There are also setInputMethodHint() and | 452 | stylusOperation(). There are also setInputMethodHint() and |
452 | inputMethodHint() functions. | 453 | inputMethodHint() functions. |
453 | 454 | ||
454 | \ingroup qtopiaemb | 455 | \ingroup qtopiaemb |
455 | */ | 456 | */ |
456 | 457 | ||
457 | /*! | 458 | /*! |
458 | \fn void QPEApplication::clientMoused() | 459 | \fn void QPEApplication::clientMoused() |
459 | 460 | ||
460 | \internal | 461 | \internal |
461 | */ | 462 | */ |
462 | 463 | ||
463 | /*! | 464 | /*! |
464 | \fn void QPEApplication::timeChanged(); | 465 | \fn void QPEApplication::timeChanged(); |
465 | This signal is emitted when the time changes outside the normal | 466 | This signal is emitted when the time changes outside the normal |
466 | passage of time, i.e. if the time is set backwards or forwards. | 467 | passage of time, i.e. if the time is set backwards or forwards. |
467 | */ | 468 | */ |
468 | 469 | ||
469 | /*! | 470 | /*! |
470 | \fn void QPEApplication::clockChanged( bool ampm ); | 471 | \fn void QPEApplication::clockChanged( bool ampm ); |
471 | 472 | ||
472 | This signal is emitted when the user changes the clock's style. If | 473 | This signal is emitted when the user changes the clock's style. If |
473 | \a ampm is TRUE, the user wants a 12-hour AM/PM clock, otherwise, | 474 | \a ampm is TRUE, the user wants a 12-hour AM/PM clock, otherwise, |
474 | they want a 24-hour clock. | 475 | they want a 24-hour clock. |
475 | */ | 476 | */ |
476 | 477 | ||
477 | /*! | 478 | /*! |
478 | \fn void QPEApplication::volumeChanged( bool muted ) | 479 | \fn void QPEApplication::volumeChanged( bool muted ) |
479 | 480 | ||
480 | This signal is emitted whenever the mute state is changed. If \a | 481 | This signal is emitted whenever the mute state is changed. If \a |
481 | muted is TRUE, then sound output has been muted. | 482 | muted is TRUE, then sound output has been muted. |
482 | */ | 483 | */ |
483 | 484 | ||
484 | /*! | 485 | /*! |
485 | \fn void QPEApplication::weekChanged( bool startOnMonday ) | 486 | \fn void QPEApplication::weekChanged( bool startOnMonday ) |
486 | 487 | ||
487 | This signal is emitted if the week start day is changed. If \a | 488 | This signal is emitted if the week start day is changed. If \a |
488 | startOnMonday is TRUE then the first day of the week is Monday; if | 489 | startOnMonday is TRUE then the first day of the week is Monday; if |
489 | \a startOnMonday is FALSE then the first day of the week is | 490 | \a startOnMonday is FALSE then the first day of the week is |
490 | Sunday. | 491 | Sunday. |
491 | */ | 492 | */ |
492 | 493 | ||
493 | /*! | 494 | /*! |
494 | \fn void QPEApplication::dateFormatChanged(DateFormat) | 495 | \fn void QPEApplication::dateFormatChanged(DateFormat) |
495 | 496 | ||
496 | This signal is emitted whenever the date format is changed. | 497 | This signal is emitted whenever the date format is changed. |
497 | */ | 498 | */ |
498 | 499 | ||
499 | /*! | 500 | /*! |
500 | \fn void QPEApplication::flush() | 501 | \fn void QPEApplication::flush() |
501 | 502 | ||
502 | ### | 503 | ### |
503 | */ | 504 | */ |
504 | 505 | ||
505 | /*! | 506 | /*! |
506 | \fn void QPEApplication::reload() | 507 | \fn void QPEApplication::reload() |
507 | 508 | ||
508 | */ | 509 | */ |
509 | 510 | ||
510 | 511 | ||
511 | 512 | ||
512 | void QPEApplication::processQCopFile() | 513 | void QPEApplication::processQCopFile() |
513 | { | 514 | { |
514 | QString qcopfn("/tmp/qcop-msg-"); | 515 | QString qcopfn("/tmp/qcop-msg-"); |
515 | qcopfn += d->appName; // append command name | 516 | qcopfn += d->appName; // append command name |
516 | 517 | ||
517 | QFile f(qcopfn); | 518 | QFile f(qcopfn); |
518 | if ( f.open(IO_ReadWrite) ) { | 519 | if ( f.open(IO_ReadWrite) ) { |
519 | #ifndef Q_OS_WIN32 | 520 | #ifndef Q_OS_WIN32 |
520 | flock(f.handle(), LOCK_EX); | 521 | flock(f.handle(), LOCK_EX); |
521 | #endif | 522 | #endif |
522 | QDataStream ds(&f); | 523 | QDataStream ds(&f); |
523 | QCString channel, message; | 524 | QCString channel, message; |
524 | QByteArray data; | 525 | QByteArray data; |
525 | while(!ds.atEnd()) { | 526 | while(!ds.atEnd()) { |
526 | ds >> channel >> message >> data; | 527 | ds >> channel >> message >> data; |
527 | d->enqueueQCop(channel,message,data); | 528 | d->enqueueQCop(channel,message,data); |
528 | } | 529 | } |
529 | ::ftruncate(f.handle(), 0); | 530 | ::ftruncate(f.handle(), 0); |
530 | #ifndef Q_OS_WIN32 | 531 | #ifndef Q_OS_WIN32 |
531 | f.flush(); | 532 | f.flush(); |
532 | flock(f.handle(), LOCK_UN); | 533 | flock(f.handle(), LOCK_UN); |
533 | #endif | 534 | #endif |
534 | } | 535 | } |
535 | #endif | 536 | #endif |
536 | } | 537 | } |
537 | 538 | ||
538 | 539 | ||
539 | /*! | 540 | /*! |
540 | \fn void QPEApplication::appMessage( const QCString& msg, const QByteArray& data ) | 541 | \fn void QPEApplication::appMessage( const QCString& msg, const QByteArray& data ) |
541 | 542 | ||
542 | This signal is emitted when a message is received on this | 543 | This signal is emitted when a message is received on this |
543 | application's QPE/Application/<i>appname</i> \link qcop.html | 544 | application's QPE/Application/<i>appname</i> \link qcop.html |
544 | QCop\endlink channel. | 545 | QCop\endlink channel. |
545 | 546 | ||
546 | The slot to which you connect this signal uses \a msg and \a data | 547 | The slot to which you connect this signal uses \a msg and \a data |
547 | in the following way: | 548 | in the following way: |
548 | 549 | ||
549 | \code | 550 | \code |
550 | void MyWidget::receive( const QCString& msg, const QByteArray& data ) | 551 | void MyWidget::receive( const QCString& msg, const QByteArray& data ) |
551 | { | 552 | { |
552 | QDataStream stream( data, IO_ReadOnly ); | 553 | QDataStream stream( data, IO_ReadOnly ); |
553 | if ( msg == "someMessage(int,int,int)" ) { | 554 | if ( msg == "someMessage(int,int,int)" ) { |
554 | int a,b,c; | 555 | int a,b,c; |
555 | stream >> a >> b >> c; | 556 | stream >> a >> b >> c; |
556 | ... | 557 | ... |
557 | } else if ( msg == "otherMessage(QString)" ) { | 558 | } else if ( msg == "otherMessage(QString)" ) { |
558 | ... | 559 | ... |
559 | } | 560 | } |
560 | } | 561 | } |
561 | \endcode | 562 | \endcode |
562 | 563 | ||
563 | \sa qcop.html | 564 | \sa qcop.html |
564 | Note that messages received here may be processed by qpe application | 565 | Note that messages received here may be processed by qpe application |
565 | and emitted as signals, such as flush() and reload(). | 566 | and emitted as signals, such as flush() and reload(). |
566 | */ | 567 | */ |
567 | 568 | ||
568 | /*! | 569 | /*! |
569 | Constructs a QPEApplication just as you would construct | 570 | Constructs a QPEApplication just as you would construct |
570 | a QApplication, passing \a argc, \a argv, and \a t. | 571 | a QApplication, passing \a argc, \a argv, and \a t. |
571 | 572 | ||
572 | For applications, \a t should be the default, GuiClient. Only | 573 | For applications, \a t should be the default, GuiClient. Only |
573 | the Qtopia server passes GuiServer. | 574 | the Qtopia server passes GuiServer. |
574 | */ | 575 | */ |
575 | QPEApplication::QPEApplication( int & argc, char **argv, Type t ) | 576 | QPEApplication::QPEApplication( int & argc, char **argv, Type t ) |
576 | : QApplication( hack(argc), argv, t ), pidChannel( 0 ) | 577 | : QApplication( hack(argc), argv, t ), pidChannel( 0 ) |
577 | { | 578 | { |
578 | d = new QPEApplicationData; | 579 | d = new QPEApplicationData; |
579 | d->loadTextCodecs(); | 580 | d->loadTextCodecs(); |
580 | d->loadImageCodecs(); | 581 | d->loadImageCodecs(); |
581 | int dw = desktop() ->width(); | 582 | int dw = desktop() ->width(); |
582 | 583 | ||
583 | if ( dw < 200 ) { | 584 | if ( dw < 200 ) { |
584 | setFont( QFont( "vera", 8 ) ); | 585 | setFont( QFont( "vera", 8 ) ); |
585 | AppLnk::setSmallIconSize( 10 ); | 586 | AppLnk::setSmallIconSize( 10 ); |
586 | AppLnk::setBigIconSize( 28 ); | 587 | AppLnk::setBigIconSize( 28 ); |
587 | } | 588 | } |
588 | #ifndef QT_QWS_SIMPAD | 589 | #ifndef QT_QWS_SIMPAD |
589 | else if ( dw > 600 ) { | 590 | else if ( dw > 600 ) { |
590 | setFont( QFont( "vera", 16 ) ); | 591 | setFont( QFont( "vera", 16 ) ); |
591 | AppLnk::setSmallIconSize( 24 ); | 592 | AppLnk::setSmallIconSize( 24 ); |
592 | AppLnk::setBigIconSize( 48 ); | 593 | AppLnk::setBigIconSize( 48 ); |
593 | } | 594 | } |
594 | #endif | 595 | #endif |
595 | else if ( dw > 200 ) { | 596 | else if ( dw > 200 ) { |
596 | setFont( QFont( "vera", 10 ) ); | 597 | setFont( QFont( "vera", 10 ) ); |
597 | AppLnk::setSmallIconSize( 14 ); | 598 | AppLnk::setSmallIconSize( 14 ); |
598 | AppLnk::setBigIconSize( 32 ); | 599 | AppLnk::setBigIconSize( 32 ); |
599 | } | 600 | } |
600 | 601 | ||
601 | QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory ); | 602 | QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory ); |
602 | 603 | ||
603 | connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) ); | 604 | connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) ); |
604 | 605 | ||
605 | 606 | ||
606 | sysChannel = new QCopChannel( "QPE/System", this ); | 607 | sysChannel = new QCopChannel( "QPE/System", this ); |
607 | connect( sysChannel, SIGNAL( received( const QCString &, const QByteArray & ) ), | 608 | connect( sysChannel, SIGNAL( received( const QCString &, const QByteArray & ) ), |
608 | this, SLOT( systemMessage( const QCString &, const QByteArray & ) ) ); | 609 | this, SLOT( systemMessage( const QCString &, const QByteArray & ) ) ); |
609 | 610 | ||
610 | /* COde now in initapp */ | 611 | /* COde now in initapp */ |
611 | #if 0 | 612 | #if 0 |
612 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 613 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
613 | 614 | ||
614 | QString qcopfn( "/tmp/qcop-msg-" ); | 615 | QString qcopfn( "/tmp/qcop-msg-" ); |
615 | qcopfn += QString( argv[ 0 ] ); // append command name | 616 | qcopfn += QString( argv[ 0 ] ); // append command name |
616 | 617 | ||
617 | QFile f( qcopfn ); | 618 | QFile f( qcopfn ); |
618 | if ( f.open( IO_ReadOnly ) ) { | 619 | if ( f.open( IO_ReadOnly ) ) { |
619 | flock( f.handle(), LOCK_EX ); | 620 | flock( f.handle(), LOCK_EX ); |
620 | } | 621 | } |
621 | 622 | ||
622 | 623 | ||
623 | 624 | ||
624 | QCString channel = QCString( argv[ 0 ] ); | 625 | QCString channel = QCString( argv[ 0 ] ); |
625 | channel.replace( QRegExp( ".*/" ), "" ); | 626 | channel.replace( QRegExp( ".*/" ), "" ); |
626 | d->appName = channel; | 627 | d->appName = channel; |
627 | channel = "QPE/Application/" + channel; | 628 | channel = "QPE/Application/" + channel; |
628 | pidChannel = new QCopChannel( channel, this ); | 629 | pidChannel = new QCopChannel( channel, this ); |
629 | connect( pidChannel, SIGNAL( received( const QCString &, const QByteArray & ) ), | 630 | connect( pidChannel, SIGNAL( received( const QCString &, const QByteArray & ) ), |
630 | this, SLOT( pidMessage( const QCString &, const QByteArray & ) ) ); | 631 | this, SLOT( pidMessage( const QCString &, const QByteArray & ) ) ); |
631 | 632 | ||
632 | if ( f.isOpen() ) { | 633 | if ( f.isOpen() ) { |
633 | d->keep_running = FALSE; | 634 | d->keep_running = FALSE; |
634 | QDataStream ds( &f ); | 635 | QDataStream ds( &f ); |
635 | QCString channel, message; | 636 | QCString channel, message; |
636 | QByteArray data; | 637 | QByteArray data; |
637 | while ( !ds.atEnd() ) { | 638 | while ( !ds.atEnd() ) { |
638 | ds >> channel >> message >> data; | 639 | ds >> channel >> message >> data; |
639 | d->enqueueQCop( channel, message, data ); | 640 | d->enqueueQCop( channel, message, data ); |
640 | } | 641 | } |
641 | 642 | ||
642 | flock( f.handle(), LOCK_UN ); | 643 | flock( f.handle(), LOCK_UN ); |
643 | f.close(); | 644 | f.close(); |
644 | f.remove(); | 645 | f.remove(); |
645 | } | 646 | } |
646 | 647 | ||
647 | for ( int a = 0; a < argc; a++ ) { | 648 | for ( int a = 0; a < argc; a++ ) { |
648 | if ( qstrcmp( argv[ a ], "-preload" ) == 0 ) { | 649 | if ( qstrcmp( argv[ a ], "-preload" ) == 0 ) { |
649 | argv[ a ] = argv[ a + 1 ]; | 650 | argv[ a ] = argv[ a + 1 ]; |
650 | a++; | 651 | a++; |
651 | d->preloaded = TRUE; | 652 | d->preloaded = TRUE; |
652 | argc -= 1; | 653 | argc -= 1; |
653 | } | 654 | } |
654 | else if ( qstrcmp( argv[ a ], "-preload-show" ) == 0 ) { | 655 | else if ( qstrcmp( argv[ a ], "-preload-show" ) == 0 ) { |
655 | argv[ a ] = argv[ a + 1 ]; | 656 | argv[ a ] = argv[ a + 1 ]; |
656 | a++; | 657 | a++; |
657 | d->preloaded = TRUE; | 658 | d->preloaded = TRUE; |
658 | d->forceshow = TRUE; | 659 | d->forceshow = TRUE; |
659 | argc -= 1; | 660 | argc -= 1; |
660 | } | 661 | } |
661 | } | 662 | } |
662 | 663 | ||
663 | /* overide stored arguments */ | 664 | /* overide stored arguments */ |
664 | setArgs( argc, argv ); | 665 | setArgs( argc, argv ); |
665 | 666 | ||
666 | #endif | 667 | #endif |
667 | #else | 668 | #else |
668 | initApp( argc, argv ); | 669 | initApp( argc, argv ); |
669 | #endif | 670 | #endif |
670 | // qwsSetDecoration( new QPEDecoration() ); | 671 | // qwsSetDecoration( new QPEDecoration() ); |
671 | 672 | ||
672 | #ifndef QT_NO_TRANSLATION | 673 | #ifndef QT_NO_TRANSLATION |
673 | 674 | ||
674 | d->langs = Global::languageList(); | 675 | d->langs = Global::languageList(); |
675 | for ( QStringList::ConstIterator it = d->langs.begin(); it != d->langs.end(); ++it ) { | 676 | for ( QStringList::ConstIterator it = d->langs.begin(); it != d->langs.end(); ++it ) { |
676 | QString lang = *it; | 677 | QString lang = *it; |
677 | 678 | ||
678 | installTranslation( lang + "/libopie.qm"); | 679 | installTranslation( lang + "/libopie.qm"); |
679 | installTranslation( lang + "/libqpe.qm" ); | 680 | installTranslation( lang + "/libqpe.qm" ); |
680 | installTranslation( lang + "/" + d->appName + ".qm" ); | 681 | installTranslation( lang + "/" + d->appName + ".qm" ); |
681 | 682 | ||
682 | 683 | ||
683 | //###language/font hack; should look it up somewhere | 684 | //###language/font hack; should look it up somewhere |
684 | #ifdef QWS | 685 | #ifdef QWS |
685 | 686 | ||
686 | if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) { | 687 | if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) { |
687 | QFont fn = FontManager::unicodeFont( FontManager::Proportional ); | 688 | QFont fn = FontManager::unicodeFont( FontManager::Proportional ); |
688 | setFont( fn ); | 689 | setFont( fn ); |
689 | } | 690 | } |
690 | #endif | 691 | #endif |
691 | } | 692 | } |
692 | #endif | 693 | #endif |
693 | 694 | ||
694 | applyStyle(); | 695 | applyStyle(); |
695 | 696 | ||
696 | if ( type() == GuiServer ) { | 697 | if ( type() == GuiServer ) { |
697 | setVolume(); | 698 | setVolume(); |
698 | } | 699 | } |
699 | 700 | ||
700 | installEventFilter( this ); | 701 | installEventFilter( this ); |
701 | 702 | ||
702 | QPEMenuToolFocusManager::initialize(); | 703 | QPEMenuToolFocusManager::initialize(); |
703 | 704 | ||
704 | #ifdef QT_NO_QWS_CURSOR | 705 | #ifdef QT_NO_QWS_CURSOR |
705 | // if we have no cursor, probably don't want tooltips | 706 | // if we have no cursor, probably don't want tooltips |
706 | QToolTip::setEnabled( FALSE ); | 707 | QToolTip::setEnabled( FALSE ); |
707 | #endif | 708 | #endif |
708 | } | 709 | } |
709 | 710 | ||
710 | 711 | ||
711 | #ifdef QTOPIA_INTERNAL_INITAPP | 712 | #ifdef QTOPIA_INTERNAL_INITAPP |
712 | void QPEApplication::initApp( int argc, char **argv ) | 713 | void QPEApplication::initApp( int argc, char **argv ) |
713 | { | 714 | { |
714 | bool initial = pidChannel; // was set to 0 in the initializer | 715 | bool initial = pidChannel; // was set to 0 in the initializer |
715 | delete pidChannel; | 716 | delete pidChannel; |
716 | d->keep_running = TRUE; | 717 | d->keep_running = TRUE; |
717 | d->preloaded = FALSE; | 718 | d->preloaded = FALSE; |
718 | d->forceshow = FALSE; | 719 | d->forceshow = FALSE; |
719 | 720 | ||
720 | QCString channel = QCString(argv[0]); | 721 | QCString channel = QCString(argv[0]); |
721 | 722 | ||
722 | channel.replace(QRegExp(".*/"),""); | 723 | channel.replace(QRegExp(".*/"),""); |
723 | d->appName = channel; | 724 | d->appName = channel; |
724 | 725 | ||
725 | #if QT_VERSION > 235 | 726 | #if QT_VERSION > 235 |
726 | qt_fbdpy->setIdentity( channel ); // In Qt/E 2.3.6 | 727 | qt_fbdpy->setIdentity( channel ); // In Qt/E 2.3.6 |
727 | #endif | 728 | #endif |
728 | 729 | ||
729 | channel = "QPE/Application/" + channel; | 730 | channel = "QPE/Application/" + channel; |
730 | pidChannel = new QCopChannel( channel, this); | 731 | pidChannel = new QCopChannel( channel, this); |
731 | connect( pidChannel, SIGNAL(received(const QCString &, const QByteArray &)), | 732 | connect( pidChannel, SIGNAL(received(const QCString &, const QByteArray &)), |
732 | this, SLOT(pidMessage(const QCString &, const QByteArray &))); | 733 | this, SLOT(pidMessage(const QCString &, const QByteArray &))); |
733 | 734 | ||
734 | if (!initial) { | 735 | if (!initial) { |
735 | processQCopFile(); | 736 | processQCopFile(); |
736 | d->keep_running = d->qcopq.isEmpty(); | 737 | d->keep_running = d->qcopq.isEmpty(); |
737 | } | 738 | } |
738 | 739 | ||
739 | for (int a=0; a<argc; a++) { | 740 | for (int a=0; a<argc; a++) { |
740 | if ( qstrcmp(argv[a],"-preload")==0 ) { | 741 | if ( qstrcmp(argv[a],"-preload")==0 ) { |
741 | argv[a] = argv[a+1]; | 742 | argv[a] = argv[a+1]; |
742 | a++; | 743 | a++; |
743 | d->preloaded = TRUE; | 744 | d->preloaded = TRUE; |
744 | argc-=1; | 745 | argc-=1; |
745 | } else if ( qstrcmp(argv[a],"-preload-show")==0 ) { | 746 | } else if ( qstrcmp(argv[a],"-preload-show")==0 ) { |
746 | argv[a] = argv[a+1]; | 747 | argv[a] = argv[a+1]; |
747 | a++; | 748 | a++; |
748 | d->preloaded = TRUE; | 749 | d->preloaded = TRUE; |
749 | d->forceshow = TRUE; | 750 | d->forceshow = TRUE; |
750 | argc-=1; | 751 | argc-=1; |
751 | } | 752 | } |
752 | } | 753 | } |
753 | 754 | ||
754 | /* overide stored arguments */ | 755 | /* overide stored arguments */ |
755 | setArgs(argc, argv); | 756 | setArgs(argc, argv); |
756 | 757 | ||
757 | /* install translation here */ | 758 | /* install translation here */ |
758 | for ( QStringList::ConstIterator it = d->langs.begin(); it != d->langs.end(); ++it ) | 759 | for ( QStringList::ConstIterator it = d->langs.begin(); it != d->langs.end(); ++it ) |
759 | installTranslation( (*it) + "/" + d->appName + ".qm" ); | 760 | installTranslation( (*it) + "/" + d->appName + ".qm" ); |
760 | } | 761 | } |
761 | #endif | 762 | #endif |
762 | 763 | ||
763 | 764 | ||
764 | static QPtrDict<void>* inputMethodDict = 0; | 765 | static QPtrDict<void>* inputMethodDict = 0; |
765 | static void createInputMethodDict() | 766 | static void createInputMethodDict() |
766 | { | 767 | { |
767 | if ( !inputMethodDict ) | 768 | if ( !inputMethodDict ) |
768 | inputMethodDict = new QPtrDict<void>; | 769 | inputMethodDict = new QPtrDict<void>; |
769 | } | 770 | } |
770 | 771 | ||
771 | /*! | 772 | /*! |
772 | Returns the currently set hint to the system as to whether | 773 | Returns the currently set hint to the system as to whether |
773 | widget \a w has any use for text input methods. | 774 | widget \a w has any use for text input methods. |
774 | 775 | ||
775 | 776 | ||
776 | \sa setInputMethodHint() InputMethodHint | 777 | \sa setInputMethodHint() InputMethodHint |
777 | */ | 778 | */ |
778 | QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w ) | 779 | QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w ) |
779 | { | 780 | { |
780 | if ( inputMethodDict && w ) | 781 | if ( inputMethodDict && w ) |
781 | return ( InputMethodHint ) ( int ) inputMethodDict->find( w ); | 782 | return ( InputMethodHint ) ( int ) inputMethodDict->find( w ); |
782 | return Normal; | 783 | return Normal; |
783 | } | 784 | } |
784 | 785 | ||
785 | /*! | 786 | /*! |
786 | \enum QPEApplication::InputMethodHint | 787 | \enum QPEApplication::InputMethodHint |
787 | 788 | ||
788 | \value Normal the application sometimes needs text input (the default). | 789 | \value Normal the application sometimes needs text input (the default). |
789 | \value AlwaysOff the application never needs text input. | 790 | \value AlwaysOff the application never needs text input. |
790 | \value AlwaysOn the application always needs text input. | 791 | \value AlwaysOn the application always needs text input. |
791 | */ | 792 | */ |
792 | 793 | ||
793 | /*! | 794 | /*! |
794 | Hints to the system that widget \a w has use for text input methods | 795 | Hints to the system that widget \a w has use for text input methods |
795 | as specified by \a mode. | 796 | as specified by \a mode. |
796 | 797 | ||
797 | \sa inputMethodHint() InputMethodHint | 798 | \sa inputMethodHint() InputMethodHint |
798 | */ | 799 | */ |
799 | void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode ) | 800 | void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode ) |
800 | { | 801 | { |
801 | createInputMethodDict(); | 802 | createInputMethodDict(); |
802 | if ( mode == Normal ) { | 803 | if ( mode == Normal ) { |
803 | inputMethodDict->remove | 804 | inputMethodDict->remove |
804 | ( w ); | 805 | ( w ); |
805 | } | 806 | } |
806 | else { | 807 | else { |
807 | inputMethodDict->insert( w, ( void* ) mode ); | 808 | inputMethodDict->insert( w, ( void* ) mode ); |
808 | } | 809 | } |
809 | } | 810 | } |
810 | 811 | ||
811 | class HackDialog : public QDialog | 812 | class HackDialog : public QDialog |
812 | { | 813 | { |
813 | public: | 814 | public: |
814 | void acceptIt() | 815 | void acceptIt() |
815 | { | 816 | { |
816 | accept(); | 817 | accept(); |
817 | } | 818 | } |
818 | void rejectIt() | 819 | void rejectIt() |
819 | { | 820 | { |
820 | reject(); | 821 | reject(); |
821 | } | 822 | } |
822 | }; | 823 | }; |
823 | 824 | ||
824 | 825 | ||
825 | void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key ) | 826 | void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key ) |
826 | { | 827 | { |
827 | // specialised actions for certain widgets. May want to | 828 | // specialised actions for certain widgets. May want to |
828 | // add more stuff here. | 829 | // add more stuff here. |
829 | if ( activePopupWidget() && activePopupWidget() ->inherits( "QListBox" ) | 830 | if ( activePopupWidget() && activePopupWidget() ->inherits( "QListBox" ) |
830 | && activePopupWidget() ->parentWidget() | 831 | && activePopupWidget() ->parentWidget() |
831 | && activePopupWidget() ->parentWidget() ->inherits( "QComboBox" ) ) | 832 | && activePopupWidget() ->parentWidget() ->inherits( "QComboBox" ) ) |
832 | key = Qt::Key_Return; | 833 | key = Qt::Key_Return; |
833 | 834 | ||
834 | if ( activePopupWidget() && activePopupWidget() ->inherits( "QPopupMenu" ) ) | 835 | if ( activePopupWidget() && activePopupWidget() ->inherits( "QPopupMenu" ) ) |
835 | key = Qt::Key_Return; | 836 | key = Qt::Key_Return; |
836 | 837 | ||
837 | #ifdef QWS | 838 | #ifdef QWS |
838 | 839 | ||
839 | ke->simpleData.keycode = key; | 840 | ke->simpleData.keycode = key; |
840 | #endif | 841 | #endif |
841 | } | 842 | } |
842 | 843 | ||
843 | class HackWidget : public QWidget | 844 | class HackWidget : public QWidget |
844 | { | 845 | { |
845 | public: | 846 | public: |
846 | bool needsOk() | 847 | bool needsOk() |
847 | { | 848 | { |
848 | return ( getWState() & WState_Reserved1 ); | 849 | return ( getWState() & WState_Reserved1 ); |
849 | } | 850 | } |
850 | }; | 851 | }; |
851 | 852 | ||
852 | /*! | 853 | /*! |
853 | \internal | 854 | \internal |
854 | */ | 855 | */ |
855 | 856 | ||
856 | #ifdef QWS | 857 | #ifdef QWS |
857 | bool QPEApplication::qwsEventFilter( QWSEvent * e ) | 858 | bool QPEApplication::qwsEventFilter( QWSEvent * e ) |
858 | { | 859 | { |
859 | if ( !d->notbusysent && e->type == QWSEvent::Focus ) { | 860 | if ( !d->notbusysent && e->type == QWSEvent::Focus ) { |
860 | if ( qApp->type() != QApplication::GuiServer ) { | 861 | if ( qApp->type() != QApplication::GuiServer ) { |
861 | QCopEnvelope e( "QPE/System", "notBusy(QString)" ); | 862 | QCopEnvelope e( "QPE/System", "notBusy(QString)" ); |
862 | e << d->appName; | 863 | e << d->appName; |
863 | } | 864 | } |
864 | d->notbusysent = TRUE; | 865 | d->notbusysent = TRUE; |
865 | } | 866 | } |
866 | if ( type() == GuiServer ) { | 867 | if ( type() == GuiServer ) { |
867 | switch ( e->type ) { | 868 | switch ( e->type ) { |
868 | case QWSEvent::Mouse: | 869 | case QWSEvent::Mouse: |
869 | if ( e->asMouse() ->simpleData.state && !QWidget::find( e->window() ) ) | 870 | if ( e->asMouse() ->simpleData.state && !QWidget::find( e->window() ) ) |
870 | emit clientMoused(); | 871 | emit clientMoused(); |
871 | break; | 872 | break; |
872 | default: | 873 | default: |
873 | break; | 874 | break; |
874 | } | 875 | } |
875 | } | 876 | } |
876 | if ( e->type == QWSEvent::Key ) { | 877 | if ( e->type == QWSEvent::Key ) { |
877 | QWSKeyEvent *ke = ( QWSKeyEvent * ) e; | 878 | QWSKeyEvent *ke = ( QWSKeyEvent * ) e; |
878 | if ( ke->simpleData.keycode == Qt::Key_F33 ) { | 879 | if ( ke->simpleData.keycode == Qt::Key_F33 ) { |
879 | // Use special "OK" key to press "OK" on top level widgets | 880 | // Use special "OK" key to press "OK" on top level widgets |
880 | QWidget * active = activeWindow(); | 881 | QWidget * active = activeWindow(); |
881 | QWidget *popup = 0; | 882 | QWidget *popup = 0; |
882 | if ( active && active->isPopup() ) { | 883 | if ( active && active->isPopup() ) { |
883 | popup = active; | 884 | popup = active; |
884 | active = active->parentWidget(); | 885 | active = active->parentWidget(); |
885 | } | 886 | } |
886 | if ( active && ( int ) active->winId() == ke->simpleData.window && | 887 | if ( active && ( int ) active->winId() == ke->simpleData.window && |
887 | !active->testWFlags( WStyle_Customize | WType_Popup | WType_Desktop ) ) { | 888 | !active->testWFlags( WStyle_Customize | WType_Popup | WType_Desktop ) ) { |
888 | if ( ke->simpleData.is_press ) { | 889 | if ( ke->simpleData.is_press ) { |
889 | if ( popup ) | 890 | if ( popup ) |
890 | popup->close(); | 891 | popup->close(); |
891 | if ( active->inherits( "QDialog" ) ) { | 892 | if ( active->inherits( "QDialog" ) ) { |
892 | HackDialog * d = ( HackDialog * ) active; | 893 | HackDialog * d = ( HackDialog * ) active; |
893 | d->acceptIt(); | 894 | d->acceptIt(); |
894 | return TRUE; | 895 | return TRUE; |
895 | } | 896 | } |
896 | else if ( ( ( HackWidget * ) active ) ->needsOk() ) { | 897 | else if ( ( ( HackWidget * ) active ) ->needsOk() ) { |
897 | QSignal s; | 898 | QSignal s; |
898 | s.connect( active, SLOT( accept() ) ); | 899 | s.connect( active, SLOT( accept() ) ); |
899 | s.activate(); | 900 | s.activate(); |
900 | } | 901 | } |
901 | else { | 902 | else { |
902 | // do the same as with the select key: Map to the default action of the widget: | 903 | // do the same as with the select key: Map to the default action of the widget: |
903 | mapToDefaultAction( ke, Qt::Key_Return ); | 904 | mapToDefaultAction( ke, Qt::Key_Return ); |
904 | } | 905 | } |
905 | } | 906 | } |
906 | } | 907 | } |
907 | } | 908 | } |
908 | else if ( ke->simpleData.keycode == Qt::Key_F30 ) { | 909 | else if ( ke->simpleData.keycode == Qt::Key_F30 ) { |
909 | // Use special "select" key to do whatever default action a widget has | 910 | // Use special "select" key to do whatever default action a widget has |
910 | mapToDefaultAction( ke, Qt::Key_Space ); | 911 | mapToDefaultAction( ke, Qt::Key_Space ); |
911 | } | 912 | } |
912 | else if ( ke->simpleData.keycode == Qt::Key_Escape && | 913 | else if ( ke->simpleData.keycode == Qt::Key_Escape && |
913 | ke->simpleData.is_press ) { | 914 | ke->simpleData.is_press ) { |
914 | // Escape key closes app if focus on toplevel | 915 | // Escape key closes app if focus on toplevel |
915 | QWidget * active = activeWindow(); | 916 | QWidget * active = activeWindow(); |
916 | if ( active && active->testWFlags( WType_TopLevel ) && | 917 | if ( active && active->testWFlags( WType_TopLevel ) && |
917 | ( int ) active->winId() == ke->simpleData.window && | 918 | ( int ) active->winId() == ke->simpleData.window && |
918 | !active->testWFlags( WStyle_Dialog | WStyle_Customize | WType_Popup | WType_Desktop ) ) { | 919 | !active->testWFlags( WStyle_Dialog | WStyle_Customize | WType_Popup | WType_Desktop ) ) { |
919 | if ( active->inherits( "QDialog" ) ) { | 920 | if ( active->inherits( "QDialog" ) ) { |
920 | HackDialog * d = ( HackDialog * ) active; | 921 | HackDialog * d = ( HackDialog * ) active; |
921 | d->rejectIt(); | 922 | d->rejectIt(); |
922 | return TRUE; | 923 | return TRUE; |