summaryrefslogtreecommitdiff
path: root/library
Unidiff
Diffstat (limited to 'library') (more/less context) (ignore whitespace changes)
-rw-r--r--library/qpeapplication.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp
index 2432b65..65fac84 100644
--- a/library/qpeapplication.cpp
+++ b/library/qpeapplication.cpp
@@ -224,513 +224,513 @@ bool keep_running :
224 lib->unload(); 224 lib->unload();
225 delete lib; 225 delete lib;
226 } 226 }
227 } 227 }
228 } 228 }
229 229
230 void loadImageCodecs() 230 void loadImageCodecs()
231 { 231 {
232 QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs"; 232 QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs";
233 QDir dir( path, "lib*.so" ); 233 QDir dir( path, "lib*.so" );
234 QStringList list = dir.entryList(); 234 QStringList list = dir.entryList();
235 QStringList::Iterator it; 235 QStringList::Iterator it;
236 for ( it = list.begin(); it != list.end(); ++it ) { 236 for ( it = list.begin(); it != list.end(); ++it ) {
237 ImageCodecInterface *iface = 0; 237 ImageCodecInterface *iface = 0;
238 QLibrary *lib = new QLibrary( path + "/" + *it ); 238 QLibrary *lib = new QLibrary( path + "/" + *it );
239 if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { 239 if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) {
240 QStringList formats = iface->keys(); 240 QStringList formats = iface->keys();
241 for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) { 241 for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) {
242 (void)iface->installIOHandler(*i); 242 (void)iface->installIOHandler(*i);
243 // ### it exists now; need to remember if we can delete it 243 // ### it exists now; need to remember if we can delete it
244 } 244 }
245 } 245 }
246 else { 246 else {
247 lib->unload(); 247 lib->unload();
248 delete lib; 248 delete lib;
249 } 249 }
250 } 250 }
251 } 251 }
252 QString styleName; 252 QString styleName;
253 QString decorationName; 253 QString decorationName;
254}; 254};
255 255
256class ResourceMimeFactory : public QMimeSourceFactory 256class ResourceMimeFactory : public QMimeSourceFactory
257{ 257{
258public: 258public:
259 ResourceMimeFactory() 259 ResourceMimeFactory()
260 { 260 {
261 setFilePath( Global::helpPath() ); 261 setFilePath( Global::helpPath() );
262 setExtensionType( "html", "text/html;charset=UTF-8" ); 262 setExtensionType( "html", "text/html;charset=UTF-8" );
263 } 263 }
264 264
265 const QMimeSource* data( const QString& abs_name ) const 265 const QMimeSource* data( const QString& abs_name ) const
266 { 266 {
267 const QMimeSource * r = QMimeSourceFactory::data( abs_name ); 267 const QMimeSource * r = QMimeSourceFactory::data( abs_name );
268 if ( !r ) { 268 if ( !r ) {
269 int sl = abs_name.length(); 269 int sl = abs_name.length();
270 do { 270 do {
271 sl = abs_name.findRev( '/', sl - 1 ); 271 sl = abs_name.findRev( '/', sl - 1 );
272 QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name; 272 QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name;
273 int dot = name.findRev( '.' ); 273 int dot = name.findRev( '.' );
274 if ( dot >= 0 ) 274 if ( dot >= 0 )
275 name = name.left( dot ); 275 name = name.left( dot );
276 QImage img = Resource::loadImage( name ); 276 QImage img = Resource::loadImage( name );
277 if ( !img.isNull() ) 277 if ( !img.isNull() )
278 r = new QImageDrag( img ); 278 r = new QImageDrag( img );
279 } 279 }
280 while ( !r && sl > 0 ); 280 while ( !r && sl > 0 );
281 } 281 }
282 return r; 282 return r;
283 } 283 }
284}; 284};
285 285
286static int muted = 0; 286static int muted = 0;
287static int micMuted = 0; 287static int micMuted = 0;
288 288
289static void setVolume( int t = 0, int percent = -1 ) 289static void setVolume( int t = 0, int percent = -1 )
290{ 290{
291 switch ( t ) { 291 switch ( t ) {
292 case 0: { 292 case 0: {
293 Config cfg( "qpe" ); 293 Config cfg( "qpe" );
294 cfg.setGroup( "Volume" ); 294 cfg.setGroup( "Volume" );
295 if ( percent < 0 ) 295 if ( percent < 0 )
296 percent = cfg.readNumEntry( "VolumePercent", 50 ); 296 percent = cfg.readNumEntry( "VolumePercent", 50 );
297 int fd = 0; 297 int fd = 0;
298 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { 298 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) {
299 int vol = muted ? 0 : percent; 299 int vol = muted ? 0 : percent;
300 // set both channels to same volume 300 // set both channels to same volume
301 vol |= vol << 8; 301 vol |= vol << 8;
302 ioctl( fd, MIXER_WRITE( 0 ), &vol ); 302 ioctl( fd, MIXER_WRITE( 0 ), &vol );
303 ::close( fd ); 303 ::close( fd );
304 } 304 }
305 } 305 }
306 break; 306 break;
307 } 307 }
308} 308}
309 309
310static void setMic( int t = 0, int percent = -1 ) 310static void setMic( int t = 0, int percent = -1 )
311{ 311{
312 switch ( t ) { 312 switch ( t ) {
313 case 0: { 313 case 0: {
314 Config cfg( "qpe" ); 314 Config cfg( "qpe" );
315 cfg.setGroup( "Volume" ); 315 cfg.setGroup( "Volume" );
316 if ( percent < 0 ) 316 if ( percent < 0 )
317 percent = cfg.readNumEntry( "Mic", 50 ); 317 percent = cfg.readNumEntry( "Mic", 50 );
318 318
319 int fd = 0; 319 int fd = 0;
320 int mic = micMuted ? 0 : percent; 320 int mic = micMuted ? 0 : percent;
321 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { 321 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) {
322 ioctl( fd, MIXER_WRITE( SOUND_MIXER_MIC ), &mic ); 322 ioctl( fd, MIXER_WRITE( SOUND_MIXER_MIC ), &mic );
323 ::close( fd ); 323 ::close( fd );
324 } 324 }
325 } 325 }
326 break; 326 break;
327 } 327 }
328} 328}
329 329
330 330
331/*! 331/*!
332 \class QPEApplication qpeapplication.h 332 \class QPEApplication qpeapplication.h
333 \brief The QPEApplication class implements various system services 333 \brief The QPEApplication class implements various system services
334 that are available to all Qtopia applications. 334 that are available to all Qtopia applications.
335 335
336 Simply by using QPEApplication instead of QApplication, a standard Qt 336 Simply by using QPEApplication instead of QApplication, a standard Qt
337 application becomes a Qtopia application. It automatically follows 337 application becomes a Qtopia application. It automatically follows
338 style changes, quits and raises, and in the 338 style changes, quits and raises, and in the
339 case of \link docwidget.html document-oriented\endlink applications, 339 case of \link docwidget.html document-oriented\endlink applications,
340 changes the currently displayed document in response to the environment. 340 changes the currently displayed document in response to the environment.
341 341
342 To create a \link docwidget.html document-oriented\endlink 342 To create a \link docwidget.html document-oriented\endlink
343 application use showMainDocumentWidget(); to create a 343 application use showMainDocumentWidget(); to create a
344 non-document-oriented application use showMainWidget(). The 344 non-document-oriented application use showMainWidget(). The
345 keepRunning() function indicates whether the application will 345 keepRunning() function indicates whether the application will
346 continue running after it's processed the last \link qcop.html 346 continue running after it's processed the last \link qcop.html
347 QCop\endlink message. This can be changed using setKeepRunning(). 347 QCop\endlink message. This can be changed using setKeepRunning().
348 348
349 A variety of signals are emitted when certain events occur, for 349 A variety of signals are emitted when certain events occur, for
350 example, timeChanged(), clockChanged(), weekChanged(), 350 example, timeChanged(), clockChanged(), weekChanged(),
351 dateFormatChanged() and volumeChanged(). If the application receives 351 dateFormatChanged() and volumeChanged(). If the application receives
352 a \link qcop.html QCop\endlink message on the application's 352 a \link qcop.html QCop\endlink message on the application's
353 QPE/Application/\e{appname} channel, the appMessage() signal is 353 QPE/Application/\e{appname} channel, the appMessage() signal is
354 emitted. There are also flush() and reload() signals, which 354 emitted. There are also flush() and reload() signals, which
355 are emitted when synching begins and ends respectively - upon these 355 are emitted when synching begins and ends respectively - upon these
356 signals, the application should save and reload any data 356 signals, the application should save and reload any data
357 files that are involved in synching. Most of these signals will initially 357 files that are involved in synching. Most of these signals will initially
358 be received and unfiltered through the appMessage() signal. 358 be received and unfiltered through the appMessage() signal.
359 359
360 This class also provides a set of useful static functions. The 360 This class also provides a set of useful static functions. The
361 qpeDir() and documentDir() functions return the respective paths. 361 qpeDir() and documentDir() functions return the respective paths.
362 The grabKeyboard() and ungrabKeyboard() functions are used to 362 The grabKeyboard() and ungrabKeyboard() functions are used to
363 control whether the application takes control of the device's 363 control whether the application takes control of the device's
364 physical buttons (e.g. application launch keys). The stylus' mode of 364 physical buttons (e.g. application launch keys). The stylus' mode of
365 operation is set with setStylusOperation() and retrieved with 365 operation is set with setStylusOperation() and retrieved with
366 stylusOperation(). There are also setInputMethodHint() and 366 stylusOperation(). There are also setInputMethodHint() and
367 inputMethodHint() functions. 367 inputMethodHint() functions.
368 368
369 \ingroup qtopiaemb 369 \ingroup qtopiaemb
370*/ 370*/
371 371
372/*! 372/*!
373 \fn void QPEApplication::clientMoused() 373 \fn void QPEApplication::clientMoused()
374 374
375 \internal 375 \internal
376*/ 376*/
377 377
378/*! 378/*!
379 \fn void QPEApplication::timeChanged(); 379 \fn void QPEApplication::timeChanged();
380 This signal is emitted when the time changes outside the normal 380 This signal is emitted when the time changes outside the normal
381 passage of time, i.e. if the time is set backwards or forwards. 381 passage of time, i.e. if the time is set backwards or forwards.
382*/ 382*/
383 383
384/*! 384/*!
385 \fn void QPEApplication::clockChanged( bool ampm ); 385 \fn void QPEApplication::clockChanged( bool ampm );
386 386
387 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
388 \a ampm is TRUE, the user wants a 12-hour AM/PM clock, otherwise, 388 \a ampm is TRUE, the user wants a 12-hour AM/PM clock, otherwise,
389 they want a 24-hour clock. 389 they want a 24-hour clock.
390*/ 390*/
391 391
392/*! 392/*!
393 \fn void QPEApplication::volumeChanged( bool muted ) 393 \fn void QPEApplication::volumeChanged( bool muted )
394 394
395 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
396 muted is TRUE, then sound output has been muted. 396 muted is TRUE, then sound output has been muted.
397*/ 397*/
398 398
399/*! 399/*!
400 \fn void QPEApplication::weekChanged( bool startOnMonday ) 400 \fn void QPEApplication::weekChanged( bool startOnMonday )
401 401
402 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
403 startOnMonday is TRUE then the first day of the week is Monday; if 403 startOnMonday is TRUE then the first day of the week is Monday; if
404 \a startOnMonday is FALSE then the first day of the week is 404 \a startOnMonday is FALSE then the first day of the week is
405 Sunday. 405 Sunday.
406*/ 406*/
407 407
408/*! 408/*!
409 \fn void QPEApplication::dateFormatChanged() 409 \fn void QPEApplication::dateFormatChanged()
410 410
411 This signal is emitted whenever the date format is changed. 411 This signal is emitted whenever the date format is changed.
412*/ 412*/
413 413
414/*! 414/*!
415 \fn void QPEApplication::flush() 415 \fn void QPEApplication::flush()
416 416
417 ### 417 ###
418*/ 418*/
419 419
420/*! 420/*!
421 \fn void QPEApplication::reload() 421 \fn void QPEApplication::reload()
422 422
423*/ 423*/
424 424
425/*! 425/*!
426 \fn void QPEApplication::appMessage( const QCString& msg, const QByteArray& data ) 426 \fn void QPEApplication::appMessage( const QCString& msg, const QByteArray& data )
427 427
428 This signal is emitted when a message is received on this 428 This signal is emitted when a message is received on this
429 application's QPE/Application/<i>appname</i> \link qcop.html 429 application's QPE/Application/<i>appname</i> \link qcop.html
430 QCop\endlink channel. 430 QCop\endlink channel.
431 431
432 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
433 in the following way: 433 in the following way:
434 434
435\code 435\code
436 void MyWidget::receive( const QCString& msg, const QByteArray& data ) 436 void MyWidget::receive( const QCString& msg, const QByteArray& data )
437 { 437 {
438 QDataStream stream( data, IO_ReadOnly ); 438 QDataStream stream( data, IO_ReadOnly );
439 if ( msg == "someMessage(int,int,int)" ) { 439 if ( msg == "someMessage(int,int,int)" ) {
440 int a,b,c; 440 int a,b,c;
441 stream >> a >> b >> c; 441 stream >> a >> b >> c;
442 ... 442 ...
443 } else if ( msg == "otherMessage(QString)" ) { 443 } else if ( msg == "otherMessage(QString)" ) {
444 ... 444 ...
445 } 445 }
446 } 446 }
447\endcode 447\endcode
448 448
449 \sa qcop.html 449 \sa qcop.html
450 Note that messages received here may be processed by qpe application 450 Note that messages received here may be processed by qpe application
451 and emitted as signals, such as flush() and reload(). 451 and emitted as signals, such as flush() and reload().
452*/ 452*/
453 453
454/*! 454/*!
455 Constructs a QPEApplication just as you would construct 455 Constructs a QPEApplication just as you would construct
456 a QApplication, passing \a argc, \a argv, and \a t. 456 a QApplication, passing \a argc, \a argv, and \a t.
457 457
458 For applications, \a t should be the default, GuiClient. Only 458 For applications, \a t should be the default, GuiClient. Only
459 the Qtopia server passes GuiServer. 459 the Qtopia server passes GuiServer.
460*/ 460*/
461QPEApplication::QPEApplication( int & argc, char **argv, Type t ) 461QPEApplication::QPEApplication( int & argc, char **argv, Type t )
462 : QApplication( argc, argv, t ) 462 : QApplication( argc, argv, t )
463{ 463{
464 d = new QPEApplicationData; 464 d = new QPEApplicationData;
465 d->loadTextCodecs(); 465 d->loadTextCodecs();
466 d->loadImageCodecs(); 466 d->loadImageCodecs();
467 int dw = desktop() ->width(); 467 int dw = desktop() ->width();
468 qWarning( "Width %d", dw ); 468 qWarning( "Width %d", dw );
469 if ( dw < 200 ) { 469 if ( dw < 200 ) {
470 setFont( QFont( "helvetica", 8 ) ); 470 setFont( QFont( "helvetica", 8 ) );
471 AppLnk::setSmallIconSize( 10 ); 471 AppLnk::setSmallIconSize( 10 );
472 AppLnk::setBigIconSize( 28 ); 472 AppLnk::setBigIconSize( 28 );
473 } 473 }
474 else if ( dw > 600 ) { 474 else if ( dw > 600 ) {
475 setFont( QFont( "helvetica", 12 ) ); 475 setFont( QFont( "helvetica", 12 ) );
476 AppLnk::setSmallIconSize( 24 ); 476 AppLnk::setSmallIconSize( 24 );
477 AppLnk::setBigIconSize( 48 ); 477 AppLnk::setBigIconSize( 48 );
478 } 478 }
479 else if ( dw > 200 ) { 479 else if ( dw > 200 ) {
480 setFont( QFont( "helvetica", 12 ) ); 480 setFont( QFont( "helvetica", 10 ) );
481 AppLnk::setSmallIconSize( 16 ); 481 AppLnk::setSmallIconSize( 16 );
482 AppLnk::setBigIconSize( 32 ); 482 AppLnk::setBigIconSize( 32 );
483 } 483 }
484 484
485 485
486 QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory ); 486 QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory );
487 487
488 connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) ); 488 connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) );
489#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 489#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
490 490
491 QString qcopfn( "/tmp/qcop-msg-" ); 491 QString qcopfn( "/tmp/qcop-msg-" );
492 qcopfn += QString( argv[ 0 ] ); // append command name 492 qcopfn += QString( argv[ 0 ] ); // append command name
493 493
494 QFile f( qcopfn ); 494 QFile f( qcopfn );
495 if ( f.open( IO_ReadOnly ) ) { 495 if ( f.open( IO_ReadOnly ) ) {
496 flock( f.handle(), LOCK_EX ); 496 flock( f.handle(), LOCK_EX );
497 } 497 }
498 498
499 sysChannel = new QCopChannel( "QPE/System", this ); 499 sysChannel = new QCopChannel( "QPE/System", this );
500 connect( sysChannel, SIGNAL( received( const QCString &, const QByteArray & ) ), 500 connect( sysChannel, SIGNAL( received( const QCString &, const QByteArray & ) ),
501 this, SLOT( systemMessage( const QCString &, const QByteArray & ) ) ); 501 this, SLOT( systemMessage( const QCString &, const QByteArray & ) ) );
502 502
503 QCString channel = QCString( argv[ 0 ] ); 503 QCString channel = QCString( argv[ 0 ] );
504 channel.replace( QRegExp( ".*/" ), "" ); 504 channel.replace( QRegExp( ".*/" ), "" );
505 d->appName = channel; 505 d->appName = channel;
506 channel = "QPE/Application/" + channel; 506 channel = "QPE/Application/" + channel;
507 pidChannel = new QCopChannel( channel, this ); 507 pidChannel = new QCopChannel( channel, this );
508 connect( pidChannel, SIGNAL( received( const QCString &, const QByteArray & ) ), 508 connect( pidChannel, SIGNAL( received( const QCString &, const QByteArray & ) ),
509 this, SLOT( pidMessage( const QCString &, const QByteArray & ) ) ); 509 this, SLOT( pidMessage( const QCString &, const QByteArray & ) ) );
510 510
511 if ( f.isOpen() ) { 511 if ( f.isOpen() ) {
512 d->keep_running = FALSE; 512 d->keep_running = FALSE;
513 QDataStream ds( &f ); 513 QDataStream ds( &f );
514 QCString channel, message; 514 QCString channel, message;
515 QByteArray data; 515 QByteArray data;
516 while ( !ds.atEnd() ) { 516 while ( !ds.atEnd() ) {
517 ds >> channel >> message >> data; 517 ds >> channel >> message >> data;
518 d->enqueueQCop( channel, message, data ); 518 d->enqueueQCop( channel, message, data );
519 } 519 }
520 520
521 flock( f.handle(), LOCK_UN ); 521 flock( f.handle(), LOCK_UN );
522 f.close(); 522 f.close();
523 f.remove(); 523 f.remove();
524 } 524 }
525 525
526 for ( int a = 0; a < argc; a++ ) { 526 for ( int a = 0; a < argc; a++ ) {
527 if ( qstrcmp( argv[ a ], "-preload" ) == 0 ) { 527 if ( qstrcmp( argv[ a ], "-preload" ) == 0 ) {
528 argv[ a ] = argv[ a + 1 ]; 528 argv[ a ] = argv[ a + 1 ];
529 a++; 529 a++;
530 d->preloaded = TRUE; 530 d->preloaded = TRUE;
531 argc -= 1; 531 argc -= 1;
532 } 532 }
533 else if ( qstrcmp( argv[ a ], "-preload-show" ) == 0 ) { 533 else if ( qstrcmp( argv[ a ], "-preload-show" ) == 0 ) {
534 argv[ a ] = argv[ a + 1 ]; 534 argv[ a ] = argv[ a + 1 ];
535 a++; 535 a++;
536 d->preloaded = TRUE; 536 d->preloaded = TRUE;
537 d->forceshow = TRUE; 537 d->forceshow = TRUE;
538 argc -= 1; 538 argc -= 1;
539 } 539 }
540 } 540 }
541 541
542 /* overide stored arguments */ 542 /* overide stored arguments */
543 setArgs( argc, argv ); 543 setArgs( argc, argv );
544 544
545#endif 545#endif
546 546
547 // qwsSetDecoration( new QPEDecoration() ); 547 // qwsSetDecoration( new QPEDecoration() );
548 548
549#ifndef QT_NO_TRANSLATION 549#ifndef QT_NO_TRANSLATION
550 550
551 QStringList langs = Global::languageList(); 551 QStringList langs = Global::languageList();
552 for ( QStringList::ConstIterator it = langs.begin(); it != langs.end(); ++it ) { 552 for ( QStringList::ConstIterator it = langs.begin(); it != langs.end(); ++it ) {
553 QString lang = *it; 553 QString lang = *it;
554 554
555 QTranslator * trans; 555 QTranslator * trans;
556 QString tfn; 556 QString tfn;
557 557
558 trans = new QTranslator( this ); 558 trans = new QTranslator( this );
559 tfn = qpeDir() + "/i18n/" + lang + "/libqpe.qm"; 559 tfn = qpeDir() + "/i18n/" + lang + "/libqpe.qm";
560 if ( trans->load( tfn ) ) 560 if ( trans->load( tfn ) )
561 installTranslator( trans ); 561 installTranslator( trans );
562 else 562 else
563 delete trans; 563 delete trans;
564 564
565 trans = new QTranslator( this ); 565 trans = new QTranslator( this );
566 tfn = qpeDir() + "/i18n/" + lang + "/" + d->appName + ".qm"; 566 tfn = qpeDir() + "/i18n/" + lang + "/" + d->appName + ".qm";
567 if ( trans->load( tfn ) ) 567 if ( trans->load( tfn ) )
568 installTranslator( trans ); 568 installTranslator( trans );
569 else 569 else
570 delete trans; 570 delete trans;
571 571
572 //###language/font hack; should look it up somewhere 572 //###language/font hack; should look it up somewhere
573#ifdef QWS 573#ifdef QWS
574 574
575 if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) { 575 if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) {
576 QFont fn = FontManager::unicodeFont( FontManager::Proportional ); 576 QFont fn = FontManager::unicodeFont( FontManager::Proportional );
577 setFont( fn ); 577 setFont( fn );
578 } 578 }
579#endif 579#endif
580 580
581 } 581 }
582#endif 582#endif
583 583
584 applyStyle(); 584 applyStyle();
585 585
586 if ( type() == GuiServer ) { 586 if ( type() == GuiServer ) {
587 setVolume(); 587 setVolume();
588 } 588 }
589 589
590 installEventFilter( this ); 590 installEventFilter( this );
591 591
592 QPEMenuToolFocusManager::initialize(); 592 QPEMenuToolFocusManager::initialize();
593 593
594#ifdef QT_NO_QWS_CURSOR 594#ifdef QT_NO_QWS_CURSOR
595 // if we have no cursor, probably don't want tooltips 595 // if we have no cursor, probably don't want tooltips
596 QToolTip::setEnabled( FALSE ); 596 QToolTip::setEnabled( FALSE );
597#endif 597#endif
598} 598}
599 599
600static QPtrDict<void>* inputMethodDict = 0; 600static QPtrDict<void>* inputMethodDict = 0;
601static void createInputMethodDict() 601static void createInputMethodDict()
602{ 602{
603 if ( !inputMethodDict ) 603 if ( !inputMethodDict )
604 inputMethodDict = new QPtrDict<void>; 604 inputMethodDict = new QPtrDict<void>;
605} 605}
606 606
607/*! 607/*!
608 Returns the currently set hint to the system as to whether 608 Returns the currently set hint to the system as to whether
609 widget \a w has any use for text input methods. 609 widget \a w has any use for text input methods.
610 610
611 611
612 \sa setInputMethodHint() InputMethodHint 612 \sa setInputMethodHint() InputMethodHint
613*/ 613*/
614QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w ) 614QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w )
615{ 615{
616 if ( inputMethodDict && w ) 616 if ( inputMethodDict && w )
617 return ( InputMethodHint ) ( int ) inputMethodDict->find( w ); 617 return ( InputMethodHint ) ( int ) inputMethodDict->find( w );
618 return Normal; 618 return Normal;
619} 619}
620 620
621/*! 621/*!
622 \enum QPEApplication::InputMethodHint 622 \enum QPEApplication::InputMethodHint
623 623
624 \value Normal the application sometimes needs text input (the default). 624 \value Normal the application sometimes needs text input (the default).
625 \value AlwaysOff the application never needs text input. 625 \value AlwaysOff the application never needs text input.
626 \value AlwaysOn the application always needs text input. 626 \value AlwaysOn the application always needs text input.
627*/ 627*/
628 628
629/*! 629/*!
630 Hints to the system that widget \a w has use for text input methods 630 Hints to the system that widget \a w has use for text input methods
631 as specified by \a mode. 631 as specified by \a mode.
632 632
633 \sa inputMethodHint() InputMethodHint 633 \sa inputMethodHint() InputMethodHint
634*/ 634*/
635void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode ) 635void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode )
636{ 636{
637 createInputMethodDict(); 637 createInputMethodDict();
638 if ( mode == Normal ) { 638 if ( mode == Normal ) {
639 inputMethodDict->remove 639 inputMethodDict->remove
640 ( w ); 640 ( w );
641 } 641 }
642 else { 642 else {
643 inputMethodDict->insert( w, ( void* ) mode ); 643 inputMethodDict->insert( w, ( void* ) mode );
644 } 644 }
645} 645}
646 646
647class HackDialog : public QDialog 647class HackDialog : public QDialog
648{ 648{
649public: 649public:
650 void acceptIt() 650 void acceptIt()
651 { 651 {
652 accept(); 652 accept();
653 } 653 }
654 void rejectIt() 654 void rejectIt()
655 { 655 {
656 reject(); 656 reject();
657 } 657 }
658}; 658};
659 659
660 660
661void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key ) 661void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key )
662{ 662{
663 // specialised actions for certain widgets. May want to 663 // specialised actions for certain widgets. May want to
664 // add more stuff here. 664 // add more stuff here.
665 if ( activePopupWidget() && activePopupWidget() ->inherits( "QListBox" ) 665 if ( activePopupWidget() && activePopupWidget() ->inherits( "QListBox" )
666 && activePopupWidget() ->parentWidget() 666 && activePopupWidget() ->parentWidget()
667 && activePopupWidget() ->parentWidget() ->inherits( "QComboBox" ) ) 667 && activePopupWidget() ->parentWidget() ->inherits( "QComboBox" ) )
668 key = Qt::Key_Return; 668 key = Qt::Key_Return;
669 669
670 if ( activePopupWidget() && activePopupWidget() ->inherits( "QPopupMenu" ) ) 670 if ( activePopupWidget() && activePopupWidget() ->inherits( "QPopupMenu" ) )
671 key = Qt::Key_Return; 671 key = Qt::Key_Return;
672 672
673#ifdef QWS 673#ifdef QWS
674 674
675 ke->simpleData.keycode = key; 675 ke->simpleData.keycode = key;
676#endif 676#endif
677} 677}
678 678
679class HackWidget : public QWidget 679class HackWidget : public QWidget
680{ 680{
681public: 681public:
682 bool needsOk() 682 bool needsOk()
683 { 683 {
684 return ( getWState() & WState_Reserved1 ); 684 return ( getWState() & WState_Reserved1 );
685 } 685 }
686}; 686};
687 687
688/*! 688/*!
689 \internal 689 \internal
690*/ 690*/
691 691
692#ifdef QWS 692#ifdef QWS
693bool QPEApplication::qwsEventFilter( QWSEvent * e ) 693bool QPEApplication::qwsEventFilter( QWSEvent * e )
694{ 694{
695 if ( !d->notbusysent && e->type == QWSEvent::Focus ) { 695 if ( !d->notbusysent && e->type == QWSEvent::Focus ) {
696 if ( qApp->type() != QApplication::GuiServer ) { 696 if ( qApp->type() != QApplication::GuiServer ) {
697 QCopEnvelope e( "QPE/System", "notBusy(QString)" ); 697 QCopEnvelope e( "QPE/System", "notBusy(QString)" );
698 e << d->appName; 698 e << d->appName;
699 } 699 }
700 d->notbusysent = TRUE; 700 d->notbusysent = TRUE;
701 } 701 }
702 if ( type() == GuiServer ) { 702 if ( type() == GuiServer ) {
703 switch ( e->type ) { 703 switch ( e->type ) {
704 case QWSEvent::Mouse: 704 case QWSEvent::Mouse:
705 if ( e->asMouse() ->simpleData.state && !QWidget::find( e->window() ) ) 705 if ( e->asMouse() ->simpleData.state && !QWidget::find( e->window() ) )
706 emit clientMoused(); 706 emit clientMoused();
707 break; 707 break;
708 default: 708 default:
709 break; 709 break;
710 } 710 }
711 } 711 }
712 if ( e->type == QWSEvent::Key ) { 712 if ( e->type == QWSEvent::Key ) {
713 if ( d->kbgrabber == 1 ) 713 if ( d->kbgrabber == 1 )
714 return TRUE; 714 return TRUE;
715 QWSKeyEvent *ke = ( QWSKeyEvent * ) e; 715 QWSKeyEvent *ke = ( QWSKeyEvent * ) e;
716 if ( ke->simpleData.keycode == Qt::Key_F33 ) { 716 if ( ke->simpleData.keycode == Qt::Key_F33 ) {
717 // Use special "OK" key to press "OK" on top level widgets 717 // Use special "OK" key to press "OK" on top level widgets
718 QWidget * active = activeWindow(); 718 QWidget * active = activeWindow();
719 QWidget *popup = 0; 719 QWidget *popup = 0;
720 if ( active && active->isPopup() ) { 720 if ( active && active->isPopup() ) {
721 popup = active; 721 popup = active;
722 active = active->parentWidget(); 722 active = active->parentWidget();
723 } 723 }
724 if ( active && ( int ) active->winId() == ke->simpleData.window && 724 if ( active && ( int ) active->winId() == ke->simpleData.window &&
725 !active->testWFlags( WStyle_Customize | WType_Popup | WType_Desktop ) ) { 725 !active->testWFlags( WStyle_Customize | WType_Popup | WType_Desktop ) ) {
726 if ( ke->simpleData.is_press ) { 726 if ( ke->simpleData.is_press ) {
727 if ( popup ) 727 if ( popup )
728 popup->close(); 728 popup->close();
729 if ( active->inherits( "QDialog" ) ) { 729 if ( active->inherits( "QDialog" ) ) {
730 HackDialog * d = ( HackDialog * ) active; 730 HackDialog * d = ( HackDialog * ) active;
731 d->acceptIt(); 731 d->acceptIt();
732 return TRUE; 732 return TRUE;
733 } 733 }
734 else if ( ( ( HackWidget * ) active ) ->needsOk() ) { 734 else if ( ( ( HackWidget * ) active ) ->needsOk() ) {
735 QSignal s; 735 QSignal s;
736 s.connect( active, SLOT( accept() ) ); 736 s.connect( active, SLOT( accept() ) );