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