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