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