summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--library/qpeapplication.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp
index d0e9613..040b2fe 100644
--- a/library/qpeapplication.cpp
+++ b/library/qpeapplication.cpp
@@ -615,1030 +615,1032 @@ static void setTreble( int t = 0, int percent = -1 )
615 615
616#ifndef QT_NO_SOUND 616#ifndef QT_NO_SOUND
617 int fd = 0; 617 int fd = 0;
618 int treble = percent; 618 int treble = percent;
619 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { 619 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) {
620 ioctl( fd, MIXER_WRITE( SOUND_MIXER_TREBLE ), &treble ); 620 ioctl( fd, MIXER_WRITE( SOUND_MIXER_TREBLE ), &treble );
621 ::close( fd ); 621 ::close( fd );
622 } 622 }
623#endif 623#endif
624 } 624 }
625 break; 625 break;
626 } 626 }
627} 627}
628 628
629 629
630/** 630/**
631 \class QPEApplication 631 \class QPEApplication
632 \brief The QPEApplication class implements various system services 632 \brief The QPEApplication class implements various system services
633 that are available to all Qtopia applications. 633 that are available to all Qtopia applications.
634 634
635 Simply by using QPEApplication instead of QApplication, a standard Qt 635 Simply by using QPEApplication instead of QApplication, a standard Qt
636 application becomes a Qtopia application. It automatically follows 636 application becomes a Qtopia application. It automatically follows
637 style changes, quits and raises, and in the 637 style changes, quits and raises, and in the
638 case of \link docwidget.html document-oriented\endlink applications, 638 case of \link docwidget.html document-oriented\endlink applications,
639 changes the currently displayed document in response to the environment. 639 changes the currently displayed document in response to the environment.
640 640
641 To create a \link docwidget.html document-oriented\endlink 641 To create a \link docwidget.html document-oriented\endlink
642 application use showMainDocumentWidget(); to create a 642 application use showMainDocumentWidget(); to create a
643 non-document-oriented application use showMainWidget(). The 643 non-document-oriented application use showMainWidget(). The
644 keepRunning() function indicates whether the application will 644 keepRunning() function indicates whether the application will
645 continue running after it's processed the last \link qcop.html 645 continue running after it's processed the last \link qcop.html
646 QCop\endlink message. This can be changed using setKeepRunning(). 646 QCop\endlink message. This can be changed using setKeepRunning().
647 647
648 A variety of signals are emitted when certain events occur, for 648 A variety of signals are emitted when certain events occur, for
649 example, timeChanged(), clockChanged(), weekChanged(), 649 example, timeChanged(), clockChanged(), weekChanged(),
650 dateFormatChanged() and volumeChanged(). If the application receives 650 dateFormatChanged() and volumeChanged(). If the application receives
651 a \link qcop.html QCop\endlink message on the application's 651 a \link qcop.html QCop\endlink message on the application's
652 QPE/Application/\e{appname} channel, the appMessage() signal is 652 QPE/Application/\e{appname} channel, the appMessage() signal is
653 emitted. There are also flush() and reload() signals, which 653 emitted. There are also flush() and reload() signals, which
654 are emitted when synching begins and ends respectively - upon these 654 are emitted when synching begins and ends respectively - upon these
655 signals, the application should save and reload any data 655 signals, the application should save and reload any data
656 files that are involved in synching. Most of these signals will initially 656 files that are involved in synching. Most of these signals will initially
657 be received and unfiltered through the appMessage() signal. 657 be received and unfiltered through the appMessage() signal.
658 658
659 This class also provides a set of useful static functions. The 659 This class also provides a set of useful static functions. The
660 qpeDir() and documentDir() functions return the respective paths. 660 qpeDir() and documentDir() functions return the respective paths.
661 The grabKeyboard() and ungrabKeyboard() functions are used to 661 The grabKeyboard() and ungrabKeyboard() functions are used to
662 control whether the application takes control of the device's 662 control whether the application takes control of the device's
663 physical buttons (e.g. application launch keys). The stylus' mode of 663 physical buttons (e.g. application launch keys). The stylus' mode of
664 operation is set with setStylusOperation() and retrieved with 664 operation is set with setStylusOperation() and retrieved with
665 stylusOperation(). There are also setInputMethodHint() and 665 stylusOperation(). There are also setInputMethodHint() and
666 inputMethodHint() functions. 666 inputMethodHint() functions.
667 667
668 \ingroup qtopiaemb 668 \ingroup qtopiaemb
669*/ 669*/
670 670
671/*! 671/*!
672 \fn void QPEApplication::clientMoused() 672 \fn void QPEApplication::clientMoused()
673 673
674 \internal 674 \internal
675*/ 675*/
676 676
677/*! 677/*!
678 \fn void QPEApplication::timeChanged(); 678 \fn void QPEApplication::timeChanged();
679 This signal is emitted when the time changes outside the normal 679 This signal is emitted when the time changes outside the normal
680 passage of time, i.e. if the time is set backwards or forwards. 680 passage of time, i.e. if the time is set backwards or forwards.
681*/ 681*/
682 682
683/*! 683/*!
684 \fn void QPEApplication::clockChanged( bool ampm ); 684 \fn void QPEApplication::clockChanged( bool ampm );
685 685
686 This signal is emitted when the user changes the clock's style. If 686 This signal is emitted when the user changes the clock's style. If
687 \a ampm is TRUE, the user wants a 12-hour AM/PM clock, otherwise, 687 \a ampm is TRUE, the user wants a 12-hour AM/PM clock, otherwise,
688 they want a 24-hour clock. 688 they want a 24-hour clock.
689*/ 689*/
690 690
691/*! 691/*!
692 \fn void QPEApplication::volumeChanged( bool muted ) 692 \fn void QPEApplication::volumeChanged( bool muted )
693 693
694 This signal is emitted whenever the mute state is changed. If \a 694 This signal is emitted whenever the mute state is changed. If \a
695 muted is TRUE, then sound output has been muted. 695 muted is TRUE, then sound output has been muted.
696*/ 696*/
697 697
698/*! 698/*!
699 \fn void QPEApplication::weekChanged( bool startOnMonday ) 699 \fn void QPEApplication::weekChanged( bool startOnMonday )
700 700
701 This signal is emitted if the week start day is changed. If \a 701 This signal is emitted if the week start day is changed. If \a
702 startOnMonday is TRUE then the first day of the week is Monday; if 702 startOnMonday is TRUE then the first day of the week is Monday; if
703 \a startOnMonday is FALSE then the first day of the week is 703 \a startOnMonday is FALSE then the first day of the week is
704 Sunday. 704 Sunday.
705*/ 705*/
706 706
707/*! 707/*!
708 \fn void QPEApplication::dateFormatChanged(DateFormat) 708 \fn void QPEApplication::dateFormatChanged(DateFormat)
709 709
710 This signal is emitted whenever the date format is changed. 710 This signal is emitted whenever the date format is changed.
711*/ 711*/
712 712
713/*! 713/*!
714 \fn void QPEApplication::flush() 714 \fn void QPEApplication::flush()
715 715
716 ### 716 ###
717*/ 717*/
718 718
719/*! 719/*!
720 \fn void QPEApplication::reload() 720 \fn void QPEApplication::reload()
721 721
722*/ 722*/
723 723
724 724
725 725
726void QPEApplication::processQCopFile() 726void QPEApplication::processQCopFile()
727{ 727{
728 QString qcopfn("/tmp/qcop-msg-"); 728 QString qcopfn("/tmp/qcop-msg-");
729 qcopfn += d->appName; // append command name 729 qcopfn += d->appName; // append command name
730 730
731 QFile f(qcopfn); 731 QFile f(qcopfn);
732 if ( f.open(IO_ReadWrite) ) { 732 if ( f.open(IO_ReadWrite) ) {
733#ifndef Q_OS_WIN32 733#ifndef Q_OS_WIN32
734 flock(f.handle(), LOCK_EX); 734 flock(f.handle(), LOCK_EX);
735#endif 735#endif
736 QDataStream ds(&f); 736 QDataStream ds(&f);
737 QCString channel, message; 737 QCString channel, message;
738 QByteArray data; 738 QByteArray data;
739 while(!ds.atEnd()) { 739 while(!ds.atEnd()) {
740 ds >> channel >> message >> data; 740 ds >> channel >> message >> data;
741 d->enqueueQCop(channel,message,data); 741 d->enqueueQCop(channel,message,data);
742 } 742 }
743 ::ftruncate(f.handle(), 0); 743 ::ftruncate(f.handle(), 0);
744#ifndef Q_OS_WIN32 744#ifndef Q_OS_WIN32
745 f.flush(); 745 f.flush();
746 flock(f.handle(), LOCK_UN); 746 flock(f.handle(), LOCK_UN);
747#endif 747#endif
748 } 748 }
749#endif 749#endif
750} 750}
751 751
752 752
753/*! 753/*!
754 \fn void QPEApplication::appMessage( const QCString& msg, const QByteArray& data ) 754 \fn void QPEApplication::appMessage( const QCString& msg, const QByteArray& data )
755 755
756 This signal is emitted when a message is received on this 756 This signal is emitted when a message is received on this
757 application's QPE/Application/<i>appname</i> \link qcop.html 757 application's QPE/Application/<i>appname</i> \link qcop.html
758 QCop\endlink channel. 758 QCop\endlink channel.
759 759
760 The slot to which you connect this signal uses \a msg and \a data 760 The slot to which you connect this signal uses \a msg and \a data
761 in the following way: 761 in the following way:
762 762
763\code 763\code
764 void MyWidget::receive( const QCString& msg, const QByteArray& data ) 764 void MyWidget::receive( const QCString& msg, const QByteArray& data )
765 { 765 {
766 QDataStream stream( data, IO_ReadOnly ); 766 QDataStream stream( data, IO_ReadOnly );
767 if ( msg == "someMessage(int,int,int)" ) { 767 if ( msg == "someMessage(int,int,int)" ) {
768 int a,b,c; 768 int a,b,c;
769 stream >> a >> b >> c; 769 stream >> a >> b >> c;
770 ... 770 ...
771 } else if ( msg == "otherMessage(QString)" ) { 771 } else if ( msg == "otherMessage(QString)" ) {
772 ... 772 ...
773 } 773 }
774 } 774 }
775\endcode 775\endcode
776 776
777 \sa qcop.html 777 \sa qcop.html
778 Note that messages received here may be processed by qpe application 778 Note that messages received here may be processed by qpe application
779 and emitted as signals, such as flush() and reload(). 779 and emitted as signals, such as flush() and reload().
780*/ 780*/
781 781
782/*! 782/*!
783 Constructs a QPEApplication just as you would construct 783 Constructs a QPEApplication just as you would construct
784 a QApplication, passing \a argc, \a argv, and \a t. 784 a QApplication, passing \a argc, \a argv, and \a t.
785 785
786 For applications, \a t should be the default, GuiClient. Only 786 For applications, \a t should be the default, GuiClient. Only
787 the Qtopia server passes GuiServer. 787 the Qtopia server passes GuiServer.
788*/ 788*/
789QPEApplication::QPEApplication( int & argc, char **argv, Type t ) 789QPEApplication::QPEApplication( int & argc, char **argv, Type t )
790 : QApplication( hack(argc), argv, t ), pidChannel( 0 ) 790 : QApplication( hack(argc), argv, t ), pidChannel( 0 )
791{ 791{
792 QPixmapCache::setCacheLimit(256); // sensible default for smaller devices. 792 QPixmapCache::setCacheLimit(256); // sensible default for smaller devices.
793 793
794 d = new QPEApplicationData; 794 d = new QPEApplicationData;
795 d->loadTextCodecs(); 795 d->loadTextCodecs();
796 d->loadImageCodecs(); 796 d->loadImageCodecs();
797 int dw = desktop() ->width(); 797 int dw = desktop() ->width();
798 798
799 if ( dw < 200 ) { 799 if ( dw < 200 ) {
800 setFont( QFont( "vera", 8 ) ); 800 setFont( QFont( "vera", 8 ) );
801 AppLnk::setSmallIconSize( 10 ); 801 AppLnk::setSmallIconSize( 10 );
802 AppLnk::setBigIconSize( 28 ); 802 AppLnk::setBigIconSize( 28 );
803 } 803 }
804#if defined(OPIE_HIGH_RES_SMALL_PHY) 804#if defined(OPIE_HIGH_RES_SMALL_PHY)
805 else if ( dw > 600 ) { 805 else if ( dw > 600 ) {
806 setFont( QFont( "vera", 16 ) ); 806 setFont( QFont( "vera", 16 ) );
807 AppLnk::setSmallIconSize( 24 ); 807 AppLnk::setSmallIconSize( 24 );
808 AppLnk::setBigIconSize( 48 ); 808 AppLnk::setBigIconSize( 48 );
809 } 809 }
810#endif 810#endif
811 else if ( dw > 200 ) { 811 else if ( dw > 200 ) {
812 setFont( QFont( "vera", 10 ) ); 812 setFont( QFont( "vera", 10 ) );
813 AppLnk::setSmallIconSize( 14 ); 813 AppLnk::setSmallIconSize( 14 );
814 AppLnk::setBigIconSize( 32 ); 814 AppLnk::setBigIconSize( 32 );
815 } 815 }
816 816
817 QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory ); 817 QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory );
818 818
819 connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) ); 819 connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) );
820 820
821 821
822 sysChannel = new QCopChannel( "QPE/System", this ); 822 sysChannel = new QCopChannel( "QPE/System", this );
823 connect( sysChannel, SIGNAL( received(const QCString&,const QByteArray&) ), 823 connect( sysChannel, SIGNAL( received(const QCString&,const QByteArray&) ),
824 this, SLOT( systemMessage(const QCString&,const QByteArray&) ) ); 824 this, SLOT( systemMessage(const QCString&,const QByteArray&) ) );
825 825
826/* COde now in initapp */ 826/* COde now in initapp */
827#if 0 827#if 0
828#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 828#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
829 829
830 QString qcopfn( "/tmp/qcop-msg-" ); 830 QString qcopfn( "/tmp/qcop-msg-" );
831 qcopfn += QString( argv[ 0 ] ); // append command name 831 qcopfn += QString( argv[ 0 ] ); // append command name
832 832
833 QFile f( qcopfn ); 833 QFile f( qcopfn );
834 if ( f.open( IO_ReadOnly ) ) { 834 if ( f.open( IO_ReadOnly ) ) {
835 flock( f.handle(), LOCK_EX ); 835 flock( f.handle(), LOCK_EX );
836 } 836 }
837 837
838 838
839 839
840 QCString channel = QCString( argv[ 0 ] ); 840 QCString channel = QCString( argv[ 0 ] );
841 channel.replace( QRegExp( ".*/" ), "" ); 841 channel.replace( QRegExp( ".*/" ), "" );
842 d->appName = channel; 842 d->appName = channel;
843 channel = "QPE/Application/" + channel; 843 channel = "QPE/Application/" + channel;
844 pidChannel = new QCopChannel( channel, this ); 844 pidChannel = new QCopChannel( channel, this );
845 connect( pidChannel, SIGNAL( received(const QCString&,const QByteArray&) ), 845 connect( pidChannel, SIGNAL( received(const QCString&,const QByteArray&) ),
846 this, SLOT( pidMessage(const QCString&,const QByteArray&) ) ); 846 this, SLOT( pidMessage(const QCString&,const QByteArray&) ) );
847 847
848 if ( f.isOpen() ) { 848 if ( f.isOpen() ) {
849 d->keep_running = FALSE; 849 d->keep_running = FALSE;
850 QDataStream ds( &f ); 850 QDataStream ds( &f );
851 QCString channel, message; 851 QCString channel, message;
852 QByteArray data; 852 QByteArray data;
853 while ( !ds.atEnd() ) { 853 while ( !ds.atEnd() ) {
854 ds >> channel >> message >> data; 854 ds >> channel >> message >> data;
855 d->enqueueQCop( channel, message, data ); 855 d->enqueueQCop( channel, message, data );
856 } 856 }
857 857
858 flock( f.handle(), LOCK_UN ); 858 flock( f.handle(), LOCK_UN );
859 f.close(); 859 f.close();
860 f.remove(); 860 f.remove();
861 } 861 }
862 862
863 for ( int a = 0; a < argc; a++ ) { 863 for ( int a = 0; a < argc; a++ ) {
864 if ( qstrcmp( argv[ a ], "-preload" ) == 0 ) { 864 if ( qstrcmp( argv[ a ], "-preload" ) == 0 ) {
865 argv[ a ] = argv[ a + 1 ]; 865 argv[ a ] = argv[ a + 1 ];
866 a++; 866 a++;
867 d->preloaded = TRUE; 867 d->preloaded = TRUE;
868 argc -= 1; 868 argc -= 1;
869 } 869 }
870 else if ( qstrcmp( argv[ a ], "-preload-show" ) == 0 ) { 870 else if ( qstrcmp( argv[ a ], "-preload-show" ) == 0 ) {
871 argv[ a ] = argv[ a + 1 ]; 871 argv[ a ] = argv[ a + 1 ];
872 a++; 872 a++;
873 d->preloaded = TRUE; 873 d->preloaded = TRUE;
874 d->forceshow = TRUE; 874 d->forceshow = TRUE;
875 argc -= 1; 875 argc -= 1;
876 } 876 }
877 } 877 }
878 878
879 /* overide stored arguments */ 879 /* overide stored arguments */
880 setArgs( argc, argv ); 880 setArgs( argc, argv );
881 881
882#endif 882#endif
883#else 883#else
884 initApp( argc, argv ); 884 initApp( argc, argv );
885#endif 885#endif
886 // qwsSetDecoration( new QPEDecoration() ); 886 // qwsSetDecoration( new QPEDecoration() );
887 887
888#ifndef QT_NO_TRANSLATION 888#ifndef QT_NO_TRANSLATION
889 889
890 d->langs = Global::languageList(); 890 d->langs = Global::languageList();
891 for ( QStringList::ConstIterator it = d->langs.begin(); it != d->langs.end(); ++it ) { 891 for ( QStringList::ConstIterator it = d->langs.begin(); it != d->langs.end(); ++it ) {
892 QString lang = *it; 892 QString lang = *it;
893 893
894 installTranslation( lang + "/libopie.qm"); 894 installTranslation( lang + "/libopie.qm");
895 installTranslation( lang + "/libqpe.qm" ); 895 installTranslation( lang + "/libqpe.qm" );
896 installTranslation( lang + "/" + d->appName + ".qm" ); 896 installTranslation( lang + "/" + d->appName + ".qm" );
897 897
898 898
899 //###language/font hack; should look it up somewhere 899 //###language/font hack; should look it up somewhere
900#ifdef QWS 900#ifdef QWS
901 901
902 if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) { 902 if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) {
903 QFont fn = FontManager::unicodeFont( FontManager::Proportional ); 903 QFont fn = FontManager::unicodeFont( FontManager::Proportional );
904 setFont( fn ); 904 setFont( fn );
905 } 905 }
906#endif 906#endif
907 } 907 }
908#endif 908#endif
909 909
910 applyStyle(); 910 applyStyle();
911 911
912 if ( type() == GuiServer ) { 912 if ( type() == GuiServer ) {
913 setVolume(); 913 setVolume();
914 } 914 }
915 915
916 installEventFilter( this ); 916 installEventFilter( this );
917 917
918 QPEMenuToolFocusManager::initialize(); 918 QPEMenuToolFocusManager::initialize();
919 919
920#ifdef QT_NO_QWS_CURSOR 920#ifdef QT_NO_QWS_CURSOR
921 // if we have no cursor, probably don't want tooltips 921 // if we have no cursor, probably don't want tooltips
922 QToolTip::setEnabled( FALSE ); 922 QToolTip::setEnabled( FALSE );
923#endif 923#endif
924} 924}
925 925
926 926
927#ifdef QTOPIA_INTERNAL_INITAPP 927#ifdef QTOPIA_INTERNAL_INITAPP
928void QPEApplication::initApp( int argc, char **argv ) 928void QPEApplication::initApp( int argc, char **argv )
929{ 929{
930 delete pidChannel; 930 delete pidChannel;
931 d->keep_running = TRUE; 931 d->keep_running = TRUE;
932 d->preloaded = FALSE; 932 d->preloaded = FALSE;
933 d->forceshow = FALSE; 933 d->forceshow = FALSE;
934 934
935 QCString channel = QCString(argv[0]); 935 QCString channel = QCString(argv[0]);
936 936
937 channel.replace(QRegExp(".*/"),""); 937 channel.replace(QRegExp(".*/"),"");
938 d->appName = channel; 938 d->appName = channel;
939 939
940 #if QT_VERSION > 235 940 #if QT_VERSION > 235
941 qt_fbdpy->setIdentity( channel ); // In Qt/E 2.3.6 941 qt_fbdpy->setIdentity( channel ); // In Qt/E 2.3.6
942 #endif 942 #endif
943 943
944 channel = "QPE/Application/" + channel; 944 channel = "QPE/Application/" + channel;
945 pidChannel = new QCopChannel( channel, this); 945 pidChannel = new QCopChannel( channel, this);
946 connect( pidChannel, SIGNAL(received(const QCString&,const QByteArray&)), 946 connect( pidChannel, SIGNAL(received(const QCString&,const QByteArray&)),
947 this, SLOT(pidMessage(const QCString&,const QByteArray&))); 947 this, SLOT(pidMessage(const QCString&,const QByteArray&)));
948 948
949 949
950 950
951 processQCopFile(); 951 processQCopFile();
952 d->keep_running = d->qcopq.isEmpty(); 952 d->keep_running = d->qcopq.isEmpty();
953 953
954 for (int a=0; a<argc; a++) { 954 for (int a=0; a<argc; a++) {
955 if ( qstrcmp(argv[a],"-preload")==0 ) { 955 if ( qstrcmp(argv[a],"-preload")==0 ) {
956 argv[a] = argv[a+1]; 956 argv[a] = argv[a+1];
957 a++; 957 a++;
958 d->preloaded = TRUE; 958 d->preloaded = TRUE;
959 argc-=1; 959 argc-=1;
960 } else if ( qstrcmp(argv[a],"-preload-show")==0 ) { 960 } else if ( qstrcmp(argv[a],"-preload-show")==0 ) {
961 argv[a] = argv[a+1]; 961 argv[a] = argv[a+1];
962 a++; 962 a++;
963 d->preloaded = TRUE; 963 d->preloaded = TRUE;
964 d->forceshow = TRUE; 964 d->forceshow = TRUE;
965 argc-=1; 965 argc-=1;
966 } 966 }
967 } 967 }
968 968
969 /* overide stored arguments */ 969 /* overide stored arguments */
970 setArgs(argc, argv); 970 setArgs(argc, argv);
971 971
972 /* install translation here */ 972 /* install translation here */
973 for ( QStringList::ConstIterator it = d->langs.begin(); it != d->langs.end(); ++it ) 973 for ( QStringList::ConstIterator it = d->langs.begin(); it != d->langs.end(); ++it )
974 installTranslation( (*it) + "/" + d->appName + ".qm" ); 974 installTranslation( (*it) + "/" + d->appName + ".qm" );
975} 975}
976#endif 976#endif
977 977
978 978
979static QPtrDict<void>* inputMethodDict = 0; 979static QPtrDict<void>* inputMethodDict = 0;
980static void createInputMethodDict() 980static void createInputMethodDict()
981{ 981{
982 if ( !inputMethodDict ) 982 if ( !inputMethodDict )
983 inputMethodDict = new QPtrDict<void>; 983 inputMethodDict = new QPtrDict<void>;
984} 984}
985 985
986/*! 986/*!
987 Returns the currently set hint to the system as to whether 987 Returns the currently set hint to the system as to whether
988 widget \a w has any use for text input methods. 988 widget \a w has any use for text input methods.
989 989
990 990
991 \sa setInputMethodHint() InputMethodHint 991 \sa setInputMethodHint() InputMethodHint
992*/ 992*/
993QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w ) 993QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w )
994{ 994{
995 if ( inputMethodDict && w ) 995 if ( inputMethodDict && w )
996 return ( InputMethodHint ) ( int ) inputMethodDict->find( w ); 996 return ( InputMethodHint ) ( int ) inputMethodDict->find( w );
997 return Normal; 997 return Normal;
998} 998}
999 999
1000/*! 1000/*!
1001 \enum QPEApplication::InputMethodHint 1001 \enum QPEApplication::InputMethodHint
1002 1002
1003 \value Normal the application sometimes needs text input (the default). 1003 \value Normal the application sometimes needs text input (the default).
1004 \value AlwaysOff the application never needs text input. 1004 \value AlwaysOff the application never needs text input.
1005 \value AlwaysOn the application always needs text input. 1005 \value AlwaysOn the application always needs text input.
1006*/ 1006*/
1007 1007
1008/*! 1008/*!
1009 Hints to the system that widget \a w has use for text input methods 1009 Hints to the system that widget \a w has use for text input methods
1010 as specified by \a mode. 1010 as specified by \a mode.
1011 1011
1012 \sa inputMethodHint() InputMethodHint 1012 \sa inputMethodHint() InputMethodHint
1013*/ 1013*/
1014void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode ) 1014void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode )
1015{ 1015{
1016 createInputMethodDict(); 1016 createInputMethodDict();
1017 if ( mode == Normal ) { 1017 if ( mode == Normal ) {
1018 inputMethodDict->remove 1018 inputMethodDict->remove
1019 ( w ); 1019 ( w );
1020 } 1020 }
1021 else { 1021 else {
1022 inputMethodDict->insert( w, ( void* ) mode ); 1022 inputMethodDict->insert( w, ( void* ) mode );
1023 } 1023 }
1024} 1024}
1025 1025
1026class HackDialog : public QDialog 1026class HackDialog : public QDialog
1027{ 1027{
1028public: 1028public:
1029 void acceptIt() 1029 void acceptIt()
1030 { 1030 {
1031 accept(); 1031 accept();
1032 } 1032 }
1033 void rejectIt() 1033 void rejectIt()
1034 { 1034 {
1035 reject(); 1035 reject();
1036 } 1036 }
1037}; 1037};
1038 1038
1039 1039
1040void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key ) 1040void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key )
1041{ 1041{
1042 // specialised actions for certain widgets. May want to 1042 // specialised actions for certain widgets. May want to
1043 // add more stuff here. 1043 // add more stuff here.
1044 if ( activePopupWidget() && activePopupWidget() ->inherits( "QListBox" ) 1044 if ( activePopupWidget() && activePopupWidget() ->inherits( "QListBox" )
1045 && activePopupWidget() ->parentWidget() 1045 && activePopupWidget() ->parentWidget()
1046 && activePopupWidget() ->parentWidget() ->inherits( "QComboBox" ) ) 1046 && activePopupWidget() ->parentWidget() ->inherits( "QComboBox" ) )
1047 key = Qt::Key_Return; 1047 key = Qt::Key_Return;
1048 1048
1049 if ( activePopupWidget() && activePopupWidget() ->inherits( "QPopupMenu" ) ) 1049 if ( activePopupWidget() && activePopupWidget() ->inherits( "QPopupMenu" ) )
1050 key = Qt::Key_Return; 1050 key = Qt::Key_Return;
1051 1051
1052#ifdef QWS 1052#ifdef QWS
1053 1053
1054 ke->simpleData.keycode = key; 1054 ke->simpleData.keycode = key;
1055#endif 1055#endif
1056} 1056}
1057 1057
1058 1058
1059/*! 1059/*!
1060 \internal 1060 \internal
1061*/ 1061*/
1062 1062
1063#ifdef QWS 1063#ifdef QWS
1064bool QPEApplication::qwsEventFilter( QWSEvent * e ) 1064bool QPEApplication::qwsEventFilter( QWSEvent * e )
1065{ 1065{
1066 if ( !d->notbusysent && e->type == QWSEvent::Focus ) { 1066 if ( !d->notbusysent && e->type == QWSEvent::Focus ) {
1067 if ( qApp->type() != QApplication::GuiServer ) { 1067 if ( qApp->type() != QApplication::GuiServer ) {
1068 QCopEnvelope e( "QPE/System", "notBusy(QString)" ); 1068 QCopEnvelope e( "QPE/System", "notBusy(QString)" );
1069 e << d->appName; 1069 e << d->appName;
1070 } 1070 }
1071 d->notbusysent = TRUE; 1071 d->notbusysent = TRUE;
1072 } 1072 }
1073 if ( type() == GuiServer ) { 1073 if ( type() == GuiServer ) {
1074 switch ( e->type ) { 1074 switch ( e->type ) {
1075 case QWSEvent::Mouse: 1075 case QWSEvent::Mouse:
1076 if ( e->asMouse() ->simpleData.state && !QWidget::find( e->window() ) ) 1076 if ( e->asMouse() ->simpleData.state && !QWidget::find( e->window() ) )
1077 emit clientMoused(); 1077 emit clientMoused();
1078 break; 1078 break;
1079 default: 1079 default:
1080 break; 1080 break;
1081 } 1081 }
1082 } 1082 }
1083 if ( e->type == QWSEvent::Key ) { 1083 if ( e->type == QWSEvent::Key ) {
1084 QWSKeyEvent *ke = ( QWSKeyEvent * ) e; 1084 QWSKeyEvent *ke = ( QWSKeyEvent * ) e;
1085 if ( ke->simpleData.keycode == Qt::Key_F33 ) { 1085 if ( ke->simpleData.keycode == Qt::Key_F33 ) {
1086 // Use special "OK" key to press "OK" on top level widgets 1086 // Use special "OK" key to press "OK" on top level widgets
1087 QWidget * active = activeWindow(); 1087 QWidget * active = activeWindow();
1088 QWidget *popup = 0; 1088 QWidget *popup = 0;
1089 if ( active && active->isPopup() ) { 1089 if ( active && active->isPopup() ) {
1090 popup = active; 1090 popup = active;
1091 active = active->parentWidget(); 1091 active = active->parentWidget();
1092 } 1092 }
1093 if ( active && ( int ) active->winId() == ke->simpleData.window && 1093 if ( active && ( int ) active->winId() == ke->simpleData.window &&
1094 !active->testWFlags( WStyle_Customize | WType_Popup | WType_Desktop ) ) { 1094 !active->testWFlags( WStyle_Customize | WType_Popup | WType_Desktop ) ) {
1095 if ( ke->simpleData.is_press ) { 1095 if ( ke->simpleData.is_press ) {
1096 if ( popup ) 1096 if ( popup )
1097 popup->close(); 1097 popup->close();
1098 if ( active->inherits( "QDialog" ) ) { 1098 if ( active->inherits( "QDialog" ) ) {
1099 HackDialog * d = ( HackDialog * ) active; 1099 HackDialog * d = ( HackDialog * ) active;
1100 d->acceptIt(); 1100 d->acceptIt();
1101 return TRUE; 1101 return TRUE;
1102 } 1102 }
1103 else if ( ( ( HackWidget * ) active ) ->needsOk() ) { 1103 else if ( ( ( HackWidget * ) active ) ->needsOk() ) {
1104 QSignal s; 1104 QSignal s;
1105 s.connect( active, SLOT( accept() ) ); 1105 s.connect( active, SLOT( accept() ) );
1106 s.activate(); 1106 s.activate();
1107 } 1107 }
1108 else { 1108 else {
1109 // do the same as with the select key: Map to the default action of the widget: 1109 // do the same as with the select key: Map to the default action of the widget:
1110 mapToDefaultAction( ke, Qt::Key_Return ); 1110 mapToDefaultAction( ke, Qt::Key_Return );
1111 } 1111 }
1112 } 1112 }
1113 } 1113 }
1114 } 1114 }
1115 else if ( ke->simpleData.keycode == Qt::Key_F30 ) { 1115 else if ( ke->simpleData.keycode == Qt::Key_F30 ) {
1116 // Use special "select" key to do whatever default action a widget has 1116 // Use special "select" key to do whatever default action a widget has
1117 mapToDefaultAction( ke, Qt::Key_Space ); 1117 mapToDefaultAction( ke, Qt::Key_Space );
1118 } 1118 }
1119 else if ( ke->simpleData.keycode == Qt::Key_Escape && 1119 else if ( ke->simpleData.keycode == Qt::Key_Escape &&
1120 ke->simpleData.is_press ) { 1120 ke->simpleData.is_press ) {
1121 // Escape key closes app if focus on toplevel 1121 // Escape key closes app if focus on toplevel
1122 QWidget * active = activeWindow(); 1122 QWidget * active = activeWindow();
1123 if ( active && active->testWFlags( WType_TopLevel ) && 1123 if ( active && active->testWFlags( WType_TopLevel ) &&
1124 ( int ) active->winId() == ke->simpleData.window && 1124 ( int ) active->winId() == ke->simpleData.window &&
1125 !active->testWFlags( WStyle_Dialog | WStyle_Customize | WType_Popup | WType_Desktop ) ) { 1125 !active->testWFlags( WStyle_Dialog | WStyle_Customize | WType_Popup | WType_Desktop ) ) {
1126 if ( active->inherits( "QDialog" ) ) { 1126 if ( active->inherits( "QDialog" ) ) {
1127 qDebug("dialog hack");
1128 HackDialog * d = ( HackDialog * ) active; 1127 HackDialog * d = ( HackDialog * ) active;
1129 d->rejectIt(); 1128 d->rejectIt();
1130 return TRUE; 1129 return TRUE;
1130 } else /*if ( strcmp( argv() [ 0 ], "embeddedkonsole" ) != 0 )*/ {
1131 active->close();
1131 } 1132 }
1132 } 1133 }
1134
1133 } 1135 }
1134 else if ( ke->simpleData.keycode >= Qt::Key_F1 && ke->simpleData.keycode <= Qt::Key_F29 ) { 1136 else if ( ke->simpleData.keycode >= Qt::Key_F1 && ke->simpleData.keycode <= Qt::Key_F29 ) {
1135 // this should be if ( ODevice::inst ( )-> buttonForKeycode ( ... )) 1137 // this should be if ( ODevice::inst ( )-> buttonForKeycode ( ... ))
1136 // but we cannot access libopie function within libqpe :( 1138 // but we cannot access libopie function within libqpe :(
1137 1139
1138 QWidget * active = activeWindow ( ); 1140 QWidget * active = activeWindow ( );
1139 if ( active && ((int) active-> winId ( ) == ke-> simpleData.window )) { 1141 if ( active && ((int) active-> winId ( ) == ke-> simpleData.window )) {
1140 if ( d-> kbgrabbed ) { // we grabbed the keyboard 1142 if ( d-> kbgrabbed ) { // we grabbed the keyboard
1141 QChar ch ( ke-> simpleData.unicode ); 1143 QChar ch ( ke-> simpleData.unicode );
1142 QKeyEvent qke ( ke-> simpleData. is_press ? QEvent::KeyPress : QEvent::KeyRelease, 1144 QKeyEvent qke ( ke-> simpleData. is_press ? QEvent::KeyPress : QEvent::KeyRelease,
1143 ke-> simpleData.keycode, 1145 ke-> simpleData.keycode,
1144 ch. latin1 ( ), 1146 ch. latin1 ( ),
1145 ke-> simpleData.modifiers, 1147 ke-> simpleData.modifiers,
1146 QString ( ch ), 1148 QString ( ch ),
1147 ke-> simpleData.is_auto_repeat, 1 ); 1149 ke-> simpleData.is_auto_repeat, 1 );
1148 1150
1149 QObject *which = QWidget::keyboardGrabber ( ); 1151 QObject *which = QWidget::keyboardGrabber ( );
1150 if ( !which ) 1152 if ( !which )
1151 which = QApplication::focusWidget ( ); 1153 which = QApplication::focusWidget ( );
1152 if ( !which ) 1154 if ( !which )
1153 which = QApplication::activeWindow ( ); 1155 which = QApplication::activeWindow ( );
1154 if ( !which ) 1156 if ( !which )
1155 which = qApp; 1157 which = qApp;
1156 1158
1157 QApplication::sendEvent ( which, &qke ); 1159 QApplication::sendEvent ( which, &qke );
1158 } 1160 }
1159 else { // we didn't grab the keyboard, so send the event to the launcher 1161 else { // we didn't grab the keyboard, so send the event to the launcher
1160 QCopEnvelope e ( "QPE/Launcher", "deviceButton(int,int,int)" ); 1162 QCopEnvelope e ( "QPE/Launcher", "deviceButton(int,int,int)" );
1161 e << int( ke-> simpleData.keycode ) << int( ke-> simpleData. is_press ) << int( ke-> simpleData.is_auto_repeat ); 1163 e << int( ke-> simpleData.keycode ) << int( ke-> simpleData. is_press ) << int( ke-> simpleData.is_auto_repeat );
1162 } 1164 }
1163 } 1165 }
1164 return true; 1166 return true;
1165 } 1167 }
1166 } 1168 }
1167 if ( e->type == QWSEvent::Focus ) { 1169 if ( e->type == QWSEvent::Focus ) {
1168 QWSFocusEvent * fe = ( QWSFocusEvent* ) e; 1170 QWSFocusEvent * fe = ( QWSFocusEvent* ) e;
1169 if ( !fe->simpleData.get_focus ) { 1171 if ( !fe->simpleData.get_focus ) {
1170 QWidget * active = activeWindow(); 1172 QWidget * active = activeWindow();
1171 while ( active && active->isPopup() ) { 1173 while ( active && active->isPopup() ) {
1172 active->close(); 1174 active->close();
1173 active = activeWindow(); 1175 active = activeWindow();
1174 } 1176 }
1175 } 1177 }
1176 else { 1178 else {
1177 // make sure our modal widget is ALWAYS on top 1179 // make sure our modal widget is ALWAYS on top
1178 QWidget *topm = activeModalWidget(); 1180 QWidget *topm = activeModalWidget();
1179 if ( topm && static_cast<int>( topm->winId() ) != fe->simpleData.window) { 1181 if ( topm && static_cast<int>( topm->winId() ) != fe->simpleData.window) {
1180 topm->raise(); 1182 topm->raise();
1181 } 1183 }
1182 } 1184 }
1183 if ( fe->simpleData.get_focus && inputMethodDict ) { 1185 if ( fe->simpleData.get_focus && inputMethodDict ) {
1184 InputMethodHint m = inputMethodHint( QWidget::find( e->window() ) ); 1186 InputMethodHint m = inputMethodHint( QWidget::find( e->window() ) );
1185 if ( m == AlwaysOff ) 1187 if ( m == AlwaysOff )
1186 Global::hideInputMethod(); 1188 Global::hideInputMethod();
1187 if ( m == AlwaysOn ) 1189 if ( m == AlwaysOn )
1188 Global::showInputMethod(); 1190 Global::showInputMethod();
1189 } 1191 }
1190 } 1192 }
1191 1193
1192 1194
1193 return QApplication::qwsEventFilter( e ); 1195 return QApplication::qwsEventFilter( e );
1194} 1196}
1195#endif 1197#endif
1196 1198
1197/*! 1199/*!
1198 Destroys the QPEApplication. 1200 Destroys the QPEApplication.
1199*/ 1201*/
1200QPEApplication::~QPEApplication() 1202QPEApplication::~QPEApplication()
1201{ 1203{
1202 ungrabKeyboard(); 1204 ungrabKeyboard();
1203#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 1205#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
1204 // Need to delete QCopChannels early, since the display will 1206 // Need to delete QCopChannels early, since the display will
1205 // be gone by the time we get to ~QObject(). 1207 // be gone by the time we get to ~QObject().
1206 delete sysChannel; 1208 delete sysChannel;
1207 delete pidChannel; 1209 delete pidChannel;
1208#endif 1210#endif
1209 1211
1210 delete d; 1212 delete d;
1211} 1213}
1212 1214
1213/*! 1215/*!
1214 Returns <tt>$OPIEDIR/</tt>. 1216 Returns <tt>$OPIEDIR/</tt>.
1215*/ 1217*/
1216QString QPEApplication::qpeDir() 1218QString QPEApplication::qpeDir()
1217{ 1219{
1218 const char * base = getenv( "OPIEDIR" ); 1220 const char * base = getenv( "OPIEDIR" );
1219 if ( base ) 1221 if ( base )
1220 return QString( base ) + "/"; 1222 return QString( base ) + "/";
1221 1223
1222 return QString( "../" ); 1224 return QString( "../" );
1223} 1225}
1224 1226
1225/*! 1227/*!
1226 Returns the user's current Document directory. There is a trailing "/". 1228 Returns the user's current Document directory. There is a trailing "/".
1227 .. well, it does now,, and there's no trailing '/' 1229 .. well, it does now,, and there's no trailing '/'
1228*/ 1230*/
1229QString QPEApplication::documentDir() 1231QString QPEApplication::documentDir()
1230{ 1232{
1231 const char* base = getenv( "HOME"); 1233 const char* base = getenv( "HOME");
1232 if ( base ) 1234 if ( base )
1233 return QString( base ) + "/Documents"; 1235 return QString( base ) + "/Documents";
1234 1236
1235 return QString( "../Documents" ); 1237 return QString( "../Documents" );
1236} 1238}
1237 1239
1238static int deforient = -1; 1240static int deforient = -1;
1239 1241
1240/*! 1242/*!
1241 \internal 1243 \internal
1242*/ 1244*/
1243int QPEApplication::defaultRotation() 1245int QPEApplication::defaultRotation()
1244{ 1246{
1245 if ( deforient < 0 ) { 1247 if ( deforient < 0 ) {
1246 QString d = getenv( "QWS_DISPLAY" ); 1248 QString d = getenv( "QWS_DISPLAY" );
1247 if ( d.contains( "Rot90" ) ) { 1249 if ( d.contains( "Rot90" ) ) {
1248 deforient = 90; 1250 deforient = 90;
1249 } 1251 }
1250 else if ( d.contains( "Rot180" ) ) { 1252 else if ( d.contains( "Rot180" ) ) {
1251 deforient = 180; 1253 deforient = 180;
1252 } 1254 }
1253 else if ( d.contains( "Rot270" ) ) { 1255 else if ( d.contains( "Rot270" ) ) {
1254 deforient = 270; 1256 deforient = 270;
1255 } 1257 }
1256 else { 1258 else {
1257 deforient = 0; 1259 deforient = 0;
1258 } 1260 }
1259 } 1261 }
1260 return deforient; 1262 return deforient;
1261} 1263}
1262 1264
1263/*! 1265/*!
1264 \internal 1266 \internal
1265*/ 1267*/
1266void QPEApplication::setDefaultRotation( int r ) 1268void QPEApplication::setDefaultRotation( int r )
1267{ 1269{
1268 if ( qApp->type() == GuiServer ) { 1270 if ( qApp->type() == GuiServer ) {
1269 deforient = r; 1271 deforient = r;
1270 setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 ); 1272 setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 );
1271 Config config("qpe"); 1273 Config config("qpe");
1272 config.setGroup( "Rotation" ); 1274 config.setGroup( "Rotation" );
1273 config.writeEntry( "Rot", r ); 1275 config.writeEntry( "Rot", r );
1274 } 1276 }
1275 else { 1277 else {
1276#ifndef QT_NO_COP 1278#ifndef QT_NO_COP
1277 { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" ); 1279 { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" );
1278 e << r; 1280 e << r;
1279 } 1281 }
1280#endif 1282#endif
1281 1283
1282 } 1284 }
1283} 1285}
1284 1286
1285#include <qgfx_qws.h> 1287#include <qgfx_qws.h>
1286#include <qwindowsystem_qws.h> 1288#include <qwindowsystem_qws.h>
1287 1289
1288extern void qws_clearLoadedFonts(); 1290extern void qws_clearLoadedFonts();
1289 1291
1290void QPEApplication::setCurrentMode( int x, int y, int depth ) 1292void QPEApplication::setCurrentMode( int x, int y, int depth )
1291{ 1293{
1292 // Reset the caches 1294 // Reset the caches
1293 qws_clearLoadedFonts(); 1295 qws_clearLoadedFonts();
1294 QPixmapCache::clear(); 1296 QPixmapCache::clear();
1295 1297
1296 // Change the screen mode 1298 // Change the screen mode
1297 qt_screen->setMode(x, y, depth); 1299 qt_screen->setMode(x, y, depth);
1298 1300
1299 if ( qApp->type() == GuiServer ) { 1301 if ( qApp->type() == GuiServer ) {
1300 // Reconfigure the GuiServer 1302 // Reconfigure the GuiServer
1301 qwsServer->beginDisplayReconfigure(); 1303 qwsServer->beginDisplayReconfigure();
1302 qwsServer->endDisplayReconfigure(); 1304 qwsServer->endDisplayReconfigure();
1303 1305
1304 // Get all the running apps to reset 1306 // Get all the running apps to reset
1305 QCopEnvelope env( "QPE/System", "reset()" ); 1307 QCopEnvelope env( "QPE/System", "reset()" );
1306 } 1308 }
1307} 1309}
1308 1310
1309void QPEApplication::reset() { 1311void QPEApplication::reset() {
1310 // Reconnect to the screen 1312 // Reconnect to the screen
1311 qt_screen->disconnect(); 1313 qt_screen->disconnect();
1312 qt_screen->connect( QString::null ); 1314 qt_screen->connect( QString::null );
1313 1315
1314 // Redraw everything 1316 // Redraw everything
1315 applyStyle(); 1317 applyStyle();
1316} 1318}
1317 1319
1318/*! 1320/*!
1319 \internal 1321 \internal
1320*/ 1322*/
1321void QPEApplication::applyStyle() 1323void QPEApplication::applyStyle()
1322{ 1324{
1323 Config config( "qpe" ); 1325 Config config( "qpe" );
1324 config.setGroup( "Appearance" ); 1326 config.setGroup( "Appearance" );
1325 1327
1326#if QT_VERSION > 233 1328#if QT_VERSION > 233
1327#if !defined(OPIE_NO_OVERRIDE_QT) 1329#if !defined(OPIE_NO_OVERRIDE_QT)
1328 // don't block ourselves ... 1330 // don't block ourselves ...
1329 Opie::force_appearance = 0; 1331 Opie::force_appearance = 0;
1330 1332
1331 static QString appname = Opie::binaryName ( ); 1333 static QString appname = Opie::binaryName ( );
1332 1334
1333 QStringList ex = config. readListEntry ( "NoStyle", ';' ); 1335 QStringList ex = config. readListEntry ( "NoStyle", ';' );
1334 int nostyle = 0; 1336 int nostyle = 0;
1335 for ( QStringList::Iterator it = ex. begin ( ); it != ex. end ( ); ++it ) { 1337 for ( QStringList::Iterator it = ex. begin ( ); it != ex. end ( ); ++it ) {
1336 if ( QRegExp (( *it ). mid ( 1 ), false, true ). find ( appname, 0 ) >= 0 ) { 1338 if ( QRegExp (( *it ). mid ( 1 ), false, true ). find ( appname, 0 ) >= 0 ) {
1337 nostyle = ( *it ). left ( 1 ). toInt ( 0, 32 ); 1339 nostyle = ( *it ). left ( 1 ). toInt ( 0, 32 );
1338 break; 1340 break;
1339 } 1341 }
1340 } 1342 }
1341#else 1343#else
1342 int nostyle = 0; 1344 int nostyle = 0;
1343#endif 1345#endif
1344 1346
1345 // Widget style 1347 // Widget style
1346 QString style = config.readEntry( "Style", "FlatStyle" ); 1348 QString style = config.readEntry( "Style", "FlatStyle" );
1347 1349
1348 // don't set a custom style 1350 // don't set a custom style
1349 if ( nostyle & Opie::Force_Style ) 1351 if ( nostyle & Opie::Force_Style )
1350 style = "FlatStyle"; 1352 style = "FlatStyle";
1351 1353
1352 internalSetStyle ( style ); 1354 internalSetStyle ( style );
1353 1355
1354 // Colors - from /etc/colors/Liquid.scheme 1356 // Colors - from /etc/colors/Liquid.scheme
1355 QColor bgcolor( config.readEntry( "Background", "#E0E0E0" ) ); 1357 QColor bgcolor( config.readEntry( "Background", "#E0E0E0" ) );
1356 QColor btncolor( config.readEntry( "Button", "#96c8fa" ) ); 1358 QColor btncolor( config.readEntry( "Button", "#96c8fa" ) );
1357 QPalette pal( btncolor, bgcolor ); 1359 QPalette pal( btncolor, bgcolor );
1358 QString color = config.readEntry( "Highlight", "#73adef" ); 1360 QString color = config.readEntry( "Highlight", "#73adef" );
1359 pal.setColor( QColorGroup::Highlight, QColor( color ) ); 1361 pal.setColor( QColorGroup::Highlight, QColor( color ) );
1360 color = config.readEntry( "HighlightedText", "#FFFFFF" ); 1362 color = config.readEntry( "HighlightedText", "#FFFFFF" );
1361 pal.setColor( QColorGroup::HighlightedText, QColor( color ) ); 1363 pal.setColor( QColorGroup::HighlightedText, QColor( color ) );
1362 color = config.readEntry( "Text", "#000000" ); 1364 color = config.readEntry( "Text", "#000000" );
1363 pal.setColor( QColorGroup::Text, QColor( color ) ); 1365 pal.setColor( QColorGroup::Text, QColor( color ) );
1364 color = config.readEntry( "ButtonText", "#000000" ); 1366 color = config.readEntry( "ButtonText", "#000000" );
1365 pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) ); 1367 pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) );
1366 color = config.readEntry( "Base", "#FFFFFF" ); 1368 color = config.readEntry( "Base", "#FFFFFF" );
1367 pal.setColor( QColorGroup::Base, QColor( color ) ); 1369 pal.setColor( QColorGroup::Base, QColor( color ) );
1368 1370
1369 pal.setColor( QPalette::Disabled, QColorGroup::Text, 1371 pal.setColor( QPalette::Disabled, QColorGroup::Text,
1370 pal.color( QPalette::Active, QColorGroup::Background ).dark() ); 1372 pal.color( QPalette::Active, QColorGroup::Background ).dark() );
1371 1373
1372 setPalette( pal, TRUE ); 1374 setPalette( pal, TRUE );
1373 1375
1374 // Window Decoration 1376 // Window Decoration
1375 QString dec = config.readEntry( "Decoration", "Flat" ); 1377 QString dec = config.readEntry( "Decoration", "Flat" );
1376 1378
1377 // don't set a custom deco 1379 // don't set a custom deco
1378 if ( nostyle & Opie::Force_Decoration ) 1380 if ( nostyle & Opie::Force_Decoration )
1379 dec = ""; 1381 dec = "";
1380 1382
1381 //qDebug ( "Setting Deco: %s -- old %s (%d)", dec.latin1(), d-> decorationName.latin1(), nostyle); 1383 //qDebug ( "Setting Deco: %s -- old %s (%d)", dec.latin1(), d-> decorationName.latin1(), nostyle);
1382 1384
1383 if ( dec != d->decorationName ) { 1385 if ( dec != d->decorationName ) {
1384 qwsSetDecoration( new QPEDecoration( dec ) ); 1386 qwsSetDecoration( new QPEDecoration( dec ) );
1385 d->decorationName = dec; 1387 d->decorationName = dec;
1386 } 1388 }
1387 1389
1388 // Font 1390 // Font
1389 QString ff = config.readEntry( "FontFamily", font().family() ); 1391 QString ff = config.readEntry( "FontFamily", font().family() );
1390 int fs = config.readNumEntry( "FontSize", font().pointSize() ); 1392 int fs = config.readNumEntry( "FontSize", font().pointSize() );
1391 1393
1392 // don't set a custom font 1394 // don't set a custom font
1393 if ( nostyle & Opie::Force_Font ) { 1395 if ( nostyle & Opie::Force_Font ) {
1394 ff = "Vera"; 1396 ff = "Vera";
1395 fs = 10; 1397 fs = 10;
1396 } 1398 }
1397 1399
1398 setFont ( QFont ( ff, fs ), true ); 1400 setFont ( QFont ( ff, fs ), true );
1399 1401
1400#if !defined(OPIE_NO_OVERRIDE_QT) 1402#if !defined(OPIE_NO_OVERRIDE_QT)
1401 // revert to global blocking policy ... 1403 // revert to global blocking policy ...
1402 Opie::force_appearance = config. readBoolEntry ( "ForceStyle", false ) ? Opie::Force_All : Opie::Force_None; 1404 Opie::force_appearance = config. readBoolEntry ( "ForceStyle", false ) ? Opie::Force_All : Opie::Force_None;
1403 Opie::force_appearance &= ~nostyle; 1405 Opie::force_appearance &= ~nostyle;
1404#endif 1406#endif
1405#endif 1407#endif
1406} 1408}
1407 1409
1408void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data ) 1410void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data )
1409{ 1411{
1410#ifdef Q_WS_QWS 1412#ifdef Q_WS_QWS
1411 QDataStream stream( data, IO_ReadOnly ); 1413 QDataStream stream( data, IO_ReadOnly );
1412 if ( msg == "applyStyle()" ) { 1414 if ( msg == "applyStyle()" ) {
1413 applyStyle(); 1415 applyStyle();
1414 } 1416 }
1415 else if ( msg == "toggleApplicationMenu()" ) { 1417 else if ( msg == "toggleApplicationMenu()" ) {
1416 QWidget *active = activeWindow ( ); 1418 QWidget *active = activeWindow ( );
1417 1419
1418 if ( active ) { 1420 if ( active ) {
1419 QPEMenuToolFocusManager *man = QPEMenuToolFocusManager::manager ( ); 1421 QPEMenuToolFocusManager *man = QPEMenuToolFocusManager::manager ( );
1420 bool oldactive = man-> isActive ( ); 1422 bool oldactive = man-> isActive ( );
1421 1423
1422 man-> setActive( !man-> isActive() ); 1424 man-> setActive( !man-> isActive() );
1423 1425
1424 if ( !oldactive && !man-> isActive ( )) { // no menubar to toggle -> try O-Menu 1426 if ( !oldactive && !man-> isActive ( )) { // no menubar to toggle -> try O-Menu
1425 QCopEnvelope e ( "QPE/TaskBar", "toggleStartMenu()" ); 1427 QCopEnvelope e ( "QPE/TaskBar", "toggleStartMenu()" );
1426 } 1428 }
1427 } 1429 }
1428 } 1430 }
1429 else if ( msg == "setDefaultRotation(int)" ) { 1431 else if ( msg == "setDefaultRotation(int)" ) {
1430 if ( type() == GuiServer ) { 1432 if ( type() == GuiServer ) {
1431 int r; 1433 int r;
1432 stream >> r; 1434 stream >> r;
1433 setDefaultRotation( r ); 1435 setDefaultRotation( r );
1434 } 1436 }
1435 } 1437 }
1436 else if ( msg == "setCurrentMode(int,int,int)" ) { // Added: 2003-06-11 by Tim Ansell <mithro@mithis.net> 1438 else if ( msg == "setCurrentMode(int,int,int)" ) { // Added: 2003-06-11 by Tim Ansell <mithro@mithis.net>
1437 if ( type() == GuiServer ) { 1439 if ( type() == GuiServer ) {
1438 int x, y, depth; 1440 int x, y, depth;
1439 stream >> x; 1441 stream >> x;
1440 stream >> y; 1442 stream >> y;
1441 stream >> depth; 1443 stream >> depth;
1442 setCurrentMode( x, y, depth ); 1444 setCurrentMode( x, y, depth );
1443 } 1445 }
1444 } 1446 }
1445 else if ( msg == "reset()" ) { 1447 else if ( msg == "reset()" ) {
1446 if ( type() != GuiServer ) 1448 if ( type() != GuiServer )
1447 reset(); 1449 reset();
1448 } 1450 }
1449 else if ( msg == "setCurrentRotation(int)" ) { 1451 else if ( msg == "setCurrentRotation(int)" ) {
1450 int r; 1452 int r;
1451 stream >> r; 1453 stream >> r;
1452 setCurrentRotation( r ); 1454 setCurrentRotation( r );
1453 } 1455 }
1454 else if ( msg == "shutdown()" ) { 1456 else if ( msg == "shutdown()" ) {
1455 if ( type() == GuiServer ) 1457 if ( type() == GuiServer )
1456 shutdown(); 1458 shutdown();
1457 } 1459 }
1458 else if ( msg == "quit()" ) { 1460 else if ( msg == "quit()" ) {
1459 if ( type() != GuiServer ) 1461 if ( type() != GuiServer )
1460 tryQuit(); 1462 tryQuit();
1461 } 1463 }
1462 else if ( msg == "forceQuit()" ) { 1464 else if ( msg == "forceQuit()" ) {
1463 if ( type() != GuiServer ) 1465 if ( type() != GuiServer )
1464 quit(); 1466 quit();
1465 } 1467 }
1466 else if ( msg == "restart()" ) { 1468 else if ( msg == "restart()" ) {
1467 if ( type() == GuiServer ) 1469 if ( type() == GuiServer )
1468 restart(); 1470 restart();
1469 } 1471 }
1470 else if ( msg == "language(QString)" ) { 1472 else if ( msg == "language(QString)" ) {
1471 if ( type() == GuiServer ) { 1473 if ( type() == GuiServer ) {
1472 QString l; 1474 QString l;
1473 stream >> l; 1475 stream >> l;
1474 QString cl = getenv( "LANG" ); 1476 QString cl = getenv( "LANG" );
1475 if ( cl != l ) { 1477 if ( cl != l ) {
1476 if ( l.isNull() ) 1478 if ( l.isNull() )
1477 unsetenv( "LANG" ); 1479 unsetenv( "LANG" );
1478 else 1480 else
1479 setenv( "LANG", l.latin1(), 1 ); 1481 setenv( "LANG", l.latin1(), 1 );
1480 restart(); 1482 restart();
1481 } 1483 }
1482 } 1484 }
1483 } 1485 }
1484 else if ( msg == "timeChange(QString)" ) { 1486 else if ( msg == "timeChange(QString)" ) {
1485 QString t; 1487 QString t;
1486 stream >> t; 1488 stream >> t;
1487 if ( t.isNull() ) 1489 if ( t.isNull() )
1488 unsetenv( "TZ" ); 1490 unsetenv( "TZ" );
1489 else 1491 else
1490 setenv( "TZ", t.latin1(), 1 ); 1492 setenv( "TZ", t.latin1(), 1 );
1491 // emit the signal so everyone else knows... 1493 // emit the signal so everyone else knows...
1492 emit timeChanged(); 1494 emit timeChanged();
1493 } 1495 }
1494 else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) { 1496 else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) {
1495 if ( type() == GuiServer ) { 1497 if ( type() == GuiServer ) {
1496 QDateTime when; 1498 QDateTime when;
1497 QCString channel, message; 1499 QCString channel, message;
1498 int data; 1500 int data;
1499 stream >> when >> channel >> message >> data; 1501 stream >> when >> channel >> message >> data;
1500 AlarmServer::addAlarm( when, channel, message, data ); 1502 AlarmServer::addAlarm( when, channel, message, data );
1501 } 1503 }
1502 } 1504 }
1503 else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) { 1505 else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) {
1504 if ( type() == GuiServer ) { 1506 if ( type() == GuiServer ) {
1505 QDateTime when; 1507 QDateTime when;
1506 QCString channel, message; 1508 QCString channel, message;
1507 int data; 1509 int data;
1508 stream >> when >> channel >> message >> data; 1510 stream >> when >> channel >> message >> data;
1509 AlarmServer::deleteAlarm( when, channel, message, data ); 1511 AlarmServer::deleteAlarm( when, channel, message, data );
1510 } 1512 }
1511 } 1513 }
1512 else if ( msg == "clockChange(bool)" ) { 1514 else if ( msg == "clockChange(bool)" ) {
1513 int tmp; 1515 int tmp;
1514 stream >> tmp; 1516 stream >> tmp;
1515 emit clockChanged( tmp ); 1517 emit clockChanged( tmp );
1516 } 1518 }
1517 else if ( msg == "weekChange(bool)" ) { 1519 else if ( msg == "weekChange(bool)" ) {
1518 int tmp; 1520 int tmp;
1519 stream >> tmp; 1521 stream >> tmp;
1520 emit weekChanged( tmp ); 1522 emit weekChanged( tmp );
1521 } 1523 }
1522 else if ( msg == "setDateFormat(DateFormat)" ) { 1524 else if ( msg == "setDateFormat(DateFormat)" ) {
1523 DateFormat tmp; 1525 DateFormat tmp;
1524 stream >> tmp; 1526 stream >> tmp;
1525 emit dateFormatChanged( tmp ); 1527 emit dateFormatChanged( tmp );
1526 } 1528 }
1527 else if ( msg == "setVolume(int,int)" ) { 1529 else if ( msg == "setVolume(int,int)" ) {
1528 int t, v; 1530 int t, v;
1529 stream >> t >> v; 1531 stream >> t >> v;
1530 setVolume( t, v ); 1532 setVolume( t, v );
1531 emit volumeChanged( muted ); 1533 emit volumeChanged( muted );
1532 } 1534 }
1533 else if ( msg == "volumeChange(bool)" ) { 1535 else if ( msg == "volumeChange(bool)" ) {
1534 stream >> muted; 1536 stream >> muted;
1535 setVolume(); 1537 setVolume();
1536 emit volumeChanged( muted ); 1538 emit volumeChanged( muted );
1537 } 1539 }
1538 else if ( msg == "setMic(int,int)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> 1540 else if ( msg == "setMic(int,int)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com>
1539 int t, v; 1541 int t, v;
1540 stream >> t >> v; 1542 stream >> t >> v;
1541 setMic( t, v ); 1543 setMic( t, v );
1542 emit micChanged( micMuted ); 1544 emit micChanged( micMuted );
1543 } 1545 }
1544 else if ( msg == "micChange(bool)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> 1546 else if ( msg == "micChange(bool)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com>
1545 stream >> micMuted; 1547 stream >> micMuted;
1546 setMic(); 1548 setMic();
1547 emit micChanged( micMuted ); 1549 emit micChanged( micMuted );
1548 } 1550 }
1549 else if ( msg == "setBass(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> 1551 else if ( msg == "setBass(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org>
1550 int t, v; 1552 int t, v;
1551 stream >> t >> v; 1553 stream >> t >> v;
1552 setBass( t, v ); 1554 setBass( t, v );
1553 } 1555 }
1554 else if ( msg == "bassChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> 1556 else if ( msg == "bassChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org>
1555 setBass(); 1557 setBass();
1556 } 1558 }
1557 else if ( msg == "setTreble(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> 1559 else if ( msg == "setTreble(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org>
1558 int t, v; 1560 int t, v;
1559 stream >> t >> v; 1561 stream >> t >> v;
1560 setTreble( t, v ); 1562 setTreble( t, v );
1561 } 1563 }
1562 else if ( msg == "trebleChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> 1564 else if ( msg == "trebleChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org>
1563 setTreble(); 1565 setTreble();
1564 } else if ( msg == "getMarkedText()" ) { 1566 } else if ( msg == "getMarkedText()" ) {
1565 if ( type() == GuiServer ) { 1567 if ( type() == GuiServer ) {
1566 const ushort unicode = 'C'-'@'; 1568 const ushort unicode = 'C'-'@';
1567 const int scan = Key_C; 1569 const int scan = Key_C;
1568 qwsServer->processKeyEvent( unicode, scan, ControlButton, TRUE, FALSE ); 1570 qwsServer->processKeyEvent( unicode, scan, ControlButton, TRUE, FALSE );
1569 qwsServer->processKeyEvent( unicode, scan, ControlButton, FALSE, FALSE ); 1571 qwsServer->processKeyEvent( unicode, scan, ControlButton, FALSE, FALSE );
1570 } 1572 }
1571 } else if ( msg == "newChannel(QString)") { 1573 } else if ( msg == "newChannel(QString)") {
1572 QString myChannel = "QPE/Application/" + d->appName; 1574 QString myChannel = "QPE/Application/" + d->appName;
1573 QString channel; 1575 QString channel;
1574 stream >> channel; 1576 stream >> channel;
1575 if (channel == myChannel) { 1577 if (channel == myChannel) {
1576 processQCopFile(); 1578 processQCopFile();
1577 d->sendQCopQ(); 1579 d->sendQCopQ();
1578 } 1580 }
1579 } 1581 }
1580 1582
1581 1583
1582#endif 1584#endif
1583} 1585}
1584 1586
1585 1587
1586 1588
1587 1589
1588 1590
1589/*! 1591/*!
1590 \internal 1592 \internal
1591*/ 1593*/
1592bool QPEApplication::raiseAppropriateWindow() 1594bool QPEApplication::raiseAppropriateWindow()
1593{ 1595{
1594 bool r=FALSE; 1596 bool r=FALSE;
1595 1597
1596 // 1. Raise the main widget 1598 // 1. Raise the main widget
1597 QWidget *top = d->qpe_main_widget; 1599 QWidget *top = d->qpe_main_widget;
1598 if ( !top ) top = mainWidget(); 1600 if ( !top ) top = mainWidget();
1599 1601
1600 if ( top && d->keep_running ) { 1602 if ( top && d->keep_running ) {
1601 if ( top->isVisible() ) 1603 if ( top->isVisible() )
1602 r = TRUE; 1604 r = TRUE;
1603 else if (d->preloaded) { 1605 else if (d->preloaded) {
1604 // We are preloaded and not visible.. pretend we just started.. 1606 // We are preloaded and not visible.. pretend we just started..
1605#ifndef QT_NO_COP 1607#ifndef QT_NO_COP
1606 QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); 1608 QCopEnvelope e("QPE/System", "fastAppShowing(QString)");
1607 e << d->appName; 1609 e << d->appName;
1608#endif 1610#endif
1609 } 1611 }
1610 1612
1611 d->show_mx(top,d->nomaximize, d->appName); 1613 d->show_mx(top,d->nomaximize, d->appName);
1612 top->raise(); 1614 top->raise();
1613 } 1615 }
1614 1616
1615 QWidget *topm = activeModalWidget(); 1617 QWidget *topm = activeModalWidget();
1616 1618
1617 // 2. Raise any parentless widgets (except top and topm, as they 1619 // 2. Raise any parentless widgets (except top and topm, as they
1618 // are raised before and after this loop). Order from most 1620 // are raised before and after this loop). Order from most
1619 // recently raised as deepest to least recently as top, so 1621 // recently raised as deepest to least recently as top, so
1620 // that repeated calls cycle through widgets. 1622 // that repeated calls cycle through widgets.
1621 QWidgetList *list = topLevelWidgets(); 1623 QWidgetList *list = topLevelWidgets();
1622 if ( list ) { 1624 if ( list ) {
1623 bool foundlast = FALSE; 1625 bool foundlast = FALSE;
1624 QWidget* topsub = 0; 1626 QWidget* topsub = 0;
1625 if ( d->lastraised ) { 1627 if ( d->lastraised ) {
1626 for (QWidget* w = list->first(); w; w = list->next()) { 1628 for (QWidget* w = list->first(); w; w = list->next()) {
1627 if ( !w->parentWidget() && w != topm && w->isVisible() && !w->isDesktop() ) { 1629 if ( !w->parentWidget() && w != topm && w->isVisible() && !w->isDesktop() ) {
1628 if ( w == d->lastraised ) 1630 if ( w == d->lastraised )
1629 foundlast = TRUE; 1631 foundlast = TRUE;
1630 if ( foundlast ) { 1632 if ( foundlast ) {
1631 w->raise(); 1633 w->raise();
1632 topsub = w; 1634 topsub = w;
1633 } 1635 }
1634 } 1636 }
1635 } 1637 }
1636 } 1638 }
1637 for (QWidget* w = list->first(); w; w = list->next()) { 1639 for (QWidget* w = list->first(); w; w = list->next()) {
1638 if ( !w->parentWidget() && w != topm && w->isVisible() && !w->isDesktop() ) { 1640 if ( !w->parentWidget() && w != topm && w->isVisible() && !w->isDesktop() ) {
1639 if ( w == d->lastraised ) 1641 if ( w == d->lastraised )
1640 break; 1642 break;
1641 w->raise(); 1643 w->raise();
1642 topsub = w; 1644 topsub = w;
1643 } 1645 }
1644 } 1646 }