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