-rw-r--r-- | library/qpeapplication.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp index af00f49..1c5ced3 100644 --- a/library/qpeapplication.cpp +++ b/library/qpeapplication.cpp | |||
@@ -1,575 +1,575 @@ | |||
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 >= 0x030000 |
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 | #include <qtopia/qpeglobal.h> | 91 | #include <qtopia/qpeglobal.h> |
92 | 92 | ||
93 | #include <unistd.h> | 93 | #include <unistd.h> |
94 | #include <sys/file.h> | 94 | #include <sys/file.h> |
95 | #include <sys/ioctl.h> | 95 | #include <sys/ioctl.h> |
96 | #ifndef QT_NO_SOUND | 96 | #ifndef QT_NO_SOUND |
97 | #include <sys/soundcard.h> | 97 | #include <sys/soundcard.h> |
98 | #endif | 98 | #endif |
99 | #include "qt_override_p.h" | 99 | #include "qt_override_p.h" |
100 | 100 | ||
101 | #include <backend/rohfeedback.h> | 101 | #include <backend/rohfeedback.h> |
102 | 102 | ||
103 | 103 | ||
104 | static bool useBigPixmaps = 0; | 104 | static bool useBigPixmaps = 0; |
105 | 105 | ||
106 | class HackWidget : public QWidget | 106 | class HackWidget : public QWidget |
107 | { | 107 | { |
108 | public: | 108 | public: |
109 | bool needsOk() | 109 | bool needsOk() |
110 | { return (getWState() & WState_Reserved1 ); } | 110 | { return (getWState() & WState_Reserved1 ); } |
111 | 111 | ||
112 | QRect normalGeometry() | 112 | QRect normalGeometry() |
113 | { return topData()->normalGeometry; }; | 113 | { return topData()->normalGeometry; }; |
114 | }; | 114 | }; |
115 | 115 | ||
116 | class QPEApplicationData | 116 | class QPEApplicationData |
117 | { | 117 | { |
118 | public: | 118 | public: |
119 | QPEApplicationData ( ) : | 119 | QPEApplicationData ( ) : |
120 | presstimer( 0 ), presswidget( 0 ), rightpressed( false ), kbgrabbed( false ), | 120 | presstimer( 0 ), presswidget( 0 ), rightpressed( false ), kbgrabbed( false ), |
121 | notbusysent( false ), preloaded( false ), forceshow( false ), nomaximize( false ), | 121 | notbusysent( false ), preloaded( false ), forceshow( false ), nomaximize( false ), |
122 | keep_running( true ), qcopQok( false ), | 122 | keep_running( true ), qcopQok( false ), |
123 | fontFamily( "Vera" ), fontSize( 10 ), smallIconSize( 14 ), | 123 | fontFamily( "Vera" ), fontSize( 10 ), smallIconSize( 14 ), |
124 | bigIconSize( 32 ), qpe_main_widget( 0 ) | 124 | bigIconSize( 32 ), qpe_main_widget( 0 ) |
125 | { | 125 | { |
126 | Config cfg( "qpe" ); | 126 | Config cfg( "qpe" ); |
127 | cfg.setGroup( "Appearance" ); | 127 | cfg.setGroup( "Appearance" ); |
128 | useBigPixmaps = cfg.readBoolEntry( "useBigPixmaps", false ); | 128 | useBigPixmaps = cfg.readBoolEntry( "useBigPixmaps", false ); |
129 | fontFamily = cfg.readEntry( "FontFamily", "Vera" ); | 129 | fontFamily = cfg.readEntry( "FontFamily", "Vera" ); |
130 | fontSize = cfg.readNumEntry( "FontSize", 10 ); | 130 | fontSize = cfg.readNumEntry( "FontSize", 10 ); |
131 | smallIconSize = cfg.readNumEntry( "SmallIconSize", 14 ); | 131 | smallIconSize = cfg.readNumEntry( "SmallIconSize", 14 ); |
132 | bigIconSize = cfg.readNumEntry( "BigIconSize", 32 ); | 132 | bigIconSize = cfg.readNumEntry( "BigIconSize", 32 ); |
133 | #ifdef OPIE_WITHROHFEEDBACK | 133 | #ifdef OPIE_WITHROHFEEDBACK |
134 | RoH = 0; | 134 | RoH = 0; |
135 | #endif | 135 | #endif |
136 | } | 136 | } |
137 | 137 | ||
138 | int presstimer; | 138 | int presstimer; |
139 | QWidget* presswidget; | 139 | QWidget* presswidget; |
140 | QPoint presspos; | 140 | QPoint presspos; |
141 | #ifdef OPIE_WITHROHFEEDBACK | 141 | #ifdef OPIE_WITHROHFEEDBACK |
142 | Opie::Internal::RoHFeedback *RoH; | 142 | Opie::Internal::RoHFeedback *RoH; |
143 | #endif | 143 | #endif |
144 | 144 | ||
145 | bool rightpressed : 1; | 145 | bool rightpressed : 1; |
146 | bool kbgrabbed : 1; | 146 | bool kbgrabbed : 1; |
147 | bool notbusysent : 1; | 147 | bool notbusysent : 1; |
148 | bool preloaded : 1; | 148 | bool preloaded : 1; |
149 | bool forceshow : 1; | 149 | bool forceshow : 1; |
150 | bool nomaximize : 1; | 150 | bool nomaximize : 1; |
151 | bool keep_running : 1; | 151 | bool keep_running : 1; |
152 | bool qcopQok : 1; | 152 | bool qcopQok : 1; |
153 | 153 | ||
154 | QCString fontFamily; | 154 | QCString fontFamily; |
155 | int fontSize; | 155 | int fontSize; |
156 | int smallIconSize; | 156 | int smallIconSize; |
157 | int bigIconSize; | 157 | int bigIconSize; |
158 | 158 | ||
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 | if ( mw->inherits("QMainWindow") || mw->isA("QMainWindow") ) | 202 | if ( mw->inherits("QMainWindow") || mw->isA("QMainWindow") ) |
203 | { | 203 | { |
204 | ( ( QMainWindow* ) mw )->setUsesBigPixmaps( useBigPixmaps ); | 204 | ( ( QMainWindow* ) mw )->setUsesBigPixmaps( useBigPixmaps ); |
205 | } | 205 | } |
206 | QPoint p; | 206 | QPoint p; |
207 | QSize s; | 207 | QSize s; |
208 | bool max; | 208 | bool max; |
209 | 209 | ||
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 | QPEApplication::showDialog((QDialog*)mw,nomaximize); | 229 | QPEApplication::showDialog((QDialog*)mw,nomaximize); |
230 | } | 230 | } |
231 | } else { | 231 | } else { |
232 | if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { | 232 | if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { |
233 | mw->resize(s); | 233 | mw->resize(s); |
234 | mw->move(p); | 234 | mw->move(p); |
235 | } else { //no stored rectangle, make an estimation | 235 | } else { //no stored rectangle, make an estimation |
236 | int x = (qApp->desktop()->width()-mw->frameGeometry().width())/2; | 236 | int x = (qApp->desktop()->width()-mw->frameGeometry().width())/2; |
237 | int y = (qApp->desktop()->height()-mw->frameGeometry().height())/2; | 237 | int y = (qApp->desktop()->height()-mw->frameGeometry().height())/2; |
238 | mw->move( QMAX(x,0), QMAX(y,0) ); | 238 | mw->move( QMAX(x,0), QMAX(y,0) ); |
239 | #ifdef Q_WS_QWS | 239 | #ifdef Q_WS_QWS |
240 | if ( !nomaximize ) | 240 | if ( !nomaximize ) |
241 | mw->showMaximized(); | 241 | mw->showMaximized(); |
242 | #endif | 242 | #endif |
243 | } | 243 | } |
244 | if ( max && !nomaximize ) | 244 | if ( max && !nomaximize ) |
245 | mw->showMaximized(); | 245 | mw->showMaximized(); |
246 | else | 246 | else |
247 | mw->show(); | 247 | mw->show(); |
248 | } | 248 | } |
249 | } | 249 | } |
250 | } | 250 | } |
251 | 251 | ||
252 | static bool read_widget_rect(const QString &app, bool &maximized, QPoint &p, QSize &s) | 252 | static bool read_widget_rect(const QString &app, bool &maximized, QPoint &p, QSize &s) |
253 | { | 253 | { |
254 | maximized = TRUE; | 254 | maximized = TRUE; |
255 | // 350 is the trigger in qwsdefaultdecoration for providing a resize button | 255 | // 350 is the trigger in qwsdefaultdecoration for providing a resize button |
256 | if ( qApp->desktop()->width() <= 350 ) | 256 | if ( qApp->desktop()->width() <= 350 ) |
257 | return FALSE; | 257 | return FALSE; |
258 | 258 | ||
259 | Config cfg( "qpe" ); | 259 | Config cfg( "qpe" ); |
260 | cfg.setGroup("ApplicationPositions"); | 260 | cfg.setGroup("ApplicationPositions"); |
261 | QString str = cfg.readEntry( app, QString::null ); | 261 | QString str = cfg.readEntry( app, QString::null ); |
262 | QStringList l = QStringList::split(",", str); | 262 | QStringList l = QStringList::split(",", str); |
263 | 263 | ||
264 | if ( l.count() == 5) { | 264 | if ( l.count() == 5) { |
265 | p.setX( l[0].toInt() ); | 265 | p.setX( l[0].toInt() ); |
266 | p.setY( l[1].toInt() ); | 266 | p.setY( l[1].toInt() ); |
267 | 267 | ||
268 | s.setWidth( l[2].toInt() ); | 268 | s.setWidth( l[2].toInt() ); |
269 | s.setHeight( l[3].toInt() ); | 269 | s.setHeight( l[3].toInt() ); |
270 | 270 | ||
271 | maximized = l[4].toInt(); | 271 | maximized = l[4].toInt(); |
272 | 272 | ||
273 | return TRUE; | 273 | return TRUE; |
274 | } | 274 | } |
275 | 275 | ||
276 | return FALSE; | 276 | return FALSE; |
277 | } | 277 | } |
278 | 278 | ||
279 | 279 | ||
280 | static bool validate_widget_size(const QWidget *w, QPoint &p, QSize &s) | 280 | static bool validate_widget_size(const QWidget *w, QPoint &p, QSize &s) |
281 | { | 281 | { |
282 | #ifndef Q_WS_QWS | 282 | #ifndef Q_WS_QWS |
283 | QRect qt_maxWindowRect = qApp->desktop()->geometry(); | 283 | QRect qt_maxWindowRect = qApp->desktop()->geometry(); |
284 | #endif | 284 | #endif |
285 | int maxX = qt_maxWindowRect.width(); | 285 | int maxX = qt_maxWindowRect.width(); |
286 | int maxY = qt_maxWindowRect.height(); | 286 | int maxY = qt_maxWindowRect.height(); |
287 | int wWidth = s.width() + ( w->frameGeometry().width() - w->geometry().width() ); | 287 | int wWidth = s.width() + ( w->frameGeometry().width() - w->geometry().width() ); |
288 | int wHeight = s.height() + ( w->frameGeometry().height() - w->geometry().height() ); | 288 | int wHeight = s.height() + ( w->frameGeometry().height() - w->geometry().height() ); |
289 | 289 | ||
290 | // total window size is not allowed to be larger than desktop window size | 290 | // total window size is not allowed to be larger than desktop window size |
291 | if ( ( wWidth >= maxX ) && ( wHeight >= maxY ) ) | 291 | if ( ( wWidth >= maxX ) && ( wHeight >= maxY ) ) |
292 | return FALSE; | 292 | return FALSE; |
293 | 293 | ||
294 | if ( wWidth > maxX ) { | 294 | if ( wWidth > maxX ) { |
295 | s.setWidth( maxX - (w->frameGeometry().width() - w->geometry().width() ) ); | 295 | s.setWidth( maxX - (w->frameGeometry().width() - w->geometry().width() ) ); |
296 | wWidth = maxX; | 296 | wWidth = maxX; |
297 | } | 297 | } |
298 | 298 | ||
299 | if ( wHeight > maxY ) { | 299 | if ( wHeight > maxY ) { |
300 | s.setHeight( maxY - (w->frameGeometry().height() - w->geometry().height() ) ); | 300 | s.setHeight( maxY - (w->frameGeometry().height() - w->geometry().height() ) ); |
301 | wHeight = maxY; | 301 | wHeight = maxY; |
302 | } | 302 | } |
303 | 303 | ||
304 | // any smaller than this and the maximize/close/help buttons will be overlapping | 304 | // any smaller than this and the maximize/close/help buttons will be overlapping |
305 | if ( wWidth < 80 || wHeight < 60 ) | 305 | if ( wWidth < 80 || wHeight < 60 ) |
306 | return FALSE; | 306 | return FALSE; |
307 | 307 | ||
308 | if ( p.x() < 0 ) | 308 | if ( p.x() < 0 ) |
309 | p.setX(0); | 309 | p.setX(0); |
310 | if ( p.y() < 0 ) | 310 | if ( p.y() < 0 ) |
311 | p.setY(0); | 311 | p.setY(0); |
312 | 312 | ||
313 | if ( p.x() + wWidth > maxX ) | 313 | if ( p.x() + wWidth > maxX ) |
314 | p.setX( maxX - wWidth ); | 314 | p.setX( maxX - wWidth ); |
315 | if ( p.y() + wHeight > maxY ) | 315 | if ( p.y() + wHeight > maxY ) |
316 | p.setY( maxY - wHeight ); | 316 | p.setY( maxY - wHeight ); |
317 | 317 | ||
318 | return TRUE; | 318 | return TRUE; |
319 | } | 319 | } |
320 | 320 | ||
321 | static void store_widget_rect(QWidget *w, QString &app) | 321 | static void store_widget_rect(QWidget *w, QString &app) |
322 | { | 322 | { |
323 | // 350 is the trigger in qwsdefaultdecoration for providing a resize button | 323 | // 350 is the trigger in qwsdefaultdecoration for providing a resize button |
324 | if ( qApp->desktop()->width() <= 350 ) | 324 | if ( qApp->desktop()->width() <= 350 ) |
325 | return; | 325 | return; |
326 | // we use these to map the offset of geometry and pos. ( we can only use normalGeometry to | 326 | // we use these to map the offset of geometry and pos. ( we can only use normalGeometry to |
327 | // get the non-maximized version, so we have to do it the hard way ) | 327 | // get the non-maximized version, so we have to do it the hard way ) |
328 | int offsetX = w->x() - w->geometry().left(); | 328 | int offsetX = w->x() - w->geometry().left(); |
329 | int offsetY = w->y() - w->geometry().top(); | 329 | int offsetY = w->y() - w->geometry().top(); |
330 | 330 | ||
331 | QRect r; | 331 | QRect r; |
332 | if ( w->isMaximized() ) | 332 | if ( w->isMaximized() ) |
333 | r = ( (HackWidget *) w)->normalGeometry(); | 333 | r = ( (HackWidget *) w)->normalGeometry(); |
334 | else | 334 | else |
335 | r = w->geometry(); | 335 | r = w->geometry(); |
336 | 336 | ||
337 | // Stores the window placement as pos(), size() (due to the offset mapping) | 337 | // Stores the window placement as pos(), size() (due to the offset mapping) |
338 | Config cfg( "qpe" ); | 338 | Config cfg( "qpe" ); |
339 | cfg.setGroup("ApplicationPositions"); | 339 | cfg.setGroup("ApplicationPositions"); |
340 | QString s; | 340 | QString s; |
341 | s.sprintf("%d,%d,%d,%d,%d", r.left() + offsetX, r.top() + offsetY, r.width(), r.height(), w->isMaximized() ); | 341 | s.sprintf("%d,%d,%d,%d,%d", r.left() + offsetX, r.top() + offsetY, r.width(), r.height(), w->isMaximized() ); |
342 | cfg.writeEntry( app, s ); | 342 | cfg.writeEntry( app, s ); |
343 | } | 343 | } |
344 | 344 | ||
345 | static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) | 345 | static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) |
346 | { | 346 | { |
347 | /* | 347 | /* |
348 | // This works but disable it for now until it is safe to apply | 348 | // This works but disable it for now until it is safe to apply |
349 | // What is does is scan the .desktop files of all the apps for | 349 | // What is does is scan the .desktop files of all the apps for |
350 | // the applnk that has the corresponding argv[0] as this program | 350 | // the applnk that has the corresponding argv[0] as this program |
351 | // then it uses the name stored in the .desktop file as the caption | 351 | // then it uses the name stored in the .desktop file as the caption |
352 | // for the main widget. This saves duplicating translations for | 352 | // for the main widget. This saves duplicating translations for |
353 | // the app name in the program and in the .desktop files. | 353 | // the app name in the program and in the .desktop files. |
354 | 354 | ||
355 | AppLnkSet apps( appsPath ); | 355 | AppLnkSet apps( appsPath ); |
356 | 356 | ||
357 | QList<AppLnk> appsList = apps.children(); | 357 | QList<AppLnk> appsList = apps.children(); |
358 | for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) { | 358 | for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) { |
359 | if ( (*it)->exec() == appName ) { | 359 | if ( (*it)->exec() == appName ) { |
360 | mw->setCaption( (*it)->name() ); | 360 | mw->setCaption( (*it)->name() ); |
361 | return TRUE; | 361 | return TRUE; |
362 | } | 362 | } |
363 | } | 363 | } |
364 | */ | 364 | */ |
365 | return FALSE; | 365 | return FALSE; |
366 | } | 366 | } |
367 | 367 | ||
368 | 368 | ||
369 | void show(QWidget* mw, bool nomax) | 369 | void show(QWidget* mw, bool nomax) |
370 | { | 370 | { |
371 | setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" ); | 371 | setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" ); |
372 | nomaximize = nomax; | 372 | nomaximize = nomax; |
373 | qpe_main_widget = mw; | 373 | qpe_main_widget = mw; |
374 | qcopQok = TRUE; | 374 | qcopQok = TRUE; |
375 | #ifndef QT_NO_COP | 375 | #ifndef QT_NO_COP |
376 | 376 | ||
377 | sendQCopQ(); | 377 | sendQCopQ(); |
378 | #endif | 378 | #endif |
379 | 379 | ||
380 | if ( preloaded ) { | 380 | if ( preloaded ) { |
381 | if (forceshow) | 381 | if (forceshow) |
382 | show_mx(mw, nomax, appName); | 382 | show_mx(mw, nomax, appName); |
383 | } | 383 | } |
384 | else if ( keep_running ) { | 384 | else if ( keep_running ) { |
385 | show_mx(mw, nomax, appName); | 385 | show_mx(mw, nomax, appName); |
386 | } | 386 | } |
387 | } | 387 | } |
388 | 388 | ||
389 | void loadTextCodecs() | 389 | void loadTextCodecs() |
390 | { | 390 | { |
391 | QString path = QPEApplication::qpeDir() + "plugins/textcodecs"; | 391 | QString path = QPEApplication::qpeDir() + "plugins/textcodecs"; |
392 | #ifdef Q_OS_MACX | 392 | #ifdef Q_OS_MACX |
393 | QDir dir( path, "lib*.dylib" ); | 393 | QDir dir( path, "lib*.dylib" ); |
394 | #else | 394 | #else |
395 | QDir dir( path, "lib*.so" ); | 395 | QDir dir( path, "lib*.so" ); |
396 | #endif | 396 | #endif |
397 | QStringList list; | 397 | QStringList list; |
398 | if ( dir. exists ( )) | 398 | if ( dir. exists ( )) |
399 | list = dir.entryList(); | 399 | list = dir.entryList(); |
400 | QStringList::Iterator it; | 400 | QStringList::Iterator it; |
401 | for ( it = list.begin(); it != list.end(); ++it ) { | 401 | for ( it = list.begin(); it != list.end(); ++it ) { |
402 | TextCodecInterface *iface = 0; | 402 | TextCodecInterface *iface = 0; |
403 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 403 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
404 | if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { | 404 | if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { |
405 | QValueList<int> mibs = iface->mibEnums(); | 405 | QValueList<int> mibs = iface->mibEnums(); |
406 | for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) { | 406 | for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) { |
407 | (void)iface->createForMib(*i); | 407 | (void)iface->createForMib(*i); |
408 | // ### it exists now; need to remember if we can delete it | 408 | // ### it exists now; need to remember if we can delete it |
409 | } | 409 | } |
410 | } | 410 | } |
411 | else { | 411 | else { |
412 | lib->unload(); | 412 | lib->unload(); |
413 | delete lib; | 413 | delete lib; |
414 | } | 414 | } |
415 | } | 415 | } |
416 | } | 416 | } |
417 | 417 | ||
418 | void loadImageCodecs() | 418 | void loadImageCodecs() |
419 | { | 419 | { |
420 | QString path = QPEApplication::qpeDir() + "plugins/imagecodecs"; | 420 | QString path = QPEApplication::qpeDir() + "plugins/imagecodecs"; |
421 | #ifdef Q_OS_MACX | 421 | #ifdef Q_OS_MACX |
422 | QDir dir( path, "lib*.dylib" ); | 422 | QDir dir( path, "lib*.dylib" ); |
423 | #else | 423 | #else |
424 | QDir dir( path, "lib*.so" ); | 424 | QDir dir( path, "lib*.so" ); |
425 | #endif | 425 | #endif |
426 | QStringList list; | 426 | QStringList list; |
427 | if ( dir. exists ( )) | 427 | if ( dir. exists ( )) |
428 | list = dir.entryList(); | 428 | list = dir.entryList(); |
429 | QStringList::Iterator it; | 429 | QStringList::Iterator it; |
430 | for ( it = list.begin(); it != list.end(); ++it ) { | 430 | for ( it = list.begin(); it != list.end(); ++it ) { |
431 | ImageCodecInterface *iface = 0; | 431 | ImageCodecInterface *iface = 0; |
432 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 432 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
433 | if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { | 433 | if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { |
434 | QStringList formats = iface->keys(); | 434 | QStringList formats = iface->keys(); |
435 | for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) { | 435 | for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) { |
436 | (void)iface->installIOHandler(*i); | 436 | (void)iface->installIOHandler(*i); |
437 | // ### it exists now; need to remember if we can delete it | 437 | // ### it exists now; need to remember if we can delete it |
438 | } | 438 | } |
439 | } | 439 | } |
440 | else { | 440 | else { |
441 | lib->unload(); | 441 | lib->unload(); |
442 | delete lib; | 442 | delete lib; |
443 | } | 443 | } |
444 | } | 444 | } |
445 | } | 445 | } |
446 | 446 | ||
447 | }; | 447 | }; |
448 | 448 | ||
449 | class ResourceMimeFactory : public QMimeSourceFactory | 449 | class ResourceMimeFactory : public QMimeSourceFactory |
450 | { | 450 | { |
451 | public: | 451 | public: |
452 | ResourceMimeFactory() : resImage( 0 ) | 452 | ResourceMimeFactory() : resImage( 0 ) |
453 | { | 453 | { |
454 | setFilePath( Global::helpPath() ); | 454 | setFilePath( Global::helpPath() ); |
455 | setExtensionType( "html", "text/html;charset=UTF-8" ); | 455 | setExtensionType( "html", "text/html;charset=UTF-8" ); |
456 | } | 456 | } |
457 | ~ResourceMimeFactory() { | 457 | ~ResourceMimeFactory() { |
458 | delete resImage; | 458 | delete resImage; |
459 | } | 459 | } |
460 | 460 | ||
461 | const QMimeSource* data( const QString& abs_name ) const | 461 | const QMimeSource* data( const QString& abs_name ) const |
462 | { | 462 | { |
463 | const QMimeSource * r = QMimeSourceFactory::data( abs_name ); | 463 | const QMimeSource * r = QMimeSourceFactory::data( abs_name ); |
464 | if ( !r ) { | 464 | if ( !r ) { |
465 | int sl = abs_name.length(); | 465 | int sl = abs_name.length(); |
466 | do { | 466 | do { |
467 | sl = abs_name.findRev( '/', sl - 1 ); | 467 | sl = abs_name.findRev( '/', sl - 1 ); |
468 | QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name; | 468 | QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name; |
469 | int dot = name.findRev( '.' ); | 469 | int dot = name.findRev( '.' ); |
470 | if ( dot >= 0 ) | 470 | if ( dot >= 0 ) |
471 | name = name.left( dot ); | 471 | name = name.left( dot ); |
472 | QImage img = Resource::loadImage( name ); | 472 | QImage img = Resource::loadImage( name ); |
473 | if ( !img.isNull() ) { | 473 | if ( !img.isNull() ) { |
474 | delete resImage; | 474 | delete resImage; |
475 | resImage = new QImageDrag( img ); | 475 | resImage = new QImageDrag( img ); |
476 | r = resImage; | 476 | r = resImage; |
477 | } | 477 | } |
478 | } | 478 | } |
479 | while ( !r && sl > 0 ); | 479 | while ( !r && sl > 0 ); |
480 | } | 480 | } |
481 | return r; | 481 | return r; |
482 | } | 482 | } |
483 | private: | 483 | private: |
484 | mutable QImageDrag *resImage; | 484 | mutable QImageDrag *resImage; |
485 | }; | 485 | }; |
486 | 486 | ||
487 | static int& hack(int& i) | 487 | static int& hack(int& i) |
488 | { | 488 | { |
489 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) | 489 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) |
490 | // These should be created, but aren't in Qt 2.3.0 | 490 | // These should be created, but aren't in Qt 2.3.0 |
491 | (void)new QUtf8Codec; | 491 | (void)new QUtf8Codec; |
492 | (void)new QUtf16Codec; | 492 | (void)new QUtf16Codec; |
493 | #endif | 493 | #endif |
494 | return i; | 494 | return i; |
495 | } | 495 | } |
496 | 496 | ||
497 | static int muted = 0; | 497 | static int muted = 0; |
498 | static int micMuted = 0; | 498 | static int micMuted = 0; |
499 | 499 | ||
500 | static void setVolume( int t = 0, int percent = -1 ) | 500 | static void setVolume( int t = 0, int percent = -1 ) |
501 | { | 501 | { |
502 | switch ( t ) { | 502 | switch ( t ) { |
503 | case 0: { | 503 | case 0: { |
504 | Config cfg( "qpe" ); | 504 | Config cfg( "qpe" ); |
505 | cfg.setGroup( "Volume" ); | 505 | cfg.setGroup( "Volume" ); |
506 | if ( percent < 0 ) | 506 | if ( percent < 0 ) |
507 | percent = cfg.readNumEntry( "VolumePercent", 50 ); | 507 | percent = cfg.readNumEntry( "VolumePercent", 50 ); |
508 | #ifndef QT_NO_SOUND | 508 | #ifndef QT_NO_SOUND |
509 | int fd = 0; | 509 | int fd = 0; |
510 | #ifdef QT_QWS_DEVFS | 510 | #ifdef QT_QWS_DEVFS |
511 | if ( ( fd = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) { | 511 | if ( ( fd = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) { |
512 | #else | 512 | #else |
513 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 513 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
514 | #endif | 514 | #endif |
515 | int vol = muted ? 0 : percent; | 515 | int vol = muted ? 0 : percent; |
516 | // set both channels to same volume | 516 | // set both channels to same volume |
517 | vol |= vol << 8; | 517 | vol |= vol << 8; |
518 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_VOLUME ), &vol ); | 518 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_VOLUME ), &vol ); |
519 | ::close( fd ); | 519 | ::close( fd ); |
520 | } | 520 | } |
521 | #endif | 521 | #endif |
522 | } | 522 | } |
523 | break; | 523 | break; |
524 | } | 524 | } |
525 | } | 525 | } |
526 | 526 | ||
527 | static void setMic( int t = 0, int percent = -1 ) | 527 | static void setMic( int t = 0, int percent = -1 ) |
528 | { | 528 | { |
529 | switch ( t ) { | 529 | switch ( t ) { |
530 | case 0: { | 530 | case 0: { |
531 | Config cfg( "qpe" ); | 531 | Config cfg( "qpe" ); |
532 | cfg.setGroup( "Volume" ); | 532 | cfg.setGroup( "Volume" ); |
533 | if ( percent < 0 ) | 533 | if ( percent < 0 ) |
534 | percent = cfg.readNumEntry( "Mic", 50 ); | 534 | percent = cfg.readNumEntry( "Mic", 50 ); |
535 | 535 | ||
536 | #ifndef QT_NO_SOUND | 536 | #ifndef QT_NO_SOUND |
537 | int fd = 0; | 537 | int fd = 0; |
538 | int mic = micMuted ? 0 : percent; | 538 | int mic = micMuted ? 0 : percent; |
539 | #ifdef QT_QWS_DEVFS | 539 | #ifdef QT_QWS_DEVFS |
540 | if ( ( fd = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) { | 540 | if ( ( fd = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) { |
541 | #else | 541 | #else |
542 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 542 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
543 | #endif | 543 | #endif |
544 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_MIC ), &mic ); | 544 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_MIC ), &mic ); |
545 | ::close( fd ); | 545 | ::close( fd ); |
546 | } | 546 | } |
547 | #endif | 547 | #endif |
548 | } | 548 | } |
549 | break; | 549 | break; |
550 | } | 550 | } |
551 | } | 551 | } |
552 | 552 | ||
553 | 553 | ||
554 | static void setBass( int t = 0, int percent = -1 ) | 554 | static void setBass( int t = 0, int percent = -1 ) |
555 | { | 555 | { |
556 | switch ( t ) { | 556 | switch ( t ) { |
557 | case 0: { | 557 | case 0: { |
558 | Config cfg( "qpe" ); | 558 | Config cfg( "qpe" ); |
559 | cfg.setGroup( "Volume" ); | 559 | cfg.setGroup( "Volume" ); |
560 | if ( percent < 0 ) | 560 | if ( percent < 0 ) |
561 | percent = cfg.readNumEntry( "BassPercent", 50 ); | 561 | percent = cfg.readNumEntry( "BassPercent", 50 ); |
562 | 562 | ||
563 | #ifndef QT_NO_SOUND | 563 | #ifndef QT_NO_SOUND |
564 | int fd = 0; | 564 | int fd = 0; |
565 | int bass = percent; | 565 | int bass = percent; |
566 | #ifdef QT_QWS_DEVFS | 566 | #ifdef QT_QWS_DEVFS |
567 | if ( ( fd = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) { | 567 | if ( ( fd = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) { |
568 | #else | 568 | #else |
569 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 569 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
570 | #endif | 570 | #endif |
571 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_BASS ), &bass ); | 571 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_BASS ), &bass ); |
572 | ::close( fd ); | 572 | ::close( fd ); |
573 | } | 573 | } |
574 | #endif | 574 | #endif |
575 | } | 575 | } |
@@ -1334,989 +1334,989 @@ void QPEApplication::reset() { | |||
1334 | qt_screen->connect( QString::null ); | 1334 | qt_screen->connect( QString::null ); |
1335 | 1335 | ||
1336 | // Redraw everything | 1336 | // Redraw everything |
1337 | applyStyle(); | 1337 | applyStyle(); |
1338 | } | 1338 | } |
1339 | 1339 | ||
1340 | #if (QT_VERSION < 238) && defined Q_OS_MACX | 1340 | #if (QT_VERSION < 238) && defined Q_OS_MACX |
1341 | bool qt_left_hand_scrollbars = false; | 1341 | bool qt_left_hand_scrollbars = false; |
1342 | #else | 1342 | #else |
1343 | extern bool qt_left_hand_scrollbars QPE_WEAK_SYMBOL; | 1343 | extern bool qt_left_hand_scrollbars QPE_WEAK_SYMBOL; |
1344 | #endif | 1344 | #endif |
1345 | 1345 | ||
1346 | /*! | 1346 | /*! |
1347 | \internal | 1347 | \internal |
1348 | */ | 1348 | */ |
1349 | void QPEApplication::applyStyle() | 1349 | void QPEApplication::applyStyle() |
1350 | { | 1350 | { |
1351 | Config config( "qpe" ); | 1351 | Config config( "qpe" ); |
1352 | config.setGroup( "Appearance" ); | 1352 | config.setGroup( "Appearance" ); |
1353 | 1353 | ||
1354 | #if QT_VERSION > 233 | 1354 | #if QT_VERSION > 233 |
1355 | #if !defined(OPIE_NO_OVERRIDE_QT) | 1355 | #if !defined(OPIE_NO_OVERRIDE_QT) |
1356 | // don't block ourselves ... | 1356 | // don't block ourselves ... |
1357 | Opie::force_appearance = 0; | 1357 | Opie::force_appearance = 0; |
1358 | 1358 | ||
1359 | static QString appname = Opie::binaryName ( ); | 1359 | static QString appname = Opie::binaryName ( ); |
1360 | 1360 | ||
1361 | QStringList ex = config. readListEntry ( "NoStyle", ';' ); | 1361 | QStringList ex = config. readListEntry ( "NoStyle", ';' ); |
1362 | int nostyle = 0; | 1362 | int nostyle = 0; |
1363 | for ( QStringList::Iterator it = ex. begin ( ); it != ex. end ( ); ++it ) { | 1363 | for ( QStringList::Iterator it = ex. begin ( ); it != ex. end ( ); ++it ) { |
1364 | if ( QRegExp (( *it ). mid ( 1 ), false, true ). find ( appname, 0 ) >= 0 ) { | 1364 | if ( QRegExp (( *it ). mid ( 1 ), false, true ). find ( appname, 0 ) >= 0 ) { |
1365 | nostyle = ( *it ). left ( 1 ). toInt ( 0, 32 ); | 1365 | nostyle = ( *it ). left ( 1 ). toInt ( 0, 32 ); |
1366 | break; | 1366 | break; |
1367 | } | 1367 | } |
1368 | } | 1368 | } |
1369 | #else | 1369 | #else |
1370 | int nostyle = 0; | 1370 | int nostyle = 0; |
1371 | #endif | 1371 | #endif |
1372 | 1372 | ||
1373 | // Widget style | 1373 | // Widget style |
1374 | QString style = config.readEntry( "Style", "FlatStyle" ); | 1374 | QString style = config.readEntry( "Style", "FlatStyle" ); |
1375 | 1375 | ||
1376 | // don't set a custom style | 1376 | // don't set a custom style |
1377 | if ( nostyle & Opie::Force_Style ) | 1377 | if ( nostyle & Opie::Force_Style ) |
1378 | style = "FlatStyle"; | 1378 | style = "FlatStyle"; |
1379 | 1379 | ||
1380 | internalSetStyle ( style ); | 1380 | internalSetStyle ( style ); |
1381 | 1381 | ||
1382 | // Colors - from /etc/colors/Liquid.scheme | 1382 | // Colors - from /etc/colors/Liquid.scheme |
1383 | QColor bgcolor( config.readEntry( "Background", "#E0E0E0" ) ); | 1383 | QColor bgcolor( config.readEntry( "Background", "#E0E0E0" ) ); |
1384 | QColor btncolor( config.readEntry( "Button", "#96c8fa" ) ); | 1384 | QColor btncolor( config.readEntry( "Button", "#96c8fa" ) ); |
1385 | QPalette pal( btncolor, bgcolor ); | 1385 | QPalette pal( btncolor, bgcolor ); |
1386 | QString color = config.readEntry( "Highlight", "#73adef" ); | 1386 | QString color = config.readEntry( "Highlight", "#73adef" ); |
1387 | pal.setColor( QColorGroup::Highlight, QColor( color ) ); | 1387 | pal.setColor( QColorGroup::Highlight, QColor( color ) ); |
1388 | color = config.readEntry( "HighlightedText", "#FFFFFF" ); | 1388 | color = config.readEntry( "HighlightedText", "#FFFFFF" ); |
1389 | pal.setColor( QColorGroup::HighlightedText, QColor( color ) ); | 1389 | pal.setColor( QColorGroup::HighlightedText, QColor( color ) ); |
1390 | color = config.readEntry( "Text", "#000000" ); | 1390 | color = config.readEntry( "Text", "#000000" ); |
1391 | pal.setColor( QColorGroup::Text, QColor( color ) ); | 1391 | pal.setColor( QColorGroup::Text, QColor( color ) ); |
1392 | color = config.readEntry( "ButtonText", "#000000" ); | 1392 | color = config.readEntry( "ButtonText", "#000000" ); |
1393 | pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) ); | 1393 | pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) ); |
1394 | color = config.readEntry( "Base", "#FFFFFF" ); | 1394 | color = config.readEntry( "Base", "#FFFFFF" ); |
1395 | pal.setColor( QColorGroup::Base, QColor( color ) ); | 1395 | pal.setColor( QColorGroup::Base, QColor( color ) ); |
1396 | 1396 | ||
1397 | pal.setColor( QPalette::Disabled, QColorGroup::Text, | 1397 | pal.setColor( QPalette::Disabled, QColorGroup::Text, |
1398 | pal.color( QPalette::Active, QColorGroup::Background ).dark() ); | 1398 | pal.color( QPalette::Active, QColorGroup::Background ).dark() ); |
1399 | 1399 | ||
1400 | setPalette( pal, TRUE ); | 1400 | setPalette( pal, TRUE ); |
1401 | 1401 | ||
1402 | 1402 | ||
1403 | // Set the ScrollBar on the 'right' side but only if the weak symbol is present | 1403 | // Set the ScrollBar on the 'right' side but only if the weak symbol is present |
1404 | if (&qt_left_hand_scrollbars ) | 1404 | if (&qt_left_hand_scrollbars ) |
1405 | qt_left_hand_scrollbars = config.readBoolEntry( "LeftHand", false ); | 1405 | qt_left_hand_scrollbars = config.readBoolEntry( "LeftHand", false ); |
1406 | 1406 | ||
1407 | // Window Decoration | 1407 | // Window Decoration |
1408 | QString dec = config.readEntry( "Decoration", "Flat" ); | 1408 | QString dec = config.readEntry( "Decoration", "Flat" ); |
1409 | 1409 | ||
1410 | // don't set a custom deco | 1410 | // don't set a custom deco |
1411 | if ( nostyle & Opie::Force_Decoration ) | 1411 | if ( nostyle & Opie::Force_Decoration ) |
1412 | dec = ""; | 1412 | dec = ""; |
1413 | 1413 | ||
1414 | 1414 | ||
1415 | if ( dec != d->decorationName ) { | 1415 | if ( dec != d->decorationName ) { |
1416 | qwsSetDecoration( new QPEDecoration( dec ) ); | 1416 | qwsSetDecoration( new QPEDecoration( dec ) ); |
1417 | d->decorationName = dec; | 1417 | d->decorationName = dec; |
1418 | } | 1418 | } |
1419 | 1419 | ||
1420 | // Font | 1420 | // Font |
1421 | QString ff = config.readEntry( "FontFamily", font().family() ); | 1421 | QString ff = config.readEntry( "FontFamily", font().family() ); |
1422 | int fs = config.readNumEntry( "FontSize", font().pointSize() ); | 1422 | int fs = config.readNumEntry( "FontSize", font().pointSize() ); |
1423 | 1423 | ||
1424 | // don't set a custom font | 1424 | // don't set a custom font |
1425 | if ( nostyle & Opie::Force_Font ) { | 1425 | if ( nostyle & Opie::Force_Font ) { |
1426 | ff = "Vera"; | 1426 | ff = "Vera"; |
1427 | fs = 10; | 1427 | fs = 10; |
1428 | } | 1428 | } |
1429 | 1429 | ||
1430 | setFont ( QFont ( ff, fs ), true ); | 1430 | setFont ( QFont ( ff, fs ), true ); |
1431 | 1431 | ||
1432 | #if !defined(OPIE_NO_OVERRIDE_QT) | 1432 | #if !defined(OPIE_NO_OVERRIDE_QT) |
1433 | // revert to global blocking policy ... | 1433 | // revert to global blocking policy ... |
1434 | Opie::force_appearance = config. readBoolEntry ( "ForceStyle", false ) ? Opie::Force_All : Opie::Force_None; | 1434 | Opie::force_appearance = config. readBoolEntry ( "ForceStyle", false ) ? Opie::Force_All : Opie::Force_None; |
1435 | Opie::force_appearance &= ~nostyle; | 1435 | Opie::force_appearance &= ~nostyle; |
1436 | #endif | 1436 | #endif |
1437 | #endif | 1437 | #endif |
1438 | } | 1438 | } |
1439 | 1439 | ||
1440 | void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data ) | 1440 | void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data ) |
1441 | { | 1441 | { |
1442 | #ifdef Q_WS_QWS | 1442 | #ifdef Q_WS_QWS |
1443 | QDataStream stream( data, IO_ReadOnly ); | 1443 | QDataStream stream( data, IO_ReadOnly ); |
1444 | if ( msg == "applyStyle()" ) { | 1444 | if ( msg == "applyStyle()" ) { |
1445 | applyStyle(); | 1445 | applyStyle(); |
1446 | } | 1446 | } |
1447 | else if ( msg == "toggleApplicationMenu()" ) { | 1447 | else if ( msg == "toggleApplicationMenu()" ) { |
1448 | QWidget *active = activeWindow ( ); | 1448 | QWidget *active = activeWindow ( ); |
1449 | 1449 | ||
1450 | if ( active ) { | 1450 | if ( active ) { |
1451 | QPEMenuToolFocusManager *man = QPEMenuToolFocusManager::manager ( ); | 1451 | QPEMenuToolFocusManager *man = QPEMenuToolFocusManager::manager ( ); |
1452 | bool oldactive = man-> isActive ( ); | 1452 | bool oldactive = man-> isActive ( ); |
1453 | 1453 | ||
1454 | man-> setActive( !man-> isActive() ); | 1454 | man-> setActive( !man-> isActive() ); |
1455 | 1455 | ||
1456 | if ( !oldactive && !man-> isActive ( )) { // no menubar to toggle -> try O-Menu | 1456 | if ( !oldactive && !man-> isActive ( )) { // no menubar to toggle -> try O-Menu |
1457 | QCopEnvelope e ( "QPE/TaskBar", "toggleStartMenu()" ); | 1457 | QCopEnvelope e ( "QPE/TaskBar", "toggleStartMenu()" ); |
1458 | } | 1458 | } |
1459 | } | 1459 | } |
1460 | } | 1460 | } |
1461 | else if ( msg == "setDefaultRotation(int)" ) { | 1461 | else if ( msg == "setDefaultRotation(int)" ) { |
1462 | if ( type() == GuiServer ) { | 1462 | if ( type() == GuiServer ) { |
1463 | int r; | 1463 | int r; |
1464 | stream >> r; | 1464 | stream >> r; |
1465 | setDefaultRotation( r ); | 1465 | setDefaultRotation( r ); |
1466 | } | 1466 | } |
1467 | } | 1467 | } |
1468 | else if ( msg == "setCurrentMode(int,int,int)" ) { // Added: 2003-06-11 by Tim Ansell <mithro@mithis.net> | 1468 | else if ( msg == "setCurrentMode(int,int,int)" ) { // Added: 2003-06-11 by Tim Ansell <mithro@mithis.net> |
1469 | if ( type() == GuiServer ) { | 1469 | if ( type() == GuiServer ) { |
1470 | int x, y, depth; | 1470 | int x, y, depth; |
1471 | stream >> x; | 1471 | stream >> x; |
1472 | stream >> y; | 1472 | stream >> y; |
1473 | stream >> depth; | 1473 | stream >> depth; |
1474 | setCurrentMode( x, y, depth ); | 1474 | setCurrentMode( x, y, depth ); |
1475 | } | 1475 | } |
1476 | } | 1476 | } |
1477 | else if ( msg == "reset()" ) { | 1477 | else if ( msg == "reset()" ) { |
1478 | if ( type() != GuiServer ) | 1478 | if ( type() != GuiServer ) |
1479 | reset(); | 1479 | reset(); |
1480 | } | 1480 | } |
1481 | else if ( msg == "setCurrentRotation(int)" ) { | 1481 | else if ( msg == "setCurrentRotation(int)" ) { |
1482 | int r; | 1482 | int r; |
1483 | stream >> r; | 1483 | stream >> r; |
1484 | setCurrentRotation( r ); | 1484 | setCurrentRotation( r ); |
1485 | } | 1485 | } |
1486 | else if ( msg == "shutdown()" ) { | 1486 | else if ( msg == "shutdown()" ) { |
1487 | if ( type() == GuiServer ) | 1487 | if ( type() == GuiServer ) |
1488 | shutdown(); | 1488 | shutdown(); |
1489 | } | 1489 | } |
1490 | else if ( msg == "quit()" ) { | 1490 | else if ( msg == "quit()" ) { |
1491 | if ( type() != GuiServer ) | 1491 | if ( type() != GuiServer ) |
1492 | tryQuit(); | 1492 | tryQuit(); |
1493 | } | 1493 | } |
1494 | else if ( msg == "forceQuit()" ) { | 1494 | else if ( msg == "forceQuit()" ) { |
1495 | if ( type() != GuiServer ) | 1495 | if ( type() != GuiServer ) |
1496 | quit(); | 1496 | quit(); |
1497 | } | 1497 | } |
1498 | else if ( msg == "restart()" ) { | 1498 | else if ( msg == "restart()" ) { |
1499 | if ( type() == GuiServer ) | 1499 | if ( type() == GuiServer ) |
1500 | restart(); | 1500 | restart(); |
1501 | } | 1501 | } |
1502 | else if ( msg == "language(QString)" ) { | 1502 | else if ( msg == "language(QString)" ) { |
1503 | if ( type() == GuiServer ) { | 1503 | if ( type() == GuiServer ) { |
1504 | QString l; | 1504 | QString l; |
1505 | stream >> l; | 1505 | stream >> l; |
1506 | QString cl = getenv( "LANG" ); | 1506 | QString cl = getenv( "LANG" ); |
1507 | if ( cl != l ) { | 1507 | if ( cl != l ) { |
1508 | if ( l.isNull() ) | 1508 | if ( l.isNull() ) |
1509 | unsetenv( "LANG" ); | 1509 | unsetenv( "LANG" ); |
1510 | else | 1510 | else |
1511 | setenv( "LANG", l.latin1(), 1 ); | 1511 | setenv( "LANG", l.latin1(), 1 ); |
1512 | restart(); | 1512 | restart(); |
1513 | } | 1513 | } |
1514 | } | 1514 | } |
1515 | } | 1515 | } |
1516 | else if ( msg == "timeChange(QString)" ) { | 1516 | else if ( msg == "timeChange(QString)" ) { |
1517 | QString t; | 1517 | QString t; |
1518 | stream >> t; | 1518 | stream >> t; |
1519 | if ( t.isNull() ) | 1519 | if ( t.isNull() ) |
1520 | unsetenv( "TZ" ); | 1520 | unsetenv( "TZ" ); |
1521 | else | 1521 | else |
1522 | setenv( "TZ", t.latin1(), 1 ); | 1522 | setenv( "TZ", t.latin1(), 1 ); |
1523 | // emit the signal so everyone else knows... | 1523 | // emit the signal so everyone else knows... |
1524 | emit timeChanged(); | 1524 | emit timeChanged(); |
1525 | } | 1525 | } |
1526 | else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) { | 1526 | else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) { |
1527 | if ( type() == GuiServer ) { | 1527 | if ( type() == GuiServer ) { |
1528 | QDateTime when; | 1528 | QDateTime when; |
1529 | QCString channel, message; | 1529 | QCString channel, message; |
1530 | int data; | 1530 | int data; |
1531 | stream >> when >> channel >> message >> data; | 1531 | stream >> when >> channel >> message >> data; |
1532 | AlarmServer::addAlarm( when, channel, message, data ); | 1532 | AlarmServer::addAlarm( when, channel, message, data ); |
1533 | } | 1533 | } |
1534 | } | 1534 | } |
1535 | else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) { | 1535 | else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) { |
1536 | if ( type() == GuiServer ) { | 1536 | if ( type() == GuiServer ) { |
1537 | QDateTime when; | 1537 | QDateTime when; |
1538 | QCString channel, message; | 1538 | QCString channel, message; |
1539 | int data; | 1539 | int data; |
1540 | stream >> when >> channel >> message >> data; | 1540 | stream >> when >> channel >> message >> data; |
1541 | AlarmServer::deleteAlarm( when, channel, message, data ); | 1541 | AlarmServer::deleteAlarm( when, channel, message, data ); |
1542 | } | 1542 | } |
1543 | } | 1543 | } |
1544 | else if ( msg == "clockChange(bool)" ) { | 1544 | else if ( msg == "clockChange(bool)" ) { |
1545 | int tmp; | 1545 | int tmp; |
1546 | stream >> tmp; | 1546 | stream >> tmp; |
1547 | emit clockChanged( tmp ); | 1547 | emit clockChanged( tmp ); |
1548 | } | 1548 | } |
1549 | else if ( msg == "weekChange(bool)" ) { | 1549 | else if ( msg == "weekChange(bool)" ) { |
1550 | int tmp; | 1550 | int tmp; |
1551 | stream >> tmp; | 1551 | stream >> tmp; |
1552 | emit weekChanged( tmp ); | 1552 | emit weekChanged( tmp ); |
1553 | } | 1553 | } |
1554 | else if ( msg == "setDateFormat(DateFormat)" ) { | 1554 | else if ( msg == "setDateFormat(DateFormat)" ) { |
1555 | DateFormat tmp; | 1555 | DateFormat tmp; |
1556 | stream >> tmp; | 1556 | stream >> tmp; |
1557 | emit dateFormatChanged( tmp ); | 1557 | emit dateFormatChanged( tmp ); |
1558 | } | 1558 | } |
1559 | else if ( msg == "setVolume(int,int)" ) { | 1559 | else if ( msg == "setVolume(int,int)" ) { |
1560 | int t, v; | 1560 | int t, v; |
1561 | stream >> t >> v; | 1561 | stream >> t >> v; |
1562 | setVolume( t, v ); | 1562 | setVolume( t, v ); |
1563 | emit volumeChanged( muted ); | 1563 | emit volumeChanged( muted ); |
1564 | } | 1564 | } |
1565 | else if ( msg == "volumeChange(bool)" ) { | 1565 | else if ( msg == "volumeChange(bool)" ) { |
1566 | stream >> muted; | 1566 | stream >> muted; |
1567 | setVolume(); | 1567 | setVolume(); |
1568 | emit volumeChanged( muted ); | 1568 | emit volumeChanged( muted ); |
1569 | } | 1569 | } |
1570 | else if ( msg == "setMic(int,int)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> | 1570 | else if ( msg == "setMic(int,int)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> |
1571 | int t, v; | 1571 | int t, v; |
1572 | stream >> t >> v; | 1572 | stream >> t >> v; |
1573 | setMic( t, v ); | 1573 | setMic( t, v ); |
1574 | emit micChanged( micMuted ); | 1574 | emit micChanged( micMuted ); |
1575 | } | 1575 | } |
1576 | else if ( msg == "micChange(bool)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> | 1576 | else if ( msg == "micChange(bool)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> |
1577 | stream >> micMuted; | 1577 | stream >> micMuted; |
1578 | setMic(); | 1578 | setMic(); |
1579 | emit micChanged( micMuted ); | 1579 | emit micChanged( micMuted ); |
1580 | } | 1580 | } |
1581 | else if ( msg == "setBass(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> | 1581 | else if ( msg == "setBass(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> |
1582 | int t, v; | 1582 | int t, v; |
1583 | stream >> t >> v; | 1583 | stream >> t >> v; |
1584 | setBass( t, v ); | 1584 | setBass( t, v ); |
1585 | } | 1585 | } |
1586 | else if ( msg == "bassChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> | 1586 | else if ( msg == "bassChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> |
1587 | setBass(); | 1587 | setBass(); |
1588 | } | 1588 | } |
1589 | else if ( msg == "setTreble(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> | 1589 | else if ( msg == "setTreble(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> |
1590 | int t, v; | 1590 | int t, v; |
1591 | stream >> t >> v; | 1591 | stream >> t >> v; |
1592 | setTreble( t, v ); | 1592 | setTreble( t, v ); |
1593 | } | 1593 | } |
1594 | else if ( msg == "trebleChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> | 1594 | else if ( msg == "trebleChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> |
1595 | setTreble(); | 1595 | setTreble(); |
1596 | } else if ( msg == "getMarkedText()" ) { | 1596 | } else if ( msg == "getMarkedText()" ) { |
1597 | if ( type() == GuiServer ) { | 1597 | if ( type() == GuiServer ) { |
1598 | const ushort unicode = 'C'-'@'; | 1598 | const ushort unicode = 'C'-'@'; |
1599 | const int scan = Key_C; | 1599 | const int scan = Key_C; |
1600 | qwsServer->processKeyEvent( unicode, scan, ControlButton, TRUE, FALSE ); | 1600 | qwsServer->processKeyEvent( unicode, scan, ControlButton, TRUE, FALSE ); |
1601 | qwsServer->processKeyEvent( unicode, scan, ControlButton, FALSE, FALSE ); | 1601 | qwsServer->processKeyEvent( unicode, scan, ControlButton, FALSE, FALSE ); |
1602 | } | 1602 | } |
1603 | } else if ( msg == "newChannel(QString)") { | 1603 | } else if ( msg == "newChannel(QString)") { |
1604 | QString myChannel = "QPE/Application/" + d->appName; | 1604 | QString myChannel = "QPE/Application/" + d->appName; |
1605 | QString channel; | 1605 | QString channel; |
1606 | stream >> channel; | 1606 | stream >> channel; |
1607 | if (channel == myChannel) { | 1607 | if (channel == myChannel) { |
1608 | processQCopFile(); | 1608 | processQCopFile(); |
1609 | d->sendQCopQ(); | 1609 | d->sendQCopQ(); |
1610 | } | 1610 | } |
1611 | } | 1611 | } |
1612 | 1612 | ||
1613 | 1613 | ||
1614 | #endif | 1614 | #endif |
1615 | } | 1615 | } |
1616 | 1616 | ||
1617 | 1617 | ||
1618 | 1618 | ||
1619 | 1619 | ||
1620 | 1620 | ||
1621 | /*! | 1621 | /*! |
1622 | \internal | 1622 | \internal |
1623 | */ | 1623 | */ |
1624 | bool QPEApplication::raiseAppropriateWindow() | 1624 | bool QPEApplication::raiseAppropriateWindow() |
1625 | { | 1625 | { |
1626 | bool r=FALSE; | 1626 | bool r=FALSE; |
1627 | 1627 | ||
1628 | // 1. Raise the main widget | 1628 | // 1. Raise the main widget |
1629 | QWidget *top = d->qpe_main_widget; | 1629 | QWidget *top = d->qpe_main_widget; |
1630 | if ( !top ) top = mainWidget(); | 1630 | if ( !top ) top = mainWidget(); |
1631 | 1631 | ||
1632 | if ( top && d->keep_running ) { | 1632 | if ( top && d->keep_running ) { |
1633 | if ( top->isVisible() ) | 1633 | if ( top->isVisible() ) |
1634 | r = TRUE; | 1634 | r = TRUE; |
1635 | else if (d->preloaded) { | 1635 | else if (d->preloaded) { |
1636 | // We are preloaded and not visible.. pretend we just started.. | 1636 | // We are preloaded and not visible.. pretend we just started.. |
1637 | #ifndef QT_NO_COP | 1637 | #ifndef QT_NO_COP |
1638 | QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); | 1638 | QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); |
1639 | e << d->appName; | 1639 | e << d->appName; |
1640 | #endif | 1640 | #endif |
1641 | } | 1641 | } |
1642 | 1642 | ||
1643 | d->show_mx(top,d->nomaximize, d->appName); | 1643 | d->show_mx(top,d->nomaximize, d->appName); |
1644 | top->raise(); | 1644 | top->raise(); |
1645 | } | 1645 | } |
1646 | 1646 | ||
1647 | QWidget *topm = activeModalWidget(); | 1647 | QWidget *topm = activeModalWidget(); |
1648 | 1648 | ||
1649 | // 2. Raise any parentless widgets (except top and topm, as they | 1649 | // 2. Raise any parentless widgets (except top and topm, as they |
1650 | // are raised before and after this loop). Order from most | 1650 | // are raised before and after this loop). Order from most |
1651 | // recently raised as deepest to least recently as top, so | 1651 | // recently raised as deepest to least recently as top, so |
1652 | // that repeated calls cycle through widgets. | 1652 | // that repeated calls cycle through widgets. |
1653 | QWidgetList *list = topLevelWidgets(); | 1653 | QWidgetList *list = topLevelWidgets(); |
1654 | if ( list ) { | 1654 | if ( list ) { |
1655 | bool foundlast = FALSE; | 1655 | bool foundlast = FALSE; |
1656 | QWidget* topsub = 0; | 1656 | QWidget* topsub = 0; |
1657 | if ( d->lastraised ) { | 1657 | if ( d->lastraised ) { |
1658 | for (QWidget* w = list->first(); w; w = list->next()) { | 1658 | for (QWidget* w = list->first(); w; w = list->next()) { |
1659 | if ( !w->parentWidget() && w != topm && w->isVisible() && !w->isDesktop() ) { | 1659 | if ( !w->parentWidget() && w != topm && w->isVisible() && !w->isDesktop() ) { |
1660 | if ( w == d->lastraised ) | 1660 | if ( w == d->lastraised ) |
1661 | foundlast = TRUE; | 1661 | foundlast = TRUE; |
1662 | if ( foundlast ) { | 1662 | if ( foundlast ) { |
1663 | w->raise(); | 1663 | w->raise(); |
1664 | topsub = w; | 1664 | topsub = w; |
1665 | } | 1665 | } |
1666 | } | 1666 | } |
1667 | } | 1667 | } |
1668 | } | 1668 | } |
1669 | for (QWidget* w = list->first(); w; w = list->next()) { | 1669 | for (QWidget* w = list->first(); w; w = list->next()) { |
1670 | if ( !w->parentWidget() && w != topm && w->isVisible() && !w->isDesktop() ) { | 1670 | if ( !w->parentWidget() && w != topm && w->isVisible() && !w->isDesktop() ) { |
1671 | if ( w == d->lastraised ) | 1671 | if ( w == d->lastraised ) |
1672 | break; | 1672 | break; |
1673 | w->raise(); | 1673 | w->raise(); |
1674 | topsub = w; | 1674 | topsub = w; |
1675 | } | 1675 | } |
1676 | } | 1676 | } |
1677 | d->lastraised = topsub; | 1677 | d->lastraised = topsub; |
1678 | delete list; | 1678 | delete list; |
1679 | } | 1679 | } |
1680 | 1680 | ||
1681 | // 3. Raise the active modal widget. | 1681 | // 3. Raise the active modal widget. |
1682 | if ( topm ) { | 1682 | if ( topm ) { |
1683 | topm->show(); | 1683 | topm->show(); |
1684 | topm->raise(); | 1684 | topm->raise(); |
1685 | // If we haven't already handled the fastAppShowing message | 1685 | // If we haven't already handled the fastAppShowing message |
1686 | if (!top && d->preloaded) { | 1686 | if (!top && d->preloaded) { |
1687 | #ifndef QT_NO_COP | 1687 | #ifndef QT_NO_COP |
1688 | QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); | 1688 | QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); |
1689 | e << d->appName; | 1689 | e << d->appName; |
1690 | #endif | 1690 | #endif |
1691 | } | 1691 | } |
1692 | r = FALSE; | 1692 | r = FALSE; |
1693 | } | 1693 | } |
1694 | 1694 | ||
1695 | return r; | 1695 | return r; |
1696 | } | 1696 | } |
1697 | 1697 | ||
1698 | 1698 | ||
1699 | void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data) | 1699 | void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data) |
1700 | { | 1700 | { |
1701 | #ifdef Q_WS_QWS | 1701 | #ifdef Q_WS_QWS |
1702 | 1702 | ||
1703 | if ( msg == "quit()" ) { | 1703 | if ( msg == "quit()" ) { |
1704 | tryQuit(); | 1704 | tryQuit(); |
1705 | } | 1705 | } |
1706 | else if ( msg == "quitIfInvisible()" ) { | 1706 | else if ( msg == "quitIfInvisible()" ) { |
1707 | if ( d->qpe_main_widget && !d->qpe_main_widget->isVisible() ) | 1707 | if ( d->qpe_main_widget && !d->qpe_main_widget->isVisible() ) |
1708 | quit(); | 1708 | quit(); |
1709 | } | 1709 | } |
1710 | else if ( msg == "close()" ) { | 1710 | else if ( msg == "close()" ) { |
1711 | hideOrQuit(); | 1711 | hideOrQuit(); |
1712 | } | 1712 | } |
1713 | else if ( msg == "disablePreload()" ) { | 1713 | else if ( msg == "disablePreload()" ) { |
1714 | d->preloaded = FALSE; | 1714 | d->preloaded = FALSE; |
1715 | d->keep_running = TRUE; | 1715 | d->keep_running = TRUE; |
1716 | /* so that quit will quit */ | 1716 | /* so that quit will quit */ |
1717 | } | 1717 | } |
1718 | else if ( msg == "enablePreload()" ) { | 1718 | else if ( msg == "enablePreload()" ) { |
1719 | if (d->qpe_main_widget) | 1719 | if (d->qpe_main_widget) |
1720 | d->preloaded = TRUE; | 1720 | d->preloaded = TRUE; |
1721 | d->keep_running = TRUE; | 1721 | d->keep_running = TRUE; |
1722 | /* so next quit won't quit */ | 1722 | /* so next quit won't quit */ |
1723 | } | 1723 | } |
1724 | else if ( msg == "raise()" ) { | 1724 | else if ( msg == "raise()" ) { |
1725 | d->keep_running = TRUE; | 1725 | d->keep_running = TRUE; |
1726 | d->notbusysent = FALSE; | 1726 | d->notbusysent = FALSE; |
1727 | raiseAppropriateWindow(); | 1727 | raiseAppropriateWindow(); |
1728 | // Tell the system we're still chugging along... | 1728 | // Tell the system we're still chugging along... |
1729 | QCopEnvelope e("QPE/System", "appRaised(QString)"); | 1729 | QCopEnvelope e("QPE/System", "appRaised(QString)"); |
1730 | e << d->appName; | 1730 | e << d->appName; |
1731 | } | 1731 | } |
1732 | else if ( msg == "flush()" ) { | 1732 | else if ( msg == "flush()" ) { |
1733 | emit flush(); | 1733 | emit flush(); |
1734 | // we need to tell the desktop | 1734 | // we need to tell the desktop |
1735 | QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" ); | 1735 | QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" ); |
1736 | e << d->appName; | 1736 | e << d->appName; |
1737 | } | 1737 | } |
1738 | else if ( msg == "reload()" ) { | 1738 | else if ( msg == "reload()" ) { |
1739 | emit reload(); | 1739 | emit reload(); |
1740 | } | 1740 | } |
1741 | else if ( msg == "setDocument(QString)" ) { | 1741 | else if ( msg == "setDocument(QString)" ) { |
1742 | d->keep_running = TRUE; | 1742 | d->keep_running = TRUE; |
1743 | QDataStream stream( data, IO_ReadOnly ); | 1743 | QDataStream stream( data, IO_ReadOnly ); |
1744 | QString doc; | 1744 | QString doc; |
1745 | stream >> doc; | 1745 | stream >> doc; |
1746 | QWidget *mw = mainWidget(); | 1746 | QWidget *mw = mainWidget(); |
1747 | if ( !mw ) | 1747 | if ( !mw ) |
1748 | mw = d->qpe_main_widget; | 1748 | mw = d->qpe_main_widget; |
1749 | if ( mw ) | 1749 | if ( mw ) |
1750 | Global::setDocument( mw, doc ); | 1750 | Global::setDocument( mw, doc ); |
1751 | 1751 | ||
1752 | } else if ( msg == "QPEProcessQCop()" ) { | 1752 | } else if ( msg == "QPEProcessQCop()" ) { |
1753 | processQCopFile(); | 1753 | processQCopFile(); |
1754 | d->sendQCopQ(); | 1754 | d->sendQCopQ(); |
1755 | }else | 1755 | }else |
1756 | { | 1756 | { |
1757 | bool p = d->keep_running; | 1757 | bool p = d->keep_running; |
1758 | d->keep_running = FALSE; | 1758 | d->keep_running = FALSE; |
1759 | emit appMessage( msg, data); | 1759 | emit appMessage( msg, data); |
1760 | if ( d->keep_running ) { | 1760 | if ( d->keep_running ) { |
1761 | d->notbusysent = FALSE; | 1761 | d->notbusysent = FALSE; |
1762 | raiseAppropriateWindow(); | 1762 | raiseAppropriateWindow(); |
1763 | if ( !p ) { | 1763 | if ( !p ) { |
1764 | // Tell the system we're still chugging along... | 1764 | // Tell the system we're still chugging along... |
1765 | #ifndef QT_NO_COP | 1765 | #ifndef QT_NO_COP |
1766 | QCopEnvelope e("QPE/System", "appRaised(QString)"); | 1766 | QCopEnvelope e("QPE/System", "appRaised(QString)"); |
1767 | e << d->appName; | 1767 | e << d->appName; |
1768 | #endif | 1768 | #endif |
1769 | } | 1769 | } |
1770 | } | 1770 | } |
1771 | if ( p ) | 1771 | if ( p ) |
1772 | d->keep_running = p; | 1772 | d->keep_running = p; |
1773 | } | 1773 | } |
1774 | #endif | 1774 | #endif |
1775 | } | 1775 | } |
1776 | 1776 | ||
1777 | 1777 | ||
1778 | /*! | 1778 | /*! |
1779 | Sets widget \a mw as the mainWidget() and shows it. For small windows, | 1779 | Sets widget \a mw as the mainWidget() and shows it. For small windows, |
1780 | consider passing TRUE for \a nomaximize rather than the default FALSE. | 1780 | consider passing TRUE for \a nomaximize rather than the default FALSE. |
1781 | 1781 | ||
1782 | \sa showMainDocumentWidget() | 1782 | \sa showMainDocumentWidget() |
1783 | */ | 1783 | */ |
1784 | void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize ) | 1784 | void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize ) |
1785 | { | 1785 | { |
1786 | // setMainWidget(mw); this breaks FastLoading because lastWindowClose() would quit | 1786 | // setMainWidget(mw); this breaks FastLoading because lastWindowClose() would quit |
1787 | d->show(mw, nomaximize ); | 1787 | d->show(mw, nomaximize ); |
1788 | } | 1788 | } |
1789 | 1789 | ||
1790 | /*! | 1790 | /*! |
1791 | Sets widget \a mw as the mainWidget() and shows it. For small windows, | 1791 | Sets widget \a mw as the mainWidget() and shows it. For small windows, |
1792 | consider passing TRUE for \a nomaximize rather than the default FALSE. | 1792 | consider passing TRUE for \a nomaximize rather than the default FALSE. |
1793 | 1793 | ||
1794 | This calls designates the application as | 1794 | This calls designates the application as |
1795 | a \link docwidget.html document-oriented\endlink application. | 1795 | a \link docwidget.html document-oriented\endlink application. |
1796 | 1796 | ||
1797 | The \a mw widget \e must have this slot: setDocument(const QString&). | 1797 | The \a mw widget \e must have this slot: setDocument(const QString&). |
1798 | 1798 | ||
1799 | \sa showMainWidget() | 1799 | \sa showMainWidget() |
1800 | */ | 1800 | */ |
1801 | void QPEApplication::showMainDocumentWidget( QWidget* mw, bool nomaximize ) | 1801 | void QPEApplication::showMainDocumentWidget( QWidget* mw, bool nomaximize ) |
1802 | { | 1802 | { |
1803 | if ( mw && argc() == 2 ) | 1803 | if ( mw && argc() == 2 ) |
1804 | Global::setDocument( mw, QString::fromUtf8(argv()[1]) ); | 1804 | Global::setDocument( mw, QString::fromUtf8(argv()[1]) ); |
1805 | 1805 | ||
1806 | 1806 | ||
1807 | // setMainWidget(mw); see above | 1807 | // setMainWidget(mw); see above |
1808 | d->show(mw, nomaximize ); | 1808 | d->show(mw, nomaximize ); |
1809 | } | 1809 | } |
1810 | 1810 | ||
1811 | 1811 | ||
1812 | /*! | 1812 | /*! |
1813 | If an application is started via a \link qcop.html QCop\endlink | 1813 | If an application is started via a \link qcop.html QCop\endlink |
1814 | message, the application will process the \link qcop.html | 1814 | message, the application will process the \link qcop.html |
1815 | QCop\endlink message and then quit. If the application calls this | 1815 | QCop\endlink message and then quit. If the application calls this |
1816 | function while processing a \link qcop.html QCop\endlink message, | 1816 | function while processing a \link qcop.html QCop\endlink message, |
1817 | after processing its outstanding \link qcop.html QCop\endlink | 1817 | after processing its outstanding \link qcop.html QCop\endlink |
1818 | messages the application will start 'properly' and show itself. | 1818 | messages the application will start 'properly' and show itself. |
1819 | 1819 | ||
1820 | \sa keepRunning() | 1820 | \sa keepRunning() |
1821 | */ | 1821 | */ |
1822 | void QPEApplication::setKeepRunning() | 1822 | void QPEApplication::setKeepRunning() |
1823 | { | 1823 | { |
1824 | if ( qApp && qApp->inherits( "QPEApplication" ) ) { | 1824 | if ( qApp && qApp->inherits( "QPEApplication" ) ) { |
1825 | QPEApplication * qpeApp = ( QPEApplication* ) qApp; | 1825 | QPEApplication * qpeApp = ( QPEApplication* ) qApp; |
1826 | qpeApp->d->keep_running = TRUE; | 1826 | qpeApp->d->keep_running = TRUE; |
1827 | } | 1827 | } |
1828 | } | 1828 | } |
1829 | 1829 | ||
1830 | /*! | 1830 | /*! |
1831 | Returns TRUE if the application will quit after processing the | 1831 | Returns TRUE if the application will quit after processing the |
1832 | current list of qcop messages; otherwise returns FALSE. | 1832 | current list of qcop messages; otherwise returns FALSE. |
1833 | 1833 | ||
1834 | \sa setKeepRunning() | 1834 | \sa setKeepRunning() |
1835 | */ | 1835 | */ |
1836 | bool QPEApplication::keepRunning() const | 1836 | bool QPEApplication::keepRunning() const |
1837 | { | 1837 | { |
1838 | return d->keep_running; | 1838 | return d->keep_running; |
1839 | } | 1839 | } |
1840 | 1840 | ||
1841 | /*! | 1841 | /*! |
1842 | \internal | 1842 | \internal |
1843 | */ | 1843 | */ |
1844 | void QPEApplication::internalSetStyle( const QString &style ) | 1844 | void QPEApplication::internalSetStyle( const QString &style ) |
1845 | { | 1845 | { |
1846 | #if QT_VERSION >= 300 | 1846 | #if QT_VERSION >= 0x030000 |
1847 | if ( style == "QPE" ) { | 1847 | if ( style == "QPE" ) { |
1848 | setStyle( new QPEStyle ); | 1848 | setStyle( new QPEStyle ); |
1849 | } | 1849 | } |
1850 | else { | 1850 | else { |
1851 | QStyle *s = QStyleFactory::create( style ); | 1851 | QStyle *s = QStyleFactory::create( style ); |
1852 | if ( s ) | 1852 | if ( s ) |
1853 | setStyle( s ); | 1853 | setStyle( s ); |
1854 | } | 1854 | } |
1855 | #else | 1855 | #else |
1856 | if ( style == "Windows" ) { | 1856 | if ( style == "Windows" ) { |
1857 | setStyle( new QWindowsStyle ); | 1857 | setStyle( new QWindowsStyle ); |
1858 | } | 1858 | } |
1859 | else if ( style == "QPE" ) { | 1859 | else if ( style == "QPE" ) { |
1860 | setStyle( new QPEStyle ); | 1860 | setStyle( new QPEStyle ); |
1861 | } | 1861 | } |
1862 | else if ( style == "Light" ) { | 1862 | else if ( style == "Light" ) { |
1863 | setStyle( new LightStyle ); | 1863 | setStyle( new LightStyle ); |
1864 | } | 1864 | } |
1865 | #ifndef QT_NO_STYLE_PLATINUM | 1865 | #ifndef QT_NO_STYLE_PLATINUM |
1866 | else if ( style == "Platinum" ) { | 1866 | else if ( style == "Platinum" ) { |
1867 | setStyle( new QPlatinumStyle ); | 1867 | setStyle( new QPlatinumStyle ); |
1868 | } | 1868 | } |
1869 | #endif | 1869 | #endif |
1870 | #ifndef QT_NO_STYLE_MOTIF | 1870 | #ifndef QT_NO_STYLE_MOTIF |
1871 | else if ( style == "Motif" ) { | 1871 | else if ( style == "Motif" ) { |
1872 | setStyle( new QMotifStyle ); | 1872 | setStyle( new QMotifStyle ); |
1873 | } | 1873 | } |
1874 | #endif | 1874 | #endif |
1875 | #ifndef QT_NO_STYLE_MOTIFPLUS | 1875 | #ifndef QT_NO_STYLE_MOTIFPLUS |
1876 | else if ( style == "MotifPlus" ) { | 1876 | else if ( style == "MotifPlus" ) { |
1877 | setStyle( new QMotifPlusStyle ); | 1877 | setStyle( new QMotifPlusStyle ); |
1878 | } | 1878 | } |
1879 | #endif | 1879 | #endif |
1880 | 1880 | ||
1881 | else { | 1881 | else { |
1882 | QStyle *sty = 0; | 1882 | QStyle *sty = 0; |
1883 | QString path = QPEApplication::qpeDir ( ) + "plugins/styles/"; | 1883 | QString path = QPEApplication::qpeDir ( ) + "plugins/styles/"; |
1884 | 1884 | ||
1885 | #ifdef Q_OS_MACX | 1885 | #ifdef Q_OS_MACX |
1886 | if ( style. find ( ".dylib" ) > 0 ) | 1886 | if ( style. find ( ".dylib" ) > 0 ) |
1887 | path += style; | 1887 | path += style; |
1888 | else | 1888 | else |
1889 | path = path + "lib" + style. lower ( ) + ".dylib"; // compatibility | 1889 | path = path + "lib" + style. lower ( ) + ".dylib"; // compatibility |
1890 | #else | 1890 | #else |
1891 | if ( style. find ( ".so" ) > 0 ) | 1891 | if ( style. find ( ".so" ) > 0 ) |
1892 | path += style; | 1892 | path += style; |
1893 | else | 1893 | else |
1894 | path = path + "lib" + style. lower ( ) + ".so"; // compatibility | 1894 | path = path + "lib" + style. lower ( ) + ".so"; // compatibility |
1895 | #endif | 1895 | #endif |
1896 | static QLibrary *lastlib = 0; | 1896 | static QLibrary *lastlib = 0; |
1897 | static StyleInterface *lastiface = 0; | 1897 | static StyleInterface *lastiface = 0; |
1898 | 1898 | ||
1899 | QLibrary *lib = new QLibrary ( path ); | 1899 | QLibrary *lib = new QLibrary ( path ); |
1900 | StyleInterface *iface = 0; | 1900 | StyleInterface *iface = 0; |
1901 | 1901 | ||
1902 | if (( lib-> queryInterface ( IID_Style, ( QUnknownInterface ** ) &iface ) == QS_OK ) && iface ) | 1902 | if (( lib-> queryInterface ( IID_Style, ( QUnknownInterface ** ) &iface ) == QS_OK ) && iface ) |
1903 | sty = iface-> style ( ); | 1903 | sty = iface-> style ( ); |
1904 | 1904 | ||
1905 | if ( sty ) { | 1905 | if ( sty ) { |
1906 | setStyle ( sty ); | 1906 | setStyle ( sty ); |
1907 | 1907 | ||
1908 | if ( lastiface ) | 1908 | if ( lastiface ) |
1909 | lastiface-> release ( ); | 1909 | lastiface-> release ( ); |
1910 | lastiface = iface; | 1910 | lastiface = iface; |
1911 | 1911 | ||
1912 | if ( lastlib ) { | 1912 | if ( lastlib ) { |
1913 | lastlib-> unload ( ); | 1913 | lastlib-> unload ( ); |
1914 | delete lastlib; | 1914 | delete lastlib; |
1915 | } | 1915 | } |
1916 | lastlib = lib; | 1916 | lastlib = lib; |
1917 | } | 1917 | } |
1918 | else { | 1918 | else { |
1919 | if ( iface ) | 1919 | if ( iface ) |
1920 | iface-> release ( ); | 1920 | iface-> release ( ); |
1921 | delete lib; | 1921 | delete lib; |
1922 | 1922 | ||
1923 | setStyle ( new LightStyle ( )); | 1923 | setStyle ( new LightStyle ( )); |
1924 | } | 1924 | } |
1925 | } | 1925 | } |
1926 | #endif | 1926 | #endif |
1927 | } | 1927 | } |
1928 | 1928 | ||
1929 | /*! | 1929 | /*! |
1930 | \internal | 1930 | \internal |
1931 | */ | 1931 | */ |
1932 | void QPEApplication::prepareForTermination( bool willrestart ) | 1932 | void QPEApplication::prepareForTermination( bool willrestart ) |
1933 | { | 1933 | { |
1934 | if ( willrestart ) { | 1934 | if ( willrestart ) { |
1935 | QLabel *lblWait = new QLabel( tr( "Please wait..." ), 0, "wait hack", QWidget::WStyle_Customize | | 1935 | QLabel *lblWait = new QLabel( tr( "Please wait..." ), 0, "wait hack", QWidget::WStyle_Customize | |
1936 | QWidget::WStyle_NoBorder | QWidget::WStyle_Tool ); | 1936 | QWidget::WStyle_NoBorder | QWidget::WStyle_Tool ); |
1937 | lblWait->setAlignment( QWidget::AlignCenter ); | 1937 | lblWait->setAlignment( QWidget::AlignCenter ); |
1938 | lblWait->show(); | 1938 | lblWait->show(); |
1939 | lblWait->showMaximized(); | 1939 | lblWait->showMaximized(); |
1940 | } | 1940 | } |
1941 | { QCopEnvelope envelope( "QPE/System", "forceQuit()" ); | 1941 | { QCopEnvelope envelope( "QPE/System", "forceQuit()" ); |
1942 | } | 1942 | } |
1943 | processEvents(); // ensure the message goes out. | 1943 | processEvents(); // ensure the message goes out. |
1944 | } | 1944 | } |
1945 | 1945 | ||
1946 | /*! | 1946 | /*! |
1947 | \internal | 1947 | \internal |
1948 | */ | 1948 | */ |
1949 | void QPEApplication::shutdown() | 1949 | void QPEApplication::shutdown() |
1950 | { | 1950 | { |
1951 | // Implement in server's QPEApplication subclass | 1951 | // Implement in server's QPEApplication subclass |
1952 | } | 1952 | } |
1953 | 1953 | ||
1954 | /*! | 1954 | /*! |
1955 | \internal | 1955 | \internal |
1956 | */ | 1956 | */ |
1957 | void QPEApplication::restart() | 1957 | void QPEApplication::restart() |
1958 | { | 1958 | { |
1959 | // Implement in server's QPEApplication subclass | 1959 | // Implement in server's QPEApplication subclass |
1960 | } | 1960 | } |
1961 | 1961 | ||
1962 | static QPtrDict<void>* stylusDict = 0; | 1962 | static QPtrDict<void>* stylusDict = 0; |
1963 | static void createDict() | 1963 | static void createDict() |
1964 | { | 1964 | { |
1965 | if ( !stylusDict ) | 1965 | if ( !stylusDict ) |
1966 | stylusDict = new QPtrDict<void>; | 1966 | stylusDict = new QPtrDict<void>; |
1967 | } | 1967 | } |
1968 | 1968 | ||
1969 | /*! | 1969 | /*! |
1970 | Returns the current StylusMode for widget \a w. | 1970 | Returns the current StylusMode for widget \a w. |
1971 | 1971 | ||
1972 | \sa setStylusOperation() StylusMode | 1972 | \sa setStylusOperation() StylusMode |
1973 | */ | 1973 | */ |
1974 | QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w ) | 1974 | QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w ) |
1975 | { | 1975 | { |
1976 | if ( stylusDict ) | 1976 | if ( stylusDict ) |
1977 | return ( StylusMode ) ( int ) stylusDict->find( w ); | 1977 | return ( StylusMode ) ( int ) stylusDict->find( w ); |
1978 | return LeftOnly; | 1978 | return LeftOnly; |
1979 | } | 1979 | } |
1980 | 1980 | ||
1981 | /*! | 1981 | /*! |
1982 | \enum QPEApplication::StylusMode | 1982 | \enum QPEApplication::StylusMode |
1983 | 1983 | ||
1984 | \value LeftOnly the stylus only generates LeftButton | 1984 | \value LeftOnly the stylus only generates LeftButton |
1985 | events (the default). | 1985 | events (the default). |
1986 | \value RightOnHold the stylus generates RightButton events | 1986 | \value RightOnHold the stylus generates RightButton events |
1987 | if the user uses the press-and-hold gesture. | 1987 | if the user uses the press-and-hold gesture. |
1988 | 1988 | ||
1989 | \sa setStylusOperation() stylusOperation() | 1989 | \sa setStylusOperation() stylusOperation() |
1990 | */ | 1990 | */ |
1991 | 1991 | ||
1992 | /*! | 1992 | /*! |
1993 | Causes widget \a w to receive mouse events according to the stylus | 1993 | Causes widget \a w to receive mouse events according to the stylus |
1994 | \a mode. | 1994 | \a mode. |
1995 | 1995 | ||
1996 | \sa stylusOperation() StylusMode | 1996 | \sa stylusOperation() StylusMode |
1997 | */ | 1997 | */ |
1998 | void QPEApplication::setStylusOperation( QWidget * w, StylusMode mode ) | 1998 | void QPEApplication::setStylusOperation( QWidget * w, StylusMode mode ) |
1999 | { | 1999 | { |
2000 | createDict(); | 2000 | createDict(); |
2001 | if ( mode == LeftOnly ) { | 2001 | if ( mode == LeftOnly ) { |
2002 | stylusDict->remove | 2002 | stylusDict->remove |
2003 | ( w ); | 2003 | ( w ); |
2004 | w->removeEventFilter( qApp ); | 2004 | w->removeEventFilter( qApp ); |
2005 | } | 2005 | } |
2006 | else { | 2006 | else { |
2007 | stylusDict->insert( w, ( void* ) mode ); | 2007 | stylusDict->insert( w, ( void* ) mode ); |
2008 | connect( w, SIGNAL( destroyed() ), qApp, SLOT( removeSenderFromStylusDict() ) ); | 2008 | connect( w, SIGNAL( destroyed() ), qApp, SLOT( removeSenderFromStylusDict() ) ); |
2009 | w->installEventFilter( qApp ); | 2009 | w->installEventFilter( qApp ); |
2010 | } | 2010 | } |
2011 | } | 2011 | } |
2012 | 2012 | ||
2013 | 2013 | ||
2014 | /*! | 2014 | /*! |
2015 | \reimp | 2015 | \reimp |
2016 | */ | 2016 | */ |
2017 | bool QPEApplication::eventFilter( QObject *o, QEvent *e ) | 2017 | bool QPEApplication::eventFilter( QObject *o, QEvent *e ) |
2018 | { | 2018 | { |
2019 | if ( !o->isWidgetType() ) | 2019 | if ( !o->isWidgetType() ) |
2020 | return FALSE; | 2020 | return FALSE; |
2021 | 2021 | ||
2022 | if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) { | 2022 | if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) { |
2023 | QMouseEvent * me = ( QMouseEvent* ) e; | 2023 | QMouseEvent * me = ( QMouseEvent* ) e; |
2024 | StylusMode mode = (StylusMode)(int)stylusDict->find(o); | 2024 | StylusMode mode = (StylusMode)(int)stylusDict->find(o); |
2025 | switch (mode) { | 2025 | switch (mode) { |
2026 | case RightOnHold: | 2026 | case RightOnHold: |
2027 | switch ( me->type() ) { | 2027 | switch ( me->type() ) { |
2028 | case QEvent::MouseButtonPress: | 2028 | case QEvent::MouseButtonPress: |
2029 | if ( me->button() == LeftButton ) { | 2029 | if ( me->button() == LeftButton ) { |
2030 | static long Pref = 500; // #### pref. | 2030 | static long Pref = 500; // #### pref. |
2031 | d->presswidget = (QWidget*)o; | 2031 | d->presswidget = (QWidget*)o; |
2032 | d->presspos = me->pos(); | 2032 | d->presspos = me->pos(); |
2033 | d->rightpressed = FALSE; | 2033 | d->rightpressed = FALSE; |
2034 | #ifdef OPIE_WITHROHFEEDBACK | 2034 | #ifdef OPIE_WITHROHFEEDBACK |
2035 | if( ! d->RoH ) | 2035 | if( ! d->RoH ) |
2036 | d->RoH = new Opie::Internal::RoHFeedback; | 2036 | d->RoH = new Opie::Internal::RoHFeedback; |
2037 | 2037 | ||
2038 | d->RoH->init( me->globalPos(), d->presswidget ); | 2038 | d->RoH->init( me->globalPos(), d->presswidget ); |
2039 | Pref = d->RoH->delay(); | 2039 | Pref = d->RoH->delay(); |
2040 | 2040 | ||
2041 | #endif | 2041 | #endif |
2042 | if (!d->presstimer ) | 2042 | if (!d->presstimer ) |
2043 | d->presstimer = startTimer( Pref ); // #### pref. | 2043 | d->presstimer = startTimer( Pref ); // #### pref. |
2044 | 2044 | ||
2045 | } | 2045 | } |
2046 | break; | 2046 | break; |
2047 | case QEvent::MouseMove: | 2047 | case QEvent::MouseMove: |
2048 | if (d->presstimer && (me->pos() - d->presspos).manhattanLength() > 8) { | 2048 | if (d->presstimer && (me->pos() - d->presspos).manhattanLength() > 8) { |
2049 | killTimer(d->presstimer); | 2049 | killTimer(d->presstimer); |
2050 | #ifdef OPIE_WITHROHFEEDBACK | 2050 | #ifdef OPIE_WITHROHFEEDBACK |
2051 | d->RoH->stop(); | 2051 | d->RoH->stop(); |
2052 | #endif | 2052 | #endif |
2053 | d->presstimer = 0; | 2053 | d->presstimer = 0; |
2054 | } | 2054 | } |
2055 | break; | 2055 | break; |
2056 | case QEvent::MouseButtonRelease: | 2056 | case QEvent::MouseButtonRelease: |
2057 | if ( me->button() == LeftButton ) { | 2057 | if ( me->button() == LeftButton ) { |
2058 | if ( d->presstimer ) { | 2058 | if ( d->presstimer ) { |
2059 | killTimer(d->presstimer); | 2059 | killTimer(d->presstimer); |
2060 | #ifdef OPIE_WITHROHFEEDBACK | 2060 | #ifdef OPIE_WITHROHFEEDBACK |
2061 | d->RoH->stop( ); | 2061 | d->RoH->stop( ); |
2062 | #endif | 2062 | #endif |
2063 | d->presstimer = 0; | 2063 | d->presstimer = 0; |
2064 | } | 2064 | } |
2065 | if ( d->rightpressed && d->presswidget ) { | 2065 | if ( d->rightpressed && d->presswidget ) { |
2066 | printf( "Send ButtonRelease\n" ); | 2066 | printf( "Send ButtonRelease\n" ); |
2067 | // Right released | 2067 | // Right released |
2068 | postEvent( d->presswidget, | 2068 | postEvent( d->presswidget, |
2069 | new QMouseEvent( QEvent::MouseButtonRelease, me->pos(), | 2069 | new QMouseEvent( QEvent::MouseButtonRelease, me->pos(), |
2070 | RightButton, LeftButton + RightButton ) ); | 2070 | RightButton, LeftButton + RightButton ) ); |
2071 | // Left released, off-widget | 2071 | // Left released, off-widget |
2072 | postEvent( d->presswidget, | 2072 | postEvent( d->presswidget, |
2073 | new QMouseEvent( QEvent::MouseMove, QPoint( -1, -1), | 2073 | new QMouseEvent( QEvent::MouseMove, QPoint( -1, -1), |
2074 | LeftButton, LeftButton ) ); | 2074 | LeftButton, LeftButton ) ); |
2075 | postEvent( d->presswidget, | 2075 | postEvent( d->presswidget, |
2076 | new QMouseEvent( QEvent::MouseButtonRelease, QPoint( -1, -1), | 2076 | new QMouseEvent( QEvent::MouseButtonRelease, QPoint( -1, -1), |
2077 | LeftButton, LeftButton ) ); | 2077 | LeftButton, LeftButton ) ); |
2078 | d->rightpressed = FALSE; | 2078 | d->rightpressed = FALSE; |
2079 | return TRUE; // don't send the real Left release | 2079 | return TRUE; // don't send the real Left release |
2080 | } | 2080 | } |
2081 | } | 2081 | } |
2082 | break; | 2082 | break; |
2083 | default: | 2083 | default: |
2084 | break; | 2084 | break; |
2085 | } | 2085 | } |
2086 | break; | 2086 | break; |
2087 | default: | 2087 | default: |
2088 | ; | 2088 | ; |
2089 | } | 2089 | } |
2090 | } | 2090 | } |
2091 | else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { | 2091 | else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { |
2092 | QKeyEvent *ke = (QKeyEvent *)e; | 2092 | QKeyEvent *ke = (QKeyEvent *)e; |
2093 | if ( ke->key() == Key_Enter ) { | 2093 | if ( ke->key() == Key_Enter ) { |
2094 | if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) { | 2094 | if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) { |
2095 | postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ', | 2095 | postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ', |
2096 | ke->state(), " ", ke->isAutoRepeat(), ke->count() ) ); | 2096 | ke->state(), " ", ke->isAutoRepeat(), ke->count() ) ); |
2097 | return TRUE; | 2097 | return TRUE; |
2098 | } | 2098 | } |
2099 | } | 2099 | } |
2100 | } | 2100 | } |
2101 | return FALSE; | 2101 | return FALSE; |
2102 | } | 2102 | } |
2103 | 2103 | ||
2104 | /*! | 2104 | /*! |
2105 | \reimp | 2105 | \reimp |
2106 | */ | 2106 | */ |
2107 | void QPEApplication::timerEvent( QTimerEvent *e ) | 2107 | void QPEApplication::timerEvent( QTimerEvent *e ) |
2108 | { | 2108 | { |
2109 | if ( e->timerId() == d->presstimer && d->presswidget ) { | 2109 | if ( e->timerId() == d->presstimer && d->presswidget ) { |
2110 | 2110 | ||
2111 | // Right pressed | 2111 | // Right pressed |
2112 | postEvent( d->presswidget, | 2112 | postEvent( d->presswidget, |
2113 | new QMouseEvent( QEvent::MouseButtonPress, d->presspos, | 2113 | new QMouseEvent( QEvent::MouseButtonPress, d->presspos, |
2114 | RightButton, LeftButton ) ); | 2114 | RightButton, LeftButton ) ); |
2115 | killTimer( d->presstimer ); | 2115 | killTimer( d->presstimer ); |
2116 | d->presstimer = 0; | 2116 | d->presstimer = 0; |
2117 | d->rightpressed = TRUE; | 2117 | d->rightpressed = TRUE; |
2118 | #ifdef OPIE_WITHROHFEEDBACK | 2118 | #ifdef OPIE_WITHROHFEEDBACK |
2119 | d->RoH->stop(); | 2119 | d->RoH->stop(); |
2120 | #endif | 2120 | #endif |
2121 | } | 2121 | } |
2122 | } | 2122 | } |
2123 | 2123 | ||
2124 | void QPEApplication::removeSenderFromStylusDict() | 2124 | void QPEApplication::removeSenderFromStylusDict() |
2125 | { | 2125 | { |
2126 | stylusDict->remove | 2126 | stylusDict->remove |
2127 | ( ( void* ) sender() ); | 2127 | ( ( void* ) sender() ); |
2128 | if ( d->presswidget == sender() ) | 2128 | if ( d->presswidget == sender() ) |
2129 | d->presswidget = 0; | 2129 | d->presswidget = 0; |
2130 | } | 2130 | } |
2131 | 2131 | ||
2132 | /*! | 2132 | /*! |
2133 | \internal | 2133 | \internal |
2134 | */ | 2134 | */ |
2135 | bool QPEApplication::keyboardGrabbed() const | 2135 | bool QPEApplication::keyboardGrabbed() const |
2136 | { | 2136 | { |
2137 | return d->kbgrabbed; | 2137 | return d->kbgrabbed; |
2138 | } | 2138 | } |
2139 | 2139 | ||
2140 | 2140 | ||
2141 | /*! | 2141 | /*! |
2142 | Reverses the effect of grabKeyboard(). This is called automatically | 2142 | Reverses the effect of grabKeyboard(). This is called automatically |
2143 | on program exit. | 2143 | on program exit. |
2144 | */ | 2144 | */ |
2145 | void QPEApplication::ungrabKeyboard() | 2145 | void QPEApplication::ungrabKeyboard() |
2146 | { | 2146 | { |
2147 | ((QPEApplication *) qApp )-> d-> kbgrabbed = false; | 2147 | ((QPEApplication *) qApp )-> d-> kbgrabbed = false; |
2148 | } | 2148 | } |
2149 | 2149 | ||
2150 | /*! | 2150 | /*! |
2151 | Grabs the physical keyboard keys, e.g. the application's launching | 2151 | Grabs the physical keyboard keys, e.g. the application's launching |
2152 | keys. Instead of launching applications when these keys are pressed | 2152 | keys. Instead of launching applications when these keys are pressed |
2153 | the signals emitted are sent to this application instead. Some games | 2153 | the signals emitted are sent to this application instead. Some games |
2154 | programs take over the launch keys in this way to make interaction | 2154 | programs take over the launch keys in this way to make interaction |
2155 | easier. | 2155 | easier. |
2156 | 2156 | ||
2157 | \sa ungrabKeyboard() | 2157 | \sa ungrabKeyboard() |
2158 | */ | 2158 | */ |
2159 | void QPEApplication::grabKeyboard() | 2159 | void QPEApplication::grabKeyboard() |
2160 | { | 2160 | { |
2161 | ((QPEApplication *) qApp )-> d-> kbgrabbed = true; | 2161 | ((QPEApplication *) qApp )-> d-> kbgrabbed = true; |
2162 | } | 2162 | } |
2163 | 2163 | ||
2164 | /*! | 2164 | /*! |
2165 | \reimp | 2165 | \reimp |
2166 | */ | 2166 | */ |
2167 | int QPEApplication::exec() | 2167 | int QPEApplication::exec() |
2168 | { | 2168 | { |
2169 | d->qcopQok = true; | 2169 | d->qcopQok = true; |
2170 | #ifndef QT_NO_COP | 2170 | #ifndef QT_NO_COP |
2171 | d->sendQCopQ(); | 2171 | d->sendQCopQ(); |
2172 | if ( !d->keep_running ) | 2172 | if ( !d->keep_running ) |
2173 | processEvents(); // we may have received QCop messages in the meantime. | 2173 | processEvents(); // we may have received QCop messages in the meantime. |
2174 | #endif | 2174 | #endif |
2175 | 2175 | ||
2176 | if ( d->keep_running ) | 2176 | if ( d->keep_running ) |
2177 | //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() ) | 2177 | //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() ) |
2178 | return QApplication::exec(); | 2178 | return QApplication::exec(); |
2179 | 2179 | ||
2180 | #ifndef QT_NO_COP | 2180 | #ifndef QT_NO_COP |
2181 | 2181 | ||
2182 | { | 2182 | { |
2183 | QCopEnvelope e( "QPE/System", "closing(QString)" ); | 2183 | QCopEnvelope e( "QPE/System", "closing(QString)" ); |
2184 | e << d->appName; | 2184 | e << d->appName; |
2185 | } | 2185 | } |
2186 | #endif | 2186 | #endif |
2187 | processEvents(); | 2187 | processEvents(); |
2188 | return 0; | 2188 | return 0; |
2189 | } | 2189 | } |
2190 | 2190 | ||
2191 | /*! | 2191 | /*! |
2192 | \internal | 2192 | \internal |
2193 | External request for application to quit. Quits if possible without | 2193 | External request for application to quit. Quits if possible without |
2194 | loosing state. | 2194 | loosing state. |
2195 | */ | 2195 | */ |
2196 | void QPEApplication::tryQuit() | 2196 | void QPEApplication::tryQuit() |
2197 | { | 2197 | { |
2198 | if ( activeModalWidget() ) | 2198 | if ( activeModalWidget() ) |
2199 | return ; // Inside modal loop or konsole. Too hard to save state. | 2199 | return ; // Inside modal loop or konsole. Too hard to save state. |
2200 | #ifndef QT_NO_COP | 2200 | #ifndef QT_NO_COP |
2201 | 2201 | ||
2202 | { | 2202 | { |
2203 | QCopEnvelope e( "QPE/System", "closing(QString)" ); | 2203 | QCopEnvelope e( "QPE/System", "closing(QString)" ); |
2204 | e << d->appName; | 2204 | e << d->appName; |
2205 | } | 2205 | } |
2206 | #endif | 2206 | #endif |
2207 | if ( d->keep_running ) | 2207 | if ( d->keep_running ) |
2208 | d->store_widget_rect(d->qpe_main_widget, d->appName); | 2208 | d->store_widget_rect(d->qpe_main_widget, d->appName); |
2209 | processEvents(); | 2209 | processEvents(); |
2210 | 2210 | ||
2211 | quit(); | 2211 | quit(); |
2212 | } | 2212 | } |
2213 | 2213 | ||
2214 | 2214 | ||
2215 | /*! | 2215 | /*! |
2216 | \internal | 2216 | \internal |
2217 | User initiated quit. Makes the window 'Go Away'. If preloaded this means | 2217 | User initiated quit. Makes the window 'Go Away'. If preloaded this means |
2218 | hiding the window. If not it means quitting the application. | 2218 | hiding the window. If not it means quitting the application. |
2219 | As this is user initiated we don't need to check state. | 2219 | As this is user initiated we don't need to check state. |
2220 | */ | 2220 | */ |
2221 | void QPEApplication::hideOrQuit() | 2221 | void QPEApplication::hideOrQuit() |
2222 | { | 2222 | { |
2223 | if ( d->keep_running ) | 2223 | if ( d->keep_running ) |
2224 | d->store_widget_rect(d->qpe_main_widget, d->appName); | 2224 | d->store_widget_rect(d->qpe_main_widget, d->appName); |
2225 | processEvents(); | 2225 | processEvents(); |
2226 | 2226 | ||
2227 | // If we are a preloaded application we don't actually quit, so emit | 2227 | // If we are a preloaded application we don't actually quit, so emit |
2228 | // a System message indicating we're quasi-closing. | 2228 | // a System message indicating we're quasi-closing. |
2229 | if ( d->preloaded && d->qpe_main_widget ) | 2229 | if ( d->preloaded && d->qpe_main_widget ) |
2230 | #ifndef QT_NO_COP | 2230 | #ifndef QT_NO_COP |
2231 | 2231 | ||
2232 | { | 2232 | { |
2233 | QCopEnvelope e("QPE/System", "fastAppHiding(QString)" ); | 2233 | QCopEnvelope e("QPE/System", "fastAppHiding(QString)" ); |
2234 | e << d->appName; | 2234 | e << d->appName; |
2235 | d->qpe_main_widget->hide(); | 2235 | d->qpe_main_widget->hide(); |
2236 | } | 2236 | } |
2237 | #endif | 2237 | #endif |
2238 | else | 2238 | else |
2239 | quit(); | 2239 | quit(); |
2240 | } | 2240 | } |
2241 | 2241 | ||
2242 | #if (__GNUC__ > 2 ) | 2242 | #if (__GNUC__ > 2 ) |
2243 | extern "C" void __cxa_pure_virtual(); | 2243 | extern "C" void __cxa_pure_virtual(); |
2244 | 2244 | ||
2245 | void __cxa_pure_virtual() | 2245 | void __cxa_pure_virtual() |
2246 | { | 2246 | { |
2247 | fprintf( stderr, "Pure virtual called\n"); | 2247 | fprintf( stderr, "Pure virtual called\n"); |
2248 | abort(); | 2248 | abort(); |
2249 | 2249 | ||
2250 | } | 2250 | } |
2251 | 2251 | ||
2252 | #endif | 2252 | #endif |
2253 | 2253 | ||
2254 | 2254 | ||
2255 | #if defined(OPIE_NEW_MALLOC) | 2255 | #if defined(OPIE_NEW_MALLOC) |
2256 | 2256 | ||
2257 | // The libraries with the skiff package (and possibly others) have | 2257 | // The libraries with the skiff package (and possibly others) have |
2258 | // completely useless implementations of builtin new and delete that | 2258 | // completely useless implementations of builtin new and delete that |
2259 | // use about 50% of your CPU. Here we revert to the simple libc | 2259 | // use about 50% of your CPU. Here we revert to the simple libc |
2260 | // functions. | 2260 | // functions. |
2261 | 2261 | ||
2262 | void* operator new[]( size_t size ) | 2262 | void* operator new[]( size_t size ) |
2263 | { | 2263 | { |
2264 | return malloc( size ); | 2264 | return malloc( size ); |
2265 | } | 2265 | } |
2266 | 2266 | ||
2267 | void* operator new( size_t size ) | 2267 | void* operator new( size_t size ) |
2268 | { | 2268 | { |
2269 | return malloc( size ); | 2269 | return malloc( size ); |
2270 | } | 2270 | } |
2271 | 2271 | ||
2272 | void operator delete[]( void* p ) | 2272 | void operator delete[]( void* p ) |
2273 | { | 2273 | { |
2274 | if ( p ) | 2274 | if ( p ) |
2275 | free( p ); | 2275 | free( p ); |
2276 | } | 2276 | } |
2277 | 2277 | ||
2278 | void operator delete[]( void* p, size_t /*size*/ ) | 2278 | void operator delete[]( void* p, size_t /*size*/ ) |
2279 | { | 2279 | { |
2280 | if ( p ) | 2280 | if ( p ) |
2281 | free( p ); | 2281 | free( p ); |
2282 | } | 2282 | } |
2283 | 2283 | ||
2284 | 2284 | ||
2285 | void operator delete( void* p ) | 2285 | void operator delete( void* p ) |
2286 | { | 2286 | { |
2287 | if ( p ) | 2287 | if ( p ) |
2288 | free( p ); | 2288 | free( p ); |
2289 | } | 2289 | } |
2290 | 2290 | ||
2291 | void operator delete( void* p, size_t /*size*/ ) | 2291 | void operator delete( void* p, size_t /*size*/ ) |
2292 | { | 2292 | { |
2293 | if ( p ) | 2293 | if ( p ) |
2294 | free( p ); | 2294 | free( p ); |
2295 | } | 2295 | } |
2296 | 2296 | ||
2297 | #endif | 2297 | #endif |
2298 | 2298 | ||
2299 | #if ( QT_VERSION <= 230 ) && !defined(SINGLE_APP) | 2299 | #if ( QT_VERSION <= 230 ) && !defined(SINGLE_APP) |
2300 | #include <qwidgetlist.h> | 2300 | #include <qwidgetlist.h> |
2301 | #ifdef QWS | 2301 | #ifdef QWS |
2302 | #include <qgfx_qws.h> | 2302 | #include <qgfx_qws.h> |
2303 | extern QRect qt_maxWindowRect; | 2303 | extern QRect qt_maxWindowRect; |
2304 | void qt_setMaxWindowRect(const QRect& r ) | 2304 | void qt_setMaxWindowRect(const QRect& r ) |
2305 | { | 2305 | { |
2306 | qt_maxWindowRect = qt_screen->mapFromDevice( r, | 2306 | qt_maxWindowRect = qt_screen->mapFromDevice( r, |
2307 | qt_screen->mapToDevice( QSize( qt_screen->width(), qt_screen->height() ) ) ); | 2307 | qt_screen->mapToDevice( QSize( qt_screen->width(), qt_screen->height() ) ) ); |
2308 | // Re-resize any maximized windows | 2308 | // Re-resize any maximized windows |
2309 | QWidgetList* l = QApplication::topLevelWidgets(); | 2309 | QWidgetList* l = QApplication::topLevelWidgets(); |
2310 | if ( l ) { | 2310 | if ( l ) { |
2311 | QWidget * w = l->first(); | 2311 | QWidget * w = l->first(); |
2312 | while ( w ) { | 2312 | while ( w ) { |
2313 | if ( w->isVisible() && w->isMaximized() ) { | 2313 | if ( w->isVisible() && w->isMaximized() ) { |
2314 | w->showMaximized(); | 2314 | w->showMaximized(); |
2315 | } | 2315 | } |
2316 | w = l->next(); | 2316 | w = l->next(); |
2317 | } | 2317 | } |
2318 | delete l; | 2318 | delete l; |
2319 | } | 2319 | } |
2320 | } | 2320 | } |
2321 | #endif | 2321 | #endif |
2322 | #endif | 2322 | #endif |