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