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