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