summaryrefslogtreecommitdiff
path: root/library/qpeapplication.cpp
Unidiff
Diffstat (limited to 'library/qpeapplication.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--library/qpeapplication.cpp43
1 files changed, 21 insertions, 22 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp
index b5dff3a..c41dd06 100644
--- a/library/qpeapplication.cpp
+++ b/library/qpeapplication.cpp
@@ -1,493 +1,492 @@
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 "qpeapplication.h" 53#include "qpeapplication.h"
54#include "qpestyle.h" 54#include "qpestyle.h"
55#include "styleinterface.h" 55#include "styleinterface.h"
56#if QT_VERSION >= 300 56#if QT_VERSION >= 300
57#include <qstylefactory.h> 57#include <qstylefactory.h>
58#else 58#else
59#include <qplatinumstyle.h> 59#include <qplatinumstyle.h>
60#include <qwindowsstyle.h> 60#include <qwindowsstyle.h>
61#include <qmotifstyle.h> 61#include <qmotifstyle.h>
62#include <qmotifplusstyle.h> 62#include <qmotifplusstyle.h>
63#include "lightstyle.h" 63#include "lightstyle.h"
64 64
65#include <qpe/qlibrary.h> 65#include <qpe/qlibrary.h>
66#endif 66#endif
67#include "global.h" 67#include "global.h"
68#include "resource.h" 68#include "resource.h"
69#if QT_VERSION <= 230 && defined(QT_NO_CODECS) 69#if QT_VERSION <= 230 && defined(QT_NO_CODECS)
70#include "qutfcodec.h" 70#include "qutfcodec.h"
71#endif 71#endif
72#include "config.h" 72#include "config.h"
73#include "network.h" 73#include "network.h"
74#ifdef QWS 74#ifdef QWS
75#include "fontmanager.h" 75#include "fontmanager.h"
76#endif 76#endif
77 77
78#include "alarmserver.h" 78#include "alarmserver.h"
79#include "applnk.h" 79#include "applnk.h"
80#include "qpemenubar.h" 80#include "qpemenubar.h"
81#include "textcodecinterface.h" 81#include "textcodecinterface.h"
82#include "imagecodecinterface.h" 82#include "imagecodecinterface.h"
83 83
84#include <unistd.h> 84#include <unistd.h>
85#include <sys/file.h> 85#include <sys/file.h>
86#include <sys/ioctl.h> 86#include <sys/ioctl.h>
87#include <sys/soundcard.h> 87#include <sys/soundcard.h>
88 88
89#include "qt_override_p.h" 89#include "qt_override_p.h"
90 90
91 91
92class QPEApplicationData 92class QPEApplicationData
93{ 93{
94public: 94public:
95 QPEApplicationData() : presstimer( 0 ), presswidget( 0 ), rightpressed( FALSE ), 95 QPEApplicationData() : presstimer( 0 ), presswidget( 0 ), kbgrabber( 0 ),
96 kbgrabber( 0 ), kbregrab( FALSE ), notbusysent( FALSE ), preloaded( FALSE ), 96 rightpressed( FALSE ), kbregrab( FALSE ), notbusysent( FALSE ), preloaded( FALSE ),
97 forceshow( FALSE ), nomaximize( FALSE ), qpe_main_widget( 0 ), 97 forceshow( FALSE ), nomaximize( FALSE ), keep_running( TRUE ), qpe_main_widget( 0 )
98 keep_running( TRUE ) 98
99 { 99 {
100 qcopq.setAutoDelete( TRUE ); 100 qcopq.setAutoDelete( TRUE );
101 } 101 }
102 102
103 int presstimer; 103 int presstimer;
104 QWidget* presswidget; 104 QWidget* presswidget;
105 QPoint presspos;
106bool rightpressed :
107 1; // AEH why not use uint foobar :1; if it's tt style -zecke
108 int kbgrabber; 105 int kbgrabber;
109bool kbregrab : 106 QPoint presspos;
110 1; 107
111bool notbusysent : 108 bool rightpressed : 1;
112 1; 109 bool kbregrab : 1;
110 bool notbusysent : 1;
111 bool preloaded : 1;
112 bool forceshow : 1;
113 bool nomaximize : 1;
114 bool keep_running : 1;
115
113 QString appName; 116 QString appName;
114 struct QCopRec 117 struct QCopRec
115 { 118 {
116 QCopRec( const QCString &ch, const QCString &msg, 119 QCopRec( const QCString &ch, const QCString &msg,
117 const QByteArray &d ) : 120 const QByteArray &d ) :
118 channel( ch ), message( msg ), data( d ) 121 channel( ch ), message( msg ), data( d )
119 { } 122 { }
120 123
121 QCString channel; 124 QCString channel;
122 QCString message; 125 QCString message;
123 QByteArray data; 126 QByteArray data;
124 }; 127 };
125bool preloaded :
126 1;
127bool forceshow :
128 1;
129bool nomaximize :
130 1;
131 QWidget* qpe_main_widget; 128 QWidget* qpe_main_widget;
132bool keep_running :
133 1;
134 QList<QCopRec> qcopq; 129 QList<QCopRec> qcopq;
135 130
136 void enqueueQCop( const QCString &ch, const QCString &msg, 131 void enqueueQCop( const QCString &ch, const QCString &msg,
137 const QByteArray &data ) 132 const QByteArray &data )
138 { 133 {
139 qcopq.append( new QCopRec( ch, msg, data ) ); 134 qcopq.append( new QCopRec( ch, msg, data ) );
140 } 135 }
141 void sendQCopQ() 136 void sendQCopQ()
142 { 137 {
143 QCopRec * r; 138 QCopRec * r;
144#ifndef QT_NO_COP 139#ifndef QT_NO_COP
145 140
146 for ( QListIterator<QCopRec> it( qcopq ); ( r = it.current() ); ++it ) 141 for ( QListIterator<QCopRec> it( qcopq ); ( r = it.current() ); ++it )
147 QCopChannel::sendLocally( r->channel, r->message, r->data ); 142 QCopChannel::sendLocally( r->channel, r->message, r->data );
148#endif 143#endif
149 144
150 qcopq.clear(); 145 qcopq.clear();
151 } 146 }
152 static void show_mx(QWidget* mw, bool nomaximize) 147 static void show_mx(QWidget* mw, bool nomaximize)
153 { 148 {
154 if ( mw->layout() && mw->inherits("QDialog") ) { 149 if ( mw->layout() && mw->inherits("QDialog") ) {
155 QPEApplication::showDialog((QDialog*)mw, nomaximize); 150 QPEApplication::showDialog((QDialog*)mw, nomaximize);
156 } 151 }
157 else { 152 else {
158#ifdef Q_WS_QWS 153#ifdef Q_WS_QWS
159 if ( !nomaximize ) 154 if ( !nomaximize )
160 mw->showMaximized(); 155 mw->showMaximized();
161 else 156 else
162#endif 157#endif
163 158
164 mw->show(); 159 mw->show();
165 } 160 }
166 } 161 }
167 static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) 162 static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ )
168 { 163 {
169 /* 164 /*
170 // This works but disable it for now until it is safe to apply 165 // This works but disable it for now until it is safe to apply
171 // What is does is scan the .desktop files of all the apps for 166 // What is does is scan the .desktop files of all the apps for
172 // the applnk that has the corresponding argv[0] as this program 167 // the applnk that has the corresponding argv[0] as this program
173 // then it uses the name stored in the .desktop file as the caption 168 // then it uses the name stored in the .desktop file as the caption
174 // for the main widget. This saves duplicating translations for 169 // for the main widget. This saves duplicating translations for
175 // the app name in the program and in the .desktop files. 170 // the app name in the program and in the .desktop files.
176 171
177 AppLnkSet apps( appsPath ); 172 AppLnkSet apps( appsPath );
178 173
179 QList<AppLnk> appsList = apps.children(); 174 QList<AppLnk> appsList = apps.children();
180 for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) { 175 for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) {
181 if ( (*it)->exec() == appName ) { 176 if ( (*it)->exec() == appName ) {
182 mw->setCaption( (*it)->name() ); 177 mw->setCaption( (*it)->name() );
183 return TRUE; 178 return TRUE;
184 } 179 }
185 } 180 }
186 */ 181 */
187 return FALSE; 182 return FALSE;
188 } 183 }
189 184
190 185
191 void show(QWidget* mw, bool nomax) 186 void show(QWidget* mw, bool nomax)
192 { 187 {
193 setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" ); 188 setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" );
194 nomaximize = nomax; 189 nomaximize = nomax;
195 qpe_main_widget = mw; 190 qpe_main_widget = mw;
196#ifndef QT_NO_COP 191#ifndef QT_NO_COP
197 192
198 sendQCopQ(); 193 sendQCopQ();
199#endif 194#endif
200 195
201 if ( preloaded ) { 196 if ( preloaded ) {
202 if (forceshow) 197 if (forceshow)
203 show_mx(mw, nomax); 198 show_mx(mw, nomax);
204 } 199 }
205 else if ( keep_running ) { 200 else if ( keep_running ) {
206 show_mx(mw, nomax); 201 show_mx(mw, nomax);
207 } 202 }
208 } 203 }
209 204
210 void loadTextCodecs() 205 void loadTextCodecs()
211 { 206 {
212 QString path = QPEApplication::qpeDir() + "/plugins/textcodecs"; 207 QString path = QPEApplication::qpeDir() + "/plugins/textcodecs";
213 QDir dir( path, "lib*.so" ); 208 QDir dir( path, "lib*.so" );
214 QStringList list = dir.entryList(); 209 QStringList list;
210 if ( dir. exists ( ))
211 list = dir.entryList();
215 QStringList::Iterator it; 212 QStringList::Iterator it;
216 for ( it = list.begin(); it != list.end(); ++it ) { 213 for ( it = list.begin(); it != list.end(); ++it ) {
217 TextCodecInterface *iface = 0; 214 TextCodecInterface *iface = 0;
218 QLibrary *lib = new QLibrary( path + "/" + *it ); 215 QLibrary *lib = new QLibrary( path + "/" + *it );
219 if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { 216 if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) {
220 QValueList<int> mibs = iface->mibEnums(); 217 QValueList<int> mibs = iface->mibEnums();
221 for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) { 218 for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) {
222 (void)iface->createForMib(*i); 219 (void)iface->createForMib(*i);
223 // ### it exists now; need to remember if we can delete it 220 // ### it exists now; need to remember if we can delete it
224 } 221 }
225 } 222 }
226 else { 223 else {
227 lib->unload(); 224 lib->unload();
228 delete lib; 225 delete lib;
229 } 226 }
230 } 227 }
231 } 228 }
232 229
233 void loadImageCodecs() 230 void loadImageCodecs()
234 { 231 {
235 QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs"; 232 QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs";
236 QDir dir( path, "lib*.so" ); 233 QDir dir( path, "lib*.so" );
237 QStringList list = dir.entryList(); 234 QStringList list;
235 if ( dir. exists ( ))
236 list = dir.entryList();
238 QStringList::Iterator it; 237 QStringList::Iterator it;
239 for ( it = list.begin(); it != list.end(); ++it ) { 238 for ( it = list.begin(); it != list.end(); ++it ) {
240 ImageCodecInterface *iface = 0; 239 ImageCodecInterface *iface = 0;
241 QLibrary *lib = new QLibrary( path + "/" + *it ); 240 QLibrary *lib = new QLibrary( path + "/" + *it );
242 if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { 241 if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) {
243 QStringList formats = iface->keys(); 242 QStringList formats = iface->keys();
244 for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) { 243 for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) {
245 (void)iface->installIOHandler(*i); 244 (void)iface->installIOHandler(*i);
246 // ### it exists now; need to remember if we can delete it 245 // ### it exists now; need to remember if we can delete it
247 } 246 }
248 } 247 }
249 else { 248 else {
250 lib->unload(); 249 lib->unload();
251 delete lib; 250 delete lib;
252 } 251 }
253 } 252 }
254 } 253 }
255 QString styleName; 254 QString styleName;
256 QString decorationName; 255 QString decorationName;
257}; 256};
258 257
259class ResourceMimeFactory : public QMimeSourceFactory 258class ResourceMimeFactory : public QMimeSourceFactory
260{ 259{
261public: 260public:
262 ResourceMimeFactory() 261 ResourceMimeFactory()
263 { 262 {
264 setFilePath( Global::helpPath() ); 263 setFilePath( Global::helpPath() );
265 setExtensionType( "html", "text/html;charset=UTF-8" ); 264 setExtensionType( "html", "text/html;charset=UTF-8" );
266 } 265 }
267 266
268 const QMimeSource* data( const QString& abs_name ) const 267 const QMimeSource* data( const QString& abs_name ) const
269 { 268 {
270 const QMimeSource * r = QMimeSourceFactory::data( abs_name ); 269 const QMimeSource * r = QMimeSourceFactory::data( abs_name );
271 if ( !r ) { 270 if ( !r ) {
272 int sl = abs_name.length(); 271 int sl = abs_name.length();
273 do { 272 do {
274 sl = abs_name.findRev( '/', sl - 1 ); 273 sl = abs_name.findRev( '/', sl - 1 );
275 QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name; 274 QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name;
276 int dot = name.findRev( '.' ); 275 int dot = name.findRev( '.' );
277 if ( dot >= 0 ) 276 if ( dot >= 0 )
278 name = name.left( dot ); 277 name = name.left( dot );
279 QImage img = Resource::loadImage( name ); 278 QImage img = Resource::loadImage( name );
280 if ( !img.isNull() ) 279 if ( !img.isNull() )
281 r = new QImageDrag( img ); 280 r = new QImageDrag( img );
282 } 281 }
283 while ( !r && sl > 0 ); 282 while ( !r && sl > 0 );
284 } 283 }
285 return r; 284 return r;
286 } 285 }
287}; 286};
288 287
289static int muted = 0; 288static int muted = 0;
290static int micMuted = 0; 289static int micMuted = 0;
291 290
292static void setVolume( int t = 0, int percent = -1 ) 291static void setVolume( int t = 0, int percent = -1 )
293{ 292{
294 switch ( t ) { 293 switch ( t ) {
295 case 0: { 294 case 0: {
296 Config cfg( "qpe" ); 295 Config cfg( "qpe" );
297 cfg.setGroup( "Volume" ); 296 cfg.setGroup( "Volume" );
298 if ( percent < 0 ) 297 if ( percent < 0 )
299 percent = cfg.readNumEntry( "VolumePercent", 50 ); 298 percent = cfg.readNumEntry( "VolumePercent", 50 );
300 int fd = 0; 299 int fd = 0;
301 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { 300 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) {
302 int vol = muted ? 0 : percent; 301 int vol = muted ? 0 : percent;
303 // set both channels to same volume 302 // set both channels to same volume
304 vol |= vol << 8; 303 vol |= vol << 8;
305 ioctl( fd, MIXER_WRITE( 0 ), &vol ); 304 ioctl( fd, MIXER_WRITE( 0 ), &vol );
306 ::close( fd ); 305 ::close( fd );
307 } 306 }
308 } 307 }
309 break; 308 break;
310 } 309 }
311} 310}
312 311
313static void setMic( int t = 0, int percent = -1 ) 312static void setMic( int t = 0, int percent = -1 )
314{ 313{
315 switch ( t ) { 314 switch ( t ) {
316 case 0: { 315 case 0: {
317 Config cfg( "qpe" ); 316 Config cfg( "qpe" );
318 cfg.setGroup( "Volume" ); 317 cfg.setGroup( "Volume" );
319 if ( percent < 0 ) 318 if ( percent < 0 )
320 percent = cfg.readNumEntry( "Mic", 50 ); 319 percent = cfg.readNumEntry( "Mic", 50 );
321 320
322 int fd = 0; 321 int fd = 0;
323 int mic = micMuted ? 0 : percent; 322 int mic = micMuted ? 0 : percent;
324 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { 323 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) {
325 ioctl( fd, MIXER_WRITE( SOUND_MIXER_MIC ), &mic ); 324 ioctl( fd, MIXER_WRITE( SOUND_MIXER_MIC ), &mic );
326 ::close( fd ); 325 ::close( fd );
327 } 326 }
328 } 327 }
329 break; 328 break;
330 } 329 }
331} 330}
332 331
333 332
334/*! 333/*!
335 \class QPEApplication qpeapplication.h 334 \class QPEApplication qpeapplication.h
336 \brief The QPEApplication class implements various system services 335 \brief The QPEApplication class implements various system services
337 that are available to all Qtopia applications. 336 that are available to all Qtopia applications.
338 337
339 Simply by using QPEApplication instead of QApplication, a standard Qt 338 Simply by using QPEApplication instead of QApplication, a standard Qt
340 application becomes a Qtopia application. It automatically follows 339 application becomes a Qtopia application. It automatically follows
341 style changes, quits and raises, and in the 340 style changes, quits and raises, and in the
342 case of \link docwidget.html document-oriented\endlink applications, 341 case of \link docwidget.html document-oriented\endlink applications,
343 changes the currently displayed document in response to the environment. 342 changes the currently displayed document in response to the environment.
344 343
345 To create a \link docwidget.html document-oriented\endlink 344 To create a \link docwidget.html document-oriented\endlink
346 application use showMainDocumentWidget(); to create a 345 application use showMainDocumentWidget(); to create a
347 non-document-oriented application use showMainWidget(). The 346 non-document-oriented application use showMainWidget(). The
348 keepRunning() function indicates whether the application will 347 keepRunning() function indicates whether the application will
349 continue running after it's processed the last \link qcop.html 348 continue running after it's processed the last \link qcop.html
350 QCop\endlink message. This can be changed using setKeepRunning(). 349 QCop\endlink message. This can be changed using setKeepRunning().
351 350
352 A variety of signals are emitted when certain events occur, for 351 A variety of signals are emitted when certain events occur, for
353 example, timeChanged(), clockChanged(), weekChanged(), 352 example, timeChanged(), clockChanged(), weekChanged(),
354 dateFormatChanged() and volumeChanged(). If the application receives 353 dateFormatChanged() and volumeChanged(). If the application receives
355 a \link qcop.html QCop\endlink message on the application's 354 a \link qcop.html QCop\endlink message on the application's
356 QPE/Application/\e{appname} channel, the appMessage() signal is 355 QPE/Application/\e{appname} channel, the appMessage() signal is
357 emitted. There are also flush() and reload() signals, which 356 emitted. There are also flush() and reload() signals, which
358 are emitted when synching begins and ends respectively - upon these 357 are emitted when synching begins and ends respectively - upon these
359 signals, the application should save and reload any data 358 signals, the application should save and reload any data
360 files that are involved in synching. Most of these signals will initially 359 files that are involved in synching. Most of these signals will initially
361 be received and unfiltered through the appMessage() signal. 360 be received and unfiltered through the appMessage() signal.
362 361
363 This class also provides a set of useful static functions. The 362 This class also provides a set of useful static functions. The
364 qpeDir() and documentDir() functions return the respective paths. 363 qpeDir() and documentDir() functions return the respective paths.
365 The grabKeyboard() and ungrabKeyboard() functions are used to 364 The grabKeyboard() and ungrabKeyboard() functions are used to
366 control whether the application takes control of the device's 365 control whether the application takes control of the device's
367 physical buttons (e.g. application launch keys). The stylus' mode of 366 physical buttons (e.g. application launch keys). The stylus' mode of
368 operation is set with setStylusOperation() and retrieved with 367 operation is set with setStylusOperation() and retrieved with
369 stylusOperation(). There are also setInputMethodHint() and 368 stylusOperation(). There are also setInputMethodHint() and
370 inputMethodHint() functions. 369 inputMethodHint() functions.
371 370
372 \ingroup qtopiaemb 371 \ingroup qtopiaemb
373*/ 372*/
374 373
375/*! 374/*!
376 \fn void QPEApplication::clientMoused() 375 \fn void QPEApplication::clientMoused()
377 376
378 \internal 377 \internal
379*/ 378*/
380 379
381/*! 380/*!
382 \fn void QPEApplication::timeChanged(); 381 \fn void QPEApplication::timeChanged();
383 This signal is emitted when the time changes outside the normal 382 This signal is emitted when the time changes outside the normal
384 passage of time, i.e. if the time is set backwards or forwards. 383 passage of time, i.e. if the time is set backwards or forwards.
385*/ 384*/
386 385
387/*! 386/*!
388 \fn void QPEApplication::clockChanged( bool ampm ); 387 \fn void QPEApplication::clockChanged( bool ampm );
389 388
390 This signal is emitted when the user changes the clock's style. If 389 This signal is emitted when the user changes the clock's style. If
391 \a ampm is TRUE, the user wants a 12-hour AM/PM clock, otherwise, 390 \a ampm is TRUE, the user wants a 12-hour AM/PM clock, otherwise,
392 they want a 24-hour clock. 391 they want a 24-hour clock.
393*/ 392*/
394 393
395/*! 394/*!
396 \fn void QPEApplication::volumeChanged( bool muted ) 395 \fn void QPEApplication::volumeChanged( bool muted )
397 396
398 This signal is emitted whenever the mute state is changed. If \a 397 This signal is emitted whenever the mute state is changed. If \a
399 muted is TRUE, then sound output has been muted. 398 muted is TRUE, then sound output has been muted.
400*/ 399*/
401 400
402/*! 401/*!
403 \fn void QPEApplication::weekChanged( bool startOnMonday ) 402 \fn void QPEApplication::weekChanged( bool startOnMonday )
404 403
405 This signal is emitted if the week start day is changed. If \a 404 This signal is emitted if the week start day is changed. If \a
406 startOnMonday is TRUE then the first day of the week is Monday; if 405 startOnMonday is TRUE then the first day of the week is Monday; if
407 \a startOnMonday is FALSE then the first day of the week is 406 \a startOnMonday is FALSE then the first day of the week is
408 Sunday. 407 Sunday.
409*/ 408*/
410 409
411/*! 410/*!
412 \fn void QPEApplication::dateFormatChanged() 411 \fn void QPEApplication::dateFormatChanged()
413 412
414 This signal is emitted whenever the date format is changed. 413 This signal is emitted whenever the date format is changed.
415*/ 414*/
416 415
417/*! 416/*!
418 \fn void QPEApplication::flush() 417 \fn void QPEApplication::flush()
419 418
420 ### 419 ###
421*/ 420*/
422 421
423/*! 422/*!
424 \fn void QPEApplication::reload() 423 \fn void QPEApplication::reload()
425 424
426*/ 425*/
427 426
428/*! 427/*!
429 \fn void QPEApplication::appMessage( const QCString& msg, const QByteArray& data ) 428 \fn void QPEApplication::appMessage( const QCString& msg, const QByteArray& data )
430 429
431 This signal is emitted when a message is received on this 430 This signal is emitted when a message is received on this
432 application's QPE/Application/<i>appname</i> \link qcop.html 431 application's QPE/Application/<i>appname</i> \link qcop.html
433 QCop\endlink channel. 432 QCop\endlink channel.
434 433
435 The slot to which you connect this signal uses \a msg and \a data 434 The slot to which you connect this signal uses \a msg and \a data
436 in the following way: 435 in the following way:
437 436
438\code 437\code
439 void MyWidget::receive( const QCString& msg, const QByteArray& data ) 438 void MyWidget::receive( const QCString& msg, const QByteArray& data )
440 { 439 {
441 QDataStream stream( data, IO_ReadOnly ); 440 QDataStream stream( data, IO_ReadOnly );
442 if ( msg == "someMessage(int,int,int)" ) { 441 if ( msg == "someMessage(int,int,int)" ) {
443 int a,b,c; 442 int a,b,c;
444 stream >> a >> b >> c; 443 stream >> a >> b >> c;
445 ... 444 ...
446 } else if ( msg == "otherMessage(QString)" ) { 445 } else if ( msg == "otherMessage(QString)" ) {
447 ... 446 ...
448 } 447 }
449 } 448 }
450\endcode 449\endcode
451 450
452 \sa qcop.html 451 \sa qcop.html
453 Note that messages received here may be processed by qpe application 452 Note that messages received here may be processed by qpe application
454 and emitted as signals, such as flush() and reload(). 453 and emitted as signals, such as flush() and reload().
455*/ 454*/
456 455
457/*! 456/*!
458 Constructs a QPEApplication just as you would construct 457 Constructs a QPEApplication just as you would construct
459 a QApplication, passing \a argc, \a argv, and \a t. 458 a QApplication, passing \a argc, \a argv, and \a t.
460 459
461 For applications, \a t should be the default, GuiClient. Only 460 For applications, \a t should be the default, GuiClient. Only
462 the Qtopia server passes GuiServer. 461 the Qtopia server passes GuiServer.
463*/ 462*/
464QPEApplication::QPEApplication( int & argc, char **argv, Type t ) 463QPEApplication::QPEApplication( int & argc, char **argv, Type t )
465 : QApplication( argc, argv, t ) 464 : QApplication( argc, argv, t )
466{ 465{
467 d = new QPEApplicationData; 466 d = new QPEApplicationData;
468 d->loadTextCodecs(); 467 d->loadTextCodecs();
469 d->loadImageCodecs(); 468 d->loadImageCodecs();
470 int dw = desktop() ->width(); 469 int dw = desktop() ->width();
471 qWarning( "Width %d", dw ); 470 qWarning( "Width %d", dw );
472 if ( dw < 200 ) { 471 if ( dw < 200 ) {
473 setFont( QFont( "helvetica", 8 ) ); 472 setFont( QFont( "helvetica", 8 ) );
474 AppLnk::setSmallIconSize( 10 ); 473 AppLnk::setSmallIconSize( 10 );
475 AppLnk::setBigIconSize( 28 ); 474 AppLnk::setBigIconSize( 28 );
476 } 475 }
477 else if ( dw > 600 ) { 476 else if ( dw > 600 ) {
478 setFont( QFont( "helvetica", 12 ) ); 477 setFont( QFont( "helvetica", 12 ) );
479 AppLnk::setSmallIconSize( 24 ); 478 AppLnk::setSmallIconSize( 24 );
480 AppLnk::setBigIconSize( 48 ); 479 AppLnk::setBigIconSize( 48 );
481 } 480 }
482 else if ( dw > 200 ) { 481 else if ( dw > 200 ) {
483 setFont( QFont( "helvetica", 10 ) ); 482 setFont( QFont( "helvetica", 10 ) );
484 AppLnk::setSmallIconSize( 16 ); 483 AppLnk::setSmallIconSize( 16 );
485 AppLnk::setBigIconSize( 32 ); 484 AppLnk::setBigIconSize( 32 );
486 } 485 }
487 486
488 487
489 QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory ); 488 QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory );
490 489
491 connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) ); 490 connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) );
492#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 491#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
493 492