author | sandman <sandman> | 2002-12-17 00:20:01 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-12-17 00:20:01 (UTC) |
commit | 70090722d240bed8c390281e072c9bcfc5ba7782 (patch) (unidiff) | |
tree | 453b4715acff74889655877a491c6cc3791d5de0 | |
parent | 79b94019014efe998b126219827f3050395beea7 (diff) | |
download | opie-70090722d240bed8c390281e072c9bcfc5ba7782.zip opie-70090722d240bed8c390281e072c9bcfc5ba7782.tar.gz opie-70090722d240bed8c390281e072c9bcfc5ba7782.tar.bz2 |
small additions to support grabbing the buttons back from a crashed
application
-rw-r--r-- | library/qpeapplication.cpp | 11 | ||||
-rw-r--r-- | library/qpeapplication.h | 2 |
2 files changed, 13 insertions, 0 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp index 852671a..b26933b 100644 --- a/library/qpeapplication.cpp +++ b/library/qpeapplication.cpp | |||
@@ -1,233 +1,234 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | ** $Id$ | 19 | ** $Id$ |
20 | ** | 20 | ** |
21 | **********************************************************************/ | 21 | **********************************************************************/ |
22 | #define QTOPIA_INTERNAL_LANGLIST | 22 | #define QTOPIA_INTERNAL_LANGLIST |
23 | #include <stdlib.h> | 23 | #include <stdlib.h> |
24 | #include <unistd.h> | 24 | #include <unistd.h> |
25 | #include <linux/limits.h> // needed for some toolchains (PATH_MAX) | 25 | #include <linux/limits.h> // needed for some toolchains (PATH_MAX) |
26 | #include <qfile.h> | 26 | #include <qfile.h> |
27 | #ifdef Q_WS_QWS | 27 | #ifdef Q_WS_QWS |
28 | #ifndef QT_NO_COP | 28 | #ifndef QT_NO_COP |
29 | #if QT_VERSION <= 231 | 29 | #if QT_VERSION <= 231 |
30 | #define private public | 30 | #define private public |
31 | #define sendLocally processEvent | 31 | #define sendLocally processEvent |
32 | #include "qcopenvelope_qws.h" | 32 | #include "qcopenvelope_qws.h" |
33 | #undef private | 33 | #undef private |
34 | #else | 34 | #else |
35 | #include "qcopenvelope_qws.h" | 35 | #include "qcopenvelope_qws.h" |
36 | #endif | 36 | #endif |
37 | #endif | 37 | #endif |
38 | #include <qwindowsystem_qws.h> | 38 | #include <qwindowsystem_qws.h> |
39 | #endif | 39 | #endif |
40 | #include <qtextstream.h> | 40 | #include <qtextstream.h> |
41 | #include <qpalette.h> | 41 | #include <qpalette.h> |
42 | #include <qbuffer.h> | 42 | #include <qbuffer.h> |
43 | #include <qptrdict.h> | 43 | #include <qptrdict.h> |
44 | #include <qregexp.h> | 44 | #include <qregexp.h> |
45 | #include <qdir.h> | 45 | #include <qdir.h> |
46 | #include <qlabel.h> | 46 | #include <qlabel.h> |
47 | #include <qdialog.h> | 47 | #include <qdialog.h> |
48 | #include <qdragobject.h> | 48 | #include <qdragobject.h> |
49 | #include <qtextcodec.h> | 49 | #include <qtextcodec.h> |
50 | #include <qevent.h> | 50 | #include <qevent.h> |
51 | #include <qtooltip.h> | 51 | #include <qtooltip.h> |
52 | #include <qsignal.h> | 52 | #include <qsignal.h> |
53 | #include "qpeapplication.h" | 53 | #include "qpeapplication.h" |
54 | #include "qpestyle.h" | 54 | #include "qpestyle.h" |
55 | #include "styleinterface.h" | 55 | #include "styleinterface.h" |
56 | #if QT_VERSION >= 300 | 56 | #if QT_VERSION >= 300 |
57 | #include <qstylefactory.h> | 57 | #include <qstylefactory.h> |
58 | #else | 58 | #else |
59 | #include <qplatinumstyle.h> | 59 | #include <qplatinumstyle.h> |
60 | #include <qwindowsstyle.h> | 60 | #include <qwindowsstyle.h> |
61 | #include <qmotifstyle.h> | 61 | #include <qmotifstyle.h> |
62 | #include <qmotifplusstyle.h> | 62 | #include <qmotifplusstyle.h> |
63 | #include "lightstyle.h" | 63 | #include "lightstyle.h" |
64 | 64 | ||
65 | #include <qpe/qlibrary.h> | 65 | #include <qpe/qlibrary.h> |
66 | #endif | 66 | #endif |
67 | #include "global.h" | 67 | #include "global.h" |
68 | #include "resource.h" | 68 | #include "resource.h" |
69 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) | 69 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) |
70 | #include "qutfcodec.h" | 70 | #include "qutfcodec.h" |
71 | #endif | 71 | #endif |
72 | #include "config.h" | 72 | #include "config.h" |
73 | #include "network.h" | 73 | #include "network.h" |
74 | #ifdef QWS | 74 | #ifdef QWS |
75 | #include "fontmanager.h" | 75 | #include "fontmanager.h" |
76 | #endif | 76 | #endif |
77 | 77 | ||
78 | #include "alarmserver.h" | 78 | #include "alarmserver.h" |
79 | #include "applnk.h" | 79 | #include "applnk.h" |
80 | #include "qpemenubar.h" | 80 | #include "qpemenubar.h" |
81 | #include "textcodecinterface.h" | 81 | #include "textcodecinterface.h" |
82 | #include "imagecodecinterface.h" | 82 | #include "imagecodecinterface.h" |
83 | 83 | ||
84 | #include <unistd.h> | 84 | #include <unistd.h> |
85 | #include <sys/file.h> | 85 | #include <sys/file.h> |
86 | #include <sys/ioctl.h> | 86 | #include <sys/ioctl.h> |
87 | #include <sys/soundcard.h> | 87 | #include <sys/soundcard.h> |
88 | 88 | ||
89 | #include "qt_override_p.h" | 89 | #include "qt_override_p.h" |
90 | 90 | ||
91 | 91 | ||
92 | class QPEApplicationData | 92 | class QPEApplicationData |
93 | { | 93 | { |
94 | public: | 94 | public: |
95 | QPEApplicationData() : presstimer( 0 ), presswidget( 0 ), kbgrabber( 0 ), | 95 | QPEApplicationData() : presstimer( 0 ), presswidget( 0 ), kbgrabber( 0 ), |
96 | rightpressed( FALSE ), kbregrab( FALSE ), notbusysent( FALSE ), preloaded( FALSE ), | 96 | rightpressed( FALSE ), kbregrab( FALSE ), notbusysent( FALSE ), preloaded( FALSE ), |
97 | forceshow( FALSE ), nomaximize( FALSE ), keep_running( TRUE ), qpe_main_widget( 0 ) | 97 | forceshow( FALSE ), nomaximize( FALSE ), keep_running( TRUE ), qpe_main_widget( 0 ) |
98 | 98 | ||
99 | { | 99 | { |
100 | qcopq.setAutoDelete( TRUE ); | 100 | qcopq.setAutoDelete( TRUE ); |
101 | } | 101 | } |
102 | 102 | ||
103 | int presstimer; | 103 | int presstimer; |
104 | QWidget* presswidget; | 104 | QWidget* presswidget; |
105 | int kbgrabber; | 105 | int kbgrabber; |
106 | QString kbgrabber_appname; | ||
106 | QPoint presspos; | 107 | QPoint presspos; |
107 | 108 | ||
108 | bool rightpressed : 1; | 109 | bool rightpressed : 1; |
109 | bool kbregrab : 1; | 110 | bool kbregrab : 1; |
110 | bool notbusysent : 1; | 111 | bool notbusysent : 1; |
111 | bool preloaded : 1; | 112 | bool preloaded : 1; |
112 | bool forceshow : 1; | 113 | bool forceshow : 1; |
113 | bool nomaximize : 1; | 114 | bool nomaximize : 1; |
114 | bool keep_running : 1; | 115 | bool keep_running : 1; |
115 | 116 | ||
116 | QString appName; | 117 | QString appName; |
117 | struct QCopRec | 118 | struct QCopRec |
118 | { | 119 | { |
119 | QCopRec( const QCString &ch, const QCString &msg, | 120 | QCopRec( const QCString &ch, const QCString &msg, |
120 | const QByteArray &d ) : | 121 | const QByteArray &d ) : |
121 | channel( ch ), message( msg ), data( d ) | 122 | channel( ch ), message( msg ), data( d ) |
122 | { } | 123 | { } |
123 | 124 | ||
124 | QCString channel; | 125 | QCString channel; |
125 | QCString message; | 126 | QCString message; |
126 | QByteArray data; | 127 | QByteArray data; |
127 | }; | 128 | }; |
128 | QWidget* qpe_main_widget; | 129 | QWidget* qpe_main_widget; |
129 | QList<QCopRec> qcopq; | 130 | QList<QCopRec> qcopq; |
130 | 131 | ||
131 | void enqueueQCop( const QCString &ch, const QCString &msg, | 132 | void enqueueQCop( const QCString &ch, const QCString &msg, |
132 | const QByteArray &data ) | 133 | const QByteArray &data ) |
133 | { | 134 | { |
134 | qcopq.append( new QCopRec( ch, msg, data ) ); | 135 | qcopq.append( new QCopRec( ch, msg, data ) ); |
135 | } | 136 | } |
136 | void sendQCopQ() | 137 | void sendQCopQ() |
137 | { | 138 | { |
138 | QCopRec * r; | 139 | QCopRec * r; |
139 | #ifndef QT_NO_COP | 140 | #ifndef QT_NO_COP |
140 | 141 | ||
141 | for ( QListIterator<QCopRec> it( qcopq ); ( r = it.current() ); ++it ) | 142 | for ( QListIterator<QCopRec> it( qcopq ); ( r = it.current() ); ++it ) |
142 | QCopChannel::sendLocally( r->channel, r->message, r->data ); | 143 | QCopChannel::sendLocally( r->channel, r->message, r->data ); |
143 | #endif | 144 | #endif |
144 | 145 | ||
145 | qcopq.clear(); | 146 | qcopq.clear(); |
146 | } | 147 | } |
147 | static void show_mx(QWidget* mw, bool nomaximize) | 148 | static void show_mx(QWidget* mw, bool nomaximize) |
148 | { | 149 | { |
149 | if ( mw->layout() && mw->inherits("QDialog") ) { | 150 | if ( mw->layout() && mw->inherits("QDialog") ) { |
150 | QPEApplication::showDialog((QDialog*)mw, nomaximize); | 151 | QPEApplication::showDialog((QDialog*)mw, nomaximize); |
151 | } | 152 | } |
152 | else { | 153 | else { |
153 | #ifdef Q_WS_QWS | 154 | #ifdef Q_WS_QWS |
154 | if ( !nomaximize ) | 155 | if ( !nomaximize ) |
155 | mw->showMaximized(); | 156 | mw->showMaximized(); |
156 | else | 157 | else |
157 | #endif | 158 | #endif |
158 | 159 | ||
159 | mw->show(); | 160 | mw->show(); |
160 | } | 161 | } |
161 | } | 162 | } |
162 | static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) | 163 | static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) |
163 | { | 164 | { |
164 | /* | 165 | /* |
165 | // This works but disable it for now until it is safe to apply | 166 | // This works but disable it for now until it is safe to apply |
166 | // What is does is scan the .desktop files of all the apps for | 167 | // What is does is scan the .desktop files of all the apps for |
167 | // the applnk that has the corresponding argv[0] as this program | 168 | // the applnk that has the corresponding argv[0] as this program |
168 | // then it uses the name stored in the .desktop file as the caption | 169 | // then it uses the name stored in the .desktop file as the caption |
169 | // for the main widget. This saves duplicating translations for | 170 | // for the main widget. This saves duplicating translations for |
170 | // the app name in the program and in the .desktop files. | 171 | // the app name in the program and in the .desktop files. |
171 | 172 | ||
172 | AppLnkSet apps( appsPath ); | 173 | AppLnkSet apps( appsPath ); |
173 | 174 | ||
174 | QList<AppLnk> appsList = apps.children(); | 175 | QList<AppLnk> appsList = apps.children(); |
175 | for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) { | 176 | for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) { |
176 | if ( (*it)->exec() == appName ) { | 177 | if ( (*it)->exec() == appName ) { |
177 | mw->setCaption( (*it)->name() ); | 178 | mw->setCaption( (*it)->name() ); |
178 | return TRUE; | 179 | return TRUE; |
179 | } | 180 | } |
180 | } | 181 | } |
181 | */ | 182 | */ |
182 | return FALSE; | 183 | return FALSE; |
183 | } | 184 | } |
184 | 185 | ||
185 | 186 | ||
186 | void show(QWidget* mw, bool nomax) | 187 | void show(QWidget* mw, bool nomax) |
187 | { | 188 | { |
188 | setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" ); | 189 | setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" ); |
189 | nomaximize = nomax; | 190 | nomaximize = nomax; |
190 | qpe_main_widget = mw; | 191 | qpe_main_widget = mw; |
191 | #ifndef QT_NO_COP | 192 | #ifndef QT_NO_COP |
192 | 193 | ||
193 | sendQCopQ(); | 194 | sendQCopQ(); |
194 | #endif | 195 | #endif |
195 | 196 | ||
196 | if ( preloaded ) { | 197 | if ( preloaded ) { |
197 | if (forceshow) | 198 | if (forceshow) |
198 | show_mx(mw, nomax); | 199 | show_mx(mw, nomax); |
199 | } | 200 | } |
200 | else if ( keep_running ) { | 201 | else if ( keep_running ) { |
201 | show_mx(mw, nomax); | 202 | show_mx(mw, nomax); |
202 | } | 203 | } |
203 | } | 204 | } |
204 | 205 | ||
205 | void loadTextCodecs() | 206 | void loadTextCodecs() |
206 | { | 207 | { |
207 | QString path = QPEApplication::qpeDir() + "/plugins/textcodecs"; | 208 | QString path = QPEApplication::qpeDir() + "/plugins/textcodecs"; |
208 | QDir dir( path, "lib*.so" ); | 209 | QDir dir( path, "lib*.so" ); |
209 | QStringList list; | 210 | QStringList list; |
210 | if ( dir. exists ( )) | 211 | if ( dir. exists ( )) |
211 | list = dir.entryList(); | 212 | list = dir.entryList(); |
212 | QStringList::Iterator it; | 213 | QStringList::Iterator it; |
213 | for ( it = list.begin(); it != list.end(); ++it ) { | 214 | for ( it = list.begin(); it != list.end(); ++it ) { |
214 | TextCodecInterface *iface = 0; | 215 | TextCodecInterface *iface = 0; |
215 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 216 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
216 | if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { | 217 | if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { |
217 | QValueList<int> mibs = iface->mibEnums(); | 218 | QValueList<int> mibs = iface->mibEnums(); |
218 | for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) { | 219 | for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) { |
219 | (void)iface->createForMib(*i); | 220 | (void)iface->createForMib(*i); |
220 | // ### it exists now; need to remember if we can delete it | 221 | // ### it exists now; need to remember if we can delete it |
221 | } | 222 | } |
222 | } | 223 | } |
223 | else { | 224 | else { |
224 | lib->unload(); | 225 | lib->unload(); |
225 | delete lib; | 226 | delete lib; |
226 | } | 227 | } |
227 | } | 228 | } |
228 | } | 229 | } |
229 | 230 | ||
230 | void loadImageCodecs() | 231 | void loadImageCodecs() |
231 | { | 232 | { |
232 | QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs"; | 233 | QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs"; |
233 | QDir dir( path, "lib*.so" ); | 234 | QDir dir( path, "lib*.so" ); |
@@ -939,256 +940,258 @@ void QPEApplication::setDefaultRotation( int r ) | |||
939 | } | 940 | } |
940 | #endif | 941 | #endif |
941 | 942 | ||
942 | } | 943 | } |
943 | } | 944 | } |
944 | 945 | ||
945 | 946 | ||
946 | /*! | 947 | /*! |
947 | \internal | 948 | \internal |
948 | */ | 949 | */ |
949 | void QPEApplication::applyStyle() | 950 | void QPEApplication::applyStyle() |
950 | { | 951 | { |
951 | Config config( "qpe" ); | 952 | Config config( "qpe" ); |
952 | config.setGroup( "Appearance" ); | 953 | config.setGroup( "Appearance" ); |
953 | 954 | ||
954 | // don't block ourselves ... | 955 | // don't block ourselves ... |
955 | Opie::force_appearance = 0; | 956 | Opie::force_appearance = 0; |
956 | 957 | ||
957 | static QString appname = Opie::binaryName ( ); | 958 | static QString appname = Opie::binaryName ( ); |
958 | 959 | ||
959 | QStringList ex = config. readListEntry ( "NoStyle", ';' ); | 960 | QStringList ex = config. readListEntry ( "NoStyle", ';' ); |
960 | int nostyle = 0; | 961 | int nostyle = 0; |
961 | for ( QStringList::Iterator it = ex. begin ( ); it != ex. end ( ); ++it ) { | 962 | for ( QStringList::Iterator it = ex. begin ( ); it != ex. end ( ); ++it ) { |
962 | if ( QRegExp (( *it ). mid ( 1 ), false, true ). find ( appname, 0 ) >= 0 ) { | 963 | if ( QRegExp (( *it ). mid ( 1 ), false, true ). find ( appname, 0 ) >= 0 ) { |
963 | nostyle = ( *it ). left ( 1 ). toInt ( 0, 32 ); | 964 | nostyle = ( *it ). left ( 1 ). toInt ( 0, 32 ); |
964 | break; | 965 | break; |
965 | } | 966 | } |
966 | } | 967 | } |
967 | 968 | ||
968 | // Widget style | 969 | // Widget style |
969 | QString style = config.readEntry( "Style", "Light" ); | 970 | QString style = config.readEntry( "Style", "Light" ); |
970 | 971 | ||
971 | // don't set a custom style | 972 | // don't set a custom style |
972 | if ( nostyle & Opie::Force_Style ) | 973 | if ( nostyle & Opie::Force_Style ) |
973 | style = "Light"; | 974 | style = "Light"; |
974 | 975 | ||
975 | internalSetStyle ( style ); | 976 | internalSetStyle ( style ); |
976 | 977 | ||
977 | // Colors | 978 | // Colors |
978 | QColor bgcolor( config.readEntry( "Background", "#E5E1D5" ) ); | 979 | QColor bgcolor( config.readEntry( "Background", "#E5E1D5" ) ); |
979 | QColor btncolor( config.readEntry( "Button", "#D6CDBB" ) ); | 980 | QColor btncolor( config.readEntry( "Button", "#D6CDBB" ) ); |
980 | QPalette pal( btncolor, bgcolor ); | 981 | QPalette pal( btncolor, bgcolor ); |
981 | QString color = config.readEntry( "Highlight", "#800000" ); | 982 | QString color = config.readEntry( "Highlight", "#800000" ); |
982 | pal.setColor( QColorGroup::Highlight, QColor( color ) ); | 983 | pal.setColor( QColorGroup::Highlight, QColor( color ) ); |
983 | color = config.readEntry( "HighlightedText", "#FFFFFF" ); | 984 | color = config.readEntry( "HighlightedText", "#FFFFFF" ); |
984 | pal.setColor( QColorGroup::HighlightedText, QColor( color ) ); | 985 | pal.setColor( QColorGroup::HighlightedText, QColor( color ) ); |
985 | color = config.readEntry( "Text", "#000000" ); | 986 | color = config.readEntry( "Text", "#000000" ); |
986 | pal.setColor( QColorGroup::Text, QColor( color ) ); | 987 | pal.setColor( QColorGroup::Text, QColor( color ) ); |
987 | color = config.readEntry( "ButtonText", "#000000" ); | 988 | color = config.readEntry( "ButtonText", "#000000" ); |
988 | pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) ); | 989 | pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) ); |
989 | color = config.readEntry( "Base", "#FFFFFF" ); | 990 | color = config.readEntry( "Base", "#FFFFFF" ); |
990 | pal.setColor( QColorGroup::Base, QColor( color ) ); | 991 | pal.setColor( QColorGroup::Base, QColor( color ) ); |
991 | 992 | ||
992 | pal.setColor( QPalette::Disabled, QColorGroup::Text, | 993 | pal.setColor( QPalette::Disabled, QColorGroup::Text, |
993 | pal.color( QPalette::Active, QColorGroup::Background ).dark() ); | 994 | pal.color( QPalette::Active, QColorGroup::Background ).dark() ); |
994 | 995 | ||
995 | setPalette( pal, TRUE ); | 996 | setPalette( pal, TRUE ); |
996 | 997 | ||
997 | // Window Decoration | 998 | // Window Decoration |
998 | QString dec = config.readEntry( "Decoration", "Qtopia" ); | 999 | QString dec = config.readEntry( "Decoration", "Qtopia" ); |
999 | 1000 | ||
1000 | // don't set a custom deco | 1001 | // don't set a custom deco |
1001 | if ( nostyle & Opie::Force_Decoration ) | 1002 | if ( nostyle & Opie::Force_Decoration ) |
1002 | dec = ""; | 1003 | dec = ""; |
1003 | 1004 | ||
1004 | //qDebug ( "Setting Deco: %s -- old %s (%d)", dec.latin1(), d-> decorationName.latin1(), nostyle); | 1005 | //qDebug ( "Setting Deco: %s -- old %s (%d)", dec.latin1(), d-> decorationName.latin1(), nostyle); |
1005 | 1006 | ||
1006 | if ( dec != d->decorationName ) { | 1007 | if ( dec != d->decorationName ) { |
1007 | qwsSetDecoration( new QPEDecoration( dec ) ); | 1008 | qwsSetDecoration( new QPEDecoration( dec ) ); |
1008 | d->decorationName = dec; | 1009 | d->decorationName = dec; |
1009 | } | 1010 | } |
1010 | 1011 | ||
1011 | // Font | 1012 | // Font |
1012 | QString ff = config.readEntry( "FontFamily", font().family() ); | 1013 | QString ff = config.readEntry( "FontFamily", font().family() ); |
1013 | int fs = config.readNumEntry( "FontSize", font().pointSize() ); | 1014 | int fs = config.readNumEntry( "FontSize", font().pointSize() ); |
1014 | 1015 | ||
1015 | // don't set a custom font | 1016 | // don't set a custom font |
1016 | if ( nostyle & Opie::Force_Font ) { | 1017 | if ( nostyle & Opie::Force_Font ) { |
1017 | ff = "Helvetica"; | 1018 | ff = "Helvetica"; |
1018 | fs = 10; | 1019 | fs = 10; |
1019 | } | 1020 | } |
1020 | 1021 | ||
1021 | setFont ( QFont ( ff, fs ), true ); | 1022 | setFont ( QFont ( ff, fs ), true ); |
1022 | 1023 | ||
1023 | // revert to global blocking policy ... | 1024 | // revert to global blocking policy ... |
1024 | Opie::force_appearance = config. readBoolEntry ( "ForceStyle", false ) ? Opie::Force_All : Opie::Force_None; | 1025 | Opie::force_appearance = config. readBoolEntry ( "ForceStyle", false ) ? Opie::Force_All : Opie::Force_None; |
1025 | Opie::force_appearance &= ~nostyle; | 1026 | Opie::force_appearance &= ~nostyle; |
1026 | } | 1027 | } |
1027 | 1028 | ||
1028 | void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data ) | 1029 | void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data ) |
1029 | { | 1030 | { |
1030 | #ifdef Q_WS_QWS | 1031 | #ifdef Q_WS_QWS |
1031 | QDataStream stream( data, IO_ReadOnly ); | 1032 | QDataStream stream( data, IO_ReadOnly ); |
1032 | if ( msg == "applyStyle()" ) { | 1033 | if ( msg == "applyStyle()" ) { |
1033 | applyStyle(); | 1034 | applyStyle(); |
1034 | } | 1035 | } |
1035 | else if ( msg == "setDefaultRotation(int)" ) { | 1036 | else if ( msg == "setDefaultRotation(int)" ) { |
1036 | if ( type() == GuiServer ) { | 1037 | if ( type() == GuiServer ) { |
1037 | int r; | 1038 | int r; |
1038 | stream >> r; | 1039 | stream >> r; |
1039 | setDefaultRotation( r ); | 1040 | setDefaultRotation( r ); |
1040 | } | 1041 | } |
1041 | } | 1042 | } |
1042 | else if ( msg == "shutdown()" ) { | 1043 | else if ( msg == "shutdown()" ) { |
1043 | if ( type() == GuiServer ) | 1044 | if ( type() == GuiServer ) |
1044 | shutdown(); | 1045 | shutdown(); |
1045 | } | 1046 | } |
1046 | else if ( msg == "quit()" ) { | 1047 | else if ( msg == "quit()" ) { |
1047 | if ( type() != GuiServer ) | 1048 | if ( type() != GuiServer ) |
1048 | tryQuit(); | 1049 | tryQuit(); |
1049 | } | 1050 | } |
1050 | else if ( msg == "forceQuit()" ) { | 1051 | else if ( msg == "forceQuit()" ) { |
1051 | if ( type() != GuiServer ) | 1052 | if ( type() != GuiServer ) |
1052 | quit(); | 1053 | quit(); |
1053 | } | 1054 | } |
1054 | else if ( msg == "restart()" ) { | 1055 | else if ( msg == "restart()" ) { |
1055 | if ( type() == GuiServer ) | 1056 | if ( type() == GuiServer ) |
1056 | restart(); | 1057 | restart(); |
1057 | } | 1058 | } |
1058 | else if ( msg == "grabKeyboard(QString)" ) { | 1059 | else if ( msg == "grabKeyboard(QString)" ) { |
1059 | QString who; | 1060 | QString who; |
1060 | stream >> who; | 1061 | stream >> who; |
1061 | if ( who.isEmpty() ) | 1062 | if ( who.isEmpty() ) |
1062 | d->kbgrabber = 0; | 1063 | d->kbgrabber = 0; |
1063 | else if ( who != d->appName ) | 1064 | else if ( who != d->appName ) |
1064 | d->kbgrabber = 1; | 1065 | d->kbgrabber = 1; |
1065 | else | 1066 | else |
1066 | d->kbgrabber = 2; | 1067 | d->kbgrabber = 2; |
1068 | |||
1069 | d-> kbgrabber_appname = who; | ||
1067 | } | 1070 | } |
1068 | else if ( msg == "language(QString)" ) { | 1071 | else if ( msg == "language(QString)" ) { |
1069 | if ( type() == GuiServer ) { | 1072 | if ( type() == GuiServer ) { |
1070 | QString l; | 1073 | QString l; |
1071 | stream >> l; | 1074 | stream >> l; |
1072 | QString cl = getenv( "LANG" ); | 1075 | QString cl = getenv( "LANG" ); |
1073 | if ( cl != l ) { | 1076 | if ( cl != l ) { |
1074 | if ( l.isNull() ) | 1077 | if ( l.isNull() ) |
1075 | unsetenv( "LANG" ); | 1078 | unsetenv( "LANG" ); |
1076 | else | 1079 | else |
1077 | setenv( "LANG", l.latin1(), 1 ); | 1080 | setenv( "LANG", l.latin1(), 1 ); |
1078 | restart(); | 1081 | restart(); |
1079 | } | 1082 | } |
1080 | } | 1083 | } |
1081 | } | 1084 | } |
1082 | else if ( msg == "timeChange(QString)" ) { | 1085 | else if ( msg == "timeChange(QString)" ) { |
1083 | QString t; | 1086 | QString t; |
1084 | stream >> t; | 1087 | stream >> t; |
1085 | if ( t.isNull() ) | 1088 | if ( t.isNull() ) |
1086 | unsetenv( "TZ" ); | 1089 | unsetenv( "TZ" ); |
1087 | else | 1090 | else |
1088 | setenv( "TZ", t.latin1(), 1 ); | 1091 | setenv( "TZ", t.latin1(), 1 ); |
1089 | // emit the signal so everyone else knows... | 1092 | // emit the signal so everyone else knows... |
1090 | emit timeChanged(); | 1093 | emit timeChanged(); |
1091 | } | 1094 | } |
1092 | else if ( msg == "execute(QString)" ) { | 1095 | else if ( msg == "execute(QString)" ) { |
1093 | if ( type() == GuiServer ) { | 1096 | if ( type() == GuiServer ) { |
1094 | QString t; | 1097 | QString t; |
1095 | stream >> t; | 1098 | stream >> t; |
1096 | Global::execute( t ); | 1099 | Global::execute( t ); |
1097 | } | 1100 | } |
1098 | } | 1101 | } |
1099 | else if ( msg == "execute(QString,QString)" ) { | 1102 | else if ( msg == "execute(QString,QString)" ) { |
1100 | if ( type() == GuiServer ) { | 1103 | if ( type() == GuiServer ) { |
1101 | QString t, d; | 1104 | QString t, d; |
1102 | stream >> t >> d; | 1105 | stream >> t >> d; |
1103 | Global::execute( t, d ); | 1106 | Global::execute( t, d ); |
1104 | } | 1107 | } |
1105 | } | 1108 | } |
1106 | else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) { | 1109 | else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) { |
1107 | if ( type() == GuiServer ) { | 1110 | if ( type() == GuiServer ) { |
1108 | QDateTime when; | 1111 | QDateTime when; |
1109 | QCString channel, message; | 1112 | QCString channel, message; |
1110 | int data; | 1113 | int data; |
1111 | stream >> when >> channel >> message >> data; | 1114 | stream >> when >> channel >> message >> data; |
1112 | AlarmServer::addAlarm( when, channel, message, data ); | 1115 | AlarmServer::addAlarm( when, channel, message, data ); |
1113 | } | 1116 | } |
1114 | } | 1117 | } |
1115 | else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) { | 1118 | else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) { |
1116 | if ( type() == GuiServer ) { | 1119 | if ( type() == GuiServer ) { |
1117 | QDateTime when; | 1120 | QDateTime when; |
1118 | QCString channel, message; | 1121 | QCString channel, message; |
1119 | int data; | 1122 | int data; |
1120 | stream >> when >> channel >> message >> data; | 1123 | stream >> when >> channel >> message >> data; |
1121 | AlarmServer::deleteAlarm( when, channel, message, data ); | 1124 | AlarmServer::deleteAlarm( when, channel, message, data ); |
1122 | } | 1125 | } |
1123 | } | 1126 | } |
1124 | else if ( msg == "clockChange(bool)" ) { | 1127 | else if ( msg == "clockChange(bool)" ) { |
1125 | int tmp; | 1128 | int tmp; |
1126 | stream >> tmp; | 1129 | stream >> tmp; |
1127 | emit clockChanged( tmp ); | 1130 | emit clockChanged( tmp ); |
1128 | } | 1131 | } |
1129 | else if ( msg == "weekChange(bool)" ) { | 1132 | else if ( msg == "weekChange(bool)" ) { |
1130 | int tmp; | 1133 | int tmp; |
1131 | stream >> tmp; | 1134 | stream >> tmp; |
1132 | emit weekChanged( tmp ); | 1135 | emit weekChanged( tmp ); |
1133 | } | 1136 | } |
1134 | else if ( msg == "setDateFormat(DateFormat)" ) { | 1137 | else if ( msg == "setDateFormat(DateFormat)" ) { |
1135 | DateFormat tmp; | 1138 | DateFormat tmp; |
1136 | stream >> tmp; | 1139 | stream >> tmp; |
1137 | emit dateFormatChanged( tmp ); | 1140 | emit dateFormatChanged( tmp ); |
1138 | } | 1141 | } |
1139 | else if ( msg == "setVolume(int,int)" ) { | 1142 | else if ( msg == "setVolume(int,int)" ) { |
1140 | int t, v; | 1143 | int t, v; |
1141 | stream >> t >> v; | 1144 | stream >> t >> v; |
1142 | setVolume( t, v ); | 1145 | setVolume( t, v ); |
1143 | emit volumeChanged( muted ); | 1146 | emit volumeChanged( muted ); |
1144 | } | 1147 | } |
1145 | else if ( msg == "volumeChange(bool)" ) { | 1148 | else if ( msg == "volumeChange(bool)" ) { |
1146 | stream >> muted; | 1149 | stream >> muted; |
1147 | setVolume(); | 1150 | setVolume(); |
1148 | emit volumeChanged( muted ); | 1151 | emit volumeChanged( muted ); |
1149 | } | 1152 | } |
1150 | else if ( msg == "setMic(int,int)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> | 1153 | else if ( msg == "setMic(int,int)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> |
1151 | int t, v; | 1154 | int t, v; |
1152 | stream >> t >> v; | 1155 | stream >> t >> v; |
1153 | setMic( t, v ); | 1156 | setMic( t, v ); |
1154 | emit micChanged( micMuted ); | 1157 | emit micChanged( micMuted ); |
1155 | } | 1158 | } |
1156 | else if ( msg == "micChange(bool)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> | 1159 | else if ( msg == "micChange(bool)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> |
1157 | stream >> micMuted; | 1160 | stream >> micMuted; |
1158 | setMic(); | 1161 | setMic(); |
1159 | emit micChanged( micMuted ); | 1162 | emit micChanged( micMuted ); |
1160 | } | 1163 | } |
1161 | else if ( msg == "setBass(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> | 1164 | else if ( msg == "setBass(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> |
1162 | int t, v; | 1165 | int t, v; |
1163 | stream >> t >> v; | 1166 | stream >> t >> v; |
1164 | setBass( t, v ); | 1167 | setBass( t, v ); |
1165 | } | 1168 | } |
1166 | else if ( msg == "bassChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> | 1169 | else if ( msg == "bassChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> |
1167 | setBass(); | 1170 | setBass(); |
1168 | } | 1171 | } |
1169 | else if ( msg == "setTreble(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> | 1172 | else if ( msg == "setTreble(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> |
1170 | int t, v; | 1173 | int t, v; |
1171 | stream >> t >> v; | 1174 | stream >> t >> v; |
1172 | setTreble( t, v ); | 1175 | setTreble( t, v ); |
1173 | } | 1176 | } |
1174 | else if ( msg == "trebleChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> | 1177 | else if ( msg == "trebleChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> |
1175 | setTreble(); | 1178 | setTreble(); |
1176 | } | 1179 | } |
1177 | 1180 | ||
1178 | 1181 | ||
1179 | 1182 | ||
1180 | #endif | 1183 | #endif |
1181 | } | 1184 | } |
1182 | 1185 | ||
1183 | /*! | 1186 | /*! |
1184 | \internal | 1187 | \internal |
1185 | */ | 1188 | */ |
1186 | bool QPEApplication::raiseAppropriateWindow() | 1189 | bool QPEApplication::raiseAppropriateWindow() |
1187 | { | 1190 | { |
1188 | bool r = FALSE; | 1191 | bool r = FALSE; |
1189 | // ########## raise()ing main window should raise and set active | 1192 | // ########## raise()ing main window should raise and set active |
1190 | // ########## it and then all childen. This belongs in Qt/Embedded | 1193 | // ########## it and then all childen. This belongs in Qt/Embedded |
1191 | QWidget *top = d->qpe_main_widget; | 1194 | QWidget *top = d->qpe_main_widget; |
1192 | if ( !top ) | 1195 | if ( !top ) |
1193 | top = mainWidget(); | 1196 | top = mainWidget(); |
1194 | if ( top && d->keep_running ) { | 1197 | if ( top && d->keep_running ) { |
@@ -1499,256 +1502,264 @@ QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w ) | |||
1499 | if the user uses the press-and-hold gesture. | 1502 | if the user uses the press-and-hold gesture. |
1500 | 1503 | ||
1501 | \sa setStylusOperation() stylusOperation() | 1504 | \sa setStylusOperation() stylusOperation() |
1502 | */ | 1505 | */ |
1503 | 1506 | ||
1504 | /*! | 1507 | /*! |
1505 | Causes widget \a w to receive mouse events according to the stylus | 1508 | Causes widget \a w to receive mouse events according to the stylus |
1506 | \a mode. | 1509 | \a mode. |
1507 | 1510 | ||
1508 | \sa stylusOperation() StylusMode | 1511 | \sa stylusOperation() StylusMode |
1509 | */ | 1512 | */ |
1510 | void QPEApplication::setStylusOperation( QWidget * w, StylusMode mode ) | 1513 | void QPEApplication::setStylusOperation( QWidget * w, StylusMode mode ) |
1511 | { | 1514 | { |
1512 | createDict(); | 1515 | createDict(); |
1513 | if ( mode == LeftOnly ) { | 1516 | if ( mode == LeftOnly ) { |
1514 | stylusDict->remove | 1517 | stylusDict->remove |
1515 | ( w ); | 1518 | ( w ); |
1516 | w->removeEventFilter( qApp ); | 1519 | w->removeEventFilter( qApp ); |
1517 | } | 1520 | } |
1518 | else { | 1521 | else { |
1519 | stylusDict->insert( w, ( void* ) mode ); | 1522 | stylusDict->insert( w, ( void* ) mode ); |
1520 | connect( w, SIGNAL( destroyed() ), qApp, SLOT( removeSenderFromStylusDict() ) ); | 1523 | connect( w, SIGNAL( destroyed() ), qApp, SLOT( removeSenderFromStylusDict() ) ); |
1521 | w->installEventFilter( qApp ); | 1524 | w->installEventFilter( qApp ); |
1522 | } | 1525 | } |
1523 | } | 1526 | } |
1524 | 1527 | ||
1525 | 1528 | ||
1526 | /*! | 1529 | /*! |
1527 | \reimp | 1530 | \reimp |
1528 | */ | 1531 | */ |
1529 | bool QPEApplication::eventFilter( QObject *o, QEvent *e ) | 1532 | bool QPEApplication::eventFilter( QObject *o, QEvent *e ) |
1530 | { | 1533 | { |
1531 | if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) { | 1534 | if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) { |
1532 | QMouseEvent * me = ( QMouseEvent* ) e; | 1535 | QMouseEvent * me = ( QMouseEvent* ) e; |
1533 | StylusMode mode = (StylusMode)(int)stylusDict->find(o); | 1536 | StylusMode mode = (StylusMode)(int)stylusDict->find(o); |
1534 | switch (mode) { | 1537 | switch (mode) { |
1535 | case RightOnHold: | 1538 | case RightOnHold: |
1536 | switch ( me->type() ) { | 1539 | switch ( me->type() ) { |
1537 | case QEvent::MouseButtonPress: | 1540 | case QEvent::MouseButtonPress: |
1538 | if ( me->button() == LeftButton ) { | 1541 | if ( me->button() == LeftButton ) { |
1539 | d->presstimer = startTimer(500); // #### pref. | 1542 | d->presstimer = startTimer(500); // #### pref. |
1540 | d->presswidget = (QWidget*)o; | 1543 | d->presswidget = (QWidget*)o; |
1541 | d->presspos = me->pos(); | 1544 | d->presspos = me->pos(); |
1542 | d->rightpressed = FALSE; | 1545 | d->rightpressed = FALSE; |
1543 | } | 1546 | } |
1544 | break; | 1547 | break; |
1545 | case QEvent::MouseMove: | 1548 | case QEvent::MouseMove: |
1546 | if (d->presstimer && (me->pos() - d->presspos).manhattanLength() > 8) { | 1549 | if (d->presstimer && (me->pos() - d->presspos).manhattanLength() > 8) { |
1547 | killTimer(d->presstimer); | 1550 | killTimer(d->presstimer); |
1548 | d->presstimer = 0; | 1551 | d->presstimer = 0; |
1549 | } | 1552 | } |
1550 | break; | 1553 | break; |
1551 | case QEvent::MouseButtonRelease: | 1554 | case QEvent::MouseButtonRelease: |
1552 | if ( me->button() == LeftButton ) { | 1555 | if ( me->button() == LeftButton ) { |
1553 | if ( d->presstimer ) { | 1556 | if ( d->presstimer ) { |
1554 | killTimer(d->presstimer); | 1557 | killTimer(d->presstimer); |
1555 | d->presstimer = 0; | 1558 | d->presstimer = 0; |
1556 | } | 1559 | } |
1557 | if ( d->rightpressed && d->presswidget ) { | 1560 | if ( d->rightpressed && d->presswidget ) { |
1558 | // Right released | 1561 | // Right released |
1559 | postEvent( d->presswidget, | 1562 | postEvent( d->presswidget, |
1560 | new QMouseEvent( QEvent::MouseButtonRelease, me->pos(), | 1563 | new QMouseEvent( QEvent::MouseButtonRelease, me->pos(), |
1561 | RightButton, LeftButton + RightButton ) ); | 1564 | RightButton, LeftButton + RightButton ) ); |
1562 | // Left released, off-widget | 1565 | // Left released, off-widget |
1563 | postEvent( d->presswidget, | 1566 | postEvent( d->presswidget, |
1564 | new QMouseEvent( QEvent::MouseMove, QPoint( -1, -1), | 1567 | new QMouseEvent( QEvent::MouseMove, QPoint( -1, -1), |
1565 | LeftButton, LeftButton ) ); | 1568 | LeftButton, LeftButton ) ); |
1566 | postEvent( d->presswidget, | 1569 | postEvent( d->presswidget, |
1567 | new QMouseEvent( QEvent::MouseButtonRelease, QPoint( -1, -1), | 1570 | new QMouseEvent( QEvent::MouseButtonRelease, QPoint( -1, -1), |
1568 | LeftButton, LeftButton ) ); | 1571 | LeftButton, LeftButton ) ); |
1569 | d->rightpressed = FALSE; | 1572 | d->rightpressed = FALSE; |
1570 | return TRUE; // don't send the real Left release | 1573 | return TRUE; // don't send the real Left release |
1571 | } | 1574 | } |
1572 | } | 1575 | } |
1573 | break; | 1576 | break; |
1574 | default: | 1577 | default: |
1575 | break; | 1578 | break; |
1576 | } | 1579 | } |
1577 | break; | 1580 | break; |
1578 | default: | 1581 | default: |
1579 | ; | 1582 | ; |
1580 | } | 1583 | } |
1581 | } | 1584 | } |
1582 | else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { | 1585 | else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { |
1583 | QKeyEvent *ke = (QKeyEvent *)e; | 1586 | QKeyEvent *ke = (QKeyEvent *)e; |
1584 | if ( ke->key() == Key_Enter ) { | 1587 | if ( ke->key() == Key_Enter ) { |
1585 | if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) { | 1588 | if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) { |
1586 | postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ', | 1589 | postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ', |
1587 | ke->state(), " ", ke->isAutoRepeat(), ke->count() ) ); | 1590 | ke->state(), " ", ke->isAutoRepeat(), ke->count() ) ); |
1588 | return TRUE; | 1591 | return TRUE; |
1589 | } | 1592 | } |
1590 | } | 1593 | } |
1591 | } | 1594 | } |
1592 | return FALSE; | 1595 | return FALSE; |
1593 | } | 1596 | } |
1594 | 1597 | ||
1595 | /*! | 1598 | /*! |
1596 | \reimp | 1599 | \reimp |
1597 | */ | 1600 | */ |
1598 | void QPEApplication::timerEvent( QTimerEvent *e ) | 1601 | void QPEApplication::timerEvent( QTimerEvent *e ) |
1599 | { | 1602 | { |
1600 | if ( e->timerId() == d->presstimer && d->presswidget ) { | 1603 | if ( e->timerId() == d->presstimer && d->presswidget ) { |
1601 | // Right pressed | 1604 | // Right pressed |
1602 | postEvent( d->presswidget, | 1605 | postEvent( d->presswidget, |
1603 | new QMouseEvent( QEvent::MouseButtonPress, d->presspos, | 1606 | new QMouseEvent( QEvent::MouseButtonPress, d->presspos, |
1604 | RightButton, LeftButton ) ); | 1607 | RightButton, LeftButton ) ); |
1605 | killTimer( d->presstimer ); | 1608 | killTimer( d->presstimer ); |
1606 | d->presstimer = 0; | 1609 | d->presstimer = 0; |
1607 | d->rightpressed = TRUE; | 1610 | d->rightpressed = TRUE; |
1608 | } | 1611 | } |
1609 | } | 1612 | } |
1610 | 1613 | ||
1611 | void QPEApplication::removeSenderFromStylusDict() | 1614 | void QPEApplication::removeSenderFromStylusDict() |
1612 | { | 1615 | { |
1613 | stylusDict->remove | 1616 | stylusDict->remove |
1614 | ( ( void* ) sender() ); | 1617 | ( ( void* ) sender() ); |
1615 | if ( d->presswidget == sender() ) | 1618 | if ( d->presswidget == sender() ) |
1616 | d->presswidget = 0; | 1619 | d->presswidget = 0; |
1617 | } | 1620 | } |
1618 | 1621 | ||
1619 | /*! | 1622 | /*! |
1620 | \internal | 1623 | \internal |
1621 | */ | 1624 | */ |
1622 | bool QPEApplication::keyboardGrabbed() const | 1625 | bool QPEApplication::keyboardGrabbed() const |
1623 | { | 1626 | { |
1624 | return d->kbgrabber; | 1627 | return d->kbgrabber; |
1625 | } | 1628 | } |
1626 | 1629 | ||
1630 | /*! | ||
1631 | \internal | ||
1632 | */ | ||
1633 | QString QPEApplication::keyboardGrabbedBy() const | ||
1634 | { | ||
1635 | return d->kbgrabber_appname; | ||
1636 | } | ||
1637 | |||
1627 | 1638 | ||
1628 | /*! | 1639 | /*! |
1629 | Reverses the effect of grabKeyboard(). This is called automatically | 1640 | Reverses the effect of grabKeyboard(). This is called automatically |
1630 | on program exit. | 1641 | on program exit. |
1631 | */ | 1642 | */ |
1632 | void QPEApplication::ungrabKeyboard() | 1643 | void QPEApplication::ungrabKeyboard() |
1633 | { | 1644 | { |
1634 | QPEApplicationData * d = ( ( QPEApplication* ) qApp ) ->d; | 1645 | QPEApplicationData * d = ( ( QPEApplication* ) qApp ) ->d; |
1635 | if ( d->kbgrabber == 2 ) { | 1646 | if ( d->kbgrabber == 2 ) { |
1636 | #ifndef QT_NO_COP | 1647 | #ifndef QT_NO_COP |
1637 | QCopEnvelope e( "QPE/System", "grabKeyboard(QString)" ); | 1648 | QCopEnvelope e( "QPE/System", "grabKeyboard(QString)" ); |
1638 | e << QString::null; | 1649 | e << QString::null; |
1639 | #endif | 1650 | #endif |
1640 | 1651 | ||
1641 | d->kbregrab = FALSE; | 1652 | d->kbregrab = FALSE; |
1642 | d->kbgrabber = 0; | 1653 | d->kbgrabber = 0; |
1643 | } | 1654 | } |
1644 | } | 1655 | } |
1645 | 1656 | ||
1646 | /*! | 1657 | /*! |
1647 | Grabs the physical keyboard keys, e.g. the application's launching | 1658 | Grabs the physical keyboard keys, e.g. the application's launching |
1648 | keys. Instead of launching applications when these keys are pressed | 1659 | keys. Instead of launching applications when these keys are pressed |
1649 | the signals emitted are sent to this application instead. Some games | 1660 | the signals emitted are sent to this application instead. Some games |
1650 | programs take over the launch keys in this way to make interaction | 1661 | programs take over the launch keys in this way to make interaction |
1651 | easier. | 1662 | easier. |
1652 | 1663 | ||
1653 | \sa ungrabKeyboard() | 1664 | \sa ungrabKeyboard() |
1654 | */ | 1665 | */ |
1655 | void QPEApplication::grabKeyboard() | 1666 | void QPEApplication::grabKeyboard() |
1656 | { | 1667 | { |
1657 | QPEApplicationData * d = ( ( QPEApplication* ) qApp ) ->d; | 1668 | QPEApplicationData * d = ( ( QPEApplication* ) qApp ) ->d; |
1658 | if ( qApp->type() == QApplication::GuiServer ) | 1669 | if ( qApp->type() == QApplication::GuiServer ) |
1659 | d->kbgrabber = 0; | 1670 | d->kbgrabber = 0; |
1660 | else { | 1671 | else { |
1661 | #ifndef QT_NO_COP | 1672 | #ifndef QT_NO_COP |
1662 | QCopEnvelope e( "QPE/System", "grabKeyboard(QString)" ); | 1673 | QCopEnvelope e( "QPE/System", "grabKeyboard(QString)" ); |
1663 | e << d->appName; | 1674 | e << d->appName; |
1664 | #endif | 1675 | #endif |
1665 | 1676 | ||
1666 | d->kbgrabber = 2; // me | 1677 | d->kbgrabber = 2; // me |
1667 | } | 1678 | } |
1668 | } | 1679 | } |
1669 | 1680 | ||
1670 | /*! | 1681 | /*! |
1671 | \reimp | 1682 | \reimp |
1672 | */ | 1683 | */ |
1673 | int QPEApplication::exec() | 1684 | int QPEApplication::exec() |
1674 | { | 1685 | { |
1675 | #ifndef QT_NO_COP | 1686 | #ifndef QT_NO_COP |
1676 | d->sendQCopQ(); | 1687 | d->sendQCopQ(); |
1677 | #endif | 1688 | #endif |
1678 | 1689 | ||
1679 | if ( d->keep_running ) | 1690 | if ( d->keep_running ) |
1680 | //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() ) | 1691 | //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() ) |
1681 | return QApplication::exec(); | 1692 | return QApplication::exec(); |
1682 | 1693 | ||
1683 | #ifndef QT_NO_COP | 1694 | #ifndef QT_NO_COP |
1684 | 1695 | ||
1685 | { | 1696 | { |
1686 | QCopEnvelope e( "QPE/System", "closing(QString)" ); | 1697 | QCopEnvelope e( "QPE/System", "closing(QString)" ); |
1687 | e << d->appName; | 1698 | e << d->appName; |
1688 | } | 1699 | } |
1689 | #endif | 1700 | #endif |
1690 | processEvents(); | 1701 | processEvents(); |
1691 | return 0; | 1702 | return 0; |
1692 | } | 1703 | } |
1693 | 1704 | ||
1694 | /*! | 1705 | /*! |
1695 | \internal | 1706 | \internal |
1696 | External request for application to quit. Quits if possible without | 1707 | External request for application to quit. Quits if possible without |
1697 | loosing state. | 1708 | loosing state. |
1698 | */ | 1709 | */ |
1699 | void QPEApplication::tryQuit() | 1710 | void QPEApplication::tryQuit() |
1700 | { | 1711 | { |
1701 | if ( activeModalWidget() || strcmp( argv() [ 0 ], "embeddedkonsole" ) == 0 ) | 1712 | if ( activeModalWidget() || strcmp( argv() [ 0 ], "embeddedkonsole" ) == 0 ) |
1702 | return ; // Inside modal loop or konsole. Too hard to save state. | 1713 | return ; // Inside modal loop or konsole. Too hard to save state. |
1703 | #ifndef QT_NO_COP | 1714 | #ifndef QT_NO_COP |
1704 | 1715 | ||
1705 | { | 1716 | { |
1706 | QCopEnvelope e( "QPE/System", "closing(QString)" ); | 1717 | QCopEnvelope e( "QPE/System", "closing(QString)" ); |
1707 | e << d->appName; | 1718 | e << d->appName; |
1708 | } | 1719 | } |
1709 | #endif | 1720 | #endif |
1710 | processEvents(); | 1721 | processEvents(); |
1711 | 1722 | ||
1712 | quit(); | 1723 | quit(); |
1713 | } | 1724 | } |
1714 | 1725 | ||
1715 | /*! | 1726 | /*! |
1716 | \internal | 1727 | \internal |
1717 | User initiated quit. Makes the window 'Go Away'. If preloaded this means | 1728 | User initiated quit. Makes the window 'Go Away'. If preloaded this means |
1718 | hiding the window. If not it means quitting the application. | 1729 | hiding the window. If not it means quitting the application. |
1719 | As this is user initiated we don't need to check state. | 1730 | As this is user initiated we don't need to check state. |
1720 | */ | 1731 | */ |
1721 | void QPEApplication::hideOrQuit() | 1732 | void QPEApplication::hideOrQuit() |
1722 | { | 1733 | { |
1723 | processEvents(); | 1734 | processEvents(); |
1724 | 1735 | ||
1725 | // If we are a preloaded application we don't actually quit, so emit | 1736 | // If we are a preloaded application we don't actually quit, so emit |
1726 | // a System message indicating we're quasi-closing. | 1737 | // a System message indicating we're quasi-closing. |
1727 | if ( d->preloaded && d->qpe_main_widget ) | 1738 | if ( d->preloaded && d->qpe_main_widget ) |
1728 | #ifndef QT_NO_COP | 1739 | #ifndef QT_NO_COP |
1729 | 1740 | ||
1730 | { | 1741 | { |
1731 | QCopEnvelope e("QPE/System", "fastAppHiding(QString)" ); | 1742 | QCopEnvelope e("QPE/System", "fastAppHiding(QString)" ); |
1732 | e << d->appName; | 1743 | e << d->appName; |
1733 | d->qpe_main_widget->hide(); | 1744 | d->qpe_main_widget->hide(); |
1734 | } | 1745 | } |
1735 | #endif | 1746 | #endif |
1736 | else | 1747 | else |
1737 | quit(); | 1748 | quit(); |
1738 | } | 1749 | } |
1739 | 1750 | ||
1740 | 1751 | ||
1741 | #if defined(QT_QWS_IPAQ) || defined(QT_QWS_SHARP) | 1752 | #if defined(QT_QWS_IPAQ) || defined(QT_QWS_SHARP) |
1742 | 1753 | ||
1743 | // The libraries with the skiff package (and possibly others) have | 1754 | // The libraries with the skiff package (and possibly others) have |
1744 | // completely useless implementations of builtin new and delete that | 1755 | // completely useless implementations of builtin new and delete that |
1745 | // use about 50% of your CPU. Here we revert to the simple libc | 1756 | // use about 50% of your CPU. Here we revert to the simple libc |
1746 | // functions. | 1757 | // functions. |
1747 | 1758 | ||
1748 | void* operator new[]( size_t size ) | 1759 | void* operator new[]( size_t size ) |
1749 | { | 1760 | { |
1750 | return malloc( size ); | 1761 | return malloc( size ); |
1751 | } | 1762 | } |
1752 | 1763 | ||
1753 | void* operator new( size_t size ) | 1764 | void* operator new( size_t size ) |
1754 | { | 1765 | { |
diff --git a/library/qpeapplication.h b/library/qpeapplication.h index 86affa6..f712077 100644 --- a/library/qpeapplication.h +++ b/library/qpeapplication.h | |||
@@ -1,158 +1,160 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #ifndef __QPE_APPLICATION_H__ | 20 | #ifndef __QPE_APPLICATION_H__ |
21 | #define __QPE_APPLICATION_H__ | 21 | #define __QPE_APPLICATION_H__ |
22 | 22 | ||
23 | 23 | ||
24 | #include <qapplication.h> | 24 | #include <qapplication.h> |
25 | #include <qdialog.h> | 25 | #include <qdialog.h> |
26 | #if defined(_WS_QWS_) && !defined(Q_WS_QWS) | 26 | #if defined(_WS_QWS_) && !defined(Q_WS_QWS) |
27 | #define Q_WS_QWS | 27 | #define Q_WS_QWS |
28 | #endif | 28 | #endif |
29 | #include "qpedecoration_qws.h" | 29 | #include "qpedecoration_qws.h" |
30 | #include "timestring.h" | 30 | #include "timestring.h" |
31 | 31 | ||
32 | class QCopChannel; | 32 | class QCopChannel; |
33 | class QPEApplicationData; | 33 | class QPEApplicationData; |
34 | class QWSEvent; | 34 | class QWSEvent; |
35 | class QWSKeyEvent; | 35 | class QWSKeyEvent; |
36 | 36 | ||
37 | |||
37 | class QPEApplication : public QApplication | 38 | class QPEApplication : public QApplication |
38 | { | 39 | { |
39 | Q_OBJECT | 40 | Q_OBJECT |
40 | public: | 41 | public: |
41 | QPEApplication( int& argc, char **argv, Type=GuiClient ); | 42 | QPEApplication( int& argc, char **argv, Type=GuiClient ); |
42 | ~QPEApplication(); | 43 | ~QPEApplication(); |
43 | 44 | ||
44 | static QString qpeDir(); | 45 | static QString qpeDir(); |
45 | static QString documentDir(); | 46 | static QString documentDir(); |
46 | void applyStyle(); | 47 | void applyStyle(); |
47 | static int defaultRotation(); | 48 | static int defaultRotation(); |
48 | static void setDefaultRotation(int r); | 49 | static void setDefaultRotation(int r); |
49 | static void grabKeyboard(); | 50 | static void grabKeyboard(); |
50 | static void ungrabKeyboard(); | 51 | static void ungrabKeyboard(); |
51 | 52 | ||
52 | enum StylusMode { | 53 | enum StylusMode { |
53 | LeftOnly, | 54 | LeftOnly, |
54 | RightOnHold | 55 | RightOnHold |
55 | // RightOnHoldLeftDelayed, etc. | 56 | // RightOnHoldLeftDelayed, etc. |
56 | }; | 57 | }; |
57 | static void setStylusOperation( QWidget*, StylusMode ); | 58 | static void setStylusOperation( QWidget*, StylusMode ); |
58 | static StylusMode stylusOperation( QWidget* ); | 59 | static StylusMode stylusOperation( QWidget* ); |
59 | 60 | ||
60 | enum InputMethodHint { | 61 | enum InputMethodHint { |
61 | Normal, | 62 | Normal, |
62 | AlwaysOff, | 63 | AlwaysOff, |
63 | AlwaysOn | 64 | AlwaysOn |
64 | }; | 65 | }; |
65 | 66 | ||
66 | enum screenSaverHint { | 67 | enum screenSaverHint { |
67 | Disable = 0, | 68 | Disable = 0, |
68 | DisableLightOff = 1, | 69 | DisableLightOff = 1, |
69 | DisableSuspend = 2, | 70 | DisableSuspend = 2, |
70 | Enable = 100 | 71 | Enable = 100 |
71 | }; | 72 | }; |
72 | 73 | ||
73 | static void setInputMethodHint( QWidget *, InputMethodHint ); | 74 | static void setInputMethodHint( QWidget *, InputMethodHint ); |
74 | static InputMethodHint inputMethodHint( QWidget * ); | 75 | static InputMethodHint inputMethodHint( QWidget * ); |
75 | 76 | ||
76 | void showMainWidget( QWidget*, bool nomax=FALSE ); | 77 | void showMainWidget( QWidget*, bool nomax=FALSE ); |
77 | void showMainDocumentWidget( QWidget*, bool nomax=FALSE ); | 78 | void showMainDocumentWidget( QWidget*, bool nomax=FALSE ); |
78 | static void showDialog( QDialog*, bool nomax=FALSE ); | 79 | static void showDialog( QDialog*, bool nomax=FALSE ); |
79 | static int execDialog( QDialog*, bool nomax=FALSE ); | 80 | static int execDialog( QDialog*, bool nomax=FALSE ); |
80 | 81 | ||
81 | static void setKeepRunning(); | 82 | static void setKeepRunning(); |
82 | bool keepRunning() const; | 83 | bool keepRunning() const; |
83 | 84 | ||
84 | bool keyboardGrabbed() const; | 85 | bool keyboardGrabbed() const; |
86 | QString keyboardGrabbedBy ( ) const; | ||
85 | 87 | ||
86 | int exec(); | 88 | int exec(); |
87 | 89 | ||
88 | signals: | 90 | signals: |
89 | void clientMoused(); | 91 | void clientMoused(); |
90 | void timeChanged(); | 92 | void timeChanged(); |
91 | void clockChanged( bool pm ); | 93 | void clockChanged( bool pm ); |
92 | void micChanged( bool muted ); | 94 | void micChanged( bool muted ); |
93 | void volumeChanged( bool muted ); | 95 | void volumeChanged( bool muted ); |
94 | void appMessage( const QCString& msg, const QByteArray& data); | 96 | void appMessage( const QCString& msg, const QByteArray& data); |
95 | void weekChanged( bool startOnMonday ); | 97 | void weekChanged( bool startOnMonday ); |
96 | void dateFormatChanged( DateFormat ); | 98 | void dateFormatChanged( DateFormat ); |
97 | void flush(); | 99 | void flush(); |
98 | void reload(); | 100 | void reload(); |
99 | 101 | ||
100 | private slots: | 102 | private slots: |
101 | void systemMessage( const QCString &msg, const QByteArray &data ); | 103 | void systemMessage( const QCString &msg, const QByteArray &data ); |
102 | void pidMessage( const QCString &msg, const QByteArray &data ); | 104 | void pidMessage( const QCString &msg, const QByteArray &data ); |
103 | void removeSenderFromStylusDict(); | 105 | void removeSenderFromStylusDict(); |
104 | void hideOrQuit(); | 106 | void hideOrQuit(); |
105 | 107 | ||
106 | protected: | 108 | protected: |
107 | bool qwsEventFilter( QWSEvent * ); | 109 | bool qwsEventFilter( QWSEvent * ); |
108 | void internalSetStyle( const QString &style ); | 110 | void internalSetStyle( const QString &style ); |
109 | void prepareForTermination(bool willrestart); | 111 | void prepareForTermination(bool willrestart); |
110 | virtual void restart(); | 112 | virtual void restart(); |
111 | virtual void shutdown(); | 113 | virtual void shutdown(); |
112 | bool eventFilter( QObject *, QEvent * ); | 114 | bool eventFilter( QObject *, QEvent * ); |
113 | void timerEvent( QTimerEvent * ); | 115 | void timerEvent( QTimerEvent * ); |
114 | bool raiseAppropriateWindow(); | 116 | bool raiseAppropriateWindow(); |
115 | virtual void tryQuit(); | 117 | virtual void tryQuit(); |
116 | 118 | ||
117 | virtual void polish ( QWidget * ); // this is actually implemented in qt_override.cpp (!) | 119 | virtual void polish ( QWidget * ); // this is actually implemented in qt_override.cpp (!) |
118 | 120 | ||
119 | private: | 121 | private: |
120 | void mapToDefaultAction( QWSKeyEvent *ke, int defKey ); | 122 | void mapToDefaultAction( QWSKeyEvent *ke, int defKey ); |
121 | 123 | ||
122 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 124 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
123 | QCopChannel *sysChannel; | 125 | QCopChannel *sysChannel; |
124 | QCopChannel *pidChannel; | 126 | QCopChannel *pidChannel; |
125 | #endif | 127 | #endif |
126 | QPEApplicationData *d; | 128 | QPEApplicationData *d; |
127 | 129 | ||
128 | bool reserved_sh; | 130 | bool reserved_sh; |
129 | 131 | ||
130 | 132 | ||
131 | 133 | ||
132 | }; | 134 | }; |
133 | 135 | ||
134 | inline void QPEApplication::showDialog( QDialog* d, bool nomax ) | 136 | inline void QPEApplication::showDialog( QDialog* d, bool nomax ) |
135 | { | 137 | { |
136 | QSize sh = d->sizeHint(); | 138 | QSize sh = d->sizeHint(); |
137 | int w = QMAX(sh.width(),d->width()); | 139 | int w = QMAX(sh.width(),d->width()); |
138 | int h = QMAX(sh.height(),d->height()); | 140 | int h = QMAX(sh.height(),d->height()); |
139 | if ( !nomax | 141 | if ( !nomax |
140 | && ( w > qApp->desktop()->width()*3/4 | 142 | && ( w > qApp->desktop()->width()*3/4 |
141 | || h > qApp->desktop()->height()*3/4 ) ) | 143 | || h > qApp->desktop()->height()*3/4 ) ) |
142 | { | 144 | { |
143 | d->showMaximized(); | 145 | d->showMaximized(); |
144 | } else { | 146 | } else { |
145 | d->resize(w,h); | 147 | d->resize(w,h); |
146 | d->show(); | 148 | d->show(); |
147 | } | 149 | } |
148 | } | 150 | } |
149 | 151 | ||
150 | inline int QPEApplication::execDialog( QDialog* d, bool nomax ) | 152 | inline int QPEApplication::execDialog( QDialog* d, bool nomax ) |
151 | { | 153 | { |
152 | showDialog(d,nomax); | 154 | showDialog(d,nomax); |
153 | return d->exec(); | 155 | return d->exec(); |
154 | } | 156 | } |
155 | 157 | ||
156 | 158 | ||
157 | #endif | 159 | #endif |
158 | 160 | ||