author | zecke <zecke> | 2003-09-30 08:22:29 (UTC) |
---|---|---|
committer | zecke <zecke> | 2003-09-30 08:22:29 (UTC) |
commit | 5430b226e390cc9af6a3257d6998e34bf806c9e2 (patch) (unidiff) | |
tree | 3a1e3ad2087157c5d95574f2b2a5d09ed68f65d5 /library | |
parent | c638bdc2b6ff6a18ec851f4317629b9d3eed4d7b (diff) | |
download | opie-5430b226e390cc9af6a3257d6998e34bf806c9e2.zip opie-5430b226e390cc9af6a3257d6998e34bf806c9e2.tar.gz opie-5430b226e390cc9af6a3257d6998e34bf806c9e2.tar.bz2 |
Only send local QCOP Requests when you've inserted the event loop because
only at this point they will be delivered right ( slots connected to the
signals )
Needs a backport!!!!
-rw-r--r-- | library/qpeapplication.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp index 86aa53d..4d0b0ea 100644 --- a/library/qpeapplication.cpp +++ b/library/qpeapplication.cpp | |||
@@ -1,400 +1,405 @@ | |||
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 | #ifdef Q_WS_QWS | 25 | #ifdef Q_WS_QWS |
26 | #ifndef QT_NO_COP | 26 | #ifndef QT_NO_COP |
27 | #if QT_VERSION <= 231 | 27 | #if QT_VERSION <= 231 |
28 | #define private public | 28 | #define private public |
29 | #define sendLocally processEvent | 29 | #define sendLocally processEvent |
30 | #include "qcopenvelope_qws.h" | 30 | #include "qcopenvelope_qws.h" |
31 | #undef private | 31 | #undef private |
32 | #else | 32 | #else |
33 | #include "qcopenvelope_qws.h" | 33 | #include "qcopenvelope_qws.h" |
34 | #endif | 34 | #endif |
35 | #endif | 35 | #endif |
36 | #include <qwindowsystem_qws.h> | 36 | #include <qwindowsystem_qws.h> |
37 | #endif | 37 | #endif |
38 | #include <qtextstream.h> | 38 | #include <qtextstream.h> |
39 | #include <qpalette.h> | 39 | #include <qpalette.h> |
40 | #include <qbuffer.h> | 40 | #include <qbuffer.h> |
41 | #include <qptrdict.h> | 41 | #include <qptrdict.h> |
42 | #include <qregexp.h> | 42 | #include <qregexp.h> |
43 | #include <qdir.h> | 43 | #include <qdir.h> |
44 | #include <qlabel.h> | 44 | #include <qlabel.h> |
45 | #include <qdialog.h> | 45 | #include <qdialog.h> |
46 | #include <qdragobject.h> | 46 | #include <qdragobject.h> |
47 | #include <qtextcodec.h> | 47 | #include <qtextcodec.h> |
48 | #include <qevent.h> | 48 | #include <qevent.h> |
49 | #include <qtooltip.h> | 49 | #include <qtooltip.h> |
50 | #include <qsignal.h> | 50 | #include <qsignal.h> |
51 | #include <qmainwindow.h> | 51 | #include <qmainwindow.h> |
52 | #include <qwidgetlist.h> | 52 | #include <qwidgetlist.h> |
53 | 53 | ||
54 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 54 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
55 | #define QTOPIA_INTERNAL_INITAPP | 55 | #define QTOPIA_INTERNAL_INITAPP |
56 | #include "qpeapplication.h" | 56 | #include "qpeapplication.h" |
57 | #include "qpestyle.h" | 57 | #include "qpestyle.h" |
58 | #include "styleinterface.h" | 58 | #include "styleinterface.h" |
59 | #if QT_VERSION >= 300 | 59 | #if QT_VERSION >= 300 |
60 | #include <qstylefactory.h> | 60 | #include <qstylefactory.h> |
61 | #else | 61 | #else |
62 | #include <qplatinumstyle.h> | 62 | #include <qplatinumstyle.h> |
63 | #include <qwindowsstyle.h> | 63 | #include <qwindowsstyle.h> |
64 | #include <qmotifstyle.h> | 64 | #include <qmotifstyle.h> |
65 | #include <qmotifplusstyle.h> | 65 | #include <qmotifplusstyle.h> |
66 | #include "lightstyle.h" | 66 | #include "lightstyle.h" |
67 | 67 | ||
68 | #include <qpe/qlibrary.h> | 68 | #include <qpe/qlibrary.h> |
69 | #endif | 69 | #endif |
70 | #include "global.h" | 70 | #include "global.h" |
71 | #include "resource.h" | 71 | #include "resource.h" |
72 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) | 72 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) |
73 | #include "qutfcodec.h" | 73 | #include "qutfcodec.h" |
74 | #endif | 74 | #endif |
75 | #include "config.h" | 75 | #include "config.h" |
76 | #include "network.h" | 76 | #include "network.h" |
77 | #ifdef QWS | 77 | #ifdef QWS |
78 | #include "fontmanager.h" | 78 | #include "fontmanager.h" |
79 | #endif | 79 | #endif |
80 | 80 | ||
81 | #include "alarmserver.h" | 81 | #include "alarmserver.h" |
82 | #include "applnk.h" | 82 | #include "applnk.h" |
83 | #include "qpemenubar.h" | 83 | #include "qpemenubar.h" |
84 | #include "textcodecinterface.h" | 84 | #include "textcodecinterface.h" |
85 | #include "imagecodecinterface.h" | 85 | #include "imagecodecinterface.h" |
86 | 86 | ||
87 | #include <unistd.h> | 87 | #include <unistd.h> |
88 | #include <sys/file.h> | 88 | #include <sys/file.h> |
89 | #include <sys/ioctl.h> | 89 | #include <sys/ioctl.h> |
90 | #include <sys/soundcard.h> | 90 | #include <sys/soundcard.h> |
91 | 91 | ||
92 | #include "qt_override_p.h" | 92 | #include "qt_override_p.h" |
93 | 93 | ||
94 | 94 | ||
95 | class QPEApplicationData | 95 | class QPEApplicationData |
96 | { | 96 | { |
97 | public: | 97 | public: |
98 | QPEApplicationData ( ) | 98 | QPEApplicationData ( ) |
99 | : presstimer( 0 ), presswidget( 0 ), rightpressed( false ), kbgrabbed( false ), | 99 | : presstimer( 0 ), presswidget( 0 ), rightpressed( false ), kbgrabbed( false ), |
100 | notbusysent( false ), preloaded( false ), forceshow( false ), nomaximize( false ), | 100 | notbusysent( false ), preloaded( false ), forceshow( false ), nomaximize( false ), |
101 | keep_running( true ), qpe_main_widget( 0 ) | 101 | keep_running( true ), qpe_main_widget( 0 ), qcopQok( false ) |
102 | 102 | ||
103 | { | 103 | { |
104 | qcopq.setAutoDelete( TRUE ); | 104 | qcopq.setAutoDelete( TRUE ); |
105 | } | 105 | } |
106 | 106 | ||
107 | int presstimer; | 107 | int presstimer; |
108 | QWidget* presswidget; | 108 | QWidget* presswidget; |
109 | QPoint presspos; | 109 | QPoint presspos; |
110 | 110 | ||
111 | bool rightpressed : 1; | 111 | bool rightpressed : 1; |
112 | bool kbgrabbed : 1; | 112 | bool kbgrabbed : 1; |
113 | bool notbusysent : 1; | 113 | bool notbusysent : 1; |
114 | bool preloaded : 1; | 114 | bool preloaded : 1; |
115 | bool forceshow : 1; | 115 | bool forceshow : 1; |
116 | bool nomaximize : 1; | 116 | bool nomaximize : 1; |
117 | bool qcopQok : 1; | ||
117 | bool keep_running : 1; | 118 | bool keep_running : 1; |
118 | 119 | ||
120 | |||
119 | QStringList langs; | 121 | QStringList langs; |
120 | QString appName; | 122 | QString appName; |
121 | struct QCopRec | 123 | struct QCopRec |
122 | { | 124 | { |
123 | QCopRec( const QCString &ch, const QCString &msg, | 125 | QCopRec( const QCString &ch, const QCString &msg, |
124 | const QByteArray &d ) : | 126 | const QByteArray &d ) : |
125 | channel( ch ), message( msg ), data( d ) | 127 | channel( ch ), message( msg ), data( d ) |
126 | { } | 128 | { } |
127 | 129 | ||
128 | QCString channel; | 130 | QCString channel; |
129 | QCString message; | 131 | QCString message; |
130 | QByteArray data; | 132 | QByteArray data; |
131 | }; | 133 | }; |
132 | QWidget* qpe_main_widget; | 134 | QWidget* qpe_main_widget; |
133 | QGuardedPtr<QWidget> lastraised; | 135 | QGuardedPtr<QWidget> lastraised; |
134 | QList<QCopRec> qcopq; | 136 | QList<QCopRec> qcopq; |
135 | QString styleName; | 137 | QString styleName; |
136 | QString decorationName; | 138 | QString decorationName; |
137 | 139 | ||
138 | void enqueueQCop( const QCString &ch, const QCString &msg, | 140 | void enqueueQCop( const QCString &ch, const QCString &msg, |
139 | const QByteArray &data ) | 141 | const QByteArray &data ) |
140 | { | 142 | { |
141 | qcopq.append( new QCopRec( ch, msg, data ) ); | 143 | qcopq.append( new QCopRec( ch, msg, data ) ); |
142 | } | 144 | } |
143 | void sendQCopQ() | 145 | void sendQCopQ() |
144 | { | 146 | { |
147 | if (!qcopQok ) | ||
148 | return; | ||
149 | |||
145 | QCopRec * r; | 150 | QCopRec * r; |
146 | #ifndef QT_NO_COP | 151 | #ifndef QT_NO_COP |
147 | 152 | ||
148 | for ( QListIterator<QCopRec> it( qcopq ); ( r = it.current() ); ++it ) | 153 | for ( QListIterator<QCopRec> it( qcopq ); ( r = it.current() ); ++it ) |
149 | QCopChannel::sendLocally( r->channel, r->message, r->data ); | 154 | QCopChannel::sendLocally( r->channel, r->message, r->data ); |
150 | #endif | 155 | #endif |
151 | 156 | ||
152 | qcopq.clear(); | 157 | qcopq.clear(); |
153 | } | 158 | } |
154 | static void show_mx(QWidget* mw, bool nomaximize, const QString & = QString::null ) | 159 | static void show_mx(QWidget* mw, bool nomaximize, const QString & = QString::null ) |
155 | { | 160 | { |
156 | 161 | ||
157 | // ugly hack, remove that later after finding a sane solution | 162 | // ugly hack, remove that later after finding a sane solution |
158 | // Addendum: Only Sharp currently has models with high resolution but (physically) small displays, | 163 | // Addendum: Only Sharp currently has models with high resolution but (physically) small displays, |
159 | // so this is only useful if QT_QWS_SIMPAD is NOT defined. E.g. SIMpad has 800x600 but has | 164 | // so this is only useful if QT_QWS_SIMPAD is NOT defined. E.g. SIMpad has 800x600 but has |
160 | // a (physically) large enough display to use the small icons | 165 | // a (physically) large enough display to use the small icons |
161 | #ifndef QT_QWS_SIMPAD | 166 | #ifndef QT_QWS_SIMPAD |
162 | if ( QPEApplication::desktop() ->width() >= 600 && ( mw->inherits("QMainWindow") || mw->isA("QMainWindow") ) ) { | 167 | if ( QPEApplication::desktop() ->width() >= 600 && ( mw->inherits("QMainWindow") || mw->isA("QMainWindow") ) ) { |
163 | ( ( QMainWindow* ) mw )->setUsesBigPixmaps( true ); | 168 | ( ( QMainWindow* ) mw )->setUsesBigPixmaps( true ); |
164 | } | 169 | } |
165 | #endif | 170 | #endif |
166 | 171 | ||
167 | if ( mw->layout() && mw->inherits("QDialog") ) { | 172 | if ( mw->layout() && mw->inherits("QDialog") ) { |
168 | QPEApplication::showDialog((QDialog*)mw, nomaximize); | 173 | QPEApplication::showDialog((QDialog*)mw, nomaximize); |
169 | } | 174 | } |
170 | else { | 175 | else { |
171 | #ifdef Q_WS_QWS | 176 | #ifdef Q_WS_QWS |
172 | if ( !nomaximize ) | 177 | if ( !nomaximize ) |
173 | mw->showMaximized(); | 178 | mw->showMaximized(); |
174 | else | 179 | else |
175 | #endif | 180 | #endif |
176 | 181 | ||
177 | mw->show(); | 182 | mw->show(); |
178 | } | 183 | } |
179 | } | 184 | } |
180 | static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) | 185 | static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) |
181 | { | 186 | { |
182 | /* | 187 | /* |
183 | // This works but disable it for now until it is safe to apply | 188 | // This works but disable it for now until it is safe to apply |
184 | // What is does is scan the .desktop files of all the apps for | 189 | // What is does is scan the .desktop files of all the apps for |
185 | // the applnk that has the corresponding argv[0] as this program | 190 | // the applnk that has the corresponding argv[0] as this program |
186 | // then it uses the name stored in the .desktop file as the caption | 191 | // then it uses the name stored in the .desktop file as the caption |
187 | // for the main widget. This saves duplicating translations for | 192 | // for the main widget. This saves duplicating translations for |
188 | // the app name in the program and in the .desktop files. | 193 | // the app name in the program and in the .desktop files. |
189 | 194 | ||
190 | AppLnkSet apps( appsPath ); | 195 | AppLnkSet apps( appsPath ); |
191 | 196 | ||
192 | QList<AppLnk> appsList = apps.children(); | 197 | QList<AppLnk> appsList = apps.children(); |
193 | for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) { | 198 | for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) { |
194 | if ( (*it)->exec() == appName ) { | 199 | if ( (*it)->exec() == appName ) { |
195 | mw->setCaption( (*it)->name() ); | 200 | mw->setCaption( (*it)->name() ); |
196 | return TRUE; | 201 | return TRUE; |
197 | } | 202 | } |
198 | } | 203 | } |
199 | */ | 204 | */ |
200 | return FALSE; | 205 | return FALSE; |
201 | } | 206 | } |
202 | 207 | ||
203 | 208 | ||
204 | void show(QWidget* mw, bool nomax) | 209 | void show(QWidget* mw, bool nomax) |
205 | { | 210 | { |
206 | setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" ); | 211 | setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" ); |
207 | nomaximize = nomax; | 212 | nomaximize = nomax; |
208 | qpe_main_widget = mw; | 213 | qpe_main_widget = mw; |
209 | #ifndef QT_NO_COP | 214 | #ifndef QT_NO_COP |
210 | 215 | ||
211 | sendQCopQ(); | 216 | sendQCopQ(); |
212 | #endif | 217 | #endif |
213 | 218 | ||
214 | if ( preloaded ) { | 219 | if ( preloaded ) { |
215 | if (forceshow) | 220 | if (forceshow) |
216 | show_mx(mw, nomax); | 221 | show_mx(mw, nomax); |
217 | } | 222 | } |
218 | else if ( keep_running ) { | 223 | else if ( keep_running ) { |
219 | show_mx(mw, nomax); | 224 | show_mx(mw, nomax); |
220 | } | 225 | } |
221 | } | 226 | } |
222 | 227 | ||
223 | void loadTextCodecs() | 228 | void loadTextCodecs() |
224 | { | 229 | { |
225 | QString path = QPEApplication::qpeDir() + "/plugins/textcodecs"; | 230 | QString path = QPEApplication::qpeDir() + "/plugins/textcodecs"; |
226 | QDir dir( path, "lib*.so" ); | 231 | QDir dir( path, "lib*.so" ); |
227 | QStringList list; | 232 | QStringList list; |
228 | if ( dir. exists ( )) | 233 | if ( dir. exists ( )) |
229 | list = dir.entryList(); | 234 | list = dir.entryList(); |
230 | QStringList::Iterator it; | 235 | QStringList::Iterator it; |
231 | for ( it = list.begin(); it != list.end(); ++it ) { | 236 | for ( it = list.begin(); it != list.end(); ++it ) { |
232 | TextCodecInterface *iface = 0; | 237 | TextCodecInterface *iface = 0; |
233 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 238 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
234 | if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { | 239 | if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { |
235 | QValueList<int> mibs = iface->mibEnums(); | 240 | QValueList<int> mibs = iface->mibEnums(); |
236 | for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) { | 241 | for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) { |
237 | (void)iface->createForMib(*i); | 242 | (void)iface->createForMib(*i); |
238 | // ### it exists now; need to remember if we can delete it | 243 | // ### it exists now; need to remember if we can delete it |
239 | } | 244 | } |
240 | } | 245 | } |
241 | else { | 246 | else { |
242 | lib->unload(); | 247 | lib->unload(); |
243 | delete lib; | 248 | delete lib; |
244 | } | 249 | } |
245 | } | 250 | } |
246 | } | 251 | } |
247 | 252 | ||
248 | void loadImageCodecs() | 253 | void loadImageCodecs() |
249 | { | 254 | { |
250 | QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs"; | 255 | QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs"; |
251 | QDir dir( path, "lib*.so" ); | 256 | QDir dir( path, "lib*.so" ); |
252 | QStringList list; | 257 | QStringList list; |
253 | if ( dir. exists ( )) | 258 | if ( dir. exists ( )) |
254 | list = dir.entryList(); | 259 | list = dir.entryList(); |
255 | QStringList::Iterator it; | 260 | QStringList::Iterator it; |
256 | for ( it = list.begin(); it != list.end(); ++it ) { | 261 | for ( it = list.begin(); it != list.end(); ++it ) { |
257 | ImageCodecInterface *iface = 0; | 262 | ImageCodecInterface *iface = 0; |
258 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 263 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
259 | if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { | 264 | if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { |
260 | QStringList formats = iface->keys(); | 265 | QStringList formats = iface->keys(); |
261 | for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) { | 266 | for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) { |
262 | (void)iface->installIOHandler(*i); | 267 | (void)iface->installIOHandler(*i); |
263 | // ### it exists now; need to remember if we can delete it | 268 | // ### it exists now; need to remember if we can delete it |
264 | } | 269 | } |
265 | } | 270 | } |
266 | else { | 271 | else { |
267 | lib->unload(); | 272 | lib->unload(); |
268 | delete lib; | 273 | delete lib; |
269 | } | 274 | } |
270 | } | 275 | } |
271 | } | 276 | } |
272 | }; | 277 | }; |
273 | 278 | ||
274 | class ResourceMimeFactory : public QMimeSourceFactory | 279 | class ResourceMimeFactory : public QMimeSourceFactory |
275 | { | 280 | { |
276 | public: | 281 | public: |
277 | ResourceMimeFactory() : resImage( 0 ) | 282 | ResourceMimeFactory() : resImage( 0 ) |
278 | { | 283 | { |
279 | setFilePath( Global::helpPath() ); | 284 | setFilePath( Global::helpPath() ); |
280 | setExtensionType( "html", "text/html;charset=UTF-8" ); | 285 | setExtensionType( "html", "text/html;charset=UTF-8" ); |
281 | } | 286 | } |
282 | ~ResourceMimeFactory() { | 287 | ~ResourceMimeFactory() { |
283 | delete resImage; | 288 | delete resImage; |
284 | } | 289 | } |
285 | 290 | ||
286 | const QMimeSource* data( const QString& abs_name ) const | 291 | const QMimeSource* data( const QString& abs_name ) const |
287 | { | 292 | { |
288 | const QMimeSource * r = QMimeSourceFactory::data( abs_name ); | 293 | const QMimeSource * r = QMimeSourceFactory::data( abs_name ); |
289 | if ( !r ) { | 294 | if ( !r ) { |
290 | int sl = abs_name.length(); | 295 | int sl = abs_name.length(); |
291 | do { | 296 | do { |
292 | sl = abs_name.findRev( '/', sl - 1 ); | 297 | sl = abs_name.findRev( '/', sl - 1 ); |
293 | QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name; | 298 | QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name; |
294 | int dot = name.findRev( '.' ); | 299 | int dot = name.findRev( '.' ); |
295 | if ( dot >= 0 ) | 300 | if ( dot >= 0 ) |
296 | name = name.left( dot ); | 301 | name = name.left( dot ); |
297 | QImage img = Resource::loadImage( name ); | 302 | QImage img = Resource::loadImage( name ); |
298 | if ( !img.isNull() ) { | 303 | if ( !img.isNull() ) { |
299 | delete resImage; | 304 | delete resImage; |
300 | resImage = new QImageDrag( img ); | 305 | resImage = new QImageDrag( img ); |
301 | r = resImage; | 306 | r = resImage; |
302 | } | 307 | } |
303 | } | 308 | } |
304 | while ( !r && sl > 0 ); | 309 | while ( !r && sl > 0 ); |
305 | } | 310 | } |
306 | return r; | 311 | return r; |
307 | } | 312 | } |
308 | private: | 313 | private: |
309 | mutable QImageDrag *resImage; | 314 | mutable QImageDrag *resImage; |
310 | }; | 315 | }; |
311 | 316 | ||
312 | static int& hack(int& i) | 317 | static int& hack(int& i) |
313 | { | 318 | { |
314 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) | 319 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) |
315 | // These should be created, but aren't in Qt 2.3.0 | 320 | // These should be created, but aren't in Qt 2.3.0 |
316 | (void)new QUtf8Codec; | 321 | (void)new QUtf8Codec; |
317 | (void)new QUtf16Codec; | 322 | (void)new QUtf16Codec; |
318 | #endif | 323 | #endif |
319 | return i; | 324 | return i; |
320 | } | 325 | } |
321 | 326 | ||
322 | static int muted = 0; | 327 | static int muted = 0; |
323 | static int micMuted = 0; | 328 | static int micMuted = 0; |
324 | 329 | ||
325 | static void setVolume( int t = 0, int percent = -1 ) | 330 | static void setVolume( int t = 0, int percent = -1 ) |
326 | { | 331 | { |
327 | switch ( t ) { | 332 | switch ( t ) { |
328 | case 0: { | 333 | case 0: { |
329 | Config cfg( "qpe" ); | 334 | Config cfg( "qpe" ); |
330 | cfg.setGroup( "Volume" ); | 335 | cfg.setGroup( "Volume" ); |
331 | if ( percent < 0 ) | 336 | if ( percent < 0 ) |
332 | percent = cfg.readNumEntry( "VolumePercent", 50 ); | 337 | percent = cfg.readNumEntry( "VolumePercent", 50 ); |
333 | int fd = 0; | 338 | int fd = 0; |
334 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 339 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
335 | int vol = muted ? 0 : percent; | 340 | int vol = muted ? 0 : percent; |
336 | // set both channels to same volume | 341 | // set both channels to same volume |
337 | vol |= vol << 8; | 342 | vol |= vol << 8; |
338 | ioctl( fd, MIXER_WRITE( 0 ), &vol ); | 343 | ioctl( fd, MIXER_WRITE( 0 ), &vol ); |
339 | ::close( fd ); | 344 | ::close( fd ); |
340 | } | 345 | } |
341 | } | 346 | } |
342 | break; | 347 | break; |
343 | } | 348 | } |
344 | } | 349 | } |
345 | 350 | ||
346 | static void setMic( int t = 0, int percent = -1 ) | 351 | static void setMic( int t = 0, int percent = -1 ) |
347 | { | 352 | { |
348 | switch ( t ) { | 353 | switch ( t ) { |
349 | case 0: { | 354 | case 0: { |
350 | Config cfg( "qpe" ); | 355 | Config cfg( "qpe" ); |
351 | cfg.setGroup( "Volume" ); | 356 | cfg.setGroup( "Volume" ); |
352 | if ( percent < 0 ) | 357 | if ( percent < 0 ) |
353 | percent = cfg.readNumEntry( "Mic", 50 ); | 358 | percent = cfg.readNumEntry( "Mic", 50 ); |
354 | 359 | ||
355 | int fd = 0; | 360 | int fd = 0; |
356 | int mic = micMuted ? 0 : percent; | 361 | int mic = micMuted ? 0 : percent; |
357 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 362 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
358 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_MIC ), &mic ); | 363 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_MIC ), &mic ); |
359 | ::close( fd ); | 364 | ::close( fd ); |
360 | } | 365 | } |
361 | } | 366 | } |
362 | break; | 367 | break; |
363 | } | 368 | } |
364 | } | 369 | } |
365 | 370 | ||
366 | 371 | ||
367 | static void setBass( int t = 0, int percent = -1 ) | 372 | static void setBass( int t = 0, int percent = -1 ) |
368 | { | 373 | { |
369 | switch ( t ) { | 374 | switch ( t ) { |
370 | case 0: { | 375 | case 0: { |
371 | Config cfg( "qpe" ); | 376 | Config cfg( "qpe" ); |
372 | cfg.setGroup( "Volume" ); | 377 | cfg.setGroup( "Volume" ); |
373 | if ( percent < 0 ) | 378 | if ( percent < 0 ) |
374 | percent = cfg.readNumEntry( "BassPercent", 50 ); | 379 | percent = cfg.readNumEntry( "BassPercent", 50 ); |
375 | 380 | ||
376 | int fd = 0; | 381 | int fd = 0; |
377 | int bass = percent; | 382 | int bass = percent; |
378 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 383 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
379 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_BASS ), &bass ); | 384 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_BASS ), &bass ); |
380 | ::close( fd ); | 385 | ::close( fd ); |
381 | } | 386 | } |
382 | } | 387 | } |
383 | break; | 388 | break; |
384 | } | 389 | } |
385 | } | 390 | } |
386 | 391 | ||
387 | 392 | ||
388 | static void setTreble( int t = 0, int percent = -1 ) | 393 | static void setTreble( int t = 0, int percent = -1 ) |
389 | { | 394 | { |
390 | switch ( t ) { | 395 | switch ( t ) { |
391 | case 0: { | 396 | case 0: { |
392 | Config cfg( "qpe" ); | 397 | Config cfg( "qpe" ); |
393 | cfg.setGroup( "Volume" ); | 398 | cfg.setGroup( "Volume" ); |
394 | if ( percent < 0 ) | 399 | if ( percent < 0 ) |
395 | percent = cfg.readNumEntry( "TreblePercent", 50 ); | 400 | percent = cfg.readNumEntry( "TreblePercent", 50 ); |
396 | 401 | ||
397 | int fd = 0; | 402 | int fd = 0; |
398 | int treble = percent; | 403 | int treble = percent; |
399 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 404 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
400 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_TREBLE ), &treble ); | 405 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_TREBLE ), &treble ); |
@@ -1640,410 +1645,411 @@ void QPEApplication::internalSetStyle( const QString &style ) | |||
1640 | static StyleInterface *lastiface = 0; | 1645 | static StyleInterface *lastiface = 0; |
1641 | 1646 | ||
1642 | QLibrary *lib = new QLibrary ( path ); | 1647 | QLibrary *lib = new QLibrary ( path ); |
1643 | StyleInterface *iface = 0; | 1648 | StyleInterface *iface = 0; |
1644 | 1649 | ||
1645 | if (( lib-> queryInterface ( IID_Style, ( QUnknownInterface ** ) &iface ) == QS_OK ) && iface ) | 1650 | if (( lib-> queryInterface ( IID_Style, ( QUnknownInterface ** ) &iface ) == QS_OK ) && iface ) |
1646 | sty = iface-> style ( ); | 1651 | sty = iface-> style ( ); |
1647 | 1652 | ||
1648 | if ( sty ) { | 1653 | if ( sty ) { |
1649 | setStyle ( sty ); | 1654 | setStyle ( sty ); |
1650 | 1655 | ||
1651 | if ( lastiface ) | 1656 | if ( lastiface ) |
1652 | lastiface-> release ( ); | 1657 | lastiface-> release ( ); |
1653 | lastiface = iface; | 1658 | lastiface = iface; |
1654 | 1659 | ||
1655 | if ( lastlib ) { | 1660 | if ( lastlib ) { |
1656 | lastlib-> unload ( ); | 1661 | lastlib-> unload ( ); |
1657 | delete lastlib; | 1662 | delete lastlib; |
1658 | } | 1663 | } |
1659 | lastlib = lib; | 1664 | lastlib = lib; |
1660 | } | 1665 | } |
1661 | else { | 1666 | else { |
1662 | if ( iface ) | 1667 | if ( iface ) |
1663 | iface-> release ( ); | 1668 | iface-> release ( ); |
1664 | delete lib; | 1669 | delete lib; |
1665 | 1670 | ||
1666 | setStyle ( new LightStyle ( )); | 1671 | setStyle ( new LightStyle ( )); |
1667 | } | 1672 | } |
1668 | } | 1673 | } |
1669 | #endif | 1674 | #endif |
1670 | } | 1675 | } |
1671 | 1676 | ||
1672 | /*! | 1677 | /*! |
1673 | \internal | 1678 | \internal |
1674 | */ | 1679 | */ |
1675 | void QPEApplication::prepareForTermination( bool willrestart ) | 1680 | void QPEApplication::prepareForTermination( bool willrestart ) |
1676 | { | 1681 | { |
1677 | if ( willrestart ) { | 1682 | if ( willrestart ) { |
1678 | // Draw a big wait icon, the image can be altered in later revisions | 1683 | // Draw a big wait icon, the image can be altered in later revisions |
1679 | // QWidget *d = QApplication::desktop(); | 1684 | // QWidget *d = QApplication::desktop(); |
1680 | QImage img = Resource::loadImage( "launcher/new_wait" ); | 1685 | QImage img = Resource::loadImage( "launcher/new_wait" ); |
1681 | QPixmap pix; | 1686 | QPixmap pix; |
1682 | pix.convertFromImage( img.smoothScale( 1 * img.width(), 1 * img.height() ) ); | 1687 | pix.convertFromImage( img.smoothScale( 1 * img.width(), 1 * img.height() ) ); |
1683 | QLabel *lblWait = new QLabel( 0, "wait hack!", QWidget::WStyle_Customize | | 1688 | QLabel *lblWait = new QLabel( 0, "wait hack!", QWidget::WStyle_Customize | |
1684 | QWidget::WStyle_NoBorder | QWidget::WStyle_Tool ); | 1689 | QWidget::WStyle_NoBorder | QWidget::WStyle_Tool ); |
1685 | lblWait->setPixmap( pix ); | 1690 | lblWait->setPixmap( pix ); |
1686 | lblWait->setAlignment( QWidget::AlignCenter ); | 1691 | lblWait->setAlignment( QWidget::AlignCenter ); |
1687 | lblWait->show(); | 1692 | lblWait->show(); |
1688 | lblWait->showMaximized(); | 1693 | lblWait->showMaximized(); |
1689 | } | 1694 | } |
1690 | #ifndef SINGLE_APP | 1695 | #ifndef SINGLE_APP |
1691 | { QCopEnvelope envelope( "QPE/System", "forceQuit()" ); | 1696 | { QCopEnvelope envelope( "QPE/System", "forceQuit()" ); |
1692 | } | 1697 | } |
1693 | processEvents(); // ensure the message goes out. | 1698 | processEvents(); // ensure the message goes out. |
1694 | sleep( 1 ); // You have 1 second to comply. | 1699 | sleep( 1 ); // You have 1 second to comply. |
1695 | #endif | 1700 | #endif |
1696 | } | 1701 | } |
1697 | 1702 | ||
1698 | /*! | 1703 | /*! |
1699 | \internal | 1704 | \internal |
1700 | */ | 1705 | */ |
1701 | void QPEApplication::shutdown() | 1706 | void QPEApplication::shutdown() |
1702 | { | 1707 | { |
1703 | // Implement in server's QPEApplication subclass | 1708 | // Implement in server's QPEApplication subclass |
1704 | } | 1709 | } |
1705 | 1710 | ||
1706 | /*! | 1711 | /*! |
1707 | \internal | 1712 | \internal |
1708 | */ | 1713 | */ |
1709 | void QPEApplication::restart() | 1714 | void QPEApplication::restart() |
1710 | { | 1715 | { |
1711 | // Implement in server's QPEApplication subclass | 1716 | // Implement in server's QPEApplication subclass |
1712 | } | 1717 | } |
1713 | 1718 | ||
1714 | static QPtrDict<void>* stylusDict = 0; | 1719 | static QPtrDict<void>* stylusDict = 0; |
1715 | static void createDict() | 1720 | static void createDict() |
1716 | { | 1721 | { |
1717 | if ( !stylusDict ) | 1722 | if ( !stylusDict ) |
1718 | stylusDict = new QPtrDict<void>; | 1723 | stylusDict = new QPtrDict<void>; |
1719 | } | 1724 | } |
1720 | 1725 | ||
1721 | /*! | 1726 | /*! |
1722 | Returns the current StylusMode for widget \a w. | 1727 | Returns the current StylusMode for widget \a w. |
1723 | 1728 | ||
1724 | \sa setStylusOperation() StylusMode | 1729 | \sa setStylusOperation() StylusMode |
1725 | */ | 1730 | */ |
1726 | QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w ) | 1731 | QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w ) |
1727 | { | 1732 | { |
1728 | if ( stylusDict ) | 1733 | if ( stylusDict ) |
1729 | return ( StylusMode ) ( int ) stylusDict->find( w ); | 1734 | return ( StylusMode ) ( int ) stylusDict->find( w ); |
1730 | return LeftOnly; | 1735 | return LeftOnly; |
1731 | } | 1736 | } |
1732 | 1737 | ||
1733 | /*! | 1738 | /*! |
1734 | \enum QPEApplication::StylusMode | 1739 | \enum QPEApplication::StylusMode |
1735 | 1740 | ||
1736 | \value LeftOnly the stylus only generates LeftButton | 1741 | \value LeftOnly the stylus only generates LeftButton |
1737 | events (the default). | 1742 | events (the default). |
1738 | \value RightOnHold the stylus generates RightButton events | 1743 | \value RightOnHold the stylus generates RightButton events |
1739 | if the user uses the press-and-hold gesture. | 1744 | if the user uses the press-and-hold gesture. |
1740 | 1745 | ||
1741 | \sa setStylusOperation() stylusOperation() | 1746 | \sa setStylusOperation() stylusOperation() |
1742 | */ | 1747 | */ |
1743 | 1748 | ||
1744 | /*! | 1749 | /*! |
1745 | Causes widget \a w to receive mouse events according to the stylus | 1750 | Causes widget \a w to receive mouse events according to the stylus |
1746 | \a mode. | 1751 | \a mode. |
1747 | 1752 | ||
1748 | \sa stylusOperation() StylusMode | 1753 | \sa stylusOperation() StylusMode |
1749 | */ | 1754 | */ |
1750 | void QPEApplication::setStylusOperation( QWidget * w, StylusMode mode ) | 1755 | void QPEApplication::setStylusOperation( QWidget * w, StylusMode mode ) |
1751 | { | 1756 | { |
1752 | createDict(); | 1757 | createDict(); |
1753 | if ( mode == LeftOnly ) { | 1758 | if ( mode == LeftOnly ) { |
1754 | stylusDict->remove | 1759 | stylusDict->remove |
1755 | ( w ); | 1760 | ( w ); |
1756 | w->removeEventFilter( qApp ); | 1761 | w->removeEventFilter( qApp ); |
1757 | } | 1762 | } |
1758 | else { | 1763 | else { |
1759 | stylusDict->insert( w, ( void* ) mode ); | 1764 | stylusDict->insert( w, ( void* ) mode ); |
1760 | connect( w, SIGNAL( destroyed() ), qApp, SLOT( removeSenderFromStylusDict() ) ); | 1765 | connect( w, SIGNAL( destroyed() ), qApp, SLOT( removeSenderFromStylusDict() ) ); |
1761 | w->installEventFilter( qApp ); | 1766 | w->installEventFilter( qApp ); |
1762 | } | 1767 | } |
1763 | } | 1768 | } |
1764 | 1769 | ||
1765 | 1770 | ||
1766 | /*! | 1771 | /*! |
1767 | \reimp | 1772 | \reimp |
1768 | */ | 1773 | */ |
1769 | bool QPEApplication::eventFilter( QObject *o, QEvent *e ) | 1774 | bool QPEApplication::eventFilter( QObject *o, QEvent *e ) |
1770 | { | 1775 | { |
1771 | if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) { | 1776 | if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) { |
1772 | QMouseEvent * me = ( QMouseEvent* ) e; | 1777 | QMouseEvent * me = ( QMouseEvent* ) e; |
1773 | StylusMode mode = (StylusMode)(int)stylusDict->find(o); | 1778 | StylusMode mode = (StylusMode)(int)stylusDict->find(o); |
1774 | switch (mode) { | 1779 | switch (mode) { |
1775 | case RightOnHold: | 1780 | case RightOnHold: |
1776 | switch ( me->type() ) { | 1781 | switch ( me->type() ) { |
1777 | case QEvent::MouseButtonPress: | 1782 | case QEvent::MouseButtonPress: |
1778 | if ( me->button() == LeftButton ) { | 1783 | if ( me->button() == LeftButton ) { |
1779 | d->presstimer = startTimer(500); // #### pref. | 1784 | d->presstimer = startTimer(500); // #### pref. |
1780 | d->presswidget = (QWidget*)o; | 1785 | d->presswidget = (QWidget*)o; |
1781 | d->presspos = me->pos(); | 1786 | d->presspos = me->pos(); |
1782 | d->rightpressed = FALSE; | 1787 | d->rightpressed = FALSE; |
1783 | } | 1788 | } |
1784 | break; | 1789 | break; |
1785 | case QEvent::MouseMove: | 1790 | case QEvent::MouseMove: |
1786 | if (d->presstimer && (me->pos() - d->presspos).manhattanLength() > 8) { | 1791 | if (d->presstimer && (me->pos() - d->presspos).manhattanLength() > 8) { |
1787 | killTimer(d->presstimer); | 1792 | killTimer(d->presstimer); |
1788 | d->presstimer = 0; | 1793 | d->presstimer = 0; |
1789 | } | 1794 | } |
1790 | break; | 1795 | break; |
1791 | case QEvent::MouseButtonRelease: | 1796 | case QEvent::MouseButtonRelease: |
1792 | if ( me->button() == LeftButton ) { | 1797 | if ( me->button() == LeftButton ) { |
1793 | if ( d->presstimer ) { | 1798 | if ( d->presstimer ) { |
1794 | killTimer(d->presstimer); | 1799 | killTimer(d->presstimer); |
1795 | d->presstimer = 0; | 1800 | d->presstimer = 0; |
1796 | } | 1801 | } |
1797 | if ( d->rightpressed && d->presswidget ) { | 1802 | if ( d->rightpressed && d->presswidget ) { |
1798 | // Right released | 1803 | // Right released |
1799 | postEvent( d->presswidget, | 1804 | postEvent( d->presswidget, |
1800 | new QMouseEvent( QEvent::MouseButtonRelease, me->pos(), | 1805 | new QMouseEvent( QEvent::MouseButtonRelease, me->pos(), |
1801 | RightButton, LeftButton + RightButton ) ); | 1806 | RightButton, LeftButton + RightButton ) ); |
1802 | // Left released, off-widget | 1807 | // Left released, off-widget |
1803 | postEvent( d->presswidget, | 1808 | postEvent( d->presswidget, |
1804 | new QMouseEvent( QEvent::MouseMove, QPoint( -1, -1), | 1809 | new QMouseEvent( QEvent::MouseMove, QPoint( -1, -1), |
1805 | LeftButton, LeftButton ) ); | 1810 | LeftButton, LeftButton ) ); |
1806 | postEvent( d->presswidget, | 1811 | postEvent( d->presswidget, |
1807 | new QMouseEvent( QEvent::MouseButtonRelease, QPoint( -1, -1), | 1812 | new QMouseEvent( QEvent::MouseButtonRelease, QPoint( -1, -1), |
1808 | LeftButton, LeftButton ) ); | 1813 | LeftButton, LeftButton ) ); |
1809 | d->rightpressed = FALSE; | 1814 | d->rightpressed = FALSE; |
1810 | return TRUE; // don't send the real Left release | 1815 | return TRUE; // don't send the real Left release |
1811 | } | 1816 | } |
1812 | } | 1817 | } |
1813 | break; | 1818 | break; |
1814 | default: | 1819 | default: |
1815 | break; | 1820 | break; |
1816 | } | 1821 | } |
1817 | break; | 1822 | break; |
1818 | default: | 1823 | default: |
1819 | ; | 1824 | ; |
1820 | } | 1825 | } |
1821 | } | 1826 | } |
1822 | else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { | 1827 | else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { |
1823 | QKeyEvent *ke = (QKeyEvent *)e; | 1828 | QKeyEvent *ke = (QKeyEvent *)e; |
1824 | if ( ke->key() == Key_Enter ) { | 1829 | if ( ke->key() == Key_Enter ) { |
1825 | if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) { | 1830 | if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) { |
1826 | postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ', | 1831 | postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ', |
1827 | ke->state(), " ", ke->isAutoRepeat(), ke->count() ) ); | 1832 | ke->state(), " ", ke->isAutoRepeat(), ke->count() ) ); |
1828 | return TRUE; | 1833 | return TRUE; |
1829 | } | 1834 | } |
1830 | } | 1835 | } |
1831 | } | 1836 | } |
1832 | return FALSE; | 1837 | return FALSE; |
1833 | } | 1838 | } |
1834 | 1839 | ||
1835 | /*! | 1840 | /*! |
1836 | \reimp | 1841 | \reimp |
1837 | */ | 1842 | */ |
1838 | void QPEApplication::timerEvent( QTimerEvent *e ) | 1843 | void QPEApplication::timerEvent( QTimerEvent *e ) |
1839 | { | 1844 | { |
1840 | if ( e->timerId() == d->presstimer && d->presswidget ) { | 1845 | if ( e->timerId() == d->presstimer && d->presswidget ) { |
1841 | // Right pressed | 1846 | // Right pressed |
1842 | postEvent( d->presswidget, | 1847 | postEvent( d->presswidget, |
1843 | new QMouseEvent( QEvent::MouseButtonPress, d->presspos, | 1848 | new QMouseEvent( QEvent::MouseButtonPress, d->presspos, |
1844 | RightButton, LeftButton ) ); | 1849 | RightButton, LeftButton ) ); |
1845 | killTimer( d->presstimer ); | 1850 | killTimer( d->presstimer ); |
1846 | d->presstimer = 0; | 1851 | d->presstimer = 0; |
1847 | d->rightpressed = TRUE; | 1852 | d->rightpressed = TRUE; |
1848 | } | 1853 | } |
1849 | } | 1854 | } |
1850 | 1855 | ||
1851 | void QPEApplication::removeSenderFromStylusDict() | 1856 | void QPEApplication::removeSenderFromStylusDict() |
1852 | { | 1857 | { |
1853 | stylusDict->remove | 1858 | stylusDict->remove |
1854 | ( ( void* ) sender() ); | 1859 | ( ( void* ) sender() ); |
1855 | if ( d->presswidget == sender() ) | 1860 | if ( d->presswidget == sender() ) |
1856 | d->presswidget = 0; | 1861 | d->presswidget = 0; |
1857 | } | 1862 | } |
1858 | 1863 | ||
1859 | /*! | 1864 | /*! |
1860 | \internal | 1865 | \internal |
1861 | */ | 1866 | */ |
1862 | bool QPEApplication::keyboardGrabbed() const | 1867 | bool QPEApplication::keyboardGrabbed() const |
1863 | { | 1868 | { |
1864 | return d->kbgrabbed; | 1869 | return d->kbgrabbed; |
1865 | } | 1870 | } |
1866 | 1871 | ||
1867 | 1872 | ||
1868 | /*! | 1873 | /*! |
1869 | Reverses the effect of grabKeyboard(). This is called automatically | 1874 | Reverses the effect of grabKeyboard(). This is called automatically |
1870 | on program exit. | 1875 | on program exit. |
1871 | */ | 1876 | */ |
1872 | void QPEApplication::ungrabKeyboard() | 1877 | void QPEApplication::ungrabKeyboard() |
1873 | { | 1878 | { |
1874 | ((QPEApplication *) qApp )-> d-> kbgrabbed = false; | 1879 | ((QPEApplication *) qApp )-> d-> kbgrabbed = false; |
1875 | } | 1880 | } |
1876 | 1881 | ||
1877 | /*! | 1882 | /*! |
1878 | Grabs the physical keyboard keys, e.g. the application's launching | 1883 | Grabs the physical keyboard keys, e.g. the application's launching |
1879 | keys. Instead of launching applications when these keys are pressed | 1884 | keys. Instead of launching applications when these keys are pressed |
1880 | the signals emitted are sent to this application instead. Some games | 1885 | the signals emitted are sent to this application instead. Some games |
1881 | programs take over the launch keys in this way to make interaction | 1886 | programs take over the launch keys in this way to make interaction |
1882 | easier. | 1887 | easier. |
1883 | 1888 | ||
1884 | \sa ungrabKeyboard() | 1889 | \sa ungrabKeyboard() |
1885 | */ | 1890 | */ |
1886 | void QPEApplication::grabKeyboard() | 1891 | void QPEApplication::grabKeyboard() |
1887 | { | 1892 | { |
1888 | ((QPEApplication *) qApp )-> d-> kbgrabbed = true; | 1893 | ((QPEApplication *) qApp )-> d-> kbgrabbed = true; |
1889 | } | 1894 | } |
1890 | 1895 | ||
1891 | /*! | 1896 | /*! |
1892 | \reimp | 1897 | \reimp |
1893 | */ | 1898 | */ |
1894 | int QPEApplication::exec() | 1899 | int QPEApplication::exec() |
1895 | { | 1900 | { |
1901 | d->qcopQok = true; | ||
1896 | #ifndef QT_NO_COP | 1902 | #ifndef QT_NO_COP |
1897 | d->sendQCopQ(); | 1903 | d->sendQCopQ(); |
1898 | #endif | 1904 | #endif |
1899 | 1905 | ||
1900 | if ( d->keep_running ) | 1906 | if ( d->keep_running ) |
1901 | //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() ) | 1907 | //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() ) |
1902 | return QApplication::exec(); | 1908 | return QApplication::exec(); |
1903 | 1909 | ||
1904 | #ifndef QT_NO_COP | 1910 | #ifndef QT_NO_COP |
1905 | 1911 | ||
1906 | { | 1912 | { |
1907 | QCopEnvelope e( "QPE/System", "closing(QString)" ); | 1913 | QCopEnvelope e( "QPE/System", "closing(QString)" ); |
1908 | e << d->appName; | 1914 | e << d->appName; |
1909 | } | 1915 | } |
1910 | #endif | 1916 | #endif |
1911 | processEvents(); | 1917 | processEvents(); |
1912 | return 0; | 1918 | return 0; |
1913 | } | 1919 | } |
1914 | 1920 | ||
1915 | /*! | 1921 | /*! |
1916 | \internal | 1922 | \internal |
1917 | External request for application to quit. Quits if possible without | 1923 | External request for application to quit. Quits if possible without |
1918 | loosing state. | 1924 | loosing state. |
1919 | */ | 1925 | */ |
1920 | void QPEApplication::tryQuit() | 1926 | void QPEApplication::tryQuit() |
1921 | { | 1927 | { |
1922 | if ( activeModalWidget() || strcmp( argv() [ 0 ], "embeddedkonsole" ) == 0 ) | 1928 | if ( activeModalWidget() || strcmp( argv() [ 0 ], "embeddedkonsole" ) == 0 ) |
1923 | return ; // Inside modal loop or konsole. Too hard to save state. | 1929 | return ; // Inside modal loop or konsole. Too hard to save state. |
1924 | #ifndef QT_NO_COP | 1930 | #ifndef QT_NO_COP |
1925 | 1931 | ||
1926 | { | 1932 | { |
1927 | QCopEnvelope e( "QPE/System", "closing(QString)" ); | 1933 | QCopEnvelope e( "QPE/System", "closing(QString)" ); |
1928 | e << d->appName; | 1934 | e << d->appName; |
1929 | } | 1935 | } |
1930 | #endif | 1936 | #endif |
1931 | processEvents(); | 1937 | processEvents(); |
1932 | 1938 | ||
1933 | quit(); | 1939 | quit(); |
1934 | } | 1940 | } |
1935 | 1941 | ||
1936 | /*! | 1942 | /*! |
1937 | \internal | 1943 | \internal |
1938 | */ | 1944 | */ |
1939 | void QPEApplication::installTranslation( const QString& baseName ) { | 1945 | void QPEApplication::installTranslation( const QString& baseName ) { |
1940 | QTranslator* trans = new QTranslator(this); | 1946 | QTranslator* trans = new QTranslator(this); |
1941 | QString tfn = qpeDir() + "/i18n/"+baseName; | 1947 | QString tfn = qpeDir() + "/i18n/"+baseName; |
1942 | if ( trans->load( tfn ) ) | 1948 | if ( trans->load( tfn ) ) |
1943 | installTranslator( trans ); | 1949 | installTranslator( trans ); |
1944 | else | 1950 | else |
1945 | delete trans; | 1951 | delete trans; |
1946 | } | 1952 | } |
1947 | 1953 | ||
1948 | /*! | 1954 | /*! |
1949 | \internal | 1955 | \internal |
1950 | User initiated quit. Makes the window 'Go Away'. If preloaded this means | 1956 | User initiated quit. Makes the window 'Go Away'. If preloaded this means |
1951 | hiding the window. If not it means quitting the application. | 1957 | hiding the window. If not it means quitting the application. |
1952 | As this is user initiated we don't need to check state. | 1958 | As this is user initiated we don't need to check state. |
1953 | */ | 1959 | */ |
1954 | void QPEApplication::hideOrQuit() | 1960 | void QPEApplication::hideOrQuit() |
1955 | { | 1961 | { |
1956 | processEvents(); | 1962 | processEvents(); |
1957 | 1963 | ||
1958 | // If we are a preloaded application we don't actually quit, so emit | 1964 | // If we are a preloaded application we don't actually quit, so emit |
1959 | // a System message indicating we're quasi-closing. | 1965 | // a System message indicating we're quasi-closing. |
1960 | if ( d->preloaded && d->qpe_main_widget ) | 1966 | if ( d->preloaded && d->qpe_main_widget ) |
1961 | #ifndef QT_NO_COP | 1967 | #ifndef QT_NO_COP |
1962 | 1968 | ||
1963 | { | 1969 | { |
1964 | QCopEnvelope e("QPE/System", "fastAppHiding(QString)" ); | 1970 | QCopEnvelope e("QPE/System", "fastAppHiding(QString)" ); |
1965 | e << d->appName; | 1971 | e << d->appName; |
1966 | d->qpe_main_widget->hide(); | 1972 | d->qpe_main_widget->hide(); |
1967 | } | 1973 | } |
1968 | #endif | 1974 | #endif |
1969 | else | 1975 | else |
1970 | quit(); | 1976 | quit(); |
1971 | } | 1977 | } |
1972 | 1978 | ||
1973 | #if (__GNUC__ > 2 ) | 1979 | #if (__GNUC__ > 2 ) |
1974 | extern "C" void __cxa_pure_virtual(); | 1980 | extern "C" void __cxa_pure_virtual(); |
1975 | 1981 | ||
1976 | void __cxa_pure_virtual() | 1982 | void __cxa_pure_virtual() |
1977 | { | 1983 | { |
1978 | fprintf( stderr, "Pure virtual called\n"); | 1984 | fprintf( stderr, "Pure virtual called\n"); |
1979 | abort(); | 1985 | abort(); |
1980 | 1986 | ||
1981 | } | 1987 | } |
1982 | 1988 | ||
1983 | #endif | 1989 | #endif |
1984 | 1990 | ||
1985 | 1991 | ||
1986 | #if defined(QT_QWS_IPAQ) || defined(QT_QWS_SL5XXX) || defined(QT_QWS_RAMSES) | 1992 | #if defined(QT_QWS_IPAQ) || defined(QT_QWS_SL5XXX) || defined(QT_QWS_RAMSES) |
1987 | 1993 | ||
1988 | // The libraries with the skiff package (and possibly others) have | 1994 | // The libraries with the skiff package (and possibly others) have |
1989 | // completely useless implementations of builtin new and delete that | 1995 | // completely useless implementations of builtin new and delete that |
1990 | // use about 50% of your CPU. Here we revert to the simple libc | 1996 | // use about 50% of your CPU. Here we revert to the simple libc |
1991 | // functions. | 1997 | // functions. |
1992 | 1998 | ||
1993 | void* operator new[]( size_t size ) | 1999 | void* operator new[]( size_t size ) |
1994 | { | 2000 | { |
1995 | return malloc( size ); | 2001 | return malloc( size ); |
1996 | } | 2002 | } |
1997 | 2003 | ||
1998 | void* operator new( size_t size ) | 2004 | void* operator new( size_t size ) |
1999 | { | 2005 | { |
2000 | return malloc( size ); | 2006 | return malloc( size ); |
2001 | } | 2007 | } |
2002 | 2008 | ||
2003 | void operator delete[]( void* p ) | 2009 | void operator delete[]( void* p ) |
2004 | { | 2010 | { |
2005 | free( p ); | 2011 | free( p ); |
2006 | } | 2012 | } |
2007 | 2013 | ||
2008 | void operator delete[]( void* p, size_t /*size*/ ) | 2014 | void operator delete[]( void* p, size_t /*size*/ ) |
2009 | { | 2015 | { |
2010 | free( p ); | 2016 | free( p ); |
2011 | } | 2017 | } |
2012 | 2018 | ||
2013 | 2019 | ||
2014 | void operator delete( void* p ) | 2020 | void operator delete( void* p ) |
2015 | { | 2021 | { |
2016 | free( p ); | 2022 | free( p ); |
2017 | } | 2023 | } |
2018 | 2024 | ||
2019 | void operator delete( void* p, size_t /*size*/ ) | 2025 | void operator delete( void* p, size_t /*size*/ ) |
2020 | { | 2026 | { |
2021 | free( p ); | 2027 | free( p ); |
2022 | } | 2028 | } |
2023 | 2029 | ||
2024 | #endif | 2030 | #endif |
2025 | 2031 | ||
2026 | #if ( QT_VERSION <= 230 ) && !defined(SINGLE_APP) | 2032 | #if ( QT_VERSION <= 230 ) && !defined(SINGLE_APP) |
2027 | #include <qwidgetlist.h> | 2033 | #include <qwidgetlist.h> |
2028 | #ifdef QWS | 2034 | #ifdef QWS |
2029 | #include <qgfx_qws.h> | 2035 | #include <qgfx_qws.h> |
2030 | extern QRect qt_maxWindowRect; | 2036 | extern QRect qt_maxWindowRect; |
2031 | void qt_setMaxWindowRect(const QRect& r ) | 2037 | void qt_setMaxWindowRect(const QRect& r ) |
2032 | { | 2038 | { |
2033 | qt_maxWindowRect = qt_screen->mapFromDevice( r, | 2039 | qt_maxWindowRect = qt_screen->mapFromDevice( r, |
2034 | qt_screen->mapToDevice( QSize( qt_screen->width(), qt_screen->height() ) ) ); | 2040 | qt_screen->mapToDevice( QSize( qt_screen->width(), qt_screen->height() ) ) ); |
2035 | // Re-resize any maximized windows | 2041 | // Re-resize any maximized windows |
2036 | QWidgetList* l = QApplication::topLevelWidgets(); | 2042 | QWidgetList* l = QApplication::topLevelWidgets(); |
2037 | if ( l ) { | 2043 | if ( l ) { |
2038 | QWidget * w = l->first(); | 2044 | QWidget * w = l->first(); |
2039 | while ( w ) { | 2045 | while ( w ) { |
2040 | if ( w->isVisible() && w->isMaximized() ) { | 2046 | if ( w->isVisible() && w->isMaximized() ) { |
2041 | w->showMaximized(); | 2047 | w->showMaximized(); |
2042 | } | 2048 | } |
2043 | w = l->next(); | 2049 | w = l->next(); |
2044 | } | 2050 | } |
2045 | delete l; | 2051 | delete l; |
2046 | } | 2052 | } |
2047 | } | 2053 | } |
2048 | #endif | 2054 | #endif |
2049 | #endif | 2055 | #endif |