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