author | zecke <zecke> | 2002-09-25 18:15:58 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-09-25 18:15:58 (UTC) |
commit | c96507591791d48a6d6dad3de6c15739c84e1c93 (patch) (unidiff) | |
tree | f5476860497023dd6d9e1c82c61cc6bb3f61a6da /library/qpeapplication.cpp | |
parent | d44c455b86d6cccbc497e3e8d8aa399096eff7db (diff) | |
download | opie-c96507591791d48a6d6dad3de6c15739c84e1c93.zip opie-c96507591791d48a6d6dad3de6c15739c84e1c93.tar.gz opie-c96507591791d48a6d6dad3de6c15739c84e1c93.tar.bz2 |
ljps patch was/is correct
but for some reason TT is not using QFile
so I made it use getenv(HOME) instead
-rw-r--r-- | library/qpeapplication.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp index bdf67b9..533d7bd 100644 --- a/library/qpeapplication.cpp +++ b/library/qpeapplication.cpp | |||
@@ -1,1616 +1,1620 @@ | |||
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 | ** $Id$ | 19 | ** $Id$ |
20 | ** | 20 | ** |
21 | **********************************************************************/ | 21 | **********************************************************************/ |
22 | #define QTOPIA_INTERNAL_LANGLIST | 22 | #define QTOPIA_INTERNAL_LANGLIST |
23 | #include <stdlib.h> | 23 | #include <stdlib.h> |
24 | #include <unistd.h> | 24 | #include <unistd.h> |
25 | #include <qfile.h> | 25 | #include <qfile.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 "qpeapplication.h" | 52 | #include "qpeapplication.h" |
53 | #include "qpestyle.h" | 53 | #include "qpestyle.h" |
54 | #include "styleinterface.h" | 54 | #include "styleinterface.h" |
55 | #if QT_VERSION >= 300 | 55 | #if QT_VERSION >= 300 |
56 | #include <qstylefactory.h> | 56 | #include <qstylefactory.h> |
57 | #else | 57 | #else |
58 | #include <qplatinumstyle.h> | 58 | #include <qplatinumstyle.h> |
59 | #include <qwindowsstyle.h> | 59 | #include <qwindowsstyle.h> |
60 | #include <qmotifstyle.h> | 60 | #include <qmotifstyle.h> |
61 | #include <qmotifplusstyle.h> | 61 | #include <qmotifplusstyle.h> |
62 | #include "lightstyle.h" | 62 | #include "lightstyle.h" |
63 | 63 | ||
64 | #include <qpe/qlibrary.h> | 64 | #include <qpe/qlibrary.h> |
65 | #endif | 65 | #endif |
66 | #include "global.h" | 66 | #include "global.h" |
67 | #include "resource.h" | 67 | #include "resource.h" |
68 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) | 68 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) |
69 | #include "qutfcodec.h" | 69 | #include "qutfcodec.h" |
70 | #endif | 70 | #endif |
71 | #include "config.h" | 71 | #include "config.h" |
72 | #include "network.h" | 72 | #include "network.h" |
73 | #ifdef QWS | 73 | #ifdef QWS |
74 | #include "fontmanager.h" | 74 | #include "fontmanager.h" |
75 | #endif | 75 | #endif |
76 | 76 | ||
77 | #include "alarmserver.h" | 77 | #include "alarmserver.h" |
78 | #include "applnk.h" | 78 | #include "applnk.h" |
79 | #include "qpemenubar.h" | 79 | #include "qpemenubar.h" |
80 | #include "textcodecinterface.h" | 80 | #include "textcodecinterface.h" |
81 | #include "imagecodecinterface.h" | 81 | #include "imagecodecinterface.h" |
82 | 82 | ||
83 | #include <unistd.h> | 83 | #include <unistd.h> |
84 | #include <sys/file.h> | 84 | #include <sys/file.h> |
85 | #include <sys/ioctl.h> | 85 | #include <sys/ioctl.h> |
86 | #include <sys/soundcard.h> | 86 | #include <sys/soundcard.h> |
87 | 87 | ||
88 | 88 | ||
89 | class QPEApplicationData { | 89 | class QPEApplicationData { |
90 | public: | 90 | public: |
91 | QPEApplicationData() : presstimer( 0 ), presswidget( 0 ), rightpressed( FALSE ), | 91 | QPEApplicationData() : presstimer( 0 ), presswidget( 0 ), rightpressed( FALSE ), |
92 | kbgrabber( 0 ), kbregrab( FALSE ), notbusysent( FALSE ), preloaded( FALSE ), | 92 | kbgrabber( 0 ), kbregrab( FALSE ), notbusysent( FALSE ), preloaded( FALSE ), |
93 | forceshow( FALSE ), nomaximize( FALSE ), qpe_main_widget( 0 ), | 93 | forceshow( FALSE ), nomaximize( FALSE ), qpe_main_widget( 0 ), |
94 | keep_running( TRUE ) | 94 | keep_running( TRUE ) |
95 | { | 95 | { |
96 | qcopq.setAutoDelete( TRUE ); | 96 | qcopq.setAutoDelete( TRUE ); |
97 | } | 97 | } |
98 | 98 | ||
99 | int presstimer; | 99 | int presstimer; |
100 | QWidget* presswidget; | 100 | QWidget* presswidget; |
101 | QPoint presspos; | 101 | QPoint presspos; |
102 | bool rightpressed : 1; // AEH why not use uint foobar :1; if it's tt style -zecke | 102 | bool rightpressed : 1; // AEH why not use uint foobar :1; if it's tt style -zecke |
103 | int kbgrabber; | 103 | int kbgrabber; |
104 | bool kbregrab : 1; | 104 | bool kbregrab : 1; |
105 | bool notbusysent : 1; | 105 | bool notbusysent : 1; |
106 | QString appName; | 106 | QString appName; |
107 | struct QCopRec { | 107 | struct QCopRec { |
108 | QCopRec( const QCString &ch, const QCString &msg, | 108 | QCopRec( const QCString &ch, const QCString &msg, |
109 | const QByteArray &d ) : | 109 | const QByteArray &d ) : |
110 | channel( ch ), message( msg ), data( d ) { } | 110 | channel( ch ), message( msg ), data( d ) { } |
111 | 111 | ||
112 | QCString channel; | 112 | QCString channel; |
113 | QCString message; | 113 | QCString message; |
114 | QByteArray data; | 114 | QByteArray data; |
115 | }; | 115 | }; |
116 | bool preloaded : 1; | 116 | bool preloaded : 1; |
117 | bool forceshow : 1; | 117 | bool forceshow : 1; |
118 | bool nomaximize : 1; | 118 | bool nomaximize : 1; |
119 | QWidget* qpe_main_widget; | 119 | QWidget* qpe_main_widget; |
120 | bool keep_running : 1; | 120 | bool keep_running : 1; |
121 | QList<QCopRec> qcopq; | 121 | QList<QCopRec> qcopq; |
122 | 122 | ||
123 | void enqueueQCop( const QCString &ch, const QCString &msg, | 123 | void enqueueQCop( const QCString &ch, const QCString &msg, |
124 | const QByteArray &data ) | 124 | const QByteArray &data ) |
125 | { | 125 | { |
126 | qcopq.append( new QCopRec( ch, msg, data ) ); | 126 | qcopq.append( new QCopRec( ch, msg, data ) ); |
127 | } | 127 | } |
128 | void sendQCopQ() { | 128 | void sendQCopQ() { |
129 | QCopRec * r; | 129 | QCopRec * r; |
130 | #ifndef QT_NO_COP | 130 | #ifndef QT_NO_COP |
131 | for ( QListIterator<QCopRec> it( qcopq ); ( r = it.current() ); ++it ) | 131 | for ( QListIterator<QCopRec> it( qcopq ); ( r = it.current() ); ++it ) |
132 | QCopChannel::sendLocally( r->channel, r->message, r->data ); | 132 | QCopChannel::sendLocally( r->channel, r->message, r->data ); |
133 | #endif | 133 | #endif |
134 | qcopq.clear(); | 134 | qcopq.clear(); |
135 | } | 135 | } |
136 | static void show_mx(QWidget* mw, bool nomaximize) { | 136 | static void show_mx(QWidget* mw, bool nomaximize) { |
137 | if ( mw->layout() && mw->inherits("QDialog") ) { | 137 | if ( mw->layout() && mw->inherits("QDialog") ) { |
138 | QPEApplication::showDialog((QDialog*)mw,nomaximize); | 138 | QPEApplication::showDialog((QDialog*)mw,nomaximize); |
139 | } else { | 139 | } else { |
140 | #ifdef Q_WS_QWS | 140 | #ifdef Q_WS_QWS |
141 | if ( !nomaximize ) | 141 | if ( !nomaximize ) |
142 | mw->showMaximized(); | 142 | mw->showMaximized(); |
143 | else | 143 | else |
144 | #endif | 144 | #endif |
145 | mw->show(); | 145 | mw->show(); |
146 | } | 146 | } |
147 | } | 147 | } |
148 | static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) | 148 | static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) |
149 | { | 149 | { |
150 | /* | 150 | /* |
151 | // This works but disable it for now until it is safe to apply | 151 | // This works but disable it for now until it is safe to apply |
152 | // What is does is scan the .desktop files of all the apps for | 152 | // What is does is scan the .desktop files of all the apps for |
153 | // the applnk that has the corresponding argv[0] as this program | 153 | // the applnk that has the corresponding argv[0] as this program |
154 | // then it uses the name stored in the .desktop file as the caption | 154 | // then it uses the name stored in the .desktop file as the caption |
155 | // for the main widget. This saves duplicating translations for | 155 | // for the main widget. This saves duplicating translations for |
156 | // the app name in the program and in the .desktop files. | 156 | // the app name in the program and in the .desktop files. |
157 | 157 | ||
158 | AppLnkSet apps( appsPath ); | 158 | AppLnkSet apps( appsPath ); |
159 | 159 | ||
160 | QList<AppLnk> appsList = apps.children(); | 160 | QList<AppLnk> appsList = apps.children(); |
161 | for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) { | 161 | for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) { |
162 | if ( (*it)->exec() == appName ) { | 162 | if ( (*it)->exec() == appName ) { |
163 | mw->setCaption( (*it)->name() ); | 163 | mw->setCaption( (*it)->name() ); |
164 | return TRUE; | 164 | return TRUE; |
165 | } | 165 | } |
166 | } | 166 | } |
167 | */ | 167 | */ |
168 | return FALSE; | 168 | return FALSE; |
169 | } | 169 | } |
170 | 170 | ||
171 | 171 | ||
172 | void show(QWidget* mw, bool nomax) | 172 | void show(QWidget* mw, bool nomax) |
173 | { | 173 | { |
174 | setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" ); | 174 | setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" ); |
175 | nomaximize = nomax; | 175 | nomaximize = nomax; |
176 | qpe_main_widget = mw; | 176 | qpe_main_widget = mw; |
177 | #ifndef QT_NO_COP | 177 | #ifndef QT_NO_COP |
178 | sendQCopQ(); | 178 | sendQCopQ(); |
179 | #endif | 179 | #endif |
180 | if ( preloaded ) { | 180 | if ( preloaded ) { |
181 | if(forceshow) | 181 | if(forceshow) |
182 | show_mx(mw,nomax); | 182 | show_mx(mw,nomax); |
183 | } else if ( keep_running ) { | 183 | } else if ( keep_running ) { |
184 | show_mx(mw,nomax); | 184 | show_mx(mw,nomax); |
185 | } | 185 | } |
186 | } | 186 | } |
187 | 187 | ||
188 | void loadTextCodecs() | 188 | void loadTextCodecs() |
189 | { | 189 | { |
190 | QString path = QPEApplication::qpeDir() + "/plugins/textcodecs"; | 190 | QString path = QPEApplication::qpeDir() + "/plugins/textcodecs"; |
191 | QDir dir( path, "lib*.so" ); | 191 | QDir dir( path, "lib*.so" ); |
192 | QStringList list = dir.entryList(); | 192 | QStringList list = dir.entryList(); |
193 | QStringList::Iterator it; | 193 | QStringList::Iterator it; |
194 | for ( it = list.begin(); it != list.end(); ++it ) { | 194 | for ( it = list.begin(); it != list.end(); ++it ) { |
195 | TextCodecInterface *iface = 0; | 195 | TextCodecInterface *iface = 0; |
196 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 196 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
197 | if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { | 197 | if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { |
198 | QValueList<int> mibs = iface->mibEnums(); | 198 | QValueList<int> mibs = iface->mibEnums(); |
199 | for (QValueList<int>::ConstIterator i=mibs.begin(); i!=mibs.end(); ++i) { | 199 | for (QValueList<int>::ConstIterator i=mibs.begin(); i!=mibs.end(); ++i) { |
200 | (void)iface->createForMib(*i); | 200 | (void)iface->createForMib(*i); |
201 | // ### it exists now; need to remember if we can delete it | 201 | // ### it exists now; need to remember if we can delete it |
202 | } | 202 | } |
203 | } else { | 203 | } else { |
204 | lib->unload(); | 204 | lib->unload(); |
205 | delete lib; | 205 | delete lib; |
206 | } | 206 | } |
207 | } | 207 | } |
208 | } | 208 | } |
209 | 209 | ||
210 | void loadImageCodecs() | 210 | void loadImageCodecs() |
211 | { | 211 | { |
212 | QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs"; | 212 | QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs"; |
213 | QDir dir( path, "lib*.so" ); | 213 | QDir dir( path, "lib*.so" ); |
214 | QStringList list = dir.entryList(); | 214 | QStringList list = dir.entryList(); |
215 | QStringList::Iterator it; | 215 | QStringList::Iterator it; |
216 | for ( it = list.begin(); it != list.end(); ++it ) { | 216 | for ( it = list.begin(); it != list.end(); ++it ) { |
217 | ImageCodecInterface *iface = 0; | 217 | ImageCodecInterface *iface = 0; |
218 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 218 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
219 | if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { | 219 | if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { |
220 | QStringList formats = iface->keys(); | 220 | QStringList formats = iface->keys(); |
221 | for (QStringList::ConstIterator i=formats.begin(); i!=formats.end(); ++i) { | 221 | for (QStringList::ConstIterator i=formats.begin(); i!=formats.end(); ++i) { |
222 | (void)iface->installIOHandler(*i); | 222 | (void)iface->installIOHandler(*i); |
223 | // ### it exists now; need to remember if we can delete it | 223 | // ### it exists now; need to remember if we can delete it |
224 | } | 224 | } |
225 | } else { | 225 | } else { |
226 | lib->unload(); | 226 | lib->unload(); |
227 | delete lib; | 227 | delete lib; |
228 | } | 228 | } |
229 | } | 229 | } |
230 | } | 230 | } |
231 | QString styleName; | 231 | QString styleName; |
232 | QString decorationName; | 232 | QString decorationName; |
233 | }; | 233 | }; |
234 | 234 | ||
235 | class ResourceMimeFactory : public QMimeSourceFactory { | 235 | class ResourceMimeFactory : public QMimeSourceFactory { |
236 | public: | 236 | public: |
237 | ResourceMimeFactory() | 237 | ResourceMimeFactory() |
238 | { | 238 | { |
239 | setFilePath( Global::helpPath() ); | 239 | setFilePath( Global::helpPath() ); |
240 | setExtensionType( "html", "text/html;charset=UTF-8" ); | 240 | setExtensionType( "html", "text/html;charset=UTF-8" ); |
241 | } | 241 | } |
242 | 242 | ||
243 | const QMimeSource* data( const QString& abs_name ) const | 243 | const QMimeSource* data( const QString& abs_name ) const |
244 | { | 244 | { |
245 | const QMimeSource * r = QMimeSourceFactory::data( abs_name ); | 245 | const QMimeSource * r = QMimeSourceFactory::data( abs_name ); |
246 | if ( !r ) { | 246 | if ( !r ) { |
247 | int sl = abs_name.length(); | 247 | int sl = abs_name.length(); |
248 | do { | 248 | do { |
249 | sl = abs_name.findRev( '/', sl - 1 ); | 249 | sl = abs_name.findRev( '/', sl - 1 ); |
250 | QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name; | 250 | QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name; |
251 | int dot = name.findRev( '.' ); | 251 | int dot = name.findRev( '.' ); |
252 | if ( dot >= 0 ) | 252 | if ( dot >= 0 ) |
253 | name = name.left( dot ); | 253 | name = name.left( dot ); |
254 | QImage img = Resource::loadImage( name ); | 254 | QImage img = Resource::loadImage( name ); |
255 | if ( !img.isNull() ) | 255 | if ( !img.isNull() ) |
256 | r = new QImageDrag( img ); | 256 | r = new QImageDrag( img ); |
257 | } | 257 | } |
258 | while ( !r && sl > 0 ); | 258 | while ( !r && sl > 0 ); |
259 | } | 259 | } |
260 | return r; | 260 | return r; |
261 | } | 261 | } |
262 | }; | 262 | }; |
263 | 263 | ||
264 | static int muted = 0; | 264 | static int muted = 0; |
265 | static int micMuted = 0; | 265 | static int micMuted = 0; |
266 | 266 | ||
267 | static void setVolume( int t = 0, int percent = -1 ) | 267 | static void setVolume( int t = 0, int percent = -1 ) |
268 | { | 268 | { |
269 | switch ( t ) { | 269 | switch ( t ) { |
270 | case 0: { | 270 | case 0: { |
271 | Config cfg( "qpe" ); | 271 | Config cfg( "qpe" ); |
272 | cfg.setGroup( "Volume" ); | 272 | cfg.setGroup( "Volume" ); |
273 | if ( percent < 0 ) | 273 | if ( percent < 0 ) |
274 | percent = cfg.readNumEntry( "VolumePercent", 50 ); | 274 | percent = cfg.readNumEntry( "VolumePercent", 50 ); |
275 | int fd = 0; | 275 | int fd = 0; |
276 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 276 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
277 | int vol = muted ? 0 : percent; | 277 | int vol = muted ? 0 : percent; |
278 | // set both channels to same volume | 278 | // set both channels to same volume |
279 | vol |= vol << 8; | 279 | vol |= vol << 8; |
280 | ioctl( fd, MIXER_WRITE( 0 ), &vol ); | 280 | ioctl( fd, MIXER_WRITE( 0 ), &vol ); |
281 | ::close( fd ); | 281 | ::close( fd ); |
282 | } | 282 | } |
283 | } | 283 | } |
284 | break; | 284 | break; |
285 | } | 285 | } |
286 | } | 286 | } |
287 | 287 | ||
288 | static void setMic( int t = 0, int percent = -1 ) | 288 | static void setMic( int t = 0, int percent = -1 ) |
289 | { | 289 | { |
290 | switch ( t ) { | 290 | switch ( t ) { |
291 | case 0: { | 291 | case 0: { |
292 | Config cfg( "qpe" ); | 292 | Config cfg( "qpe" ); |
293 | cfg.setGroup( "Volume" ); | 293 | cfg.setGroup( "Volume" ); |
294 | if ( percent < 0 ) | 294 | if ( percent < 0 ) |
295 | percent = cfg.readNumEntry( "Mic", 50 ); | 295 | percent = cfg.readNumEntry( "Mic", 50 ); |
296 | 296 | ||
297 | int fd = 0; | 297 | int fd = 0; |
298 | int mic = micMuted ? 0 : percent; | 298 | int mic = micMuted ? 0 : percent; |
299 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 299 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
300 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_MIC ), &mic ); | 300 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_MIC ), &mic ); |
301 | ::close( fd ); | 301 | ::close( fd ); |
302 | } | 302 | } |
303 | } | 303 | } |
304 | break; | 304 | break; |
305 | } | 305 | } |
306 | } | 306 | } |
307 | 307 | ||
308 | 308 | ||
309 | /*! | 309 | /*! |
310 | \class QPEApplication qpeapplication.h | 310 | \class QPEApplication qpeapplication.h |
311 | \brief The QPEApplication class implements various system services | 311 | \brief The QPEApplication class implements various system services |
312 | that are available to all Qtopia applications. | 312 | that are available to all Qtopia applications. |
313 | 313 | ||
314 | Simply by using QPEApplication instead of QApplication, a standard Qt | 314 | Simply by using QPEApplication instead of QApplication, a standard Qt |
315 | application becomes a Qtopia application. It automatically follows | 315 | application becomes a Qtopia application. It automatically follows |
316 | style changes, quits and raises, and in the | 316 | style changes, quits and raises, and in the |
317 | case of \link docwidget.html document-oriented\endlink applications, | 317 | case of \link docwidget.html document-oriented\endlink applications, |
318 | changes the currently displayed document in response to the environment. | 318 | changes the currently displayed document in response to the environment. |
319 | 319 | ||
320 | To create a \link docwidget.html document-oriented\endlink | 320 | To create a \link docwidget.html document-oriented\endlink |
321 | application use showMainDocumentWidget(); to create a | 321 | application use showMainDocumentWidget(); to create a |
322 | non-document-oriented application use showMainWidget(). The | 322 | non-document-oriented application use showMainWidget(). The |
323 | keepRunning() function indicates whether the application will | 323 | keepRunning() function indicates whether the application will |
324 | continue running after it's processed the last \link qcop.html | 324 | continue running after it's processed the last \link qcop.html |
325 | QCop\endlink message. This can be changed using setKeepRunning(). | 325 | QCop\endlink message. This can be changed using setKeepRunning(). |
326 | 326 | ||
327 | A variety of signals are emitted when certain events occur, for | 327 | A variety of signals are emitted when certain events occur, for |
328 | example, timeChanged(), clockChanged(), weekChanged(), | 328 | example, timeChanged(), clockChanged(), weekChanged(), |
329 | dateFormatChanged() and volumeChanged(). If the application receives | 329 | dateFormatChanged() and volumeChanged(). If the application receives |
330 | a \link qcop.html QCop\endlink message on the application's | 330 | a \link qcop.html QCop\endlink message on the application's |
331 | QPE/Application/\e{appname} channel, the appMessage() signal is | 331 | QPE/Application/\e{appname} channel, the appMessage() signal is |
332 | emitted. There are also flush() and reload() signals, which | 332 | emitted. There are also flush() and reload() signals, which |
333 | are emitted when synching begins and ends respectively - upon these | 333 | are emitted when synching begins and ends respectively - upon these |
334 | signals, the application should save and reload any data | 334 | signals, the application should save and reload any data |
335 | files that are involved in synching. Most of these signals will initially | 335 | files that are involved in synching. Most of these signals will initially |
336 | be received and unfiltered through the appMessage() signal. | 336 | be received and unfiltered through the appMessage() signal. |
337 | 337 | ||
338 | This class also provides a set of useful static functions. The | 338 | This class also provides a set of useful static functions. The |
339 | qpeDir() and documentDir() functions return the respective paths. | 339 | qpeDir() and documentDir() functions return the respective paths. |
340 | The grabKeyboard() and ungrabKeyboard() functions are used to | 340 | The grabKeyboard() and ungrabKeyboard() functions are used to |
341 | control whether the application takes control of the device's | 341 | control whether the application takes control of the device's |
342 | physical buttons (e.g. application launch keys). The stylus' mode of | 342 | physical buttons (e.g. application launch keys). The stylus' mode of |
343 | operation is set with setStylusOperation() and retrieved with | 343 | operation is set with setStylusOperation() and retrieved with |
344 | stylusOperation(). There are also setInputMethodHint() and | 344 | stylusOperation(). There are also setInputMethodHint() and |
345 | inputMethodHint() functions. | 345 | inputMethodHint() functions. |
346 | 346 | ||
347 | \ingroup qtopiaemb | 347 | \ingroup qtopiaemb |
348 | */ | 348 | */ |
349 | 349 | ||
350 | /*! | 350 | /*! |
351 | \fn void QPEApplication::clientMoused() | 351 | \fn void QPEApplication::clientMoused() |
352 | 352 | ||
353 | \internal | 353 | \internal |
354 | */ | 354 | */ |
355 | 355 | ||
356 | /*! | 356 | /*! |
357 | \fn void QPEApplication::timeChanged(); | 357 | \fn void QPEApplication::timeChanged(); |
358 | This signal is emitted when the time changes outside the normal | 358 | This signal is emitted when the time changes outside the normal |
359 | passage of time, i.e. if the time is set backwards or forwards. | 359 | passage of time, i.e. if the time is set backwards or forwards. |
360 | */ | 360 | */ |
361 | 361 | ||
362 | /*! | 362 | /*! |
363 | \fn void QPEApplication::clockChanged( bool ampm ); | 363 | \fn void QPEApplication::clockChanged( bool ampm ); |
364 | 364 | ||
365 | This signal is emitted when the user changes the clock's style. If | 365 | This signal is emitted when the user changes the clock's style. If |
366 | \a ampm is TRUE, the user wants a 12-hour AM/PM clock, otherwise, | 366 | \a ampm is TRUE, the user wants a 12-hour AM/PM clock, otherwise, |
367 | they want a 24-hour clock. | 367 | they want a 24-hour clock. |
368 | */ | 368 | */ |
369 | 369 | ||
370 | /*! | 370 | /*! |
371 | \fn void QPEApplication::volumeChanged( bool muted ) | 371 | \fn void QPEApplication::volumeChanged( bool muted ) |
372 | 372 | ||
373 | This signal is emitted whenever the mute state is changed. If \a | 373 | This signal is emitted whenever the mute state is changed. If \a |
374 | muted is TRUE, then sound output has been muted. | 374 | muted is TRUE, then sound output has been muted. |
375 | */ | 375 | */ |
376 | 376 | ||
377 | /*! | 377 | /*! |
378 | \fn void QPEApplication::weekChanged( bool startOnMonday ) | 378 | \fn void QPEApplication::weekChanged( bool startOnMonday ) |
379 | 379 | ||
380 | This signal is emitted if the week start day is changed. If \a | 380 | This signal is emitted if the week start day is changed. If \a |
381 | startOnMonday is TRUE then the first day of the week is Monday; if | 381 | startOnMonday is TRUE then the first day of the week is Monday; if |
382 | \a startOnMonday is FALSE then the first day of the week is | 382 | \a startOnMonday is FALSE then the first day of the week is |
383 | Sunday. | 383 | Sunday. |
384 | */ | 384 | */ |
385 | 385 | ||
386 | /*! | 386 | /*! |
387 | \fn void QPEApplication::dateFormatChanged() | 387 | \fn void QPEApplication::dateFormatChanged() |
388 | 388 | ||
389 | This signal is emitted whenever the date format is changed. | 389 | This signal is emitted whenever the date format is changed. |
390 | */ | 390 | */ |
391 | 391 | ||
392 | /*! | 392 | /*! |
393 | \fn void QPEApplication::flush() | 393 | \fn void QPEApplication::flush() |
394 | 394 | ||
395 | ### | 395 | ### |
396 | */ | 396 | */ |
397 | 397 | ||
398 | /*! | 398 | /*! |
399 | \fn void QPEApplication::reload() | 399 | \fn void QPEApplication::reload() |
400 | 400 | ||
401 | */ | 401 | */ |
402 | 402 | ||
403 | /*! | 403 | /*! |
404 | \fn void QPEApplication::appMessage( const QCString& msg, const QByteArray& data ) | 404 | \fn void QPEApplication::appMessage( const QCString& msg, const QByteArray& data ) |
405 | 405 | ||
406 | This signal is emitted when a message is received on this | 406 | This signal is emitted when a message is received on this |
407 | application's QPE/Application/<i>appname</i> \link qcop.html | 407 | application's QPE/Application/<i>appname</i> \link qcop.html |
408 | QCop\endlink channel. | 408 | QCop\endlink channel. |
409 | 409 | ||
410 | The slot to which you connect this signal uses \a msg and \a data | 410 | The slot to which you connect this signal uses \a msg and \a data |
411 | in the following way: | 411 | in the following way: |
412 | 412 | ||
413 | \code | 413 | \code |
414 | void MyWidget::receive( const QCString& msg, const QByteArray& data ) | 414 | void MyWidget::receive( const QCString& msg, const QByteArray& data ) |
415 | { | 415 | { |
416 | QDataStream stream( data, IO_ReadOnly ); | 416 | QDataStream stream( data, IO_ReadOnly ); |
417 | if ( msg == "someMessage(int,int,int)" ) { | 417 | if ( msg == "someMessage(int,int,int)" ) { |
418 | int a,b,c; | 418 | int a,b,c; |
419 | stream >> a >> b >> c; | 419 | stream >> a >> b >> c; |
420 | ... | 420 | ... |
421 | } else if ( msg == "otherMessage(QString)" ) { | 421 | } else if ( msg == "otherMessage(QString)" ) { |
422 | ... | 422 | ... |
423 | } | 423 | } |
424 | } | 424 | } |
425 | \endcode | 425 | \endcode |
426 | 426 | ||
427 | \sa qcop.html | 427 | \sa qcop.html |
428 | Note that messages received here may be processed by qpe application | 428 | Note that messages received here may be processed by qpe application |
429 | and emitted as signals, such as flush() and reload(). | 429 | and emitted as signals, such as flush() and reload(). |
430 | */ | 430 | */ |
431 | 431 | ||
432 | /*! | 432 | /*! |
433 | Constructs a QPEApplication just as you would construct | 433 | Constructs a QPEApplication just as you would construct |
434 | a QApplication, passing \a argc, \a argv, and \a t. | 434 | a QApplication, passing \a argc, \a argv, and \a t. |
435 | 435 | ||
436 | For applications, \a t should be the default, GuiClient. Only | 436 | For applications, \a t should be the default, GuiClient. Only |
437 | the Qtopia server passes GuiServer. | 437 | the Qtopia server passes GuiServer. |
438 | */ | 438 | */ |
439 | QPEApplication::QPEApplication( int & argc, char **argv, Type t ) | 439 | QPEApplication::QPEApplication( int & argc, char **argv, Type t ) |
440 | : QApplication( argc, argv, t ) | 440 | : QApplication( argc, argv, t ) |
441 | { | 441 | { |
442 | d = new QPEApplicationData; | 442 | d = new QPEApplicationData; |
443 | d->loadTextCodecs(); | 443 | d->loadTextCodecs(); |
444 | d->loadImageCodecs(); | 444 | d->loadImageCodecs(); |
445 | int dw = desktop() ->width(); | 445 | int dw = desktop() ->width(); |
446 | qWarning( "Width %d", dw ); | 446 | qWarning( "Width %d", dw ); |
447 | if ( dw < 200 ) { | 447 | if ( dw < 200 ) { |
448 | setFont( QFont( "helvetica", 8 ) ); | 448 | setFont( QFont( "helvetica", 8 ) ); |
449 | AppLnk::setSmallIconSize( 10 ); | 449 | AppLnk::setSmallIconSize( 10 ); |
450 | AppLnk::setBigIconSize( 28 ); | 450 | AppLnk::setBigIconSize( 28 ); |
451 | }else if ( dw > 600 ) { | 451 | }else if ( dw > 600 ) { |
452 | setFont( QFont( "helvetica", 12 ) ); | 452 | setFont( QFont( "helvetica", 12 ) ); |
453 | AppLnk::setSmallIconSize( 24 ); | 453 | AppLnk::setSmallIconSize( 24 ); |
454 | AppLnk::setBigIconSize( 48 ); | 454 | AppLnk::setBigIconSize( 48 ); |
455 | }else if ( dw > 200 ) { | 455 | }else if ( dw > 200 ) { |
456 | setFont( QFont( "helvetica", 12 ) ); | 456 | setFont( QFont( "helvetica", 12 ) ); |
457 | AppLnk::setSmallIconSize( 16 ); | 457 | AppLnk::setSmallIconSize( 16 ); |
458 | AppLnk::setBigIconSize( 32 ); | 458 | AppLnk::setBigIconSize( 32 ); |
459 | } | 459 | } |
460 | 460 | ||
461 | 461 | ||
462 | QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory ); | 462 | QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory ); |
463 | 463 | ||
464 | connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) ); | 464 | connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) ); |
465 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 465 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
466 | 466 | ||
467 | QString qcopfn( "/tmp/qcop-msg-" ); | 467 | QString qcopfn( "/tmp/qcop-msg-" ); |
468 | qcopfn += QString( argv[ 0 ] ); // append command name | 468 | qcopfn += QString( argv[ 0 ] ); // append command name |
469 | 469 | ||
470 | QFile f( qcopfn ); | 470 | QFile f( qcopfn ); |
471 | if ( f.open( IO_ReadOnly ) ) { | 471 | if ( f.open( IO_ReadOnly ) ) { |
472 | flock( f.handle(), LOCK_EX ); | 472 | flock( f.handle(), LOCK_EX ); |
473 | } | 473 | } |
474 | 474 | ||
475 | sysChannel = new QCopChannel( "QPE/System", this ); | 475 | sysChannel = new QCopChannel( "QPE/System", this ); |
476 | connect( sysChannel, SIGNAL( received( const QCString &, const QByteArray & ) ), | 476 | connect( sysChannel, SIGNAL( received( const QCString &, const QByteArray & ) ), |
477 | this, SLOT( systemMessage( const QCString &, const QByteArray & ) ) ); | 477 | this, SLOT( systemMessage( const QCString &, const QByteArray & ) ) ); |
478 | 478 | ||
479 | QCString channel = QCString( argv[ 0 ] ); | 479 | QCString channel = QCString( argv[ 0 ] ); |
480 | channel.replace( QRegExp( ".*/" ), "" ); | 480 | channel.replace( QRegExp( ".*/" ), "" ); |
481 | d->appName = channel; | 481 | d->appName = channel; |
482 | channel = "QPE/Application/" + channel; | 482 | channel = "QPE/Application/" + channel; |
483 | pidChannel = new QCopChannel( channel, this ); | 483 | pidChannel = new QCopChannel( channel, this ); |
484 | connect( pidChannel, SIGNAL( received( const QCString &, const QByteArray & ) ), | 484 | connect( pidChannel, SIGNAL( received( const QCString &, const QByteArray & ) ), |
485 | this, SLOT( pidMessage( const QCString &, const QByteArray & ) ) ); | 485 | this, SLOT( pidMessage( const QCString &, const QByteArray & ) ) ); |
486 | 486 | ||
487 | if ( f.isOpen() ) { | 487 | if ( f.isOpen() ) { |
488 | d->keep_running = FALSE; | 488 | d->keep_running = FALSE; |
489 | QDataStream ds( &f ); | 489 | QDataStream ds( &f ); |
490 | QCString channel, message; | 490 | QCString channel, message; |
491 | QByteArray data; | 491 | QByteArray data; |
492 | while ( !ds.atEnd() ) { | 492 | while ( !ds.atEnd() ) { |
493 | ds >> channel >> message >> data; | 493 | ds >> channel >> message >> data; |
494 | d->enqueueQCop( channel, message, data ); | 494 | d->enqueueQCop( channel, message, data ); |
495 | } | 495 | } |
496 | 496 | ||
497 | flock( f.handle(), LOCK_UN ); | 497 | flock( f.handle(), LOCK_UN ); |
498 | f.close(); | 498 | f.close(); |
499 | f.remove(); | 499 | f.remove(); |
500 | } | 500 | } |
501 | 501 | ||
502 | for ( int a = 0; a < argc; a++ ) { | 502 | for ( int a = 0; a < argc; a++ ) { |
503 | if ( qstrcmp( argv[ a ], "-preload" ) == 0 ) { | 503 | if ( qstrcmp( argv[ a ], "-preload" ) == 0 ) { |
504 | argv[ a ] = argv[ a + 1 ]; | 504 | argv[ a ] = argv[ a + 1 ]; |
505 | a++; | 505 | a++; |
506 | d->preloaded = TRUE; | 506 | d->preloaded = TRUE; |
507 | argc -= 1; | 507 | argc -= 1; |
508 | } | 508 | } |
509 | else if ( qstrcmp( argv[ a ], "-preload-show" ) == 0 ) { | 509 | else if ( qstrcmp( argv[ a ], "-preload-show" ) == 0 ) { |
510 | argv[ a ] = argv[ a + 1 ]; | 510 | argv[ a ] = argv[ a + 1 ]; |
511 | a++; | 511 | a++; |
512 | d->preloaded = TRUE; | 512 | d->preloaded = TRUE; |
513 | d->forceshow = TRUE; | 513 | d->forceshow = TRUE; |
514 | argc -= 1; | 514 | argc -= 1; |
515 | } | 515 | } |
516 | } | 516 | } |
517 | 517 | ||
518 | /* overide stored arguments */ | 518 | /* overide stored arguments */ |
519 | setArgs( argc, argv ); | 519 | setArgs( argc, argv ); |
520 | 520 | ||
521 | #endif | 521 | #endif |
522 | 522 | ||
523 | // qwsSetDecoration( new QPEDecoration() ); | 523 | // qwsSetDecoration( new QPEDecoration() ); |
524 | 524 | ||
525 | #ifndef QT_NO_TRANSLATION | 525 | #ifndef QT_NO_TRANSLATION |
526 | 526 | ||
527 | QStringList langs = Global::languageList(); | 527 | QStringList langs = Global::languageList(); |
528 | for ( QStringList::ConstIterator it = langs.begin(); it != langs.end(); ++it ) { | 528 | for ( QStringList::ConstIterator it = langs.begin(); it != langs.end(); ++it ) { |
529 | QString lang = *it; | 529 | QString lang = *it; |
530 | 530 | ||
531 | QTranslator * trans; | 531 | QTranslator * trans; |
532 | QString tfn; | 532 | QString tfn; |
533 | 533 | ||
534 | trans = new QTranslator( this ); | 534 | trans = new QTranslator( this ); |
535 | tfn = qpeDir() + "/i18n/" + lang + "/libqpe.qm"; | 535 | tfn = qpeDir() + "/i18n/" + lang + "/libqpe.qm"; |
536 | if ( trans->load( tfn ) ) | 536 | if ( trans->load( tfn ) ) |
537 | installTranslator( trans ); | 537 | installTranslator( trans ); |
538 | else | 538 | else |
539 | delete trans; | 539 | delete trans; |
540 | 540 | ||
541 | trans = new QTranslator( this ); | 541 | trans = new QTranslator( this ); |
542 | tfn = qpeDir() + "/i18n/" + lang + "/" + d->appName + ".qm"; | 542 | tfn = qpeDir() + "/i18n/" + lang + "/" + d->appName + ".qm"; |
543 | if ( trans->load( tfn ) ) | 543 | if ( trans->load( tfn ) ) |
544 | installTranslator( trans ); | 544 | installTranslator( trans ); |
545 | else | 545 | else |
546 | delete trans; | 546 | delete trans; |
547 | 547 | ||
548 | //###language/font hack; should look it up somewhere | 548 | //###language/font hack; should look it up somewhere |
549 | #ifdef QWS | 549 | #ifdef QWS |
550 | if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) { | 550 | if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) { |
551 | QFont fn = FontManager::unicodeFont( FontManager::Proportional ); | 551 | QFont fn = FontManager::unicodeFont( FontManager::Proportional ); |
552 | setFont( fn ); | 552 | setFont( fn ); |
553 | } | 553 | } |
554 | #endif | 554 | #endif |
555 | } | 555 | } |
556 | #endif | 556 | #endif |
557 | 557 | ||
558 | applyStyle(); | 558 | applyStyle(); |
559 | 559 | ||
560 | if ( type() == GuiServer ) { | 560 | if ( type() == GuiServer ) { |
561 | setVolume(); | 561 | setVolume(); |
562 | } | 562 | } |
563 | 563 | ||
564 | installEventFilter( this ); | 564 | installEventFilter( this ); |
565 | 565 | ||
566 | QPEMenuToolFocusManager::initialize(); | 566 | QPEMenuToolFocusManager::initialize(); |
567 | 567 | ||
568 | #ifdef QT_NO_QWS_CURSOR | 568 | #ifdef QT_NO_QWS_CURSOR |
569 | // if we have no cursor, probably don't want tooltips | 569 | // if we have no cursor, probably don't want tooltips |
570 | QToolTip::setEnabled( FALSE ); | 570 | QToolTip::setEnabled( FALSE ); |
571 | #endif | 571 | #endif |
572 | } | 572 | } |
573 | 573 | ||
574 | static QPtrDict<void>* inputMethodDict = 0; | 574 | static QPtrDict<void>* inputMethodDict = 0; |
575 | static void createInputMethodDict() | 575 | static void createInputMethodDict() |
576 | { | 576 | { |
577 | if ( !inputMethodDict ) | 577 | if ( !inputMethodDict ) |
578 | inputMethodDict = new QPtrDict<void>; | 578 | inputMethodDict = new QPtrDict<void>; |
579 | } | 579 | } |
580 | 580 | ||
581 | /*! | 581 | /*! |
582 | Returns the currently set hint to the system as to whether | 582 | Returns the currently set hint to the system as to whether |
583 | widget \a w has any use for text input methods. | 583 | widget \a w has any use for text input methods. |
584 | 584 | ||
585 | 585 | ||
586 | \sa setInputMethodHint() InputMethodHint | 586 | \sa setInputMethodHint() InputMethodHint |
587 | */ | 587 | */ |
588 | QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w ) | 588 | QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w ) |
589 | { | 589 | { |
590 | if ( inputMethodDict && w ) | 590 | if ( inputMethodDict && w ) |
591 | return ( InputMethodHint ) ( int ) inputMethodDict->find( w ); | 591 | return ( InputMethodHint ) ( int ) inputMethodDict->find( w ); |
592 | return Normal; | 592 | return Normal; |
593 | } | 593 | } |
594 | 594 | ||
595 | /*! | 595 | /*! |
596 | \enum QPEApplication::InputMethodHint | 596 | \enum QPEApplication::InputMethodHint |
597 | 597 | ||
598 | \value Normal the application sometimes needs text input (the default). | 598 | \value Normal the application sometimes needs text input (the default). |
599 | \value AlwaysOff the application never needs text input. | 599 | \value AlwaysOff the application never needs text input. |
600 | \value AlwaysOn the application always needs text input. | 600 | \value AlwaysOn the application always needs text input. |
601 | */ | 601 | */ |
602 | 602 | ||
603 | /*! | 603 | /*! |
604 | Hints to the system that widget \a w has use for text input methods | 604 | Hints to the system that widget \a w has use for text input methods |
605 | as specified by \a mode. | 605 | as specified by \a mode. |
606 | 606 | ||
607 | \sa inputMethodHint() InputMethodHint | 607 | \sa inputMethodHint() InputMethodHint |
608 | */ | 608 | */ |
609 | void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode ) | 609 | void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode ) |
610 | { | 610 | { |
611 | createInputMethodDict(); | 611 | createInputMethodDict(); |
612 | if ( mode == Normal ) { | 612 | if ( mode == Normal ) { |
613 | inputMethodDict->remove | 613 | inputMethodDict->remove |
614 | ( w ); | 614 | ( w ); |
615 | } | 615 | } |
616 | else { | 616 | else { |
617 | inputMethodDict->insert( w, ( void* ) mode ); | 617 | inputMethodDict->insert( w, ( void* ) mode ); |
618 | } | 618 | } |
619 | } | 619 | } |
620 | 620 | ||
621 | class HackDialog : public QDialog | 621 | class HackDialog : public QDialog |
622 | { | 622 | { |
623 | public: | 623 | public: |
624 | void acceptIt() { accept(); } | 624 | void acceptIt() { accept(); } |
625 | void rejectIt() { reject(); } | 625 | void rejectIt() { reject(); } |
626 | }; | 626 | }; |
627 | 627 | ||
628 | 628 | ||
629 | void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key ) | 629 | void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key ) |
630 | { | 630 | { |
631 | // specialised actions for certain widgets. May want to | 631 | // specialised actions for certain widgets. May want to |
632 | // add more stuff here. | 632 | // add more stuff here. |
633 | if ( activePopupWidget() && activePopupWidget() ->inherits( "QListBox" ) | 633 | if ( activePopupWidget() && activePopupWidget() ->inherits( "QListBox" ) |
634 | && activePopupWidget() ->parentWidget() | 634 | && activePopupWidget() ->parentWidget() |
635 | && activePopupWidget() ->parentWidget() ->inherits( "QComboBox" ) ) | 635 | && activePopupWidget() ->parentWidget() ->inherits( "QComboBox" ) ) |
636 | key = Qt::Key_Return; | 636 | key = Qt::Key_Return; |
637 | 637 | ||
638 | if ( activePopupWidget() && activePopupWidget() ->inherits( "QPopupMenu" ) ) | 638 | if ( activePopupWidget() && activePopupWidget() ->inherits( "QPopupMenu" ) ) |
639 | key = Qt::Key_Return; | 639 | key = Qt::Key_Return; |
640 | 640 | ||
641 | #ifdef QWS | 641 | #ifdef QWS |
642 | ke->simpleData.keycode = key; | 642 | ke->simpleData.keycode = key; |
643 | #endif | 643 | #endif |
644 | } | 644 | } |
645 | 645 | ||
646 | class HackWidget : public QWidget | 646 | class HackWidget : public QWidget |
647 | { | 647 | { |
648 | public: | 648 | public: |
649 | bool needsOk() | 649 | bool needsOk() |
650 | { return ( getWState() & WState_Reserved1 ); } | 650 | { return ( getWState() & WState_Reserved1 ); } |
651 | }; | 651 | }; |
652 | 652 | ||
653 | /*! | 653 | /*! |
654 | \internal | 654 | \internal |
655 | */ | 655 | */ |
656 | 656 | ||
657 | #ifdef QWS | 657 | #ifdef QWS |
658 | bool QPEApplication::qwsEventFilter( QWSEvent * e ) | 658 | bool QPEApplication::qwsEventFilter( QWSEvent * e ) |
659 | { | 659 | { |
660 | if ( !d->notbusysent && e->type == QWSEvent::Focus ) { | 660 | if ( !d->notbusysent && e->type == QWSEvent::Focus ) { |
661 | if ( qApp->type() != QApplication::GuiServer ) { | 661 | if ( qApp->type() != QApplication::GuiServer ) { |
662 | QCopEnvelope e( "QPE/System", "notBusy(QString)" ); | 662 | QCopEnvelope e( "QPE/System", "notBusy(QString)" ); |
663 | e << d->appName; | 663 | e << d->appName; |
664 | } | 664 | } |
665 | d->notbusysent = TRUE; | 665 | d->notbusysent = TRUE; |
666 | } | 666 | } |
667 | if ( type() == GuiServer ) { | 667 | if ( type() == GuiServer ) { |
668 | switch ( e->type ) { | 668 | switch ( e->type ) { |
669 | case QWSEvent::Mouse: | 669 | case QWSEvent::Mouse: |
670 | if ( e->asMouse() ->simpleData.state && !QWidget::find( e->window() ) ) | 670 | if ( e->asMouse() ->simpleData.state && !QWidget::find( e->window() ) ) |
671 | emit clientMoused(); | 671 | emit clientMoused(); |
672 | break; | 672 | break; |
673 | default: | 673 | default: |
674 | break; | 674 | break; |
675 | } | 675 | } |
676 | } | 676 | } |
677 | if ( e->type == QWSEvent::Key ) { | 677 | if ( e->type == QWSEvent::Key ) { |
678 | if ( d->kbgrabber == 1 ) | 678 | if ( d->kbgrabber == 1 ) |
679 | return TRUE; | 679 | return TRUE; |
680 | QWSKeyEvent *ke = ( QWSKeyEvent * ) e; | 680 | QWSKeyEvent *ke = ( QWSKeyEvent * ) e; |
681 | if ( ke->simpleData.keycode == Qt::Key_F33 ) { | 681 | if ( ke->simpleData.keycode == Qt::Key_F33 ) { |
682 | // Use special "OK" key to press "OK" on top level widgets | 682 | // Use special "OK" key to press "OK" on top level widgets |
683 | QWidget * active = activeWindow(); | 683 | QWidget * active = activeWindow(); |
684 | QWidget *popup = 0; | 684 | QWidget *popup = 0; |
685 | if ( active && active->isPopup() ) { | 685 | if ( active && active->isPopup() ) { |
686 | popup = active; | 686 | popup = active; |
687 | active = active->parentWidget(); | 687 | active = active->parentWidget(); |
688 | } | 688 | } |
689 | if ( active && ( int ) active->winId() == ke->simpleData.window && | 689 | if ( active && ( int ) active->winId() == ke->simpleData.window && |
690 | !active->testWFlags( WStyle_Customize | WType_Popup | WType_Desktop ) ) { | 690 | !active->testWFlags( WStyle_Customize | WType_Popup | WType_Desktop ) ) { |
691 | if ( ke->simpleData.is_press ) { | 691 | if ( ke->simpleData.is_press ) { |
692 | if ( popup ) | 692 | if ( popup ) |
693 | popup->close(); | 693 | popup->close(); |
694 | if ( active->inherits( "QDialog" ) ) { | 694 | if ( active->inherits( "QDialog" ) ) { |
695 | HackDialog * d = ( HackDialog * ) active; | 695 | HackDialog * d = ( HackDialog * ) active; |
696 | d->acceptIt(); | 696 | d->acceptIt(); |
697 | return TRUE; | 697 | return TRUE; |
698 | } | 698 | } |
699 | else if ( ( ( HackWidget * ) active ) ->needsOk() ) { | 699 | else if ( ( ( HackWidget * ) active ) ->needsOk() ) { |
700 | QSignal s; | 700 | QSignal s; |
701 | s.connect( active, SLOT( accept() ) ); | 701 | s.connect( active, SLOT( accept() ) ); |
702 | s.activate(); | 702 | s.activate(); |
703 | } | 703 | } |
704 | else { | 704 | else { |
705 | // do the same as with the select key: Map to the default action of the widget: | 705 | // do the same as with the select key: Map to the default action of the widget: |
706 | mapToDefaultAction( ke, Qt::Key_Return ); | 706 | mapToDefaultAction( ke, Qt::Key_Return ); |
707 | } | 707 | } |
708 | } | 708 | } |
709 | } | 709 | } |
710 | } else if ( ke->simpleData.keycode == Qt::Key_F30 ) { | 710 | } else if ( ke->simpleData.keycode == Qt::Key_F30 ) { |
711 | // Use special "select" key to do whatever default action a widget has | 711 | // Use special "select" key to do whatever default action a widget has |
712 | mapToDefaultAction( ke, Qt::Key_Space ); | 712 | mapToDefaultAction( ke, Qt::Key_Space ); |
713 | } | 713 | } |
714 | else if ( ke->simpleData.keycode == Qt::Key_Escape && | 714 | else if ( ke->simpleData.keycode == Qt::Key_Escape && |
715 | ke->simpleData.is_press ) { | 715 | ke->simpleData.is_press ) { |
716 | // Escape key closes app if focus on toplevel | 716 | // Escape key closes app if focus on toplevel |
717 | QWidget * active = activeWindow(); | 717 | QWidget * active = activeWindow(); |
718 | if ( active && active->testWFlags( WType_TopLevel ) && | 718 | if ( active && active->testWFlags( WType_TopLevel ) && |
719 | ( int ) active->winId() == ke->simpleData.window && | 719 | ( int ) active->winId() == ke->simpleData.window && |
720 | !active->testWFlags( WStyle_Dialog | WStyle_Customize | WType_Popup | WType_Desktop ) ) { | 720 | !active->testWFlags( WStyle_Dialog | WStyle_Customize | WType_Popup | WType_Desktop ) ) { |
721 | if ( active->inherits( "QDialog" ) ) { | 721 | if ( active->inherits( "QDialog" ) ) { |
722 | HackDialog * d = ( HackDialog * ) active; | 722 | HackDialog * d = ( HackDialog * ) active; |
723 | d->rejectIt(); | 723 | d->rejectIt(); |
724 | return TRUE; | 724 | return TRUE; |
725 | } | 725 | } |
726 | else if ( strcmp( argv() [ 0 ], "embeddedkonsole" ) != 0 ) { | 726 | else if ( strcmp( argv() [ 0 ], "embeddedkonsole" ) != 0 ) { |
727 | active->close(); | 727 | active->close(); |
728 | } | 728 | } |
729 | } | 729 | } |
730 | } | 730 | } |
731 | 731 | ||
732 | #if QT_VERSION < 231 | 732 | #if QT_VERSION < 231 |
733 | // Filter out the F4/Launcher key from apps | 733 | // Filter out the F4/Launcher key from apps |
734 | // ### The launcher key may not always be F4 on all devices | 734 | // ### The launcher key may not always be F4 on all devices |
735 | if ( ( ( QWSKeyEvent * ) e ) ->simpleData.keycode == Qt::Key_F4 ) | 735 | if ( ( ( QWSKeyEvent * ) e ) ->simpleData.keycode == Qt::Key_F4 ) |
736 | return TRUE; | 736 | return TRUE; |
737 | #endif | 737 | #endif |
738 | 738 | ||
739 | } | 739 | } |
740 | if ( e->type == QWSEvent::Focus ) { | 740 | if ( e->type == QWSEvent::Focus ) { |
741 | QWSFocusEvent * fe = ( QWSFocusEvent* ) e; | 741 | QWSFocusEvent * fe = ( QWSFocusEvent* ) e; |
742 | QWidget* nfw = QWidget::find( e->window() ); | 742 | QWidget* nfw = QWidget::find( e->window() ); |
743 | if ( !fe->simpleData.get_focus ) { | 743 | if ( !fe->simpleData.get_focus ) { |
744 | QWidget * active = activeWindow(); | 744 | QWidget * active = activeWindow(); |
745 | while ( active && active->isPopup() ) { | 745 | while ( active && active->isPopup() ) { |
746 | active->close(); | 746 | active->close(); |
747 | active = activeWindow(); | 747 | active = activeWindow(); |
748 | } | 748 | } |
749 | if ( !nfw && d->kbgrabber == 2 ) { | 749 | if ( !nfw && d->kbgrabber == 2 ) { |
750 | ungrabKeyboard(); | 750 | ungrabKeyboard(); |
751 | d->kbregrab = TRUE; // want kb back when we're active | 751 | d->kbregrab = TRUE; // want kb back when we're active |
752 | } | 752 | } |
753 | } | 753 | } |
754 | else { | 754 | else { |
755 | // make sure our modal widget is ALWAYS on top | 755 | // make sure our modal widget is ALWAYS on top |
756 | QWidget *topm = activeModalWidget(); | 756 | QWidget *topm = activeModalWidget(); |
757 | if ( topm ) { | 757 | if ( topm ) { |
758 | topm->raise(); | 758 | topm->raise(); |
759 | } | 759 | } |
760 | if ( d->kbregrab ) { | 760 | if ( d->kbregrab ) { |
761 | grabKeyboard(); | 761 | grabKeyboard(); |
762 | d->kbregrab = FALSE; | 762 | d->kbregrab = FALSE; |
763 | } | 763 | } |
764 | } | 764 | } |
765 | if ( fe->simpleData.get_focus && inputMethodDict ) { | 765 | if ( fe->simpleData.get_focus && inputMethodDict ) { |
766 | InputMethodHint m = inputMethodHint( QWidget::find( e->window() ) ); | 766 | InputMethodHint m = inputMethodHint( QWidget::find( e->window() ) ); |
767 | if ( m == AlwaysOff ) | 767 | if ( m == AlwaysOff ) |
768 | Global::hideInputMethod(); | 768 | Global::hideInputMethod(); |
769 | if ( m == AlwaysOn ) | 769 | if ( m == AlwaysOn ) |
770 | Global::showInputMethod(); | 770 | Global::showInputMethod(); |
771 | } | 771 | } |
772 | } | 772 | } |
773 | return QApplication::qwsEventFilter( e ); | 773 | return QApplication::qwsEventFilter( e ); |
774 | } | 774 | } |
775 | #endif | 775 | #endif |
776 | 776 | ||
777 | /*! | 777 | /*! |
778 | Destroys the QPEApplication. | 778 | Destroys the QPEApplication. |
779 | */ | 779 | */ |
780 | QPEApplication::~QPEApplication() | 780 | QPEApplication::~QPEApplication() |
781 | { | 781 | { |
782 | ungrabKeyboard(); | 782 | ungrabKeyboard(); |
783 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 783 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
784 | // Need to delete QCopChannels early, since the display will | 784 | // Need to delete QCopChannels early, since the display will |
785 | // be gone by the time we get to ~QObject(). | 785 | // be gone by the time we get to ~QObject(). |
786 | delete sysChannel; | 786 | delete sysChannel; |
787 | delete pidChannel; | 787 | delete pidChannel; |
788 | #endif | 788 | #endif |
789 | 789 | ||
790 | delete d; | 790 | delete d; |
791 | } | 791 | } |
792 | 792 | ||
793 | /*! | 793 | /*! |
794 | Returns <tt>$OPIEDIR/</tt>. | 794 | Returns <tt>$OPIEDIR/</tt>. |
795 | */ | 795 | */ |
796 | QString QPEApplication::qpeDir() | 796 | QString QPEApplication::qpeDir() |
797 | { | 797 | { |
798 | const char * base = getenv( "OPIEDIR" ); | 798 | const char * base = getenv( "OPIEDIR" ); |
799 | if ( base ) | 799 | if ( base ) |
800 | return QString( base ) + "/"; | 800 | return QString( base ) + "/"; |
801 | 801 | ||
802 | return QString( "../" ); | 802 | return QString( "../" ); |
803 | } | 803 | } |
804 | 804 | ||
805 | /*! | 805 | /*! |
806 | Returns the user's current Document directory. There is a trailing "/". | 806 | Returns the user's current Document directory. There is a trailing "/". |
807 | .. well, it does now,, and there's no trailing '/' | 807 | .. well, it does now,, and there's no trailing '/' |
808 | */ | 808 | */ |
809 | QString QPEApplication::documentDir() | 809 | QString QPEApplication::documentDir() |
810 | { | 810 | { |
811 | return QString( QDir::homeDirPath() + "/Documents"); | 811 | const char* base = getenv( "HOME"); |
812 | if( base ) | ||
813 | return QString( base ) + "/Documents"; | ||
814 | |||
815 | return QString( "../Documents" ); | ||
812 | } | 816 | } |
813 | 817 | ||
814 | static int deforient = -1; | 818 | static int deforient = -1; |
815 | 819 | ||
816 | /*! | 820 | /*! |
817 | \internal | 821 | \internal |
818 | */ | 822 | */ |
819 | int QPEApplication::defaultRotation() | 823 | int QPEApplication::defaultRotation() |
820 | { | 824 | { |
821 | if ( deforient < 0 ) { | 825 | if ( deforient < 0 ) { |
822 | QString d = getenv( "QWS_DISPLAY" ); | 826 | QString d = getenv( "QWS_DISPLAY" ); |
823 | if ( d.contains( "Rot90" ) ) { | 827 | if ( d.contains( "Rot90" ) ) { |
824 | deforient = 90; | 828 | deforient = 90; |
825 | } | 829 | } |
826 | else if ( d.contains( "Rot180" ) ) { | 830 | else if ( d.contains( "Rot180" ) ) { |
827 | deforient = 180; | 831 | deforient = 180; |
828 | } | 832 | } |
829 | else if ( d.contains( "Rot270" ) ) { | 833 | else if ( d.contains( "Rot270" ) ) { |
830 | deforient = 270; | 834 | deforient = 270; |
831 | } | 835 | } |
832 | else { | 836 | else { |
833 | deforient = 0; | 837 | deforient = 0; |
834 | } | 838 | } |
835 | } | 839 | } |
836 | return deforient; | 840 | return deforient; |
837 | } | 841 | } |
838 | 842 | ||
839 | /*! | 843 | /*! |
840 | \internal | 844 | \internal |
841 | */ | 845 | */ |
842 | void QPEApplication::setDefaultRotation( int r ) | 846 | void QPEApplication::setDefaultRotation( int r ) |
843 | { | 847 | { |
844 | if ( qApp->type() == GuiServer ) { | 848 | if ( qApp->type() == GuiServer ) { |
845 | deforient = r; | 849 | deforient = r; |
846 | setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 ); | 850 | setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 ); |
847 | Config config("qpe"); | 851 | Config config("qpe"); |
848 | config.setGroup( "Rotation" ); | 852 | config.setGroup( "Rotation" ); |
849 | config.writeEntry( "Screen", getenv("QWS_DISPLAY") ); | 853 | config.writeEntry( "Screen", getenv("QWS_DISPLAY") ); |
850 | } else { | 854 | } else { |
851 | #ifndef QT_NO_COP | 855 | #ifndef QT_NO_COP |
852 | { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" ); e << r; } | 856 | { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" ); e << r; } |
853 | #endif | 857 | #endif |
854 | } | 858 | } |
855 | } | 859 | } |
856 | 860 | ||
857 | /*! | 861 | /*! |
858 | \internal | 862 | \internal |
859 | */ | 863 | */ |
860 | void QPEApplication::applyStyle() | 864 | void QPEApplication::applyStyle() |
861 | { | 865 | { |
862 | Config config( "qpe" ); | 866 | Config config( "qpe" ); |
863 | 867 | ||
864 | config.setGroup( "Appearance" ); | 868 | config.setGroup( "Appearance" ); |
865 | 869 | ||
866 | // Widget style | 870 | // Widget style |
867 | QString style = config.readEntry( "Style", "Light" ); | 871 | QString style = config.readEntry( "Style", "Light" ); |
868 | internalSetStyle( style ); | 872 | internalSetStyle( style ); |
869 | 873 | ||
870 | // Colors | 874 | // Colors |
871 | QColor bgcolor( config.readEntry( "Background", "#E5E1D5" ) ); | 875 | QColor bgcolor( config.readEntry( "Background", "#E5E1D5" ) ); |
872 | QColor btncolor( config.readEntry( "Button", "#D6CDBB" ) ); | 876 | QColor btncolor( config.readEntry( "Button", "#D6CDBB" ) ); |
873 | QPalette pal( btncolor, bgcolor ); | 877 | QPalette pal( btncolor, bgcolor ); |
874 | QString color = config.readEntry( "Highlight", "#800000" ); | 878 | QString color = config.readEntry( "Highlight", "#800000" ); |
875 | pal.setColor( QColorGroup::Highlight, QColor( color ) ); | 879 | pal.setColor( QColorGroup::Highlight, QColor( color ) ); |
876 | color = config.readEntry( "HighlightedText", "#FFFFFF" ); | 880 | color = config.readEntry( "HighlightedText", "#FFFFFF" ); |
877 | pal.setColor( QColorGroup::HighlightedText, QColor( color ) ); | 881 | pal.setColor( QColorGroup::HighlightedText, QColor( color ) ); |
878 | color = config.readEntry( "Text", "#000000" ); | 882 | color = config.readEntry( "Text", "#000000" ); |
879 | pal.setColor( QColorGroup::Text, QColor( color ) ); | 883 | pal.setColor( QColorGroup::Text, QColor( color ) ); |
880 | color = config.readEntry( "ButtonText", "#000000" ); | 884 | color = config.readEntry( "ButtonText", "#000000" ); |
881 | pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) ); | 885 | pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) ); |
882 | color = config.readEntry( "Base", "#FFFFFF" ); | 886 | color = config.readEntry( "Base", "#FFFFFF" ); |
883 | pal.setColor( QColorGroup::Base, QColor( color ) ); | 887 | pal.setColor( QColorGroup::Base, QColor( color ) ); |
884 | 888 | ||
885 | pal.setColor( QPalette::Disabled, QColorGroup::Text, | 889 | pal.setColor( QPalette::Disabled, QColorGroup::Text, |
886 | pal.color( QPalette::Active, QColorGroup::Background ).dark() ); | 890 | pal.color( QPalette::Active, QColorGroup::Background ).dark() ); |
887 | 891 | ||
888 | setPalette( pal, TRUE ); | 892 | setPalette( pal, TRUE ); |
889 | 893 | ||
890 | // Window Decoration | 894 | // Window Decoration |
891 | QString dec = config.readEntry( "Decoration", "Qtopia" ); | 895 | QString dec = config.readEntry( "Decoration", "Qtopia" ); |
892 | if ( dec != d->decorationName ) { | 896 | if ( dec != d->decorationName ) { |
893 | qwsSetDecoration( new QPEDecoration( dec ) ); | 897 | qwsSetDecoration( new QPEDecoration( dec ) ); |
894 | d->decorationName = dec; | 898 | d->decorationName = dec; |
895 | } | 899 | } |
896 | 900 | ||
897 | // Font | 901 | // Font |
898 | QString ff = config.readEntry( "FontFamily", font().family() ); | 902 | QString ff = config.readEntry( "FontFamily", font().family() ); |
899 | int fs = config.readNumEntry( "FontSize", font().pointSize() ); | 903 | int fs = config.readNumEntry( "FontSize", font().pointSize() ); |
900 | setFont( QFont(ff,fs) ); | 904 | setFont( QFont(ff,fs) ); |
901 | } | 905 | } |
902 | 906 | ||
903 | void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data ) | 907 | void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data ) |
904 | { | 908 | { |
905 | #ifdef Q_WS_QWS | 909 | #ifdef Q_WS_QWS |
906 | QDataStream stream( data, IO_ReadOnly ); | 910 | QDataStream stream( data, IO_ReadOnly ); |
907 | if ( msg == "applyStyle()" ) { | 911 | if ( msg == "applyStyle()" ) { |
908 | applyStyle(); | 912 | applyStyle(); |
909 | } else if ( msg == "setDefaultRotation(int)" ) { | 913 | } else if ( msg == "setDefaultRotation(int)" ) { |
910 | if ( type() == GuiServer ) { | 914 | if ( type() == GuiServer ) { |
911 | int r; | 915 | int r; |
912 | stream >> r; | 916 | stream >> r; |
913 | setDefaultRotation( r ); | 917 | setDefaultRotation( r ); |
914 | } | 918 | } |
915 | } else if ( msg == "shutdown()" ) { | 919 | } else if ( msg == "shutdown()" ) { |
916 | if ( type() == GuiServer ) | 920 | if ( type() == GuiServer ) |
917 | shutdown(); | 921 | shutdown(); |
918 | } else if ( msg == "quit()" ) { | 922 | } else if ( msg == "quit()" ) { |
919 | if ( type() != GuiServer ) | 923 | if ( type() != GuiServer ) |
920 | tryQuit(); | 924 | tryQuit(); |
921 | } else if ( msg == "forceQuit()" ) { | 925 | } else if ( msg == "forceQuit()" ) { |
922 | if ( type() != GuiServer ) | 926 | if ( type() != GuiServer ) |
923 | quit(); | 927 | quit(); |
924 | } else if ( msg == "restart()" ) { | 928 | } else if ( msg == "restart()" ) { |
925 | if ( type() == GuiServer ) | 929 | if ( type() == GuiServer ) |
926 | restart(); | 930 | restart(); |
927 | } else if ( msg == "grabKeyboard(QString)" ) { | 931 | } else if ( msg == "grabKeyboard(QString)" ) { |
928 | QString who; | 932 | QString who; |
929 | stream >> who; | 933 | stream >> who; |
930 | if ( who.isEmpty() ) | 934 | if ( who.isEmpty() ) |
931 | d->kbgrabber = 0; | 935 | d->kbgrabber = 0; |
932 | else if ( who != d->appName ) | 936 | else if ( who != d->appName ) |
933 | d->kbgrabber = 1; | 937 | d->kbgrabber = 1; |
934 | else | 938 | else |
935 | d->kbgrabber = 2; | 939 | d->kbgrabber = 2; |
936 | } else if ( msg == "language(QString)" ) { | 940 | } else if ( msg == "language(QString)" ) { |
937 | if ( type() == GuiServer ) { | 941 | if ( type() == GuiServer ) { |
938 | QString l; | 942 | QString l; |
939 | stream >> l; | 943 | stream >> l; |
940 | QString cl = getenv( "LANG" ); | 944 | QString cl = getenv( "LANG" ); |
941 | if ( cl != l ) { | 945 | if ( cl != l ) { |
942 | if ( l.isNull() ) | 946 | if ( l.isNull() ) |
943 | unsetenv( "LANG" ); | 947 | unsetenv( "LANG" ); |
944 | else | 948 | else |
945 | setenv( "LANG", l.latin1(), 1 ); | 949 | setenv( "LANG", l.latin1(), 1 ); |
946 | restart(); | 950 | restart(); |
947 | } | 951 | } |
948 | } | 952 | } |
949 | } else if ( msg == "timeChange(QString)" ) { | 953 | } else if ( msg == "timeChange(QString)" ) { |
950 | QString t; | 954 | QString t; |
951 | stream >> t; | 955 | stream >> t; |
952 | if ( t.isNull() ) | 956 | if ( t.isNull() ) |
953 | unsetenv( "TZ" ); | 957 | unsetenv( "TZ" ); |
954 | else | 958 | else |
955 | setenv( "TZ", t.latin1(), 1 ); | 959 | setenv( "TZ", t.latin1(), 1 ); |
956 | // emit the signal so everyone else knows... | 960 | // emit the signal so everyone else knows... |
957 | emit timeChanged(); | 961 | emit timeChanged(); |
958 | } else if ( msg == "execute(QString)" ) { | 962 | } else if ( msg == "execute(QString)" ) { |
959 | if ( type() == GuiServer ) { | 963 | if ( type() == GuiServer ) { |
960 | QString t; | 964 | QString t; |
961 | stream >> t; | 965 | stream >> t; |
962 | Global::execute( t ); | 966 | Global::execute( t ); |
963 | } | 967 | } |
964 | } else if ( msg == "execute(QString,QString)" ) { | 968 | } else if ( msg == "execute(QString,QString)" ) { |
965 | if ( type() == GuiServer ) { | 969 | if ( type() == GuiServer ) { |
966 | QString t, d; | 970 | QString t, d; |
967 | stream >> t >> d; | 971 | stream >> t >> d; |
968 | Global::execute( t, d ); | 972 | Global::execute( t, d ); |
969 | } | 973 | } |
970 | } else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) { | 974 | } else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) { |
971 | if ( type() == GuiServer ) { | 975 | if ( type() == GuiServer ) { |
972 | QDateTime when; | 976 | QDateTime when; |
973 | QCString channel, message; | 977 | QCString channel, message; |
974 | int data; | 978 | int data; |
975 | stream >> when >> channel >> message >> data; | 979 | stream >> when >> channel >> message >> data; |
976 | AlarmServer::addAlarm( when, channel, message, data ); | 980 | AlarmServer::addAlarm( when, channel, message, data ); |
977 | } | 981 | } |
978 | } else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) { | 982 | } else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) { |
979 | if ( type() == GuiServer ) { | 983 | if ( type() == GuiServer ) { |
980 | QDateTime when; | 984 | QDateTime when; |
981 | QCString channel, message; | 985 | QCString channel, message; |
982 | int data; | 986 | int data; |
983 | stream >> when >> channel >> message >> data; | 987 | stream >> when >> channel >> message >> data; |
984 | AlarmServer::deleteAlarm( when, channel, message, data ); | 988 | AlarmServer::deleteAlarm( when, channel, message, data ); |
985 | } | 989 | } |
986 | } else if ( msg == "clockChange(bool)" ) { | 990 | } else if ( msg == "clockChange(bool)" ) { |
987 | int tmp; | 991 | int tmp; |
988 | stream >> tmp; | 992 | stream >> tmp; |
989 | emit clockChanged( tmp ); | 993 | emit clockChanged( tmp ); |
990 | } else if ( msg == "weekChange(bool)" ) { | 994 | } else if ( msg == "weekChange(bool)" ) { |
991 | int tmp; | 995 | int tmp; |
992 | stream >> tmp; | 996 | stream >> tmp; |
993 | emit weekChanged( tmp ); | 997 | emit weekChanged( tmp ); |
994 | } else if ( msg == "setDateFormat(DateFormat)" ) { | 998 | } else if ( msg == "setDateFormat(DateFormat)" ) { |
995 | DateFormat tmp; | 999 | DateFormat tmp; |
996 | stream >> tmp; | 1000 | stream >> tmp; |
997 | emit dateFormatChanged( tmp ); | 1001 | emit dateFormatChanged( tmp ); |
998 | } else if ( msg == "setVolume(int,int)" ) { | 1002 | } else if ( msg == "setVolume(int,int)" ) { |
999 | int t, v; | 1003 | int t, v; |
1000 | stream >> t >> v; | 1004 | stream >> t >> v; |
1001 | setVolume( t, v ); | 1005 | setVolume( t, v ); |
1002 | emit volumeChanged( muted ); | 1006 | emit volumeChanged( muted ); |
1003 | } else if ( msg == "volumeChange(bool)" ) { | 1007 | } else if ( msg == "volumeChange(bool)" ) { |
1004 | stream >> muted; | 1008 | stream >> muted; |
1005 | setVolume(); | 1009 | setVolume(); |
1006 | emit volumeChanged( muted ); | 1010 | emit volumeChanged( muted ); |
1007 | } else if ( msg == "setMic(int,int)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> | 1011 | } else if ( msg == "setMic(int,int)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> |
1008 | int t, v; | 1012 | int t, v; |
1009 | stream >> t >> v; | 1013 | stream >> t >> v; |
1010 | setMic( t, v ); | 1014 | setMic( t, v ); |
1011 | emit micChanged( micMuted ); | 1015 | emit micChanged( micMuted ); |
1012 | } else if ( msg == "micChange(bool)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> | 1016 | } else if ( msg == "micChange(bool)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> |
1013 | stream >> micMuted; | 1017 | stream >> micMuted; |
1014 | setMic(); | 1018 | setMic(); |
1015 | emit micChanged( micMuted ); | 1019 | emit micChanged( micMuted ); |
1016 | } | 1020 | } |
1017 | #endif | 1021 | #endif |
1018 | } | 1022 | } |
1019 | 1023 | ||
1020 | /*! | 1024 | /*! |
1021 | \internal | 1025 | \internal |
1022 | */ | 1026 | */ |
1023 | bool QPEApplication::raiseAppropriateWindow() | 1027 | bool QPEApplication::raiseAppropriateWindow() |
1024 | { | 1028 | { |
1025 | bool r=FALSE; | 1029 | bool r=FALSE; |
1026 | // ########## raise()ing main window should raise and set active | 1030 | // ########## raise()ing main window should raise and set active |
1027 | // ########## it and then all childen. This belongs in Qt/Embedded | 1031 | // ########## it and then all childen. This belongs in Qt/Embedded |
1028 | QWidget *top = d->qpe_main_widget; | 1032 | QWidget *top = d->qpe_main_widget; |
1029 | if ( !top ) top =mainWidget(); | 1033 | if ( !top ) top =mainWidget(); |
1030 | if ( top && d->keep_running ) { | 1034 | if ( top && d->keep_running ) { |
1031 | if ( top->isVisible() ) | 1035 | if ( top->isVisible() ) |
1032 | r = TRUE; | 1036 | r = TRUE; |
1033 | else if (d->preloaded) { | 1037 | else if (d->preloaded) { |
1034 | // We are preloaded and not visible.. pretend we just started.. | 1038 | // We are preloaded and not visible.. pretend we just started.. |
1035 | QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); | 1039 | QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); |
1036 | e << d->appName; | 1040 | e << d->appName; |
1037 | } | 1041 | } |
1038 | 1042 | ||
1039 | d->show_mx(top,d->nomaximize); | 1043 | d->show_mx(top,d->nomaximize); |
1040 | top->raise(); | 1044 | top->raise(); |
1041 | top->setActiveWindow(); | 1045 | top->setActiveWindow(); |
1042 | } | 1046 | } |
1043 | QWidget *topm = activeModalWidget(); | 1047 | QWidget *topm = activeModalWidget(); |
1044 | if ( topm && topm != top ) { | 1048 | if ( topm && topm != top ) { |
1045 | topm->show(); | 1049 | topm->show(); |
1046 | topm->raise(); | 1050 | topm->raise(); |
1047 | topm->setActiveWindow(); | 1051 | topm->setActiveWindow(); |
1048 | // If we haven't already handled the fastAppShowing message | 1052 | // If we haven't already handled the fastAppShowing message |
1049 | if (!top && d->preloaded) { | 1053 | if (!top && d->preloaded) { |
1050 | QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); | 1054 | QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); |
1051 | e << d->appName; | 1055 | e << d->appName; |
1052 | } | 1056 | } |
1053 | r = FALSE; | 1057 | r = FALSE; |
1054 | } | 1058 | } |
1055 | return r; | 1059 | return r; |
1056 | } | 1060 | } |
1057 | 1061 | ||
1058 | void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data) | 1062 | void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data) |
1059 | { | 1063 | { |
1060 | #ifdef Q_WS_QWS | 1064 | #ifdef Q_WS_QWS |
1061 | 1065 | ||
1062 | if ( msg == "quit()" ) { | 1066 | if ( msg == "quit()" ) { |
1063 | tryQuit(); | 1067 | tryQuit(); |
1064 | } else if ( msg == "quitIfInvisible()" ) { | 1068 | } else if ( msg == "quitIfInvisible()" ) { |
1065 | if ( d->qpe_main_widget && !d->qpe_main_widget->isVisible() ) | 1069 | if ( d->qpe_main_widget && !d->qpe_main_widget->isVisible() ) |
1066 | quit(); | 1070 | quit(); |
1067 | } else if ( msg == "close()" ) { | 1071 | } else if ( msg == "close()" ) { |
1068 | hideOrQuit(); | 1072 | hideOrQuit(); |
1069 | } else if ( msg == "disablePreload()" ) { | 1073 | } else if ( msg == "disablePreload()" ) { |
1070 | d->preloaded = FALSE; | 1074 | d->preloaded = FALSE; |
1071 | d->keep_running = TRUE; | 1075 | d->keep_running = TRUE; |
1072 | /* so that quit will quit */ | 1076 | /* so that quit will quit */ |
1073 | } else if ( msg == "enablePreload()" ) { | 1077 | } else if ( msg == "enablePreload()" ) { |
1074 | if (d->qpe_main_widget) | 1078 | if (d->qpe_main_widget) |
1075 | d->preloaded = TRUE; | 1079 | d->preloaded = TRUE; |
1076 | d->keep_running = TRUE; | 1080 | d->keep_running = TRUE; |
1077 | /* so next quit won't quit */ | 1081 | /* so next quit won't quit */ |
1078 | } else if ( msg == "raise()" ) { | 1082 | } else if ( msg == "raise()" ) { |
1079 | d->keep_running = TRUE; | 1083 | d->keep_running = TRUE; |
1080 | d->notbusysent = FALSE; | 1084 | d->notbusysent = FALSE; |
1081 | raiseAppropriateWindow(); | 1085 | raiseAppropriateWindow(); |
1082 | // Tell the system we're still chugging along... | 1086 | // Tell the system we're still chugging along... |
1083 | QCopEnvelope e("QPE/System", "appRaised(QString)"); | 1087 | QCopEnvelope e("QPE/System", "appRaised(QString)"); |
1084 | e << d->appName; | 1088 | e << d->appName; |
1085 | } else if ( msg == "flush()" ) { | 1089 | } else if ( msg == "flush()" ) { |
1086 | emit flush(); | 1090 | emit flush(); |
1087 | // we need to tell the desktop | 1091 | // we need to tell the desktop |
1088 | QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" ); | 1092 | QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" ); |
1089 | e << d->appName; | 1093 | e << d->appName; |
1090 | } else if ( msg == "reload()" ) { | 1094 | } else if ( msg == "reload()" ) { |
1091 | emit reload(); | 1095 | emit reload(); |
1092 | } else if ( msg == "setDocument(QString)" ) { | 1096 | } else if ( msg == "setDocument(QString)" ) { |
1093 | d->keep_running = TRUE; | 1097 | d->keep_running = TRUE; |
1094 | QDataStream stream( data, IO_ReadOnly ); | 1098 | QDataStream stream( data, IO_ReadOnly ); |
1095 | QString doc; | 1099 | QString doc; |
1096 | stream >> doc; | 1100 | stream >> doc; |
1097 | QWidget *mw = mainWidget(); | 1101 | QWidget *mw = mainWidget(); |
1098 | if ( !mw ) | 1102 | if ( !mw ) |
1099 | mw = d->qpe_main_widget; | 1103 | mw = d->qpe_main_widget; |
1100 | if ( mw ) | 1104 | if ( mw ) |
1101 | Global::setDocument( mw, doc ); | 1105 | Global::setDocument( mw, doc ); |
1102 | } else if ( msg == "nextView()" ) { | 1106 | } else if ( msg == "nextView()" ) { |
1103 | qDebug("got nextView()"); | 1107 | qDebug("got nextView()"); |
1104 | /* | 1108 | /* |
1105 | if ( raiseAppropriateWindow() ) | 1109 | if ( raiseAppropriateWindow() ) |
1106 | */ | 1110 | */ |
1107 | emit appMessage( msg, data); | 1111 | emit appMessage( msg, data); |
1108 | } else { | 1112 | } else { |
1109 | emit appMessage( msg, data); | 1113 | emit appMessage( msg, data); |
1110 | } | 1114 | } |
1111 | 1115 | ||
1112 | #endif | 1116 | #endif |
1113 | } | 1117 | } |
1114 | 1118 | ||
1115 | 1119 | ||
1116 | /*! | 1120 | /*! |
1117 | Sets widget \a mw as the mainWidget() and shows it. For small windows, | 1121 | Sets widget \a mw as the mainWidget() and shows it. For small windows, |
1118 | consider passing TRUE for \a nomaximize rather than the default FALSE. | 1122 | consider passing TRUE for \a nomaximize rather than the default FALSE. |
1119 | 1123 | ||
1120 | \sa showMainDocumentWidget() | 1124 | \sa showMainDocumentWidget() |
1121 | */ | 1125 | */ |
1122 | void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize ) | 1126 | void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize ) |
1123 | { | 1127 | { |
1124 | d->show(mw,nomaximize ); | 1128 | d->show(mw,nomaximize ); |
1125 | } | 1129 | } |
1126 | 1130 | ||
1127 | /*! | 1131 | /*! |
1128 | Sets widget \a mw as the mainWidget() and shows it. For small windows, | 1132 | Sets widget \a mw as the mainWidget() and shows it. For small windows, |
1129 | consider passing TRUE for \a nomaximize rather than the default FALSE. | 1133 | consider passing TRUE for \a nomaximize rather than the default FALSE. |
1130 | 1134 | ||
1131 | This calls designates the application as | 1135 | This calls designates the application as |
1132 | a \link docwidget.html document-oriented\endlink application. | 1136 | a \link docwidget.html document-oriented\endlink application. |
1133 | 1137 | ||
1134 | The \a mw widget \e must have this slot: setDocument(const QString&). | 1138 | The \a mw widget \e must have this slot: setDocument(const QString&). |
1135 | 1139 | ||
1136 | \sa showMainWidget() | 1140 | \sa showMainWidget() |
1137 | */ | 1141 | */ |
1138 | void QPEApplication::showMainDocumentWidget( QWidget* mw, bool nomaximize ) | 1142 | void QPEApplication::showMainDocumentWidget( QWidget* mw, bool nomaximize ) |
1139 | { | 1143 | { |
1140 | if ( mw && argc() == 2 ) | 1144 | if ( mw && argc() == 2 ) |
1141 | Global::setDocument( mw, QString::fromUtf8(argv()[1]) ); | 1145 | Global::setDocument( mw, QString::fromUtf8(argv()[1]) ); |
1142 | 1146 | ||
1143 | d->show(mw, nomaximize ); | 1147 | d->show(mw, nomaximize ); |
1144 | } | 1148 | } |
1145 | 1149 | ||
1146 | 1150 | ||
1147 | /*! | 1151 | /*! |
1148 | If an application is started via a \link qcop.html QCop\endlink | 1152 | If an application is started via a \link qcop.html QCop\endlink |
1149 | message, the application will process the \link qcop.html | 1153 | message, the application will process the \link qcop.html |
1150 | QCop\endlink message and then quit. If the application calls this | 1154 | QCop\endlink message and then quit. If the application calls this |
1151 | function while processing a \link qcop.html QCop\endlink message, | 1155 | function while processing a \link qcop.html QCop\endlink message, |
1152 | after processing its outstanding \link qcop.html QCop\endlink | 1156 | after processing its outstanding \link qcop.html QCop\endlink |
1153 | messages the application will start 'properly' and show itself. | 1157 | messages the application will start 'properly' and show itself. |
1154 | 1158 | ||
1155 | \sa keepRunning() | 1159 | \sa keepRunning() |
1156 | */ | 1160 | */ |
1157 | void QPEApplication::setKeepRunning() | 1161 | void QPEApplication::setKeepRunning() |
1158 | { | 1162 | { |
1159 | if ( qApp && qApp->inherits( "QPEApplication" ) ) { | 1163 | if ( qApp && qApp->inherits( "QPEApplication" ) ) { |
1160 | QPEApplication * qpeApp = ( QPEApplication* ) qApp; | 1164 | QPEApplication * qpeApp = ( QPEApplication* ) qApp; |
1161 | qpeApp->d->keep_running = TRUE; | 1165 | qpeApp->d->keep_running = TRUE; |
1162 | } | 1166 | } |
1163 | } | 1167 | } |
1164 | 1168 | ||
1165 | /*! | 1169 | /*! |
1166 | Returns TRUE if the application will quit after processing the | 1170 | Returns TRUE if the application will quit after processing the |
1167 | current list of qcop messages; otherwise returns FALSE. | 1171 | current list of qcop messages; otherwise returns FALSE. |
1168 | 1172 | ||
1169 | \sa setKeepRunning() | 1173 | \sa setKeepRunning() |
1170 | */ | 1174 | */ |
1171 | bool QPEApplication::keepRunning() const | 1175 | bool QPEApplication::keepRunning() const |
1172 | { | 1176 | { |
1173 | return d->keep_running; | 1177 | return d->keep_running; |
1174 | } | 1178 | } |
1175 | 1179 | ||
1176 | /*! | 1180 | /*! |
1177 | \internal | 1181 | \internal |
1178 | */ | 1182 | */ |
1179 | void QPEApplication::internalSetStyle( const QString &style ) | 1183 | void QPEApplication::internalSetStyle( const QString &style ) |
1180 | { | 1184 | { |
1181 | #if QT_VERSION >= 300 | 1185 | #if QT_VERSION >= 300 |
1182 | if ( style == "QPE" ) { | 1186 | if ( style == "QPE" ) { |
1183 | setStyle( new QPEStyle ); | 1187 | setStyle( new QPEStyle ); |
1184 | } | 1188 | } |
1185 | else { | 1189 | else { |
1186 | QStyle *s = QStyleFactory::create( style ); | 1190 | QStyle *s = QStyleFactory::create( style ); |
1187 | if ( s ) | 1191 | if ( s ) |
1188 | setStyle( s ); | 1192 | setStyle( s ); |
1189 | } | 1193 | } |
1190 | #else | 1194 | #else |
1191 | if ( style == "Windows" ) { | 1195 | if ( style == "Windows" ) { |
1192 | setStyle( new QWindowsStyle ); | 1196 | setStyle( new QWindowsStyle ); |
1193 | } | 1197 | } |
1194 | else if ( style == "QPE" ) { | 1198 | else if ( style == "QPE" ) { |
1195 | setStyle( new QPEStyle ); | 1199 | setStyle( new QPEStyle ); |
1196 | } | 1200 | } |
1197 | else if ( style == "Light" ) { | 1201 | else if ( style == "Light" ) { |
1198 | setStyle( new LightStyle ); | 1202 | setStyle( new LightStyle ); |
1199 | } | 1203 | } |
1200 | #ifndef QT_NO_STYLE_PLATINUM | 1204 | #ifndef QT_NO_STYLE_PLATINUM |
1201 | else if ( style == "Platinum" ) { | 1205 | else if ( style == "Platinum" ) { |
1202 | setStyle( new QPlatinumStyle ); | 1206 | setStyle( new QPlatinumStyle ); |
1203 | } | 1207 | } |
1204 | #endif | 1208 | #endif |
1205 | #ifndef QT_NO_STYLE_MOTIF | 1209 | #ifndef QT_NO_STYLE_MOTIF |
1206 | else if ( style == "Motif" ) { | 1210 | else if ( style == "Motif" ) { |
1207 | setStyle( new QMotifStyle ); | 1211 | setStyle( new QMotifStyle ); |
1208 | } | 1212 | } |
1209 | #endif | 1213 | #endif |
1210 | #ifndef QT_NO_STYLE_MOTIFPLUS | 1214 | #ifndef QT_NO_STYLE_MOTIFPLUS |
1211 | else if ( style == "MotifPlus" ) { | 1215 | else if ( style == "MotifPlus" ) { |
1212 | setStyle( new QMotifPlusStyle ); | 1216 | setStyle( new QMotifPlusStyle ); |
1213 | } | 1217 | } |
1214 | #endif | 1218 | #endif |
1215 | 1219 | ||
1216 | else { | 1220 | else { |
1217 | QStyle *sty = 0; | 1221 | QStyle *sty = 0; |
1218 | QString path = QPEApplication::qpeDir ( ) + "/plugins/styles/lib" + style. lower ( ) + ".so"; | 1222 | QString path = QPEApplication::qpeDir ( ) + "/plugins/styles/lib" + style. lower ( ) + ".so"; |
1219 | 1223 | ||
1220 | static QLibrary *lastlib = 0; | 1224 | static QLibrary *lastlib = 0; |
1221 | static StyleInterface *lastiface = 0; | 1225 | static StyleInterface *lastiface = 0; |
1222 | 1226 | ||
1223 | QLibrary *lib = new QLibrary ( path ); | 1227 | QLibrary *lib = new QLibrary ( path ); |
1224 | StyleInterface *iface = 0; | 1228 | StyleInterface *iface = 0; |
1225 | 1229 | ||
1226 | if ( lib-> queryInterface ( IID_Style, ( QUnknownInterface ** ) &iface ) == QS_OK ) | 1230 | if ( lib-> queryInterface ( IID_Style, ( QUnknownInterface ** ) &iface ) == QS_OK ) |
1227 | sty = iface-> create ( ); | 1231 | sty = iface-> create ( ); |
1228 | 1232 | ||
1229 | if ( sty ) { | 1233 | if ( sty ) { |
1230 | setStyle ( sty ); | 1234 | setStyle ( sty ); |
1231 | 1235 | ||
1232 | if ( lastiface ) | 1236 | if ( lastiface ) |
1233 | lastiface-> release ( ); | 1237 | lastiface-> release ( ); |
1234 | lastiface = iface; | 1238 | lastiface = iface; |
1235 | 1239 | ||
1236 | if ( lastlib ) { | 1240 | if ( lastlib ) { |
1237 | lastlib-> unload ( ); | 1241 | lastlib-> unload ( ); |
1238 | delete lastlib; | 1242 | delete lastlib; |
1239 | } | 1243 | } |
1240 | lastlib = lib; | 1244 | lastlib = lib; |
1241 | } | 1245 | } |
1242 | else { | 1246 | else { |
1243 | if ( iface ) | 1247 | if ( iface ) |
1244 | iface-> release ( ); | 1248 | iface-> release ( ); |
1245 | delete lib; | 1249 | delete lib; |
1246 | 1250 | ||
1247 | setStyle ( new QPEStyle ( )); | 1251 | setStyle ( new QPEStyle ( )); |
1248 | } | 1252 | } |
1249 | } | 1253 | } |
1250 | #endif | 1254 | #endif |
1251 | } | 1255 | } |
1252 | 1256 | ||
1253 | /*! | 1257 | /*! |
1254 | \internal | 1258 | \internal |
1255 | */ | 1259 | */ |
1256 | void QPEApplication::prepareForTermination( bool willrestart ) | 1260 | void QPEApplication::prepareForTermination( bool willrestart ) |
1257 | { | 1261 | { |
1258 | if ( willrestart ) { | 1262 | if ( willrestart ) { |
1259 | // Draw a big wait icon, the image can be altered in later revisions | 1263 | // Draw a big wait icon, the image can be altered in later revisions |
1260 | // QWidget *d = QApplication::desktop(); | 1264 | // QWidget *d = QApplication::desktop(); |
1261 | QImage img = Resource::loadImage( "launcher/new_wait" ); | 1265 | QImage img = Resource::loadImage( "launcher/new_wait" ); |
1262 | QPixmap pix; | 1266 | QPixmap pix; |
1263 | pix.convertFromImage( img.smoothScale( 1 * img.width(), 1 * img.height() ) ); | 1267 | pix.convertFromImage( img.smoothScale( 1 * img.width(), 1 * img.height() ) ); |
1264 | QLabel *lblWait = new QLabel( 0, "wait hack!", QWidget::WStyle_Customize | | 1268 | QLabel *lblWait = new QLabel( 0, "wait hack!", QWidget::WStyle_Customize | |
1265 | QWidget::WStyle_NoBorder | QWidget::WStyle_Tool ); | 1269 | QWidget::WStyle_NoBorder | QWidget::WStyle_Tool ); |
1266 | lblWait->setPixmap( pix ); | 1270 | lblWait->setPixmap( pix ); |
1267 | lblWait->setAlignment( QWidget::AlignCenter ); | 1271 | lblWait->setAlignment( QWidget::AlignCenter ); |
1268 | lblWait->show(); | 1272 | lblWait->show(); |
1269 | lblWait->showMaximized(); | 1273 | lblWait->showMaximized(); |
1270 | } | 1274 | } |
1271 | #ifndef SINGLE_APP | 1275 | #ifndef SINGLE_APP |
1272 | { QCopEnvelope envelope( "QPE/System", "forceQuit()" ); | 1276 | { QCopEnvelope envelope( "QPE/System", "forceQuit()" ); |
1273 | } | 1277 | } |
1274 | processEvents(); // ensure the message goes out. | 1278 | processEvents(); // ensure the message goes out. |
1275 | sleep( 1 ); // You have 1 second to comply. | 1279 | sleep( 1 ); // You have 1 second to comply. |
1276 | #endif | 1280 | #endif |
1277 | } | 1281 | } |
1278 | 1282 | ||
1279 | /*! | 1283 | /*! |
1280 | \internal | 1284 | \internal |
1281 | */ | 1285 | */ |
1282 | void QPEApplication::shutdown() | 1286 | void QPEApplication::shutdown() |
1283 | { | 1287 | { |
1284 | // Implement in server's QPEApplication subclass | 1288 | // Implement in server's QPEApplication subclass |
1285 | } | 1289 | } |
1286 | 1290 | ||
1287 | /*! | 1291 | /*! |
1288 | \internal | 1292 | \internal |
1289 | */ | 1293 | */ |
1290 | void QPEApplication::restart() | 1294 | void QPEApplication::restart() |
1291 | { | 1295 | { |
1292 | // Implement in server's QPEApplication subclass | 1296 | // Implement in server's QPEApplication subclass |
1293 | } | 1297 | } |
1294 | 1298 | ||
1295 | static QPtrDict<void>* stylusDict = 0; | 1299 | static QPtrDict<void>* stylusDict = 0; |
1296 | static void createDict() | 1300 | static void createDict() |
1297 | { | 1301 | { |
1298 | if ( !stylusDict ) | 1302 | if ( !stylusDict ) |
1299 | stylusDict = new QPtrDict<void>; | 1303 | stylusDict = new QPtrDict<void>; |
1300 | } | 1304 | } |
1301 | 1305 | ||
1302 | /*! | 1306 | /*! |
1303 | Returns the current StylusMode for widget \a w. | 1307 | Returns the current StylusMode for widget \a w. |
1304 | 1308 | ||
1305 | \sa setStylusOperation() StylusMode | 1309 | \sa setStylusOperation() StylusMode |
1306 | */ | 1310 | */ |
1307 | QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w ) | 1311 | QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w ) |
1308 | { | 1312 | { |
1309 | if ( stylusDict ) | 1313 | if ( stylusDict ) |
1310 | return ( StylusMode ) ( int ) stylusDict->find( w ); | 1314 | return ( StylusMode ) ( int ) stylusDict->find( w ); |
1311 | return LeftOnly; | 1315 | return LeftOnly; |
1312 | } | 1316 | } |
1313 | 1317 | ||
1314 | /*! | 1318 | /*! |
1315 | \enum QPEApplication::StylusMode | 1319 | \enum QPEApplication::StylusMode |
1316 | 1320 | ||
1317 | \value LeftOnly the stylus only generates LeftButton | 1321 | \value LeftOnly the stylus only generates LeftButton |
1318 | events (the default). | 1322 | events (the default). |
1319 | \value RightOnHold the stylus generates RightButton events | 1323 | \value RightOnHold the stylus generates RightButton events |
1320 | if the user uses the press-and-hold gesture. | 1324 | if the user uses the press-and-hold gesture. |
1321 | 1325 | ||
1322 | \sa setStylusOperation() stylusOperation() | 1326 | \sa setStylusOperation() stylusOperation() |
1323 | */ | 1327 | */ |
1324 | 1328 | ||
1325 | /*! | 1329 | /*! |
1326 | Causes widget \a w to receive mouse events according to the stylus | 1330 | Causes widget \a w to receive mouse events according to the stylus |
1327 | \a mode. | 1331 | \a mode. |
1328 | 1332 | ||
1329 | \sa stylusOperation() StylusMode | 1333 | \sa stylusOperation() StylusMode |
1330 | */ | 1334 | */ |
1331 | void QPEApplication::setStylusOperation( QWidget * w, StylusMode mode ) | 1335 | void QPEApplication::setStylusOperation( QWidget * w, StylusMode mode ) |
1332 | { | 1336 | { |
1333 | createDict(); | 1337 | createDict(); |
1334 | if ( mode == LeftOnly ) { | 1338 | if ( mode == LeftOnly ) { |
1335 | stylusDict->remove | 1339 | stylusDict->remove |
1336 | ( w ); | 1340 | ( w ); |
1337 | w->removeEventFilter( qApp ); | 1341 | w->removeEventFilter( qApp ); |
1338 | } | 1342 | } |
1339 | else { | 1343 | else { |
1340 | stylusDict->insert( w, ( void* ) mode ); | 1344 | stylusDict->insert( w, ( void* ) mode ); |
1341 | connect( w, SIGNAL( destroyed() ), qApp, SLOT( removeSenderFromStylusDict() ) ); | 1345 | connect( w, SIGNAL( destroyed() ), qApp, SLOT( removeSenderFromStylusDict() ) ); |
1342 | w->installEventFilter( qApp ); | 1346 | w->installEventFilter( qApp ); |
1343 | } | 1347 | } |
1344 | } | 1348 | } |
1345 | 1349 | ||
1346 | 1350 | ||
1347 | /*! | 1351 | /*! |
1348 | \reimp | 1352 | \reimp |
1349 | */ | 1353 | */ |
1350 | bool QPEApplication::eventFilter( QObject *o, QEvent *e ) | 1354 | bool QPEApplication::eventFilter( QObject *o, QEvent *e ) |
1351 | { | 1355 | { |
1352 | if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) { | 1356 | if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) { |
1353 | QMouseEvent * me = ( QMouseEvent* ) e; | 1357 | QMouseEvent * me = ( QMouseEvent* ) e; |
1354 | StylusMode mode = (StylusMode)(int)stylusDict->find(o); | 1358 | StylusMode mode = (StylusMode)(int)stylusDict->find(o); |
1355 | switch (mode) { | 1359 | switch (mode) { |
1356 | case RightOnHold: | 1360 | case RightOnHold: |
1357 | switch ( me->type() ) { | 1361 | switch ( me->type() ) { |
1358 | case QEvent::MouseButtonPress: | 1362 | case QEvent::MouseButtonPress: |
1359 | if ( me->button() == LeftButton ) { | 1363 | if ( me->button() == LeftButton ) { |
1360 | d->presstimer = startTimer(500); // #### pref. | 1364 | d->presstimer = startTimer(500); // #### pref. |
1361 | d->presswidget = (QWidget*)o; | 1365 | d->presswidget = (QWidget*)o; |
1362 | d->presspos = me->pos(); | 1366 | d->presspos = me->pos(); |
1363 | d->rightpressed = FALSE; | 1367 | d->rightpressed = FALSE; |
1364 | } | 1368 | } |
1365 | break; | 1369 | break; |
1366 | case QEvent::MouseMove: | 1370 | case QEvent::MouseMove: |
1367 | if (d->presstimer && (me->pos()-d->presspos).manhattanLength() > 8) { | 1371 | if (d->presstimer && (me->pos()-d->presspos).manhattanLength() > 8) { |
1368 | killTimer(d->presstimer); | 1372 | killTimer(d->presstimer); |
1369 | d->presstimer = 0; | 1373 | d->presstimer = 0; |
1370 | } | 1374 | } |
1371 | break; | 1375 | break; |
1372 | case QEvent::MouseButtonRelease: | 1376 | case QEvent::MouseButtonRelease: |
1373 | if ( me->button() == LeftButton ) { | 1377 | if ( me->button() == LeftButton ) { |
1374 | if ( d->presstimer ) { | 1378 | if ( d->presstimer ) { |
1375 | killTimer(d->presstimer); | 1379 | killTimer(d->presstimer); |
1376 | d->presstimer = 0; | 1380 | d->presstimer = 0; |
1377 | } | 1381 | } |
1378 | if ( d->rightpressed && d->presswidget ) { | 1382 | if ( d->rightpressed && d->presswidget ) { |
1379 | // Right released | 1383 | // Right released |
1380 | postEvent( d->presswidget, | 1384 | postEvent( d->presswidget, |
1381 | new QMouseEvent( QEvent::MouseButtonRelease, me->pos(), | 1385 | new QMouseEvent( QEvent::MouseButtonRelease, me->pos(), |
1382 | RightButton, LeftButton+RightButton ) ); | 1386 | RightButton, LeftButton+RightButton ) ); |
1383 | // Left released, off-widget | 1387 | // Left released, off-widget |
1384 | postEvent( d->presswidget, | 1388 | postEvent( d->presswidget, |
1385 | new QMouseEvent( QEvent::MouseMove, QPoint(-1,-1), | 1389 | new QMouseEvent( QEvent::MouseMove, QPoint(-1,-1), |
1386 | LeftButton, LeftButton ) ); | 1390 | LeftButton, LeftButton ) ); |
1387 | postEvent( d->presswidget, | 1391 | postEvent( d->presswidget, |
1388 | new QMouseEvent( QEvent::MouseButtonRelease, QPoint(-1,-1), | 1392 | new QMouseEvent( QEvent::MouseButtonRelease, QPoint(-1,-1), |
1389 | LeftButton, LeftButton ) ); | 1393 | LeftButton, LeftButton ) ); |
1390 | d->rightpressed = FALSE; | 1394 | d->rightpressed = FALSE; |
1391 | return TRUE; // don't send the real Left release | 1395 | return TRUE; // don't send the real Left release |
1392 | } | 1396 | } |
1393 | } | 1397 | } |
1394 | break; | 1398 | break; |
1395 | default: | 1399 | default: |
1396 | break; | 1400 | break; |
1397 | } | 1401 | } |
1398 | break; | 1402 | break; |
1399 | default: | 1403 | default: |
1400 | ; | 1404 | ; |
1401 | } | 1405 | } |
1402 | }else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { | 1406 | }else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { |
1403 | QKeyEvent *ke = (QKeyEvent *)e; | 1407 | QKeyEvent *ke = (QKeyEvent *)e; |
1404 | if ( ke->key() == Key_Enter ) { | 1408 | if ( ke->key() == Key_Enter ) { |
1405 | if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) { | 1409 | if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) { |
1406 | postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ', | 1410 | postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ', |
1407 | ke->state(), " ", ke->isAutoRepeat(), ke->count() ) ); | 1411 | ke->state(), " ", ke->isAutoRepeat(), ke->count() ) ); |
1408 | return TRUE; | 1412 | return TRUE; |
1409 | } | 1413 | } |
1410 | } | 1414 | } |
1411 | } | 1415 | } |
1412 | return FALSE; | 1416 | return FALSE; |
1413 | } | 1417 | } |
1414 | 1418 | ||
1415 | /*! | 1419 | /*! |
1416 | \reimp | 1420 | \reimp |
1417 | */ | 1421 | */ |
1418 | void QPEApplication::timerEvent( QTimerEvent *e ) | 1422 | void QPEApplication::timerEvent( QTimerEvent *e ) |
1419 | { | 1423 | { |
1420 | if ( e->timerId() == d->presstimer && d->presswidget ) { | 1424 | if ( e->timerId() == d->presstimer && d->presswidget ) { |
1421 | // Right pressed | 1425 | // Right pressed |
1422 | postEvent( d->presswidget, | 1426 | postEvent( d->presswidget, |
1423 | new QMouseEvent( QEvent::MouseButtonPress, d->presspos, | 1427 | new QMouseEvent( QEvent::MouseButtonPress, d->presspos, |
1424 | RightButton, LeftButton ) ); | 1428 | RightButton, LeftButton ) ); |
1425 | killTimer( d->presstimer ); | 1429 | killTimer( d->presstimer ); |
1426 | d->presstimer = 0; | 1430 | d->presstimer = 0; |
1427 | d->rightpressed = TRUE; | 1431 | d->rightpressed = TRUE; |
1428 | } | 1432 | } |
1429 | } | 1433 | } |
1430 | 1434 | ||
1431 | void QPEApplication::removeSenderFromStylusDict() | 1435 | void QPEApplication::removeSenderFromStylusDict() |
1432 | { | 1436 | { |
1433 | stylusDict->remove | 1437 | stylusDict->remove |
1434 | ( ( void* ) sender() ); | 1438 | ( ( void* ) sender() ); |
1435 | if ( d->presswidget == sender() ) | 1439 | if ( d->presswidget == sender() ) |
1436 | d->presswidget = 0; | 1440 | d->presswidget = 0; |
1437 | } | 1441 | } |
1438 | 1442 | ||
1439 | /*! | 1443 | /*! |
1440 | \internal | 1444 | \internal |
1441 | */ | 1445 | */ |
1442 | bool QPEApplication::keyboardGrabbed() const | 1446 | bool QPEApplication::keyboardGrabbed() const |
1443 | { | 1447 | { |
1444 | return d->kbgrabber; | 1448 | return d->kbgrabber; |
1445 | } | 1449 | } |
1446 | 1450 | ||
1447 | 1451 | ||
1448 | /*! | 1452 | /*! |
1449 | Reverses the effect of grabKeyboard(). This is called automatically | 1453 | Reverses the effect of grabKeyboard(). This is called automatically |
1450 | on program exit. | 1454 | on program exit. |
1451 | */ | 1455 | */ |
1452 | void QPEApplication::ungrabKeyboard() | 1456 | void QPEApplication::ungrabKeyboard() |
1453 | { | 1457 | { |
1454 | QPEApplicationData * d = ( ( QPEApplication* ) qApp ) ->d; | 1458 | QPEApplicationData * d = ( ( QPEApplication* ) qApp ) ->d; |
1455 | if ( d->kbgrabber == 2 ) { | 1459 | if ( d->kbgrabber == 2 ) { |
1456 | #ifndef QT_NO_COP | 1460 | #ifndef QT_NO_COP |
1457 | QCopEnvelope e( "QPE/System", "grabKeyboard(QString)" ); | 1461 | QCopEnvelope e( "QPE/System", "grabKeyboard(QString)" ); |
1458 | e << QString::null; | 1462 | e << QString::null; |
1459 | #endif | 1463 | #endif |
1460 | d->kbregrab = FALSE; | 1464 | d->kbregrab = FALSE; |
1461 | d->kbgrabber = 0; | 1465 | d->kbgrabber = 0; |
1462 | } | 1466 | } |
1463 | } | 1467 | } |
1464 | 1468 | ||
1465 | /*! | 1469 | /*! |
1466 | Grabs the physical keyboard keys, e.g. the application's launching | 1470 | Grabs the physical keyboard keys, e.g. the application's launching |
1467 | keys. Instead of launching applications when these keys are pressed | 1471 | keys. Instead of launching applications when these keys are pressed |
1468 | the signals emitted are sent to this application instead. Some games | 1472 | the signals emitted are sent to this application instead. Some games |
1469 | programs take over the launch keys in this way to make interaction | 1473 | programs take over the launch keys in this way to make interaction |
1470 | easier. | 1474 | easier. |
1471 | 1475 | ||
1472 | \sa ungrabKeyboard() | 1476 | \sa ungrabKeyboard() |
1473 | */ | 1477 | */ |
1474 | void QPEApplication::grabKeyboard() | 1478 | void QPEApplication::grabKeyboard() |
1475 | { | 1479 | { |
1476 | QPEApplicationData * d = ( ( QPEApplication* ) qApp ) ->d; | 1480 | QPEApplicationData * d = ( ( QPEApplication* ) qApp ) ->d; |
1477 | if ( qApp->type() == QApplication::GuiServer ) | 1481 | if ( qApp->type() == QApplication::GuiServer ) |
1478 | d->kbgrabber = 0; | 1482 | d->kbgrabber = 0; |
1479 | else { | 1483 | else { |
1480 | #ifndef QT_NO_COP | 1484 | #ifndef QT_NO_COP |
1481 | QCopEnvelope e( "QPE/System", "grabKeyboard(QString)" ); | 1485 | QCopEnvelope e( "QPE/System", "grabKeyboard(QString)" ); |
1482 | e << d->appName; | 1486 | e << d->appName; |
1483 | #endif | 1487 | #endif |
1484 | d->kbgrabber = 2; // me | 1488 | d->kbgrabber = 2; // me |
1485 | } | 1489 | } |
1486 | } | 1490 | } |
1487 | 1491 | ||
1488 | /*! | 1492 | /*! |
1489 | \reimp | 1493 | \reimp |
1490 | */ | 1494 | */ |
1491 | int QPEApplication::exec() | 1495 | int QPEApplication::exec() |
1492 | { | 1496 | { |
1493 | #ifndef QT_NO_COP | 1497 | #ifndef QT_NO_COP |
1494 | d->sendQCopQ(); | 1498 | d->sendQCopQ(); |
1495 | #endif | 1499 | #endif |
1496 | if ( d->keep_running ) | 1500 | if ( d->keep_running ) |
1497 | //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() ) | 1501 | //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() ) |
1498 | return QApplication::exec(); | 1502 | return QApplication::exec(); |
1499 | 1503 | ||
1500 | #ifndef QT_NO_COP | 1504 | #ifndef QT_NO_COP |
1501 | { | 1505 | { |
1502 | QCopEnvelope e( "QPE/System", "closing(QString)" ); | 1506 | QCopEnvelope e( "QPE/System", "closing(QString)" ); |
1503 | e << d->appName; | 1507 | e << d->appName; |
1504 | } | 1508 | } |
1505 | #endif | 1509 | #endif |
1506 | processEvents(); | 1510 | processEvents(); |
1507 | return 0; | 1511 | return 0; |
1508 | } | 1512 | } |
1509 | 1513 | ||
1510 | /*! | 1514 | /*! |
1511 | \internal | 1515 | \internal |
1512 | External request for application to quit. Quits if possible without | 1516 | External request for application to quit. Quits if possible without |
1513 | loosing state. | 1517 | loosing state. |
1514 | */ | 1518 | */ |
1515 | void QPEApplication::tryQuit() | 1519 | void QPEApplication::tryQuit() |
1516 | { | 1520 | { |
1517 | if ( activeModalWidget() || strcmp( argv() [ 0 ], "embeddedkonsole" ) == 0 ) | 1521 | if ( activeModalWidget() || strcmp( argv() [ 0 ], "embeddedkonsole" ) == 0 ) |
1518 | return ; // Inside modal loop or konsole. Too hard to save state. | 1522 | return ; // Inside modal loop or konsole. Too hard to save state. |
1519 | #ifndef QT_NO_COP | 1523 | #ifndef QT_NO_COP |
1520 | { | 1524 | { |
1521 | QCopEnvelope e( "QPE/System", "closing(QString)" ); | 1525 | QCopEnvelope e( "QPE/System", "closing(QString)" ); |
1522 | e << d->appName; | 1526 | e << d->appName; |
1523 | } | 1527 | } |
1524 | #endif | 1528 | #endif |
1525 | processEvents(); | 1529 | processEvents(); |
1526 | 1530 | ||
1527 | quit(); | 1531 | quit(); |
1528 | } | 1532 | } |
1529 | 1533 | ||
1530 | /*! | 1534 | /*! |
1531 | \internal | 1535 | \internal |
1532 | User initiated quit. Makes the window 'Go Away'. If preloaded this means | 1536 | User initiated quit. Makes the window 'Go Away'. If preloaded this means |
1533 | hiding the window. If not it means quitting the application. | 1537 | hiding the window. If not it means quitting the application. |
1534 | As this is user initiated we don't need to check state. | 1538 | As this is user initiated we don't need to check state. |
1535 | */ | 1539 | */ |
1536 | void QPEApplication::hideOrQuit() | 1540 | void QPEApplication::hideOrQuit() |
1537 | { | 1541 | { |
1538 | processEvents(); | 1542 | processEvents(); |
1539 | 1543 | ||
1540 | // If we are a preloaded application we don't actually quit, so emit | 1544 | // If we are a preloaded application we don't actually quit, so emit |
1541 | // a System message indicating we're quasi-closing. | 1545 | // a System message indicating we're quasi-closing. |
1542 | if ( d->preloaded && d->qpe_main_widget ) | 1546 | if ( d->preloaded && d->qpe_main_widget ) |
1543 | #ifndef QT_NO_COP | 1547 | #ifndef QT_NO_COP |
1544 | { | 1548 | { |
1545 | QCopEnvelope e("QPE/System", "fastAppHiding(QString)" ); | 1549 | QCopEnvelope e("QPE/System", "fastAppHiding(QString)" ); |
1546 | e << d->appName; | 1550 | e << d->appName; |
1547 | d->qpe_main_widget->hide(); | 1551 | d->qpe_main_widget->hide(); |
1548 | } | 1552 | } |
1549 | #endif | 1553 | #endif |
1550 | else | 1554 | else |
1551 | quit(); | 1555 | quit(); |
1552 | } | 1556 | } |
1553 | 1557 | ||
1554 | #if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) | 1558 | #if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) |
1555 | 1559 | ||
1556 | // The libraries with the skiff package (and possibly others) have | 1560 | // The libraries with the skiff package (and possibly others) have |
1557 | // completely useless implementations of builtin new and delete that | 1561 | // completely useless implementations of builtin new and delete that |
1558 | // use about 50% of your CPU. Here we revert to the simple libc | 1562 | // use about 50% of your CPU. Here we revert to the simple libc |
1559 | // functions. | 1563 | // functions. |
1560 | 1564 | ||
1561 | void* operator new[]( size_t size ) | 1565 | void* operator new[]( size_t size ) |
1562 | { | 1566 | { |
1563 | return malloc( size ); | 1567 | return malloc( size ); |
1564 | } | 1568 | } |
1565 | 1569 | ||
1566 | void* operator new( size_t size ) | 1570 | void* operator new( size_t size ) |
1567 | { | 1571 | { |
1568 | return malloc( size ); | 1572 | return malloc( size ); |
1569 | } | 1573 | } |
1570 | 1574 | ||
1571 | void operator delete[]( void* p ) | 1575 | void operator delete[]( void* p ) |
1572 | { | 1576 | { |
1573 | free( p ); | 1577 | free( p ); |
1574 | } | 1578 | } |
1575 | 1579 | ||
1576 | void operator delete[]( void* p, size_t /*size*/ ) | 1580 | void operator delete[]( void* p, size_t /*size*/ ) |
1577 | { | 1581 | { |
1578 | free( p ); | 1582 | free( p ); |
1579 | } | 1583 | } |
1580 | 1584 | ||
1581 | void operator delete( void* p ) | 1585 | void operator delete( void* p ) |
1582 | { | 1586 | { |
1583 | free( p ); | 1587 | free( p ); |
1584 | } | 1588 | } |
1585 | 1589 | ||
1586 | void operator delete( void* p, size_t /*size*/ ) | 1590 | void operator delete( void* p, size_t /*size*/ ) |
1587 | { | 1591 | { |
1588 | free( p ); | 1592 | free( p ); |
1589 | } | 1593 | } |
1590 | 1594 | ||
1591 | #endif | 1595 | #endif |
1592 | 1596 | ||
1593 | #if ( QT_VERSION <= 230 ) && !defined(SINGLE_APP) | 1597 | #if ( QT_VERSION <= 230 ) && !defined(SINGLE_APP) |
1594 | #include <qwidgetlist.h> | 1598 | #include <qwidgetlist.h> |
1595 | #ifdef QWS | 1599 | #ifdef QWS |
1596 | #include <qgfx_qws.h> | 1600 | #include <qgfx_qws.h> |
1597 | extern QRect qt_maxWindowRect; | 1601 | extern QRect qt_maxWindowRect; |
1598 | void qt_setMaxWindowRect(const QRect& r ) | 1602 | void qt_setMaxWindowRect(const QRect& r ) |
1599 | { | 1603 | { |
1600 | qt_maxWindowRect = qt_screen->mapFromDevice( r, | 1604 | qt_maxWindowRect = qt_screen->mapFromDevice( r, |
1601 | qt_screen->mapToDevice( QSize( qt_screen->width(), qt_screen->height() ) ) ); | 1605 | qt_screen->mapToDevice( QSize( qt_screen->width(), qt_screen->height() ) ) ); |
1602 | // Re-resize any maximized windows | 1606 | // Re-resize any maximized windows |
1603 | QWidgetList* l = QApplication::topLevelWidgets(); | 1607 | QWidgetList* l = QApplication::topLevelWidgets(); |
1604 | if ( l ) { | 1608 | if ( l ) { |
1605 | QWidget * w = l->first(); | 1609 | QWidget * w = l->first(); |
1606 | while ( w ) { | 1610 | while ( w ) { |
1607 | if ( w->isVisible() && w->isMaximized() ) { | 1611 | if ( w->isVisible() && w->isMaximized() ) { |
1608 | w->showMaximized(); | 1612 | w->showMaximized(); |
1609 | } | 1613 | } |
1610 | w = l->next(); | 1614 | w = l->next(); |
1611 | } | 1615 | } |
1612 | delete l; | 1616 | delete l; |
1613 | } | 1617 | } |
1614 | } | 1618 | } |
1615 | #endif | 1619 | #endif |
1616 | #endif | 1620 | #endif |