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