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