summaryrefslogtreecommitdiff
path: root/library/qpeapplication.cpp
Unidiff
Diffstat (limited to 'library/qpeapplication.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--library/qpeapplication.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp
index a54fb20..c8e6e74 100644
--- a/library/qpeapplication.cpp
+++ b/library/qpeapplication.cpp
@@ -774,351 +774,354 @@ bool QPEApplication::qwsEventFilter( QWSEvent * e )
774 774
775 } 775 }
776 if ( e->type == QWSEvent::Focus ) { 776 if ( e->type == QWSEvent::Focus ) {
777 QWSFocusEvent * fe = ( QWSFocusEvent* ) e; 777 QWSFocusEvent * fe = ( QWSFocusEvent* ) e;
778 QWidget* nfw = QWidget::find( e->window() ); 778 QWidget* nfw = QWidget::find( e->window() );
779 if ( !fe->simpleData.get_focus ) { 779 if ( !fe->simpleData.get_focus ) {
780 QWidget * active = activeWindow(); 780 QWidget * active = activeWindow();
781 while ( active && active->isPopup() ) { 781 while ( active && active->isPopup() ) {
782 active->close(); 782 active->close();
783 active = activeWindow(); 783 active = activeWindow();
784 } 784 }
785 if ( !nfw && d->kbgrabber == 2 ) { 785 if ( !nfw && d->kbgrabber == 2 ) {
786 ungrabKeyboard(); 786 ungrabKeyboard();
787 d->kbregrab = TRUE; // want kb back when we're active 787 d->kbregrab = TRUE; // want kb back when we're active
788 } 788 }
789 } 789 }
790 else { 790 else {
791 // make sure our modal widget is ALWAYS on top 791 // make sure our modal widget is ALWAYS on top
792 QWidget *topm = activeModalWidget(); 792 QWidget *topm = activeModalWidget();
793 if ( topm ) { 793 if ( topm ) {
794 topm->raise(); 794 topm->raise();
795 } 795 }
796 if ( d->kbregrab ) { 796 if ( d->kbregrab ) {
797 grabKeyboard(); 797 grabKeyboard();
798 d->kbregrab = FALSE; 798 d->kbregrab = FALSE;
799 } 799 }
800 } 800 }
801 if ( fe->simpleData.get_focus && inputMethodDict ) { 801 if ( fe->simpleData.get_focus && inputMethodDict ) {
802 InputMethodHint m = inputMethodHint( QWidget::find( e->window() ) ); 802 InputMethodHint m = inputMethodHint( QWidget::find( e->window() ) );
803 if ( m == AlwaysOff ) 803 if ( m == AlwaysOff )
804 Global::hideInputMethod(); 804 Global::hideInputMethod();
805 if ( m == AlwaysOn ) 805 if ( m == AlwaysOn )
806 Global::showInputMethod(); 806 Global::showInputMethod();
807 } 807 }
808 } 808 }
809 return QApplication::qwsEventFilter( e ); 809 return QApplication::qwsEventFilter( e );
810} 810}
811#endif 811#endif
812 812
813/*! 813/*!
814 Destroys the QPEApplication. 814 Destroys the QPEApplication.
815*/ 815*/
816QPEApplication::~QPEApplication() 816QPEApplication::~QPEApplication()
817{ 817{
818 ungrabKeyboard(); 818 ungrabKeyboard();
819#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 819#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
820 // Need to delete QCopChannels early, since the display will 820 // Need to delete QCopChannels early, since the display will
821 // be gone by the time we get to ~QObject(). 821 // be gone by the time we get to ~QObject().
822 delete sysChannel; 822 delete sysChannel;
823 delete pidChannel; 823 delete pidChannel;
824#endif 824#endif
825 825
826 delete d; 826 delete d;
827} 827}
828 828
829/*! 829/*!
830 Returns <tt>$OPIEDIR/</tt>. 830 Returns <tt>$OPIEDIR/</tt>.
831*/ 831*/
832QString QPEApplication::qpeDir() 832QString QPEApplication::qpeDir()
833{ 833{
834 const char * base = getenv( "OPIEDIR" ); 834 const char * base = getenv( "OPIEDIR" );
835 if ( base ) 835 if ( base )
836 return QString( base ) + "/"; 836 return QString( base ) + "/";
837 837
838 return QString( "../" ); 838 return QString( "../" );
839} 839}
840 840
841/*! 841/*!
842 Returns the user's current Document directory. There is a trailing "/". 842 Returns the user's current Document directory. There is a trailing "/".
843 .. well, it does now,, and there's no trailing '/' 843 .. well, it does now,, and there's no trailing '/'
844*/ 844*/
845QString QPEApplication::documentDir() 845QString QPEApplication::documentDir()
846{ 846{
847 const char* base = getenv( "HOME"); 847 const char* base = getenv( "HOME");
848 if ( base ) 848 if ( base )
849 return QString( base ) + "/Documents"; 849 return QString( base ) + "/Documents";
850 850
851 return QString( "../Documents" ); 851 return QString( "../Documents" );
852} 852}
853 853
854static int deforient = -1; 854static int deforient = -1;
855 855
856/*! 856/*!
857 \internal 857 \internal
858*/ 858*/
859int QPEApplication::defaultRotation() 859int QPEApplication::defaultRotation()
860{ 860{
861 if ( deforient < 0 ) { 861 if ( deforient < 0 ) {
862 QString d = getenv( "QWS_DISPLAY" ); 862 QString d = getenv( "QWS_DISPLAY" );
863 if ( d.contains( "Rot90" ) ) { 863 if ( d.contains( "Rot90" ) ) {
864 deforient = 90; 864 deforient = 90;
865 } 865 }
866 else if ( d.contains( "Rot180" ) ) { 866 else if ( d.contains( "Rot180" ) ) {
867 deforient = 180; 867 deforient = 180;
868 } 868 }
869 else if ( d.contains( "Rot270" ) ) { 869 else if ( d.contains( "Rot270" ) ) {
870 deforient = 270; 870 deforient = 270;
871 } 871 }
872 else { 872 else {
873 deforient = 0; 873 deforient = 0;
874 } 874 }
875 } 875 }
876 return deforient; 876 return deforient;
877} 877}
878 878
879/*! 879/*!
880 \internal 880 \internal
881*/ 881*/
882void QPEApplication::setDefaultRotation( int r ) 882void QPEApplication::setDefaultRotation( int r )
883{ 883{
884 if ( qApp->type() == GuiServer ) { 884 if ( qApp->type() == GuiServer ) {
885 deforient = r; 885 deforient = r;
886 setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 ); 886 setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 );
887 Config config("qpe"); 887 Config config("qpe");
888 config.setGroup( "Rotation" ); 888 config.setGroup( "Rotation" );
889 config.writeEntry( "Screen", getenv("QWS_DISPLAY") ); 889 config.writeEntry( "Screen", getenv("QWS_DISPLAY") );
890 } 890 }
891 else { 891 else {
892#ifndef QT_NO_COP 892#ifndef QT_NO_COP
893 { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" ); 893 { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" );
894 e << r; 894 e << r;
895 } 895 }
896#endif 896#endif
897 897
898 } 898 }
899} 899}
900 900
901// exported to libpreload.so 901// exported to libpreload.so
902bool opie_block_style = false; 902int opie_block_style = 0;
903 903
904/*! 904/*!
905 \internal 905 \internal
906*/ 906*/
907void QPEApplication::applyStyle() 907void QPEApplication::applyStyle()
908{ 908{
909 Config config( "qpe" ); 909 Config config( "qpe" );
910 config.setGroup( "Appearance" ); 910 config.setGroup( "Appearance" );
911 911
912 // don't block ourselves ... 912 // don't block ourselves ...
913 opie_block_style = false; 913 opie_block_style = 0;
914 914
915 915
916 static QString appname; 916 static QString appname;
917 917
918 if ( appname. isNull ( )) { 918 if ( appname. isNull ( )) {
919 char src [32]; 919 char src [32];
920 char dst [PATH_MAX + 1]; 920 char dst [PATH_MAX + 1];
921 ::sprintf ( src, "/proc/%d/exe", ::getpid ( )); 921 ::sprintf ( src, "/proc/%d/exe", ::getpid ( ));
922 int l = ::readlink ( src, dst, PATH_MAX ); 922 int l = ::readlink ( src, dst, PATH_MAX );
923 if ( l > 0 ) { 923 if ( l > 0 ) {
924 dst [l] = 0; 924 dst [l] = 0;
925 const char *b = ::strrchr ( dst, '/' ); 925 const char *b = ::strrchr ( dst, '/' );
926 appname = ( b ? b + 1 : dst ); 926 appname = ( b ? b + 1 : dst );
927 } 927 }
928 else 928 else
929 appname = ""; 929 appname = "";
930 } 930 }
931 931
932 932
933 QStringList ex = config. readListEntry ( "NoStyle", ';' ); 933 QStringList ex = config. readListEntry ( "NoStyle", ';' );
934 int nostyle = 0; 934 int nostyle = 0;
935 for ( QStringList::Iterator it = ex. begin ( ); it != ex. end ( ); ++it ) { 935 for ( QStringList::Iterator it = ex. begin ( ); it != ex. end ( ); ++it ) {
936 if ( QRegExp (( *it ). mid ( 1 ), false, true ). find ( appname, 0 ) >= 0 ) { 936 if ( QRegExp (( *it ). mid ( 1 ), false, true ). find ( appname, 0 ) >= 0 ) {
937 nostyle = ( *it ). left ( 1 ). toInt ( 0, 32 ); 937 nostyle = ( *it ). left ( 1 ). toInt ( 0, 32 );
938 break; 938 break;
939 } 939 }
940 } 940 }
941 941
942 // Widget style 942 // Widget style
943 QString style = config.readEntry( "Style", "Light" ); 943 QString style = config.readEntry( "Style", "Light" );
944 944
945 // don't set a custom style 945 // don't set a custom style
946 if ( nostyle & 0x01 ) 946 if ( nostyle & 0x01 )
947 style = "Light"; 947 style = "Light";
948 948
949 internalSetStyle ( style ); 949 internalSetStyle ( style );
950 950
951 // Colors 951 // Colors
952 QColor bgcolor( config.readEntry( "Background", "#E5E1D5" ) ); 952 QColor bgcolor( config.readEntry( "Background", "#E5E1D5" ) );
953 QColor btncolor( config.readEntry( "Button", "#D6CDBB" ) ); 953 QColor btncolor( config.readEntry( "Button", "#D6CDBB" ) );
954 QPalette pal( btncolor, bgcolor ); 954 QPalette pal( btncolor, bgcolor );
955 QString color = config.readEntry( "Highlight", "#800000" ); 955 QString color = config.readEntry( "Highlight", "#800000" );
956 pal.setColor( QColorGroup::Highlight, QColor( color ) ); 956 pal.setColor( QColorGroup::Highlight, QColor( color ) );
957 color = config.readEntry( "HighlightedText", "#FFFFFF" ); 957 color = config.readEntry( "HighlightedText", "#FFFFFF" );
958 pal.setColor( QColorGroup::HighlightedText, QColor( color ) ); 958 pal.setColor( QColorGroup::HighlightedText, QColor( color ) );
959 color = config.readEntry( "Text", "#000000" ); 959 color = config.readEntry( "Text", "#000000" );
960 pal.setColor( QColorGroup::Text, QColor( color ) ); 960 pal.setColor( QColorGroup::Text, QColor( color ) );
961 color = config.readEntry( "ButtonText", "#000000" ); 961 color = config.readEntry( "ButtonText", "#000000" );
962 pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) ); 962 pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) );
963 color = config.readEntry( "Base", "#FFFFFF" ); 963 color = config.readEntry( "Base", "#FFFFFF" );
964 pal.setColor( QColorGroup::Base, QColor( color ) ); 964 pal.setColor( QColorGroup::Base, QColor( color ) );
965 965
966 pal.setColor( QPalette::Disabled, QColorGroup::Text, 966 pal.setColor( QPalette::Disabled, QColorGroup::Text,
967 pal.color( QPalette::Active, QColorGroup::Background ).dark() ); 967 pal.color( QPalette::Active, QColorGroup::Background ).dark() );
968 968
969 setPalette( pal, TRUE ); 969 setPalette( pal, TRUE );
970 970
971 // Window Decoration 971 // Window Decoration
972 QString dec = config.readEntry( "Decoration", "Qtopia" ); 972 QString dec = config.readEntry( "Decoration", "Qtopia" );
973 973
974 // don't set a custom deco 974 // don't set a custom deco
975 if ( nostyle & 0x04 ) 975 if ( nostyle & 0x04 )
976 dec = ""; 976 dec = "";
977 977
978 //qDebug ( "Setting Deco: %s -- old %s (%d)", dec.latin1(), d-> decorationName.latin1(), nostyle);
979
978 if ( dec != d->decorationName ) { 980 if ( dec != d->decorationName ) {
979 qwsSetDecoration( new QPEDecoration( dec ) ); 981 qwsSetDecoration( new QPEDecoration( dec ) );
980 d->decorationName = dec; 982 d->decorationName = dec;
981 } 983 }
982 984
983 // Font 985 // Font
984 QString ff = config.readEntry( "FontFamily", font().family() ); 986 QString ff = config.readEntry( "FontFamily", font().family() );
985 int fs = config.readNumEntry( "FontSize", font().pointSize() ); 987 int fs = config.readNumEntry( "FontSize", font().pointSize() );
986 988
987 // don't set a custom font 989 // don't set a custom font
988 if ( nostyle & 0x02 ) { 990 if ( nostyle & 0x02 ) {
989 ff = "Helvetica"; 991 ff = "Helvetica";
990 fs = 10; 992 fs = 10;
991 } 993 }
992 994
993 setFont( QFont(ff, fs) ); 995 setFont( QFont(ff, fs) );
994 996
995 // revert to global blocking policy ... 997 // revert to global blocking policy ...
996 opie_block_style = config. readBoolEntry ( "ForceStyle", false ); 998 opie_block_style = config. readBoolEntry ( "ForceStyle", false ) ? 0xff : 0x00;
999 opie_block_style -= nostyle;
997} 1000}
998 1001
999void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data ) 1002void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data )
1000{ 1003{
1001#ifdef Q_WS_QWS 1004#ifdef Q_WS_QWS
1002 QDataStream stream( data, IO_ReadOnly ); 1005 QDataStream stream( data, IO_ReadOnly );
1003 if ( msg == "applyStyle()" ) { 1006 if ( msg == "applyStyle()" ) {
1004 applyStyle(); 1007 applyStyle();
1005 } 1008 }
1006 else if ( msg == "setDefaultRotation(int)" ) { 1009 else if ( msg == "setDefaultRotation(int)" ) {
1007 if ( type() == GuiServer ) { 1010 if ( type() == GuiServer ) {
1008 int r; 1011 int r;
1009 stream >> r; 1012 stream >> r;
1010 setDefaultRotation( r ); 1013 setDefaultRotation( r );
1011 } 1014 }
1012 } 1015 }
1013 else if ( msg == "shutdown()" ) { 1016 else if ( msg == "shutdown()" ) {
1014 if ( type() == GuiServer ) 1017 if ( type() == GuiServer )
1015 shutdown(); 1018 shutdown();
1016 } 1019 }
1017 else if ( msg == "quit()" ) { 1020 else if ( msg == "quit()" ) {
1018 if ( type() != GuiServer ) 1021 if ( type() != GuiServer )
1019 tryQuit(); 1022 tryQuit();
1020 } 1023 }
1021 else if ( msg == "forceQuit()" ) { 1024 else if ( msg == "forceQuit()" ) {
1022 if ( type() != GuiServer ) 1025 if ( type() != GuiServer )
1023 quit(); 1026 quit();
1024 } 1027 }
1025 else if ( msg == "restart()" ) { 1028 else if ( msg == "restart()" ) {
1026 if ( type() == GuiServer ) 1029 if ( type() == GuiServer )
1027 restart(); 1030 restart();
1028 } 1031 }
1029 else if ( msg == "grabKeyboard(QString)" ) { 1032 else if ( msg == "grabKeyboard(QString)" ) {
1030 QString who; 1033 QString who;
1031 stream >> who; 1034 stream >> who;
1032 if ( who.isEmpty() ) 1035 if ( who.isEmpty() )
1033 d->kbgrabber = 0; 1036 d->kbgrabber = 0;
1034 else if ( who != d->appName ) 1037 else if ( who != d->appName )
1035 d->kbgrabber = 1; 1038 d->kbgrabber = 1;
1036 else 1039 else
1037 d->kbgrabber = 2; 1040 d->kbgrabber = 2;
1038 } 1041 }
1039 else if ( msg == "language(QString)" ) { 1042 else if ( msg == "language(QString)" ) {
1040 if ( type() == GuiServer ) { 1043 if ( type() == GuiServer ) {
1041 QString l; 1044 QString l;
1042 stream >> l; 1045 stream >> l;
1043 QString cl = getenv( "LANG" ); 1046 QString cl = getenv( "LANG" );
1044 if ( cl != l ) { 1047 if ( cl != l ) {
1045 if ( l.isNull() ) 1048 if ( l.isNull() )
1046 unsetenv( "LANG" ); 1049 unsetenv( "LANG" );
1047 else 1050 else
1048 setenv( "LANG", l.latin1(), 1 ); 1051 setenv( "LANG", l.latin1(), 1 );
1049 restart(); 1052 restart();
1050 } 1053 }
1051 } 1054 }
1052 } 1055 }
1053 else if ( msg == "timeChange(QString)" ) { 1056 else if ( msg == "timeChange(QString)" ) {
1054 QString t; 1057 QString t;
1055 stream >> t; 1058 stream >> t;
1056 if ( t.isNull() ) 1059 if ( t.isNull() )
1057 unsetenv( "TZ" ); 1060 unsetenv( "TZ" );
1058 else 1061 else
1059 setenv( "TZ", t.latin1(), 1 ); 1062 setenv( "TZ", t.latin1(), 1 );
1060 // emit the signal so everyone else knows... 1063 // emit the signal so everyone else knows...
1061 emit timeChanged(); 1064 emit timeChanged();
1062 } 1065 }
1063 else if ( msg == "execute(QString)" ) { 1066 else if ( msg == "execute(QString)" ) {
1064 if ( type() == GuiServer ) { 1067 if ( type() == GuiServer ) {
1065 QString t; 1068 QString t;
1066 stream >> t; 1069 stream >> t;
1067 Global::execute( t ); 1070 Global::execute( t );
1068 } 1071 }
1069 } 1072 }
1070 else if ( msg == "execute(QString,QString)" ) { 1073 else if ( msg == "execute(QString,QString)" ) {
1071 if ( type() == GuiServer ) { 1074 if ( type() == GuiServer ) {
1072 QString t, d; 1075 QString t, d;
1073 stream >> t >> d; 1076 stream >> t >> d;
1074 Global::execute( t, d ); 1077 Global::execute( t, d );
1075 } 1078 }
1076 } 1079 }
1077 else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) { 1080 else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) {
1078 if ( type() == GuiServer ) { 1081 if ( type() == GuiServer ) {
1079 QDateTime when; 1082 QDateTime when;
1080 QCString channel, message; 1083 QCString channel, message;
1081 int data; 1084 int data;
1082 stream >> when >> channel >> message >> data; 1085 stream >> when >> channel >> message >> data;
1083 AlarmServer::addAlarm( when, channel, message, data ); 1086 AlarmServer::addAlarm( when, channel, message, data );
1084 } 1087 }
1085 } 1088 }
1086 else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) { 1089 else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) {
1087 if ( type() == GuiServer ) { 1090 if ( type() == GuiServer ) {
1088 QDateTime when; 1091 QDateTime when;
1089 QCString channel, message; 1092 QCString channel, message;
1090 int data; 1093 int data;
1091 stream >> when >> channel >> message >> data; 1094 stream >> when >> channel >> message >> data;
1092 AlarmServer::deleteAlarm( when, channel, message, data ); 1095 AlarmServer::deleteAlarm( when, channel, message, data );
1093 } 1096 }
1094 } 1097 }
1095 else if ( msg == "clockChange(bool)" ) { 1098 else if ( msg == "clockChange(bool)" ) {
1096 int tmp; 1099 int tmp;
1097 stream >> tmp; 1100 stream >> tmp;
1098 emit clockChanged( tmp ); 1101 emit clockChanged( tmp );
1099 } 1102 }
1100 else if ( msg == "weekChange(bool)" ) { 1103 else if ( msg == "weekChange(bool)" ) {
1101 int tmp; 1104 int tmp;
1102 stream >> tmp; 1105 stream >> tmp;
1103 emit weekChanged( tmp ); 1106 emit weekChanged( tmp );
1104 } 1107 }
1105 else if ( msg == "setDateFormat(DateFormat)" ) { 1108 else if ( msg == "setDateFormat(DateFormat)" ) {
1106 DateFormat tmp; 1109 DateFormat tmp;
1107 stream >> tmp; 1110 stream >> tmp;
1108 emit dateFormatChanged( tmp ); 1111 emit dateFormatChanged( tmp );
1109 } 1112 }
1110 else if ( msg == "setVolume(int,int)" ) { 1113 else if ( msg == "setVolume(int,int)" ) {
1111 int t, v; 1114 int t, v;
1112 stream >> t >> v; 1115 stream >> t >> v;
1113 setVolume( t, v ); 1116 setVolume( t, v );
1114 emit volumeChanged( muted ); 1117 emit volumeChanged( muted );
1115 } 1118 }
1116 else if ( msg == "volumeChange(bool)" ) { 1119 else if ( msg == "volumeChange(bool)" ) {
1117 stream >> muted; 1120 stream >> muted;
1118 setVolume(); 1121 setVolume();
1119 emit volumeChanged( muted ); 1122 emit volumeChanged( muted );
1120 } 1123 }
1121 else if ( msg == "setMic(int,int)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> 1124 else if ( msg == "setMic(int,int)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com>
1122 int t, v; 1125 int t, v;
1123 stream >> t >> v; 1126 stream >> t >> v;
1124 setMic( t, v ); 1127 setMic( t, v );