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