author | zecke <zecke> | 2004-09-19 18:48:56 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-09-19 18:48:56 (UTC) |
commit | 4564befecf3df38911d48f216ab216faf93b9c1d (patch) (unidiff) | |
tree | 9d4ec4264de74230e9fba4f9963535be604db90a | |
parent | 84166797fd3caa436d38e312957d5542046f10b0 (diff) | |
download | opie-4564befecf3df38911d48f216ab216faf93b9c1d.zip opie-4564befecf3df38911d48f216ab216faf93b9c1d.tar.gz opie-4564befecf3df38911d48f216ab216faf93b9c1d.tar.bz2 |
Have only one showDialog function.
If the dialog sizeHint is smaller than the width of the desktop
qpe_show_dialog didn't 'maximize' the widget and just showed it.
QPEApplication::showDialog does better in that respect but does not
have custom 'centering' of the dialog. But that doesn't matter
as we save/restore size and position for BigScreen.
-rw-r--r-- | library/qpeapplication.cpp | 60 |
1 files changed, 1 insertions, 59 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp index e1edd4c..df313ce 100644 --- a/library/qpeapplication.cpp +++ b/library/qpeapplication.cpp | |||
@@ -1,2346 +1,2288 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | */ | 19 | */ |
20 | #define QTOPIA_INTERNAL_LANGLIST | 20 | #define QTOPIA_INTERNAL_LANGLIST |
21 | #include <stdlib.h> | 21 | #include <stdlib.h> |
22 | #include <unistd.h> | 22 | #include <unistd.h> |
23 | #ifndef Q_OS_MACX | 23 | #ifndef Q_OS_MACX |
24 | #include <linux/limits.h> // needed for some toolchains (PATH_MAX) | 24 | #include <linux/limits.h> // needed for some toolchains (PATH_MAX) |
25 | #endif | 25 | #endif |
26 | #include <qfile.h> | 26 | #include <qfile.h> |
27 | #include <qqueue.h> | 27 | #include <qqueue.h> |
28 | #ifdef Q_WS_QWS | 28 | #ifdef Q_WS_QWS |
29 | #ifndef QT_NO_COP | 29 | #ifndef QT_NO_COP |
30 | #if QT_VERSION <= 231 | 30 | #if QT_VERSION <= 231 |
31 | #define private public | 31 | #define private public |
32 | #define sendLocally processEvent | 32 | #define sendLocally processEvent |
33 | #include "qcopenvelope_qws.h" | 33 | #include "qcopenvelope_qws.h" |
34 | #undef private | 34 | #undef private |
35 | #else | 35 | #else |
36 | #include "qcopenvelope_qws.h" | 36 | #include "qcopenvelope_qws.h" |
37 | #endif | 37 | #endif |
38 | #endif | 38 | #endif |
39 | #include <qwindowsystem_qws.h> | 39 | #include <qwindowsystem_qws.h> |
40 | #endif | 40 | #endif |
41 | #include <qtextstream.h> | 41 | #include <qtextstream.h> |
42 | #include <qpalette.h> | 42 | #include <qpalette.h> |
43 | #include <qbuffer.h> | 43 | #include <qbuffer.h> |
44 | #include <qptrdict.h> | 44 | #include <qptrdict.h> |
45 | #include <qregexp.h> | 45 | #include <qregexp.h> |
46 | #include <qdir.h> | 46 | #include <qdir.h> |
47 | #include <qlabel.h> | 47 | #include <qlabel.h> |
48 | #include <qdialog.h> | 48 | #include <qdialog.h> |
49 | #include <qdragobject.h> | 49 | #include <qdragobject.h> |
50 | #include <qtextcodec.h> | 50 | #include <qtextcodec.h> |
51 | #include <qevent.h> | 51 | #include <qevent.h> |
52 | #include <qtooltip.h> | 52 | #include <qtooltip.h> |
53 | #include <qsignal.h> | 53 | #include <qsignal.h> |
54 | #include <qmainwindow.h> | 54 | #include <qmainwindow.h> |
55 | #include <qwidgetlist.h> | 55 | #include <qwidgetlist.h> |
56 | #include <qpixmapcache.h> | 56 | #include <qpixmapcache.h> |
57 | 57 | ||
58 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 58 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
59 | #define QTOPIA_INTERNAL_INITAPP | 59 | #define QTOPIA_INTERNAL_INITAPP |
60 | #include "qpeapplication.h" | 60 | #include "qpeapplication.h" |
61 | #include "qpestyle.h" | 61 | #include "qpestyle.h" |
62 | #include "styleinterface.h" | 62 | #include "styleinterface.h" |
63 | #if QT_VERSION >= 300 | 63 | #if QT_VERSION >= 300 |
64 | #include <qstylefactory.h> | 64 | #include <qstylefactory.h> |
65 | #else | 65 | #else |
66 | #include <qplatinumstyle.h> | 66 | #include <qplatinumstyle.h> |
67 | #include <qwindowsstyle.h> | 67 | #include <qwindowsstyle.h> |
68 | #include <qmotifstyle.h> | 68 | #include <qmotifstyle.h> |
69 | #include <qmotifplusstyle.h> | 69 | #include <qmotifplusstyle.h> |
70 | #include "lightstyle.h" | 70 | #include "lightstyle.h" |
71 | 71 | ||
72 | #include <qpe/qlibrary.h> | 72 | #include <qpe/qlibrary.h> |
73 | #endif | 73 | #endif |
74 | #include "global.h" | 74 | #include "global.h" |
75 | #include "resource.h" | 75 | #include "resource.h" |
76 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) | 76 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) |
77 | #include "qutfcodec.h" | 77 | #include "qutfcodec.h" |
78 | #endif | 78 | #endif |
79 | #include "config.h" | 79 | #include "config.h" |
80 | #include "network.h" | 80 | #include "network.h" |
81 | #ifdef QWS | 81 | #ifdef QWS |
82 | #include "fontmanager.h" | 82 | #include "fontmanager.h" |
83 | #include "fontdatabase.h" | 83 | #include "fontdatabase.h" |
84 | #endif | 84 | #endif |
85 | 85 | ||
86 | #include "alarmserver.h" | 86 | #include "alarmserver.h" |
87 | #include "applnk.h" | 87 | #include "applnk.h" |
88 | #include "qpemenubar.h" | 88 | #include "qpemenubar.h" |
89 | #include "textcodecinterface.h" | 89 | #include "textcodecinterface.h" |
90 | #include "imagecodecinterface.h" | 90 | #include "imagecodecinterface.h" |
91 | 91 | ||
92 | #include <unistd.h> | 92 | #include <unistd.h> |
93 | #include <sys/file.h> | 93 | #include <sys/file.h> |
94 | #include <sys/ioctl.h> | 94 | #include <sys/ioctl.h> |
95 | #ifndef QT_NO_SOUND | 95 | #ifndef QT_NO_SOUND |
96 | #include <sys/soundcard.h> | 96 | #include <sys/soundcard.h> |
97 | #endif | 97 | #endif |
98 | #include "qt_override_p.h" | 98 | #include "qt_override_p.h" |
99 | 99 | ||
100 | #include <backend/rohfeedback.h> | 100 | #include <backend/rohfeedback.h> |
101 | 101 | ||
102 | 102 | ||
103 | static bool useBigPixmaps = 0; | 103 | static bool useBigPixmaps = 0; |
104 | 104 | ||
105 | class HackWidget : public QWidget | 105 | class HackWidget : public QWidget |
106 | { | 106 | { |
107 | public: | 107 | public: |
108 | bool needsOk() | 108 | bool needsOk() |
109 | { return (getWState() & WState_Reserved1 ); } | 109 | { return (getWState() & WState_Reserved1 ); } |
110 | 110 | ||
111 | QRect normalGeometry() | 111 | QRect normalGeometry() |
112 | { return topData()->normalGeometry; }; | 112 | { return topData()->normalGeometry; }; |
113 | }; | 113 | }; |
114 | 114 | ||
115 | class QPEApplicationData | 115 | class QPEApplicationData |
116 | { | 116 | { |
117 | public: | 117 | public: |
118 | QPEApplicationData ( ) : | 118 | QPEApplicationData ( ) : |
119 | presstimer( 0 ), presswidget( 0 ), rightpressed( false ), kbgrabbed( false ), | 119 | presstimer( 0 ), presswidget( 0 ), rightpressed( false ), kbgrabbed( false ), |
120 | notbusysent( false ), preloaded( false ), forceshow( false ), nomaximize( false ), | 120 | notbusysent( false ), preloaded( false ), forceshow( false ), nomaximize( false ), |
121 | keep_running( true ), qcopQok( false ), | 121 | keep_running( true ), qcopQok( false ), |
122 | fontFamily( "Vera" ), fontSize( 10 ), smallIconSize( 14 ), | 122 | fontFamily( "Vera" ), fontSize( 10 ), smallIconSize( 14 ), |
123 | bigIconSize( 32 ), qpe_main_widget( 0 ) | 123 | bigIconSize( 32 ), qpe_main_widget( 0 ) |
124 | { | 124 | { |
125 | Config cfg( "qpe" ); | 125 | Config cfg( "qpe" ); |
126 | cfg.setGroup( "Appearance" ); | 126 | cfg.setGroup( "Appearance" ); |
127 | useBigPixmaps = cfg.readBoolEntry( "useBigPixmaps", false ); | 127 | useBigPixmaps = cfg.readBoolEntry( "useBigPixmaps", false ); |
128 | fontFamily = cfg.readEntry( "FontFamily", "Vera" ); | 128 | fontFamily = cfg.readEntry( "FontFamily", "Vera" ); |
129 | fontSize = cfg.readNumEntry( "FontSize", 10 ); | 129 | fontSize = cfg.readNumEntry( "FontSize", 10 ); |
130 | smallIconSize = cfg.readNumEntry( "SmallIconSize", 14 ); | 130 | smallIconSize = cfg.readNumEntry( "SmallIconSize", 14 ); |
131 | bigIconSize = cfg.readNumEntry( "BigIconSize", 32 ); | 131 | bigIconSize = cfg.readNumEntry( "BigIconSize", 32 ); |
132 | #ifdef OPIE_WITHROHFEEDBACK | 132 | #ifdef OPIE_WITHROHFEEDBACK |
133 | RoH = 0; | 133 | RoH = 0; |
134 | #endif | 134 | #endif |
135 | } | 135 | } |
136 | 136 | ||
137 | int presstimer; | 137 | int presstimer; |
138 | QWidget* presswidget; | 138 | QWidget* presswidget; |
139 | QPoint presspos; | 139 | QPoint presspos; |
140 | #ifdef OPIE_WITHROHFEEDBACK | 140 | #ifdef OPIE_WITHROHFEEDBACK |
141 | Opie::Internal::RoHFeedback *RoH; | 141 | Opie::Internal::RoHFeedback *RoH; |
142 | #endif | 142 | #endif |
143 | 143 | ||
144 | bool rightpressed : 1; | 144 | bool rightpressed : 1; |
145 | bool kbgrabbed : 1; | 145 | bool kbgrabbed : 1; |
146 | bool notbusysent : 1; | 146 | bool notbusysent : 1; |
147 | bool preloaded : 1; | 147 | bool preloaded : 1; |
148 | bool forceshow : 1; | 148 | bool forceshow : 1; |
149 | bool nomaximize : 1; | 149 | bool nomaximize : 1; |
150 | bool keep_running : 1; | 150 | bool keep_running : 1; |
151 | bool qcopQok : 1; | 151 | bool qcopQok : 1; |
152 | 152 | ||
153 | QCString fontFamily; | 153 | QCString fontFamily; |
154 | int fontSize; | 154 | int fontSize; |
155 | int smallIconSize; | 155 | int smallIconSize; |
156 | int bigIconSize; | 156 | int bigIconSize; |
157 | 157 | ||
158 | QStringList langs; | 158 | QStringList langs; |
159 | QString appName; | 159 | QString appName; |
160 | struct QCopRec | 160 | struct QCopRec |
161 | { | 161 | { |
162 | QCopRec( const QCString &ch, const QCString &msg, | 162 | QCopRec( const QCString &ch, const QCString &msg, |
163 | const QByteArray &d ) : | 163 | const QByteArray &d ) : |
164 | channel( ch ), message( msg ), data( d ) | 164 | channel( ch ), message( msg ), data( d ) |
165 | { } | 165 | { } |
166 | 166 | ||
167 | QCString channel; | 167 | QCString channel; |
168 | QCString message; | 168 | QCString message; |
169 | QByteArray data; | 169 | QByteArray data; |
170 | }; | 170 | }; |
171 | QWidget* qpe_main_widget; | 171 | QWidget* qpe_main_widget; |
172 | QGuardedPtr<QWidget> lastraised; | 172 | QGuardedPtr<QWidget> lastraised; |
173 | QQueue<QCopRec> qcopq; | 173 | QQueue<QCopRec> qcopq; |
174 | QString styleName; | 174 | QString styleName; |
175 | QString decorationName; | 175 | QString decorationName; |
176 | 176 | ||
177 | void enqueueQCop( const QCString &ch, const QCString &msg, | 177 | void enqueueQCop( const QCString &ch, const QCString &msg, |
178 | const QByteArray &data ) | 178 | const QByteArray &data ) |
179 | { | 179 | { |
180 | qcopq.enqueue( new QCopRec( ch, msg, data ) ); | 180 | qcopq.enqueue( new QCopRec( ch, msg, data ) ); |
181 | } | 181 | } |
182 | void sendQCopQ() | 182 | void sendQCopQ() |
183 | { | 183 | { |
184 | if (!qcopQok ) | 184 | if (!qcopQok ) |
185 | return; | 185 | return; |
186 | 186 | ||
187 | QCopRec * r; | 187 | QCopRec * r; |
188 | 188 | ||
189 | while((r=qcopq.dequeue())) { | 189 | while((r=qcopq.dequeue())) { |
190 | // remove from queue before sending... | 190 | // remove from queue before sending... |
191 | // event loop can come around again before getting | 191 | // event loop can come around again before getting |
192 | // back from sendLocally | 192 | // back from sendLocally |
193 | #ifndef QT_NO_COP | 193 | #ifndef QT_NO_COP |
194 | QCopChannel::sendLocally( r->channel, r->message, r->data ); | 194 | QCopChannel::sendLocally( r->channel, r->message, r->data ); |
195 | #endif | 195 | #endif |
196 | 196 | ||
197 | delete r; | 197 | delete r; |
198 | } | 198 | } |
199 | } | 199 | } |
200 | 200 | ||
201 | static void show_mx(QWidget* mw, bool nomaximize, QString &strName) | 201 | static void show_mx(QWidget* mw, bool nomaximize, QString &strName) |
202 | { | 202 | { |
203 | if ( mw->inherits("QMainWindow") || mw->isA("QMainWindow") ) | 203 | if ( mw->inherits("QMainWindow") || mw->isA("QMainWindow") ) |
204 | { | 204 | { |
205 | ( ( QMainWindow* ) mw )->setUsesBigPixmaps( useBigPixmaps ); | 205 | ( ( QMainWindow* ) mw )->setUsesBigPixmaps( useBigPixmaps ); |
206 | } | 206 | } |
207 | QPoint p; | 207 | QPoint p; |
208 | QSize s; | 208 | QSize s; |
209 | bool max; | 209 | bool max; |
210 | if ( mw->isVisible() ) { | 210 | if ( mw->isVisible() ) { |
211 | if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { | 211 | if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { |
212 | mw->resize(s); | 212 | mw->resize(s); |
213 | mw->move(p); | 213 | mw->move(p); |
214 | } | 214 | } |
215 | mw->raise(); | 215 | mw->raise(); |
216 | } else { | 216 | } else { |
217 | 217 | ||
218 | if ( mw->layout() && mw->inherits("QDialog") ) { | 218 | if ( mw->layout() && mw->inherits("QDialog") ) { |
219 | if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { | 219 | if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { |
220 | mw->resize(s); | 220 | mw->resize(s); |
221 | mw->move(p); | 221 | mw->move(p); |
222 | 222 | ||
223 | if ( max && !nomaximize ) { | 223 | if ( max && !nomaximize ) { |
224 | mw->showMaximized(); | 224 | mw->showMaximized(); |
225 | } else { | 225 | } else { |
226 | mw->show(); | 226 | mw->show(); |
227 | } | 227 | } |
228 | } else { | 228 | } else { |
229 | qpe_show_dialog((QDialog*)mw,nomaximize); | 229 | QPEApplication::showDialog((QDialog*)mw,nomaximize); |
230 | } | 230 | } |
231 | } else { | 231 | } else { |
232 | if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { | 232 | if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { |
233 | mw->resize(s); | 233 | mw->resize(s); |
234 | mw->move(p); | 234 | mw->move(p); |
235 | } else { //no stored rectangle, make an estimation | 235 | } else { //no stored rectangle, make an estimation |
236 | int x = (qApp->desktop()->width()-mw->frameGeometry().width())/2; | 236 | int x = (qApp->desktop()->width()-mw->frameGeometry().width())/2; |
237 | int y = (qApp->desktop()->height()-mw->frameGeometry().height())/2; | 237 | int y = (qApp->desktop()->height()-mw->frameGeometry().height())/2; |
238 | mw->move( QMAX(x,0), QMAX(y,0) ); | 238 | mw->move( QMAX(x,0), QMAX(y,0) ); |
239 | #ifdef Q_WS_QWS | 239 | #ifdef Q_WS_QWS |
240 | if ( !nomaximize ) | 240 | if ( !nomaximize ) |
241 | mw->showMaximized(); | 241 | mw->showMaximized(); |
242 | #endif | 242 | #endif |
243 | } | 243 | } |
244 | if ( max && !nomaximize ) | 244 | if ( max && !nomaximize ) |
245 | mw->showMaximized(); | 245 | mw->showMaximized(); |
246 | else | 246 | else |
247 | mw->show(); | 247 | mw->show(); |
248 | } | 248 | } |
249 | } | 249 | } |
250 | } | 250 | } |
251 | 251 | ||
252 | static void qpe_show_dialog( QDialog* d, bool nomax ) | ||
253 | { | ||
254 | QSize sh = d->sizeHint(); | ||
255 | int w = QMAX(sh.width(),d->width()); | ||
256 | int h = QMAX(sh.height(),d->height()); | ||
257 | |||
258 | if ( d->parentWidget() && !d->parentWidget()->topLevelWidget()->isMaximized() ) | ||
259 | nomax = TRUE; | ||
260 | |||
261 | #ifndef Q_WS_QWS | ||
262 | QSize s(qApp->desktop()->width(), qApp->desktop()->height() ); | ||
263 | #else | ||
264 | QSize s(qt_maxWindowRect.width(), qt_maxWindowRect.height() ); | ||
265 | #endif | ||
266 | |||
267 | int maxX = s.width() - (d->frameGeometry().width() - d->geometry().width()); | ||
268 | int maxY = s.height() - (d->frameGeometry().height() - d->geometry().height()); | ||
269 | |||
270 | if ( (w >= maxX && h >= maxY) || ( (!nomax) && ( w > s.width()*3/4 || h > s.height()*3/4 ) ) ) { | ||
271 | d->showMaximized(); | ||
272 | } else { | ||
273 | // try centering the dialog around its parent | ||
274 | QPoint p(0,0); | ||
275 | if ( d->parentWidget() ) { | ||
276 | QPoint pp = d->parentWidget()->mapToGlobal( QPoint(0,0) ); | ||
277 | p = QPoint( pp.x() + d->parentWidget()->width()/2, | ||
278 | pp.y() + d->parentWidget()->height()/ 2 ); | ||
279 | } else { | ||
280 | p = QPoint( maxX/2, maxY/2 ); | ||
281 | } | ||
282 | |||
283 | p = QPoint( p.x() - w/2, p.y() - h/2 ); | ||
284 | // qDebug("p(x,y) is %d %d", p.x(), p.y() ); | ||
285 | |||
286 | if ( w >= maxX ) { | ||
287 | if ( p.y() < 0 ) | ||
288 | p.setY(0); | ||
289 | if ( p.y() + h > maxY ) | ||
290 | p.setY( maxY - h); | ||
291 | |||
292 | d->resize(maxX, h); | ||
293 | d->move(0, p.y() ); | ||
294 | } else if ( h >= maxY ) { | ||
295 | if ( p.x() < 0 ) | ||
296 | p.setX(0); | ||
297 | if ( p.x() + w > maxX ) | ||
298 | p.setX( maxX - w); | ||
299 | |||
300 | d->resize(w, maxY); | ||
301 | d->move(p.x(),0); | ||
302 | } else { | ||
303 | d->resize(w, h); | ||
304 | } | ||
305 | |||
306 | d->show(); | ||
307 | } | ||
308 | } | ||
309 | |||
310 | static bool read_widget_rect(const QString &app, bool &maximized, QPoint &p, QSize &s) | 252 | static bool read_widget_rect(const QString &app, bool &maximized, QPoint &p, QSize &s) |
311 | { | 253 | { |
312 | maximized = TRUE; | 254 | maximized = TRUE; |
313 | // 350 is the trigger in qwsdefaultdecoration for providing a resize button | 255 | // 350 is the trigger in qwsdefaultdecoration for providing a resize button |
314 | if ( qApp->desktop()->width() <= 350 ) | 256 | if ( qApp->desktop()->width() <= 350 ) |
315 | return FALSE; | 257 | return FALSE; |
316 | 258 | ||
317 | Config cfg( "qpe" ); | 259 | Config cfg( "qpe" ); |
318 | cfg.setGroup("ApplicationPositions"); | 260 | cfg.setGroup("ApplicationPositions"); |
319 | QString str = cfg.readEntry( app, QString::null ); | 261 | QString str = cfg.readEntry( app, QString::null ); |
320 | QStringList l = QStringList::split(",", str); | 262 | QStringList l = QStringList::split(",", str); |
321 | 263 | ||
322 | if ( l.count() == 5) { | 264 | if ( l.count() == 5) { |
323 | p.setX( l[0].toInt() ); | 265 | p.setX( l[0].toInt() ); |
324 | p.setY( l[1].toInt() ); | 266 | p.setY( l[1].toInt() ); |
325 | 267 | ||
326 | s.setWidth( l[2].toInt() ); | 268 | s.setWidth( l[2].toInt() ); |
327 | s.setHeight( l[3].toInt() ); | 269 | s.setHeight( l[3].toInt() ); |
328 | 270 | ||
329 | maximized = l[4].toInt(); | 271 | maximized = l[4].toInt(); |
330 | 272 | ||
331 | return TRUE; | 273 | return TRUE; |
332 | } | 274 | } |
333 | 275 | ||
334 | return FALSE; | 276 | return FALSE; |
335 | } | 277 | } |
336 | 278 | ||
337 | 279 | ||
338 | static bool validate_widget_size(const QWidget *w, QPoint &p, QSize &s) | 280 | static bool validate_widget_size(const QWidget *w, QPoint &p, QSize &s) |
339 | { | 281 | { |
340 | #ifndef Q_WS_QWS | 282 | #ifndef Q_WS_QWS |
341 | QRect qt_maxWindowRect = qApp->desktop()->geometry(); | 283 | QRect qt_maxWindowRect = qApp->desktop()->geometry(); |
342 | #endif | 284 | #endif |
343 | int maxX = qt_maxWindowRect.width(); | 285 | int maxX = qt_maxWindowRect.width(); |
344 | int maxY = qt_maxWindowRect.height(); | 286 | int maxY = qt_maxWindowRect.height(); |
345 | int wWidth = s.width() + ( w->frameGeometry().width() - w->geometry().width() ); | 287 | int wWidth = s.width() + ( w->frameGeometry().width() - w->geometry().width() ); |
346 | int wHeight = s.height() + ( w->frameGeometry().height() - w->geometry().height() ); | 288 | int wHeight = s.height() + ( w->frameGeometry().height() - w->geometry().height() ); |
347 | 289 | ||
348 | // total window size is not allowed to be larger than desktop window size | 290 | // total window size is not allowed to be larger than desktop window size |
349 | if ( ( wWidth >= maxX ) && ( wHeight >= maxY ) ) | 291 | if ( ( wWidth >= maxX ) && ( wHeight >= maxY ) ) |
350 | return FALSE; | 292 | return FALSE; |
351 | 293 | ||
352 | if ( wWidth > maxX ) { | 294 | if ( wWidth > maxX ) { |
353 | s.setWidth( maxX - (w->frameGeometry().width() - w->geometry().width() ) ); | 295 | s.setWidth( maxX - (w->frameGeometry().width() - w->geometry().width() ) ); |
354 | wWidth = maxX; | 296 | wWidth = maxX; |
355 | } | 297 | } |
356 | 298 | ||
357 | if ( wHeight > maxY ) { | 299 | if ( wHeight > maxY ) { |
358 | s.setHeight( maxY - (w->frameGeometry().height() - w->geometry().height() ) ); | 300 | s.setHeight( maxY - (w->frameGeometry().height() - w->geometry().height() ) ); |
359 | wHeight = maxY; | 301 | wHeight = maxY; |
360 | } | 302 | } |
361 | 303 | ||
362 | // any smaller than this and the maximize/close/help buttons will be overlapping | 304 | // any smaller than this and the maximize/close/help buttons will be overlapping |
363 | if ( wWidth < 80 || wHeight < 60 ) | 305 | if ( wWidth < 80 || wHeight < 60 ) |
364 | return FALSE; | 306 | return FALSE; |
365 | 307 | ||
366 | if ( p.x() < 0 ) | 308 | if ( p.x() < 0 ) |
367 | p.setX(0); | 309 | p.setX(0); |
368 | if ( p.y() < 0 ) | 310 | if ( p.y() < 0 ) |
369 | p.setY(0); | 311 | p.setY(0); |
370 | 312 | ||
371 | if ( p.x() + wWidth > maxX ) | 313 | if ( p.x() + wWidth > maxX ) |
372 | p.setX( maxX - wWidth ); | 314 | p.setX( maxX - wWidth ); |
373 | if ( p.y() + wHeight > maxY ) | 315 | if ( p.y() + wHeight > maxY ) |
374 | p.setY( maxY - wHeight ); | 316 | p.setY( maxY - wHeight ); |
375 | 317 | ||
376 | return TRUE; | 318 | return TRUE; |
377 | } | 319 | } |
378 | 320 | ||
379 | static void store_widget_rect(QWidget *w, QString &app) | 321 | static void store_widget_rect(QWidget *w, QString &app) |
380 | { | 322 | { |
381 | // 350 is the trigger in qwsdefaultdecoration for providing a resize button | 323 | // 350 is the trigger in qwsdefaultdecoration for providing a resize button |
382 | if ( qApp->desktop()->width() <= 350 ) | 324 | if ( qApp->desktop()->width() <= 350 ) |
383 | return; | 325 | return; |
384 | // we use these to map the offset of geometry and pos. ( we can only use normalGeometry to | 326 | // we use these to map the offset of geometry and pos. ( we can only use normalGeometry to |
385 | // get the non-maximized version, so we have to do it the hard way ) | 327 | // get the non-maximized version, so we have to do it the hard way ) |
386 | int offsetX = w->x() - w->geometry().left(); | 328 | int offsetX = w->x() - w->geometry().left(); |
387 | int offsetY = w->y() - w->geometry().top(); | 329 | int offsetY = w->y() - w->geometry().top(); |
388 | 330 | ||
389 | QRect r; | 331 | QRect r; |
390 | if ( w->isMaximized() ) | 332 | if ( w->isMaximized() ) |
391 | r = ( (HackWidget *) w)->normalGeometry(); | 333 | r = ( (HackWidget *) w)->normalGeometry(); |
392 | else | 334 | else |
393 | r = w->geometry(); | 335 | r = w->geometry(); |
394 | 336 | ||
395 | // Stores the window placement as pos(), size() (due to the offset mapping) | 337 | // Stores the window placement as pos(), size() (due to the offset mapping) |
396 | Config cfg( "qpe" ); | 338 | Config cfg( "qpe" ); |
397 | cfg.setGroup("ApplicationPositions"); | 339 | cfg.setGroup("ApplicationPositions"); |
398 | QString s; | 340 | QString s; |
399 | s.sprintf("%d,%d,%d,%d,%d", r.left() + offsetX, r.top() + offsetY, r.width(), r.height(), w->isMaximized() ); | 341 | s.sprintf("%d,%d,%d,%d,%d", r.left() + offsetX, r.top() + offsetY, r.width(), r.height(), w->isMaximized() ); |
400 | cfg.writeEntry( app, s ); | 342 | cfg.writeEntry( app, s ); |
401 | } | 343 | } |
402 | 344 | ||
403 | static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) | 345 | static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) |
404 | { | 346 | { |
405 | /* | 347 | /* |
406 | // This works but disable it for now until it is safe to apply | 348 | // This works but disable it for now until it is safe to apply |
407 | // What is does is scan the .desktop files of all the apps for | 349 | // What is does is scan the .desktop files of all the apps for |
408 | // the applnk that has the corresponding argv[0] as this program | 350 | // the applnk that has the corresponding argv[0] as this program |
409 | // then it uses the name stored in the .desktop file as the caption | 351 | // then it uses the name stored in the .desktop file as the caption |
410 | // for the main widget. This saves duplicating translations for | 352 | // for the main widget. This saves duplicating translations for |
411 | // the app name in the program and in the .desktop files. | 353 | // the app name in the program and in the .desktop files. |
412 | 354 | ||
413 | AppLnkSet apps( appsPath ); | 355 | AppLnkSet apps( appsPath ); |
414 | 356 | ||
415 | QList<AppLnk> appsList = apps.children(); | 357 | QList<AppLnk> appsList = apps.children(); |
416 | for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) { | 358 | for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) { |
417 | if ( (*it)->exec() == appName ) { | 359 | if ( (*it)->exec() == appName ) { |
418 | mw->setCaption( (*it)->name() ); | 360 | mw->setCaption( (*it)->name() ); |
419 | return TRUE; | 361 | return TRUE; |
420 | } | 362 | } |
421 | } | 363 | } |
422 | */ | 364 | */ |
423 | return FALSE; | 365 | return FALSE; |
424 | } | 366 | } |
425 | 367 | ||
426 | 368 | ||
427 | void show(QWidget* mw, bool nomax) | 369 | void show(QWidget* mw, bool nomax) |
428 | { | 370 | { |
429 | setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" ); | 371 | setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" ); |
430 | nomaximize = nomax; | 372 | nomaximize = nomax; |
431 | qpe_main_widget = mw; | 373 | qpe_main_widget = mw; |
432 | qcopQok = TRUE; | 374 | qcopQok = TRUE; |
433 | #ifndef QT_NO_COP | 375 | #ifndef QT_NO_COP |
434 | 376 | ||
435 | sendQCopQ(); | 377 | sendQCopQ(); |
436 | #endif | 378 | #endif |
437 | 379 | ||
438 | if ( preloaded ) { | 380 | if ( preloaded ) { |
439 | if (forceshow) | 381 | if (forceshow) |
440 | show_mx(mw, nomax, appName); | 382 | show_mx(mw, nomax, appName); |
441 | } | 383 | } |
442 | else if ( keep_running ) { | 384 | else if ( keep_running ) { |
443 | show_mx(mw, nomax, appName); | 385 | show_mx(mw, nomax, appName); |
444 | } | 386 | } |
445 | } | 387 | } |
446 | 388 | ||
447 | void loadTextCodecs() | 389 | void loadTextCodecs() |
448 | { | 390 | { |
449 | QString path = QPEApplication::qpeDir() + "/plugins/textcodecs"; | 391 | QString path = QPEApplication::qpeDir() + "/plugins/textcodecs"; |
450 | #ifdef Q_OS_MACX | 392 | #ifdef Q_OS_MACX |
451 | QDir dir( path, "lib*.dylib" ); | 393 | QDir dir( path, "lib*.dylib" ); |
452 | #else | 394 | #else |
453 | QDir dir( path, "lib*.so" ); | 395 | QDir dir( path, "lib*.so" ); |
454 | #endif | 396 | #endif |
455 | QStringList list; | 397 | QStringList list; |
456 | if ( dir. exists ( )) | 398 | if ( dir. exists ( )) |
457 | list = dir.entryList(); | 399 | list = dir.entryList(); |
458 | QStringList::Iterator it; | 400 | QStringList::Iterator it; |
459 | for ( it = list.begin(); it != list.end(); ++it ) { | 401 | for ( it = list.begin(); it != list.end(); ++it ) { |
460 | TextCodecInterface *iface = 0; | 402 | TextCodecInterface *iface = 0; |
461 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 403 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
462 | if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { | 404 | if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { |
463 | QValueList<int> mibs = iface->mibEnums(); | 405 | QValueList<int> mibs = iface->mibEnums(); |
464 | for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) { | 406 | for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) { |
465 | (void)iface->createForMib(*i); | 407 | (void)iface->createForMib(*i); |
466 | // ### it exists now; need to remember if we can delete it | 408 | // ### it exists now; need to remember if we can delete it |
467 | } | 409 | } |
468 | } | 410 | } |
469 | else { | 411 | else { |
470 | lib->unload(); | 412 | lib->unload(); |
471 | delete lib; | 413 | delete lib; |
472 | } | 414 | } |
473 | } | 415 | } |
474 | } | 416 | } |
475 | 417 | ||
476 | void loadImageCodecs() | 418 | void loadImageCodecs() |
477 | { | 419 | { |
478 | QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs"; | 420 | QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs"; |
479 | #ifdef Q_OS_MACX | 421 | #ifdef Q_OS_MACX |
480 | QDir dir( path, "lib*.dylib" ); | 422 | QDir dir( path, "lib*.dylib" ); |
481 | #else | 423 | #else |
482 | QDir dir( path, "lib*.so" ); | 424 | QDir dir( path, "lib*.so" ); |
483 | #endif | 425 | #endif |
484 | QStringList list; | 426 | QStringList list; |
485 | if ( dir. exists ( )) | 427 | if ( dir. exists ( )) |
486 | list = dir.entryList(); | 428 | list = dir.entryList(); |
487 | QStringList::Iterator it; | 429 | QStringList::Iterator it; |
488 | for ( it = list.begin(); it != list.end(); ++it ) { | 430 | for ( it = list.begin(); it != list.end(); ++it ) { |
489 | ImageCodecInterface *iface = 0; | 431 | ImageCodecInterface *iface = 0; |
490 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 432 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
491 | if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { | 433 | if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { |
492 | QStringList formats = iface->keys(); | 434 | QStringList formats = iface->keys(); |
493 | for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) { | 435 | for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) { |
494 | (void)iface->installIOHandler(*i); | 436 | (void)iface->installIOHandler(*i); |
495 | // ### it exists now; need to remember if we can delete it | 437 | // ### it exists now; need to remember if we can delete it |
496 | } | 438 | } |
497 | } | 439 | } |
498 | else { | 440 | else { |
499 | lib->unload(); | 441 | lib->unload(); |
500 | delete lib; | 442 | delete lib; |
501 | } | 443 | } |
502 | } | 444 | } |
503 | } | 445 | } |
504 | 446 | ||
505 | }; | 447 | }; |
506 | 448 | ||
507 | class ResourceMimeFactory : public QMimeSourceFactory | 449 | class ResourceMimeFactory : public QMimeSourceFactory |
508 | { | 450 | { |
509 | public: | 451 | public: |
510 | ResourceMimeFactory() : resImage( 0 ) | 452 | ResourceMimeFactory() : resImage( 0 ) |
511 | { | 453 | { |
512 | setFilePath( Global::helpPath() ); | 454 | setFilePath( Global::helpPath() ); |
513 | setExtensionType( "html", "text/html;charset=UTF-8" ); | 455 | setExtensionType( "html", "text/html;charset=UTF-8" ); |
514 | } | 456 | } |
515 | ~ResourceMimeFactory() { | 457 | ~ResourceMimeFactory() { |
516 | delete resImage; | 458 | delete resImage; |
517 | } | 459 | } |
518 | 460 | ||
519 | const QMimeSource* data( const QString& abs_name ) const | 461 | const QMimeSource* data( const QString& abs_name ) const |
520 | { | 462 | { |
521 | const QMimeSource * r = QMimeSourceFactory::data( abs_name ); | 463 | const QMimeSource * r = QMimeSourceFactory::data( abs_name ); |
522 | if ( !r ) { | 464 | if ( !r ) { |
523 | int sl = abs_name.length(); | 465 | int sl = abs_name.length(); |
524 | do { | 466 | do { |
525 | sl = abs_name.findRev( '/', sl - 1 ); | 467 | sl = abs_name.findRev( '/', sl - 1 ); |
526 | QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name; | 468 | QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name; |
527 | int dot = name.findRev( '.' ); | 469 | int dot = name.findRev( '.' ); |
528 | if ( dot >= 0 ) | 470 | if ( dot >= 0 ) |
529 | name = name.left( dot ); | 471 | name = name.left( dot ); |
530 | QImage img = Resource::loadImage( name ); | 472 | QImage img = Resource::loadImage( name ); |
531 | if ( !img.isNull() ) { | 473 | if ( !img.isNull() ) { |
532 | delete resImage; | 474 | delete resImage; |
533 | resImage = new QImageDrag( img ); | 475 | resImage = new QImageDrag( img ); |
534 | r = resImage; | 476 | r = resImage; |
535 | } | 477 | } |
536 | } | 478 | } |
537 | while ( !r && sl > 0 ); | 479 | while ( !r && sl > 0 ); |
538 | } | 480 | } |
539 | return r; | 481 | return r; |
540 | } | 482 | } |
541 | private: | 483 | private: |
542 | mutable QImageDrag *resImage; | 484 | mutable QImageDrag *resImage; |
543 | }; | 485 | }; |
544 | 486 | ||
545 | static int& hack(int& i) | 487 | static int& hack(int& i) |
546 | { | 488 | { |
547 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) | 489 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) |
548 | // These should be created, but aren't in Qt 2.3.0 | 490 | // These should be created, but aren't in Qt 2.3.0 |
549 | (void)new QUtf8Codec; | 491 | (void)new QUtf8Codec; |
550 | (void)new QUtf16Codec; | 492 | (void)new QUtf16Codec; |
551 | #endif | 493 | #endif |
552 | return i; | 494 | return i; |
553 | } | 495 | } |
554 | 496 | ||
555 | static int muted = 0; | 497 | static int muted = 0; |
556 | static int micMuted = 0; | 498 | static int micMuted = 0; |
557 | 499 | ||
558 | static void setVolume( int t = 0, int percent = -1 ) | 500 | static void setVolume( int t = 0, int percent = -1 ) |
559 | { | 501 | { |
560 | switch ( t ) { | 502 | switch ( t ) { |
561 | case 0: { | 503 | case 0: { |
562 | Config cfg( "qpe" ); | 504 | Config cfg( "qpe" ); |
563 | cfg.setGroup( "Volume" ); | 505 | cfg.setGroup( "Volume" ); |
564 | if ( percent < 0 ) | 506 | if ( percent < 0 ) |
565 | percent = cfg.readNumEntry( "VolumePercent", 50 ); | 507 | percent = cfg.readNumEntry( "VolumePercent", 50 ); |
566 | #ifndef QT_NO_SOUND | 508 | #ifndef QT_NO_SOUND |
567 | int fd = 0; | 509 | int fd = 0; |
568 | #ifdef QT_QWS_DEVFS | 510 | #ifdef QT_QWS_DEVFS |
569 | if ( ( fd = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) { | 511 | if ( ( fd = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) { |
570 | #else | 512 | #else |
571 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 513 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
572 | #endif | 514 | #endif |
573 | int vol = muted ? 0 : percent; | 515 | int vol = muted ? 0 : percent; |
574 | // set both channels to same volume | 516 | // set both channels to same volume |
575 | vol |= vol << 8; | 517 | vol |= vol << 8; |
576 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_VOLUME ), &vol ); | 518 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_VOLUME ), &vol ); |
577 | ::close( fd ); | 519 | ::close( fd ); |
578 | } | 520 | } |
579 | #endif | 521 | #endif |
580 | } | 522 | } |
581 | break; | 523 | break; |
582 | } | 524 | } |
583 | } | 525 | } |
584 | 526 | ||
585 | static void setMic( int t = 0, int percent = -1 ) | 527 | static void setMic( int t = 0, int percent = -1 ) |
586 | { | 528 | { |
587 | switch ( t ) { | 529 | switch ( t ) { |
588 | case 0: { | 530 | case 0: { |
589 | Config cfg( "qpe" ); | 531 | Config cfg( "qpe" ); |
590 | cfg.setGroup( "Volume" ); | 532 | cfg.setGroup( "Volume" ); |
591 | if ( percent < 0 ) | 533 | if ( percent < 0 ) |
592 | percent = cfg.readNumEntry( "Mic", 50 ); | 534 | percent = cfg.readNumEntry( "Mic", 50 ); |
593 | 535 | ||
594 | #ifndef QT_NO_SOUND | 536 | #ifndef QT_NO_SOUND |
595 | int fd = 0; | 537 | int fd = 0; |
596 | int mic = micMuted ? 0 : percent; | 538 | int mic = micMuted ? 0 : percent; |
597 | #ifdef QT_QWS_DEVFS | 539 | #ifdef QT_QWS_DEVFS |
598 | if ( ( fd = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) { | 540 | if ( ( fd = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) { |
599 | #else | 541 | #else |
600 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 542 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
601 | #endif | 543 | #endif |
602 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_MIC ), &mic ); | 544 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_MIC ), &mic ); |
603 | ::close( fd ); | 545 | ::close( fd ); |
604 | } | 546 | } |
605 | #endif | 547 | #endif |
606 | } | 548 | } |
607 | break; | 549 | break; |
608 | } | 550 | } |
609 | } | 551 | } |
610 | 552 | ||
611 | 553 | ||
612 | static void setBass( int t = 0, int percent = -1 ) | 554 | static void setBass( int t = 0, int percent = -1 ) |
613 | { | 555 | { |
614 | switch ( t ) { | 556 | switch ( t ) { |
615 | case 0: { | 557 | case 0: { |
616 | Config cfg( "qpe" ); | 558 | Config cfg( "qpe" ); |
617 | cfg.setGroup( "Volume" ); | 559 | cfg.setGroup( "Volume" ); |
618 | if ( percent < 0 ) | 560 | if ( percent < 0 ) |
619 | percent = cfg.readNumEntry( "BassPercent", 50 ); | 561 | percent = cfg.readNumEntry( "BassPercent", 50 ); |
620 | 562 | ||
621 | #ifndef QT_NO_SOUND | 563 | #ifndef QT_NO_SOUND |
622 | int fd = 0; | 564 | int fd = 0; |
623 | int bass = percent; | 565 | int bass = percent; |
624 | #ifdef QT_QWS_DEVFS | 566 | #ifdef QT_QWS_DEVFS |
625 | if ( ( fd = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) { | 567 | if ( ( fd = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) { |
626 | #else | 568 | #else |
627 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 569 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
628 | #endif | 570 | #endif |
629 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_BASS ), &bass ); | 571 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_BASS ), &bass ); |
630 | ::close( fd ); | 572 | ::close( fd ); |
631 | } | 573 | } |
632 | #endif | 574 | #endif |
633 | } | 575 | } |
634 | break; | 576 | break; |
635 | } | 577 | } |
636 | } | 578 | } |
637 | 579 | ||
638 | 580 | ||
639 | static void setTreble( int t = 0, int percent = -1 ) | 581 | static void setTreble( int t = 0, int percent = -1 ) |
640 | { | 582 | { |
641 | switch ( t ) { | 583 | switch ( t ) { |
642 | case 0: { | 584 | case 0: { |
643 | Config cfg( "qpe" ); | 585 | Config cfg( "qpe" ); |
644 | cfg.setGroup( "Volume" ); | 586 | cfg.setGroup( "Volume" ); |
645 | if ( percent < 0 ) | 587 | if ( percent < 0 ) |
646 | percent = cfg.readNumEntry( "TreblePercent", 50 ); | 588 | percent = cfg.readNumEntry( "TreblePercent", 50 ); |
647 | 589 | ||
648 | #ifndef QT_NO_SOUND | 590 | #ifndef QT_NO_SOUND |
649 | int fd = 0; | 591 | int fd = 0; |
650 | int treble = percent; | 592 | int treble = percent; |
651 | #ifdef QT_QWS_DEVFS | 593 | #ifdef QT_QWS_DEVFS |
652 | if ( ( fd = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) { | 594 | if ( ( fd = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) { |
653 | #else | 595 | #else |
654 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 596 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
655 | #endif | 597 | #endif |
656 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_TREBLE ), &treble ); | 598 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_TREBLE ), &treble ); |
657 | ::close( fd ); | 599 | ::close( fd ); |
658 | } | 600 | } |
659 | #endif | 601 | #endif |
660 | } | 602 | } |
661 | break; | 603 | break; |
662 | } | 604 | } |
663 | } | 605 | } |
664 | 606 | ||
665 | 607 | ||
666 | /** | 608 | /** |
667 | \class QPEApplication | 609 | \class QPEApplication |
668 | \brief The QPEApplication class implements various system services | 610 | \brief The QPEApplication class implements various system services |
669 | that are available to all Qtopia applications. | 611 | that are available to all Qtopia applications. |
670 | 612 | ||
671 | Simply by using QPEApplication instead of QApplication, a standard Qt | 613 | Simply by using QPEApplication instead of QApplication, a standard Qt |
672 | application becomes a Qtopia application. It automatically follows | 614 | application becomes a Qtopia application. It automatically follows |
673 | style changes, quits and raises, and in the | 615 | style changes, quits and raises, and in the |
674 | case of \link docwidget.html document-oriented\endlink applications, | 616 | case of \link docwidget.html document-oriented\endlink applications, |
675 | changes the currently displayed document in response to the environment. | 617 | changes the currently displayed document in response to the environment. |
676 | 618 | ||
677 | To create a \link docwidget.html document-oriented\endlink | 619 | To create a \link docwidget.html document-oriented\endlink |
678 | application use showMainDocumentWidget(); to create a | 620 | application use showMainDocumentWidget(); to create a |
679 | non-document-oriented application use showMainWidget(). The | 621 | non-document-oriented application use showMainWidget(). The |
680 | keepRunning() function indicates whether the application will | 622 | keepRunning() function indicates whether the application will |
681 | continue running after it's processed the last \link qcop.html | 623 | continue running after it's processed the last \link qcop.html |
682 | QCop\endlink message. This can be changed using setKeepRunning(). | 624 | QCop\endlink message. This can be changed using setKeepRunning(). |
683 | 625 | ||
684 | A variety of signals are emitted when certain events occur, for | 626 | A variety of signals are emitted when certain events occur, for |
685 | example, timeChanged(), clockChanged(), weekChanged(), | 627 | example, timeChanged(), clockChanged(), weekChanged(), |
686 | dateFormatChanged() and volumeChanged(). If the application receives | 628 | dateFormatChanged() and volumeChanged(). If the application receives |
687 | a \link qcop.html QCop\endlink message on the application's | 629 | a \link qcop.html QCop\endlink message on the application's |
688 | QPE/Application/\e{appname} channel, the appMessage() signal is | 630 | QPE/Application/\e{appname} channel, the appMessage() signal is |
689 | emitted. There are also flush() and reload() signals, which | 631 | emitted. There are also flush() and reload() signals, which |
690 | are emitted when synching begins and ends respectively - upon these | 632 | are emitted when synching begins and ends respectively - upon these |
691 | signals, the application should save and reload any data | 633 | signals, the application should save and reload any data |
692 | files that are involved in synching. Most of these signals will initially | 634 | files that are involved in synching. Most of these signals will initially |
693 | be received and unfiltered through the appMessage() signal. | 635 | be received and unfiltered through the appMessage() signal. |
694 | 636 | ||
695 | This class also provides a set of useful static functions. The | 637 | This class also provides a set of useful static functions. The |
696 | qpeDir() and documentDir() functions return the respective paths. | 638 | qpeDir() and documentDir() functions return the respective paths. |
697 | The grabKeyboard() and ungrabKeyboard() functions are used to | 639 | The grabKeyboard() and ungrabKeyboard() functions are used to |
698 | control whether the application takes control of the device's | 640 | control whether the application takes control of the device's |
699 | physical buttons (e.g. application launch keys). The stylus' mode of | 641 | physical buttons (e.g. application launch keys). The stylus' mode of |
700 | operation is set with setStylusOperation() and retrieved with | 642 | operation is set with setStylusOperation() and retrieved with |
701 | stylusOperation(). There are also setInputMethodHint() and | 643 | stylusOperation(). There are also setInputMethodHint() and |
702 | inputMethodHint() functions. | 644 | inputMethodHint() functions. |
703 | 645 | ||
704 | \ingroup qtopiaemb | 646 | \ingroup qtopiaemb |
705 | */ | 647 | */ |
706 | 648 | ||
707 | /*! | 649 | /*! |
708 | \fn void QPEApplication::clientMoused() | 650 | \fn void QPEApplication::clientMoused() |
709 | 651 | ||
710 | \internal | 652 | \internal |
711 | */ | 653 | */ |
712 | 654 | ||
713 | /*! | 655 | /*! |
714 | \fn void QPEApplication::timeChanged(); | 656 | \fn void QPEApplication::timeChanged(); |
715 | This signal is emitted when the time changes outside the normal | 657 | This signal is emitted when the time changes outside the normal |
716 | passage of time, i.e. if the time is set backwards or forwards. | 658 | passage of time, i.e. if the time is set backwards or forwards. |
717 | */ | 659 | */ |
718 | 660 | ||
719 | /*! | 661 | /*! |
720 | \fn void QPEApplication::clockChanged( bool ampm ); | 662 | \fn void QPEApplication::clockChanged( bool ampm ); |
721 | 663 | ||
722 | This signal is emitted when the user changes the clock's style. If | 664 | This signal is emitted when the user changes the clock's style. If |
723 | \a ampm is TRUE, the user wants a 12-hour AM/PM clock, otherwise, | 665 | \a ampm is TRUE, the user wants a 12-hour AM/PM clock, otherwise, |
724 | they want a 24-hour clock. | 666 | they want a 24-hour clock. |
725 | */ | 667 | */ |
726 | 668 | ||
727 | /*! | 669 | /*! |
728 | \fn void QPEApplication::volumeChanged( bool muted ) | 670 | \fn void QPEApplication::volumeChanged( bool muted ) |
729 | 671 | ||
730 | This signal is emitted whenever the mute state is changed. If \a | 672 | This signal is emitted whenever the mute state is changed. If \a |
731 | muted is TRUE, then sound output has been muted. | 673 | muted is TRUE, then sound output has been muted. |
732 | */ | 674 | */ |
733 | 675 | ||
734 | /*! | 676 | /*! |
735 | \fn void QPEApplication::weekChanged( bool startOnMonday ) | 677 | \fn void QPEApplication::weekChanged( bool startOnMonday ) |
736 | 678 | ||
737 | This signal is emitted if the week start day is changed. If \a | 679 | This signal is emitted if the week start day is changed. If \a |
738 | startOnMonday is TRUE then the first day of the week is Monday; if | 680 | startOnMonday is TRUE then the first day of the week is Monday; if |
739 | \a startOnMonday is FALSE then the first day of the week is | 681 | \a startOnMonday is FALSE then the first day of the week is |
740 | Sunday. | 682 | Sunday. |
741 | */ | 683 | */ |
742 | 684 | ||
743 | /*! | 685 | /*! |
744 | \fn void QPEApplication::dateFormatChanged(DateFormat) | 686 | \fn void QPEApplication::dateFormatChanged(DateFormat) |
745 | 687 | ||
746 | This signal is emitted whenever the date format is changed. | 688 | This signal is emitted whenever the date format is changed. |
747 | */ | 689 | */ |
748 | 690 | ||
749 | /*! | 691 | /*! |
750 | \fn void QPEApplication::flush() | 692 | \fn void QPEApplication::flush() |
751 | 693 | ||
752 | ### | 694 | ### |
753 | */ | 695 | */ |
754 | 696 | ||
755 | /*! | 697 | /*! |
756 | \fn void QPEApplication::reload() | 698 | \fn void QPEApplication::reload() |
757 | 699 | ||
758 | */ | 700 | */ |
759 | 701 | ||
760 | 702 | ||
761 | 703 | ||
762 | void QPEApplication::processQCopFile() | 704 | void QPEApplication::processQCopFile() |
763 | { | 705 | { |
764 | QString qcopfn("/tmp/qcop-msg-"); | 706 | QString qcopfn("/tmp/qcop-msg-"); |
765 | qcopfn += d->appName; // append command name | 707 | qcopfn += d->appName; // append command name |
766 | 708 | ||
767 | QFile f(qcopfn); | 709 | QFile f(qcopfn); |
768 | if ( f.open(IO_ReadWrite) ) { | 710 | if ( f.open(IO_ReadWrite) ) { |
769 | #ifndef Q_OS_WIN32 | 711 | #ifndef Q_OS_WIN32 |
770 | flock(f.handle(), LOCK_EX); | 712 | flock(f.handle(), LOCK_EX); |
771 | #endif | 713 | #endif |
772 | QDataStream ds(&f); | 714 | QDataStream ds(&f); |
773 | QCString channel, message; | 715 | QCString channel, message; |
774 | QByteArray data; | 716 | QByteArray data; |
775 | while(!ds.atEnd()) { | 717 | while(!ds.atEnd()) { |
776 | ds >> channel >> message >> data; | 718 | ds >> channel >> message >> data; |
777 | d->enqueueQCop(channel,message,data); | 719 | d->enqueueQCop(channel,message,data); |
778 | } | 720 | } |
779 | ::ftruncate(f.handle(), 0); | 721 | ::ftruncate(f.handle(), 0); |
780 | #ifndef Q_OS_WIN32 | 722 | #ifndef Q_OS_WIN32 |
781 | f.flush(); | 723 | f.flush(); |
782 | flock(f.handle(), LOCK_UN); | 724 | flock(f.handle(), LOCK_UN); |
783 | #endif | 725 | #endif |
784 | } | 726 | } |
785 | #endif | 727 | #endif |
786 | } | 728 | } |
787 | 729 | ||
788 | 730 | ||
789 | /*! | 731 | /*! |
790 | \fn void QPEApplication::appMessage( const QCString& msg, const QByteArray& data ) | 732 | \fn void QPEApplication::appMessage( const QCString& msg, const QByteArray& data ) |
791 | 733 | ||
792 | This signal is emitted when a message is received on this | 734 | This signal is emitted when a message is received on this |
793 | application's QPE/Application/<i>appname</i> \link qcop.html | 735 | application's QPE/Application/<i>appname</i> \link qcop.html |
794 | QCop\endlink channel. | 736 | QCop\endlink channel. |
795 | 737 | ||
796 | The slot to which you connect this signal uses \a msg and \a data | 738 | The slot to which you connect this signal uses \a msg and \a data |
797 | in the following way: | 739 | in the following way: |
798 | 740 | ||
799 | \code | 741 | \code |
800 | void MyWidget::receive( const QCString& msg, const QByteArray& data ) | 742 | void MyWidget::receive( const QCString& msg, const QByteArray& data ) |
801 | { | 743 | { |
802 | QDataStream stream( data, IO_ReadOnly ); | 744 | QDataStream stream( data, IO_ReadOnly ); |
803 | if ( msg == "someMessage(int,int,int)" ) { | 745 | if ( msg == "someMessage(int,int,int)" ) { |
804 | int a,b,c; | 746 | int a,b,c; |
805 | stream >> a >> b >> c; | 747 | stream >> a >> b >> c; |
806 | ... | 748 | ... |
807 | } else if ( msg == "otherMessage(QString)" ) { | 749 | } else if ( msg == "otherMessage(QString)" ) { |
808 | ... | 750 | ... |
809 | } | 751 | } |
810 | } | 752 | } |
811 | \endcode | 753 | \endcode |
812 | 754 | ||
813 | \sa qcop.html | 755 | \sa qcop.html |
814 | Note that messages received here may be processed by qpe application | 756 | Note that messages received here may be processed by qpe application |
815 | and emitted as signals, such as flush() and reload(). | 757 | and emitted as signals, such as flush() and reload(). |
816 | */ | 758 | */ |
817 | 759 | ||
818 | /*! | 760 | /*! |
819 | Constructs a QPEApplication just as you would construct | 761 | Constructs a QPEApplication just as you would construct |
820 | a QApplication, passing \a argc, \a argv, and \a t. | 762 | a QApplication, passing \a argc, \a argv, and \a t. |
821 | 763 | ||
822 | For applications, \a t should be the default, GuiClient. Only | 764 | For applications, \a t should be the default, GuiClient. Only |
823 | the Qtopia server passes GuiServer. | 765 | the Qtopia server passes GuiServer. |
824 | */ | 766 | */ |
825 | QPEApplication::QPEApplication( int & argc, char **argv, Type t ) | 767 | QPEApplication::QPEApplication( int & argc, char **argv, Type t ) |
826 | : QApplication( hack(argc), argv, t ), pidChannel( 0 ) | 768 | : QApplication( hack(argc), argv, t ), pidChannel( 0 ) |
827 | { | 769 | { |
828 | QPixmapCache::setCacheLimit(256); // sensible default for smaller devices. | 770 | QPixmapCache::setCacheLimit(256); // sensible default for smaller devices. |
829 | 771 | ||
830 | d = new QPEApplicationData; | 772 | d = new QPEApplicationData; |
831 | d->loadTextCodecs(); | 773 | d->loadTextCodecs(); |
832 | d->loadImageCodecs(); | 774 | d->loadImageCodecs(); |
833 | 775 | ||
834 | setFont( QFont( d->fontFamily, d->fontSize ) ); | 776 | setFont( QFont( d->fontFamily, d->fontSize ) ); |
835 | AppLnk::setSmallIconSize( d->smallIconSize ); | 777 | AppLnk::setSmallIconSize( d->smallIconSize ); |
836 | AppLnk::setBigIconSize( d->bigIconSize ); | 778 | AppLnk::setBigIconSize( d->bigIconSize ); |
837 | 779 | ||
838 | QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory ); | 780 | QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory ); |
839 | 781 | ||
840 | connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) ); | 782 | connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) ); |
841 | 783 | ||
842 | 784 | ||
843 | sysChannel = new QCopChannel( "QPE/System", this ); | 785 | sysChannel = new QCopChannel( "QPE/System", this ); |
844 | connect( sysChannel, SIGNAL( received(const QCString&,const QByteArray&) ), | 786 | connect( sysChannel, SIGNAL( received(const QCString&,const QByteArray&) ), |
845 | this, SLOT( systemMessage(const QCString&,const QByteArray&) ) ); | 787 | this, SLOT( systemMessage(const QCString&,const QByteArray&) ) ); |
846 | 788 | ||
847 | /* COde now in initapp */ | 789 | /* COde now in initapp */ |
848 | #if 0 | 790 | #if 0 |
849 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 791 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
850 | 792 | ||
851 | QString qcopfn( "/tmp/qcop-msg-" ); | 793 | QString qcopfn( "/tmp/qcop-msg-" ); |
852 | qcopfn += QString( argv[ 0 ] ); // append command name | 794 | qcopfn += QString( argv[ 0 ] ); // append command name |
853 | 795 | ||
854 | QFile f( qcopfn ); | 796 | QFile f( qcopfn ); |
855 | if ( f.open( IO_ReadOnly ) ) { | 797 | if ( f.open( IO_ReadOnly ) ) { |
856 | flock( f.handle(), LOCK_EX ); | 798 | flock( f.handle(), LOCK_EX ); |
857 | } | 799 | } |
858 | 800 | ||
859 | 801 | ||
860 | 802 | ||
861 | QCString channel = QCString( argv[ 0 ] ); | 803 | QCString channel = QCString( argv[ 0 ] ); |
862 | channel.replace( QRegExp( ".*/" ), "" ); | 804 | channel.replace( QRegExp( ".*/" ), "" ); |
863 | d->appName = channel; | 805 | d->appName = channel; |
864 | channel = "QPE/Application/" + channel; | 806 | channel = "QPE/Application/" + channel; |
865 | pidChannel = new QCopChannel( channel, this ); | 807 | pidChannel = new QCopChannel( channel, this ); |
866 | connect( pidChannel, SIGNAL( received(const QCString&,const QByteArray&) ), | 808 | connect( pidChannel, SIGNAL( received(const QCString&,const QByteArray&) ), |
867 | this, SLOT( pidMessage(const QCString&,const QByteArray&) ) ); | 809 | this, SLOT( pidMessage(const QCString&,const QByteArray&) ) ); |
868 | 810 | ||
869 | if ( f.isOpen() ) { | 811 | if ( f.isOpen() ) { |
870 | d->keep_running = FALSE; | 812 | d->keep_running = FALSE; |
871 | QDataStream ds( &f ); | 813 | QDataStream ds( &f ); |
872 | QCString channel, message; | 814 | QCString channel, message; |
873 | QByteArray data; | 815 | QByteArray data; |
874 | while ( !ds.atEnd() ) { | 816 | while ( !ds.atEnd() ) { |
875 | ds >> channel >> message >> data; | 817 | ds >> channel >> message >> data; |
876 | d->enqueueQCop( channel, message, data ); | 818 | d->enqueueQCop( channel, message, data ); |
877 | } | 819 | } |
878 | 820 | ||
879 | flock( f.handle(), LOCK_UN ); | 821 | flock( f.handle(), LOCK_UN ); |
880 | f.close(); | 822 | f.close(); |
881 | f.remove(); | 823 | f.remove(); |
882 | } | 824 | } |
883 | 825 | ||
884 | for ( int a = 0; a < argc; a++ ) { | 826 | for ( int a = 0; a < argc; a++ ) { |
885 | if ( qstrcmp( argv[ a ], "-preload" ) == 0 ) { | 827 | if ( qstrcmp( argv[ a ], "-preload" ) == 0 ) { |
886 | argv[ a ] = argv[ a + 1 ]; | 828 | argv[ a ] = argv[ a + 1 ]; |
887 | a++; | 829 | a++; |
888 | d->preloaded = TRUE; | 830 | d->preloaded = TRUE; |
889 | argc -= 1; | 831 | argc -= 1; |
890 | } | 832 | } |
891 | else if ( qstrcmp( argv[ a ], "-preload-show" ) == 0 ) { | 833 | else if ( qstrcmp( argv[ a ], "-preload-show" ) == 0 ) { |
892 | argv[ a ] = argv[ a + 1 ]; | 834 | argv[ a ] = argv[ a + 1 ]; |
893 | a++; | 835 | a++; |
894 | d->preloaded = TRUE; | 836 | d->preloaded = TRUE; |
895 | d->forceshow = TRUE; | 837 | d->forceshow = TRUE; |
896 | argc -= 1; | 838 | argc -= 1; |
897 | } | 839 | } |
898 | } | 840 | } |
899 | 841 | ||
900 | /* overide stored arguments */ | 842 | /* overide stored arguments */ |
901 | setArgs( argc, argv ); | 843 | setArgs( argc, argv ); |
902 | 844 | ||
903 | #endif | 845 | #endif |
904 | #else | 846 | #else |
905 | initApp( argc, argv ); | 847 | initApp( argc, argv ); |
906 | #endif | 848 | #endif |
907 | #ifdef Q_WS_QWS | 849 | #ifdef Q_WS_QWS |
908 | /* load the font renderer factories */ | 850 | /* load the font renderer factories */ |
909 | FontDatabase::loadRenderers(); | 851 | FontDatabase::loadRenderers(); |
910 | #endif | 852 | #endif |
911 | #ifndef QT_NO_TRANSLATION | 853 | #ifndef QT_NO_TRANSLATION |
912 | 854 | ||
913 | d->langs = Global::languageList(); | 855 | d->langs = Global::languageList(); |
914 | for ( QStringList::ConstIterator it = d->langs.begin(); it != d->langs.end(); ++it ) { | 856 | for ( QStringList::ConstIterator it = d->langs.begin(); it != d->langs.end(); ++it ) { |
915 | QString lang = *it; | 857 | QString lang = *it; |
916 | 858 | ||
917 | installTranslation( lang + "/libopie.qm"); | 859 | installTranslation( lang + "/libopie.qm"); |
918 | installTranslation( lang + "/libqpe.qm" ); | 860 | installTranslation( lang + "/libqpe.qm" ); |
919 | installTranslation( lang + "/" + d->appName + ".qm" ); | 861 | installTranslation( lang + "/" + d->appName + ".qm" ); |
920 | 862 | ||
921 | 863 | ||
922 | //###language/font hack; should look it up somewhere | 864 | //###language/font hack; should look it up somewhere |
923 | #ifdef QWS | 865 | #ifdef QWS |
924 | 866 | ||
925 | if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) { | 867 | if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) { |
926 | QFont fn = FontManager::unicodeFont( FontManager::Proportional ); | 868 | QFont fn = FontManager::unicodeFont( FontManager::Proportional ); |
927 | setFont( fn ); | 869 | setFont( fn ); |
928 | } | 870 | } |
929 | #endif | 871 | #endif |
930 | } | 872 | } |
931 | #endif | 873 | #endif |
932 | 874 | ||
933 | applyStyle(); | 875 | applyStyle(); |
934 | 876 | ||
935 | if ( type() == GuiServer ) { | 877 | if ( type() == GuiServer ) { |
936 | setVolume(); | 878 | setVolume(); |
937 | } | 879 | } |
938 | 880 | ||
939 | installEventFilter( this ); | 881 | installEventFilter( this ); |
940 | 882 | ||
941 | QPEMenuToolFocusManager::initialize(); | 883 | QPEMenuToolFocusManager::initialize(); |
942 | 884 | ||
943 | #ifdef QT_NO_QWS_CURSOR | 885 | #ifdef QT_NO_QWS_CURSOR |
944 | // if we have no cursor, probably don't want tooltips | 886 | // if we have no cursor, probably don't want tooltips |
945 | QToolTip::setEnabled( FALSE ); | 887 | QToolTip::setEnabled( FALSE ); |
946 | #endif | 888 | #endif |
947 | } | 889 | } |
948 | 890 | ||
949 | 891 | ||
950 | #ifdef QTOPIA_INTERNAL_INITAPP | 892 | #ifdef QTOPIA_INTERNAL_INITAPP |
951 | void QPEApplication::initApp( int argc, char **argv ) | 893 | void QPEApplication::initApp( int argc, char **argv ) |
952 | { | 894 | { |
953 | delete pidChannel; | 895 | delete pidChannel; |
954 | d->keep_running = TRUE; | 896 | d->keep_running = TRUE; |
955 | d->preloaded = FALSE; | 897 | d->preloaded = FALSE; |
956 | d->forceshow = FALSE; | 898 | d->forceshow = FALSE; |
957 | 899 | ||
958 | QCString channel = QCString(argv[0]); | 900 | QCString channel = QCString(argv[0]); |
959 | 901 | ||
960 | channel.replace(QRegExp(".*/"),""); | 902 | channel.replace(QRegExp(".*/"),""); |
961 | d->appName = channel; | 903 | d->appName = channel; |
962 | 904 | ||
963 | #if QT_VERSION > 235 | 905 | #if QT_VERSION > 235 |
964 | qt_fbdpy->setIdentity( channel ); // In Qt/E 2.3.6 | 906 | qt_fbdpy->setIdentity( channel ); // In Qt/E 2.3.6 |
965 | #endif | 907 | #endif |
966 | 908 | ||
967 | channel = "QPE/Application/" + channel; | 909 | channel = "QPE/Application/" + channel; |
968 | pidChannel = new QCopChannel( channel, this); | 910 | pidChannel = new QCopChannel( channel, this); |
969 | connect( pidChannel, SIGNAL(received(const QCString&,const QByteArray&)), | 911 | connect( pidChannel, SIGNAL(received(const QCString&,const QByteArray&)), |
970 | this, SLOT(pidMessage(const QCString&,const QByteArray&))); | 912 | this, SLOT(pidMessage(const QCString&,const QByteArray&))); |
971 | 913 | ||
972 | 914 | ||
973 | 915 | ||
974 | processQCopFile(); | 916 | processQCopFile(); |
975 | d->keep_running = d->qcopq.isEmpty(); | 917 | d->keep_running = d->qcopq.isEmpty(); |
976 | 918 | ||
977 | for (int a=0; a<argc; a++) { | 919 | for (int a=0; a<argc; a++) { |
978 | if ( qstrcmp(argv[a],"-preload")==0 ) { | 920 | if ( qstrcmp(argv[a],"-preload")==0 ) { |
979 | argv[a] = argv[a+1]; | 921 | argv[a] = argv[a+1]; |
980 | a++; | 922 | a++; |
981 | d->preloaded = TRUE; | 923 | d->preloaded = TRUE; |
982 | argc-=1; | 924 | argc-=1; |
983 | } else if ( qstrcmp(argv[a],"-preload-show")==0 ) { | 925 | } else if ( qstrcmp(argv[a],"-preload-show")==0 ) { |
984 | argv[a] = argv[a+1]; | 926 | argv[a] = argv[a+1]; |
985 | a++; | 927 | a++; |
986 | d->preloaded = TRUE; | 928 | d->preloaded = TRUE; |
987 | d->forceshow = TRUE; | 929 | d->forceshow = TRUE; |
988 | argc-=1; | 930 | argc-=1; |
989 | } | 931 | } |
990 | } | 932 | } |
991 | 933 | ||
992 | /* overide stored arguments */ | 934 | /* overide stored arguments */ |
993 | setArgs(argc, argv); | 935 | setArgs(argc, argv); |
994 | 936 | ||
995 | /* install translation here */ | 937 | /* install translation here */ |
996 | for ( QStringList::ConstIterator it = d->langs.begin(); it != d->langs.end(); ++it ) | 938 | for ( QStringList::ConstIterator it = d->langs.begin(); it != d->langs.end(); ++it ) |
997 | installTranslation( (*it) + "/" + d->appName + ".qm" ); | 939 | installTranslation( (*it) + "/" + d->appName + ".qm" ); |
998 | } | 940 | } |
999 | #endif | 941 | #endif |
1000 | 942 | ||
1001 | 943 | ||
1002 | static QPtrDict<void>* inputMethodDict = 0; | 944 | static QPtrDict<void>* inputMethodDict = 0; |
1003 | static void createInputMethodDict() | 945 | static void createInputMethodDict() |
1004 | { | 946 | { |
1005 | if ( !inputMethodDict ) | 947 | if ( !inputMethodDict ) |
1006 | inputMethodDict = new QPtrDict<void>; | 948 | inputMethodDict = new QPtrDict<void>; |
1007 | } | 949 | } |
1008 | 950 | ||
1009 | /*! | 951 | /*! |
1010 | Returns the currently set hint to the system as to whether | 952 | Returns the currently set hint to the system as to whether |
1011 | widget \a w has any use for text input methods. | 953 | widget \a w has any use for text input methods. |
1012 | 954 | ||
1013 | 955 | ||
1014 | \sa setInputMethodHint() InputMethodHint | 956 | \sa setInputMethodHint() InputMethodHint |
1015 | */ | 957 | */ |
1016 | QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w ) | 958 | QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w ) |
1017 | { | 959 | { |
1018 | if ( inputMethodDict && w ) | 960 | if ( inputMethodDict && w ) |
1019 | return ( InputMethodHint ) ( int ) inputMethodDict->find( w ); | 961 | return ( InputMethodHint ) ( int ) inputMethodDict->find( w ); |
1020 | return Normal; | 962 | return Normal; |
1021 | } | 963 | } |
1022 | 964 | ||
1023 | /*! | 965 | /*! |
1024 | \enum QPEApplication::InputMethodHint | 966 | \enum QPEApplication::InputMethodHint |
1025 | 967 | ||
1026 | \value Normal the application sometimes needs text input (the default). | 968 | \value Normal the application sometimes needs text input (the default). |
1027 | \value AlwaysOff the application never needs text input. | 969 | \value AlwaysOff the application never needs text input. |
1028 | \value AlwaysOn the application always needs text input. | 970 | \value AlwaysOn the application always needs text input. |
1029 | */ | 971 | */ |
1030 | 972 | ||
1031 | /*! | 973 | /*! |
1032 | Hints to the system that widget \a w has use for text input methods | 974 | Hints to the system that widget \a w has use for text input methods |
1033 | as specified by \a mode. | 975 | as specified by \a mode. |
1034 | 976 | ||
1035 | \sa inputMethodHint() InputMethodHint | 977 | \sa inputMethodHint() InputMethodHint |
1036 | */ | 978 | */ |
1037 | void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode ) | 979 | void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode ) |
1038 | { | 980 | { |
1039 | createInputMethodDict(); | 981 | createInputMethodDict(); |
1040 | if ( mode == Normal ) { | 982 | if ( mode == Normal ) { |
1041 | inputMethodDict->remove | 983 | inputMethodDict->remove |
1042 | ( w ); | 984 | ( w ); |
1043 | } | 985 | } |
1044 | else { | 986 | else { |
1045 | inputMethodDict->insert( w, ( void* ) mode ); | 987 | inputMethodDict->insert( w, ( void* ) mode ); |
1046 | } | 988 | } |
1047 | } | 989 | } |
1048 | 990 | ||
1049 | class HackDialog : public QDialog | 991 | class HackDialog : public QDialog |
1050 | { | 992 | { |
1051 | public: | 993 | public: |
1052 | void acceptIt() | 994 | void acceptIt() |
1053 | { | 995 | { |
1054 | accept(); | 996 | accept(); |
1055 | } | 997 | } |
1056 | void rejectIt() | 998 | void rejectIt() |
1057 | { | 999 | { |
1058 | reject(); | 1000 | reject(); |
1059 | } | 1001 | } |
1060 | }; | 1002 | }; |
1061 | 1003 | ||
1062 | 1004 | ||
1063 | void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key ) | 1005 | void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key ) |
1064 | { | 1006 | { |
1065 | // specialised actions for certain widgets. May want to | 1007 | // specialised actions for certain widgets. May want to |
1066 | // add more stuff here. | 1008 | // add more stuff here. |
1067 | if ( activePopupWidget() && activePopupWidget() ->inherits( "QListBox" ) | 1009 | if ( activePopupWidget() && activePopupWidget() ->inherits( "QListBox" ) |
1068 | && activePopupWidget() ->parentWidget() | 1010 | && activePopupWidget() ->parentWidget() |
1069 | && activePopupWidget() ->parentWidget() ->inherits( "QComboBox" ) ) | 1011 | && activePopupWidget() ->parentWidget() ->inherits( "QComboBox" ) ) |
1070 | key = Qt::Key_Return; | 1012 | key = Qt::Key_Return; |
1071 | 1013 | ||
1072 | if ( activePopupWidget() && activePopupWidget() ->inherits( "QPopupMenu" ) ) | 1014 | if ( activePopupWidget() && activePopupWidget() ->inherits( "QPopupMenu" ) ) |
1073 | key = Qt::Key_Return; | 1015 | key = Qt::Key_Return; |
1074 | 1016 | ||
1075 | #ifdef QWS | 1017 | #ifdef QWS |
1076 | 1018 | ||
1077 | ke->simpleData.keycode = key; | 1019 | ke->simpleData.keycode = key; |
1078 | #endif | 1020 | #endif |
1079 | } | 1021 | } |
1080 | 1022 | ||
1081 | 1023 | ||
1082 | /*! | 1024 | /*! |
1083 | \internal | 1025 | \internal |
1084 | */ | 1026 | */ |
1085 | 1027 | ||
1086 | #ifdef QWS | 1028 | #ifdef QWS |
1087 | bool QPEApplication::qwsEventFilter( QWSEvent * e ) | 1029 | bool QPEApplication::qwsEventFilter( QWSEvent * e ) |
1088 | { | 1030 | { |
1089 | if ( !d->notbusysent && e->type == QWSEvent::Focus ) { | 1031 | if ( !d->notbusysent && e->type == QWSEvent::Focus ) { |
1090 | if ( qApp->type() != QApplication::GuiServer ) { | 1032 | if ( qApp->type() != QApplication::GuiServer ) { |
1091 | QCopEnvelope e( "QPE/System", "notBusy(QString)" ); | 1033 | QCopEnvelope e( "QPE/System", "notBusy(QString)" ); |
1092 | e << d->appName; | 1034 | e << d->appName; |
1093 | } | 1035 | } |
1094 | d->notbusysent = TRUE; | 1036 | d->notbusysent = TRUE; |
1095 | } | 1037 | } |
1096 | if ( type() == GuiServer ) { | 1038 | if ( type() == GuiServer ) { |
1097 | switch ( e->type ) { | 1039 | switch ( e->type ) { |
1098 | case QWSEvent::Mouse: | 1040 | case QWSEvent::Mouse: |
1099 | if ( e->asMouse() ->simpleData.state && !QWidget::find( e->window() ) ) | 1041 | if ( e->asMouse() ->simpleData.state && !QWidget::find( e->window() ) ) |
1100 | emit clientMoused(); | 1042 | emit clientMoused(); |
1101 | break; | 1043 | break; |
1102 | default: | 1044 | default: |
1103 | break; | 1045 | break; |
1104 | } | 1046 | } |
1105 | } | 1047 | } |
1106 | if ( e->type == QWSEvent::Key ) { | 1048 | if ( e->type == QWSEvent::Key ) { |
1107 | QWSKeyEvent *ke = ( QWSKeyEvent * ) e; | 1049 | QWSKeyEvent *ke = ( QWSKeyEvent * ) e; |
1108 | if ( ke->simpleData.keycode == Qt::Key_F33 ) { | 1050 | if ( ke->simpleData.keycode == Qt::Key_F33 ) { |
1109 | // Use special "OK" key to press "OK" on top level widgets | 1051 | // Use special "OK" key to press "OK" on top level widgets |
1110 | QWidget * active = activeWindow(); | 1052 | QWidget * active = activeWindow(); |
1111 | QWidget *popup = 0; | 1053 | QWidget *popup = 0; |
1112 | if ( active && active->isPopup() ) { | 1054 | if ( active && active->isPopup() ) { |
1113 | popup = active; | 1055 | popup = active; |
1114 | active = active->parentWidget(); | 1056 | active = active->parentWidget(); |
1115 | } | 1057 | } |
1116 | if ( active && ( int ) active->winId() == ke->simpleData.window && | 1058 | if ( active && ( int ) active->winId() == ke->simpleData.window && |
1117 | !active->testWFlags( WStyle_Customize | WType_Popup | WType_Desktop ) ) { | 1059 | !active->testWFlags( WStyle_Customize | WType_Popup | WType_Desktop ) ) { |
1118 | if ( ke->simpleData.is_press ) { | 1060 | if ( ke->simpleData.is_press ) { |
1119 | if ( popup ) | 1061 | if ( popup ) |
1120 | popup->close(); | 1062 | popup->close(); |
1121 | if ( active->inherits( "QDialog" ) ) { | 1063 | if ( active->inherits( "QDialog" ) ) { |
1122 | HackDialog * d = ( HackDialog * ) active; | 1064 | HackDialog * d = ( HackDialog * ) active; |
1123 | d->acceptIt(); | 1065 | d->acceptIt(); |
1124 | return TRUE; | 1066 | return TRUE; |
1125 | } | 1067 | } |
1126 | else if ( ( ( HackWidget * ) active ) ->needsOk() ) { | 1068 | else if ( ( ( HackWidget * ) active ) ->needsOk() ) { |
1127 | QSignal s; | 1069 | QSignal s; |
1128 | s.connect( active, SLOT( accept() ) ); | 1070 | s.connect( active, SLOT( accept() ) ); |
1129 | s.activate(); | 1071 | s.activate(); |
1130 | } | 1072 | } |
1131 | else { | 1073 | else { |
1132 | // do the same as with the select key: Map to the default action of the widget: | 1074 | // do the same as with the select key: Map to the default action of the widget: |
1133 | mapToDefaultAction( ke, Qt::Key_Return ); | 1075 | mapToDefaultAction( ke, Qt::Key_Return ); |
1134 | } | 1076 | } |
1135 | } | 1077 | } |
1136 | } | 1078 | } |
1137 | } | 1079 | } |
1138 | else if ( ke->simpleData.keycode == Qt::Key_F30 ) { | 1080 | else if ( ke->simpleData.keycode == Qt::Key_F30 ) { |
1139 | // Use special "select" key to do whatever default action a widget has | 1081 | // Use special "select" key to do whatever default action a widget has |
1140 | mapToDefaultAction( ke, Qt::Key_Space ); | 1082 | mapToDefaultAction( ke, Qt::Key_Space ); |
1141 | } | 1083 | } |
1142 | else if ( ke->simpleData.keycode == Qt::Key_Escape && | 1084 | else if ( ke->simpleData.keycode == Qt::Key_Escape && |
1143 | ke->simpleData.is_press ) { | 1085 | ke->simpleData.is_press ) { |
1144 | // Escape key closes app if focus on toplevel | 1086 | // Escape key closes app if focus on toplevel |
1145 | QWidget * active = activeWindow(); | 1087 | QWidget * active = activeWindow(); |
1146 | if ( active && active->testWFlags( WType_TopLevel ) && | 1088 | if ( active && active->testWFlags( WType_TopLevel ) && |
1147 | ( int ) active->winId() == ke->simpleData.window && | 1089 | ( int ) active->winId() == ke->simpleData.window && |
1148 | !active->testWFlags( WStyle_Dialog | WStyle_Customize | WType_Popup | WType_Desktop ) ) { | 1090 | !active->testWFlags( WStyle_Dialog | WStyle_Customize | WType_Popup | WType_Desktop ) ) { |
1149 | if ( active->inherits( "QDialog" ) ) { | 1091 | if ( active->inherits( "QDialog" ) ) { |
1150 | HackDialog * d = ( HackDialog * ) active; | 1092 | HackDialog * d = ( HackDialog * ) active; |
1151 | d->rejectIt(); | 1093 | d->rejectIt(); |
1152 | return TRUE; | 1094 | return TRUE; |
1153 | } else /*if ( strcmp( argv() [ 0 ], "embeddedkonsole" ) != 0 )*/ { | 1095 | } else /*if ( strcmp( argv() [ 0 ], "embeddedkonsole" ) != 0 )*/ { |
1154 | active->close(); | 1096 | active->close(); |
1155 | } | 1097 | } |
1156 | } | 1098 | } |
1157 | 1099 | ||
1158 | } | 1100 | } |
1159 | else if ( ke->simpleData.keycode >= Qt::Key_F1 && ke->simpleData.keycode <= Qt::Key_F29 ) { | 1101 | else if ( ke->simpleData.keycode >= Qt::Key_F1 && ke->simpleData.keycode <= Qt::Key_F29 ) { |
1160 | // this should be if ( ODevice::inst ( )-> buttonForKeycode ( ... )) | 1102 | // this should be if ( ODevice::inst ( )-> buttonForKeycode ( ... )) |
1161 | // but we cannot access libopie function within libqpe :( | 1103 | // but we cannot access libopie function within libqpe :( |
1162 | 1104 | ||
1163 | QWidget * active = activeWindow ( ); | 1105 | QWidget * active = activeWindow ( ); |
1164 | if ( active && ((int) active-> winId ( ) == ke-> simpleData.window )) { | 1106 | if ( active && ((int) active-> winId ( ) == ke-> simpleData.window )) { |
1165 | if ( d-> kbgrabbed ) { // we grabbed the keyboard | 1107 | if ( d-> kbgrabbed ) { // we grabbed the keyboard |
1166 | QChar ch ( ke-> simpleData.unicode ); | 1108 | QChar ch ( ke-> simpleData.unicode ); |
1167 | QKeyEvent qke ( ke-> simpleData. is_press ? QEvent::KeyPress : QEvent::KeyRelease, | 1109 | QKeyEvent qke ( ke-> simpleData. is_press ? QEvent::KeyPress : QEvent::KeyRelease, |
1168 | ke-> simpleData.keycode, | 1110 | ke-> simpleData.keycode, |
1169 | ch. latin1 ( ), | 1111 | ch. latin1 ( ), |
1170 | ke-> simpleData.modifiers, | 1112 | ke-> simpleData.modifiers, |
1171 | QString ( ch ), | 1113 | QString ( ch ), |
1172 | ke-> simpleData.is_auto_repeat, 1 ); | 1114 | ke-> simpleData.is_auto_repeat, 1 ); |
1173 | 1115 | ||
1174 | QObject *which = QWidget::keyboardGrabber ( ); | 1116 | QObject *which = QWidget::keyboardGrabber ( ); |
1175 | if ( !which ) | 1117 | if ( !which ) |
1176 | which = QApplication::focusWidget ( ); | 1118 | which = QApplication::focusWidget ( ); |
1177 | if ( !which ) | 1119 | if ( !which ) |
1178 | which = QApplication::activeWindow ( ); | 1120 | which = QApplication::activeWindow ( ); |
1179 | if ( !which ) | 1121 | if ( !which ) |
1180 | which = qApp; | 1122 | which = qApp; |
1181 | 1123 | ||
1182 | QApplication::sendEvent ( which, &qke ); | 1124 | QApplication::sendEvent ( which, &qke ); |
1183 | } | 1125 | } |
1184 | else { // we didn't grab the keyboard, so send the event to the launcher | 1126 | else { // we didn't grab the keyboard, so send the event to the launcher |
1185 | QCopEnvelope e ( "QPE/Launcher", "deviceButton(int,int,int)" ); | 1127 | QCopEnvelope e ( "QPE/Launcher", "deviceButton(int,int,int)" ); |
1186 | e << int( ke-> simpleData.keycode ) << int( ke-> simpleData. is_press ) << int( ke-> simpleData.is_auto_repeat ); | 1128 | e << int( ke-> simpleData.keycode ) << int( ke-> simpleData. is_press ) << int( ke-> simpleData.is_auto_repeat ); |
1187 | } | 1129 | } |
1188 | } | 1130 | } |
1189 | return true; | 1131 | return true; |
1190 | } | 1132 | } |
1191 | } | 1133 | } |
1192 | if ( e->type == QWSEvent::Focus ) { | 1134 | if ( e->type == QWSEvent::Focus ) { |
1193 | QWSFocusEvent * fe = ( QWSFocusEvent* ) e; | 1135 | QWSFocusEvent * fe = ( QWSFocusEvent* ) e; |
1194 | if ( !fe->simpleData.get_focus ) { | 1136 | if ( !fe->simpleData.get_focus ) { |
1195 | QWidget * active = activeWindow(); | 1137 | QWidget * active = activeWindow(); |
1196 | while ( active && active->isPopup() ) { | 1138 | while ( active && active->isPopup() ) { |
1197 | active->close(); | 1139 | active->close(); |
1198 | active = activeWindow(); | 1140 | active = activeWindow(); |
1199 | } | 1141 | } |
1200 | } | 1142 | } |
1201 | else { | 1143 | else { |
1202 | // make sure our modal widget is ALWAYS on top | 1144 | // make sure our modal widget is ALWAYS on top |
1203 | QWidget *topm = activeModalWidget(); | 1145 | QWidget *topm = activeModalWidget(); |
1204 | if ( topm && static_cast<int>( topm->winId() ) != fe->simpleData.window) { | 1146 | if ( topm && static_cast<int>( topm->winId() ) != fe->simpleData.window) { |
1205 | topm->raise(); | 1147 | topm->raise(); |
1206 | } | 1148 | } |
1207 | } | 1149 | } |
1208 | if ( fe->simpleData.get_focus && inputMethodDict ) { | 1150 | if ( fe->simpleData.get_focus && inputMethodDict ) { |
1209 | InputMethodHint m = inputMethodHint( QWidget::find( e->window() ) ); | 1151 | InputMethodHint m = inputMethodHint( QWidget::find( e->window() ) ); |
1210 | if ( m == AlwaysOff ) | 1152 | if ( m == AlwaysOff ) |
1211 | Global::hideInputMethod(); | 1153 | Global::hideInputMethod(); |
1212 | if ( m == AlwaysOn ) | 1154 | if ( m == AlwaysOn ) |
1213 | Global::showInputMethod(); | 1155 | Global::showInputMethod(); |
1214 | } | 1156 | } |
1215 | } | 1157 | } |
1216 | 1158 | ||
1217 | 1159 | ||
1218 | return QApplication::qwsEventFilter( e ); | 1160 | return QApplication::qwsEventFilter( e ); |
1219 | } | 1161 | } |
1220 | #endif | 1162 | #endif |
1221 | 1163 | ||
1222 | /*! | 1164 | /*! |
1223 | Destroys the QPEApplication. | 1165 | Destroys the QPEApplication. |
1224 | */ | 1166 | */ |
1225 | QPEApplication::~QPEApplication() | 1167 | QPEApplication::~QPEApplication() |
1226 | { | 1168 | { |
1227 | ungrabKeyboard(); | 1169 | ungrabKeyboard(); |
1228 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 1170 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
1229 | // Need to delete QCopChannels early, since the display will | 1171 | // Need to delete QCopChannels early, since the display will |
1230 | // be gone by the time we get to ~QObject(). | 1172 | // be gone by the time we get to ~QObject(). |
1231 | delete sysChannel; | 1173 | delete sysChannel; |
1232 | delete pidChannel; | 1174 | delete pidChannel; |
1233 | #endif | 1175 | #endif |
1234 | 1176 | ||
1235 | #ifdef OPIE_WITHROHFEEDBACK | 1177 | #ifdef OPIE_WITHROHFEEDBACK |
1236 | if( d->RoH ) | 1178 | if( d->RoH ) |
1237 | delete d->RoH; | 1179 | delete d->RoH; |
1238 | #endif | 1180 | #endif |
1239 | delete d; | 1181 | delete d; |
1240 | } | 1182 | } |
1241 | 1183 | ||
1242 | /*! | 1184 | /*! |
1243 | Returns <tt>$OPIEDIR/</tt>. | 1185 | Returns <tt>$OPIEDIR/</tt>. |
1244 | */ | 1186 | */ |
1245 | QString QPEApplication::qpeDir() | 1187 | QString QPEApplication::qpeDir() |
1246 | { | 1188 | { |
1247 | const char * base = getenv( "OPIEDIR" ); | 1189 | const char * base = getenv( "OPIEDIR" ); |
1248 | if ( base ) | 1190 | if ( base ) |
1249 | return QString( base ) + "/"; | 1191 | return QString( base ) + "/"; |
1250 | 1192 | ||
1251 | return QString( "../" ); | 1193 | return QString( "../" ); |
1252 | } | 1194 | } |
1253 | 1195 | ||
1254 | /*! | 1196 | /*! |
1255 | Returns the user's current Document directory. There is a trailing "/". | 1197 | Returns the user's current Document directory. There is a trailing "/". |
1256 | .. well, it does now,, and there's no trailing '/' | 1198 | .. well, it does now,, and there's no trailing '/' |
1257 | */ | 1199 | */ |
1258 | QString QPEApplication::documentDir() | 1200 | QString QPEApplication::documentDir() |
1259 | { | 1201 | { |
1260 | const char* base = getenv( "HOME"); | 1202 | const char* base = getenv( "HOME"); |
1261 | if ( base ) | 1203 | if ( base ) |
1262 | return QString( base ) + "/Documents"; | 1204 | return QString( base ) + "/Documents"; |
1263 | 1205 | ||
1264 | return QString( "../Documents" ); | 1206 | return QString( "../Documents" ); |
1265 | } | 1207 | } |
1266 | 1208 | ||
1267 | static int deforient = -1; | 1209 | static int deforient = -1; |
1268 | 1210 | ||
1269 | /*! | 1211 | /*! |
1270 | \internal | 1212 | \internal |
1271 | */ | 1213 | */ |
1272 | int QPEApplication::defaultRotation() | 1214 | int QPEApplication::defaultRotation() |
1273 | { | 1215 | { |
1274 | if ( deforient < 0 ) { | 1216 | if ( deforient < 0 ) { |
1275 | QString d = getenv( "QWS_DISPLAY" ); | 1217 | QString d = getenv( "QWS_DISPLAY" ); |
1276 | if ( d.contains( "Rot90" ) ) { | 1218 | if ( d.contains( "Rot90" ) ) { |
1277 | deforient = 90; | 1219 | deforient = 90; |
1278 | } | 1220 | } |
1279 | else if ( d.contains( "Rot180" ) ) { | 1221 | else if ( d.contains( "Rot180" ) ) { |
1280 | deforient = 180; | 1222 | deforient = 180; |
1281 | } | 1223 | } |
1282 | else if ( d.contains( "Rot270" ) ) { | 1224 | else if ( d.contains( "Rot270" ) ) { |
1283 | deforient = 270; | 1225 | deforient = 270; |
1284 | } | 1226 | } |
1285 | else { | 1227 | else { |
1286 | deforient = 0; | 1228 | deforient = 0; |
1287 | } | 1229 | } |
1288 | } | 1230 | } |
1289 | return deforient; | 1231 | return deforient; |
1290 | } | 1232 | } |
1291 | 1233 | ||
1292 | /*! | 1234 | /*! |
1293 | \internal | 1235 | \internal |
1294 | */ | 1236 | */ |
1295 | void QPEApplication::setDefaultRotation( int r ) | 1237 | void QPEApplication::setDefaultRotation( int r ) |
1296 | { | 1238 | { |
1297 | if ( qApp->type() == GuiServer ) { | 1239 | if ( qApp->type() == GuiServer ) { |
1298 | deforient = r; | 1240 | deforient = r; |
1299 | setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 ); | 1241 | setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 ); |
1300 | Config config("qpe"); | 1242 | Config config("qpe"); |
1301 | config.setGroup( "Rotation" ); | 1243 | config.setGroup( "Rotation" ); |
1302 | config.writeEntry( "Rot", r ); | 1244 | config.writeEntry( "Rot", r ); |
1303 | } | 1245 | } |
1304 | else { | 1246 | else { |
1305 | #ifndef QT_NO_COP | 1247 | #ifndef QT_NO_COP |
1306 | { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" ); | 1248 | { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" ); |
1307 | e << r; | 1249 | e << r; |
1308 | } | 1250 | } |
1309 | #endif | 1251 | #endif |
1310 | 1252 | ||
1311 | } | 1253 | } |
1312 | } | 1254 | } |
1313 | 1255 | ||
1314 | #include <qgfx_qws.h> | 1256 | #include <qgfx_qws.h> |
1315 | #include <qwindowsystem_qws.h> | 1257 | #include <qwindowsystem_qws.h> |
1316 | 1258 | ||
1317 | #if QT_VERSION > 236 | 1259 | #if QT_VERSION > 236 |
1318 | extern void qws_clearLoadedFonts(); | 1260 | extern void qws_clearLoadedFonts(); |
1319 | #endif | 1261 | #endif |
1320 | 1262 | ||
1321 | void QPEApplication::setCurrentMode( int x, int y, int depth ) | 1263 | void QPEApplication::setCurrentMode( int x, int y, int depth ) |
1322 | { | 1264 | { |
1323 | // Reset the caches | 1265 | // Reset the caches |
1324 | #if QT_VERSION > 236 | 1266 | #if QT_VERSION > 236 |
1325 | qws_clearLoadedFonts(); | 1267 | qws_clearLoadedFonts(); |
1326 | #endif | 1268 | #endif |
1327 | QPixmapCache::clear(); | 1269 | QPixmapCache::clear(); |
1328 | 1270 | ||
1329 | // Change the screen mode | 1271 | // Change the screen mode |
1330 | qt_screen->setMode(x, y, depth); | 1272 | qt_screen->setMode(x, y, depth); |
1331 | 1273 | ||
1332 | if ( qApp->type() == GuiServer ) { | 1274 | if ( qApp->type() == GuiServer ) { |
1333 | #if QT_VERSION > 236 | 1275 | #if QT_VERSION > 236 |
1334 | // Reconfigure the GuiServer | 1276 | // Reconfigure the GuiServer |
1335 | qwsServer->beginDisplayReconfigure(); | 1277 | qwsServer->beginDisplayReconfigure(); |
1336 | qwsServer->endDisplayReconfigure(); | 1278 | qwsServer->endDisplayReconfigure(); |
1337 | #endif | 1279 | #endif |
1338 | // Get all the running apps to reset | 1280 | // Get all the running apps to reset |
1339 | QCopEnvelope env( "QPE/System", "reset()" ); | 1281 | QCopEnvelope env( "QPE/System", "reset()" ); |
1340 | } | 1282 | } |
1341 | } | 1283 | } |
1342 | 1284 | ||
1343 | void QPEApplication::reset() { | 1285 | void QPEApplication::reset() { |
1344 | // Reconnect to the screen | 1286 | // Reconnect to the screen |
1345 | qt_screen->disconnect(); | 1287 | qt_screen->disconnect(); |
1346 | qt_screen->connect( QString::null ); | 1288 | qt_screen->connect( QString::null ); |
1347 | 1289 | ||
1348 | // Redraw everything | 1290 | // Redraw everything |
1349 | applyStyle(); | 1291 | applyStyle(); |
1350 | } | 1292 | } |
1351 | 1293 | ||
1352 | #if (QT_VERSION < 238) && defined Q_OS_MACX | 1294 | #if (QT_VERSION < 238) && defined Q_OS_MACX |
1353 | bool qt_left_hand_scrollbars = false; | 1295 | bool qt_left_hand_scrollbars = false; |
1354 | #else | 1296 | #else |
1355 | #ifdef Q_OS_MACX | 1297 | #ifdef Q_OS_MACX |
1356 | #define WEAK_SYMBOL __attribute__((weak_import)) | 1298 | #define WEAK_SYMBOL __attribute__((weak_import)) |
1357 | #else | 1299 | #else |
1358 | #define WEAK_SYMBOL __attribute__((weak)) | 1300 | #define WEAK_SYMBOL __attribute__((weak)) |
1359 | #endif | 1301 | #endif |
1360 | extern bool qt_left_hand_scrollbars WEAK_SYMBOL; | 1302 | extern bool qt_left_hand_scrollbars WEAK_SYMBOL; |
1361 | #endif | 1303 | #endif |
1362 | 1304 | ||
1363 | /*! | 1305 | /*! |
1364 | \internal | 1306 | \internal |
1365 | */ | 1307 | */ |
1366 | void QPEApplication::applyStyle() | 1308 | void QPEApplication::applyStyle() |
1367 | { | 1309 | { |
1368 | Config config( "qpe" ); | 1310 | Config config( "qpe" ); |
1369 | config.setGroup( "Appearance" ); | 1311 | config.setGroup( "Appearance" ); |
1370 | 1312 | ||
1371 | #if QT_VERSION > 233 | 1313 | #if QT_VERSION > 233 |
1372 | #if !defined(OPIE_NO_OVERRIDE_QT) | 1314 | #if !defined(OPIE_NO_OVERRIDE_QT) |
1373 | // don't block ourselves ... | 1315 | // don't block ourselves ... |
1374 | Opie::force_appearance = 0; | 1316 | Opie::force_appearance = 0; |
1375 | 1317 | ||
1376 | static QString appname = Opie::binaryName ( ); | 1318 | static QString appname = Opie::binaryName ( ); |
1377 | 1319 | ||
1378 | QStringList ex = config. readListEntry ( "NoStyle", ';' ); | 1320 | QStringList ex = config. readListEntry ( "NoStyle", ';' ); |
1379 | int nostyle = 0; | 1321 | int nostyle = 0; |
1380 | for ( QStringList::Iterator it = ex. begin ( ); it != ex. end ( ); ++it ) { | 1322 | for ( QStringList::Iterator it = ex. begin ( ); it != ex. end ( ); ++it ) { |
1381 | if ( QRegExp (( *it ). mid ( 1 ), false, true ). find ( appname, 0 ) >= 0 ) { | 1323 | if ( QRegExp (( *it ). mid ( 1 ), false, true ). find ( appname, 0 ) >= 0 ) { |
1382 | nostyle = ( *it ). left ( 1 ). toInt ( 0, 32 ); | 1324 | nostyle = ( *it ). left ( 1 ). toInt ( 0, 32 ); |
1383 | break; | 1325 | break; |
1384 | } | 1326 | } |
1385 | } | 1327 | } |
1386 | #else | 1328 | #else |
1387 | int nostyle = 0; | 1329 | int nostyle = 0; |
1388 | #endif | 1330 | #endif |
1389 | 1331 | ||
1390 | // Widget style | 1332 | // Widget style |
1391 | QString style = config.readEntry( "Style", "FlatStyle" ); | 1333 | QString style = config.readEntry( "Style", "FlatStyle" ); |
1392 | 1334 | ||
1393 | // don't set a custom style | 1335 | // don't set a custom style |
1394 | if ( nostyle & Opie::Force_Style ) | 1336 | if ( nostyle & Opie::Force_Style ) |
1395 | style = "FlatStyle"; | 1337 | style = "FlatStyle"; |
1396 | 1338 | ||
1397 | internalSetStyle ( style ); | 1339 | internalSetStyle ( style ); |
1398 | 1340 | ||
1399 | // Colors - from /etc/colors/Liquid.scheme | 1341 | // Colors - from /etc/colors/Liquid.scheme |
1400 | QColor bgcolor( config.readEntry( "Background", "#E0E0E0" ) ); | 1342 | QColor bgcolor( config.readEntry( "Background", "#E0E0E0" ) ); |
1401 | QColor btncolor( config.readEntry( "Button", "#96c8fa" ) ); | 1343 | QColor btncolor( config.readEntry( "Button", "#96c8fa" ) ); |
1402 | QPalette pal( btncolor, bgcolor ); | 1344 | QPalette pal( btncolor, bgcolor ); |
1403 | QString color = config.readEntry( "Highlight", "#73adef" ); | 1345 | QString color = config.readEntry( "Highlight", "#73adef" ); |
1404 | pal.setColor( QColorGroup::Highlight, QColor( color ) ); | 1346 | pal.setColor( QColorGroup::Highlight, QColor( color ) ); |
1405 | color = config.readEntry( "HighlightedText", "#FFFFFF" ); | 1347 | color = config.readEntry( "HighlightedText", "#FFFFFF" ); |
1406 | pal.setColor( QColorGroup::HighlightedText, QColor( color ) ); | 1348 | pal.setColor( QColorGroup::HighlightedText, QColor( color ) ); |
1407 | color = config.readEntry( "Text", "#000000" ); | 1349 | color = config.readEntry( "Text", "#000000" ); |
1408 | pal.setColor( QColorGroup::Text, QColor( color ) ); | 1350 | pal.setColor( QColorGroup::Text, QColor( color ) ); |
1409 | color = config.readEntry( "ButtonText", "#000000" ); | 1351 | color = config.readEntry( "ButtonText", "#000000" ); |
1410 | pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) ); | 1352 | pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) ); |
1411 | color = config.readEntry( "Base", "#FFFFFF" ); | 1353 | color = config.readEntry( "Base", "#FFFFFF" ); |
1412 | pal.setColor( QColorGroup::Base, QColor( color ) ); | 1354 | pal.setColor( QColorGroup::Base, QColor( color ) ); |
1413 | 1355 | ||
1414 | pal.setColor( QPalette::Disabled, QColorGroup::Text, | 1356 | pal.setColor( QPalette::Disabled, QColorGroup::Text, |
1415 | pal.color( QPalette::Active, QColorGroup::Background ).dark() ); | 1357 | pal.color( QPalette::Active, QColorGroup::Background ).dark() ); |
1416 | 1358 | ||
1417 | setPalette( pal, TRUE ); | 1359 | setPalette( pal, TRUE ); |
1418 | 1360 | ||
1419 | 1361 | ||
1420 | // Set the ScrollBar on the 'right' side but only if the weak symbol is present | 1362 | // Set the ScrollBar on the 'right' side but only if the weak symbol is present |
1421 | if (&qt_left_hand_scrollbars ) | 1363 | if (&qt_left_hand_scrollbars ) |
1422 | qt_left_hand_scrollbars = config.readBoolEntry( "LeftHand", false ); | 1364 | qt_left_hand_scrollbars = config.readBoolEntry( "LeftHand", false ); |
1423 | 1365 | ||
1424 | // Window Decoration | 1366 | // Window Decoration |
1425 | QString dec = config.readEntry( "Decoration", "Flat" ); | 1367 | QString dec = config.readEntry( "Decoration", "Flat" ); |
1426 | 1368 | ||
1427 | // don't set a custom deco | 1369 | // don't set a custom deco |
1428 | if ( nostyle & Opie::Force_Decoration ) | 1370 | if ( nostyle & Opie::Force_Decoration ) |
1429 | dec = ""; | 1371 | dec = ""; |
1430 | 1372 | ||
1431 | 1373 | ||
1432 | if ( dec != d->decorationName ) { | 1374 | if ( dec != d->decorationName ) { |
1433 | qwsSetDecoration( new QPEDecoration( dec ) ); | 1375 | qwsSetDecoration( new QPEDecoration( dec ) ); |
1434 | d->decorationName = dec; | 1376 | d->decorationName = dec; |
1435 | } | 1377 | } |
1436 | 1378 | ||
1437 | // Font | 1379 | // Font |
1438 | QString ff = config.readEntry( "FontFamily", font().family() ); | 1380 | QString ff = config.readEntry( "FontFamily", font().family() ); |
1439 | int fs = config.readNumEntry( "FontSize", font().pointSize() ); | 1381 | int fs = config.readNumEntry( "FontSize", font().pointSize() ); |
1440 | 1382 | ||
1441 | // don't set a custom font | 1383 | // don't set a custom font |
1442 | if ( nostyle & Opie::Force_Font ) { | 1384 | if ( nostyle & Opie::Force_Font ) { |
1443 | ff = "Vera"; | 1385 | ff = "Vera"; |
1444 | fs = 10; | 1386 | fs = 10; |
1445 | } | 1387 | } |
1446 | 1388 | ||
1447 | setFont ( QFont ( ff, fs ), true ); | 1389 | setFont ( QFont ( ff, fs ), true ); |
1448 | 1390 | ||
1449 | #if !defined(OPIE_NO_OVERRIDE_QT) | 1391 | #if !defined(OPIE_NO_OVERRIDE_QT) |
1450 | // revert to global blocking policy ... | 1392 | // revert to global blocking policy ... |
1451 | Opie::force_appearance = config. readBoolEntry ( "ForceStyle", false ) ? Opie::Force_All : Opie::Force_None; | 1393 | Opie::force_appearance = config. readBoolEntry ( "ForceStyle", false ) ? Opie::Force_All : Opie::Force_None; |
1452 | Opie::force_appearance &= ~nostyle; | 1394 | Opie::force_appearance &= ~nostyle; |
1453 | #endif | 1395 | #endif |
1454 | #endif | 1396 | #endif |
1455 | } | 1397 | } |
1456 | 1398 | ||
1457 | void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data ) | 1399 | void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data ) |
1458 | { | 1400 | { |
1459 | #ifdef Q_WS_QWS | 1401 | #ifdef Q_WS_QWS |
1460 | QDataStream stream( data, IO_ReadOnly ); | 1402 | QDataStream stream( data, IO_ReadOnly ); |
1461 | if ( msg == "applyStyle()" ) { | 1403 | if ( msg == "applyStyle()" ) { |
1462 | applyStyle(); | 1404 | applyStyle(); |
1463 | } | 1405 | } |
1464 | else if ( msg == "toggleApplicationMenu()" ) { | 1406 | else if ( msg == "toggleApplicationMenu()" ) { |
1465 | QWidget *active = activeWindow ( ); | 1407 | QWidget *active = activeWindow ( ); |
1466 | 1408 | ||
1467 | if ( active ) { | 1409 | if ( active ) { |
1468 | QPEMenuToolFocusManager *man = QPEMenuToolFocusManager::manager ( ); | 1410 | QPEMenuToolFocusManager *man = QPEMenuToolFocusManager::manager ( ); |
1469 | bool oldactive = man-> isActive ( ); | 1411 | bool oldactive = man-> isActive ( ); |
1470 | 1412 | ||
1471 | man-> setActive( !man-> isActive() ); | 1413 | man-> setActive( !man-> isActive() ); |
1472 | 1414 | ||
1473 | if ( !oldactive && !man-> isActive ( )) { // no menubar to toggle -> try O-Menu | 1415 | if ( !oldactive && !man-> isActive ( )) { // no menubar to toggle -> try O-Menu |
1474 | QCopEnvelope e ( "QPE/TaskBar", "toggleStartMenu()" ); | 1416 | QCopEnvelope e ( "QPE/TaskBar", "toggleStartMenu()" ); |
1475 | } | 1417 | } |
1476 | } | 1418 | } |
1477 | } | 1419 | } |
1478 | else if ( msg == "setDefaultRotation(int)" ) { | 1420 | else if ( msg == "setDefaultRotation(int)" ) { |
1479 | if ( type() == GuiServer ) { | 1421 | if ( type() == GuiServer ) { |
1480 | int r; | 1422 | int r; |
1481 | stream >> r; | 1423 | stream >> r; |
1482 | setDefaultRotation( r ); | 1424 | setDefaultRotation( r ); |
1483 | } | 1425 | } |
1484 | } | 1426 | } |
1485 | else if ( msg == "setCurrentMode(int,int,int)" ) { // Added: 2003-06-11 by Tim Ansell <mithro@mithis.net> | 1427 | else if ( msg == "setCurrentMode(int,int,int)" ) { // Added: 2003-06-11 by Tim Ansell <mithro@mithis.net> |
1486 | if ( type() == GuiServer ) { | 1428 | if ( type() == GuiServer ) { |
1487 | int x, y, depth; | 1429 | int x, y, depth; |
1488 | stream >> x; | 1430 | stream >> x; |
1489 | stream >> y; | 1431 | stream >> y; |
1490 | stream >> depth; | 1432 | stream >> depth; |
1491 | setCurrentMode( x, y, depth ); | 1433 | setCurrentMode( x, y, depth ); |
1492 | } | 1434 | } |
1493 | } | 1435 | } |
1494 | else if ( msg == "reset()" ) { | 1436 | else if ( msg == "reset()" ) { |
1495 | if ( type() != GuiServer ) | 1437 | if ( type() != GuiServer ) |
1496 | reset(); | 1438 | reset(); |
1497 | } | 1439 | } |
1498 | else if ( msg == "setCurrentRotation(int)" ) { | 1440 | else if ( msg == "setCurrentRotation(int)" ) { |
1499 | int r; | 1441 | int r; |
1500 | stream >> r; | 1442 | stream >> r; |
1501 | setCurrentRotation( r ); | 1443 | setCurrentRotation( r ); |
1502 | } | 1444 | } |
1503 | else if ( msg == "shutdown()" ) { | 1445 | else if ( msg == "shutdown()" ) { |
1504 | if ( type() == GuiServer ) | 1446 | if ( type() == GuiServer ) |
1505 | shutdown(); | 1447 | shutdown(); |
1506 | } | 1448 | } |
1507 | else if ( msg == "quit()" ) { | 1449 | else if ( msg == "quit()" ) { |
1508 | if ( type() != GuiServer ) | 1450 | if ( type() != GuiServer ) |
1509 | tryQuit(); | 1451 | tryQuit(); |
1510 | } | 1452 | } |
1511 | else if ( msg == "forceQuit()" ) { | 1453 | else if ( msg == "forceQuit()" ) { |
1512 | if ( type() != GuiServer ) | 1454 | if ( type() != GuiServer ) |
1513 | quit(); | 1455 | quit(); |
1514 | } | 1456 | } |
1515 | else if ( msg == "restart()" ) { | 1457 | else if ( msg == "restart()" ) { |
1516 | if ( type() == GuiServer ) | 1458 | if ( type() == GuiServer ) |
1517 | restart(); | 1459 | restart(); |
1518 | } | 1460 | } |
1519 | else if ( msg == "language(QString)" ) { | 1461 | else if ( msg == "language(QString)" ) { |
1520 | if ( type() == GuiServer ) { | 1462 | if ( type() == GuiServer ) { |
1521 | QString l; | 1463 | QString l; |
1522 | stream >> l; | 1464 | stream >> l; |
1523 | QString cl = getenv( "LANG" ); | 1465 | QString cl = getenv( "LANG" ); |
1524 | if ( cl != l ) { | 1466 | if ( cl != l ) { |
1525 | if ( l.isNull() ) | 1467 | if ( l.isNull() ) |
1526 | unsetenv( "LANG" ); | 1468 | unsetenv( "LANG" ); |
1527 | else | 1469 | else |
1528 | setenv( "LANG", l.latin1(), 1 ); | 1470 | setenv( "LANG", l.latin1(), 1 ); |
1529 | restart(); | 1471 | restart(); |
1530 | } | 1472 | } |
1531 | } | 1473 | } |
1532 | } | 1474 | } |
1533 | else if ( msg == "timeChange(QString)" ) { | 1475 | else if ( msg == "timeChange(QString)" ) { |
1534 | QString t; | 1476 | QString t; |
1535 | stream >> t; | 1477 | stream >> t; |
1536 | if ( t.isNull() ) | 1478 | if ( t.isNull() ) |
1537 | unsetenv( "TZ" ); | 1479 | unsetenv( "TZ" ); |
1538 | else | 1480 | else |
1539 | setenv( "TZ", t.latin1(), 1 ); | 1481 | setenv( "TZ", t.latin1(), 1 ); |
1540 | // emit the signal so everyone else knows... | 1482 | // emit the signal so everyone else knows... |
1541 | emit timeChanged(); | 1483 | emit timeChanged(); |
1542 | } | 1484 | } |
1543 | else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) { | 1485 | else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) { |
1544 | if ( type() == GuiServer ) { | 1486 | if ( type() == GuiServer ) { |
1545 | QDateTime when; | 1487 | QDateTime when; |
1546 | QCString channel, message; | 1488 | QCString channel, message; |
1547 | int data; | 1489 | int data; |
1548 | stream >> when >> channel >> message >> data; | 1490 | stream >> when >> channel >> message >> data; |
1549 | AlarmServer::addAlarm( when, channel, message, data ); | 1491 | AlarmServer::addAlarm( when, channel, message, data ); |
1550 | } | 1492 | } |
1551 | } | 1493 | } |
1552 | else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) { | 1494 | else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) { |
1553 | if ( type() == GuiServer ) { | 1495 | if ( type() == GuiServer ) { |
1554 | QDateTime when; | 1496 | QDateTime when; |
1555 | QCString channel, message; | 1497 | QCString channel, message; |
1556 | int data; | 1498 | int data; |
1557 | stream >> when >> channel >> message >> data; | 1499 | stream >> when >> channel >> message >> data; |
1558 | AlarmServer::deleteAlarm( when, channel, message, data ); | 1500 | AlarmServer::deleteAlarm( when, channel, message, data ); |
1559 | } | 1501 | } |
1560 | } | 1502 | } |
1561 | else if ( msg == "clockChange(bool)" ) { | 1503 | else if ( msg == "clockChange(bool)" ) { |
1562 | int tmp; | 1504 | int tmp; |
1563 | stream >> tmp; | 1505 | stream >> tmp; |
1564 | emit clockChanged( tmp ); | 1506 | emit clockChanged( tmp ); |
1565 | } | 1507 | } |
1566 | else if ( msg == "weekChange(bool)" ) { | 1508 | else if ( msg == "weekChange(bool)" ) { |
1567 | int tmp; | 1509 | int tmp; |
1568 | stream >> tmp; | 1510 | stream >> tmp; |
1569 | emit weekChanged( tmp ); | 1511 | emit weekChanged( tmp ); |
1570 | } | 1512 | } |
1571 | else if ( msg == "setDateFormat(DateFormat)" ) { | 1513 | else if ( msg == "setDateFormat(DateFormat)" ) { |
1572 | DateFormat tmp; | 1514 | DateFormat tmp; |
1573 | stream >> tmp; | 1515 | stream >> tmp; |
1574 | emit dateFormatChanged( tmp ); | 1516 | emit dateFormatChanged( tmp ); |
1575 | } | 1517 | } |
1576 | else if ( msg == "setVolume(int,int)" ) { | 1518 | else if ( msg == "setVolume(int,int)" ) { |
1577 | int t, v; | 1519 | int t, v; |
1578 | stream >> t >> v; | 1520 | stream >> t >> v; |
1579 | setVolume( t, v ); | 1521 | setVolume( t, v ); |
1580 | emit volumeChanged( muted ); | 1522 | emit volumeChanged( muted ); |
1581 | } | 1523 | } |
1582 | else if ( msg == "volumeChange(bool)" ) { | 1524 | else if ( msg == "volumeChange(bool)" ) { |
1583 | stream >> muted; | 1525 | stream >> muted; |
1584 | setVolume(); | 1526 | setVolume(); |
1585 | emit volumeChanged( muted ); | 1527 | emit volumeChanged( muted ); |
1586 | } | 1528 | } |
1587 | else if ( msg == "setMic(int,int)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> | 1529 | else if ( msg == "setMic(int,int)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> |
1588 | int t, v; | 1530 | int t, v; |
1589 | stream >> t >> v; | 1531 | stream >> t >> v; |
1590 | setMic( t, v ); | 1532 | setMic( t, v ); |
1591 | emit micChanged( micMuted ); | 1533 | emit micChanged( micMuted ); |
1592 | } | 1534 | } |
1593 | else if ( msg == "micChange(bool)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> | 1535 | else if ( msg == "micChange(bool)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> |
1594 | stream >> micMuted; | 1536 | stream >> micMuted; |
1595 | setMic(); | 1537 | setMic(); |
1596 | emit micChanged( micMuted ); | 1538 | emit micChanged( micMuted ); |
1597 | } | 1539 | } |
1598 | else if ( msg == "setBass(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> | 1540 | else if ( msg == "setBass(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> |
1599 | int t, v; | 1541 | int t, v; |
1600 | stream >> t >> v; | 1542 | stream >> t >> v; |
1601 | setBass( t, v ); | 1543 | setBass( t, v ); |
1602 | } | 1544 | } |
1603 | else if ( msg == "bassChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> | 1545 | else if ( msg == "bassChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> |
1604 | setBass(); | 1546 | setBass(); |
1605 | } | 1547 | } |
1606 | else if ( msg == "setTreble(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> | 1548 | else if ( msg == "setTreble(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> |
1607 | int t, v; | 1549 | int t, v; |
1608 | stream >> t >> v; | 1550 | stream >> t >> v; |
1609 | setTreble( t, v ); | 1551 | setTreble( t, v ); |
1610 | } | 1552 | } |
1611 | else if ( msg == "trebleChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> | 1553 | else if ( msg == "trebleChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> |
1612 | setTreble(); | 1554 | setTreble(); |
1613 | } else if ( msg == "getMarkedText()" ) { | 1555 | } else if ( msg == "getMarkedText()" ) { |
1614 | if ( type() == GuiServer ) { | 1556 | if ( type() == GuiServer ) { |
1615 | const ushort unicode = 'C'-'@'; | 1557 | const ushort unicode = 'C'-'@'; |
1616 | const int scan = Key_C; | 1558 | const int scan = Key_C; |
1617 | qwsServer->processKeyEvent( unicode, scan, ControlButton, TRUE, FALSE ); | 1559 | qwsServer->processKeyEvent( unicode, scan, ControlButton, TRUE, FALSE ); |
1618 | qwsServer->processKeyEvent( unicode, scan, ControlButton, FALSE, FALSE ); | 1560 | qwsServer->processKeyEvent( unicode, scan, ControlButton, FALSE, FALSE ); |
1619 | } | 1561 | } |
1620 | } else if ( msg == "newChannel(QString)") { | 1562 | } else if ( msg == "newChannel(QString)") { |
1621 | QString myChannel = "QPE/Application/" + d->appName; | 1563 | QString myChannel = "QPE/Application/" + d->appName; |
1622 | QString channel; | 1564 | QString channel; |
1623 | stream >> channel; | 1565 | stream >> channel; |
1624 | if (channel == myChannel) { | 1566 | if (channel == myChannel) { |
1625 | processQCopFile(); | 1567 | processQCopFile(); |
1626 | d->sendQCopQ(); | 1568 | d->sendQCopQ(); |
1627 | } | 1569 | } |
1628 | } | 1570 | } |
1629 | 1571 | ||
1630 | 1572 | ||
1631 | #endif | 1573 | #endif |
1632 | } | 1574 | } |
1633 | 1575 | ||
1634 | 1576 | ||
1635 | 1577 | ||
1636 | 1578 | ||
1637 | 1579 | ||
1638 | /*! | 1580 | /*! |
1639 | \internal | 1581 | \internal |
1640 | */ | 1582 | */ |
1641 | bool QPEApplication::raiseAppropriateWindow() | 1583 | bool QPEApplication::raiseAppropriateWindow() |
1642 | { | 1584 | { |
1643 | bool r=FALSE; | 1585 | bool r=FALSE; |
1644 | 1586 | ||
1645 | // 1. Raise the main widget | 1587 | // 1. Raise the main widget |
1646 | QWidget *top = d->qpe_main_widget; | 1588 | QWidget *top = d->qpe_main_widget; |
1647 | if ( !top ) top = mainWidget(); | 1589 | if ( !top ) top = mainWidget(); |
1648 | 1590 | ||
1649 | if ( top && d->keep_running ) { | 1591 | if ( top && d->keep_running ) { |
1650 | if ( top->isVisible() ) | 1592 | if ( top->isVisible() ) |
1651 | r = TRUE; | 1593 | r = TRUE; |
1652 | else if (d->preloaded) { | 1594 | else if (d->preloaded) { |
1653 | // We are preloaded and not visible.. pretend we just started.. | 1595 | // We are preloaded and not visible.. pretend we just started.. |
1654 | #ifndef QT_NO_COP | 1596 | #ifndef QT_NO_COP |
1655 | QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); | 1597 | QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); |
1656 | e << d->appName; | 1598 | e << d->appName; |
1657 | #endif | 1599 | #endif |
1658 | } | 1600 | } |
1659 | 1601 | ||
1660 | d->show_mx(top,d->nomaximize, d->appName); | 1602 | d->show_mx(top,d->nomaximize, d->appName); |
1661 | top->raise(); | 1603 | top->raise(); |
1662 | } | 1604 | } |
1663 | 1605 | ||
1664 | QWidget *topm = activeModalWidget(); | 1606 | QWidget *topm = activeModalWidget(); |
1665 | 1607 | ||
1666 | // 2. Raise any parentless widgets (except top and topm, as they | 1608 | // 2. Raise any parentless widgets (except top and topm, as they |
1667 | // are raised before and after this loop). Order from most | 1609 | // are raised before and after this loop). Order from most |
1668 | // recently raised as deepest to least recently as top, so | 1610 | // recently raised as deepest to least recently as top, so |
1669 | // that repeated calls cycle through widgets. | 1611 | // that repeated calls cycle through widgets. |
1670 | QWidgetList *list = topLevelWidgets(); | 1612 | QWidgetList *list = topLevelWidgets(); |
1671 | if ( list ) { | 1613 | if ( list ) { |
1672 | bool foundlast = FALSE; | 1614 | bool foundlast = FALSE; |
1673 | QWidget* topsub = 0; | 1615 | QWidget* topsub = 0; |
1674 | if ( d->lastraised ) { | 1616 | if ( d->lastraised ) { |
1675 | for (QWidget* w = list->first(); w; w = list->next()) { | 1617 | for (QWidget* w = list->first(); w; w = list->next()) { |
1676 | if ( !w->parentWidget() && w != topm && w->isVisible() && !w->isDesktop() ) { | 1618 | if ( !w->parentWidget() && w != topm && w->isVisible() && !w->isDesktop() ) { |
1677 | if ( w == d->lastraised ) | 1619 | if ( w == d->lastraised ) |
1678 | foundlast = TRUE; | 1620 | foundlast = TRUE; |
1679 | if ( foundlast ) { | 1621 | if ( foundlast ) { |
1680 | w->raise(); | 1622 | w->raise(); |
1681 | topsub = w; | 1623 | topsub = w; |
1682 | } | 1624 | } |
1683 | } | 1625 | } |
1684 | } | 1626 | } |
1685 | } | 1627 | } |
1686 | for (QWidget* w = list->first(); w; w = list->next()) { | 1628 | for (QWidget* w = list->first(); w; w = list->next()) { |
1687 | if ( !w->parentWidget() && w != topm && w->isVisible() && !w->isDesktop() ) { | 1629 | if ( !w->parentWidget() && w != topm && w->isVisible() && !w->isDesktop() ) { |
1688 | if ( w == d->lastraised ) | 1630 | if ( w == d->lastraised ) |
1689 | break; | 1631 | break; |
1690 | w->raise(); | 1632 | w->raise(); |
1691 | topsub = w; | 1633 | topsub = w; |
1692 | } | 1634 | } |
1693 | } | 1635 | } |
1694 | d->lastraised = topsub; | 1636 | d->lastraised = topsub; |
1695 | delete list; | 1637 | delete list; |
1696 | } | 1638 | } |
1697 | 1639 | ||
1698 | // 3. Raise the active modal widget. | 1640 | // 3. Raise the active modal widget. |
1699 | if ( topm ) { | 1641 | if ( topm ) { |
1700 | topm->show(); | 1642 | topm->show(); |
1701 | topm->raise(); | 1643 | topm->raise(); |
1702 | // If we haven't already handled the fastAppShowing message | 1644 | // If we haven't already handled the fastAppShowing message |
1703 | if (!top && d->preloaded) { | 1645 | if (!top && d->preloaded) { |
1704 | #ifndef QT_NO_COP | 1646 | #ifndef QT_NO_COP |
1705 | QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); | 1647 | QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); |
1706 | e << d->appName; | 1648 | e << d->appName; |
1707 | #endif | 1649 | #endif |
1708 | } | 1650 | } |
1709 | r = FALSE; | 1651 | r = FALSE; |
1710 | } | 1652 | } |
1711 | 1653 | ||
1712 | return r; | 1654 | return r; |
1713 | } | 1655 | } |
1714 | 1656 | ||
1715 | 1657 | ||
1716 | void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data) | 1658 | void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data) |
1717 | { | 1659 | { |
1718 | #ifdef Q_WS_QWS | 1660 | #ifdef Q_WS_QWS |
1719 | 1661 | ||
1720 | if ( msg == "quit()" ) { | 1662 | if ( msg == "quit()" ) { |
1721 | tryQuit(); | 1663 | tryQuit(); |
1722 | } | 1664 | } |
1723 | else if ( msg == "quitIfInvisible()" ) { | 1665 | else if ( msg == "quitIfInvisible()" ) { |
1724 | if ( d->qpe_main_widget && !d->qpe_main_widget->isVisible() ) | 1666 | if ( d->qpe_main_widget && !d->qpe_main_widget->isVisible() ) |
1725 | quit(); | 1667 | quit(); |
1726 | } | 1668 | } |
1727 | else if ( msg == "close()" ) { | 1669 | else if ( msg == "close()" ) { |
1728 | hideOrQuit(); | 1670 | hideOrQuit(); |
1729 | } | 1671 | } |
1730 | else if ( msg == "disablePreload()" ) { | 1672 | else if ( msg == "disablePreload()" ) { |
1731 | d->preloaded = FALSE; | 1673 | d->preloaded = FALSE; |
1732 | d->keep_running = TRUE; | 1674 | d->keep_running = TRUE; |
1733 | /* so that quit will quit */ | 1675 | /* so that quit will quit */ |
1734 | } | 1676 | } |
1735 | else if ( msg == "enablePreload()" ) { | 1677 | else if ( msg == "enablePreload()" ) { |
1736 | if (d->qpe_main_widget) | 1678 | if (d->qpe_main_widget) |
1737 | d->preloaded = TRUE; | 1679 | d->preloaded = TRUE; |
1738 | d->keep_running = TRUE; | 1680 | d->keep_running = TRUE; |
1739 | /* so next quit won't quit */ | 1681 | /* so next quit won't quit */ |
1740 | } | 1682 | } |
1741 | else if ( msg == "raise()" ) { | 1683 | else if ( msg == "raise()" ) { |
1742 | d->keep_running = TRUE; | 1684 | d->keep_running = TRUE; |
1743 | d->notbusysent = FALSE; | 1685 | d->notbusysent = FALSE; |
1744 | raiseAppropriateWindow(); | 1686 | raiseAppropriateWindow(); |
1745 | // Tell the system we're still chugging along... | 1687 | // Tell the system we're still chugging along... |
1746 | QCopEnvelope e("QPE/System", "appRaised(QString)"); | 1688 | QCopEnvelope e("QPE/System", "appRaised(QString)"); |
1747 | e << d->appName; | 1689 | e << d->appName; |
1748 | } | 1690 | } |
1749 | else if ( msg == "flush()" ) { | 1691 | else if ( msg == "flush()" ) { |
1750 | emit flush(); | 1692 | emit flush(); |
1751 | // we need to tell the desktop | 1693 | // we need to tell the desktop |
1752 | QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" ); | 1694 | QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" ); |
1753 | e << d->appName; | 1695 | e << d->appName; |
1754 | } | 1696 | } |
1755 | else if ( msg == "reload()" ) { | 1697 | else if ( msg == "reload()" ) { |
1756 | emit reload(); | 1698 | emit reload(); |
1757 | } | 1699 | } |
1758 | else if ( msg == "setDocument(QString)" ) { | 1700 | else if ( msg == "setDocument(QString)" ) { |
1759 | d->keep_running = TRUE; | 1701 | d->keep_running = TRUE; |
1760 | QDataStream stream( data, IO_ReadOnly ); | 1702 | QDataStream stream( data, IO_ReadOnly ); |
1761 | QString doc; | 1703 | QString doc; |
1762 | stream >> doc; | 1704 | stream >> doc; |
1763 | QWidget *mw = mainWidget(); | 1705 | QWidget *mw = mainWidget(); |
1764 | if ( !mw ) | 1706 | if ( !mw ) |
1765 | mw = d->qpe_main_widget; | 1707 | mw = d->qpe_main_widget; |
1766 | if ( mw ) | 1708 | if ( mw ) |
1767 | Global::setDocument( mw, doc ); | 1709 | Global::setDocument( mw, doc ); |
1768 | 1710 | ||
1769 | } else if ( msg == "QPEProcessQCop()" ) { | 1711 | } else if ( msg == "QPEProcessQCop()" ) { |
1770 | processQCopFile(); | 1712 | processQCopFile(); |
1771 | d->sendQCopQ(); | 1713 | d->sendQCopQ(); |
1772 | }else | 1714 | }else |
1773 | { | 1715 | { |
1774 | bool p = d->keep_running; | 1716 | bool p = d->keep_running; |
1775 | d->keep_running = FALSE; | 1717 | d->keep_running = FALSE; |
1776 | emit appMessage( msg, data); | 1718 | emit appMessage( msg, data); |
1777 | if ( d->keep_running ) { | 1719 | if ( d->keep_running ) { |
1778 | d->notbusysent = FALSE; | 1720 | d->notbusysent = FALSE; |
1779 | raiseAppropriateWindow(); | 1721 | raiseAppropriateWindow(); |
1780 | if ( !p ) { | 1722 | if ( !p ) { |
1781 | // Tell the system we're still chugging along... | 1723 | // Tell the system we're still chugging along... |
1782 | #ifndef QT_NO_COP | 1724 | #ifndef QT_NO_COP |
1783 | QCopEnvelope e("QPE/System", "appRaised(QString)"); | 1725 | QCopEnvelope e("QPE/System", "appRaised(QString)"); |
1784 | e << d->appName; | 1726 | e << d->appName; |
1785 | #endif | 1727 | #endif |
1786 | } | 1728 | } |
1787 | } | 1729 | } |
1788 | if ( p ) | 1730 | if ( p ) |
1789 | d->keep_running = p; | 1731 | d->keep_running = p; |
1790 | } | 1732 | } |
1791 | #endif | 1733 | #endif |
1792 | } | 1734 | } |
1793 | 1735 | ||
1794 | 1736 | ||
1795 | /*! | 1737 | /*! |
1796 | Sets widget \a mw as the mainWidget() and shows it. For small windows, | 1738 | Sets widget \a mw as the mainWidget() and shows it. For small windows, |
1797 | consider passing TRUE for \a nomaximize rather than the default FALSE. | 1739 | consider passing TRUE for \a nomaximize rather than the default FALSE. |
1798 | 1740 | ||
1799 | \sa showMainDocumentWidget() | 1741 | \sa showMainDocumentWidget() |
1800 | */ | 1742 | */ |
1801 | void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize ) | 1743 | void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize ) |
1802 | { | 1744 | { |
1803 | // setMainWidget(mw); this breaks FastLoading because lastWindowClose() would quit | 1745 | // setMainWidget(mw); this breaks FastLoading because lastWindowClose() would quit |
1804 | d->show(mw, nomaximize ); | 1746 | d->show(mw, nomaximize ); |
1805 | } | 1747 | } |
1806 | 1748 | ||
1807 | /*! | 1749 | /*! |
1808 | Sets widget \a mw as the mainWidget() and shows it. For small windows, | 1750 | Sets widget \a mw as the mainWidget() and shows it. For small windows, |
1809 | consider passing TRUE for \a nomaximize rather than the default FALSE. | 1751 | consider passing TRUE for \a nomaximize rather than the default FALSE. |
1810 | 1752 | ||
1811 | This calls designates the application as | 1753 | This calls designates the application as |
1812 | a \link docwidget.html document-oriented\endlink application. | 1754 | a \link docwidget.html document-oriented\endlink application. |
1813 | 1755 | ||
1814 | The \a mw widget \e must have this slot: setDocument(const QString&). | 1756 | The \a mw widget \e must have this slot: setDocument(const QString&). |
1815 | 1757 | ||
1816 | \sa showMainWidget() | 1758 | \sa showMainWidget() |
1817 | */ | 1759 | */ |
1818 | void QPEApplication::showMainDocumentWidget( QWidget* mw, bool nomaximize ) | 1760 | void QPEApplication::showMainDocumentWidget( QWidget* mw, bool nomaximize ) |
1819 | { | 1761 | { |
1820 | if ( mw && argc() == 2 ) | 1762 | if ( mw && argc() == 2 ) |
1821 | Global::setDocument( mw, QString::fromUtf8(argv()[1]) ); | 1763 | Global::setDocument( mw, QString::fromUtf8(argv()[1]) ); |
1822 | 1764 | ||
1823 | 1765 | ||
1824 | // setMainWidget(mw); see above | 1766 | // setMainWidget(mw); see above |
1825 | d->show(mw, nomaximize ); | 1767 | d->show(mw, nomaximize ); |
1826 | } | 1768 | } |
1827 | 1769 | ||
1828 | 1770 | ||
1829 | /*! | 1771 | /*! |
1830 | If an application is started via a \link qcop.html QCop\endlink | 1772 | If an application is started via a \link qcop.html QCop\endlink |
1831 | message, the application will process the \link qcop.html | 1773 | message, the application will process the \link qcop.html |
1832 | QCop\endlink message and then quit. If the application calls this | 1774 | QCop\endlink message and then quit. If the application calls this |
1833 | function while processing a \link qcop.html QCop\endlink message, | 1775 | function while processing a \link qcop.html QCop\endlink message, |
1834 | after processing its outstanding \link qcop.html QCop\endlink | 1776 | after processing its outstanding \link qcop.html QCop\endlink |
1835 | messages the application will start 'properly' and show itself. | 1777 | messages the application will start 'properly' and show itself. |
1836 | 1778 | ||
1837 | \sa keepRunning() | 1779 | \sa keepRunning() |
1838 | */ | 1780 | */ |
1839 | void QPEApplication::setKeepRunning() | 1781 | void QPEApplication::setKeepRunning() |
1840 | { | 1782 | { |
1841 | if ( qApp && qApp->inherits( "QPEApplication" ) ) { | 1783 | if ( qApp && qApp->inherits( "QPEApplication" ) ) { |
1842 | QPEApplication * qpeApp = ( QPEApplication* ) qApp; | 1784 | QPEApplication * qpeApp = ( QPEApplication* ) qApp; |
1843 | qpeApp->d->keep_running = TRUE; | 1785 | qpeApp->d->keep_running = TRUE; |
1844 | } | 1786 | } |
1845 | } | 1787 | } |
1846 | 1788 | ||
1847 | /*! | 1789 | /*! |
1848 | Returns TRUE if the application will quit after processing the | 1790 | Returns TRUE if the application will quit after processing the |
1849 | current list of qcop messages; otherwise returns FALSE. | 1791 | current list of qcop messages; otherwise returns FALSE. |
1850 | 1792 | ||
1851 | \sa setKeepRunning() | 1793 | \sa setKeepRunning() |
1852 | */ | 1794 | */ |
1853 | bool QPEApplication::keepRunning() const | 1795 | bool QPEApplication::keepRunning() const |
1854 | { | 1796 | { |
1855 | return d->keep_running; | 1797 | return d->keep_running; |
1856 | } | 1798 | } |
1857 | 1799 | ||
1858 | /*! | 1800 | /*! |
1859 | \internal | 1801 | \internal |
1860 | */ | 1802 | */ |
1861 | void QPEApplication::internalSetStyle( const QString &style ) | 1803 | void QPEApplication::internalSetStyle( const QString &style ) |
1862 | { | 1804 | { |
1863 | #if QT_VERSION >= 300 | 1805 | #if QT_VERSION >= 300 |
1864 | if ( style == "QPE" ) { | 1806 | if ( style == "QPE" ) { |
1865 | setStyle( new QPEStyle ); | 1807 | setStyle( new QPEStyle ); |
1866 | } | 1808 | } |
1867 | else { | 1809 | else { |
1868 | QStyle *s = QStyleFactory::create( style ); | 1810 | QStyle *s = QStyleFactory::create( style ); |
1869 | if ( s ) | 1811 | if ( s ) |
1870 | setStyle( s ); | 1812 | setStyle( s ); |
1871 | } | 1813 | } |
1872 | #else | 1814 | #else |
1873 | if ( style == "Windows" ) { | 1815 | if ( style == "Windows" ) { |
1874 | setStyle( new QWindowsStyle ); | 1816 | setStyle( new QWindowsStyle ); |
1875 | } | 1817 | } |
1876 | else if ( style == "QPE" ) { | 1818 | else if ( style == "QPE" ) { |
1877 | setStyle( new QPEStyle ); | 1819 | setStyle( new QPEStyle ); |
1878 | } | 1820 | } |
1879 | else if ( style == "Light" ) { | 1821 | else if ( style == "Light" ) { |
1880 | setStyle( new LightStyle ); | 1822 | setStyle( new LightStyle ); |
1881 | } | 1823 | } |
1882 | #ifndef QT_NO_STYLE_PLATINUM | 1824 | #ifndef QT_NO_STYLE_PLATINUM |
1883 | else if ( style == "Platinum" ) { | 1825 | else if ( style == "Platinum" ) { |
1884 | setStyle( new QPlatinumStyle ); | 1826 | setStyle( new QPlatinumStyle ); |
1885 | } | 1827 | } |
1886 | #endif | 1828 | #endif |
1887 | #ifndef QT_NO_STYLE_MOTIF | 1829 | #ifndef QT_NO_STYLE_MOTIF |
1888 | else if ( style == "Motif" ) { | 1830 | else if ( style == "Motif" ) { |
1889 | setStyle( new QMotifStyle ); | 1831 | setStyle( new QMotifStyle ); |
1890 | } | 1832 | } |
1891 | #endif | 1833 | #endif |
1892 | #ifndef QT_NO_STYLE_MOTIFPLUS | 1834 | #ifndef QT_NO_STYLE_MOTIFPLUS |
1893 | else if ( style == "MotifPlus" ) { | 1835 | else if ( style == "MotifPlus" ) { |
1894 | setStyle( new QMotifPlusStyle ); | 1836 | setStyle( new QMotifPlusStyle ); |
1895 | } | 1837 | } |
1896 | #endif | 1838 | #endif |
1897 | 1839 | ||
1898 | else { | 1840 | else { |
1899 | QStyle *sty = 0; | 1841 | QStyle *sty = 0; |
1900 | QString path = QPEApplication::qpeDir ( ) + "/plugins/styles/"; | 1842 | QString path = QPEApplication::qpeDir ( ) + "/plugins/styles/"; |
1901 | 1843 | ||
1902 | #ifdef Q_OS_MACX | 1844 | #ifdef Q_OS_MACX |
1903 | if ( style. find ( ".dylib" ) > 0 ) | 1845 | if ( style. find ( ".dylib" ) > 0 ) |
1904 | path += style; | 1846 | path += style; |
1905 | else | 1847 | else |
1906 | path = path + "lib" + style. lower ( ) + ".dylib"; // compatibility | 1848 | path = path + "lib" + style. lower ( ) + ".dylib"; // compatibility |
1907 | #else | 1849 | #else |
1908 | if ( style. find ( ".so" ) > 0 ) | 1850 | if ( style. find ( ".so" ) > 0 ) |
1909 | path += style; | 1851 | path += style; |
1910 | else | 1852 | else |
1911 | path = path + "lib" + style. lower ( ) + ".so"; // compatibility | 1853 | path = path + "lib" + style. lower ( ) + ".so"; // compatibility |
1912 | #endif | 1854 | #endif |
1913 | static QLibrary *lastlib = 0; | 1855 | static QLibrary *lastlib = 0; |
1914 | static StyleInterface *lastiface = 0; | 1856 | static StyleInterface *lastiface = 0; |
1915 | 1857 | ||
1916 | QLibrary *lib = new QLibrary ( path ); | 1858 | QLibrary *lib = new QLibrary ( path ); |
1917 | StyleInterface *iface = 0; | 1859 | StyleInterface *iface = 0; |
1918 | 1860 | ||
1919 | if (( lib-> queryInterface ( IID_Style, ( QUnknownInterface ** ) &iface ) == QS_OK ) && iface ) | 1861 | if (( lib-> queryInterface ( IID_Style, ( QUnknownInterface ** ) &iface ) == QS_OK ) && iface ) |
1920 | sty = iface-> style ( ); | 1862 | sty = iface-> style ( ); |
1921 | 1863 | ||
1922 | if ( sty ) { | 1864 | if ( sty ) { |
1923 | setStyle ( sty ); | 1865 | setStyle ( sty ); |
1924 | 1866 | ||
1925 | if ( lastiface ) | 1867 | if ( lastiface ) |
1926 | lastiface-> release ( ); | 1868 | lastiface-> release ( ); |
1927 | lastiface = iface; | 1869 | lastiface = iface; |
1928 | 1870 | ||
1929 | if ( lastlib ) { | 1871 | if ( lastlib ) { |
1930 | lastlib-> unload ( ); | 1872 | lastlib-> unload ( ); |
1931 | delete lastlib; | 1873 | delete lastlib; |
1932 | } | 1874 | } |
1933 | lastlib = lib; | 1875 | lastlib = lib; |
1934 | } | 1876 | } |
1935 | else { | 1877 | else { |
1936 | if ( iface ) | 1878 | if ( iface ) |
1937 | iface-> release ( ); | 1879 | iface-> release ( ); |
1938 | delete lib; | 1880 | delete lib; |
1939 | 1881 | ||
1940 | setStyle ( new LightStyle ( )); | 1882 | setStyle ( new LightStyle ( )); |
1941 | } | 1883 | } |
1942 | } | 1884 | } |
1943 | #endif | 1885 | #endif |
1944 | } | 1886 | } |
1945 | 1887 | ||
1946 | /*! | 1888 | /*! |
1947 | \internal | 1889 | \internal |
1948 | */ | 1890 | */ |
1949 | void QPEApplication::prepareForTermination( bool willrestart ) | 1891 | void QPEApplication::prepareForTermination( bool willrestart ) |
1950 | { | 1892 | { |
1951 | if ( willrestart ) { | 1893 | if ( willrestart ) { |
1952 | QLabel *lblWait = new QLabel( tr( "Please wait..." ), 0, "wait hack", QWidget::WStyle_Customize | | 1894 | QLabel *lblWait = new QLabel( tr( "Please wait..." ), 0, "wait hack", QWidget::WStyle_Customize | |
1953 | QWidget::WStyle_NoBorder | QWidget::WStyle_Tool ); | 1895 | QWidget::WStyle_NoBorder | QWidget::WStyle_Tool ); |
1954 | lblWait->setAlignment( QWidget::AlignCenter ); | 1896 | lblWait->setAlignment( QWidget::AlignCenter ); |
1955 | lblWait->show(); | 1897 | lblWait->show(); |
1956 | lblWait->showMaximized(); | 1898 | lblWait->showMaximized(); |
1957 | } | 1899 | } |
1958 | { QCopEnvelope envelope( "QPE/System", "forceQuit()" ); | 1900 | { QCopEnvelope envelope( "QPE/System", "forceQuit()" ); |
1959 | } | 1901 | } |
1960 | processEvents(); // ensure the message goes out. | 1902 | processEvents(); // ensure the message goes out. |
1961 | } | 1903 | } |
1962 | 1904 | ||
1963 | /*! | 1905 | /*! |
1964 | \internal | 1906 | \internal |
1965 | */ | 1907 | */ |
1966 | void QPEApplication::shutdown() | 1908 | void QPEApplication::shutdown() |
1967 | { | 1909 | { |
1968 | // Implement in server's QPEApplication subclass | 1910 | // Implement in server's QPEApplication subclass |
1969 | } | 1911 | } |
1970 | 1912 | ||
1971 | /*! | 1913 | /*! |
1972 | \internal | 1914 | \internal |
1973 | */ | 1915 | */ |
1974 | void QPEApplication::restart() | 1916 | void QPEApplication::restart() |
1975 | { | 1917 | { |
1976 | // Implement in server's QPEApplication subclass | 1918 | // Implement in server's QPEApplication subclass |
1977 | } | 1919 | } |
1978 | 1920 | ||
1979 | static QPtrDict<void>* stylusDict = 0; | 1921 | static QPtrDict<void>* stylusDict = 0; |
1980 | static void createDict() | 1922 | static void createDict() |
1981 | { | 1923 | { |
1982 | if ( !stylusDict ) | 1924 | if ( !stylusDict ) |
1983 | stylusDict = new QPtrDict<void>; | 1925 | stylusDict = new QPtrDict<void>; |
1984 | } | 1926 | } |
1985 | 1927 | ||
1986 | /*! | 1928 | /*! |
1987 | Returns the current StylusMode for widget \a w. | 1929 | Returns the current StylusMode for widget \a w. |
1988 | 1930 | ||
1989 | \sa setStylusOperation() StylusMode | 1931 | \sa setStylusOperation() StylusMode |
1990 | */ | 1932 | */ |
1991 | QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w ) | 1933 | QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w ) |
1992 | { | 1934 | { |
1993 | if ( stylusDict ) | 1935 | if ( stylusDict ) |
1994 | return ( StylusMode ) ( int ) stylusDict->find( w ); | 1936 | return ( StylusMode ) ( int ) stylusDict->find( w ); |
1995 | return LeftOnly; | 1937 | return LeftOnly; |
1996 | } | 1938 | } |
1997 | 1939 | ||
1998 | /*! | 1940 | /*! |
1999 | \enum QPEApplication::StylusMode | 1941 | \enum QPEApplication::StylusMode |
2000 | 1942 | ||
2001 | \value LeftOnly the stylus only generates LeftButton | 1943 | \value LeftOnly the stylus only generates LeftButton |
2002 | events (the default). | 1944 | events (the default). |
2003 | \value RightOnHold the stylus generates RightButton events | 1945 | \value RightOnHold the stylus generates RightButton events |
2004 | if the user uses the press-and-hold gesture. | 1946 | if the user uses the press-and-hold gesture. |
2005 | 1947 | ||
2006 | \sa setStylusOperation() stylusOperation() | 1948 | \sa setStylusOperation() stylusOperation() |
2007 | */ | 1949 | */ |
2008 | 1950 | ||
2009 | /*! | 1951 | /*! |
2010 | Causes widget \a w to receive mouse events according to the stylus | 1952 | Causes widget \a w to receive mouse events according to the stylus |
2011 | \a mode. | 1953 | \a mode. |
2012 | 1954 | ||
2013 | \sa stylusOperation() StylusMode | 1955 | \sa stylusOperation() StylusMode |
2014 | */ | 1956 | */ |
2015 | void QPEApplication::setStylusOperation( QWidget * w, StylusMode mode ) | 1957 | void QPEApplication::setStylusOperation( QWidget * w, StylusMode mode ) |
2016 | { | 1958 | { |
2017 | createDict(); | 1959 | createDict(); |
2018 | if ( mode == LeftOnly ) { | 1960 | if ( mode == LeftOnly ) { |
2019 | stylusDict->remove | 1961 | stylusDict->remove |
2020 | ( w ); | 1962 | ( w ); |
2021 | w->removeEventFilter( qApp ); | 1963 | w->removeEventFilter( qApp ); |
2022 | } | 1964 | } |
2023 | else { | 1965 | else { |
2024 | stylusDict->insert( w, ( void* ) mode ); | 1966 | stylusDict->insert( w, ( void* ) mode ); |
2025 | connect( w, SIGNAL( destroyed() ), qApp, SLOT( removeSenderFromStylusDict() ) ); | 1967 | connect( w, SIGNAL( destroyed() ), qApp, SLOT( removeSenderFromStylusDict() ) ); |
2026 | w->installEventFilter( qApp ); | 1968 | w->installEventFilter( qApp ); |
2027 | } | 1969 | } |
2028 | } | 1970 | } |
2029 | 1971 | ||
2030 | 1972 | ||
2031 | /*! | 1973 | /*! |
2032 | \reimp | 1974 | \reimp |
2033 | */ | 1975 | */ |
2034 | bool QPEApplication::eventFilter( QObject *o, QEvent *e ) | 1976 | bool QPEApplication::eventFilter( QObject *o, QEvent *e ) |
2035 | { | 1977 | { |
2036 | if ( !o->isWidgetType() ) | 1978 | if ( !o->isWidgetType() ) |
2037 | return FALSE; | 1979 | return FALSE; |
2038 | 1980 | ||
2039 | if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) { | 1981 | if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) { |
2040 | QMouseEvent * me = ( QMouseEvent* ) e; | 1982 | QMouseEvent * me = ( QMouseEvent* ) e; |
2041 | StylusMode mode = (StylusMode)(int)stylusDict->find(o); | 1983 | StylusMode mode = (StylusMode)(int)stylusDict->find(o); |
2042 | switch (mode) { | 1984 | switch (mode) { |
2043 | case RightOnHold: | 1985 | case RightOnHold: |
2044 | switch ( me->type() ) { | 1986 | switch ( me->type() ) { |
2045 | case QEvent::MouseButtonPress: | 1987 | case QEvent::MouseButtonPress: |
2046 | if ( me->button() == LeftButton ) { | 1988 | if ( me->button() == LeftButton ) { |
2047 | static long Pref = 500; // #### pref. | 1989 | static long Pref = 500; // #### pref. |
2048 | d->presswidget = (QWidget*)o; | 1990 | d->presswidget = (QWidget*)o; |
2049 | d->presspos = me->pos(); | 1991 | d->presspos = me->pos(); |
2050 | d->rightpressed = FALSE; | 1992 | d->rightpressed = FALSE; |
2051 | #ifdef OPIE_WITHROHFEEDBACK | 1993 | #ifdef OPIE_WITHROHFEEDBACK |
2052 | if( ! d->RoH ) | 1994 | if( ! d->RoH ) |
2053 | d->RoH = new Opie::Internal::RoHFeedback; | 1995 | d->RoH = new Opie::Internal::RoHFeedback; |
2054 | 1996 | ||
2055 | d->RoH->init( me->globalPos(), d->presswidget ); | 1997 | d->RoH->init( me->globalPos(), d->presswidget ); |
2056 | Pref = d->RoH->delay(); | 1998 | Pref = d->RoH->delay(); |
2057 | 1999 | ||
2058 | #endif | 2000 | #endif |
2059 | if (!d->presstimer ) | 2001 | if (!d->presstimer ) |
2060 | d->presstimer = startTimer( Pref ); // #### pref. | 2002 | d->presstimer = startTimer( Pref ); // #### pref. |
2061 | 2003 | ||
2062 | } | 2004 | } |
2063 | break; | 2005 | break; |
2064 | case QEvent::MouseMove: | 2006 | case QEvent::MouseMove: |
2065 | if (d->presstimer && (me->pos() - d->presspos).manhattanLength() > 8) { | 2007 | if (d->presstimer && (me->pos() - d->presspos).manhattanLength() > 8) { |
2066 | killTimer(d->presstimer); | 2008 | killTimer(d->presstimer); |
2067 | #ifdef OPIE_WITHROHFEEDBACK | 2009 | #ifdef OPIE_WITHROHFEEDBACK |
2068 | d->RoH->stop(); | 2010 | d->RoH->stop(); |
2069 | #endif | 2011 | #endif |
2070 | d->presstimer = 0; | 2012 | d->presstimer = 0; |
2071 | } | 2013 | } |
2072 | break; | 2014 | break; |
2073 | case QEvent::MouseButtonRelease: | 2015 | case QEvent::MouseButtonRelease: |
2074 | if ( me->button() == LeftButton ) { | 2016 | if ( me->button() == LeftButton ) { |
2075 | if ( d->presstimer ) { | 2017 | if ( d->presstimer ) { |
2076 | killTimer(d->presstimer); | 2018 | killTimer(d->presstimer); |
2077 | #ifdef OPIE_WITHROHFEEDBACK | 2019 | #ifdef OPIE_WITHROHFEEDBACK |
2078 | d->RoH->stop( ); | 2020 | d->RoH->stop( ); |
2079 | #endif | 2021 | #endif |
2080 | d->presstimer = 0; | 2022 | d->presstimer = 0; |
2081 | } | 2023 | } |
2082 | if ( d->rightpressed && d->presswidget ) { | 2024 | if ( d->rightpressed && d->presswidget ) { |
2083 | printf( "Send ButtonRelease\n" ); | 2025 | printf( "Send ButtonRelease\n" ); |
2084 | // Right released | 2026 | // Right released |
2085 | postEvent( d->presswidget, | 2027 | postEvent( d->presswidget, |
2086 | new QMouseEvent( QEvent::MouseButtonRelease, me->pos(), | 2028 | new QMouseEvent( QEvent::MouseButtonRelease, me->pos(), |
2087 | RightButton, LeftButton + RightButton ) ); | 2029 | RightButton, LeftButton + RightButton ) ); |
2088 | // Left released, off-widget | 2030 | // Left released, off-widget |
2089 | postEvent( d->presswidget, | 2031 | postEvent( d->presswidget, |
2090 | new QMouseEvent( QEvent::MouseMove, QPoint( -1, -1), | 2032 | new QMouseEvent( QEvent::MouseMove, QPoint( -1, -1), |
2091 | LeftButton, LeftButton ) ); | 2033 | LeftButton, LeftButton ) ); |
2092 | postEvent( d->presswidget, | 2034 | postEvent( d->presswidget, |
2093 | new QMouseEvent( QEvent::MouseButtonRelease, QPoint( -1, -1), | 2035 | new QMouseEvent( QEvent::MouseButtonRelease, QPoint( -1, -1), |
2094 | LeftButton, LeftButton ) ); | 2036 | LeftButton, LeftButton ) ); |
2095 | d->rightpressed = FALSE; | 2037 | d->rightpressed = FALSE; |
2096 | return TRUE; // don't send the real Left release | 2038 | return TRUE; // don't send the real Left release |
2097 | } | 2039 | } |
2098 | } | 2040 | } |
2099 | break; | 2041 | break; |
2100 | default: | 2042 | default: |
2101 | break; | 2043 | break; |
2102 | } | 2044 | } |
2103 | break; | 2045 | break; |
2104 | default: | 2046 | default: |
2105 | ; | 2047 | ; |
2106 | } | 2048 | } |
2107 | } | 2049 | } |
2108 | else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { | 2050 | else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { |
2109 | QKeyEvent *ke = (QKeyEvent *)e; | 2051 | QKeyEvent *ke = (QKeyEvent *)e; |
2110 | if ( ke->key() == Key_Enter ) { | 2052 | if ( ke->key() == Key_Enter ) { |
2111 | if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) { | 2053 | if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) { |
2112 | postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ', | 2054 | postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ', |
2113 | ke->state(), " ", ke->isAutoRepeat(), ke->count() ) ); | 2055 | ke->state(), " ", ke->isAutoRepeat(), ke->count() ) ); |
2114 | return TRUE; | 2056 | return TRUE; |
2115 | } | 2057 | } |
2116 | } | 2058 | } |
2117 | } | 2059 | } |
2118 | return FALSE; | 2060 | return FALSE; |
2119 | } | 2061 | } |
2120 | 2062 | ||
2121 | /*! | 2063 | /*! |
2122 | \reimp | 2064 | \reimp |
2123 | */ | 2065 | */ |
2124 | void QPEApplication::timerEvent( QTimerEvent *e ) | 2066 | void QPEApplication::timerEvent( QTimerEvent *e ) |
2125 | { | 2067 | { |
2126 | if ( e->timerId() == d->presstimer && d->presswidget ) { | 2068 | if ( e->timerId() == d->presstimer && d->presswidget ) { |
2127 | 2069 | ||
2128 | // Right pressed | 2070 | // Right pressed |
2129 | postEvent( d->presswidget, | 2071 | postEvent( d->presswidget, |
2130 | new QMouseEvent( QEvent::MouseButtonPress, d->presspos, | 2072 | new QMouseEvent( QEvent::MouseButtonPress, d->presspos, |
2131 | RightButton, LeftButton ) ); | 2073 | RightButton, LeftButton ) ); |
2132 | killTimer( d->presstimer ); | 2074 | killTimer( d->presstimer ); |
2133 | d->presstimer = 0; | 2075 | d->presstimer = 0; |
2134 | d->rightpressed = TRUE; | 2076 | d->rightpressed = TRUE; |
2135 | #ifdef OPIE_WITHROHFEEDBACK | 2077 | #ifdef OPIE_WITHROHFEEDBACK |
2136 | d->RoH->stop(); | 2078 | d->RoH->stop(); |
2137 | #endif | 2079 | #endif |
2138 | } | 2080 | } |
2139 | } | 2081 | } |
2140 | 2082 | ||
2141 | void QPEApplication::removeSenderFromStylusDict() | 2083 | void QPEApplication::removeSenderFromStylusDict() |
2142 | { | 2084 | { |
2143 | stylusDict->remove | 2085 | stylusDict->remove |
2144 | ( ( void* ) sender() ); | 2086 | ( ( void* ) sender() ); |
2145 | if ( d->presswidget == sender() ) | 2087 | if ( d->presswidget == sender() ) |
2146 | d->presswidget = 0; | 2088 | d->presswidget = 0; |
2147 | } | 2089 | } |
2148 | 2090 | ||
2149 | /*! | 2091 | /*! |
2150 | \internal | 2092 | \internal |
2151 | */ | 2093 | */ |
2152 | bool QPEApplication::keyboardGrabbed() const | 2094 | bool QPEApplication::keyboardGrabbed() const |
2153 | { | 2095 | { |
2154 | return d->kbgrabbed; | 2096 | return d->kbgrabbed; |
2155 | } | 2097 | } |
2156 | 2098 | ||
2157 | 2099 | ||
2158 | /*! | 2100 | /*! |
2159 | Reverses the effect of grabKeyboard(). This is called automatically | 2101 | Reverses the effect of grabKeyboard(). This is called automatically |
2160 | on program exit. | 2102 | on program exit. |
2161 | */ | 2103 | */ |
2162 | void QPEApplication::ungrabKeyboard() | 2104 | void QPEApplication::ungrabKeyboard() |
2163 | { | 2105 | { |
2164 | ((QPEApplication *) qApp )-> d-> kbgrabbed = false; | 2106 | ((QPEApplication *) qApp )-> d-> kbgrabbed = false; |
2165 | } | 2107 | } |
2166 | 2108 | ||
2167 | /*! | 2109 | /*! |
2168 | Grabs the physical keyboard keys, e.g. the application's launching | 2110 | Grabs the physical keyboard keys, e.g. the application's launching |
2169 | keys. Instead of launching applications when these keys are pressed | 2111 | keys. Instead of launching applications when these keys are pressed |
2170 | the signals emitted are sent to this application instead. Some games | 2112 | the signals emitted are sent to this application instead. Some games |
2171 | programs take over the launch keys in this way to make interaction | 2113 | programs take over the launch keys in this way to make interaction |
2172 | easier. | 2114 | easier. |
2173 | 2115 | ||
2174 | \sa ungrabKeyboard() | 2116 | \sa ungrabKeyboard() |
2175 | */ | 2117 | */ |
2176 | void QPEApplication::grabKeyboard() | 2118 | void QPEApplication::grabKeyboard() |
2177 | { | 2119 | { |
2178 | ((QPEApplication *) qApp )-> d-> kbgrabbed = true; | 2120 | ((QPEApplication *) qApp )-> d-> kbgrabbed = true; |
2179 | } | 2121 | } |
2180 | 2122 | ||
2181 | /*! | 2123 | /*! |
2182 | \reimp | 2124 | \reimp |
2183 | */ | 2125 | */ |
2184 | int QPEApplication::exec() | 2126 | int QPEApplication::exec() |
2185 | { | 2127 | { |
2186 | d->qcopQok = true; | 2128 | d->qcopQok = true; |
2187 | #ifndef QT_NO_COP | 2129 | #ifndef QT_NO_COP |
2188 | d->sendQCopQ(); | 2130 | d->sendQCopQ(); |
2189 | if ( !d->keep_running ) | 2131 | if ( !d->keep_running ) |
2190 | processEvents(); // we may have received QCop messages in the meantime. | 2132 | processEvents(); // we may have received QCop messages in the meantime. |
2191 | #endif | 2133 | #endif |
2192 | 2134 | ||
2193 | if ( d->keep_running ) | 2135 | if ( d->keep_running ) |
2194 | //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() ) | 2136 | //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() ) |
2195 | return QApplication::exec(); | 2137 | return QApplication::exec(); |
2196 | 2138 | ||
2197 | #ifndef QT_NO_COP | 2139 | #ifndef QT_NO_COP |
2198 | 2140 | ||
2199 | { | 2141 | { |
2200 | QCopEnvelope e( "QPE/System", "closing(QString)" ); | 2142 | QCopEnvelope e( "QPE/System", "closing(QString)" ); |
2201 | e << d->appName; | 2143 | e << d->appName; |
2202 | } | 2144 | } |
2203 | #endif | 2145 | #endif |
2204 | processEvents(); | 2146 | processEvents(); |
2205 | return 0; | 2147 | return 0; |
2206 | } | 2148 | } |
2207 | 2149 | ||
2208 | /*! | 2150 | /*! |
2209 | \internal | 2151 | \internal |
2210 | External request for application to quit. Quits if possible without | 2152 | External request for application to quit. Quits if possible without |
2211 | loosing state. | 2153 | loosing state. |
2212 | */ | 2154 | */ |
2213 | void QPEApplication::tryQuit() | 2155 | void QPEApplication::tryQuit() |
2214 | { | 2156 | { |
2215 | if ( activeModalWidget() ) | 2157 | if ( activeModalWidget() ) |
2216 | return ; // Inside modal loop or konsole. Too hard to save state. | 2158 | return ; // Inside modal loop or konsole. Too hard to save state. |
2217 | #ifndef QT_NO_COP | 2159 | #ifndef QT_NO_COP |
2218 | 2160 | ||
2219 | { | 2161 | { |
2220 | QCopEnvelope e( "QPE/System", "closing(QString)" ); | 2162 | QCopEnvelope e( "QPE/System", "closing(QString)" ); |
2221 | e << d->appName; | 2163 | e << d->appName; |
2222 | } | 2164 | } |
2223 | #endif | 2165 | #endif |
2224 | if ( d->keep_running ) | 2166 | if ( d->keep_running ) |
2225 | d->store_widget_rect(d->qpe_main_widget, d->appName); | 2167 | d->store_widget_rect(d->qpe_main_widget, d->appName); |
2226 | processEvents(); | 2168 | processEvents(); |
2227 | 2169 | ||
2228 | quit(); | 2170 | quit(); |
2229 | } | 2171 | } |
2230 | 2172 | ||
2231 | /*! | 2173 | /*! |
2232 | \internal | 2174 | \internal |
2233 | */ | 2175 | */ |
2234 | void QPEApplication::installTranslation( const QString& baseName ) { | 2176 | void QPEApplication::installTranslation( const QString& baseName ) { |
2235 | QTranslator* trans = new QTranslator(this); | 2177 | QTranslator* trans = new QTranslator(this); |
2236 | QString tfn = qpeDir() + "/i18n/"+baseName; | 2178 | QString tfn = qpeDir() + "/i18n/"+baseName; |
2237 | if ( trans->load( tfn ) ) | 2179 | if ( trans->load( tfn ) ) |
2238 | installTranslator( trans ); | 2180 | installTranslator( trans ); |
2239 | else | 2181 | else |
2240 | delete trans; | 2182 | delete trans; |
2241 | } | 2183 | } |
2242 | 2184 | ||
2243 | /*! | 2185 | /*! |
2244 | \internal | 2186 | \internal |
2245 | User initiated quit. Makes the window 'Go Away'. If preloaded this means | 2187 | User initiated quit. Makes the window 'Go Away'. If preloaded this means |
2246 | hiding the window. If not it means quitting the application. | 2188 | hiding the window. If not it means quitting the application. |
2247 | As this is user initiated we don't need to check state. | 2189 | As this is user initiated we don't need to check state. |
2248 | */ | 2190 | */ |
2249 | void QPEApplication::hideOrQuit() | 2191 | void QPEApplication::hideOrQuit() |
2250 | { | 2192 | { |
2251 | if ( d->keep_running ) | 2193 | if ( d->keep_running ) |
2252 | d->store_widget_rect(d->qpe_main_widget, d->appName); | 2194 | d->store_widget_rect(d->qpe_main_widget, d->appName); |
2253 | processEvents(); | 2195 | processEvents(); |
2254 | 2196 | ||
2255 | // If we are a preloaded application we don't actually quit, so emit | 2197 | // If we are a preloaded application we don't actually quit, so emit |
2256 | // a System message indicating we're quasi-closing. | 2198 | // a System message indicating we're quasi-closing. |
2257 | if ( d->preloaded && d->qpe_main_widget ) | 2199 | if ( d->preloaded && d->qpe_main_widget ) |
2258 | #ifndef QT_NO_COP | 2200 | #ifndef QT_NO_COP |
2259 | 2201 | ||
2260 | { | 2202 | { |
2261 | QCopEnvelope e("QPE/System", "fastAppHiding(QString)" ); | 2203 | QCopEnvelope e("QPE/System", "fastAppHiding(QString)" ); |
2262 | e << d->appName; | 2204 | e << d->appName; |
2263 | d->qpe_main_widget->hide(); | 2205 | d->qpe_main_widget->hide(); |
2264 | } | 2206 | } |
2265 | #endif | 2207 | #endif |
2266 | else | 2208 | else |
2267 | quit(); | 2209 | quit(); |
2268 | } | 2210 | } |
2269 | 2211 | ||
2270 | #if (__GNUC__ > 2 ) | 2212 | #if (__GNUC__ > 2 ) |
2271 | extern "C" void __cxa_pure_virtual(); | 2213 | extern "C" void __cxa_pure_virtual(); |
2272 | 2214 | ||
2273 | void __cxa_pure_virtual() | 2215 | void __cxa_pure_virtual() |
2274 | { | 2216 | { |
2275 | fprintf( stderr, "Pure virtual called\n"); | 2217 | fprintf( stderr, "Pure virtual called\n"); |
2276 | abort(); | 2218 | abort(); |
2277 | 2219 | ||
2278 | } | 2220 | } |
2279 | 2221 | ||
2280 | #endif | 2222 | #endif |
2281 | 2223 | ||
2282 | 2224 | ||
2283 | #if defined(OPIE_NEW_MALLOC) | 2225 | #if defined(OPIE_NEW_MALLOC) |
2284 | 2226 | ||
2285 | // The libraries with the skiff package (and possibly others) have | 2227 | // The libraries with the skiff package (and possibly others) have |
2286 | // completely useless implementations of builtin new and delete that | 2228 | // completely useless implementations of builtin new and delete that |
2287 | // use about 50% of your CPU. Here we revert to the simple libc | 2229 | // use about 50% of your CPU. Here we revert to the simple libc |
2288 | // functions. | 2230 | // functions. |
2289 | 2231 | ||
2290 | void* operator new[]( size_t size ) | 2232 | void* operator new[]( size_t size ) |
2291 | { | 2233 | { |
2292 | return malloc( size ); | 2234 | return malloc( size ); |
2293 | } | 2235 | } |
2294 | 2236 | ||
2295 | void* operator new( size_t size ) | 2237 | void* operator new( size_t size ) |
2296 | { | 2238 | { |
2297 | return malloc( size ); | 2239 | return malloc( size ); |
2298 | } | 2240 | } |
2299 | 2241 | ||
2300 | void operator delete[]( void* p ) | 2242 | void operator delete[]( void* p ) |
2301 | { | 2243 | { |
2302 | free( p ); | 2244 | free( p ); |
2303 | } | 2245 | } |
2304 | 2246 | ||
2305 | void operator delete[]( void* p, size_t /*size*/ ) | 2247 | void operator delete[]( void* p, size_t /*size*/ ) |
2306 | { | 2248 | { |
2307 | free( p ); | 2249 | free( p ); |
2308 | } | 2250 | } |
2309 | 2251 | ||
2310 | 2252 | ||
2311 | void operator delete( void* p ) | 2253 | void operator delete( void* p ) |
2312 | { | 2254 | { |
2313 | free( p ); | 2255 | free( p ); |
2314 | } | 2256 | } |
2315 | 2257 | ||
2316 | void operator delete( void* p, size_t /*size*/ ) | 2258 | void operator delete( void* p, size_t /*size*/ ) |
2317 | { | 2259 | { |
2318 | free( p ); | 2260 | free( p ); |
2319 | } | 2261 | } |
2320 | 2262 | ||
2321 | #endif | 2263 | #endif |
2322 | 2264 | ||
2323 | #if ( QT_VERSION <= 230 ) && !defined(SINGLE_APP) | 2265 | #if ( QT_VERSION <= 230 ) && !defined(SINGLE_APP) |
2324 | #include <qwidgetlist.h> | 2266 | #include <qwidgetlist.h> |
2325 | #ifdef QWS | 2267 | #ifdef QWS |
2326 | #include <qgfx_qws.h> | 2268 | #include <qgfx_qws.h> |
2327 | extern QRect qt_maxWindowRect; | 2269 | extern QRect qt_maxWindowRect; |
2328 | void qt_setMaxWindowRect(const QRect& r ) | 2270 | void qt_setMaxWindowRect(const QRect& r ) |
2329 | { | 2271 | { |
2330 | qt_maxWindowRect = qt_screen->mapFromDevice( r, | 2272 | qt_maxWindowRect = qt_screen->mapFromDevice( r, |
2331 | qt_screen->mapToDevice( QSize( qt_screen->width(), qt_screen->height() ) ) ); | 2273 | qt_screen->mapToDevice( QSize( qt_screen->width(), qt_screen->height() ) ) ); |
2332 | // Re-resize any maximized windows | 2274 | // Re-resize any maximized windows |
2333 | QWidgetList* l = QApplication::topLevelWidgets(); | 2275 | QWidgetList* l = QApplication::topLevelWidgets(); |
2334 | if ( l ) { | 2276 | if ( l ) { |
2335 | QWidget * w = l->first(); | 2277 | QWidget * w = l->first(); |
2336 | while ( w ) { | 2278 | while ( w ) { |
2337 | if ( w->isVisible() && w->isMaximized() ) { | 2279 | if ( w->isVisible() && w->isMaximized() ) { |
2338 | w->showMaximized(); | 2280 | w->showMaximized(); |
2339 | } | 2281 | } |
2340 | w = l->next(); | 2282 | w = l->next(); |
2341 | } | 2283 | } |
2342 | delete l; | 2284 | delete l; |
2343 | } | 2285 | } |
2344 | } | 2286 | } |
2345 | #endif | 2287 | #endif |
2346 | #endif | 2288 | #endif |