summaryrefslogtreecommitdiff
authorharlekin <harlekin>2002-12-13 19:37:59 (UTC)
committer harlekin <harlekin>2002-12-13 19:37:59 (UTC)
commite348262d418e3a133d13d039ed23da4625726f9d (patch) (unidiff)
tree36cdf26700d424b06b6c37b86e5f1e07bc233b88
parent11ccc2e5341677cd54037a1f9cfb04831feed0f9 (diff)
downloadopie-e348262d418e3a133d13d039ed23da4625726f9d.zip
opie-e348262d418e3a133d13d039ed23da4625726f9d.tar.gz
opie-e348262d418e3a133d13d039ed23da4625726f9d.tar.bz2
added Bass and Treble handling - next stop should be odevice
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--library/qpeapplication.cpp155
1 files changed, 108 insertions, 47 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp
index c41dd06..852671a 100644
--- a/library/qpeapplication.cpp
+++ b/library/qpeapplication.cpp
@@ -2,729 +2,771 @@
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** $Id$ 19** $Id$
20** 20**
21**********************************************************************/ 21**********************************************************************/
22#define QTOPIA_INTERNAL_LANGLIST 22#define QTOPIA_INTERNAL_LANGLIST
23#include <stdlib.h> 23#include <stdlib.h>
24#include <unistd.h> 24#include <unistd.h>
25#include <linux/limits.h> // needed for some toolchains (PATH_MAX) 25#include <linux/limits.h> // needed for some toolchains (PATH_MAX)
26#include <qfile.h> 26#include <qfile.h>
27#ifdef Q_WS_QWS 27#ifdef Q_WS_QWS
28#ifndef QT_NO_COP 28#ifndef QT_NO_COP
29#if QT_VERSION <= 231 29#if QT_VERSION <= 231
30#define private public 30#define private public
31#define sendLocally processEvent 31#define sendLocally processEvent
32#include "qcopenvelope_qws.h" 32#include "qcopenvelope_qws.h"
33#undef private 33#undef private
34#else 34#else
35#include "qcopenvelope_qws.h" 35#include "qcopenvelope_qws.h"
36#endif 36#endif
37#endif 37#endif
38#include <qwindowsystem_qws.h> 38#include <qwindowsystem_qws.h>
39#endif 39#endif
40#include <qtextstream.h> 40#include <qtextstream.h>
41#include <qpalette.h> 41#include <qpalette.h>
42#include <qbuffer.h> 42#include <qbuffer.h>
43#include <qptrdict.h> 43#include <qptrdict.h>
44#include <qregexp.h> 44#include <qregexp.h>
45#include <qdir.h> 45#include <qdir.h>
46#include <qlabel.h> 46#include <qlabel.h>
47#include <qdialog.h> 47#include <qdialog.h>
48#include <qdragobject.h> 48#include <qdragobject.h>
49#include <qtextcodec.h> 49#include <qtextcodec.h>
50#include <qevent.h> 50#include <qevent.h>
51#include <qtooltip.h> 51#include <qtooltip.h>
52#include <qsignal.h> 52#include <qsignal.h>
53#include "qpeapplication.h" 53#include "qpeapplication.h"
54#include "qpestyle.h" 54#include "qpestyle.h"
55#include "styleinterface.h" 55#include "styleinterface.h"
56#if QT_VERSION >= 300 56#if QT_VERSION >= 300
57#include <qstylefactory.h> 57#include <qstylefactory.h>
58#else 58#else
59#include <qplatinumstyle.h> 59#include <qplatinumstyle.h>
60#include <qwindowsstyle.h> 60#include <qwindowsstyle.h>
61#include <qmotifstyle.h> 61#include <qmotifstyle.h>
62#include <qmotifplusstyle.h> 62#include <qmotifplusstyle.h>
63#include "lightstyle.h" 63#include "lightstyle.h"
64 64
65#include <qpe/qlibrary.h> 65#include <qpe/qlibrary.h>
66#endif 66#endif
67#include "global.h" 67#include "global.h"
68#include "resource.h" 68#include "resource.h"
69#if QT_VERSION <= 230 && defined(QT_NO_CODECS) 69#if QT_VERSION <= 230 && defined(QT_NO_CODECS)
70#include "qutfcodec.h" 70#include "qutfcodec.h"
71#endif 71#endif
72#include "config.h" 72#include "config.h"
73#include "network.h" 73#include "network.h"
74#ifdef QWS 74#ifdef QWS
75#include "fontmanager.h" 75#include "fontmanager.h"
76#endif 76#endif
77 77
78#include "alarmserver.h" 78#include "alarmserver.h"
79#include "applnk.h" 79#include "applnk.h"
80#include "qpemenubar.h" 80#include "qpemenubar.h"
81#include "textcodecinterface.h" 81#include "textcodecinterface.h"
82#include "imagecodecinterface.h" 82#include "imagecodecinterface.h"
83 83
84#include <unistd.h> 84#include <unistd.h>
85#include <sys/file.h> 85#include <sys/file.h>
86#include <sys/ioctl.h> 86#include <sys/ioctl.h>
87#include <sys/soundcard.h> 87#include <sys/soundcard.h>
88 88
89#include "qt_override_p.h" 89#include "qt_override_p.h"
90 90
91 91
92class QPEApplicationData 92class QPEApplicationData
93{ 93{
94public: 94public:
95 QPEApplicationData() : presstimer( 0 ), presswidget( 0 ), kbgrabber( 0 ), 95 QPEApplicationData() : presstimer( 0 ), presswidget( 0 ), kbgrabber( 0 ),
96 rightpressed( FALSE ), kbregrab( FALSE ), notbusysent( FALSE ), preloaded( FALSE ), 96 rightpressed( FALSE ), kbregrab( FALSE ), notbusysent( FALSE ), preloaded( FALSE ),
97 forceshow( FALSE ), nomaximize( FALSE ), keep_running( TRUE ), qpe_main_widget( 0 ) 97 forceshow( FALSE ), nomaximize( FALSE ), keep_running( TRUE ), qpe_main_widget( 0 )
98 98
99 { 99 {
100 qcopq.setAutoDelete( TRUE ); 100 qcopq.setAutoDelete( TRUE );
101 } 101 }
102 102
103 int presstimer; 103 int presstimer;
104 QWidget* presswidget; 104 QWidget* presswidget;
105 int kbgrabber; 105 int kbgrabber;
106 QPoint presspos; 106 QPoint presspos;
107 107
108 bool rightpressed : 1; 108 bool rightpressed : 1;
109 bool kbregrab : 1; 109 bool kbregrab : 1;
110 bool notbusysent : 1; 110 bool notbusysent : 1;
111 bool preloaded : 1; 111 bool preloaded : 1;
112 bool forceshow : 1; 112 bool forceshow : 1;
113 bool nomaximize : 1; 113 bool nomaximize : 1;
114 bool keep_running : 1; 114 bool keep_running : 1;
115 115
116 QString appName; 116 QString appName;
117 struct QCopRec 117 struct QCopRec
118 { 118 {
119 QCopRec( const QCString &ch, const QCString &msg, 119 QCopRec( const QCString &ch, const QCString &msg,
120 const QByteArray &d ) : 120 const QByteArray &d ) :
121 channel( ch ), message( msg ), data( d ) 121 channel( ch ), message( msg ), data( d )
122 { } 122 { }
123 123
124 QCString channel; 124 QCString channel;
125 QCString message; 125 QCString message;
126 QByteArray data; 126 QByteArray data;
127 }; 127 };
128 QWidget* qpe_main_widget; 128 QWidget* qpe_main_widget;
129 QList<QCopRec> qcopq; 129 QList<QCopRec> qcopq;
130 130
131 void enqueueQCop( const QCString &ch, const QCString &msg, 131 void enqueueQCop( const QCString &ch, const QCString &msg,
132 const QByteArray &data ) 132 const QByteArray &data )
133 { 133 {
134 qcopq.append( new QCopRec( ch, msg, data ) ); 134 qcopq.append( new QCopRec( ch, msg, data ) );
135 } 135 }
136 void sendQCopQ() 136 void sendQCopQ()
137 { 137 {
138 QCopRec * r; 138 QCopRec * r;
139#ifndef QT_NO_COP 139#ifndef QT_NO_COP
140 140
141 for ( QListIterator<QCopRec> it( qcopq ); ( r = it.current() ); ++it ) 141 for ( QListIterator<QCopRec> it( qcopq ); ( r = it.current() ); ++it )
142 QCopChannel::sendLocally( r->channel, r->message, r->data ); 142 QCopChannel::sendLocally( r->channel, r->message, r->data );
143#endif 143#endif
144 144
145 qcopq.clear(); 145 qcopq.clear();
146 } 146 }
147 static void show_mx(QWidget* mw, bool nomaximize) 147 static void show_mx(QWidget* mw, bool nomaximize)
148 { 148 {
149 if ( mw->layout() && mw->inherits("QDialog") ) { 149 if ( mw->layout() && mw->inherits("QDialog") ) {
150 QPEApplication::showDialog((QDialog*)mw, nomaximize); 150 QPEApplication::showDialog((QDialog*)mw, nomaximize);
151 } 151 }
152 else { 152 else {
153#ifdef Q_WS_QWS 153#ifdef Q_WS_QWS
154 if ( !nomaximize ) 154 if ( !nomaximize )
155 mw->showMaximized(); 155 mw->showMaximized();
156 else 156 else
157#endif 157#endif
158 158
159 mw->show(); 159 mw->show();
160 } 160 }
161 } 161 }
162 static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) 162 static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ )
163 { 163 {
164 /* 164 /*
165 // This works but disable it for now until it is safe to apply 165 // This works but disable it for now until it is safe to apply
166 // What is does is scan the .desktop files of all the apps for 166 // What is does is scan the .desktop files of all the apps for
167 // the applnk that has the corresponding argv[0] as this program 167 // the applnk that has the corresponding argv[0] as this program
168 // then it uses the name stored in the .desktop file as the caption 168 // then it uses the name stored in the .desktop file as the caption
169 // for the main widget. This saves duplicating translations for 169 // for the main widget. This saves duplicating translations for
170 // the app name in the program and in the .desktop files. 170 // the app name in the program and in the .desktop files.
171 171
172 AppLnkSet apps( appsPath ); 172 AppLnkSet apps( appsPath );
173 173
174 QList<AppLnk> appsList = apps.children(); 174 QList<AppLnk> appsList = apps.children();
175 for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) { 175 for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) {
176 if ( (*it)->exec() == appName ) { 176 if ( (*it)->exec() == appName ) {
177 mw->setCaption( (*it)->name() ); 177 mw->setCaption( (*it)->name() );
178 return TRUE; 178 return TRUE;
179 } 179 }
180 } 180 }
181 */ 181 */
182 return FALSE; 182 return FALSE;
183 } 183 }
184 184
185 185
186 void show(QWidget* mw, bool nomax) 186 void show(QWidget* mw, bool nomax)
187 { 187 {
188 setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" ); 188 setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" );
189 nomaximize = nomax; 189 nomaximize = nomax;
190 qpe_main_widget = mw; 190 qpe_main_widget = mw;
191#ifndef QT_NO_COP 191#ifndef QT_NO_COP
192 192
193 sendQCopQ(); 193 sendQCopQ();
194#endif 194#endif
195 195
196 if ( preloaded ) { 196 if ( preloaded ) {
197 if (forceshow) 197 if (forceshow)
198 show_mx(mw, nomax); 198 show_mx(mw, nomax);
199 } 199 }
200 else if ( keep_running ) { 200 else if ( keep_running ) {
201 show_mx(mw, nomax); 201 show_mx(mw, nomax);
202 } 202 }
203 } 203 }
204 204
205 void loadTextCodecs() 205 void loadTextCodecs()
206 { 206 {
207 QString path = QPEApplication::qpeDir() + "/plugins/textcodecs"; 207 QString path = QPEApplication::qpeDir() + "/plugins/textcodecs";
208 QDir dir( path, "lib*.so" ); 208 QDir dir( path, "lib*.so" );
209 QStringList list; 209 QStringList list;
210 if ( dir. exists ( )) 210 if ( dir. exists ( ))
211 list = dir.entryList(); 211 list = dir.entryList();
212 QStringList::Iterator it; 212 QStringList::Iterator it;
213 for ( it = list.begin(); it != list.end(); ++it ) { 213 for ( it = list.begin(); it != list.end(); ++it ) {
214 TextCodecInterface *iface = 0; 214 TextCodecInterface *iface = 0;
215 QLibrary *lib = new QLibrary( path + "/" + *it ); 215 QLibrary *lib = new QLibrary( path + "/" + *it );
216 if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { 216 if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) {
217 QValueList<int> mibs = iface->mibEnums(); 217 QValueList<int> mibs = iface->mibEnums();
218 for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) { 218 for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) {
219 (void)iface->createForMib(*i); 219 (void)iface->createForMib(*i);
220 // ### it exists now; need to remember if we can delete it 220 // ### it exists now; need to remember if we can delete it
221 } 221 }
222 } 222 }
223 else { 223 else {
224 lib->unload(); 224 lib->unload();
225 delete lib; 225 delete lib;
226 } 226 }
227 } 227 }
228 } 228 }
229 229
230 void loadImageCodecs() 230 void loadImageCodecs()
231 { 231 {
232 QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs"; 232 QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs";
233 QDir dir( path, "lib*.so" ); 233 QDir dir( path, "lib*.so" );
234 QStringList list; 234 QStringList list;
235 if ( dir. exists ( )) 235 if ( dir. exists ( ))
236 list = dir.entryList(); 236 list = dir.entryList();
237 QStringList::Iterator it; 237 QStringList::Iterator it;
238 for ( it = list.begin(); it != list.end(); ++it ) { 238 for ( it = list.begin(); it != list.end(); ++it ) {
239 ImageCodecInterface *iface = 0; 239 ImageCodecInterface *iface = 0;
240 QLibrary *lib = new QLibrary( path + "/" + *it ); 240 QLibrary *lib = new QLibrary( path + "/" + *it );
241 if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { 241 if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) {
242 QStringList formats = iface->keys(); 242 QStringList formats = iface->keys();
243 for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) { 243 for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) {
244 (void)iface->installIOHandler(*i); 244 (void)iface->installIOHandler(*i);
245 // ### it exists now; need to remember if we can delete it 245 // ### it exists now; need to remember if we can delete it
246 } 246 }
247 } 247 }
248 else { 248 else {
249 lib->unload(); 249 lib->unload();
250 delete lib; 250 delete lib;
251 } 251 }
252 } 252 }
253 } 253 }
254 QString styleName; 254 QString styleName;
255 QString decorationName; 255 QString decorationName;
256}; 256};
257 257
258class ResourceMimeFactory : public QMimeSourceFactory 258class ResourceMimeFactory : public QMimeSourceFactory
259{ 259{
260public: 260public:
261 ResourceMimeFactory() 261 ResourceMimeFactory()
262 { 262 {
263 setFilePath( Global::helpPath() ); 263 setFilePath( Global::helpPath() );
264 setExtensionType( "html", "text/html;charset=UTF-8" ); 264 setExtensionType( "html", "text/html;charset=UTF-8" );
265 } 265 }
266 266
267 const QMimeSource* data( const QString& abs_name ) const 267 const QMimeSource* data( const QString& abs_name ) const
268 { 268 {
269 const QMimeSource * r = QMimeSourceFactory::data( abs_name ); 269 const QMimeSource * r = QMimeSourceFactory::data( abs_name );
270 if ( !r ) { 270 if ( !r ) {
271 int sl = abs_name.length(); 271 int sl = abs_name.length();
272 do { 272 do {
273 sl = abs_name.findRev( '/', sl - 1 ); 273 sl = abs_name.findRev( '/', sl - 1 );
274 QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name; 274 QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name;
275 int dot = name.findRev( '.' ); 275 int dot = name.findRev( '.' );
276 if ( dot >= 0 ) 276 if ( dot >= 0 )
277 name = name.left( dot ); 277 name = name.left( dot );
278 QImage img = Resource::loadImage( name ); 278 QImage img = Resource::loadImage( name );
279 if ( !img.isNull() ) 279 if ( !img.isNull() )
280 r = new QImageDrag( img ); 280 r = new QImageDrag( img );
281 } 281 }
282 while ( !r && sl > 0 ); 282 while ( !r && sl > 0 );
283 } 283 }
284 return r; 284 return r;
285 } 285 }
286}; 286};
287 287
288static int muted = 0; 288static int muted = 0;
289static int micMuted = 0; 289static int micMuted = 0;
290 290
291static void setVolume( int t = 0, int percent = -1 ) 291static void setVolume( int t = 0, int percent = -1 )
292{ 292{
293 switch ( t ) { 293 switch ( t ) {
294 case 0: { 294 case 0: {
295 Config cfg( "qpe" ); 295 Config cfg( "qpe" );
296 cfg.setGroup( "Volume" ); 296 cfg.setGroup( "Volume" );
297 if ( percent < 0 ) 297 if ( percent < 0 )
298 percent = cfg.readNumEntry( "VolumePercent", 50 ); 298 percent = cfg.readNumEntry( "VolumePercent", 50 );
299 int fd = 0; 299 int fd = 0;
300 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { 300 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) {
301 int vol = muted ? 0 : percent; 301 int vol = muted ? 0 : percent;
302 // set both channels to same volume 302 // set both channels to same volume
303 vol |= vol << 8; 303 vol |= vol << 8;
304 ioctl( fd, MIXER_WRITE( 0 ), &vol ); 304 ioctl( fd, MIXER_WRITE( 0 ), &vol );
305 ::close( fd ); 305 ::close( fd );
306 } 306 }
307 } 307 }
308 break; 308 break;
309 } 309 }
310} 310}
311 311
312static void setMic( int t = 0, int percent = -1 ) 312static void setMic( int t = 0, int percent = -1 )
313{ 313{
314 switch ( t ) { 314 switch ( t ) {
315 case 0: { 315 case 0: {
316 Config cfg( "qpe" ); 316 Config cfg( "qpe" );
317 cfg.setGroup( "Volume" ); 317 cfg.setGroup( "Volume" );
318 if ( percent < 0 ) 318 if ( percent < 0 )
319 percent = cfg.readNumEntry( "Mic", 50 ); 319 percent = cfg.readNumEntry( "Mic", 50 );
320 320
321 int fd = 0; 321 int fd = 0;
322 int mic = micMuted ? 0 : percent; 322 int mic = micMuted ? 0 : percent;
323 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { 323 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) {
324 ioctl( fd, MIXER_WRITE( SOUND_MIXER_MIC ), &mic ); 324 ioctl( fd, MIXER_WRITE( SOUND_MIXER_MIC ), &mic );
325 ::close( fd ); 325 ::close( fd );
326 } 326 }
327 } 327 }
328 break; 328 break;
329 } 329 }
330} 330}
331 331
332 332
333static void setBass( int t = 0, int percent = -1 )
334{
335 switch ( t ) {
336 case 0: {
337 Config cfg( "qpe" );
338 cfg.setGroup( "Volume" );
339 if ( percent < 0 )
340 percent = cfg.readNumEntry( "BassPercent", 50 );
341
342 int fd = 0;
343 int bass = percent;
344 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) {
345 ioctl( fd, MIXER_WRITE( SOUND_MIXER_BASS ), &bass );
346 ::close( fd );
347 }
348 }
349 break;
350 }
351}
352
353
354static void setTreble( int t = 0, int percent = -1 )
355{
356 switch ( t ) {
357 case 0: {
358 Config cfg( "qpe" );
359 cfg.setGroup( "Volume" );
360 if ( percent < 0 )
361 percent = cfg.readNumEntry( "TreblePercent", 50 );
362
363 int fd = 0;
364 int treble = percent;
365 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) {
366 ioctl( fd, MIXER_WRITE( SOUND_MIXER_TREBLE ), &treble );
367 ::close( fd );
368 }
369 }
370 break;
371 }
372}
373
374
333/*! 375/*!
334 \class QPEApplication qpeapplication.h 376 \class QPEApplication qpeapplication.h
335 \brief The QPEApplication class implements various system services 377 \brief The QPEApplication class implements various system services
336 that are available to all Qtopia applications. 378 that are available to all Qtopia applications.
337 379
338 Simply by using QPEApplication instead of QApplication, a standard Qt 380 Simply by using QPEApplication instead of QApplication, a standard Qt
339 application becomes a Qtopia application. It automatically follows 381 application becomes a Qtopia application. It automatically follows
340 style changes, quits and raises, and in the 382 style changes, quits and raises, and in the
341 case of \link docwidget.html document-oriented\endlink applications, 383 case of \link docwidget.html document-oriented\endlink applications,
342 changes the currently displayed document in response to the environment. 384 changes the currently displayed document in response to the environment.
343 385
344 To create a \link docwidget.html document-oriented\endlink 386 To create a \link docwidget.html document-oriented\endlink
345 application use showMainDocumentWidget(); to create a 387 application use showMainDocumentWidget(); to create a
346 non-document-oriented application use showMainWidget(). The 388 non-document-oriented application use showMainWidget(). The
347 keepRunning() function indicates whether the application will 389 keepRunning() function indicates whether the application will
348 continue running after it's processed the last \link qcop.html 390 continue running after it's processed the last \link qcop.html
349 QCop\endlink message. This can be changed using setKeepRunning(). 391 QCop\endlink message. This can be changed using setKeepRunning().
350 392
351 A variety of signals are emitted when certain events occur, for 393 A variety of signals are emitted when certain events occur, for
352 example, timeChanged(), clockChanged(), weekChanged(), 394 example, timeChanged(), clockChanged(), weekChanged(),
353 dateFormatChanged() and volumeChanged(). If the application receives 395 dateFormatChanged() and volumeChanged(). If the application receives
354 a \link qcop.html QCop\endlink message on the application's 396 a \link qcop.html QCop\endlink message on the application's
355 QPE/Application/\e{appname} channel, the appMessage() signal is 397 QPE/Application/\e{appname} channel, the appMessage() signal is
356 emitted. There are also flush() and reload() signals, which 398 emitted. There are also flush() and reload() signals, which
357 are emitted when synching begins and ends respectively - upon these 399 are emitted when synching begins and ends respectively - upon these
358 signals, the application should save and reload any data 400 signals, the application should save and reload any data
359 files that are involved in synching. Most of these signals will initially 401 files that are involved in synching. Most of these signals will initially
360 be received and unfiltered through the appMessage() signal. 402 be received and unfiltered through the appMessage() signal.
361 403
362 This class also provides a set of useful static functions. The 404 This class also provides a set of useful static functions. The
363 qpeDir() and documentDir() functions return the respective paths. 405 qpeDir() and documentDir() functions return the respective paths.
364 The grabKeyboard() and ungrabKeyboard() functions are used to 406 The grabKeyboard() and ungrabKeyboard() functions are used to
365 control whether the application takes control of the device's 407 control whether the application takes control of the device's
366 physical buttons (e.g. application launch keys). The stylus' mode of 408 physical buttons (e.g. application launch keys). The stylus' mode of
367 operation is set with setStylusOperation() and retrieved with 409 operation is set with setStylusOperation() and retrieved with
368 stylusOperation(). There are also setInputMethodHint() and 410 stylusOperation(). There are also setInputMethodHint() and
369 inputMethodHint() functions. 411 inputMethodHint() functions.
370 412
371 \ingroup qtopiaemb 413 \ingroup qtopiaemb
372*/ 414*/
373 415
374/*! 416/*!
375 \fn void QPEApplication::clientMoused() 417 \fn void QPEApplication::clientMoused()
376 418
377 \internal 419 \internal
378*/ 420*/
379 421
380/*! 422/*!
381 \fn void QPEApplication::timeChanged(); 423 \fn void QPEApplication::timeChanged();
382 This signal is emitted when the time changes outside the normal 424 This signal is emitted when the time changes outside the normal
383 passage of time, i.e. if the time is set backwards or forwards. 425 passage of time, i.e. if the time is set backwards or forwards.
384*/ 426*/
385 427
386/*! 428/*!
387 \fn void QPEApplication::clockChanged( bool ampm ); 429 \fn void QPEApplication::clockChanged( bool ampm );
388 430
389 This signal is emitted when the user changes the clock's style. If 431 This signal is emitted when the user changes the clock's style. If
390 \a ampm is TRUE, the user wants a 12-hour AM/PM clock, otherwise, 432 \a ampm is TRUE, the user wants a 12-hour AM/PM clock, otherwise,
391 they want a 24-hour clock. 433 they want a 24-hour clock.
392*/ 434*/
393 435
394/*! 436/*!
395 \fn void QPEApplication::volumeChanged( bool muted ) 437 \fn void QPEApplication::volumeChanged( bool muted )
396 438
397 This signal is emitted whenever the mute state is changed. If \a 439 This signal is emitted whenever the mute state is changed. If \a
398 muted is TRUE, then sound output has been muted. 440 muted is TRUE, then sound output has been muted.
399*/ 441*/
400 442
401/*! 443/*!
402 \fn void QPEApplication::weekChanged( bool startOnMonday ) 444 \fn void QPEApplication::weekChanged( bool startOnMonday )
403 445
404 This signal is emitted if the week start day is changed. If \a 446 This signal is emitted if the week start day is changed. If \a
405 startOnMonday is TRUE then the first day of the week is Monday; if 447 startOnMonday is TRUE then the first day of the week is Monday; if
406 \a startOnMonday is FALSE then the first day of the week is 448 \a startOnMonday is FALSE then the first day of the week is
407 Sunday. 449 Sunday.
408*/ 450*/
409 451
410/*! 452/*!
411 \fn void QPEApplication::dateFormatChanged() 453 \fn void QPEApplication::dateFormatChanged()
412 454
413 This signal is emitted whenever the date format is changed. 455 This signal is emitted whenever the date format is changed.
414*/ 456*/
415 457
416/*! 458/*!
417 \fn void QPEApplication::flush() 459 \fn void QPEApplication::flush()
418 460
419 ### 461 ###
420*/ 462*/
421 463
422/*! 464/*!
423 \fn void QPEApplication::reload() 465 \fn void QPEApplication::reload()
424 466
425*/ 467*/
426 468
427/*! 469/*!
428 \fn void QPEApplication::appMessage( const QCString& msg, const QByteArray& data ) 470 \fn void QPEApplication::appMessage( const QCString& msg, const QByteArray& data )
429 471
430 This signal is emitted when a message is received on this 472 This signal is emitted when a message is received on this
431 application's QPE/Application/<i>appname</i> \link qcop.html 473 application's QPE/Application/<i>appname</i> \link qcop.html
432 QCop\endlink channel. 474 QCop\endlink channel.
433 475
434 The slot to which you connect this signal uses \a msg and \a data 476 The slot to which you connect this signal uses \a msg and \a data
435 in the following way: 477 in the following way:
436 478
437\code 479\code
438 void MyWidget::receive( const QCString& msg, const QByteArray& data ) 480 void MyWidget::receive( const QCString& msg, const QByteArray& data )
439 { 481 {
440 QDataStream stream( data, IO_ReadOnly ); 482 QDataStream stream( data, IO_ReadOnly );
441 if ( msg == "someMessage(int,int,int)" ) { 483 if ( msg == "someMessage(int,int,int)" ) {
442 int a,b,c; 484 int a,b,c;
443 stream >> a >> b >> c; 485 stream >> a >> b >> c;
444 ... 486 ...
445 } else if ( msg == "otherMessage(QString)" ) { 487 } else if ( msg == "otherMessage(QString)" ) {
446 ... 488 ...
447 } 489 }
448 } 490 }
449\endcode 491\endcode
450 492
451 \sa qcop.html 493 \sa qcop.html
452 Note that messages received here may be processed by qpe application 494 Note that messages received here may be processed by qpe application
453 and emitted as signals, such as flush() and reload(). 495 and emitted as signals, such as flush() and reload().
454*/ 496*/
455 497
456/*! 498/*!
457 Constructs a QPEApplication just as you would construct 499 Constructs a QPEApplication just as you would construct
458 a QApplication, passing \a argc, \a argv, and \a t. 500 a QApplication, passing \a argc, \a argv, and \a t.
459 501
460 For applications, \a t should be the default, GuiClient. Only 502 For applications, \a t should be the default, GuiClient. Only
461 the Qtopia server passes GuiServer. 503 the Qtopia server passes GuiServer.
462*/ 504*/
463QPEApplication::QPEApplication( int & argc, char **argv, Type t ) 505QPEApplication::QPEApplication( int & argc, char **argv, Type t )
464 : QApplication( argc, argv, t ) 506 : QApplication( argc, argv, t )
465{ 507{
466 d = new QPEApplicationData; 508 d = new QPEApplicationData;
467 d->loadTextCodecs(); 509 d->loadTextCodecs();
468 d->loadImageCodecs(); 510 d->loadImageCodecs();
469 int dw = desktop() ->width(); 511 int dw = desktop() ->width();
470 qWarning( "Width %d", dw ); 512 qWarning( "Width %d", dw );
471 if ( dw < 200 ) { 513 if ( dw < 200 ) {
472 setFont( QFont( "helvetica", 8 ) ); 514 setFont( QFont( "helvetica", 8 ) );
473 AppLnk::setSmallIconSize( 10 ); 515 AppLnk::setSmallIconSize( 10 );
474 AppLnk::setBigIconSize( 28 ); 516 AppLnk::setBigIconSize( 28 );
475 } 517 }
476 else if ( dw > 600 ) { 518 else if ( dw > 600 ) {
477 setFont( QFont( "helvetica", 12 ) ); 519 setFont( QFont( "helvetica", 12 ) );
478 AppLnk::setSmallIconSize( 24 ); 520 AppLnk::setSmallIconSize( 24 );
479 AppLnk::setBigIconSize( 48 ); 521 AppLnk::setBigIconSize( 48 );
480 } 522 }
481 else if ( dw > 200 ) { 523 else if ( dw > 200 ) {
482 setFont( QFont( "helvetica", 10 ) ); 524 setFont( QFont( "helvetica", 10 ) );
483 AppLnk::setSmallIconSize( 16 ); 525 AppLnk::setSmallIconSize( 16 );
484 AppLnk::setBigIconSize( 32 ); 526 AppLnk::setBigIconSize( 32 );
485 } 527 }
486 528
487 529
488 QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory ); 530 QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory );
489 531
490 connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) ); 532 connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) );
491#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 533#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
492 534
493 QString qcopfn( "/tmp/qcop-msg-" ); 535 QString qcopfn( "/tmp/qcop-msg-" );
494 qcopfn += QString( argv[ 0 ] ); // append command name 536 qcopfn += QString( argv[ 0 ] ); // append command name
495 537
496 QFile f( qcopfn ); 538 QFile f( qcopfn );
497 if ( f.open( IO_ReadOnly ) ) { 539 if ( f.open( IO_ReadOnly ) ) {
498 flock( f.handle(), LOCK_EX ); 540 flock( f.handle(), LOCK_EX );
499 } 541 }
500 542
501 sysChannel = new QCopChannel( "QPE/System", this ); 543 sysChannel = new QCopChannel( "QPE/System", this );
502 connect( sysChannel, SIGNAL( received( const QCString &, const QByteArray & ) ), 544 connect( sysChannel, SIGNAL( received( const QCString &, const QByteArray & ) ),
503 this, SLOT( systemMessage( const QCString &, const QByteArray & ) ) ); 545 this, SLOT( systemMessage( const QCString &, const QByteArray & ) ) );
504 546
505 QCString channel = QCString( argv[ 0 ] ); 547 QCString channel = QCString( argv[ 0 ] );
506 channel.replace( QRegExp( ".*/" ), "" ); 548 channel.replace( QRegExp( ".*/" ), "" );
507 d->appName = channel; 549 d->appName = channel;
508 channel = "QPE/Application/" + channel; 550 channel = "QPE/Application/" + channel;
509 pidChannel = new QCopChannel( channel, this ); 551 pidChannel = new QCopChannel( channel, this );
510 connect( pidChannel, SIGNAL( received( const QCString &, const QByteArray & ) ), 552 connect( pidChannel, SIGNAL( received( const QCString &, const QByteArray & ) ),
511 this, SLOT( pidMessage( const QCString &, const QByteArray & ) ) ); 553 this, SLOT( pidMessage( const QCString &, const QByteArray & ) ) );
512 554
513 if ( f.isOpen() ) { 555 if ( f.isOpen() ) {
514 d->keep_running = FALSE; 556 d->keep_running = FALSE;
515 QDataStream ds( &f ); 557 QDataStream ds( &f );
516 QCString channel, message; 558 QCString channel, message;
517 QByteArray data; 559 QByteArray data;
518 while ( !ds.atEnd() ) { 560 while ( !ds.atEnd() ) {
519 ds >> channel >> message >> data; 561 ds >> channel >> message >> data;
520 d->enqueueQCop( channel, message, data ); 562 d->enqueueQCop( channel, message, data );
521 } 563 }
522 564
523 flock( f.handle(), LOCK_UN ); 565 flock( f.handle(), LOCK_UN );
524 f.close(); 566 f.close();
525 f.remove(); 567 f.remove();
526 } 568 }
527 569
528 for ( int a = 0; a < argc; a++ ) { 570 for ( int a = 0; a < argc; a++ ) {
529 if ( qstrcmp( argv[ a ], "-preload" ) == 0 ) { 571 if ( qstrcmp( argv[ a ], "-preload" ) == 0 ) {
530 argv[ a ] = argv[ a + 1 ]; 572 argv[ a ] = argv[ a + 1 ];
531 a++; 573 a++;
532 d->preloaded = TRUE; 574 d->preloaded = TRUE;
533 argc -= 1; 575 argc -= 1;
534 } 576 }
535 else if ( qstrcmp( argv[ a ], "-preload-show" ) == 0 ) { 577 else if ( qstrcmp( argv[ a ], "-preload-show" ) == 0 ) {
536 argv[ a ] = argv[ a + 1 ]; 578 argv[ a ] = argv[ a + 1 ];
537 a++; 579 a++;
538 d->preloaded = TRUE; 580 d->preloaded = TRUE;
539 d->forceshow = TRUE; 581 d->forceshow = TRUE;
540 argc -= 1; 582 argc -= 1;
541 } 583 }
542 } 584 }
543 585
544 /* overide stored arguments */ 586 /* overide stored arguments */
545 setArgs( argc, argv ); 587 setArgs( argc, argv );
546 588
547#endif 589#endif
548 590
549 // qwsSetDecoration( new QPEDecoration() ); 591 // qwsSetDecoration( new QPEDecoration() );
550 592
551#ifndef QT_NO_TRANSLATION 593#ifndef QT_NO_TRANSLATION
552 594
553 QStringList langs = Global::languageList(); 595 QStringList langs = Global::languageList();
554 for ( QStringList::ConstIterator it = langs.begin(); it != langs.end(); ++it ) { 596 for ( QStringList::ConstIterator it = langs.begin(); it != langs.end(); ++it ) {
555 QString lang = *it; 597 QString lang = *it;
556 598
557 QTranslator * trans; 599 QTranslator * trans;
558 QString tfn; 600 QString tfn;
559 601
560 trans = new QTranslator( this ); 602 trans = new QTranslator( this );
561 tfn = qpeDir() + "/i18n/" + lang + "/libqpe.qm"; 603 tfn = qpeDir() + "/i18n/" + lang + "/libqpe.qm";
562 if ( trans->load( tfn ) ) 604 if ( trans->load( tfn ) )
563 installTranslator( trans ); 605 installTranslator( trans );
564 else 606 else
565 delete trans; 607 delete trans;
566 608
567 trans = new QTranslator( this ); 609 trans = new QTranslator( this );
568 tfn = qpeDir() + "/i18n/" + lang + "/" + d->appName + ".qm"; 610 tfn = qpeDir() + "/i18n/" + lang + "/" + d->appName + ".qm";
569 if ( trans->load( tfn ) ) 611 if ( trans->load( tfn ) )
570 installTranslator( trans ); 612 installTranslator( trans );
571 else 613 else
572 delete trans; 614 delete trans;
573 615
574 //###language/font hack; should look it up somewhere 616 //###language/font hack; should look it up somewhere
575#ifdef QWS 617#ifdef QWS
576 618
577 if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) { 619 if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) {
578 QFont fn = FontManager::unicodeFont( FontManager::Proportional ); 620 QFont fn = FontManager::unicodeFont( FontManager::Proportional );
579 setFont( fn ); 621 setFont( fn );
580 } 622 }
581#endif 623#endif
582 624
583 } 625 }
584#endif 626#endif
585 627
586 applyStyle(); 628 applyStyle();
587 629
588 if ( type() == GuiServer ) { 630 if ( type() == GuiServer ) {
589 setVolume(); 631 setVolume();
590 } 632 }
591 633
592 installEventFilter( this ); 634 installEventFilter( this );
593 635
594 QPEMenuToolFocusManager::initialize(); 636 QPEMenuToolFocusManager::initialize();
595 637
596#ifdef QT_NO_QWS_CURSOR 638#ifdef QT_NO_QWS_CURSOR
597 // if we have no cursor, probably don't want tooltips 639 // if we have no cursor, probably don't want tooltips
598 QToolTip::setEnabled( FALSE ); 640 QToolTip::setEnabled( FALSE );
599#endif 641#endif
600} 642}
601 643
602static QPtrDict<void>* inputMethodDict = 0; 644static QPtrDict<void>* inputMethodDict = 0;
603static void createInputMethodDict() 645static void createInputMethodDict()
604{ 646{
605 if ( !inputMethodDict ) 647 if ( !inputMethodDict )
606 inputMethodDict = new QPtrDict<void>; 648 inputMethodDict = new QPtrDict<void>;
607} 649}
608 650
609/*! 651/*!
610 Returns the currently set hint to the system as to whether 652 Returns the currently set hint to the system as to whether
611 widget \a w has any use for text input methods. 653 widget \a w has any use for text input methods.
612 654
613 655
614 \sa setInputMethodHint() InputMethodHint 656 \sa setInputMethodHint() InputMethodHint
615*/ 657*/
616QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w ) 658QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w )
617{ 659{
618 if ( inputMethodDict && w ) 660 if ( inputMethodDict && w )
619 return ( InputMethodHint ) ( int ) inputMethodDict->find( w ); 661 return ( InputMethodHint ) ( int ) inputMethodDict->find( w );
620 return Normal; 662 return Normal;
621} 663}
622 664
623/*! 665/*!
624 \enum QPEApplication::InputMethodHint 666 \enum QPEApplication::InputMethodHint
625 667
626 \value Normal the application sometimes needs text input (the default). 668 \value Normal the application sometimes needs text input (the default).
627 \value AlwaysOff the application never needs text input. 669 \value AlwaysOff the application never needs text input.
628 \value AlwaysOn the application always needs text input. 670 \value AlwaysOn the application always needs text input.
629*/ 671*/
630 672
631/*! 673/*!
632 Hints to the system that widget \a w has use for text input methods 674 Hints to the system that widget \a w has use for text input methods
633 as specified by \a mode. 675 as specified by \a mode.
634 676
635 \sa inputMethodHint() InputMethodHint 677 \sa inputMethodHint() InputMethodHint
636*/ 678*/
637void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode ) 679void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode )
638{ 680{
639 createInputMethodDict(); 681 createInputMethodDict();
640 if ( mode == Normal ) { 682 if ( mode == Normal ) {
641 inputMethodDict->remove 683 inputMethodDict->remove
642 ( w ); 684 ( w );
643 } 685 }
644 else { 686 else {
645 inputMethodDict->insert( w, ( void* ) mode ); 687 inputMethodDict->insert( w, ( void* ) mode );
646 } 688 }
647} 689}
648 690
649class HackDialog : public QDialog 691class HackDialog : public QDialog
650{ 692{
651public: 693public:
652 void acceptIt() 694 void acceptIt()
653 { 695 {
654 accept(); 696 accept();
655 } 697 }
656 void rejectIt() 698 void rejectIt()
657 { 699 {
658 reject(); 700 reject();
659 } 701 }
660}; 702};
661 703
662 704
663void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key ) 705void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key )
664{ 706{
665 // specialised actions for certain widgets. May want to 707 // specialised actions for certain widgets. May want to
666 // add more stuff here. 708 // add more stuff here.
667 if ( activePopupWidget() && activePopupWidget() ->inherits( "QListBox" ) 709 if ( activePopupWidget() && activePopupWidget() ->inherits( "QListBox" )
668 && activePopupWidget() ->parentWidget() 710 && activePopupWidget() ->parentWidget()
669 && activePopupWidget() ->parentWidget() ->inherits( "QComboBox" ) ) 711 && activePopupWidget() ->parentWidget() ->inherits( "QComboBox" ) )
670 key = Qt::Key_Return; 712 key = Qt::Key_Return;
671 713
672 if ( activePopupWidget() && activePopupWidget() ->inherits( "QPopupMenu" ) ) 714 if ( activePopupWidget() && activePopupWidget() ->inherits( "QPopupMenu" ) )
673 key = Qt::Key_Return; 715 key = Qt::Key_Return;
674 716
675#ifdef QWS 717#ifdef QWS
676 718
677 ke->simpleData.keycode = key; 719 ke->simpleData.keycode = key;
678#endif 720#endif
679} 721}
680 722
681class HackWidget : public QWidget 723class HackWidget : public QWidget
682{ 724{
683public: 725public:
684 bool needsOk() 726 bool needsOk()
685 { 727 {
686 return ( getWState() & WState_Reserved1 ); 728 return ( getWState() & WState_Reserved1 );
687 } 729 }
688}; 730};
689 731
690/*! 732/*!
691 \internal 733 \internal
692*/ 734*/
693 735
694#ifdef QWS 736#ifdef QWS
695bool QPEApplication::qwsEventFilter( QWSEvent * e ) 737bool QPEApplication::qwsEventFilter( QWSEvent * e )
696{ 738{
697 if ( !d->notbusysent && e->type == QWSEvent::Focus ) { 739 if ( !d->notbusysent && e->type == QWSEvent::Focus ) {
698 if ( qApp->type() != QApplication::GuiServer ) { 740 if ( qApp->type() != QApplication::GuiServer ) {
699 QCopEnvelope e( "QPE/System", "notBusy(QString)" ); 741 QCopEnvelope e( "QPE/System", "notBusy(QString)" );
700 e << d->appName; 742 e << d->appName;
701 } 743 }
702 d->notbusysent = TRUE; 744 d->notbusysent = TRUE;
703 } 745 }
704 if ( type() == GuiServer ) { 746 if ( type() == GuiServer ) {
705 switch ( e->type ) { 747 switch ( e->type ) {
706 case QWSEvent::Mouse: 748 case QWSEvent::Mouse:
707 if ( e->asMouse() ->simpleData.state && !QWidget::find( e->window() ) ) 749 if ( e->asMouse() ->simpleData.state && !QWidget::find( e->window() ) )
708 emit clientMoused(); 750 emit clientMoused();
709 break; 751 break;
710 default: 752 default:
711 break; 753 break;
712 } 754 }
713 } 755 }
714 if ( e->type == QWSEvent::Key ) { 756 if ( e->type == QWSEvent::Key ) {
715 if ( d->kbgrabber == 1 ) 757 if ( d->kbgrabber == 1 )
716 return TRUE; 758 return TRUE;
717 QWSKeyEvent *ke = ( QWSKeyEvent * ) e; 759 QWSKeyEvent *ke = ( QWSKeyEvent * ) e;
718 if ( ke->simpleData.keycode == Qt::Key_F33 ) { 760 if ( ke->simpleData.keycode == Qt::Key_F33 ) {
719 // Use special "OK" key to press "OK" on top level widgets 761 // Use special "OK" key to press "OK" on top level widgets
720 QWidget * active = activeWindow(); 762 QWidget * active = activeWindow();
721 QWidget *popup = 0; 763 QWidget *popup = 0;
722 if ( active && active->isPopup() ) { 764 if ( active && active->isPopup() ) {
723 popup = active; 765 popup = active;
724 active = active->parentWidget(); 766 active = active->parentWidget();
725 } 767 }
726 if ( active && ( int ) active->winId() == ke->simpleData.window && 768 if ( active && ( int ) active->winId() == ke->simpleData.window &&
727 !active->testWFlags( WStyle_Customize | WType_Popup | WType_Desktop ) ) { 769 !active->testWFlags( WStyle_Customize | WType_Popup | WType_Desktop ) ) {
728 if ( ke->simpleData.is_press ) { 770 if ( ke->simpleData.is_press ) {
729 if ( popup ) 771 if ( popup )
730 popup->close(); 772 popup->close();
@@ -815,873 +857,892 @@ bool QPEApplication::qwsEventFilter( QWSEvent * e )
815/*! 857/*!
816 Destroys the QPEApplication. 858 Destroys the QPEApplication.
817*/ 859*/
818QPEApplication::~QPEApplication() 860QPEApplication::~QPEApplication()
819{ 861{
820 ungrabKeyboard(); 862 ungrabKeyboard();
821#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 863#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
822 // Need to delete QCopChannels early, since the display will 864 // Need to delete QCopChannels early, since the display will
823 // be gone by the time we get to ~QObject(). 865 // be gone by the time we get to ~QObject().
824 delete sysChannel; 866 delete sysChannel;
825 delete pidChannel; 867 delete pidChannel;
826#endif 868#endif
827 869
828 delete d; 870 delete d;
829} 871}
830 872
831/*! 873/*!
832 Returns <tt>$OPIEDIR/</tt>. 874 Returns <tt>$OPIEDIR/</tt>.
833*/ 875*/
834QString QPEApplication::qpeDir() 876QString QPEApplication::qpeDir()
835{ 877{
836 const char * base = getenv( "OPIEDIR" ); 878 const char * base = getenv( "OPIEDIR" );
837 if ( base ) 879 if ( base )
838 return QString( base ) + "/"; 880 return QString( base ) + "/";
839 881
840 return QString( "../" ); 882 return QString( "../" );
841} 883}
842 884
843/*! 885/*!
844 Returns the user's current Document directory. There is a trailing "/". 886 Returns the user's current Document directory. There is a trailing "/".
845 .. well, it does now,, and there's no trailing '/' 887 .. well, it does now,, and there's no trailing '/'
846*/ 888*/
847QString QPEApplication::documentDir() 889QString QPEApplication::documentDir()
848{ 890{
849 const char* base = getenv( "HOME"); 891 const char* base = getenv( "HOME");
850 if ( base ) 892 if ( base )
851 return QString( base ) + "/Documents"; 893 return QString( base ) + "/Documents";
852 894
853 return QString( "../Documents" ); 895 return QString( "../Documents" );
854} 896}
855 897
856static int deforient = -1; 898static int deforient = -1;
857 899
858/*! 900/*!
859 \internal 901 \internal
860*/ 902*/
861int QPEApplication::defaultRotation() 903int QPEApplication::defaultRotation()
862{ 904{
863 if ( deforient < 0 ) { 905 if ( deforient < 0 ) {
864 QString d = getenv( "QWS_DISPLAY" ); 906 QString d = getenv( "QWS_DISPLAY" );
865 if ( d.contains( "Rot90" ) ) { 907 if ( d.contains( "Rot90" ) ) {
866 deforient = 90; 908 deforient = 90;
867 } 909 }
868 else if ( d.contains( "Rot180" ) ) { 910 else if ( d.contains( "Rot180" ) ) {
869 deforient = 180; 911 deforient = 180;
870 } 912 }
871 else if ( d.contains( "Rot270" ) ) { 913 else if ( d.contains( "Rot270" ) ) {
872 deforient = 270; 914 deforient = 270;
873 } 915 }
874 else { 916 else {
875 deforient = 0; 917 deforient = 0;
876 } 918 }
877 } 919 }
878 return deforient; 920 return deforient;
879} 921}
880 922
881/*! 923/*!
882 \internal 924 \internal
883*/ 925*/
884void QPEApplication::setDefaultRotation( int r ) 926void QPEApplication::setDefaultRotation( int r )
885{ 927{
886 if ( qApp->type() == GuiServer ) { 928 if ( qApp->type() == GuiServer ) {
887 deforient = r; 929 deforient = r;
888 setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 ); 930 setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 );
889 Config config("qpe"); 931 Config config("qpe");
890 config.setGroup( "Rotation" ); 932 config.setGroup( "Rotation" );
891 config.writeEntry( "Screen", getenv("QWS_DISPLAY") ); 933 config.writeEntry( "Screen", getenv("QWS_DISPLAY") );
892 } 934 }
893 else { 935 else {
894#ifndef QT_NO_COP 936#ifndef QT_NO_COP
895 { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" ); 937 { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" );
896 e << r; 938 e << r;
897 } 939 }
898#endif 940#endif
899 941
900 } 942 }
901} 943}
902 944
903 945
904/*! 946/*!
905 \internal 947 \internal
906*/ 948*/
907void QPEApplication::applyStyle() 949void QPEApplication::applyStyle()
908{ 950{
909 Config config( "qpe" ); 951 Config config( "qpe" );
910 config.setGroup( "Appearance" ); 952 config.setGroup( "Appearance" );
911 953
912 // don't block ourselves ... 954 // don't block ourselves ...
913 Opie::force_appearance = 0; 955 Opie::force_appearance = 0;
914 956
915 static QString appname = Opie::binaryName ( ); 957 static QString appname = Opie::binaryName ( );
916 958
917 QStringList ex = config. readListEntry ( "NoStyle", ';' ); 959 QStringList ex = config. readListEntry ( "NoStyle", ';' );
918 int nostyle = 0; 960 int nostyle = 0;
919 for ( QStringList::Iterator it = ex. begin ( ); it != ex. end ( ); ++it ) { 961 for ( QStringList::Iterator it = ex. begin ( ); it != ex. end ( ); ++it ) {
920 if ( QRegExp (( *it ). mid ( 1 ), false, true ). find ( appname, 0 ) >= 0 ) { 962 if ( QRegExp (( *it ). mid ( 1 ), false, true ). find ( appname, 0 ) >= 0 ) {
921 nostyle = ( *it ). left ( 1 ). toInt ( 0, 32 ); 963 nostyle = ( *it ). left ( 1 ). toInt ( 0, 32 );
922 break; 964 break;
923 } 965 }
924 } 966 }
925 967
926 // Widget style 968 // Widget style
927 QString style = config.readEntry( "Style", "Light" ); 969 QString style = config.readEntry( "Style", "Light" );
928 970
929 // don't set a custom style 971 // don't set a custom style
930 if ( nostyle & Opie::Force_Style ) 972 if ( nostyle & Opie::Force_Style )
931 style = "Light"; 973 style = "Light";
932 974
933 internalSetStyle ( style ); 975 internalSetStyle ( style );
934 976
935 // Colors 977 // Colors
936 QColor bgcolor( config.readEntry( "Background", "#E5E1D5" ) ); 978 QColor bgcolor( config.readEntry( "Background", "#E5E1D5" ) );
937 QColor btncolor( config.readEntry( "Button", "#D6CDBB" ) ); 979 QColor btncolor( config.readEntry( "Button", "#D6CDBB" ) );
938 QPalette pal( btncolor, bgcolor ); 980 QPalette pal( btncolor, bgcolor );
939 QString color = config.readEntry( "Highlight", "#800000" ); 981 QString color = config.readEntry( "Highlight", "#800000" );
940 pal.setColor( QColorGroup::Highlight, QColor( color ) ); 982 pal.setColor( QColorGroup::Highlight, QColor( color ) );
941 color = config.readEntry( "HighlightedText", "#FFFFFF" ); 983 color = config.readEntry( "HighlightedText", "#FFFFFF" );
942 pal.setColor( QColorGroup::HighlightedText, QColor( color ) ); 984 pal.setColor( QColorGroup::HighlightedText, QColor( color ) );
943 color = config.readEntry( "Text", "#000000" ); 985 color = config.readEntry( "Text", "#000000" );
944 pal.setColor( QColorGroup::Text, QColor( color ) ); 986 pal.setColor( QColorGroup::Text, QColor( color ) );
945 color = config.readEntry( "ButtonText", "#000000" ); 987 color = config.readEntry( "ButtonText", "#000000" );
946 pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) ); 988 pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) );
947 color = config.readEntry( "Base", "#FFFFFF" ); 989 color = config.readEntry( "Base", "#FFFFFF" );
948 pal.setColor( QColorGroup::Base, QColor( color ) ); 990 pal.setColor( QColorGroup::Base, QColor( color ) );
949 991
950 pal.setColor( QPalette::Disabled, QColorGroup::Text, 992 pal.setColor( QPalette::Disabled, QColorGroup::Text,
951 pal.color( QPalette::Active, QColorGroup::Background ).dark() ); 993 pal.color( QPalette::Active, QColorGroup::Background ).dark() );
952 994
953 setPalette( pal, TRUE ); 995 setPalette( pal, TRUE );
954 996
955 // Window Decoration 997 // Window Decoration
956 QString dec = config.readEntry( "Decoration", "Qtopia" ); 998 QString dec = config.readEntry( "Decoration", "Qtopia" );
957 999
958 // don't set a custom deco 1000 // don't set a custom deco
959 if ( nostyle & Opie::Force_Decoration ) 1001 if ( nostyle & Opie::Force_Decoration )
960 dec = ""; 1002 dec = "";
961 1003
962 //qDebug ( "Setting Deco: %s -- old %s (%d)", dec.latin1(), d-> decorationName.latin1(), nostyle); 1004 //qDebug ( "Setting Deco: %s -- old %s (%d)", dec.latin1(), d-> decorationName.latin1(), nostyle);
963 1005
964 if ( dec != d->decorationName ) { 1006 if ( dec != d->decorationName ) {
965 qwsSetDecoration( new QPEDecoration( dec ) ); 1007 qwsSetDecoration( new QPEDecoration( dec ) );
966 d->decorationName = dec; 1008 d->decorationName = dec;
967 } 1009 }
968 1010
969 // Font 1011 // Font
970 QString ff = config.readEntry( "FontFamily", font().family() ); 1012 QString ff = config.readEntry( "FontFamily", font().family() );
971 int fs = config.readNumEntry( "FontSize", font().pointSize() ); 1013 int fs = config.readNumEntry( "FontSize", font().pointSize() );
972 1014
973 // don't set a custom font 1015 // don't set a custom font
974 if ( nostyle & Opie::Force_Font ) { 1016 if ( nostyle & Opie::Force_Font ) {
975 ff = "Helvetica"; 1017 ff = "Helvetica";
976 fs = 10; 1018 fs = 10;
977 } 1019 }
978 1020
979 setFont ( QFont ( ff, fs ), true ); 1021 setFont ( QFont ( ff, fs ), true );
980 1022
981 // revert to global blocking policy ... 1023 // revert to global blocking policy ...
982 Opie::force_appearance = config. readBoolEntry ( "ForceStyle", false ) ? Opie::Force_All : Opie::Force_None; 1024 Opie::force_appearance = config. readBoolEntry ( "ForceStyle", false ) ? Opie::Force_All : Opie::Force_None;
983 Opie::force_appearance &= ~nostyle; 1025 Opie::force_appearance &= ~nostyle;
984} 1026}
985 1027
986void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data ) 1028void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data )
987{ 1029{
988#ifdef Q_WS_QWS 1030#ifdef Q_WS_QWS
989 QDataStream stream( data, IO_ReadOnly ); 1031 QDataStream stream( data, IO_ReadOnly );
990 if ( msg == "applyStyle()" ) { 1032 if ( msg == "applyStyle()" ) {
991 applyStyle(); 1033 applyStyle();
992 } 1034 }
993 else if ( msg == "setDefaultRotation(int)" ) { 1035 else if ( msg == "setDefaultRotation(int)" ) {
994 if ( type() == GuiServer ) { 1036 if ( type() == GuiServer ) {
995 int r; 1037 int r;
996 stream >> r; 1038 stream >> r;
997 setDefaultRotation( r ); 1039 setDefaultRotation( r );
998 } 1040 }
999 } 1041 }
1000 else if ( msg == "shutdown()" ) { 1042 else if ( msg == "shutdown()" ) {
1001 if ( type() == GuiServer ) 1043 if ( type() == GuiServer )
1002 shutdown(); 1044 shutdown();
1003 } 1045 }
1004 else if ( msg == "quit()" ) { 1046 else if ( msg == "quit()" ) {
1005 if ( type() != GuiServer ) 1047 if ( type() != GuiServer )
1006 tryQuit(); 1048 tryQuit();
1007 } 1049 }
1008 else if ( msg == "forceQuit()" ) { 1050 else if ( msg == "forceQuit()" ) {
1009 if ( type() != GuiServer ) 1051 if ( type() != GuiServer )
1010 quit(); 1052 quit();
1011 } 1053 }
1012 else if ( msg == "restart()" ) { 1054 else if ( msg == "restart()" ) {
1013 if ( type() == GuiServer ) 1055 if ( type() == GuiServer )
1014 restart(); 1056 restart();
1015 } 1057 }
1016 else if ( msg == "grabKeyboard(QString)" ) { 1058 else if ( msg == "grabKeyboard(QString)" ) {
1017 QString who; 1059 QString who;
1018 stream >> who; 1060 stream >> who;
1019 if ( who.isEmpty() ) 1061 if ( who.isEmpty() )
1020 d->kbgrabber = 0; 1062 d->kbgrabber = 0;
1021 else if ( who != d->appName ) 1063 else if ( who != d->appName )
1022 d->kbgrabber = 1; 1064 d->kbgrabber = 1;
1023 else 1065 else
1024 d->kbgrabber = 2; 1066 d->kbgrabber = 2;
1025 } 1067 }
1026 else if ( msg == "language(QString)" ) { 1068 else if ( msg == "language(QString)" ) {
1027 if ( type() == GuiServer ) { 1069 if ( type() == GuiServer ) {
1028 QString l; 1070 QString l;
1029 stream >> l; 1071 stream >> l;
1030 QString cl = getenv( "LANG" ); 1072 QString cl = getenv( "LANG" );
1031 if ( cl != l ) { 1073 if ( cl != l ) {
1032 if ( l.isNull() ) 1074 if ( l.isNull() )
1033 unsetenv( "LANG" ); 1075 unsetenv( "LANG" );
1034 else 1076 else
1035 setenv( "LANG", l.latin1(), 1 ); 1077 setenv( "LANG", l.latin1(), 1 );
1036 restart(); 1078 restart();
1037 } 1079 }
1038 } 1080 }
1039 } 1081 }
1040 else if ( msg == "timeChange(QString)" ) { 1082 else if ( msg == "timeChange(QString)" ) {
1041 QString t; 1083 QString t;
1042 stream >> t; 1084 stream >> t;
1043 if ( t.isNull() ) 1085 if ( t.isNull() )
1044 unsetenv( "TZ" ); 1086 unsetenv( "TZ" );
1045 else 1087 else
1046 setenv( "TZ", t.latin1(), 1 ); 1088 setenv( "TZ", t.latin1(), 1 );
1047 // emit the signal so everyone else knows... 1089 // emit the signal so everyone else knows...
1048 emit timeChanged(); 1090 emit timeChanged();
1049 } 1091 }
1050 else if ( msg == "execute(QString)" ) { 1092 else if ( msg == "execute(QString)" ) {
1051 if ( type() == GuiServer ) { 1093 if ( type() == GuiServer ) {
1052 QString t; 1094 QString t;
1053 stream >> t; 1095 stream >> t;
1054 Global::execute( t ); 1096 Global::execute( t );
1055 } 1097 }
1056 } 1098 }
1057 else if ( msg == "execute(QString,QString)" ) { 1099 else if ( msg == "execute(QString,QString)" ) {
1058 if ( type() == GuiServer ) { 1100 if ( type() == GuiServer ) {
1059 QString t, d; 1101 QString t, d;
1060 stream >> t >> d; 1102 stream >> t >> d;
1061 Global::execute( t, d ); 1103 Global::execute( t, d );
1062 } 1104 }
1063 } 1105 }
1064 else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) { 1106 else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) {
1065 if ( type() == GuiServer ) { 1107 if ( type() == GuiServer ) {
1066 QDateTime when; 1108 QDateTime when;
1067 QCString channel, message; 1109 QCString channel, message;
1068 int data; 1110 int data;
1069 stream >> when >> channel >> message >> data; 1111 stream >> when >> channel >> message >> data;
1070 AlarmServer::addAlarm( when, channel, message, data ); 1112 AlarmServer::addAlarm( when, channel, message, data );
1071 } 1113 }
1072 } 1114 }
1073 else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) { 1115 else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) {
1074 if ( type() == GuiServer ) { 1116 if ( type() == GuiServer ) {
1075 QDateTime when; 1117 QDateTime when;
1076 QCString channel, message; 1118 QCString channel, message;
1077 int data; 1119 int data;
1078 stream >> when >> channel >> message >> data; 1120 stream >> when >> channel >> message >> data;
1079 AlarmServer::deleteAlarm( when, channel, message, data ); 1121 AlarmServer::deleteAlarm( when, channel, message, data );
1080 } 1122 }
1081 } 1123 }
1082 else if ( msg == "clockChange(bool)" ) { 1124 else if ( msg == "clockChange(bool)" ) {
1083 int tmp; 1125 int tmp;
1084 stream >> tmp; 1126 stream >> tmp;
1085 emit clockChanged( tmp ); 1127 emit clockChanged( tmp );
1086 } 1128 }
1087 else if ( msg == "weekChange(bool)" ) { 1129 else if ( msg == "weekChange(bool)" ) {
1088 int tmp; 1130 int tmp;
1089 stream >> tmp; 1131 stream >> tmp;
1090 emit weekChanged( tmp ); 1132 emit weekChanged( tmp );
1091 } 1133 }
1092 else if ( msg == "setDateFormat(DateFormat)" ) { 1134 else if ( msg == "setDateFormat(DateFormat)" ) {
1093 DateFormat tmp; 1135 DateFormat tmp;
1094 stream >> tmp; 1136 stream >> tmp;
1095 emit dateFormatChanged( tmp ); 1137 emit dateFormatChanged( tmp );
1096 } 1138 }
1097 else if ( msg == "setVolume(int,int)" ) { 1139 else if ( msg == "setVolume(int,int)" ) {
1098 int t, v; 1140 int t, v;
1099 stream >> t >> v; 1141 stream >> t >> v;
1100 setVolume( t, v ); 1142 setVolume( t, v );
1101 emit volumeChanged( muted ); 1143 emit volumeChanged( muted );
1102 } 1144 }
1103 else if ( msg == "volumeChange(bool)" ) { 1145 else if ( msg == "volumeChange(bool)" ) {
1104 stream >> muted; 1146 stream >> muted;
1105 setVolume(); 1147 setVolume();
1106 emit volumeChanged( muted ); 1148 emit volumeChanged( muted );
1107 } 1149 }
1108 else if ( msg == "setMic(int,int)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> 1150 else if ( msg == "setMic(int,int)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com>
1109 int t, v; 1151 int t, v;
1110 stream >> t >> v; 1152 stream >> t >> v;
1111 setMic( t, v ); 1153 setMic( t, v );
1112 emit micChanged( micMuted ); 1154 emit micChanged( micMuted );
1113 } 1155 }
1114 else if ( msg == "micChange(bool)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> 1156 else if ( msg == "micChange(bool)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com>
1115 stream >> micMuted; 1157 stream >> micMuted;
1116 setMic(); 1158 setMic();
1117 emit micChanged( micMuted ); 1159 emit micChanged( micMuted );
1118 } 1160 }
1161 else if ( msg == "setBass(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org>
1162 int t, v;
1163 stream >> t >> v;
1164 setBass( t, v );
1165 }
1166 else if ( msg == "bassChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org>
1167 setBass();
1168 }
1169 else if ( msg == "setTreble(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org>
1170 int t, v;
1171 stream >> t >> v;
1172 setTreble( t, v );
1173 }
1174 else if ( msg == "trebleChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org>
1175 setTreble();
1176 }
1177
1178
1179
1119#endif 1180#endif
1120} 1181}
1121 1182
1122/*! 1183/*!
1123 \internal 1184 \internal
1124*/ 1185*/
1125bool QPEApplication::raiseAppropriateWindow() 1186bool QPEApplication::raiseAppropriateWindow()
1126{ 1187{
1127 bool r = FALSE; 1188 bool r = FALSE;
1128 // ########## raise()ing main window should raise and set active 1189 // ########## raise()ing main window should raise and set active
1129 // ########## it and then all childen. This belongs in Qt/Embedded 1190 // ########## it and then all childen. This belongs in Qt/Embedded
1130 QWidget *top = d->qpe_main_widget; 1191 QWidget *top = d->qpe_main_widget;
1131 if ( !top ) 1192 if ( !top )
1132 top = mainWidget(); 1193 top = mainWidget();
1133 if ( top && d->keep_running ) { 1194 if ( top && d->keep_running ) {
1134 if ( top->isVisible() ) 1195 if ( top->isVisible() )
1135 r = TRUE; 1196 r = TRUE;
1136 else if (d->preloaded) { 1197 else if (d->preloaded) {
1137 // We are preloaded and not visible.. pretend we just started.. 1198 // We are preloaded and not visible.. pretend we just started..
1138 QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); 1199 QCopEnvelope e("QPE/System", "fastAppShowing(QString)");
1139 e << d->appName; 1200 e << d->appName;
1140 } 1201 }
1141 1202
1142 d->show_mx(top, d->nomaximize); 1203 d->show_mx(top, d->nomaximize);
1143 top->raise(); 1204 top->raise();
1144 top->setActiveWindow(); 1205 top->setActiveWindow();
1145 } 1206 }
1146 QWidget *topm = activeModalWidget(); 1207 QWidget *topm = activeModalWidget();
1147 if ( topm && topm != top ) { 1208 if ( topm && topm != top ) {
1148 topm->show(); 1209 topm->show();
1149 topm->raise(); 1210 topm->raise();
1150 topm->setActiveWindow(); 1211 topm->setActiveWindow();
1151 // If we haven't already handled the fastAppShowing message 1212 // If we haven't already handled the fastAppShowing message
1152 if (!top && d->preloaded) { 1213 if (!top && d->preloaded) {
1153 QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); 1214 QCopEnvelope e("QPE/System", "fastAppShowing(QString)");
1154 e << d->appName; 1215 e << d->appName;
1155 } 1216 }
1156 r = FALSE; 1217 r = FALSE;
1157 } 1218 }
1158 return r; 1219 return r;
1159} 1220}
1160 1221
1161void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data) 1222void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data)
1162{ 1223{
1163#ifdef Q_WS_QWS 1224#ifdef Q_WS_QWS
1164 1225
1165 if ( msg == "quit()" ) { 1226 if ( msg == "quit()" ) {
1166 tryQuit(); 1227 tryQuit();
1167 } 1228 }
1168 else if ( msg == "quitIfInvisible()" ) { 1229 else if ( msg == "quitIfInvisible()" ) {
1169 if ( d->qpe_main_widget && !d->qpe_main_widget->isVisible() ) 1230 if ( d->qpe_main_widget && !d->qpe_main_widget->isVisible() )
1170 quit(); 1231 quit();
1171 } 1232 }
1172 else if ( msg == "close()" ) { 1233 else if ( msg == "close()" ) {
1173 hideOrQuit(); 1234 hideOrQuit();
1174 } 1235 }
1175 else if ( msg == "disablePreload()" ) { 1236 else if ( msg == "disablePreload()" ) {
1176 d->preloaded = FALSE; 1237 d->preloaded = FALSE;
1177 d->keep_running = TRUE; 1238 d->keep_running = TRUE;
1178 /* so that quit will quit */ 1239 /* so that quit will quit */
1179 } 1240 }
1180 else if ( msg == "enablePreload()" ) { 1241 else if ( msg == "enablePreload()" ) {
1181 if (d->qpe_main_widget) 1242 if (d->qpe_main_widget)
1182 d->preloaded = TRUE; 1243 d->preloaded = TRUE;
1183 d->keep_running = TRUE; 1244 d->keep_running = TRUE;
1184 /* so next quit won't quit */ 1245 /* so next quit won't quit */
1185 } 1246 }
1186 else if ( msg == "raise()" ) { 1247 else if ( msg == "raise()" ) {
1187 d->keep_running = TRUE; 1248 d->keep_running = TRUE;
1188 d->notbusysent = FALSE; 1249 d->notbusysent = FALSE;
1189 raiseAppropriateWindow(); 1250 raiseAppropriateWindow();
1190 // Tell the system we're still chugging along... 1251 // Tell the system we're still chugging along...
1191 QCopEnvelope e("QPE/System", "appRaised(QString)"); 1252 QCopEnvelope e("QPE/System", "appRaised(QString)");
1192 e << d->appName; 1253 e << d->appName;
1193 } 1254 }
1194 else if ( msg == "flush()" ) { 1255 else if ( msg == "flush()" ) {
1195 emit flush(); 1256 emit flush();
1196 // we need to tell the desktop 1257 // we need to tell the desktop
1197 QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" ); 1258 QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" );
1198 e << d->appName; 1259 e << d->appName;
1199 } 1260 }
1200 else if ( msg == "reload()" ) { 1261 else if ( msg == "reload()" ) {
1201 emit reload(); 1262 emit reload();
1202 } 1263 }
1203 else if ( msg == "setDocument(QString)" ) { 1264 else if ( msg == "setDocument(QString)" ) {
1204 d->keep_running = TRUE; 1265 d->keep_running = TRUE;
1205 QDataStream stream( data, IO_ReadOnly ); 1266 QDataStream stream( data, IO_ReadOnly );
1206 QString doc; 1267 QString doc;
1207 stream >> doc; 1268 stream >> doc;
1208 QWidget *mw = mainWidget(); 1269 QWidget *mw = mainWidget();
1209 if ( !mw ) 1270 if ( !mw )
1210 mw = d->qpe_main_widget; 1271 mw = d->qpe_main_widget;
1211 if ( mw ) 1272 if ( mw )
1212 Global::setDocument( mw, doc ); 1273 Global::setDocument( mw, doc );
1213 } 1274 }
1214 else if ( msg == "nextView()" ) { 1275 else if ( msg == "nextView()" ) {
1215 qDebug("got nextView()"); 1276 qDebug("got nextView()");
1216 /* 1277 /*
1217 if ( raiseAppropriateWindow() ) 1278 if ( raiseAppropriateWindow() )
1218 */ 1279 */
1219 emit appMessage( msg, data); 1280 emit appMessage( msg, data);
1220 } 1281 }
1221 else { 1282 else {
1222 emit appMessage( msg, data); 1283 emit appMessage( msg, data);
1223 } 1284 }
1224 1285
1225#endif 1286#endif
1226} 1287}
1227 1288
1228 1289
1229/*! 1290/*!
1230 Sets widget \a mw as the mainWidget() and shows it. For small windows, 1291 Sets widget \a mw as the mainWidget() and shows it. For small windows,
1231 consider passing TRUE for \a nomaximize rather than the default FALSE. 1292 consider passing TRUE for \a nomaximize rather than the default FALSE.
1232 1293
1233 \sa showMainDocumentWidget() 1294 \sa showMainDocumentWidget()
1234*/ 1295*/
1235void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize ) 1296void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize )
1236{ 1297{
1237 d->show(mw, nomaximize ); 1298 d->show(mw, nomaximize );
1238} 1299}
1239 1300
1240/*! 1301/*!
1241 Sets widget \a mw as the mainWidget() and shows it. For small windows, 1302 Sets widget \a mw as the mainWidget() and shows it. For small windows,
1242 consider passing TRUE for \a nomaximize rather than the default FALSE. 1303 consider passing TRUE for \a nomaximize rather than the default FALSE.
1243 1304
1244 This calls designates the application as 1305 This calls designates the application as
1245 a \link docwidget.html document-oriented\endlink application. 1306 a \link docwidget.html document-oriented\endlink application.
1246 1307
1247 The \a mw widget \e must have this slot: setDocument(const QString&). 1308 The \a mw widget \e must have this slot: setDocument(const QString&).
1248 1309
1249 \sa showMainWidget() 1310 \sa showMainWidget()
1250*/ 1311*/
1251void QPEApplication::showMainDocumentWidget( QWidget* mw, bool nomaximize ) 1312void QPEApplication::showMainDocumentWidget( QWidget* mw, bool nomaximize )
1252{ 1313{
1253 if ( mw && argc() == 2 ) 1314 if ( mw && argc() == 2 )
1254 Global::setDocument( mw, QString::fromUtf8(argv()[1]) ); 1315 Global::setDocument( mw, QString::fromUtf8(argv()[1]) );
1255 1316
1256 d->show(mw, nomaximize ); 1317 d->show(mw, nomaximize );
1257} 1318}
1258 1319
1259 1320
1260/*! 1321/*!
1261 If an application is started via a \link qcop.html QCop\endlink 1322 If an application is started via a \link qcop.html QCop\endlink
1262 message, the application will process the \link qcop.html 1323 message, the application will process the \link qcop.html
1263 QCop\endlink message and then quit. If the application calls this 1324 QCop\endlink message and then quit. If the application calls this
1264 function while processing a \link qcop.html QCop\endlink message, 1325 function while processing a \link qcop.html QCop\endlink message,
1265 after processing its outstanding \link qcop.html QCop\endlink 1326 after processing its outstanding \link qcop.html QCop\endlink
1266 messages the application will start 'properly' and show itself. 1327 messages the application will start 'properly' and show itself.
1267 1328
1268 \sa keepRunning() 1329 \sa keepRunning()
1269*/ 1330*/
1270void QPEApplication::setKeepRunning() 1331void QPEApplication::setKeepRunning()
1271{ 1332{
1272 if ( qApp && qApp->inherits( "QPEApplication" ) ) { 1333 if ( qApp && qApp->inherits( "QPEApplication" ) ) {
1273 QPEApplication * qpeApp = ( QPEApplication* ) qApp; 1334 QPEApplication * qpeApp = ( QPEApplication* ) qApp;
1274 qpeApp->d->keep_running = TRUE; 1335 qpeApp->d->keep_running = TRUE;
1275 } 1336 }
1276} 1337}
1277 1338
1278/*! 1339/*!
1279 Returns TRUE if the application will quit after processing the 1340 Returns TRUE if the application will quit after processing the
1280 current list of qcop messages; otherwise returns FALSE. 1341 current list of qcop messages; otherwise returns FALSE.
1281 1342
1282 \sa setKeepRunning() 1343 \sa setKeepRunning()
1283*/ 1344*/
1284bool QPEApplication::keepRunning() const 1345bool QPEApplication::keepRunning() const
1285{ 1346{
1286 return d->keep_running; 1347 return d->keep_running;
1287} 1348}
1288 1349
1289/*! 1350/*!
1290 \internal 1351 \internal
1291*/ 1352*/
1292void QPEApplication::internalSetStyle( const QString &style ) 1353void QPEApplication::internalSetStyle( const QString &style )
1293{ 1354{
1294#if QT_VERSION >= 300 1355#if QT_VERSION >= 300
1295 if ( style == "QPE" ) { 1356 if ( style == "QPE" ) {
1296 setStyle( new QPEStyle ); 1357 setStyle( new QPEStyle );
1297 } 1358 }
1298 else { 1359 else {
1299 QStyle *s = QStyleFactory::create( style ); 1360 QStyle *s = QStyleFactory::create( style );
1300 if ( s ) 1361 if ( s )
1301 setStyle( s ); 1362 setStyle( s );
1302 } 1363 }
1303#else 1364#else
1304 if ( style == "Windows" ) { 1365 if ( style == "Windows" ) {
1305 setStyle( new QWindowsStyle ); 1366 setStyle( new QWindowsStyle );
1306 } 1367 }
1307 else if ( style == "QPE" ) { 1368 else if ( style == "QPE" ) {
1308 setStyle( new QPEStyle ); 1369 setStyle( new QPEStyle );
1309 } 1370 }
1310 else if ( style == "Light" ) { 1371 else if ( style == "Light" ) {
1311 setStyle( new LightStyle ); 1372 setStyle( new LightStyle );
1312 } 1373 }
1313#ifndef QT_NO_STYLE_PLATINUM 1374#ifndef QT_NO_STYLE_PLATINUM
1314 else if ( style == "Platinum" ) { 1375 else if ( style == "Platinum" ) {
1315 setStyle( new QPlatinumStyle ); 1376 setStyle( new QPlatinumStyle );
1316 } 1377 }
1317#endif 1378#endif
1318#ifndef QT_NO_STYLE_MOTIF 1379#ifndef QT_NO_STYLE_MOTIF
1319 else if ( style == "Motif" ) { 1380 else if ( style == "Motif" ) {
1320 setStyle( new QMotifStyle ); 1381 setStyle( new QMotifStyle );
1321 } 1382 }
1322#endif 1383#endif
1323#ifndef QT_NO_STYLE_MOTIFPLUS 1384#ifndef QT_NO_STYLE_MOTIFPLUS
1324 else if ( style == "MotifPlus" ) { 1385 else if ( style == "MotifPlus" ) {
1325 setStyle( new QMotifPlusStyle ); 1386 setStyle( new QMotifPlusStyle );
1326 } 1387 }
1327#endif 1388#endif
1328 1389
1329 else { 1390 else {
1330 QStyle *sty = 0; 1391 QStyle *sty = 0;
1331 QString path = QPEApplication::qpeDir ( ) + "/plugins/styles/"; 1392 QString path = QPEApplication::qpeDir ( ) + "/plugins/styles/";
1332 1393
1333 if ( style. find ( ".so" ) > 0 ) 1394 if ( style. find ( ".so" ) > 0 )
1334 path += style; 1395 path += style;
1335 else 1396 else
1336 path = path + "lib" + style. lower ( ) + ".so"; // compatibility 1397 path = path + "lib" + style. lower ( ) + ".so"; // compatibility
1337 1398
1338 static QLibrary *lastlib = 0; 1399 static QLibrary *lastlib = 0;
1339 static StyleInterface *lastiface = 0; 1400 static StyleInterface *lastiface = 0;
1340 1401
1341 QLibrary *lib = new QLibrary ( path ); 1402 QLibrary *lib = new QLibrary ( path );
1342 StyleInterface *iface = 0; 1403 StyleInterface *iface = 0;
1343 1404
1344 if (( lib-> queryInterface ( IID_Style, ( QUnknownInterface ** ) &iface ) == QS_OK ) && iface ) 1405 if (( lib-> queryInterface ( IID_Style, ( QUnknownInterface ** ) &iface ) == QS_OK ) && iface )
1345 sty = iface-> style ( ); 1406 sty = iface-> style ( );
1346 1407
1347 if ( sty ) { 1408 if ( sty ) {
1348 setStyle ( sty ); 1409 setStyle ( sty );
1349 1410
1350 if ( lastiface ) 1411 if ( lastiface )
1351 lastiface-> release ( ); 1412 lastiface-> release ( );
1352 lastiface = iface; 1413 lastiface = iface;
1353 1414
1354 if ( lastlib ) { 1415 if ( lastlib ) {
1355 lastlib-> unload ( ); 1416 lastlib-> unload ( );
1356 delete lastlib; 1417 delete lastlib;
1357 } 1418 }
1358 lastlib = lib; 1419 lastlib = lib;
1359 } 1420 }
1360 else { 1421 else {
1361 if ( iface ) 1422 if ( iface )
1362 iface-> release ( ); 1423 iface-> release ( );
1363 delete lib; 1424 delete lib;
1364 1425
1365 setStyle ( new LightStyle ( )); 1426 setStyle ( new LightStyle ( ));
1366 } 1427 }
1367 } 1428 }
1368#endif 1429#endif
1369} 1430}
1370 1431
1371/*! 1432/*!
1372 \internal 1433 \internal
1373*/ 1434*/
1374void QPEApplication::prepareForTermination( bool willrestart ) 1435void QPEApplication::prepareForTermination( bool willrestart )
1375{ 1436{
1376 if ( willrestart ) { 1437 if ( willrestart ) {
1377 // Draw a big wait icon, the image can be altered in later revisions 1438 // Draw a big wait icon, the image can be altered in later revisions
1378 // QWidget *d = QApplication::desktop(); 1439 // QWidget *d = QApplication::desktop();
1379 QImage img = Resource::loadImage( "launcher/new_wait" ); 1440 QImage img = Resource::loadImage( "launcher/new_wait" );
1380 QPixmap pix; 1441 QPixmap pix;
1381 pix.convertFromImage( img.smoothScale( 1 * img.width(), 1 * img.height() ) ); 1442 pix.convertFromImage( img.smoothScale( 1 * img.width(), 1 * img.height() ) );
1382 QLabel *lblWait = new QLabel( 0, "wait hack!", QWidget::WStyle_Customize | 1443 QLabel *lblWait = new QLabel( 0, "wait hack!", QWidget::WStyle_Customize |
1383 QWidget::WStyle_NoBorder | QWidget::WStyle_Tool ); 1444 QWidget::WStyle_NoBorder | QWidget::WStyle_Tool );
1384 lblWait->setPixmap( pix ); 1445 lblWait->setPixmap( pix );
1385 lblWait->setAlignment( QWidget::AlignCenter ); 1446 lblWait->setAlignment( QWidget::AlignCenter );
1386 lblWait->show(); 1447 lblWait->show();
1387 lblWait->showMaximized(); 1448 lblWait->showMaximized();
1388 } 1449 }
1389#ifndef SINGLE_APP 1450#ifndef SINGLE_APP
1390 { QCopEnvelope envelope( "QPE/System", "forceQuit()" ); 1451 { QCopEnvelope envelope( "QPE/System", "forceQuit()" );
1391 } 1452 }
1392 processEvents(); // ensure the message goes out. 1453 processEvents(); // ensure the message goes out.
1393 sleep( 1 ); // You have 1 second to comply. 1454 sleep( 1 ); // You have 1 second to comply.
1394#endif 1455#endif
1395} 1456}
1396 1457
1397/*! 1458/*!
1398 \internal 1459 \internal
1399*/ 1460*/
1400void QPEApplication::shutdown() 1461void QPEApplication::shutdown()
1401{ 1462{
1402 // Implement in server's QPEApplication subclass 1463 // Implement in server's QPEApplication subclass
1403} 1464}
1404 1465
1405/*! 1466/*!
1406 \internal 1467 \internal
1407*/ 1468*/
1408void QPEApplication::restart() 1469void QPEApplication::restart()
1409{ 1470{
1410 // Implement in server's QPEApplication subclass 1471 // Implement in server's QPEApplication subclass
1411} 1472}
1412 1473
1413static QPtrDict<void>* stylusDict = 0; 1474static QPtrDict<void>* stylusDict = 0;
1414static void createDict() 1475static void createDict()
1415{ 1476{
1416 if ( !stylusDict ) 1477 if ( !stylusDict )
1417 stylusDict = new QPtrDict<void>; 1478 stylusDict = new QPtrDict<void>;
1418} 1479}
1419 1480
1420/*! 1481/*!
1421 Returns the current StylusMode for widget \a w. 1482 Returns the current StylusMode for widget \a w.
1422 1483
1423 \sa setStylusOperation() StylusMode 1484 \sa setStylusOperation() StylusMode
1424*/ 1485*/
1425QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w ) 1486QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w )
1426{ 1487{
1427 if ( stylusDict ) 1488 if ( stylusDict )
1428 return ( StylusMode ) ( int ) stylusDict->find( w ); 1489 return ( StylusMode ) ( int ) stylusDict->find( w );
1429 return LeftOnly; 1490 return LeftOnly;
1430} 1491}
1431 1492
1432/*! 1493/*!
1433 \enum QPEApplication::StylusMode 1494 \enum QPEApplication::StylusMode
1434 1495
1435 \value LeftOnly the stylus only generates LeftButton 1496 \value LeftOnly the stylus only generates LeftButton
1436 events (the default). 1497 events (the default).
1437 \value RightOnHold the stylus generates RightButton events 1498 \value RightOnHold the stylus generates RightButton events
1438 if the user uses the press-and-hold gesture. 1499 if the user uses the press-and-hold gesture.
1439 1500
1440 \sa setStylusOperation() stylusOperation() 1501 \sa setStylusOperation() stylusOperation()
1441*/ 1502*/
1442 1503
1443/*! 1504/*!
1444 Causes widget \a w to receive mouse events according to the stylus 1505 Causes widget \a w to receive mouse events according to the stylus
1445 \a mode. 1506 \a mode.
1446 1507
1447 \sa stylusOperation() StylusMode 1508 \sa stylusOperation() StylusMode
1448*/ 1509*/
1449void QPEApplication::setStylusOperation( QWidget * w, StylusMode mode ) 1510void QPEApplication::setStylusOperation( QWidget * w, StylusMode mode )
1450{ 1511{
1451 createDict(); 1512 createDict();
1452 if ( mode == LeftOnly ) { 1513 if ( mode == LeftOnly ) {
1453 stylusDict->remove 1514 stylusDict->remove
1454 ( w ); 1515 ( w );
1455 w->removeEventFilter( qApp ); 1516 w->removeEventFilter( qApp );
1456 } 1517 }
1457 else { 1518 else {
1458 stylusDict->insert( w, ( void* ) mode ); 1519 stylusDict->insert( w, ( void* ) mode );
1459 connect( w, SIGNAL( destroyed() ), qApp, SLOT( removeSenderFromStylusDict() ) ); 1520 connect( w, SIGNAL( destroyed() ), qApp, SLOT( removeSenderFromStylusDict() ) );
1460 w->installEventFilter( qApp ); 1521 w->installEventFilter( qApp );
1461 } 1522 }
1462} 1523}
1463 1524
1464 1525
1465/*! 1526/*!
1466 \reimp 1527 \reimp
1467*/ 1528*/
1468bool QPEApplication::eventFilter( QObject *o, QEvent *e ) 1529bool QPEApplication::eventFilter( QObject *o, QEvent *e )
1469{ 1530{
1470 if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) { 1531 if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) {
1471 QMouseEvent * me = ( QMouseEvent* ) e; 1532 QMouseEvent * me = ( QMouseEvent* ) e;
1472 StylusMode mode = (StylusMode)(int)stylusDict->find(o); 1533 StylusMode mode = (StylusMode)(int)stylusDict->find(o);
1473 switch (mode) { 1534 switch (mode) {
1474 case RightOnHold: 1535 case RightOnHold:
1475 switch ( me->type() ) { 1536 switch ( me->type() ) {
1476 case QEvent::MouseButtonPress: 1537 case QEvent::MouseButtonPress:
1477 if ( me->button() == LeftButton ) { 1538 if ( me->button() == LeftButton ) {
1478 d->presstimer = startTimer(500); // #### pref. 1539 d->presstimer = startTimer(500); // #### pref.
1479 d->presswidget = (QWidget*)o; 1540 d->presswidget = (QWidget*)o;
1480 d->presspos = me->pos(); 1541 d->presspos = me->pos();
1481 d->rightpressed = FALSE; 1542 d->rightpressed = FALSE;
1482 } 1543 }
1483 break; 1544 break;
1484 case QEvent::MouseMove: 1545 case QEvent::MouseMove:
1485 if (d->presstimer && (me->pos() - d->presspos).manhattanLength() > 8) { 1546 if (d->presstimer && (me->pos() - d->presspos).manhattanLength() > 8) {
1486 killTimer(d->presstimer); 1547 killTimer(d->presstimer);
1487 d->presstimer = 0; 1548 d->presstimer = 0;
1488 } 1549 }
1489 break; 1550 break;
1490 case QEvent::MouseButtonRelease: 1551 case QEvent::MouseButtonRelease:
1491 if ( me->button() == LeftButton ) { 1552 if ( me->button() == LeftButton ) {
1492 if ( d->presstimer ) { 1553 if ( d->presstimer ) {
1493 killTimer(d->presstimer); 1554 killTimer(d->presstimer);
1494 d->presstimer = 0; 1555 d->presstimer = 0;
1495 } 1556 }
1496 if ( d->rightpressed && d->presswidget ) { 1557 if ( d->rightpressed && d->presswidget ) {
1497 // Right released 1558 // Right released
1498 postEvent( d->presswidget, 1559 postEvent( d->presswidget,
1499 new QMouseEvent( QEvent::MouseButtonRelease, me->pos(), 1560 new QMouseEvent( QEvent::MouseButtonRelease, me->pos(),
1500 RightButton, LeftButton + RightButton ) ); 1561 RightButton, LeftButton + RightButton ) );
1501 // Left released, off-widget 1562 // Left released, off-widget
1502 postEvent( d->presswidget, 1563 postEvent( d->presswidget,
1503 new QMouseEvent( QEvent::MouseMove, QPoint( -1, -1), 1564 new QMouseEvent( QEvent::MouseMove, QPoint( -1, -1),
1504 LeftButton, LeftButton ) ); 1565 LeftButton, LeftButton ) );
1505 postEvent( d->presswidget, 1566 postEvent( d->presswidget,
1506 new QMouseEvent( QEvent::MouseButtonRelease, QPoint( -1, -1), 1567 new QMouseEvent( QEvent::MouseButtonRelease, QPoint( -1, -1),
1507 LeftButton, LeftButton ) ); 1568 LeftButton, LeftButton ) );
1508 d->rightpressed = FALSE; 1569 d->rightpressed = FALSE;
1509 return TRUE; // don't send the real Left release 1570 return TRUE; // don't send the real Left release
1510 } 1571 }
1511 } 1572 }
1512 break; 1573 break;
1513 default: 1574 default:
1514 break; 1575 break;
1515 } 1576 }
1516 break; 1577 break;
1517 default: 1578 default:
1518 ; 1579 ;
1519 } 1580 }
1520 } 1581 }
1521 else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { 1582 else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) {
1522 QKeyEvent *ke = (QKeyEvent *)e; 1583 QKeyEvent *ke = (QKeyEvent *)e;
1523 if ( ke->key() == Key_Enter ) { 1584 if ( ke->key() == Key_Enter ) {
1524 if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) { 1585 if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) {
1525 postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ', 1586 postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ',
1526 ke->state(), " ", ke->isAutoRepeat(), ke->count() ) ); 1587 ke->state(), " ", ke->isAutoRepeat(), ke->count() ) );
1527 return TRUE; 1588 return TRUE;
1528 } 1589 }
1529 } 1590 }
1530 } 1591 }
1531 return FALSE; 1592 return FALSE;
1532} 1593}
1533 1594
1534/*! 1595/*!
1535 \reimp 1596 \reimp
1536*/ 1597*/
1537void QPEApplication::timerEvent( QTimerEvent *e ) 1598void QPEApplication::timerEvent( QTimerEvent *e )
1538{ 1599{
1539 if ( e->timerId() == d->presstimer && d->presswidget ) { 1600 if ( e->timerId() == d->presstimer && d->presswidget ) {
1540 // Right pressed 1601 // Right pressed
1541 postEvent( d->presswidget, 1602 postEvent( d->presswidget,
1542 new QMouseEvent( QEvent::MouseButtonPress, d->presspos, 1603 new QMouseEvent( QEvent::MouseButtonPress, d->presspos,
1543 RightButton, LeftButton ) ); 1604 RightButton, LeftButton ) );
1544 killTimer( d->presstimer ); 1605 killTimer( d->presstimer );
1545 d->presstimer = 0; 1606 d->presstimer = 0;
1546 d->rightpressed = TRUE; 1607 d->rightpressed = TRUE;
1547 } 1608 }
1548} 1609}
1549 1610
1550void QPEApplication::removeSenderFromStylusDict() 1611void QPEApplication::removeSenderFromStylusDict()
1551{ 1612{
1552 stylusDict->remove 1613 stylusDict->remove
1553 ( ( void* ) sender() ); 1614 ( ( void* ) sender() );
1554 if ( d->presswidget == sender() ) 1615 if ( d->presswidget == sender() )
1555 d->presswidget = 0; 1616 d->presswidget = 0;
1556} 1617}
1557 1618
1558/*! 1619/*!
1559 \internal 1620 \internal
1560*/ 1621*/
1561bool QPEApplication::keyboardGrabbed() const 1622bool QPEApplication::keyboardGrabbed() const
1562{ 1623{
1563 return d->kbgrabber; 1624 return d->kbgrabber;
1564} 1625}
1565 1626
1566 1627
1567/*! 1628/*!
1568 Reverses the effect of grabKeyboard(). This is called automatically 1629 Reverses the effect of grabKeyboard(). This is called automatically
1569 on program exit. 1630 on program exit.
1570*/ 1631*/
1571void QPEApplication::ungrabKeyboard() 1632void QPEApplication::ungrabKeyboard()
1572{ 1633{
1573 QPEApplicationData * d = ( ( QPEApplication* ) qApp ) ->d; 1634 QPEApplicationData * d = ( ( QPEApplication* ) qApp ) ->d;
1574 if ( d->kbgrabber == 2 ) { 1635 if ( d->kbgrabber == 2 ) {
1575#ifndef QT_NO_COP 1636#ifndef QT_NO_COP
1576 QCopEnvelope e( "QPE/System", "grabKeyboard(QString)" ); 1637 QCopEnvelope e( "QPE/System", "grabKeyboard(QString)" );
1577 e << QString::null; 1638 e << QString::null;
1578#endif 1639#endif
1579 1640
1580 d->kbregrab = FALSE; 1641 d->kbregrab = FALSE;
1581 d->kbgrabber = 0; 1642 d->kbgrabber = 0;
1582 } 1643 }
1583} 1644}
1584 1645
1585/*! 1646/*!
1586 Grabs the physical keyboard keys, e.g. the application's launching 1647 Grabs the physical keyboard keys, e.g. the application's launching
1587 keys. Instead of launching applications when these keys are pressed 1648 keys. Instead of launching applications when these keys are pressed
1588 the signals emitted are sent to this application instead. Some games 1649 the signals emitted are sent to this application instead. Some games
1589 programs take over the launch keys in this way to make interaction 1650 programs take over the launch keys in this way to make interaction
1590 easier. 1651 easier.
1591 1652
1592 \sa ungrabKeyboard() 1653 \sa ungrabKeyboard()
1593*/ 1654*/
1594void QPEApplication::grabKeyboard() 1655void QPEApplication::grabKeyboard()
1595{ 1656{
1596 QPEApplicationData * d = ( ( QPEApplication* ) qApp ) ->d; 1657 QPEApplicationData * d = ( ( QPEApplication* ) qApp ) ->d;
1597 if ( qApp->type() == QApplication::GuiServer ) 1658 if ( qApp->type() == QApplication::GuiServer )
1598 d->kbgrabber = 0; 1659 d->kbgrabber = 0;
1599 else { 1660 else {
1600#ifndef QT_NO_COP 1661#ifndef QT_NO_COP
1601 QCopEnvelope e( "QPE/System", "grabKeyboard(QString)" ); 1662 QCopEnvelope e( "QPE/System", "grabKeyboard(QString)" );
1602 e << d->appName; 1663 e << d->appName;
1603#endif 1664#endif
1604 1665
1605 d->kbgrabber = 2; // me 1666 d->kbgrabber = 2; // me
1606 } 1667 }
1607} 1668}
1608 1669
1609/*! 1670/*!
1610 \reimp 1671 \reimp
1611*/ 1672*/
1612int QPEApplication::exec() 1673int QPEApplication::exec()
1613{ 1674{
1614#ifndef QT_NO_COP 1675#ifndef QT_NO_COP
1615 d->sendQCopQ(); 1676 d->sendQCopQ();
1616#endif 1677#endif
1617 1678
1618 if ( d->keep_running ) 1679 if ( d->keep_running )
1619 //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() ) 1680 //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() )
1620 return QApplication::exec(); 1681 return QApplication::exec();
1621 1682
1622#ifndef QT_NO_COP 1683#ifndef QT_NO_COP
1623 1684
1624 { 1685 {
1625 QCopEnvelope e( "QPE/System", "closing(QString)" ); 1686 QCopEnvelope e( "QPE/System", "closing(QString)" );
1626 e << d->appName; 1687 e << d->appName;
1627 } 1688 }
1628#endif 1689#endif
1629 processEvents(); 1690 processEvents();
1630 return 0; 1691 return 0;
1631} 1692}
1632 1693
1633/*! 1694/*!
1634 \internal 1695 \internal
1635 External request for application to quit. Quits if possible without 1696 External request for application to quit. Quits if possible without
1636 loosing state. 1697 loosing state.
1637*/ 1698*/
1638void QPEApplication::tryQuit() 1699void QPEApplication::tryQuit()
1639{ 1700{
1640 if ( activeModalWidget() || strcmp( argv() [ 0 ], "embeddedkonsole" ) == 0 ) 1701 if ( activeModalWidget() || strcmp( argv() [ 0 ], "embeddedkonsole" ) == 0 )
1641 return ; // Inside modal loop or konsole. Too hard to save state. 1702 return ; // Inside modal loop or konsole. Too hard to save state.
1642#ifndef QT_NO_COP 1703#ifndef QT_NO_COP
1643 1704
1644 { 1705 {
1645 QCopEnvelope e( "QPE/System", "closing(QString)" ); 1706 QCopEnvelope e( "QPE/System", "closing(QString)" );
1646 e << d->appName; 1707 e << d->appName;
1647 } 1708 }
1648#endif 1709#endif
1649 processEvents(); 1710 processEvents();
1650 1711
1651 quit(); 1712 quit();
1652} 1713}
1653 1714
1654/*! 1715/*!
1655 \internal 1716 \internal
1656 User initiated quit. Makes the window 'Go Away'. If preloaded this means 1717 User initiated quit. Makes the window 'Go Away'. If preloaded this means
1657 hiding the window. If not it means quitting the application. 1718 hiding the window. If not it means quitting the application.
1658 As this is user initiated we don't need to check state. 1719 As this is user initiated we don't need to check state.
1659*/ 1720*/
1660void QPEApplication::hideOrQuit() 1721void QPEApplication::hideOrQuit()
1661{ 1722{
1662 processEvents(); 1723 processEvents();
1663 1724
1664 // If we are a preloaded application we don't actually quit, so emit 1725 // If we are a preloaded application we don't actually quit, so emit
1665 // a System message indicating we're quasi-closing. 1726 // a System message indicating we're quasi-closing.
1666 if ( d->preloaded && d->qpe_main_widget ) 1727 if ( d->preloaded && d->qpe_main_widget )
1667#ifndef QT_NO_COP 1728#ifndef QT_NO_COP
1668 1729
1669 { 1730 {
1670 QCopEnvelope e("QPE/System", "fastAppHiding(QString)" ); 1731 QCopEnvelope e("QPE/System", "fastAppHiding(QString)" );
1671 e << d->appName; 1732 e << d->appName;
1672 d->qpe_main_widget->hide(); 1733 d->qpe_main_widget->hide();
1673 } 1734 }
1674#endif 1735#endif
1675 else 1736 else
1676 quit(); 1737 quit();
1677} 1738}
1678 1739
1679 1740
1680#if defined(QT_QWS_IPAQ) || defined(QT_QWS_SHARP) 1741#if defined(QT_QWS_IPAQ) || defined(QT_QWS_SHARP)
1681 1742
1682// The libraries with the skiff package (and possibly others) have 1743// The libraries with the skiff package (and possibly others) have
1683// completely useless implementations of builtin new and delete that 1744// completely useless implementations of builtin new and delete that
1684// use about 50% of your CPU. Here we revert to the simple libc 1745// use about 50% of your CPU. Here we revert to the simple libc
1685// functions. 1746// functions.
1686 1747
1687void* operator new[]( size_t size ) 1748void* operator new[]( size_t size )