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