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