-rw-r--r-- | library/qpeapplication.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp index f84bc0e..1534b0b 100644 --- a/library/qpeapplication.cpp +++ b/library/qpeapplication.cpp | |||
@@ -1,220 +1,221 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | ** $Id$ | 19 | ** $Id$ |
20 | ** | 20 | ** |
21 | **********************************************************************/ | 21 | **********************************************************************/ |
22 | #define QTOPIA_INTERNAL_LANGLIST | 22 | #define QTOPIA_INTERNAL_LANGLIST |
23 | #include <stdlib.h> | 23 | #include <stdlib.h> |
24 | #include <unistd.h> | 24 | #include <unistd.h> |
25 | #include <qfile.h> | 25 | #include <qfile.h> |
26 | #ifdef Q_WS_QWS | 26 | #ifdef Q_WS_QWS |
27 | #ifndef QT_NO_COP | 27 | #ifndef QT_NO_COP |
28 | #if QT_VERSION <= 231 | 28 | #if QT_VERSION <= 231 |
29 | #define private public | 29 | #define private public |
30 | #define sendLocally processEvent | 30 | #define sendLocally processEvent |
31 | #include "qcopenvelope_qws.h" | 31 | #include "qcopenvelope_qws.h" |
32 | #undef private | 32 | #undef private |
33 | #else | 33 | #else |
34 | #include "qcopenvelope_qws.h" | 34 | #include "qcopenvelope_qws.h" |
35 | #endif | 35 | #endif |
36 | #endif | 36 | #endif |
37 | #include <qwindowsystem_qws.h> | 37 | #include <qwindowsystem_qws.h> |
38 | #endif | 38 | #endif |
39 | #include <qtextstream.h> | 39 | #include <qtextstream.h> |
40 | #include <qpalette.h> | 40 | #include <qpalette.h> |
41 | #include <qbuffer.h> | 41 | #include <qbuffer.h> |
42 | #include <qptrdict.h> | 42 | #include <qptrdict.h> |
43 | #include <qregexp.h> | 43 | #include <qregexp.h> |
44 | #include <qdir.h> | 44 | #include <qdir.h> |
45 | #include <qlabel.h> | 45 | #include <qlabel.h> |
46 | #include <qdialog.h> | 46 | #include <qdialog.h> |
47 | #include <qdragobject.h> | 47 | #include <qdragobject.h> |
48 | #include <qevent.h> | 48 | #include <qevent.h> |
49 | #include <qtooltip.h> | 49 | #include <qtooltip.h> |
50 | #include <qsignal.h> | 50 | #include <qsignal.h> |
51 | #include <linux/fb.h> | 51 | #include <linux/fb.h> |
52 | 52 | ||
53 | #include <qsignal.h> | 53 | #include <qsignal.h> |
54 | #include "qpeapplication.h" | 54 | #include "qpeapplication.h" |
55 | #include "qpestyle.h" | 55 | #include "qpestyle.h" |
56 | #if QT_VERSION >= 300 | 56 | #if QT_VERSION >= 300 |
57 | #include <qstylefactory.h> | 57 | #include <qstylefactory.h> |
58 | #else | 58 | #else |
59 | #include <qplatinumstyle.h> | 59 | #include <qplatinumstyle.h> |
60 | #include <qwindowsstyle.h> | 60 | #include <qwindowsstyle.h> |
61 | #include <qmotifstyle.h> | 61 | #include <qmotifstyle.h> |
62 | #include <qmotifplusstyle.h> | 62 | #include <qmotifplusstyle.h> |
63 | #include "lightstyle.h" | 63 | #include "lightstyle.h" |
64 | #endif | 64 | #endif |
65 | #include "global.h" | 65 | #include "global.h" |
66 | #include "resource.h" | 66 | #include "resource.h" |
67 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) | 67 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) |
68 | #include "qutfcodec.h" | 68 | #include "qutfcodec.h" |
69 | #endif | 69 | #endif |
70 | #include "config.h" | 70 | #include "config.h" |
71 | #include "network.h" | 71 | #include "network.h" |
72 | #include "fontmanager.h" | 72 | #include "fontmanager.h" |
73 | #include "fontdatabase.h" | 73 | #include "fontdatabase.h" |
74 | 74 | ||
75 | #include "power.h" | 75 | #include "power.h" |
76 | #include "alarmserver.h" | 76 | #include "alarmserver.h" |
77 | #include "applnk.h" | 77 | #include "applnk.h" |
78 | #include "qpemenubar.h" | 78 | #include "qpemenubar.h" |
79 | 79 | ||
80 | #include <unistd.h> | 80 | #include <unistd.h> |
81 | #include <sys/file.h> | 81 | #include <sys/file.h> |
82 | #include <sys/ioctl.h> | 82 | #include <sys/ioctl.h> |
83 | #include <sys/soundcard.h> | 83 | #include <sys/soundcard.h> |
84 | 84 | ||
85 | // for setBacklight() | 85 | // for setBacklight() |
86 | #if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) | 86 | #if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) |
87 | #include <linux/fb.h> | 87 | #include <linux/fb.h> |
88 | #include <sys/types.h> | 88 | #include <sys/types.h> |
89 | #include <sys/stat.h> | 89 | #include <sys/stat.h> |
90 | #endif | 90 | #endif |
91 | #include <stdlib.h> | 91 | #include <stdlib.h> |
92 | 92 | ||
93 | #include <dlfcn.h> // for Liquid HACK | ||
93 | 94 | ||
94 | class QPEApplicationData { | 95 | class QPEApplicationData { |
95 | public: | 96 | public: |
96 | QPEApplicationData() : presstimer(0), presswidget(0), rightpressed(FALSE), | 97 | QPEApplicationData() : presstimer(0), presswidget(0), rightpressed(FALSE), |
97 | kbgrabber(0), kbregrab(FALSE), notbusysent(FALSE), preloaded(FALSE), | 98 | kbgrabber(0), kbregrab(FALSE), notbusysent(FALSE), preloaded(FALSE), |
98 | forceshow(FALSE), nomaximize(FALSE), qpe_main_widget(0), | 99 | forceshow(FALSE), nomaximize(FALSE), qpe_main_widget(0), |
99 | keep_running(TRUE) | 100 | keep_running(TRUE) |
100 | { | 101 | { |
101 | qcopq.setAutoDelete(TRUE); | 102 | qcopq.setAutoDelete(TRUE); |
102 | } | 103 | } |
103 | 104 | ||
104 | int presstimer; | 105 | int presstimer; |
105 | QWidget* presswidget; | 106 | QWidget* presswidget; |
106 | QPoint presspos; | 107 | QPoint presspos; |
107 | bool rightpressed; | 108 | bool rightpressed; |
108 | int kbgrabber; | 109 | int kbgrabber; |
109 | bool kbregrab; | 110 | bool kbregrab; |
110 | bool notbusysent; | 111 | bool notbusysent; |
111 | QString appName; | 112 | QString appName; |
112 | struct QCopRec { | 113 | struct QCopRec { |
113 | QCopRec(const QCString &ch, const QCString &msg, | 114 | QCopRec(const QCString &ch, const QCString &msg, |
114 | const QByteArray &d) : | 115 | const QByteArray &d) : |
115 | channel(ch), message(msg), data(d) { } | 116 | channel(ch), message(msg), data(d) { } |
116 | 117 | ||
117 | QCString channel; | 118 | QCString channel; |
118 | QCString message; | 119 | QCString message; |
119 | QByteArray data; | 120 | QByteArray data; |
120 | }; | 121 | }; |
121 | bool preloaded; | 122 | bool preloaded; |
122 | bool forceshow; | 123 | bool forceshow; |
123 | bool nomaximize; | 124 | bool nomaximize; |
124 | QWidget* qpe_main_widget; | 125 | QWidget* qpe_main_widget; |
125 | bool keep_running; | 126 | bool keep_running; |
126 | QList<QCopRec> qcopq; | 127 | QList<QCopRec> qcopq; |
127 | 128 | ||
128 | void enqueueQCop(const QCString &ch, const QCString &msg, | 129 | void enqueueQCop(const QCString &ch, const QCString &msg, |
129 | const QByteArray &data) | 130 | const QByteArray &data) |
130 | { | 131 | { |
131 | qcopq.append(new QCopRec(ch,msg,data)); | 132 | qcopq.append(new QCopRec(ch,msg,data)); |
132 | } | 133 | } |
133 | void sendQCopQ() | 134 | void sendQCopQ() |
134 | { | 135 | { |
135 | QCopRec* r; | 136 | QCopRec* r; |
136 | for (QListIterator<QCopRec> it(qcopq); (r=it.current()); ++it) | 137 | for (QListIterator<QCopRec> it(qcopq); (r=it.current()); ++it) |
137 | QCopChannel::sendLocally(r->channel,r->message,r->data); | 138 | QCopChannel::sendLocally(r->channel,r->message,r->data); |
138 | qcopq.clear(); | 139 | qcopq.clear(); |
139 | } | 140 | } |
140 | }; | 141 | }; |
141 | 142 | ||
142 | class ResourceMimeFactory : public QMimeSourceFactory { | 143 | class ResourceMimeFactory : public QMimeSourceFactory { |
143 | public: | 144 | public: |
144 | ResourceMimeFactory() | 145 | ResourceMimeFactory() |
145 | { | 146 | { |
146 | setFilePath( Global::helpPath() ); | 147 | setFilePath( Global::helpPath() ); |
147 | setExtensionType("html","text/html;charset=UTF-8"); | 148 | setExtensionType("html","text/html;charset=UTF-8"); |
148 | } | 149 | } |
149 | 150 | ||
150 | const QMimeSource* data(const QString& abs_name) const | 151 | const QMimeSource* data(const QString& abs_name) const |
151 | { | 152 | { |
152 | const QMimeSource* r = QMimeSourceFactory::data(abs_name); | 153 | const QMimeSource* r = QMimeSourceFactory::data(abs_name); |
153 | if ( !r ) { | 154 | if ( !r ) { |
154 | int sl = abs_name.length(); | 155 | int sl = abs_name.length(); |
155 | do { | 156 | do { |
156 | sl = abs_name.findRev('/',sl-1); | 157 | sl = abs_name.findRev('/',sl-1); |
157 | QString name = sl>=0 ? abs_name.mid(sl+1) : abs_name; | 158 | QString name = sl>=0 ? abs_name.mid(sl+1) : abs_name; |
158 | int dot = name.findRev('.'); | 159 | int dot = name.findRev('.'); |
159 | if ( dot >= 0 ) | 160 | if ( dot >= 0 ) |
160 | name = name.left(dot); | 161 | name = name.left(dot); |
161 | QImage img = Resource::loadImage(name); | 162 | QImage img = Resource::loadImage(name); |
162 | if ( !img.isNull() ) | 163 | if ( !img.isNull() ) |
163 | r = new QImageDrag(img); | 164 | r = new QImageDrag(img); |
164 | } while (!r && sl>0); | 165 | } while (!r && sl>0); |
165 | } | 166 | } |
166 | return r; | 167 | return r; |
167 | } | 168 | } |
168 | }; | 169 | }; |
169 | 170 | ||
170 | static int muted=0; | 171 | static int muted=0; |
171 | static int micMuted=0; | 172 | static int micMuted=0; |
172 | 173 | ||
173 | static void setVolume(int t=0, int percent=-1) | 174 | static void setVolume(int t=0, int percent=-1) |
174 | { | 175 | { |
175 | switch (t) { | 176 | switch (t) { |
176 | case 0: { | 177 | case 0: { |
177 | Config cfg("qpe"); | 178 | Config cfg("qpe"); |
178 | cfg.setGroup("Volume"); | 179 | cfg.setGroup("Volume"); |
179 | if ( percent < 0 ) | 180 | if ( percent < 0 ) |
180 | percent = cfg.readNumEntry("VolumePercent",50); | 181 | percent = cfg.readNumEntry("VolumePercent",50); |
181 | int fd = 0; | 182 | int fd = 0; |
182 | if ((fd = open("/dev/mixer", O_RDWR))>=0) { | 183 | if ((fd = open("/dev/mixer", O_RDWR))>=0) { |
183 | int vol = muted ? 0 : percent; | 184 | int vol = muted ? 0 : percent; |
184 | // set both channels to same volume | 185 | // set both channels to same volume |
185 | vol |= vol << 8; | 186 | vol |= vol << 8; |
186 | ioctl(fd, MIXER_WRITE(0), &vol); | 187 | ioctl(fd, MIXER_WRITE(0), &vol); |
187 | ::close(fd); | 188 | ::close(fd); |
188 | } | 189 | } |
189 | } break; | 190 | } break; |
190 | } | 191 | } |
191 | } | 192 | } |
192 | 193 | ||
193 | static void setMic(int t=0, int percent=-1) | 194 | static void setMic(int t=0, int percent=-1) |
194 | { | 195 | { |
195 | switch (t) { | 196 | switch (t) { |
196 | case 0: { | 197 | case 0: { |
197 | Config cfg("qpe"); | 198 | Config cfg("qpe"); |
198 | cfg.setGroup("Volume"); | 199 | cfg.setGroup("Volume"); |
199 | if ( percent < 0 ) | 200 | if ( percent < 0 ) |
200 | percent = cfg.readNumEntry("Mic",50); | 201 | percent = cfg.readNumEntry("Mic",50); |
201 | 202 | ||
202 | int fd = 0; | 203 | int fd = 0; |
203 | int mic = micMuted ? 0 : percent; | 204 | int mic = micMuted ? 0 : percent; |
204 | if ((fd = open("/dev/mixer", O_RDWR))>=0) { | 205 | if ((fd = open("/dev/mixer", O_RDWR))>=0) { |
205 | ioctl(fd, MIXER_WRITE(SOUND_MIXER_MIC), &mic); | 206 | ioctl(fd, MIXER_WRITE(SOUND_MIXER_MIC), &mic); |
206 | ::close(fd); | 207 | ::close(fd); |
207 | } | 208 | } |
208 | } break; | 209 | } break; |
209 | } | 210 | } |
210 | } | 211 | } |
211 | 212 | ||
212 | int qpe_sysBrightnessSteps() | 213 | int qpe_sysBrightnessSteps() |
213 | { | 214 | { |
214 | #if defined(QT_QWS_IPAQ) | 215 | #if defined(QT_QWS_IPAQ) |
215 | return 255; | 216 | return 255; |
216 | #elif defined(QT_QWS_EBX) | 217 | #elif defined(QT_QWS_EBX) |
217 | return 4; | 218 | return 4; |
218 | #else | 219 | #else |
219 | return 255; // ? | 220 | return 255; // ? |
220 | #endif | 221 | #endif |
@@ -1189,256 +1190,277 @@ void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize ) | |||
1189 | { | 1190 | { |
1190 | setWidgetCaptionFromAppName( mw, d->appName, qpeDir() + "apps" ); | 1191 | setWidgetCaptionFromAppName( mw, d->appName, qpeDir() + "apps" ); |
1191 | 1192 | ||
1192 | d->nomaximize = nomaximize; | 1193 | d->nomaximize = nomaximize; |
1193 | d->qpe_main_widget = mw; | 1194 | d->qpe_main_widget = mw; |
1194 | d->sendQCopQ(); | 1195 | d->sendQCopQ(); |
1195 | if ( d->preloaded ) { | 1196 | if ( d->preloaded ) { |
1196 | if(d->forceshow) { | 1197 | if(d->forceshow) { |
1197 | #ifdef Q_WS_QWS | 1198 | #ifdef Q_WS_QWS |
1198 | if ( !nomaximize ) | 1199 | if ( !nomaximize ) |
1199 | mw->showMaximized(); | 1200 | mw->showMaximized(); |
1200 | else | 1201 | else |
1201 | #endif | 1202 | #endif |
1202 | mw->show(); | 1203 | mw->show(); |
1203 | } | 1204 | } |
1204 | } else if ( d->keep_running ) { | 1205 | } else if ( d->keep_running ) { |
1205 | #ifdef Q_WS_QWS | 1206 | #ifdef Q_WS_QWS |
1206 | if ( !nomaximize ) | 1207 | if ( !nomaximize ) |
1207 | mw->showMaximized(); | 1208 | mw->showMaximized(); |
1208 | else | 1209 | else |
1209 | #endif | 1210 | #endif |
1210 | mw->show(); | 1211 | mw->show(); |
1211 | } | 1212 | } |
1212 | } | 1213 | } |
1213 | 1214 | ||
1214 | /*! | 1215 | /*! |
1215 | Sets \a mw as the mainWidget() and shows it. For small windows, | 1216 | Sets \a mw as the mainWidget() and shows it. For small windows, |
1216 | consider passing TRUE for \a nomaximize rather than the default FALSE. | 1217 | consider passing TRUE for \a nomaximize rather than the default FALSE. |
1217 | 1218 | ||
1218 | This calls designates the application as | 1219 | This calls designates the application as |
1219 | a \link docwidget.html document-oriented\endlink application. | 1220 | a \link docwidget.html document-oriented\endlink application. |
1220 | 1221 | ||
1221 | The \a mw widget must have a slot: setDocument(const QString&). | 1222 | The \a mw widget must have a slot: setDocument(const QString&). |
1222 | 1223 | ||
1223 | \sa showMainWidget() | 1224 | \sa showMainWidget() |
1224 | */ | 1225 | */ |
1225 | void QPEApplication::showMainDocumentWidget( QWidget* mw, bool nomaximize ) | 1226 | void QPEApplication::showMainDocumentWidget( QWidget* mw, bool nomaximize ) |
1226 | { | 1227 | { |
1227 | setWidgetCaptionFromAppName( mw, d->appName, qpeDir() + "apps" ); | 1228 | setWidgetCaptionFromAppName( mw, d->appName, qpeDir() + "apps" ); |
1228 | 1229 | ||
1229 | if ( mw && argc() == 2 ) | 1230 | if ( mw && argc() == 2 ) |
1230 | Global::setDocument( mw, QString::fromUtf8(argv()[1]) ); | 1231 | Global::setDocument( mw, QString::fromUtf8(argv()[1]) ); |
1231 | d->nomaximize = nomaximize; | 1232 | d->nomaximize = nomaximize; |
1232 | d->qpe_main_widget = mw; | 1233 | d->qpe_main_widget = mw; |
1233 | d->sendQCopQ(); | 1234 | d->sendQCopQ(); |
1234 | if ( d->preloaded ) { | 1235 | if ( d->preloaded ) { |
1235 | if(d->forceshow) { | 1236 | if(d->forceshow) { |
1236 | #ifdef Q_WS_QWS | 1237 | #ifdef Q_WS_QWS |
1237 | if ( !nomaximize ) | 1238 | if ( !nomaximize ) |
1238 | mw->showMaximized(); | 1239 | mw->showMaximized(); |
1239 | else | 1240 | else |
1240 | #endif | 1241 | #endif |
1241 | mw->show(); | 1242 | mw->show(); |
1242 | } | 1243 | } |
1243 | } else if ( d->keep_running ) { | 1244 | } else if ( d->keep_running ) { |
1244 | #ifdef Q_WS_QWS | 1245 | #ifdef Q_WS_QWS |
1245 | if ( !nomaximize ) | 1246 | if ( !nomaximize ) |
1246 | mw->showMaximized(); | 1247 | mw->showMaximized(); |
1247 | else | 1248 | else |
1248 | #endif | 1249 | #endif |
1249 | mw->show(); | 1250 | mw->show(); |
1250 | } | 1251 | } |
1251 | } | 1252 | } |
1252 | 1253 | ||
1253 | 1254 | ||
1254 | /*! | 1255 | /*! |
1255 | Sets that the application should continue running after processing | 1256 | Sets that the application should continue running after processing |
1256 | qcop messages. Normally if an application is started via a qcop message, | 1257 | qcop messages. Normally if an application is started via a qcop message, |
1257 | the application will process the qcop message and then quit. If while | 1258 | the application will process the qcop message and then quit. If while |
1258 | processing the qcop message it calls this function, then the application | 1259 | processing the qcop message it calls this function, then the application |
1259 | will show and start proper once it has finished processing qcop messages. | 1260 | will show and start proper once it has finished processing qcop messages. |
1260 | 1261 | ||
1261 | \sa keepRunning() | 1262 | \sa keepRunning() |
1262 | */ | 1263 | */ |
1263 | void QPEApplication::setKeepRunning() | 1264 | void QPEApplication::setKeepRunning() |
1264 | { | 1265 | { |
1265 | if ( qApp && qApp->inherits( "QPEApplication" ) ) { | 1266 | if ( qApp && qApp->inherits( "QPEApplication" ) ) { |
1266 | QPEApplication *qpeApp = (QPEApplication*)qApp; | 1267 | QPEApplication *qpeApp = (QPEApplication*)qApp; |
1267 | qpeApp->d->keep_running = TRUE; | 1268 | qpeApp->d->keep_running = TRUE; |
1268 | } | 1269 | } |
1269 | } | 1270 | } |
1270 | 1271 | ||
1271 | /*! | 1272 | /*! |
1272 | Returns whether the application will quit after processing the current | 1273 | Returns whether the application will quit after processing the current |
1273 | list of qcop messages. | 1274 | list of qcop messages. |
1274 | 1275 | ||
1275 | \sa setKeepRunning() | 1276 | \sa setKeepRunning() |
1276 | */ | 1277 | */ |
1277 | bool QPEApplication::keepRunning() const | 1278 | bool QPEApplication::keepRunning() const |
1278 | { | 1279 | { |
1279 | return d->keep_running; | 1280 | return d->keep_running; |
1280 | } | 1281 | } |
1281 | 1282 | ||
1282 | /*! | 1283 | /*! |
1283 | \internal | 1284 | \internal |
1284 | */ | 1285 | */ |
1285 | void QPEApplication::internalSetStyle( const QString &style ) | 1286 | void QPEApplication::internalSetStyle( const QString &style ) |
1286 | { | 1287 | { |
1287 | #if QT_VERSION >= 300 | 1288 | #if QT_VERSION >= 300 |
1288 | if ( style == "QPE" ) { | 1289 | if ( style == "QPE" ) { |
1289 | setStyle( new QPEStyle ); | 1290 | setStyle( new QPEStyle ); |
1290 | } else { | 1291 | } else { |
1291 | QStyle *s = QStyleFactory::create(style); | 1292 | QStyle *s = QStyleFactory::create(style); |
1292 | if ( s ) setStyle(s); | 1293 | if ( s ) setStyle(s); |
1293 | } | 1294 | } |
1294 | #else | 1295 | #else |
1295 | if ( style == "Windows" ) { | 1296 | if ( style == "Windows" ) { |
1296 | setStyle( new QWindowsStyle ); | 1297 | setStyle( new QWindowsStyle ); |
1297 | } else if ( style == "QPE" ) { | 1298 | } else if ( style == "QPE" ) { |
1298 | setStyle( new QPEStyle ); | 1299 | setStyle( new QPEStyle ); |
1299 | } else if ( style == "Light" ) { | 1300 | } else if ( style == "Light" ) { |
1300 | setStyle( new LightStyle ); | 1301 | setStyle( new LightStyle ); |
1301 | } | 1302 | } |
1302 | #ifndef QT_NO_STYLE_PLATINUM | 1303 | #ifndef QT_NO_STYLE_PLATINUM |
1303 | else if ( style == "Platinum" ) { | 1304 | else if ( style == "Platinum" ) { |
1304 | setStyle( new QPlatinumStyle ); | 1305 | setStyle( new QPlatinumStyle ); |
1305 | } | 1306 | } |
1306 | #endif | 1307 | #endif |
1307 | #ifndef QT_NO_STYLE_MOTIF | 1308 | #ifndef QT_NO_STYLE_MOTIF |
1308 | else if ( style == "Motif" ) { | 1309 | else if ( style == "Motif" ) { |
1309 | setStyle( new QMotifStyle ); | 1310 | setStyle( new QMotifStyle ); |
1310 | } | 1311 | } |
1311 | #endif | 1312 | #endif |
1312 | #ifndef QT_NO_STYLE_MOTIFPLUS | 1313 | #ifndef QT_NO_STYLE_MOTIFPLUS |
1313 | else if ( style == "MotifPlus" ) { | 1314 | else if ( style == "MotifPlus" ) { |
1314 | setStyle( new QMotifPlusStyle ); | 1315 | setStyle( new QMotifPlusStyle ); |
1315 | } | 1316 | } |
1316 | #endif | 1317 | #endif |
1318 | |||
1319 | // HACK for Qt2 only | ||
1320 | else if ( style == "Liquid" ) { | ||
1321 | static void *lib = 0; | ||
1322 | QStyle *sty = 0; | ||
1323 | |||
1324 | |||
1325 | if ( !lib ) { | ||
1326 | QString path = QPEApplication::qpeDir() + "/plugins/styles/" + "libliquid.so"; | ||
1327 | lib = ::dlopen ( path. local8Bit ( ), RTLD_NOW | RTLD_GLOBAL ); | ||
1328 | } | ||
1329 | if ( lib ) { | ||
1330 | void *sym = ::dlsym ( lib, "allocate" ); | ||
1331 | |||
1332 | if ( sym ) | ||
1333 | sty = ((QStyle * (*) ( )) sym ) ( ); | ||
1334 | } | ||
1335 | if ( sty ) | ||
1336 | setStyle ( sty ); | ||
1337 | } | ||
1338 | // HACK for Qt2 only | ||
1317 | #endif | 1339 | #endif |
1318 | } | 1340 | } |
1319 | 1341 | ||
1320 | /*! | 1342 | /*! |
1321 | \internal | 1343 | \internal |
1322 | */ | 1344 | */ |
1323 | void QPEApplication::prepareForTermination(bool willrestart) | 1345 | void QPEApplication::prepareForTermination(bool willrestart) |
1324 | { | 1346 | { |
1325 | if ( willrestart ) { | 1347 | if ( willrestart ) { |
1326 | // Draw a big wait icon, the image can be altered in later revisions | 1348 | // Draw a big wait icon, the image can be altered in later revisions |
1327 | // QWidget *d = QApplication::desktop(); | 1349 | // QWidget *d = QApplication::desktop(); |
1328 | QImage img = Resource::loadImage( "launcher/new_wait" ); | 1350 | QImage img = Resource::loadImage( "launcher/new_wait" ); |
1329 | QPixmap pix; | 1351 | QPixmap pix; |
1330 | pix.convertFromImage(img.smoothScale(1*img.width(), 1*img.height())); | 1352 | pix.convertFromImage(img.smoothScale(1*img.width(), 1*img.height())); |
1331 | QLabel *lblWait = new QLabel(0, "wait hack!", QWidget::WStyle_Customize | | 1353 | QLabel *lblWait = new QLabel(0, "wait hack!", QWidget::WStyle_Customize | |
1332 | QWidget::WStyle_NoBorder | QWidget::WStyle_Tool ); | 1354 | QWidget::WStyle_NoBorder | QWidget::WStyle_Tool ); |
1333 | lblWait->setPixmap( pix ); | 1355 | lblWait->setPixmap( pix ); |
1334 | lblWait->setAlignment( QWidget::AlignCenter ); | 1356 | lblWait->setAlignment( QWidget::AlignCenter ); |
1335 | lblWait->show(); | 1357 | lblWait->show(); |
1336 | lblWait->showMaximized(); | 1358 | lblWait->showMaximized(); |
1337 | } | 1359 | } |
1338 | #ifndef SINGLE_APP | 1360 | #ifndef SINGLE_APP |
1339 | { QCopEnvelope envelope("QPE/System", "forceQuit()"); } | 1361 | { QCopEnvelope envelope("QPE/System", "forceQuit()"); } |
1340 | processEvents(); // ensure the message goes out. | 1362 | processEvents(); // ensure the message goes out. |
1341 | sleep(1); // You have 1 second to comply. | 1363 | sleep(1); // You have 1 second to comply. |
1342 | #endif | 1364 | #endif |
1343 | } | 1365 | } |
1344 | 1366 | ||
1345 | /*! | 1367 | /*! |
1346 | \internal | 1368 | \internal |
1347 | */ | 1369 | */ |
1348 | void QPEApplication::shutdown() | 1370 | void QPEApplication::shutdown() |
1349 | { | 1371 | { |
1350 | // Implement in server's QPEApplication subclass | 1372 | // Implement in server's QPEApplication subclass |
1351 | } | 1373 | } |
1352 | 1374 | ||
1353 | /*! | 1375 | /*! |
1354 | \internal | 1376 | \internal |
1355 | */ | 1377 | */ |
1356 | void QPEApplication::restart() | 1378 | void QPEApplication::restart() |
1357 | { | 1379 | { |
1358 | // Implement in server's QPEApplication subclass | 1380 | // Implement in server's QPEApplication subclass |
1359 | } | 1381 | } |
1360 | 1382 | ||
1361 | static QPtrDict<void>* stylusDict=0; | 1383 | static QPtrDict<void>* stylusDict=0; |
1362 | static void createDict() | 1384 | static void createDict() |
1363 | { | 1385 | { |
1364 | if ( !stylusDict ) | 1386 | if ( !stylusDict ) |
1365 | stylusDict = new QPtrDict<void>; | 1387 | stylusDict = new QPtrDict<void>; |
1366 | } | 1388 | } |
1367 | 1389 | ||
1368 | /*! | 1390 | /*! |
1369 | Returns the current StylusMode for \a w. | 1391 | Returns the current StylusMode for \a w. |
1370 | 1392 | ||
1371 | \sa setStylusOperation() | 1393 | \sa setStylusOperation() |
1372 | */ | 1394 | */ |
1373 | QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w ) | 1395 | QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w ) |
1374 | { | 1396 | { |
1375 | if ( stylusDict ) | 1397 | if ( stylusDict ) |
1376 | return (StylusMode)(int)stylusDict->find(w); | 1398 | return (StylusMode)(int)stylusDict->find(w); |
1377 | return LeftOnly; | 1399 | return LeftOnly; |
1378 | } | 1400 | } |
1379 | 1401 | ||
1380 | /*! | 1402 | /*! |
1381 | \enum QPEApplication::StylusMode | 1403 | \enum QPEApplication::StylusMode |
1382 | 1404 | ||
1383 | \value LeftOnly the stylus only generates LeftButton | 1405 | \value LeftOnly the stylus only generates LeftButton |
1384 | events (the default). | 1406 | events (the default). |
1385 | \value RightOnHold the stylus generates RightButton events | 1407 | \value RightOnHold the stylus generates RightButton events |
1386 | if the user uses the press-and-hold gesture. | 1408 | if the user uses the press-and-hold gesture. |
1387 | 1409 | ||
1388 | See setStylusOperation(). | 1410 | See setStylusOperation(). |
1389 | */ | 1411 | */ |
1390 | 1412 | ||
1391 | /*! | 1413 | /*! |
1392 | Causes \a w to receive mouse events according to \a mode. | 1414 | Causes \a w to receive mouse events according to \a mode. |
1393 | 1415 | ||
1394 | \sa stylusOperation() | 1416 | \sa stylusOperation() |
1395 | */ | 1417 | */ |
1396 | void QPEApplication::setStylusOperation( QWidget* w, StylusMode mode ) | 1418 | void QPEApplication::setStylusOperation( QWidget* w, StylusMode mode ) |
1397 | { | 1419 | { |
1398 | createDict(); | 1420 | createDict(); |
1399 | if ( mode == LeftOnly ) { | 1421 | if ( mode == LeftOnly ) { |
1400 | stylusDict->remove(w); | 1422 | stylusDict->remove(w); |
1401 | w->removeEventFilter(qApp); | 1423 | w->removeEventFilter(qApp); |
1402 | } else { | 1424 | } else { |
1403 | stylusDict->insert(w,(void*)mode); | 1425 | stylusDict->insert(w,(void*)mode); |
1404 | connect(w,SIGNAL(destroyed()),qApp,SLOT(removeSenderFromStylusDict())); | 1426 | connect(w,SIGNAL(destroyed()),qApp,SLOT(removeSenderFromStylusDict())); |
1405 | w->installEventFilter(qApp); | 1427 | w->installEventFilter(qApp); |
1406 | } | 1428 | } |
1407 | } | 1429 | } |
1408 | 1430 | ||
1409 | 1431 | ||
1410 | /*! | 1432 | /*! |
1411 | \reimp | 1433 | \reimp |
1412 | */ | 1434 | */ |
1413 | bool QPEApplication::eventFilter( QObject *o, QEvent *e ) | 1435 | bool QPEApplication::eventFilter( QObject *o, QEvent *e ) |
1414 | { | 1436 | { |
1415 | if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) { | 1437 | if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) { |
1416 | QMouseEvent* me = (QMouseEvent*)e; | 1438 | QMouseEvent* me = (QMouseEvent*)e; |
1417 | if ( me->button() == LeftButton ) { | 1439 | if ( me->button() == LeftButton ) { |
1418 | StylusMode mode = (StylusMode)(int)stylusDict->find(o); | 1440 | StylusMode mode = (StylusMode)(int)stylusDict->find(o); |
1419 | switch (mode) { | 1441 | switch (mode) { |
1420 | case RightOnHold: | 1442 | case RightOnHold: |
1421 | switch ( me->type() ) { | 1443 | switch ( me->type() ) { |
1422 | case QEvent::MouseButtonPress: | 1444 | case QEvent::MouseButtonPress: |
1423 | d->presstimer = startTimer(500); // #### pref. | 1445 | d->presstimer = startTimer(500); // #### pref. |
1424 | d->presswidget = (QWidget*)o; | 1446 | d->presswidget = (QWidget*)o; |
1425 | d->presspos = me->pos(); | 1447 | d->presspos = me->pos(); |
1426 | d->rightpressed = FALSE; | 1448 | d->rightpressed = FALSE; |
1427 | break; | 1449 | break; |
1428 | case QEvent::MouseButtonRelease: | 1450 | case QEvent::MouseButtonRelease: |
1429 | if ( d->presstimer ) { | 1451 | if ( d->presstimer ) { |
1430 | killTimer(d->presstimer); | 1452 | killTimer(d->presstimer); |
1431 | d->presstimer = 0; | 1453 | d->presstimer = 0; |
1432 | } | 1454 | } |
1433 | if ( d->rightpressed && d->presswidget ) { | 1455 | if ( d->rightpressed && d->presswidget ) { |
1434 | // Right released | 1456 | // Right released |
1435 | postEvent( d->presswidget, | 1457 | postEvent( d->presswidget, |
1436 | new QMouseEvent( QEvent::MouseButtonRelease, me->pos(), | 1458 | new QMouseEvent( QEvent::MouseButtonRelease, me->pos(), |
1437 | RightButton, LeftButton+RightButton ) ); | 1459 | RightButton, LeftButton+RightButton ) ); |
1438 | // Left released, off-widget | 1460 | // Left released, off-widget |
1439 | postEvent( d->presswidget, | 1461 | postEvent( d->presswidget, |
1440 | new QMouseEvent( QEvent::MouseMove, QPoint(-1,-1), | 1462 | new QMouseEvent( QEvent::MouseMove, QPoint(-1,-1), |
1441 | LeftButton, LeftButton ) ); | 1463 | LeftButton, LeftButton ) ); |
1442 | postEvent( d->presswidget, | 1464 | postEvent( d->presswidget, |
1443 | new QMouseEvent( QEvent::MouseButtonRelease, QPoint(-1,-1), | 1465 | new QMouseEvent( QEvent::MouseButtonRelease, QPoint(-1,-1), |
1444 | LeftButton, LeftButton ) ); | 1466 | LeftButton, LeftButton ) ); |