-rw-r--r-- | library/qpeapplication.cpp | 162 | ||||
-rw-r--r-- | library/qpeapplication.h | 3 |
2 files changed, 75 insertions, 90 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp index bf353d4..86aa53d 100644 --- a/library/qpeapplication.cpp +++ b/library/qpeapplication.cpp | |||
@@ -5,278 +5,278 @@ | |||
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 | #define QTOPIA_INTERNAL_LANGLIST | 20 | #define QTOPIA_INTERNAL_LANGLIST |
21 | #include <stdlib.h> | 21 | #include <stdlib.h> |
22 | #include <unistd.h> | 22 | #include <unistd.h> |
23 | #include <linux/limits.h> // needed for some toolchains (PATH_MAX) | 23 | #include <linux/limits.h> // needed for some toolchains (PATH_MAX) |
24 | #include <qfile.h> | 24 | #include <qfile.h> |
25 | #ifdef Q_WS_QWS | 25 | #ifdef Q_WS_QWS |
26 | #ifndef QT_NO_COP | 26 | #ifndef QT_NO_COP |
27 | #if QT_VERSION <= 231 | 27 | #if QT_VERSION <= 231 |
28 | #define private public | 28 | #define private public |
29 | #define sendLocally processEvent | 29 | #define sendLocally processEvent |
30 | #include "qcopenvelope_qws.h" | 30 | #include "qcopenvelope_qws.h" |
31 | #undef private | 31 | #undef private |
32 | #else | 32 | #else |
33 | #include "qcopenvelope_qws.h" | 33 | #include "qcopenvelope_qws.h" |
34 | #endif | 34 | #endif |
35 | #endif | 35 | #endif |
36 | #include <qwindowsystem_qws.h> | 36 | #include <qwindowsystem_qws.h> |
37 | #endif | 37 | #endif |
38 | #include <qtextstream.h> | 38 | #include <qtextstream.h> |
39 | #include <qpalette.h> | 39 | #include <qpalette.h> |
40 | #include <qbuffer.h> | 40 | #include <qbuffer.h> |
41 | #include <qptrdict.h> | 41 | #include <qptrdict.h> |
42 | #include <qregexp.h> | 42 | #include <qregexp.h> |
43 | #include <qdir.h> | 43 | #include <qdir.h> |
44 | #include <qlabel.h> | 44 | #include <qlabel.h> |
45 | #include <qdialog.h> | 45 | #include <qdialog.h> |
46 | #include <qdragobject.h> | 46 | #include <qdragobject.h> |
47 | #include <qtextcodec.h> | 47 | #include <qtextcodec.h> |
48 | #include <qevent.h> | 48 | #include <qevent.h> |
49 | #include <qtooltip.h> | 49 | #include <qtooltip.h> |
50 | #include <qsignal.h> | 50 | #include <qsignal.h> |
51 | #include <qmainwindow.h> | 51 | #include <qmainwindow.h> |
52 | #include <qwidgetlist.h> | 52 | #include <qwidgetlist.h> |
53 | 53 | ||
54 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 54 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
55 | #define QTOPIA_INTERNAL_INITAPP | 55 | #define QTOPIA_INTERNAL_INITAPP |
56 | #include "qpeapplication.h" | 56 | #include "qpeapplication.h" |
57 | #include "qpestyle.h" | 57 | #include "qpestyle.h" |
58 | #include "styleinterface.h" | 58 | #include "styleinterface.h" |
59 | #if QT_VERSION >= 300 | 59 | #if QT_VERSION >= 300 |
60 | #include <qstylefactory.h> | 60 | #include <qstylefactory.h> |
61 | #else | 61 | #else |
62 | #include <qplatinumstyle.h> | 62 | #include <qplatinumstyle.h> |
63 | #include <qwindowsstyle.h> | 63 | #include <qwindowsstyle.h> |
64 | #include <qmotifstyle.h> | 64 | #include <qmotifstyle.h> |
65 | #include <qmotifplusstyle.h> | 65 | #include <qmotifplusstyle.h> |
66 | #include "lightstyle.h" | 66 | #include "lightstyle.h" |
67 | 67 | ||
68 | #include <qpe/qlibrary.h> | 68 | #include <qpe/qlibrary.h> |
69 | #endif | 69 | #endif |
70 | #include "global.h" | 70 | #include "global.h" |
71 | #include "resource.h" | 71 | #include "resource.h" |
72 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) | 72 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) |
73 | #include "qutfcodec.h" | 73 | #include "qutfcodec.h" |
74 | #endif | 74 | #endif |
75 | #include "config.h" | 75 | #include "config.h" |
76 | #include "network.h" | 76 | #include "network.h" |
77 | #ifdef QWS | 77 | #ifdef QWS |
78 | #include "fontmanager.h" | 78 | #include "fontmanager.h" |
79 | #endif | 79 | #endif |
80 | 80 | ||
81 | #include "alarmserver.h" | 81 | #include "alarmserver.h" |
82 | #include "applnk.h" | 82 | #include "applnk.h" |
83 | #include "qpemenubar.h" | 83 | #include "qpemenubar.h" |
84 | #include "textcodecinterface.h" | 84 | #include "textcodecinterface.h" |
85 | #include "imagecodecinterface.h" | 85 | #include "imagecodecinterface.h" |
86 | 86 | ||
87 | #include <unistd.h> | 87 | #include <unistd.h> |
88 | #include <sys/file.h> | 88 | #include <sys/file.h> |
89 | #include <sys/ioctl.h> | 89 | #include <sys/ioctl.h> |
90 | #include <sys/soundcard.h> | 90 | #include <sys/soundcard.h> |
91 | 91 | ||
92 | #include "qt_override_p.h" | 92 | #include "qt_override_p.h" |
93 | 93 | ||
94 | 94 | ||
95 | class QPEApplicationData | 95 | class QPEApplicationData |
96 | { | 96 | { |
97 | public: | 97 | public: |
98 | QPEApplicationData ( ) | 98 | QPEApplicationData ( ) |
99 | : presstimer( 0 ), presswidget( 0 ), rightpressed( false ), kbgrabbed( false ), | 99 | : presstimer( 0 ), presswidget( 0 ), rightpressed( false ), kbgrabbed( false ), |
100 | notbusysent( false ), preloaded( false ), forceshow( false ), nomaximize( false ), | 100 | notbusysent( false ), preloaded( false ), forceshow( false ), nomaximize( false ), |
101 | keep_running( true ), qpe_main_widget( 0 ) | 101 | keep_running( true ), qpe_main_widget( 0 ) |
102 | 102 | ||
103 | { | 103 | { |
104 | qcopq.setAutoDelete( TRUE ); | 104 | qcopq.setAutoDelete( TRUE ); |
105 | } | 105 | } |
106 | 106 | ||
107 | int presstimer; | 107 | int presstimer; |
108 | QWidget* presswidget; | 108 | QWidget* presswidget; |
109 | QPoint presspos; | 109 | QPoint presspos; |
110 | 110 | ||
111 | bool rightpressed : 1; | 111 | bool rightpressed : 1; |
112 | bool kbgrabbed : 1; | 112 | bool kbgrabbed : 1; |
113 | bool notbusysent : 1; | 113 | bool notbusysent : 1; |
114 | bool preloaded : 1; | 114 | bool preloaded : 1; |
115 | bool forceshow : 1; | 115 | bool forceshow : 1; |
116 | bool nomaximize : 1; | 116 | bool nomaximize : 1; |
117 | bool keep_running : 1; | 117 | bool keep_running : 1; |
118 | 118 | ||
119 | QStringList langs; | 119 | QStringList langs; |
120 | QString appName; | 120 | QString appName; |
121 | struct QCopRec | 121 | struct QCopRec |
122 | { | 122 | { |
123 | QCopRec( const QCString &ch, const QCString &msg, | 123 | QCopRec( const QCString &ch, const QCString &msg, |
124 | const QByteArray &d ) : | 124 | const QByteArray &d ) : |
125 | channel( ch ), message( msg ), data( d ) | 125 | channel( ch ), message( msg ), data( d ) |
126 | { } | 126 | { } |
127 | 127 | ||
128 | QCString channel; | 128 | QCString channel; |
129 | QCString message; | 129 | QCString message; |
130 | QByteArray data; | 130 | QByteArray data; |
131 | }; | 131 | }; |
132 | QWidget* qpe_main_widget; | 132 | QWidget* qpe_main_widget; |
133 | QGuardedPtr<QWidget> lastWidget; | 133 | QGuardedPtr<QWidget> lastraised; |
134 | QList<QCopRec> qcopq; | 134 | QList<QCopRec> qcopq; |
135 | QString styleName; | 135 | QString styleName; |
136 | QString decorationName; | 136 | QString decorationName; |
137 | 137 | ||
138 | void enqueueQCop( const QCString &ch, const QCString &msg, | 138 | void enqueueQCop( const QCString &ch, const QCString &msg, |
139 | const QByteArray &data ) | 139 | const QByteArray &data ) |
140 | { | 140 | { |
141 | qcopq.append( new QCopRec( ch, msg, data ) ); | 141 | qcopq.append( new QCopRec( ch, msg, data ) ); |
142 | } | 142 | } |
143 | void sendQCopQ() | 143 | void sendQCopQ() |
144 | { | 144 | { |
145 | QCopRec * r; | 145 | QCopRec * r; |
146 | #ifndef QT_NO_COP | 146 | #ifndef QT_NO_COP |
147 | 147 | ||
148 | for ( QListIterator<QCopRec> it( qcopq ); ( r = it.current() ); ++it ) | 148 | for ( QListIterator<QCopRec> it( qcopq ); ( r = it.current() ); ++it ) |
149 | QCopChannel::sendLocally( r->channel, r->message, r->data ); | 149 | QCopChannel::sendLocally( r->channel, r->message, r->data ); |
150 | #endif | 150 | #endif |
151 | 151 | ||
152 | qcopq.clear(); | 152 | qcopq.clear(); |
153 | } | 153 | } |
154 | static void show_mx(QWidget* mw, bool nomaximize) | 154 | static void show_mx(QWidget* mw, bool nomaximize, const QString & = QString::null ) |
155 | { | 155 | { |
156 | 156 | ||
157 | // ugly hack, remove that later after finding a sane solution | 157 | // ugly hack, remove that later after finding a sane solution |
158 | // Addendum: Only Sharp currently has models with high resolution but (physically) small displays, | 158 | // Addendum: Only Sharp currently has models with high resolution but (physically) small displays, |
159 | // so this is only useful if QT_QWS_SIMPAD is NOT defined. E.g. SIMpad has 800x600 but has | 159 | // so this is only useful if QT_QWS_SIMPAD is NOT defined. E.g. SIMpad has 800x600 but has |
160 | // a (physically) large enough display to use the small icons | 160 | // a (physically) large enough display to use the small icons |
161 | #ifndef QT_QWS_SIMPAD | 161 | #ifndef QT_QWS_SIMPAD |
162 | if ( QPEApplication::desktop() ->width() >= 600 && ( mw->inherits("QMainWindow") || mw->isA("QMainWindow") ) ) { | 162 | if ( QPEApplication::desktop() ->width() >= 600 && ( mw->inherits("QMainWindow") || mw->isA("QMainWindow") ) ) { |
163 | ( ( QMainWindow* ) mw )->setUsesBigPixmaps( true ); | 163 | ( ( QMainWindow* ) mw )->setUsesBigPixmaps( true ); |
164 | } | 164 | } |
165 | #endif | 165 | #endif |
166 | 166 | ||
167 | if ( mw->layout() && mw->inherits("QDialog") ) { | 167 | if ( mw->layout() && mw->inherits("QDialog") ) { |
168 | QPEApplication::showDialog((QDialog*)mw, nomaximize); | 168 | QPEApplication::showDialog((QDialog*)mw, nomaximize); |
169 | } | 169 | } |
170 | else { | 170 | else { |
171 | #ifdef Q_WS_QWS | 171 | #ifdef Q_WS_QWS |
172 | if ( !nomaximize ) | 172 | if ( !nomaximize ) |
173 | mw->showMaximized(); | 173 | mw->showMaximized(); |
174 | else | 174 | else |
175 | #endif | 175 | #endif |
176 | 176 | ||
177 | mw->show(); | 177 | mw->show(); |
178 | } | 178 | } |
179 | } | 179 | } |
180 | static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) | 180 | static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) |
181 | { | 181 | { |
182 | /* | 182 | /* |
183 | // This works but disable it for now until it is safe to apply | 183 | // This works but disable it for now until it is safe to apply |
184 | // What is does is scan the .desktop files of all the apps for | 184 | // What is does is scan the .desktop files of all the apps for |
185 | // the applnk that has the corresponding argv[0] as this program | 185 | // the applnk that has the corresponding argv[0] as this program |
186 | // then it uses the name stored in the .desktop file as the caption | 186 | // then it uses the name stored in the .desktop file as the caption |
187 | // for the main widget. This saves duplicating translations for | 187 | // for the main widget. This saves duplicating translations for |
188 | // the app name in the program and in the .desktop files. | 188 | // the app name in the program and in the .desktop files. |
189 | 189 | ||
190 | AppLnkSet apps( appsPath ); | 190 | AppLnkSet apps( appsPath ); |
191 | 191 | ||
192 | QList<AppLnk> appsList = apps.children(); | 192 | QList<AppLnk> appsList = apps.children(); |
193 | for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) { | 193 | for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) { |
194 | if ( (*it)->exec() == appName ) { | 194 | if ( (*it)->exec() == appName ) { |
195 | mw->setCaption( (*it)->name() ); | 195 | mw->setCaption( (*it)->name() ); |
196 | return TRUE; | 196 | return TRUE; |
197 | } | 197 | } |
198 | } | 198 | } |
199 | */ | 199 | */ |
200 | return FALSE; | 200 | return FALSE; |
201 | } | 201 | } |
202 | 202 | ||
203 | 203 | ||
204 | void show(QWidget* mw, bool nomax) | 204 | void show(QWidget* mw, bool nomax) |
205 | { | 205 | { |
206 | setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" ); | 206 | setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" ); |
207 | nomaximize = nomax; | 207 | nomaximize = nomax; |
208 | qpe_main_widget = mw; | 208 | qpe_main_widget = mw; |
209 | #ifndef QT_NO_COP | 209 | #ifndef QT_NO_COP |
210 | 210 | ||
211 | sendQCopQ(); | 211 | sendQCopQ(); |
212 | #endif | 212 | #endif |
213 | 213 | ||
214 | if ( preloaded ) { | 214 | if ( preloaded ) { |
215 | if (forceshow) | 215 | if (forceshow) |
216 | show_mx(mw, nomax); | 216 | show_mx(mw, nomax); |
217 | } | 217 | } |
218 | else if ( keep_running ) { | 218 | else if ( keep_running ) { |
219 | show_mx(mw, nomax); | 219 | show_mx(mw, nomax); |
220 | } | 220 | } |
221 | } | 221 | } |
222 | 222 | ||
223 | void loadTextCodecs() | 223 | void loadTextCodecs() |
224 | { | 224 | { |
225 | QString path = QPEApplication::qpeDir() + "/plugins/textcodecs"; | 225 | QString path = QPEApplication::qpeDir() + "/plugins/textcodecs"; |
226 | QDir dir( path, "lib*.so" ); | 226 | QDir dir( path, "lib*.so" ); |
227 | QStringList list; | 227 | QStringList list; |
228 | if ( dir. exists ( )) | 228 | if ( dir. exists ( )) |
229 | list = dir.entryList(); | 229 | list = dir.entryList(); |
230 | QStringList::Iterator it; | 230 | QStringList::Iterator it; |
231 | for ( it = list.begin(); it != list.end(); ++it ) { | 231 | for ( it = list.begin(); it != list.end(); ++it ) { |
232 | TextCodecInterface *iface = 0; | 232 | TextCodecInterface *iface = 0; |
233 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 233 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
234 | if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { | 234 | if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { |
235 | QValueList<int> mibs = iface->mibEnums(); | 235 | QValueList<int> mibs = iface->mibEnums(); |
236 | for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) { | 236 | for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) { |
237 | (void)iface->createForMib(*i); | 237 | (void)iface->createForMib(*i); |
238 | // ### it exists now; need to remember if we can delete it | 238 | // ### it exists now; need to remember if we can delete it |
239 | } | 239 | } |
240 | } | 240 | } |
241 | else { | 241 | else { |
242 | lib->unload(); | 242 | lib->unload(); |
243 | delete lib; | 243 | delete lib; |
244 | } | 244 | } |
245 | } | 245 | } |
246 | } | 246 | } |
247 | 247 | ||
248 | void loadImageCodecs() | 248 | void loadImageCodecs() |
249 | { | 249 | { |
250 | QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs"; | 250 | QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs"; |
251 | QDir dir( path, "lib*.so" ); | 251 | QDir dir( path, "lib*.so" ); |
252 | QStringList list; | 252 | QStringList list; |
253 | if ( dir. exists ( )) | 253 | if ( dir. exists ( )) |
254 | list = dir.entryList(); | 254 | list = dir.entryList(); |
255 | QStringList::Iterator it; | 255 | QStringList::Iterator it; |
256 | for ( it = list.begin(); it != list.end(); ++it ) { | 256 | for ( it = list.begin(); it != list.end(); ++it ) { |
257 | ImageCodecInterface *iface = 0; | 257 | ImageCodecInterface *iface = 0; |
258 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 258 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
259 | if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { | 259 | if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { |
260 | QStringList formats = iface->keys(); | 260 | QStringList formats = iface->keys(); |
261 | for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) { | 261 | for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) { |
262 | (void)iface->installIOHandler(*i); | 262 | (void)iface->installIOHandler(*i); |
263 | // ### it exists now; need to remember if we can delete it | 263 | // ### it exists now; need to remember if we can delete it |
264 | } | 264 | } |
265 | } | 265 | } |
266 | else { | 266 | else { |
267 | lib->unload(); | 267 | lib->unload(); |
268 | delete lib; | 268 | delete lib; |
269 | } | 269 | } |
270 | } | 270 | } |
271 | } | 271 | } |
272 | }; | 272 | }; |
273 | 273 | ||
274 | class ResourceMimeFactory : public QMimeSourceFactory | 274 | class ResourceMimeFactory : public QMimeSourceFactory |
275 | { | 275 | { |
276 | public: | 276 | public: |
277 | ResourceMimeFactory() : resImage( 0 ) | 277 | ResourceMimeFactory() : resImage( 0 ) |
278 | { | 278 | { |
279 | setFilePath( Global::helpPath() ); | 279 | setFilePath( Global::helpPath() ); |
280 | setExtensionType( "html", "text/html;charset=UTF-8" ); | 280 | setExtensionType( "html", "text/html;charset=UTF-8" ); |
281 | } | 281 | } |
282 | ~ResourceMimeFactory() { | 282 | ~ResourceMimeFactory() { |
@@ -579,277 +579,280 @@ QPEApplication::QPEApplication( int & argc, char **argv, Type t ) | |||
579 | AppLnk::setBigIconSize( 28 ); | 579 | AppLnk::setBigIconSize( 28 ); |
580 | } | 580 | } |
581 | #ifndef QT_QWS_SIMPAD | 581 | #ifndef QT_QWS_SIMPAD |
582 | else if ( dw > 600 ) { | 582 | else if ( dw > 600 ) { |
583 | setFont( QFont( "vera", 16 ) ); | 583 | setFont( QFont( "vera", 16 ) ); |
584 | AppLnk::setSmallIconSize( 24 ); | 584 | AppLnk::setSmallIconSize( 24 ); |
585 | AppLnk::setBigIconSize( 48 ); | 585 | AppLnk::setBigIconSize( 48 ); |
586 | } | 586 | } |
587 | #endif | 587 | #endif |
588 | else if ( dw > 200 ) { | 588 | else if ( dw > 200 ) { |
589 | setFont( QFont( "vera", 10 ) ); | 589 | setFont( QFont( "vera", 10 ) ); |
590 | AppLnk::setSmallIconSize( 14 ); | 590 | AppLnk::setSmallIconSize( 14 ); |
591 | AppLnk::setBigIconSize( 32 ); | 591 | AppLnk::setBigIconSize( 32 ); |
592 | } | 592 | } |
593 | 593 | ||
594 | QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory ); | 594 | QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory ); |
595 | 595 | ||
596 | connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) ); | 596 | connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) ); |
597 | 597 | ||
598 | 598 | ||
599 | sysChannel = new QCopChannel( "QPE/System", this ); | 599 | sysChannel = new QCopChannel( "QPE/System", this ); |
600 | connect( sysChannel, SIGNAL( received( const QCString &, const QByteArray & ) ), | 600 | connect( sysChannel, SIGNAL( received( const QCString &, const QByteArray & ) ), |
601 | this, SLOT( systemMessage( const QCString &, const QByteArray & ) ) ); | 601 | this, SLOT( systemMessage( const QCString &, const QByteArray & ) ) ); |
602 | 602 | ||
603 | /* COde now in initapp */ | 603 | /* COde now in initapp */ |
604 | #if 0 | 604 | #if 0 |
605 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 605 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
606 | 606 | ||
607 | QString qcopfn( "/tmp/qcop-msg-" ); | 607 | QString qcopfn( "/tmp/qcop-msg-" ); |
608 | qcopfn += QString( argv[ 0 ] ); // append command name | 608 | qcopfn += QString( argv[ 0 ] ); // append command name |
609 | 609 | ||
610 | QFile f( qcopfn ); | 610 | QFile f( qcopfn ); |
611 | if ( f.open( IO_ReadOnly ) ) { | 611 | if ( f.open( IO_ReadOnly ) ) { |
612 | flock( f.handle(), LOCK_EX ); | 612 | flock( f.handle(), LOCK_EX ); |
613 | } | 613 | } |
614 | 614 | ||
615 | 615 | ||
616 | 616 | ||
617 | QCString channel = QCString( argv[ 0 ] ); | 617 | QCString channel = QCString( argv[ 0 ] ); |
618 | channel.replace( QRegExp( ".*/" ), "" ); | 618 | channel.replace( QRegExp( ".*/" ), "" ); |
619 | d->appName = channel; | 619 | d->appName = channel; |
620 | channel = "QPE/Application/" + channel; | 620 | channel = "QPE/Application/" + channel; |
621 | pidChannel = new QCopChannel( channel, this ); | 621 | pidChannel = new QCopChannel( channel, this ); |
622 | connect( pidChannel, SIGNAL( received( const QCString &, const QByteArray & ) ), | 622 | connect( pidChannel, SIGNAL( received( const QCString &, const QByteArray & ) ), |
623 | this, SLOT( pidMessage( const QCString &, const QByteArray & ) ) ); | 623 | this, SLOT( pidMessage( const QCString &, const QByteArray & ) ) ); |
624 | 624 | ||
625 | if ( f.isOpen() ) { | 625 | if ( f.isOpen() ) { |
626 | d->keep_running = FALSE; | 626 | d->keep_running = FALSE; |
627 | QDataStream ds( &f ); | 627 | QDataStream ds( &f ); |
628 | QCString channel, message; | 628 | QCString channel, message; |
629 | QByteArray data; | 629 | QByteArray data; |
630 | while ( !ds.atEnd() ) { | 630 | while ( !ds.atEnd() ) { |
631 | ds >> channel >> message >> data; | 631 | ds >> channel >> message >> data; |
632 | d->enqueueQCop( channel, message, data ); | 632 | d->enqueueQCop( channel, message, data ); |
633 | } | 633 | } |
634 | 634 | ||
635 | flock( f.handle(), LOCK_UN ); | 635 | flock( f.handle(), LOCK_UN ); |
636 | f.close(); | 636 | f.close(); |
637 | f.remove(); | 637 | f.remove(); |
638 | } | 638 | } |
639 | 639 | ||
640 | for ( int a = 0; a < argc; a++ ) { | 640 | for ( int a = 0; a < argc; a++ ) { |
641 | if ( qstrcmp( argv[ a ], "-preload" ) == 0 ) { | 641 | if ( qstrcmp( argv[ a ], "-preload" ) == 0 ) { |
642 | argv[ a ] = argv[ a + 1 ]; | 642 | argv[ a ] = argv[ a + 1 ]; |
643 | a++; | 643 | a++; |
644 | d->preloaded = TRUE; | 644 | d->preloaded = TRUE; |
645 | argc -= 1; | 645 | argc -= 1; |
646 | } | 646 | } |
647 | else if ( qstrcmp( argv[ a ], "-preload-show" ) == 0 ) { | 647 | else if ( qstrcmp( argv[ a ], "-preload-show" ) == 0 ) { |
648 | argv[ a ] = argv[ a + 1 ]; | 648 | argv[ a ] = argv[ a + 1 ]; |
649 | a++; | 649 | a++; |
650 | d->preloaded = TRUE; | 650 | d->preloaded = TRUE; |
651 | d->forceshow = TRUE; | 651 | d->forceshow = TRUE; |
652 | argc -= 1; | 652 | argc -= 1; |
653 | } | 653 | } |
654 | } | 654 | } |
655 | 655 | ||
656 | /* overide stored arguments */ | 656 | /* overide stored arguments */ |
657 | setArgs( argc, argv ); | 657 | setArgs( argc, argv ); |
658 | 658 | ||
659 | #endif | 659 | #endif |
660 | #else | 660 | #else |
661 | initApp( argc, argv ); | 661 | initApp( argc, argv ); |
662 | #endif | 662 | #endif |
663 | // qwsSetDecoration( new QPEDecoration() ); | 663 | // qwsSetDecoration( new QPEDecoration() ); |
664 | 664 | ||
665 | #ifndef QT_NO_TRANSLATION | 665 | #ifndef QT_NO_TRANSLATION |
666 | 666 | ||
667 | d->langs = Global::languageList(); | 667 | d->langs = Global::languageList(); |
668 | for ( QStringList::ConstIterator it = d->langs.begin(); it != d->langs.end(); ++it ) { | 668 | for ( QStringList::ConstIterator it = d->langs.begin(); it != d->langs.end(); ++it ) { |
669 | QString lang = *it; | 669 | QString lang = *it; |
670 | 670 | ||
671 | installTranslation( lang + "/libopie.qm"); | 671 | installTranslation( lang + "/libopie.qm"); |
672 | installTranslation( lang + "/libqpe.qm" ); | 672 | installTranslation( lang + "/libqpe.qm" ); |
673 | installTranslation( lang + "/" + d->appName + ".qm" ); | 673 | installTranslation( lang + "/" + d->appName + ".qm" ); |
674 | 674 | ||
675 | 675 | ||
676 | //###language/font hack; should look it up somewhere | 676 | //###language/font hack; should look it up somewhere |
677 | #ifdef QWS | 677 | #ifdef QWS |
678 | 678 | ||
679 | if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) { | 679 | if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) { |
680 | QFont fn = FontManager::unicodeFont( FontManager::Proportional ); | 680 | QFont fn = FontManager::unicodeFont( FontManager::Proportional ); |
681 | setFont( fn ); | 681 | setFont( fn ); |
682 | } | 682 | } |
683 | #endif | 683 | #endif |
684 | } | 684 | } |
685 | #endif | 685 | #endif |
686 | 686 | ||
687 | applyStyle(); | 687 | applyStyle(); |
688 | 688 | ||
689 | if ( type() == GuiServer ) { | 689 | if ( type() == GuiServer ) { |
690 | setVolume(); | 690 | setVolume(); |
691 | } | 691 | } |
692 | 692 | ||
693 | installEventFilter( this ); | 693 | installEventFilter( this ); |
694 | 694 | ||
695 | QPEMenuToolFocusManager::initialize(); | 695 | QPEMenuToolFocusManager::initialize(); |
696 | 696 | ||
697 | #ifdef QT_NO_QWS_CURSOR | 697 | #ifdef QT_NO_QWS_CURSOR |
698 | // if we have no cursor, probably don't want tooltips | 698 | // if we have no cursor, probably don't want tooltips |
699 | QToolTip::setEnabled( FALSE ); | 699 | QToolTip::setEnabled( FALSE ); |
700 | #endif | 700 | #endif |
701 | } | 701 | } |
702 | 702 | ||
703 | 703 | ||
704 | #ifdef QTOPIA_INTERNAL_INITAPP | 704 | #ifdef QTOPIA_INTERNAL_INITAPP |
705 | void QPEApplication::initApp( int argc, char **argv ) | 705 | void QPEApplication::initApp( int argc, char **argv ) |
706 | { | 706 | { |
707 | bool initial = pidChannel; // was set to 0 in the initializer | ||
707 | delete pidChannel; | 708 | delete pidChannel; |
708 | d->keep_running = TRUE; | 709 | d->keep_running = TRUE; |
709 | d->preloaded = FALSE; | 710 | d->preloaded = FALSE; |
710 | d->forceshow = FALSE; | 711 | d->forceshow = FALSE; |
711 | 712 | ||
712 | QCString channel = QCString(argv[0]); | 713 | QCString channel = QCString(argv[0]); |
713 | 714 | ||
714 | channel.replace(QRegExp(".*/"),""); | 715 | channel.replace(QRegExp(".*/"),""); |
715 | d->appName = channel; | 716 | d->appName = channel; |
716 | 717 | ||
717 | #if QT_VERSION > 235 | 718 | #if QT_VERSION > 235 |
718 | qt_fbdpy->setIdentity( channel ); // In Qt/E 2.3.6 | 719 | qt_fbdpy->setIdentity( channel ); // In Qt/E 2.3.6 |
719 | #endif | 720 | #endif |
720 | 721 | ||
721 | channel = "QPE/Application/" + channel; | 722 | channel = "QPE/Application/" + channel; |
722 | pidChannel = new QCopChannel( channel, this); | 723 | pidChannel = new QCopChannel( channel, this); |
723 | connect( pidChannel, SIGNAL(received(const QCString &, const QByteArray &)), | 724 | connect( pidChannel, SIGNAL(received(const QCString &, const QByteArray &)), |
724 | this, SLOT(pidMessage(const QCString &, const QByteArray &))); | 725 | this, SLOT(pidMessage(const QCString &, const QByteArray &))); |
725 | 726 | ||
726 | processQCopFile(); | 727 | if (!initial) { |
727 | d->keep_running = d->qcopq.isEmpty(); | 728 | processQCopFile(); |
729 | d->keep_running = d->qcopq.isEmpty(); | ||
730 | } | ||
728 | 731 | ||
729 | for (int a=0; a<argc; a++) { | 732 | for (int a=0; a<argc; a++) { |
730 | if ( qstrcmp(argv[a],"-preload")==0 ) { | 733 | if ( qstrcmp(argv[a],"-preload")==0 ) { |
731 | argv[a] = argv[a+1]; | 734 | argv[a] = argv[a+1]; |
732 | a++; | 735 | a++; |
733 | d->preloaded = TRUE; | 736 | d->preloaded = TRUE; |
734 | argc-=1; | 737 | argc-=1; |
735 | } else if ( qstrcmp(argv[a],"-preload-show")==0 ) { | 738 | } else if ( qstrcmp(argv[a],"-preload-show")==0 ) { |
736 | argv[a] = argv[a+1]; | 739 | argv[a] = argv[a+1]; |
737 | a++; | 740 | a++; |
738 | d->preloaded = TRUE; | 741 | d->preloaded = TRUE; |
739 | d->forceshow = TRUE; | 742 | d->forceshow = TRUE; |
740 | argc-=1; | 743 | argc-=1; |
741 | } | 744 | } |
742 | } | 745 | } |
743 | 746 | ||
744 | /* overide stored arguments */ | 747 | /* overide stored arguments */ |
745 | setArgs(argc, argv); | 748 | setArgs(argc, argv); |
746 | 749 | ||
747 | /* install translation here */ | 750 | /* install translation here */ |
748 | for ( QStringList::ConstIterator it = d->langs.begin(); it != d->langs.end(); ++it ) | 751 | for ( QStringList::ConstIterator it = d->langs.begin(); it != d->langs.end(); ++it ) |
749 | installTranslation( (*it) + "/" + d->appName + ".qm" ); | 752 | installTranslation( (*it) + "/" + d->appName + ".qm" ); |
750 | } | 753 | } |
751 | #endif | 754 | #endif |
752 | 755 | ||
753 | 756 | ||
754 | static QPtrDict<void>* inputMethodDict = 0; | 757 | static QPtrDict<void>* inputMethodDict = 0; |
755 | static void createInputMethodDict() | 758 | static void createInputMethodDict() |
756 | { | 759 | { |
757 | if ( !inputMethodDict ) | 760 | if ( !inputMethodDict ) |
758 | inputMethodDict = new QPtrDict<void>; | 761 | inputMethodDict = new QPtrDict<void>; |
759 | } | 762 | } |
760 | 763 | ||
761 | /*! | 764 | /*! |
762 | Returns the currently set hint to the system as to whether | 765 | Returns the currently set hint to the system as to whether |
763 | widget \a w has any use for text input methods. | 766 | widget \a w has any use for text input methods. |
764 | 767 | ||
765 | 768 | ||
766 | \sa setInputMethodHint() InputMethodHint | 769 | \sa setInputMethodHint() InputMethodHint |
767 | */ | 770 | */ |
768 | QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w ) | 771 | QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w ) |
769 | { | 772 | { |
770 | if ( inputMethodDict && w ) | 773 | if ( inputMethodDict && w ) |
771 | return ( InputMethodHint ) ( int ) inputMethodDict->find( w ); | 774 | return ( InputMethodHint ) ( int ) inputMethodDict->find( w ); |
772 | return Normal; | 775 | return Normal; |
773 | } | 776 | } |
774 | 777 | ||
775 | /*! | 778 | /*! |
776 | \enum QPEApplication::InputMethodHint | 779 | \enum QPEApplication::InputMethodHint |
777 | 780 | ||
778 | \value Normal the application sometimes needs text input (the default). | 781 | \value Normal the application sometimes needs text input (the default). |
779 | \value AlwaysOff the application never needs text input. | 782 | \value AlwaysOff the application never needs text input. |
780 | \value AlwaysOn the application always needs text input. | 783 | \value AlwaysOn the application always needs text input. |
781 | */ | 784 | */ |
782 | 785 | ||
783 | /*! | 786 | /*! |
784 | Hints to the system that widget \a w has use for text input methods | 787 | Hints to the system that widget \a w has use for text input methods |
785 | as specified by \a mode. | 788 | as specified by \a mode. |
786 | 789 | ||
787 | \sa inputMethodHint() InputMethodHint | 790 | \sa inputMethodHint() InputMethodHint |
788 | */ | 791 | */ |
789 | void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode ) | 792 | void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode ) |
790 | { | 793 | { |
791 | createInputMethodDict(); | 794 | createInputMethodDict(); |
792 | if ( mode == Normal ) { | 795 | if ( mode == Normal ) { |
793 | inputMethodDict->remove | 796 | inputMethodDict->remove |
794 | ( w ); | 797 | ( w ); |
795 | } | 798 | } |
796 | else { | 799 | else { |
797 | inputMethodDict->insert( w, ( void* ) mode ); | 800 | inputMethodDict->insert( w, ( void* ) mode ); |
798 | } | 801 | } |
799 | } | 802 | } |
800 | 803 | ||
801 | class HackDialog : public QDialog | 804 | class HackDialog : public QDialog |
802 | { | 805 | { |
803 | public: | 806 | public: |
804 | void acceptIt() | 807 | void acceptIt() |
805 | { | 808 | { |
806 | accept(); | 809 | accept(); |
807 | } | 810 | } |
808 | void rejectIt() | 811 | void rejectIt() |
809 | { | 812 | { |
810 | reject(); | 813 | reject(); |
811 | } | 814 | } |
812 | }; | 815 | }; |
813 | 816 | ||
814 | 817 | ||
815 | void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key ) | 818 | void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key ) |
816 | { | 819 | { |
817 | // specialised actions for certain widgets. May want to | 820 | // specialised actions for certain widgets. May want to |
818 | // add more stuff here. | 821 | // add more stuff here. |
819 | if ( activePopupWidget() && activePopupWidget() ->inherits( "QListBox" ) | 822 | if ( activePopupWidget() && activePopupWidget() ->inherits( "QListBox" ) |
820 | && activePopupWidget() ->parentWidget() | 823 | && activePopupWidget() ->parentWidget() |
821 | && activePopupWidget() ->parentWidget() ->inherits( "QComboBox" ) ) | 824 | && activePopupWidget() ->parentWidget() ->inherits( "QComboBox" ) ) |
822 | key = Qt::Key_Return; | 825 | key = Qt::Key_Return; |
823 | 826 | ||
824 | if ( activePopupWidget() && activePopupWidget() ->inherits( "QPopupMenu" ) ) | 827 | if ( activePopupWidget() && activePopupWidget() ->inherits( "QPopupMenu" ) ) |
825 | key = Qt::Key_Return; | 828 | key = Qt::Key_Return; |
826 | 829 | ||
827 | #ifdef QWS | 830 | #ifdef QWS |
828 | 831 | ||
829 | ke->simpleData.keycode = key; | 832 | ke->simpleData.keycode = key; |
830 | #endif | 833 | #endif |
831 | } | 834 | } |
832 | 835 | ||
833 | class HackWidget : public QWidget | 836 | class HackWidget : public QWidget |
834 | { | 837 | { |
835 | public: | 838 | public: |
836 | bool needsOk() | 839 | bool needsOk() |
837 | { | 840 | { |
838 | return ( getWState() & WState_Reserved1 ); | 841 | return ( getWState() & WState_Reserved1 ); |
839 | } | 842 | } |
840 | }; | 843 | }; |
841 | 844 | ||
842 | /*! | 845 | /*! |
843 | \internal | 846 | \internal |
844 | */ | 847 | */ |
845 | 848 | ||
846 | #ifdef QWS | 849 | #ifdef QWS |
847 | bool QPEApplication::qwsEventFilter( QWSEvent * e ) | 850 | bool QPEApplication::qwsEventFilter( QWSEvent * e ) |
848 | { | 851 | { |
849 | if ( !d->notbusysent && e->type == QWSEvent::Focus ) { | 852 | if ( !d->notbusysent && e->type == QWSEvent::Focus ) { |
850 | if ( qApp->type() != QApplication::GuiServer ) { | 853 | if ( qApp->type() != QApplication::GuiServer ) { |
851 | QCopEnvelope e( "QPE/System", "notBusy(QString)" ); | 854 | QCopEnvelope e( "QPE/System", "notBusy(QString)" ); |
852 | e << d->appName; | 855 | e << d->appName; |
853 | } | 856 | } |
854 | d->notbusysent = TRUE; | 857 | d->notbusysent = TRUE; |
855 | } | 858 | } |
@@ -1237,347 +1240,332 @@ void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data | |||
1237 | } | 1240 | } |
1238 | else if ( msg == "quit()" ) { | 1241 | else if ( msg == "quit()" ) { |
1239 | if ( type() != GuiServer ) | 1242 | if ( type() != GuiServer ) |
1240 | tryQuit(); | 1243 | tryQuit(); |
1241 | } | 1244 | } |
1242 | else if ( msg == "forceQuit()" ) { | 1245 | else if ( msg == "forceQuit()" ) { |
1243 | if ( type() != GuiServer ) | 1246 | if ( type() != GuiServer ) |
1244 | quit(); | 1247 | quit(); |
1245 | } | 1248 | } |
1246 | else if ( msg == "restart()" ) { | 1249 | else if ( msg == "restart()" ) { |
1247 | if ( type() == GuiServer ) | 1250 | if ( type() == GuiServer ) |
1248 | restart(); | 1251 | restart(); |
1249 | } | 1252 | } |
1250 | else if ( msg == "language(QString)" ) { | 1253 | else if ( msg == "language(QString)" ) { |
1251 | if ( type() == GuiServer ) { | 1254 | if ( type() == GuiServer ) { |
1252 | QString l; | 1255 | QString l; |
1253 | stream >> l; | 1256 | stream >> l; |
1254 | QString cl = getenv( "LANG" ); | 1257 | QString cl = getenv( "LANG" ); |
1255 | if ( cl != l ) { | 1258 | if ( cl != l ) { |
1256 | if ( l.isNull() ) | 1259 | if ( l.isNull() ) |
1257 | unsetenv( "LANG" ); | 1260 | unsetenv( "LANG" ); |
1258 | else | 1261 | else |
1259 | setenv( "LANG", l.latin1(), 1 ); | 1262 | setenv( "LANG", l.latin1(), 1 ); |
1260 | restart(); | 1263 | restart(); |
1261 | } | 1264 | } |
1262 | } | 1265 | } |
1263 | } | 1266 | } |
1264 | else if ( msg == "timeChange(QString)" ) { | 1267 | else if ( msg == "timeChange(QString)" ) { |
1265 | QString t; | 1268 | QString t; |
1266 | stream >> t; | 1269 | stream >> t; |
1267 | if ( t.isNull() ) | 1270 | if ( t.isNull() ) |
1268 | unsetenv( "TZ" ); | 1271 | unsetenv( "TZ" ); |
1269 | else | 1272 | else |
1270 | setenv( "TZ", t.latin1(), 1 ); | 1273 | setenv( "TZ", t.latin1(), 1 ); |
1271 | // emit the signal so everyone else knows... | 1274 | // emit the signal so everyone else knows... |
1272 | emit timeChanged(); | 1275 | emit timeChanged(); |
1273 | } | 1276 | } |
1274 | else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) { | 1277 | else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) { |
1275 | if ( type() == GuiServer ) { | 1278 | if ( type() == GuiServer ) { |
1276 | QDateTime when; | 1279 | QDateTime when; |
1277 | QCString channel, message; | 1280 | QCString channel, message; |
1278 | int data; | 1281 | int data; |
1279 | stream >> when >> channel >> message >> data; | 1282 | stream >> when >> channel >> message >> data; |
1280 | AlarmServer::addAlarm( when, channel, message, data ); | 1283 | AlarmServer::addAlarm( when, channel, message, data ); |
1281 | } | 1284 | } |
1282 | } | 1285 | } |
1283 | else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) { | 1286 | else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) { |
1284 | if ( type() == GuiServer ) { | 1287 | if ( type() == GuiServer ) { |
1285 | QDateTime when; | 1288 | QDateTime when; |
1286 | QCString channel, message; | 1289 | QCString channel, message; |
1287 | int data; | 1290 | int data; |
1288 | stream >> when >> channel >> message >> data; | 1291 | stream >> when >> channel >> message >> data; |
1289 | AlarmServer::deleteAlarm( when, channel, message, data ); | 1292 | AlarmServer::deleteAlarm( when, channel, message, data ); |
1290 | } | 1293 | } |
1291 | } | 1294 | } |
1292 | else if ( msg == "clockChange(bool)" ) { | 1295 | else if ( msg == "clockChange(bool)" ) { |
1293 | int tmp; | 1296 | int tmp; |
1294 | stream >> tmp; | 1297 | stream >> tmp; |
1295 | emit clockChanged( tmp ); | 1298 | emit clockChanged( tmp ); |
1296 | } | 1299 | } |
1297 | else if ( msg == "weekChange(bool)" ) { | 1300 | else if ( msg == "weekChange(bool)" ) { |
1298 | int tmp; | 1301 | int tmp; |
1299 | stream >> tmp; | 1302 | stream >> tmp; |
1300 | emit weekChanged( tmp ); | 1303 | emit weekChanged( tmp ); |
1301 | } | 1304 | } |
1302 | else if ( msg == "setDateFormat(DateFormat)" ) { | 1305 | else if ( msg == "setDateFormat(DateFormat)" ) { |
1303 | DateFormat tmp; | 1306 | DateFormat tmp; |
1304 | stream >> tmp; | 1307 | stream >> tmp; |
1305 | emit dateFormatChanged( tmp ); | 1308 | emit dateFormatChanged( tmp ); |
1306 | } | 1309 | } |
1307 | else if ( msg == "setVolume(int,int)" ) { | 1310 | else if ( msg == "setVolume(int,int)" ) { |
1308 | int t, v; | 1311 | int t, v; |
1309 | stream >> t >> v; | 1312 | stream >> t >> v; |
1310 | setVolume( t, v ); | 1313 | setVolume( t, v ); |
1311 | emit volumeChanged( muted ); | 1314 | emit volumeChanged( muted ); |
1312 | } | 1315 | } |
1313 | else if ( msg == "volumeChange(bool)" ) { | 1316 | else if ( msg == "volumeChange(bool)" ) { |
1314 | stream >> muted; | 1317 | stream >> muted; |
1315 | setVolume(); | 1318 | setVolume(); |
1316 | emit volumeChanged( muted ); | 1319 | emit volumeChanged( muted ); |
1317 | } | 1320 | } |
1318 | else if ( msg == "setMic(int,int)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> | 1321 | else if ( msg == "setMic(int,int)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> |
1319 | int t, v; | 1322 | int t, v; |
1320 | stream >> t >> v; | 1323 | stream >> t >> v; |
1321 | setMic( t, v ); | 1324 | setMic( t, v ); |
1322 | emit micChanged( micMuted ); | 1325 | emit micChanged( micMuted ); |
1323 | } | 1326 | } |
1324 | else if ( msg == "micChange(bool)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> | 1327 | else if ( msg == "micChange(bool)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> |
1325 | stream >> micMuted; | 1328 | stream >> micMuted; |
1326 | setMic(); | 1329 | setMic(); |
1327 | emit micChanged( micMuted ); | 1330 | emit micChanged( micMuted ); |
1328 | } | 1331 | } |
1329 | else if ( msg == "setBass(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> | 1332 | else if ( msg == "setBass(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> |
1330 | int t, v; | 1333 | int t, v; |
1331 | stream >> t >> v; | 1334 | stream >> t >> v; |
1332 | setBass( t, v ); | 1335 | setBass( t, v ); |
1333 | } | 1336 | } |
1334 | else if ( msg == "bassChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> | 1337 | else if ( msg == "bassChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> |
1335 | setBass(); | 1338 | setBass(); |
1336 | } | 1339 | } |
1337 | else if ( msg == "setTreble(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> | 1340 | else if ( msg == "setTreble(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> |
1338 | int t, v; | 1341 | int t, v; |
1339 | stream >> t >> v; | 1342 | stream >> t >> v; |
1340 | setTreble( t, v ); | 1343 | setTreble( t, v ); |
1341 | } | 1344 | } |
1342 | else if ( msg == "trebleChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> | 1345 | else if ( msg == "trebleChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> |
1343 | setTreble(); | 1346 | setTreble(); |
1344 | } else if ( msg == "getMarkedText()" ) { | 1347 | } else if ( msg == "getMarkedText()" ) { |
1345 | if ( type() == GuiServer ) { | 1348 | if ( type() == GuiServer ) { |
1346 | const ushort unicode = 'C'-'@'; | 1349 | const ushort unicode = 'C'-'@'; |
1347 | const int scan = Key_C; | 1350 | const int scan = Key_C; |
1348 | qwsServer->processKeyEvent( unicode, scan, ControlButton, TRUE, FALSE ); | 1351 | qwsServer->processKeyEvent( unicode, scan, ControlButton, TRUE, FALSE ); |
1349 | qwsServer->processKeyEvent( unicode, scan, ControlButton, FALSE, FALSE ); | 1352 | qwsServer->processKeyEvent( unicode, scan, ControlButton, FALSE, FALSE ); |
1350 | } | 1353 | } |
1351 | } else if ( msg == "newChannel(QString)") { | 1354 | } else if ( msg == "newChannel(QString)") { |
1352 | QString myChannel = "QPE/Application/" + d->appName; | 1355 | QString myChannel = "QPE/Application/" + d->appName; |
1353 | QString channel; | 1356 | QString channel; |
1354 | stream >> channel; | 1357 | stream >> channel; |
1355 | if (channel == myChannel) { | 1358 | if (channel == myChannel) { |
1356 | processQCopFile(); | 1359 | processQCopFile(); |
1357 | d->sendQCopQ(); | 1360 | d->sendQCopQ(); |
1358 | } | 1361 | } |
1359 | } | 1362 | } |
1360 | 1363 | ||
1361 | 1364 | ||
1362 | #endif | 1365 | #endif |
1363 | } | 1366 | } |
1364 | 1367 | ||
1365 | #include <qmetaobject.h> | ||
1366 | |||
1367 | QWidget *QPEApplication::nextWidget(QWidgetList* list, QWidget* _wid) { | ||
1368 | QWidget *next = 0; | ||
1369 | if ( list->isEmpty() || list->count() == 1 ) | ||
1370 | next = _wid; | ||
1371 | else{ | ||
1372 | QWidget* wid; | ||
1373 | uint idx = list->findRef( _wid ); | ||
1374 | uint count = list->count(); | ||
1375 | |||
1376 | /* one time through the list hacky we may not start with idx but end with it*/ | ||
1377 | for (uint i = (idx + 1)%count; true; i=(i+1)%count ) { | ||
1378 | wid = list->at(i); | ||
1379 | if ( wid == _wid ) { | ||
1380 | next = _wid; | ||
1381 | break; | ||
1382 | }else if ((( wid->inherits("QMainWindow") || | ||
1383 | wid->inherits("QDialog") ) && | ||
1384 | wid != qApp->desktop() && !wid->isHidden() ) || | ||
1385 | ( wid == mainWidget() || wid == d->qpe_main_widget ) ){ | ||
1386 | next = wid; | ||
1387 | break; | ||
1388 | } | ||
1389 | } | ||
1390 | } | ||
1391 | 1368 | ||
1392 | delete list; | 1369 | |
1393 | return next; | 1370 | |
1394 | } | 1371 | |
1395 | /*! | 1372 | /*! |
1396 | \internal | 1373 | \internal |
1397 | */ | 1374 | */ |
1398 | // ########## raise()ing main window should raise and set active | ||
1399 | // ########## it and then all childen. This belongs in Qt/Embedded | ||
1400 | /* | ||
1401 | * slightly change in behaviour to kill the need of modality in Opie | ||
1402 | * If any of the topLevelWidgets !isFullyObscured we highlight the next | ||
1403 | * top level window | ||
1404 | * 1)If visible and not modal we iterate over the list of top level widgets | ||
1405 | * 2)If modal we we make the modal and its parent toplevel widget visible if available | ||
1406 | * 3)else make topLevel visible | ||
1407 | * | ||
1408 | * send qcop if necessary and save current visible widget if not modal | ||
1409 | */ | ||
1410 | bool QPEApplication::raiseAppropriateWindow() | 1375 | bool QPEApplication::raiseAppropriateWindow() |
1411 | { | 1376 | { |
1412 | bool r = FALSE; | 1377 | bool r=FALSE; |
1413 | 1378 | ||
1414 | QWidget *top = d->qpe_main_widget ? d->qpe_main_widget : mainWidget(); | 1379 | // 1. Raise the main widget |
1415 | /* 1. */ | 1380 | QWidget *top = d->qpe_main_widget; |
1416 | if ( ( top && (top->isVisible() ) || ( d->lastWidget && d->lastWidget->isVisible() ) ) && | 1381 | if ( !top ) top = mainWidget(); |
1417 | !activeModalWidget() ) { | 1382 | |
1418 | r = TRUE; | 1383 | if ( top && d->keep_running ) { |
1419 | /*wid will be valid and topLevelWidgets will be deleted properly.. */ | 1384 | if ( top->isVisible() ) |
1420 | QWidget *wid = nextWidget( topLevelWidgets(), | 1385 | r = TRUE; |
1421 | d->lastWidget ? (QWidget*)d->lastWidget : top ); | 1386 | else if (d->preloaded) { |
1422 | /* keep the size window got but not for root*/ | 1387 | // We are preloaded and not visible.. pretend we just started.. |
1423 | if ( top == wid ) | 1388 | #ifndef QT_NO_COP |
1424 | d->show_mx(top, d->nomaximize ); | 1389 | QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); |
1425 | else | 1390 | e << d->appName; |
1426 | wid->show(); | 1391 | #endif |
1427 | 1392 | } | |
1428 | wid->raise(); | 1393 | |
1429 | wid->setActiveWindow(); | 1394 | d->show_mx(top,d->nomaximize, d->appName); |
1430 | d->lastWidget = wid; | 1395 | top->raise(); |
1431 | }else if ( activeModalWidget() ) { | 1396 | } |
1432 | QWidget* mod = activeModalWidget(); | 1397 | |
1433 | /* get the parent of the modal and its topLevelWidget as background widget */ | 1398 | QWidget *topm = activeModalWidget(); |
1434 | QWidget* par = activeModalWidget()->parentWidget() ? activeModalWidget()->parentWidget()->topLevelWidget() : 0; | 1399 | |
1435 | if (par ) { | 1400 | // 2. Raise any parentless widgets (except top and topm, as they |
1436 | if (par == top ) | 1401 | // are raised before and after this loop). Order from most |
1437 | d->show_mx(par, d->nomaximize ); | 1402 | // recently raised as deepest to least recently as top, so |
1438 | else | 1403 | // that repeated calls cycle through widgets. |
1439 | par->show(); | 1404 | QWidgetList *list = topLevelWidgets(); |
1440 | par->raise(); | 1405 | if ( list ) { |
1441 | par->setActiveWindow(); | 1406 | bool foundlast = FALSE; |
1442 | } | 1407 | QWidget* topsub = 0; |
1443 | mod->show(); | 1408 | if ( d->lastraised ) { |
1444 | mod->raise(); | 1409 | for (QWidget* w = list->first(); w; w = list->next()) { |
1445 | mod->setActiveWindow(); | 1410 | if ( !w->parentWidget() && w != topm && w->isVisible() && !w->isDesktop() ) { |
1446 | }else if (top){ | 1411 | if ( w == d->lastraised ) |
1447 | d->show_mx(top, d->nomaximize ); | 1412 | foundlast = TRUE; |
1448 | top->raise(); | 1413 | if ( foundlast ) { |
1449 | top->setActiveWindow(); | 1414 | w->raise(); |
1450 | d->lastWidget = top; | 1415 | topsub = w; |
1416 | } | ||
1417 | } | ||
1418 | } | ||
1419 | } | ||
1420 | for (QWidget* w = list->first(); w; w = list->next()) { | ||
1421 | if ( !w->parentWidget() && w != topm && w->isVisible() && !w->isDesktop() ) { | ||
1422 | if ( w == d->lastraised ) | ||
1423 | break; | ||
1424 | w->raise(); | ||
1425 | topsub = w; | ||
1426 | } | ||
1427 | } | ||
1428 | d->lastraised = topsub; | ||
1429 | delete list; | ||
1451 | } | 1430 | } |
1452 | 1431 | ||
1453 | if (!r && d->preloaded ) { | 1432 | // 3. Raise the active modal widget. |
1454 | QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); | 1433 | if ( topm && topm != top ) { |
1455 | e << d->appName; | 1434 | topm->show(); |
1435 | topm->raise(); | ||
1436 | // If we haven't already handled the fastAppShowing message | ||
1437 | if (!top && d->preloaded) { | ||
1438 | #ifndef QT_NO_COP | ||
1439 | QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); | ||
1440 | e << d->appName; | ||
1441 | #endif | ||
1442 | } | ||
1443 | r = FALSE; | ||
1456 | } | 1444 | } |
1457 | 1445 | ||
1458 | return r; | 1446 | return r; |
1459 | } | 1447 | } |
1460 | 1448 | ||
1461 | 1449 | ||
1462 | void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data) | 1450 | void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data) |
1463 | { | 1451 | { |
1464 | #ifdef Q_WS_QWS | 1452 | #ifdef Q_WS_QWS |
1465 | 1453 | ||
1466 | if ( msg == "quit()" ) { | 1454 | if ( msg == "quit()" ) { |
1467 | tryQuit(); | 1455 | tryQuit(); |
1468 | } | 1456 | } |
1469 | else if ( msg == "quitIfInvisible()" ) { | 1457 | else if ( msg == "quitIfInvisible()" ) { |
1470 | if ( d->qpe_main_widget && !d->qpe_main_widget->isVisible() ) | 1458 | if ( d->qpe_main_widget && !d->qpe_main_widget->isVisible() ) |
1471 | quit(); | 1459 | quit(); |
1472 | } | 1460 | } |
1473 | else if ( msg == "close()" ) { | 1461 | else if ( msg == "close()" ) { |
1474 | hideOrQuit(); | 1462 | hideOrQuit(); |
1475 | } | 1463 | } |
1476 | else if ( msg == "disablePreload()" ) { | 1464 | else if ( msg == "disablePreload()" ) { |
1477 | d->preloaded = FALSE; | 1465 | d->preloaded = FALSE; |
1478 | d->keep_running = TRUE; | 1466 | d->keep_running = TRUE; |
1479 | /* so that quit will quit */ | 1467 | /* so that quit will quit */ |
1480 | } | 1468 | } |
1481 | else if ( msg == "enablePreload()" ) { | 1469 | else if ( msg == "enablePreload()" ) { |
1482 | if (d->qpe_main_widget) | 1470 | if (d->qpe_main_widget) |
1483 | d->preloaded = TRUE; | 1471 | d->preloaded = TRUE; |
1484 | d->keep_running = TRUE; | 1472 | d->keep_running = TRUE; |
1485 | /* so next quit won't quit */ | 1473 | /* so next quit won't quit */ |
1486 | } | 1474 | } |
1487 | else if ( msg == "raise()" ) { | 1475 | else if ( msg == "raise()" ) { |
1488 | d->keep_running = TRUE; | 1476 | d->keep_running = TRUE; |
1489 | d->notbusysent = FALSE; | 1477 | d->notbusysent = FALSE; |
1490 | raiseAppropriateWindow(); | 1478 | raiseAppropriateWindow(); |
1491 | // Tell the system we're still chugging along... | 1479 | // Tell the system we're still chugging along... |
1492 | QCopEnvelope e("QPE/System", "appRaised(QString)"); | 1480 | QCopEnvelope e("QPE/System", "appRaised(QString)"); |
1493 | e << d->appName; | 1481 | e << d->appName; |
1494 | } | 1482 | } |
1495 | else if ( msg == "flush()" ) { | 1483 | else if ( msg == "flush()" ) { |
1496 | emit flush(); | 1484 | emit flush(); |
1497 | // we need to tell the desktop | 1485 | // we need to tell the desktop |
1498 | QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" ); | 1486 | QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" ); |
1499 | e << d->appName; | 1487 | e << d->appName; |
1500 | } | 1488 | } |
1501 | else if ( msg == "reload()" ) { | 1489 | else if ( msg == "reload()" ) { |
1502 | emit reload(); | 1490 | emit reload(); |
1503 | } | 1491 | } |
1504 | else if ( msg == "setDocument(QString)" ) { | 1492 | else if ( msg == "setDocument(QString)" ) { |
1505 | d->keep_running = TRUE; | 1493 | d->keep_running = TRUE; |
1506 | QDataStream stream( data, IO_ReadOnly ); | 1494 | QDataStream stream( data, IO_ReadOnly ); |
1507 | QString doc; | 1495 | QString doc; |
1508 | stream >> doc; | 1496 | stream >> doc; |
1509 | QWidget *mw = mainWidget(); | 1497 | QWidget *mw = mainWidget(); |
1510 | if ( !mw ) | 1498 | if ( !mw ) |
1511 | mw = d->qpe_main_widget; | 1499 | mw = d->qpe_main_widget; |
1512 | if ( mw ) | 1500 | if ( mw ) |
1513 | Global::setDocument( mw, doc ); | 1501 | Global::setDocument( mw, doc ); |
1514 | 1502 | ||
1515 | } else if ( msg == "QPEProcessQCop()" ) { | 1503 | } else if ( msg == "QPEProcessQCop()" ) { |
1516 | processQCopFile(); | 1504 | processQCopFile(); |
1517 | d->sendQCopQ(); | 1505 | d->sendQCopQ(); |
1518 | }else | 1506 | }else |
1519 | { | 1507 | { |
1520 | bool p = d->keep_running; | 1508 | bool p = d->keep_running; |
1521 | d->keep_running = FALSE; | 1509 | d->keep_running = FALSE; |
1522 | emit appMessage( msg, data); | 1510 | emit appMessage( msg, data); |
1523 | if ( d->keep_running ) { | 1511 | if ( d->keep_running ) { |
1524 | d->notbusysent = FALSE; | 1512 | d->notbusysent = FALSE; |
1525 | raiseAppropriateWindow(); | 1513 | raiseAppropriateWindow(); |
1526 | if ( !p ) { | 1514 | if ( !p ) { |
1527 | // Tell the system we're still chugging along... | 1515 | // Tell the system we're still chugging along... |
1528 | #ifndef QT_NO_COP | 1516 | #ifndef QT_NO_COP |
1529 | QCopEnvelope e("QPE/System", "appRaised(QString)"); | 1517 | QCopEnvelope e("QPE/System", "appRaised(QString)"); |
1530 | e << d->appName; | 1518 | e << d->appName; |
1531 | #endif | 1519 | #endif |
1532 | } | 1520 | } |
1533 | } | 1521 | } |
1534 | if ( p ) | 1522 | if ( p ) |
1535 | d->keep_running = p; | 1523 | d->keep_running = p; |
1536 | } | 1524 | } |
1537 | #endif | 1525 | #endif |
1538 | } | 1526 | } |
1539 | 1527 | ||
1540 | 1528 | ||
1541 | /*! | 1529 | /*! |
1542 | Sets widget \a mw as the mainWidget() and shows it. For small windows, | 1530 | Sets widget \a mw as the mainWidget() and shows it. For small windows, |
1543 | consider passing TRUE for \a nomaximize rather than the default FALSE. | 1531 | consider passing TRUE for \a nomaximize rather than the default FALSE. |
1544 | 1532 | ||
1545 | \sa showMainDocumentWidget() | 1533 | \sa showMainDocumentWidget() |
1546 | */ | 1534 | */ |
1547 | void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize ) | 1535 | void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize ) |
1548 | { | 1536 | { |
1549 | d->show(mw, nomaximize ); | 1537 | d->show(mw, nomaximize ); |
1550 | } | 1538 | } |
1551 | 1539 | ||
1552 | /*! | 1540 | /*! |
1553 | Sets widget \a mw as the mainWidget() and shows it. For small windows, | 1541 | Sets widget \a mw as the mainWidget() and shows it. For small windows, |
1554 | consider passing TRUE for \a nomaximize rather than the default FALSE. | 1542 | consider passing TRUE for \a nomaximize rather than the default FALSE. |
1555 | 1543 | ||
1556 | This calls designates the application as | 1544 | This calls designates the application as |
1557 | a \link docwidget.html document-oriented\endlink application. | 1545 | a \link docwidget.html document-oriented\endlink application. |
1558 | 1546 | ||
1559 | The \a mw widget \e must have this slot: setDocument(const QString&). | 1547 | The \a mw widget \e must have this slot: setDocument(const QString&). |
1560 | 1548 | ||
1561 | \sa showMainWidget() | 1549 | \sa showMainWidget() |
1562 | */ | 1550 | */ |
1563 | void QPEApplication::showMainDocumentWidget( QWidget* mw, bool nomaximize ) | 1551 | void QPEApplication::showMainDocumentWidget( QWidget* mw, bool nomaximize ) |
1564 | { | 1552 | { |
1565 | if ( mw && argc() == 2 ) | 1553 | if ( mw && argc() == 2 ) |
1566 | Global::setDocument( mw, QString::fromUtf8(argv()[1]) ); | 1554 | Global::setDocument( mw, QString::fromUtf8(argv()[1]) ); |
1567 | 1555 | ||
1568 | 1556 | ||
1569 | d->show(mw, nomaximize ); | 1557 | d->show(mw, nomaximize ); |
1570 | } | 1558 | } |
1571 | 1559 | ||
1572 | 1560 | ||
1573 | /*! | 1561 | /*! |
1574 | If an application is started via a \link qcop.html QCop\endlink | 1562 | If an application is started via a \link qcop.html QCop\endlink |
1575 | message, the application will process the \link qcop.html | 1563 | message, the application will process the \link qcop.html |
1576 | QCop\endlink message and then quit. If the application calls this | 1564 | QCop\endlink message and then quit. If the application calls this |
1577 | function while processing a \link qcop.html QCop\endlink message, | 1565 | function while processing a \link qcop.html QCop\endlink message, |
1578 | after processing its outstanding \link qcop.html QCop\endlink | 1566 | after processing its outstanding \link qcop.html QCop\endlink |
1579 | messages the application will start 'properly' and show itself. | 1567 | messages the application will start 'properly' and show itself. |
1580 | 1568 | ||
1581 | \sa keepRunning() | 1569 | \sa keepRunning() |
1582 | */ | 1570 | */ |
1583 | void QPEApplication::setKeepRunning() | 1571 | void QPEApplication::setKeepRunning() |
diff --git a/library/qpeapplication.h b/library/qpeapplication.h index 69e0058..729cf2b 100644 --- a/library/qpeapplication.h +++ b/library/qpeapplication.h | |||
@@ -1,209 +1,206 @@ | |||
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 | #include <stdlib.h> // for setenv() | 23 | #include <stdlib.h> // for setenv() |
24 | 24 | ||
25 | #include <qglobal.h> | 25 | #include <qglobal.h> |
26 | #include <qapplication.h> | 26 | #include <qapplication.h> |
27 | #include <qdialog.h> | 27 | #include <qdialog.h> |
28 | #include <qwsdisplay_qws.h> | 28 | #include <qwsdisplay_qws.h> |
29 | #if defined(_WS_QWS_) && !defined(Q_WS_QWS) | 29 | #if defined(_WS_QWS_) && !defined(Q_WS_QWS) |
30 | #define Q_WS_QWS | 30 | #define Q_WS_QWS |
31 | #endif | 31 | #endif |
32 | #include "qpedecoration_qws.h" | 32 | #include "qpedecoration_qws.h" |
33 | #include "timestring.h" | 33 | #include "timestring.h" |
34 | 34 | ||
35 | class QCopChannel; | 35 | class QCopChannel; |
36 | class QPEApplicationData; | 36 | class QPEApplicationData; |
37 | class QWSEvent; | 37 | class QWSEvent; |
38 | class QWSKeyEvent; | 38 | class QWSKeyEvent; |
39 | 39 | ||
40 | 40 | ||
41 | class QPEApplication : public QApplication | 41 | class QPEApplication : public QApplication |
42 | { | 42 | { |
43 | Q_OBJECT | 43 | Q_OBJECT |
44 | public: | 44 | public: |
45 | QPEApplication( int& argc, char **argv, Type=GuiClient ); | 45 | QPEApplication( int& argc, char **argv, Type=GuiClient ); |
46 | ~QPEApplication(); | 46 | ~QPEApplication(); |
47 | 47 | ||
48 | static QString qpeDir(); | 48 | static QString qpeDir(); |
49 | static QString documentDir(); | 49 | static QString documentDir(); |
50 | void applyStyle(); | 50 | void applyStyle(); |
51 | void reset(); | 51 | void reset(); |
52 | static int defaultRotation(); | 52 | static int defaultRotation(); |
53 | static void setDefaultRotation(int r); | 53 | static void setDefaultRotation(int r); |
54 | static void setCurrentRotation(int r); | 54 | static void setCurrentRotation(int r); |
55 | static void setCurrentMode(int x, int y, int depth ); | 55 | static void setCurrentMode(int x, int y, int depth ); |
56 | static void grabKeyboard(); | 56 | static void grabKeyboard(); |
57 | static void ungrabKeyboard(); | 57 | static void ungrabKeyboard(); |
58 | 58 | ||
59 | enum StylusMode { | 59 | enum StylusMode { |
60 | LeftOnly, | 60 | LeftOnly, |
61 | RightOnHold | 61 | RightOnHold |
62 | // RightOnHoldLeftDelayed, etc. | 62 | // RightOnHoldLeftDelayed, etc. |
63 | }; | 63 | }; |
64 | static void setStylusOperation( QWidget*, StylusMode ); | 64 | static void setStylusOperation( QWidget*, StylusMode ); |
65 | static StylusMode stylusOperation( QWidget* ); | 65 | static StylusMode stylusOperation( QWidget* ); |
66 | 66 | ||
67 | enum InputMethodHint { | 67 | enum InputMethodHint { |
68 | Normal, | 68 | Normal, |
69 | AlwaysOff, | 69 | AlwaysOff, |
70 | AlwaysOn | 70 | AlwaysOn |
71 | }; | 71 | }; |
72 | 72 | ||
73 | enum screenSaverHint { | 73 | enum screenSaverHint { |
74 | Disable = 0, | 74 | Disable = 0, |
75 | DisableLightOff = 1, | 75 | DisableLightOff = 1, |
76 | DisableSuspend = 2, | 76 | DisableSuspend = 2, |
77 | Enable = 100 | 77 | Enable = 100 |
78 | }; | 78 | }; |
79 | 79 | ||
80 | static void setInputMethodHint( QWidget *, InputMethodHint ); | 80 | static void setInputMethodHint( QWidget *, InputMethodHint ); |
81 | static InputMethodHint inputMethodHint( QWidget * ); | 81 | static InputMethodHint inputMethodHint( QWidget * ); |
82 | 82 | ||
83 | void showMainWidget( QWidget*, bool nomax=FALSE ); | 83 | void showMainWidget( QWidget*, bool nomax=FALSE ); |
84 | void showMainDocumentWidget( QWidget*, bool nomax=FALSE ); | 84 | void showMainDocumentWidget( QWidget*, bool nomax=FALSE ); |
85 | static void showDialog( QDialog*, bool nomax=FALSE ); | 85 | static void showDialog( QDialog*, bool nomax=FALSE ); |
86 | static int execDialog( QDialog*, bool nomax=FALSE ); | 86 | static int execDialog( QDialog*, bool nomax=FALSE ); |
87 | /* Merge setTempScreenSaverMode */ | 87 | /* Merge setTempScreenSaverMode */ |
88 | #ifdef QTOPIA_INTERNAL_INITAPP | 88 | #ifdef QTOPIA_INTERNAL_INITAPP |
89 | void initApp( int argv, char **argv ); | 89 | void initApp( int argv, char **argv ); |
90 | #endif | 90 | #endif |
91 | 91 | ||
92 | static void setKeepRunning(); | 92 | static void setKeepRunning(); |
93 | bool keepRunning() const; | 93 | bool keepRunning() const; |
94 | 94 | ||
95 | bool keyboardGrabbed() const; | 95 | bool keyboardGrabbed() const; |
96 | 96 | ||
97 | int exec(); | 97 | int exec(); |
98 | 98 | ||
99 | signals: | 99 | signals: |
100 | void clientMoused(); | 100 | void clientMoused(); |
101 | void timeChanged(); | 101 | void timeChanged(); |
102 | void clockChanged( bool pm ); | 102 | void clockChanged( bool pm ); |
103 | void micChanged( bool muted ); | 103 | void micChanged( bool muted ); |
104 | void volumeChanged( bool muted ); | 104 | void volumeChanged( bool muted ); |
105 | void appMessage( const QCString& msg, const QByteArray& data); | 105 | void appMessage( const QCString& msg, const QByteArray& data); |
106 | void weekChanged( bool startOnMonday ); | 106 | void weekChanged( bool startOnMonday ); |
107 | void dateFormatChanged( DateFormat ); | 107 | void dateFormatChanged( DateFormat ); |
108 | void flush(); | 108 | void flush(); |
109 | void reload(); | 109 | void reload(); |
110 | /* linkChanged signal */ | 110 | /* linkChanged signal */ |
111 | 111 | ||
112 | private slots: | 112 | private slots: |
113 | void systemMessage( const QCString &msg, const QByteArray &data ); | 113 | void systemMessage( const QCString &msg, const QByteArray &data ); |
114 | void pidMessage( const QCString &msg, const QByteArray &data ); | 114 | void pidMessage( const QCString &msg, const QByteArray &data ); |
115 | void removeSenderFromStylusDict(); | 115 | void removeSenderFromStylusDict(); |
116 | void hideOrQuit(); | 116 | void hideOrQuit(); |
117 | 117 | ||
118 | private: | ||
119 | QWidget *nextWidget( QWidgetList*, QWidget* ); | ||
120 | |||
121 | protected: | 118 | protected: |
122 | bool qwsEventFilter( QWSEvent * ); | 119 | bool qwsEventFilter( QWSEvent * ); |
123 | void internalSetStyle( const QString &style ); | 120 | void internalSetStyle( const QString &style ); |
124 | void prepareForTermination(bool willrestart); | 121 | void prepareForTermination(bool willrestart); |
125 | virtual void restart(); | 122 | virtual void restart(); |
126 | virtual void shutdown(); | 123 | virtual void shutdown(); |
127 | bool eventFilter( QObject *, QEvent * ); | 124 | bool eventFilter( QObject *, QEvent * ); |
128 | void timerEvent( QTimerEvent * ); | 125 | void timerEvent( QTimerEvent * ); |
129 | bool raiseAppropriateWindow(); | 126 | bool raiseAppropriateWindow(); |
130 | virtual void tryQuit(); | 127 | virtual void tryQuit(); |
131 | #if QT_VERSION > 233 | 128 | #if QT_VERSION > 233 |
132 | virtual void polish ( QWidget * ); // this is actually implemented in qt_override.cpp (!) | 129 | virtual void polish ( QWidget * ); // this is actually implemented in qt_override.cpp (!) |
133 | #endif | 130 | #endif |
134 | private: | 131 | private: |
135 | #ifndef QT_NO_TRANSLATION | 132 | #ifndef QT_NO_TRANSLATION |
136 | void installTranslation( const QString& baseName ); | 133 | void installTranslation( const QString& baseName ); |
137 | #endif | 134 | #endif |
138 | void mapToDefaultAction( QWSKeyEvent *ke, int defKey ); | 135 | void mapToDefaultAction( QWSKeyEvent *ke, int defKey ); |
139 | void processQCopFile(); | 136 | void processQCopFile(); |
140 | 137 | ||
141 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 138 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
142 | QCopChannel *sysChannel; | 139 | QCopChannel *sysChannel; |
143 | QCopChannel *pidChannel; | 140 | QCopChannel *pidChannel; |
144 | #endif | 141 | #endif |
145 | QPEApplicationData *d; | 142 | QPEApplicationData *d; |
146 | 143 | ||
147 | bool reserved_sh; | 144 | bool reserved_sh; |
148 | 145 | ||
149 | 146 | ||
150 | 147 | ||
151 | }; | 148 | }; |
152 | 149 | ||
153 | inline void QPEApplication::showDialog( QDialog* d, bool nomax ) | 150 | inline void QPEApplication::showDialog( QDialog* d, bool nomax ) |
154 | { | 151 | { |
155 | QSize sh = d->sizeHint(); | 152 | QSize sh = d->sizeHint(); |
156 | int w = QMAX(sh.width(),d->width()); | 153 | int w = QMAX(sh.width(),d->width()); |
157 | int h = QMAX(sh.height(),d->height()); | 154 | int h = QMAX(sh.height(),d->height()); |
158 | if ( !nomax | 155 | if ( !nomax |
159 | && ( w > qApp->desktop()->width()*3/4 | 156 | && ( w > qApp->desktop()->width()*3/4 |
160 | || h > qApp->desktop()->height()*3/4 ) ) | 157 | || h > qApp->desktop()->height()*3/4 ) ) |
161 | { | 158 | { |
162 | d->showMaximized(); | 159 | d->showMaximized(); |
163 | } else { | 160 | } else { |
164 | d->resize(w,h); | 161 | d->resize(w,h); |
165 | d->show(); | 162 | d->show(); |
166 | } | 163 | } |
167 | } | 164 | } |
168 | 165 | ||
169 | inline int QPEApplication::execDialog( QDialog* d, bool nomax ) | 166 | inline int QPEApplication::execDialog( QDialog* d, bool nomax ) |
170 | { | 167 | { |
171 | showDialog(d,nomax); | 168 | showDialog(d,nomax); |
172 | return d->exec(); | 169 | return d->exec(); |
173 | } | 170 | } |
174 | 171 | ||
175 | enum Transformation { Rot0, Rot90, Rot180, Rot270 }; /* from qgfxtransformed_qws.cpp */ | 172 | enum Transformation { Rot0, Rot90, Rot180, Rot270 }; /* from qgfxtransformed_qws.cpp */ |
176 | 173 | ||
177 | inline int TransToDeg ( Transformation t ) | 174 | inline int TransToDeg ( Transformation t ) |
178 | { | 175 | { |
179 | int d = static_cast<int>( t ); | 176 | int d = static_cast<int>( t ); |
180 | return d * 90; | 177 | return d * 90; |
181 | } | 178 | } |
182 | 179 | ||
183 | inline Transformation DegToTrans ( int d ) | 180 | inline Transformation DegToTrans ( int d ) |
184 | { | 181 | { |
185 | Transformation t = static_cast<Transformation>( d / 90 ); | 182 | Transformation t = static_cast<Transformation>( d / 90 ); |
186 | return t; | 183 | return t; |
187 | } | 184 | } |
188 | 185 | ||
189 | /* | 186 | /* |
190 | * Set current rotation of Opie, and rotation for newly started apps. | 187 | * Set current rotation of Opie, and rotation for newly started apps. |
191 | * Differs from setDefaultRotation in that 1) it rotates currently running apps, | 188 | * Differs from setDefaultRotation in that 1) it rotates currently running apps, |
192 | * and 2) does not set deforient or save orientation to qpe.conf. | 189 | * and 2) does not set deforient or save orientation to qpe.conf. |
193 | */ | 190 | */ |
194 | 191 | ||
195 | inline void QPEApplication::setCurrentRotation( int r ) | 192 | inline void QPEApplication::setCurrentRotation( int r ) |
196 | { | 193 | { |
197 | // setTransformation has been introduced in Qt/Embedded 2.3.4 snapshots | 194 | // setTransformation has been introduced in Qt/Embedded 2.3.4 snapshots |
198 | // for compatibility with the SharpROM use fallback to setDefaultTransformation() | 195 | // for compatibility with the SharpROM use fallback to setDefaultTransformation() |
199 | #if QT_VERSION > 233 | 196 | #if QT_VERSION > 233 |
200 | Transformation e = DegToTrans( r ); | 197 | Transformation e = DegToTrans( r ); |
201 | ::setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 ); | 198 | ::setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 ); |
202 | qApp->desktop()->qwsDisplay()->setTransformation( e ); | 199 | qApp->desktop()->qwsDisplay()->setTransformation( e ); |
203 | #else | 200 | #else |
204 | setDefaultRotation( r ); | 201 | setDefaultRotation( r ); |
205 | #endif | 202 | #endif |
206 | } | 203 | } |
207 | 204 | ||
208 | 205 | ||
209 | #endif | 206 | #endif |