summaryrefslogtreecommitdiff
authorzecke <zecke>2002-09-25 18:15:58 (UTC)
committer zecke <zecke>2002-09-25 18:15:58 (UTC)
commitc96507591791d48a6d6dad3de6c15739c84e1c93 (patch) (unidiff)
treef5476860497023dd6d9e1c82c61cc6bb3f61a6da
parentd44c455b86d6cccbc497e3e8d8aa399096eff7db (diff)
downloadopie-c96507591791d48a6d6dad3de6c15739c84e1c93.zip
opie-c96507591791d48a6d6dad3de6c15739c84e1c93.tar.gz
opie-c96507591791d48a6d6dad3de6c15739c84e1c93.tar.bz2
ljps patch was/is correct
but for some reason TT is not using QFile so I made it use getenv(HOME) instead
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--library/qpeapplication.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp
index bdf67b9..533d7bd 100644
--- a/library/qpeapplication.cpp
+++ b/library/qpeapplication.cpp
@@ -683,257 +683,261 @@ bool QPEApplication::qwsEventFilter( QWSEvent * e )
683 QWidget * active = activeWindow(); 683 QWidget * active = activeWindow();
684 QWidget *popup = 0; 684 QWidget *popup = 0;
685 if ( active && active->isPopup() ) { 685 if ( active && active->isPopup() ) {
686 popup = active; 686 popup = active;
687 active = active->parentWidget(); 687 active = active->parentWidget();
688 } 688 }
689 if ( active && ( int ) active->winId() == ke->simpleData.window && 689 if ( active && ( int ) active->winId() == ke->simpleData.window &&
690 !active->testWFlags( WStyle_Customize | WType_Popup | WType_Desktop ) ) { 690 !active->testWFlags( WStyle_Customize | WType_Popup | WType_Desktop ) ) {
691 if ( ke->simpleData.is_press ) { 691 if ( ke->simpleData.is_press ) {
692 if ( popup ) 692 if ( popup )
693 popup->close(); 693 popup->close();
694 if ( active->inherits( "QDialog" ) ) { 694 if ( active->inherits( "QDialog" ) ) {
695 HackDialog * d = ( HackDialog * ) active; 695 HackDialog * d = ( HackDialog * ) active;
696 d->acceptIt(); 696 d->acceptIt();
697 return TRUE; 697 return TRUE;
698 } 698 }
699 else if ( ( ( HackWidget * ) active ) ->needsOk() ) { 699 else if ( ( ( HackWidget * ) active ) ->needsOk() ) {
700 QSignal s; 700 QSignal s;
701 s.connect( active, SLOT( accept() ) ); 701 s.connect( active, SLOT( accept() ) );
702 s.activate(); 702 s.activate();
703 } 703 }
704 else { 704 else {
705 // do the same as with the select key: Map to the default action of the widget: 705 // do the same as with the select key: Map to the default action of the widget:
706 mapToDefaultAction( ke, Qt::Key_Return ); 706 mapToDefaultAction( ke, Qt::Key_Return );
707 } 707 }
708 } 708 }
709 } 709 }
710 } else if ( ke->simpleData.keycode == Qt::Key_F30 ) { 710 } else if ( ke->simpleData.keycode == Qt::Key_F30 ) {
711 // Use special "select" key to do whatever default action a widget has 711 // Use special "select" key to do whatever default action a widget has
712 mapToDefaultAction( ke, Qt::Key_Space ); 712 mapToDefaultAction( ke, Qt::Key_Space );
713 } 713 }
714 else if ( ke->simpleData.keycode == Qt::Key_Escape && 714 else if ( ke->simpleData.keycode == Qt::Key_Escape &&
715 ke->simpleData.is_press ) { 715 ke->simpleData.is_press ) {
716 // Escape key closes app if focus on toplevel 716 // Escape key closes app if focus on toplevel
717 QWidget * active = activeWindow(); 717 QWidget * active = activeWindow();
718 if ( active && active->testWFlags( WType_TopLevel ) && 718 if ( active && active->testWFlags( WType_TopLevel ) &&
719 ( int ) active->winId() == ke->simpleData.window && 719 ( int ) active->winId() == ke->simpleData.window &&
720 !active->testWFlags( WStyle_Dialog | WStyle_Customize | WType_Popup | WType_Desktop ) ) { 720 !active->testWFlags( WStyle_Dialog | WStyle_Customize | WType_Popup | WType_Desktop ) ) {
721 if ( active->inherits( "QDialog" ) ) { 721 if ( active->inherits( "QDialog" ) ) {
722 HackDialog * d = ( HackDialog * ) active; 722 HackDialog * d = ( HackDialog * ) active;
723 d->rejectIt(); 723 d->rejectIt();
724 return TRUE; 724 return TRUE;
725 } 725 }
726 else if ( strcmp( argv() [ 0 ], "embeddedkonsole" ) != 0 ) { 726 else if ( strcmp( argv() [ 0 ], "embeddedkonsole" ) != 0 ) {
727 active->close(); 727 active->close();
728 } 728 }
729 } 729 }
730 } 730 }
731 731
732#if QT_VERSION < 231 732#if QT_VERSION < 231
733 // Filter out the F4/Launcher key from apps 733 // Filter out the F4/Launcher key from apps
734 // ### The launcher key may not always be F4 on all devices 734 // ### The launcher key may not always be F4 on all devices
735 if ( ( ( QWSKeyEvent * ) e ) ->simpleData.keycode == Qt::Key_F4 ) 735 if ( ( ( QWSKeyEvent * ) e ) ->simpleData.keycode == Qt::Key_F4 )
736 return TRUE; 736 return TRUE;
737#endif 737#endif
738 738
739 } 739 }
740 if ( e->type == QWSEvent::Focus ) { 740 if ( e->type == QWSEvent::Focus ) {
741 QWSFocusEvent * fe = ( QWSFocusEvent* ) e; 741 QWSFocusEvent * fe = ( QWSFocusEvent* ) e;
742 QWidget* nfw = QWidget::find( e->window() ); 742 QWidget* nfw = QWidget::find( e->window() );
743 if ( !fe->simpleData.get_focus ) { 743 if ( !fe->simpleData.get_focus ) {
744 QWidget * active = activeWindow(); 744 QWidget * active = activeWindow();
745 while ( active && active->isPopup() ) { 745 while ( active && active->isPopup() ) {
746 active->close(); 746 active->close();
747 active = activeWindow(); 747 active = activeWindow();
748 } 748 }
749 if ( !nfw && d->kbgrabber == 2 ) { 749 if ( !nfw && d->kbgrabber == 2 ) {
750 ungrabKeyboard(); 750 ungrabKeyboard();
751 d->kbregrab = TRUE; // want kb back when we're active 751 d->kbregrab = TRUE; // want kb back when we're active
752 } 752 }
753 } 753 }
754 else { 754 else {
755 // make sure our modal widget is ALWAYS on top 755 // make sure our modal widget is ALWAYS on top
756 QWidget *topm = activeModalWidget(); 756 QWidget *topm = activeModalWidget();
757 if ( topm ) { 757 if ( topm ) {
758 topm->raise(); 758 topm->raise();
759 } 759 }
760 if ( d->kbregrab ) { 760 if ( d->kbregrab ) {
761 grabKeyboard(); 761 grabKeyboard();
762 d->kbregrab = FALSE; 762 d->kbregrab = FALSE;
763 } 763 }
764 } 764 }
765 if ( fe->simpleData.get_focus && inputMethodDict ) { 765 if ( fe->simpleData.get_focus && inputMethodDict ) {
766 InputMethodHint m = inputMethodHint( QWidget::find( e->window() ) ); 766 InputMethodHint m = inputMethodHint( QWidget::find( e->window() ) );
767 if ( m == AlwaysOff ) 767 if ( m == AlwaysOff )
768 Global::hideInputMethod(); 768 Global::hideInputMethod();
769 if ( m == AlwaysOn ) 769 if ( m == AlwaysOn )
770 Global::showInputMethod(); 770 Global::showInputMethod();
771 } 771 }
772 } 772 }
773 return QApplication::qwsEventFilter( e ); 773 return QApplication::qwsEventFilter( e );
774} 774}
775#endif 775#endif
776 776
777/*! 777/*!
778 Destroys the QPEApplication. 778 Destroys the QPEApplication.
779*/ 779*/
780QPEApplication::~QPEApplication() 780QPEApplication::~QPEApplication()
781{ 781{
782 ungrabKeyboard(); 782 ungrabKeyboard();
783#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 783#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
784 // Need to delete QCopChannels early, since the display will 784 // Need to delete QCopChannels early, since the display will
785 // be gone by the time we get to ~QObject(). 785 // be gone by the time we get to ~QObject().
786 delete sysChannel; 786 delete sysChannel;
787 delete pidChannel; 787 delete pidChannel;
788#endif 788#endif
789 789
790 delete d; 790 delete d;
791} 791}
792 792
793/*! 793/*!
794 Returns <tt>$OPIEDIR/</tt>. 794 Returns <tt>$OPIEDIR/</tt>.
795*/ 795*/
796QString QPEApplication::qpeDir() 796QString QPEApplication::qpeDir()
797{ 797{
798 const char * base = getenv( "OPIEDIR" ); 798 const char * base = getenv( "OPIEDIR" );
799 if ( base ) 799 if ( base )
800 return QString( base ) + "/"; 800 return QString( base ) + "/";
801 801
802 return QString( "../" ); 802 return QString( "../" );
803} 803}
804 804
805/*! 805/*!
806 Returns the user's current Document directory. There is a trailing "/". 806 Returns the user's current Document directory. There is a trailing "/".
807 .. well, it does now,, and there's no trailing '/' 807 .. well, it does now,, and there's no trailing '/'
808*/ 808*/
809QString QPEApplication::documentDir() 809QString QPEApplication::documentDir()
810{ 810{
811 return QString( QDir::homeDirPath() + "/Documents"); 811 const char* base = getenv( "HOME");
812 if( base )
813 return QString( base ) + "/Documents";
814
815 return QString( "../Documents" );
812} 816}
813 817
814static int deforient = -1; 818static int deforient = -1;
815 819
816/*! 820/*!
817 \internal 821 \internal
818*/ 822*/
819int QPEApplication::defaultRotation() 823int QPEApplication::defaultRotation()
820{ 824{
821 if ( deforient < 0 ) { 825 if ( deforient < 0 ) {
822 QString d = getenv( "QWS_DISPLAY" ); 826 QString d = getenv( "QWS_DISPLAY" );
823 if ( d.contains( "Rot90" ) ) { 827 if ( d.contains( "Rot90" ) ) {
824 deforient = 90; 828 deforient = 90;
825 } 829 }
826 else if ( d.contains( "Rot180" ) ) { 830 else if ( d.contains( "Rot180" ) ) {
827 deforient = 180; 831 deforient = 180;
828 } 832 }
829 else if ( d.contains( "Rot270" ) ) { 833 else if ( d.contains( "Rot270" ) ) {
830 deforient = 270; 834 deforient = 270;
831 } 835 }
832 else { 836 else {
833 deforient = 0; 837 deforient = 0;
834 } 838 }
835 } 839 }
836 return deforient; 840 return deforient;
837} 841}
838 842
839/*! 843/*!
840 \internal 844 \internal
841*/ 845*/
842void QPEApplication::setDefaultRotation( int r ) 846void QPEApplication::setDefaultRotation( int r )
843{ 847{
844 if ( qApp->type() == GuiServer ) { 848 if ( qApp->type() == GuiServer ) {
845 deforient = r; 849 deforient = r;
846 setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 ); 850 setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 );
847 Config config("qpe"); 851 Config config("qpe");
848 config.setGroup( "Rotation" ); 852 config.setGroup( "Rotation" );
849 config.writeEntry( "Screen", getenv("QWS_DISPLAY") ); 853 config.writeEntry( "Screen", getenv("QWS_DISPLAY") );
850 } else { 854 } else {
851#ifndef QT_NO_COP 855#ifndef QT_NO_COP
852 { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" ); e << r; } 856 { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" ); e << r; }
853#endif 857#endif
854 } 858 }
855} 859}
856 860
857/*! 861/*!
858 \internal 862 \internal
859*/ 863*/
860void QPEApplication::applyStyle() 864void QPEApplication::applyStyle()
861{ 865{
862 Config config( "qpe" ); 866 Config config( "qpe" );
863 867
864 config.setGroup( "Appearance" ); 868 config.setGroup( "Appearance" );
865 869
866 // Widget style 870 // Widget style
867 QString style = config.readEntry( "Style", "Light" ); 871 QString style = config.readEntry( "Style", "Light" );
868 internalSetStyle( style ); 872 internalSetStyle( style );
869 873
870 // Colors 874 // Colors
871 QColor bgcolor( config.readEntry( "Background", "#E5E1D5" ) ); 875 QColor bgcolor( config.readEntry( "Background", "#E5E1D5" ) );
872 QColor btncolor( config.readEntry( "Button", "#D6CDBB" ) ); 876 QColor btncolor( config.readEntry( "Button", "#D6CDBB" ) );
873 QPalette pal( btncolor, bgcolor ); 877 QPalette pal( btncolor, bgcolor );
874 QString color = config.readEntry( "Highlight", "#800000" ); 878 QString color = config.readEntry( "Highlight", "#800000" );
875 pal.setColor( QColorGroup::Highlight, QColor( color ) ); 879 pal.setColor( QColorGroup::Highlight, QColor( color ) );
876 color = config.readEntry( "HighlightedText", "#FFFFFF" ); 880 color = config.readEntry( "HighlightedText", "#FFFFFF" );
877 pal.setColor( QColorGroup::HighlightedText, QColor( color ) ); 881 pal.setColor( QColorGroup::HighlightedText, QColor( color ) );
878 color = config.readEntry( "Text", "#000000" ); 882 color = config.readEntry( "Text", "#000000" );
879 pal.setColor( QColorGroup::Text, QColor( color ) ); 883 pal.setColor( QColorGroup::Text, QColor( color ) );
880 color = config.readEntry( "ButtonText", "#000000" ); 884 color = config.readEntry( "ButtonText", "#000000" );
881 pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) ); 885 pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) );
882 color = config.readEntry( "Base", "#FFFFFF" ); 886 color = config.readEntry( "Base", "#FFFFFF" );
883 pal.setColor( QColorGroup::Base, QColor( color ) ); 887 pal.setColor( QColorGroup::Base, QColor( color ) );
884 888
885 pal.setColor( QPalette::Disabled, QColorGroup::Text, 889 pal.setColor( QPalette::Disabled, QColorGroup::Text,
886 pal.color( QPalette::Active, QColorGroup::Background ).dark() ); 890 pal.color( QPalette::Active, QColorGroup::Background ).dark() );
887 891
888 setPalette( pal, TRUE ); 892 setPalette( pal, TRUE );
889 893
890 // Window Decoration 894 // Window Decoration
891 QString dec = config.readEntry( "Decoration", "Qtopia" ); 895 QString dec = config.readEntry( "Decoration", "Qtopia" );
892 if ( dec != d->decorationName ) { 896 if ( dec != d->decorationName ) {
893 qwsSetDecoration( new QPEDecoration( dec ) ); 897 qwsSetDecoration( new QPEDecoration( dec ) );
894 d->decorationName = dec; 898 d->decorationName = dec;
895 } 899 }
896 900
897 // Font 901 // Font
898 QString ff = config.readEntry( "FontFamily", font().family() ); 902 QString ff = config.readEntry( "FontFamily", font().family() );
899 int fs = config.readNumEntry( "FontSize", font().pointSize() ); 903 int fs = config.readNumEntry( "FontSize", font().pointSize() );
900 setFont( QFont(ff,fs) ); 904 setFont( QFont(ff,fs) );
901} 905}
902 906
903void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data ) 907void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data )
904{ 908{
905#ifdef Q_WS_QWS 909#ifdef Q_WS_QWS
906 QDataStream stream( data, IO_ReadOnly ); 910 QDataStream stream( data, IO_ReadOnly );
907 if ( msg == "applyStyle()" ) { 911 if ( msg == "applyStyle()" ) {
908 applyStyle(); 912 applyStyle();
909 } else if ( msg == "setDefaultRotation(int)" ) { 913 } else if ( msg == "setDefaultRotation(int)" ) {
910 if ( type() == GuiServer ) { 914 if ( type() == GuiServer ) {
911 int r; 915 int r;
912 stream >> r; 916 stream >> r;
913 setDefaultRotation( r ); 917 setDefaultRotation( r );
914 } 918 }
915 } else if ( msg == "shutdown()" ) { 919 } else if ( msg == "shutdown()" ) {
916 if ( type() == GuiServer ) 920 if ( type() == GuiServer )
917 shutdown(); 921 shutdown();
918 } else if ( msg == "quit()" ) { 922 } else if ( msg == "quit()" ) {
919 if ( type() != GuiServer ) 923 if ( type() != GuiServer )
920 tryQuit(); 924 tryQuit();
921 } else if ( msg == "forceQuit()" ) { 925 } else if ( msg == "forceQuit()" ) {
922 if ( type() != GuiServer ) 926 if ( type() != GuiServer )
923 quit(); 927 quit();
924 } else if ( msg == "restart()" ) { 928 } else if ( msg == "restart()" ) {
925 if ( type() == GuiServer ) 929 if ( type() == GuiServer )
926 restart(); 930 restart();
927 } else if ( msg == "grabKeyboard(QString)" ) { 931 } else if ( msg == "grabKeyboard(QString)" ) {
928 QString who; 932 QString who;
929 stream >> who; 933 stream >> who;
930 if ( who.isEmpty() ) 934 if ( who.isEmpty() )
931 d->kbgrabber = 0; 935 d->kbgrabber = 0;
932 else if ( who != d->appName ) 936 else if ( who != d->appName )
933 d->kbgrabber = 1; 937 d->kbgrabber = 1;
934 else 938 else
935 d->kbgrabber = 2; 939 d->kbgrabber = 2;
936 } else if ( msg == "language(QString)" ) { 940 } else if ( msg == "language(QString)" ) {
937 if ( type() == GuiServer ) { 941 if ( type() == GuiServer ) {
938 QString l; 942 QString l;
939 stream >> l; 943 stream >> l;