summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2003-05-22 13:41:36 (UTC)
committer mickeyl <mickeyl>2003-05-22 13:41:36 (UTC)
commitac74e73175ef4fecbcb77cd23b792983ca6ea06b (patch) (unidiff)
treeca2ec6c86b8a566a39308c63dcf44b1b2e9f85f6
parent6041221c6d2892c6e7a61570c524fd090f447739 (diff)
downloadopie-ac74e73175ef4fecbcb77cd23b792983ca6ea06b.zip
opie-ac74e73175ef4fecbcb77cd23b792983ca6ea06b.tar.gz
opie-ac74e73175ef4fecbcb77cd23b792983ca6ea06b.tar.bz2
guard ugly c700-only hacks with #ifdef QT_QWS_SHARP
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--library/qpeapplication.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp
index 19adb00..22d222a 100644
--- a/library/qpeapplication.cpp
+++ b/library/qpeapplication.cpp
@@ -1,1304 +1,1310 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19** $Id$ 19** $Id$
20** 20**
21**********************************************************************/ 21**********************************************************************/
22#define QTOPIA_INTERNAL_LANGLIST 22#define QTOPIA_INTERNAL_LANGLIST
23#include <stdlib.h> 23#include <stdlib.h>
24#include <unistd.h> 24#include <unistd.h>
25#include <linux/limits.h> // needed for some toolchains (PATH_MAX) 25#include <linux/limits.h> // needed for some toolchains (PATH_MAX)
26#include <qfile.h> 26#include <qfile.h>
27#ifdef Q_WS_QWS 27#ifdef Q_WS_QWS
28#ifndef QT_NO_COP 28#ifndef QT_NO_COP
29#if QT_VERSION <= 231 29#if QT_VERSION <= 231
30#define private public 30#define private public
31#define sendLocally processEvent 31#define sendLocally processEvent
32#include "qcopenvelope_qws.h" 32#include "qcopenvelope_qws.h"
33#undef private 33#undef private
34#else 34#else
35#include "qcopenvelope_qws.h" 35#include "qcopenvelope_qws.h"
36#endif 36#endif
37#endif 37#endif
38#include <qwindowsystem_qws.h> 38#include <qwindowsystem_qws.h>
39#endif 39#endif
40#include <qtextstream.h> 40#include <qtextstream.h>
41#include <qpalette.h> 41#include <qpalette.h>
42#include <qbuffer.h> 42#include <qbuffer.h>
43#include <qptrdict.h> 43#include <qptrdict.h>
44#include <qregexp.h> 44#include <qregexp.h>
45#include <qdir.h> 45#include <qdir.h>
46#include <qlabel.h> 46#include <qlabel.h>
47#include <qdialog.h> 47#include <qdialog.h>
48#include <qdragobject.h> 48#include <qdragobject.h>
49#include <qtextcodec.h> 49#include <qtextcodec.h>
50#include <qevent.h> 50#include <qevent.h>
51#include <qtooltip.h> 51#include <qtooltip.h>
52#include <qsignal.h> 52#include <qsignal.h>
53#include <qmainwindow.h> 53#include <qmainwindow.h>
54#include "qpeapplication.h" 54#include "qpeapplication.h"
55#include "qpestyle.h" 55#include "qpestyle.h"
56#include "styleinterface.h" 56#include "styleinterface.h"
57#if QT_VERSION >= 300 57#if QT_VERSION >= 300
58#include <qstylefactory.h> 58#include <qstylefactory.h>
59#else 59#else
60#include <qplatinumstyle.h> 60#include <qplatinumstyle.h>
61#include <qwindowsstyle.h> 61#include <qwindowsstyle.h>
62#include <qmotifstyle.h> 62#include <qmotifstyle.h>
63#include <qmotifplusstyle.h> 63#include <qmotifplusstyle.h>
64#include "lightstyle.h" 64#include "lightstyle.h"
65 65
66#include <qpe/qlibrary.h> 66#include <qpe/qlibrary.h>
67#endif 67#endif
68#include "global.h" 68#include "global.h"
69#include "resource.h" 69#include "resource.h"
70#if QT_VERSION <= 230 && defined(QT_NO_CODECS) 70#if QT_VERSION <= 230 && defined(QT_NO_CODECS)
71#include "qutfcodec.h" 71#include "qutfcodec.h"
72#endif 72#endif
73#include "config.h" 73#include "config.h"
74#include "network.h" 74#include "network.h"
75#ifdef QWS 75#ifdef QWS
76#include "fontmanager.h" 76#include "fontmanager.h"
77#endif 77#endif
78 78
79#include "alarmserver.h" 79#include "alarmserver.h"
80#include "applnk.h" 80#include "applnk.h"
81#include "qpemenubar.h" 81#include "qpemenubar.h"
82#include "textcodecinterface.h" 82#include "textcodecinterface.h"
83#include "imagecodecinterface.h" 83#include "imagecodecinterface.h"
84 84
85#include <unistd.h> 85#include <unistd.h>
86#include <sys/file.h> 86#include <sys/file.h>
87#include <sys/ioctl.h> 87#include <sys/ioctl.h>
88#include <sys/soundcard.h> 88#include <sys/soundcard.h>
89 89
90#include "qt_override_p.h" 90#include "qt_override_p.h"
91 91
92 92
93class QPEApplicationData 93class QPEApplicationData
94{ 94{
95public: 95public:
96 QPEApplicationData ( ) 96 QPEApplicationData ( )
97 : presstimer( 0 ), presswidget( 0 ), rightpressed( false ), kbgrabbed( false ), 97 : presstimer( 0 ), presswidget( 0 ), rightpressed( false ), kbgrabbed( false ),
98 notbusysent( false ), preloaded( false ), forceshow( false ), nomaximize( false ), 98 notbusysent( false ), preloaded( false ), forceshow( false ), nomaximize( false ),
99 keep_running( true ), qpe_main_widget( 0 ) 99 keep_running( true ), qpe_main_widget( 0 )
100 100
101 { 101 {
102 qcopq.setAutoDelete( TRUE ); 102 qcopq.setAutoDelete( TRUE );
103 } 103 }
104 104
105 int presstimer; 105 int presstimer;
106 QWidget* presswidget; 106 QWidget* presswidget;
107 QPoint presspos; 107 QPoint presspos;
108 108
109 bool rightpressed : 1; 109 bool rightpressed : 1;
110 bool kbgrabbed : 1; 110 bool kbgrabbed : 1;
111 bool notbusysent : 1; 111 bool notbusysent : 1;
112 bool preloaded : 1; 112 bool preloaded : 1;
113 bool forceshow : 1; 113 bool forceshow : 1;
114 bool nomaximize : 1; 114 bool nomaximize : 1;
115 bool keep_running : 1; 115 bool keep_running : 1;
116 116
117 QString appName; 117 QString appName;
118 struct QCopRec 118 struct QCopRec
119 { 119 {
120 QCopRec( const QCString &ch, const QCString &msg, 120 QCopRec( const QCString &ch, const QCString &msg,
121 const QByteArray &d ) : 121 const QByteArray &d ) :
122 channel( ch ), message( msg ), data( d ) 122 channel( ch ), message( msg ), data( d )
123 { } 123 { }
124 124
125 QCString channel; 125 QCString channel;
126 QCString message; 126 QCString message;
127 QByteArray data; 127 QByteArray data;
128 }; 128 };
129 QWidget* qpe_main_widget; 129 QWidget* qpe_main_widget;
130 QList<QCopRec> qcopq; 130 QList<QCopRec> qcopq;
131 131
132 void enqueueQCop( const QCString &ch, const QCString &msg, 132 void enqueueQCop( const QCString &ch, const QCString &msg,
133 const QByteArray &data ) 133 const QByteArray &data )
134 { 134 {
135 qcopq.append( new QCopRec( ch, msg, data ) ); 135 qcopq.append( new QCopRec( ch, msg, data ) );
136 } 136 }
137 void sendQCopQ() 137 void sendQCopQ()
138 { 138 {
139 QCopRec * r; 139 QCopRec * r;
140#ifndef QT_NO_COP 140#ifndef QT_NO_COP
141 141
142 for ( QListIterator<QCopRec> it( qcopq ); ( r = it.current() ); ++it ) 142 for ( QListIterator<QCopRec> it( qcopq ); ( r = it.current() ); ++it )
143 QCopChannel::sendLocally( r->channel, r->message, r->data ); 143 QCopChannel::sendLocally( r->channel, r->message, r->data );
144#endif 144#endif
145 145
146 qcopq.clear(); 146 qcopq.clear();
147 } 147 }
148 static void show_mx(QWidget* mw, bool nomaximize) 148 static void show_mx(QWidget* mw, bool nomaximize)
149 { 149 {
150 150
151 // ugly hack, remove that later after finding a sane solution 151 // ugly hack, remove that later after finding a sane solution
152 // Addendum: Only Sharp currently has models with high resolution but (physically) small displays,
153 // so this is only useful if QT_QWS_SHARP is defined. E.g. SIMpad has 800x600 but has
154 // a (physically) large enough display to use the small icons
155 #ifdef QT_QWS_SHARP
152 if ( QPEApplication::desktop() ->width() >= 600 && ( mw->inherits("QMainWindow") || mw->isA("QMainWindow") ) ) { 156 if ( QPEApplication::desktop() ->width() >= 600 && ( mw->inherits("QMainWindow") || mw->isA("QMainWindow") ) ) {
153 ( ( QMainWindow* ) mw )->setUsesBigPixmaps( true ); 157 ( ( QMainWindow* ) mw )->setUsesBigPixmaps( true );
154 } 158 }
159 #endif
155 160
156 if ( mw->layout() && mw->inherits("QDialog") ) { 161 if ( mw->layout() && mw->inherits("QDialog") ) {
157 QPEApplication::showDialog((QDialog*)mw, nomaximize); 162 QPEApplication::showDialog((QDialog*)mw, nomaximize);
158 } 163 }
159 else { 164 else {
160#ifdef Q_WS_QWS 165#ifdef Q_WS_QWS
161 if ( !nomaximize ) 166 if ( !nomaximize )
162 mw->showMaximized(); 167 mw->showMaximized();
163 else 168 else
164#endif 169#endif
165 170
166 mw->show(); 171 mw->show();
167 } 172 }
168 } 173 }
169 static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) 174 static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ )
170 { 175 {
171 /* 176 /*
172 // This works but disable it for now until it is safe to apply 177 // This works but disable it for now until it is safe to apply
173 // What is does is scan the .desktop files of all the apps for 178 // What is does is scan the .desktop files of all the apps for
174 // the applnk that has the corresponding argv[0] as this program 179 // the applnk that has the corresponding argv[0] as this program
175 // then it uses the name stored in the .desktop file as the caption 180 // then it uses the name stored in the .desktop file as the caption
176 // for the main widget. This saves duplicating translations for 181 // for the main widget. This saves duplicating translations for
177 // the app name in the program and in the .desktop files. 182 // the app name in the program and in the .desktop files.
178 183
179 AppLnkSet apps( appsPath ); 184 AppLnkSet apps( appsPath );
180 185
181 QList<AppLnk> appsList = apps.children(); 186 QList<AppLnk> appsList = apps.children();
182 for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) { 187 for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) {
183 if ( (*it)->exec() == appName ) { 188 if ( (*it)->exec() == appName ) {
184 mw->setCaption( (*it)->name() ); 189 mw->setCaption( (*it)->name() );
185 return TRUE; 190 return TRUE;
186 } 191 }
187 } 192 }
188 */ 193 */
189 return FALSE; 194 return FALSE;
190 } 195 }
191 196
192 197
193 void show(QWidget* mw, bool nomax) 198 void show(QWidget* mw, bool nomax)
194 { 199 {
195 setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" ); 200 setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" );
196 nomaximize = nomax; 201 nomaximize = nomax;
197 qpe_main_widget = mw; 202 qpe_main_widget = mw;
198#ifndef QT_NO_COP 203#ifndef QT_NO_COP
199 204
200 sendQCopQ(); 205 sendQCopQ();
201#endif 206#endif
202 207
203 if ( preloaded ) { 208 if ( preloaded ) {
204 if (forceshow) 209 if (forceshow)
205 show_mx(mw, nomax); 210 show_mx(mw, nomax);
206 } 211 }
207 else if ( keep_running ) { 212 else if ( keep_running ) {
208 show_mx(mw, nomax); 213 show_mx(mw, nomax);
209 } 214 }
210 } 215 }
211 216
212 void loadTextCodecs() 217 void loadTextCodecs()
213 { 218 {
214 QString path = QPEApplication::qpeDir() + "/plugins/textcodecs"; 219 QString path = QPEApplication::qpeDir() + "/plugins/textcodecs";
215 QDir dir( path, "lib*.so" ); 220 QDir dir( path, "lib*.so" );
216 QStringList list; 221 QStringList list;
217 if ( dir. exists ( )) 222 if ( dir. exists ( ))
218 list = dir.entryList(); 223 list = dir.entryList();
219 QStringList::Iterator it; 224 QStringList::Iterator it;
220 for ( it = list.begin(); it != list.end(); ++it ) { 225 for ( it = list.begin(); it != list.end(); ++it ) {
221 TextCodecInterface *iface = 0; 226 TextCodecInterface *iface = 0;
222 QLibrary *lib = new QLibrary( path + "/" + *it ); 227 QLibrary *lib = new QLibrary( path + "/" + *it );
223 if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { 228 if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) {
224 QValueList<int> mibs = iface->mibEnums(); 229 QValueList<int> mibs = iface->mibEnums();
225 for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) { 230 for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) {
226 (void)iface->createForMib(*i); 231 (void)iface->createForMib(*i);
227 // ### it exists now; need to remember if we can delete it 232 // ### it exists now; need to remember if we can delete it
228 } 233 }
229 } 234 }
230 else { 235 else {
231 lib->unload(); 236 lib->unload();
232 delete lib; 237 delete lib;
233 } 238 }
234 } 239 }
235 } 240 }
236 241
237 void loadImageCodecs() 242 void loadImageCodecs()
238 { 243 {
239 QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs"; 244 QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs";
240 QDir dir( path, "lib*.so" ); 245 QDir dir( path, "lib*.so" );
241 QStringList list; 246 QStringList list;
242 if ( dir. exists ( )) 247 if ( dir. exists ( ))
243 list = dir.entryList(); 248 list = dir.entryList();
244 QStringList::Iterator it; 249 QStringList::Iterator it;
245 for ( it = list.begin(); it != list.end(); ++it ) { 250 for ( it = list.begin(); it != list.end(); ++it ) {
246 ImageCodecInterface *iface = 0; 251 ImageCodecInterface *iface = 0;
247 QLibrary *lib = new QLibrary( path + "/" + *it ); 252 QLibrary *lib = new QLibrary( path + "/" + *it );
248 if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { 253 if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) {
249 QStringList formats = iface->keys(); 254 QStringList formats = iface->keys();
250 for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) { 255 for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) {
251 (void)iface->installIOHandler(*i); 256 (void)iface->installIOHandler(*i);
252 // ### it exists now; need to remember if we can delete it 257 // ### it exists now; need to remember if we can delete it
253 } 258 }
254 } 259 }
255 else { 260 else {
256 lib->unload(); 261 lib->unload();
257 delete lib; 262 delete lib;
258 } 263 }
259 } 264 }
260 } 265 }
261 QString styleName; 266 QString styleName;
262 QString decorationName; 267 QString decorationName;
263}; 268};
264 269
265class ResourceMimeFactory : public QMimeSourceFactory 270class ResourceMimeFactory : public QMimeSourceFactory
266{ 271{
267public: 272public:
268 ResourceMimeFactory() 273 ResourceMimeFactory()
269 { 274 {
270 setFilePath( Global::helpPath() ); 275 setFilePath( Global::helpPath() );
271 setExtensionType( "html", "text/html;charset=UTF-8" ); 276 setExtensionType( "html", "text/html;charset=UTF-8" );
272 } 277 }
273 278
274 const QMimeSource* data( const QString& abs_name ) const 279 const QMimeSource* data( const QString& abs_name ) const
275 { 280 {
276 const QMimeSource * r = QMimeSourceFactory::data( abs_name ); 281 const QMimeSource * r = QMimeSourceFactory::data( abs_name );
277 if ( !r ) { 282 if ( !r ) {
278 int sl = abs_name.length(); 283 int sl = abs_name.length();
279 do { 284 do {
280 sl = abs_name.findRev( '/', sl - 1 ); 285 sl = abs_name.findRev( '/', sl - 1 );
281 QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name; 286 QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name;
282 int dot = name.findRev( '.' ); 287 int dot = name.findRev( '.' );
283 if ( dot >= 0 ) 288 if ( dot >= 0 )
284 name = name.left( dot ); 289 name = name.left( dot );
285 QImage img = Resource::loadImage( name ); 290 QImage img = Resource::loadImage( name );
286 if ( !img.isNull() ) 291 if ( !img.isNull() )
287 r = new QImageDrag( img ); 292 r = new QImageDrag( img );
288 } 293 }
289 while ( !r && sl > 0 ); 294 while ( !r && sl > 0 );
290 } 295 }
291 return r; 296 return r;
292 } 297 }
293}; 298};
294 299
295static int muted = 0; 300static int muted = 0;
296static int micMuted = 0; 301static int micMuted = 0;
297 302
298static void setVolume( int t = 0, int percent = -1 ) 303static void setVolume( int t = 0, int percent = -1 )
299{ 304{
300 switch ( t ) { 305 switch ( t ) {
301 case 0: { 306 case 0: {
302 Config cfg( "qpe" ); 307 Config cfg( "qpe" );
303 cfg.setGroup( "Volume" ); 308 cfg.setGroup( "Volume" );
304 if ( percent < 0 ) 309 if ( percent < 0 )
305 percent = cfg.readNumEntry( "VolumePercent", 50 ); 310 percent = cfg.readNumEntry( "VolumePercent", 50 );
306 int fd = 0; 311 int fd = 0;
307 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { 312 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) {
308 int vol = muted ? 0 : percent; 313 int vol = muted ? 0 : percent;
309 // set both channels to same volume 314 // set both channels to same volume
310 vol |= vol << 8; 315 vol |= vol << 8;
311 ioctl( fd, MIXER_WRITE( 0 ), &vol ); 316 ioctl( fd, MIXER_WRITE( 0 ), &vol );
312 ::close( fd ); 317 ::close( fd );
313 } 318 }
314 } 319 }
315 break; 320 break;
316 } 321 }
317} 322}
318 323
319static void setMic( int t = 0, int percent = -1 ) 324static void setMic( int t = 0, int percent = -1 )
320{ 325{
321 switch ( t ) { 326 switch ( t ) {
322 case 0: { 327 case 0: {
323 Config cfg( "qpe" ); 328 Config cfg( "qpe" );
324 cfg.setGroup( "Volume" ); 329 cfg.setGroup( "Volume" );
325 if ( percent < 0 ) 330 if ( percent < 0 )
326 percent = cfg.readNumEntry( "Mic", 50 ); 331 percent = cfg.readNumEntry( "Mic", 50 );
327 332
328 int fd = 0; 333 int fd = 0;
329 int mic = micMuted ? 0 : percent; 334 int mic = micMuted ? 0 : percent;
330 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { 335 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) {
331 ioctl( fd, MIXER_WRITE( SOUND_MIXER_MIC ), &mic ); 336 ioctl( fd, MIXER_WRITE( SOUND_MIXER_MIC ), &mic );
332 ::close( fd ); 337 ::close( fd );
333 } 338 }
334 } 339 }
335 break; 340 break;
336 } 341 }
337} 342}
338 343
339 344
340static void setBass( int t = 0, int percent = -1 ) 345static void setBass( int t = 0, int percent = -1 )
341{ 346{
342 switch ( t ) { 347 switch ( t ) {
343 case 0: { 348 case 0: {
344 Config cfg( "qpe" ); 349 Config cfg( "qpe" );
345 cfg.setGroup( "Volume" ); 350 cfg.setGroup( "Volume" );
346 if ( percent < 0 ) 351 if ( percent < 0 )
347 percent = cfg.readNumEntry( "BassPercent", 50 ); 352 percent = cfg.readNumEntry( "BassPercent", 50 );
348 353
349 int fd = 0; 354 int fd = 0;
350 int bass = percent; 355 int bass = percent;
351 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { 356 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) {
352 ioctl( fd, MIXER_WRITE( SOUND_MIXER_BASS ), &bass ); 357 ioctl( fd, MIXER_WRITE( SOUND_MIXER_BASS ), &bass );
353 ::close( fd ); 358 ::close( fd );
354 } 359 }
355 } 360 }
356 break; 361 break;
357 } 362 }
358} 363}
359 364
360 365
361static void setTreble( int t = 0, int percent = -1 ) 366static void setTreble( int t = 0, int percent = -1 )
362{ 367{
363 switch ( t ) { 368 switch ( t ) {
364 case 0: { 369 case 0: {
365 Config cfg( "qpe" ); 370 Config cfg( "qpe" );
366 cfg.setGroup( "Volume" ); 371 cfg.setGroup( "Volume" );
367 if ( percent < 0 ) 372 if ( percent < 0 )
368 percent = cfg.readNumEntry( "TreblePercent", 50 ); 373 percent = cfg.readNumEntry( "TreblePercent", 50 );
369 374
370 int fd = 0; 375 int fd = 0;
371 int treble = percent; 376 int treble = percent;
372 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { 377 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) {
373 ioctl( fd, MIXER_WRITE( SOUND_MIXER_TREBLE ), &treble ); 378 ioctl( fd, MIXER_WRITE( SOUND_MIXER_TREBLE ), &treble );
374 ::close( fd ); 379 ::close( fd );
375 } 380 }
376 } 381 }
377 break; 382 break;
378 } 383 }
379} 384}
380 385
381 386
382/*! 387/*!
383 \class QPEApplication qpeapplication.h 388 \class QPEApplication qpeapplication.h
384 \brief The QPEApplication class implements various system services 389 \brief The QPEApplication class implements various system services
385 that are available to all Qtopia applications. 390 that are available to all Qtopia applications.
386 391
387 Simply by using QPEApplication instead of QApplication, a standard Qt 392 Simply by using QPEApplication instead of QApplication, a standard Qt
388 application becomes a Qtopia application. It automatically follows 393 application becomes a Qtopia application. It automatically follows
389 style changes, quits and raises, and in the 394 style changes, quits and raises, and in the
390 case of \link docwidget.html document-oriented\endlink applications, 395 case of \link docwidget.html document-oriented\endlink applications,
391 changes the currently displayed document in response to the environment. 396 changes the currently displayed document in response to the environment.
392 397
393 To create a \link docwidget.html document-oriented\endlink 398 To create a \link docwidget.html document-oriented\endlink
394 application use showMainDocumentWidget(); to create a 399 application use showMainDocumentWidget(); to create a
395 non-document-oriented application use showMainWidget(). The 400 non-document-oriented application use showMainWidget(). The
396 keepRunning() function indicates whether the application will 401 keepRunning() function indicates whether the application will
397 continue running after it's processed the last \link qcop.html 402 continue running after it's processed the last \link qcop.html
398 QCop\endlink message. This can be changed using setKeepRunning(). 403 QCop\endlink message. This can be changed using setKeepRunning().
399 404
400 A variety of signals are emitted when certain events occur, for 405 A variety of signals are emitted when certain events occur, for
401 example, timeChanged(), clockChanged(), weekChanged(), 406 example, timeChanged(), clockChanged(), weekChanged(),
402 dateFormatChanged() and volumeChanged(). If the application receives 407 dateFormatChanged() and volumeChanged(). If the application receives
403 a \link qcop.html QCop\endlink message on the application's 408 a \link qcop.html QCop\endlink message on the application's
404 QPE/Application/\e{appname} channel, the appMessage() signal is 409 QPE/Application/\e{appname} channel, the appMessage() signal is
405 emitted. There are also flush() and reload() signals, which 410 emitted. There are also flush() and reload() signals, which
406 are emitted when synching begins and ends respectively - upon these 411 are emitted when synching begins and ends respectively - upon these
407 signals, the application should save and reload any data 412 signals, the application should save and reload any data
408 files that are involved in synching. Most of these signals will initially 413 files that are involved in synching. Most of these signals will initially
409 be received and unfiltered through the appMessage() signal. 414 be received and unfiltered through the appMessage() signal.
410 415
411 This class also provides a set of useful static functions. The 416 This class also provides a set of useful static functions. The
412 qpeDir() and documentDir() functions return the respective paths. 417 qpeDir() and documentDir() functions return the respective paths.
413 The grabKeyboard() and ungrabKeyboard() functions are used to 418 The grabKeyboard() and ungrabKeyboard() functions are used to
414 control whether the application takes control of the device's 419 control whether the application takes control of the device's
415 physical buttons (e.g. application launch keys). The stylus' mode of 420 physical buttons (e.g. application launch keys). The stylus' mode of
416 operation is set with setStylusOperation() and retrieved with 421 operation is set with setStylusOperation() and retrieved with
417 stylusOperation(). There are also setInputMethodHint() and 422 stylusOperation(). There are also setInputMethodHint() and
418 inputMethodHint() functions. 423 inputMethodHint() functions.
419 424
420 \ingroup qtopiaemb 425 \ingroup qtopiaemb
421*/ 426*/
422 427
423/*! 428/*!
424 \fn void QPEApplication::clientMoused() 429 \fn void QPEApplication::clientMoused()
425 430
426 \internal 431 \internal
427*/ 432*/
428 433
429/*! 434/*!
430 \fn void QPEApplication::timeChanged(); 435 \fn void QPEApplication::timeChanged();
431 This signal is emitted when the time changes outside the normal 436 This signal is emitted when the time changes outside the normal
432 passage of time, i.e. if the time is set backwards or forwards. 437 passage of time, i.e. if the time is set backwards or forwards.
433*/ 438*/
434 439
435/*! 440/*!
436 \fn void QPEApplication::clockChanged( bool ampm ); 441 \fn void QPEApplication::clockChanged( bool ampm );
437 442
438 This signal is emitted when the user changes the clock's style. If 443 This signal is emitted when the user changes the clock's style. If
439 \a ampm is TRUE, the user wants a 12-hour AM/PM clock, otherwise, 444 \a ampm is TRUE, the user wants a 12-hour AM/PM clock, otherwise,
440 they want a 24-hour clock. 445 they want a 24-hour clock.
441*/ 446*/
442 447
443/*! 448/*!
444 \fn void QPEApplication::volumeChanged( bool muted ) 449 \fn void QPEApplication::volumeChanged( bool muted )
445 450
446 This signal is emitted whenever the mute state is changed. If \a 451 This signal is emitted whenever the mute state is changed. If \a
447 muted is TRUE, then sound output has been muted. 452 muted is TRUE, then sound output has been muted.
448*/ 453*/
449 454
450/*! 455/*!
451 \fn void QPEApplication::weekChanged( bool startOnMonday ) 456 \fn void QPEApplication::weekChanged( bool startOnMonday )
452 457
453 This signal is emitted if the week start day is changed. If \a 458 This signal is emitted if the week start day is changed. If \a
454 startOnMonday is TRUE then the first day of the week is Monday; if 459 startOnMonday is TRUE then the first day of the week is Monday; if
455 \a startOnMonday is FALSE then the first day of the week is 460 \a startOnMonday is FALSE then the first day of the week is
456 Sunday. 461 Sunday.
457*/ 462*/
458 463
459/*! 464/*!
460 \fn void QPEApplication::dateFormatChanged(DateFormat) 465 \fn void QPEApplication::dateFormatChanged(DateFormat)
461 466
462 This signal is emitted whenever the date format is changed. 467 This signal is emitted whenever the date format is changed.
463*/ 468*/
464 469
465/*! 470/*!
466 \fn void QPEApplication::flush() 471 \fn void QPEApplication::flush()
467 472
468 ### 473 ###
469*/ 474*/
470 475
471/*! 476/*!
472 \fn void QPEApplication::reload() 477 \fn void QPEApplication::reload()
473 478
474*/ 479*/
475 480
476/*! 481/*!
477 \fn void QPEApplication::appMessage( const QCString& msg, const QByteArray& data ) 482 \fn void QPEApplication::appMessage( const QCString& msg, const QByteArray& data )
478 483
479 This signal is emitted when a message is received on this 484 This signal is emitted when a message is received on this
480 application's QPE/Application/<i>appname</i> \link qcop.html 485 application's QPE/Application/<i>appname</i> \link qcop.html
481 QCop\endlink channel. 486 QCop\endlink channel.
482 487
483 The slot to which you connect this signal uses \a msg and \a data 488 The slot to which you connect this signal uses \a msg and \a data
484 in the following way: 489 in the following way:
485 490
486\code 491\code
487 void MyWidget::receive( const QCString& msg, const QByteArray& data ) 492 void MyWidget::receive( const QCString& msg, const QByteArray& data )
488 { 493 {
489 QDataStream stream( data, IO_ReadOnly ); 494 QDataStream stream( data, IO_ReadOnly );
490 if ( msg == "someMessage(int,int,int)" ) { 495 if ( msg == "someMessage(int,int,int)" ) {
491 int a,b,c; 496 int a,b,c;
492 stream >> a >> b >> c; 497 stream >> a >> b >> c;
493 ... 498 ...
494 } else if ( msg == "otherMessage(QString)" ) { 499 } else if ( msg == "otherMessage(QString)" ) {
495 ... 500 ...
496 } 501 }
497 } 502 }
498\endcode 503\endcode
499 504
500 \sa qcop.html 505 \sa qcop.html
501 Note that messages received here may be processed by qpe application 506 Note that messages received here may be processed by qpe application
502 and emitted as signals, such as flush() and reload(). 507 and emitted as signals, such as flush() and reload().
503*/ 508*/
504 509
505/*! 510/*!
506 Constructs a QPEApplication just as you would construct 511 Constructs a QPEApplication just as you would construct
507 a QApplication, passing \a argc, \a argv, and \a t. 512 a QApplication, passing \a argc, \a argv, and \a t.
508 513
509 For applications, \a t should be the default, GuiClient. Only 514 For applications, \a t should be the default, GuiClient. Only
510 the Qtopia server passes GuiServer. 515 the Qtopia server passes GuiServer.
511*/ 516*/
512QPEApplication::QPEApplication( int & argc, char **argv, Type t ) 517QPEApplication::QPEApplication( int & argc, char **argv, Type t )
513 : QApplication( argc, argv, t ) 518 : QApplication( argc, argv, t )
514{ 519{
515 d = new QPEApplicationData; 520 d = new QPEApplicationData;
516 d->loadTextCodecs(); 521 d->loadTextCodecs();
517 d->loadImageCodecs(); 522 d->loadImageCodecs();
518 int dw = desktop() ->width(); 523 int dw = desktop() ->width();
519 524
520 if ( dw < 200 ) { 525 if ( dw < 200 ) {
521 setFont( QFont( "vera", 8 ) ); 526 setFont( QFont( "vera", 8 ) );
522 AppLnk::setSmallIconSize( 10 ); 527 AppLnk::setSmallIconSize( 10 );
523 AppLnk::setBigIconSize( 28 ); 528 AppLnk::setBigIconSize( 28 );
524 } 529 }
530 #ifdef QT_QWS_SHARP
525 else if ( dw > 600 ) { 531 else if ( dw > 600 ) {
526 setFont( QFont( "vera", 16 ) ); 532 setFont( QFont( "vera", 16 ) );
527 AppLnk::setSmallIconSize( 24 ); 533 AppLnk::setSmallIconSize( 24 );
528 AppLnk::setBigIconSize( 48 ); 534 AppLnk::setBigIconSize( 48 );
529 } 535 }
536 #endif
530 else if ( dw > 200 ) { 537 else if ( dw > 200 ) {
531 setFont( QFont( "vera", 10 ) ); 538 setFont( QFont( "vera", 10 ) );
532 AppLnk::setSmallIconSize( 14 ); 539 AppLnk::setSmallIconSize( 14 );
533 AppLnk::setBigIconSize( 32 ); 540 AppLnk::setBigIconSize( 32 );
534 } 541 }
535 542
536
537 QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory ); 543 QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory );
538 544
539 connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) ); 545 connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) );
540#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 546#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
541 547
542 QString qcopfn( "/tmp/qcop-msg-" ); 548 QString qcopfn( "/tmp/qcop-msg-" );
543 qcopfn += QString( argv[ 0 ] ); // append command name 549 qcopfn += QString( argv[ 0 ] ); // append command name
544 550
545 QFile f( qcopfn ); 551 QFile f( qcopfn );
546 if ( f.open( IO_ReadOnly ) ) { 552 if ( f.open( IO_ReadOnly ) ) {
547 flock( f.handle(), LOCK_EX ); 553 flock( f.handle(), LOCK_EX );
548 } 554 }
549 555
550 sysChannel = new QCopChannel( "QPE/System", this ); 556 sysChannel = new QCopChannel( "QPE/System", this );
551 connect( sysChannel, SIGNAL( received( const QCString &, const QByteArray & ) ), 557 connect( sysChannel, SIGNAL( received( const QCString &, const QByteArray & ) ),
552 this, SLOT( systemMessage( const QCString &, const QByteArray & ) ) ); 558 this, SLOT( systemMessage( const QCString &, const QByteArray & ) ) );
553 559
554 QCString channel = QCString( argv[ 0 ] ); 560 QCString channel = QCString( argv[ 0 ] );
555 channel.replace( QRegExp( ".*/" ), "" ); 561 channel.replace( QRegExp( ".*/" ), "" );
556 d->appName = channel; 562 d->appName = channel;
557 channel = "QPE/Application/" + channel; 563 channel = "QPE/Application/" + channel;
558 pidChannel = new QCopChannel( channel, this ); 564 pidChannel = new QCopChannel( channel, this );
559 connect( pidChannel, SIGNAL( received( const QCString &, const QByteArray & ) ), 565 connect( pidChannel, SIGNAL( received( const QCString &, const QByteArray & ) ),
560 this, SLOT( pidMessage( const QCString &, const QByteArray & ) ) ); 566 this, SLOT( pidMessage( const QCString &, const QByteArray & ) ) );
561 567
562 if ( f.isOpen() ) { 568 if ( f.isOpen() ) {
563 d->keep_running = FALSE; 569 d->keep_running = FALSE;
564 QDataStream ds( &f ); 570 QDataStream ds( &f );
565 QCString channel, message; 571 QCString channel, message;
566 QByteArray data; 572 QByteArray data;
567 while ( !ds.atEnd() ) { 573 while ( !ds.atEnd() ) {
568 ds >> channel >> message >> data; 574 ds >> channel >> message >> data;
569 d->enqueueQCop( channel, message, data ); 575 d->enqueueQCop( channel, message, data );
570 } 576 }
571 577
572 flock( f.handle(), LOCK_UN ); 578 flock( f.handle(), LOCK_UN );
573 f.close(); 579 f.close();
574 f.remove(); 580 f.remove();
575 } 581 }
576 582
577 for ( int a = 0; a < argc; a++ ) { 583 for ( int a = 0; a < argc; a++ ) {
578 if ( qstrcmp( argv[ a ], "-preload" ) == 0 ) { 584 if ( qstrcmp( argv[ a ], "-preload" ) == 0 ) {
579 argv[ a ] = argv[ a + 1 ]; 585 argv[ a ] = argv[ a + 1 ];
580 a++; 586 a++;
581 d->preloaded = TRUE; 587 d->preloaded = TRUE;
582 argc -= 1; 588 argc -= 1;
583 } 589 }
584 else if ( qstrcmp( argv[ a ], "-preload-show" ) == 0 ) { 590 else if ( qstrcmp( argv[ a ], "-preload-show" ) == 0 ) {
585 argv[ a ] = argv[ a + 1 ]; 591 argv[ a ] = argv[ a + 1 ];
586 a++; 592 a++;
587 d->preloaded = TRUE; 593 d->preloaded = TRUE;
588 d->forceshow = TRUE; 594 d->forceshow = TRUE;
589 argc -= 1; 595 argc -= 1;
590 } 596 }
591 } 597 }
592 598
593 /* overide stored arguments */ 599 /* overide stored arguments */
594 setArgs( argc, argv ); 600 setArgs( argc, argv );
595 601
596#endif 602#endif
597 603
598 // qwsSetDecoration( new QPEDecoration() ); 604 // qwsSetDecoration( new QPEDecoration() );
599 605
600#ifndef QT_NO_TRANSLATION 606#ifndef QT_NO_TRANSLATION
601 607
602 QStringList langs = Global::languageList(); 608 QStringList langs = Global::languageList();
603 for ( QStringList::ConstIterator it = langs.begin(); it != langs.end(); ++it ) { 609 for ( QStringList::ConstIterator it = langs.begin(); it != langs.end(); ++it ) {
604 QString lang = *it; 610 QString lang = *it;
605 611
606 installTranslation( lang + "/libopie.qm"); 612 installTranslation( lang + "/libopie.qm");
607 installTranslation( lang + "/libqpe.qm" ); 613 installTranslation( lang + "/libqpe.qm" );
608 installTranslation( lang + "/" + d->appName + ".qm" ); 614 installTranslation( lang + "/" + d->appName + ".qm" );
609 615
610 616
611 //###language/font hack; should look it up somewhere 617 //###language/font hack; should look it up somewhere
612#ifdef QWS 618#ifdef QWS
613 619
614 if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) { 620 if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) {
615 QFont fn = FontManager::unicodeFont( FontManager::Proportional ); 621 QFont fn = FontManager::unicodeFont( FontManager::Proportional );
616 setFont( fn ); 622 setFont( fn );
617 } 623 }
618#endif 624#endif
619 625
620 } 626 }
621#endif 627#endif
622 628
623 applyStyle(); 629 applyStyle();
624 630
625 if ( type() == GuiServer ) { 631 if ( type() == GuiServer ) {
626 setVolume(); 632 setVolume();
627 } 633 }
628 634
629 installEventFilter( this ); 635 installEventFilter( this );
630 636
631 QPEMenuToolFocusManager::initialize(); 637 QPEMenuToolFocusManager::initialize();
632 638
633#ifdef QT_NO_QWS_CURSOR 639#ifdef QT_NO_QWS_CURSOR
634 // if we have no cursor, probably don't want tooltips 640 // if we have no cursor, probably don't want tooltips
635 QToolTip::setEnabled( FALSE ); 641 QToolTip::setEnabled( FALSE );
636#endif 642#endif
637} 643}
638 644
639static QPtrDict<void>* inputMethodDict = 0; 645static QPtrDict<void>* inputMethodDict = 0;
640static void createInputMethodDict() 646static void createInputMethodDict()
641{ 647{
642 if ( !inputMethodDict ) 648 if ( !inputMethodDict )
643 inputMethodDict = new QPtrDict<void>; 649 inputMethodDict = new QPtrDict<void>;
644} 650}
645 651
646/*! 652/*!
647 Returns the currently set hint to the system as to whether 653 Returns the currently set hint to the system as to whether
648 widget \a w has any use for text input methods. 654 widget \a w has any use for text input methods.
649 655
650 656
651 \sa setInputMethodHint() InputMethodHint 657 \sa setInputMethodHint() InputMethodHint
652*/ 658*/
653QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w ) 659QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w )
654{ 660{
655 if ( inputMethodDict && w ) 661 if ( inputMethodDict && w )
656 return ( InputMethodHint ) ( int ) inputMethodDict->find( w ); 662 return ( InputMethodHint ) ( int ) inputMethodDict->find( w );
657 return Normal; 663 return Normal;
658} 664}
659 665
660/*! 666/*!
661 \enum QPEApplication::InputMethodHint 667 \enum QPEApplication::InputMethodHint
662 668
663 \value Normal the application sometimes needs text input (the default). 669 \value Normal the application sometimes needs text input (the default).
664 \value AlwaysOff the application never needs text input. 670 \value AlwaysOff the application never needs text input.
665 \value AlwaysOn the application always needs text input. 671 \value AlwaysOn the application always needs text input.
666*/ 672*/
667 673
668/*! 674/*!
669 Hints to the system that widget \a w has use for text input methods 675 Hints to the system that widget \a w has use for text input methods
670 as specified by \a mode. 676 as specified by \a mode.
671 677
672 \sa inputMethodHint() InputMethodHint 678 \sa inputMethodHint() InputMethodHint
673*/ 679*/
674void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode ) 680void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode )
675{ 681{
676 createInputMethodDict(); 682 createInputMethodDict();
677 if ( mode == Normal ) { 683 if ( mode == Normal ) {
678 inputMethodDict->remove 684 inputMethodDict->remove
679 ( w ); 685 ( w );
680 } 686 }
681 else { 687 else {
682 inputMethodDict->insert( w, ( void* ) mode ); 688 inputMethodDict->insert( w, ( void* ) mode );
683 } 689 }
684} 690}
685 691
686class HackDialog : public QDialog 692class HackDialog : public QDialog
687{ 693{
688public: 694public:
689 void acceptIt() 695 void acceptIt()
690 { 696 {
691 accept(); 697 accept();
692 } 698 }
693 void rejectIt() 699 void rejectIt()
694 { 700 {
695 reject(); 701 reject();
696 } 702 }
697}; 703};
698 704
699 705
700void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key ) 706void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key )
701{ 707{
702 // specialised actions for certain widgets. May want to 708 // specialised actions for certain widgets. May want to
703 // add more stuff here. 709 // add more stuff here.
704 if ( activePopupWidget() && activePopupWidget() ->inherits( "QListBox" ) 710 if ( activePopupWidget() && activePopupWidget() ->inherits( "QListBox" )
705 && activePopupWidget() ->parentWidget() 711 && activePopupWidget() ->parentWidget()
706 && activePopupWidget() ->parentWidget() ->inherits( "QComboBox" ) ) 712 && activePopupWidget() ->parentWidget() ->inherits( "QComboBox" ) )
707 key = Qt::Key_Return; 713 key = Qt::Key_Return;
708 714
709 if ( activePopupWidget() && activePopupWidget() ->inherits( "QPopupMenu" ) ) 715 if ( activePopupWidget() && activePopupWidget() ->inherits( "QPopupMenu" ) )
710 key = Qt::Key_Return; 716 key = Qt::Key_Return;
711 717
712#ifdef QWS 718#ifdef QWS
713 719
714 ke->simpleData.keycode = key; 720 ke->simpleData.keycode = key;
715#endif 721#endif
716} 722}
717 723
718class HackWidget : public QWidget 724class HackWidget : public QWidget
719{ 725{
720public: 726public:
721 bool needsOk() 727 bool needsOk()
722 { 728 {
723 return ( getWState() & WState_Reserved1 ); 729 return ( getWState() & WState_Reserved1 );
724 } 730 }
725}; 731};
726 732
727/*! 733/*!
728 \internal 734 \internal
729*/ 735*/
730 736
731#ifdef QWS 737#ifdef QWS
732bool QPEApplication::qwsEventFilter( QWSEvent * e ) 738bool QPEApplication::qwsEventFilter( QWSEvent * e )
733{ 739{
734 if ( !d->notbusysent && e->type == QWSEvent::Focus ) { 740 if ( !d->notbusysent && e->type == QWSEvent::Focus ) {
735 if ( qApp->type() != QApplication::GuiServer ) { 741 if ( qApp->type() != QApplication::GuiServer ) {
736 QCopEnvelope e( "QPE/System", "notBusy(QString)" ); 742 QCopEnvelope e( "QPE/System", "notBusy(QString)" );
737 e << d->appName; 743 e << d->appName;
738 } 744 }
739 d->notbusysent = TRUE; 745 d->notbusysent = TRUE;
740 } 746 }
741 if ( type() == GuiServer ) { 747 if ( type() == GuiServer ) {
742 switch ( e->type ) { 748 switch ( e->type ) {
743 case QWSEvent::Mouse: 749 case QWSEvent::Mouse:
744 if ( e->asMouse() ->simpleData.state && !QWidget::find( e->window() ) ) 750 if ( e->asMouse() ->simpleData.state && !QWidget::find( e->window() ) )
745 emit clientMoused(); 751 emit clientMoused();
746 break; 752 break;
747 default: 753 default:
748 break; 754 break;
749 } 755 }
750 } 756 }
751 if ( e->type == QWSEvent::Key ) { 757 if ( e->type == QWSEvent::Key ) {
752 QWSKeyEvent *ke = ( QWSKeyEvent * ) e; 758 QWSKeyEvent *ke = ( QWSKeyEvent * ) e;
753 if ( ke->simpleData.keycode == Qt::Key_F33 ) { 759 if ( ke->simpleData.keycode == Qt::Key_F33 ) {
754 // Use special "OK" key to press "OK" on top level widgets 760 // Use special "OK" key to press "OK" on top level widgets
755 QWidget * active = activeWindow(); 761 QWidget * active = activeWindow();
756 QWidget *popup = 0; 762 QWidget *popup = 0;
757 if ( active && active->isPopup() ) { 763 if ( active && active->isPopup() ) {
758 popup = active; 764 popup = active;
759 active = active->parentWidget(); 765 active = active->parentWidget();
760 } 766 }
761 if ( active && ( int ) active->winId() == ke->simpleData.window && 767 if ( active && ( int ) active->winId() == ke->simpleData.window &&
762 !active->testWFlags( WStyle_Customize | WType_Popup | WType_Desktop ) ) { 768 !active->testWFlags( WStyle_Customize | WType_Popup | WType_Desktop ) ) {
763 if ( ke->simpleData.is_press ) { 769 if ( ke->simpleData.is_press ) {
764 if ( popup ) 770 if ( popup )
765 popup->close(); 771 popup->close();
766 if ( active->inherits( "QDialog" ) ) { 772 if ( active->inherits( "QDialog" ) ) {
767 HackDialog * d = ( HackDialog * ) active; 773 HackDialog * d = ( HackDialog * ) active;
768 d->acceptIt(); 774 d->acceptIt();
769 return TRUE; 775 return TRUE;
770 } 776 }
771 else if ( ( ( HackWidget * ) active ) ->needsOk() ) { 777 else if ( ( ( HackWidget * ) active ) ->needsOk() ) {
772 QSignal s; 778 QSignal s;
773 s.connect( active, SLOT( accept() ) ); 779 s.connect( active, SLOT( accept() ) );
774 s.activate(); 780 s.activate();
775 } 781 }
776 else { 782 else {
777 // do the same as with the select key: Map to the default action of the widget: 783 // do the same as with the select key: Map to the default action of the widget:
778 mapToDefaultAction( ke, Qt::Key_Return ); 784 mapToDefaultAction( ke, Qt::Key_Return );
779 } 785 }
780 } 786 }
781 } 787 }
782 } 788 }
783 else if ( ke->simpleData.keycode == Qt::Key_F30 ) { 789 else if ( ke->simpleData.keycode == Qt::Key_F30 ) {
784 // Use special "select" key to do whatever default action a widget has 790 // Use special "select" key to do whatever default action a widget has
785 mapToDefaultAction( ke, Qt::Key_Space ); 791 mapToDefaultAction( ke, Qt::Key_Space );
786 } 792 }
787 else if ( ke->simpleData.keycode == Qt::Key_Escape && 793 else if ( ke->simpleData.keycode == Qt::Key_Escape &&
788 ke->simpleData.is_press ) { 794 ke->simpleData.is_press ) {
789 // Escape key closes app if focus on toplevel 795 // Escape key closes app if focus on toplevel
790 QWidget * active = activeWindow(); 796 QWidget * active = activeWindow();
791 if ( active && active->testWFlags( WType_TopLevel ) && 797 if ( active && active->testWFlags( WType_TopLevel ) &&
792 ( int ) active->winId() == ke->simpleData.window && 798 ( int ) active->winId() == ke->simpleData.window &&
793 !active->testWFlags( WStyle_Dialog | WStyle_Customize | WType_Popup | WType_Desktop ) ) { 799 !active->testWFlags( WStyle_Dialog | WStyle_Customize | WType_Popup | WType_Desktop ) ) {
794 if ( active->inherits( "QDialog" ) ) { 800 if ( active->inherits( "QDialog" ) ) {
795 HackDialog * d = ( HackDialog * ) active; 801 HackDialog * d = ( HackDialog * ) active;
796 d->rejectIt(); 802 d->rejectIt();
797 return TRUE; 803 return TRUE;
798 } 804 }
799 else if ( strcmp( argv() [ 0 ], "embeddedkonsole" ) != 0 ) { 805 else if ( strcmp( argv() [ 0 ], "embeddedkonsole" ) != 0 ) {
800 active->close(); 806 active->close();
801 } 807 }
802 } 808 }
803 } 809 }
804 else if ( ke->simpleData.keycode >= Qt::Key_F1 && ke->simpleData.keycode <= Qt::Key_F29 ) { 810 else if ( ke->simpleData.keycode >= Qt::Key_F1 && ke->simpleData.keycode <= Qt::Key_F29 ) {
805 // this should be if ( ODevice::inst ( )-> buttonForKeycode ( ... )) 811 // this should be if ( ODevice::inst ( )-> buttonForKeycode ( ... ))
806 // but we cannot access libopie function within libqpe :( 812 // but we cannot access libopie function within libqpe :(
807 813
808 QWidget * active = activeWindow ( ); 814 QWidget * active = activeWindow ( );
809 if ( active && ((int) active-> winId ( ) == ke-> simpleData.window )) { 815 if ( active && ((int) active-> winId ( ) == ke-> simpleData.window )) {
810 if ( d-> kbgrabbed ) { // we grabbed the keyboard 816 if ( d-> kbgrabbed ) { // we grabbed the keyboard
811 QChar ch ( ke-> simpleData.unicode ); 817 QChar ch ( ke-> simpleData.unicode );
812 QKeyEvent qke ( ke-> simpleData. is_press ? QEvent::KeyPress : QEvent::KeyRelease, 818 QKeyEvent qke ( ke-> simpleData. is_press ? QEvent::KeyPress : QEvent::KeyRelease,
813 ke-> simpleData.keycode, 819 ke-> simpleData.keycode,
814 ch. latin1 ( ), 820 ch. latin1 ( ),
815 ke-> simpleData.modifiers, 821 ke-> simpleData.modifiers,
816 QString ( ch ), 822 QString ( ch ),
817 ke-> simpleData.is_auto_repeat, 1 ); 823 ke-> simpleData.is_auto_repeat, 1 );
818 824
819 QObject *which = QWidget::keyboardGrabber ( ); 825 QObject *which = QWidget::keyboardGrabber ( );
820 if ( !which ) 826 if ( !which )
821 which = QApplication::focusWidget ( ); 827 which = QApplication::focusWidget ( );
822 if ( !which ) 828 if ( !which )
823 which = QApplication::activeWindow ( ); 829 which = QApplication::activeWindow ( );
824 if ( !which ) 830 if ( !which )
825 which = qApp; 831 which = qApp;
826 832
827 QApplication::sendEvent ( which, &qke ); 833 QApplication::sendEvent ( which, &qke );
828 } 834 }
829 else { // we didn't grab the keyboard, so send the event to the launcher 835 else { // we didn't grab the keyboard, so send the event to the launcher
830 QCopEnvelope e ( "QPE/Launcher", "deviceButton(int,int,int)" ); 836 QCopEnvelope e ( "QPE/Launcher", "deviceButton(int,int,int)" );
831 e << int( ke-> simpleData.keycode ) << int( ke-> simpleData. is_press ) << int( ke-> simpleData.is_auto_repeat ); 837 e << int( ke-> simpleData.keycode ) << int( ke-> simpleData. is_press ) << int( ke-> simpleData.is_auto_repeat );
832 } 838 }
833 } 839 }
834 return true; 840 return true;
835 } 841 }
836 } 842 }
837 if ( e->type == QWSEvent::Focus ) { 843 if ( e->type == QWSEvent::Focus ) {
838 QWSFocusEvent * fe = ( QWSFocusEvent* ) e; 844 QWSFocusEvent * fe = ( QWSFocusEvent* ) e;
839 if ( !fe->simpleData.get_focus ) { 845 if ( !fe->simpleData.get_focus ) {
840 QWidget * active = activeWindow(); 846 QWidget * active = activeWindow();
841 while ( active && active->isPopup() ) { 847 while ( active && active->isPopup() ) {
842 active->close(); 848 active->close();
843 active = activeWindow(); 849 active = activeWindow();
844 } 850 }
845 } 851 }
846 else { 852 else {
847 // make sure our modal widget is ALWAYS on top 853 // make sure our modal widget is ALWAYS on top
848 QWidget *topm = activeModalWidget(); 854 QWidget *topm = activeModalWidget();
849 if ( topm ) { 855 if ( topm ) {
850 topm->raise(); 856 topm->raise();
851 } 857 }
852 } 858 }
853 if ( fe->simpleData.get_focus && inputMethodDict ) { 859 if ( fe->simpleData.get_focus && inputMethodDict ) {
854 InputMethodHint m = inputMethodHint( QWidget::find( e->window() ) ); 860 InputMethodHint m = inputMethodHint( QWidget::find( e->window() ) );
855 if ( m == AlwaysOff ) 861 if ( m == AlwaysOff )
856 Global::hideInputMethod(); 862 Global::hideInputMethod();
857 if ( m == AlwaysOn ) 863 if ( m == AlwaysOn )
858 Global::showInputMethod(); 864 Global::showInputMethod();
859 } 865 }
860 } 866 }
861 867
862 868
863 return QApplication::qwsEventFilter( e ); 869 return QApplication::qwsEventFilter( e );
864} 870}
865#endif 871#endif
866 872
867/*! 873/*!
868 Destroys the QPEApplication. 874 Destroys the QPEApplication.
869*/ 875*/
870QPEApplication::~QPEApplication() 876QPEApplication::~QPEApplication()
871{ 877{
872 ungrabKeyboard(); 878 ungrabKeyboard();
873#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 879#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
874 // Need to delete QCopChannels early, since the display will 880 // Need to delete QCopChannels early, since the display will
875 // be gone by the time we get to ~QObject(). 881 // be gone by the time we get to ~QObject().
876 delete sysChannel; 882 delete sysChannel;
877 delete pidChannel; 883 delete pidChannel;
878#endif 884#endif
879 885
880 delete d; 886 delete d;
881} 887}
882 888
883/*! 889/*!
884 Returns <tt>$OPIEDIR/</tt>. 890 Returns <tt>$OPIEDIR/</tt>.
885*/ 891*/
886QString QPEApplication::qpeDir() 892QString QPEApplication::qpeDir()
887{ 893{
888 const char * base = getenv( "OPIEDIR" ); 894 const char * base = getenv( "OPIEDIR" );
889 if ( base ) 895 if ( base )
890 return QString( base ) + "/"; 896 return QString( base ) + "/";
891 897
892 return QString( "../" ); 898 return QString( "../" );
893} 899}
894 900
895/*! 901/*!
896 Returns the user's current Document directory. There is a trailing "/". 902 Returns the user's current Document directory. There is a trailing "/".
897 .. well, it does now,, and there's no trailing '/' 903 .. well, it does now,, and there's no trailing '/'
898*/ 904*/
899QString QPEApplication::documentDir() 905QString QPEApplication::documentDir()
900{ 906{
901 const char* base = getenv( "HOME"); 907 const char* base = getenv( "HOME");
902 if ( base ) 908 if ( base )
903 return QString( base ) + "/Documents"; 909 return QString( base ) + "/Documents";
904 910
905 return QString( "../Documents" ); 911 return QString( "../Documents" );
906} 912}
907 913
908static int deforient = -1; 914static int deforient = -1;
909 915
910/*! 916/*!
911 \internal 917 \internal
912*/ 918*/
913int QPEApplication::defaultRotation() 919int QPEApplication::defaultRotation()
914{ 920{
915 if ( deforient < 0 ) { 921 if ( deforient < 0 ) {
916 QString d = getenv( "QWS_DISPLAY" ); 922 QString d = getenv( "QWS_DISPLAY" );
917 if ( d.contains( "Rot90" ) ) { 923 if ( d.contains( "Rot90" ) ) {
918 deforient = 90; 924 deforient = 90;
919 } 925 }
920 else if ( d.contains( "Rot180" ) ) { 926 else if ( d.contains( "Rot180" ) ) {
921 deforient = 180; 927 deforient = 180;
922 } 928 }
923 else if ( d.contains( "Rot270" ) ) { 929 else if ( d.contains( "Rot270" ) ) {
924 deforient = 270; 930 deforient = 270;
925 } 931 }
926 else { 932 else {
927 deforient = 0; 933 deforient = 0;
928 } 934 }
929 } 935 }
930 return deforient; 936 return deforient;
931} 937}
932 938
933/*! 939/*!
934 \internal 940 \internal
935*/ 941*/
936void QPEApplication::setDefaultRotation( int r ) 942void QPEApplication::setDefaultRotation( int r )
937{ 943{
938 if ( qApp->type() == GuiServer ) { 944 if ( qApp->type() == GuiServer ) {
939 deforient = r; 945 deforient = r;
940 setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 ); 946 setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 );
941 Config config("qpe"); 947 Config config("qpe");
942 config.setGroup( "Rotation" ); 948 config.setGroup( "Rotation" );
943 config.writeEntry( "Rot", r ); 949 config.writeEntry( "Rot", r );
944 } 950 }
945 else { 951 else {
946#ifndef QT_NO_COP 952#ifndef QT_NO_COP
947 { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" ); 953 { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" );
948 e << r; 954 e << r;
949 } 955 }
950#endif 956#endif
951 957
952 } 958 }
953} 959}
954 960
955 961
956/*! 962/*!
957 \internal 963 \internal
958*/ 964*/
959void QPEApplication::applyStyle() 965void QPEApplication::applyStyle()
960{ 966{
961 Config config( "qpe" ); 967 Config config( "qpe" );
962 config.setGroup( "Appearance" ); 968 config.setGroup( "Appearance" );
963 969
964 #if QT_VERSION > 233 970 #if QT_VERSION > 233
965 // don't block ourselves ... 971 // don't block ourselves ...
966 Opie::force_appearance = 0; 972 Opie::force_appearance = 0;
967 973
968 static QString appname = Opie::binaryName ( ); 974 static QString appname = Opie::binaryName ( );
969 975
970 QStringList ex = config. readListEntry ( "NoStyle", ';' ); 976 QStringList ex = config. readListEntry ( "NoStyle", ';' );
971 int nostyle = 0; 977 int nostyle = 0;
972 for ( QStringList::Iterator it = ex. begin ( ); it != ex. end ( ); ++it ) { 978 for ( QStringList::Iterator it = ex. begin ( ); it != ex. end ( ); ++it ) {
973 if ( QRegExp (( *it ). mid ( 1 ), false, true ). find ( appname, 0 ) >= 0 ) { 979 if ( QRegExp (( *it ). mid ( 1 ), false, true ). find ( appname, 0 ) >= 0 ) {
974 nostyle = ( *it ). left ( 1 ). toInt ( 0, 32 ); 980 nostyle = ( *it ). left ( 1 ). toInt ( 0, 32 );
975 break; 981 break;
976 } 982 }
977 } 983 }
978 984
979 // Widget style 985 // Widget style
980 QString style = config.readEntry( "Style", "Light" ); 986 QString style = config.readEntry( "Style", "Light" );
981 987
982 // don't set a custom style 988 // don't set a custom style
983 if ( nostyle & Opie::Force_Style ) 989 if ( nostyle & Opie::Force_Style )
984 style = "Light"; 990 style = "Light";
985 991
986 internalSetStyle ( style ); 992 internalSetStyle ( style );
987 993
988 // Colors 994 // Colors
989 QColor bgcolor( config.readEntry( "Background", "#E5E1D5" ) ); 995 QColor bgcolor( config.readEntry( "Background", "#E5E1D5" ) );
990 QColor btncolor( config.readEntry( "Button", "#D6CDBB" ) ); 996 QColor btncolor( config.readEntry( "Button", "#D6CDBB" ) );
991 QPalette pal( btncolor, bgcolor ); 997 QPalette pal( btncolor, bgcolor );
992 QString color = config.readEntry( "Highlight", "#800000" ); 998 QString color = config.readEntry( "Highlight", "#800000" );
993 pal.setColor( QColorGroup::Highlight, QColor( color ) ); 999 pal.setColor( QColorGroup::Highlight, QColor( color ) );
994 color = config.readEntry( "HighlightedText", "#FFFFFF" ); 1000 color = config.readEntry( "HighlightedText", "#FFFFFF" );
995 pal.setColor( QColorGroup::HighlightedText, QColor( color ) ); 1001 pal.setColor( QColorGroup::HighlightedText, QColor( color ) );
996 color = config.readEntry( "Text", "#000000" ); 1002 color = config.readEntry( "Text", "#000000" );
997 pal.setColor( QColorGroup::Text, QColor( color ) ); 1003 pal.setColor( QColorGroup::Text, QColor( color ) );
998 color = config.readEntry( "ButtonText", "#000000" ); 1004 color = config.readEntry( "ButtonText", "#000000" );
999 pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) ); 1005 pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) );
1000 color = config.readEntry( "Base", "#FFFFFF" ); 1006 color = config.readEntry( "Base", "#FFFFFF" );
1001 pal.setColor( QColorGroup::Base, QColor( color ) ); 1007 pal.setColor( QColorGroup::Base, QColor( color ) );
1002 1008
1003 pal.setColor( QPalette::Disabled, QColorGroup::Text, 1009 pal.setColor( QPalette::Disabled, QColorGroup::Text,
1004 pal.color( QPalette::Active, QColorGroup::Background ).dark() ); 1010 pal.color( QPalette::Active, QColorGroup::Background ).dark() );
1005 1011
1006 setPalette( pal, TRUE ); 1012 setPalette( pal, TRUE );
1007 1013
1008 // Window Decoration 1014 // Window Decoration
1009 QString dec = config.readEntry( "Decoration", "Qtopia" ); 1015 QString dec = config.readEntry( "Decoration", "Qtopia" );
1010 1016
1011 // don't set a custom deco 1017 // don't set a custom deco
1012 if ( nostyle & Opie::Force_Decoration ) 1018 if ( nostyle & Opie::Force_Decoration )
1013 dec = ""; 1019 dec = "";
1014 1020
1015 //qDebug ( "Setting Deco: %s -- old %s (%d)", dec.latin1(), d-> decorationName.latin1(), nostyle); 1021 //qDebug ( "Setting Deco: %s -- old %s (%d)", dec.latin1(), d-> decorationName.latin1(), nostyle);
1016 1022
1017 if ( dec != d->decorationName ) { 1023 if ( dec != d->decorationName ) {
1018 qwsSetDecoration( new QPEDecoration( dec ) ); 1024 qwsSetDecoration( new QPEDecoration( dec ) );
1019 d->decorationName = dec; 1025 d->decorationName = dec;
1020 } 1026 }
1021 1027
1022 // Font 1028 // Font
1023 QString ff = config.readEntry( "FontFamily", font().family() ); 1029 QString ff = config.readEntry( "FontFamily", font().family() );
1024 int fs = config.readNumEntry( "FontSize", font().pointSize() ); 1030 int fs = config.readNumEntry( "FontSize", font().pointSize() );
1025 1031
1026 // don't set a custom font 1032 // don't set a custom font
1027 if ( nostyle & Opie::Force_Font ) { 1033 if ( nostyle & Opie::Force_Font ) {
1028 ff = "Vera"; 1034 ff = "Vera";
1029 fs = 10; 1035 fs = 10;
1030 } 1036 }
1031 1037
1032 setFont ( QFont ( ff, fs ), true ); 1038 setFont ( QFont ( ff, fs ), true );
1033 1039
1034 // revert to global blocking policy ... 1040 // revert to global blocking policy ...
1035 Opie::force_appearance = config. readBoolEntry ( "ForceStyle", false ) ? Opie::Force_All : Opie::Force_None; 1041 Opie::force_appearance = config. readBoolEntry ( "ForceStyle", false ) ? Opie::Force_All : Opie::Force_None;
1036 Opie::force_appearance &= ~nostyle; 1042 Opie::force_appearance &= ~nostyle;
1037 #endif 1043 #endif
1038} 1044}
1039 1045
1040void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data ) 1046void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data )
1041{ 1047{
1042#ifdef Q_WS_QWS 1048#ifdef Q_WS_QWS
1043 QDataStream stream( data, IO_ReadOnly ); 1049 QDataStream stream( data, IO_ReadOnly );
1044 if ( msg == "applyStyle()" ) { 1050 if ( msg == "applyStyle()" ) {
1045 applyStyle(); 1051 applyStyle();
1046 } 1052 }
1047 else if ( msg == "toggleApplicationMenu()" ) { 1053 else if ( msg == "toggleApplicationMenu()" ) {
1048 QWidget *active = activeWindow ( ); 1054 QWidget *active = activeWindow ( );
1049 1055
1050 if ( active ) { 1056 if ( active ) {
1051 QPEMenuToolFocusManager *man = QPEMenuToolFocusManager::manager ( ); 1057 QPEMenuToolFocusManager *man = QPEMenuToolFocusManager::manager ( );
1052 bool oldactive = man-> isActive ( ); 1058 bool oldactive = man-> isActive ( );
1053 1059
1054 man-> setActive( !man-> isActive() ); 1060 man-> setActive( !man-> isActive() );
1055 1061
1056 if ( !oldactive && !man-> isActive ( )) { // no menubar to toggle -> try O-Menu 1062 if ( !oldactive && !man-> isActive ( )) { // no menubar to toggle -> try O-Menu
1057 QCopEnvelope e ( "QPE/TaskBar", "toggleStartMenu()" ); 1063 QCopEnvelope e ( "QPE/TaskBar", "toggleStartMenu()" );
1058 } 1064 }
1059 } 1065 }
1060 } 1066 }
1061 else if ( msg == "setDefaultRotation(int)" ) { 1067 else if ( msg == "setDefaultRotation(int)" ) {
1062 if ( type() == GuiServer ) { 1068 if ( type() == GuiServer ) {
1063 int r; 1069 int r;
1064 stream >> r; 1070 stream >> r;
1065 setDefaultRotation( r ); 1071 setDefaultRotation( r );
1066 } 1072 }
1067 } 1073 }
1068 else if ( msg == "setCurrentRotation(int)" ) { 1074 else if ( msg == "setCurrentRotation(int)" ) {
1069 int r; 1075 int r;
1070 stream >> r; 1076 stream >> r;
1071 setCurrentRotation( r ); 1077 setCurrentRotation( r );
1072 } 1078 }
1073 else if ( msg == "shutdown()" ) { 1079 else if ( msg == "shutdown()" ) {
1074 if ( type() == GuiServer ) 1080 if ( type() == GuiServer )
1075 shutdown(); 1081 shutdown();
1076 } 1082 }
1077 else if ( msg == "quit()" ) { 1083 else if ( msg == "quit()" ) {
1078 if ( type() != GuiServer ) 1084 if ( type() != GuiServer )
1079 tryQuit(); 1085 tryQuit();
1080 } 1086 }
1081 else if ( msg == "forceQuit()" ) { 1087 else if ( msg == "forceQuit()" ) {
1082 if ( type() != GuiServer ) 1088 if ( type() != GuiServer )
1083 quit(); 1089 quit();
1084 } 1090 }
1085 else if ( msg == "restart()" ) { 1091 else if ( msg == "restart()" ) {
1086 if ( type() == GuiServer ) 1092 if ( type() == GuiServer )
1087 restart(); 1093 restart();
1088 } 1094 }
1089 else if ( msg == "language(QString)" ) { 1095 else if ( msg == "language(QString)" ) {
1090 if ( type() == GuiServer ) { 1096 if ( type() == GuiServer ) {
1091 QString l; 1097 QString l;
1092 stream >> l; 1098 stream >> l;
1093 QString cl = getenv( "LANG" ); 1099 QString cl = getenv( "LANG" );
1094 if ( cl != l ) { 1100 if ( cl != l ) {
1095 if ( l.isNull() ) 1101 if ( l.isNull() )
1096 unsetenv( "LANG" ); 1102 unsetenv( "LANG" );
1097 else 1103 else
1098 setenv( "LANG", l.latin1(), 1 ); 1104 setenv( "LANG", l.latin1(), 1 );
1099 restart(); 1105 restart();
1100 } 1106 }
1101 } 1107 }
1102 } 1108 }
1103 else if ( msg == "timeChange(QString)" ) { 1109 else if ( msg == "timeChange(QString)" ) {
1104 QString t; 1110 QString t;
1105 stream >> t; 1111 stream >> t;
1106 if ( t.isNull() ) 1112 if ( t.isNull() )
1107 unsetenv( "TZ" ); 1113 unsetenv( "TZ" );
1108 else 1114 else
1109 setenv( "TZ", t.latin1(), 1 ); 1115 setenv( "TZ", t.latin1(), 1 );
1110 // emit the signal so everyone else knows... 1116 // emit the signal so everyone else knows...
1111 emit timeChanged(); 1117 emit timeChanged();
1112 } 1118 }
1113 else if ( msg == "execute(QString)" ) { 1119 else if ( msg == "execute(QString)" ) {
1114 if ( type() == GuiServer ) { 1120 if ( type() == GuiServer ) {
1115 QString t; 1121 QString t;
1116 stream >> t; 1122 stream >> t;
1117 Global::execute( t ); 1123 Global::execute( t );
1118 } 1124 }
1119 } 1125 }
1120 else if ( msg == "execute(QString,QString)" ) { 1126 else if ( msg == "execute(QString,QString)" ) {
1121 if ( type() == GuiServer ) { 1127 if ( type() == GuiServer ) {
1122 QString t, d; 1128 QString t, d;
1123 stream >> t >> d; 1129 stream >> t >> d;
1124 Global::execute( t, d ); 1130 Global::execute( t, d );
1125 } 1131 }
1126 } 1132 }
1127 else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) { 1133 else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) {
1128 if ( type() == GuiServer ) { 1134 if ( type() == GuiServer ) {
1129 QDateTime when; 1135 QDateTime when;
1130 QCString channel, message; 1136 QCString channel, message;
1131 int data; 1137 int data;
1132 stream >> when >> channel >> message >> data; 1138 stream >> when >> channel >> message >> data;
1133 AlarmServer::addAlarm( when, channel, message, data ); 1139 AlarmServer::addAlarm( when, channel, message, data );
1134 } 1140 }
1135 } 1141 }
1136 else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) { 1142 else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) {
1137 if ( type() == GuiServer ) { 1143 if ( type() == GuiServer ) {
1138 QDateTime when; 1144 QDateTime when;
1139 QCString channel, message; 1145 QCString channel, message;
1140 int data; 1146 int data;
1141 stream >> when >> channel >> message >> data; 1147 stream >> when >> channel >> message >> data;
1142 AlarmServer::deleteAlarm( when, channel, message, data ); 1148 AlarmServer::deleteAlarm( when, channel, message, data );
1143 } 1149 }
1144 } 1150 }
1145 else if ( msg == "clockChange(bool)" ) { 1151 else if ( msg == "clockChange(bool)" ) {
1146 int tmp; 1152 int tmp;
1147 stream >> tmp; 1153 stream >> tmp;
1148 emit clockChanged( tmp ); 1154 emit clockChanged( tmp );
1149 } 1155 }
1150 else if ( msg == "weekChange(bool)" ) { 1156 else if ( msg == "weekChange(bool)" ) {
1151 int tmp; 1157 int tmp;
1152 stream >> tmp; 1158 stream >> tmp;
1153 emit weekChanged( tmp ); 1159 emit weekChanged( tmp );
1154 } 1160 }
1155 else if ( msg == "setDateFormat(DateFormat)" ) { 1161 else if ( msg == "setDateFormat(DateFormat)" ) {
1156 DateFormat tmp; 1162 DateFormat tmp;
1157 stream >> tmp; 1163 stream >> tmp;
1158 emit dateFormatChanged( tmp ); 1164 emit dateFormatChanged( tmp );
1159 } 1165 }
1160 else if ( msg == "setVolume(int,int)" ) { 1166 else if ( msg == "setVolume(int,int)" ) {
1161 int t, v; 1167 int t, v;
1162 stream >> t >> v; 1168 stream >> t >> v;
1163 setVolume( t, v ); 1169 setVolume( t, v );
1164 emit volumeChanged( muted ); 1170 emit volumeChanged( muted );
1165 } 1171 }
1166 else if ( msg == "volumeChange(bool)" ) { 1172 else if ( msg == "volumeChange(bool)" ) {
1167 stream >> muted; 1173 stream >> muted;
1168 setVolume(); 1174 setVolume();
1169 emit volumeChanged( muted ); 1175 emit volumeChanged( muted );
1170 } 1176 }
1171 else if ( msg == "setMic(int,int)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> 1177 else if ( msg == "setMic(int,int)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com>
1172 int t, v; 1178 int t, v;
1173 stream >> t >> v; 1179 stream >> t >> v;
1174 setMic( t, v ); 1180 setMic( t, v );
1175 emit micChanged( micMuted ); 1181 emit micChanged( micMuted );
1176 } 1182 }
1177 else if ( msg == "micChange(bool)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> 1183 else if ( msg == "micChange(bool)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com>
1178 stream >> micMuted; 1184 stream >> micMuted;
1179 setMic(); 1185 setMic();
1180 emit micChanged( micMuted ); 1186 emit micChanged( micMuted );
1181 } 1187 }
1182 else if ( msg == "setBass(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> 1188 else if ( msg == "setBass(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org>
1183 int t, v; 1189 int t, v;
1184 stream >> t >> v; 1190 stream >> t >> v;
1185 setBass( t, v ); 1191 setBass( t, v );
1186 } 1192 }
1187 else if ( msg == "bassChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> 1193 else if ( msg == "bassChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org>
1188 setBass(); 1194 setBass();
1189 } 1195 }
1190 else if ( msg == "setTreble(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> 1196 else if ( msg == "setTreble(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org>
1191 int t, v; 1197 int t, v;
1192 stream >> t >> v; 1198 stream >> t >> v;
1193 setTreble( t, v ); 1199 setTreble( t, v );
1194 } 1200 }
1195 else if ( msg == "trebleChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> 1201 else if ( msg == "trebleChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org>
1196 setTreble(); 1202 setTreble();
1197 } 1203 }
1198 1204
1199 1205
1200 1206
1201#endif 1207#endif
1202} 1208}
1203 1209
1204/*! 1210/*!
1205 \internal 1211 \internal
1206*/ 1212*/
1207bool QPEApplication::raiseAppropriateWindow() 1213bool QPEApplication::raiseAppropriateWindow()
1208{ 1214{
1209 bool r = FALSE; 1215 bool r = FALSE;
1210 // ########## raise()ing main window should raise and set active 1216 // ########## raise()ing main window should raise and set active
1211 // ########## it and then all childen. This belongs in Qt/Embedded 1217 // ########## it and then all childen. This belongs in Qt/Embedded
1212 QWidget *top = d->qpe_main_widget; 1218 QWidget *top = d->qpe_main_widget;
1213 if ( !top ) 1219 if ( !top )
1214 top = mainWidget(); 1220 top = mainWidget();
1215 if ( top && d->keep_running ) { 1221 if ( top && d->keep_running ) {
1216 if ( top->isVisible() ) 1222 if ( top->isVisible() )
1217 r = TRUE; 1223 r = TRUE;
1218 else if (d->preloaded) { 1224 else if (d->preloaded) {
1219 // We are preloaded and not visible.. pretend we just started.. 1225 // We are preloaded and not visible.. pretend we just started..
1220 QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); 1226 QCopEnvelope e("QPE/System", "fastAppShowing(QString)");
1221 e << d->appName; 1227 e << d->appName;
1222 } 1228 }
1223 1229
1224 d->show_mx(top, d->nomaximize); 1230 d->show_mx(top, d->nomaximize);
1225 top->raise(); 1231 top->raise();
1226 top->setActiveWindow(); 1232 top->setActiveWindow();
1227 } 1233 }
1228 QWidget *topm = activeModalWidget(); 1234 QWidget *topm = activeModalWidget();
1229 if ( topm && topm != top ) { 1235 if ( topm && topm != top ) {
1230 topm->show(); 1236 topm->show();
1231 topm->raise(); 1237 topm->raise();
1232 topm->setActiveWindow(); 1238 topm->setActiveWindow();
1233 // If we haven't already handled the fastAppShowing message 1239 // If we haven't already handled the fastAppShowing message
1234 if (!top && d->preloaded) { 1240 if (!top && d->preloaded) {
1235 QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); 1241 QCopEnvelope e("QPE/System", "fastAppShowing(QString)");
1236 e << d->appName; 1242 e << d->appName;
1237 } 1243 }
1238 r = FALSE; 1244 r = FALSE;
1239 } 1245 }
1240 return r; 1246 return r;
1241} 1247}
1242 1248
1243void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data) 1249void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data)
1244{ 1250{
1245#ifdef Q_WS_QWS 1251#ifdef Q_WS_QWS
1246 1252
1247 if ( msg == "quit()" ) { 1253 if ( msg == "quit()" ) {
1248 tryQuit(); 1254 tryQuit();
1249 } 1255 }
1250 else if ( msg == "quitIfInvisible()" ) { 1256 else if ( msg == "quitIfInvisible()" ) {
1251 if ( d->qpe_main_widget && !d->qpe_main_widget->isVisible() ) 1257 if ( d->qpe_main_widget && !d->qpe_main_widget->isVisible() )
1252 quit(); 1258 quit();
1253 } 1259 }
1254 else if ( msg == "close()" ) { 1260 else if ( msg == "close()" ) {
1255 hideOrQuit(); 1261 hideOrQuit();
1256 } 1262 }
1257 else if ( msg == "disablePreload()" ) { 1263 else if ( msg == "disablePreload()" ) {
1258 d->preloaded = FALSE; 1264 d->preloaded = FALSE;
1259 d->keep_running = TRUE; 1265 d->keep_running = TRUE;
1260 /* so that quit will quit */ 1266 /* so that quit will quit */
1261 } 1267 }
1262 else if ( msg == "enablePreload()" ) { 1268 else if ( msg == "enablePreload()" ) {
1263 if (d->qpe_main_widget) 1269 if (d->qpe_main_widget)
1264 d->preloaded = TRUE; 1270 d->preloaded = TRUE;
1265 d->keep_running = TRUE; 1271 d->keep_running = TRUE;
1266 /* so next quit won't quit */ 1272 /* so next quit won't quit */
1267 } 1273 }
1268 else if ( msg == "raise()" ) { 1274 else if ( msg == "raise()" ) {
1269 d->keep_running = TRUE; 1275 d->keep_running = TRUE;
1270 d->notbusysent = FALSE; 1276 d->notbusysent = FALSE;
1271 raiseAppropriateWindow(); 1277 raiseAppropriateWindow();
1272 // Tell the system we're still chugging along... 1278 // Tell the system we're still chugging along...
1273 QCopEnvelope e("QPE/System", "appRaised(QString)"); 1279 QCopEnvelope e("QPE/System", "appRaised(QString)");
1274 e << d->appName; 1280 e << d->appName;
1275 } 1281 }
1276 else if ( msg == "flush()" ) { 1282 else if ( msg == "flush()" ) {
1277 emit flush(); 1283 emit flush();
1278 // we need to tell the desktop 1284 // we need to tell the desktop
1279 QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" ); 1285 QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" );
1280 e << d->appName; 1286 e << d->appName;
1281 } 1287 }
1282 else if ( msg == "reload()" ) { 1288 else if ( msg == "reload()" ) {
1283 emit reload(); 1289 emit reload();
1284 } 1290 }
1285 else if ( msg == "setDocument(QString)" ) { 1291 else if ( msg == "setDocument(QString)" ) {
1286 d->keep_running = TRUE; 1292 d->keep_running = TRUE;
1287 QDataStream stream( data, IO_ReadOnly ); 1293 QDataStream stream( data, IO_ReadOnly );
1288 QString doc; 1294 QString doc;
1289 stream >> doc; 1295 stream >> doc;
1290 QWidget *mw = mainWidget(); 1296 QWidget *mw = mainWidget();
1291 if ( !mw ) 1297 if ( !mw )
1292 mw = d->qpe_main_widget; 1298 mw = d->qpe_main_widget;
1293 if ( mw ) 1299 if ( mw )
1294 Global::setDocument( mw, doc ); 1300 Global::setDocument( mw, doc );
1295 } 1301 }
1296 else if ( msg == "nextView()" ) { 1302 else if ( msg == "nextView()" ) {
1297 qDebug("got nextView()"); 1303 qDebug("got nextView()");
1298 /* 1304 /*
1299 if ( raiseAppropriateWindow() ) 1305 if ( raiseAppropriateWindow() )
1300 */ 1306 */
1301 emit appMessage( msg, data); 1307 emit appMessage( msg, data);
1302 } 1308 }
1303 else { 1309 else {
1304 emit appMessage( msg, data); 1310 emit appMessage( msg, data);