summaryrefslogtreecommitdiff
authorzecke <zecke>2003-10-02 19:50:57 (UTC)
committer zecke <zecke>2003-10-02 19:50:57 (UTC)
commita5622a23c3083e1ff8a526713aed6a36aaf7a5bd (patch) (unidiff)
treea11dd920c777ebceee2026e573d4e0111875174c
parentb262f4cbe41c144c472f17996a8739952464e00c (diff)
downloadopie-a5622a23c3083e1ff8a526713aed6a36aaf7a5bd.zip
opie-a5622a23c3083e1ff8a526713aed6a36aaf7a5bd.tar.gz
opie-a5622a23c3083e1ff8a526713aed6a36aaf7a5bd.tar.bz2
Move the #ifdef so that the code actually compiles if the expression
is not true
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--library/qpeapplication.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp
index 98af70a..0e469ae 100644
--- a/library/qpeapplication.cpp
+++ b/library/qpeapplication.cpp
@@ -1,1690 +1,1691 @@
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#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#include <qqueue.h> 25#include <qqueue.h>
26#ifdef Q_WS_QWS 26#ifdef Q_WS_QWS
27#ifndef QT_NO_COP 27#ifndef QT_NO_COP
28#if QT_VERSION <= 231 28#if QT_VERSION <= 231
29#define private public 29#define private public
30#define sendLocally processEvent 30#define sendLocally processEvent
31#include "qcopenvelope_qws.h" 31#include "qcopenvelope_qws.h"
32#undef private 32#undef private
33#else 33#else
34#include "qcopenvelope_qws.h" 34#include "qcopenvelope_qws.h"
35#endif 35#endif
36#endif 36#endif
37#include <qwindowsystem_qws.h> 37#include <qwindowsystem_qws.h>
38#endif 38#endif
39#include <qtextstream.h> 39#include <qtextstream.h>
40#include <qpalette.h> 40#include <qpalette.h>
41#include <qbuffer.h> 41#include <qbuffer.h>
42#include <qptrdict.h> 42#include <qptrdict.h>
43#include <qregexp.h> 43#include <qregexp.h>
44#include <qdir.h> 44#include <qdir.h>
45#include <qlabel.h> 45#include <qlabel.h>
46#include <qdialog.h> 46#include <qdialog.h>
47#include <qdragobject.h> 47#include <qdragobject.h>
48#include <qtextcodec.h> 48#include <qtextcodec.h>
49#include <qevent.h> 49#include <qevent.h>
50#include <qtooltip.h> 50#include <qtooltip.h>
51#include <qsignal.h> 51#include <qsignal.h>
52#include <qmainwindow.h> 52#include <qmainwindow.h>
53#include <qwidgetlist.h> 53#include <qwidgetlist.h>
54 54
55#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 55#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
56#define QTOPIA_INTERNAL_INITAPP 56#define QTOPIA_INTERNAL_INITAPP
57#include "qpeapplication.h" 57#include "qpeapplication.h"
58#include "qpestyle.h" 58#include "qpestyle.h"
59#include "styleinterface.h" 59#include "styleinterface.h"
60#if QT_VERSION >= 300 60#if QT_VERSION >= 300
61#include <qstylefactory.h> 61#include <qstylefactory.h>
62#else 62#else
63#include <qplatinumstyle.h> 63#include <qplatinumstyle.h>
64#include <qwindowsstyle.h> 64#include <qwindowsstyle.h>
65#include <qmotifstyle.h> 65#include <qmotifstyle.h>
66#include <qmotifplusstyle.h> 66#include <qmotifplusstyle.h>
67#include "lightstyle.h" 67#include "lightstyle.h"
68 68
69#include <qpe/qlibrary.h> 69#include <qpe/qlibrary.h>
70#endif 70#endif
71#include "global.h" 71#include "global.h"
72#include "resource.h" 72#include "resource.h"
73#if QT_VERSION <= 230 && defined(QT_NO_CODECS) 73#if QT_VERSION <= 230 && defined(QT_NO_CODECS)
74#include "qutfcodec.h" 74#include "qutfcodec.h"
75#endif 75#endif
76#include "config.h" 76#include "config.h"
77#include "network.h" 77#include "network.h"
78#ifdef QWS 78#ifdef QWS
79#include "fontmanager.h" 79#include "fontmanager.h"
80#endif 80#endif
81 81
82#include "alarmserver.h" 82#include "alarmserver.h"
83#include "applnk.h" 83#include "applnk.h"
84#include "qpemenubar.h" 84#include "qpemenubar.h"
85#include "textcodecinterface.h" 85#include "textcodecinterface.h"
86#include "imagecodecinterface.h" 86#include "imagecodecinterface.h"
87 87
88#include <unistd.h> 88#include <unistd.h>
89#include <sys/file.h> 89#include <sys/file.h>
90#include <sys/ioctl.h> 90#include <sys/ioctl.h>
91#include <sys/soundcard.h> 91#include <sys/soundcard.h>
92 92
93#include "qt_override_p.h" 93#include "qt_override_p.h"
94 94
95 95
96class QPEApplicationData 96class QPEApplicationData
97{ 97{
98public: 98public:
99 QPEApplicationData ( ) 99 QPEApplicationData ( )
100 : presstimer( 0 ), presswidget( 0 ), rightpressed( false ), kbgrabbed( false ), 100 : presstimer( 0 ), presswidget( 0 ), rightpressed( false ), kbgrabbed( false ),
101 notbusysent( false ), preloaded( false ), forceshow( false ), nomaximize( false ), 101 notbusysent( false ), preloaded( false ), forceshow( false ), nomaximize( false ),
102 keep_running( true ), qpe_main_widget( 0 ), qcopQok( false ) 102 keep_running( true ), qpe_main_widget( 0 ), qcopQok( false )
103 103
104 {} 104 {}
105 105
106 int presstimer; 106 int presstimer;
107 QWidget* presswidget; 107 QWidget* presswidget;
108 QPoint presspos; 108 QPoint presspos;
109 109
110 bool rightpressed : 1; 110 bool rightpressed : 1;
111 bool kbgrabbed : 1; 111 bool kbgrabbed : 1;
112 bool notbusysent : 1; 112 bool notbusysent : 1;
113 bool preloaded : 1; 113 bool preloaded : 1;
114 bool forceshow : 1; 114 bool forceshow : 1;
115 bool nomaximize : 1; 115 bool nomaximize : 1;
116 bool qcopQok : 1; 116 bool qcopQok : 1;
117 bool keep_running : 1; 117 bool keep_running : 1;
118 118
119 119
120 QStringList langs; 120 QStringList langs;
121 QString appName; 121 QString appName;
122 struct QCopRec 122 struct QCopRec
123 { 123 {
124 QCopRec( const QCString &ch, const QCString &msg, 124 QCopRec( const QCString &ch, const QCString &msg,
125 const QByteArray &d ) : 125 const QByteArray &d ) :
126 channel( ch ), message( msg ), data( d ) 126 channel( ch ), message( msg ), data( d )
127 { } 127 { }
128 128
129 QCString channel; 129 QCString channel;
130 QCString message; 130 QCString message;
131 QByteArray data; 131 QByteArray data;
132 }; 132 };
133 QWidget* qpe_main_widget; 133 QWidget* qpe_main_widget;
134 QGuardedPtr<QWidget> lastraised; 134 QGuardedPtr<QWidget> lastraised;
135 QQueue<QCopRec> qcopq; 135 QQueue<QCopRec> qcopq;
136 QString styleName; 136 QString styleName;
137 QString decorationName; 137 QString decorationName;
138 138
139 void enqueueQCop( const QCString &ch, const QCString &msg, 139 void enqueueQCop( const QCString &ch, const QCString &msg,
140 const QByteArray &data ) 140 const QByteArray &data )
141 { 141 {
142 qcopq.enqueue( new QCopRec( ch, msg, data ) ); 142 qcopq.enqueue( new QCopRec( ch, msg, data ) );
143 } 143 }
144 void sendQCopQ() 144 void sendQCopQ()
145 { 145 {
146 if (!qcopQok ) 146 if (!qcopQok )
147 return; 147 return;
148 148
149 QCopRec * r; 149 QCopRec * r;
150#ifndef QT_NO_COP 150
151 while((r=qcopq.dequeue())) { 151 while((r=qcopq.dequeue())) {
152 // remove from queue before sending... 152 // remove from queue before sending...
153 // event loop can come around again before getting 153 // event loop can come around again before getting
154 // back from sendLocally 154 // back from sendLocally
155#ifndef QT_NO_COP
155 QCopChannel::sendLocally( r->channel, r->message, r->data ); 156 QCopChannel::sendLocally( r->channel, r->message, r->data );
156#endif 157#endif
157 158
158 delete r; 159 delete r;
159 } 160 }
160 } 161 }
161 static void show_mx(QWidget* mw, bool nomaximize, const QString & = QString::null ) 162 static void show_mx(QWidget* mw, bool nomaximize, const QString & = QString::null )
162 { 163 {
163 164
164 // ugly hack, remove that later after finding a sane solution 165 // ugly hack, remove that later after finding a sane solution
165 // Addendum: Only Sharp currently has models with high resolution but (physically) small displays, 166 // Addendum: Only Sharp currently has models with high resolution but (physically) small displays,
166 // so this is only useful if QT_QWS_SIMPAD is NOT defined. E.g. SIMpad has 800x600 but has 167 // so this is only useful if QT_QWS_SIMPAD is NOT defined. E.g. SIMpad has 800x600 but has
167 // a (physically) large enough display to use the small icons 168 // a (physically) large enough display to use the small icons
168#ifndef QT_QWS_SIMPAD 169#ifndef QT_QWS_SIMPAD
169 if ( QPEApplication::desktop() ->width() >= 600 && ( mw->inherits("QMainWindow") || mw->isA("QMainWindow") ) ) { 170 if ( QPEApplication::desktop() ->width() >= 600 && ( mw->inherits("QMainWindow") || mw->isA("QMainWindow") ) ) {
170 ( ( QMainWindow* ) mw )->setUsesBigPixmaps( true ); 171 ( ( QMainWindow* ) mw )->setUsesBigPixmaps( true );
171 } 172 }
172#endif 173#endif
173 174
174 if ( mw->layout() && mw->inherits("QDialog") ) { 175 if ( mw->layout() && mw->inherits("QDialog") ) {
175 QPEApplication::showDialog((QDialog*)mw, nomaximize); 176 QPEApplication::showDialog((QDialog*)mw, nomaximize);
176 } 177 }
177 else { 178 else {
178#ifdef Q_WS_QWS 179#ifdef Q_WS_QWS
179 if ( !nomaximize ) 180 if ( !nomaximize )
180 mw->showMaximized(); 181 mw->showMaximized();
181 else 182 else
182#endif 183#endif
183 184
184 mw->show(); 185 mw->show();
185 } 186 }
186 } 187 }
187 static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) 188 static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ )
188 { 189 {
189 /* 190 /*
190 // This works but disable it for now until it is safe to apply 191 // This works but disable it for now until it is safe to apply
191 // What is does is scan the .desktop files of all the apps for 192 // What is does is scan the .desktop files of all the apps for
192 // the applnk that has the corresponding argv[0] as this program 193 // the applnk that has the corresponding argv[0] as this program
193 // then it uses the name stored in the .desktop file as the caption 194 // then it uses the name stored in the .desktop file as the caption
194 // for the main widget. This saves duplicating translations for 195 // for the main widget. This saves duplicating translations for
195 // the app name in the program and in the .desktop files. 196 // the app name in the program and in the .desktop files.
196 197
197 AppLnkSet apps( appsPath ); 198 AppLnkSet apps( appsPath );
198 199
199 QList<AppLnk> appsList = apps.children(); 200 QList<AppLnk> appsList = apps.children();
200 for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) { 201 for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) {
201 if ( (*it)->exec() == appName ) { 202 if ( (*it)->exec() == appName ) {
202 mw->setCaption( (*it)->name() ); 203 mw->setCaption( (*it)->name() );
203 return TRUE; 204 return TRUE;
204 } 205 }
205 } 206 }
206 */ 207 */
207 return FALSE; 208 return FALSE;
208 } 209 }
209 210
210 211
211 void show(QWidget* mw, bool nomax) 212 void show(QWidget* mw, bool nomax)
212 { 213 {
213 setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" ); 214 setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" );
214 nomaximize = nomax; 215 nomaximize = nomax;
215 qpe_main_widget = mw; 216 qpe_main_widget = mw;
216#ifndef QT_NO_COP 217#ifndef QT_NO_COP
217 218
218 sendQCopQ(); 219 sendQCopQ();
219#endif 220#endif
220 221
221 if ( preloaded ) { 222 if ( preloaded ) {
222 if (forceshow) 223 if (forceshow)
223 show_mx(mw, nomax); 224 show_mx(mw, nomax);
224 } 225 }
225 else if ( keep_running ) { 226 else if ( keep_running ) {
226 show_mx(mw, nomax); 227 show_mx(mw, nomax);
227 } 228 }
228 } 229 }
229 230
230 void loadTextCodecs() 231 void loadTextCodecs()
231 { 232 {
232 QString path = QPEApplication::qpeDir() + "/plugins/textcodecs"; 233 QString path = QPEApplication::qpeDir() + "/plugins/textcodecs";
233 QDir dir( path, "lib*.so" ); 234 QDir dir( path, "lib*.so" );
234 QStringList list; 235 QStringList list;
235 if ( dir. exists ( )) 236 if ( dir. exists ( ))
236 list = dir.entryList(); 237 list = dir.entryList();
237 QStringList::Iterator it; 238 QStringList::Iterator it;
238 for ( it = list.begin(); it != list.end(); ++it ) { 239 for ( it = list.begin(); it != list.end(); ++it ) {
239 TextCodecInterface *iface = 0; 240 TextCodecInterface *iface = 0;
240 QLibrary *lib = new QLibrary( path + "/" + *it ); 241 QLibrary *lib = new QLibrary( path + "/" + *it );
241 if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { 242 if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) {
242 QValueList<int> mibs = iface->mibEnums(); 243 QValueList<int> mibs = iface->mibEnums();
243 for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) { 244 for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) {
244 (void)iface->createForMib(*i); 245 (void)iface->createForMib(*i);
245 // ### it exists now; need to remember if we can delete it 246 // ### it exists now; need to remember if we can delete it
246 } 247 }
247 } 248 }
248 else { 249 else {
249 lib->unload(); 250 lib->unload();
250 delete lib; 251 delete lib;
251 } 252 }
252 } 253 }
253 } 254 }
254 255
255 void loadImageCodecs() 256 void loadImageCodecs()
256 { 257 {
257 QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs"; 258 QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs";
258 QDir dir( path, "lib*.so" ); 259 QDir dir( path, "lib*.so" );
259 QStringList list; 260 QStringList list;
260 if ( dir. exists ( )) 261 if ( dir. exists ( ))
261 list = dir.entryList(); 262 list = dir.entryList();
262 QStringList::Iterator it; 263 QStringList::Iterator it;
263 for ( it = list.begin(); it != list.end(); ++it ) { 264 for ( it = list.begin(); it != list.end(); ++it ) {
264 ImageCodecInterface *iface = 0; 265 ImageCodecInterface *iface = 0;
265 QLibrary *lib = new QLibrary( path + "/" + *it ); 266 QLibrary *lib = new QLibrary( path + "/" + *it );
266 if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { 267 if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) {
267 QStringList formats = iface->keys(); 268 QStringList formats = iface->keys();
268 for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) { 269 for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) {
269 (void)iface->installIOHandler(*i); 270 (void)iface->installIOHandler(*i);
270 // ### it exists now; need to remember if we can delete it 271 // ### it exists now; need to remember if we can delete it
271 } 272 }
272 } 273 }
273 else { 274 else {
274 lib->unload(); 275 lib->unload();
275 delete lib; 276 delete lib;
276 } 277 }
277 } 278 }
278 } 279 }
279}; 280};
280 281
281class ResourceMimeFactory : public QMimeSourceFactory 282class ResourceMimeFactory : public QMimeSourceFactory
282{ 283{
283public: 284public:
284 ResourceMimeFactory() : resImage( 0 ) 285 ResourceMimeFactory() : resImage( 0 )
285 { 286 {
286 setFilePath( Global::helpPath() ); 287 setFilePath( Global::helpPath() );
287 setExtensionType( "html", "text/html;charset=UTF-8" ); 288 setExtensionType( "html", "text/html;charset=UTF-8" );
288 } 289 }
289 ~ResourceMimeFactory() { 290 ~ResourceMimeFactory() {
290 delete resImage; 291 delete resImage;
291 } 292 }
292 293
293 const QMimeSource* data( const QString& abs_name ) const 294 const QMimeSource* data( const QString& abs_name ) const
294 { 295 {
295 const QMimeSource * r = QMimeSourceFactory::data( abs_name ); 296 const QMimeSource * r = QMimeSourceFactory::data( abs_name );
296 if ( !r ) { 297 if ( !r ) {
297 int sl = abs_name.length(); 298 int sl = abs_name.length();
298 do { 299 do {
299 sl = abs_name.findRev( '/', sl - 1 ); 300 sl = abs_name.findRev( '/', sl - 1 );
300 QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name; 301 QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name;
301 int dot = name.findRev( '.' ); 302 int dot = name.findRev( '.' );
302 if ( dot >= 0 ) 303 if ( dot >= 0 )
303 name = name.left( dot ); 304 name = name.left( dot );
304 QImage img = Resource::loadImage( name ); 305 QImage img = Resource::loadImage( name );
305 if ( !img.isNull() ) { 306 if ( !img.isNull() ) {
306 delete resImage; 307 delete resImage;
307 resImage = new QImageDrag( img ); 308 resImage = new QImageDrag( img );
308 r = resImage; 309 r = resImage;
309 } 310 }
310 } 311 }
311 while ( !r && sl > 0 ); 312 while ( !r && sl > 0 );
312 } 313 }
313 return r; 314 return r;
314 } 315 }
315private: 316private:
316 mutable QImageDrag *resImage; 317 mutable QImageDrag *resImage;
317}; 318};
318 319
319static int& hack(int& i) 320static int& hack(int& i)
320{ 321{
321#if QT_VERSION <= 230 && defined(QT_NO_CODECS) 322#if QT_VERSION <= 230 && defined(QT_NO_CODECS)
322 // These should be created, but aren't in Qt 2.3.0 323 // These should be created, but aren't in Qt 2.3.0
323 (void)new QUtf8Codec; 324 (void)new QUtf8Codec;
324 (void)new QUtf16Codec; 325 (void)new QUtf16Codec;
325#endif 326#endif
326 return i; 327 return i;
327} 328}
328 329
329static int muted = 0; 330static int muted = 0;
330static int micMuted = 0; 331static int micMuted = 0;
331 332
332static void setVolume( int t = 0, int percent = -1 ) 333static void setVolume( int t = 0, int percent = -1 )
333{ 334{
334 switch ( t ) { 335 switch ( t ) {
335 case 0: { 336 case 0: {
336 Config cfg( "qpe" ); 337 Config cfg( "qpe" );
337 cfg.setGroup( "Volume" ); 338 cfg.setGroup( "Volume" );
338 if ( percent < 0 ) 339 if ( percent < 0 )
339 percent = cfg.readNumEntry( "VolumePercent", 50 ); 340 percent = cfg.readNumEntry( "VolumePercent", 50 );
340 int fd = 0; 341 int fd = 0;
341 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { 342 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) {
342 int vol = muted ? 0 : percent; 343 int vol = muted ? 0 : percent;
343 // set both channels to same volume 344 // set both channels to same volume
344 vol |= vol << 8; 345 vol |= vol << 8;
345 ioctl( fd, MIXER_WRITE( 0 ), &vol ); 346 ioctl( fd, MIXER_WRITE( 0 ), &vol );
346 ::close( fd ); 347 ::close( fd );
347 } 348 }
348 } 349 }
349 break; 350 break;
350 } 351 }
351} 352}
352 353
353static void setMic( int t = 0, int percent = -1 ) 354static void setMic( int t = 0, int percent = -1 )
354{ 355{
355 switch ( t ) { 356 switch ( t ) {
356 case 0: { 357 case 0: {
357 Config cfg( "qpe" ); 358 Config cfg( "qpe" );
358 cfg.setGroup( "Volume" ); 359 cfg.setGroup( "Volume" );
359 if ( percent < 0 ) 360 if ( percent < 0 )
360 percent = cfg.readNumEntry( "Mic", 50 ); 361 percent = cfg.readNumEntry( "Mic", 50 );
361 362
362 int fd = 0; 363 int fd = 0;
363 int mic = micMuted ? 0 : percent; 364 int mic = micMuted ? 0 : percent;
364 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { 365 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) {
365 ioctl( fd, MIXER_WRITE( SOUND_MIXER_MIC ), &mic ); 366 ioctl( fd, MIXER_WRITE( SOUND_MIXER_MIC ), &mic );
366 ::close( fd ); 367 ::close( fd );
367 } 368 }
368 } 369 }
369 break; 370 break;
370 } 371 }
371} 372}
372 373
373 374
374static void setBass( int t = 0, int percent = -1 ) 375static void setBass( int t = 0, int percent = -1 )
375{ 376{
376 switch ( t ) { 377 switch ( t ) {
377 case 0: { 378 case 0: {
378 Config cfg( "qpe" ); 379 Config cfg( "qpe" );
379 cfg.setGroup( "Volume" ); 380 cfg.setGroup( "Volume" );
380 if ( percent < 0 ) 381 if ( percent < 0 )
381 percent = cfg.readNumEntry( "BassPercent", 50 ); 382 percent = cfg.readNumEntry( "BassPercent", 50 );
382 383
383 int fd = 0; 384 int fd = 0;
384 int bass = percent; 385 int bass = percent;
385 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { 386 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) {
386 ioctl( fd, MIXER_WRITE( SOUND_MIXER_BASS ), &bass ); 387 ioctl( fd, MIXER_WRITE( SOUND_MIXER_BASS ), &bass );
387 ::close( fd ); 388 ::close( fd );
388 } 389 }
389 } 390 }
390 break; 391 break;
391 } 392 }
392} 393}
393 394
394 395
395static void setTreble( int t = 0, int percent = -1 ) 396static void setTreble( int t = 0, int percent = -1 )
396{ 397{
397 switch ( t ) { 398 switch ( t ) {
398 case 0: { 399 case 0: {
399 Config cfg( "qpe" ); 400 Config cfg( "qpe" );
400 cfg.setGroup( "Volume" ); 401 cfg.setGroup( "Volume" );
401 if ( percent < 0 ) 402 if ( percent < 0 )
402 percent = cfg.readNumEntry( "TreblePercent", 50 ); 403 percent = cfg.readNumEntry( "TreblePercent", 50 );
403 404
404 int fd = 0; 405 int fd = 0;
405 int treble = percent; 406 int treble = percent;
406 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { 407 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) {
407 ioctl( fd, MIXER_WRITE( SOUND_MIXER_TREBLE ), &treble ); 408 ioctl( fd, MIXER_WRITE( SOUND_MIXER_TREBLE ), &treble );
408 ::close( fd ); 409 ::close( fd );
409 } 410 }
410 } 411 }
411 break; 412 break;
412 } 413 }
413} 414}
414 415
415 416
416/*! 417/*!
417 \class QPEApplication qpeapplication.h 418 \class QPEApplication qpeapplication.h
418 \brief The QPEApplication class implements various system services 419 \brief The QPEApplication class implements various system services
419 that are available to all Qtopia applications. 420 that are available to all Qtopia applications.
420 421
421 Simply by using QPEApplication instead of QApplication, a standard Qt 422 Simply by using QPEApplication instead of QApplication, a standard Qt
422 application becomes a Qtopia application. It automatically follows 423 application becomes a Qtopia application. It automatically follows
423 style changes, quits and raises, and in the 424 style changes, quits and raises, and in the
424 case of \link docwidget.html document-oriented\endlink applications, 425 case of \link docwidget.html document-oriented\endlink applications,
425 changes the currently displayed document in response to the environment. 426 changes the currently displayed document in response to the environment.
426 427
427 To create a \link docwidget.html document-oriented\endlink 428 To create a \link docwidget.html document-oriented\endlink
428 application use showMainDocumentWidget(); to create a 429 application use showMainDocumentWidget(); to create a
429 non-document-oriented application use showMainWidget(). The 430 non-document-oriented application use showMainWidget(). The
430 keepRunning() function indicates whether the application will 431 keepRunning() function indicates whether the application will
431 continue running after it's processed the last \link qcop.html 432 continue running after it's processed the last \link qcop.html
432 QCop\endlink message. This can be changed using setKeepRunning(). 433 QCop\endlink message. This can be changed using setKeepRunning().
433 434
434 A variety of signals are emitted when certain events occur, for 435 A variety of signals are emitted when certain events occur, for
435 example, timeChanged(), clockChanged(), weekChanged(), 436 example, timeChanged(), clockChanged(), weekChanged(),
436 dateFormatChanged() and volumeChanged(). If the application receives 437 dateFormatChanged() and volumeChanged(). If the application receives
437 a \link qcop.html QCop\endlink message on the application's 438 a \link qcop.html QCop\endlink message on the application's
438 QPE/Application/\e{appname} channel, the appMessage() signal is 439 QPE/Application/\e{appname} channel, the appMessage() signal is
439 emitted. There are also flush() and reload() signals, which 440 emitted. There are also flush() and reload() signals, which
440 are emitted when synching begins and ends respectively - upon these 441 are emitted when synching begins and ends respectively - upon these
441 signals, the application should save and reload any data 442 signals, the application should save and reload any data
442 files that are involved in synching. Most of these signals will initially 443 files that are involved in synching. Most of these signals will initially
443 be received and unfiltered through the appMessage() signal. 444 be received and unfiltered through the appMessage() signal.
444 445
445 This class also provides a set of useful static functions. The 446 This class also provides a set of useful static functions. The
446 qpeDir() and documentDir() functions return the respective paths. 447 qpeDir() and documentDir() functions return the respective paths.
447 The grabKeyboard() and ungrabKeyboard() functions are used to 448 The grabKeyboard() and ungrabKeyboard() functions are used to
448 control whether the application takes control of the device's 449 control whether the application takes control of the device's
449 physical buttons (e.g. application launch keys). The stylus' mode of 450 physical buttons (e.g. application launch keys). The stylus' mode of
450 operation is set with setStylusOperation() and retrieved with 451 operation is set with setStylusOperation() and retrieved with
451 stylusOperation(). There are also setInputMethodHint() and 452 stylusOperation(). There are also setInputMethodHint() and
452 inputMethodHint() functions. 453 inputMethodHint() functions.
453 454
454 \ingroup qtopiaemb 455 \ingroup qtopiaemb
455*/ 456*/
456 457
457/*! 458/*!
458 \fn void QPEApplication::clientMoused() 459 \fn void QPEApplication::clientMoused()
459 460
460 \internal 461 \internal
461*/ 462*/
462 463
463/*! 464/*!
464 \fn void QPEApplication::timeChanged(); 465 \fn void QPEApplication::timeChanged();
465 This signal is emitted when the time changes outside the normal 466 This signal is emitted when the time changes outside the normal
466 passage of time, i.e. if the time is set backwards or forwards. 467 passage of time, i.e. if the time is set backwards or forwards.
467*/ 468*/
468 469
469/*! 470/*!
470 \fn void QPEApplication::clockChanged( bool ampm ); 471 \fn void QPEApplication::clockChanged( bool ampm );
471 472
472 This signal is emitted when the user changes the clock's style. If 473 This signal is emitted when the user changes the clock's style. If
473 \a ampm is TRUE, the user wants a 12-hour AM/PM clock, otherwise, 474 \a ampm is TRUE, the user wants a 12-hour AM/PM clock, otherwise,
474 they want a 24-hour clock. 475 they want a 24-hour clock.
475*/ 476*/
476 477
477/*! 478/*!
478 \fn void QPEApplication::volumeChanged( bool muted ) 479 \fn void QPEApplication::volumeChanged( bool muted )
479 480
480 This signal is emitted whenever the mute state is changed. If \a 481 This signal is emitted whenever the mute state is changed. If \a
481 muted is TRUE, then sound output has been muted. 482 muted is TRUE, then sound output has been muted.
482*/ 483*/
483 484
484/*! 485/*!
485 \fn void QPEApplication::weekChanged( bool startOnMonday ) 486 \fn void QPEApplication::weekChanged( bool startOnMonday )
486 487
487 This signal is emitted if the week start day is changed. If \a 488 This signal is emitted if the week start day is changed. If \a
488 startOnMonday is TRUE then the first day of the week is Monday; if 489 startOnMonday is TRUE then the first day of the week is Monday; if
489 \a startOnMonday is FALSE then the first day of the week is 490 \a startOnMonday is FALSE then the first day of the week is
490 Sunday. 491 Sunday.
491*/ 492*/
492 493
493/*! 494/*!
494 \fn void QPEApplication::dateFormatChanged(DateFormat) 495 \fn void QPEApplication::dateFormatChanged(DateFormat)
495 496
496 This signal is emitted whenever the date format is changed. 497 This signal is emitted whenever the date format is changed.
497*/ 498*/
498 499
499/*! 500/*!
500 \fn void QPEApplication::flush() 501 \fn void QPEApplication::flush()
501 502
502 ### 503 ###
503*/ 504*/
504 505
505/*! 506/*!
506 \fn void QPEApplication::reload() 507 \fn void QPEApplication::reload()
507 508
508*/ 509*/
509 510
510 511
511 512
512void QPEApplication::processQCopFile() 513void QPEApplication::processQCopFile()
513{ 514{
514 QString qcopfn("/tmp/qcop-msg-"); 515 QString qcopfn("/tmp/qcop-msg-");
515 qcopfn += d->appName; // append command name 516 qcopfn += d->appName; // append command name
516 517
517 QFile f(qcopfn); 518 QFile f(qcopfn);
518 if ( f.open(IO_ReadWrite) ) { 519 if ( f.open(IO_ReadWrite) ) {
519#ifndef Q_OS_WIN32 520#ifndef Q_OS_WIN32
520 flock(f.handle(), LOCK_EX); 521 flock(f.handle(), LOCK_EX);
521#endif 522#endif
522 QDataStream ds(&f); 523 QDataStream ds(&f);
523 QCString channel, message; 524 QCString channel, message;
524 QByteArray data; 525 QByteArray data;
525 while(!ds.atEnd()) { 526 while(!ds.atEnd()) {
526 ds >> channel >> message >> data; 527 ds >> channel >> message >> data;
527 d->enqueueQCop(channel,message,data); 528 d->enqueueQCop(channel,message,data);
528 } 529 }
529 ::ftruncate(f.handle(), 0); 530 ::ftruncate(f.handle(), 0);
530#ifndef Q_OS_WIN32 531#ifndef Q_OS_WIN32
531 f.flush(); 532 f.flush();
532 flock(f.handle(), LOCK_UN); 533 flock(f.handle(), LOCK_UN);
533#endif 534#endif
534 } 535 }
535#endif 536#endif
536} 537}
537 538
538 539
539/*! 540/*!
540 \fn void QPEApplication::appMessage( const QCString& msg, const QByteArray& data ) 541 \fn void QPEApplication::appMessage( const QCString& msg, const QByteArray& data )
541 542
542 This signal is emitted when a message is received on this 543 This signal is emitted when a message is received on this
543 application's QPE/Application/<i>appname</i> \link qcop.html 544 application's QPE/Application/<i>appname</i> \link qcop.html
544 QCop\endlink channel. 545 QCop\endlink channel.
545 546
546 The slot to which you connect this signal uses \a msg and \a data 547 The slot to which you connect this signal uses \a msg and \a data
547 in the following way: 548 in the following way:
548 549
549\code 550\code
550 void MyWidget::receive( const QCString& msg, const QByteArray& data ) 551 void MyWidget::receive( const QCString& msg, const QByteArray& data )
551 { 552 {
552 QDataStream stream( data, IO_ReadOnly ); 553 QDataStream stream( data, IO_ReadOnly );
553 if ( msg == "someMessage(int,int,int)" ) { 554 if ( msg == "someMessage(int,int,int)" ) {
554 int a,b,c; 555 int a,b,c;
555 stream >> a >> b >> c; 556 stream >> a >> b >> c;
556 ... 557 ...
557 } else if ( msg == "otherMessage(QString)" ) { 558 } else if ( msg == "otherMessage(QString)" ) {
558 ... 559 ...
559 } 560 }
560 } 561 }
561\endcode 562\endcode
562 563
563 \sa qcop.html 564 \sa qcop.html
564 Note that messages received here may be processed by qpe application 565 Note that messages received here may be processed by qpe application
565 and emitted as signals, such as flush() and reload(). 566 and emitted as signals, such as flush() and reload().
566*/ 567*/
567 568
568/*! 569/*!
569 Constructs a QPEApplication just as you would construct 570 Constructs a QPEApplication just as you would construct
570 a QApplication, passing \a argc, \a argv, and \a t. 571 a QApplication, passing \a argc, \a argv, and \a t.
571 572
572 For applications, \a t should be the default, GuiClient. Only 573 For applications, \a t should be the default, GuiClient. Only
573 the Qtopia server passes GuiServer. 574 the Qtopia server passes GuiServer.
574*/ 575*/
575QPEApplication::QPEApplication( int & argc, char **argv, Type t ) 576QPEApplication::QPEApplication( int & argc, char **argv, Type t )
576 : QApplication( hack(argc), argv, t ), pidChannel( 0 ) 577 : QApplication( hack(argc), argv, t ), pidChannel( 0 )
577{ 578{
578 d = new QPEApplicationData; 579 d = new QPEApplicationData;
579 d->loadTextCodecs(); 580 d->loadTextCodecs();
580 d->loadImageCodecs(); 581 d->loadImageCodecs();
581 int dw = desktop() ->width(); 582 int dw = desktop() ->width();
582 583
583 if ( dw < 200 ) { 584 if ( dw < 200 ) {
584 setFont( QFont( "vera", 8 ) ); 585 setFont( QFont( "vera", 8 ) );
585 AppLnk::setSmallIconSize( 10 ); 586 AppLnk::setSmallIconSize( 10 );
586 AppLnk::setBigIconSize( 28 ); 587 AppLnk::setBigIconSize( 28 );
587 } 588 }
588#ifndef QT_QWS_SIMPAD 589#ifndef QT_QWS_SIMPAD
589 else if ( dw > 600 ) { 590 else if ( dw > 600 ) {
590 setFont( QFont( "vera", 16 ) ); 591 setFont( QFont( "vera", 16 ) );
591 AppLnk::setSmallIconSize( 24 ); 592 AppLnk::setSmallIconSize( 24 );
592 AppLnk::setBigIconSize( 48 ); 593 AppLnk::setBigIconSize( 48 );
593 } 594 }
594#endif 595#endif
595 else if ( dw > 200 ) { 596 else if ( dw > 200 ) {
596 setFont( QFont( "vera", 10 ) ); 597 setFont( QFont( "vera", 10 ) );
597 AppLnk::setSmallIconSize( 14 ); 598 AppLnk::setSmallIconSize( 14 );
598 AppLnk::setBigIconSize( 32 ); 599 AppLnk::setBigIconSize( 32 );
599 } 600 }
600 601
601 QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory ); 602 QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory );
602 603
603 connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) ); 604 connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) );
604 605
605 606
606 sysChannel = new QCopChannel( "QPE/System", this ); 607 sysChannel = new QCopChannel( "QPE/System", this );
607 connect( sysChannel, SIGNAL( received( const QCString &, const QByteArray & ) ), 608 connect( sysChannel, SIGNAL( received( const QCString &, const QByteArray & ) ),
608 this, SLOT( systemMessage( const QCString &, const QByteArray & ) ) ); 609 this, SLOT( systemMessage( const QCString &, const QByteArray & ) ) );
609 610
610/* COde now in initapp */ 611/* COde now in initapp */
611#if 0 612#if 0
612#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 613#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
613 614
614 QString qcopfn( "/tmp/qcop-msg-" ); 615 QString qcopfn( "/tmp/qcop-msg-" );
615 qcopfn += QString( argv[ 0 ] ); // append command name 616 qcopfn += QString( argv[ 0 ] ); // append command name
616 617
617 QFile f( qcopfn ); 618 QFile f( qcopfn );
618 if ( f.open( IO_ReadOnly ) ) { 619 if ( f.open( IO_ReadOnly ) ) {
619 flock( f.handle(), LOCK_EX ); 620 flock( f.handle(), LOCK_EX );
620 } 621 }
621 622
622 623
623 624
624 QCString channel = QCString( argv[ 0 ] ); 625 QCString channel = QCString( argv[ 0 ] );
625 channel.replace( QRegExp( ".*/" ), "" ); 626 channel.replace( QRegExp( ".*/" ), "" );
626 d->appName = channel; 627 d->appName = channel;
627 channel = "QPE/Application/" + channel; 628 channel = "QPE/Application/" + channel;
628 pidChannel = new QCopChannel( channel, this ); 629 pidChannel = new QCopChannel( channel, this );
629 connect( pidChannel, SIGNAL( received( const QCString &, const QByteArray & ) ), 630 connect( pidChannel, SIGNAL( received( const QCString &, const QByteArray & ) ),
630 this, SLOT( pidMessage( const QCString &, const QByteArray & ) ) ); 631 this, SLOT( pidMessage( const QCString &, const QByteArray & ) ) );
631 632
632 if ( f.isOpen() ) { 633 if ( f.isOpen() ) {
633 d->keep_running = FALSE; 634 d->keep_running = FALSE;
634 QDataStream ds( &f ); 635 QDataStream ds( &f );
635 QCString channel, message; 636 QCString channel, message;
636 QByteArray data; 637 QByteArray data;
637 while ( !ds.atEnd() ) { 638 while ( !ds.atEnd() ) {
638 ds >> channel >> message >> data; 639 ds >> channel >> message >> data;
639 d->enqueueQCop( channel, message, data ); 640 d->enqueueQCop( channel, message, data );
640 } 641 }
641 642
642 flock( f.handle(), LOCK_UN ); 643 flock( f.handle(), LOCK_UN );
643 f.close(); 644 f.close();
644 f.remove(); 645 f.remove();
645 } 646 }
646 647
647 for ( int a = 0; a < argc; a++ ) { 648 for ( int a = 0; a < argc; a++ ) {
648 if ( qstrcmp( argv[ a ], "-preload" ) == 0 ) { 649 if ( qstrcmp( argv[ a ], "-preload" ) == 0 ) {
649 argv[ a ] = argv[ a + 1 ]; 650 argv[ a ] = argv[ a + 1 ];
650 a++; 651 a++;
651 d->preloaded = TRUE; 652 d->preloaded = TRUE;
652 argc -= 1; 653 argc -= 1;
653 } 654 }
654 else if ( qstrcmp( argv[ a ], "-preload-show" ) == 0 ) { 655 else if ( qstrcmp( argv[ a ], "-preload-show" ) == 0 ) {
655 argv[ a ] = argv[ a + 1 ]; 656 argv[ a ] = argv[ a + 1 ];
656 a++; 657 a++;
657 d->preloaded = TRUE; 658 d->preloaded = TRUE;
658 d->forceshow = TRUE; 659 d->forceshow = TRUE;
659 argc -= 1; 660 argc -= 1;
660 } 661 }
661 } 662 }
662 663
663 /* overide stored arguments */ 664 /* overide stored arguments */
664 setArgs( argc, argv ); 665 setArgs( argc, argv );
665 666
666#endif 667#endif
667#else 668#else
668 initApp( argc, argv ); 669 initApp( argc, argv );
669#endif 670#endif
670 // qwsSetDecoration( new QPEDecoration() ); 671 // qwsSetDecoration( new QPEDecoration() );
671 672
672#ifndef QT_NO_TRANSLATION 673#ifndef QT_NO_TRANSLATION
673 674
674 d->langs = Global::languageList(); 675 d->langs = Global::languageList();
675 for ( QStringList::ConstIterator it = d->langs.begin(); it != d->langs.end(); ++it ) { 676 for ( QStringList::ConstIterator it = d->langs.begin(); it != d->langs.end(); ++it ) {
676 QString lang = *it; 677 QString lang = *it;
677 678
678 installTranslation( lang + "/libopie.qm"); 679 installTranslation( lang + "/libopie.qm");
679 installTranslation( lang + "/libqpe.qm" ); 680 installTranslation( lang + "/libqpe.qm" );
680 installTranslation( lang + "/" + d->appName + ".qm" ); 681 installTranslation( lang + "/" + d->appName + ".qm" );
681 682
682 683
683 //###language/font hack; should look it up somewhere 684 //###language/font hack; should look it up somewhere
684#ifdef QWS 685#ifdef QWS
685 686
686 if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) { 687 if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) {
687 QFont fn = FontManager::unicodeFont( FontManager::Proportional ); 688 QFont fn = FontManager::unicodeFont( FontManager::Proportional );
688 setFont( fn ); 689 setFont( fn );
689 } 690 }
690#endif 691#endif
691 } 692 }
692#endif 693#endif
693 694
694 applyStyle(); 695 applyStyle();
695 696
696 if ( type() == GuiServer ) { 697 if ( type() == GuiServer ) {
697 setVolume(); 698 setVolume();
698 } 699 }
699 700
700 installEventFilter( this ); 701 installEventFilter( this );
701 702
702 QPEMenuToolFocusManager::initialize(); 703 QPEMenuToolFocusManager::initialize();
703 704
704#ifdef QT_NO_QWS_CURSOR 705#ifdef QT_NO_QWS_CURSOR
705 // if we have no cursor, probably don't want tooltips 706 // if we have no cursor, probably don't want tooltips
706 QToolTip::setEnabled( FALSE ); 707 QToolTip::setEnabled( FALSE );
707#endif 708#endif
708} 709}
709 710
710 711
711#ifdef QTOPIA_INTERNAL_INITAPP 712#ifdef QTOPIA_INTERNAL_INITAPP
712void QPEApplication::initApp( int argc, char **argv ) 713void QPEApplication::initApp( int argc, char **argv )
713{ 714{
714 bool initial = pidChannel; // was set to 0 in the initializer 715 bool initial = pidChannel; // was set to 0 in the initializer
715 delete pidChannel; 716 delete pidChannel;
716 d->keep_running = TRUE; 717 d->keep_running = TRUE;
717 d->preloaded = FALSE; 718 d->preloaded = FALSE;
718 d->forceshow = FALSE; 719 d->forceshow = FALSE;
719 720
720 QCString channel = QCString(argv[0]); 721 QCString channel = QCString(argv[0]);
721 722
722 channel.replace(QRegExp(".*/"),""); 723 channel.replace(QRegExp(".*/"),"");
723 d->appName = channel; 724 d->appName = channel;
724 725
725 #if QT_VERSION > 235 726 #if QT_VERSION > 235
726 qt_fbdpy->setIdentity( channel ); // In Qt/E 2.3.6 727 qt_fbdpy->setIdentity( channel ); // In Qt/E 2.3.6
727 #endif 728 #endif
728 729
729 channel = "QPE/Application/" + channel; 730 channel = "QPE/Application/" + channel;
730 pidChannel = new QCopChannel( channel, this); 731 pidChannel = new QCopChannel( channel, this);
731 connect( pidChannel, SIGNAL(received(const QCString &, const QByteArray &)), 732 connect( pidChannel, SIGNAL(received(const QCString &, const QByteArray &)),
732 this, SLOT(pidMessage(const QCString &, const QByteArray &))); 733 this, SLOT(pidMessage(const QCString &, const QByteArray &)));
733 734
734 if (!initial) { 735 if (!initial) {
735 processQCopFile(); 736 processQCopFile();
736 d->keep_running = d->qcopq.isEmpty(); 737 d->keep_running = d->qcopq.isEmpty();
737 } 738 }
738 739
739 for (int a=0; a<argc; a++) { 740 for (int a=0; a<argc; a++) {
740 if ( qstrcmp(argv[a],"-preload")==0 ) { 741 if ( qstrcmp(argv[a],"-preload")==0 ) {
741 argv[a] = argv[a+1]; 742 argv[a] = argv[a+1];
742 a++; 743 a++;
743 d->preloaded = TRUE; 744 d->preloaded = TRUE;
744 argc-=1; 745 argc-=1;
745 } else if ( qstrcmp(argv[a],"-preload-show")==0 ) { 746 } else if ( qstrcmp(argv[a],"-preload-show")==0 ) {
746 argv[a] = argv[a+1]; 747 argv[a] = argv[a+1];
747 a++; 748 a++;
748 d->preloaded = TRUE; 749 d->preloaded = TRUE;
749 d->forceshow = TRUE; 750 d->forceshow = TRUE;
750 argc-=1; 751 argc-=1;
751 } 752 }
752 } 753 }
753 754
754 /* overide stored arguments */ 755 /* overide stored arguments */
755 setArgs(argc, argv); 756 setArgs(argc, argv);
756 757
757 /* install translation here */ 758 /* install translation here */
758 for ( QStringList::ConstIterator it = d->langs.begin(); it != d->langs.end(); ++it ) 759 for ( QStringList::ConstIterator it = d->langs.begin(); it != d->langs.end(); ++it )
759 installTranslation( (*it) + "/" + d->appName + ".qm" ); 760 installTranslation( (*it) + "/" + d->appName + ".qm" );
760} 761}
761#endif 762#endif
762 763
763 764
764static QPtrDict<void>* inputMethodDict = 0; 765static QPtrDict<void>* inputMethodDict = 0;
765static void createInputMethodDict() 766static void createInputMethodDict()
766{ 767{
767 if ( !inputMethodDict ) 768 if ( !inputMethodDict )
768 inputMethodDict = new QPtrDict<void>; 769 inputMethodDict = new QPtrDict<void>;
769} 770}
770 771
771/*! 772/*!
772 Returns the currently set hint to the system as to whether 773 Returns the currently set hint to the system as to whether
773 widget \a w has any use for text input methods. 774 widget \a w has any use for text input methods.
774 775
775 776
776 \sa setInputMethodHint() InputMethodHint 777 \sa setInputMethodHint() InputMethodHint
777*/ 778*/
778QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w ) 779QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w )
779{ 780{
780 if ( inputMethodDict && w ) 781 if ( inputMethodDict && w )
781 return ( InputMethodHint ) ( int ) inputMethodDict->find( w ); 782 return ( InputMethodHint ) ( int ) inputMethodDict->find( w );
782 return Normal; 783 return Normal;
783} 784}
784 785
785/*! 786/*!
786 \enum QPEApplication::InputMethodHint 787 \enum QPEApplication::InputMethodHint
787 788
788 \value Normal the application sometimes needs text input (the default). 789 \value Normal the application sometimes needs text input (the default).
789 \value AlwaysOff the application never needs text input. 790 \value AlwaysOff the application never needs text input.
790 \value AlwaysOn the application always needs text input. 791 \value AlwaysOn the application always needs text input.
791*/ 792*/
792 793
793/*! 794/*!
794 Hints to the system that widget \a w has use for text input methods 795 Hints to the system that widget \a w has use for text input methods
795 as specified by \a mode. 796 as specified by \a mode.
796 797
797 \sa inputMethodHint() InputMethodHint 798 \sa inputMethodHint() InputMethodHint
798*/ 799*/
799void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode ) 800void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode )
800{ 801{
801 createInputMethodDict(); 802 createInputMethodDict();
802 if ( mode == Normal ) { 803 if ( mode == Normal ) {
803 inputMethodDict->remove 804 inputMethodDict->remove
804 ( w ); 805 ( w );
805 } 806 }
806 else { 807 else {
807 inputMethodDict->insert( w, ( void* ) mode ); 808 inputMethodDict->insert( w, ( void* ) mode );
808 } 809 }
809} 810}
810 811
811class HackDialog : public QDialog 812class HackDialog : public QDialog
812{ 813{
813public: 814public:
814 void acceptIt() 815 void acceptIt()
815 { 816 {
816 accept(); 817 accept();
817 } 818 }
818 void rejectIt() 819 void rejectIt()
819 { 820 {
820 reject(); 821 reject();
821 } 822 }
822}; 823};
823 824
824 825
825void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key ) 826void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key )
826{ 827{
827 // specialised actions for certain widgets. May want to 828 // specialised actions for certain widgets. May want to
828 // add more stuff here. 829 // add more stuff here.
829 if ( activePopupWidget() && activePopupWidget() ->inherits( "QListBox" ) 830 if ( activePopupWidget() && activePopupWidget() ->inherits( "QListBox" )
830 && activePopupWidget() ->parentWidget() 831 && activePopupWidget() ->parentWidget()
831 && activePopupWidget() ->parentWidget() ->inherits( "QComboBox" ) ) 832 && activePopupWidget() ->parentWidget() ->inherits( "QComboBox" ) )
832 key = Qt::Key_Return; 833 key = Qt::Key_Return;
833 834
834 if ( activePopupWidget() && activePopupWidget() ->inherits( "QPopupMenu" ) ) 835 if ( activePopupWidget() && activePopupWidget() ->inherits( "QPopupMenu" ) )
835 key = Qt::Key_Return; 836 key = Qt::Key_Return;
836 837
837#ifdef QWS 838#ifdef QWS
838 839
839 ke->simpleData.keycode = key; 840 ke->simpleData.keycode = key;
840#endif 841#endif
841} 842}
842 843
843class HackWidget : public QWidget 844class HackWidget : public QWidget
844{ 845{
845public: 846public:
846 bool needsOk() 847 bool needsOk()
847 { 848 {
848 return ( getWState() & WState_Reserved1 ); 849 return ( getWState() & WState_Reserved1 );
849 } 850 }
850}; 851};
851 852
852/*! 853/*!
853 \internal 854 \internal
854*/ 855*/
855 856
856#ifdef QWS 857#ifdef QWS
857bool QPEApplication::qwsEventFilter( QWSEvent * e ) 858bool QPEApplication::qwsEventFilter( QWSEvent * e )
858{ 859{
859 if ( !d->notbusysent && e->type == QWSEvent::Focus ) { 860 if ( !d->notbusysent && e->type == QWSEvent::Focus ) {
860 if ( qApp->type() != QApplication::GuiServer ) { 861 if ( qApp->type() != QApplication::GuiServer ) {
861 QCopEnvelope e( "QPE/System", "notBusy(QString)" ); 862 QCopEnvelope e( "QPE/System", "notBusy(QString)" );
862 e << d->appName; 863 e << d->appName;
863 } 864 }
864 d->notbusysent = TRUE; 865 d->notbusysent = TRUE;
865 } 866 }
866 if ( type() == GuiServer ) { 867 if ( type() == GuiServer ) {
867 switch ( e->type ) { 868 switch ( e->type ) {
868 case QWSEvent::Mouse: 869 case QWSEvent::Mouse:
869 if ( e->asMouse() ->simpleData.state && !QWidget::find( e->window() ) ) 870 if ( e->asMouse() ->simpleData.state && !QWidget::find( e->window() ) )
870 emit clientMoused(); 871 emit clientMoused();
871 break; 872 break;
872 default: 873 default:
873 break; 874 break;
874 } 875 }
875 } 876 }
876 if ( e->type == QWSEvent::Key ) { 877 if ( e->type == QWSEvent::Key ) {
877 QWSKeyEvent *ke = ( QWSKeyEvent * ) e; 878 QWSKeyEvent *ke = ( QWSKeyEvent * ) e;
878 if ( ke->simpleData.keycode == Qt::Key_F33 ) { 879 if ( ke->simpleData.keycode == Qt::Key_F33 ) {
879 // Use special "OK" key to press "OK" on top level widgets 880 // Use special "OK" key to press "OK" on top level widgets
880 QWidget * active = activeWindow(); 881 QWidget * active = activeWindow();
881 QWidget *popup = 0; 882 QWidget *popup = 0;
882 if ( active && active->isPopup() ) { 883 if ( active && active->isPopup() ) {
883 popup = active; 884 popup = active;
884 active = active->parentWidget(); 885 active = active->parentWidget();
885 } 886 }
886 if ( active && ( int ) active->winId() == ke->simpleData.window && 887 if ( active && ( int ) active->winId() == ke->simpleData.window &&
887 !active->testWFlags( WStyle_Customize | WType_Popup | WType_Desktop ) ) { 888 !active->testWFlags( WStyle_Customize | WType_Popup | WType_Desktop ) ) {
888 if ( ke->simpleData.is_press ) { 889 if ( ke->simpleData.is_press ) {
889 if ( popup ) 890 if ( popup )
890 popup->close(); 891 popup->close();
891 if ( active->inherits( "QDialog" ) ) { 892 if ( active->inherits( "QDialog" ) ) {
892 HackDialog * d = ( HackDialog * ) active; 893 HackDialog * d = ( HackDialog * ) active;
893 d->acceptIt(); 894 d->acceptIt();
894 return TRUE; 895 return TRUE;
895 } 896 }
896 else if ( ( ( HackWidget * ) active ) ->needsOk() ) { 897 else if ( ( ( HackWidget * ) active ) ->needsOk() ) {
897 QSignal s; 898 QSignal s;
898 s.connect( active, SLOT( accept() ) ); 899 s.connect( active, SLOT( accept() ) );
899 s.activate(); 900 s.activate();
900 } 901 }
901 else { 902 else {
902 // do the same as with the select key: Map to the default action of the widget: 903 // do the same as with the select key: Map to the default action of the widget:
903 mapToDefaultAction( ke, Qt::Key_Return ); 904 mapToDefaultAction( ke, Qt::Key_Return );
904 } 905 }
905 } 906 }
906 } 907 }
907 } 908 }
908 else if ( ke->simpleData.keycode == Qt::Key_F30 ) { 909 else if ( ke->simpleData.keycode == Qt::Key_F30 ) {
909 // Use special "select" key to do whatever default action a widget has 910 // Use special "select" key to do whatever default action a widget has
910 mapToDefaultAction( ke, Qt::Key_Space ); 911 mapToDefaultAction( ke, Qt::Key_Space );
911 } 912 }
912 else if ( ke->simpleData.keycode == Qt::Key_Escape && 913 else if ( ke->simpleData.keycode == Qt::Key_Escape &&
913 ke->simpleData.is_press ) { 914 ke->simpleData.is_press ) {
914 // Escape key closes app if focus on toplevel 915 // Escape key closes app if focus on toplevel
915 QWidget * active = activeWindow(); 916 QWidget * active = activeWindow();
916 if ( active && active->testWFlags( WType_TopLevel ) && 917 if ( active && active->testWFlags( WType_TopLevel ) &&
917 ( int ) active->winId() == ke->simpleData.window && 918 ( int ) active->winId() == ke->simpleData.window &&
918 !active->testWFlags( WStyle_Dialog | WStyle_Customize | WType_Popup | WType_Desktop ) ) { 919 !active->testWFlags( WStyle_Dialog | WStyle_Customize | WType_Popup | WType_Desktop ) ) {
919 if ( active->inherits( "QDialog" ) ) { 920 if ( active->inherits( "QDialog" ) ) {
920 HackDialog * d = ( HackDialog * ) active; 921 HackDialog * d = ( HackDialog * ) active;
921 d->rejectIt(); 922 d->rejectIt();
922 return TRUE; 923 return TRUE;
923 } 924 }
924 else if ( strcmp( argv() [ 0 ], "embeddedkonsole" ) != 0 ) { 925 else if ( strcmp( argv() [ 0 ], "embeddedkonsole" ) != 0 ) {
925 active->close(); 926 active->close();
926 } 927 }
927 } 928 }
928 } 929 }
929 else if ( ke->simpleData.keycode >= Qt::Key_F1 && ke->simpleData.keycode <= Qt::Key_F29 ) { 930 else if ( ke->simpleData.keycode >= Qt::Key_F1 && ke->simpleData.keycode <= Qt::Key_F29 ) {
930 // this should be if ( ODevice::inst ( )-> buttonForKeycode ( ... )) 931 // this should be if ( ODevice::inst ( )-> buttonForKeycode ( ... ))
931 // but we cannot access libopie function within libqpe :( 932 // but we cannot access libopie function within libqpe :(
932 933
933 QWidget * active = activeWindow ( ); 934 QWidget * active = activeWindow ( );
934 if ( active && ((int) active-> winId ( ) == ke-> simpleData.window )) { 935 if ( active && ((int) active-> winId ( ) == ke-> simpleData.window )) {
935 if ( d-> kbgrabbed ) { // we grabbed the keyboard 936 if ( d-> kbgrabbed ) { // we grabbed the keyboard
936 QChar ch ( ke-> simpleData.unicode ); 937 QChar ch ( ke-> simpleData.unicode );
937 QKeyEvent qke ( ke-> simpleData. is_press ? QEvent::KeyPress : QEvent::KeyRelease, 938 QKeyEvent qke ( ke-> simpleData. is_press ? QEvent::KeyPress : QEvent::KeyRelease,
938 ke-> simpleData.keycode, 939 ke-> simpleData.keycode,
939 ch. latin1 ( ), 940 ch. latin1 ( ),
940 ke-> simpleData.modifiers, 941 ke-> simpleData.modifiers,
941 QString ( ch ), 942 QString ( ch ),
942 ke-> simpleData.is_auto_repeat, 1 ); 943 ke-> simpleData.is_auto_repeat, 1 );
943 944
944 QObject *which = QWidget::keyboardGrabber ( ); 945 QObject *which = QWidget::keyboardGrabber ( );
945 if ( !which ) 946 if ( !which )
946 which = QApplication::focusWidget ( ); 947 which = QApplication::focusWidget ( );
947 if ( !which ) 948 if ( !which )
948 which = QApplication::activeWindow ( ); 949 which = QApplication::activeWindow ( );
949 if ( !which ) 950 if ( !which )
950 which = qApp; 951 which = qApp;
951 952
952 QApplication::sendEvent ( which, &qke ); 953 QApplication::sendEvent ( which, &qke );
953 } 954 }
954 else { // we didn't grab the keyboard, so send the event to the launcher 955 else { // we didn't grab the keyboard, so send the event to the launcher
955 QCopEnvelope e ( "QPE/Launcher", "deviceButton(int,int,int)" ); 956 QCopEnvelope e ( "QPE/Launcher", "deviceButton(int,int,int)" );
956 e << int( ke-> simpleData.keycode ) << int( ke-> simpleData. is_press ) << int( ke-> simpleData.is_auto_repeat ); 957 e << int( ke-> simpleData.keycode ) << int( ke-> simpleData. is_press ) << int( ke-> simpleData.is_auto_repeat );
957 } 958 }
958 } 959 }
959 return true; 960 return true;
960 } 961 }
961 } 962 }
962 if ( e->type == QWSEvent::Focus ) { 963 if ( e->type == QWSEvent::Focus ) {
963 QWSFocusEvent * fe = ( QWSFocusEvent* ) e; 964 QWSFocusEvent * fe = ( QWSFocusEvent* ) e;
964 if ( !fe->simpleData.get_focus ) { 965 if ( !fe->simpleData.get_focus ) {
965 QWidget * active = activeWindow(); 966 QWidget * active = activeWindow();
966 while ( active && active->isPopup() ) { 967 while ( active && active->isPopup() ) {
967 active->close(); 968 active->close();
968 active = activeWindow(); 969 active = activeWindow();
969 } 970 }
970 } 971 }
971 else { 972 else {
972 // make sure our modal widget is ALWAYS on top 973 // make sure our modal widget is ALWAYS on top
973 QWidget *topm = activeModalWidget(); 974 QWidget *topm = activeModalWidget();
974 if ( topm ) { 975 if ( topm ) {
975 topm->raise(); 976 topm->raise();
976 } 977 }
977 } 978 }
978 if ( fe->simpleData.get_focus && inputMethodDict ) { 979 if ( fe->simpleData.get_focus && inputMethodDict ) {
979 InputMethodHint m = inputMethodHint( QWidget::find( e->window() ) ); 980 InputMethodHint m = inputMethodHint( QWidget::find( e->window() ) );
980 if ( m == AlwaysOff ) 981 if ( m == AlwaysOff )
981 Global::hideInputMethod(); 982 Global::hideInputMethod();
982 if ( m == AlwaysOn ) 983 if ( m == AlwaysOn )
983 Global::showInputMethod(); 984 Global::showInputMethod();
984 } 985 }
985 } 986 }
986 987
987 988
988 return QApplication::qwsEventFilter( e ); 989 return QApplication::qwsEventFilter( e );
989} 990}
990#endif 991#endif
991 992
992/*! 993/*!
993 Destroys the QPEApplication. 994 Destroys the QPEApplication.
994*/ 995*/
995QPEApplication::~QPEApplication() 996QPEApplication::~QPEApplication()
996{ 997{
997 ungrabKeyboard(); 998 ungrabKeyboard();
998#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 999#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
999 // Need to delete QCopChannels early, since the display will 1000 // Need to delete QCopChannels early, since the display will
1000 // be gone by the time we get to ~QObject(). 1001 // be gone by the time we get to ~QObject().
1001 delete sysChannel; 1002 delete sysChannel;
1002 delete pidChannel; 1003 delete pidChannel;
1003#endif 1004#endif
1004 1005
1005 delete d; 1006 delete d;
1006} 1007}
1007 1008
1008/*! 1009/*!
1009 Returns <tt>$OPIEDIR/</tt>. 1010 Returns <tt>$OPIEDIR/</tt>.
1010*/ 1011*/
1011QString QPEApplication::qpeDir() 1012QString QPEApplication::qpeDir()
1012{ 1013{
1013 const char * base = getenv( "OPIEDIR" ); 1014 const char * base = getenv( "OPIEDIR" );
1014 if ( base ) 1015 if ( base )
1015 return QString( base ) + "/"; 1016 return QString( base ) + "/";
1016 1017
1017 return QString( "../" ); 1018 return QString( "../" );
1018} 1019}
1019 1020
1020/*! 1021/*!
1021 Returns the user's current Document directory. There is a trailing "/". 1022 Returns the user's current Document directory. There is a trailing "/".
1022 .. well, it does now,, and there's no trailing '/' 1023 .. well, it does now,, and there's no trailing '/'
1023*/ 1024*/
1024QString QPEApplication::documentDir() 1025QString QPEApplication::documentDir()
1025{ 1026{
1026 const char* base = getenv( "HOME"); 1027 const char* base = getenv( "HOME");
1027 if ( base ) 1028 if ( base )
1028 return QString( base ) + "/Documents"; 1029 return QString( base ) + "/Documents";
1029 1030
1030 return QString( "../Documents" ); 1031 return QString( "../Documents" );
1031} 1032}
1032 1033
1033static int deforient = -1; 1034static int deforient = -1;
1034 1035
1035/*! 1036/*!
1036 \internal 1037 \internal
1037*/ 1038*/
1038int QPEApplication::defaultRotation() 1039int QPEApplication::defaultRotation()
1039{ 1040{
1040 if ( deforient < 0 ) { 1041 if ( deforient < 0 ) {
1041 QString d = getenv( "QWS_DISPLAY" ); 1042 QString d = getenv( "QWS_DISPLAY" );
1042 if ( d.contains( "Rot90" ) ) { 1043 if ( d.contains( "Rot90" ) ) {
1043 deforient = 90; 1044 deforient = 90;
1044 } 1045 }
1045 else if ( d.contains( "Rot180" ) ) { 1046 else if ( d.contains( "Rot180" ) ) {
1046 deforient = 180; 1047 deforient = 180;
1047 } 1048 }
1048 else if ( d.contains( "Rot270" ) ) { 1049 else if ( d.contains( "Rot270" ) ) {
1049 deforient = 270; 1050 deforient = 270;
1050 } 1051 }
1051 else { 1052 else {
1052 deforient = 0; 1053 deforient = 0;
1053 } 1054 }
1054 } 1055 }
1055 return deforient; 1056 return deforient;
1056} 1057}
1057 1058
1058/*! 1059/*!
1059 \internal 1060 \internal
1060*/ 1061*/
1061void QPEApplication::setDefaultRotation( int r ) 1062void QPEApplication::setDefaultRotation( int r )
1062{ 1063{
1063 if ( qApp->type() == GuiServer ) { 1064 if ( qApp->type() == GuiServer ) {
1064 deforient = r; 1065 deforient = r;
1065 setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 ); 1066 setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 );
1066 Config config("qpe"); 1067 Config config("qpe");
1067 config.setGroup( "Rotation" ); 1068 config.setGroup( "Rotation" );
1068 config.writeEntry( "Rot", r ); 1069 config.writeEntry( "Rot", r );
1069 } 1070 }
1070 else { 1071 else {
1071#ifndef QT_NO_COP 1072#ifndef QT_NO_COP
1072 { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" ); 1073 { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" );
1073 e << r; 1074 e << r;
1074 } 1075 }
1075#endif 1076#endif
1076 1077
1077 } 1078 }
1078} 1079}
1079 1080
1080#include <qgfx_qws.h> 1081#include <qgfx_qws.h>
1081#include <qwindowsystem_qws.h> 1082#include <qwindowsystem_qws.h>
1082#include <qpixmapcache.h> 1083#include <qpixmapcache.h>
1083 1084
1084extern void qws_clearLoadedFonts(); 1085extern void qws_clearLoadedFonts();
1085 1086
1086void QPEApplication::setCurrentMode( int x, int y, int depth ) 1087void QPEApplication::setCurrentMode( int x, int y, int depth )
1087{ 1088{
1088 // Reset the caches 1089 // Reset the caches
1089 qws_clearLoadedFonts(); 1090 qws_clearLoadedFonts();
1090 QPixmapCache::clear(); 1091 QPixmapCache::clear();
1091 1092
1092 // Change the screen mode 1093 // Change the screen mode
1093 qt_screen->setMode(x, y, depth); 1094 qt_screen->setMode(x, y, depth);
1094 1095
1095 if ( qApp->type() == GuiServer ) { 1096 if ( qApp->type() == GuiServer ) {
1096 // Reconfigure the GuiServer 1097 // Reconfigure the GuiServer
1097 qwsServer->beginDisplayReconfigure(); 1098 qwsServer->beginDisplayReconfigure();
1098 qwsServer->endDisplayReconfigure(); 1099 qwsServer->endDisplayReconfigure();
1099 1100
1100 // Get all the running apps to reset 1101 // Get all the running apps to reset
1101 QCopEnvelope env( "QPE/System", "reset()" ); 1102 QCopEnvelope env( "QPE/System", "reset()" );
1102 } 1103 }
1103} 1104}
1104 1105
1105void QPEApplication::reset() { 1106void QPEApplication::reset() {
1106 // Reconnect to the screen 1107 // Reconnect to the screen
1107 qt_screen->disconnect(); 1108 qt_screen->disconnect();
1108 qt_screen->connect( QString::null ); 1109 qt_screen->connect( QString::null );
1109 1110
1110 // Redraw everything 1111 // Redraw everything
1111 applyStyle(); 1112 applyStyle();
1112} 1113}
1113 1114
1114/*! 1115/*!
1115 \internal 1116 \internal
1116*/ 1117*/
1117void QPEApplication::applyStyle() 1118void QPEApplication::applyStyle()
1118{ 1119{
1119 Config config( "qpe" ); 1120 Config config( "qpe" );
1120 config.setGroup( "Appearance" ); 1121 config.setGroup( "Appearance" );
1121 1122
1122 #if QT_VERSION > 233 1123 #if QT_VERSION > 233
1123 // don't block ourselves ... 1124 // don't block ourselves ...
1124 Opie::force_appearance = 0; 1125 Opie::force_appearance = 0;
1125 1126
1126 static QString appname = Opie::binaryName ( ); 1127 static QString appname = Opie::binaryName ( );
1127 1128
1128 QStringList ex = config. readListEntry ( "NoStyle", ';' ); 1129 QStringList ex = config. readListEntry ( "NoStyle", ';' );
1129 int nostyle = 0; 1130 int nostyle = 0;
1130 for ( QStringList::Iterator it = ex. begin ( ); it != ex. end ( ); ++it ) { 1131 for ( QStringList::Iterator it = ex. begin ( ); it != ex. end ( ); ++it ) {
1131 if ( QRegExp (( *it ). mid ( 1 ), false, true ). find ( appname, 0 ) >= 0 ) { 1132 if ( QRegExp (( *it ). mid ( 1 ), false, true ). find ( appname, 0 ) >= 0 ) {
1132 nostyle = ( *it ). left ( 1 ). toInt ( 0, 32 ); 1133 nostyle = ( *it ). left ( 1 ). toInt ( 0, 32 );
1133 break; 1134 break;
1134 } 1135 }
1135 } 1136 }
1136 1137
1137 // Widget style 1138 // Widget style
1138 QString style = config.readEntry( "Style", "FlatStyle" ); 1139 QString style = config.readEntry( "Style", "FlatStyle" );
1139 1140
1140 // don't set a custom style 1141 // don't set a custom style
1141 if ( nostyle & Opie::Force_Style ) 1142 if ( nostyle & Opie::Force_Style )
1142 style = "FlatStyle"; 1143 style = "FlatStyle";
1143 1144
1144 internalSetStyle ( style ); 1145 internalSetStyle ( style );
1145 1146
1146 // Colors - from /etc/colors/Liquid.scheme 1147 // Colors - from /etc/colors/Liquid.scheme
1147 QColor bgcolor( config.readEntry( "Background", "#E0E0E0" ) ); 1148 QColor bgcolor( config.readEntry( "Background", "#E0E0E0" ) );
1148 QColor btncolor( config.readEntry( "Button", "#96c8fa" ) ); 1149 QColor btncolor( config.readEntry( "Button", "#96c8fa" ) );
1149 QPalette pal( btncolor, bgcolor ); 1150 QPalette pal( btncolor, bgcolor );
1150 QString color = config.readEntry( "Highlight", "#73adef" ); 1151 QString color = config.readEntry( "Highlight", "#73adef" );
1151 pal.setColor( QColorGroup::Highlight, QColor( color ) ); 1152 pal.setColor( QColorGroup::Highlight, QColor( color ) );
1152 color = config.readEntry( "HighlightedText", "#FFFFFF" ); 1153 color = config.readEntry( "HighlightedText", "#FFFFFF" );
1153 pal.setColor( QColorGroup::HighlightedText, QColor( color ) ); 1154 pal.setColor( QColorGroup::HighlightedText, QColor( color ) );
1154 color = config.readEntry( "Text", "#000000" ); 1155 color = config.readEntry( "Text", "#000000" );
1155 pal.setColor( QColorGroup::Text, QColor( color ) ); 1156 pal.setColor( QColorGroup::Text, QColor( color ) );
1156 color = config.readEntry( "ButtonText", "#000000" ); 1157 color = config.readEntry( "ButtonText", "#000000" );
1157 pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) ); 1158 pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) );
1158 color = config.readEntry( "Base", "#FFFFFF" ); 1159 color = config.readEntry( "Base", "#FFFFFF" );
1159 pal.setColor( QColorGroup::Base, QColor( color ) ); 1160 pal.setColor( QColorGroup::Base, QColor( color ) );
1160 1161
1161 pal.setColor( QPalette::Disabled, QColorGroup::Text, 1162 pal.setColor( QPalette::Disabled, QColorGroup::Text,
1162 pal.color( QPalette::Active, QColorGroup::Background ).dark() ); 1163 pal.color( QPalette::Active, QColorGroup::Background ).dark() );
1163 1164
1164 setPalette( pal, TRUE ); 1165 setPalette( pal, TRUE );
1165 1166
1166 // Window Decoration 1167 // Window Decoration
1167 QString dec = config.readEntry( "Decoration", "Flat" ); 1168 QString dec = config.readEntry( "Decoration", "Flat" );
1168 1169
1169 // don't set a custom deco 1170 // don't set a custom deco
1170 if ( nostyle & Opie::Force_Decoration ) 1171 if ( nostyle & Opie::Force_Decoration )
1171 dec = ""; 1172 dec = "";
1172 1173
1173 //qDebug ( "Setting Deco: %s -- old %s (%d)", dec.latin1(), d-> decorationName.latin1(), nostyle); 1174 //qDebug ( "Setting Deco: %s -- old %s (%d)", dec.latin1(), d-> decorationName.latin1(), nostyle);
1174 1175
1175 if ( dec != d->decorationName ) { 1176 if ( dec != d->decorationName ) {
1176 qwsSetDecoration( new QPEDecoration( dec ) ); 1177 qwsSetDecoration( new QPEDecoration( dec ) );
1177 d->decorationName = dec; 1178 d->decorationName = dec;
1178 } 1179 }
1179 1180
1180 // Font 1181 // Font
1181 QString ff = config.readEntry( "FontFamily", font().family() ); 1182 QString ff = config.readEntry( "FontFamily", font().family() );
1182 int fs = config.readNumEntry( "FontSize", font().pointSize() ); 1183 int fs = config.readNumEntry( "FontSize", font().pointSize() );
1183 1184
1184 // don't set a custom font 1185 // don't set a custom font
1185 if ( nostyle & Opie::Force_Font ) { 1186 if ( nostyle & Opie::Force_Font ) {
1186 ff = "Vera"; 1187 ff = "Vera";
1187 fs = 10; 1188 fs = 10;
1188 } 1189 }
1189 1190
1190 setFont ( QFont ( ff, fs ), true ); 1191 setFont ( QFont ( ff, fs ), true );
1191 1192
1192 // revert to global blocking policy ... 1193 // revert to global blocking policy ...
1193 Opie::force_appearance = config. readBoolEntry ( "ForceStyle", false ) ? Opie::Force_All : Opie::Force_None; 1194 Opie::force_appearance = config. readBoolEntry ( "ForceStyle", false ) ? Opie::Force_All : Opie::Force_None;
1194 Opie::force_appearance &= ~nostyle; 1195 Opie::force_appearance &= ~nostyle;
1195 #endif 1196 #endif
1196} 1197}
1197 1198
1198void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data ) 1199void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data )
1199{ 1200{
1200#ifdef Q_WS_QWS 1201#ifdef Q_WS_QWS
1201 QDataStream stream( data, IO_ReadOnly ); 1202 QDataStream stream( data, IO_ReadOnly );
1202 if ( msg == "applyStyle()" ) { 1203 if ( msg == "applyStyle()" ) {
1203 applyStyle(); 1204 applyStyle();
1204 } 1205 }
1205 else if ( msg == "toggleApplicationMenu()" ) { 1206 else if ( msg == "toggleApplicationMenu()" ) {
1206 QWidget *active = activeWindow ( ); 1207 QWidget *active = activeWindow ( );
1207 1208
1208 if ( active ) { 1209 if ( active ) {
1209 QPEMenuToolFocusManager *man = QPEMenuToolFocusManager::manager ( ); 1210 QPEMenuToolFocusManager *man = QPEMenuToolFocusManager::manager ( );
1210 bool oldactive = man-> isActive ( ); 1211 bool oldactive = man-> isActive ( );
1211 1212
1212 man-> setActive( !man-> isActive() ); 1213 man-> setActive( !man-> isActive() );
1213 1214
1214 if ( !oldactive && !man-> isActive ( )) { // no menubar to toggle -> try O-Menu 1215 if ( !oldactive && !man-> isActive ( )) { // no menubar to toggle -> try O-Menu
1215 QCopEnvelope e ( "QPE/TaskBar", "toggleStartMenu()" ); 1216 QCopEnvelope e ( "QPE/TaskBar", "toggleStartMenu()" );
1216 } 1217 }
1217 } 1218 }
1218 } 1219 }
1219 else if ( msg == "setDefaultRotation(int)" ) { 1220 else if ( msg == "setDefaultRotation(int)" ) {
1220 if ( type() == GuiServer ) { 1221 if ( type() == GuiServer ) {
1221 int r; 1222 int r;
1222 stream >> r; 1223 stream >> r;
1223 setDefaultRotation( r ); 1224 setDefaultRotation( r );
1224 } 1225 }
1225 } 1226 }
1226 else if ( msg == "setCurrentMode(int,int,int)" ) { // Added: 2003-06-11 by Tim Ansell <mithro@mithis.net> 1227 else if ( msg == "setCurrentMode(int,int,int)" ) { // Added: 2003-06-11 by Tim Ansell <mithro@mithis.net>
1227 if ( type() == GuiServer ) { 1228 if ( type() == GuiServer ) {
1228 int x, y, depth; 1229 int x, y, depth;
1229 stream >> x; 1230 stream >> x;
1230 stream >> y; 1231 stream >> y;
1231 stream >> depth; 1232 stream >> depth;
1232 setCurrentMode( x, y, depth ); 1233 setCurrentMode( x, y, depth );
1233 } 1234 }
1234 } 1235 }
1235 else if ( msg == "reset()" ) { 1236 else if ( msg == "reset()" ) {
1236 if ( type() != GuiServer ) 1237 if ( type() != GuiServer )
1237 reset(); 1238 reset();
1238 } 1239 }
1239 else if ( msg == "setCurrentRotation(int)" ) { 1240 else if ( msg == "setCurrentRotation(int)" ) {
1240 int r; 1241 int r;
1241 stream >> r; 1242 stream >> r;
1242 setCurrentRotation( r ); 1243 setCurrentRotation( r );
1243 } 1244 }
1244 else if ( msg == "shutdown()" ) { 1245 else if ( msg == "shutdown()" ) {
1245 if ( type() == GuiServer ) 1246 if ( type() == GuiServer )
1246 shutdown(); 1247 shutdown();
1247 } 1248 }
1248 else if ( msg == "quit()" ) { 1249 else if ( msg == "quit()" ) {
1249 if ( type() != GuiServer ) 1250 if ( type() != GuiServer )
1250 tryQuit(); 1251 tryQuit();
1251 } 1252 }
1252 else if ( msg == "forceQuit()" ) { 1253 else if ( msg == "forceQuit()" ) {
1253 if ( type() != GuiServer ) 1254 if ( type() != GuiServer )
1254 quit(); 1255 quit();
1255 } 1256 }
1256 else if ( msg == "restart()" ) { 1257 else if ( msg == "restart()" ) {
1257 if ( type() == GuiServer ) 1258 if ( type() == GuiServer )
1258 restart(); 1259 restart();
1259 } 1260 }
1260 else if ( msg == "language(QString)" ) { 1261 else if ( msg == "language(QString)" ) {
1261 if ( type() == GuiServer ) { 1262 if ( type() == GuiServer ) {
1262 QString l; 1263 QString l;
1263 stream >> l; 1264 stream >> l;
1264 QString cl = getenv( "LANG" ); 1265 QString cl = getenv( "LANG" );
1265 if ( cl != l ) { 1266 if ( cl != l ) {
1266 if ( l.isNull() ) 1267 if ( l.isNull() )
1267 unsetenv( "LANG" ); 1268 unsetenv( "LANG" );
1268 else 1269 else
1269 setenv( "LANG", l.latin1(), 1 ); 1270 setenv( "LANG", l.latin1(), 1 );
1270 restart(); 1271 restart();
1271 } 1272 }
1272 } 1273 }
1273 } 1274 }
1274 else if ( msg == "timeChange(QString)" ) { 1275 else if ( msg == "timeChange(QString)" ) {
1275 QString t; 1276 QString t;
1276 stream >> t; 1277 stream >> t;
1277 if ( t.isNull() ) 1278 if ( t.isNull() )
1278 unsetenv( "TZ" ); 1279 unsetenv( "TZ" );
1279 else 1280 else
1280 setenv( "TZ", t.latin1(), 1 ); 1281 setenv( "TZ", t.latin1(), 1 );
1281 // emit the signal so everyone else knows... 1282 // emit the signal so everyone else knows...
1282 emit timeChanged(); 1283 emit timeChanged();
1283 } 1284 }
1284 else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) { 1285 else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) {
1285 if ( type() == GuiServer ) { 1286 if ( type() == GuiServer ) {
1286 QDateTime when; 1287 QDateTime when;
1287 QCString channel, message; 1288 QCString channel, message;
1288 int data; 1289 int data;
1289 stream >> when >> channel >> message >> data; 1290 stream >> when >> channel >> message >> data;
1290 AlarmServer::addAlarm( when, channel, message, data ); 1291 AlarmServer::addAlarm( when, channel, message, data );
1291 } 1292 }
1292 } 1293 }
1293 else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) { 1294 else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) {
1294 if ( type() == GuiServer ) { 1295 if ( type() == GuiServer ) {
1295 QDateTime when; 1296 QDateTime when;
1296 QCString channel, message; 1297 QCString channel, message;
1297 int data; 1298 int data;
1298 stream >> when >> channel >> message >> data; 1299 stream >> when >> channel >> message >> data;
1299 AlarmServer::deleteAlarm( when, channel, message, data ); 1300 AlarmServer::deleteAlarm( when, channel, message, data );
1300 } 1301 }
1301 } 1302 }
1302 else if ( msg == "clockChange(bool)" ) { 1303 else if ( msg == "clockChange(bool)" ) {
1303 int tmp; 1304 int tmp;
1304 stream >> tmp; 1305 stream >> tmp;
1305 emit clockChanged( tmp ); 1306 emit clockChanged( tmp );
1306 } 1307 }
1307 else if ( msg == "weekChange(bool)" ) { 1308 else if ( msg == "weekChange(bool)" ) {
1308 int tmp; 1309 int tmp;
1309 stream >> tmp; 1310 stream >> tmp;
1310 emit weekChanged( tmp ); 1311 emit weekChanged( tmp );
1311 } 1312 }
1312 else if ( msg == "setDateFormat(DateFormat)" ) { 1313 else if ( msg == "setDateFormat(DateFormat)" ) {
1313 DateFormat tmp; 1314 DateFormat tmp;
1314 stream >> tmp; 1315 stream >> tmp;
1315 emit dateFormatChanged( tmp ); 1316 emit dateFormatChanged( tmp );
1316 } 1317 }
1317 else if ( msg == "setVolume(int,int)" ) { 1318 else if ( msg == "setVolume(int,int)" ) {
1318 int t, v; 1319 int t, v;
1319 stream >> t >> v; 1320 stream >> t >> v;
1320 setVolume( t, v ); 1321 setVolume( t, v );
1321 emit volumeChanged( muted ); 1322 emit volumeChanged( muted );
1322 } 1323 }
1323 else if ( msg == "volumeChange(bool)" ) { 1324 else if ( msg == "volumeChange(bool)" ) {
1324 stream >> muted; 1325 stream >> muted;
1325 setVolume(); 1326 setVolume();
1326 emit volumeChanged( muted ); 1327 emit volumeChanged( muted );
1327 } 1328 }
1328 else if ( msg == "setMic(int,int)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> 1329 else if ( msg == "setMic(int,int)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com>
1329 int t, v; 1330 int t, v;
1330 stream >> t >> v; 1331 stream >> t >> v;
1331 setMic( t, v ); 1332 setMic( t, v );
1332 emit micChanged( micMuted ); 1333 emit micChanged( micMuted );
1333 } 1334 }
1334 else if ( msg == "micChange(bool)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> 1335 else if ( msg == "micChange(bool)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com>
1335 stream >> micMuted; 1336 stream >> micMuted;
1336 setMic(); 1337 setMic();
1337 emit micChanged( micMuted ); 1338 emit micChanged( micMuted );
1338 } 1339 }
1339 else if ( msg == "setBass(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> 1340 else if ( msg == "setBass(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org>
1340 int t, v; 1341 int t, v;
1341 stream >> t >> v; 1342 stream >> t >> v;
1342 setBass( t, v ); 1343 setBass( t, v );
1343 } 1344 }
1344 else if ( msg == "bassChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> 1345 else if ( msg == "bassChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org>
1345 setBass(); 1346 setBass();
1346 } 1347 }
1347 else if ( msg == "setTreble(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> 1348 else if ( msg == "setTreble(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org>
1348 int t, v; 1349 int t, v;
1349 stream >> t >> v; 1350 stream >> t >> v;
1350 setTreble( t, v ); 1351 setTreble( t, v );
1351 } 1352 }
1352 else if ( msg == "trebleChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> 1353 else if ( msg == "trebleChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org>
1353 setTreble(); 1354 setTreble();
1354 } else if ( msg == "getMarkedText()" ) { 1355 } else if ( msg == "getMarkedText()" ) {
1355 if ( type() == GuiServer ) { 1356 if ( type() == GuiServer ) {
1356 const ushort unicode = 'C'-'@'; 1357 const ushort unicode = 'C'-'@';
1357 const int scan = Key_C; 1358 const int scan = Key_C;
1358 qwsServer->processKeyEvent( unicode, scan, ControlButton, TRUE, FALSE ); 1359 qwsServer->processKeyEvent( unicode, scan, ControlButton, TRUE, FALSE );
1359 qwsServer->processKeyEvent( unicode, scan, ControlButton, FALSE, FALSE ); 1360 qwsServer->processKeyEvent( unicode, scan, ControlButton, FALSE, FALSE );
1360 } 1361 }
1361 } else if ( msg == "newChannel(QString)") { 1362 } else if ( msg == "newChannel(QString)") {
1362 QString myChannel = "QPE/Application/" + d->appName; 1363 QString myChannel = "QPE/Application/" + d->appName;
1363 QString channel; 1364 QString channel;
1364 stream >> channel; 1365 stream >> channel;
1365 if (channel == myChannel) { 1366 if (channel == myChannel) {
1366 processQCopFile(); 1367 processQCopFile();
1367 d->sendQCopQ(); 1368 d->sendQCopQ();
1368 } 1369 }
1369 } 1370 }
1370 1371
1371 1372
1372#endif 1373#endif
1373} 1374}
1374 1375
1375 1376
1376 1377
1377 1378
1378 1379
1379/*! 1380/*!
1380 \internal 1381 \internal
1381*/ 1382*/
1382bool QPEApplication::raiseAppropriateWindow() 1383bool QPEApplication::raiseAppropriateWindow()
1383{ 1384{
1384 bool r=FALSE; 1385 bool r=FALSE;
1385 1386
1386 // 1. Raise the main widget 1387 // 1. Raise the main widget
1387 QWidget *top = d->qpe_main_widget; 1388 QWidget *top = d->qpe_main_widget;
1388 if ( !top ) top = mainWidget(); 1389 if ( !top ) top = mainWidget();
1389 1390
1390 if ( top && d->keep_running ) { 1391 if ( top && d->keep_running ) {
1391 if ( top->isVisible() ) 1392 if ( top->isVisible() )
1392 r = TRUE; 1393 r = TRUE;
1393 else if (d->preloaded) { 1394 else if (d->preloaded) {
1394 // We are preloaded and not visible.. pretend we just started.. 1395 // We are preloaded and not visible.. pretend we just started..
1395#ifndef QT_NO_COP 1396#ifndef QT_NO_COP
1396 QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); 1397 QCopEnvelope e("QPE/System", "fastAppShowing(QString)");
1397 e << d->appName; 1398 e << d->appName;
1398#endif 1399#endif
1399 } 1400 }
1400 1401
1401 d->show_mx(top,d->nomaximize, d->appName); 1402 d->show_mx(top,d->nomaximize, d->appName);
1402 top->raise(); 1403 top->raise();
1403 } 1404 }
1404 1405
1405 QWidget *topm = activeModalWidget(); 1406 QWidget *topm = activeModalWidget();
1406 1407
1407 // 2. Raise any parentless widgets (except top and topm, as they 1408 // 2. Raise any parentless widgets (except top and topm, as they
1408 // are raised before and after this loop). Order from most 1409 // are raised before and after this loop). Order from most
1409 // recently raised as deepest to least recently as top, so 1410 // recently raised as deepest to least recently as top, so
1410 // that repeated calls cycle through widgets. 1411 // that repeated calls cycle through widgets.
1411 QWidgetList *list = topLevelWidgets(); 1412 QWidgetList *list = topLevelWidgets();
1412 if ( list ) { 1413 if ( list ) {
1413 bool foundlast = FALSE; 1414 bool foundlast = FALSE;
1414 QWidget* topsub = 0; 1415 QWidget* topsub = 0;
1415 if ( d->lastraised ) { 1416 if ( d->lastraised ) {
1416 for (QWidget* w = list->first(); w; w = list->next()) { 1417 for (QWidget* w = list->first(); w; w = list->next()) {
1417 if ( !w->parentWidget() && w != topm && w->isVisible() && !w->isDesktop() ) { 1418 if ( !w->parentWidget() && w != topm && w->isVisible() && !w->isDesktop() ) {
1418 if ( w == d->lastraised ) 1419 if ( w == d->lastraised )
1419 foundlast = TRUE; 1420 foundlast = TRUE;
1420 if ( foundlast ) { 1421 if ( foundlast ) {
1421 w->raise(); 1422 w->raise();
1422 topsub = w; 1423 topsub = w;
1423 } 1424 }
1424 } 1425 }
1425 } 1426 }
1426 } 1427 }
1427 for (QWidget* w = list->first(); w; w = list->next()) { 1428 for (QWidget* w = list->first(); w; w = list->next()) {
1428 if ( !w->parentWidget() && w != topm && w->isVisible() && !w->isDesktop() ) { 1429 if ( !w->parentWidget() && w != topm && w->isVisible() && !w->isDesktop() ) {
1429 if ( w == d->lastraised ) 1430 if ( w == d->lastraised )
1430 break; 1431 break;
1431 w->raise(); 1432 w->raise();
1432 topsub = w; 1433 topsub = w;
1433 } 1434 }
1434 } 1435 }
1435 d->lastraised = topsub; 1436 d->lastraised = topsub;
1436 delete list; 1437 delete list;
1437 } 1438 }
1438 1439
1439 // 3. Raise the active modal widget. 1440 // 3. Raise the active modal widget.
1440 if ( topm && topm != top ) { 1441 if ( topm && topm != top ) {
1441 topm->show(); 1442 topm->show();
1442 topm->raise(); 1443 topm->raise();
1443 // If we haven't already handled the fastAppShowing message 1444 // If we haven't already handled the fastAppShowing message
1444 if (!top && d->preloaded) { 1445 if (!top && d->preloaded) {
1445#ifndef QT_NO_COP 1446#ifndef QT_NO_COP
1446 QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); 1447 QCopEnvelope e("QPE/System", "fastAppShowing(QString)");
1447 e << d->appName; 1448 e << d->appName;
1448#endif 1449#endif
1449 } 1450 }
1450 r = FALSE; 1451 r = FALSE;
1451 } 1452 }
1452 1453
1453 return r; 1454 return r;
1454} 1455}
1455 1456
1456 1457
1457void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data) 1458void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data)
1458{ 1459{
1459#ifdef Q_WS_QWS 1460#ifdef Q_WS_QWS
1460 1461
1461 if ( msg == "quit()" ) { 1462 if ( msg == "quit()" ) {
1462 tryQuit(); 1463 tryQuit();
1463 } 1464 }
1464 else if ( msg == "quitIfInvisible()" ) { 1465 else if ( msg == "quitIfInvisible()" ) {
1465 if ( d->qpe_main_widget && !d->qpe_main_widget->isVisible() ) 1466 if ( d->qpe_main_widget && !d->qpe_main_widget->isVisible() )
1466 quit(); 1467 quit();
1467 } 1468 }
1468 else if ( msg == "close()" ) { 1469 else if ( msg == "close()" ) {
1469 hideOrQuit(); 1470 hideOrQuit();
1470 } 1471 }
1471 else if ( msg == "disablePreload()" ) { 1472 else if ( msg == "disablePreload()" ) {
1472 d->preloaded = FALSE; 1473 d->preloaded = FALSE;
1473 d->keep_running = TRUE; 1474 d->keep_running = TRUE;
1474 /* so that quit will quit */ 1475 /* so that quit will quit */
1475 } 1476 }
1476 else if ( msg == "enablePreload()" ) { 1477 else if ( msg == "enablePreload()" ) {
1477 if (d->qpe_main_widget) 1478 if (d->qpe_main_widget)
1478 d->preloaded = TRUE; 1479 d->preloaded = TRUE;
1479 d->keep_running = TRUE; 1480 d->keep_running = TRUE;
1480 /* so next quit won't quit */ 1481 /* so next quit won't quit */
1481 } 1482 }
1482 else if ( msg == "raise()" ) { 1483 else if ( msg == "raise()" ) {
1483 d->keep_running = TRUE; 1484 d->keep_running = TRUE;
1484 d->notbusysent = FALSE; 1485 d->notbusysent = FALSE;
1485 raiseAppropriateWindow(); 1486 raiseAppropriateWindow();
1486 // Tell the system we're still chugging along... 1487 // Tell the system we're still chugging along...
1487 QCopEnvelope e("QPE/System", "appRaised(QString)"); 1488 QCopEnvelope e("QPE/System", "appRaised(QString)");
1488 e << d->appName; 1489 e << d->appName;
1489 } 1490 }
1490 else if ( msg == "flush()" ) { 1491 else if ( msg == "flush()" ) {
1491 emit flush(); 1492 emit flush();
1492 // we need to tell the desktop 1493 // we need to tell the desktop
1493 QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" ); 1494 QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" );
1494 e << d->appName; 1495 e << d->appName;
1495 } 1496 }
1496 else if ( msg == "reload()" ) { 1497 else if ( msg == "reload()" ) {
1497 emit reload(); 1498 emit reload();
1498 } 1499 }
1499 else if ( msg == "setDocument(QString)" ) { 1500 else if ( msg == "setDocument(QString)" ) {
1500 d->keep_running = TRUE; 1501 d->keep_running = TRUE;
1501 QDataStream stream( data, IO_ReadOnly ); 1502 QDataStream stream( data, IO_ReadOnly );
1502 QString doc; 1503 QString doc;
1503 stream >> doc; 1504 stream >> doc;
1504 QWidget *mw = mainWidget(); 1505 QWidget *mw = mainWidget();
1505 if ( !mw ) 1506 if ( !mw )
1506 mw = d->qpe_main_widget; 1507 mw = d->qpe_main_widget;
1507 if ( mw ) 1508 if ( mw )
1508 Global::setDocument( mw, doc ); 1509 Global::setDocument( mw, doc );
1509 1510
1510 } else if ( msg == "QPEProcessQCop()" ) { 1511 } else if ( msg == "QPEProcessQCop()" ) {
1511 processQCopFile(); 1512 processQCopFile();
1512 d->sendQCopQ(); 1513 d->sendQCopQ();
1513 }else 1514 }else
1514 { 1515 {
1515 bool p = d->keep_running; 1516 bool p = d->keep_running;
1516 d->keep_running = FALSE; 1517 d->keep_running = FALSE;
1517 emit appMessage( msg, data); 1518 emit appMessage( msg, data);
1518 if ( d->keep_running ) { 1519 if ( d->keep_running ) {
1519 d->notbusysent = FALSE; 1520 d->notbusysent = FALSE;
1520 raiseAppropriateWindow(); 1521 raiseAppropriateWindow();
1521 if ( !p ) { 1522 if ( !p ) {
1522 // Tell the system we're still chugging along... 1523 // Tell the system we're still chugging along...
1523#ifndef QT_NO_COP 1524#ifndef QT_NO_COP
1524 QCopEnvelope e("QPE/System", "appRaised(QString)"); 1525 QCopEnvelope e("QPE/System", "appRaised(QString)");
1525 e << d->appName; 1526 e << d->appName;
1526#endif 1527#endif
1527 } 1528 }
1528 } 1529 }
1529 if ( p ) 1530 if ( p )
1530 d->keep_running = p; 1531 d->keep_running = p;
1531 } 1532 }
1532#endif 1533#endif
1533} 1534}
1534 1535
1535 1536
1536/*! 1537/*!
1537 Sets widget \a mw as the mainWidget() and shows it. For small windows, 1538 Sets widget \a mw as the mainWidget() and shows it. For small windows,
1538 consider passing TRUE for \a nomaximize rather than the default FALSE. 1539 consider passing TRUE for \a nomaximize rather than the default FALSE.
1539 1540
1540 \sa showMainDocumentWidget() 1541 \sa showMainDocumentWidget()
1541*/ 1542*/
1542void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize ) 1543void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize )
1543{ 1544{
1544 d->show(mw, nomaximize ); 1545 d->show(mw, nomaximize );
1545} 1546}
1546 1547
1547/*! 1548/*!
1548 Sets widget \a mw as the mainWidget() and shows it. For small windows, 1549 Sets widget \a mw as the mainWidget() and shows it. For small windows,
1549 consider passing TRUE for \a nomaximize rather than the default FALSE. 1550 consider passing TRUE for \a nomaximize rather than the default FALSE.
1550 1551
1551 This calls designates the application as 1552 This calls designates the application as
1552 a \link docwidget.html document-oriented\endlink application. 1553 a \link docwidget.html document-oriented\endlink application.
1553 1554
1554 The \a mw widget \e must have this slot: setDocument(const QString&). 1555 The \a mw widget \e must have this slot: setDocument(const QString&).
1555 1556
1556 \sa showMainWidget() 1557 \sa showMainWidget()
1557*/ 1558*/
1558void QPEApplication::showMainDocumentWidget( QWidget* mw, bool nomaximize ) 1559void QPEApplication::showMainDocumentWidget( QWidget* mw, bool nomaximize )
1559{ 1560{
1560 if ( mw && argc() == 2 ) 1561 if ( mw && argc() == 2 )
1561 Global::setDocument( mw, QString::fromUtf8(argv()[1]) ); 1562 Global::setDocument( mw, QString::fromUtf8(argv()[1]) );
1562 1563
1563 1564
1564 d->show(mw, nomaximize ); 1565 d->show(mw, nomaximize );
1565} 1566}
1566 1567
1567 1568
1568/*! 1569/*!
1569 If an application is started via a \link qcop.html QCop\endlink 1570 If an application is started via a \link qcop.html QCop\endlink
1570 message, the application will process the \link qcop.html 1571 message, the application will process the \link qcop.html
1571 QCop\endlink message and then quit. If the application calls this 1572 QCop\endlink message and then quit. If the application calls this
1572 function while processing a \link qcop.html QCop\endlink message, 1573 function while processing a \link qcop.html QCop\endlink message,
1573 after processing its outstanding \link qcop.html QCop\endlink 1574 after processing its outstanding \link qcop.html QCop\endlink
1574 messages the application will start 'properly' and show itself. 1575 messages the application will start 'properly' and show itself.
1575 1576
1576 \sa keepRunning() 1577 \sa keepRunning()
1577*/ 1578*/
1578void QPEApplication::setKeepRunning() 1579void QPEApplication::setKeepRunning()
1579{ 1580{
1580 if ( qApp && qApp->inherits( "QPEApplication" ) ) { 1581 if ( qApp && qApp->inherits( "QPEApplication" ) ) {
1581 QPEApplication * qpeApp = ( QPEApplication* ) qApp; 1582 QPEApplication * qpeApp = ( QPEApplication* ) qApp;
1582 qpeApp->d->keep_running = TRUE; 1583 qpeApp->d->keep_running = TRUE;
1583 } 1584 }
1584} 1585}
1585 1586
1586/*! 1587/*!
1587 Returns TRUE if the application will quit after processing the 1588 Returns TRUE if the application will quit after processing the
1588 current list of qcop messages; otherwise returns FALSE. 1589 current list of qcop messages; otherwise returns FALSE.
1589 1590
1590 \sa setKeepRunning() 1591 \sa setKeepRunning()
1591*/ 1592*/
1592bool QPEApplication::keepRunning() const 1593bool QPEApplication::keepRunning() const
1593{ 1594{
1594 return d->keep_running; 1595 return d->keep_running;
1595} 1596}
1596 1597
1597/*! 1598/*!
1598 \internal 1599 \internal
1599*/ 1600*/
1600void QPEApplication::internalSetStyle( const QString &style ) 1601void QPEApplication::internalSetStyle( const QString &style )
1601{ 1602{
1602#if QT_VERSION >= 300 1603#if QT_VERSION >= 300
1603 if ( style == "QPE" ) { 1604 if ( style == "QPE" ) {
1604 setStyle( new QPEStyle ); 1605 setStyle( new QPEStyle );
1605 } 1606 }
1606 else { 1607 else {
1607 QStyle *s = QStyleFactory::create( style ); 1608 QStyle *s = QStyleFactory::create( style );
1608 if ( s ) 1609 if ( s )
1609 setStyle( s ); 1610 setStyle( s );
1610 } 1611 }
1611#else 1612#else
1612 if ( style == "Windows" ) { 1613 if ( style == "Windows" ) {
1613 setStyle( new QWindowsStyle ); 1614 setStyle( new QWindowsStyle );
1614 } 1615 }
1615 else if ( style == "QPE" ) { 1616 else if ( style == "QPE" ) {
1616 setStyle( new QPEStyle ); 1617 setStyle( new QPEStyle );
1617 } 1618 }
1618 else if ( style == "Light" ) { 1619 else if ( style == "Light" ) {
1619 setStyle( new LightStyle ); 1620 setStyle( new LightStyle );
1620 } 1621 }
1621#ifndef QT_NO_STYLE_PLATINUM 1622#ifndef QT_NO_STYLE_PLATINUM
1622 else if ( style == "Platinum" ) { 1623 else if ( style == "Platinum" ) {
1623 setStyle( new QPlatinumStyle ); 1624 setStyle( new QPlatinumStyle );
1624 } 1625 }
1625#endif 1626#endif
1626#ifndef QT_NO_STYLE_MOTIF 1627#ifndef QT_NO_STYLE_MOTIF
1627 else if ( style == "Motif" ) { 1628 else if ( style == "Motif" ) {
1628 setStyle( new QMotifStyle ); 1629 setStyle( new QMotifStyle );
1629 } 1630 }
1630#endif 1631#endif
1631#ifndef QT_NO_STYLE_MOTIFPLUS 1632#ifndef QT_NO_STYLE_MOTIFPLUS
1632 else if ( style == "MotifPlus" ) { 1633 else if ( style == "MotifPlus" ) {
1633 setStyle( new QMotifPlusStyle ); 1634 setStyle( new QMotifPlusStyle );
1634 } 1635 }
1635#endif 1636#endif
1636 1637
1637 else { 1638 else {
1638 QStyle *sty = 0; 1639 QStyle *sty = 0;
1639 QString path = QPEApplication::qpeDir ( ) + "/plugins/styles/"; 1640 QString path = QPEApplication::qpeDir ( ) + "/plugins/styles/";
1640 1641
1641 if ( style. find ( ".so" ) > 0 ) 1642 if ( style. find ( ".so" ) > 0 )
1642 path += style; 1643 path += style;
1643 else 1644 else
1644 path = path + "lib" + style. lower ( ) + ".so"; // compatibility 1645 path = path + "lib" + style. lower ( ) + ".so"; // compatibility
1645 1646
1646 static QLibrary *lastlib = 0; 1647 static QLibrary *lastlib = 0;
1647 static StyleInterface *lastiface = 0; 1648 static StyleInterface *lastiface = 0;
1648 1649
1649 QLibrary *lib = new QLibrary ( path ); 1650 QLibrary *lib = new QLibrary ( path );
1650 StyleInterface *iface = 0; 1651 StyleInterface *iface = 0;
1651 1652
1652 if (( lib-> queryInterface ( IID_Style, ( QUnknownInterface ** ) &iface ) == QS_OK ) && iface ) 1653 if (( lib-> queryInterface ( IID_Style, ( QUnknownInterface ** ) &iface ) == QS_OK ) && iface )
1653 sty = iface-> style ( ); 1654 sty = iface-> style ( );
1654 1655
1655 if ( sty ) { 1656 if ( sty ) {
1656 setStyle ( sty ); 1657 setStyle ( sty );
1657 1658
1658 if ( lastiface ) 1659 if ( lastiface )
1659 lastiface-> release ( ); 1660 lastiface-> release ( );
1660 lastiface = iface; 1661 lastiface = iface;
1661 1662
1662 if ( lastlib ) { 1663 if ( lastlib ) {
1663 lastlib-> unload ( ); 1664 lastlib-> unload ( );
1664 delete lastlib; 1665 delete lastlib;
1665 } 1666 }
1666 lastlib = lib; 1667 lastlib = lib;
1667 } 1668 }
1668 else { 1669 else {
1669 if ( iface ) 1670 if ( iface )
1670 iface-> release ( ); 1671 iface-> release ( );
1671 delete lib; 1672 delete lib;
1672 1673
1673 setStyle ( new LightStyle ( )); 1674 setStyle ( new LightStyle ( ));
1674 } 1675 }
1675 } 1676 }
1676#endif 1677#endif
1677} 1678}
1678 1679
1679/*! 1680/*!
1680 \internal 1681 \internal
1681*/ 1682*/
1682void QPEApplication::prepareForTermination( bool willrestart ) 1683void QPEApplication::prepareForTermination( bool willrestart )
1683{ 1684{
1684 if ( willrestart ) { 1685 if ( willrestart ) {
1685 // Draw a big wait icon, the image can be altered in later revisions 1686 // Draw a big wait icon, the image can be altered in later revisions
1686 // QWidget *d = QApplication::desktop(); 1687 // QWidget *d = QApplication::desktop();
1687 QImage img = Resource::loadImage( "launcher/new_wait" ); 1688 QImage img = Resource::loadImage( "launcher/new_wait" );
1688 QPixmap pix; 1689 QPixmap pix;
1689 pix.convertFromImage( img.smoothScale( 1 * img.width(), 1 * img.height() ) ); 1690 pix.convertFromImage( img.smoothScale( 1 * img.width(), 1 * img.height() ) );
1690 QLabel *lblWait = new QLabel( 0, "wait hack!", QWidget::WStyle_Customize | 1691 QLabel *lblWait = new QLabel( 0, "wait hack!", QWidget::WStyle_Customize |