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