author | sandman <sandman> | 2002-12-03 22:51:55 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-12-03 22:51:55 (UTC) |
commit | 56d74fadbb911e169461a9bbefa664cd1ab6b129 (patch) (unidiff) | |
tree | 8dd94e6043c5ca70ed30141967fa683078ea4e9a /library/qpeapplication.cpp | |
parent | b840b9c453badfec16deffeffae5337320bff5a7 (diff) | |
download | opie-56d74fadbb911e169461a9bbefa664cd1ab6b129.zip opie-56d74fadbb911e169461a9bbefa664cd1ab6b129.tar.gz opie-56d74fadbb911e169461a9bbefa664cd1ab6b129.tar.bz2 |
why didn't anybody notice this ? If you change the font, all currently open
applications don't change their font -- that's not normal - that's a bug :)
Fixed now
-rw-r--r-- | library/qpeapplication.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp index c782837..7cbda92 100644 --- a/library/qpeapplication.cpp +++ b/library/qpeapplication.cpp | |||
@@ -740,513 +740,513 @@ bool QPEApplication::qwsEventFilter( QWSEvent * e ) | |||
740 | else { | 740 | else { |
741 | // do the same as with the select key: Map to the default action of the widget: | 741 | // do the same as with the select key: Map to the default action of the widget: |
742 | mapToDefaultAction( ke, Qt::Key_Return ); | 742 | mapToDefaultAction( ke, Qt::Key_Return ); |
743 | } | 743 | } |
744 | } | 744 | } |
745 | } | 745 | } |
746 | } | 746 | } |
747 | else if ( ke->simpleData.keycode == Qt::Key_F30 ) { | 747 | else if ( ke->simpleData.keycode == Qt::Key_F30 ) { |
748 | // Use special "select" key to do whatever default action a widget has | 748 | // Use special "select" key to do whatever default action a widget has |
749 | mapToDefaultAction( ke, Qt::Key_Space ); | 749 | mapToDefaultAction( ke, Qt::Key_Space ); |
750 | } | 750 | } |
751 | else if ( ke->simpleData.keycode == Qt::Key_Escape && | 751 | else if ( ke->simpleData.keycode == Qt::Key_Escape && |
752 | ke->simpleData.is_press ) { | 752 | ke->simpleData.is_press ) { |
753 | // Escape key closes app if focus on toplevel | 753 | // Escape key closes app if focus on toplevel |
754 | QWidget * active = activeWindow(); | 754 | QWidget * active = activeWindow(); |
755 | if ( active && active->testWFlags( WType_TopLevel ) && | 755 | if ( active && active->testWFlags( WType_TopLevel ) && |
756 | ( int ) active->winId() == ke->simpleData.window && | 756 | ( int ) active->winId() == ke->simpleData.window && |
757 | !active->testWFlags( WStyle_Dialog | WStyle_Customize | WType_Popup | WType_Desktop ) ) { | 757 | !active->testWFlags( WStyle_Dialog | WStyle_Customize | WType_Popup | WType_Desktop ) ) { |
758 | if ( active->inherits( "QDialog" ) ) { | 758 | if ( active->inherits( "QDialog" ) ) { |
759 | HackDialog * d = ( HackDialog * ) active; | 759 | HackDialog * d = ( HackDialog * ) active; |
760 | d->rejectIt(); | 760 | d->rejectIt(); |
761 | return TRUE; | 761 | return TRUE; |
762 | } | 762 | } |
763 | else if ( strcmp( argv() [ 0 ], "embeddedkonsole" ) != 0 ) { | 763 | else if ( strcmp( argv() [ 0 ], "embeddedkonsole" ) != 0 ) { |
764 | active->close(); | 764 | active->close(); |
765 | } | 765 | } |
766 | } | 766 | } |
767 | } | 767 | } |
768 | 768 | ||
769 | #if QT_VERSION < 231 | 769 | #if QT_VERSION < 231 |
770 | // Filter out the F4/Launcher key from apps | 770 | // Filter out the F4/Launcher key from apps |
771 | // ### The launcher key may not always be F4 on all devices | 771 | // ### The launcher key may not always be F4 on all devices |
772 | if ( ( ( QWSKeyEvent * ) e ) ->simpleData.keycode == Qt::Key_F4 ) | 772 | if ( ( ( QWSKeyEvent * ) e ) ->simpleData.keycode == Qt::Key_F4 ) |
773 | return TRUE; | 773 | return TRUE; |
774 | #endif | 774 | #endif |
775 | 775 | ||
776 | } | 776 | } |
777 | if ( e->type == QWSEvent::Focus ) { | 777 | if ( e->type == QWSEvent::Focus ) { |
778 | QWSFocusEvent * fe = ( QWSFocusEvent* ) e; | 778 | QWSFocusEvent * fe = ( QWSFocusEvent* ) e; |
779 | QWidget* nfw = QWidget::find( e->window() ); | 779 | QWidget* nfw = QWidget::find( e->window() ); |
780 | if ( !fe->simpleData.get_focus ) { | 780 | if ( !fe->simpleData.get_focus ) { |
781 | QWidget * active = activeWindow(); | 781 | QWidget * active = activeWindow(); |
782 | while ( active && active->isPopup() ) { | 782 | while ( active && active->isPopup() ) { |
783 | active->close(); | 783 | active->close(); |
784 | active = activeWindow(); | 784 | active = activeWindow(); |
785 | } | 785 | } |
786 | if ( !nfw && d->kbgrabber == 2 ) { | 786 | if ( !nfw && d->kbgrabber == 2 ) { |
787 | ungrabKeyboard(); | 787 | ungrabKeyboard(); |
788 | d->kbregrab = TRUE; // want kb back when we're active | 788 | d->kbregrab = TRUE; // want kb back when we're active |
789 | } | 789 | } |
790 | } | 790 | } |
791 | else { | 791 | else { |
792 | // make sure our modal widget is ALWAYS on top | 792 | // make sure our modal widget is ALWAYS on top |
793 | QWidget *topm = activeModalWidget(); | 793 | QWidget *topm = activeModalWidget(); |
794 | if ( topm ) { | 794 | if ( topm ) { |
795 | topm->raise(); | 795 | topm->raise(); |
796 | } | 796 | } |
797 | if ( d->kbregrab ) { | 797 | if ( d->kbregrab ) { |
798 | grabKeyboard(); | 798 | grabKeyboard(); |
799 | d->kbregrab = FALSE; | 799 | d->kbregrab = FALSE; |
800 | } | 800 | } |
801 | } | 801 | } |
802 | if ( fe->simpleData.get_focus && inputMethodDict ) { | 802 | if ( fe->simpleData.get_focus && inputMethodDict ) { |
803 | InputMethodHint m = inputMethodHint( QWidget::find( e->window() ) ); | 803 | InputMethodHint m = inputMethodHint( QWidget::find( e->window() ) ); |
804 | if ( m == AlwaysOff ) | 804 | if ( m == AlwaysOff ) |
805 | Global::hideInputMethod(); | 805 | Global::hideInputMethod(); |
806 | if ( m == AlwaysOn ) | 806 | if ( m == AlwaysOn ) |
807 | Global::showInputMethod(); | 807 | Global::showInputMethod(); |
808 | } | 808 | } |
809 | } | 809 | } |
810 | return QApplication::qwsEventFilter( e ); | 810 | return QApplication::qwsEventFilter( e ); |
811 | } | 811 | } |
812 | #endif | 812 | #endif |
813 | 813 | ||
814 | /*! | 814 | /*! |
815 | Destroys the QPEApplication. | 815 | Destroys the QPEApplication. |
816 | */ | 816 | */ |
817 | QPEApplication::~QPEApplication() | 817 | QPEApplication::~QPEApplication() |
818 | { | 818 | { |
819 | ungrabKeyboard(); | 819 | ungrabKeyboard(); |
820 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 820 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
821 | // Need to delete QCopChannels early, since the display will | 821 | // Need to delete QCopChannels early, since the display will |
822 | // be gone by the time we get to ~QObject(). | 822 | // be gone by the time we get to ~QObject(). |
823 | delete sysChannel; | 823 | delete sysChannel; |
824 | delete pidChannel; | 824 | delete pidChannel; |
825 | #endif | 825 | #endif |
826 | 826 | ||
827 | delete d; | 827 | delete d; |
828 | } | 828 | } |
829 | 829 | ||
830 | /*! | 830 | /*! |
831 | Returns <tt>$OPIEDIR/</tt>. | 831 | Returns <tt>$OPIEDIR/</tt>. |
832 | */ | 832 | */ |
833 | QString QPEApplication::qpeDir() | 833 | QString QPEApplication::qpeDir() |
834 | { | 834 | { |
835 | const char * base = getenv( "OPIEDIR" ); | 835 | const char * base = getenv( "OPIEDIR" ); |
836 | if ( base ) | 836 | if ( base ) |
837 | return QString( base ) + "/"; | 837 | return QString( base ) + "/"; |
838 | 838 | ||
839 | return QString( "../" ); | 839 | return QString( "../" ); |
840 | } | 840 | } |
841 | 841 | ||
842 | /*! | 842 | /*! |
843 | Returns the user's current Document directory. There is a trailing "/". | 843 | Returns the user's current Document directory. There is a trailing "/". |
844 | .. well, it does now,, and there's no trailing '/' | 844 | .. well, it does now,, and there's no trailing '/' |
845 | */ | 845 | */ |
846 | QString QPEApplication::documentDir() | 846 | QString QPEApplication::documentDir() |
847 | { | 847 | { |
848 | const char* base = getenv( "HOME"); | 848 | const char* base = getenv( "HOME"); |
849 | if ( base ) | 849 | if ( base ) |
850 | return QString( base ) + "/Documents"; | 850 | return QString( base ) + "/Documents"; |
851 | 851 | ||
852 | return QString( "../Documents" ); | 852 | return QString( "../Documents" ); |
853 | } | 853 | } |
854 | 854 | ||
855 | static int deforient = -1; | 855 | static int deforient = -1; |
856 | 856 | ||
857 | /*! | 857 | /*! |
858 | \internal | 858 | \internal |
859 | */ | 859 | */ |
860 | int QPEApplication::defaultRotation() | 860 | int QPEApplication::defaultRotation() |
861 | { | 861 | { |
862 | if ( deforient < 0 ) { | 862 | if ( deforient < 0 ) { |
863 | QString d = getenv( "QWS_DISPLAY" ); | 863 | QString d = getenv( "QWS_DISPLAY" ); |
864 | if ( d.contains( "Rot90" ) ) { | 864 | if ( d.contains( "Rot90" ) ) { |
865 | deforient = 90; | 865 | deforient = 90; |
866 | } | 866 | } |
867 | else if ( d.contains( "Rot180" ) ) { | 867 | else if ( d.contains( "Rot180" ) ) { |
868 | deforient = 180; | 868 | deforient = 180; |
869 | } | 869 | } |
870 | else if ( d.contains( "Rot270" ) ) { | 870 | else if ( d.contains( "Rot270" ) ) { |
871 | deforient = 270; | 871 | deforient = 270; |
872 | } | 872 | } |
873 | else { | 873 | else { |
874 | deforient = 0; | 874 | deforient = 0; |
875 | } | 875 | } |
876 | } | 876 | } |
877 | return deforient; | 877 | return deforient; |
878 | } | 878 | } |
879 | 879 | ||
880 | /*! | 880 | /*! |
881 | \internal | 881 | \internal |
882 | */ | 882 | */ |
883 | void QPEApplication::setDefaultRotation( int r ) | 883 | void QPEApplication::setDefaultRotation( int r ) |
884 | { | 884 | { |
885 | if ( qApp->type() == GuiServer ) { | 885 | if ( qApp->type() == GuiServer ) { |
886 | deforient = r; | 886 | deforient = r; |
887 | setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 ); | 887 | setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 ); |
888 | Config config("qpe"); | 888 | Config config("qpe"); |
889 | config.setGroup( "Rotation" ); | 889 | config.setGroup( "Rotation" ); |
890 | config.writeEntry( "Screen", getenv("QWS_DISPLAY") ); | 890 | config.writeEntry( "Screen", getenv("QWS_DISPLAY") ); |
891 | } | 891 | } |
892 | else { | 892 | else { |
893 | #ifndef QT_NO_COP | 893 | #ifndef QT_NO_COP |
894 | { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" ); | 894 | { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" ); |
895 | e << r; | 895 | e << r; |
896 | } | 896 | } |
897 | #endif | 897 | #endif |
898 | 898 | ||
899 | } | 899 | } |
900 | } | 900 | } |
901 | 901 | ||
902 | // exported to libpreload.so | 902 | // exported to libpreload.so |
903 | int opie_block_style = 0; | 903 | int opie_block_style = 0; |
904 | 904 | ||
905 | /*! | 905 | /*! |
906 | \internal | 906 | \internal |
907 | */ | 907 | */ |
908 | void QPEApplication::applyStyle() | 908 | void QPEApplication::applyStyle() |
909 | { | 909 | { |
910 | Config config( "qpe" ); | 910 | Config config( "qpe" ); |
911 | config.setGroup( "Appearance" ); | 911 | config.setGroup( "Appearance" ); |
912 | 912 | ||
913 | // don't block ourselves ... | 913 | // don't block ourselves ... |
914 | opie_block_style = 0; | 914 | opie_block_style = 0; |
915 | 915 | ||
916 | 916 | ||
917 | static QString appname; | 917 | static QString appname; |
918 | 918 | ||
919 | if ( appname. isNull ( )) { | 919 | if ( appname. isNull ( )) { |
920 | char src [32]; | 920 | char src [32]; |
921 | char dst [PATH_MAX + 1]; | 921 | char dst [PATH_MAX + 1]; |
922 | ::sprintf ( src, "/proc/%d/exe", ::getpid ( )); | 922 | ::sprintf ( src, "/proc/%d/exe", ::getpid ( )); |
923 | int l = ::readlink ( src, dst, PATH_MAX ); | 923 | int l = ::readlink ( src, dst, PATH_MAX ); |
924 | if ( l > 0 ) { | 924 | if ( l > 0 ) { |
925 | dst [l] = 0; | 925 | dst [l] = 0; |
926 | const char *b = ::strrchr ( dst, '/' ); | 926 | const char *b = ::strrchr ( dst, '/' ); |
927 | appname = ( b ? b + 1 : dst ); | 927 | appname = ( b ? b + 1 : dst ); |
928 | } | 928 | } |
929 | else | 929 | else |
930 | appname = ""; | 930 | appname = ""; |
931 | } | 931 | } |
932 | 932 | ||
933 | 933 | ||
934 | QStringList ex = config. readListEntry ( "NoStyle", ';' ); | 934 | QStringList ex = config. readListEntry ( "NoStyle", ';' ); |
935 | int nostyle = 0; | 935 | int nostyle = 0; |
936 | for ( QStringList::Iterator it = ex. begin ( ); it != ex. end ( ); ++it ) { | 936 | for ( QStringList::Iterator it = ex. begin ( ); it != ex. end ( ); ++it ) { |
937 | if ( QRegExp (( *it ). mid ( 1 ), false, true ). find ( appname, 0 ) >= 0 ) { | 937 | if ( QRegExp (( *it ). mid ( 1 ), false, true ). find ( appname, 0 ) >= 0 ) { |
938 | nostyle = ( *it ). left ( 1 ). toInt ( 0, 32 ); | 938 | nostyle = ( *it ). left ( 1 ). toInt ( 0, 32 ); |
939 | break; | 939 | break; |
940 | } | 940 | } |
941 | } | 941 | } |
942 | 942 | ||
943 | // Widget style | 943 | // Widget style |
944 | QString style = config.readEntry( "Style", "Light" ); | 944 | QString style = config.readEntry( "Style", "Light" ); |
945 | 945 | ||
946 | // don't set a custom style | 946 | // don't set a custom style |
947 | if ( nostyle & 0x01 ) | 947 | if ( nostyle & 0x01 ) |
948 | style = "Light"; | 948 | style = "Light"; |
949 | 949 | ||
950 | internalSetStyle ( style ); | 950 | internalSetStyle ( style ); |
951 | 951 | ||
952 | // Colors | 952 | // Colors |
953 | QColor bgcolor( config.readEntry( "Background", "#E5E1D5" ) ); | 953 | QColor bgcolor( config.readEntry( "Background", "#E5E1D5" ) ); |
954 | QColor btncolor( config.readEntry( "Button", "#D6CDBB" ) ); | 954 | QColor btncolor( config.readEntry( "Button", "#D6CDBB" ) ); |
955 | QPalette pal( btncolor, bgcolor ); | 955 | QPalette pal( btncolor, bgcolor ); |
956 | QString color = config.readEntry( "Highlight", "#800000" ); | 956 | QString color = config.readEntry( "Highlight", "#800000" ); |
957 | pal.setColor( QColorGroup::Highlight, QColor( color ) ); | 957 | pal.setColor( QColorGroup::Highlight, QColor( color ) ); |
958 | color = config.readEntry( "HighlightedText", "#FFFFFF" ); | 958 | color = config.readEntry( "HighlightedText", "#FFFFFF" ); |
959 | pal.setColor( QColorGroup::HighlightedText, QColor( color ) ); | 959 | pal.setColor( QColorGroup::HighlightedText, QColor( color ) ); |
960 | color = config.readEntry( "Text", "#000000" ); | 960 | color = config.readEntry( "Text", "#000000" ); |
961 | pal.setColor( QColorGroup::Text, QColor( color ) ); | 961 | pal.setColor( QColorGroup::Text, QColor( color ) ); |
962 | color = config.readEntry( "ButtonText", "#000000" ); | 962 | color = config.readEntry( "ButtonText", "#000000" ); |
963 | pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) ); | 963 | pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) ); |
964 | color = config.readEntry( "Base", "#FFFFFF" ); | 964 | color = config.readEntry( "Base", "#FFFFFF" ); |
965 | pal.setColor( QColorGroup::Base, QColor( color ) ); | 965 | pal.setColor( QColorGroup::Base, QColor( color ) ); |
966 | 966 | ||
967 | pal.setColor( QPalette::Disabled, QColorGroup::Text, | 967 | pal.setColor( QPalette::Disabled, QColorGroup::Text, |
968 | pal.color( QPalette::Active, QColorGroup::Background ).dark() ); | 968 | pal.color( QPalette::Active, QColorGroup::Background ).dark() ); |
969 | 969 | ||
970 | setPalette( pal, TRUE ); | 970 | setPalette( pal, TRUE ); |
971 | 971 | ||
972 | // Window Decoration | 972 | // Window Decoration |
973 | QString dec = config.readEntry( "Decoration", "Qtopia" ); | 973 | QString dec = config.readEntry( "Decoration", "Qtopia" ); |
974 | 974 | ||
975 | // don't set a custom deco | 975 | // don't set a custom deco |
976 | if ( nostyle & 0x04 ) | 976 | if ( nostyle & 0x04 ) |
977 | dec = ""; | 977 | dec = ""; |
978 | 978 | ||
979 | //qDebug ( "Setting Deco: %s -- old %s (%d)", dec.latin1(), d-> decorationName.latin1(), nostyle); | 979 | //qDebug ( "Setting Deco: %s -- old %s (%d)", dec.latin1(), d-> decorationName.latin1(), nostyle); |
980 | 980 | ||
981 | if ( dec != d->decorationName ) { | 981 | if ( dec != d->decorationName ) { |
982 | qwsSetDecoration( new QPEDecoration( dec ) ); | 982 | qwsSetDecoration( new QPEDecoration( dec ) ); |
983 | d->decorationName = dec; | 983 | d->decorationName = dec; |
984 | } | 984 | } |
985 | 985 | ||
986 | // Font | 986 | // Font |
987 | QString ff = config.readEntry( "FontFamily", font().family() ); | 987 | QString ff = config.readEntry( "FontFamily", font().family() ); |
988 | int fs = config.readNumEntry( "FontSize", font().pointSize() ); | 988 | int fs = config.readNumEntry( "FontSize", font().pointSize() ); |
989 | 989 | ||
990 | // don't set a custom font | 990 | // don't set a custom font |
991 | if ( nostyle & 0x02 ) { | 991 | if ( nostyle & 0x02 ) { |
992 | ff = "Helvetica"; | 992 | ff = "Helvetica"; |
993 | fs = 10; | 993 | fs = 10; |
994 | } | 994 | } |
995 | 995 | ||
996 | setFont( QFont(ff, fs) ); | 996 | setFont ( QFont ( ff, fs ), true ); |
997 | 997 | ||
998 | // revert to global blocking policy ... | 998 | // revert to global blocking policy ... |
999 | opie_block_style = config. readBoolEntry ( "ForceStyle", false ) ? 0xff : 0x00; | 999 | opie_block_style = config. readBoolEntry ( "ForceStyle", false ) ? 0xff : 0x00; |
1000 | opie_block_style -= nostyle; | 1000 | opie_block_style -= nostyle; |
1001 | } | 1001 | } |
1002 | 1002 | ||
1003 | void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data ) | 1003 | void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data ) |
1004 | { | 1004 | { |
1005 | #ifdef Q_WS_QWS | 1005 | #ifdef Q_WS_QWS |
1006 | QDataStream stream( data, IO_ReadOnly ); | 1006 | QDataStream stream( data, IO_ReadOnly ); |
1007 | if ( msg == "applyStyle()" ) { | 1007 | if ( msg == "applyStyle()" ) { |
1008 | applyStyle(); | 1008 | applyStyle(); |
1009 | } | 1009 | } |
1010 | else if ( msg == "setDefaultRotation(int)" ) { | 1010 | else if ( msg == "setDefaultRotation(int)" ) { |
1011 | if ( type() == GuiServer ) { | 1011 | if ( type() == GuiServer ) { |
1012 | int r; | 1012 | int r; |
1013 | stream >> r; | 1013 | stream >> r; |
1014 | setDefaultRotation( r ); | 1014 | setDefaultRotation( r ); |
1015 | } | 1015 | } |
1016 | } | 1016 | } |
1017 | else if ( msg == "shutdown()" ) { | 1017 | else if ( msg == "shutdown()" ) { |
1018 | if ( type() == GuiServer ) | 1018 | if ( type() == GuiServer ) |
1019 | shutdown(); | 1019 | shutdown(); |
1020 | } | 1020 | } |
1021 | else if ( msg == "quit()" ) { | 1021 | else if ( msg == "quit()" ) { |
1022 | if ( type() != GuiServer ) | 1022 | if ( type() != GuiServer ) |
1023 | tryQuit(); | 1023 | tryQuit(); |
1024 | } | 1024 | } |
1025 | else if ( msg == "forceQuit()" ) { | 1025 | else if ( msg == "forceQuit()" ) { |
1026 | if ( type() != GuiServer ) | 1026 | if ( type() != GuiServer ) |
1027 | quit(); | 1027 | quit(); |
1028 | } | 1028 | } |
1029 | else if ( msg == "restart()" ) { | 1029 | else if ( msg == "restart()" ) { |
1030 | if ( type() == GuiServer ) | 1030 | if ( type() == GuiServer ) |
1031 | restart(); | 1031 | restart(); |
1032 | } | 1032 | } |
1033 | else if ( msg == "grabKeyboard(QString)" ) { | 1033 | else if ( msg == "grabKeyboard(QString)" ) { |
1034 | QString who; | 1034 | QString who; |
1035 | stream >> who; | 1035 | stream >> who; |
1036 | if ( who.isEmpty() ) | 1036 | if ( who.isEmpty() ) |
1037 | d->kbgrabber = 0; | 1037 | d->kbgrabber = 0; |
1038 | else if ( who != d->appName ) | 1038 | else if ( who != d->appName ) |
1039 | d->kbgrabber = 1; | 1039 | d->kbgrabber = 1; |
1040 | else | 1040 | else |
1041 | d->kbgrabber = 2; | 1041 | d->kbgrabber = 2; |
1042 | } | 1042 | } |
1043 | else if ( msg == "language(QString)" ) { | 1043 | else if ( msg == "language(QString)" ) { |
1044 | if ( type() == GuiServer ) { | 1044 | if ( type() == GuiServer ) { |
1045 | QString l; | 1045 | QString l; |
1046 | stream >> l; | 1046 | stream >> l; |
1047 | QString cl = getenv( "LANG" ); | 1047 | QString cl = getenv( "LANG" ); |
1048 | if ( cl != l ) { | 1048 | if ( cl != l ) { |
1049 | if ( l.isNull() ) | 1049 | if ( l.isNull() ) |
1050 | unsetenv( "LANG" ); | 1050 | unsetenv( "LANG" ); |
1051 | else | 1051 | else |
1052 | setenv( "LANG", l.latin1(), 1 ); | 1052 | setenv( "LANG", l.latin1(), 1 ); |
1053 | restart(); | 1053 | restart(); |
1054 | } | 1054 | } |
1055 | } | 1055 | } |
1056 | } | 1056 | } |
1057 | else if ( msg == "timeChange(QString)" ) { | 1057 | else if ( msg == "timeChange(QString)" ) { |
1058 | QString t; | 1058 | QString t; |
1059 | stream >> t; | 1059 | stream >> t; |
1060 | if ( t.isNull() ) | 1060 | if ( t.isNull() ) |
1061 | unsetenv( "TZ" ); | 1061 | unsetenv( "TZ" ); |
1062 | else | 1062 | else |
1063 | setenv( "TZ", t.latin1(), 1 ); | 1063 | setenv( "TZ", t.latin1(), 1 ); |
1064 | // emit the signal so everyone else knows... | 1064 | // emit the signal so everyone else knows... |
1065 | emit timeChanged(); | 1065 | emit timeChanged(); |
1066 | } | 1066 | } |
1067 | else if ( msg == "execute(QString)" ) { | 1067 | else if ( msg == "execute(QString)" ) { |
1068 | if ( type() == GuiServer ) { | 1068 | if ( type() == GuiServer ) { |
1069 | QString t; | 1069 | QString t; |
1070 | stream >> t; | 1070 | stream >> t; |
1071 | Global::execute( t ); | 1071 | Global::execute( t ); |
1072 | } | 1072 | } |
1073 | } | 1073 | } |
1074 | else if ( msg == "execute(QString,QString)" ) { | 1074 | else if ( msg == "execute(QString,QString)" ) { |
1075 | if ( type() == GuiServer ) { | 1075 | if ( type() == GuiServer ) { |
1076 | QString t, d; | 1076 | QString t, d; |
1077 | stream >> t >> d; | 1077 | stream >> t >> d; |
1078 | Global::execute( t, d ); | 1078 | Global::execute( t, d ); |
1079 | } | 1079 | } |
1080 | } | 1080 | } |
1081 | else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) { | 1081 | else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) { |
1082 | if ( type() == GuiServer ) { | 1082 | if ( type() == GuiServer ) { |
1083 | QDateTime when; | 1083 | QDateTime when; |
1084 | QCString channel, message; | 1084 | QCString channel, message; |
1085 | int data; | 1085 | int data; |
1086 | stream >> when >> channel >> message >> data; | 1086 | stream >> when >> channel >> message >> data; |
1087 | AlarmServer::addAlarm( when, channel, message, data ); | 1087 | AlarmServer::addAlarm( when, channel, message, data ); |
1088 | } | 1088 | } |
1089 | } | 1089 | } |
1090 | else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) { | 1090 | else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) { |
1091 | if ( type() == GuiServer ) { | 1091 | if ( type() == GuiServer ) { |
1092 | QDateTime when; | 1092 | QDateTime when; |
1093 | QCString channel, message; | 1093 | QCString channel, message; |
1094 | int data; | 1094 | int data; |
1095 | stream >> when >> channel >> message >> data; | 1095 | stream >> when >> channel >> message >> data; |
1096 | AlarmServer::deleteAlarm( when, channel, message, data ); | 1096 | AlarmServer::deleteAlarm( when, channel, message, data ); |
1097 | } | 1097 | } |
1098 | } | 1098 | } |
1099 | else if ( msg == "clockChange(bool)" ) { | 1099 | else if ( msg == "clockChange(bool)" ) { |
1100 | int tmp; | 1100 | int tmp; |
1101 | stream >> tmp; | 1101 | stream >> tmp; |
1102 | emit clockChanged( tmp ); | 1102 | emit clockChanged( tmp ); |
1103 | } | 1103 | } |
1104 | else if ( msg == "weekChange(bool)" ) { | 1104 | else if ( msg == "weekChange(bool)" ) { |
1105 | int tmp; | 1105 | int tmp; |
1106 | stream >> tmp; | 1106 | stream >> tmp; |
1107 | emit weekChanged( tmp ); | 1107 | emit weekChanged( tmp ); |
1108 | } | 1108 | } |
1109 | else if ( msg == "setDateFormat(DateFormat)" ) { | 1109 | else if ( msg == "setDateFormat(DateFormat)" ) { |
1110 | DateFormat tmp; | 1110 | DateFormat tmp; |
1111 | stream >> tmp; | 1111 | stream >> tmp; |
1112 | emit dateFormatChanged( tmp ); | 1112 | emit dateFormatChanged( tmp ); |
1113 | } | 1113 | } |
1114 | else if ( msg == "setVolume(int,int)" ) { | 1114 | else if ( msg == "setVolume(int,int)" ) { |
1115 | int t, v; | 1115 | int t, v; |
1116 | stream >> t >> v; | 1116 | stream >> t >> v; |
1117 | setVolume( t, v ); | 1117 | setVolume( t, v ); |
1118 | emit volumeChanged( muted ); | 1118 | emit volumeChanged( muted ); |
1119 | } | 1119 | } |
1120 | else if ( msg == "volumeChange(bool)" ) { | 1120 | else if ( msg == "volumeChange(bool)" ) { |
1121 | stream >> muted; | 1121 | stream >> muted; |
1122 | setVolume(); | 1122 | setVolume(); |
1123 | emit volumeChanged( muted ); | 1123 | emit volumeChanged( muted ); |
1124 | } | 1124 | } |
1125 | else if ( msg == "setMic(int,int)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> | 1125 | else if ( msg == "setMic(int,int)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> |
1126 | int t, v; | 1126 | int t, v; |
1127 | stream >> t >> v; | 1127 | stream >> t >> v; |
1128 | setMic( t, v ); | 1128 | setMic( t, v ); |
1129 | emit micChanged( micMuted ); | 1129 | emit micChanged( micMuted ); |
1130 | } | 1130 | } |
1131 | else if ( msg == "micChange(bool)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> | 1131 | else if ( msg == "micChange(bool)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> |
1132 | stream >> micMuted; | 1132 | stream >> micMuted; |
1133 | setMic(); | 1133 | setMic(); |
1134 | emit micChanged( micMuted ); | 1134 | emit micChanged( micMuted ); |
1135 | } | 1135 | } |
1136 | #endif | 1136 | #endif |
1137 | } | 1137 | } |
1138 | 1138 | ||
1139 | /*! | 1139 | /*! |
1140 | \internal | 1140 | \internal |
1141 | */ | 1141 | */ |
1142 | bool QPEApplication::raiseAppropriateWindow() | 1142 | bool QPEApplication::raiseAppropriateWindow() |
1143 | { | 1143 | { |
1144 | bool r = FALSE; | 1144 | bool r = FALSE; |
1145 | // ########## raise()ing main window should raise and set active | 1145 | // ########## raise()ing main window should raise and set active |
1146 | // ########## it and then all childen. This belongs in Qt/Embedded | 1146 | // ########## it and then all childen. This belongs in Qt/Embedded |
1147 | QWidget *top = d->qpe_main_widget; | 1147 | QWidget *top = d->qpe_main_widget; |
1148 | if ( !top ) | 1148 | if ( !top ) |
1149 | top = mainWidget(); | 1149 | top = mainWidget(); |
1150 | if ( top && d->keep_running ) { | 1150 | if ( top && d->keep_running ) { |
1151 | if ( top->isVisible() ) | 1151 | if ( top->isVisible() ) |
1152 | r = TRUE; | 1152 | r = TRUE; |
1153 | else if (d->preloaded) { | 1153 | else if (d->preloaded) { |
1154 | // We are preloaded and not visible.. pretend we just started.. | 1154 | // We are preloaded and not visible.. pretend we just started.. |
1155 | QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); | 1155 | QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); |
1156 | e << d->appName; | 1156 | e << d->appName; |
1157 | } | 1157 | } |
1158 | 1158 | ||
1159 | d->show_mx(top, d->nomaximize); | 1159 | d->show_mx(top, d->nomaximize); |
1160 | top->raise(); | 1160 | top->raise(); |
1161 | top->setActiveWindow(); | 1161 | top->setActiveWindow(); |
1162 | } | 1162 | } |
1163 | QWidget *topm = activeModalWidget(); | 1163 | QWidget *topm = activeModalWidget(); |
1164 | if ( topm && topm != top ) { | 1164 | if ( topm && topm != top ) { |
1165 | topm->show(); | 1165 | topm->show(); |
1166 | topm->raise(); | 1166 | topm->raise(); |
1167 | topm->setActiveWindow(); | 1167 | topm->setActiveWindow(); |
1168 | // If we haven't already handled the fastAppShowing message | 1168 | // If we haven't already handled the fastAppShowing message |
1169 | if (!top && d->preloaded) { | 1169 | if (!top && d->preloaded) { |
1170 | QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); | 1170 | QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); |
1171 | e << d->appName; | 1171 | e << d->appName; |
1172 | } | 1172 | } |
1173 | r = FALSE; | 1173 | r = FALSE; |
1174 | } | 1174 | } |
1175 | return r; | 1175 | return r; |
1176 | } | 1176 | } |
1177 | 1177 | ||
1178 | void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data) | 1178 | void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data) |
1179 | { | 1179 | { |
1180 | #ifdef Q_WS_QWS | 1180 | #ifdef Q_WS_QWS |
1181 | 1181 | ||
1182 | if ( msg == "quit()" ) { | 1182 | if ( msg == "quit()" ) { |
1183 | tryQuit(); | 1183 | tryQuit(); |
1184 | } | 1184 | } |
1185 | else if ( msg == "quitIfInvisible()" ) { | 1185 | else if ( msg == "quitIfInvisible()" ) { |
1186 | if ( d->qpe_main_widget && !d->qpe_main_widget->isVisible() ) | 1186 | if ( d->qpe_main_widget && !d->qpe_main_widget->isVisible() ) |
1187 | quit(); | 1187 | quit(); |
1188 | } | 1188 | } |
1189 | else if ( msg == "close()" ) { | 1189 | else if ( msg == "close()" ) { |
1190 | hideOrQuit(); | 1190 | hideOrQuit(); |
1191 | } | 1191 | } |
1192 | else if ( msg == "disablePreload()" ) { | 1192 | else if ( msg == "disablePreload()" ) { |
1193 | d->preloaded = FALSE; | 1193 | d->preloaded = FALSE; |
1194 | d->keep_running = TRUE; | 1194 | d->keep_running = TRUE; |
1195 | /* so that quit will quit */ | 1195 | /* so that quit will quit */ |
1196 | } | 1196 | } |
1197 | else if ( msg == "enablePreload()" ) { | 1197 | else if ( msg == "enablePreload()" ) { |
1198 | if (d->qpe_main_widget) | 1198 | if (d->qpe_main_widget) |
1199 | d->preloaded = TRUE; | 1199 | d->preloaded = TRUE; |
1200 | d->keep_running = TRUE; | 1200 | d->keep_running = TRUE; |
1201 | /* so next quit won't quit */ | 1201 | /* so next quit won't quit */ |
1202 | } | 1202 | } |
1203 | else if ( msg == "raise()" ) { | 1203 | else if ( msg == "raise()" ) { |
1204 | d->keep_running = TRUE; | 1204 | d->keep_running = TRUE; |
1205 | d->notbusysent = FALSE; | 1205 | d->notbusysent = FALSE; |
1206 | raiseAppropriateWindow(); | 1206 | raiseAppropriateWindow(); |
1207 | // Tell the system we're still chugging along... | 1207 | // Tell the system we're still chugging along... |
1208 | QCopEnvelope e("QPE/System", "appRaised(QString)"); | 1208 | QCopEnvelope e("QPE/System", "appRaised(QString)"); |
1209 | e << d->appName; | 1209 | e << d->appName; |
1210 | } | 1210 | } |
1211 | else if ( msg == "flush()" ) { | 1211 | else if ( msg == "flush()" ) { |
1212 | emit flush(); | 1212 | emit flush(); |
1213 | // we need to tell the desktop | 1213 | // we need to tell the desktop |
1214 | QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" ); | 1214 | QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" ); |
1215 | e << d->appName; | 1215 | e << d->appName; |
1216 | } | 1216 | } |
1217 | else if ( msg == "reload()" ) { | 1217 | else if ( msg == "reload()" ) { |
1218 | emit reload(); | 1218 | emit reload(); |
1219 | } | 1219 | } |
1220 | else if ( msg == "setDocument(QString)" ) { | 1220 | else if ( msg == "setDocument(QString)" ) { |
1221 | d->keep_running = TRUE; | 1221 | d->keep_running = TRUE; |
1222 | QDataStream stream( data, IO_ReadOnly ); | 1222 | QDataStream stream( data, IO_ReadOnly ); |
1223 | QString doc; | 1223 | QString doc; |
1224 | stream >> doc; | 1224 | stream >> doc; |
1225 | QWidget *mw = mainWidget(); | 1225 | QWidget *mw = mainWidget(); |
1226 | if ( !mw ) | 1226 | if ( !mw ) |
1227 | mw = d->qpe_main_widget; | 1227 | mw = d->qpe_main_widget; |
1228 | if ( mw ) | 1228 | if ( mw ) |
1229 | Global::setDocument( mw, doc ); | 1229 | Global::setDocument( mw, doc ); |
1230 | } | 1230 | } |
1231 | else if ( msg == "nextView()" ) { | 1231 | else if ( msg == "nextView()" ) { |
1232 | qDebug("got nextView()"); | 1232 | qDebug("got nextView()"); |
1233 | /* | 1233 | /* |
1234 | if ( raiseAppropriateWindow() ) | 1234 | if ( raiseAppropriateWindow() ) |
1235 | */ | 1235 | */ |
1236 | emit appMessage( msg, data); | 1236 | emit appMessage( msg, data); |
1237 | } | 1237 | } |
1238 | else { | 1238 | else { |
1239 | emit appMessage( msg, data); | 1239 | emit appMessage( msg, data); |
1240 | } | 1240 | } |
1241 | 1241 | ||
1242 | #endif | 1242 | #endif |
1243 | } | 1243 | } |
1244 | 1244 | ||
1245 | 1245 | ||
1246 | /*! | 1246 | /*! |
1247 | Sets widget \a mw as the mainWidget() and shows it. For small windows, | 1247 | Sets widget \a mw as the mainWidget() and shows it. For small windows, |
1248 | consider passing TRUE for \a nomaximize rather than the default FALSE. | 1248 | consider passing TRUE for \a nomaximize rather than the default FALSE. |
1249 | 1249 | ||
1250 | \sa showMainDocumentWidget() | 1250 | \sa showMainDocumentWidget() |
1251 | */ | 1251 | */ |
1252 | void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize ) | 1252 | void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize ) |