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