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