summaryrefslogtreecommitdiff
path: root/library/qpeapplication.cpp
Unidiff
Diffstat (limited to 'library/qpeapplication.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--library/qpeapplication.cpp30
1 files changed, 15 insertions, 15 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp
index e5da48c..f4db1ab 100644
--- a/library/qpeapplication.cpp
+++ b/library/qpeapplication.cpp
@@ -350,528 +350,516 @@ static void setBass( int t = 0, int percent = -1 )
350 int bass = percent; 350 int bass = percent;
351 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { 351 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) {
352 ioctl( fd, MIXER_WRITE( SOUND_MIXER_BASS ), &bass ); 352 ioctl( fd, MIXER_WRITE( SOUND_MIXER_BASS ), &bass );
353 ::close( fd ); 353 ::close( fd );
354 } 354 }
355 } 355 }
356 break; 356 break;
357 } 357 }
358} 358}
359 359
360 360
361static void setTreble( int t = 0, int percent = -1 ) 361static void setTreble( int t = 0, int percent = -1 )
362{ 362{
363 switch ( t ) { 363 switch ( t ) {
364 case 0: { 364 case 0: {
365 Config cfg( "qpe" ); 365 Config cfg( "qpe" );
366 cfg.setGroup( "Volume" ); 366 cfg.setGroup( "Volume" );
367 if ( percent < 0 ) 367 if ( percent < 0 )
368 percent = cfg.readNumEntry( "TreblePercent", 50 ); 368 percent = cfg.readNumEntry( "TreblePercent", 50 );
369 369
370 int fd = 0; 370 int fd = 0;
371 int treble = percent; 371 int treble = percent;
372 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { 372 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) {
373 ioctl( fd, MIXER_WRITE( SOUND_MIXER_TREBLE ), &treble ); 373 ioctl( fd, MIXER_WRITE( SOUND_MIXER_TREBLE ), &treble );
374 ::close( fd ); 374 ::close( fd );
375 } 375 }
376 } 376 }
377 break; 377 break;
378 } 378 }
379} 379}
380 380
381 381
382/*! 382/*!
383 \class QPEApplication qpeapplication.h 383 \class QPEApplication qpeapplication.h
384 \brief The QPEApplication class implements various system services 384 \brief The QPEApplication class implements various system services
385 that are available to all Qtopia applications. 385 that are available to all Qtopia applications.
386 386
387 Simply by using QPEApplication instead of QApplication, a standard Qt 387 Simply by using QPEApplication instead of QApplication, a standard Qt
388 application becomes a Qtopia application. It automatically follows 388 application becomes a Qtopia application. It automatically follows
389 style changes, quits and raises, and in the 389 style changes, quits and raises, and in the
390 case of \link docwidget.html document-oriented\endlink applications, 390 case of \link docwidget.html document-oriented\endlink applications,
391 changes the currently displayed document in response to the environment. 391 changes the currently displayed document in response to the environment.
392 392
393 To create a \link docwidget.html document-oriented\endlink 393 To create a \link docwidget.html document-oriented\endlink
394 application use showMainDocumentWidget(); to create a 394 application use showMainDocumentWidget(); to create a
395 non-document-oriented application use showMainWidget(). The 395 non-document-oriented application use showMainWidget(). The
396 keepRunning() function indicates whether the application will 396 keepRunning() function indicates whether the application will
397 continue running after it's processed the last \link qcop.html 397 continue running after it's processed the last \link qcop.html
398 QCop\endlink message. This can be changed using setKeepRunning(). 398 QCop\endlink message. This can be changed using setKeepRunning().
399 399
400 A variety of signals are emitted when certain events occur, for 400 A variety of signals are emitted when certain events occur, for
401 example, timeChanged(), clockChanged(), weekChanged(), 401 example, timeChanged(), clockChanged(), weekChanged(),
402 dateFormatChanged() and volumeChanged(). If the application receives 402 dateFormatChanged() and volumeChanged(). If the application receives
403 a \link qcop.html QCop\endlink message on the application's 403 a \link qcop.html QCop\endlink message on the application's
404 QPE/Application/\e{appname} channel, the appMessage() signal is 404 QPE/Application/\e{appname} channel, the appMessage() signal is
405 emitted. There are also flush() and reload() signals, which 405 emitted. There are also flush() and reload() signals, which
406 are emitted when synching begins and ends respectively - upon these 406 are emitted when synching begins and ends respectively - upon these
407 signals, the application should save and reload any data 407 signals, the application should save and reload any data
408 files that are involved in synching. Most of these signals will initially 408 files that are involved in synching. Most of these signals will initially
409 be received and unfiltered through the appMessage() signal. 409 be received and unfiltered through the appMessage() signal.
410 410
411 This class also provides a set of useful static functions. The 411 This class also provides a set of useful static functions. The
412 qpeDir() and documentDir() functions return the respective paths. 412 qpeDir() and documentDir() functions return the respective paths.
413 The grabKeyboard() and ungrabKeyboard() functions are used to 413 The grabKeyboard() and ungrabKeyboard() functions are used to
414 control whether the application takes control of the device's 414 control whether the application takes control of the device's
415 physical buttons (e.g. application launch keys). The stylus' mode of 415 physical buttons (e.g. application launch keys). The stylus' mode of
416 operation is set with setStylusOperation() and retrieved with 416 operation is set with setStylusOperation() and retrieved with
417 stylusOperation(). There are also setInputMethodHint() and 417 stylusOperation(). There are also setInputMethodHint() and
418 inputMethodHint() functions. 418 inputMethodHint() functions.
419 419
420 \ingroup qtopiaemb 420 \ingroup qtopiaemb
421*/ 421*/
422 422
423/*! 423/*!
424 \fn void QPEApplication::clientMoused() 424 \fn void QPEApplication::clientMoused()
425 425
426 \internal 426 \internal
427*/ 427*/
428 428
429/*! 429/*!
430 \fn void QPEApplication::timeChanged(); 430 \fn void QPEApplication::timeChanged();
431 This signal is emitted when the time changes outside the normal 431 This signal is emitted when the time changes outside the normal
432 passage of time, i.e. if the time is set backwards or forwards. 432 passage of time, i.e. if the time is set backwards or forwards.
433*/ 433*/
434 434
435/*! 435/*!
436 \fn void QPEApplication::clockChanged( bool ampm ); 436 \fn void QPEApplication::clockChanged( bool ampm );
437 437
438 This signal is emitted when the user changes the clock's style. If 438 This signal is emitted when the user changes the clock's style. If
439 \a ampm is TRUE, the user wants a 12-hour AM/PM clock, otherwise, 439 \a ampm is TRUE, the user wants a 12-hour AM/PM clock, otherwise,
440 they want a 24-hour clock. 440 they want a 24-hour clock.
441*/ 441*/
442 442
443/*! 443/*!
444 \fn void QPEApplication::volumeChanged( bool muted ) 444 \fn void QPEApplication::volumeChanged( bool muted )
445 445
446 This signal is emitted whenever the mute state is changed. If \a 446 This signal is emitted whenever the mute state is changed. If \a
447 muted is TRUE, then sound output has been muted. 447 muted is TRUE, then sound output has been muted.
448*/ 448*/
449 449
450/*! 450/*!
451 \fn void QPEApplication::weekChanged( bool startOnMonday ) 451 \fn void QPEApplication::weekChanged( bool startOnMonday )
452 452
453 This signal is emitted if the week start day is changed. If \a 453 This signal is emitted if the week start day is changed. If \a
454 startOnMonday is TRUE then the first day of the week is Monday; if 454 startOnMonday is TRUE then the first day of the week is Monday; if
455 \a startOnMonday is FALSE then the first day of the week is 455 \a startOnMonday is FALSE then the first day of the week is
456 Sunday. 456 Sunday.
457*/ 457*/
458 458
459/*! 459/*!
460 \fn void QPEApplication::dateFormatChanged(DateFormat) 460 \fn void QPEApplication::dateFormatChanged(DateFormat)
461 461
462 This signal is emitted whenever the date format is changed. 462 This signal is emitted whenever the date format is changed.
463*/ 463*/
464 464
465/*! 465/*!
466 \fn void QPEApplication::flush() 466 \fn void QPEApplication::flush()
467 467
468 ### 468 ###
469*/ 469*/
470 470
471/*! 471/*!
472 \fn void QPEApplication::reload() 472 \fn void QPEApplication::reload()
473 473
474*/ 474*/
475 475
476/*! 476/*!
477 \fn void QPEApplication::appMessage( const QCString& msg, const QByteArray& data ) 477 \fn void QPEApplication::appMessage( const QCString& msg, const QByteArray& data )
478 478
479 This signal is emitted when a message is received on this 479 This signal is emitted when a message is received on this
480 application's QPE/Application/<i>appname</i> \link qcop.html 480 application's QPE/Application/<i>appname</i> \link qcop.html
481 QCop\endlink channel. 481 QCop\endlink channel.
482 482
483 The slot to which you connect this signal uses \a msg and \a data 483 The slot to which you connect this signal uses \a msg and \a data
484 in the following way: 484 in the following way:
485 485
486\code 486\code
487 void MyWidget::receive( const QCString& msg, const QByteArray& data ) 487 void MyWidget::receive( const QCString& msg, const QByteArray& data )
488 { 488 {
489 QDataStream stream( data, IO_ReadOnly ); 489 QDataStream stream( data, IO_ReadOnly );
490 if ( msg == "someMessage(int,int,int)" ) { 490 if ( msg == "someMessage(int,int,int)" ) {
491 int a,b,c; 491 int a,b,c;
492 stream >> a >> b >> c; 492 stream >> a >> b >> c;
493 ... 493 ...
494 } else if ( msg == "otherMessage(QString)" ) { 494 } else if ( msg == "otherMessage(QString)" ) {
495 ... 495 ...
496 } 496 }
497 } 497 }
498\endcode 498\endcode
499 499
500 \sa qcop.html 500 \sa qcop.html
501 Note that messages received here may be processed by qpe application 501 Note that messages received here may be processed by qpe application
502 and emitted as signals, such as flush() and reload(). 502 and emitted as signals, such as flush() and reload().
503*/ 503*/
504 504
505/*! 505/*!
506 Constructs a QPEApplication just as you would construct 506 Constructs a QPEApplication just as you would construct
507 a QApplication, passing \a argc, \a argv, and \a t. 507 a QApplication, passing \a argc, \a argv, and \a t.
508 508
509 For applications, \a t should be the default, GuiClient. Only 509 For applications, \a t should be the default, GuiClient. Only
510 the Qtopia server passes GuiServer. 510 the Qtopia server passes GuiServer.
511*/ 511*/
512QPEApplication::QPEApplication( int & argc, char **argv, Type t ) 512QPEApplication::QPEApplication( int & argc, char **argv, Type t )
513 : QApplication( argc, argv, t ) 513 : QApplication( argc, argv, t )
514{ 514{
515 d = new QPEApplicationData; 515 d = new QPEApplicationData;
516 d->loadTextCodecs(); 516 d->loadTextCodecs();
517 d->loadImageCodecs(); 517 d->loadImageCodecs();
518 int dw = desktop() ->width(); 518 int dw = desktop() ->width();
519 519
520 if ( dw < 200 ) { 520 if ( dw < 200 ) {
521 setFont( QFont( "vera", 8 ) ); 521 setFont( QFont( "vera", 8 ) );
522 AppLnk::setSmallIconSize( 10 ); 522 AppLnk::setSmallIconSize( 10 );
523 AppLnk::setBigIconSize( 28 ); 523 AppLnk::setBigIconSize( 28 );
524 } 524 }
525 else if ( dw > 600 ) { 525 else if ( dw > 600 ) {
526 setFont( QFont( "vera", 16 ) ); 526 setFont( QFont( "vera", 16 ) );
527 AppLnk::setSmallIconSize( 24 ); 527 AppLnk::setSmallIconSize( 24 );
528 AppLnk::setBigIconSize( 48 ); 528 AppLnk::setBigIconSize( 48 );
529 } 529 }
530 else if ( dw > 200 ) { 530 else if ( dw > 200 ) {
531 setFont( QFont( "vera", 10 ) ); 531 setFont( QFont( "vera", 10 ) );
532 AppLnk::setSmallIconSize( 14 ); 532 AppLnk::setSmallIconSize( 14 );
533 AppLnk::setBigIconSize( 32 ); 533 AppLnk::setBigIconSize( 32 );
534 } 534 }
535 535
536 536
537 QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory ); 537 QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory );
538 538
539 connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) ); 539 connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) );
540#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 540#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
541 541
542 QString qcopfn( "/tmp/qcop-msg-" ); 542 QString qcopfn( "/tmp/qcop-msg-" );
543 qcopfn += QString( argv[ 0 ] ); // append command name 543 qcopfn += QString( argv[ 0 ] ); // append command name
544 544
545 QFile f( qcopfn ); 545 QFile f( qcopfn );
546 if ( f.open( IO_ReadOnly ) ) { 546 if ( f.open( IO_ReadOnly ) ) {
547 flock( f.handle(), LOCK_EX ); 547 flock( f.handle(), LOCK_EX );
548 } 548 }
549 549
550 sysChannel = new QCopChannel( "QPE/System", this ); 550 sysChannel = new QCopChannel( "QPE/System", this );
551 connect( sysChannel, SIGNAL( received( const QCString &, const QByteArray & ) ), 551 connect( sysChannel, SIGNAL( received( const QCString &, const QByteArray & ) ),
552 this, SLOT( systemMessage( const QCString &, const QByteArray & ) ) ); 552 this, SLOT( systemMessage( const QCString &, const QByteArray & ) ) );
553 553
554 QCString channel = QCString( argv[ 0 ] ); 554 QCString channel = QCString( argv[ 0 ] );
555 channel.replace( QRegExp( ".*/" ), "" ); 555 channel.replace( QRegExp( ".*/" ), "" );
556 d->appName = channel; 556 d->appName = channel;
557 channel = "QPE/Application/" + channel; 557 channel = "QPE/Application/" + channel;
558 pidChannel = new QCopChannel( channel, this ); 558 pidChannel = new QCopChannel( channel, this );
559 connect( pidChannel, SIGNAL( received( const QCString &, const QByteArray & ) ), 559 connect( pidChannel, SIGNAL( received( const QCString &, const QByteArray & ) ),
560 this, SLOT( pidMessage( const QCString &, const QByteArray & ) ) ); 560 this, SLOT( pidMessage( const QCString &, const QByteArray & ) ) );
561 561
562 if ( f.isOpen() ) { 562 if ( f.isOpen() ) {
563 d->keep_running = FALSE; 563 d->keep_running = FALSE;
564 QDataStream ds( &f ); 564 QDataStream ds( &f );
565 QCString channel, message; 565 QCString channel, message;
566 QByteArray data; 566 QByteArray data;
567 while ( !ds.atEnd() ) { 567 while ( !ds.atEnd() ) {
568 ds >> channel >> message >> data; 568 ds >> channel >> message >> data;
569 d->enqueueQCop( channel, message, data ); 569 d->enqueueQCop( channel, message, data );
570 } 570 }
571 571
572 flock( f.handle(), LOCK_UN ); 572 flock( f.handle(), LOCK_UN );
573 f.close(); 573 f.close();
574 f.remove(); 574 f.remove();
575 } 575 }
576 576
577 for ( int a = 0; a < argc; a++ ) { 577 for ( int a = 0; a < argc; a++ ) {
578 if ( qstrcmp( argv[ a ], "-preload" ) == 0 ) { 578 if ( qstrcmp( argv[ a ], "-preload" ) == 0 ) {
579 argv[ a ] = argv[ a + 1 ]; 579 argv[ a ] = argv[ a + 1 ];
580 a++; 580 a++;
581 d->preloaded = TRUE; 581 d->preloaded = TRUE;
582 argc -= 1; 582 argc -= 1;
583 } 583 }
584 else if ( qstrcmp( argv[ a ], "-preload-show" ) == 0 ) { 584 else if ( qstrcmp( argv[ a ], "-preload-show" ) == 0 ) {
585 argv[ a ] = argv[ a + 1 ]; 585 argv[ a ] = argv[ a + 1 ];
586 a++; 586 a++;
587 d->preloaded = TRUE; 587 d->preloaded = TRUE;
588 d->forceshow = TRUE; 588 d->forceshow = TRUE;
589 argc -= 1; 589 argc -= 1;
590 } 590 }
591 } 591 }
592 592
593 /* overide stored arguments */ 593 /* overide stored arguments */
594 setArgs( argc, argv ); 594 setArgs( argc, argv );
595 595
596#endif 596#endif
597 597
598 // qwsSetDecoration( new QPEDecoration() ); 598 // qwsSetDecoration( new QPEDecoration() );
599 599
600#ifndef QT_NO_TRANSLATION 600#ifndef QT_NO_TRANSLATION
601 601
602 QStringList langs = Global::languageList(); 602 QStringList langs = Global::languageList();
603 for ( QStringList::ConstIterator it = langs.begin(); it != langs.end(); ++it ) { 603 for ( QStringList::ConstIterator it = langs.begin(); it != langs.end(); ++it ) {
604 QString lang = *it; 604 QString lang = *it;
605 605
606 QTranslator * trans; 606 installTranslation( lang + "/libopie.qm");
607 QString tfn; 607 installTranslation( lang + "/libqpe.qm" );
608 installTranslation( lang + "/" + d->appName + ".qm" );
608 609
609 trans = new QTranslator( this );
610 tfn = qpeDir() + "/i18n/" + lang + "/libqpe.qm";
611 if ( trans->load( tfn ) )
612 installTranslator( trans );
613 else
614 delete trans;
615
616 trans = new QTranslator( this );
617 tfn = qpeDir() + "/i18n/" + lang + "/" + d->appName + ".qm";
618 if ( trans->load( tfn ) )
619 installTranslator( trans );
620 else
621 delete trans;
622 610
623 //###language/font hack; should look it up somewhere 611 //###language/font hack; should look it up somewhere
624#ifdef QWS 612#ifdef QWS
625 613
626 if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) { 614 if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) {
627 QFont fn = FontManager::unicodeFont( FontManager::Proportional ); 615 QFont fn = FontManager::unicodeFont( FontManager::Proportional );
628 setFont( fn ); 616 setFont( fn );
629 } 617 }
630#endif 618#endif
631 619
632 } 620 }
633#endif 621#endif
634 622
635 applyStyle(); 623 applyStyle();
636 624
637 if ( type() == GuiServer ) { 625 if ( type() == GuiServer ) {
638 setVolume(); 626 setVolume();
639 } 627 }
640 628
641 installEventFilter( this ); 629 installEventFilter( this );
642 630
643 QPEMenuToolFocusManager::initialize(); 631 QPEMenuToolFocusManager::initialize();
644 632
645#ifdef QT_NO_QWS_CURSOR 633#ifdef QT_NO_QWS_CURSOR
646 // if we have no cursor, probably don't want tooltips 634 // if we have no cursor, probably don't want tooltips
647 QToolTip::setEnabled( FALSE ); 635 QToolTip::setEnabled( FALSE );
648#endif 636#endif
649} 637}
650 638
651static QPtrDict<void>* inputMethodDict = 0; 639static QPtrDict<void>* inputMethodDict = 0;
652static void createInputMethodDict() 640static void createInputMethodDict()
653{ 641{
654 if ( !inputMethodDict ) 642 if ( !inputMethodDict )
655 inputMethodDict = new QPtrDict<void>; 643 inputMethodDict = new QPtrDict<void>;
656} 644}
657 645
658/*! 646/*!
659 Returns the currently set hint to the system as to whether 647 Returns the currently set hint to the system as to whether
660 widget \a w has any use for text input methods. 648 widget \a w has any use for text input methods.
661 649
662 650
663 \sa setInputMethodHint() InputMethodHint 651 \sa setInputMethodHint() InputMethodHint
664*/ 652*/
665QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w ) 653QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w )
666{ 654{
667 if ( inputMethodDict && w ) 655 if ( inputMethodDict && w )
668 return ( InputMethodHint ) ( int ) inputMethodDict->find( w ); 656 return ( InputMethodHint ) ( int ) inputMethodDict->find( w );
669 return Normal; 657 return Normal;
670} 658}
671 659
672/*! 660/*!
673 \enum QPEApplication::InputMethodHint 661 \enum QPEApplication::InputMethodHint
674 662
675 \value Normal the application sometimes needs text input (the default). 663 \value Normal the application sometimes needs text input (the default).
676 \value AlwaysOff the application never needs text input. 664 \value AlwaysOff the application never needs text input.
677 \value AlwaysOn the application always needs text input. 665 \value AlwaysOn the application always needs text input.
678*/ 666*/
679 667
680/*! 668/*!
681 Hints to the system that widget \a w has use for text input methods 669 Hints to the system that widget \a w has use for text input methods
682 as specified by \a mode. 670 as specified by \a mode.
683 671
684 \sa inputMethodHint() InputMethodHint 672 \sa inputMethodHint() InputMethodHint
685*/ 673*/
686void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode ) 674void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode )
687{ 675{
688 createInputMethodDict(); 676 createInputMethodDict();
689 if ( mode == Normal ) { 677 if ( mode == Normal ) {
690 inputMethodDict->remove 678 inputMethodDict->remove
691 ( w ); 679 ( w );
692 } 680 }
693 else { 681 else {
694 inputMethodDict->insert( w, ( void* ) mode ); 682 inputMethodDict->insert( w, ( void* ) mode );
695 } 683 }
696} 684}
697 685
698class HackDialog : public QDialog 686class HackDialog : public QDialog
699{ 687{
700public: 688public:
701 void acceptIt() 689 void acceptIt()
702 { 690 {
703 accept(); 691 accept();
704 } 692 }
705 void rejectIt() 693 void rejectIt()
706 { 694 {
707 reject(); 695 reject();
708 } 696 }
709}; 697};
710 698
711 699
712void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key ) 700void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key )
713{ 701{
714 // specialised actions for certain widgets. May want to 702 // specialised actions for certain widgets. May want to
715 // add more stuff here. 703 // add more stuff here.
716 if ( activePopupWidget() && activePopupWidget() ->inherits( "QListBox" ) 704 if ( activePopupWidget() && activePopupWidget() ->inherits( "QListBox" )
717 && activePopupWidget() ->parentWidget() 705 && activePopupWidget() ->parentWidget()
718 && activePopupWidget() ->parentWidget() ->inherits( "QComboBox" ) ) 706 && activePopupWidget() ->parentWidget() ->inherits( "QComboBox" ) )
719 key = Qt::Key_Return; 707 key = Qt::Key_Return;
720 708
721 if ( activePopupWidget() && activePopupWidget() ->inherits( "QPopupMenu" ) ) 709 if ( activePopupWidget() && activePopupWidget() ->inherits( "QPopupMenu" ) )
722 key = Qt::Key_Return; 710 key = Qt::Key_Return;
723 711
724#ifdef QWS 712#ifdef QWS
725 713
726 ke->simpleData.keycode = key; 714 ke->simpleData.keycode = key;
727#endif 715#endif
728} 716}
729 717
730class HackWidget : public QWidget 718class HackWidget : public QWidget
731{ 719{
732public: 720public:
733 bool needsOk() 721 bool needsOk()
734 { 722 {
735 return ( getWState() & WState_Reserved1 ); 723 return ( getWState() & WState_Reserved1 );
736 } 724 }
737}; 725};
738 726
739/*! 727/*!
740 \internal 728 \internal
741*/ 729*/
742 730
743#ifdef QWS 731#ifdef QWS
744bool QPEApplication::qwsEventFilter( QWSEvent * e ) 732bool QPEApplication::qwsEventFilter( QWSEvent * e )
745{ 733{
746 if ( !d->notbusysent && e->type == QWSEvent::Focus ) { 734 if ( !d->notbusysent && e->type == QWSEvent::Focus ) {
747 if ( qApp->type() != QApplication::GuiServer ) { 735 if ( qApp->type() != QApplication::GuiServer ) {
748 QCopEnvelope e( "QPE/System", "notBusy(QString)" ); 736 QCopEnvelope e( "QPE/System", "notBusy(QString)" );
749 e << d->appName; 737 e << d->appName;
750 } 738 }
751 d->notbusysent = TRUE; 739 d->notbusysent = TRUE;
752 } 740 }
753 if ( type() == GuiServer ) { 741 if ( type() == GuiServer ) {
754 switch ( e->type ) { 742 switch ( e->type ) {
755 case QWSEvent::Mouse: 743 case QWSEvent::Mouse:
756 if ( e->asMouse() ->simpleData.state && !QWidget::find( e->window() ) ) 744 if ( e->asMouse() ->simpleData.state && !QWidget::find( e->window() ) )
757 emit clientMoused(); 745 emit clientMoused();
758 break; 746 break;
759 default: 747 default:
760 break; 748 break;
761 } 749 }
762 } 750 }
763 if ( e->type == QWSEvent::Key ) { 751 if ( e->type == QWSEvent::Key ) {
764 QWSKeyEvent *ke = ( QWSKeyEvent * ) e; 752 QWSKeyEvent *ke = ( QWSKeyEvent * ) e;
765 if ( ke->simpleData.keycode == Qt::Key_F33 ) { 753 if ( ke->simpleData.keycode == Qt::Key_F33 ) {
766 // Use special "OK" key to press "OK" on top level widgets 754 // Use special "OK" key to press "OK" on top level widgets
767 QWidget * active = activeWindow(); 755 QWidget * active = activeWindow();
768 QWidget *popup = 0; 756 QWidget *popup = 0;
769 if ( active && active->isPopup() ) { 757 if ( active && active->isPopup() ) {
770 popup = active; 758 popup = active;
771 active = active->parentWidget(); 759 active = active->parentWidget();
772 } 760 }
773 if ( active && ( int ) active->winId() == ke->simpleData.window && 761 if ( active && ( int ) active->winId() == ke->simpleData.window &&
774 !active->testWFlags( WStyle_Customize | WType_Popup | WType_Desktop ) ) { 762 !active->testWFlags( WStyle_Customize | WType_Popup | WType_Desktop ) ) {
775 if ( ke->simpleData.is_press ) { 763 if ( ke->simpleData.is_press ) {
776 if ( popup ) 764 if ( popup )
777 popup->close(); 765 popup->close();
778 if ( active->inherits( "QDialog" ) ) { 766 if ( active->inherits( "QDialog" ) ) {
779 HackDialog * d = ( HackDialog * ) active; 767 HackDialog * d = ( HackDialog * ) active;
780 d->acceptIt(); 768 d->acceptIt();
781 return TRUE; 769 return TRUE;
782 } 770 }
783 else if ( ( ( HackWidget * ) active ) ->needsOk() ) { 771 else if ( ( ( HackWidget * ) active ) ->needsOk() ) {
784 QSignal s; 772 QSignal s;
785 s.connect( active, SLOT( accept() ) ); 773 s.connect( active, SLOT( accept() ) );
786 s.activate(); 774 s.activate();
787 } 775 }
788 else { 776 else {
789 // do the same as with the select key: Map to the default action of the widget: 777 // do the same as with the select key: Map to the default action of the widget:
790 mapToDefaultAction( ke, Qt::Key_Return ); 778 mapToDefaultAction( ke, Qt::Key_Return );
791 } 779 }
792 } 780 }
793 } 781 }
794 } 782 }
795 else if ( ke->simpleData.keycode == Qt::Key_F30 ) { 783 else if ( ke->simpleData.keycode == Qt::Key_F30 ) {
796 // Use special "select" key to do whatever default action a widget has 784 // Use special "select" key to do whatever default action a widget has
797 mapToDefaultAction( ke, Qt::Key_Space ); 785 mapToDefaultAction( ke, Qt::Key_Space );
798 } 786 }
799 else if ( ke->simpleData.keycode == Qt::Key_Escape && 787 else if ( ke->simpleData.keycode == Qt::Key_Escape &&
800 ke->simpleData.is_press ) { 788 ke->simpleData.is_press ) {
801 // Escape key closes app if focus on toplevel 789 // Escape key closes app if focus on toplevel
802 QWidget * active = activeWindow(); 790 QWidget * active = activeWindow();
803 if ( active && active->testWFlags( WType_TopLevel ) && 791 if ( active && active->testWFlags( WType_TopLevel ) &&
804 ( int ) active->winId() == ke->simpleData.window && 792 ( int ) active->winId() == ke->simpleData.window &&
805 !active->testWFlags( WStyle_Dialog | WStyle_Customize | WType_Popup | WType_Desktop ) ) { 793 !active->testWFlags( WStyle_Dialog | WStyle_Customize | WType_Popup | WType_Desktop ) ) {
806 if ( active->inherits( "QDialog" ) ) { 794 if ( active->inherits( "QDialog" ) ) {
807 HackDialog * d = ( HackDialog * ) active; 795 HackDialog * d = ( HackDialog * ) active;
808 d->rejectIt(); 796 d->rejectIt();
809 return TRUE; 797 return TRUE;
810 } 798 }
811 else if ( strcmp( argv() [ 0 ], "embeddedkonsole" ) != 0 ) { 799 else if ( strcmp( argv() [ 0 ], "embeddedkonsole" ) != 0 ) {
812 active->close(); 800 active->close();
813 } 801 }
814 } 802 }
815 } 803 }
816 else if ( ke->simpleData.keycode >= Qt::Key_F1 && ke->simpleData.keycode <= Qt::Key_F29 ) { 804 else if ( ke->simpleData.keycode >= Qt::Key_F1 && ke->simpleData.keycode <= Qt::Key_F29 ) {
817 // this should be if ( ODevice::inst ( )-> buttonForKeycode ( ... )) 805 // this should be if ( ODevice::inst ( )-> buttonForKeycode ( ... ))
818 // but we cannot access libopie function within libqpe :( 806 // but we cannot access libopie function within libqpe :(
819 807
820 QWidget * active = activeWindow ( ); 808 QWidget * active = activeWindow ( );
821 if ( active && ((int) active-> winId ( ) == ke-> simpleData.window )) { 809 if ( active && ((int) active-> winId ( ) == ke-> simpleData.window )) {
822 if ( d-> kbgrabbed ) { // we grabbed the keyboard 810 if ( d-> kbgrabbed ) { // we grabbed the keyboard
823 QChar ch ( ke-> simpleData.unicode ); 811 QChar ch ( ke-> simpleData.unicode );
824 QKeyEvent qke ( ke-> simpleData. is_press ? QEvent::KeyPress : QEvent::KeyRelease, 812 QKeyEvent qke ( ke-> simpleData. is_press ? QEvent::KeyPress : QEvent::KeyRelease,
825 ke-> simpleData.keycode, 813 ke-> simpleData.keycode,
826 ch. latin1 ( ), 814 ch. latin1 ( ),
827 ke-> simpleData.modifiers, 815 ke-> simpleData.modifiers,
828 QString ( ch ), 816 QString ( ch ),
829 ke-> simpleData.is_auto_repeat, 1 ); 817 ke-> simpleData.is_auto_repeat, 1 );
830 818
831 QObject *which = QWidget::keyboardGrabber ( ); 819 QObject *which = QWidget::keyboardGrabber ( );
832 if ( !which ) 820 if ( !which )
833 which = QApplication::focusWidget ( ); 821 which = QApplication::focusWidget ( );
834 if ( !which ) 822 if ( !which )
835 which = QApplication::activeWindow ( ); 823 which = QApplication::activeWindow ( );
836 if ( !which ) 824 if ( !which )
837 which = qApp; 825 which = qApp;
838 826
839 QApplication::sendEvent ( which, &qke ); 827 QApplication::sendEvent ( which, &qke );
840 } 828 }
841 else { // we didn't grab the keyboard, so send the event to the launcher 829 else { // we didn't grab the keyboard, so send the event to the launcher
842 QCopEnvelope e ( "QPE/Launcher", "deviceButton(int,int,int)" ); 830 QCopEnvelope e ( "QPE/Launcher", "deviceButton(int,int,int)" );
843 e << int( ke-> simpleData.keycode ) << int( ke-> simpleData. is_press ) << int( ke-> simpleData.is_auto_repeat ); 831 e << int( ke-> simpleData.keycode ) << int( ke-> simpleData. is_press ) << int( ke-> simpleData.is_auto_repeat );
844 } 832 }
845 } 833 }
846 return true; 834 return true;
847 } 835 }
848 } 836 }
849 if ( e->type == QWSEvent::Focus ) { 837 if ( e->type == QWSEvent::Focus ) {
850 QWSFocusEvent * fe = ( QWSFocusEvent* ) e; 838 QWSFocusEvent * fe = ( QWSFocusEvent* ) e;
851 if ( !fe->simpleData.get_focus ) { 839 if ( !fe->simpleData.get_focus ) {
852 QWidget * active = activeWindow(); 840 QWidget * active = activeWindow();
853 while ( active && active->isPopup() ) { 841 while ( active && active->isPopup() ) {
854 active->close(); 842 active->close();
855 active = activeWindow(); 843 active = activeWindow();
856 } 844 }
857 } 845 }
858 else { 846 else {
859 // make sure our modal widget is ALWAYS on top 847 // make sure our modal widget is ALWAYS on top
860 QWidget *topm = activeModalWidget(); 848 QWidget *topm = activeModalWidget();
861 if ( topm ) { 849 if ( topm ) {
862 topm->raise(); 850 topm->raise();
863 } 851 }
864 } 852 }
865 if ( fe->simpleData.get_focus && inputMethodDict ) { 853 if ( fe->simpleData.get_focus && inputMethodDict ) {
866 InputMethodHint m = inputMethodHint( QWidget::find( e->window() ) ); 854 InputMethodHint m = inputMethodHint( QWidget::find( e->window() ) );
867 if ( m == AlwaysOff ) 855 if ( m == AlwaysOff )
868 Global::hideInputMethod(); 856 Global::hideInputMethod();
869 if ( m == AlwaysOn ) 857 if ( m == AlwaysOn )
870 Global::showInputMethod(); 858 Global::showInputMethod();
871 } 859 }
872 } 860 }
873 861
874 862
875 return QApplication::qwsEventFilter( e ); 863 return QApplication::qwsEventFilter( e );
876} 864}
877#endif 865#endif
@@ -1474,344 +1462,356 @@ void QPEApplication::prepareForTermination( bool willrestart )
1474 pix.convertFromImage( img.smoothScale( 1 * img.width(), 1 * img.height() ) ); 1462 pix.convertFromImage( img.smoothScale( 1 * img.width(), 1 * img.height() ) );
1475 QLabel *lblWait = new QLabel( 0, "wait hack!", QWidget::WStyle_Customize | 1463 QLabel *lblWait = new QLabel( 0, "wait hack!", QWidget::WStyle_Customize |
1476 QWidget::WStyle_NoBorder | QWidget::WStyle_Tool ); 1464 QWidget::WStyle_NoBorder | QWidget::WStyle_Tool );
1477 lblWait->setPixmap( pix ); 1465 lblWait->setPixmap( pix );
1478 lblWait->setAlignment( QWidget::AlignCenter ); 1466 lblWait->setAlignment( QWidget::AlignCenter );
1479 lblWait->show(); 1467 lblWait->show();
1480 lblWait->showMaximized(); 1468 lblWait->showMaximized();
1481 } 1469 }
1482#ifndef SINGLE_APP 1470#ifndef SINGLE_APP
1483 { QCopEnvelope envelope( "QPE/System", "forceQuit()" ); 1471 { QCopEnvelope envelope( "QPE/System", "forceQuit()" );
1484 } 1472 }
1485 processEvents(); // ensure the message goes out. 1473 processEvents(); // ensure the message goes out.
1486 sleep( 1 ); // You have 1 second to comply. 1474 sleep( 1 ); // You have 1 second to comply.
1487#endif 1475#endif
1488} 1476}
1489 1477
1490/*! 1478/*!
1491 \internal 1479 \internal
1492*/ 1480*/
1493void QPEApplication::shutdown() 1481void QPEApplication::shutdown()
1494{ 1482{
1495 // Implement in server's QPEApplication subclass 1483 // Implement in server's QPEApplication subclass
1496} 1484}
1497 1485
1498/*! 1486/*!
1499 \internal 1487 \internal
1500*/ 1488*/
1501void QPEApplication::restart() 1489void QPEApplication::restart()
1502{ 1490{
1503 // Implement in server's QPEApplication subclass 1491 // Implement in server's QPEApplication subclass
1504} 1492}
1505 1493
1506static QPtrDict<void>* stylusDict = 0; 1494static QPtrDict<void>* stylusDict = 0;
1507static void createDict() 1495static void createDict()
1508{ 1496{
1509 if ( !stylusDict ) 1497 if ( !stylusDict )
1510 stylusDict = new QPtrDict<void>; 1498 stylusDict = new QPtrDict<void>;
1511} 1499}
1512 1500
1513/*! 1501/*!
1514 Returns the current StylusMode for widget \a w. 1502 Returns the current StylusMode for widget \a w.
1515 1503
1516 \sa setStylusOperation() StylusMode 1504 \sa setStylusOperation() StylusMode
1517*/ 1505*/
1518QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w ) 1506QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w )
1519{ 1507{
1520 if ( stylusDict ) 1508 if ( stylusDict )
1521 return ( StylusMode ) ( int ) stylusDict->find( w ); 1509 return ( StylusMode ) ( int ) stylusDict->find( w );
1522 return LeftOnly; 1510 return LeftOnly;
1523} 1511}
1524 1512
1525/*! 1513/*!
1526 \enum QPEApplication::StylusMode 1514 \enum QPEApplication::StylusMode
1527 1515
1528 \value LeftOnly the stylus only generates LeftButton 1516 \value LeftOnly the stylus only generates LeftButton
1529 events (the default). 1517 events (the default).
1530 \value RightOnHold the stylus generates RightButton events 1518 \value RightOnHold the stylus generates RightButton events
1531 if the user uses the press-and-hold gesture. 1519 if the user uses the press-and-hold gesture.
1532 1520
1533 \sa setStylusOperation() stylusOperation() 1521 \sa setStylusOperation() stylusOperation()
1534*/ 1522*/
1535 1523
1536/*! 1524/*!
1537 Causes widget \a w to receive mouse events according to the stylus 1525 Causes widget \a w to receive mouse events according to the stylus
1538 \a mode. 1526 \a mode.
1539 1527
1540 \sa stylusOperation() StylusMode 1528 \sa stylusOperation() StylusMode
1541*/ 1529*/
1542void QPEApplication::setStylusOperation( QWidget * w, StylusMode mode ) 1530void QPEApplication::setStylusOperation( QWidget * w, StylusMode mode )
1543{ 1531{
1544 createDict(); 1532 createDict();
1545 if ( mode == LeftOnly ) { 1533 if ( mode == LeftOnly ) {
1546 stylusDict->remove 1534 stylusDict->remove
1547 ( w ); 1535 ( w );
1548 w->removeEventFilter( qApp ); 1536 w->removeEventFilter( qApp );
1549 } 1537 }
1550 else { 1538 else {
1551 stylusDict->insert( w, ( void* ) mode ); 1539 stylusDict->insert( w, ( void* ) mode );
1552 connect( w, SIGNAL( destroyed() ), qApp, SLOT( removeSenderFromStylusDict() ) ); 1540 connect( w, SIGNAL( destroyed() ), qApp, SLOT( removeSenderFromStylusDict() ) );
1553 w->installEventFilter( qApp ); 1541 w->installEventFilter( qApp );
1554 } 1542 }
1555} 1543}
1556 1544
1557 1545
1558/*! 1546/*!
1559 \reimp 1547 \reimp
1560*/ 1548*/
1561bool QPEApplication::eventFilter( QObject *o, QEvent *e ) 1549bool QPEApplication::eventFilter( QObject *o, QEvent *e )
1562{ 1550{
1563 if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) { 1551 if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) {
1564 QMouseEvent * me = ( QMouseEvent* ) e; 1552 QMouseEvent * me = ( QMouseEvent* ) e;
1565 StylusMode mode = (StylusMode)(int)stylusDict->find(o); 1553 StylusMode mode = (StylusMode)(int)stylusDict->find(o);
1566 switch (mode) { 1554 switch (mode) {
1567 case RightOnHold: 1555 case RightOnHold:
1568 switch ( me->type() ) { 1556 switch ( me->type() ) {
1569 case QEvent::MouseButtonPress: 1557 case QEvent::MouseButtonPress:
1570 if ( me->button() == LeftButton ) { 1558 if ( me->button() == LeftButton ) {
1571 d->presstimer = startTimer(500); // #### pref. 1559 d->presstimer = startTimer(500); // #### pref.
1572 d->presswidget = (QWidget*)o; 1560 d->presswidget = (QWidget*)o;
1573 d->presspos = me->pos(); 1561 d->presspos = me->pos();
1574 d->rightpressed = FALSE; 1562 d->rightpressed = FALSE;
1575 } 1563 }
1576 break; 1564 break;
1577 case QEvent::MouseMove: 1565 case QEvent::MouseMove:
1578 if (d->presstimer && (me->pos() - d->presspos).manhattanLength() > 8) { 1566 if (d->presstimer && (me->pos() - d->presspos).manhattanLength() > 8) {
1579 killTimer(d->presstimer); 1567 killTimer(d->presstimer);
1580 d->presstimer = 0; 1568 d->presstimer = 0;
1581 } 1569 }
1582 break; 1570 break;
1583 case QEvent::MouseButtonRelease: 1571 case QEvent::MouseButtonRelease:
1584 if ( me->button() == LeftButton ) { 1572 if ( me->button() == LeftButton ) {
1585 if ( d->presstimer ) { 1573 if ( d->presstimer ) {
1586 killTimer(d->presstimer); 1574 killTimer(d->presstimer);
1587 d->presstimer = 0; 1575 d->presstimer = 0;
1588 } 1576 }
1589 if ( d->rightpressed && d->presswidget ) { 1577 if ( d->rightpressed && d->presswidget ) {
1590 // Right released 1578 // Right released
1591 postEvent( d->presswidget, 1579 postEvent( d->presswidget,
1592 new QMouseEvent( QEvent::MouseButtonRelease, me->pos(), 1580 new QMouseEvent( QEvent::MouseButtonRelease, me->pos(),
1593 RightButton, LeftButton + RightButton ) ); 1581 RightButton, LeftButton + RightButton ) );
1594 // Left released, off-widget 1582 // Left released, off-widget
1595 postEvent( d->presswidget, 1583 postEvent( d->presswidget,
1596 new QMouseEvent( QEvent::MouseMove, QPoint( -1, -1), 1584 new QMouseEvent( QEvent::MouseMove, QPoint( -1, -1),
1597 LeftButton, LeftButton ) ); 1585 LeftButton, LeftButton ) );
1598 postEvent( d->presswidget, 1586 postEvent( d->presswidget,
1599 new QMouseEvent( QEvent::MouseButtonRelease, QPoint( -1, -1), 1587 new QMouseEvent( QEvent::MouseButtonRelease, QPoint( -1, -1),
1600 LeftButton, LeftButton ) ); 1588 LeftButton, LeftButton ) );
1601 d->rightpressed = FALSE; 1589 d->rightpressed = FALSE;
1602 return TRUE; // don't send the real Left release 1590 return TRUE; // don't send the real Left release
1603 } 1591 }
1604 } 1592 }
1605 break; 1593 break;
1606 default: 1594 default:
1607 break; 1595 break;
1608 } 1596 }
1609 break; 1597 break;
1610 default: 1598 default:
1611 ; 1599 ;
1612 } 1600 }
1613 } 1601 }
1614 else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { 1602 else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) {
1615 QKeyEvent *ke = (QKeyEvent *)e; 1603 QKeyEvent *ke = (QKeyEvent *)e;
1616 if ( ke->key() == Key_Enter ) { 1604 if ( ke->key() == Key_Enter ) {
1617 if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) { 1605 if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) {
1618 postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ', 1606 postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ',
1619 ke->state(), " ", ke->isAutoRepeat(), ke->count() ) ); 1607 ke->state(), " ", ke->isAutoRepeat(), ke->count() ) );
1620 return TRUE; 1608 return TRUE;
1621 } 1609 }
1622 } 1610 }
1623 } 1611 }
1624 return FALSE; 1612 return FALSE;
1625} 1613}
1626 1614
1627/*! 1615/*!
1628 \reimp 1616 \reimp
1629*/ 1617*/
1630void QPEApplication::timerEvent( QTimerEvent *e ) 1618void QPEApplication::timerEvent( QTimerEvent *e )
1631{ 1619{
1632 if ( e->timerId() == d->presstimer && d->presswidget ) { 1620 if ( e->timerId() == d->presstimer && d->presswidget ) {
1633 // Right pressed 1621 // Right pressed
1634 postEvent( d->presswidget, 1622 postEvent( d->presswidget,
1635 new QMouseEvent( QEvent::MouseButtonPress, d->presspos, 1623 new QMouseEvent( QEvent::MouseButtonPress, d->presspos,
1636 RightButton, LeftButton ) ); 1624 RightButton, LeftButton ) );
1637 killTimer( d->presstimer ); 1625 killTimer( d->presstimer );
1638 d->presstimer = 0; 1626 d->presstimer = 0;
1639 d->rightpressed = TRUE; 1627 d->rightpressed = TRUE;
1640 } 1628 }
1641} 1629}
1642 1630
1643void QPEApplication::removeSenderFromStylusDict() 1631void QPEApplication::removeSenderFromStylusDict()
1644{ 1632{
1645 stylusDict->remove 1633 stylusDict->remove
1646 ( ( void* ) sender() ); 1634 ( ( void* ) sender() );
1647 if ( d->presswidget == sender() ) 1635 if ( d->presswidget == sender() )
1648 d->presswidget = 0; 1636 d->presswidget = 0;
1649} 1637}
1650 1638
1651/*! 1639/*!
1652 \internal 1640 \internal
1653*/ 1641*/
1654bool QPEApplication::keyboardGrabbed() const 1642bool QPEApplication::keyboardGrabbed() const
1655{ 1643{
1656 return d->kbgrabbed; 1644 return d->kbgrabbed;
1657} 1645}
1658 1646
1659 1647
1660/*! 1648/*!
1661 Reverses the effect of grabKeyboard(). This is called automatically 1649 Reverses the effect of grabKeyboard(). This is called automatically
1662 on program exit. 1650 on program exit.
1663*/ 1651*/
1664void QPEApplication::ungrabKeyboard() 1652void QPEApplication::ungrabKeyboard()
1665{ 1653{
1666 ((QPEApplication *) qApp )-> d-> kbgrabbed = false; 1654 ((QPEApplication *) qApp )-> d-> kbgrabbed = false;
1667} 1655}
1668 1656
1669/*! 1657/*!
1670 Grabs the physical keyboard keys, e.g. the application's launching 1658 Grabs the physical keyboard keys, e.g. the application's launching
1671 keys. Instead of launching applications when these keys are pressed 1659 keys. Instead of launching applications when these keys are pressed
1672 the signals emitted are sent to this application instead. Some games 1660 the signals emitted are sent to this application instead. Some games
1673 programs take over the launch keys in this way to make interaction 1661 programs take over the launch keys in this way to make interaction
1674 easier. 1662 easier.
1675 1663
1676 \sa ungrabKeyboard() 1664 \sa ungrabKeyboard()
1677*/ 1665*/
1678void QPEApplication::grabKeyboard() 1666void QPEApplication::grabKeyboard()
1679{ 1667{
1680 ((QPEApplication *) qApp )-> d-> kbgrabbed = true; 1668 ((QPEApplication *) qApp )-> d-> kbgrabbed = true;
1681} 1669}
1682 1670
1683/*! 1671/*!
1684 \reimp 1672 \reimp
1685*/ 1673*/
1686int QPEApplication::exec() 1674int QPEApplication::exec()
1687{ 1675{
1688#ifndef QT_NO_COP 1676#ifndef QT_NO_COP
1689 d->sendQCopQ(); 1677 d->sendQCopQ();
1690#endif 1678#endif
1691 1679
1692 if ( d->keep_running ) 1680 if ( d->keep_running )
1693 //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() ) 1681 //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() )
1694 return QApplication::exec(); 1682 return QApplication::exec();
1695 1683
1696#ifndef QT_NO_COP 1684#ifndef QT_NO_COP
1697 1685
1698 { 1686 {
1699 QCopEnvelope e( "QPE/System", "closing(QString)" ); 1687 QCopEnvelope e( "QPE/System", "closing(QString)" );
1700 e << d->appName; 1688 e << d->appName;
1701 } 1689 }
1702#endif 1690#endif
1703 processEvents(); 1691 processEvents();
1704 return 0; 1692 return 0;
1705} 1693}
1706 1694
1707/*! 1695/*!
1708 \internal 1696 \internal
1709 External request for application to quit. Quits if possible without 1697 External request for application to quit. Quits if possible without
1710 loosing state. 1698 loosing state.
1711*/ 1699*/
1712void QPEApplication::tryQuit() 1700void QPEApplication::tryQuit()
1713{ 1701{
1714 if ( activeModalWidget() || strcmp( argv() [ 0 ], "embeddedkonsole" ) == 0 ) 1702 if ( activeModalWidget() || strcmp( argv() [ 0 ], "embeddedkonsole" ) == 0 )
1715 return ; // Inside modal loop or konsole. Too hard to save state. 1703 return ; // Inside modal loop or konsole. Too hard to save state.
1716#ifndef QT_NO_COP 1704#ifndef QT_NO_COP
1717 1705
1718 { 1706 {
1719 QCopEnvelope e( "QPE/System", "closing(QString)" ); 1707 QCopEnvelope e( "QPE/System", "closing(QString)" );
1720 e << d->appName; 1708 e << d->appName;
1721 } 1709 }
1722#endif 1710#endif
1723 processEvents(); 1711 processEvents();
1724 1712
1725 quit(); 1713 quit();
1726} 1714}
1727 1715
1728/*! 1716/*!
1729 \internal 1717 \internal
1718*/
1719void QPEApplication::installTranslation( const QString& baseName ) {
1720 QTranslator* trans = new QTranslator(this);
1721 QString tfn = qpeDir() + "/i18n/"+baseName;
1722 if ( trans->load( tfn ) )
1723 installTranslator( trans );
1724 else
1725 delete trans;
1726}
1727
1728/*!
1729 \internal
1730 User initiated quit. Makes the window 'Go Away'. If preloaded this means 1730 User initiated quit. Makes the window 'Go Away'. If preloaded this means
1731 hiding the window. If not it means quitting the application. 1731 hiding the window. If not it means quitting the application.
1732 As this is user initiated we don't need to check state. 1732 As this is user initiated we don't need to check state.
1733*/ 1733*/
1734void QPEApplication::hideOrQuit() 1734void QPEApplication::hideOrQuit()
1735{ 1735{
1736 processEvents(); 1736 processEvents();
1737 1737
1738 // If we are a preloaded application we don't actually quit, so emit 1738 // If we are a preloaded application we don't actually quit, so emit
1739 // a System message indicating we're quasi-closing. 1739 // a System message indicating we're quasi-closing.
1740 if ( d->preloaded && d->qpe_main_widget ) 1740 if ( d->preloaded && d->qpe_main_widget )
1741#ifndef QT_NO_COP 1741#ifndef QT_NO_COP
1742 1742
1743 { 1743 {
1744 QCopEnvelope e("QPE/System", "fastAppHiding(QString)" ); 1744 QCopEnvelope e("QPE/System", "fastAppHiding(QString)" );
1745 e << d->appName; 1745 e << d->appName;
1746 d->qpe_main_widget->hide(); 1746 d->qpe_main_widget->hide();
1747 } 1747 }
1748#endif 1748#endif
1749 else 1749 else
1750 quit(); 1750 quit();
1751} 1751}
1752 1752
1753 1753
1754#if defined(QT_QWS_IPAQ) || defined(QT_QWS_SL5XXX) 1754#if defined(QT_QWS_IPAQ) || defined(QT_QWS_SL5XXX)
1755 1755
1756// The libraries with the skiff package (and possibly others) have 1756// The libraries with the skiff package (and possibly others) have
1757// completely useless implementations of builtin new and delete that 1757// completely useless implementations of builtin new and delete that
1758// use about 50% of your CPU. Here we revert to the simple libc 1758// use about 50% of your CPU. Here we revert to the simple libc
1759// functions. 1759// functions.
1760 1760
1761void* operator new[]( size_t size ) 1761void* operator new[]( size_t size )
1762{ 1762{
1763 return malloc( size ); 1763 return malloc( size );
1764} 1764}
1765 1765
1766void* operator new( size_t size ) 1766void* operator new( size_t size )
1767{ 1767{
1768 return malloc( size ); 1768 return malloc( size );
1769} 1769}
1770 1770
1771void operator delete[]( void* p ) 1771void operator delete[]( void* p )
1772{ 1772{
1773 free( p ); 1773 free( p );
1774} 1774}
1775 1775
1776void operator delete[]( void* p, size_t /*size*/ ) 1776void operator delete[]( void* p, size_t /*size*/ )
1777{ 1777{
1778 free( p ); 1778 free( p );
1779} 1779}
1780 1780
1781 1781
1782void operator delete( void* p ) 1782void operator delete( void* p )
1783{ 1783{
1784 free( p ); 1784 free( p );
1785} 1785}
1786 1786
1787void operator delete( void* p, size_t /*size*/ ) 1787void operator delete( void* p, size_t /*size*/ )
1788{ 1788{
1789 free( p ); 1789 free( p );
1790} 1790}
1791 1791
1792#endif 1792#endif
1793 1793
1794#if ( QT_VERSION <= 230 ) && !defined(SINGLE_APP) 1794#if ( QT_VERSION <= 230 ) && !defined(SINGLE_APP)
1795#include <qwidgetlist.h> 1795#include <qwidgetlist.h>
1796#ifdef QWS 1796#ifdef QWS
1797#include <qgfx_qws.h> 1797#include <qgfx_qws.h>
1798extern QRect qt_maxWindowRect; 1798extern QRect qt_maxWindowRect;
1799void qt_setMaxWindowRect(const QRect& r ) 1799void qt_setMaxWindowRect(const QRect& r )
1800{ 1800{
1801 qt_maxWindowRect = qt_screen->mapFromDevice( r, 1801 qt_maxWindowRect = qt_screen->mapFromDevice( r,
1802 qt_screen->mapToDevice( QSize( qt_screen->width(), qt_screen->height() ) ) ); 1802 qt_screen->mapToDevice( QSize( qt_screen->width(), qt_screen->height() ) ) );
1803 // Re-resize any maximized windows 1803 // Re-resize any maximized windows
1804 QWidgetList* l = QApplication::topLevelWidgets(); 1804 QWidgetList* l = QApplication::topLevelWidgets();
1805 if ( l ) { 1805 if ( l ) {
1806 QWidget * w = l->first(); 1806 QWidget * w = l->first();
1807 while ( w ) { 1807 while ( w ) {
1808 if ( w->isVisible() && w->isMaximized() ) { 1808 if ( w->isVisible() && w->isMaximized() ) {
1809 w->showMaximized(); 1809 w->showMaximized();
1810 } 1810 }
1811 w = l->next(); 1811 w = l->next();
1812 } 1812 }
1813 delete l; 1813 delete l;
1814 } 1814 }
1815} 1815}
1816#endif 1816#endif
1817#endif 1817#endif