summaryrefslogtreecommitdiff
path: root/library
authorllornkcor <llornkcor>2004-04-25 09:23:09 (UTC)
committer llornkcor <llornkcor>2004-04-25 09:23:09 (UTC)
commita4b1facac26431ddfcb4d31b2e6489a8a9e047b9 (patch) (unidiff)
tree0742ebba7371963c369cbfc03f17eefc605f52d5 /library
parent5d3c80f70109bee75d55db2a11d7112eb7ebaa99 (diff)
downloadopie-a4b1facac26431ddfcb4d31b2e6489a8a9e047b9.zip
opie-a4b1facac26431ddfcb4d31b2e6489a8a9e047b9.tar.gz
opie-a4b1facac26431ddfcb4d31b2e6489a8a9e047b9.tar.bz2
remove embeddedkonsole hack
Diffstat (limited to 'library') (more/less context) (ignore whitespace changes)
-rw-r--r--library/qpeapplication.cpp5
1 files changed, 1 insertions, 4 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp
index 10c6c40..c875ff2 100644
--- a/library/qpeapplication.cpp
+++ b/library/qpeapplication.cpp
@@ -745,771 +745,768 @@ void QPEApplication::processQCopFile()
745 745
746 This signal is emitted when a message is received on this 746 This signal is emitted when a message is received on this
747 application's QPE/Application/<i>appname</i> \link qcop.html 747 application's QPE/Application/<i>appname</i> \link qcop.html
748 QCop\endlink channel. 748 QCop\endlink channel.
749 749
750 The slot to which you connect this signal uses \a msg and \a data 750 The slot to which you connect this signal uses \a msg and \a data
751 in the following way: 751 in the following way:
752 752
753\code 753\code
754 void MyWidget::receive( const QCString& msg, const QByteArray& data ) 754 void MyWidget::receive( const QCString& msg, const QByteArray& data )
755 { 755 {
756 QDataStream stream( data, IO_ReadOnly ); 756 QDataStream stream( data, IO_ReadOnly );
757 if ( msg == "someMessage(int,int,int)" ) { 757 if ( msg == "someMessage(int,int,int)" ) {
758 int a,b,c; 758 int a,b,c;
759 stream >> a >> b >> c; 759 stream >> a >> b >> c;
760 ... 760 ...
761 } else if ( msg == "otherMessage(QString)" ) { 761 } else if ( msg == "otherMessage(QString)" ) {
762 ... 762 ...
763 } 763 }
764 } 764 }
765\endcode 765\endcode
766 766
767 \sa qcop.html 767 \sa qcop.html
768 Note that messages received here may be processed by qpe application 768 Note that messages received here may be processed by qpe application
769 and emitted as signals, such as flush() and reload(). 769 and emitted as signals, such as flush() and reload().
770*/ 770*/
771 771
772/*! 772/*!
773 Constructs a QPEApplication just as you would construct 773 Constructs a QPEApplication just as you would construct
774 a QApplication, passing \a argc, \a argv, and \a t. 774 a QApplication, passing \a argc, \a argv, and \a t.
775 775
776 For applications, \a t should be the default, GuiClient. Only 776 For applications, \a t should be the default, GuiClient. Only
777 the Qtopia server passes GuiServer. 777 the Qtopia server passes GuiServer.
778*/ 778*/
779QPEApplication::QPEApplication( int & argc, char **argv, Type t ) 779QPEApplication::QPEApplication( int & argc, char **argv, Type t )
780 : QApplication( hack(argc), argv, t ), pidChannel( 0 ) 780 : QApplication( hack(argc), argv, t ), pidChannel( 0 )
781{ 781{
782 QPixmapCache::setCacheLimit(256); // sensible default for smaller devices. 782 QPixmapCache::setCacheLimit(256); // sensible default for smaller devices.
783 783
784 d = new QPEApplicationData; 784 d = new QPEApplicationData;
785 d->loadTextCodecs(); 785 d->loadTextCodecs();
786 d->loadImageCodecs(); 786 d->loadImageCodecs();
787 int dw = desktop() ->width(); 787 int dw = desktop() ->width();
788 788
789 if ( dw < 200 ) { 789 if ( dw < 200 ) {
790 setFont( QFont( "vera", 8 ) ); 790 setFont( QFont( "vera", 8 ) );
791 AppLnk::setSmallIconSize( 10 ); 791 AppLnk::setSmallIconSize( 10 );
792 AppLnk::setBigIconSize( 28 ); 792 AppLnk::setBigIconSize( 28 );
793 } 793 }
794#if defined(OPIE_HIGH_RES_SMALL_PHY) 794#if defined(OPIE_HIGH_RES_SMALL_PHY)
795 else if ( dw > 600 ) { 795 else if ( dw > 600 ) {
796 setFont( QFont( "vera", 16 ) ); 796 setFont( QFont( "vera", 16 ) );
797 AppLnk::setSmallIconSize( 24 ); 797 AppLnk::setSmallIconSize( 24 );
798 AppLnk::setBigIconSize( 48 ); 798 AppLnk::setBigIconSize( 48 );
799 } 799 }
800#endif 800#endif
801 else if ( dw > 200 ) { 801 else if ( dw > 200 ) {
802 setFont( QFont( "vera", 10 ) ); 802 setFont( QFont( "vera", 10 ) );
803 AppLnk::setSmallIconSize( 14 ); 803 AppLnk::setSmallIconSize( 14 );
804 AppLnk::setBigIconSize( 32 ); 804 AppLnk::setBigIconSize( 32 );
805 } 805 }
806 806
807 QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory ); 807 QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory );
808 808
809 connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) ); 809 connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) );
810 810
811 811
812 sysChannel = new QCopChannel( "QPE/System", this ); 812 sysChannel = new QCopChannel( "QPE/System", this );
813 connect( sysChannel, SIGNAL( received(const QCString&,const QByteArray&) ), 813 connect( sysChannel, SIGNAL( received(const QCString&,const QByteArray&) ),
814 this, SLOT( systemMessage(const QCString&,const QByteArray&) ) ); 814 this, SLOT( systemMessage(const QCString&,const QByteArray&) ) );
815 815
816/* COde now in initapp */ 816/* COde now in initapp */
817#if 0 817#if 0
818#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 818#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
819 819
820 QString qcopfn( "/tmp/qcop-msg-" ); 820 QString qcopfn( "/tmp/qcop-msg-" );
821 qcopfn += QString( argv[ 0 ] ); // append command name 821 qcopfn += QString( argv[ 0 ] ); // append command name
822 822
823 QFile f( qcopfn ); 823 QFile f( qcopfn );
824 if ( f.open( IO_ReadOnly ) ) { 824 if ( f.open( IO_ReadOnly ) ) {
825 flock( f.handle(), LOCK_EX ); 825 flock( f.handle(), LOCK_EX );
826 } 826 }
827 827
828 828
829 829
830 QCString channel = QCString( argv[ 0 ] ); 830 QCString channel = QCString( argv[ 0 ] );
831 channel.replace( QRegExp( ".*/" ), "" ); 831 channel.replace( QRegExp( ".*/" ), "" );
832 d->appName = channel; 832 d->appName = channel;
833 channel = "QPE/Application/" + channel; 833 channel = "QPE/Application/" + channel;
834 pidChannel = new QCopChannel( channel, this ); 834 pidChannel = new QCopChannel( channel, this );
835 connect( pidChannel, SIGNAL( received(const QCString&,const QByteArray&) ), 835 connect( pidChannel, SIGNAL( received(const QCString&,const QByteArray&) ),
836 this, SLOT( pidMessage(const QCString&,const QByteArray&) ) ); 836 this, SLOT( pidMessage(const QCString&,const QByteArray&) ) );
837 837
838 if ( f.isOpen() ) { 838 if ( f.isOpen() ) {
839 d->keep_running = FALSE; 839 d->keep_running = FALSE;
840 QDataStream ds( &f ); 840 QDataStream ds( &f );
841 QCString channel, message; 841 QCString channel, message;
842 QByteArray data; 842 QByteArray data;
843 while ( !ds.atEnd() ) { 843 while ( !ds.atEnd() ) {
844 ds >> channel >> message >> data; 844 ds >> channel >> message >> data;
845 d->enqueueQCop( channel, message, data ); 845 d->enqueueQCop( channel, message, data );
846 } 846 }
847 847
848 flock( f.handle(), LOCK_UN ); 848 flock( f.handle(), LOCK_UN );
849 f.close(); 849 f.close();
850 f.remove(); 850 f.remove();
851 } 851 }
852 852
853 for ( int a = 0; a < argc; a++ ) { 853 for ( int a = 0; a < argc; a++ ) {
854 if ( qstrcmp( argv[ a ], "-preload" ) == 0 ) { 854 if ( qstrcmp( argv[ a ], "-preload" ) == 0 ) {
855 argv[ a ] = argv[ a + 1 ]; 855 argv[ a ] = argv[ a + 1 ];
856 a++; 856 a++;
857 d->preloaded = TRUE; 857 d->preloaded = TRUE;
858 argc -= 1; 858 argc -= 1;
859 } 859 }
860 else if ( qstrcmp( argv[ a ], "-preload-show" ) == 0 ) { 860 else if ( qstrcmp( argv[ a ], "-preload-show" ) == 0 ) {
861 argv[ a ] = argv[ a + 1 ]; 861 argv[ a ] = argv[ a + 1 ];
862 a++; 862 a++;
863 d->preloaded = TRUE; 863 d->preloaded = TRUE;
864 d->forceshow = TRUE; 864 d->forceshow = TRUE;
865 argc -= 1; 865 argc -= 1;
866 } 866 }
867 } 867 }
868 868
869 /* overide stored arguments */ 869 /* overide stored arguments */
870 setArgs( argc, argv ); 870 setArgs( argc, argv );
871 871
872#endif 872#endif
873#else 873#else
874 initApp( argc, argv ); 874 initApp( argc, argv );
875#endif 875#endif
876 // qwsSetDecoration( new QPEDecoration() ); 876 // qwsSetDecoration( new QPEDecoration() );
877 877
878#ifndef QT_NO_TRANSLATION 878#ifndef QT_NO_TRANSLATION
879 879
880 d->langs = Global::languageList(); 880 d->langs = Global::languageList();
881 for ( QStringList::ConstIterator it = d->langs.begin(); it != d->langs.end(); ++it ) { 881 for ( QStringList::ConstIterator it = d->langs.begin(); it != d->langs.end(); ++it ) {
882 QString lang = *it; 882 QString lang = *it;
883 883
884 installTranslation( lang + "/libopie.qm"); 884 installTranslation( lang + "/libopie.qm");
885 installTranslation( lang + "/libqpe.qm" ); 885 installTranslation( lang + "/libqpe.qm" );
886 installTranslation( lang + "/" + d->appName + ".qm" ); 886 installTranslation( lang + "/" + d->appName + ".qm" );
887 887
888 888
889 //###language/font hack; should look it up somewhere 889 //###language/font hack; should look it up somewhere
890#ifdef QWS 890#ifdef QWS
891 891
892 if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) { 892 if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) {
893 QFont fn = FontManager::unicodeFont( FontManager::Proportional ); 893 QFont fn = FontManager::unicodeFont( FontManager::Proportional );
894 setFont( fn ); 894 setFont( fn );
895 } 895 }
896#endif 896#endif
897 } 897 }
898#endif 898#endif
899 899
900 applyStyle(); 900 applyStyle();
901 901
902 if ( type() == GuiServer ) { 902 if ( type() == GuiServer ) {
903 setVolume(); 903 setVolume();
904 } 904 }
905 905
906 installEventFilter( this ); 906 installEventFilter( this );
907 907
908 QPEMenuToolFocusManager::initialize(); 908 QPEMenuToolFocusManager::initialize();
909 909
910#ifdef QT_NO_QWS_CURSOR 910#ifdef QT_NO_QWS_CURSOR
911 // if we have no cursor, probably don't want tooltips 911 // if we have no cursor, probably don't want tooltips
912 QToolTip::setEnabled( FALSE ); 912 QToolTip::setEnabled( FALSE );
913#endif 913#endif
914} 914}
915 915
916 916
917#ifdef QTOPIA_INTERNAL_INITAPP 917#ifdef QTOPIA_INTERNAL_INITAPP
918void QPEApplication::initApp( int argc, char **argv ) 918void QPEApplication::initApp( int argc, char **argv )
919{ 919{
920 delete pidChannel; 920 delete pidChannel;
921 d->keep_running = TRUE; 921 d->keep_running = TRUE;
922 d->preloaded = FALSE; 922 d->preloaded = FALSE;
923 d->forceshow = FALSE; 923 d->forceshow = FALSE;
924 924
925 QCString channel = QCString(argv[0]); 925 QCString channel = QCString(argv[0]);
926 926
927 channel.replace(QRegExp(".*/"),""); 927 channel.replace(QRegExp(".*/"),"");
928 d->appName = channel; 928 d->appName = channel;
929 929
930 #if QT_VERSION > 235 930 #if QT_VERSION > 235
931 qt_fbdpy->setIdentity( channel ); // In Qt/E 2.3.6 931 qt_fbdpy->setIdentity( channel ); // In Qt/E 2.3.6
932 #endif 932 #endif
933 933
934 channel = "QPE/Application/" + channel; 934 channel = "QPE/Application/" + channel;
935 pidChannel = new QCopChannel( channel, this); 935 pidChannel = new QCopChannel( channel, this);
936 connect( pidChannel, SIGNAL(received(const QCString&,const QByteArray&)), 936 connect( pidChannel, SIGNAL(received(const QCString&,const QByteArray&)),
937 this, SLOT(pidMessage(const QCString&,const QByteArray&))); 937 this, SLOT(pidMessage(const QCString&,const QByteArray&)));
938 938
939 939
940 940
941 processQCopFile(); 941 processQCopFile();
942 d->keep_running = d->qcopq.isEmpty(); 942 d->keep_running = d->qcopq.isEmpty();
943 943
944 for (int a=0; a<argc; a++) { 944 for (int a=0; a<argc; a++) {
945 if ( qstrcmp(argv[a],"-preload")==0 ) { 945 if ( qstrcmp(argv[a],"-preload")==0 ) {
946 argv[a] = argv[a+1]; 946 argv[a] = argv[a+1];
947 a++; 947 a++;
948 d->preloaded = TRUE; 948 d->preloaded = TRUE;
949 argc-=1; 949 argc-=1;
950 } else if ( qstrcmp(argv[a],"-preload-show")==0 ) { 950 } else if ( qstrcmp(argv[a],"-preload-show")==0 ) {
951 argv[a] = argv[a+1]; 951 argv[a] = argv[a+1];
952 a++; 952 a++;
953 d->preloaded = TRUE; 953 d->preloaded = TRUE;
954 d->forceshow = TRUE; 954 d->forceshow = TRUE;
955 argc-=1; 955 argc-=1;
956 } 956 }
957 } 957 }
958 958
959 /* overide stored arguments */ 959 /* overide stored arguments */
960 setArgs(argc, argv); 960 setArgs(argc, argv);
961 961
962 /* install translation here */ 962 /* install translation here */
963 for ( QStringList::ConstIterator it = d->langs.begin(); it != d->langs.end(); ++it ) 963 for ( QStringList::ConstIterator it = d->langs.begin(); it != d->langs.end(); ++it )
964 installTranslation( (*it) + "/" + d->appName + ".qm" ); 964 installTranslation( (*it) + "/" + d->appName + ".qm" );
965} 965}
966#endif 966#endif
967 967
968 968
969static QPtrDict<void>* inputMethodDict = 0; 969static QPtrDict<void>* inputMethodDict = 0;
970static void createInputMethodDict() 970static void createInputMethodDict()
971{ 971{
972 if ( !inputMethodDict ) 972 if ( !inputMethodDict )
973 inputMethodDict = new QPtrDict<void>; 973 inputMethodDict = new QPtrDict<void>;
974} 974}
975 975
976/*! 976/*!
977 Returns the currently set hint to the system as to whether 977 Returns the currently set hint to the system as to whether
978 widget \a w has any use for text input methods. 978 widget \a w has any use for text input methods.
979 979
980 980
981 \sa setInputMethodHint() InputMethodHint 981 \sa setInputMethodHint() InputMethodHint
982*/ 982*/
983QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w ) 983QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w )
984{ 984{
985 if ( inputMethodDict && w ) 985 if ( inputMethodDict && w )
986 return ( InputMethodHint ) ( int ) inputMethodDict->find( w ); 986 return ( InputMethodHint ) ( int ) inputMethodDict->find( w );
987 return Normal; 987 return Normal;
988} 988}
989 989
990/*! 990/*!
991 \enum QPEApplication::InputMethodHint 991 \enum QPEApplication::InputMethodHint
992 992
993 \value Normal the application sometimes needs text input (the default). 993 \value Normal the application sometimes needs text input (the default).
994 \value AlwaysOff the application never needs text input. 994 \value AlwaysOff the application never needs text input.
995 \value AlwaysOn the application always needs text input. 995 \value AlwaysOn the application always needs text input.
996*/ 996*/
997 997
998/*! 998/*!
999 Hints to the system that widget \a w has use for text input methods 999 Hints to the system that widget \a w has use for text input methods
1000 as specified by \a mode. 1000 as specified by \a mode.
1001 1001
1002 \sa inputMethodHint() InputMethodHint 1002 \sa inputMethodHint() InputMethodHint
1003*/ 1003*/
1004void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode ) 1004void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode )
1005{ 1005{
1006 createInputMethodDict(); 1006 createInputMethodDict();
1007 if ( mode == Normal ) { 1007 if ( mode == Normal ) {
1008 inputMethodDict->remove 1008 inputMethodDict->remove
1009 ( w ); 1009 ( w );
1010 } 1010 }
1011 else { 1011 else {
1012 inputMethodDict->insert( w, ( void* ) mode ); 1012 inputMethodDict->insert( w, ( void* ) mode );
1013 } 1013 }
1014} 1014}
1015 1015
1016class HackDialog : public QDialog 1016class HackDialog : public QDialog
1017{ 1017{
1018public: 1018public:
1019 void acceptIt() 1019 void acceptIt()
1020 { 1020 {
1021 accept(); 1021 accept();
1022 } 1022 }
1023 void rejectIt() 1023 void rejectIt()
1024 { 1024 {
1025 reject(); 1025 reject();
1026 } 1026 }
1027}; 1027};
1028 1028
1029 1029
1030void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key ) 1030void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key )
1031{ 1031{
1032 // specialised actions for certain widgets. May want to 1032 // specialised actions for certain widgets. May want to
1033 // add more stuff here. 1033 // add more stuff here.
1034 if ( activePopupWidget() && activePopupWidget() ->inherits( "QListBox" ) 1034 if ( activePopupWidget() && activePopupWidget() ->inherits( "QListBox" )
1035 && activePopupWidget() ->parentWidget() 1035 && activePopupWidget() ->parentWidget()
1036 && activePopupWidget() ->parentWidget() ->inherits( "QComboBox" ) ) 1036 && activePopupWidget() ->parentWidget() ->inherits( "QComboBox" ) )
1037 key = Qt::Key_Return; 1037 key = Qt::Key_Return;
1038 1038
1039 if ( activePopupWidget() && activePopupWidget() ->inherits( "QPopupMenu" ) ) 1039 if ( activePopupWidget() && activePopupWidget() ->inherits( "QPopupMenu" ) )
1040 key = Qt::Key_Return; 1040 key = Qt::Key_Return;
1041 1041
1042#ifdef QWS 1042#ifdef QWS
1043 1043
1044 ke->simpleData.keycode = key; 1044 ke->simpleData.keycode = key;
1045#endif 1045#endif
1046} 1046}
1047 1047
1048// class HackWidget : public QWidget 1048// class HackWidget : public QWidget
1049// { 1049// {
1050// public: 1050// public:
1051 // bool needsOk() 1051 // bool needsOk()
1052 // { 1052 // {
1053 // return ( getWState() & WState_Reserved1 ); 1053 // return ( getWState() & WState_Reserved1 );
1054 // } 1054 // }
1055// }; 1055// };
1056 1056
1057/*! 1057/*!
1058 \internal 1058 \internal
1059*/ 1059*/
1060 1060
1061#ifdef QWS 1061#ifdef QWS
1062bool QPEApplication::qwsEventFilter( QWSEvent * e ) 1062bool QPEApplication::qwsEventFilter( QWSEvent * e )
1063{ 1063{
1064 if ( !d->notbusysent && e->type == QWSEvent::Focus ) { 1064 if ( !d->notbusysent && e->type == QWSEvent::Focus ) {
1065 if ( qApp->type() != QApplication::GuiServer ) { 1065 if ( qApp->type() != QApplication::GuiServer ) {
1066 QCopEnvelope e( "QPE/System", "notBusy(QString)" ); 1066 QCopEnvelope e( "QPE/System", "notBusy(QString)" );
1067 e << d->appName; 1067 e << d->appName;
1068 } 1068 }
1069 d->notbusysent = TRUE; 1069 d->notbusysent = TRUE;
1070 } 1070 }
1071 if ( type() == GuiServer ) { 1071 if ( type() == GuiServer ) {
1072 switch ( e->type ) { 1072 switch ( e->type ) {
1073 case QWSEvent::Mouse: 1073 case QWSEvent::Mouse:
1074 if ( e->asMouse() ->simpleData.state && !QWidget::find( e->window() ) ) 1074 if ( e->asMouse() ->simpleData.state && !QWidget::find( e->window() ) )
1075 emit clientMoused(); 1075 emit clientMoused();
1076 break; 1076 break;
1077 default: 1077 default:
1078 break; 1078 break;
1079 } 1079 }
1080 } 1080 }
1081 if ( e->type == QWSEvent::Key ) { 1081 if ( e->type == QWSEvent::Key ) {
1082 QWSKeyEvent *ke = ( QWSKeyEvent * ) e; 1082 QWSKeyEvent *ke = ( QWSKeyEvent * ) e;
1083 if ( ke->simpleData.keycode == Qt::Key_F33 ) { 1083 if ( ke->simpleData.keycode == Qt::Key_F33 ) {
1084 // Use special "OK" key to press "OK" on top level widgets 1084 // Use special "OK" key to press "OK" on top level widgets
1085 QWidget * active = activeWindow(); 1085 QWidget * active = activeWindow();
1086 QWidget *popup = 0; 1086 QWidget *popup = 0;
1087 if ( active && active->isPopup() ) { 1087 if ( active && active->isPopup() ) {
1088 popup = active; 1088 popup = active;
1089 active = active->parentWidget(); 1089 active = active->parentWidget();
1090 } 1090 }
1091 if ( active && ( int ) active->winId() == ke->simpleData.window && 1091 if ( active && ( int ) active->winId() == ke->simpleData.window &&
1092 !active->testWFlags( WStyle_Customize | WType_Popup | WType_Desktop ) ) { 1092 !active->testWFlags( WStyle_Customize | WType_Popup | WType_Desktop ) ) {
1093 if ( ke->simpleData.is_press ) { 1093 if ( ke->simpleData.is_press ) {
1094 if ( popup ) 1094 if ( popup )
1095 popup->close(); 1095 popup->close();
1096 if ( active->inherits( "QDialog" ) ) { 1096 if ( active->inherits( "QDialog" ) ) {
1097 HackDialog * d = ( HackDialog * ) active; 1097 HackDialog * d = ( HackDialog * ) active;
1098 d->acceptIt(); 1098 d->acceptIt();
1099 return TRUE; 1099 return TRUE;
1100 } 1100 }
1101 else if ( ( ( HackWidget * ) active ) ->needsOk() ) { 1101 else if ( ( ( HackWidget * ) active ) ->needsOk() ) {
1102 QSignal s; 1102 QSignal s;
1103 s.connect( active, SLOT( accept() ) ); 1103 s.connect( active, SLOT( accept() ) );
1104 s.activate(); 1104 s.activate();
1105 } 1105 }
1106 else { 1106 else {
1107 // do the same as with the select key: Map to the default action of the widget: 1107 // do the same as with the select key: Map to the default action of the widget:
1108 mapToDefaultAction( ke, Qt::Key_Return ); 1108 mapToDefaultAction( ke, Qt::Key_Return );
1109 } 1109 }
1110 } 1110 }
1111 } 1111 }
1112 } 1112 }
1113 else if ( ke->simpleData.keycode == Qt::Key_F30 ) { 1113 else if ( ke->simpleData.keycode == Qt::Key_F30 ) {
1114 // Use special "select" key to do whatever default action a widget has 1114 // Use special "select" key to do whatever default action a widget has
1115 mapToDefaultAction( ke, Qt::Key_Space ); 1115 mapToDefaultAction( ke, Qt::Key_Space );
1116 } 1116 }
1117 else if ( ke->simpleData.keycode == Qt::Key_Escape && 1117 else if ( ke->simpleData.keycode == Qt::Key_Escape &&
1118 ke->simpleData.is_press ) { 1118 ke->simpleData.is_press ) {
1119 // Escape key closes app if focus on toplevel 1119 // Escape key closes app if focus on toplevel
1120 QWidget * active = activeWindow(); 1120 QWidget * active = activeWindow();
1121 if ( active && active->testWFlags( WType_TopLevel ) && 1121 if ( active && active->testWFlags( WType_TopLevel ) &&
1122 ( int ) active->winId() == ke->simpleData.window && 1122 ( int ) active->winId() == ke->simpleData.window &&
1123 !active->testWFlags( WStyle_Dialog | WStyle_Customize | WType_Popup | WType_Desktop ) ) { 1123 !active->testWFlags( WStyle_Dialog | WStyle_Customize | WType_Popup | WType_Desktop ) ) {
1124 if ( active->inherits( "QDialog" ) ) { 1124 if ( active->inherits( "QDialog" ) ) {
1125 HackDialog * d = ( HackDialog * ) active; 1125 HackDialog * d = ( HackDialog * ) active;
1126 d->rejectIt(); 1126 d->rejectIt();
1127 return TRUE; 1127 return TRUE;
1128 } 1128 }
1129 else if ( strcmp( argv() [ 0 ], "embeddedkonsole" ) != 0 ) {
1130 active->close();
1131 }
1132 } 1129 }
1133 } 1130 }
1134 else if ( ke->simpleData.keycode >= Qt::Key_F1 && ke->simpleData.keycode <= Qt::Key_F29 ) { 1131 else if ( ke->simpleData.keycode >= Qt::Key_F1 && ke->simpleData.keycode <= Qt::Key_F29 ) {
1135 // this should be if ( ODevice::inst ( )-> buttonForKeycode ( ... )) 1132 // this should be if ( ODevice::inst ( )-> buttonForKeycode ( ... ))
1136 // but we cannot access libopie function within libqpe :( 1133 // but we cannot access libopie function within libqpe :(
1137 1134
1138 QWidget * active = activeWindow ( ); 1135 QWidget * active = activeWindow ( );
1139 if ( active && ((int) active-> winId ( ) == ke-> simpleData.window )) { 1136 if ( active && ((int) active-> winId ( ) == ke-> simpleData.window )) {
1140 if ( d-> kbgrabbed ) { // we grabbed the keyboard 1137 if ( d-> kbgrabbed ) { // we grabbed the keyboard
1141 QChar ch ( ke-> simpleData.unicode ); 1138 QChar ch ( ke-> simpleData.unicode );
1142 QKeyEvent qke ( ke-> simpleData. is_press ? QEvent::KeyPress : QEvent::KeyRelease, 1139 QKeyEvent qke ( ke-> simpleData. is_press ? QEvent::KeyPress : QEvent::KeyRelease,
1143 ke-> simpleData.keycode, 1140 ke-> simpleData.keycode,
1144 ch. latin1 ( ), 1141 ch. latin1 ( ),
1145 ke-> simpleData.modifiers, 1142 ke-> simpleData.modifiers,
1146 QString ( ch ), 1143 QString ( ch ),
1147 ke-> simpleData.is_auto_repeat, 1 ); 1144 ke-> simpleData.is_auto_repeat, 1 );
1148 1145
1149 QObject *which = QWidget::keyboardGrabber ( ); 1146 QObject *which = QWidget::keyboardGrabber ( );
1150 if ( !which ) 1147 if ( !which )
1151 which = QApplication::focusWidget ( ); 1148 which = QApplication::focusWidget ( );
1152 if ( !which ) 1149 if ( !which )
1153 which = QApplication::activeWindow ( ); 1150 which = QApplication::activeWindow ( );
1154 if ( !which ) 1151 if ( !which )
1155 which = qApp; 1152 which = qApp;
1156 1153
1157 QApplication::sendEvent ( which, &qke ); 1154 QApplication::sendEvent ( which, &qke );
1158 } 1155 }
1159 else { // we didn't grab the keyboard, so send the event to the launcher 1156 else { // we didn't grab the keyboard, so send the event to the launcher
1160 QCopEnvelope e ( "QPE/Launcher", "deviceButton(int,int,int)" ); 1157 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 ); 1158 e << int( ke-> simpleData.keycode ) << int( ke-> simpleData. is_press ) << int( ke-> simpleData.is_auto_repeat );
1162 } 1159 }
1163 } 1160 }
1164 return true; 1161 return true;
1165 } 1162 }
1166 } 1163 }
1167 if ( e->type == QWSEvent::Focus ) { 1164 if ( e->type == QWSEvent::Focus ) {
1168 QWSFocusEvent * fe = ( QWSFocusEvent* ) e; 1165 QWSFocusEvent * fe = ( QWSFocusEvent* ) e;
1169 if ( !fe->simpleData.get_focus ) { 1166 if ( !fe->simpleData.get_focus ) {
1170 QWidget * active = activeWindow(); 1167 QWidget * active = activeWindow();
1171 while ( active && active->isPopup() ) { 1168 while ( active && active->isPopup() ) {
1172 active->close(); 1169 active->close();
1173 active = activeWindow(); 1170 active = activeWindow();
1174 } 1171 }
1175 } 1172 }
1176 else { 1173 else {
1177 // make sure our modal widget is ALWAYS on top 1174 // make sure our modal widget is ALWAYS on top
1178 QWidget *topm = activeModalWidget(); 1175 QWidget *topm = activeModalWidget();
1179 if ( topm && static_cast<int>( topm->winId() ) != fe->simpleData.window) { 1176 if ( topm && static_cast<int>( topm->winId() ) != fe->simpleData.window) {
1180 topm->raise(); 1177 topm->raise();
1181 } 1178 }
1182 } 1179 }
1183 if ( fe->simpleData.get_focus && inputMethodDict ) { 1180 if ( fe->simpleData.get_focus && inputMethodDict ) {
1184 InputMethodHint m = inputMethodHint( QWidget::find( e->window() ) ); 1181 InputMethodHint m = inputMethodHint( QWidget::find( e->window() ) );
1185 if ( m == AlwaysOff ) 1182 if ( m == AlwaysOff )
1186 Global::hideInputMethod(); 1183 Global::hideInputMethod();
1187 if ( m == AlwaysOn ) 1184 if ( m == AlwaysOn )
1188 Global::showInputMethod(); 1185 Global::showInputMethod();
1189 } 1186 }
1190 } 1187 }
1191 1188
1192 1189
1193 return QApplication::qwsEventFilter( e ); 1190 return QApplication::qwsEventFilter( e );
1194} 1191}
1195#endif 1192#endif
1196 1193
1197/*! 1194/*!
1198 Destroys the QPEApplication. 1195 Destroys the QPEApplication.
1199*/ 1196*/
1200QPEApplication::~QPEApplication() 1197QPEApplication::~QPEApplication()
1201{ 1198{
1202 ungrabKeyboard(); 1199 ungrabKeyboard();
1203#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 1200#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
1204 // Need to delete QCopChannels early, since the display will 1201 // Need to delete QCopChannels early, since the display will
1205 // be gone by the time we get to ~QObject(). 1202 // be gone by the time we get to ~QObject().
1206 delete sysChannel; 1203 delete sysChannel;
1207 delete pidChannel; 1204 delete pidChannel;
1208#endif 1205#endif
1209 1206
1210 delete d; 1207 delete d;
1211} 1208}
1212 1209
1213/*! 1210/*!
1214 Returns <tt>$OPIEDIR/</tt>. 1211 Returns <tt>$OPIEDIR/</tt>.
1215*/ 1212*/
1216QString QPEApplication::qpeDir() 1213QString QPEApplication::qpeDir()
1217{ 1214{
1218 const char * base = getenv( "OPIEDIR" ); 1215 const char * base = getenv( "OPIEDIR" );
1219 if ( base ) 1216 if ( base )
1220 return QString( base ) + "/"; 1217 return QString( base ) + "/";
1221 1218
1222 return QString( "../" ); 1219 return QString( "../" );
1223} 1220}
1224 1221
1225/*! 1222/*!
1226 Returns the user's current Document directory. There is a trailing "/". 1223 Returns the user's current Document directory. There is a trailing "/".
1227 .. well, it does now,, and there's no trailing '/' 1224 .. well, it does now,, and there's no trailing '/'
1228*/ 1225*/
1229QString QPEApplication::documentDir() 1226QString QPEApplication::documentDir()
1230{ 1227{
1231 const char* base = getenv( "HOME"); 1228 const char* base = getenv( "HOME");
1232 if ( base ) 1229 if ( base )
1233 return QString( base ) + "/Documents"; 1230 return QString( base ) + "/Documents";
1234 1231
1235 return QString( "../Documents" ); 1232 return QString( "../Documents" );
1236} 1233}
1237 1234
1238static int deforient = -1; 1235static int deforient = -1;
1239 1236
1240/*! 1237/*!
1241 \internal 1238 \internal
1242*/ 1239*/
1243int QPEApplication::defaultRotation() 1240int QPEApplication::defaultRotation()
1244{ 1241{
1245 if ( deforient < 0 ) { 1242 if ( deforient < 0 ) {
1246 QString d = getenv( "QWS_DISPLAY" ); 1243 QString d = getenv( "QWS_DISPLAY" );
1247 if ( d.contains( "Rot90" ) ) { 1244 if ( d.contains( "Rot90" ) ) {
1248 deforient = 90; 1245 deforient = 90;
1249 } 1246 }
1250 else if ( d.contains( "Rot180" ) ) { 1247 else if ( d.contains( "Rot180" ) ) {
1251 deforient = 180; 1248 deforient = 180;
1252 } 1249 }
1253 else if ( d.contains( "Rot270" ) ) { 1250 else if ( d.contains( "Rot270" ) ) {
1254 deforient = 270; 1251 deforient = 270;
1255 } 1252 }
1256 else { 1253 else {
1257 deforient = 0; 1254 deforient = 0;
1258 } 1255 }
1259 } 1256 }
1260 return deforient; 1257 return deforient;
1261} 1258}
1262 1259
1263/*! 1260/*!
1264 \internal 1261 \internal
1265*/ 1262*/
1266void QPEApplication::setDefaultRotation( int r ) 1263void QPEApplication::setDefaultRotation( int r )
1267{ 1264{
1268 if ( qApp->type() == GuiServer ) { 1265 if ( qApp->type() == GuiServer ) {
1269 deforient = r; 1266 deforient = r;
1270 setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 ); 1267 setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 );
1271 Config config("qpe"); 1268 Config config("qpe");
1272 config.setGroup( "Rotation" ); 1269 config.setGroup( "Rotation" );
1273 config.writeEntry( "Rot", r ); 1270 config.writeEntry( "Rot", r );
1274 } 1271 }
1275 else { 1272 else {
1276#ifndef QT_NO_COP 1273#ifndef QT_NO_COP
1277 { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" ); 1274 { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" );
1278 e << r; 1275 e << r;
1279 } 1276 }
1280#endif 1277#endif
1281 1278
1282 } 1279 }
1283} 1280}
1284 1281
1285#include <qgfx_qws.h> 1282#include <qgfx_qws.h>
1286#include <qwindowsystem_qws.h> 1283#include <qwindowsystem_qws.h>
1287 1284
1288extern void qws_clearLoadedFonts(); 1285extern void qws_clearLoadedFonts();
1289 1286
1290void QPEApplication::setCurrentMode( int x, int y, int depth ) 1287void QPEApplication::setCurrentMode( int x, int y, int depth )
1291{ 1288{
1292 // Reset the caches 1289 // Reset the caches
1293 qws_clearLoadedFonts(); 1290 qws_clearLoadedFonts();
1294 QPixmapCache::clear(); 1291 QPixmapCache::clear();
1295 1292
1296 // Change the screen mode 1293 // Change the screen mode
1297 qt_screen->setMode(x, y, depth); 1294 qt_screen->setMode(x, y, depth);
1298 1295
1299 if ( qApp->type() == GuiServer ) { 1296 if ( qApp->type() == GuiServer ) {
1300 // Reconfigure the GuiServer 1297 // Reconfigure the GuiServer
1301 qwsServer->beginDisplayReconfigure(); 1298 qwsServer->beginDisplayReconfigure();
1302 qwsServer->endDisplayReconfigure(); 1299 qwsServer->endDisplayReconfigure();
1303 1300
1304 // Get all the running apps to reset 1301 // Get all the running apps to reset
1305 QCopEnvelope env( "QPE/System", "reset()" ); 1302 QCopEnvelope env( "QPE/System", "reset()" );
1306 } 1303 }
1307} 1304}
1308 1305
1309void QPEApplication::reset() { 1306void QPEApplication::reset() {
1310 // Reconnect to the screen 1307 // Reconnect to the screen
1311 qt_screen->disconnect(); 1308 qt_screen->disconnect();
1312 qt_screen->connect( QString::null ); 1309 qt_screen->connect( QString::null );
1313 1310
1314 // Redraw everything 1311 // Redraw everything
1315 applyStyle(); 1312 applyStyle();
1316} 1313}
1317 1314
1318/*! 1315/*!
1319 \internal 1316 \internal
1320*/ 1317*/
1321void QPEApplication::applyStyle() 1318void QPEApplication::applyStyle()
1322{ 1319{
1323 Config config( "qpe" ); 1320 Config config( "qpe" );
1324 config.setGroup( "Appearance" ); 1321 config.setGroup( "Appearance" );
1325 1322
1326#if QT_VERSION > 233 1323#if QT_VERSION > 233
1327#if !defined(OPIE_NO_OVERRIDE_QT) 1324#if !defined(OPIE_NO_OVERRIDE_QT)
1328 // don't block ourselves ... 1325 // don't block ourselves ...
1329 Opie::force_appearance = 0; 1326 Opie::force_appearance = 0;
1330 1327
1331 static QString appname = Opie::binaryName ( ); 1328 static QString appname = Opie::binaryName ( );
1332 1329
1333 QStringList ex = config. readListEntry ( "NoStyle", ';' ); 1330 QStringList ex = config. readListEntry ( "NoStyle", ';' );
1334 int nostyle = 0; 1331 int nostyle = 0;
1335 for ( QStringList::Iterator it = ex. begin ( ); it != ex. end ( ); ++it ) { 1332 for ( QStringList::Iterator it = ex. begin ( ); it != ex. end ( ); ++it ) {
1336 if ( QRegExp (( *it ). mid ( 1 ), false, true ). find ( appname, 0 ) >= 0 ) { 1333 if ( QRegExp (( *it ). mid ( 1 ), false, true ). find ( appname, 0 ) >= 0 ) {
1337 nostyle = ( *it ). left ( 1 ). toInt ( 0, 32 ); 1334 nostyle = ( *it ). left ( 1 ). toInt ( 0, 32 );
1338 break; 1335 break;
1339 } 1336 }
1340 } 1337 }
1341#else 1338#else
1342 int nostyle = 0; 1339 int nostyle = 0;
1343#endif 1340#endif
1344 1341
1345 // Widget style 1342 // Widget style
1346 QString style = config.readEntry( "Style", "FlatStyle" ); 1343 QString style = config.readEntry( "Style", "FlatStyle" );
1347 1344
1348 // don't set a custom style 1345 // don't set a custom style
1349 if ( nostyle & Opie::Force_Style ) 1346 if ( nostyle & Opie::Force_Style )
1350 style = "FlatStyle"; 1347 style = "FlatStyle";
1351 1348
1352 internalSetStyle ( style ); 1349 internalSetStyle ( style );
1353 1350
1354 // Colors - from /etc/colors/Liquid.scheme 1351 // Colors - from /etc/colors/Liquid.scheme
1355 QColor bgcolor( config.readEntry( "Background", "#E0E0E0" ) ); 1352 QColor bgcolor( config.readEntry( "Background", "#E0E0E0" ) );
1356 QColor btncolor( config.readEntry( "Button", "#96c8fa" ) ); 1353 QColor btncolor( config.readEntry( "Button", "#96c8fa" ) );
1357 QPalette pal( btncolor, bgcolor ); 1354 QPalette pal( btncolor, bgcolor );
1358 QString color = config.readEntry( "Highlight", "#73adef" ); 1355 QString color = config.readEntry( "Highlight", "#73adef" );
1359 pal.setColor( QColorGroup::Highlight, QColor( color ) ); 1356 pal.setColor( QColorGroup::Highlight, QColor( color ) );
1360 color = config.readEntry( "HighlightedText", "#FFFFFF" ); 1357 color = config.readEntry( "HighlightedText", "#FFFFFF" );
1361 pal.setColor( QColorGroup::HighlightedText, QColor( color ) ); 1358 pal.setColor( QColorGroup::HighlightedText, QColor( color ) );
1362 color = config.readEntry( "Text", "#000000" ); 1359 color = config.readEntry( "Text", "#000000" );
1363 pal.setColor( QColorGroup::Text, QColor( color ) ); 1360 pal.setColor( QColorGroup::Text, QColor( color ) );
1364 color = config.readEntry( "ButtonText", "#000000" ); 1361 color = config.readEntry( "ButtonText", "#000000" );
1365 pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) ); 1362 pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) );
1366 color = config.readEntry( "Base", "#FFFFFF" ); 1363 color = config.readEntry( "Base", "#FFFFFF" );
1367 pal.setColor( QColorGroup::Base, QColor( color ) ); 1364 pal.setColor( QColorGroup::Base, QColor( color ) );
1368 1365
1369 pal.setColor( QPalette::Disabled, QColorGroup::Text, 1366 pal.setColor( QPalette::Disabled, QColorGroup::Text,
1370 pal.color( QPalette::Active, QColorGroup::Background ).dark() ); 1367 pal.color( QPalette::Active, QColorGroup::Background ).dark() );
1371 1368
1372 setPalette( pal, TRUE ); 1369 setPalette( pal, TRUE );
1373 1370
1374 // Window Decoration 1371 // Window Decoration
1375 QString dec = config.readEntry( "Decoration", "Flat" ); 1372 QString dec = config.readEntry( "Decoration", "Flat" );
1376 1373
1377 // don't set a custom deco 1374 // don't set a custom deco
1378 if ( nostyle & Opie::Force_Decoration ) 1375 if ( nostyle & Opie::Force_Decoration )
1379 dec = ""; 1376 dec = "";
1380 1377
1381 //qDebug ( "Setting Deco: %s -- old %s (%d)", dec.latin1(), d-> decorationName.latin1(), nostyle); 1378 //qDebug ( "Setting Deco: %s -- old %s (%d)", dec.latin1(), d-> decorationName.latin1(), nostyle);
1382 1379
1383 if ( dec != d->decorationName ) { 1380 if ( dec != d->decorationName ) {
1384 qwsSetDecoration( new QPEDecoration( dec ) ); 1381 qwsSetDecoration( new QPEDecoration( dec ) );
1385 d->decorationName = dec; 1382 d->decorationName = dec;
1386 } 1383 }
1387 1384
1388 // Font 1385 // Font
1389 QString ff = config.readEntry( "FontFamily", font().family() ); 1386 QString ff = config.readEntry( "FontFamily", font().family() );
1390 int fs = config.readNumEntry( "FontSize", font().pointSize() ); 1387 int fs = config.readNumEntry( "FontSize", font().pointSize() );
1391 1388
1392 // don't set a custom font 1389 // don't set a custom font
1393 if ( nostyle & Opie::Force_Font ) { 1390 if ( nostyle & Opie::Force_Font ) {
1394 ff = "Vera"; 1391 ff = "Vera";
1395 fs = 10; 1392 fs = 10;
1396 } 1393 }
1397 1394
1398 setFont ( QFont ( ff, fs ), true ); 1395 setFont ( QFont ( ff, fs ), true );
1399 1396
1400#if !defined(OPIE_NO_OVERRIDE_QT) 1397#if !defined(OPIE_NO_OVERRIDE_QT)
1401 // revert to global blocking policy ... 1398 // revert to global blocking policy ...
1402 Opie::force_appearance = config. readBoolEntry ( "ForceStyle", false ) ? Opie::Force_All : Opie::Force_None; 1399 Opie::force_appearance = config. readBoolEntry ( "ForceStyle", false ) ? Opie::Force_All : Opie::Force_None;
1403 Opie::force_appearance &= ~nostyle; 1400 Opie::force_appearance &= ~nostyle;
1404#endif 1401#endif
1405#endif 1402#endif
1406} 1403}
1407 1404
1408void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data ) 1405void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data )
1409{ 1406{
1410#ifdef Q_WS_QWS 1407#ifdef Q_WS_QWS
1411 QDataStream stream( data, IO_ReadOnly ); 1408 QDataStream stream( data, IO_ReadOnly );
1412 if ( msg == "applyStyle()" ) { 1409 if ( msg == "applyStyle()" ) {
1413 applyStyle(); 1410 applyStyle();
1414 } 1411 }
1415 else if ( msg == "toggleApplicationMenu()" ) { 1412 else if ( msg == "toggleApplicationMenu()" ) {
1416 QWidget *active = activeWindow ( ); 1413 QWidget *active = activeWindow ( );
1417 1414
1418 if ( active ) { 1415 if ( active ) {
1419 QPEMenuToolFocusManager *man = QPEMenuToolFocusManager::manager ( ); 1416 QPEMenuToolFocusManager *man = QPEMenuToolFocusManager::manager ( );
1420 bool oldactive = man-> isActive ( ); 1417 bool oldactive = man-> isActive ( );
1421 1418
1422 man-> setActive( !man-> isActive() ); 1419 man-> setActive( !man-> isActive() );
1423 1420
1424 if ( !oldactive && !man-> isActive ( )) { // no menubar to toggle -> try O-Menu 1421 if ( !oldactive && !man-> isActive ( )) { // no menubar to toggle -> try O-Menu
1425 QCopEnvelope e ( "QPE/TaskBar", "toggleStartMenu()" ); 1422 QCopEnvelope e ( "QPE/TaskBar", "toggleStartMenu()" );
1426 } 1423 }
1427 } 1424 }
1428 } 1425 }
1429 else if ( msg == "setDefaultRotation(int)" ) { 1426 else if ( msg == "setDefaultRotation(int)" ) {
1430 if ( type() == GuiServer ) { 1427 if ( type() == GuiServer ) {
1431 int r; 1428 int r;
1432 stream >> r; 1429 stream >> r;
1433 setDefaultRotation( r ); 1430 setDefaultRotation( r );
1434 } 1431 }
1435 } 1432 }
1436 else if ( msg == "setCurrentMode(int,int,int)" ) { // Added: 2003-06-11 by Tim Ansell <mithro@mithis.net> 1433 else if ( msg == "setCurrentMode(int,int,int)" ) { // Added: 2003-06-11 by Tim Ansell <mithro@mithis.net>
1437 if ( type() == GuiServer ) { 1434 if ( type() == GuiServer ) {
1438 int x, y, depth; 1435 int x, y, depth;
1439 stream >> x; 1436 stream >> x;
1440 stream >> y; 1437 stream >> y;
1441 stream >> depth; 1438 stream >> depth;
1442 setCurrentMode( x, y, depth ); 1439 setCurrentMode( x, y, depth );
1443 } 1440 }
1444 } 1441 }
1445 else if ( msg == "reset()" ) { 1442 else if ( msg == "reset()" ) {
1446 if ( type() != GuiServer ) 1443 if ( type() != GuiServer )
1447 reset(); 1444 reset();
1448 } 1445 }
1449 else if ( msg == "setCurrentRotation(int)" ) { 1446 else if ( msg == "setCurrentRotation(int)" ) {
1450 int r; 1447 int r;
1451 stream >> r; 1448 stream >> r;
1452 setCurrentRotation( r ); 1449 setCurrentRotation( r );
1453 } 1450 }
1454 else if ( msg == "shutdown()" ) { 1451 else if ( msg == "shutdown()" ) {
1455 if ( type() == GuiServer ) 1452 if ( type() == GuiServer )
1456 shutdown(); 1453 shutdown();
1457 } 1454 }
1458 else if ( msg == "quit()" ) { 1455 else if ( msg == "quit()" ) {
1459 if ( type() != GuiServer ) 1456 if ( type() != GuiServer )
1460 tryQuit(); 1457 tryQuit();
1461 } 1458 }
1462 else if ( msg == "forceQuit()" ) { 1459 else if ( msg == "forceQuit()" ) {
1463 if ( type() != GuiServer ) 1460 if ( type() != GuiServer )
1464 quit(); 1461 quit();
1465 } 1462 }
1466 else if ( msg == "restart()" ) { 1463 else if ( msg == "restart()" ) {
1467 if ( type() == GuiServer ) 1464 if ( type() == GuiServer )
1468 restart(); 1465 restart();
1469 } 1466 }
1470 else if ( msg == "language(QString)" ) { 1467 else if ( msg == "language(QString)" ) {
1471 if ( type() == GuiServer ) { 1468 if ( type() == GuiServer ) {
1472 QString l; 1469 QString l;
1473 stream >> l; 1470 stream >> l;
1474 QString cl = getenv( "LANG" ); 1471 QString cl = getenv( "LANG" );
1475 if ( cl != l ) { 1472 if ( cl != l ) {
1476 if ( l.isNull() ) 1473 if ( l.isNull() )
1477 unsetenv( "LANG" ); 1474 unsetenv( "LANG" );
1478 else 1475 else
1479 setenv( "LANG", l.latin1(), 1 ); 1476 setenv( "LANG", l.latin1(), 1 );
1480 restart(); 1477 restart();
1481 } 1478 }
1482 } 1479 }
1483 } 1480 }
1484 else if ( msg == "timeChange(QString)" ) { 1481 else if ( msg == "timeChange(QString)" ) {
1485 QString t; 1482 QString t;
1486 stream >> t; 1483 stream >> t;
1487 if ( t.isNull() ) 1484 if ( t.isNull() )
1488 unsetenv( "TZ" ); 1485 unsetenv( "TZ" );
1489 else 1486 else
1490 setenv( "TZ", t.latin1(), 1 ); 1487 setenv( "TZ", t.latin1(), 1 );
1491 // emit the signal so everyone else knows... 1488 // emit the signal so everyone else knows...
1492 emit timeChanged(); 1489 emit timeChanged();
1493 } 1490 }
1494 else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) { 1491 else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) {
1495 if ( type() == GuiServer ) { 1492 if ( type() == GuiServer ) {
1496 QDateTime when; 1493 QDateTime when;
1497 QCString channel, message; 1494 QCString channel, message;
1498 int data; 1495 int data;
1499 stream >> when >> channel >> message >> data; 1496 stream >> when >> channel >> message >> data;
1500 AlarmServer::addAlarm( when, channel, message, data ); 1497 AlarmServer::addAlarm( when, channel, message, data );
1501 } 1498 }
1502 } 1499 }
1503 else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) { 1500 else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) {
1504 if ( type() == GuiServer ) { 1501 if ( type() == GuiServer ) {
1505 QDateTime when; 1502 QDateTime when;
1506 QCString channel, message; 1503 QCString channel, message;
1507 int data; 1504 int data;
1508 stream >> when >> channel >> message >> data; 1505 stream >> when >> channel >> message >> data;
1509 AlarmServer::deleteAlarm( when, channel, message, data ); 1506 AlarmServer::deleteAlarm( when, channel, message, data );
1510 } 1507 }
1511 } 1508 }
1512 else if ( msg == "clockChange(bool)" ) { 1509 else if ( msg == "clockChange(bool)" ) {
1513 int tmp; 1510 int tmp;
1514 stream >> tmp; 1511 stream >> tmp;
1515 emit clockChanged( tmp ); 1512 emit clockChanged( tmp );
@@ -1770,516 +1767,516 @@ void QPEApplication::showMainDocumentWidget( QWidget* mw, bool nomaximize )
1770{ 1767{
1771 if ( mw && argc() == 2 ) 1768 if ( mw && argc() == 2 )
1772 Global::setDocument( mw, QString::fromUtf8(argv()[1]) ); 1769 Global::setDocument( mw, QString::fromUtf8(argv()[1]) );
1773 1770
1774 1771
1775 //setMainWidget(mw); see above 1772 //setMainWidget(mw); see above
1776 d->show(mw, nomaximize ); 1773 d->show(mw, nomaximize );
1777} 1774}
1778 1775
1779 1776
1780/*! 1777/*!
1781 If an application is started via a \link qcop.html QCop\endlink 1778 If an application is started via a \link qcop.html QCop\endlink
1782 message, the application will process the \link qcop.html 1779 message, the application will process the \link qcop.html
1783 QCop\endlink message and then quit. If the application calls this 1780 QCop\endlink message and then quit. If the application calls this
1784 function while processing a \link qcop.html QCop\endlink message, 1781 function while processing a \link qcop.html QCop\endlink message,
1785 after processing its outstanding \link qcop.html QCop\endlink 1782 after processing its outstanding \link qcop.html QCop\endlink
1786 messages the application will start 'properly' and show itself. 1783 messages the application will start 'properly' and show itself.
1787 1784
1788 \sa keepRunning() 1785 \sa keepRunning()
1789*/ 1786*/
1790void QPEApplication::setKeepRunning() 1787void QPEApplication::setKeepRunning()
1791{ 1788{
1792 if ( qApp && qApp->inherits( "QPEApplication" ) ) { 1789 if ( qApp && qApp->inherits( "QPEApplication" ) ) {
1793 QPEApplication * qpeApp = ( QPEApplication* ) qApp; 1790 QPEApplication * qpeApp = ( QPEApplication* ) qApp;
1794 qpeApp->d->keep_running = TRUE; 1791 qpeApp->d->keep_running = TRUE;
1795 } 1792 }
1796} 1793}
1797 1794
1798/*! 1795/*!
1799 Returns TRUE if the application will quit after processing the 1796 Returns TRUE if the application will quit after processing the
1800 current list of qcop messages; otherwise returns FALSE. 1797 current list of qcop messages; otherwise returns FALSE.
1801 1798
1802 \sa setKeepRunning() 1799 \sa setKeepRunning()
1803*/ 1800*/
1804bool QPEApplication::keepRunning() const 1801bool QPEApplication::keepRunning() const
1805{ 1802{
1806 return d->keep_running; 1803 return d->keep_running;
1807} 1804}
1808 1805
1809/*! 1806/*!
1810 \internal 1807 \internal
1811*/ 1808*/
1812void QPEApplication::internalSetStyle( const QString &style ) 1809void QPEApplication::internalSetStyle( const QString &style )
1813{ 1810{
1814#if QT_VERSION >= 300 1811#if QT_VERSION >= 300
1815 if ( style == "QPE" ) { 1812 if ( style == "QPE" ) {
1816 setStyle( new QPEStyle ); 1813 setStyle( new QPEStyle );
1817 } 1814 }
1818 else { 1815 else {
1819 QStyle *s = QStyleFactory::create( style ); 1816 QStyle *s = QStyleFactory::create( style );
1820 if ( s ) 1817 if ( s )
1821 setStyle( s ); 1818 setStyle( s );
1822 } 1819 }
1823#else 1820#else
1824 if ( style == "Windows" ) { 1821 if ( style == "Windows" ) {
1825 setStyle( new QWindowsStyle ); 1822 setStyle( new QWindowsStyle );
1826 } 1823 }
1827 else if ( style == "QPE" ) { 1824 else if ( style == "QPE" ) {
1828 setStyle( new QPEStyle ); 1825 setStyle( new QPEStyle );
1829 } 1826 }
1830 else if ( style == "Light" ) { 1827 else if ( style == "Light" ) {
1831 setStyle( new LightStyle ); 1828 setStyle( new LightStyle );
1832 } 1829 }
1833#ifndef QT_NO_STYLE_PLATINUM 1830#ifndef QT_NO_STYLE_PLATINUM
1834 else if ( style == "Platinum" ) { 1831 else if ( style == "Platinum" ) {
1835 setStyle( new QPlatinumStyle ); 1832 setStyle( new QPlatinumStyle );
1836 } 1833 }
1837#endif 1834#endif
1838#ifndef QT_NO_STYLE_MOTIF 1835#ifndef QT_NO_STYLE_MOTIF
1839 else if ( style == "Motif" ) { 1836 else if ( style == "Motif" ) {
1840 setStyle( new QMotifStyle ); 1837 setStyle( new QMotifStyle );
1841 } 1838 }
1842#endif 1839#endif
1843#ifndef QT_NO_STYLE_MOTIFPLUS 1840#ifndef QT_NO_STYLE_MOTIFPLUS
1844 else if ( style == "MotifPlus" ) { 1841 else if ( style == "MotifPlus" ) {
1845 setStyle( new QMotifPlusStyle ); 1842 setStyle( new QMotifPlusStyle );
1846 } 1843 }
1847#endif 1844#endif
1848 1845
1849 else { 1846 else {
1850 QStyle *sty = 0; 1847 QStyle *sty = 0;
1851 QString path = QPEApplication::qpeDir ( ) + "/plugins/styles/"; 1848 QString path = QPEApplication::qpeDir ( ) + "/plugins/styles/";
1852 1849
1853#ifdef Q_OS_MACX 1850#ifdef Q_OS_MACX
1854 if ( style. find ( ".dylib" ) > 0 ) 1851 if ( style. find ( ".dylib" ) > 0 )
1855 path += style; 1852 path += style;
1856 else 1853 else
1857 path = path + "lib" + style. lower ( ) + ".dylib"; // compatibility 1854 path = path + "lib" + style. lower ( ) + ".dylib"; // compatibility
1858#else 1855#else
1859 if ( style. find ( ".so" ) > 0 ) 1856 if ( style. find ( ".so" ) > 0 )
1860 path += style; 1857 path += style;
1861 else 1858 else
1862 path = path + "lib" + style. lower ( ) + ".so"; // compatibility 1859 path = path + "lib" + style. lower ( ) + ".so"; // compatibility
1863#endif 1860#endif
1864 static QLibrary *lastlib = 0; 1861 static QLibrary *lastlib = 0;
1865 static StyleInterface *lastiface = 0; 1862 static StyleInterface *lastiface = 0;
1866 1863
1867 QLibrary *lib = new QLibrary ( path ); 1864 QLibrary *lib = new QLibrary ( path );
1868 StyleInterface *iface = 0; 1865 StyleInterface *iface = 0;
1869 1866
1870 if (( lib-> queryInterface ( IID_Style, ( QUnknownInterface ** ) &iface ) == QS_OK ) && iface ) 1867 if (( lib-> queryInterface ( IID_Style, ( QUnknownInterface ** ) &iface ) == QS_OK ) && iface )
1871 sty = iface-> style ( ); 1868 sty = iface-> style ( );
1872 1869
1873 if ( sty ) { 1870 if ( sty ) {
1874 setStyle ( sty ); 1871 setStyle ( sty );
1875 1872
1876 if ( lastiface ) 1873 if ( lastiface )
1877 lastiface-> release ( ); 1874 lastiface-> release ( );
1878 lastiface = iface; 1875 lastiface = iface;
1879 1876
1880 if ( lastlib ) { 1877 if ( lastlib ) {
1881 lastlib-> unload ( ); 1878 lastlib-> unload ( );
1882 delete lastlib; 1879 delete lastlib;
1883 } 1880 }
1884 lastlib = lib; 1881 lastlib = lib;
1885 } 1882 }
1886 else { 1883 else {
1887 if ( iface ) 1884 if ( iface )
1888 iface-> release ( ); 1885 iface-> release ( );
1889 delete lib; 1886 delete lib;
1890 1887
1891 setStyle ( new LightStyle ( )); 1888 setStyle ( new LightStyle ( ));
1892 } 1889 }
1893 } 1890 }
1894#endif 1891#endif
1895} 1892}
1896 1893
1897/*! 1894/*!
1898 \internal 1895 \internal
1899*/ 1896*/
1900void QPEApplication::prepareForTermination( bool willrestart ) 1897void QPEApplication::prepareForTermination( bool willrestart )
1901{ 1898{
1902 if ( willrestart ) { 1899 if ( willrestart ) {
1903 // Draw a big wait icon, the image can be altered in later revisions 1900 // Draw a big wait icon, the image can be altered in later revisions
1904 // QWidget *d = QApplication::desktop(); 1901 // QWidget *d = QApplication::desktop();
1905 QImage img = Resource::loadImage( "launcher/new_wait" ); 1902 QImage img = Resource::loadImage( "launcher/new_wait" );
1906 QPixmap pix; 1903 QPixmap pix;
1907 pix.convertFromImage( img.smoothScale( 1 * img.width(), 1 * img.height() ) ); 1904 pix.convertFromImage( img.smoothScale( 1 * img.width(), 1 * img.height() ) );
1908 QLabel *lblWait = new QLabel( 0, "wait hack!", QWidget::WStyle_Customize | 1905 QLabel *lblWait = new QLabel( 0, "wait hack!", QWidget::WStyle_Customize |
1909 QWidget::WStyle_NoBorder | QWidget::WStyle_Tool ); 1906 QWidget::WStyle_NoBorder | QWidget::WStyle_Tool );
1910 lblWait->setPixmap( pix ); 1907 lblWait->setPixmap( pix );
1911 lblWait->setAlignment( QWidget::AlignCenter ); 1908 lblWait->setAlignment( QWidget::AlignCenter );
1912 lblWait->show(); 1909 lblWait->show();
1913 lblWait->showMaximized(); 1910 lblWait->showMaximized();
1914 } 1911 }
1915#ifndef SINGLE_APP 1912#ifndef SINGLE_APP
1916 { QCopEnvelope envelope( "QPE/System", "forceQuit()" ); 1913 { QCopEnvelope envelope( "QPE/System", "forceQuit()" );
1917 } 1914 }
1918 processEvents(); // ensure the message goes out. 1915 processEvents(); // ensure the message goes out.
1919 sleep( 1 ); // You have 1 second to comply. 1916 sleep( 1 ); // You have 1 second to comply.
1920#endif 1917#endif
1921} 1918}
1922 1919
1923/*! 1920/*!
1924 \internal 1921 \internal
1925*/ 1922*/
1926void QPEApplication::shutdown() 1923void QPEApplication::shutdown()
1927{ 1924{
1928 // Implement in server's QPEApplication subclass 1925 // Implement in server's QPEApplication subclass
1929} 1926}
1930 1927
1931/*! 1928/*!
1932 \internal 1929 \internal
1933*/ 1930*/
1934void QPEApplication::restart() 1931void QPEApplication::restart()
1935{ 1932{
1936 // Implement in server's QPEApplication subclass 1933 // Implement in server's QPEApplication subclass
1937} 1934}
1938 1935
1939static QPtrDict<void>* stylusDict = 0; 1936static QPtrDict<void>* stylusDict = 0;
1940static void createDict() 1937static void createDict()
1941{ 1938{
1942 if ( !stylusDict ) 1939 if ( !stylusDict )
1943 stylusDict = new QPtrDict<void>; 1940 stylusDict = new QPtrDict<void>;
1944} 1941}
1945 1942
1946/*! 1943/*!
1947 Returns the current StylusMode for widget \a w. 1944 Returns the current StylusMode for widget \a w.
1948 1945
1949 \sa setStylusOperation() StylusMode 1946 \sa setStylusOperation() StylusMode
1950*/ 1947*/
1951QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w ) 1948QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w )
1952{ 1949{
1953 if ( stylusDict ) 1950 if ( stylusDict )
1954 return ( StylusMode ) ( int ) stylusDict->find( w ); 1951 return ( StylusMode ) ( int ) stylusDict->find( w );
1955 return LeftOnly; 1952 return LeftOnly;
1956} 1953}
1957 1954
1958/*! 1955/*!
1959 \enum QPEApplication::StylusMode 1956 \enum QPEApplication::StylusMode
1960 1957
1961 \value LeftOnly the stylus only generates LeftButton 1958 \value LeftOnly the stylus only generates LeftButton
1962 events (the default). 1959 events (the default).
1963 \value RightOnHold the stylus generates RightButton events 1960 \value RightOnHold the stylus generates RightButton events
1964 if the user uses the press-and-hold gesture. 1961 if the user uses the press-and-hold gesture.
1965 1962
1966 \sa setStylusOperation() stylusOperation() 1963 \sa setStylusOperation() stylusOperation()
1967*/ 1964*/
1968 1965
1969/*! 1966/*!
1970 Causes widget \a w to receive mouse events according to the stylus 1967 Causes widget \a w to receive mouse events according to the stylus
1971 \a mode. 1968 \a mode.
1972 1969
1973 \sa stylusOperation() StylusMode 1970 \sa stylusOperation() StylusMode
1974*/ 1971*/
1975void QPEApplication::setStylusOperation( QWidget * w, StylusMode mode ) 1972void QPEApplication::setStylusOperation( QWidget * w, StylusMode mode )
1976{ 1973{
1977 createDict(); 1974 createDict();
1978 if ( mode == LeftOnly ) { 1975 if ( mode == LeftOnly ) {
1979 stylusDict->remove 1976 stylusDict->remove
1980 ( w ); 1977 ( w );
1981 w->removeEventFilter( qApp ); 1978 w->removeEventFilter( qApp );
1982 } 1979 }
1983 else { 1980 else {
1984 stylusDict->insert( w, ( void* ) mode ); 1981 stylusDict->insert( w, ( void* ) mode );
1985 connect( w, SIGNAL( destroyed() ), qApp, SLOT( removeSenderFromStylusDict() ) ); 1982 connect( w, SIGNAL( destroyed() ), qApp, SLOT( removeSenderFromStylusDict() ) );
1986 w->installEventFilter( qApp ); 1983 w->installEventFilter( qApp );
1987 } 1984 }
1988} 1985}
1989 1986
1990 1987
1991/*! 1988/*!
1992 \reimp 1989 \reimp
1993*/ 1990*/
1994bool QPEApplication::eventFilter( QObject *o, QEvent *e ) 1991bool QPEApplication::eventFilter( QObject *o, QEvent *e )
1995{ 1992{
1996 if ( !o->isWidgetType() ) 1993 if ( !o->isWidgetType() )
1997 return FALSE; 1994 return FALSE;
1998 1995
1999 if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) { 1996 if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) {
2000 QMouseEvent * me = ( QMouseEvent* ) e; 1997 QMouseEvent * me = ( QMouseEvent* ) e;
2001 StylusMode mode = (StylusMode)(int)stylusDict->find(o); 1998 StylusMode mode = (StylusMode)(int)stylusDict->find(o);
2002 switch (mode) { 1999 switch (mode) {
2003 case RightOnHold: 2000 case RightOnHold:
2004 switch ( me->type() ) { 2001 switch ( me->type() ) {
2005 case QEvent::MouseButtonPress: 2002 case QEvent::MouseButtonPress:
2006 if ( me->button() == LeftButton ) { 2003 if ( me->button() == LeftButton ) {
2007 if (!d->presstimer ) 2004 if (!d->presstimer )
2008 d->presstimer = startTimer(500); // #### pref. 2005 d->presstimer = startTimer(500); // #### pref.
2009 d->presswidget = (QWidget*)o; 2006 d->presswidget = (QWidget*)o;
2010 d->presspos = me->pos(); 2007 d->presspos = me->pos();
2011 d->rightpressed = FALSE; 2008 d->rightpressed = FALSE;
2012 } 2009 }
2013 break; 2010 break;
2014 case QEvent::MouseMove: 2011 case QEvent::MouseMove:
2015 if (d->presstimer && (me->pos() - d->presspos).manhattanLength() > 8) { 2012 if (d->presstimer && (me->pos() - d->presspos).manhattanLength() > 8) {
2016 killTimer(d->presstimer); 2013 killTimer(d->presstimer);
2017 d->presstimer = 0; 2014 d->presstimer = 0;
2018 } 2015 }
2019 break; 2016 break;
2020 case QEvent::MouseButtonRelease: 2017 case QEvent::MouseButtonRelease:
2021 if ( me->button() == LeftButton ) { 2018 if ( me->button() == LeftButton ) {
2022 if ( d->presstimer ) { 2019 if ( d->presstimer ) {
2023 killTimer(d->presstimer); 2020 killTimer(d->presstimer);
2024 d->presstimer = 0; 2021 d->presstimer = 0;
2025 } 2022 }
2026 if ( d->rightpressed && d->presswidget ) { 2023 if ( d->rightpressed && d->presswidget ) {
2027 // Right released 2024 // Right released
2028 postEvent( d->presswidget, 2025 postEvent( d->presswidget,
2029 new QMouseEvent( QEvent::MouseButtonRelease, me->pos(), 2026 new QMouseEvent( QEvent::MouseButtonRelease, me->pos(),
2030 RightButton, LeftButton + RightButton ) ); 2027 RightButton, LeftButton + RightButton ) );
2031 // Left released, off-widget 2028 // Left released, off-widget
2032 postEvent( d->presswidget, 2029 postEvent( d->presswidget,
2033 new QMouseEvent( QEvent::MouseMove, QPoint( -1, -1), 2030 new QMouseEvent( QEvent::MouseMove, QPoint( -1, -1),
2034 LeftButton, LeftButton ) ); 2031 LeftButton, LeftButton ) );
2035 postEvent( d->presswidget, 2032 postEvent( d->presswidget,
2036 new QMouseEvent( QEvent::MouseButtonRelease, QPoint( -1, -1), 2033 new QMouseEvent( QEvent::MouseButtonRelease, QPoint( -1, -1),
2037 LeftButton, LeftButton ) ); 2034 LeftButton, LeftButton ) );
2038 d->rightpressed = FALSE; 2035 d->rightpressed = FALSE;
2039 return TRUE; // don't send the real Left release 2036 return TRUE; // don't send the real Left release
2040 } 2037 }
2041 } 2038 }
2042 break; 2039 break;
2043 default: 2040 default:
2044 break; 2041 break;
2045 } 2042 }
2046 break; 2043 break;
2047 default: 2044 default:
2048 ; 2045 ;
2049 } 2046 }
2050 } 2047 }
2051 else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { 2048 else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) {
2052 QKeyEvent *ke = (QKeyEvent *)e; 2049 QKeyEvent *ke = (QKeyEvent *)e;
2053 if ( ke->key() == Key_Enter ) { 2050 if ( ke->key() == Key_Enter ) {
2054 if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) { 2051 if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) {
2055 postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ', 2052 postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ',
2056 ke->state(), " ", ke->isAutoRepeat(), ke->count() ) ); 2053 ke->state(), " ", ke->isAutoRepeat(), ke->count() ) );
2057 return TRUE; 2054 return TRUE;
2058 } 2055 }
2059 } 2056 }
2060 } 2057 }
2061 return FALSE; 2058 return FALSE;
2062} 2059}
2063 2060
2064/*! 2061/*!
2065 \reimp 2062 \reimp
2066*/ 2063*/
2067void QPEApplication::timerEvent( QTimerEvent *e ) 2064void QPEApplication::timerEvent( QTimerEvent *e )
2068{ 2065{
2069 if ( e->timerId() == d->presstimer && d->presswidget ) { 2066 if ( e->timerId() == d->presstimer && d->presswidget ) {
2070 // Right pressed 2067 // Right pressed
2071 postEvent( d->presswidget, 2068 postEvent( d->presswidget,
2072 new QMouseEvent( QEvent::MouseButtonPress, d->presspos, 2069 new QMouseEvent( QEvent::MouseButtonPress, d->presspos,
2073 RightButton, LeftButton ) ); 2070 RightButton, LeftButton ) );
2074 killTimer( d->presstimer ); 2071 killTimer( d->presstimer );
2075 d->presstimer = 0; 2072 d->presstimer = 0;
2076 d->rightpressed = TRUE; 2073 d->rightpressed = TRUE;
2077 } 2074 }
2078} 2075}
2079 2076
2080void QPEApplication::removeSenderFromStylusDict() 2077void QPEApplication::removeSenderFromStylusDict()
2081{ 2078{
2082 stylusDict->remove 2079 stylusDict->remove
2083 ( ( void* ) sender() ); 2080 ( ( void* ) sender() );
2084 if ( d->presswidget == sender() ) 2081 if ( d->presswidget == sender() )
2085 d->presswidget = 0; 2082 d->presswidget = 0;
2086} 2083}
2087 2084
2088/*! 2085/*!
2089 \internal 2086 \internal
2090*/ 2087*/
2091bool QPEApplication::keyboardGrabbed() const 2088bool QPEApplication::keyboardGrabbed() const
2092{ 2089{
2093 return d->kbgrabbed; 2090 return d->kbgrabbed;
2094} 2091}
2095 2092
2096 2093
2097/*! 2094/*!
2098 Reverses the effect of grabKeyboard(). This is called automatically 2095 Reverses the effect of grabKeyboard(). This is called automatically
2099 on program exit. 2096 on program exit.
2100*/ 2097*/
2101void QPEApplication::ungrabKeyboard() 2098void QPEApplication::ungrabKeyboard()
2102{ 2099{
2103 ((QPEApplication *) qApp )-> d-> kbgrabbed = false; 2100 ((QPEApplication *) qApp )-> d-> kbgrabbed = false;
2104} 2101}
2105 2102
2106/*! 2103/*!
2107 Grabs the physical keyboard keys, e.g. the application's launching 2104 Grabs the physical keyboard keys, e.g. the application's launching
2108 keys. Instead of launching applications when these keys are pressed 2105 keys. Instead of launching applications when these keys are pressed
2109 the signals emitted are sent to this application instead. Some games 2106 the signals emitted are sent to this application instead. Some games
2110 programs take over the launch keys in this way to make interaction 2107 programs take over the launch keys in this way to make interaction
2111 easier. 2108 easier.
2112 2109
2113 \sa ungrabKeyboard() 2110 \sa ungrabKeyboard()
2114*/ 2111*/
2115void QPEApplication::grabKeyboard() 2112void QPEApplication::grabKeyboard()
2116{ 2113{
2117 ((QPEApplication *) qApp )-> d-> kbgrabbed = true; 2114 ((QPEApplication *) qApp )-> d-> kbgrabbed = true;
2118} 2115}
2119 2116
2120/*! 2117/*!
2121 \reimp 2118 \reimp
2122*/ 2119*/
2123int QPEApplication::exec() 2120int QPEApplication::exec()
2124{ 2121{
2125 d->qcopQok = true; 2122 d->qcopQok = true;
2126#ifndef QT_NO_COP 2123#ifndef QT_NO_COP
2127 d->sendQCopQ(); 2124 d->sendQCopQ();
2128 if ( !d->keep_running ) 2125 if ( !d->keep_running )
2129 processEvents(); // we may have received QCop messages in the meantime. 2126 processEvents(); // we may have received QCop messages in the meantime.
2130#endif 2127#endif
2131 2128
2132 if ( d->keep_running ) 2129 if ( d->keep_running )
2133 //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() ) 2130 //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() )
2134 return QApplication::exec(); 2131 return QApplication::exec();
2135 2132
2136#ifndef QT_NO_COP 2133#ifndef QT_NO_COP
2137 2134
2138 { 2135 {
2139 QCopEnvelope e( "QPE/System", "closing(QString)" ); 2136 QCopEnvelope e( "QPE/System", "closing(QString)" );
2140 e << d->appName; 2137 e << d->appName;
2141 } 2138 }
2142#endif 2139#endif
2143 processEvents(); 2140 processEvents();
2144 return 0; 2141 return 0;
2145} 2142}
2146 2143
2147/*! 2144/*!
2148 \internal 2145 \internal
2149 External request for application to quit. Quits if possible without 2146 External request for application to quit. Quits if possible without
2150 loosing state. 2147 loosing state.
2151*/ 2148*/
2152void QPEApplication::tryQuit() 2149void QPEApplication::tryQuit()
2153{ 2150{
2154 if ( activeModalWidget() || strcmp( argv() [ 0 ], "embeddedkonsole" ) == 0 ) 2151 if ( activeModalWidget() )
2155 return ; // Inside modal loop or konsole. Too hard to save state. 2152 return ; // Inside modal loop or konsole. Too hard to save state.
2156#ifndef QT_NO_COP 2153#ifndef QT_NO_COP
2157 2154
2158 { 2155 {
2159 QCopEnvelope e( "QPE/System", "closing(QString)" ); 2156 QCopEnvelope e( "QPE/System", "closing(QString)" );
2160 e << d->appName; 2157 e << d->appName;
2161 } 2158 }
2162#endif 2159#endif
2163 if ( d->keep_running ) 2160 if ( d->keep_running )
2164 d->store_widget_rect(d->qpe_main_widget, d->appName); 2161 d->store_widget_rect(d->qpe_main_widget, d->appName);
2165 processEvents(); 2162 processEvents();
2166 2163
2167 quit(); 2164 quit();
2168} 2165}
2169 2166
2170/*! 2167/*!
2171 \internal 2168 \internal
2172*/ 2169*/
2173void QPEApplication::installTranslation( const QString& baseName ) { 2170void QPEApplication::installTranslation( const QString& baseName ) {
2174 QTranslator* trans = new QTranslator(this); 2171 QTranslator* trans = new QTranslator(this);
2175 QString tfn = qpeDir() + "/i18n/"+baseName; 2172 QString tfn = qpeDir() + "/i18n/"+baseName;
2176 if ( trans->load( tfn ) ) 2173 if ( trans->load( tfn ) )
2177 installTranslator( trans ); 2174 installTranslator( trans );
2178 else 2175 else
2179 delete trans; 2176 delete trans;
2180} 2177}
2181 2178
2182/*! 2179/*!
2183 \internal 2180 \internal
2184 User initiated quit. Makes the window 'Go Away'. If preloaded this means 2181 User initiated quit. Makes the window 'Go Away'. If preloaded this means
2185 hiding the window. If not it means quitting the application. 2182 hiding the window. If not it means quitting the application.
2186 As this is user initiated we don't need to check state. 2183 As this is user initiated we don't need to check state.
2187*/ 2184*/
2188void QPEApplication::hideOrQuit() 2185void QPEApplication::hideOrQuit()
2189{ 2186{
2190 if ( d->keep_running ) 2187 if ( d->keep_running )
2191 d->store_widget_rect(d->qpe_main_widget, d->appName); 2188 d->store_widget_rect(d->qpe_main_widget, d->appName);
2192 processEvents(); 2189 processEvents();
2193 2190
2194 // If we are a preloaded application we don't actually quit, so emit 2191 // If we are a preloaded application we don't actually quit, so emit
2195 // a System message indicating we're quasi-closing. 2192 // a System message indicating we're quasi-closing.
2196 if ( d->preloaded && d->qpe_main_widget ) 2193 if ( d->preloaded && d->qpe_main_widget )
2197#ifndef QT_NO_COP 2194#ifndef QT_NO_COP
2198 2195
2199 { 2196 {
2200 QCopEnvelope e("QPE/System", "fastAppHiding(QString)" ); 2197 QCopEnvelope e("QPE/System", "fastAppHiding(QString)" );
2201 e << d->appName; 2198 e << d->appName;
2202 d->qpe_main_widget->hide(); 2199 d->qpe_main_widget->hide();
2203 } 2200 }
2204#endif 2201#endif
2205 else 2202 else
2206 quit(); 2203 quit();
2207} 2204}
2208 2205
2209#if (__GNUC__ > 2 ) 2206#if (__GNUC__ > 2 )
2210extern "C" void __cxa_pure_virtual(); 2207extern "C" void __cxa_pure_virtual();
2211 2208
2212void __cxa_pure_virtual() 2209void __cxa_pure_virtual()
2213{ 2210{
2214 fprintf( stderr, "Pure virtual called\n"); 2211 fprintf( stderr, "Pure virtual called\n");
2215 abort(); 2212 abort();
2216 2213
2217} 2214}
2218 2215
2219#endif 2216#endif
2220 2217
2221 2218
2222#if defined(OPIE_NEW_MALLOC) 2219#if defined(OPIE_NEW_MALLOC)
2223 2220
2224// The libraries with the skiff package (and possibly others) have 2221// The libraries with the skiff package (and possibly others) have
2225// completely useless implementations of builtin new and delete that 2222// completely useless implementations of builtin new and delete that
2226// use about 50% of your CPU. Here we revert to the simple libc 2223// use about 50% of your CPU. Here we revert to the simple libc
2227// functions. 2224// functions.
2228 2225
2229void* operator new[]( size_t size ) 2226void* operator new[]( size_t size )
2230{ 2227{
2231 return malloc( size ); 2228 return malloc( size );
2232} 2229}
2233 2230
2234void* operator new( size_t size ) 2231void* operator new( size_t size )
2235{ 2232{
2236 return malloc( size ); 2233 return malloc( size );
2237} 2234}
2238 2235
2239void operator delete[]( void* p ) 2236void operator delete[]( void* p )
2240{ 2237{
2241 free( p ); 2238 free( p );
2242} 2239}
2243 2240
2244void operator delete[]( void* p, size_t /*size*/ ) 2241void operator delete[]( void* p, size_t /*size*/ )
2245{ 2242{
2246 free( p ); 2243 free( p );
2247} 2244}
2248 2245
2249 2246
2250void operator delete( void* p ) 2247void operator delete( void* p )
2251{ 2248{
2252 free( p ); 2249 free( p );
2253} 2250}
2254 2251
2255void operator delete( void* p, size_t /*size*/ ) 2252void operator delete( void* p, size_t /*size*/ )
2256{ 2253{
2257 free( p ); 2254 free( p );
2258} 2255}
2259 2256
2260#endif 2257#endif
2261 2258
2262#if ( QT_VERSION <= 230 ) && !defined(SINGLE_APP) 2259#if ( QT_VERSION <= 230 ) && !defined(SINGLE_APP)
2263#include <qwidgetlist.h> 2260#include <qwidgetlist.h>
2264#ifdef QWS 2261#ifdef QWS
2265#include <qgfx_qws.h> 2262#include <qgfx_qws.h>
2266extern QRect qt_maxWindowRect; 2263extern QRect qt_maxWindowRect;
2267void qt_setMaxWindowRect(const QRect& r ) 2264void qt_setMaxWindowRect(const QRect& r )
2268{ 2265{
2269 qt_maxWindowRect = qt_screen->mapFromDevice( r, 2266 qt_maxWindowRect = qt_screen->mapFromDevice( r,
2270 qt_screen->mapToDevice( QSize( qt_screen->width(), qt_screen->height() ) ) ); 2267 qt_screen->mapToDevice( QSize( qt_screen->width(), qt_screen->height() ) ) );
2271 // Re-resize any maximized windows 2268 // Re-resize any maximized windows
2272 QWidgetList* l = QApplication::topLevelWidgets(); 2269 QWidgetList* l = QApplication::topLevelWidgets();
2273 if ( l ) { 2270 if ( l ) {
2274 QWidget * w = l->first(); 2271 QWidget * w = l->first();
2275 while ( w ) { 2272 while ( w ) {
2276 if ( w->isVisible() && w->isMaximized() ) { 2273 if ( w->isVisible() && w->isMaximized() ) {
2277 w->showMaximized(); 2274 w->showMaximized();
2278 } 2275 }
2279 w = l->next(); 2276 w = l->next();
2280 } 2277 }
2281 delete l; 2278 delete l;
2282 } 2279 }
2283} 2280}
2284#endif 2281#endif
2285#endif 2282#endif