-rw-r--r-- | library/qpeapplication.cpp | 46 | ||||
-rw-r--r-- | library/qpeapplication.h | 2 |
2 files changed, 48 insertions, 0 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp index 149e6bb..71ec5b3 100644 --- a/library/qpeapplication.cpp +++ b/library/qpeapplication.cpp | |||
@@ -558,1137 +558,1183 @@ void QPEApplication::processQCopFile() | |||
558 | and emitted as signals, such as flush() and reload(). | 558 | and emitted as signals, such as flush() and reload(). |
559 | */ | 559 | */ |
560 | 560 | ||
561 | /*! | 561 | /*! |
562 | Constructs a QPEApplication just as you would construct | 562 | Constructs a QPEApplication just as you would construct |
563 | a QApplication, passing \a argc, \a argv, and \a t. | 563 | a QApplication, passing \a argc, \a argv, and \a t. |
564 | 564 | ||
565 | For applications, \a t should be the default, GuiClient. Only | 565 | For applications, \a t should be the default, GuiClient. Only |
566 | the Qtopia server passes GuiServer. | 566 | the Qtopia server passes GuiServer. |
567 | */ | 567 | */ |
568 | QPEApplication::QPEApplication( int & argc, char **argv, Type t ) | 568 | QPEApplication::QPEApplication( int & argc, char **argv, Type t ) |
569 | : QApplication( hack(argc), argv, t ), pidChannel( 0 ) | 569 | : QApplication( hack(argc), argv, t ), pidChannel( 0 ) |
570 | { | 570 | { |
571 | d = new QPEApplicationData; | 571 | d = new QPEApplicationData; |
572 | d->loadTextCodecs(); | 572 | d->loadTextCodecs(); |
573 | d->loadImageCodecs(); | 573 | d->loadImageCodecs(); |
574 | int dw = desktop() ->width(); | 574 | int dw = desktop() ->width(); |
575 | 575 | ||
576 | if ( dw < 200 ) { | 576 | if ( dw < 200 ) { |
577 | setFont( QFont( "vera", 8 ) ); | 577 | setFont( QFont( "vera", 8 ) ); |
578 | AppLnk::setSmallIconSize( 10 ); | 578 | AppLnk::setSmallIconSize( 10 ); |
579 | AppLnk::setBigIconSize( 28 ); | 579 | AppLnk::setBigIconSize( 28 ); |
580 | } | 580 | } |
581 | #ifndef QT_QWS_SIMPAD | 581 | #ifndef QT_QWS_SIMPAD |
582 | else if ( dw > 600 ) { | 582 | else if ( dw > 600 ) { |
583 | setFont( QFont( "vera", 16 ) ); | 583 | setFont( QFont( "vera", 16 ) ); |
584 | AppLnk::setSmallIconSize( 24 ); | 584 | AppLnk::setSmallIconSize( 24 ); |
585 | AppLnk::setBigIconSize( 48 ); | 585 | AppLnk::setBigIconSize( 48 ); |
586 | } | 586 | } |
587 | #endif | 587 | #endif |
588 | else if ( dw > 200 ) { | 588 | else if ( dw > 200 ) { |
589 | setFont( QFont( "vera", 10 ) ); | 589 | setFont( QFont( "vera", 10 ) ); |
590 | AppLnk::setSmallIconSize( 14 ); | 590 | AppLnk::setSmallIconSize( 14 ); |
591 | AppLnk::setBigIconSize( 32 ); | 591 | AppLnk::setBigIconSize( 32 ); |
592 | } | 592 | } |
593 | 593 | ||
594 | QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory ); | 594 | QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory ); |
595 | 595 | ||
596 | connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) ); | 596 | connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) ); |
597 | 597 | ||
598 | 598 | ||
599 | sysChannel = new QCopChannel( "QPE/System", this ); | 599 | sysChannel = new QCopChannel( "QPE/System", this ); |
600 | connect( sysChannel, SIGNAL( received( const QCString &, const QByteArray & ) ), | 600 | connect( sysChannel, SIGNAL( received( const QCString &, const QByteArray & ) ), |
601 | this, SLOT( systemMessage( const QCString &, const QByteArray & ) ) ); | 601 | this, SLOT( systemMessage( const QCString &, const QByteArray & ) ) ); |
602 | 602 | ||
603 | /* COde now in initapp */ | 603 | /* COde now in initapp */ |
604 | #if 0 | 604 | #if 0 |
605 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 605 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
606 | 606 | ||
607 | QString qcopfn( "/tmp/qcop-msg-" ); | 607 | QString qcopfn( "/tmp/qcop-msg-" ); |
608 | qcopfn += QString( argv[ 0 ] ); // append command name | 608 | qcopfn += QString( argv[ 0 ] ); // append command name |
609 | 609 | ||
610 | QFile f( qcopfn ); | 610 | QFile f( qcopfn ); |
611 | if ( f.open( IO_ReadOnly ) ) { | 611 | if ( f.open( IO_ReadOnly ) ) { |
612 | flock( f.handle(), LOCK_EX ); | 612 | flock( f.handle(), LOCK_EX ); |
613 | } | 613 | } |
614 | 614 | ||
615 | 615 | ||
616 | 616 | ||
617 | QCString channel = QCString( argv[ 0 ] ); | 617 | QCString channel = QCString( argv[ 0 ] ); |
618 | channel.replace( QRegExp( ".*/" ), "" ); | 618 | channel.replace( QRegExp( ".*/" ), "" ); |
619 | d->appName = channel; | 619 | d->appName = channel; |
620 | channel = "QPE/Application/" + channel; | 620 | channel = "QPE/Application/" + channel; |
621 | pidChannel = new QCopChannel( channel, this ); | 621 | pidChannel = new QCopChannel( channel, this ); |
622 | connect( pidChannel, SIGNAL( received( const QCString &, const QByteArray & ) ), | 622 | connect( pidChannel, SIGNAL( received( const QCString &, const QByteArray & ) ), |
623 | this, SLOT( pidMessage( const QCString &, const QByteArray & ) ) ); | 623 | this, SLOT( pidMessage( const QCString &, const QByteArray & ) ) ); |
624 | 624 | ||
625 | if ( f.isOpen() ) { | 625 | if ( f.isOpen() ) { |
626 | d->keep_running = FALSE; | 626 | d->keep_running = FALSE; |
627 | QDataStream ds( &f ); | 627 | QDataStream ds( &f ); |
628 | QCString channel, message; | 628 | QCString channel, message; |
629 | QByteArray data; | 629 | QByteArray data; |
630 | while ( !ds.atEnd() ) { | 630 | while ( !ds.atEnd() ) { |
631 | ds >> channel >> message >> data; | 631 | ds >> channel >> message >> data; |
632 | d->enqueueQCop( channel, message, data ); | 632 | d->enqueueQCop( channel, message, data ); |
633 | } | 633 | } |
634 | 634 | ||
635 | flock( f.handle(), LOCK_UN ); | 635 | flock( f.handle(), LOCK_UN ); |
636 | f.close(); | 636 | f.close(); |
637 | f.remove(); | 637 | f.remove(); |
638 | } | 638 | } |
639 | 639 | ||
640 | for ( int a = 0; a < argc; a++ ) { | 640 | for ( int a = 0; a < argc; a++ ) { |
641 | if ( qstrcmp( argv[ a ], "-preload" ) == 0 ) { | 641 | if ( qstrcmp( argv[ a ], "-preload" ) == 0 ) { |
642 | argv[ a ] = argv[ a + 1 ]; | 642 | argv[ a ] = argv[ a + 1 ]; |
643 | a++; | 643 | a++; |
644 | d->preloaded = TRUE; | 644 | d->preloaded = TRUE; |
645 | argc -= 1; | 645 | argc -= 1; |
646 | } | 646 | } |
647 | else if ( qstrcmp( argv[ a ], "-preload-show" ) == 0 ) { | 647 | else if ( qstrcmp( argv[ a ], "-preload-show" ) == 0 ) { |
648 | argv[ a ] = argv[ a + 1 ]; | 648 | argv[ a ] = argv[ a + 1 ]; |
649 | a++; | 649 | a++; |
650 | d->preloaded = TRUE; | 650 | d->preloaded = TRUE; |
651 | d->forceshow = TRUE; | 651 | d->forceshow = TRUE; |
652 | argc -= 1; | 652 | argc -= 1; |
653 | } | 653 | } |
654 | } | 654 | } |
655 | 655 | ||
656 | /* overide stored arguments */ | 656 | /* overide stored arguments */ |
657 | setArgs( argc, argv ); | 657 | setArgs( argc, argv ); |
658 | 658 | ||
659 | #endif | 659 | #endif |
660 | #else | 660 | #else |
661 | initApp( argc, argv ); | 661 | initApp( argc, argv ); |
662 | #endif | 662 | #endif |
663 | // qwsSetDecoration( new QPEDecoration() ); | 663 | // qwsSetDecoration( new QPEDecoration() ); |
664 | 664 | ||
665 | #ifndef QT_NO_TRANSLATION | 665 | #ifndef QT_NO_TRANSLATION |
666 | 666 | ||
667 | d->langs = Global::languageList(); | 667 | d->langs = Global::languageList(); |
668 | for ( QStringList::ConstIterator it = d->langs.begin(); it != d->langs.end(); ++it ) { | 668 | for ( QStringList::ConstIterator it = d->langs.begin(); it != d->langs.end(); ++it ) { |
669 | QString lang = *it; | 669 | QString lang = *it; |
670 | 670 | ||
671 | installTranslation( lang + "/libopie.qm"); | 671 | installTranslation( lang + "/libopie.qm"); |
672 | installTranslation( lang + "/libqpe.qm" ); | 672 | installTranslation( lang + "/libqpe.qm" ); |
673 | installTranslation( lang + "/" + d->appName + ".qm" ); | 673 | installTranslation( lang + "/" + d->appName + ".qm" ); |
674 | 674 | ||
675 | 675 | ||
676 | //###language/font hack; should look it up somewhere | 676 | //###language/font hack; should look it up somewhere |
677 | #ifdef QWS | 677 | #ifdef QWS |
678 | 678 | ||
679 | if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) { | 679 | if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) { |
680 | QFont fn = FontManager::unicodeFont( FontManager::Proportional ); | 680 | QFont fn = FontManager::unicodeFont( FontManager::Proportional ); |
681 | setFont( fn ); | 681 | setFont( fn ); |
682 | } | 682 | } |
683 | #endif | 683 | #endif |
684 | } | 684 | } |
685 | #endif | 685 | #endif |
686 | 686 | ||
687 | applyStyle(); | 687 | applyStyle(); |
688 | 688 | ||
689 | if ( type() == GuiServer ) { | 689 | if ( type() == GuiServer ) { |
690 | setVolume(); | 690 | setVolume(); |
691 | } | 691 | } |
692 | 692 | ||
693 | installEventFilter( this ); | 693 | installEventFilter( this ); |
694 | 694 | ||
695 | QPEMenuToolFocusManager::initialize(); | 695 | QPEMenuToolFocusManager::initialize(); |
696 | 696 | ||
697 | #ifdef QT_NO_QWS_CURSOR | 697 | #ifdef QT_NO_QWS_CURSOR |
698 | // if we have no cursor, probably don't want tooltips | 698 | // if we have no cursor, probably don't want tooltips |
699 | QToolTip::setEnabled( FALSE ); | 699 | QToolTip::setEnabled( FALSE ); |
700 | #endif | 700 | #endif |
701 | } | 701 | } |
702 | 702 | ||
703 | 703 | ||
704 | #ifdef QTOPIA_INTERNAL_INITAPP | 704 | #ifdef QTOPIA_INTERNAL_INITAPP |
705 | void QPEApplication::initApp( int argc, char **argv ) | 705 | void QPEApplication::initApp( int argc, char **argv ) |
706 | { | 706 | { |
707 | delete pidChannel; | 707 | delete pidChannel; |
708 | d->keep_running = TRUE; | 708 | d->keep_running = TRUE; |
709 | d->preloaded = FALSE; | 709 | d->preloaded = FALSE; |
710 | d->forceshow = FALSE; | 710 | d->forceshow = FALSE; |
711 | 711 | ||
712 | QCString channel = QCString(argv[0]); | 712 | QCString channel = QCString(argv[0]); |
713 | 713 | ||
714 | channel.replace(QRegExp(".*/"),""); | 714 | channel.replace(QRegExp(".*/"),""); |
715 | d->appName = channel; | 715 | d->appName = channel; |
716 | 716 | ||
717 | #if QT_VERSION > 235 | 717 | #if QT_VERSION > 235 |
718 | qt_fbdpy->setIdentity( channel ); // In Qt/E 2.3.6 | 718 | qt_fbdpy->setIdentity( channel ); // In Qt/E 2.3.6 |
719 | #endif | 719 | #endif |
720 | 720 | ||
721 | channel = "QPE/Application/" + channel; | 721 | channel = "QPE/Application/" + channel; |
722 | pidChannel = new QCopChannel( channel, this); | 722 | pidChannel = new QCopChannel( channel, this); |
723 | connect( pidChannel, SIGNAL(received(const QCString &, const QByteArray &)), | 723 | connect( pidChannel, SIGNAL(received(const QCString &, const QByteArray &)), |
724 | this, SLOT(pidMessage(const QCString &, const QByteArray &))); | 724 | this, SLOT(pidMessage(const QCString &, const QByteArray &))); |
725 | 725 | ||
726 | processQCopFile(); | 726 | processQCopFile(); |
727 | d->keep_running = d->qcopq.isEmpty(); | 727 | d->keep_running = d->qcopq.isEmpty(); |
728 | 728 | ||
729 | for (int a=0; a<argc; a++) { | 729 | for (int a=0; a<argc; a++) { |
730 | if ( qstrcmp(argv[a],"-preload")==0 ) { | 730 | if ( qstrcmp(argv[a],"-preload")==0 ) { |
731 | argv[a] = argv[a+1]; | 731 | argv[a] = argv[a+1]; |
732 | a++; | 732 | a++; |
733 | d->preloaded = TRUE; | 733 | d->preloaded = TRUE; |
734 | argc-=1; | 734 | argc-=1; |
735 | } else if ( qstrcmp(argv[a],"-preload-show")==0 ) { | 735 | } else if ( qstrcmp(argv[a],"-preload-show")==0 ) { |
736 | argv[a] = argv[a+1]; | 736 | argv[a] = argv[a+1]; |
737 | a++; | 737 | a++; |
738 | d->preloaded = TRUE; | 738 | d->preloaded = TRUE; |
739 | d->forceshow = TRUE; | 739 | d->forceshow = TRUE; |
740 | argc-=1; | 740 | argc-=1; |
741 | } | 741 | } |
742 | } | 742 | } |
743 | 743 | ||
744 | /* overide stored arguments */ | 744 | /* overide stored arguments */ |
745 | setArgs(argc, argv); | 745 | setArgs(argc, argv); |
746 | 746 | ||
747 | /* install translation here */ | 747 | /* install translation here */ |
748 | for ( QStringList::ConstIterator it = d->langs.begin(); it != d->langs.end(); ++it ) | 748 | for ( QStringList::ConstIterator it = d->langs.begin(); it != d->langs.end(); ++it ) |
749 | installTranslation( (*it) + "/" + d->appName + ".qm" ); | 749 | installTranslation( (*it) + "/" + d->appName + ".qm" ); |
750 | } | 750 | } |
751 | #endif | 751 | #endif |
752 | 752 | ||
753 | 753 | ||
754 | static QPtrDict<void>* inputMethodDict = 0; | 754 | static QPtrDict<void>* inputMethodDict = 0; |
755 | static void createInputMethodDict() | 755 | static void createInputMethodDict() |
756 | { | 756 | { |
757 | if ( !inputMethodDict ) | 757 | if ( !inputMethodDict ) |
758 | inputMethodDict = new QPtrDict<void>; | 758 | inputMethodDict = new QPtrDict<void>; |
759 | } | 759 | } |
760 | 760 | ||
761 | /*! | 761 | /*! |
762 | Returns the currently set hint to the system as to whether | 762 | Returns the currently set hint to the system as to whether |
763 | widget \a w has any use for text input methods. | 763 | widget \a w has any use for text input methods. |
764 | 764 | ||
765 | 765 | ||
766 | \sa setInputMethodHint() InputMethodHint | 766 | \sa setInputMethodHint() InputMethodHint |
767 | */ | 767 | */ |
768 | QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w ) | 768 | QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w ) |
769 | { | 769 | { |
770 | if ( inputMethodDict && w ) | 770 | if ( inputMethodDict && w ) |
771 | return ( InputMethodHint ) ( int ) inputMethodDict->find( w ); | 771 | return ( InputMethodHint ) ( int ) inputMethodDict->find( w ); |
772 | return Normal; | 772 | return Normal; |
773 | } | 773 | } |
774 | 774 | ||
775 | /*! | 775 | /*! |
776 | \enum QPEApplication::InputMethodHint | 776 | \enum QPEApplication::InputMethodHint |
777 | 777 | ||
778 | \value Normal the application sometimes needs text input (the default). | 778 | \value Normal the application sometimes needs text input (the default). |
779 | \value AlwaysOff the application never needs text input. | 779 | \value AlwaysOff the application never needs text input. |
780 | \value AlwaysOn the application always needs text input. | 780 | \value AlwaysOn the application always needs text input. |
781 | */ | 781 | */ |
782 | 782 | ||
783 | /*! | 783 | /*! |
784 | Hints to the system that widget \a w has use for text input methods | 784 | Hints to the system that widget \a w has use for text input methods |
785 | as specified by \a mode. | 785 | as specified by \a mode. |
786 | 786 | ||
787 | \sa inputMethodHint() InputMethodHint | 787 | \sa inputMethodHint() InputMethodHint |
788 | */ | 788 | */ |
789 | void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode ) | 789 | void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode ) |
790 | { | 790 | { |
791 | createInputMethodDict(); | 791 | createInputMethodDict(); |
792 | if ( mode == Normal ) { | 792 | if ( mode == Normal ) { |
793 | inputMethodDict->remove | 793 | inputMethodDict->remove |
794 | ( w ); | 794 | ( w ); |
795 | } | 795 | } |
796 | else { | 796 | else { |
797 | inputMethodDict->insert( w, ( void* ) mode ); | 797 | inputMethodDict->insert( w, ( void* ) mode ); |
798 | } | 798 | } |
799 | } | 799 | } |
800 | 800 | ||
801 | class HackDialog : public QDialog | 801 | class HackDialog : public QDialog |
802 | { | 802 | { |
803 | public: | 803 | public: |
804 | void acceptIt() | 804 | void acceptIt() |
805 | { | 805 | { |
806 | accept(); | 806 | accept(); |
807 | } | 807 | } |
808 | void rejectIt() | 808 | void rejectIt() |
809 | { | 809 | { |
810 | reject(); | 810 | reject(); |
811 | } | 811 | } |
812 | }; | 812 | }; |
813 | 813 | ||
814 | 814 | ||
815 | void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key ) | 815 | void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key ) |
816 | { | 816 | { |
817 | // specialised actions for certain widgets. May want to | 817 | // specialised actions for certain widgets. May want to |
818 | // add more stuff here. | 818 | // add more stuff here. |
819 | if ( activePopupWidget() && activePopupWidget() ->inherits( "QListBox" ) | 819 | if ( activePopupWidget() && activePopupWidget() ->inherits( "QListBox" ) |
820 | && activePopupWidget() ->parentWidget() | 820 | && activePopupWidget() ->parentWidget() |
821 | && activePopupWidget() ->parentWidget() ->inherits( "QComboBox" ) ) | 821 | && activePopupWidget() ->parentWidget() ->inherits( "QComboBox" ) ) |
822 | key = Qt::Key_Return; | 822 | key = Qt::Key_Return; |
823 | 823 | ||
824 | if ( activePopupWidget() && activePopupWidget() ->inherits( "QPopupMenu" ) ) | 824 | if ( activePopupWidget() && activePopupWidget() ->inherits( "QPopupMenu" ) ) |
825 | key = Qt::Key_Return; | 825 | key = Qt::Key_Return; |
826 | 826 | ||
827 | #ifdef QWS | 827 | #ifdef QWS |
828 | 828 | ||
829 | ke->simpleData.keycode = key; | 829 | ke->simpleData.keycode = key; |
830 | #endif | 830 | #endif |
831 | } | 831 | } |
832 | 832 | ||
833 | class HackWidget : public QWidget | 833 | class HackWidget : public QWidget |
834 | { | 834 | { |
835 | public: | 835 | public: |
836 | bool needsOk() | 836 | bool needsOk() |
837 | { | 837 | { |
838 | return ( getWState() & WState_Reserved1 ); | 838 | return ( getWState() & WState_Reserved1 ); |
839 | } | 839 | } |
840 | }; | 840 | }; |
841 | 841 | ||
842 | /*! | 842 | /*! |
843 | \internal | 843 | \internal |
844 | */ | 844 | */ |
845 | 845 | ||
846 | #ifdef QWS | 846 | #ifdef QWS |
847 | bool QPEApplication::qwsEventFilter( QWSEvent * e ) | 847 | bool QPEApplication::qwsEventFilter( QWSEvent * e ) |
848 | { | 848 | { |
849 | if ( !d->notbusysent && e->type == QWSEvent::Focus ) { | 849 | if ( !d->notbusysent && e->type == QWSEvent::Focus ) { |
850 | if ( qApp->type() != QApplication::GuiServer ) { | 850 | if ( qApp->type() != QApplication::GuiServer ) { |
851 | QCopEnvelope e( "QPE/System", "notBusy(QString)" ); | 851 | QCopEnvelope e( "QPE/System", "notBusy(QString)" ); |
852 | e << d->appName; | 852 | e << d->appName; |
853 | } | 853 | } |
854 | d->notbusysent = TRUE; | 854 | d->notbusysent = TRUE; |
855 | } | 855 | } |
856 | if ( type() == GuiServer ) { | 856 | if ( type() == GuiServer ) { |
857 | switch ( e->type ) { | 857 | switch ( e->type ) { |
858 | case QWSEvent::Mouse: | 858 | case QWSEvent::Mouse: |
859 | if ( e->asMouse() ->simpleData.state && !QWidget::find( e->window() ) ) | 859 | if ( e->asMouse() ->simpleData.state && !QWidget::find( e->window() ) ) |
860 | emit clientMoused(); | 860 | emit clientMoused(); |
861 | break; | 861 | break; |
862 | default: | 862 | default: |
863 | break; | 863 | break; |
864 | } | 864 | } |
865 | } | 865 | } |
866 | if ( e->type == QWSEvent::Key ) { | 866 | if ( e->type == QWSEvent::Key ) { |
867 | QWSKeyEvent *ke = ( QWSKeyEvent * ) e; | 867 | QWSKeyEvent *ke = ( QWSKeyEvent * ) e; |
868 | if ( ke->simpleData.keycode == Qt::Key_F33 ) { | 868 | if ( ke->simpleData.keycode == Qt::Key_F33 ) { |
869 | // Use special "OK" key to press "OK" on top level widgets | 869 | // Use special "OK" key to press "OK" on top level widgets |
870 | QWidget * active = activeWindow(); | 870 | QWidget * active = activeWindow(); |
871 | QWidget *popup = 0; | 871 | QWidget *popup = 0; |
872 | if ( active && active->isPopup() ) { | 872 | if ( active && active->isPopup() ) { |
873 | popup = active; | 873 | popup = active; |
874 | active = active->parentWidget(); | 874 | active = active->parentWidget(); |
875 | } | 875 | } |
876 | if ( active && ( int ) active->winId() == ke->simpleData.window && | 876 | if ( active && ( int ) active->winId() == ke->simpleData.window && |
877 | !active->testWFlags( WStyle_Customize | WType_Popup | WType_Desktop ) ) { | 877 | !active->testWFlags( WStyle_Customize | WType_Popup | WType_Desktop ) ) { |
878 | if ( ke->simpleData.is_press ) { | 878 | if ( ke->simpleData.is_press ) { |
879 | if ( popup ) | 879 | if ( popup ) |
880 | popup->close(); | 880 | popup->close(); |
881 | if ( active->inherits( "QDialog" ) ) { | 881 | if ( active->inherits( "QDialog" ) ) { |
882 | HackDialog * d = ( HackDialog * ) active; | 882 | HackDialog * d = ( HackDialog * ) active; |
883 | d->acceptIt(); | 883 | d->acceptIt(); |
884 | return TRUE; | 884 | return TRUE; |
885 | } | 885 | } |
886 | else if ( ( ( HackWidget * ) active ) ->needsOk() ) { | 886 | else if ( ( ( HackWidget * ) active ) ->needsOk() ) { |
887 | QSignal s; | 887 | QSignal s; |
888 | s.connect( active, SLOT( accept() ) ); | 888 | s.connect( active, SLOT( accept() ) ); |
889 | s.activate(); | 889 | s.activate(); |
890 | } | 890 | } |
891 | else { | 891 | else { |
892 | // do the same as with the select key: Map to the default action of the widget: | 892 | // do the same as with the select key: Map to the default action of the widget: |
893 | mapToDefaultAction( ke, Qt::Key_Return ); | 893 | mapToDefaultAction( ke, Qt::Key_Return ); |
894 | } | 894 | } |
895 | } | 895 | } |
896 | } | 896 | } |
897 | } | 897 | } |
898 | else if ( ke->simpleData.keycode == Qt::Key_F30 ) { | 898 | else if ( ke->simpleData.keycode == Qt::Key_F30 ) { |
899 | // Use special "select" key to do whatever default action a widget has | 899 | // Use special "select" key to do whatever default action a widget has |
900 | mapToDefaultAction( ke, Qt::Key_Space ); | 900 | mapToDefaultAction( ke, Qt::Key_Space ); |
901 | } | 901 | } |
902 | else if ( ke->simpleData.keycode == Qt::Key_Escape && | 902 | else if ( ke->simpleData.keycode == Qt::Key_Escape && |
903 | ke->simpleData.is_press ) { | 903 | ke->simpleData.is_press ) { |
904 | // Escape key closes app if focus on toplevel | 904 | // Escape key closes app if focus on toplevel |
905 | QWidget * active = activeWindow(); | 905 | QWidget * active = activeWindow(); |
906 | if ( active && active->testWFlags( WType_TopLevel ) && | 906 | if ( active && active->testWFlags( WType_TopLevel ) && |
907 | ( int ) active->winId() == ke->simpleData.window && | 907 | ( int ) active->winId() == ke->simpleData.window && |
908 | !active->testWFlags( WStyle_Dialog | WStyle_Customize | WType_Popup | WType_Desktop ) ) { | 908 | !active->testWFlags( WStyle_Dialog | WStyle_Customize | WType_Popup | WType_Desktop ) ) { |
909 | if ( active->inherits( "QDialog" ) ) { | 909 | if ( active->inherits( "QDialog" ) ) { |
910 | HackDialog * d = ( HackDialog * ) active; | 910 | HackDialog * d = ( HackDialog * ) active; |
911 | d->rejectIt(); | 911 | d->rejectIt(); |
912 | return TRUE; | 912 | return TRUE; |
913 | } | 913 | } |
914 | else if ( strcmp( argv() [ 0 ], "embeddedkonsole" ) != 0 ) { | 914 | else if ( strcmp( argv() [ 0 ], "embeddedkonsole" ) != 0 ) { |
915 | active->close(); | 915 | active->close(); |
916 | } | 916 | } |
917 | } | 917 | } |
918 | } | 918 | } |
919 | else if ( ke->simpleData.keycode >= Qt::Key_F1 && ke->simpleData.keycode <= Qt::Key_F29 ) { | 919 | else if ( ke->simpleData.keycode >= Qt::Key_F1 && ke->simpleData.keycode <= Qt::Key_F29 ) { |
920 | // this should be if ( ODevice::inst ( )-> buttonForKeycode ( ... )) | 920 | // this should be if ( ODevice::inst ( )-> buttonForKeycode ( ... )) |
921 | // but we cannot access libopie function within libqpe :( | 921 | // but we cannot access libopie function within libqpe :( |
922 | 922 | ||
923 | QWidget * active = activeWindow ( ); | 923 | QWidget * active = activeWindow ( ); |
924 | if ( active && ((int) active-> winId ( ) == ke-> simpleData.window )) { | 924 | if ( active && ((int) active-> winId ( ) == ke-> simpleData.window )) { |
925 | if ( d-> kbgrabbed ) { // we grabbed the keyboard | 925 | if ( d-> kbgrabbed ) { // we grabbed the keyboard |
926 | QChar ch ( ke-> simpleData.unicode ); | 926 | QChar ch ( ke-> simpleData.unicode ); |
927 | QKeyEvent qke ( ke-> simpleData. is_press ? QEvent::KeyPress : QEvent::KeyRelease, | 927 | QKeyEvent qke ( ke-> simpleData. is_press ? QEvent::KeyPress : QEvent::KeyRelease, |
928 | ke-> simpleData.keycode, | 928 | ke-> simpleData.keycode, |
929 | ch. latin1 ( ), | 929 | ch. latin1 ( ), |
930 | ke-> simpleData.modifiers, | 930 | ke-> simpleData.modifiers, |
931 | QString ( ch ), | 931 | QString ( ch ), |
932 | ke-> simpleData.is_auto_repeat, 1 ); | 932 | ke-> simpleData.is_auto_repeat, 1 ); |
933 | 933 | ||
934 | QObject *which = QWidget::keyboardGrabber ( ); | 934 | QObject *which = QWidget::keyboardGrabber ( ); |
935 | if ( !which ) | 935 | if ( !which ) |
936 | which = QApplication::focusWidget ( ); | 936 | which = QApplication::focusWidget ( ); |
937 | if ( !which ) | 937 | if ( !which ) |
938 | which = QApplication::activeWindow ( ); | 938 | which = QApplication::activeWindow ( ); |
939 | if ( !which ) | 939 | if ( !which ) |
940 | which = qApp; | 940 | which = qApp; |
941 | 941 | ||
942 | QApplication::sendEvent ( which, &qke ); | 942 | QApplication::sendEvent ( which, &qke ); |
943 | } | 943 | } |
944 | else { // we didn't grab the keyboard, so send the event to the launcher | 944 | else { // we didn't grab the keyboard, so send the event to the launcher |
945 | QCopEnvelope e ( "QPE/Launcher", "deviceButton(int,int,int)" ); | 945 | QCopEnvelope e ( "QPE/Launcher", "deviceButton(int,int,int)" ); |
946 | e << int( ke-> simpleData.keycode ) << int( ke-> simpleData. is_press ) << int( ke-> simpleData.is_auto_repeat ); | 946 | e << int( ke-> simpleData.keycode ) << int( ke-> simpleData. is_press ) << int( ke-> simpleData.is_auto_repeat ); |
947 | } | 947 | } |
948 | } | 948 | } |
949 | return true; | 949 | return true; |
950 | } | 950 | } |
951 | } | 951 | } |
952 | if ( e->type == QWSEvent::Focus ) { | 952 | if ( e->type == QWSEvent::Focus ) { |
953 | QWSFocusEvent * fe = ( QWSFocusEvent* ) e; | 953 | QWSFocusEvent * fe = ( QWSFocusEvent* ) e; |
954 | if ( !fe->simpleData.get_focus ) { | 954 | if ( !fe->simpleData.get_focus ) { |
955 | QWidget * active = activeWindow(); | 955 | QWidget * active = activeWindow(); |
956 | while ( active && active->isPopup() ) { | 956 | while ( active && active->isPopup() ) { |
957 | active->close(); | 957 | active->close(); |
958 | active = activeWindow(); | 958 | active = activeWindow(); |
959 | } | 959 | } |
960 | } | 960 | } |
961 | else { | 961 | else { |
962 | // make sure our modal widget is ALWAYS on top | 962 | // make sure our modal widget is ALWAYS on top |
963 | QWidget *topm = activeModalWidget(); | 963 | QWidget *topm = activeModalWidget(); |
964 | if ( topm ) { | 964 | if ( topm ) { |
965 | topm->raise(); | 965 | topm->raise(); |
966 | } | 966 | } |
967 | } | 967 | } |
968 | if ( fe->simpleData.get_focus && inputMethodDict ) { | 968 | if ( fe->simpleData.get_focus && inputMethodDict ) { |
969 | InputMethodHint m = inputMethodHint( QWidget::find( e->window() ) ); | 969 | InputMethodHint m = inputMethodHint( QWidget::find( e->window() ) ); |
970 | if ( m == AlwaysOff ) | 970 | if ( m == AlwaysOff ) |
971 | Global::hideInputMethod(); | 971 | Global::hideInputMethod(); |
972 | if ( m == AlwaysOn ) | 972 | if ( m == AlwaysOn ) |
973 | Global::showInputMethod(); | 973 | Global::showInputMethod(); |
974 | } | 974 | } |
975 | } | 975 | } |
976 | 976 | ||
977 | 977 | ||
978 | return QApplication::qwsEventFilter( e ); | 978 | return QApplication::qwsEventFilter( e ); |
979 | } | 979 | } |
980 | #endif | 980 | #endif |
981 | 981 | ||
982 | /*! | 982 | /*! |
983 | Destroys the QPEApplication. | 983 | Destroys the QPEApplication. |
984 | */ | 984 | */ |
985 | QPEApplication::~QPEApplication() | 985 | QPEApplication::~QPEApplication() |
986 | { | 986 | { |
987 | ungrabKeyboard(); | 987 | ungrabKeyboard(); |
988 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 988 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
989 | // Need to delete QCopChannels early, since the display will | 989 | // Need to delete QCopChannels early, since the display will |
990 | // be gone by the time we get to ~QObject(). | 990 | // be gone by the time we get to ~QObject(). |
991 | delete sysChannel; | 991 | delete sysChannel; |
992 | delete pidChannel; | 992 | delete pidChannel; |
993 | #endif | 993 | #endif |
994 | 994 | ||
995 | delete d; | 995 | delete d; |
996 | } | 996 | } |
997 | 997 | ||
998 | /*! | 998 | /*! |
999 | Returns <tt>$OPIEDIR/</tt>. | 999 | Returns <tt>$OPIEDIR/</tt>. |
1000 | */ | 1000 | */ |
1001 | QString QPEApplication::qpeDir() | 1001 | QString QPEApplication::qpeDir() |
1002 | { | 1002 | { |
1003 | const char * base = getenv( "OPIEDIR" ); | 1003 | const char * base = getenv( "OPIEDIR" ); |
1004 | if ( base ) | 1004 | if ( base ) |
1005 | return QString( base ) + "/"; | 1005 | return QString( base ) + "/"; |
1006 | 1006 | ||
1007 | return QString( "../" ); | 1007 | return QString( "../" ); |
1008 | } | 1008 | } |
1009 | 1009 | ||
1010 | /*! | 1010 | /*! |
1011 | Returns the user's current Document directory. There is a trailing "/". | 1011 | Returns the user's current Document directory. There is a trailing "/". |
1012 | .. well, it does now,, and there's no trailing '/' | 1012 | .. well, it does now,, and there's no trailing '/' |
1013 | */ | 1013 | */ |
1014 | QString QPEApplication::documentDir() | 1014 | QString QPEApplication::documentDir() |
1015 | { | 1015 | { |
1016 | const char* base = getenv( "HOME"); | 1016 | const char* base = getenv( "HOME"); |
1017 | if ( base ) | 1017 | if ( base ) |
1018 | return QString( base ) + "/Documents"; | 1018 | return QString( base ) + "/Documents"; |
1019 | 1019 | ||
1020 | return QString( "../Documents" ); | 1020 | return QString( "../Documents" ); |
1021 | } | 1021 | } |
1022 | 1022 | ||
1023 | static int deforient = -1; | 1023 | static int deforient = -1; |
1024 | 1024 | ||
1025 | /*! | 1025 | /*! |
1026 | \internal | 1026 | \internal |
1027 | */ | 1027 | */ |
1028 | int QPEApplication::defaultRotation() | 1028 | int QPEApplication::defaultRotation() |
1029 | { | 1029 | { |
1030 | if ( deforient < 0 ) { | 1030 | if ( deforient < 0 ) { |
1031 | QString d = getenv( "QWS_DISPLAY" ); | 1031 | QString d = getenv( "QWS_DISPLAY" ); |
1032 | if ( d.contains( "Rot90" ) ) { | 1032 | if ( d.contains( "Rot90" ) ) { |
1033 | deforient = 90; | 1033 | deforient = 90; |
1034 | } | 1034 | } |
1035 | else if ( d.contains( "Rot180" ) ) { | 1035 | else if ( d.contains( "Rot180" ) ) { |
1036 | deforient = 180; | 1036 | deforient = 180; |
1037 | } | 1037 | } |
1038 | else if ( d.contains( "Rot270" ) ) { | 1038 | else if ( d.contains( "Rot270" ) ) { |
1039 | deforient = 270; | 1039 | deforient = 270; |
1040 | } | 1040 | } |
1041 | else { | 1041 | else { |
1042 | deforient = 0; | 1042 | deforient = 0; |
1043 | } | 1043 | } |
1044 | } | 1044 | } |
1045 | return deforient; | 1045 | return deforient; |
1046 | } | 1046 | } |
1047 | 1047 | ||
1048 | /*! | 1048 | /*! |
1049 | \internal | 1049 | \internal |
1050 | */ | 1050 | */ |
1051 | void QPEApplication::setDefaultRotation( int r ) | 1051 | void QPEApplication::setDefaultRotation( int r ) |
1052 | { | 1052 | { |
1053 | if ( qApp->type() == GuiServer ) { | 1053 | if ( qApp->type() == GuiServer ) { |
1054 | deforient = r; | 1054 | deforient = r; |
1055 | setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 ); | 1055 | setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 ); |
1056 | Config config("qpe"); | 1056 | Config config("qpe"); |
1057 | config.setGroup( "Rotation" ); | 1057 | config.setGroup( "Rotation" ); |
1058 | config.writeEntry( "Rot", r ); | 1058 | config.writeEntry( "Rot", r ); |
1059 | } | 1059 | } |
1060 | else { | 1060 | else { |
1061 | #ifndef QT_NO_COP | 1061 | #ifndef QT_NO_COP |
1062 | { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" ); | 1062 | { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" ); |
1063 | e << r; | 1063 | e << r; |
1064 | } | 1064 | } |
1065 | #endif | 1065 | #endif |
1066 | 1066 | ||
1067 | } | 1067 | } |
1068 | } | 1068 | } |
1069 | 1069 | ||
1070 | #include <qgfx_qws.h> | ||
1071 | #include <qwindowsystem_qws.h> | ||
1072 | #include <qpixmapcache.h> | ||
1073 | |||
1074 | extern void qws_clearLoadedFonts(); | ||
1075 | |||
1076 | inline void QPEApplication::setCurrentMode( int x, int y, int depth ) | ||
1077 | { | ||
1078 | // Reset the caches | ||
1079 | qws_clearLoadedFonts(); | ||
1080 | QPixmapCache::clear(); | ||
1081 | |||
1082 | // Change the screen mode | ||
1083 | qt_screen->setMode(x, y, depth); | ||
1084 | |||
1085 | if ( qApp->type() == GuiServer ) { | ||
1086 | // Reconfigure the GuiServer | ||
1087 | qwsServer->beginDisplayReconfigure(); | ||
1088 | qwsServer->endDisplayReconfigure(); | ||
1089 | |||
1090 | // Get all the running apps to reset | ||
1091 | QCopEnvelope env( "QPE/System", "reset()" ); | ||
1092 | } | ||
1093 | } | ||
1094 | |||
1095 | inline void QPEApplication::reset() { | ||
1096 | // Reconnect to the screen | ||
1097 | qt_screen->disconnect(); | ||
1098 | qt_screen->connect( QString::null ); | ||
1099 | |||
1100 | // Redraw everything | ||
1101 | applyStyle(); | ||
1102 | } | ||
1070 | 1103 | ||
1071 | /*! | 1104 | /*! |
1072 | \internal | 1105 | \internal |
1073 | */ | 1106 | */ |
1074 | void QPEApplication::applyStyle() | 1107 | void QPEApplication::applyStyle() |
1075 | { | 1108 | { |
1076 | Config config( "qpe" ); | 1109 | Config config( "qpe" ); |
1077 | config.setGroup( "Appearance" ); | 1110 | config.setGroup( "Appearance" ); |
1078 | 1111 | ||
1079 | #if QT_VERSION > 233 | 1112 | #if QT_VERSION > 233 |
1080 | // don't block ourselves ... | 1113 | // don't block ourselves ... |
1081 | Opie::force_appearance = 0; | 1114 | Opie::force_appearance = 0; |
1082 | 1115 | ||
1083 | static QString appname = Opie::binaryName ( ); | 1116 | static QString appname = Opie::binaryName ( ); |
1084 | 1117 | ||
1085 | QStringList ex = config. readListEntry ( "NoStyle", ';' ); | 1118 | QStringList ex = config. readListEntry ( "NoStyle", ';' ); |
1086 | int nostyle = 0; | 1119 | int nostyle = 0; |
1087 | for ( QStringList::Iterator it = ex. begin ( ); it != ex. end ( ); ++it ) { | 1120 | for ( QStringList::Iterator it = ex. begin ( ); it != ex. end ( ); ++it ) { |
1088 | if ( QRegExp (( *it ). mid ( 1 ), false, true ). find ( appname, 0 ) >= 0 ) { | 1121 | if ( QRegExp (( *it ). mid ( 1 ), false, true ). find ( appname, 0 ) >= 0 ) { |
1089 | nostyle = ( *it ). left ( 1 ). toInt ( 0, 32 ); | 1122 | nostyle = ( *it ). left ( 1 ). toInt ( 0, 32 ); |
1090 | break; | 1123 | break; |
1091 | } | 1124 | } |
1092 | } | 1125 | } |
1093 | 1126 | ||
1094 | // Widget style | 1127 | // Widget style |
1095 | QString style = config.readEntry( "Style", "FlatStyle" ); | 1128 | QString style = config.readEntry( "Style", "FlatStyle" ); |
1096 | 1129 | ||
1097 | // don't set a custom style | 1130 | // don't set a custom style |
1098 | if ( nostyle & Opie::Force_Style ) | 1131 | if ( nostyle & Opie::Force_Style ) |
1099 | style = "FlatStyle"; | 1132 | style = "FlatStyle"; |
1100 | 1133 | ||
1101 | internalSetStyle ( style ); | 1134 | internalSetStyle ( style ); |
1102 | 1135 | ||
1103 | // Colors - from /etc/colors/Liquid.scheme | 1136 | // Colors - from /etc/colors/Liquid.scheme |
1104 | QColor bgcolor( config.readEntry( "Background", "#E0E0E0" ) ); | 1137 | QColor bgcolor( config.readEntry( "Background", "#E0E0E0" ) ); |
1105 | QColor btncolor( config.readEntry( "Button", "#96c8fa" ) ); | 1138 | QColor btncolor( config.readEntry( "Button", "#96c8fa" ) ); |
1106 | QPalette pal( btncolor, bgcolor ); | 1139 | QPalette pal( btncolor, bgcolor ); |
1107 | QString color = config.readEntry( "Highlight", "#73adef" ); | 1140 | QString color = config.readEntry( "Highlight", "#73adef" ); |
1108 | pal.setColor( QColorGroup::Highlight, QColor( color ) ); | 1141 | pal.setColor( QColorGroup::Highlight, QColor( color ) ); |
1109 | color = config.readEntry( "HighlightedText", "#FFFFFF" ); | 1142 | color = config.readEntry( "HighlightedText", "#FFFFFF" ); |
1110 | pal.setColor( QColorGroup::HighlightedText, QColor( color ) ); | 1143 | pal.setColor( QColorGroup::HighlightedText, QColor( color ) ); |
1111 | color = config.readEntry( "Text", "#000000" ); | 1144 | color = config.readEntry( "Text", "#000000" ); |
1112 | pal.setColor( QColorGroup::Text, QColor( color ) ); | 1145 | pal.setColor( QColorGroup::Text, QColor( color ) ); |
1113 | color = config.readEntry( "ButtonText", "#000000" ); | 1146 | color = config.readEntry( "ButtonText", "#000000" ); |
1114 | pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) ); | 1147 | pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) ); |
1115 | color = config.readEntry( "Base", "#FFFFFF" ); | 1148 | color = config.readEntry( "Base", "#FFFFFF" ); |
1116 | pal.setColor( QColorGroup::Base, QColor( color ) ); | 1149 | pal.setColor( QColorGroup::Base, QColor( color ) ); |
1117 | 1150 | ||
1118 | pal.setColor( QPalette::Disabled, QColorGroup::Text, | 1151 | pal.setColor( QPalette::Disabled, QColorGroup::Text, |
1119 | pal.color( QPalette::Active, QColorGroup::Background ).dark() ); | 1152 | pal.color( QPalette::Active, QColorGroup::Background ).dark() ); |
1120 | 1153 | ||
1121 | setPalette( pal, TRUE ); | 1154 | setPalette( pal, TRUE ); |
1122 | 1155 | ||
1123 | // Window Decoration | 1156 | // Window Decoration |
1124 | QString dec = config.readEntry( "Decoration", "Flat" ); | 1157 | QString dec = config.readEntry( "Decoration", "Flat" ); |
1125 | 1158 | ||
1126 | // don't set a custom deco | 1159 | // don't set a custom deco |
1127 | if ( nostyle & Opie::Force_Decoration ) | 1160 | if ( nostyle & Opie::Force_Decoration ) |
1128 | dec = ""; | 1161 | dec = ""; |
1129 | 1162 | ||
1130 | //qDebug ( "Setting Deco: %s -- old %s (%d)", dec.latin1(), d-> decorationName.latin1(), nostyle); | 1163 | //qDebug ( "Setting Deco: %s -- old %s (%d)", dec.latin1(), d-> decorationName.latin1(), nostyle); |
1131 | 1164 | ||
1132 | if ( dec != d->decorationName ) { | 1165 | if ( dec != d->decorationName ) { |
1133 | qwsSetDecoration( new QPEDecoration( dec ) ); | 1166 | qwsSetDecoration( new QPEDecoration( dec ) ); |
1134 | d->decorationName = dec; | 1167 | d->decorationName = dec; |
1135 | } | 1168 | } |
1136 | 1169 | ||
1137 | // Font | 1170 | // Font |
1138 | QString ff = config.readEntry( "FontFamily", font().family() ); | 1171 | QString ff = config.readEntry( "FontFamily", font().family() ); |
1139 | int fs = config.readNumEntry( "FontSize", font().pointSize() ); | 1172 | int fs = config.readNumEntry( "FontSize", font().pointSize() ); |
1140 | 1173 | ||
1141 | // don't set a custom font | 1174 | // don't set a custom font |
1142 | if ( nostyle & Opie::Force_Font ) { | 1175 | if ( nostyle & Opie::Force_Font ) { |
1143 | ff = "Vera"; | 1176 | ff = "Vera"; |
1144 | fs = 10; | 1177 | fs = 10; |
1145 | } | 1178 | } |
1146 | 1179 | ||
1147 | setFont ( QFont ( ff, fs ), true ); | 1180 | setFont ( QFont ( ff, fs ), true ); |
1148 | 1181 | ||
1149 | // revert to global blocking policy ... | 1182 | // revert to global blocking policy ... |
1150 | Opie::force_appearance = config. readBoolEntry ( "ForceStyle", false ) ? Opie::Force_All : Opie::Force_None; | 1183 | Opie::force_appearance = config. readBoolEntry ( "ForceStyle", false ) ? Opie::Force_All : Opie::Force_None; |
1151 | Opie::force_appearance &= ~nostyle; | 1184 | Opie::force_appearance &= ~nostyle; |
1152 | #endif | 1185 | #endif |
1153 | } | 1186 | } |
1154 | 1187 | ||
1155 | void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data ) | 1188 | void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data ) |
1156 | { | 1189 | { |
1157 | #ifdef Q_WS_QWS | 1190 | #ifdef Q_WS_QWS |
1158 | QDataStream stream( data, IO_ReadOnly ); | 1191 | QDataStream stream( data, IO_ReadOnly ); |
1159 | if ( msg == "applyStyle()" ) { | 1192 | if ( msg == "applyStyle()" ) { |
1160 | applyStyle(); | 1193 | applyStyle(); |
1161 | } | 1194 | } |
1162 | else if ( msg == "toggleApplicationMenu()" ) { | 1195 | else if ( msg == "toggleApplicationMenu()" ) { |
1163 | QWidget *active = activeWindow ( ); | 1196 | QWidget *active = activeWindow ( ); |
1164 | 1197 | ||
1165 | if ( active ) { | 1198 | if ( active ) { |
1166 | QPEMenuToolFocusManager *man = QPEMenuToolFocusManager::manager ( ); | 1199 | QPEMenuToolFocusManager *man = QPEMenuToolFocusManager::manager ( ); |
1167 | bool oldactive = man-> isActive ( ); | 1200 | bool oldactive = man-> isActive ( ); |
1168 | 1201 | ||
1169 | man-> setActive( !man-> isActive() ); | 1202 | man-> setActive( !man-> isActive() ); |
1170 | 1203 | ||
1171 | if ( !oldactive && !man-> isActive ( )) { // no menubar to toggle -> try O-Menu | 1204 | if ( !oldactive && !man-> isActive ( )) { // no menubar to toggle -> try O-Menu |
1172 | QCopEnvelope e ( "QPE/TaskBar", "toggleStartMenu()" ); | 1205 | QCopEnvelope e ( "QPE/TaskBar", "toggleStartMenu()" ); |
1173 | } | 1206 | } |
1174 | } | 1207 | } |
1175 | } | 1208 | } |
1176 | else if ( msg == "setDefaultRotation(int)" ) { | 1209 | else if ( msg == "setDefaultRotation(int)" ) { |
1177 | if ( type() == GuiServer ) { | 1210 | if ( type() == GuiServer ) { |
1178 | int r; | 1211 | int r; |
1179 | stream >> r; | 1212 | stream >> r; |
1180 | setDefaultRotation( r ); | 1213 | setDefaultRotation( r ); |
1181 | } | 1214 | } |
1182 | } | 1215 | } |
1216 | else if ( msg == "setCurrentMode(int,int,int)" ) { // Added: 2003-06-11 by Tim Ansell <mithro@mithis.net> | ||
1217 | if ( type() == GuiServer ) { | ||
1218 | int x, y, depth; | ||
1219 | stream >> x; | ||
1220 | stream >> y; | ||
1221 | stream >> depth; | ||
1222 | setCurrentMode( x, y, depth ); | ||
1223 | } | ||
1224 | } | ||
1225 | else if ( msg == "reset()" ) { | ||
1226 | if ( type() != GuiServer ) | ||
1227 | reset(); | ||
1228 | } | ||
1183 | else if ( msg == "setCurrentRotation(int)" ) { | 1229 | else if ( msg == "setCurrentRotation(int)" ) { |
1184 | int r; | 1230 | int r; |
1185 | stream >> r; | 1231 | stream >> r; |
1186 | setCurrentRotation( r ); | 1232 | setCurrentRotation( r ); |
1187 | } | 1233 | } |
1188 | else if ( msg == "shutdown()" ) { | 1234 | else if ( msg == "shutdown()" ) { |
1189 | if ( type() == GuiServer ) | 1235 | if ( type() == GuiServer ) |
1190 | shutdown(); | 1236 | shutdown(); |
1191 | } | 1237 | } |
1192 | else if ( msg == "quit()" ) { | 1238 | else if ( msg == "quit()" ) { |
1193 | if ( type() != GuiServer ) | 1239 | if ( type() != GuiServer ) |
1194 | tryQuit(); | 1240 | tryQuit(); |
1195 | } | 1241 | } |
1196 | else if ( msg == "forceQuit()" ) { | 1242 | else if ( msg == "forceQuit()" ) { |
1197 | if ( type() != GuiServer ) | 1243 | if ( type() != GuiServer ) |
1198 | quit(); | 1244 | quit(); |
1199 | } | 1245 | } |
1200 | else if ( msg == "restart()" ) { | 1246 | else if ( msg == "restart()" ) { |
1201 | if ( type() == GuiServer ) | 1247 | if ( type() == GuiServer ) |
1202 | restart(); | 1248 | restart(); |
1203 | } | 1249 | } |
1204 | else if ( msg == "language(QString)" ) { | 1250 | else if ( msg == "language(QString)" ) { |
1205 | if ( type() == GuiServer ) { | 1251 | if ( type() == GuiServer ) { |
1206 | QString l; | 1252 | QString l; |
1207 | stream >> l; | 1253 | stream >> l; |
1208 | QString cl = getenv( "LANG" ); | 1254 | QString cl = getenv( "LANG" ); |
1209 | if ( cl != l ) { | 1255 | if ( cl != l ) { |
1210 | if ( l.isNull() ) | 1256 | if ( l.isNull() ) |
1211 | unsetenv( "LANG" ); | 1257 | unsetenv( "LANG" ); |
1212 | else | 1258 | else |
1213 | setenv( "LANG", l.latin1(), 1 ); | 1259 | setenv( "LANG", l.latin1(), 1 ); |
1214 | restart(); | 1260 | restart(); |
1215 | } | 1261 | } |
1216 | } | 1262 | } |
1217 | } | 1263 | } |
1218 | else if ( msg == "timeChange(QString)" ) { | 1264 | else if ( msg == "timeChange(QString)" ) { |
1219 | QString t; | 1265 | QString t; |
1220 | stream >> t; | 1266 | stream >> t; |
1221 | if ( t.isNull() ) | 1267 | if ( t.isNull() ) |
1222 | unsetenv( "TZ" ); | 1268 | unsetenv( "TZ" ); |
1223 | else | 1269 | else |
1224 | setenv( "TZ", t.latin1(), 1 ); | 1270 | setenv( "TZ", t.latin1(), 1 ); |
1225 | // emit the signal so everyone else knows... | 1271 | // emit the signal so everyone else knows... |
1226 | emit timeChanged(); | 1272 | emit timeChanged(); |
1227 | } | 1273 | } |
1228 | else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) { | 1274 | else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) { |
1229 | if ( type() == GuiServer ) { | 1275 | if ( type() == GuiServer ) { |
1230 | QDateTime when; | 1276 | QDateTime when; |
1231 | QCString channel, message; | 1277 | QCString channel, message; |
1232 | int data; | 1278 | int data; |
1233 | stream >> when >> channel >> message >> data; | 1279 | stream >> when >> channel >> message >> data; |
1234 | AlarmServer::addAlarm( when, channel, message, data ); | 1280 | AlarmServer::addAlarm( when, channel, message, data ); |
1235 | } | 1281 | } |
1236 | } | 1282 | } |
1237 | else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) { | 1283 | else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) { |
1238 | if ( type() == GuiServer ) { | 1284 | if ( type() == GuiServer ) { |
1239 | QDateTime when; | 1285 | QDateTime when; |
1240 | QCString channel, message; | 1286 | QCString channel, message; |
1241 | int data; | 1287 | int data; |
1242 | stream >> when >> channel >> message >> data; | 1288 | stream >> when >> channel >> message >> data; |
1243 | AlarmServer::deleteAlarm( when, channel, message, data ); | 1289 | AlarmServer::deleteAlarm( when, channel, message, data ); |
1244 | } | 1290 | } |
1245 | } | 1291 | } |
1246 | else if ( msg == "clockChange(bool)" ) { | 1292 | else if ( msg == "clockChange(bool)" ) { |
1247 | int tmp; | 1293 | int tmp; |
1248 | stream >> tmp; | 1294 | stream >> tmp; |
1249 | emit clockChanged( tmp ); | 1295 | emit clockChanged( tmp ); |
1250 | } | 1296 | } |
1251 | else if ( msg == "weekChange(bool)" ) { | 1297 | else if ( msg == "weekChange(bool)" ) { |
1252 | int tmp; | 1298 | int tmp; |
1253 | stream >> tmp; | 1299 | stream >> tmp; |
1254 | emit weekChanged( tmp ); | 1300 | emit weekChanged( tmp ); |
1255 | } | 1301 | } |
1256 | else if ( msg == "setDateFormat(DateFormat)" ) { | 1302 | else if ( msg == "setDateFormat(DateFormat)" ) { |
1257 | DateFormat tmp; | 1303 | DateFormat tmp; |
1258 | stream >> tmp; | 1304 | stream >> tmp; |
1259 | emit dateFormatChanged( tmp ); | 1305 | emit dateFormatChanged( tmp ); |
1260 | } | 1306 | } |
1261 | else if ( msg == "setVolume(int,int)" ) { | 1307 | else if ( msg == "setVolume(int,int)" ) { |
1262 | int t, v; | 1308 | int t, v; |
1263 | stream >> t >> v; | 1309 | stream >> t >> v; |
1264 | setVolume( t, v ); | 1310 | setVolume( t, v ); |
1265 | emit volumeChanged( muted ); | 1311 | emit volumeChanged( muted ); |
1266 | } | 1312 | } |
1267 | else if ( msg == "volumeChange(bool)" ) { | 1313 | else if ( msg == "volumeChange(bool)" ) { |
1268 | stream >> muted; | 1314 | stream >> muted; |
1269 | setVolume(); | 1315 | setVolume(); |
1270 | emit volumeChanged( muted ); | 1316 | emit volumeChanged( muted ); |
1271 | } | 1317 | } |
1272 | else if ( msg == "setMic(int,int)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> | 1318 | else if ( msg == "setMic(int,int)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> |
1273 | int t, v; | 1319 | int t, v; |
1274 | stream >> t >> v; | 1320 | stream >> t >> v; |
1275 | setMic( t, v ); | 1321 | setMic( t, v ); |
1276 | emit micChanged( micMuted ); | 1322 | emit micChanged( micMuted ); |
1277 | } | 1323 | } |
1278 | else if ( msg == "micChange(bool)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> | 1324 | else if ( msg == "micChange(bool)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> |
1279 | stream >> micMuted; | 1325 | stream >> micMuted; |
1280 | setMic(); | 1326 | setMic(); |
1281 | emit micChanged( micMuted ); | 1327 | emit micChanged( micMuted ); |
1282 | } | 1328 | } |
1283 | else if ( msg == "setBass(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> | 1329 | else if ( msg == "setBass(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> |
1284 | int t, v; | 1330 | int t, v; |
1285 | stream >> t >> v; | 1331 | stream >> t >> v; |
1286 | setBass( t, v ); | 1332 | setBass( t, v ); |
1287 | } | 1333 | } |
1288 | else if ( msg == "bassChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> | 1334 | else if ( msg == "bassChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> |
1289 | setBass(); | 1335 | setBass(); |
1290 | } | 1336 | } |
1291 | else if ( msg == "setTreble(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> | 1337 | else if ( msg == "setTreble(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> |
1292 | int t, v; | 1338 | int t, v; |
1293 | stream >> t >> v; | 1339 | stream >> t >> v; |
1294 | setTreble( t, v ); | 1340 | setTreble( t, v ); |
1295 | } | 1341 | } |
1296 | else if ( msg == "trebleChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> | 1342 | else if ( msg == "trebleChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> |
1297 | setTreble(); | 1343 | setTreble(); |
1298 | } else if ( msg == "getMarkedText()" ) { | 1344 | } else if ( msg == "getMarkedText()" ) { |
1299 | if ( type() == GuiServer ) { | 1345 | if ( type() == GuiServer ) { |
1300 | const ushort unicode = 'C'-'@'; | 1346 | const ushort unicode = 'C'-'@'; |
1301 | const int scan = Key_C; | 1347 | const int scan = Key_C; |
1302 | qwsServer->processKeyEvent( unicode, scan, ControlButton, TRUE, FALSE ); | 1348 | qwsServer->processKeyEvent( unicode, scan, ControlButton, TRUE, FALSE ); |
1303 | qwsServer->processKeyEvent( unicode, scan, ControlButton, FALSE, FALSE ); | 1349 | qwsServer->processKeyEvent( unicode, scan, ControlButton, FALSE, FALSE ); |
1304 | } | 1350 | } |
1305 | } else if ( msg == "newChannel(QString)") { | 1351 | } else if ( msg == "newChannel(QString)") { |
1306 | QString myChannel = "QPE/Application/" + d->appName; | 1352 | QString myChannel = "QPE/Application/" + d->appName; |
1307 | QString channel; | 1353 | QString channel; |
1308 | stream >> channel; | 1354 | stream >> channel; |
1309 | if (channel == myChannel) { | 1355 | if (channel == myChannel) { |
1310 | processQCopFile(); | 1356 | processQCopFile(); |
1311 | d->sendQCopQ(); | 1357 | d->sendQCopQ(); |
1312 | } | 1358 | } |
1313 | } | 1359 | } |
1314 | 1360 | ||
1315 | 1361 | ||
1316 | #endif | 1362 | #endif |
1317 | } | 1363 | } |
1318 | 1364 | ||
1319 | #include <qmetaobject.h> | 1365 | #include <qmetaobject.h> |
1320 | 1366 | ||
1321 | QWidget *QPEApplication::nextWidget(QWidgetList* list, QWidget* _wid) { | 1367 | QWidget *QPEApplication::nextWidget(QWidgetList* list, QWidget* _wid) { |
1322 | QWidget *next = 0; | 1368 | QWidget *next = 0; |
1323 | if ( list->isEmpty() || list->count() == 1 ) | 1369 | if ( list->isEmpty() || list->count() == 1 ) |
1324 | next = _wid; | 1370 | next = _wid; |
1325 | else{ | 1371 | else{ |
1326 | QWidget* wid; | 1372 | QWidget* wid; |
1327 | uint idx = list->findRef( _wid ); | 1373 | uint idx = list->findRef( _wid ); |
1328 | uint count = list->count(); | 1374 | uint count = list->count(); |
1329 | 1375 | ||
1330 | /* one time through the list hacky we may not start with idx but end with it*/ | 1376 | /* one time through the list hacky we may not start with idx but end with it*/ |
1331 | for (uint i = (idx + 1)%count; true; i=(i+1)%count ) { | 1377 | for (uint i = (idx + 1)%count; true; i=(i+1)%count ) { |
1332 | wid = list->at(i); | 1378 | wid = list->at(i); |
1333 | if ( wid == _wid ) { | 1379 | if ( wid == _wid ) { |
1334 | next = _wid; | 1380 | next = _wid; |
1335 | break; | 1381 | break; |
1336 | }else if ((( wid->inherits("QMainWindow") || | 1382 | }else if ((( wid->inherits("QMainWindow") || |
1337 | wid->inherits("QDialog") ) && | 1383 | wid->inherits("QDialog") ) && |
1338 | wid != qApp->desktop() && !wid->isHidden() ) || | 1384 | wid != qApp->desktop() && !wid->isHidden() ) || |
1339 | ( wid == mainWidget() || wid == d->qpe_main_widget ) ){ | 1385 | ( wid == mainWidget() || wid == d->qpe_main_widget ) ){ |
1340 | next = wid; | 1386 | next = wid; |
1341 | break; | 1387 | break; |
1342 | } | 1388 | } |
1343 | } | 1389 | } |
1344 | } | 1390 | } |
1345 | 1391 | ||
1346 | delete list; | 1392 | delete list; |
1347 | return next; | 1393 | return next; |
1348 | } | 1394 | } |
1349 | /*! | 1395 | /*! |
1350 | \internal | 1396 | \internal |
1351 | */ | 1397 | */ |
1352 | // ########## raise()ing main window should raise and set active | 1398 | // ########## raise()ing main window should raise and set active |
1353 | // ########## it and then all childen. This belongs in Qt/Embedded | 1399 | // ########## it and then all childen. This belongs in Qt/Embedded |
1354 | /* | 1400 | /* |
1355 | * slightly change in behaviour to kill the need of modality in Opie | 1401 | * slightly change in behaviour to kill the need of modality in Opie |
1356 | * If any of the topLevelWidgets !isFullyObscured we highlight the next | 1402 | * If any of the topLevelWidgets !isFullyObscured we highlight the next |
1357 | * top level window | 1403 | * top level window |
1358 | * 1)If visible and not modal we iterate over the list of top level widgets | 1404 | * 1)If visible and not modal we iterate over the list of top level widgets |
1359 | * 2)If modal we we make the modal and its parent toplevel widget visible if available | 1405 | * 2)If modal we we make the modal and its parent toplevel widget visible if available |
1360 | * 3)else make topLevel visible | 1406 | * 3)else make topLevel visible |
1361 | * | 1407 | * |
1362 | * send qcop if necessary and save current visible widget if not modal | 1408 | * send qcop if necessary and save current visible widget if not modal |
1363 | */ | 1409 | */ |
1364 | bool QPEApplication::raiseAppropriateWindow() | 1410 | bool QPEApplication::raiseAppropriateWindow() |
1365 | { | 1411 | { |
1366 | bool r = FALSE; | 1412 | bool r = FALSE; |
1367 | 1413 | ||
1368 | QWidget *top = d->qpe_main_widget ? d->qpe_main_widget : mainWidget(); | 1414 | QWidget *top = d->qpe_main_widget ? d->qpe_main_widget : mainWidget(); |
1369 | /* 1. */ | 1415 | /* 1. */ |
1370 | if ( ( top && (top->isVisible() ) || ( d->lastWidget && d->lastWidget->isVisible() ) ) && | 1416 | if ( ( top && (top->isVisible() ) || ( d->lastWidget && d->lastWidget->isVisible() ) ) && |
1371 | !activeModalWidget() ) { | 1417 | !activeModalWidget() ) { |
1372 | r = TRUE; | 1418 | r = TRUE; |
1373 | /*wid will be valid and topLevelWidgets will be deleted properly.. */ | 1419 | /*wid will be valid and topLevelWidgets will be deleted properly.. */ |
1374 | QWidget *wid = nextWidget( topLevelWidgets(), | 1420 | QWidget *wid = nextWidget( topLevelWidgets(), |
1375 | d->lastWidget ? (QWidget*)d->lastWidget : top ); | 1421 | d->lastWidget ? (QWidget*)d->lastWidget : top ); |
1376 | /* keep the size window got but not for root*/ | 1422 | /* keep the size window got but not for root*/ |
1377 | if ( top == wid ) | 1423 | if ( top == wid ) |
1378 | d->show_mx(top, d->nomaximize ); | 1424 | d->show_mx(top, d->nomaximize ); |
1379 | else | 1425 | else |
1380 | wid->show(); | 1426 | wid->show(); |
1381 | 1427 | ||
1382 | wid->raise(); | 1428 | wid->raise(); |
1383 | wid->setActiveWindow(); | 1429 | wid->setActiveWindow(); |
1384 | d->lastWidget = wid; | 1430 | d->lastWidget = wid; |
1385 | }else if ( activeModalWidget() ) { | 1431 | }else if ( activeModalWidget() ) { |
1386 | QWidget* mod = activeModalWidget(); | 1432 | QWidget* mod = activeModalWidget(); |
1387 | /* get the parent of the modal and its topLevelWidget as background widget */ | 1433 | /* get the parent of the modal and its topLevelWidget as background widget */ |
1388 | QWidget* par = activeModalWidget()->parentWidget() ? activeModalWidget()->parentWidget()->topLevelWidget() : 0; | 1434 | QWidget* par = activeModalWidget()->parentWidget() ? activeModalWidget()->parentWidget()->topLevelWidget() : 0; |
1389 | if (par ) { | 1435 | if (par ) { |
1390 | if (par == top ) | 1436 | if (par == top ) |
1391 | d->show_mx(par, d->nomaximize ); | 1437 | d->show_mx(par, d->nomaximize ); |
1392 | else | 1438 | else |
1393 | par->show(); | 1439 | par->show(); |
1394 | par->raise(); | 1440 | par->raise(); |
1395 | par->setActiveWindow(); | 1441 | par->setActiveWindow(); |
1396 | } | 1442 | } |
1397 | mod->show(); | 1443 | mod->show(); |
1398 | mod->raise(); | 1444 | mod->raise(); |
1399 | mod->setActiveWindow(); | 1445 | mod->setActiveWindow(); |
1400 | }else if (top){ | 1446 | }else if (top){ |
1401 | d->show_mx(top, d->nomaximize ); | 1447 | d->show_mx(top, d->nomaximize ); |
1402 | top->raise(); | 1448 | top->raise(); |
1403 | top->setActiveWindow(); | 1449 | top->setActiveWindow(); |
1404 | d->lastWidget = top; | 1450 | d->lastWidget = top; |
1405 | } | 1451 | } |
1406 | 1452 | ||
1407 | if (!r && d->preloaded ) { | 1453 | if (!r && d->preloaded ) { |
1408 | QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); | 1454 | QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); |
1409 | e << d->appName; | 1455 | e << d->appName; |
1410 | } | 1456 | } |
1411 | 1457 | ||
1412 | return r; | 1458 | return r; |
1413 | } | 1459 | } |
1414 | 1460 | ||
1415 | 1461 | ||
1416 | void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data) | 1462 | void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data) |
1417 | { | 1463 | { |
1418 | #ifdef Q_WS_QWS | 1464 | #ifdef Q_WS_QWS |
1419 | 1465 | ||
1420 | if ( msg == "quit()" ) { | 1466 | if ( msg == "quit()" ) { |
1421 | tryQuit(); | 1467 | tryQuit(); |
1422 | } | 1468 | } |
1423 | else if ( msg == "quitIfInvisible()" ) { | 1469 | else if ( msg == "quitIfInvisible()" ) { |
1424 | if ( d->qpe_main_widget && !d->qpe_main_widget->isVisible() ) | 1470 | if ( d->qpe_main_widget && !d->qpe_main_widget->isVisible() ) |
1425 | quit(); | 1471 | quit(); |
1426 | } | 1472 | } |
1427 | else if ( msg == "close()" ) { | 1473 | else if ( msg == "close()" ) { |
1428 | hideOrQuit(); | 1474 | hideOrQuit(); |
1429 | } | 1475 | } |
1430 | else if ( msg == "disablePreload()" ) { | 1476 | else if ( msg == "disablePreload()" ) { |
1431 | d->preloaded = FALSE; | 1477 | d->preloaded = FALSE; |
1432 | d->keep_running = TRUE; | 1478 | d->keep_running = TRUE; |
1433 | /* so that quit will quit */ | 1479 | /* so that quit will quit */ |
1434 | } | 1480 | } |
1435 | else if ( msg == "enablePreload()" ) { | 1481 | else if ( msg == "enablePreload()" ) { |
1436 | if (d->qpe_main_widget) | 1482 | if (d->qpe_main_widget) |
1437 | d->preloaded = TRUE; | 1483 | d->preloaded = TRUE; |
1438 | d->keep_running = TRUE; | 1484 | d->keep_running = TRUE; |
1439 | /* so next quit won't quit */ | 1485 | /* so next quit won't quit */ |
1440 | } | 1486 | } |
1441 | else if ( msg == "raise()" ) { | 1487 | else if ( msg == "raise()" ) { |
1442 | d->keep_running = TRUE; | 1488 | d->keep_running = TRUE; |
1443 | d->notbusysent = FALSE; | 1489 | d->notbusysent = FALSE; |
1444 | raiseAppropriateWindow(); | 1490 | raiseAppropriateWindow(); |
1445 | // Tell the system we're still chugging along... | 1491 | // Tell the system we're still chugging along... |
1446 | QCopEnvelope e("QPE/System", "appRaised(QString)"); | 1492 | QCopEnvelope e("QPE/System", "appRaised(QString)"); |
1447 | e << d->appName; | 1493 | e << d->appName; |
1448 | } | 1494 | } |
1449 | else if ( msg == "flush()" ) { | 1495 | else if ( msg == "flush()" ) { |
1450 | emit flush(); | 1496 | emit flush(); |
1451 | // we need to tell the desktop | 1497 | // we need to tell the desktop |
1452 | QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" ); | 1498 | QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" ); |
1453 | e << d->appName; | 1499 | e << d->appName; |
1454 | } | 1500 | } |
1455 | else if ( msg == "reload()" ) { | 1501 | else if ( msg == "reload()" ) { |
1456 | emit reload(); | 1502 | emit reload(); |
1457 | } | 1503 | } |
1458 | else if ( msg == "setDocument(QString)" ) { | 1504 | else if ( msg == "setDocument(QString)" ) { |
1459 | d->keep_running = TRUE; | 1505 | d->keep_running = TRUE; |
1460 | QDataStream stream( data, IO_ReadOnly ); | 1506 | QDataStream stream( data, IO_ReadOnly ); |
1461 | QString doc; | 1507 | QString doc; |
1462 | stream >> doc; | 1508 | stream >> doc; |
1463 | QWidget *mw = mainWidget(); | 1509 | QWidget *mw = mainWidget(); |
1464 | if ( !mw ) | 1510 | if ( !mw ) |
1465 | mw = d->qpe_main_widget; | 1511 | mw = d->qpe_main_widget; |
1466 | if ( mw ) | 1512 | if ( mw ) |
1467 | Global::setDocument( mw, doc ); | 1513 | Global::setDocument( mw, doc ); |
1468 | 1514 | ||
1469 | } else if ( msg == "QPEProcessQCop()" ) { | 1515 | } else if ( msg == "QPEProcessQCop()" ) { |
1470 | processQCopFile(); | 1516 | processQCopFile(); |
1471 | d->sendQCopQ(); | 1517 | d->sendQCopQ(); |
1472 | }else | 1518 | }else |
1473 | { | 1519 | { |
1474 | bool p = d->keep_running; | 1520 | bool p = d->keep_running; |
1475 | d->keep_running = FALSE; | 1521 | d->keep_running = FALSE; |
1476 | emit appMessage( msg, data); | 1522 | emit appMessage( msg, data); |
1477 | if ( d->keep_running ) { | 1523 | if ( d->keep_running ) { |
1478 | d->notbusysent = FALSE; | 1524 | d->notbusysent = FALSE; |
1479 | raiseAppropriateWindow(); | 1525 | raiseAppropriateWindow(); |
1480 | if ( !p ) { | 1526 | if ( !p ) { |
1481 | // Tell the system we're still chugging along... | 1527 | // Tell the system we're still chugging along... |
1482 | #ifndef QT_NO_COP | 1528 | #ifndef QT_NO_COP |
1483 | QCopEnvelope e("QPE/System", "appRaised(QString)"); | 1529 | QCopEnvelope e("QPE/System", "appRaised(QString)"); |
1484 | e << d->appName; | 1530 | e << d->appName; |
1485 | #endif | 1531 | #endif |
1486 | } | 1532 | } |
1487 | } | 1533 | } |
1488 | if ( p ) | 1534 | if ( p ) |
1489 | d->keep_running = p; | 1535 | d->keep_running = p; |
1490 | } | 1536 | } |
1491 | #endif | 1537 | #endif |
1492 | } | 1538 | } |
1493 | 1539 | ||
1494 | 1540 | ||
1495 | /*! | 1541 | /*! |
1496 | Sets widget \a mw as the mainWidget() and shows it. For small windows, | 1542 | Sets widget \a mw as the mainWidget() and shows it. For small windows, |
1497 | consider passing TRUE for \a nomaximize rather than the default FALSE. | 1543 | consider passing TRUE for \a nomaximize rather than the default FALSE. |
1498 | 1544 | ||
1499 | \sa showMainDocumentWidget() | 1545 | \sa showMainDocumentWidget() |
1500 | */ | 1546 | */ |
1501 | void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize ) | 1547 | void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize ) |
1502 | { | 1548 | { |
1503 | d->show(mw, nomaximize ); | 1549 | d->show(mw, nomaximize ); |
1504 | } | 1550 | } |
1505 | 1551 | ||
1506 | /*! | 1552 | /*! |
1507 | Sets widget \a mw as the mainWidget() and shows it. For small windows, | 1553 | Sets widget \a mw as the mainWidget() and shows it. For small windows, |
1508 | consider passing TRUE for \a nomaximize rather than the default FALSE. | 1554 | consider passing TRUE for \a nomaximize rather than the default FALSE. |
1509 | 1555 | ||
1510 | This calls designates the application as | 1556 | This calls designates the application as |
1511 | a \link docwidget.html document-oriented\endlink application. | 1557 | a \link docwidget.html document-oriented\endlink application. |
1512 | 1558 | ||
1513 | The \a mw widget \e must have this slot: setDocument(const QString&). | 1559 | The \a mw widget \e must have this slot: setDocument(const QString&). |
1514 | 1560 | ||
1515 | \sa showMainWidget() | 1561 | \sa showMainWidget() |
1516 | */ | 1562 | */ |
1517 | void QPEApplication::showMainDocumentWidget( QWidget* mw, bool nomaximize ) | 1563 | void QPEApplication::showMainDocumentWidget( QWidget* mw, bool nomaximize ) |
1518 | { | 1564 | { |
1519 | if ( mw && argc() == 2 ) | 1565 | if ( mw && argc() == 2 ) |
1520 | Global::setDocument( mw, QString::fromUtf8(argv()[1]) ); | 1566 | Global::setDocument( mw, QString::fromUtf8(argv()[1]) ); |
1521 | 1567 | ||
1522 | 1568 | ||
1523 | d->show(mw, nomaximize ); | 1569 | d->show(mw, nomaximize ); |
1524 | } | 1570 | } |
1525 | 1571 | ||
1526 | 1572 | ||
1527 | /*! | 1573 | /*! |
1528 | If an application is started via a \link qcop.html QCop\endlink | 1574 | If an application is started via a \link qcop.html QCop\endlink |
1529 | message, the application will process the \link qcop.html | 1575 | message, the application will process the \link qcop.html |
1530 | QCop\endlink message and then quit. If the application calls this | 1576 | QCop\endlink message and then quit. If the application calls this |
1531 | function while processing a \link qcop.html QCop\endlink message, | 1577 | function while processing a \link qcop.html QCop\endlink message, |
1532 | after processing its outstanding \link qcop.html QCop\endlink | 1578 | after processing its outstanding \link qcop.html QCop\endlink |
1533 | messages the application will start 'properly' and show itself. | 1579 | messages the application will start 'properly' and show itself. |
1534 | 1580 | ||
1535 | \sa keepRunning() | 1581 | \sa keepRunning() |
1536 | */ | 1582 | */ |
1537 | void QPEApplication::setKeepRunning() | 1583 | void QPEApplication::setKeepRunning() |
1538 | { | 1584 | { |
1539 | if ( qApp && qApp->inherits( "QPEApplication" ) ) { | 1585 | if ( qApp && qApp->inherits( "QPEApplication" ) ) { |
1540 | QPEApplication * qpeApp = ( QPEApplication* ) qApp; | 1586 | QPEApplication * qpeApp = ( QPEApplication* ) qApp; |
1541 | qpeApp->d->keep_running = TRUE; | 1587 | qpeApp->d->keep_running = TRUE; |
1542 | } | 1588 | } |
1543 | } | 1589 | } |
1544 | 1590 | ||
1545 | /*! | 1591 | /*! |
1546 | Returns TRUE if the application will quit after processing the | 1592 | Returns TRUE if the application will quit after processing the |
1547 | current list of qcop messages; otherwise returns FALSE. | 1593 | current list of qcop messages; otherwise returns FALSE. |
1548 | 1594 | ||
1549 | \sa setKeepRunning() | 1595 | \sa setKeepRunning() |
1550 | */ | 1596 | */ |
1551 | bool QPEApplication::keepRunning() const | 1597 | bool QPEApplication::keepRunning() const |
1552 | { | 1598 | { |
1553 | return d->keep_running; | 1599 | return d->keep_running; |
1554 | } | 1600 | } |
1555 | 1601 | ||
1556 | /*! | 1602 | /*! |
1557 | \internal | 1603 | \internal |
1558 | */ | 1604 | */ |
1559 | void QPEApplication::internalSetStyle( const QString &style ) | 1605 | void QPEApplication::internalSetStyle( const QString &style ) |
1560 | { | 1606 | { |
1561 | #if QT_VERSION >= 300 | 1607 | #if QT_VERSION >= 300 |
1562 | if ( style == "QPE" ) { | 1608 | if ( style == "QPE" ) { |
1563 | setStyle( new QPEStyle ); | 1609 | setStyle( new QPEStyle ); |
1564 | } | 1610 | } |
1565 | else { | 1611 | else { |
1566 | QStyle *s = QStyleFactory::create( style ); | 1612 | QStyle *s = QStyleFactory::create( style ); |
1567 | if ( s ) | 1613 | if ( s ) |
1568 | setStyle( s ); | 1614 | setStyle( s ); |
1569 | } | 1615 | } |
1570 | #else | 1616 | #else |
1571 | if ( style == "Windows" ) { | 1617 | if ( style == "Windows" ) { |
1572 | setStyle( new QWindowsStyle ); | 1618 | setStyle( new QWindowsStyle ); |
1573 | } | 1619 | } |
1574 | else if ( style == "QPE" ) { | 1620 | else if ( style == "QPE" ) { |
1575 | setStyle( new QPEStyle ); | 1621 | setStyle( new QPEStyle ); |
1576 | } | 1622 | } |
1577 | else if ( style == "Light" ) { | 1623 | else if ( style == "Light" ) { |
1578 | setStyle( new LightStyle ); | 1624 | setStyle( new LightStyle ); |
1579 | } | 1625 | } |
1580 | #ifndef QT_NO_STYLE_PLATINUM | 1626 | #ifndef QT_NO_STYLE_PLATINUM |
1581 | else if ( style == "Platinum" ) { | 1627 | else if ( style == "Platinum" ) { |
1582 | setStyle( new QPlatinumStyle ); | 1628 | setStyle( new QPlatinumStyle ); |
1583 | } | 1629 | } |
1584 | #endif | 1630 | #endif |
1585 | #ifndef QT_NO_STYLE_MOTIF | 1631 | #ifndef QT_NO_STYLE_MOTIF |
1586 | else if ( style == "Motif" ) { | 1632 | else if ( style == "Motif" ) { |
1587 | setStyle( new QMotifStyle ); | 1633 | setStyle( new QMotifStyle ); |
1588 | } | 1634 | } |
1589 | #endif | 1635 | #endif |
1590 | #ifndef QT_NO_STYLE_MOTIFPLUS | 1636 | #ifndef QT_NO_STYLE_MOTIFPLUS |
1591 | else if ( style == "MotifPlus" ) { | 1637 | else if ( style == "MotifPlus" ) { |
1592 | setStyle( new QMotifPlusStyle ); | 1638 | setStyle( new QMotifPlusStyle ); |
1593 | } | 1639 | } |
1594 | #endif | 1640 | #endif |
1595 | 1641 | ||
1596 | else { | 1642 | else { |
1597 | QStyle *sty = 0; | 1643 | QStyle *sty = 0; |
1598 | QString path = QPEApplication::qpeDir ( ) + "/plugins/styles/"; | 1644 | QString path = QPEApplication::qpeDir ( ) + "/plugins/styles/"; |
1599 | 1645 | ||
1600 | if ( style. find ( ".so" ) > 0 ) | 1646 | if ( style. find ( ".so" ) > 0 ) |
1601 | path += style; | 1647 | path += style; |
1602 | else | 1648 | else |
1603 | path = path + "lib" + style. lower ( ) + ".so"; // compatibility | 1649 | path = path + "lib" + style. lower ( ) + ".so"; // compatibility |
1604 | 1650 | ||
1605 | static QLibrary *lastlib = 0; | 1651 | static QLibrary *lastlib = 0; |
1606 | static StyleInterface *lastiface = 0; | 1652 | static StyleInterface *lastiface = 0; |
1607 | 1653 | ||
1608 | QLibrary *lib = new QLibrary ( path ); | 1654 | QLibrary *lib = new QLibrary ( path ); |
1609 | StyleInterface *iface = 0; | 1655 | StyleInterface *iface = 0; |
1610 | 1656 | ||
1611 | if (( lib-> queryInterface ( IID_Style, ( QUnknownInterface ** ) &iface ) == QS_OK ) && iface ) | 1657 | if (( lib-> queryInterface ( IID_Style, ( QUnknownInterface ** ) &iface ) == QS_OK ) && iface ) |
1612 | sty = iface-> style ( ); | 1658 | sty = iface-> style ( ); |
1613 | 1659 | ||
1614 | if ( sty ) { | 1660 | if ( sty ) { |
1615 | setStyle ( sty ); | 1661 | setStyle ( sty ); |
1616 | 1662 | ||
1617 | if ( lastiface ) | 1663 | if ( lastiface ) |
1618 | lastiface-> release ( ); | 1664 | lastiface-> release ( ); |
1619 | lastiface = iface; | 1665 | lastiface = iface; |
1620 | 1666 | ||
1621 | if ( lastlib ) { | 1667 | if ( lastlib ) { |
1622 | lastlib-> unload ( ); | 1668 | lastlib-> unload ( ); |
1623 | delete lastlib; | 1669 | delete lastlib; |
1624 | } | 1670 | } |
1625 | lastlib = lib; | 1671 | lastlib = lib; |
1626 | } | 1672 | } |
1627 | else { | 1673 | else { |
1628 | if ( iface ) | 1674 | if ( iface ) |
1629 | iface-> release ( ); | 1675 | iface-> release ( ); |
1630 | delete lib; | 1676 | delete lib; |
1631 | 1677 | ||
1632 | setStyle ( new LightStyle ( )); | 1678 | setStyle ( new LightStyle ( )); |
1633 | } | 1679 | } |
1634 | } | 1680 | } |
1635 | #endif | 1681 | #endif |
1636 | } | 1682 | } |
1637 | 1683 | ||
1638 | /*! | 1684 | /*! |
1639 | \internal | 1685 | \internal |
1640 | */ | 1686 | */ |
1641 | void QPEApplication::prepareForTermination( bool willrestart ) | 1687 | void QPEApplication::prepareForTermination( bool willrestart ) |
1642 | { | 1688 | { |
1643 | if ( willrestart ) { | 1689 | if ( willrestart ) { |
1644 | // Draw a big wait icon, the image can be altered in later revisions | 1690 | // Draw a big wait icon, the image can be altered in later revisions |
1645 | // QWidget *d = QApplication::desktop(); | 1691 | // QWidget *d = QApplication::desktop(); |
1646 | QImage img = Resource::loadImage( "launcher/new_wait" ); | 1692 | QImage img = Resource::loadImage( "launcher/new_wait" ); |
1647 | QPixmap pix; | 1693 | QPixmap pix; |
1648 | pix.convertFromImage( img.smoothScale( 1 * img.width(), 1 * img.height() ) ); | 1694 | pix.convertFromImage( img.smoothScale( 1 * img.width(), 1 * img.height() ) ); |
1649 | QLabel *lblWait = new QLabel( 0, "wait hack!", QWidget::WStyle_Customize | | 1695 | QLabel *lblWait = new QLabel( 0, "wait hack!", QWidget::WStyle_Customize | |
1650 | QWidget::WStyle_NoBorder | QWidget::WStyle_Tool ); | 1696 | QWidget::WStyle_NoBorder | QWidget::WStyle_Tool ); |
1651 | lblWait->setPixmap( pix ); | 1697 | lblWait->setPixmap( pix ); |
1652 | lblWait->setAlignment( QWidget::AlignCenter ); | 1698 | lblWait->setAlignment( QWidget::AlignCenter ); |
1653 | lblWait->show(); | 1699 | lblWait->show(); |
1654 | lblWait->showMaximized(); | 1700 | lblWait->showMaximized(); |
1655 | } | 1701 | } |
1656 | #ifndef SINGLE_APP | 1702 | #ifndef SINGLE_APP |
1657 | { QCopEnvelope envelope( "QPE/System", "forceQuit()" ); | 1703 | { QCopEnvelope envelope( "QPE/System", "forceQuit()" ); |
1658 | } | 1704 | } |
1659 | processEvents(); // ensure the message goes out. | 1705 | processEvents(); // ensure the message goes out. |
1660 | sleep( 1 ); // You have 1 second to comply. | 1706 | sleep( 1 ); // You have 1 second to comply. |
1661 | #endif | 1707 | #endif |
1662 | } | 1708 | } |
1663 | 1709 | ||
1664 | /*! | 1710 | /*! |
1665 | \internal | 1711 | \internal |
1666 | */ | 1712 | */ |
1667 | void QPEApplication::shutdown() | 1713 | void QPEApplication::shutdown() |
1668 | { | 1714 | { |
1669 | // Implement in server's QPEApplication subclass | 1715 | // Implement in server's QPEApplication subclass |
1670 | } | 1716 | } |
1671 | 1717 | ||
1672 | /*! | 1718 | /*! |
1673 | \internal | 1719 | \internal |
1674 | */ | 1720 | */ |
1675 | void QPEApplication::restart() | 1721 | void QPEApplication::restart() |
1676 | { | 1722 | { |
1677 | // Implement in server's QPEApplication subclass | 1723 | // Implement in server's QPEApplication subclass |
1678 | } | 1724 | } |
1679 | 1725 | ||
1680 | static QPtrDict<void>* stylusDict = 0; | 1726 | static QPtrDict<void>* stylusDict = 0; |
1681 | static void createDict() | 1727 | static void createDict() |
1682 | { | 1728 | { |
1683 | if ( !stylusDict ) | 1729 | if ( !stylusDict ) |
1684 | stylusDict = new QPtrDict<void>; | 1730 | stylusDict = new QPtrDict<void>; |
1685 | } | 1731 | } |
1686 | 1732 | ||
1687 | /*! | 1733 | /*! |
1688 | Returns the current StylusMode for widget \a w. | 1734 | Returns the current StylusMode for widget \a w. |
1689 | 1735 | ||
1690 | \sa setStylusOperation() StylusMode | 1736 | \sa setStylusOperation() StylusMode |
1691 | */ | 1737 | */ |
1692 | QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w ) | 1738 | QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w ) |
1693 | { | 1739 | { |
1694 | if ( stylusDict ) | 1740 | if ( stylusDict ) |
diff --git a/library/qpeapplication.h b/library/qpeapplication.h index 343e0b9..42810e8 100644 --- a/library/qpeapplication.h +++ b/library/qpeapplication.h | |||
@@ -1,207 +1,209 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #ifndef __QPE_APPLICATION_H__ | 20 | #ifndef __QPE_APPLICATION_H__ |
21 | #define __QPE_APPLICATION_H__ | 21 | #define __QPE_APPLICATION_H__ |
22 | 22 | ||
23 | #include <stdlib.h> // for setenv() | 23 | #include <stdlib.h> // for setenv() |
24 | 24 | ||
25 | #include <qglobal.h> | 25 | #include <qglobal.h> |
26 | #include <qapplication.h> | 26 | #include <qapplication.h> |
27 | #include <qdialog.h> | 27 | #include <qdialog.h> |
28 | #include <qwsdisplay_qws.h> | 28 | #include <qwsdisplay_qws.h> |
29 | #if defined(_WS_QWS_) && !defined(Q_WS_QWS) | 29 | #if defined(_WS_QWS_) && !defined(Q_WS_QWS) |
30 | #define Q_WS_QWS | 30 | #define Q_WS_QWS |
31 | #endif | 31 | #endif |
32 | #include "qpedecoration_qws.h" | 32 | #include "qpedecoration_qws.h" |
33 | #include "timestring.h" | 33 | #include "timestring.h" |
34 | 34 | ||
35 | class QCopChannel; | 35 | class QCopChannel; |
36 | class QPEApplicationData; | 36 | class QPEApplicationData; |
37 | class QWSEvent; | 37 | class QWSEvent; |
38 | class QWSKeyEvent; | 38 | class QWSKeyEvent; |
39 | 39 | ||
40 | 40 | ||
41 | class QPEApplication : public QApplication | 41 | class QPEApplication : public QApplication |
42 | { | 42 | { |
43 | Q_OBJECT | 43 | Q_OBJECT |
44 | public: | 44 | public: |
45 | QPEApplication( int& argc, char **argv, Type=GuiClient ); | 45 | QPEApplication( int& argc, char **argv, Type=GuiClient ); |
46 | ~QPEApplication(); | 46 | ~QPEApplication(); |
47 | 47 | ||
48 | static QString qpeDir(); | 48 | static QString qpeDir(); |
49 | static QString documentDir(); | 49 | static QString documentDir(); |
50 | void applyStyle(); | 50 | void applyStyle(); |
51 | void reset(); | ||
51 | static int defaultRotation(); | 52 | static int defaultRotation(); |
52 | static void setDefaultRotation(int r); | 53 | static void setDefaultRotation(int r); |
53 | static void setCurrentRotation(int r); | 54 | static void setCurrentRotation(int r); |
55 | static void setCurrentMode(int x, int y, int depth ); | ||
54 | static void grabKeyboard(); | 56 | static void grabKeyboard(); |
55 | static void ungrabKeyboard(); | 57 | static void ungrabKeyboard(); |
56 | 58 | ||
57 | enum StylusMode { | 59 | enum StylusMode { |
58 | LeftOnly, | 60 | LeftOnly, |
59 | RightOnHold | 61 | RightOnHold |
60 | // RightOnHoldLeftDelayed, etc. | 62 | // RightOnHoldLeftDelayed, etc. |
61 | }; | 63 | }; |
62 | static void setStylusOperation( QWidget*, StylusMode ); | 64 | static void setStylusOperation( QWidget*, StylusMode ); |
63 | static StylusMode stylusOperation( QWidget* ); | 65 | static StylusMode stylusOperation( QWidget* ); |
64 | 66 | ||
65 | enum InputMethodHint { | 67 | enum InputMethodHint { |
66 | Normal, | 68 | Normal, |
67 | AlwaysOff, | 69 | AlwaysOff, |
68 | AlwaysOn | 70 | AlwaysOn |
69 | }; | 71 | }; |
70 | 72 | ||
71 | enum screenSaverHint { | 73 | enum screenSaverHint { |
72 | Disable = 0, | 74 | Disable = 0, |
73 | DisableLightOff = 1, | 75 | DisableLightOff = 1, |
74 | DisableSuspend = 2, | 76 | DisableSuspend = 2, |
75 | Enable = 100 | 77 | Enable = 100 |
76 | }; | 78 | }; |
77 | 79 | ||
78 | static void setInputMethodHint( QWidget *, InputMethodHint ); | 80 | static void setInputMethodHint( QWidget *, InputMethodHint ); |
79 | static InputMethodHint inputMethodHint( QWidget * ); | 81 | static InputMethodHint inputMethodHint( QWidget * ); |
80 | 82 | ||
81 | void showMainWidget( QWidget*, bool nomax=FALSE ); | 83 | void showMainWidget( QWidget*, bool nomax=FALSE ); |
82 | void showMainDocumentWidget( QWidget*, bool nomax=FALSE ); | 84 | void showMainDocumentWidget( QWidget*, bool nomax=FALSE ); |
83 | static void showDialog( QDialog*, bool nomax=FALSE ); | 85 | static void showDialog( QDialog*, bool nomax=FALSE ); |
84 | static int execDialog( QDialog*, bool nomax=FALSE ); | 86 | static int execDialog( QDialog*, bool nomax=FALSE ); |
85 | /* Merge setTempScreenSaverMode */ | 87 | /* Merge setTempScreenSaverMode */ |
86 | #ifdef QTOPIA_INTERNAL_INITAPP | 88 | #ifdef QTOPIA_INTERNAL_INITAPP |
87 | void initApp( int argv, char **argv ); | 89 | void initApp( int argv, char **argv ); |
88 | #endif | 90 | #endif |
89 | 91 | ||
90 | static void setKeepRunning(); | 92 | static void setKeepRunning(); |
91 | bool keepRunning() const; | 93 | bool keepRunning() const; |
92 | 94 | ||
93 | bool keyboardGrabbed() const; | 95 | bool keyboardGrabbed() const; |
94 | 96 | ||
95 | int exec(); | 97 | int exec(); |
96 | 98 | ||
97 | signals: | 99 | signals: |
98 | void clientMoused(); | 100 | void clientMoused(); |
99 | void timeChanged(); | 101 | void timeChanged(); |
100 | void clockChanged( bool pm ); | 102 | void clockChanged( bool pm ); |
101 | void micChanged( bool muted ); | 103 | void micChanged( bool muted ); |
102 | void volumeChanged( bool muted ); | 104 | void volumeChanged( bool muted ); |
103 | void appMessage( const QCString& msg, const QByteArray& data); | 105 | void appMessage( const QCString& msg, const QByteArray& data); |
104 | void weekChanged( bool startOnMonday ); | 106 | void weekChanged( bool startOnMonday ); |
105 | void dateFormatChanged( DateFormat ); | 107 | void dateFormatChanged( DateFormat ); |
106 | void flush(); | 108 | void flush(); |
107 | void reload(); | 109 | void reload(); |
108 | /* linkChanged signal */ | 110 | /* linkChanged signal */ |
109 | 111 | ||
110 | private slots: | 112 | private slots: |
111 | void systemMessage( const QCString &msg, const QByteArray &data ); | 113 | void systemMessage( const QCString &msg, const QByteArray &data ); |
112 | void pidMessage( const QCString &msg, const QByteArray &data ); | 114 | void pidMessage( const QCString &msg, const QByteArray &data ); |
113 | void removeSenderFromStylusDict(); | 115 | void removeSenderFromStylusDict(); |
114 | void hideOrQuit(); | 116 | void hideOrQuit(); |
115 | 117 | ||
116 | private: | 118 | private: |
117 | inline QWidget *nextWidget( QWidgetList*, QWidget* ); | 119 | inline QWidget *nextWidget( QWidgetList*, QWidget* ); |
118 | 120 | ||
119 | protected: | 121 | protected: |
120 | bool qwsEventFilter( QWSEvent * ); | 122 | bool qwsEventFilter( QWSEvent * ); |
121 | void internalSetStyle( const QString &style ); | 123 | void internalSetStyle( const QString &style ); |
122 | void prepareForTermination(bool willrestart); | 124 | void prepareForTermination(bool willrestart); |
123 | virtual void restart(); | 125 | virtual void restart(); |
124 | virtual void shutdown(); | 126 | virtual void shutdown(); |
125 | bool eventFilter( QObject *, QEvent * ); | 127 | bool eventFilter( QObject *, QEvent * ); |
126 | void timerEvent( QTimerEvent * ); | 128 | void timerEvent( QTimerEvent * ); |
127 | bool raiseAppropriateWindow(); | 129 | bool raiseAppropriateWindow(); |
128 | virtual void tryQuit(); | 130 | virtual void tryQuit(); |
129 | #if QT_VERSION > 233 | 131 | #if QT_VERSION > 233 |
130 | virtual void polish ( QWidget * ); // this is actually implemented in qt_override.cpp (!) | 132 | virtual void polish ( QWidget * ); // this is actually implemented in qt_override.cpp (!) |
131 | #endif | 133 | #endif |
132 | private: | 134 | private: |
133 | #ifndef QT_NO_TRANSLATION | 135 | #ifndef QT_NO_TRANSLATION |
134 | void installTranslation( const QString& baseName ); | 136 | void installTranslation( const QString& baseName ); |
135 | #endif | 137 | #endif |
136 | void mapToDefaultAction( QWSKeyEvent *ke, int defKey ); | 138 | void mapToDefaultAction( QWSKeyEvent *ke, int defKey ); |
137 | void processQCopFile(); | 139 | void processQCopFile(); |
138 | 140 | ||
139 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 141 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
140 | QCopChannel *sysChannel; | 142 | QCopChannel *sysChannel; |
141 | QCopChannel *pidChannel; | 143 | QCopChannel *pidChannel; |
142 | #endif | 144 | #endif |
143 | QPEApplicationData *d; | 145 | QPEApplicationData *d; |
144 | 146 | ||
145 | bool reserved_sh; | 147 | bool reserved_sh; |
146 | 148 | ||
147 | 149 | ||
148 | 150 | ||
149 | }; | 151 | }; |
150 | 152 | ||
151 | inline void QPEApplication::showDialog( QDialog* d, bool nomax ) | 153 | inline void QPEApplication::showDialog( QDialog* d, bool nomax ) |
152 | { | 154 | { |
153 | QSize sh = d->sizeHint(); | 155 | QSize sh = d->sizeHint(); |
154 | int w = QMAX(sh.width(),d->width()); | 156 | int w = QMAX(sh.width(),d->width()); |
155 | int h = QMAX(sh.height(),d->height()); | 157 | int h = QMAX(sh.height(),d->height()); |
156 | if ( !nomax | 158 | if ( !nomax |
157 | && ( w > qApp->desktop()->width()*3/4 | 159 | && ( w > qApp->desktop()->width()*3/4 |
158 | || h > qApp->desktop()->height()*3/4 ) ) | 160 | || h > qApp->desktop()->height()*3/4 ) ) |
159 | { | 161 | { |
160 | d->showMaximized(); | 162 | d->showMaximized(); |
161 | } else { | 163 | } else { |
162 | d->resize(w,h); | 164 | d->resize(w,h); |
163 | d->show(); | 165 | d->show(); |
164 | } | 166 | } |
165 | } | 167 | } |
166 | 168 | ||
167 | inline int QPEApplication::execDialog( QDialog* d, bool nomax ) | 169 | inline int QPEApplication::execDialog( QDialog* d, bool nomax ) |
168 | { | 170 | { |
169 | showDialog(d,nomax); | 171 | showDialog(d,nomax); |
170 | return d->exec(); | 172 | return d->exec(); |
171 | } | 173 | } |
172 | 174 | ||
173 | enum Transformation { Rot0, Rot90, Rot180, Rot270 }; /* from qgfxtransformed_qws.cpp */ | 175 | enum Transformation { Rot0, Rot90, Rot180, Rot270 }; /* from qgfxtransformed_qws.cpp */ |
174 | 176 | ||
175 | inline int TransToDeg ( Transformation t ) | 177 | inline int TransToDeg ( Transformation t ) |
176 | { | 178 | { |
177 | int d = static_cast<int>( t ); | 179 | int d = static_cast<int>( t ); |
178 | return d * 90; | 180 | return d * 90; |
179 | } | 181 | } |
180 | 182 | ||
181 | inline Transformation DegToTrans ( int d ) | 183 | inline Transformation DegToTrans ( int d ) |
182 | { | 184 | { |
183 | Transformation t = static_cast<Transformation>( d / 90 ); | 185 | Transformation t = static_cast<Transformation>( d / 90 ); |
184 | return t; | 186 | return t; |
185 | } | 187 | } |
186 | 188 | ||
187 | /* | 189 | /* |
188 | * Set current rotation of Opie, and rotation for newly started apps. | 190 | * Set current rotation of Opie, and rotation for newly started apps. |
189 | * Differs from setDefaultRotation in that 1) it rotates currently running apps, | 191 | * Differs from setDefaultRotation in that 1) it rotates currently running apps, |
190 | * and 2) does not set deforient or save orientation to qpe.conf. | 192 | * and 2) does not set deforient or save orientation to qpe.conf. |
191 | */ | 193 | */ |
192 | 194 | ||
193 | inline void QPEApplication::setCurrentRotation( int r ) | 195 | inline void QPEApplication::setCurrentRotation( int r ) |
194 | { | 196 | { |
195 | // setTransformation has been introduced in Qt/Embedded 2.3.4 snapshots | 197 | // setTransformation has been introduced in Qt/Embedded 2.3.4 snapshots |
196 | // for compatibility with the SharpROM use fallback to setDefaultTransformation() | 198 | // for compatibility with the SharpROM use fallback to setDefaultTransformation() |
197 | #if QT_VERSION > 233 | 199 | #if QT_VERSION > 233 |
198 | Transformation e = DegToTrans( r ); | 200 | Transformation e = DegToTrans( r ); |
199 | ::setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 ); | 201 | ::setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 ); |
200 | qApp->desktop()->qwsDisplay()->setTransformation( e ); | 202 | qApp->desktop()->qwsDisplay()->setTransformation( e ); |
201 | #else | 203 | #else |
202 | setDefaultRotation( r ); | 204 | setDefaultRotation( r ); |
203 | #endif | 205 | #endif |
204 | } | 206 | } |
205 | 207 | ||
206 | 208 | ||
207 | #endif | 209 | #endif |