-rw-r--r-- | library/qpeapplication.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp index f4db1ab..19adb00 100644 --- a/library/qpeapplication.cpp +++ b/library/qpeapplication.cpp | |||
@@ -868,264 +868,266 @@ bool QPEApplication::qwsEventFilter( QWSEvent * e ) | |||
868 | Destroys the QPEApplication. | 868 | Destroys the QPEApplication. |
869 | */ | 869 | */ |
870 | QPEApplication::~QPEApplication() | 870 | QPEApplication::~QPEApplication() |
871 | { | 871 | { |
872 | ungrabKeyboard(); | 872 | ungrabKeyboard(); |
873 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 873 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
874 | // Need to delete QCopChannels early, since the display will | 874 | // Need to delete QCopChannels early, since the display will |
875 | // be gone by the time we get to ~QObject(). | 875 | // be gone by the time we get to ~QObject(). |
876 | delete sysChannel; | 876 | delete sysChannel; |
877 | delete pidChannel; | 877 | delete pidChannel; |
878 | #endif | 878 | #endif |
879 | 879 | ||
880 | delete d; | 880 | delete d; |
881 | } | 881 | } |
882 | 882 | ||
883 | /*! | 883 | /*! |
884 | Returns <tt>$OPIEDIR/</tt>. | 884 | Returns <tt>$OPIEDIR/</tt>. |
885 | */ | 885 | */ |
886 | QString QPEApplication::qpeDir() | 886 | QString QPEApplication::qpeDir() |
887 | { | 887 | { |
888 | const char * base = getenv( "OPIEDIR" ); | 888 | const char * base = getenv( "OPIEDIR" ); |
889 | if ( base ) | 889 | if ( base ) |
890 | return QString( base ) + "/"; | 890 | return QString( base ) + "/"; |
891 | 891 | ||
892 | return QString( "../" ); | 892 | return QString( "../" ); |
893 | } | 893 | } |
894 | 894 | ||
895 | /*! | 895 | /*! |
896 | Returns the user's current Document directory. There is a trailing "/". | 896 | Returns the user's current Document directory. There is a trailing "/". |
897 | .. well, it does now,, and there's no trailing '/' | 897 | .. well, it does now,, and there's no trailing '/' |
898 | */ | 898 | */ |
899 | QString QPEApplication::documentDir() | 899 | QString QPEApplication::documentDir() |
900 | { | 900 | { |
901 | const char* base = getenv( "HOME"); | 901 | const char* base = getenv( "HOME"); |
902 | if ( base ) | 902 | if ( base ) |
903 | return QString( base ) + "/Documents"; | 903 | return QString( base ) + "/Documents"; |
904 | 904 | ||
905 | return QString( "../Documents" ); | 905 | return QString( "../Documents" ); |
906 | } | 906 | } |
907 | 907 | ||
908 | static int deforient = -1; | 908 | static int deforient = -1; |
909 | 909 | ||
910 | /*! | 910 | /*! |
911 | \internal | 911 | \internal |
912 | */ | 912 | */ |
913 | int QPEApplication::defaultRotation() | 913 | int QPEApplication::defaultRotation() |
914 | { | 914 | { |
915 | if ( deforient < 0 ) { | 915 | if ( deforient < 0 ) { |
916 | QString d = getenv( "QWS_DISPLAY" ); | 916 | QString d = getenv( "QWS_DISPLAY" ); |
917 | if ( d.contains( "Rot90" ) ) { | 917 | if ( d.contains( "Rot90" ) ) { |
918 | deforient = 90; | 918 | deforient = 90; |
919 | } | 919 | } |
920 | else if ( d.contains( "Rot180" ) ) { | 920 | else if ( d.contains( "Rot180" ) ) { |
921 | deforient = 180; | 921 | deforient = 180; |
922 | } | 922 | } |
923 | else if ( d.contains( "Rot270" ) ) { | 923 | else if ( d.contains( "Rot270" ) ) { |
924 | deforient = 270; | 924 | deforient = 270; |
925 | } | 925 | } |
926 | else { | 926 | else { |
927 | deforient = 0; | 927 | deforient = 0; |
928 | } | 928 | } |
929 | } | 929 | } |
930 | return deforient; | 930 | return deforient; |
931 | } | 931 | } |
932 | 932 | ||
933 | /*! | 933 | /*! |
934 | \internal | 934 | \internal |
935 | */ | 935 | */ |
936 | void QPEApplication::setDefaultRotation( int r ) | 936 | void QPEApplication::setDefaultRotation( int r ) |
937 | { | 937 | { |
938 | if ( qApp->type() == GuiServer ) { | 938 | if ( qApp->type() == GuiServer ) { |
939 | deforient = r; | 939 | deforient = r; |
940 | setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 ); | 940 | setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 ); |
941 | Config config("qpe"); | 941 | Config config("qpe"); |
942 | config.setGroup( "Rotation" ); | 942 | config.setGroup( "Rotation" ); |
943 | config.writeEntry( "Rot", r ); | 943 | config.writeEntry( "Rot", r ); |
944 | } | 944 | } |
945 | else { | 945 | else { |
946 | #ifndef QT_NO_COP | 946 | #ifndef QT_NO_COP |
947 | { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" ); | 947 | { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" ); |
948 | e << r; | 948 | e << r; |
949 | } | 949 | } |
950 | #endif | 950 | #endif |
951 | 951 | ||
952 | } | 952 | } |
953 | } | 953 | } |
954 | 954 | ||
955 | 955 | ||
956 | /*! | 956 | /*! |
957 | \internal | 957 | \internal |
958 | */ | 958 | */ |
959 | void QPEApplication::applyStyle() | 959 | void QPEApplication::applyStyle() |
960 | { | 960 | { |
961 | Config config( "qpe" ); | 961 | Config config( "qpe" ); |
962 | config.setGroup( "Appearance" ); | 962 | config.setGroup( "Appearance" ); |
963 | 963 | ||
964 | #if QT_VERSION > 233 | ||
964 | // don't block ourselves ... | 965 | // don't block ourselves ... |
965 | Opie::force_appearance = 0; | 966 | Opie::force_appearance = 0; |
966 | 967 | ||
967 | static QString appname = Opie::binaryName ( ); | 968 | static QString appname = Opie::binaryName ( ); |
968 | 969 | ||
969 | QStringList ex = config. readListEntry ( "NoStyle", ';' ); | 970 | QStringList ex = config. readListEntry ( "NoStyle", ';' ); |
970 | int nostyle = 0; | 971 | int nostyle = 0; |
971 | for ( QStringList::Iterator it = ex. begin ( ); it != ex. end ( ); ++it ) { | 972 | for ( QStringList::Iterator it = ex. begin ( ); it != ex. end ( ); ++it ) { |
972 | if ( QRegExp (( *it ). mid ( 1 ), false, true ). find ( appname, 0 ) >= 0 ) { | 973 | if ( QRegExp (( *it ). mid ( 1 ), false, true ). find ( appname, 0 ) >= 0 ) { |
973 | nostyle = ( *it ). left ( 1 ). toInt ( 0, 32 ); | 974 | nostyle = ( *it ). left ( 1 ). toInt ( 0, 32 ); |
974 | break; | 975 | break; |
975 | } | 976 | } |
976 | } | 977 | } |
977 | 978 | ||
978 | // Widget style | 979 | // Widget style |
979 | QString style = config.readEntry( "Style", "Light" ); | 980 | QString style = config.readEntry( "Style", "Light" ); |
980 | 981 | ||
981 | // don't set a custom style | 982 | // don't set a custom style |
982 | if ( nostyle & Opie::Force_Style ) | 983 | if ( nostyle & Opie::Force_Style ) |
983 | style = "Light"; | 984 | style = "Light"; |
984 | 985 | ||
985 | internalSetStyle ( style ); | 986 | internalSetStyle ( style ); |
986 | 987 | ||
987 | // Colors | 988 | // Colors |
988 | QColor bgcolor( config.readEntry( "Background", "#E5E1D5" ) ); | 989 | QColor bgcolor( config.readEntry( "Background", "#E5E1D5" ) ); |
989 | QColor btncolor( config.readEntry( "Button", "#D6CDBB" ) ); | 990 | QColor btncolor( config.readEntry( "Button", "#D6CDBB" ) ); |
990 | QPalette pal( btncolor, bgcolor ); | 991 | QPalette pal( btncolor, bgcolor ); |
991 | QString color = config.readEntry( "Highlight", "#800000" ); | 992 | QString color = config.readEntry( "Highlight", "#800000" ); |
992 | pal.setColor( QColorGroup::Highlight, QColor( color ) ); | 993 | pal.setColor( QColorGroup::Highlight, QColor( color ) ); |
993 | color = config.readEntry( "HighlightedText", "#FFFFFF" ); | 994 | color = config.readEntry( "HighlightedText", "#FFFFFF" ); |
994 | pal.setColor( QColorGroup::HighlightedText, QColor( color ) ); | 995 | pal.setColor( QColorGroup::HighlightedText, QColor( color ) ); |
995 | color = config.readEntry( "Text", "#000000" ); | 996 | color = config.readEntry( "Text", "#000000" ); |
996 | pal.setColor( QColorGroup::Text, QColor( color ) ); | 997 | pal.setColor( QColorGroup::Text, QColor( color ) ); |
997 | color = config.readEntry( "ButtonText", "#000000" ); | 998 | color = config.readEntry( "ButtonText", "#000000" ); |
998 | pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) ); | 999 | pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) ); |
999 | color = config.readEntry( "Base", "#FFFFFF" ); | 1000 | color = config.readEntry( "Base", "#FFFFFF" ); |
1000 | pal.setColor( QColorGroup::Base, QColor( color ) ); | 1001 | pal.setColor( QColorGroup::Base, QColor( color ) ); |
1001 | 1002 | ||
1002 | pal.setColor( QPalette::Disabled, QColorGroup::Text, | 1003 | pal.setColor( QPalette::Disabled, QColorGroup::Text, |
1003 | pal.color( QPalette::Active, QColorGroup::Background ).dark() ); | 1004 | pal.color( QPalette::Active, QColorGroup::Background ).dark() ); |
1004 | 1005 | ||
1005 | setPalette( pal, TRUE ); | 1006 | setPalette( pal, TRUE ); |
1006 | 1007 | ||
1007 | // Window Decoration | 1008 | // Window Decoration |
1008 | QString dec = config.readEntry( "Decoration", "Qtopia" ); | 1009 | QString dec = config.readEntry( "Decoration", "Qtopia" ); |
1009 | 1010 | ||
1010 | // don't set a custom deco | 1011 | // don't set a custom deco |
1011 | if ( nostyle & Opie::Force_Decoration ) | 1012 | if ( nostyle & Opie::Force_Decoration ) |
1012 | dec = ""; | 1013 | dec = ""; |
1013 | 1014 | ||
1014 | //qDebug ( "Setting Deco: %s -- old %s (%d)", dec.latin1(), d-> decorationName.latin1(), nostyle); | 1015 | //qDebug ( "Setting Deco: %s -- old %s (%d)", dec.latin1(), d-> decorationName.latin1(), nostyle); |
1015 | 1016 | ||
1016 | if ( dec != d->decorationName ) { | 1017 | if ( dec != d->decorationName ) { |
1017 | qwsSetDecoration( new QPEDecoration( dec ) ); | 1018 | qwsSetDecoration( new QPEDecoration( dec ) ); |
1018 | d->decorationName = dec; | 1019 | d->decorationName = dec; |
1019 | } | 1020 | } |
1020 | 1021 | ||
1021 | // Font | 1022 | // Font |
1022 | QString ff = config.readEntry( "FontFamily", font().family() ); | 1023 | QString ff = config.readEntry( "FontFamily", font().family() ); |
1023 | int fs = config.readNumEntry( "FontSize", font().pointSize() ); | 1024 | int fs = config.readNumEntry( "FontSize", font().pointSize() ); |
1024 | 1025 | ||
1025 | // don't set a custom font | 1026 | // don't set a custom font |
1026 | if ( nostyle & Opie::Force_Font ) { | 1027 | if ( nostyle & Opie::Force_Font ) { |
1027 | ff = "Vera"; | 1028 | ff = "Vera"; |
1028 | fs = 10; | 1029 | fs = 10; |
1029 | } | 1030 | } |
1030 | 1031 | ||
1031 | setFont ( QFont ( ff, fs ), true ); | 1032 | setFont ( QFont ( ff, fs ), true ); |
1032 | 1033 | ||
1033 | // revert to global blocking policy ... | 1034 | // revert to global blocking policy ... |
1034 | Opie::force_appearance = config. readBoolEntry ( "ForceStyle", false ) ? Opie::Force_All : Opie::Force_None; | 1035 | Opie::force_appearance = config. readBoolEntry ( "ForceStyle", false ) ? Opie::Force_All : Opie::Force_None; |
1035 | Opie::force_appearance &= ~nostyle; | 1036 | Opie::force_appearance &= ~nostyle; |
1037 | #endif | ||
1036 | } | 1038 | } |
1037 | 1039 | ||
1038 | void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data ) | 1040 | void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data ) |
1039 | { | 1041 | { |
1040 | #ifdef Q_WS_QWS | 1042 | #ifdef Q_WS_QWS |
1041 | QDataStream stream( data, IO_ReadOnly ); | 1043 | QDataStream stream( data, IO_ReadOnly ); |
1042 | if ( msg == "applyStyle()" ) { | 1044 | if ( msg == "applyStyle()" ) { |
1043 | applyStyle(); | 1045 | applyStyle(); |
1044 | } | 1046 | } |
1045 | else if ( msg == "toggleApplicationMenu()" ) { | 1047 | else if ( msg == "toggleApplicationMenu()" ) { |
1046 | QWidget *active = activeWindow ( ); | 1048 | QWidget *active = activeWindow ( ); |
1047 | 1049 | ||
1048 | if ( active ) { | 1050 | if ( active ) { |
1049 | QPEMenuToolFocusManager *man = QPEMenuToolFocusManager::manager ( ); | 1051 | QPEMenuToolFocusManager *man = QPEMenuToolFocusManager::manager ( ); |
1050 | bool oldactive = man-> isActive ( ); | 1052 | bool oldactive = man-> isActive ( ); |
1051 | 1053 | ||
1052 | man-> setActive( !man-> isActive() ); | 1054 | man-> setActive( !man-> isActive() ); |
1053 | 1055 | ||
1054 | if ( !oldactive && !man-> isActive ( )) { // no menubar to toggle -> try O-Menu | 1056 | if ( !oldactive && !man-> isActive ( )) { // no menubar to toggle -> try O-Menu |
1055 | QCopEnvelope e ( "QPE/TaskBar", "toggleStartMenu()" ); | 1057 | QCopEnvelope e ( "QPE/TaskBar", "toggleStartMenu()" ); |
1056 | } | 1058 | } |
1057 | } | 1059 | } |
1058 | } | 1060 | } |
1059 | else if ( msg == "setDefaultRotation(int)" ) { | 1061 | else if ( msg == "setDefaultRotation(int)" ) { |
1060 | if ( type() == GuiServer ) { | 1062 | if ( type() == GuiServer ) { |
1061 | int r; | 1063 | int r; |
1062 | stream >> r; | 1064 | stream >> r; |
1063 | setDefaultRotation( r ); | 1065 | setDefaultRotation( r ); |
1064 | } | 1066 | } |
1065 | } | 1067 | } |
1066 | else if ( msg == "setCurrentRotation(int)" ) { | 1068 | else if ( msg == "setCurrentRotation(int)" ) { |
1067 | int r; | 1069 | int r; |
1068 | stream >> r; | 1070 | stream >> r; |
1069 | setCurrentRotation( r ); | 1071 | setCurrentRotation( r ); |
1070 | } | 1072 | } |
1071 | else if ( msg == "shutdown()" ) { | 1073 | else if ( msg == "shutdown()" ) { |
1072 | if ( type() == GuiServer ) | 1074 | if ( type() == GuiServer ) |
1073 | shutdown(); | 1075 | shutdown(); |
1074 | } | 1076 | } |
1075 | else if ( msg == "quit()" ) { | 1077 | else if ( msg == "quit()" ) { |
1076 | if ( type() != GuiServer ) | 1078 | if ( type() != GuiServer ) |
1077 | tryQuit(); | 1079 | tryQuit(); |
1078 | } | 1080 | } |
1079 | else if ( msg == "forceQuit()" ) { | 1081 | else if ( msg == "forceQuit()" ) { |
1080 | if ( type() != GuiServer ) | 1082 | if ( type() != GuiServer ) |
1081 | quit(); | 1083 | quit(); |
1082 | } | 1084 | } |
1083 | else if ( msg == "restart()" ) { | 1085 | else if ( msg == "restart()" ) { |
1084 | if ( type() == GuiServer ) | 1086 | if ( type() == GuiServer ) |
1085 | restart(); | 1087 | restart(); |
1086 | } | 1088 | } |
1087 | else if ( msg == "language(QString)" ) { | 1089 | else if ( msg == "language(QString)" ) { |
1088 | if ( type() == GuiServer ) { | 1090 | if ( type() == GuiServer ) { |
1089 | QString l; | 1091 | QString l; |
1090 | stream >> l; | 1092 | stream >> l; |
1091 | QString cl = getenv( "LANG" ); | 1093 | QString cl = getenv( "LANG" ); |
1092 | if ( cl != l ) { | 1094 | if ( cl != l ) { |
1093 | if ( l.isNull() ) | 1095 | if ( l.isNull() ) |
1094 | unsetenv( "LANG" ); | 1096 | unsetenv( "LANG" ); |
1095 | else | 1097 | else |
1096 | setenv( "LANG", l.latin1(), 1 ); | 1098 | setenv( "LANG", l.latin1(), 1 ); |
1097 | restart(); | 1099 | restart(); |
1098 | } | 1100 | } |
1099 | } | 1101 | } |
1100 | } | 1102 | } |
1101 | else if ( msg == "timeChange(QString)" ) { | 1103 | else if ( msg == "timeChange(QString)" ) { |
1102 | QString t; | 1104 | QString t; |
1103 | stream >> t; | 1105 | stream >> t; |
1104 | if ( t.isNull() ) | 1106 | if ( t.isNull() ) |
1105 | unsetenv( "TZ" ); | 1107 | unsetenv( "TZ" ); |
1106 | else | 1108 | else |
1107 | setenv( "TZ", t.latin1(), 1 ); | 1109 | setenv( "TZ", t.latin1(), 1 ); |
1108 | // emit the signal so everyone else knows... | 1110 | // emit the signal so everyone else knows... |
1109 | emit timeChanged(); | 1111 | emit timeChanged(); |
1110 | } | 1112 | } |
1111 | else if ( msg == "execute(QString)" ) { | 1113 | else if ( msg == "execute(QString)" ) { |
1112 | if ( type() == GuiServer ) { | 1114 | if ( type() == GuiServer ) { |
1113 | QString t; | 1115 | QString t; |
1114 | stream >> t; | 1116 | stream >> t; |
1115 | Global::execute( t ); | 1117 | Global::execute( t ); |
1116 | } | 1118 | } |
1117 | } | 1119 | } |
1118 | else if ( msg == "execute(QString,QString)" ) { | 1120 | else if ( msg == "execute(QString,QString)" ) { |
1119 | if ( type() == GuiServer ) { | 1121 | if ( type() == GuiServer ) { |
1120 | QString t, d; | 1122 | QString t, d; |
1121 | stream >> t >> d; | 1123 | stream >> t >> d; |
1122 | Global::execute( t, d ); | 1124 | Global::execute( t, d ); |
1123 | } | 1125 | } |
1124 | } | 1126 | } |
1125 | else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) { | 1127 | else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) { |
1126 | if ( type() == GuiServer ) { | 1128 | if ( type() == GuiServer ) { |
1127 | QDateTime when; | 1129 | QDateTime when; |
1128 | QCString channel, message; | 1130 | QCString channel, message; |
1129 | int data; | 1131 | int data; |
1130 | stream >> when >> channel >> message >> data; | 1132 | stream >> when >> channel >> message >> data; |
1131 | AlarmServer::addAlarm( when, channel, message, data ); | 1133 | AlarmServer::addAlarm( when, channel, message, data ); |