-rw-r--r-- | library/qpeapplication.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp index b1b7ed4..9286f9f 100644 --- a/library/qpeapplication.cpp +++ b/library/qpeapplication.cpp | |||
@@ -460,513 +460,515 @@ static void setTreble( int t = 0, int percent = -1 ) | |||
460 | 460 | ||
461 | /*! | 461 | /*! |
462 | \fn void QPEApplication::clockChanged( bool ampm ); | 462 | \fn void QPEApplication::clockChanged( bool ampm ); |
463 | 463 | ||
464 | This signal is emitted when the user changes the clock's style. If | 464 | This signal is emitted when the user changes the clock's style. If |
465 | \a ampm is TRUE, the user wants a 12-hour AM/PM clock, otherwise, | 465 | \a ampm is TRUE, the user wants a 12-hour AM/PM clock, otherwise, |
466 | they want a 24-hour clock. | 466 | they want a 24-hour clock. |
467 | */ | 467 | */ |
468 | 468 | ||
469 | /*! | 469 | /*! |
470 | \fn void QPEApplication::volumeChanged( bool muted ) | 470 | \fn void QPEApplication::volumeChanged( bool muted ) |
471 | 471 | ||
472 | This signal is emitted whenever the mute state is changed. If \a | 472 | This signal is emitted whenever the mute state is changed. If \a |
473 | muted is TRUE, then sound output has been muted. | 473 | muted is TRUE, then sound output has been muted. |
474 | */ | 474 | */ |
475 | 475 | ||
476 | /*! | 476 | /*! |
477 | \fn void QPEApplication::weekChanged( bool startOnMonday ) | 477 | \fn void QPEApplication::weekChanged( bool startOnMonday ) |
478 | 478 | ||
479 | This signal is emitted if the week start day is changed. If \a | 479 | This signal is emitted if the week start day is changed. If \a |
480 | startOnMonday is TRUE then the first day of the week is Monday; if | 480 | startOnMonday is TRUE then the first day of the week is Monday; if |
481 | \a startOnMonday is FALSE then the first day of the week is | 481 | \a startOnMonday is FALSE then the first day of the week is |
482 | Sunday. | 482 | Sunday. |
483 | */ | 483 | */ |
484 | 484 | ||
485 | /*! | 485 | /*! |
486 | \fn void QPEApplication::dateFormatChanged(DateFormat) | 486 | \fn void QPEApplication::dateFormatChanged(DateFormat) |
487 | 487 | ||
488 | This signal is emitted whenever the date format is changed. | 488 | This signal is emitted whenever the date format is changed. |
489 | */ | 489 | */ |
490 | 490 | ||
491 | /*! | 491 | /*! |
492 | \fn void QPEApplication::flush() | 492 | \fn void QPEApplication::flush() |
493 | 493 | ||
494 | ### | 494 | ### |
495 | */ | 495 | */ |
496 | 496 | ||
497 | /*! | 497 | /*! |
498 | \fn void QPEApplication::reload() | 498 | \fn void QPEApplication::reload() |
499 | 499 | ||
500 | */ | 500 | */ |
501 | 501 | ||
502 | 502 | ||
503 | 503 | ||
504 | void QPEApplication::processQCopFile() | 504 | void QPEApplication::processQCopFile() |
505 | { | 505 | { |
506 | QString qcopfn("/tmp/qcop-msg-"); | 506 | QString qcopfn("/tmp/qcop-msg-"); |
507 | qcopfn += d->appName; // append command name | 507 | qcopfn += d->appName; // append command name |
508 | 508 | ||
509 | QFile f(qcopfn); | 509 | QFile f(qcopfn); |
510 | if ( f.open(IO_ReadWrite) ) { | 510 | if ( f.open(IO_ReadWrite) ) { |
511 | #ifndef Q_OS_WIN32 | 511 | #ifndef Q_OS_WIN32 |
512 | flock(f.handle(), LOCK_EX); | 512 | flock(f.handle(), LOCK_EX); |
513 | #endif | 513 | #endif |
514 | QDataStream ds(&f); | 514 | QDataStream ds(&f); |
515 | QCString channel, message; | 515 | QCString channel, message; |
516 | QByteArray data; | 516 | QByteArray data; |
517 | while(!ds.atEnd()) { | 517 | while(!ds.atEnd()) { |
518 | ds >> channel >> message >> data; | 518 | ds >> channel >> message >> data; |
519 | d->enqueueQCop(channel,message,data); | 519 | d->enqueueQCop(channel,message,data); |
520 | } | 520 | } |
521 | ::ftruncate(f.handle(), 0); | 521 | ::ftruncate(f.handle(), 0); |
522 | #ifndef Q_OS_WIN32 | 522 | #ifndef Q_OS_WIN32 |
523 | f.flush(); | 523 | f.flush(); |
524 | flock(f.handle(), LOCK_UN); | 524 | flock(f.handle(), LOCK_UN); |
525 | #endif | 525 | #endif |
526 | } | 526 | } |
527 | #endif | 527 | #endif |
528 | } | 528 | } |
529 | 529 | ||
530 | 530 | ||
531 | /*! | 531 | /*! |
532 | \fn void QPEApplication::appMessage( const QCString& msg, const QByteArray& data ) | 532 | \fn void QPEApplication::appMessage( const QCString& msg, const QByteArray& data ) |
533 | 533 | ||
534 | This signal is emitted when a message is received on this | 534 | This signal is emitted when a message is received on this |
535 | application's QPE/Application/<i>appname</i> \link qcop.html | 535 | application's QPE/Application/<i>appname</i> \link qcop.html |
536 | QCop\endlink channel. | 536 | QCop\endlink channel. |
537 | 537 | ||
538 | The slot to which you connect this signal uses \a msg and \a data | 538 | The slot to which you connect this signal uses \a msg and \a data |
539 | in the following way: | 539 | in the following way: |
540 | 540 | ||
541 | \code | 541 | \code |
542 | void MyWidget::receive( const QCString& msg, const QByteArray& data ) | 542 | void MyWidget::receive( const QCString& msg, const QByteArray& data ) |
543 | { | 543 | { |
544 | QDataStream stream( data, IO_ReadOnly ); | 544 | QDataStream stream( data, IO_ReadOnly ); |
545 | if ( msg == "someMessage(int,int,int)" ) { | 545 | if ( msg == "someMessage(int,int,int)" ) { |
546 | int a,b,c; | 546 | int a,b,c; |
547 | stream >> a >> b >> c; | 547 | stream >> a >> b >> c; |
548 | ... | 548 | ... |
549 | } else if ( msg == "otherMessage(QString)" ) { | 549 | } else if ( msg == "otherMessage(QString)" ) { |
550 | ... | 550 | ... |
551 | } | 551 | } |
552 | } | 552 | } |
553 | \endcode | 553 | \endcode |
554 | 554 | ||
555 | \sa qcop.html | 555 | \sa qcop.html |
556 | Note that messages received here may be processed by qpe application | 556 | Note that messages received here may be processed by qpe application |
557 | and emitted as signals, such as flush() and reload(). | 557 | and emitted as signals, such as flush() and reload(). |
558 | */ | 558 | */ |
559 | 559 | ||
560 | /*! | 560 | /*! |
561 | Constructs a QPEApplication just as you would construct | 561 | Constructs a QPEApplication just as you would construct |
562 | a QApplication, passing \a argc, \a argv, and \a t. | 562 | a QApplication, passing \a argc, \a argv, and \a t. |
563 | 563 | ||
564 | For applications, \a t should be the default, GuiClient. Only | 564 | For applications, \a t should be the default, GuiClient. Only |
565 | the Qtopia server passes GuiServer. | 565 | the Qtopia server passes GuiServer. |
566 | */ | 566 | */ |
567 | QPEApplication::QPEApplication( int & argc, char **argv, Type t ) | 567 | QPEApplication::QPEApplication( int & argc, char **argv, Type t ) |
568 | : QApplication( hack(argc), argv, t ), pidChannel( 0 ) | 568 | : QApplication( hack(argc), argv, t ), pidChannel( 0 ) |
569 | { | 569 | { |
570 | d = new QPEApplicationData; | 570 | d = new QPEApplicationData; |
571 | d->loadTextCodecs(); | 571 | d->loadTextCodecs(); |
572 | d->loadImageCodecs(); | 572 | d->loadImageCodecs(); |
573 | int dw = desktop() ->width(); | 573 | int dw = desktop() ->width(); |
574 | 574 | ||
575 | if ( dw < 200 ) { | 575 | if ( dw < 200 ) { |
576 | setFont( QFont( "vera", 8 ) ); | 576 | setFont( QFont( "vera", 8 ) ); |
577 | AppLnk::setSmallIconSize( 10 ); | 577 | AppLnk::setSmallIconSize( 10 ); |
578 | AppLnk::setBigIconSize( 28 ); | 578 | AppLnk::setBigIconSize( 28 ); |
579 | } | 579 | } |
580 | #ifndef QT_QWS_SIMPAD | 580 | #ifndef QT_QWS_SIMPAD |
581 | else if ( dw > 600 ) { | 581 | else if ( dw > 600 ) { |
582 | setFont( QFont( "vera", 16 ) ); | 582 | setFont( QFont( "vera", 16 ) ); |
583 | AppLnk::setSmallIconSize( 24 ); | 583 | AppLnk::setSmallIconSize( 24 ); |
584 | AppLnk::setBigIconSize( 48 ); | 584 | AppLnk::setBigIconSize( 48 ); |
585 | } | 585 | } |
586 | #endif | 586 | #endif |
587 | else if ( dw > 200 ) { | 587 | else if ( dw > 200 ) { |
588 | setFont( QFont( "vera", 10 ) ); | 588 | setFont( QFont( "vera", 10 ) ); |
589 | AppLnk::setSmallIconSize( 14 ); | 589 | AppLnk::setSmallIconSize( 14 ); |
590 | AppLnk::setBigIconSize( 32 ); | 590 | AppLnk::setBigIconSize( 32 ); |
591 | } | 591 | } |
592 | 592 | ||
593 | QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory ); | 593 | QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory ); |
594 | 594 | ||
595 | connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) ); | 595 | connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) ); |
596 | 596 | ||
597 | 597 | ||
598 | sysChannel = new QCopChannel( "QPE/System", this ); | 598 | sysChannel = new QCopChannel( "QPE/System", this ); |
599 | connect( sysChannel, SIGNAL( received( const QCString &, const QByteArray & ) ), | 599 | connect( sysChannel, SIGNAL( received( const QCString &, const QByteArray & ) ), |
600 | this, SLOT( systemMessage( const QCString &, const QByteArray & ) ) ); | 600 | this, SLOT( systemMessage( const QCString &, const QByteArray & ) ) ); |
601 | 601 | ||
602 | /* COde now in initapp */ | 602 | /* COde now in initapp */ |
603 | #if 0 | 603 | #if 0 |
604 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 604 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
605 | 605 | ||
606 | QString qcopfn( "/tmp/qcop-msg-" ); | 606 | QString qcopfn( "/tmp/qcop-msg-" ); |
607 | qcopfn += QString( argv[ 0 ] ); // append command name | 607 | qcopfn += QString( argv[ 0 ] ); // append command name |
608 | 608 | ||
609 | QFile f( qcopfn ); | 609 | QFile f( qcopfn ); |
610 | if ( f.open( IO_ReadOnly ) ) { | 610 | if ( f.open( IO_ReadOnly ) ) { |
611 | flock( f.handle(), LOCK_EX ); | 611 | flock( f.handle(), LOCK_EX ); |
612 | } | 612 | } |
613 | 613 | ||
614 | 614 | ||
615 | 615 | ||
616 | QCString channel = QCString( argv[ 0 ] ); | 616 | QCString channel = QCString( argv[ 0 ] ); |
617 | channel.replace( QRegExp( ".*/" ), "" ); | 617 | channel.replace( QRegExp( ".*/" ), "" ); |
618 | d->appName = channel; | 618 | d->appName = channel; |
619 | channel = "QPE/Application/" + channel; | 619 | channel = "QPE/Application/" + channel; |
620 | pidChannel = new QCopChannel( channel, this ); | 620 | pidChannel = new QCopChannel( channel, this ); |
621 | connect( pidChannel, SIGNAL( received( const QCString &, const QByteArray & ) ), | 621 | connect( pidChannel, SIGNAL( received( const QCString &, const QByteArray & ) ), |
622 | this, SLOT( pidMessage( const QCString &, const QByteArray & ) ) ); | 622 | this, SLOT( pidMessage( const QCString &, const QByteArray & ) ) ); |
623 | 623 | ||
624 | if ( f.isOpen() ) { | 624 | if ( f.isOpen() ) { |
625 | d->keep_running = FALSE; | 625 | d->keep_running = FALSE; |
626 | QDataStream ds( &f ); | 626 | QDataStream ds( &f ); |
627 | QCString channel, message; | 627 | QCString channel, message; |
628 | QByteArray data; | 628 | QByteArray data; |
629 | while ( !ds.atEnd() ) { | 629 | while ( !ds.atEnd() ) { |
630 | ds >> channel >> message >> data; | 630 | ds >> channel >> message >> data; |
631 | d->enqueueQCop( channel, message, data ); | 631 | d->enqueueQCop( channel, message, data ); |
632 | } | 632 | } |
633 | 633 | ||
634 | flock( f.handle(), LOCK_UN ); | 634 | flock( f.handle(), LOCK_UN ); |
635 | f.close(); | 635 | f.close(); |
636 | f.remove(); | 636 | f.remove(); |
637 | } | 637 | } |
638 | 638 | ||
639 | for ( int a = 0; a < argc; a++ ) { | 639 | for ( int a = 0; a < argc; a++ ) { |
640 | if ( qstrcmp( argv[ a ], "-preload" ) == 0 ) { | 640 | if ( qstrcmp( argv[ a ], "-preload" ) == 0 ) { |
641 | argv[ a ] = argv[ a + 1 ]; | 641 | argv[ a ] = argv[ a + 1 ]; |
642 | a++; | 642 | a++; |
643 | d->preloaded = TRUE; | 643 | d->preloaded = TRUE; |
644 | argc -= 1; | 644 | argc -= 1; |
645 | } | 645 | } |
646 | else if ( qstrcmp( argv[ a ], "-preload-show" ) == 0 ) { | 646 | else if ( qstrcmp( argv[ a ], "-preload-show" ) == 0 ) { |
647 | argv[ a ] = argv[ a + 1 ]; | 647 | argv[ a ] = argv[ a + 1 ]; |
648 | a++; | 648 | a++; |
649 | d->preloaded = TRUE; | 649 | d->preloaded = TRUE; |
650 | d->forceshow = TRUE; | 650 | d->forceshow = TRUE; |
651 | argc -= 1; | 651 | argc -= 1; |
652 | } | 652 | } |
653 | } | 653 | } |
654 | 654 | ||
655 | /* overide stored arguments */ | 655 | /* overide stored arguments */ |
656 | setArgs( argc, argv ); | 656 | setArgs( argc, argv ); |
657 | 657 | ||
658 | #endif | 658 | #endif |
659 | #else | 659 | #else |
660 | initApp( argc, argv ); | 660 | initApp( argc, argv ); |
661 | #endif | 661 | #endif |
662 | // qwsSetDecoration( new QPEDecoration() ); | 662 | // qwsSetDecoration( new QPEDecoration() ); |
663 | 663 | ||
664 | #ifndef QT_NO_TRANSLATION | 664 | #ifndef QT_NO_TRANSLATION |
665 | 665 | ||
666 | QStringList langs = Global::languageList(); | 666 | QStringList langs = Global::languageList(); |
667 | for ( QStringList::ConstIterator it = langs.begin(); it != langs.end(); ++it ) { | 667 | for ( QStringList::ConstIterator it = langs.begin(); it != langs.end(); ++it ) { |
668 | QString lang = *it; | 668 | QString lang = *it; |
669 | 669 | ||
670 | installTranslation( lang + "/libopie.qm"); | 670 | installTranslation( lang + "/libopie.qm"); |
671 | installTranslation( lang + "/libqpe.qm" ); | 671 | installTranslation( lang + "/libqpe.qm" ); |
672 | installTranslation( lang + "/" + d->appName + ".qm" ); | 672 | installTranslation( lang + "/" + d->appName + ".qm" ); |
673 | 673 | ||
674 | 674 | ||
675 | //###language/font hack; should look it up somewhere | 675 | //###language/font hack; should look it up somewhere |
676 | #ifdef QWS | 676 | #ifdef QWS |
677 | 677 | ||
678 | if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) { | 678 | if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) { |
679 | QFont fn = FontManager::unicodeFont( FontManager::Proportional ); | 679 | QFont fn = FontManager::unicodeFont( FontManager::Proportional ); |
680 | setFont( fn ); | 680 | setFont( fn ); |
681 | } | 681 | } |
682 | #endif | 682 | #endif |
683 | } | 683 | } |
684 | #endif | 684 | #endif |
685 | 685 | ||
686 | applyStyle(); | 686 | applyStyle(); |
687 | 687 | ||
688 | if ( type() == GuiServer ) { | 688 | if ( type() == GuiServer ) { |
689 | setVolume(); | 689 | setVolume(); |
690 | } | 690 | } |
691 | 691 | ||
692 | installEventFilter( this ); | 692 | installEventFilter( this ); |
693 | 693 | ||
694 | QPEMenuToolFocusManager::initialize(); | 694 | QPEMenuToolFocusManager::initialize(); |
695 | 695 | ||
696 | #ifdef QT_NO_QWS_CURSOR | 696 | #ifdef QT_NO_QWS_CURSOR |
697 | // if we have no cursor, probably don't want tooltips | 697 | // if we have no cursor, probably don't want tooltips |
698 | QToolTip::setEnabled( FALSE ); | 698 | QToolTip::setEnabled( FALSE ); |
699 | #endif | 699 | #endif |
700 | } | 700 | } |
701 | 701 | ||
702 | 702 | ||
703 | #ifdef QTOPIA_INTERNAL_INITAPP | 703 | #ifdef QTOPIA_INTERNAL_INITAPP |
704 | void QPEApplication::initApp( int argc, char **argv ) | 704 | void QPEApplication::initApp( int argc, char **argv ) |
705 | { | 705 | { |
706 | delete pidChannel; | 706 | delete pidChannel; |
707 | d->keep_running = TRUE; | 707 | d->keep_running = TRUE; |
708 | d->preloaded = FALSE; | 708 | d->preloaded = FALSE; |
709 | d->forceshow = FALSE; | 709 | d->forceshow = FALSE; |
710 | 710 | ||
711 | QCString channel = QCString(argv[0]); | 711 | QCString channel = QCString(argv[0]); |
712 | 712 | ||
713 | channel.replace(QRegExp(".*/"),""); | 713 | channel.replace(QRegExp(".*/"),""); |
714 | d->appName = channel; | 714 | d->appName = channel; |
715 | 715 | ||
716 | #if QT_VERSION > 235 | ||
716 | qt_fbdpy->setIdentity( channel ); // In Qt/E 2.3.6 | 717 | qt_fbdpy->setIdentity( channel ); // In Qt/E 2.3.6 |
718 | #endif | ||
717 | 719 | ||
718 | channel = "QPE/Application/" + channel; | 720 | channel = "QPE/Application/" + channel; |
719 | pidChannel = new QCopChannel( channel, this); | 721 | pidChannel = new QCopChannel( channel, this); |
720 | connect( pidChannel, SIGNAL(received(const QCString &, const QByteArray &)), | 722 | connect( pidChannel, SIGNAL(received(const QCString &, const QByteArray &)), |
721 | this, SLOT(pidMessage(const QCString &, const QByteArray &))); | 723 | this, SLOT(pidMessage(const QCString &, const QByteArray &))); |
722 | 724 | ||
723 | processQCopFile(); | 725 | processQCopFile(); |
724 | d->keep_running = d->qcopq.isEmpty(); | 726 | d->keep_running = d->qcopq.isEmpty(); |
725 | 727 | ||
726 | for (int a=0; a<argc; a++) { | 728 | for (int a=0; a<argc; a++) { |
727 | if ( qstrcmp(argv[a],"-preload")==0 ) { | 729 | if ( qstrcmp(argv[a],"-preload")==0 ) { |
728 | argv[a] = argv[a+1]; | 730 | argv[a] = argv[a+1]; |
729 | a++; | 731 | a++; |
730 | d->preloaded = TRUE; | 732 | d->preloaded = TRUE; |
731 | argc-=1; | 733 | argc-=1; |
732 | } else if ( qstrcmp(argv[a],"-preload-show")==0 ) { | 734 | } else if ( qstrcmp(argv[a],"-preload-show")==0 ) { |
733 | argv[a] = argv[a+1]; | 735 | argv[a] = argv[a+1]; |
734 | a++; | 736 | a++; |
735 | d->preloaded = TRUE; | 737 | d->preloaded = TRUE; |
736 | d->forceshow = TRUE; | 738 | d->forceshow = TRUE; |
737 | argc-=1; | 739 | argc-=1; |
738 | } | 740 | } |
739 | } | 741 | } |
740 | 742 | ||
741 | /* overide stored arguments */ | 743 | /* overide stored arguments */ |
742 | setArgs(argc, argv); | 744 | setArgs(argc, argv); |
743 | } | 745 | } |
744 | #endif | 746 | #endif |
745 | 747 | ||
746 | 748 | ||
747 | static QPtrDict<void>* inputMethodDict = 0; | 749 | static QPtrDict<void>* inputMethodDict = 0; |
748 | static void createInputMethodDict() | 750 | static void createInputMethodDict() |
749 | { | 751 | { |
750 | if ( !inputMethodDict ) | 752 | if ( !inputMethodDict ) |
751 | inputMethodDict = new QPtrDict<void>; | 753 | inputMethodDict = new QPtrDict<void>; |
752 | } | 754 | } |
753 | 755 | ||
754 | /*! | 756 | /*! |
755 | Returns the currently set hint to the system as to whether | 757 | Returns the currently set hint to the system as to whether |
756 | widget \a w has any use for text input methods. | 758 | widget \a w has any use for text input methods. |
757 | 759 | ||
758 | 760 | ||
759 | \sa setInputMethodHint() InputMethodHint | 761 | \sa setInputMethodHint() InputMethodHint |
760 | */ | 762 | */ |
761 | QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w ) | 763 | QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w ) |
762 | { | 764 | { |
763 | if ( inputMethodDict && w ) | 765 | if ( inputMethodDict && w ) |
764 | return ( InputMethodHint ) ( int ) inputMethodDict->find( w ); | 766 | return ( InputMethodHint ) ( int ) inputMethodDict->find( w ); |
765 | return Normal; | 767 | return Normal; |
766 | } | 768 | } |
767 | 769 | ||
768 | /*! | 770 | /*! |
769 | \enum QPEApplication::InputMethodHint | 771 | \enum QPEApplication::InputMethodHint |
770 | 772 | ||
771 | \value Normal the application sometimes needs text input (the default). | 773 | \value Normal the application sometimes needs text input (the default). |
772 | \value AlwaysOff the application never needs text input. | 774 | \value AlwaysOff the application never needs text input. |
773 | \value AlwaysOn the application always needs text input. | 775 | \value AlwaysOn the application always needs text input. |
774 | */ | 776 | */ |
775 | 777 | ||
776 | /*! | 778 | /*! |
777 | Hints to the system that widget \a w has use for text input methods | 779 | Hints to the system that widget \a w has use for text input methods |
778 | as specified by \a mode. | 780 | as specified by \a mode. |
779 | 781 | ||
780 | \sa inputMethodHint() InputMethodHint | 782 | \sa inputMethodHint() InputMethodHint |
781 | */ | 783 | */ |
782 | void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode ) | 784 | void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode ) |
783 | { | 785 | { |
784 | createInputMethodDict(); | 786 | createInputMethodDict(); |
785 | if ( mode == Normal ) { | 787 | if ( mode == Normal ) { |
786 | inputMethodDict->remove | 788 | inputMethodDict->remove |
787 | ( w ); | 789 | ( w ); |
788 | } | 790 | } |
789 | else { | 791 | else { |
790 | inputMethodDict->insert( w, ( void* ) mode ); | 792 | inputMethodDict->insert( w, ( void* ) mode ); |
791 | } | 793 | } |
792 | } | 794 | } |
793 | 795 | ||
794 | class HackDialog : public QDialog | 796 | class HackDialog : public QDialog |
795 | { | 797 | { |
796 | public: | 798 | public: |
797 | void acceptIt() | 799 | void acceptIt() |
798 | { | 800 | { |
799 | accept(); | 801 | accept(); |
800 | } | 802 | } |
801 | void rejectIt() | 803 | void rejectIt() |
802 | { | 804 | { |
803 | reject(); | 805 | reject(); |
804 | } | 806 | } |
805 | }; | 807 | }; |
806 | 808 | ||
807 | 809 | ||
808 | void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key ) | 810 | void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key ) |
809 | { | 811 | { |
810 | // specialised actions for certain widgets. May want to | 812 | // specialised actions for certain widgets. May want to |
811 | // add more stuff here. | 813 | // add more stuff here. |
812 | if ( activePopupWidget() && activePopupWidget() ->inherits( "QListBox" ) | 814 | if ( activePopupWidget() && activePopupWidget() ->inherits( "QListBox" ) |
813 | && activePopupWidget() ->parentWidget() | 815 | && activePopupWidget() ->parentWidget() |
814 | && activePopupWidget() ->parentWidget() ->inherits( "QComboBox" ) ) | 816 | && activePopupWidget() ->parentWidget() ->inherits( "QComboBox" ) ) |
815 | key = Qt::Key_Return; | 817 | key = Qt::Key_Return; |
816 | 818 | ||
817 | if ( activePopupWidget() && activePopupWidget() ->inherits( "QPopupMenu" ) ) | 819 | if ( activePopupWidget() && activePopupWidget() ->inherits( "QPopupMenu" ) ) |
818 | key = Qt::Key_Return; | 820 | key = Qt::Key_Return; |
819 | 821 | ||
820 | #ifdef QWS | 822 | #ifdef QWS |
821 | 823 | ||
822 | ke->simpleData.keycode = key; | 824 | ke->simpleData.keycode = key; |
823 | #endif | 825 | #endif |
824 | } | 826 | } |
825 | 827 | ||
826 | class HackWidget : public QWidget | 828 | class HackWidget : public QWidget |
827 | { | 829 | { |
828 | public: | 830 | public: |
829 | bool needsOk() | 831 | bool needsOk() |
830 | { | 832 | { |
831 | return ( getWState() & WState_Reserved1 ); | 833 | return ( getWState() & WState_Reserved1 ); |
832 | } | 834 | } |
833 | }; | 835 | }; |
834 | 836 | ||
835 | /*! | 837 | /*! |
836 | \internal | 838 | \internal |
837 | */ | 839 | */ |
838 | 840 | ||
839 | #ifdef QWS | 841 | #ifdef QWS |
840 | bool QPEApplication::qwsEventFilter( QWSEvent * e ) | 842 | bool QPEApplication::qwsEventFilter( QWSEvent * e ) |
841 | { | 843 | { |
842 | if ( !d->notbusysent && e->type == QWSEvent::Focus ) { | 844 | if ( !d->notbusysent && e->type == QWSEvent::Focus ) { |
843 | if ( qApp->type() != QApplication::GuiServer ) { | 845 | if ( qApp->type() != QApplication::GuiServer ) { |
844 | QCopEnvelope e( "QPE/System", "notBusy(QString)" ); | 846 | QCopEnvelope e( "QPE/System", "notBusy(QString)" ); |
845 | e << d->appName; | 847 | e << d->appName; |
846 | } | 848 | } |
847 | d->notbusysent = TRUE; | 849 | d->notbusysent = TRUE; |
848 | } | 850 | } |
849 | if ( type() == GuiServer ) { | 851 | if ( type() == GuiServer ) { |
850 | switch ( e->type ) { | 852 | switch ( e->type ) { |
851 | case QWSEvent::Mouse: | 853 | case QWSEvent::Mouse: |
852 | if ( e->asMouse() ->simpleData.state && !QWidget::find( e->window() ) ) | 854 | if ( e->asMouse() ->simpleData.state && !QWidget::find( e->window() ) ) |
853 | emit clientMoused(); | 855 | emit clientMoused(); |
854 | break; | 856 | break; |
855 | default: | 857 | default: |
856 | break; | 858 | break; |
857 | } | 859 | } |
858 | } | 860 | } |
859 | if ( e->type == QWSEvent::Key ) { | 861 | if ( e->type == QWSEvent::Key ) { |
860 | QWSKeyEvent *ke = ( QWSKeyEvent * ) e; | 862 | QWSKeyEvent *ke = ( QWSKeyEvent * ) e; |
861 | if ( ke->simpleData.keycode == Qt::Key_F33 ) { | 863 | if ( ke->simpleData.keycode == Qt::Key_F33 ) { |
862 | // Use special "OK" key to press "OK" on top level widgets | 864 | // Use special "OK" key to press "OK" on top level widgets |
863 | QWidget * active = activeWindow(); | 865 | QWidget * active = activeWindow(); |
864 | QWidget *popup = 0; | 866 | QWidget *popup = 0; |
865 | if ( active && active->isPopup() ) { | 867 | if ( active && active->isPopup() ) { |
866 | popup = active; | 868 | popup = active; |
867 | active = active->parentWidget(); | 869 | active = active->parentWidget(); |
868 | } | 870 | } |
869 | if ( active && ( int ) active->winId() == ke->simpleData.window && | 871 | if ( active && ( int ) active->winId() == ke->simpleData.window && |
870 | !active->testWFlags( WStyle_Customize | WType_Popup | WType_Desktop ) ) { | 872 | !active->testWFlags( WStyle_Customize | WType_Popup | WType_Desktop ) ) { |
871 | if ( ke->simpleData.is_press ) { | 873 | if ( ke->simpleData.is_press ) { |
872 | if ( popup ) | 874 | if ( popup ) |
873 | popup->close(); | 875 | popup->close(); |
874 | if ( active->inherits( "QDialog" ) ) { | 876 | if ( active->inherits( "QDialog" ) ) { |
875 | HackDialog * d = ( HackDialog * ) active; | 877 | HackDialog * d = ( HackDialog * ) active; |
876 | d->acceptIt(); | 878 | d->acceptIt(); |
877 | return TRUE; | 879 | return TRUE; |
878 | } | 880 | } |
879 | else if ( ( ( HackWidget * ) active ) ->needsOk() ) { | 881 | else if ( ( ( HackWidget * ) active ) ->needsOk() ) { |
880 | QSignal s; | 882 | QSignal s; |
881 | s.connect( active, SLOT( accept() ) ); | 883 | s.connect( active, SLOT( accept() ) ); |
882 | s.activate(); | 884 | s.activate(); |
883 | } | 885 | } |
884 | else { | 886 | else { |
885 | // do the same as with the select key: Map to the default action of the widget: | 887 | // do the same as with the select key: Map to the default action of the widget: |
886 | mapToDefaultAction( ke, Qt::Key_Return ); | 888 | mapToDefaultAction( ke, Qt::Key_Return ); |
887 | } | 889 | } |
888 | } | 890 | } |
889 | } | 891 | } |
890 | } | 892 | } |
891 | else if ( ke->simpleData.keycode == Qt::Key_F30 ) { | 893 | else if ( ke->simpleData.keycode == Qt::Key_F30 ) { |
892 | // Use special "select" key to do whatever default action a widget has | 894 | // Use special "select" key to do whatever default action a widget has |
893 | mapToDefaultAction( ke, Qt::Key_Space ); | 895 | mapToDefaultAction( ke, Qt::Key_Space ); |
894 | } | 896 | } |
895 | else if ( ke->simpleData.keycode == Qt::Key_Escape && | 897 | else if ( ke->simpleData.keycode == Qt::Key_Escape && |
896 | ke->simpleData.is_press ) { | 898 | ke->simpleData.is_press ) { |
897 | // Escape key closes app if focus on toplevel | 899 | // Escape key closes app if focus on toplevel |
898 | QWidget * active = activeWindow(); | 900 | QWidget * active = activeWindow(); |
899 | if ( active && active->testWFlags( WType_TopLevel ) && | 901 | if ( active && active->testWFlags( WType_TopLevel ) && |
900 | ( int ) active->winId() == ke->simpleData.window && | 902 | ( int ) active->winId() == ke->simpleData.window && |
901 | !active->testWFlags( WStyle_Dialog | WStyle_Customize | WType_Popup | WType_Desktop ) ) { | 903 | !active->testWFlags( WStyle_Dialog | WStyle_Customize | WType_Popup | WType_Desktop ) ) { |
902 | if ( active->inherits( "QDialog" ) ) { | 904 | if ( active->inherits( "QDialog" ) ) { |
903 | HackDialog * d = ( HackDialog * ) active; | 905 | HackDialog * d = ( HackDialog * ) active; |
904 | d->rejectIt(); | 906 | d->rejectIt(); |
905 | return TRUE; | 907 | return TRUE; |
906 | } | 908 | } |
907 | else if ( strcmp( argv() [ 0 ], "embeddedkonsole" ) != 0 ) { | 909 | else if ( strcmp( argv() [ 0 ], "embeddedkonsole" ) != 0 ) { |
908 | active->close(); | 910 | active->close(); |
909 | } | 911 | } |
910 | } | 912 | } |
911 | } | 913 | } |
912 | else if ( ke->simpleData.keycode >= Qt::Key_F1 && ke->simpleData.keycode <= Qt::Key_F29 ) { | 914 | else if ( ke->simpleData.keycode >= Qt::Key_F1 && ke->simpleData.keycode <= Qt::Key_F29 ) { |
913 | // this should be if ( ODevice::inst ( )-> buttonForKeycode ( ... )) | 915 | // this should be if ( ODevice::inst ( )-> buttonForKeycode ( ... )) |
914 | // but we cannot access libopie function within libqpe :( | 916 | // but we cannot access libopie function within libqpe :( |
915 | 917 | ||
916 | QWidget * active = activeWindow ( ); | 918 | QWidget * active = activeWindow ( ); |
917 | if ( active && ((int) active-> winId ( ) == ke-> simpleData.window )) { | 919 | if ( active && ((int) active-> winId ( ) == ke-> simpleData.window )) { |
918 | if ( d-> kbgrabbed ) { // we grabbed the keyboard | 920 | if ( d-> kbgrabbed ) { // we grabbed the keyboard |
919 | QChar ch ( ke-> simpleData.unicode ); | 921 | QChar ch ( ke-> simpleData.unicode ); |
920 | QKeyEvent qke ( ke-> simpleData. is_press ? QEvent::KeyPress : QEvent::KeyRelease, | 922 | QKeyEvent qke ( ke-> simpleData. is_press ? QEvent::KeyPress : QEvent::KeyRelease, |
921 | ke-> simpleData.keycode, | 923 | ke-> simpleData.keycode, |
922 | ch. latin1 ( ), | 924 | ch. latin1 ( ), |
923 | ke-> simpleData.modifiers, | 925 | ke-> simpleData.modifiers, |
924 | QString ( ch ), | 926 | QString ( ch ), |
925 | ke-> simpleData.is_auto_repeat, 1 ); | 927 | ke-> simpleData.is_auto_repeat, 1 ); |
926 | 928 | ||
927 | QObject *which = QWidget::keyboardGrabber ( ); | 929 | QObject *which = QWidget::keyboardGrabber ( ); |
928 | if ( !which ) | 930 | if ( !which ) |
929 | which = QApplication::focusWidget ( ); | 931 | which = QApplication::focusWidget ( ); |
930 | if ( !which ) | 932 | if ( !which ) |
931 | which = QApplication::activeWindow ( ); | 933 | which = QApplication::activeWindow ( ); |
932 | if ( !which ) | 934 | if ( !which ) |
933 | which = qApp; | 935 | which = qApp; |
934 | 936 | ||
935 | QApplication::sendEvent ( which, &qke ); | 937 | QApplication::sendEvent ( which, &qke ); |
936 | } | 938 | } |
937 | else { // we didn't grab the keyboard, so send the event to the launcher | 939 | else { // we didn't grab the keyboard, so send the event to the launcher |
938 | QCopEnvelope e ( "QPE/Launcher", "deviceButton(int,int,int)" ); | 940 | QCopEnvelope e ( "QPE/Launcher", "deviceButton(int,int,int)" ); |
939 | e << int( ke-> simpleData.keycode ) << int( ke-> simpleData. is_press ) << int( ke-> simpleData.is_auto_repeat ); | 941 | e << int( ke-> simpleData.keycode ) << int( ke-> simpleData. is_press ) << int( ke-> simpleData.is_auto_repeat ); |
940 | } | 942 | } |
941 | } | 943 | } |
942 | return true; | 944 | return true; |
943 | } | 945 | } |
944 | } | 946 | } |
945 | if ( e->type == QWSEvent::Focus ) { | 947 | if ( e->type == QWSEvent::Focus ) { |
946 | QWSFocusEvent * fe = ( QWSFocusEvent* ) e; | 948 | QWSFocusEvent * fe = ( QWSFocusEvent* ) e; |
947 | if ( !fe->simpleData.get_focus ) { | 949 | if ( !fe->simpleData.get_focus ) { |
948 | QWidget * active = activeWindow(); | 950 | QWidget * active = activeWindow(); |
949 | while ( active && active->isPopup() ) { | 951 | while ( active && active->isPopup() ) { |
950 | active->close(); | 952 | active->close(); |
951 | active = activeWindow(); | 953 | active = activeWindow(); |
952 | } | 954 | } |
953 | } | 955 | } |
954 | else { | 956 | else { |
955 | // make sure our modal widget is ALWAYS on top | 957 | // make sure our modal widget is ALWAYS on top |
956 | QWidget *topm = activeModalWidget(); | 958 | QWidget *topm = activeModalWidget(); |
957 | if ( topm ) { | 959 | if ( topm ) { |
958 | topm->raise(); | 960 | topm->raise(); |
959 | } | 961 | } |
960 | } | 962 | } |
961 | if ( fe->simpleData.get_focus && inputMethodDict ) { | 963 | if ( fe->simpleData.get_focus && inputMethodDict ) { |
962 | InputMethodHint m = inputMethodHint( QWidget::find( e->window() ) ); | 964 | InputMethodHint m = inputMethodHint( QWidget::find( e->window() ) ); |
963 | if ( m == AlwaysOff ) | 965 | if ( m == AlwaysOff ) |
964 | Global::hideInputMethod(); | 966 | Global::hideInputMethod(); |
965 | if ( m == AlwaysOn ) | 967 | if ( m == AlwaysOn ) |
966 | Global::showInputMethod(); | 968 | Global::showInputMethod(); |
967 | } | 969 | } |
968 | } | 970 | } |
969 | 971 | ||
970 | 972 | ||
971 | return QApplication::qwsEventFilter( e ); | 973 | return QApplication::qwsEventFilter( e ); |
972 | } | 974 | } |