-rw-r--r-- | library/qpeapplication.cpp | 61 |
1 files changed, 45 insertions, 16 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp index 76d62ef..6e2db7c 100644 --- a/library/qpeapplication.cpp +++ b/library/qpeapplication.cpp | |||
@@ -1,296 +1,298 @@ | |||
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 | 51 | ||
52 | 52 | ||
53 | //#include <linux/fb.h> better not rely on kernel headers in userspace ... | 53 | //#include <linux/fb.h> better not rely on kernel headers in userspace ... |
54 | 54 | ||
55 | /* VESA Blanking Levels */ | 55 | /* VESA Blanking Levels */ |
56 | #define VESA_NO_BLANKING 0 | 56 | #define VESA_NO_BLANKING 0 |
57 | #define VESA_VSYNC_SUSPEND 1 | 57 | #define VESA_VSYNC_SUSPEND 1 |
58 | #define VESA_HSYNC_SUSPEND 2 | 58 | #define VESA_HSYNC_SUSPEND 2 |
59 | #define VESA_POWERDOWN 3 | 59 | #define VESA_POWERDOWN 3 |
60 | 60 | ||
61 | #define FBIOBLANK 0x4611 | 61 | #define FBIOBLANK 0x4611 |
62 | 62 | ||
63 | 63 | ||
64 | #include <qsignal.h> | 64 | #include <qsignal.h> |
65 | #include "qpeapplication.h" | 65 | #include "qpeapplication.h" |
66 | #include "qpestyle.h" | 66 | #include "qpestyle.h" |
67 | #if QT_VERSION >= 300 | 67 | #if QT_VERSION >= 300 |
68 | #include <qstylefactory.h> | 68 | #include <qstylefactory.h> |
69 | #else | 69 | #else |
70 | #include <qplatinumstyle.h> | 70 | #include <qplatinumstyle.h> |
71 | #include <qwindowsstyle.h> | 71 | #include <qwindowsstyle.h> |
72 | #include <qmotifstyle.h> | 72 | #include <qmotifstyle.h> |
73 | #include <qmotifplusstyle.h> | 73 | #include <qmotifplusstyle.h> |
74 | #include "lightstyle.h" | 74 | #include "lightstyle.h" |
75 | |||
76 | #include <qpe/qlibrary.h> | ||
77 | #include <dlfcn.h> | ||
75 | #endif | 78 | #endif |
76 | #include "global.h" | 79 | #include "global.h" |
77 | #include "resource.h" | 80 | #include "resource.h" |
78 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) | 81 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) |
79 | #include "qutfcodec.h" | 82 | #include "qutfcodec.h" |
80 | #endif | 83 | #endif |
81 | #include "config.h" | 84 | #include "config.h" |
82 | #include "network.h" | 85 | #include "network.h" |
83 | #include "fontmanager.h" | 86 | #include "fontmanager.h" |
84 | #include "fontdatabase.h" | 87 | #include "fontdatabase.h" |
85 | 88 | ||
86 | #include "power.h" | 89 | #include "power.h" |
87 | #include "alarmserver.h" | 90 | #include "alarmserver.h" |
88 | #include "applnk.h" | 91 | #include "applnk.h" |
89 | #include "qpemenubar.h" | 92 | #include "qpemenubar.h" |
90 | 93 | ||
91 | #include <unistd.h> | 94 | #include <unistd.h> |
92 | #include <sys/file.h> | 95 | #include <sys/file.h> |
93 | #include <sys/ioctl.h> | 96 | #include <sys/ioctl.h> |
94 | #include <sys/soundcard.h> | 97 | #include <sys/soundcard.h> |
95 | 98 | ||
96 | // for setBacklight() | 99 | // for setBacklight() |
97 | #if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) | 100 | #if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) |
98 | #include <linux/fb.h> | 101 | #include <linux/fb.h> |
99 | #include <sys/types.h> | 102 | #include <sys/types.h> |
100 | #include <sys/stat.h> | 103 | #include <sys/stat.h> |
101 | #endif | 104 | #endif |
102 | #include <stdlib.h> | 105 | #include <stdlib.h> |
103 | 106 | ||
104 | #include <dlfcn.h> // for Liquid HACK | ||
105 | 107 | ||
106 | class QPEApplicationData { | 108 | class QPEApplicationData { |
107 | public: | 109 | public: |
108 | QPEApplicationData() : presstimer(0), presswidget(0), rightpressed(FALSE), | 110 | QPEApplicationData() : presstimer(0), presswidget(0), rightpressed(FALSE), |
109 | kbgrabber(0), kbregrab(FALSE), notbusysent(FALSE), preloaded(FALSE), | 111 | kbgrabber(0), kbregrab(FALSE), notbusysent(FALSE), preloaded(FALSE), |
110 | forceshow(FALSE), nomaximize(FALSE), qpe_main_widget(0), | 112 | forceshow(FALSE), nomaximize(FALSE), qpe_main_widget(0), |
111 | keep_running(TRUE) | 113 | keep_running(TRUE) |
112 | { | 114 | { |
113 | qcopq.setAutoDelete(TRUE); | 115 | qcopq.setAutoDelete(TRUE); |
114 | } | 116 | } |
115 | 117 | ||
116 | int presstimer; | 118 | int presstimer; |
117 | QWidget* presswidget; | 119 | QWidget* presswidget; |
118 | QPoint presspos; | 120 | QPoint presspos; |
119 | bool rightpressed; | 121 | bool rightpressed; |
120 | int kbgrabber; | 122 | int kbgrabber; |
121 | bool kbregrab; | 123 | bool kbregrab; |
122 | bool notbusysent; | 124 | bool notbusysent; |
123 | QString appName; | 125 | QString appName; |
124 | struct QCopRec { | 126 | struct QCopRec { |
125 | QCopRec(const QCString &ch, const QCString &msg, | 127 | QCopRec(const QCString &ch, const QCString &msg, |
126 | const QByteArray &d) : | 128 | const QByteArray &d) : |
127 | channel(ch), message(msg), data(d) { } | 129 | channel(ch), message(msg), data(d) { } |
128 | 130 | ||
129 | QCString channel; | 131 | QCString channel; |
130 | QCString message; | 132 | QCString message; |
131 | QByteArray data; | 133 | QByteArray data; |
132 | }; | 134 | }; |
133 | bool preloaded; | 135 | bool preloaded; |
134 | bool forceshow; | 136 | bool forceshow; |
135 | bool nomaximize; | 137 | bool nomaximize; |
136 | QWidget* qpe_main_widget; | 138 | QWidget* qpe_main_widget; |
137 | bool keep_running; | 139 | bool keep_running; |
138 | QList<QCopRec> qcopq; | 140 | QList<QCopRec> qcopq; |
139 | 141 | ||
140 | void enqueueQCop(const QCString &ch, const QCString &msg, | 142 | void enqueueQCop(const QCString &ch, const QCString &msg, |
141 | const QByteArray &data) | 143 | const QByteArray &data) |
142 | { | 144 | { |
143 | qcopq.append(new QCopRec(ch,msg,data)); | 145 | qcopq.append(new QCopRec(ch,msg,data)); |
144 | } | 146 | } |
145 | void sendQCopQ() | 147 | void sendQCopQ() |
146 | { | 148 | { |
147 | QCopRec* r; | 149 | QCopRec* r; |
148 | for (QListIterator<QCopRec> it(qcopq); (r=it.current()); ++it) | 150 | for (QListIterator<QCopRec> it(qcopq); (r=it.current()); ++it) |
149 | QCopChannel::sendLocally(r->channel,r->message,r->data); | 151 | QCopChannel::sendLocally(r->channel,r->message,r->data); |
150 | qcopq.clear(); | 152 | qcopq.clear(); |
151 | } | 153 | } |
152 | }; | 154 | }; |
153 | 155 | ||
154 | class ResourceMimeFactory : public QMimeSourceFactory { | 156 | class ResourceMimeFactory : public QMimeSourceFactory { |
155 | public: | 157 | public: |
156 | ResourceMimeFactory() | 158 | ResourceMimeFactory() |
157 | { | 159 | { |
158 | setFilePath( Global::helpPath() ); | 160 | setFilePath( Global::helpPath() ); |
159 | setExtensionType("html","text/html;charset=UTF-8"); | 161 | setExtensionType("html","text/html;charset=UTF-8"); |
160 | } | 162 | } |
161 | 163 | ||
162 | const QMimeSource* data(const QString& abs_name) const | 164 | const QMimeSource* data(const QString& abs_name) const |
163 | { | 165 | { |
164 | const QMimeSource* r = QMimeSourceFactory::data(abs_name); | 166 | const QMimeSource* r = QMimeSourceFactory::data(abs_name); |
165 | if ( !r ) { | 167 | if ( !r ) { |
166 | int sl = abs_name.length(); | 168 | int sl = abs_name.length(); |
167 | do { | 169 | do { |
168 | sl = abs_name.findRev('/',sl-1); | 170 | sl = abs_name.findRev('/',sl-1); |
169 | QString name = sl>=0 ? abs_name.mid(sl+1) : abs_name; | 171 | QString name = sl>=0 ? abs_name.mid(sl+1) : abs_name; |
170 | int dot = name.findRev('.'); | 172 | int dot = name.findRev('.'); |
171 | if ( dot >= 0 ) | 173 | if ( dot >= 0 ) |
172 | name = name.left(dot); | 174 | name = name.left(dot); |
173 | QImage img = Resource::loadImage(name); | 175 | QImage img = Resource::loadImage(name); |
174 | if ( !img.isNull() ) | 176 | if ( !img.isNull() ) |
175 | r = new QImageDrag(img); | 177 | r = new QImageDrag(img); |
176 | } while (!r && sl>0); | 178 | } while (!r && sl>0); |
177 | } | 179 | } |
178 | return r; | 180 | return r; |
179 | } | 181 | } |
180 | }; | 182 | }; |
181 | 183 | ||
182 | static int muted=0; | 184 | static int muted=0; |
183 | static int micMuted=0; | 185 | static int micMuted=0; |
184 | 186 | ||
185 | static void setVolume(int t=0, int percent=-1) | 187 | static void setVolume(int t=0, int percent=-1) |
186 | { | 188 | { |
187 | switch (t) { | 189 | switch (t) { |
188 | case 0: { | 190 | case 0: { |
189 | Config cfg("qpe"); | 191 | Config cfg("qpe"); |
190 | cfg.setGroup("Volume"); | 192 | cfg.setGroup("Volume"); |
191 | if ( percent < 0 ) | 193 | if ( percent < 0 ) |
192 | percent = cfg.readNumEntry("VolumePercent",50); | 194 | percent = cfg.readNumEntry("VolumePercent",50); |
193 | int fd = 0; | 195 | int fd = 0; |
194 | if ((fd = open("/dev/mixer", O_RDWR))>=0) { | 196 | if ((fd = open("/dev/mixer", O_RDWR))>=0) { |
195 | int vol = muted ? 0 : percent; | 197 | int vol = muted ? 0 : percent; |
196 | // set both channels to same volume | 198 | // set both channels to same volume |
197 | vol |= vol << 8; | 199 | vol |= vol << 8; |
198 | ioctl(fd, MIXER_WRITE(0), &vol); | 200 | ioctl(fd, MIXER_WRITE(0), &vol); |
199 | ::close(fd); | 201 | ::close(fd); |
200 | } | 202 | } |
201 | } break; | 203 | } break; |
202 | } | 204 | } |
203 | } | 205 | } |
204 | 206 | ||
205 | static void setMic(int t=0, int percent=-1) | 207 | static void setMic(int t=0, int percent=-1) |
206 | { | 208 | { |
207 | switch (t) { | 209 | switch (t) { |
208 | case 0: { | 210 | case 0: { |
209 | Config cfg("qpe"); | 211 | Config cfg("qpe"); |
210 | cfg.setGroup("Volume"); | 212 | cfg.setGroup("Volume"); |
211 | if ( percent < 0 ) | 213 | if ( percent < 0 ) |
212 | percent = cfg.readNumEntry("Mic",50); | 214 | percent = cfg.readNumEntry("Mic",50); |
213 | 215 | ||
214 | int fd = 0; | 216 | int fd = 0; |
215 | int mic = micMuted ? 0 : percent; | 217 | int mic = micMuted ? 0 : percent; |
216 | if ((fd = open("/dev/mixer", O_RDWR))>=0) { | 218 | if ((fd = open("/dev/mixer", O_RDWR))>=0) { |
217 | ioctl(fd, MIXER_WRITE(SOUND_MIXER_MIC), &mic); | 219 | ioctl(fd, MIXER_WRITE(SOUND_MIXER_MIC), &mic); |
218 | ::close(fd); | 220 | ::close(fd); |
219 | } | 221 | } |
220 | } break; | 222 | } break; |
221 | } | 223 | } |
222 | } | 224 | } |
223 | 225 | ||
224 | int qpe_sysBrightnessSteps() | 226 | int qpe_sysBrightnessSteps() |
225 | { | 227 | { |
226 | #if defined(QT_QWS_IPAQ) | 228 | #if defined(QT_QWS_IPAQ) |
227 | return 255; | 229 | return 255; |
228 | #elif defined(QT_QWS_EBX) | 230 | #elif defined(QT_QWS_EBX) |
229 | return 4; | 231 | return 4; |
230 | #else | 232 | #else |
231 | return 255; // ? | 233 | return 255; // ? |
232 | #endif | 234 | #endif |
233 | } | 235 | } |
234 | 236 | ||
235 | 237 | ||
236 | static int& hack(int& i) | 238 | static int& hack(int& i) |
237 | { | 239 | { |
238 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) | 240 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) |
239 | // These should be created, but aren't in Qt 2.3.0 | 241 | // These should be created, but aren't in Qt 2.3.0 |
240 | (void)new QUtf8Codec; | 242 | (void)new QUtf8Codec; |
241 | (void)new QUtf16Codec; | 243 | (void)new QUtf16Codec; |
242 | #endif | 244 | #endif |
243 | return i; | 245 | return i; |
244 | } | 246 | } |
245 | 247 | ||
246 | static bool forced_off = FALSE; | 248 | static bool forced_off = FALSE; |
247 | static int curbl=-1; | 249 | static int curbl=-1; |
248 | 250 | ||
249 | static int backlight() | 251 | static int backlight() |
250 | { | 252 | { |
251 | if ( curbl == -1 ) { | 253 | if ( curbl == -1 ) { |
252 | // Read from config | 254 | // Read from config |
253 | Config config( "qpe" ); | 255 | Config config( "qpe" ); |
254 | config.setGroup( "Screensaver" ); | 256 | config.setGroup( "Screensaver" ); |
255 | curbl = config.readNumEntry("Brightness",255); | 257 | curbl = config.readNumEntry("Brightness",255); |
256 | } | 258 | } |
257 | return curbl; | 259 | return curbl; |
258 | } | 260 | } |
259 | 261 | ||
260 | static void setBacklight(int bright) | 262 | static void setBacklight(int bright) |
261 | { | 263 | { |
262 | if ( bright == -3 ) { | 264 | if ( bright == -3 ) { |
263 | // Forced on | 265 | // Forced on |
264 | forced_off = FALSE; | 266 | forced_off = FALSE; |
265 | bright = -1; | 267 | bright = -1; |
266 | } | 268 | } |
267 | if ( forced_off && bright != -2 ) | 269 | if ( forced_off && bright != -2 ) |
268 | return; | 270 | return; |
269 | if ( bright == -2 ) { | 271 | if ( bright == -2 ) { |
270 | // Toggle between off and on | 272 | // Toggle between off and on |
271 | bright = curbl ? 0 : -1; | 273 | bright = curbl ? 0 : -1; |
272 | forced_off = !bright; | 274 | forced_off = !bright; |
273 | } | 275 | } |
274 | if ( bright == -1 ) { | 276 | if ( bright == -1 ) { |
275 | // Read from config | 277 | // Read from config |
276 | Config config( "qpe" ); | 278 | Config config( "qpe" ); |
277 | config.setGroup( "Screensaver" ); | 279 | config.setGroup( "Screensaver" ); |
278 | bright = config.readNumEntry("Brightness",255); | 280 | bright = config.readNumEntry("Brightness",255); |
279 | } | 281 | } |
280 | #if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) | 282 | #if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) |
281 | if ( QFile::exists("/usr/bin/bl") ) { | 283 | if ( QFile::exists("/usr/bin/bl") ) { |
282 | QString cmd = "/usr/bin/bl 1 "; | 284 | QString cmd = "/usr/bin/bl 1 "; |
283 | cmd += bright<=0 ? "0 " : "1 "; | 285 | cmd += bright<=0 ? "0 " : "1 "; |
284 | cmd += QString::number(bright); | 286 | cmd += QString::number(bright); |
285 | system(cmd.latin1()); | 287 | system(cmd.latin1()); |
286 | #if defined(QT_QWS_EBX) | 288 | #if defined(QT_QWS_EBX) |
287 | } else if ( QFile::exists("/dev/fl") ) { | 289 | } else if ( QFile::exists("/dev/fl") ) { |
288 | #define FL_IOCTL_STEP_CONTRAST 100 | 290 | #define FL_IOCTL_STEP_CONTRAST 100 |
289 | int fd = open("/dev/fl", O_WRONLY); | 291 | int fd = open("/dev/fl", O_WRONLY); |
290 | if (fd >= 0 ) { | 292 | if (fd >= 0 ) { |
291 | int steps = qpe_sysBrightnessSteps(); | 293 | int steps = qpe_sysBrightnessSteps(); |
292 | int bl = ( bright * steps + 127 ) / 255; | 294 | int bl = ( bright * steps + 127 ) / 255; |
293 | if ( bright && !bl ) bl = 1; | 295 | if ( bright && !bl ) bl = 1; |
294 | bl = ioctl(fd, FL_IOCTL_STEP_CONTRAST, bl); | 296 | bl = ioctl(fd, FL_IOCTL_STEP_CONTRAST, bl); |
295 | close(fd); | 297 | close(fd); |
296 | } | 298 | } |
@@ -1139,401 +1141,428 @@ void QPEApplication::pidMessage( const QCString &msg, const QByteArray & data) | |||
1139 | } else if ( msg == "raise()" ) { | 1141 | } else if ( msg == "raise()" ) { |
1140 | d->keep_running = TRUE; | 1142 | d->keep_running = TRUE; |
1141 | d->notbusysent = FALSE; | 1143 | d->notbusysent = FALSE; |
1142 | raiseAppropriateWindow(); | 1144 | raiseAppropriateWindow(); |
1143 | } else if ( msg == "flush()" ) { | 1145 | } else if ( msg == "flush()" ) { |
1144 | emit flush(); | 1146 | emit flush(); |
1145 | // we need to tell the desktop | 1147 | // we need to tell the desktop |
1146 | QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" ); | 1148 | QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" ); |
1147 | e << d->appName; | 1149 | e << d->appName; |
1148 | } else if ( msg == "reload()" ) { | 1150 | } else if ( msg == "reload()" ) { |
1149 | emit reload(); | 1151 | emit reload(); |
1150 | } else if ( msg == "setDocument(QString)" ) { | 1152 | } else if ( msg == "setDocument(QString)" ) { |
1151 | d->keep_running = TRUE; | 1153 | d->keep_running = TRUE; |
1152 | QDataStream stream( data, IO_ReadOnly ); | 1154 | QDataStream stream( data, IO_ReadOnly ); |
1153 | QString doc; | 1155 | QString doc; |
1154 | stream >> doc; | 1156 | stream >> doc; |
1155 | QWidget *mw = mainWidget(); | 1157 | QWidget *mw = mainWidget(); |
1156 | if ( !mw ) | 1158 | if ( !mw ) |
1157 | mw = d->qpe_main_widget; | 1159 | mw = d->qpe_main_widget; |
1158 | if ( mw ) | 1160 | if ( mw ) |
1159 | Global::setDocument( mw, doc ); | 1161 | Global::setDocument( mw, doc ); |
1160 | } else if ( msg == "nextView()" ) { | 1162 | } else if ( msg == "nextView()" ) { |
1161 | if ( raiseAppropriateWindow() ) | 1163 | if ( raiseAppropriateWindow() ) |
1162 | emit appMessage( msg, data); | 1164 | emit appMessage( msg, data); |
1163 | } else { | 1165 | } else { |
1164 | emit appMessage( msg, data); | 1166 | emit appMessage( msg, data); |
1165 | } | 1167 | } |
1166 | #endif | 1168 | #endif |
1167 | } | 1169 | } |
1168 | 1170 | ||
1169 | 1171 | ||
1170 | static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) | 1172 | static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) |
1171 | { | 1173 | { |
1172 | /* | 1174 | /* |
1173 | // This works but disable it for now until it is safe to apply | 1175 | // This works but disable it for now until it is safe to apply |
1174 | // What is does is scan the .desktop files of all the apps for | 1176 | // What is does is scan the .desktop files of all the apps for |
1175 | // the applnk that has the corresponding argv[0] as this program | 1177 | // the applnk that has the corresponding argv[0] as this program |
1176 | // then it uses the name stored in the .desktop file as the caption | 1178 | // then it uses the name stored in the .desktop file as the caption |
1177 | // for the main widget. This saves duplicating translations for | 1179 | // for the main widget. This saves duplicating translations for |
1178 | // the app name in the program and in the .desktop files. | 1180 | // the app name in the program and in the .desktop files. |
1179 | 1181 | ||
1180 | AppLnkSet apps( appsPath ); | 1182 | AppLnkSet apps( appsPath ); |
1181 | 1183 | ||
1182 | QList<AppLnk> appsList = apps.children(); | 1184 | QList<AppLnk> appsList = apps.children(); |
1183 | for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) { | 1185 | for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) { |
1184 | if ( (*it)->exec() == appName ) { | 1186 | if ( (*it)->exec() == appName ) { |
1185 | mw->setCaption( (*it)->name() ); | 1187 | mw->setCaption( (*it)->name() ); |
1186 | return TRUE; | 1188 | return TRUE; |
1187 | } | 1189 | } |
1188 | } | 1190 | } |
1189 | */ | 1191 | */ |
1190 | return FALSE; | 1192 | return FALSE; |
1191 | } | 1193 | } |
1192 | 1194 | ||
1193 | 1195 | ||
1194 | /*! | 1196 | /*! |
1195 | Sets \a mw as the mainWidget() and shows it. For small windows, | 1197 | Sets \a mw as the mainWidget() and shows it. For small windows, |
1196 | consider passing TRUE for \a nomaximize rather than the default FALSE. | 1198 | consider passing TRUE for \a nomaximize rather than the default FALSE. |
1197 | 1199 | ||
1198 | \sa showMainDocumentWidget() | 1200 | \sa showMainDocumentWidget() |
1199 | */ | 1201 | */ |
1200 | void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize ) | 1202 | void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize ) |
1201 | { | 1203 | { |
1202 | setWidgetCaptionFromAppName( mw, d->appName, qpeDir() + "apps" ); | 1204 | setWidgetCaptionFromAppName( mw, d->appName, qpeDir() + "apps" ); |
1203 | 1205 | ||
1204 | d->nomaximize = nomaximize; | 1206 | d->nomaximize = nomaximize; |
1205 | d->qpe_main_widget = mw; | 1207 | d->qpe_main_widget = mw; |
1206 | d->sendQCopQ(); | 1208 | d->sendQCopQ(); |
1207 | if ( d->preloaded ) { | 1209 | if ( d->preloaded ) { |
1208 | if(d->forceshow) { | 1210 | if(d->forceshow) { |
1209 | #ifdef Q_WS_QWS | 1211 | #ifdef Q_WS_QWS |
1210 | if ( !nomaximize ) | 1212 | if ( !nomaximize ) |
1211 | mw->showMaximized(); | 1213 | mw->showMaximized(); |
1212 | else | 1214 | else |
1213 | #endif | 1215 | #endif |
1214 | mw->show(); | 1216 | mw->show(); |
1215 | } | 1217 | } |
1216 | } else if ( d->keep_running ) { | 1218 | } else if ( d->keep_running ) { |
1217 | #ifdef Q_WS_QWS | 1219 | #ifdef Q_WS_QWS |
1218 | if ( !nomaximize ) | 1220 | if ( !nomaximize ) |
1219 | mw->showMaximized(); | 1221 | mw->showMaximized(); |
1220 | else | 1222 | else |
1221 | #endif | 1223 | #endif |
1222 | mw->show(); | 1224 | mw->show(); |
1223 | } | 1225 | } |
1224 | } | 1226 | } |
1225 | 1227 | ||
1226 | /*! | 1228 | /*! |
1227 | Sets \a mw as the mainWidget() and shows it. For small windows, | 1229 | Sets \a mw as the mainWidget() and shows it. For small windows, |
1228 | consider passing TRUE for \a nomaximize rather than the default FALSE. | 1230 | consider passing TRUE for \a nomaximize rather than the default FALSE. |
1229 | 1231 | ||
1230 | This calls designates the application as | 1232 | This calls designates the application as |
1231 | a \link docwidget.html document-oriented\endlink application. | 1233 | a \link docwidget.html document-oriented\endlink application. |
1232 | 1234 | ||
1233 | The \a mw widget must have a slot: setDocument(const QString&). | 1235 | The \a mw widget must have a slot: setDocument(const QString&). |
1234 | 1236 | ||
1235 | \sa showMainWidget() | 1237 | \sa showMainWidget() |
1236 | */ | 1238 | */ |
1237 | void QPEApplication::showMainDocumentWidget( QWidget* mw, bool nomaximize ) | 1239 | void QPEApplication::showMainDocumentWidget( QWidget* mw, bool nomaximize ) |
1238 | { | 1240 | { |
1239 | setWidgetCaptionFromAppName( mw, d->appName, qpeDir() + "apps" ); | 1241 | setWidgetCaptionFromAppName( mw, d->appName, qpeDir() + "apps" ); |
1240 | 1242 | ||
1241 | if ( mw && argc() == 2 ) | 1243 | if ( mw && argc() == 2 ) |
1242 | Global::setDocument( mw, QString::fromUtf8(argv()[1]) ); | 1244 | Global::setDocument( mw, QString::fromUtf8(argv()[1]) ); |
1243 | d->nomaximize = nomaximize; | 1245 | d->nomaximize = nomaximize; |
1244 | d->qpe_main_widget = mw; | 1246 | d->qpe_main_widget = mw; |
1245 | d->sendQCopQ(); | 1247 | d->sendQCopQ(); |
1246 | if ( d->preloaded ) { | 1248 | if ( d->preloaded ) { |
1247 | if(d->forceshow) { | 1249 | if(d->forceshow) { |
1248 | #ifdef Q_WS_QWS | 1250 | #ifdef Q_WS_QWS |
1249 | if ( !nomaximize ) | 1251 | if ( !nomaximize ) |
1250 | mw->showMaximized(); | 1252 | mw->showMaximized(); |
1251 | else | 1253 | else |
1252 | #endif | 1254 | #endif |
1253 | mw->show(); | 1255 | mw->show(); |
1254 | } | 1256 | } |
1255 | } else if ( d->keep_running ) { | 1257 | } else if ( d->keep_running ) { |
1256 | #ifdef Q_WS_QWS | 1258 | #ifdef Q_WS_QWS |
1257 | if ( !nomaximize ) | 1259 | if ( !nomaximize ) |
1258 | mw->showMaximized(); | 1260 | mw->showMaximized(); |
1259 | else | 1261 | else |
1260 | #endif | 1262 | #endif |
1261 | mw->show(); | 1263 | mw->show(); |
1262 | } | 1264 | } |
1263 | } | 1265 | } |
1264 | 1266 | ||
1265 | 1267 | ||
1266 | /*! | 1268 | /*! |
1267 | Sets that the application should continue running after processing | 1269 | Sets that the application should continue running after processing |
1268 | qcop messages. Normally if an application is started via a qcop message, | 1270 | qcop messages. Normally if an application is started via a qcop message, |
1269 | the application will process the qcop message and then quit. If while | 1271 | the application will process the qcop message and then quit. If while |
1270 | processing the qcop message it calls this function, then the application | 1272 | processing the qcop message it calls this function, then the application |
1271 | will show and start proper once it has finished processing qcop messages. | 1273 | will show and start proper once it has finished processing qcop messages. |
1272 | 1274 | ||
1273 | \sa keepRunning() | 1275 | \sa keepRunning() |
1274 | */ | 1276 | */ |
1275 | void QPEApplication::setKeepRunning() | 1277 | void QPEApplication::setKeepRunning() |
1276 | { | 1278 | { |
1277 | if ( qApp && qApp->inherits( "QPEApplication" ) ) { | 1279 | if ( qApp && qApp->inherits( "QPEApplication" ) ) { |
1278 | QPEApplication *qpeApp = (QPEApplication*)qApp; | 1280 | QPEApplication *qpeApp = (QPEApplication*)qApp; |
1279 | qpeApp->d->keep_running = TRUE; | 1281 | qpeApp->d->keep_running = TRUE; |
1280 | } | 1282 | } |
1281 | } | 1283 | } |
1282 | 1284 | ||
1283 | /*! | 1285 | /*! |
1284 | Returns whether the application will quit after processing the current | 1286 | Returns whether the application will quit after processing the current |
1285 | list of qcop messages. | 1287 | list of qcop messages. |
1286 | 1288 | ||
1287 | \sa setKeepRunning() | 1289 | \sa setKeepRunning() |
1288 | */ | 1290 | */ |
1289 | bool QPEApplication::keepRunning() const | 1291 | bool QPEApplication::keepRunning() const |
1290 | { | 1292 | { |
1291 | return d->keep_running; | 1293 | return d->keep_running; |
1292 | } | 1294 | } |
1293 | 1295 | ||
1294 | /*! | 1296 | /*! |
1295 | \internal | 1297 | \internal |
1296 | */ | 1298 | */ |
1297 | void QPEApplication::internalSetStyle( const QString &style ) | 1299 | void QPEApplication::internalSetStyle( const QString &style ) |
1298 | { | 1300 | { |
1299 | #if QT_VERSION >= 300 | 1301 | #if QT_VERSION >= 300 |
1300 | if ( style == "QPE" ) { | 1302 | if ( style == "QPE" ) { |
1301 | setStyle( new QPEStyle ); | 1303 | setStyle( new QPEStyle ); |
1302 | } else { | 1304 | } else { |
1303 | QStyle *s = QStyleFactory::create(style); | 1305 | QStyle *s = QStyleFactory::create(style); |
1304 | if ( s ) setStyle(s); | 1306 | if ( s ) setStyle(s); |
1305 | } | 1307 | } |
1306 | #else | 1308 | #else |
1307 | if ( style == "Windows" ) { | 1309 | if ( style == "Windows" ) { |
1308 | setStyle( new QWindowsStyle ); | 1310 | setStyle( new QWindowsStyle ); |
1309 | } else if ( style == "QPE" ) { | 1311 | } else if ( style == "QPE" ) { |
1310 | setStyle( new QPEStyle ); | 1312 | setStyle( new QPEStyle ); |
1311 | } else if ( style == "Light" ) { | 1313 | } else if ( style == "Light" ) { |
1312 | setStyle( new LightStyle ); | 1314 | setStyle( new LightStyle ); |
1313 | } | 1315 | } |
1314 | #ifndef QT_NO_STYLE_PLATINUM | 1316 | #ifndef QT_NO_STYLE_PLATINUM |
1315 | else if ( style == "Platinum" ) { | 1317 | else if ( style == "Platinum" ) { |
1316 | setStyle( new QPlatinumStyle ); | 1318 | setStyle( new QPlatinumStyle ); |
1317 | } | 1319 | } |
1318 | #endif | 1320 | #endif |
1319 | #ifndef QT_NO_STYLE_MOTIF | 1321 | #ifndef QT_NO_STYLE_MOTIF |
1320 | else if ( style == "Motif" ) { | 1322 | else if ( style == "Motif" ) { |
1321 | setStyle( new QMotifStyle ); | 1323 | setStyle( new QMotifStyle ); |
1322 | } | 1324 | } |
1323 | #endif | 1325 | #endif |
1324 | #ifndef QT_NO_STYLE_MOTIFPLUS | 1326 | #ifndef QT_NO_STYLE_MOTIFPLUS |
1325 | else if ( style == "MotifPlus" ) { | 1327 | else if ( style == "MotifPlus" ) { |
1326 | setStyle( new QMotifPlusStyle ); | 1328 | setStyle( new QMotifPlusStyle ); |
1327 | } | 1329 | } |
1328 | #endif | 1330 | #endif |
1329 | 1331 | ||
1330 | // HACK for Qt2 only | 1332 | // HACK for Qt2 only |
1331 | else if ( style == "Liquid" ) { | 1333 | else { |
1332 | static void *lib = 0; | 1334 | // style == "Liquid Style (libliquid.so)" (or "Windows XP (libxp.so)" |
1333 | QStyle *sty = 0; | 1335 | |
1336 | int p2 = style. findRev ( ']' ); | ||
1337 | int p1 = style. findRev ( '[' ); | ||
1338 | QString style2; | ||
1334 | 1339 | ||
1335 | 1340 | if (( p1 > 0 ) && ( p2 > 0 ) && (( p1 + 1 ) < p2 )) | |
1336 | if ( !lib ) { | 1341 | style2 = "lib" + style. mid ( p1 + 1, p2 - p1 - 1 ). lower ( ) + ".so"; |
1337 | QString path = QPEApplication::qpeDir() + "/plugins/styles/" + "libliquid.so"; | 1342 | else |
1338 | lib = ::dlopen ( path. local8Bit ( ), RTLD_NOW | RTLD_GLOBAL ); | 1343 | style2 = "lib" + style. lower ( ) + ".so"; |
1339 | } | ||
1340 | if ( lib ) { | ||
1341 | void *sym = ::dlsym ( lib, "allocate" ); | ||
1342 | 1344 | ||
1343 | if ( sym ) | 1345 | // static QLibrary *currentlib = 0; |
1344 | sty = ((QStyle * (*) ( )) sym ) ( ); | 1346 | static void *currentlib = 0; |
1345 | } | 1347 | |
1346 | if ( sty ) | 1348 | QString path = QPEApplication::qpeDir ( ) + "/plugins/styles/" + style2; |
1347 | setStyle ( sty ); | 1349 | |
1350 | do { // try/catch simulation | ||
1351 | // QLibrary *lib = new QLibrary ( path, QLibrary::Immediately ); | ||
1352 | void *lib = ::dlopen ( path. local8Bit ( ), RTLD_NOW | RTLD_GLOBAL ); | ||
1353 | |||
1354 | if ( lib ) { | ||
1355 | //QStyle * (*fpa) ( ) = (QStyle * (*) ( )) lib-> resolve ( "allocate" ); | ||
1356 | QStyle * (*fpa) ( ) = (QStyle * (*) ( )) ::dlsym ( lib, "allocate" ); | ||
1357 | |||
1358 | if ( fpa ) { | ||
1359 | QStyle *sty = ( *fpa ) ( ); | ||
1360 | |||
1361 | if ( sty ) { | ||
1362 | setStyle ( sty ); | ||
1363 | |||
1364 | if ( currentlib ) { | ||
1365 | //delete currentlib; | ||
1366 | ::dlclose ( currentlib ); | ||
1367 | } | ||
1368 | currentlib = lib; | ||
1369 | |||
1370 | break; | ||
1371 | } | ||
1372 | } | ||
1373 | //delete lib; | ||
1374 | ::dlclose ( lib ); | ||
1375 | } | ||
1376 | } while ( false ); | ||
1348 | } | 1377 | } |
1349 | // HACK for Qt2 only | 1378 | // HACK for Qt2 only |
1350 | #endif | 1379 | #endif |
1351 | } | 1380 | } |
1352 | 1381 | ||
1353 | /*! | 1382 | /*! |
1354 | \internal | 1383 | \internal |
1355 | */ | 1384 | */ |
1356 | void QPEApplication::prepareForTermination(bool willrestart) | 1385 | void QPEApplication::prepareForTermination(bool willrestart) |
1357 | { | 1386 | { |
1358 | if ( willrestart ) { | 1387 | if ( willrestart ) { |
1359 | // Draw a big wait icon, the image can be altered in later revisions | 1388 | // Draw a big wait icon, the image can be altered in later revisions |
1360 | // QWidget *d = QApplication::desktop(); | 1389 | // QWidget *d = QApplication::desktop(); |
1361 | QImage img = Resource::loadImage( "launcher/new_wait" ); | 1390 | QImage img = Resource::loadImage( "launcher/new_wait" ); |
1362 | QPixmap pix; | 1391 | QPixmap pix; |
1363 | pix.convertFromImage(img.smoothScale(1*img.width(), 1*img.height())); | 1392 | pix.convertFromImage(img.smoothScale(1*img.width(), 1*img.height())); |
1364 | QLabel *lblWait = new QLabel(0, "wait hack!", QWidget::WStyle_Customize | | 1393 | QLabel *lblWait = new QLabel(0, "wait hack!", QWidget::WStyle_Customize | |
1365 | QWidget::WStyle_NoBorder | QWidget::WStyle_Tool ); | 1394 | QWidget::WStyle_NoBorder | QWidget::WStyle_Tool ); |
1366 | lblWait->setPixmap( pix ); | 1395 | lblWait->setPixmap( pix ); |
1367 | lblWait->setAlignment( QWidget::AlignCenter ); | 1396 | lblWait->setAlignment( QWidget::AlignCenter ); |
1368 | lblWait->show(); | 1397 | lblWait->show(); |
1369 | lblWait->showMaximized(); | 1398 | lblWait->showMaximized(); |
1370 | } | 1399 | } |
1371 | #ifndef SINGLE_APP | 1400 | #ifndef SINGLE_APP |
1372 | { QCopEnvelope envelope("QPE/System", "forceQuit()"); } | 1401 | { QCopEnvelope envelope("QPE/System", "forceQuit()"); } |
1373 | processEvents(); // ensure the message goes out. | 1402 | processEvents(); // ensure the message goes out. |
1374 | sleep(1); // You have 1 second to comply. | 1403 | sleep(1); // You have 1 second to comply. |
1375 | #endif | 1404 | #endif |
1376 | } | 1405 | } |
1377 | 1406 | ||
1378 | /*! | 1407 | /*! |
1379 | \internal | 1408 | \internal |
1380 | */ | 1409 | */ |
1381 | void QPEApplication::shutdown() | 1410 | void QPEApplication::shutdown() |
1382 | { | 1411 | { |
1383 | // Implement in server's QPEApplication subclass | 1412 | // Implement in server's QPEApplication subclass |
1384 | } | 1413 | } |
1385 | 1414 | ||
1386 | /*! | 1415 | /*! |
1387 | \internal | 1416 | \internal |
1388 | */ | 1417 | */ |
1389 | void QPEApplication::restart() | 1418 | void QPEApplication::restart() |
1390 | { | 1419 | { |
1391 | // Implement in server's QPEApplication subclass | 1420 | // Implement in server's QPEApplication subclass |
1392 | } | 1421 | } |
1393 | 1422 | ||
1394 | static QPtrDict<void>* stylusDict=0; | 1423 | static QPtrDict<void>* stylusDict=0; |
1395 | static void createDict() | 1424 | static void createDict() |
1396 | { | 1425 | { |
1397 | if ( !stylusDict ) | 1426 | if ( !stylusDict ) |
1398 | stylusDict = new QPtrDict<void>; | 1427 | stylusDict = new QPtrDict<void>; |
1399 | } | 1428 | } |
1400 | 1429 | ||
1401 | /*! | 1430 | /*! |
1402 | Returns the current StylusMode for \a w. | 1431 | Returns the current StylusMode for \a w. |
1403 | 1432 | ||
1404 | \sa setStylusOperation() | 1433 | \sa setStylusOperation() |
1405 | */ | 1434 | */ |
1406 | QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w ) | 1435 | QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w ) |
1407 | { | 1436 | { |
1408 | if ( stylusDict ) | 1437 | if ( stylusDict ) |
1409 | return (StylusMode)(int)stylusDict->find(w); | 1438 | return (StylusMode)(int)stylusDict->find(w); |
1410 | return LeftOnly; | 1439 | return LeftOnly; |
1411 | } | 1440 | } |
1412 | 1441 | ||
1413 | /*! | 1442 | /*! |
1414 | \enum QPEApplication::StylusMode | 1443 | \enum QPEApplication::StylusMode |
1415 | 1444 | ||
1416 | \value LeftOnly the stylus only generates LeftButton | 1445 | \value LeftOnly the stylus only generates LeftButton |
1417 | events (the default). | 1446 | events (the default). |
1418 | \value RightOnHold the stylus generates RightButton events | 1447 | \value RightOnHold the stylus generates RightButton events |
1419 | if the user uses the press-and-hold gesture. | 1448 | if the user uses the press-and-hold gesture. |
1420 | 1449 | ||
1421 | See setStylusOperation(). | 1450 | See setStylusOperation(). |
1422 | */ | 1451 | */ |
1423 | 1452 | ||
1424 | /*! | 1453 | /*! |
1425 | Causes \a w to receive mouse events according to \a mode. | 1454 | Causes \a w to receive mouse events according to \a mode. |
1426 | 1455 | ||
1427 | \sa stylusOperation() | 1456 | \sa stylusOperation() |
1428 | */ | 1457 | */ |
1429 | void QPEApplication::setStylusOperation( QWidget* w, StylusMode mode ) | 1458 | void QPEApplication::setStylusOperation( QWidget* w, StylusMode mode ) |
1430 | { | 1459 | { |
1431 | createDict(); | 1460 | createDict(); |
1432 | if ( mode == LeftOnly ) { | 1461 | if ( mode == LeftOnly ) { |
1433 | stylusDict->remove(w); | 1462 | stylusDict->remove(w); |
1434 | w->removeEventFilter(qApp); | 1463 | w->removeEventFilter(qApp); |
1435 | } else { | 1464 | } else { |
1436 | stylusDict->insert(w,(void*)mode); | 1465 | stylusDict->insert(w,(void*)mode); |
1437 | connect(w,SIGNAL(destroyed()),qApp,SLOT(removeSenderFromStylusDict())); | 1466 | connect(w,SIGNAL(destroyed()),qApp,SLOT(removeSenderFromStylusDict())); |
1438 | w->installEventFilter(qApp); | 1467 | w->installEventFilter(qApp); |
1439 | } | 1468 | } |
1440 | } | 1469 | } |
1441 | 1470 | ||
1442 | 1471 | ||
1443 | /*! | 1472 | /*! |
1444 | \reimp | 1473 | \reimp |
1445 | */ | 1474 | */ |
1446 | bool QPEApplication::eventFilter( QObject *o, QEvent *e ) | 1475 | bool QPEApplication::eventFilter( QObject *o, QEvent *e ) |
1447 | { | 1476 | { |
1448 | if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) { | 1477 | if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) { |
1449 | QMouseEvent* me = (QMouseEvent*)e; | 1478 | QMouseEvent* me = (QMouseEvent*)e; |
1450 | if ( me->button() == LeftButton ) { | 1479 | if ( me->button() == LeftButton ) { |
1451 | StylusMode mode = (StylusMode)(int)stylusDict->find(o); | 1480 | StylusMode mode = (StylusMode)(int)stylusDict->find(o); |
1452 | switch (mode) { | 1481 | switch (mode) { |
1453 | case RightOnHold: | 1482 | case RightOnHold: |
1454 | switch ( me->type() ) { | 1483 | switch ( me->type() ) { |
1455 | case QEvent::MouseButtonPress: | 1484 | case QEvent::MouseButtonPress: |
1456 | d->presstimer = startTimer(500); // #### pref. | 1485 | d->presstimer = startTimer(500); // #### pref. |
1457 | d->presswidget = (QWidget*)o; | 1486 | d->presswidget = (QWidget*)o; |
1458 | d->presspos = me->pos(); | 1487 | d->presspos = me->pos(); |
1459 | d->rightpressed = FALSE; | 1488 | d->rightpressed = FALSE; |
1460 | break; | 1489 | break; |
1461 | case QEvent::MouseButtonRelease: | 1490 | case QEvent::MouseButtonRelease: |
1462 | if ( d->presstimer ) { | 1491 | if ( d->presstimer ) { |
1463 | killTimer(d->presstimer); | 1492 | killTimer(d->presstimer); |
1464 | d->presstimer = 0; | 1493 | d->presstimer = 0; |
1465 | } | 1494 | } |
1466 | if ( d->rightpressed && d->presswidget ) { | 1495 | if ( d->rightpressed && d->presswidget ) { |
1467 | // Right released | 1496 | // Right released |
1468 | postEvent( d->presswidget, | 1497 | postEvent( d->presswidget, |
1469 | new QMouseEvent( QEvent::MouseButtonRelease, me->pos(), | 1498 | new QMouseEvent( QEvent::MouseButtonRelease, me->pos(), |
1470 | RightButton, LeftButton+RightButton ) ); | 1499 | RightButton, LeftButton+RightButton ) ); |
1471 | // Left released, off-widget | 1500 | // Left released, off-widget |
1472 | postEvent( d->presswidget, | 1501 | postEvent( d->presswidget, |
1473 | new QMouseEvent( QEvent::MouseMove, QPoint(-1,-1), | 1502 | new QMouseEvent( QEvent::MouseMove, QPoint(-1,-1), |
1474 | LeftButton, LeftButton ) ); | 1503 | LeftButton, LeftButton ) ); |
1475 | postEvent( d->presswidget, | 1504 | postEvent( d->presswidget, |
1476 | new QMouseEvent( QEvent::MouseButtonRelease, QPoint(-1,-1), | 1505 | new QMouseEvent( QEvent::MouseButtonRelease, QPoint(-1,-1), |
1477 | LeftButton, LeftButton ) ); | 1506 | LeftButton, LeftButton ) ); |
1478 | d->rightpressed = FALSE; | 1507 | d->rightpressed = FALSE; |
1479 | return TRUE; // don't send the real Left release | 1508 | return TRUE; // don't send the real Left release |
1480 | } | 1509 | } |
1481 | break; | 1510 | break; |
1482 | default: | 1511 | default: |
1483 | break; | 1512 | break; |
1484 | } | 1513 | } |
1485 | break; | 1514 | break; |
1486 | default: | 1515 | default: |
1487 | ; | 1516 | ; |
1488 | } | 1517 | } |
1489 | } | 1518 | } |
1490 | } else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { | 1519 | } else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { |
1491 | QKeyEvent *ke = (QKeyEvent *)e; | 1520 | QKeyEvent *ke = (QKeyEvent *)e; |
1492 | if ( ke->key() == Key_Enter ) { | 1521 | if ( ke->key() == Key_Enter ) { |
1493 | if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) { | 1522 | if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) { |
1494 | postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ', | 1523 | postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ', |
1495 | ke->state(), " ", ke->isAutoRepeat(), ke->count() ) ); | 1524 | ke->state(), " ", ke->isAutoRepeat(), ke->count() ) ); |
1496 | return TRUE; | 1525 | return TRUE; |
1497 | } | 1526 | } |
1498 | } | 1527 | } |
1499 | } | 1528 | } |
1500 | 1529 | ||
1501 | return FALSE; | 1530 | return FALSE; |
1502 | } | 1531 | } |
1503 | 1532 | ||
1504 | /*! | 1533 | /*! |
1505 | \reimp | 1534 | \reimp |
1506 | */ | 1535 | */ |
1507 | void QPEApplication::timerEvent( QTimerEvent *e ) | 1536 | void QPEApplication::timerEvent( QTimerEvent *e ) |
1508 | { | 1537 | { |
1509 | if ( e->timerId() == d->presstimer && d->presswidget ) { | 1538 | if ( e->timerId() == d->presstimer && d->presswidget ) { |
1510 | // Right pressed | 1539 | // Right pressed |
1511 | postEvent( d->presswidget, | 1540 | postEvent( d->presswidget, |
1512 | new QMouseEvent( QEvent::MouseButtonPress, d->presspos, | 1541 | new QMouseEvent( QEvent::MouseButtonPress, d->presspos, |
1513 | RightButton, LeftButton ) ); | 1542 | RightButton, LeftButton ) ); |
1514 | killTimer( d->presstimer ); | 1543 | killTimer( d->presstimer ); |
1515 | d->presstimer = 0; | 1544 | d->presstimer = 0; |
1516 | d->rightpressed = TRUE; | 1545 | d->rightpressed = TRUE; |
1517 | } | 1546 | } |
1518 | } | 1547 | } |
1519 | 1548 | ||
1520 | void QPEApplication::removeSenderFromStylusDict() | 1549 | void QPEApplication::removeSenderFromStylusDict() |
1521 | { | 1550 | { |
1522 | stylusDict->remove((void*)sender()); | 1551 | stylusDict->remove((void*)sender()); |
1523 | if ( d->presswidget == sender() ) | 1552 | if ( d->presswidget == sender() ) |
1524 | d->presswidget = 0; | 1553 | d->presswidget = 0; |
1525 | } | 1554 | } |
1526 | 1555 | ||
1527 | /*! | 1556 | /*! |
1528 | \internal | 1557 | \internal |
1529 | */ | 1558 | */ |
1530 | bool QPEApplication::keyboardGrabbed() const | 1559 | bool QPEApplication::keyboardGrabbed() const |
1531 | { | 1560 | { |
1532 | return d->kbgrabber; | 1561 | return d->kbgrabber; |
1533 | } | 1562 | } |
1534 | 1563 | ||
1535 | 1564 | ||
1536 | /*! | 1565 | /*! |
1537 | Reverses the effect of grabKeyboard(). This is called automatically | 1566 | Reverses the effect of grabKeyboard(). This is called automatically |
1538 | on program exit. | 1567 | on program exit. |
1539 | */ | 1568 | */ |