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