summaryrefslogtreecommitdiff
path: root/library/qpeapplication.cpp
authorwimpie <wimpie>2004-08-25 01:47:35 (UTC)
committer wimpie <wimpie>2004-08-25 01:47:35 (UTC)
commitf6a6fe57c9e0047379f4b8b40da4776f1c4d7b25 (patch) (unidiff)
tree2db64e885b1a67058fa45533819993c8dcb4fb96 /library/qpeapplication.cpp
parent49c47e98bed6e35d0bdc8e1e4cc40bdbb07eab06 (diff)
downloadopie-f6a6fe57c9e0047379f4b8b40da4776f1c4d7b25.zip
opie-f6a6fe57c9e0047379f4b8b40da4776f1c4d7b25.tar.gz
opie-f6a6fe57c9e0047379f4b8b40da4776f1c4d7b25.tar.bz2
Final changes for RoH Feedback
- changed *.pro file to compile in backend - some more fixes to rohfeedback and qpeapplication
Diffstat (limited to 'library/qpeapplication.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--library/qpeapplication.cpp58
1 files changed, 30 insertions, 28 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp
index 35f433c..c6d9cfd 100644
--- a/library/qpeapplication.cpp
+++ b/library/qpeapplication.cpp
@@ -1,269 +1,268 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19*/ 19*/
20#define QTOPIA_INTERNAL_LANGLIST 20#define QTOPIA_INTERNAL_LANGLIST
21#include <stdlib.h> 21#include <stdlib.h>
22#include <unistd.h> 22#include <unistd.h>
23#ifndef Q_OS_MACX 23#ifndef Q_OS_MACX
24#include <linux/limits.h> // needed for some toolchains (PATH_MAX) 24#include <linux/limits.h> // needed for some toolchains (PATH_MAX)
25#endif 25#endif
26#include <qfile.h> 26#include <qfile.h>
27#include <qqueue.h> 27#include <qqueue.h>
28#ifdef Q_WS_QWS 28#ifdef Q_WS_QWS
29#ifndef QT_NO_COP 29#ifndef QT_NO_COP
30#if QT_VERSION <= 231 30#if QT_VERSION <= 231
31#define private public 31#define private public
32#define sendLocally processEvent 32#define sendLocally processEvent
33#include "qcopenvelope_qws.h" 33#include "qcopenvelope_qws.h"
34#undef private 34#undef private
35#else 35#else
36#include "qcopenvelope_qws.h" 36#include "qcopenvelope_qws.h"
37#endif 37#endif
38#endif 38#endif
39#include <qwindowsystem_qws.h> 39#include <qwindowsystem_qws.h>
40#endif 40#endif
41#include <qtextstream.h> 41#include <qtextstream.h>
42#include <qpalette.h> 42#include <qpalette.h>
43#include <qbuffer.h> 43#include <qbuffer.h>
44#include <qptrdict.h> 44#include <qptrdict.h>
45#include <qregexp.h> 45#include <qregexp.h>
46#include <qdir.h> 46#include <qdir.h>
47#include <qlabel.h> 47#include <qlabel.h>
48#include <qdialog.h> 48#include <qdialog.h>
49#include <qdragobject.h> 49#include <qdragobject.h>
50#include <qtextcodec.h> 50#include <qtextcodec.h>
51#include <qevent.h> 51#include <qevent.h>
52#include <qtooltip.h> 52#include <qtooltip.h>
53#include <qsignal.h> 53#include <qsignal.h>
54#include <qmainwindow.h> 54#include <qmainwindow.h>
55#include <qwidgetlist.h> 55#include <qwidgetlist.h>
56#include <qpixmapcache.h> 56#include <qpixmapcache.h>
57 57
58#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 58#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
59#define QTOPIA_INTERNAL_INITAPP 59#define QTOPIA_INTERNAL_INITAPP
60#include "qpeapplication.h" 60#include "qpeapplication.h"
61#include "qpestyle.h" 61#include "qpestyle.h"
62#include "styleinterface.h" 62#include "styleinterface.h"
63#if QT_VERSION >= 300 63#if QT_VERSION >= 300
64#include <qstylefactory.h> 64#include <qstylefactory.h>
65#else 65#else
66#include <qplatinumstyle.h> 66#include <qplatinumstyle.h>
67#include <qwindowsstyle.h> 67#include <qwindowsstyle.h>
68#include <qmotifstyle.h> 68#include <qmotifstyle.h>
69#include <qmotifplusstyle.h> 69#include <qmotifplusstyle.h>
70#include "lightstyle.h" 70#include "lightstyle.h"
71 71
72#include <qpe/qlibrary.h> 72#include <qpe/qlibrary.h>
73#endif 73#endif
74#include "global.h" 74#include "global.h"
75#include "resource.h" 75#include "resource.h"
76#if QT_VERSION <= 230 && defined(QT_NO_CODECS) 76#if QT_VERSION <= 230 && defined(QT_NO_CODECS)
77#include "qutfcodec.h" 77#include "qutfcodec.h"
78#endif 78#endif
79#include "config.h" 79#include "config.h"
80#include "network.h" 80#include "network.h"
81#ifdef QWS 81#ifdef QWS
82#include "fontmanager.h" 82#include "fontmanager.h"
83#include "fontdatabase.h" 83#include "fontdatabase.h"
84#endif 84#endif
85 85
86#include "alarmserver.h" 86#include "alarmserver.h"
87#include "applnk.h" 87#include "applnk.h"
88#include "qpemenubar.h" 88#include "qpemenubar.h"
89#include "textcodecinterface.h" 89#include "textcodecinterface.h"
90#include "imagecodecinterface.h" 90#include "imagecodecinterface.h"
91 91
92#include <unistd.h> 92#include <unistd.h>
93#include <sys/file.h> 93#include <sys/file.h>
94#include <sys/ioctl.h> 94#include <sys/ioctl.h>
95#ifndef QT_NO_SOUND 95#ifndef QT_NO_SOUND
96#include <sys/soundcard.h> 96#include <sys/soundcard.h>
97#endif 97#endif
98#include "qt_override_p.h" 98#include "qt_override_p.h"
99 99
100#include <qpe/rohfeedback.h> 100#include <backend/rohfeedback.h>
101 101
102 102
103static bool useBigPixmaps = 0; 103static bool useBigPixmaps = 0;
104 104
105
106class HackWidget : public QWidget 105class HackWidget : public QWidget
107{ 106{
108public: 107public:
109 bool needsOk() 108 bool needsOk()
110 { return (getWState() & WState_Reserved1 ); } 109 { return (getWState() & WState_Reserved1 ); }
111 110
112 QRect normalGeometry() 111 QRect normalGeometry()
113 { return topData()->normalGeometry; }; 112 { return topData()->normalGeometry; };
114}; 113};
115 114
116class QPEApplicationData 115class QPEApplicationData
117{ 116{
118public: 117public:
119 QPEApplicationData ( ) 118 QPEApplicationData ( ) :
120 : presstimer( 0 ), presswidget( 0 ), rightpressed( false ), kbgrabbed( false ), 119 presstimer( 0 ), presswidget( 0 ), rightpressed( false ), kbgrabbed( false ),
121 notbusysent( false ), preloaded( false ), forceshow( false ), nomaximize( false ), 120 notbusysent( false ), preloaded( false ), forceshow( false ), nomaximize( false ),
122 keep_running( true ), qcopQok( false ), 121 keep_running( true ), qcopQok( false ),
123 fontFamily( "Vera" ), fontSize( 10 ), smallIconSize( 14 ), 122 fontFamily( "Vera" ), fontSize( 10 ), smallIconSize( 14 ),
124 bigIconSize( 32 ), qpe_main_widget( 0 ) 123 bigIconSize( 32 ), qpe_main_widget( 0 )
125 { 124 {
126 Config cfg( "qpe" ); 125 Config cfg( "qpe" );
127 cfg.setGroup( "Appearance" ); 126 cfg.setGroup( "Appearance" );
128 useBigPixmaps = cfg.readBoolEntry( "useBigPixmaps", false ); 127 useBigPixmaps = cfg.readBoolEntry( "useBigPixmaps", false );
129 fontFamily = cfg.readEntry( "FontFamily", "Vera" ); 128 fontFamily = cfg.readEntry( "FontFamily", "Vera" );
130 fontSize = cfg.readNumEntry( "FontSize", 10 ); 129 fontSize = cfg.readNumEntry( "FontSize", 10 );
131 smallIconSize = cfg.readNumEntry( "SmallIconSize", 14 ); 130 smallIconSize = cfg.readNumEntry( "SmallIconSize", 14 );
132 bigIconSize = cfg.readNumEntry( "BigIconSize", 32 ); 131 bigIconSize = cfg.readNumEntry( "BigIconSize", 32 );
133#ifdef OPIE_ROHFEEDBACK 132#ifdef OPIE_WITHROHFEEDBACK
134 RoH = 0; 133 RoH = 0;
135#endif 134#endif
136 } 135 }
137 136
138 int presstimer; 137 int presstimer;
139 QWidget* presswidget; 138 QWidget* presswidget;
140 QPoint presspos; 139 QPoint presspos;
141#ifdef OPIE_ROHFEEDBACK 140#ifdef OPIE_WITHROHFEEDBACK
142 Opie::Internal::RoHFeedback *RoH; 141 Opie::Internal::RoHFeedback *RoH;
143#endif 142#endif
144 143
145 bool rightpressed : 1; 144 bool rightpressed : 1;
146 bool kbgrabbed : 1; 145 bool kbgrabbed : 1;
147 bool notbusysent : 1; 146 bool notbusysent : 1;
148 bool preloaded : 1; 147 bool preloaded : 1;
149 bool forceshow : 1; 148 bool forceshow : 1;
150 bool nomaximize : 1; 149 bool nomaximize : 1;
151 bool keep_running : 1; 150 bool keep_running : 1;
152 bool qcopQok : 1; 151 bool qcopQok : 1;
153 152
154 QCString fontFamily; 153 QCString fontFamily;
155 int fontSize; 154 int fontSize;
156 int smallIconSize; 155 int smallIconSize;
157 int bigIconSize; 156 int bigIconSize;
158 157
159 QStringList langs; 158 QStringList langs;
160 QString appName; 159 QString appName;
161 struct QCopRec 160 struct QCopRec
162 { 161 {
163 QCopRec( const QCString &ch, const QCString &msg, 162 QCopRec( const QCString &ch, const QCString &msg,
164 const QByteArray &d ) : 163 const QByteArray &d ) :
165 channel( ch ), message( msg ), data( d ) 164 channel( ch ), message( msg ), data( d )
166 { } 165 { }
167 166
168 QCString channel; 167 QCString channel;
169 QCString message; 168 QCString message;
170 QByteArray data; 169 QByteArray data;
171 }; 170 };
172 QWidget* qpe_main_widget; 171 QWidget* qpe_main_widget;
173 QGuardedPtr<QWidget> lastraised; 172 QGuardedPtr<QWidget> lastraised;
174 QQueue<QCopRec> qcopq; 173 QQueue<QCopRec> qcopq;
175 QString styleName; 174 QString styleName;
176 QString decorationName; 175 QString decorationName;
177 176
178 void enqueueQCop( const QCString &ch, const QCString &msg, 177 void enqueueQCop( const QCString &ch, const QCString &msg,
179 const QByteArray &data ) 178 const QByteArray &data )
180 { 179 {
181 qcopq.enqueue( new QCopRec( ch, msg, data ) ); 180 qcopq.enqueue( new QCopRec( ch, msg, data ) );
182 } 181 }
183 void sendQCopQ() 182 void sendQCopQ()
184 { 183 {
185 if (!qcopQok ) 184 if (!qcopQok )
186 return; 185 return;
187 186
188 QCopRec * r; 187 QCopRec * r;
189 188
190 while((r=qcopq.dequeue())) { 189 while((r=qcopq.dequeue())) {
191 // remove from queue before sending... 190 // remove from queue before sending...
192 // event loop can come around again before getting 191 // event loop can come around again before getting
193 // back from sendLocally 192 // back from sendLocally
194#ifndef QT_NO_COP 193#ifndef QT_NO_COP
195 QCopChannel::sendLocally( r->channel, r->message, r->data ); 194 QCopChannel::sendLocally( r->channel, r->message, r->data );
196#endif 195#endif
197 196
198 delete r; 197 delete r;
199 } 198 }
200 } 199 }
201 200
202 static void show_mx(QWidget* mw, bool nomaximize, QString &strName) 201 static void show_mx(QWidget* mw, bool nomaximize, QString &strName)
203 { 202 {
204 if ( mw->inherits("QMainWindow") || mw->isA("QMainWindow") ) 203 if ( mw->inherits("QMainWindow") || mw->isA("QMainWindow") )
205 { 204 {
206 ( ( QMainWindow* ) mw )->setUsesBigPixmaps( useBigPixmaps ); 205 ( ( QMainWindow* ) mw )->setUsesBigPixmaps( useBigPixmaps );
207 } 206 }
208 QPoint p; 207 QPoint p;
209 QSize s; 208 QSize s;
210 bool max; 209 bool max;
211 if ( mw->isVisible() ) { 210 if ( mw->isVisible() ) {
212 if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { 211 if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) {
213 mw->resize(s); 212 mw->resize(s);
214 mw->move(p); 213 mw->move(p);
215 } 214 }
216 mw->raise(); 215 mw->raise();
217 } else { 216 } else {
218 217
219 if ( mw->layout() && mw->inherits("QDialog") ) { 218 if ( mw->layout() && mw->inherits("QDialog") ) {
220 if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { 219 if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) {
221 mw->resize(s); 220 mw->resize(s);
222 mw->move(p); 221 mw->move(p);
223 222
224 if ( max && !nomaximize ) { 223 if ( max && !nomaximize ) {
225 mw->showMaximized(); 224 mw->showMaximized();
226 } else { 225 } else {
227 mw->show(); 226 mw->show();
228 } 227 }
229 } else { 228 } else {
230 qpe_show_dialog((QDialog*)mw,nomaximize); 229 qpe_show_dialog((QDialog*)mw,nomaximize);
231 } 230 }
232 } else { 231 } else {
233 if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { 232 if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) {
234 mw->resize(s); 233 mw->resize(s);
235 mw->move(p); 234 mw->move(p);
236 } else { //no stored rectangle, make an estimation 235 } else { //no stored rectangle, make an estimation
237 int x = (qApp->desktop()->width()-mw->frameGeometry().width())/2; 236 int x = (qApp->desktop()->width()-mw->frameGeometry().width())/2;
238 int y = (qApp->desktop()->height()-mw->frameGeometry().height())/2; 237 int y = (qApp->desktop()->height()-mw->frameGeometry().height())/2;
239 mw->move( QMAX(x,0), QMAX(y,0) ); 238 mw->move( QMAX(x,0), QMAX(y,0) );
240#ifdef Q_WS_QWS 239#ifdef Q_WS_QWS
241 if ( !nomaximize ) 240 if ( !nomaximize )
242 mw->showMaximized(); 241 mw->showMaximized();
243#endif 242#endif
244 } 243 }
245 if ( max && !nomaximize ) 244 if ( max && !nomaximize )
246 mw->showMaximized(); 245 mw->showMaximized();
247 else 246 else
248 mw->show(); 247 mw->show();
249 } 248 }
250 } 249 }
251 } 250 }
252 251
253static void qpe_show_dialog( QDialog* d, bool nomax ) 252static void qpe_show_dialog( QDialog* d, bool nomax )
254{ 253{
255 QSize sh = d->sizeHint(); 254 QSize sh = d->sizeHint();
256 int w = QMAX(sh.width(),d->width()); 255 int w = QMAX(sh.width(),d->width());
257 int h = QMAX(sh.height(),d->height()); 256 int h = QMAX(sh.height(),d->height());
258 257
259 if ( d->parentWidget() && !d->parentWidget()->topLevelWidget()->isMaximized() ) 258 if ( d->parentWidget() && !d->parentWidget()->topLevelWidget()->isMaximized() )
260 nomax = TRUE; 259 nomax = TRUE;
261 260
262#ifndef Q_WS_QWS 261#ifndef Q_WS_QWS
263 QSize s(qApp->desktop()->width(), qApp->desktop()->height() ); 262 QSize s(qApp->desktop()->width(), qApp->desktop()->height() );
264#else 263#else
265 QSize s(qt_maxWindowRect.width(), qt_maxWindowRect.height() ); 264 QSize s(qt_maxWindowRect.width(), qt_maxWindowRect.height() );
266#endif 265#endif
267 266
268 int maxX = s.width() - (d->frameGeometry().width() - d->geometry().width()); 267 int maxX = s.width() - (d->frameGeometry().width() - d->geometry().width());
269 int maxY = s.height() - (d->frameGeometry().height() - d->geometry().height()); 268 int maxY = s.height() - (d->frameGeometry().height() - d->geometry().height());
@@ -377,256 +376,257 @@ static void qpe_show_dialog( QDialog* d, bool nomax )
377 return TRUE; 376 return TRUE;
378 } 377 }
379 378
380 static void store_widget_rect(QWidget *w, QString &app) 379 static void store_widget_rect(QWidget *w, QString &app)
381 { 380 {
382 // 350 is the trigger in qwsdefaultdecoration for providing a resize button 381 // 350 is the trigger in qwsdefaultdecoration for providing a resize button
383 if ( qApp->desktop()->width() <= 350 ) 382 if ( qApp->desktop()->width() <= 350 )
384 return; 383 return;
385 // we use these to map the offset of geometry and pos. ( we can only use normalGeometry to 384 // we use these to map the offset of geometry and pos. ( we can only use normalGeometry to
386 // get the non-maximized version, so we have to do it the hard way ) 385 // get the non-maximized version, so we have to do it the hard way )
387 int offsetX = w->x() - w->geometry().left(); 386 int offsetX = w->x() - w->geometry().left();
388 int offsetY = w->y() - w->geometry().top(); 387 int offsetY = w->y() - w->geometry().top();
389 388
390 QRect r; 389 QRect r;
391 if ( w->isMaximized() ) 390 if ( w->isMaximized() )
392 r = ( (HackWidget *) w)->normalGeometry(); 391 r = ( (HackWidget *) w)->normalGeometry();
393 else 392 else
394 r = w->geometry(); 393 r = w->geometry();
395 394
396 // Stores the window placement as pos(), size() (due to the offset mapping) 395 // Stores the window placement as pos(), size() (due to the offset mapping)
397 Config cfg( "qpe" ); 396 Config cfg( "qpe" );
398 cfg.setGroup("ApplicationPositions"); 397 cfg.setGroup("ApplicationPositions");
399 QString s; 398 QString s;
400 s.sprintf("%d,%d,%d,%d,%d", r.left() + offsetX, r.top() + offsetY, r.width(), r.height(), w->isMaximized() ); 399 s.sprintf("%d,%d,%d,%d,%d", r.left() + offsetX, r.top() + offsetY, r.width(), r.height(), w->isMaximized() );
401 cfg.writeEntry( app, s ); 400 cfg.writeEntry( app, s );
402 } 401 }
403 402
404 static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) 403 static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ )
405 { 404 {
406 /* 405 /*
407 // This works but disable it for now until it is safe to apply 406 // This works but disable it for now until it is safe to apply
408 // What is does is scan the .desktop files of all the apps for 407 // What is does is scan the .desktop files of all the apps for
409 // the applnk that has the corresponding argv[0] as this program 408 // the applnk that has the corresponding argv[0] as this program
410 // then it uses the name stored in the .desktop file as the caption 409 // then it uses the name stored in the .desktop file as the caption
411 // for the main widget. This saves duplicating translations for 410 // for the main widget. This saves duplicating translations for
412 // the app name in the program and in the .desktop files. 411 // the app name in the program and in the .desktop files.
413 412
414 AppLnkSet apps( appsPath ); 413 AppLnkSet apps( appsPath );
415 414
416 QList<AppLnk> appsList = apps.children(); 415 QList<AppLnk> appsList = apps.children();
417 for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) { 416 for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) {
418 if ( (*it)->exec() == appName ) { 417 if ( (*it)->exec() == appName ) {
419 mw->setCaption( (*it)->name() ); 418 mw->setCaption( (*it)->name() );
420 return TRUE; 419 return TRUE;
421 } 420 }
422 } 421 }
423 */ 422 */
424 return FALSE; 423 return FALSE;
425 } 424 }
426 425
427 426
428 void show(QWidget* mw, bool nomax) 427 void show(QWidget* mw, bool nomax)
429 { 428 {
430 setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" ); 429 setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" );
431 nomaximize = nomax; 430 nomaximize = nomax;
432 qpe_main_widget = mw; 431 qpe_main_widget = mw;
433 qcopQok = TRUE; 432 qcopQok = TRUE;
434#ifndef QT_NO_COP 433#ifndef QT_NO_COP
435 434
436 sendQCopQ(); 435 sendQCopQ();
437#endif 436#endif
438 437
439 if ( preloaded ) { 438 if ( preloaded ) {
440 if (forceshow) 439 if (forceshow)
441 show_mx(mw, nomax, appName); 440 show_mx(mw, nomax, appName);
442 } 441 }
443 else if ( keep_running ) { 442 else if ( keep_running ) {
444 show_mx(mw, nomax, appName); 443 show_mx(mw, nomax, appName);
445 } 444 }
446 } 445 }
447 446
448 void loadTextCodecs() 447 void loadTextCodecs()
449 { 448 {
450 QString path = QPEApplication::qpeDir() + "/plugins/textcodecs"; 449 QString path = QPEApplication::qpeDir() + "/plugins/textcodecs";
451#ifdef Q_OS_MACX 450#ifdef Q_OS_MACX
452 QDir dir( path, "lib*.dylib" ); 451 QDir dir( path, "lib*.dylib" );
453#else 452#else
454 QDir dir( path, "lib*.so" ); 453 QDir dir( path, "lib*.so" );
455#endif 454#endif
456 QStringList list; 455 QStringList list;
457 if ( dir. exists ( )) 456 if ( dir. exists ( ))
458 list = dir.entryList(); 457 list = dir.entryList();
459 QStringList::Iterator it; 458 QStringList::Iterator it;
460 for ( it = list.begin(); it != list.end(); ++it ) { 459 for ( it = list.begin(); it != list.end(); ++it ) {
461 TextCodecInterface *iface = 0; 460 TextCodecInterface *iface = 0;
462 QLibrary *lib = new QLibrary( path + "/" + *it ); 461 QLibrary *lib = new QLibrary( path + "/" + *it );
463 if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { 462 if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) {
464 QValueList<int> mibs = iface->mibEnums(); 463 QValueList<int> mibs = iface->mibEnums();
465 for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) { 464 for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) {
466 (void)iface->createForMib(*i); 465 (void)iface->createForMib(*i);
467 // ### it exists now; need to remember if we can delete it 466 // ### it exists now; need to remember if we can delete it
468 } 467 }
469 } 468 }
470 else { 469 else {
471 lib->unload(); 470 lib->unload();
472 delete lib; 471 delete lib;
473 } 472 }
474 } 473 }
475 } 474 }
476 475
477 void loadImageCodecs() 476 void loadImageCodecs()
478 { 477 {
479 QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs"; 478 QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs";
480#ifdef Q_OS_MACX 479#ifdef Q_OS_MACX
481 QDir dir( path, "lib*.dylib" ); 480 QDir dir( path, "lib*.dylib" );
482#else 481#else
483 QDir dir( path, "lib*.so" ); 482 QDir dir( path, "lib*.so" );
484#endif 483#endif
485 QStringList list; 484 QStringList list;
486 if ( dir. exists ( )) 485 if ( dir. exists ( ))
487 list = dir.entryList(); 486 list = dir.entryList();
488 QStringList::Iterator it; 487 QStringList::Iterator it;
489 for ( it = list.begin(); it != list.end(); ++it ) { 488 for ( it = list.begin(); it != list.end(); ++it ) {
490 ImageCodecInterface *iface = 0; 489 ImageCodecInterface *iface = 0;
491 QLibrary *lib = new QLibrary( path + "/" + *it ); 490 QLibrary *lib = new QLibrary( path + "/" + *it );
492 if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { 491 if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) {
493 QStringList formats = iface->keys(); 492 QStringList formats = iface->keys();
494 for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) { 493 for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) {
495 (void)iface->installIOHandler(*i); 494 (void)iface->installIOHandler(*i);
496 // ### it exists now; need to remember if we can delete it 495 // ### it exists now; need to remember if we can delete it
497 } 496 }
498 } 497 }
499 else { 498 else {
500 lib->unload(); 499 lib->unload();
501 delete lib; 500 delete lib;
502 } 501 }
503 } 502 }
504 } 503 }
504
505}; 505};
506 506
507class ResourceMimeFactory : public QMimeSourceFactory 507class ResourceMimeFactory : public QMimeSourceFactory
508{ 508{
509public: 509public:
510 ResourceMimeFactory() : resImage( 0 ) 510 ResourceMimeFactory() : resImage( 0 )
511 { 511 {
512 setFilePath( Global::helpPath() ); 512 setFilePath( Global::helpPath() );
513 setExtensionType( "html", "text/html;charset=UTF-8" ); 513 setExtensionType( "html", "text/html;charset=UTF-8" );
514 } 514 }
515 ~ResourceMimeFactory() { 515 ~ResourceMimeFactory() {
516 delete resImage; 516 delete resImage;
517 } 517 }
518 518
519 const QMimeSource* data( const QString& abs_name ) const 519 const QMimeSource* data( const QString& abs_name ) const
520 { 520 {
521 const QMimeSource * r = QMimeSourceFactory::data( abs_name ); 521 const QMimeSource * r = QMimeSourceFactory::data( abs_name );
522 if ( !r ) { 522 if ( !r ) {
523 int sl = abs_name.length(); 523 int sl = abs_name.length();
524 do { 524 do {
525 sl = abs_name.findRev( '/', sl - 1 ); 525 sl = abs_name.findRev( '/', sl - 1 );
526 QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name; 526 QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name;
527 int dot = name.findRev( '.' ); 527 int dot = name.findRev( '.' );
528 if ( dot >= 0 ) 528 if ( dot >= 0 )
529 name = name.left( dot ); 529 name = name.left( dot );
530 QImage img = Resource::loadImage( name ); 530 QImage img = Resource::loadImage( name );
531 if ( !img.isNull() ) { 531 if ( !img.isNull() ) {
532 delete resImage; 532 delete resImage;
533 resImage = new QImageDrag( img ); 533 resImage = new QImageDrag( img );
534 r = resImage; 534 r = resImage;
535 } 535 }
536 } 536 }
537 while ( !r && sl > 0 ); 537 while ( !r && sl > 0 );
538 } 538 }
539 return r; 539 return r;
540 } 540 }
541private: 541private:
542 mutable QImageDrag *resImage; 542 mutable QImageDrag *resImage;
543}; 543};
544 544
545static int& hack(int& i) 545static int& hack(int& i)
546{ 546{
547#if QT_VERSION <= 230 && defined(QT_NO_CODECS) 547#if QT_VERSION <= 230 && defined(QT_NO_CODECS)
548 // These should be created, but aren't in Qt 2.3.0 548 // These should be created, but aren't in Qt 2.3.0
549 (void)new QUtf8Codec; 549 (void)new QUtf8Codec;
550 (void)new QUtf16Codec; 550 (void)new QUtf16Codec;
551#endif 551#endif
552 return i; 552 return i;
553} 553}
554 554
555static int muted = 0; 555static int muted = 0;
556static int micMuted = 0; 556static int micMuted = 0;
557 557
558static void setVolume( int t = 0, int percent = -1 ) 558static void setVolume( int t = 0, int percent = -1 )
559{ 559{
560 switch ( t ) { 560 switch ( t ) {
561 case 0: { 561 case 0: {
562 Config cfg( "qpe" ); 562 Config cfg( "qpe" );
563 cfg.setGroup( "Volume" ); 563 cfg.setGroup( "Volume" );
564 if ( percent < 0 ) 564 if ( percent < 0 )
565 percent = cfg.readNumEntry( "VolumePercent", 50 ); 565 percent = cfg.readNumEntry( "VolumePercent", 50 );
566#ifndef QT_NO_SOUND 566#ifndef QT_NO_SOUND
567 int fd = 0; 567 int fd = 0;
568 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { 568 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) {
569 int vol = muted ? 0 : percent; 569 int vol = muted ? 0 : percent;
570 // set both channels to same volume 570 // set both channels to same volume
571 vol |= vol << 8; 571 vol |= vol << 8;
572 ioctl( fd, MIXER_WRITE( SOUND_MIXER_VOLUME ), &vol ); 572 ioctl( fd, MIXER_WRITE( SOUND_MIXER_VOLUME ), &vol );
573 ::close( fd ); 573 ::close( fd );
574 } 574 }
575#endif 575#endif
576 } 576 }
577 break; 577 break;
578 } 578 }
579} 579}
580 580
581static void setMic( int t = 0, int percent = -1 ) 581static void setMic( int t = 0, int percent = -1 )
582{ 582{
583 switch ( t ) { 583 switch ( t ) {
584 case 0: { 584 case 0: {
585 Config cfg( "qpe" ); 585 Config cfg( "qpe" );
586 cfg.setGroup( "Volume" ); 586 cfg.setGroup( "Volume" );
587 if ( percent < 0 ) 587 if ( percent < 0 )
588 percent = cfg.readNumEntry( "Mic", 50 ); 588 percent = cfg.readNumEntry( "Mic", 50 );
589 589
590#ifndef QT_NO_SOUND 590#ifndef QT_NO_SOUND
591 int fd = 0; 591 int fd = 0;
592 int mic = micMuted ? 0 : percent; 592 int mic = micMuted ? 0 : percent;
593 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { 593 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) {
594 ioctl( fd, MIXER_WRITE( SOUND_MIXER_MIC ), &mic ); 594 ioctl( fd, MIXER_WRITE( SOUND_MIXER_MIC ), &mic );
595 ::close( fd ); 595 ::close( fd );
596 } 596 }
597#endif 597#endif
598 } 598 }
599 break; 599 break;
600 } 600 }
601} 601}
602 602
603 603
604static void setBass( int t = 0, int percent = -1 ) 604static void setBass( int t = 0, int percent = -1 )
605{ 605{
606 switch ( t ) { 606 switch ( t ) {
607 case 0: { 607 case 0: {
608 Config cfg( "qpe" ); 608 Config cfg( "qpe" );
609 cfg.setGroup( "Volume" ); 609 cfg.setGroup( "Volume" );
610 if ( percent < 0 ) 610 if ( percent < 0 )
611 percent = cfg.readNumEntry( "BassPercent", 50 ); 611 percent = cfg.readNumEntry( "BassPercent", 50 );
612 612
613#ifndef QT_NO_SOUND 613#ifndef QT_NO_SOUND
614 int fd = 0; 614 int fd = 0;
615 int bass = percent; 615 int bass = percent;
616 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { 616 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) {
617 ioctl( fd, MIXER_WRITE( SOUND_MIXER_BASS ), &bass ); 617 ioctl( fd, MIXER_WRITE( SOUND_MIXER_BASS ), &bass );
618 ::close( fd ); 618 ::close( fd );
619 } 619 }
620#endif 620#endif
621 } 621 }
622 break; 622 break;
623 } 623 }
624} 624}
625 625
626 626
627static void setTreble( int t = 0, int percent = -1 ) 627static void setTreble( int t = 0, int percent = -1 )
628{ 628{
629 switch ( t ) { 629 switch ( t ) {
630 case 0: { 630 case 0: {
631 Config cfg( "qpe" ); 631 Config cfg( "qpe" );
632 cfg.setGroup( "Volume" ); 632 cfg.setGroup( "Volume" );
@@ -1090,258 +1090,260 @@ bool QPEApplication::qwsEventFilter( QWSEvent * e )
1090 if ( e->type == QWSEvent::Key ) { 1090 if ( e->type == QWSEvent::Key ) {
1091 QWSKeyEvent *ke = ( QWSKeyEvent * ) e; 1091 QWSKeyEvent *ke = ( QWSKeyEvent * ) e;
1092 if ( ke->simpleData.keycode == Qt::Key_F33 ) { 1092 if ( ke->simpleData.keycode == Qt::Key_F33 ) {
1093 // Use special "OK" key to press "OK" on top level widgets 1093 // Use special "OK" key to press "OK" on top level widgets
1094 QWidget * active = activeWindow(); 1094 QWidget * active = activeWindow();
1095 QWidget *popup = 0; 1095 QWidget *popup = 0;
1096 if ( active && active->isPopup() ) { 1096 if ( active && active->isPopup() ) {
1097 popup = active; 1097 popup = active;
1098 active = active->parentWidget(); 1098 active = active->parentWidget();
1099 } 1099 }
1100 if ( active && ( int ) active->winId() == ke->simpleData.window && 1100 if ( active && ( int ) active->winId() == ke->simpleData.window &&
1101 !active->testWFlags( WStyle_Customize | WType_Popup | WType_Desktop ) ) { 1101 !active->testWFlags( WStyle_Customize | WType_Popup | WType_Desktop ) ) {
1102 if ( ke->simpleData.is_press ) { 1102 if ( ke->simpleData.is_press ) {
1103 if ( popup ) 1103 if ( popup )
1104 popup->close(); 1104 popup->close();
1105 if ( active->inherits( "QDialog" ) ) { 1105 if ( active->inherits( "QDialog" ) ) {
1106 HackDialog * d = ( HackDialog * ) active; 1106 HackDialog * d = ( HackDialog * ) active;
1107 d->acceptIt(); 1107 d->acceptIt();
1108 return TRUE; 1108 return TRUE;
1109 } 1109 }
1110 else if ( ( ( HackWidget * ) active ) ->needsOk() ) { 1110 else if ( ( ( HackWidget * ) active ) ->needsOk() ) {
1111 QSignal s; 1111 QSignal s;
1112 s.connect( active, SLOT( accept() ) ); 1112 s.connect( active, SLOT( accept() ) );
1113 s.activate(); 1113 s.activate();
1114 } 1114 }
1115 else { 1115 else {
1116 // do the same as with the select key: Map to the default action of the widget: 1116 // do the same as with the select key: Map to the default action of the widget:
1117 mapToDefaultAction( ke, Qt::Key_Return ); 1117 mapToDefaultAction( ke, Qt::Key_Return );
1118 } 1118 }
1119 } 1119 }
1120 } 1120 }
1121 } 1121 }
1122 else if ( ke->simpleData.keycode == Qt::Key_F30 ) { 1122 else if ( ke->simpleData.keycode == Qt::Key_F30 ) {
1123 // Use special "select" key to do whatever default action a widget has 1123 // Use special "select" key to do whatever default action a widget has
1124 mapToDefaultAction( ke, Qt::Key_Space ); 1124 mapToDefaultAction( ke, Qt::Key_Space );
1125 } 1125 }
1126 else if ( ke->simpleData.keycode == Qt::Key_Escape && 1126 else if ( ke->simpleData.keycode == Qt::Key_Escape &&
1127 ke->simpleData.is_press ) { 1127 ke->simpleData.is_press ) {
1128 // Escape key closes app if focus on toplevel 1128 // Escape key closes app if focus on toplevel
1129 QWidget * active = activeWindow(); 1129 QWidget * active = activeWindow();
1130 if ( active && active->testWFlags( WType_TopLevel ) && 1130 if ( active && active->testWFlags( WType_TopLevel ) &&
1131 ( int ) active->winId() == ke->simpleData.window && 1131 ( int ) active->winId() == ke->simpleData.window &&
1132 !active->testWFlags( WStyle_Dialog | WStyle_Customize | WType_Popup | WType_Desktop ) ) { 1132 !active->testWFlags( WStyle_Dialog | WStyle_Customize | WType_Popup | WType_Desktop ) ) {
1133 if ( active->inherits( "QDialog" ) ) { 1133 if ( active->inherits( "QDialog" ) ) {
1134 HackDialog * d = ( HackDialog * ) active; 1134 HackDialog * d = ( HackDialog * ) active;
1135 d->rejectIt(); 1135 d->rejectIt();
1136 return TRUE; 1136 return TRUE;
1137 } else /*if ( strcmp( argv() [ 0 ], "embeddedkonsole" ) != 0 )*/ { 1137 } else /*if ( strcmp( argv() [ 0 ], "embeddedkonsole" ) != 0 )*/ {
1138 active->close(); 1138 active->close();
1139 } 1139 }
1140 } 1140 }
1141 1141
1142 } 1142 }
1143 else if ( ke->simpleData.keycode >= Qt::Key_F1 && ke->simpleData.keycode <= Qt::Key_F29 ) { 1143 else if ( ke->simpleData.keycode >= Qt::Key_F1 && ke->simpleData.keycode <= Qt::Key_F29 ) {
1144 // this should be if ( ODevice::inst ( )-> buttonForKeycode ( ... )) 1144 // this should be if ( ODevice::inst ( )-> buttonForKeycode ( ... ))
1145 // but we cannot access libopie function within libqpe :( 1145 // but we cannot access libopie function within libqpe :(
1146 1146
1147 QWidget * active = activeWindow ( ); 1147 QWidget * active = activeWindow ( );
1148 if ( active && ((int) active-> winId ( ) == ke-> simpleData.window )) { 1148 if ( active && ((int) active-> winId ( ) == ke-> simpleData.window )) {
1149 if ( d-> kbgrabbed ) { // we grabbed the keyboard 1149 if ( d-> kbgrabbed ) { // we grabbed the keyboard
1150 QChar ch ( ke-> simpleData.unicode ); 1150 QChar ch ( ke-> simpleData.unicode );
1151 QKeyEvent qke ( ke-> simpleData. is_press ? QEvent::KeyPress : QEvent::KeyRelease, 1151 QKeyEvent qke ( ke-> simpleData. is_press ? QEvent::KeyPress : QEvent::KeyRelease,
1152 ke-> simpleData.keycode, 1152 ke-> simpleData.keycode,
1153 ch. latin1 ( ), 1153 ch. latin1 ( ),
1154 ke-> simpleData.modifiers, 1154 ke-> simpleData.modifiers,
1155 QString ( ch ), 1155 QString ( ch ),
1156 ke-> simpleData.is_auto_repeat, 1 ); 1156 ke-> simpleData.is_auto_repeat, 1 );
1157 1157
1158 QObject *which = QWidget::keyboardGrabber ( ); 1158 QObject *which = QWidget::keyboardGrabber ( );
1159 if ( !which ) 1159 if ( !which )
1160 which = QApplication::focusWidget ( ); 1160 which = QApplication::focusWidget ( );
1161 if ( !which ) 1161 if ( !which )
1162 which = QApplication::activeWindow ( ); 1162 which = QApplication::activeWindow ( );
1163 if ( !which ) 1163 if ( !which )
1164 which = qApp; 1164 which = qApp;
1165 1165
1166 QApplication::sendEvent ( which, &qke ); 1166 QApplication::sendEvent ( which, &qke );
1167 } 1167 }
1168 else { // we didn't grab the keyboard, so send the event to the launcher 1168 else { // we didn't grab the keyboard, so send the event to the launcher
1169 QCopEnvelope e ( "QPE/Launcher", "deviceButton(int,int,int)" ); 1169 QCopEnvelope e ( "QPE/Launcher", "deviceButton(int,int,int)" );
1170 e << int( ke-> simpleData.keycode ) << int( ke-> simpleData. is_press ) << int( ke-> simpleData.is_auto_repeat ); 1170 e << int( ke-> simpleData.keycode ) << int( ke-> simpleData. is_press ) << int( ke-> simpleData.is_auto_repeat );
1171 } 1171 }
1172 } 1172 }
1173 return true; 1173 return true;
1174 } 1174 }
1175 } 1175 }
1176 if ( e->type == QWSEvent::Focus ) { 1176 if ( e->type == QWSEvent::Focus ) {
1177 QWSFocusEvent * fe = ( QWSFocusEvent* ) e; 1177 QWSFocusEvent * fe = ( QWSFocusEvent* ) e;
1178 if ( !fe->simpleData.get_focus ) { 1178 if ( !fe->simpleData.get_focus ) {
1179 QWidget * active = activeWindow(); 1179 QWidget * active = activeWindow();
1180 while ( active && active->isPopup() ) { 1180 while ( active && active->isPopup() ) {
1181 active->close(); 1181 active->close();
1182 active = activeWindow(); 1182 active = activeWindow();
1183 } 1183 }
1184 } 1184 }
1185 else { 1185 else {
1186 // make sure our modal widget is ALWAYS on top 1186 // make sure our modal widget is ALWAYS on top
1187 QWidget *topm = activeModalWidget(); 1187 QWidget *topm = activeModalWidget();
1188 if ( topm && static_cast<int>( topm->winId() ) != fe->simpleData.window) { 1188 if ( topm && static_cast<int>( topm->winId() ) != fe->simpleData.window) {
1189 topm->raise(); 1189 topm->raise();
1190 } 1190 }
1191 } 1191 }
1192 if ( fe->simpleData.get_focus && inputMethodDict ) { 1192 if ( fe->simpleData.get_focus && inputMethodDict ) {
1193 InputMethodHint m = inputMethodHint( QWidget::find( e->window() ) ); 1193 InputMethodHint m = inputMethodHint( QWidget::find( e->window() ) );
1194 if ( m == AlwaysOff ) 1194 if ( m == AlwaysOff )
1195 Global::hideInputMethod(); 1195 Global::hideInputMethod();
1196 if ( m == AlwaysOn ) 1196 if ( m == AlwaysOn )
1197 Global::showInputMethod(); 1197 Global::showInputMethod();
1198 } 1198 }
1199 } 1199 }
1200 1200
1201 1201
1202 return QApplication::qwsEventFilter( e ); 1202 return QApplication::qwsEventFilter( e );
1203} 1203}
1204#endif 1204#endif
1205 1205
1206/*! 1206/*!
1207 Destroys the QPEApplication. 1207 Destroys the QPEApplication.
1208*/ 1208*/
1209QPEApplication::~QPEApplication() 1209QPEApplication::~QPEApplication()
1210{ 1210{
1211 ungrabKeyboard(); 1211 ungrabKeyboard();
1212#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 1212#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
1213 // Need to delete QCopChannels early, since the display will 1213 // Need to delete QCopChannels early, since the display will
1214 // be gone by the time we get to ~QObject(). 1214 // be gone by the time we get to ~QObject().
1215 delete sysChannel; 1215 delete sysChannel;
1216 delete pidChannel; 1216 delete pidChannel;
1217#endif 1217#endif
1218#ifdef OPIE_ROHFEEDBACK 1218
1219 delete d->RoH; 1219#ifdef OPIE_WITHROHFEEDBACK
1220 if( d->RoH )
1221 delete d->RoH;
1220#endif 1222#endif
1221 delete d; 1223 delete d;
1222} 1224}
1223 1225
1224/*! 1226/*!
1225 Returns <tt>$OPIEDIR/</tt>. 1227 Returns <tt>$OPIEDIR/</tt>.
1226*/ 1228*/
1227QString QPEApplication::qpeDir() 1229QString QPEApplication::qpeDir()
1228{ 1230{
1229 const char * base = getenv( "OPIEDIR" ); 1231 const char * base = getenv( "OPIEDIR" );
1230 if ( base ) 1232 if ( base )
1231 return QString( base ) + "/"; 1233 return QString( base ) + "/";
1232 1234
1233 return QString( "../" ); 1235 return QString( "../" );
1234} 1236}
1235 1237
1236/*! 1238/*!
1237 Returns the user's current Document directory. There is a trailing "/". 1239 Returns the user's current Document directory. There is a trailing "/".
1238 .. well, it does now,, and there's no trailing '/' 1240 .. well, it does now,, and there's no trailing '/'
1239*/ 1241*/
1240QString QPEApplication::documentDir() 1242QString QPEApplication::documentDir()
1241{ 1243{
1242 const char* base = getenv( "HOME"); 1244 const char* base = getenv( "HOME");
1243 if ( base ) 1245 if ( base )
1244 return QString( base ) + "/Documents"; 1246 return QString( base ) + "/Documents";
1245 1247
1246 return QString( "../Documents" ); 1248 return QString( "../Documents" );
1247} 1249}
1248 1250
1249static int deforient = -1; 1251static int deforient = -1;
1250 1252
1251/*! 1253/*!
1252 \internal 1254 \internal
1253*/ 1255*/
1254int QPEApplication::defaultRotation() 1256int QPEApplication::defaultRotation()
1255{ 1257{
1256 if ( deforient < 0 ) { 1258 if ( deforient < 0 ) {
1257 QString d = getenv( "QWS_DISPLAY" ); 1259 QString d = getenv( "QWS_DISPLAY" );
1258 if ( d.contains( "Rot90" ) ) { 1260 if ( d.contains( "Rot90" ) ) {
1259 deforient = 90; 1261 deforient = 90;
1260 } 1262 }
1261 else if ( d.contains( "Rot180" ) ) { 1263 else if ( d.contains( "Rot180" ) ) {
1262 deforient = 180; 1264 deforient = 180;
1263 } 1265 }
1264 else if ( d.contains( "Rot270" ) ) { 1266 else if ( d.contains( "Rot270" ) ) {
1265 deforient = 270; 1267 deforient = 270;
1266 } 1268 }
1267 else { 1269 else {
1268 deforient = 0; 1270 deforient = 0;
1269 } 1271 }
1270 } 1272 }
1271 return deforient; 1273 return deforient;
1272} 1274}
1273 1275
1274/*! 1276/*!
1275 \internal 1277 \internal
1276*/ 1278*/
1277void QPEApplication::setDefaultRotation( int r ) 1279void QPEApplication::setDefaultRotation( int r )
1278{ 1280{
1279 if ( qApp->type() == GuiServer ) { 1281 if ( qApp->type() == GuiServer ) {
1280 deforient = r; 1282 deforient = r;
1281 setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 ); 1283 setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 );
1282 Config config("qpe"); 1284 Config config("qpe");
1283 config.setGroup( "Rotation" ); 1285 config.setGroup( "Rotation" );
1284 config.writeEntry( "Rot", r ); 1286 config.writeEntry( "Rot", r );
1285 } 1287 }
1286 else { 1288 else {
1287#ifndef QT_NO_COP 1289#ifndef QT_NO_COP
1288 { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" ); 1290 { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" );
1289 e << r; 1291 e << r;
1290 } 1292 }
1291#endif 1293#endif
1292 1294
1293 } 1295 }
1294} 1296}
1295 1297
1296#include <qgfx_qws.h> 1298#include <qgfx_qws.h>
1297#include <qwindowsystem_qws.h> 1299#include <qwindowsystem_qws.h>
1298 1300
1299#if QT_VERSION > 236 1301#if QT_VERSION > 236
1300extern void qws_clearLoadedFonts(); 1302extern void qws_clearLoadedFonts();
1301#endif 1303#endif
1302 1304
1303void QPEApplication::setCurrentMode( int x, int y, int depth ) 1305void QPEApplication::setCurrentMode( int x, int y, int depth )
1304{ 1306{
1305 // Reset the caches 1307 // Reset the caches
1306#if QT_VERSION > 236 1308#if QT_VERSION > 236
1307 qws_clearLoadedFonts(); 1309 qws_clearLoadedFonts();
1308#endif 1310#endif
1309 QPixmapCache::clear(); 1311 QPixmapCache::clear();
1310 1312
1311 // Change the screen mode 1313 // Change the screen mode
1312 qt_screen->setMode(x, y, depth); 1314 qt_screen->setMode(x, y, depth);
1313 1315
1314 if ( qApp->type() == GuiServer ) { 1316 if ( qApp->type() == GuiServer ) {
1315#if QT_VERSION > 236 1317#if QT_VERSION > 236
1316 // Reconfigure the GuiServer 1318 // Reconfigure the GuiServer
1317 qwsServer->beginDisplayReconfigure(); 1319 qwsServer->beginDisplayReconfigure();
1318 qwsServer->endDisplayReconfigure(); 1320 qwsServer->endDisplayReconfigure();
1319#endif 1321#endif
1320 // Get all the running apps to reset 1322 // Get all the running apps to reset
1321 QCopEnvelope env( "QPE/System", "reset()" ); 1323 QCopEnvelope env( "QPE/System", "reset()" );
1322 } 1324 }
1323} 1325}
1324 1326
1325void QPEApplication::reset() { 1327void QPEApplication::reset() {
1326 // Reconnect to the screen 1328 // Reconnect to the screen
1327 qt_screen->disconnect(); 1329 qt_screen->disconnect();
1328 qt_screen->connect( QString::null ); 1330 qt_screen->connect( QString::null );
1329 1331
1330 // Redraw everything 1332 // Redraw everything
1331 applyStyle(); 1333 applyStyle();
1332} 1334}
1333 1335
1334#if (QT_VERSION < 238) && defined Q_OS_MACX 1336#if (QT_VERSION < 238) && defined Q_OS_MACX
1335bool qt_left_hand_scrollbars = false; 1337bool qt_left_hand_scrollbars = false;
1336#else 1338#else
1337#ifdef Q_OS_MACX 1339#ifdef Q_OS_MACX
1338#define WEAK_SYMBOL __attribute__((weak_import)) 1340#define WEAK_SYMBOL __attribute__((weak_import))
1339#else 1341#else
1340#define WEAK_SYMBOL __attribute__((weak)) 1342#define WEAK_SYMBOL __attribute__((weak))
1341#endif 1343#endif
1342extern bool qt_left_hand_scrollbars WEAK_SYMBOL; 1344extern bool qt_left_hand_scrollbars WEAK_SYMBOL;
1343#endif 1345#endif
1344 1346
1345/*! 1347/*!
1346 \internal 1348 \internal
1347*/ 1349*/
@@ -1910,346 +1912,346 @@ void QPEApplication::internalSetStyle( const QString &style )
1910 1912
1911 if ( lastlib ) { 1913 if ( lastlib ) {
1912 lastlib-> unload ( ); 1914 lastlib-> unload ( );
1913 delete lastlib; 1915 delete lastlib;
1914 } 1916 }
1915 lastlib = lib; 1917 lastlib = lib;
1916 } 1918 }
1917 else { 1919 else {
1918 if ( iface ) 1920 if ( iface )
1919 iface-> release ( ); 1921 iface-> release ( );
1920 delete lib; 1922 delete lib;
1921 1923
1922 setStyle ( new LightStyle ( )); 1924 setStyle ( new LightStyle ( ));
1923 } 1925 }
1924 } 1926 }
1925#endif 1927#endif
1926} 1928}
1927 1929
1928/*! 1930/*!
1929 \internal 1931 \internal
1930*/ 1932*/
1931void QPEApplication::prepareForTermination( bool willrestart ) 1933void QPEApplication::prepareForTermination( bool willrestart )
1932{ 1934{
1933 if ( willrestart ) { 1935 if ( willrestart ) {
1934 // Draw a big wait icon, the image can be altered in later revisions 1936 // Draw a big wait icon, the image can be altered in later revisions
1935 // QWidget *d = QApplication::desktop(); 1937 // QWidget *d = QApplication::desktop();
1936 QImage img = Resource::loadImage( "launcher/new_wait" ); 1938 QImage img = Resource::loadImage( "launcher/new_wait" );
1937 QPixmap pix; 1939 QPixmap pix;
1938 pix.convertFromImage( img.smoothScale( 1 * img.width(), 1 * img.height() ) ); 1940 pix.convertFromImage( img.smoothScale( 1 * img.width(), 1 * img.height() ) );
1939 QLabel *lblWait = new QLabel( 0, "wait hack!", QWidget::WStyle_Customize | 1941 QLabel *lblWait = new QLabel( 0, "wait hack!", QWidget::WStyle_Customize |
1940 QWidget::WStyle_NoBorder | QWidget::WStyle_Tool ); 1942 QWidget::WStyle_NoBorder | QWidget::WStyle_Tool );
1941 lblWait->setPixmap( pix ); 1943 lblWait->setPixmap( pix );
1942 lblWait->setAlignment( QWidget::AlignCenter ); 1944 lblWait->setAlignment( QWidget::AlignCenter );
1943 lblWait->show(); 1945 lblWait->show();
1944 lblWait->showMaximized(); 1946 lblWait->showMaximized();
1945 } 1947 }
1946#ifndef SINGLE_APP 1948#ifndef SINGLE_APP
1947 { QCopEnvelope envelope( "QPE/System", "forceQuit()" ); 1949 { QCopEnvelope envelope( "QPE/System", "forceQuit()" );
1948 } 1950 }
1949 processEvents(); // ensure the message goes out. 1951 processEvents(); // ensure the message goes out.
1950 sleep( 1 ); // You have 1 second to comply. 1952 sleep( 1 ); // You have 1 second to comply.
1951#endif 1953#endif
1952} 1954}
1953 1955
1954/*! 1956/*!
1955 \internal 1957 \internal
1956*/ 1958*/
1957void QPEApplication::shutdown() 1959void QPEApplication::shutdown()
1958{ 1960{
1959 // Implement in server's QPEApplication subclass 1961 // Implement in server's QPEApplication subclass
1960} 1962}
1961 1963
1962/*! 1964/*!
1963 \internal 1965 \internal
1964*/ 1966*/
1965void QPEApplication::restart() 1967void QPEApplication::restart()
1966{ 1968{
1967 // Implement in server's QPEApplication subclass 1969 // Implement in server's QPEApplication subclass
1968} 1970}
1969 1971
1970static QPtrDict<void>* stylusDict = 0; 1972static QPtrDict<void>* stylusDict = 0;
1971static void createDict() 1973static void createDict()
1972{ 1974{
1973 if ( !stylusDict ) 1975 if ( !stylusDict )
1974 stylusDict = new QPtrDict<void>; 1976 stylusDict = new QPtrDict<void>;
1975} 1977}
1976 1978
1977/*! 1979/*!
1978 Returns the current StylusMode for widget \a w. 1980 Returns the current StylusMode for widget \a w.
1979 1981
1980 \sa setStylusOperation() StylusMode 1982 \sa setStylusOperation() StylusMode
1981*/ 1983*/
1982QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w ) 1984QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w )
1983{ 1985{
1984 if ( stylusDict ) 1986 if ( stylusDict )
1985 return ( StylusMode ) ( int ) stylusDict->find( w ); 1987 return ( StylusMode ) ( int ) stylusDict->find( w );
1986 return LeftOnly; 1988 return LeftOnly;
1987} 1989}
1988 1990
1989/*! 1991/*!
1990 \enum QPEApplication::StylusMode 1992 \enum QPEApplication::StylusMode
1991 1993
1992 \value LeftOnly the stylus only generates LeftButton 1994 \value LeftOnly the stylus only generates LeftButton
1993 events (the default). 1995 events (the default).
1994 \value RightOnHold the stylus generates RightButton events 1996 \value RightOnHold the stylus generates RightButton events
1995 if the user uses the press-and-hold gesture. 1997 if the user uses the press-and-hold gesture.
1996 1998
1997 \sa setStylusOperation() stylusOperation() 1999 \sa setStylusOperation() stylusOperation()
1998*/ 2000*/
1999 2001
2000/*! 2002/*!
2001 Causes widget \a w to receive mouse events according to the stylus 2003 Causes widget \a w to receive mouse events according to the stylus
2002 \a mode. 2004 \a mode.
2003 2005
2004 \sa stylusOperation() StylusMode 2006 \sa stylusOperation() StylusMode
2005*/ 2007*/
2006void QPEApplication::setStylusOperation( QWidget * w, StylusMode mode ) 2008void QPEApplication::setStylusOperation( QWidget * w, StylusMode mode )
2007{ 2009{
2008 createDict(); 2010 createDict();
2009 if ( mode == LeftOnly ) { 2011 if ( mode == LeftOnly ) {
2010 stylusDict->remove 2012 stylusDict->remove
2011 ( w ); 2013 ( w );
2012 w->removeEventFilter( qApp ); 2014 w->removeEventFilter( qApp );
2013 } 2015 }
2014 else { 2016 else {
2015 stylusDict->insert( w, ( void* ) mode ); 2017 stylusDict->insert( w, ( void* ) mode );
2016 connect( w, SIGNAL( destroyed() ), qApp, SLOT( removeSenderFromStylusDict() ) ); 2018 connect( w, SIGNAL( destroyed() ), qApp, SLOT( removeSenderFromStylusDict() ) );
2017 w->installEventFilter( qApp ); 2019 w->installEventFilter( qApp );
2018 } 2020 }
2019} 2021}
2020 2022
2021 2023
2022/*! 2024/*!
2023 \reimp 2025 \reimp
2024*/ 2026*/
2025bool QPEApplication::eventFilter( QObject *o, QEvent *e ) 2027bool QPEApplication::eventFilter( QObject *o, QEvent *e )
2026{ 2028{
2027 if ( !o->isWidgetType() ) 2029 if ( !o->isWidgetType() )
2028 return FALSE; 2030 return FALSE;
2029 2031
2030 if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) { 2032 if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) {
2031 QMouseEvent * me = ( QMouseEvent* ) e; 2033 QMouseEvent * me = ( QMouseEvent* ) e;
2032 StylusMode mode = (StylusMode)(int)stylusDict->find(o); 2034 StylusMode mode = (StylusMode)(int)stylusDict->find(o);
2033 switch (mode) { 2035 switch (mode) {
2034 case RightOnHold: 2036 case RightOnHold:
2035 switch ( me->type() ) { 2037 switch ( me->type() ) {
2036 case QEvent::MouseButtonPress: 2038 case QEvent::MouseButtonPress:
2037 if ( me->button() == LeftButton ) { 2039 if ( me->button() == LeftButton ) {
2040 static long Pref = 500; // #### pref.
2038 d->presswidget = (QWidget*)o; 2041 d->presswidget = (QWidget*)o;
2039 d->presspos = me->pos(); 2042 d->presspos = me->pos();
2040 d->rightpressed = FALSE; 2043 d->rightpressed = FALSE;
2041 // just for the time being 2044#ifdef OPIE_WITHROHFEEDBACK
2042 static int pref = 500;
2043#ifdef OPIE_ROHFEEDBACK
2044 if( ! d->RoH ) 2045 if( ! d->RoH )
2045 d->RoH = new Opie::Internal::RoHFeedback; 2046 d->RoH = new Opie::Internal::RoHFeedback;
2046 2047
2047 d->RoH->init( me->globalPos(), d->presswidget ); 2048 d->RoH->init( me->globalPos(), d->presswidget );
2048 pref = d->RoH->delay(); 2049 Pref = d->RoH->delay();
2050
2049#endif 2051#endif
2050 if (!d->presstimer ) 2052 if (!d->presstimer )
2051 d->presstimer = startTimer( pref ); // #### pref. 2053 d->presstimer = startTimer( Pref ); // #### pref.
2052 2054
2053 } 2055 }
2054 break; 2056 break;
2055 case QEvent::MouseMove: 2057 case QEvent::MouseMove:
2056 if (d->presstimer && (me->pos() - d->presspos).manhattanLength() > 8) { 2058 if (d->presstimer && (me->pos() - d->presspos).manhattanLength() > 8) {
2057 killTimer(d->presstimer); 2059 killTimer(d->presstimer);
2058#ifdef OPIE_ROHFEEDBACK 2060#ifdef OPIE_WITHROHFEEDBACK
2059 if( d->RoH ) 2061 d->RoH->stop();
2060 d->RoH->stop( );
2061#endif 2062#endif
2062 d->presstimer = 0; 2063 d->presstimer = 0;
2063 } 2064 }
2064 break; 2065 break;
2065 case QEvent::MouseButtonRelease: 2066 case QEvent::MouseButtonRelease:
2066 if ( me->button() == LeftButton ) { 2067 if ( me->button() == LeftButton ) {
2067 if ( d->presstimer ) { 2068 if ( d->presstimer ) {
2068 killTimer(d->presstimer); 2069 killTimer(d->presstimer);
2069#ifdef OPIE_ROHFEEDBACK 2070#ifdef OPIE_WITHROHFEEDBACK
2070 if( d->RoH ) 2071 d->RoH->stop( );
2071 d->RoH->stop( );
2072#endif 2072#endif
2073 d->presstimer = 0; 2073 d->presstimer = 0;
2074 } 2074 }
2075 if ( d->rightpressed && d->presswidget ) { 2075 if ( d->rightpressed && d->presswidget ) {
2076 printf( "Send ButtonRelease\n" );
2076 // Right released 2077 // Right released
2077 postEvent( d->presswidget, 2078 postEvent( d->presswidget,
2078 new QMouseEvent( QEvent::MouseButtonRelease, me->pos(), 2079 new QMouseEvent( QEvent::MouseButtonRelease, me->pos(),
2079 RightButton, LeftButton + RightButton ) ); 2080 RightButton, LeftButton + RightButton ) );
2080 // Left released, off-widget 2081 // Left released, off-widget
2081 postEvent( d->presswidget, 2082 postEvent( d->presswidget,
2082 new QMouseEvent( QEvent::MouseMove, QPoint( -1, -1), 2083 new QMouseEvent( QEvent::MouseMove, QPoint( -1, -1),
2083 LeftButton, LeftButton ) ); 2084 LeftButton, LeftButton ) );
2084 postEvent( d->presswidget, 2085 postEvent( d->presswidget,
2085 new QMouseEvent( QEvent::MouseButtonRelease, QPoint( -1, -1), 2086 new QMouseEvent( QEvent::MouseButtonRelease, QPoint( -1, -1),
2086 LeftButton, LeftButton ) ); 2087 LeftButton, LeftButton ) );
2087 d->rightpressed = FALSE; 2088 d->rightpressed = FALSE;
2088 return TRUE; // don't send the real Left release 2089 return TRUE; // don't send the real Left release
2089 } 2090 }
2090 } 2091 }
2091 break; 2092 break;
2092 default: 2093 default:
2093 break; 2094 break;
2094 } 2095 }
2095 break; 2096 break;
2096 default: 2097 default:
2097 ; 2098 ;
2098 } 2099 }
2099 } 2100 }
2100 else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { 2101 else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) {
2101 QKeyEvent *ke = (QKeyEvent *)e; 2102 QKeyEvent *ke = (QKeyEvent *)e;
2102 if ( ke->key() == Key_Enter ) { 2103 if ( ke->key() == Key_Enter ) {
2103 if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) { 2104 if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) {
2104 postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ', 2105 postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ',
2105 ke->state(), " ", ke->isAutoRepeat(), ke->count() ) ); 2106 ke->state(), " ", ke->isAutoRepeat(), ke->count() ) );
2106 return TRUE; 2107 return TRUE;
2107 } 2108 }
2108 } 2109 }
2109 } 2110 }
2110 return FALSE; 2111 return FALSE;
2111} 2112}
2112 2113
2113/*! 2114/*!
2114 \reimp 2115 \reimp
2115*/ 2116*/
2116void QPEApplication::timerEvent( QTimerEvent *e ) 2117void QPEApplication::timerEvent( QTimerEvent *e )
2117{ 2118{
2118 if ( e->timerId() == d->presstimer && d->presswidget ) { 2119 if ( e->timerId() == d->presstimer && d->presswidget ) {
2119 // Right pressed 2120
2120 postEvent( d->presswidget, 2121 // Right pressed
2121 new QMouseEvent( QEvent::MouseButtonPress, d->presspos, 2122 postEvent( d->presswidget,
2122 RightButton, LeftButton ) ); 2123 new QMouseEvent( QEvent::MouseButtonPress, d->presspos,
2123 killTimer( d->presstimer ); 2124 RightButton, LeftButton ) );
2124 d->presstimer = 0; 2125 killTimer( d->presstimer );
2125 d->rightpressed = TRUE; 2126 d->presstimer = 0;
2126#ifdef OPIE_ROHFEEDBACK 2127 d->rightpressed = TRUE;
2127 d->RoH->stop(); 2128#ifdef OPIE_WITHROHFEEDBACK
2129 d->RoH->stop();
2128#endif 2130#endif
2129 } 2131 }
2130} 2132}
2131 2133
2132void QPEApplication::removeSenderFromStylusDict() 2134void QPEApplication::removeSenderFromStylusDict()
2133{ 2135{
2134 stylusDict->remove 2136 stylusDict->remove
2135 ( ( void* ) sender() ); 2137 ( ( void* ) sender() );
2136 if ( d->presswidget == sender() ) 2138 if ( d->presswidget == sender() )
2137 d->presswidget = 0; 2139 d->presswidget = 0;
2138} 2140}
2139 2141
2140/*! 2142/*!
2141 \internal 2143 \internal
2142*/ 2144*/
2143bool QPEApplication::keyboardGrabbed() const 2145bool QPEApplication::keyboardGrabbed() const
2144{ 2146{
2145 return d->kbgrabbed; 2147 return d->kbgrabbed;
2146} 2148}
2147 2149
2148 2150
2149/*! 2151/*!
2150 Reverses the effect of grabKeyboard(). This is called automatically 2152 Reverses the effect of grabKeyboard(). This is called automatically
2151 on program exit. 2153 on program exit.
2152*/ 2154*/
2153void QPEApplication::ungrabKeyboard() 2155void QPEApplication::ungrabKeyboard()
2154{ 2156{
2155 ((QPEApplication *) qApp )-> d-> kbgrabbed = false; 2157 ((QPEApplication *) qApp )-> d-> kbgrabbed = false;
2156} 2158}
2157 2159
2158/*! 2160/*!
2159 Grabs the physical keyboard keys, e.g. the application's launching 2161 Grabs the physical keyboard keys, e.g. the application's launching
2160 keys. Instead of launching applications when these keys are pressed 2162 keys. Instead of launching applications when these keys are pressed
2161 the signals emitted are sent to this application instead. Some games 2163 the signals emitted are sent to this application instead. Some games
2162 programs take over the launch keys in this way to make interaction 2164 programs take over the launch keys in this way to make interaction
2163 easier. 2165 easier.
2164 2166
2165 \sa ungrabKeyboard() 2167 \sa ungrabKeyboard()
2166*/ 2168*/
2167void QPEApplication::grabKeyboard() 2169void QPEApplication::grabKeyboard()
2168{ 2170{
2169 ((QPEApplication *) qApp )-> d-> kbgrabbed = true; 2171 ((QPEApplication *) qApp )-> d-> kbgrabbed = true;
2170} 2172}
2171 2173
2172/*! 2174/*!
2173 \reimp 2175 \reimp
2174*/ 2176*/
2175int QPEApplication::exec() 2177int QPEApplication::exec()
2176{ 2178{
2177 d->qcopQok = true; 2179 d->qcopQok = true;
2178#ifndef QT_NO_COP 2180#ifndef QT_NO_COP
2179 d->sendQCopQ(); 2181 d->sendQCopQ();
2180 if ( !d->keep_running ) 2182 if ( !d->keep_running )
2181 processEvents(); // we may have received QCop messages in the meantime. 2183 processEvents(); // we may have received QCop messages in the meantime.
2182#endif 2184#endif
2183 2185
2184 if ( d->keep_running ) 2186 if ( d->keep_running )
2185 //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() ) 2187 //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() )
2186 return QApplication::exec(); 2188 return QApplication::exec();
2187 2189
2188#ifndef QT_NO_COP 2190#ifndef QT_NO_COP
2189 2191
2190 { 2192 {
2191 QCopEnvelope e( "QPE/System", "closing(QString)" ); 2193 QCopEnvelope e( "QPE/System", "closing(QString)" );
2192 e << d->appName; 2194 e << d->appName;
2193 } 2195 }
2194#endif 2196#endif
2195 processEvents(); 2197 processEvents();
2196 return 0; 2198 return 0;
2197} 2199}
2198 2200
2199/*! 2201/*!
2200 \internal 2202 \internal
2201 External request for application to quit. Quits if possible without 2203 External request for application to quit. Quits if possible without
2202 loosing state. 2204 loosing state.
2203*/ 2205*/
2204void QPEApplication::tryQuit() 2206void QPEApplication::tryQuit()
2205{ 2207{
2206 if ( activeModalWidget() ) 2208 if ( activeModalWidget() )
2207 return ; // Inside modal loop or konsole. Too hard to save state. 2209 return ; // Inside modal loop or konsole. Too hard to save state.
2208#ifndef QT_NO_COP 2210#ifndef QT_NO_COP
2209 2211
2210 { 2212 {
2211 QCopEnvelope e( "QPE/System", "closing(QString)" ); 2213 QCopEnvelope e( "QPE/System", "closing(QString)" );
2212 e << d->appName; 2214 e << d->appName;
2213 } 2215 }
2214#endif 2216#endif
2215 if ( d->keep_running ) 2217 if ( d->keep_running )
2216 d->store_widget_rect(d->qpe_main_widget, d->appName); 2218 d->store_widget_rect(d->qpe_main_widget, d->appName);
2217 processEvents(); 2219 processEvents();
2218 2220
2219 quit(); 2221 quit();
2220} 2222}
2221 2223
2222/*! 2224/*!
2223 \internal 2225 \internal
2224*/ 2226*/
2225void QPEApplication::installTranslation( const QString& baseName ) { 2227void QPEApplication::installTranslation( const QString& baseName ) {
2226 QTranslator* trans = new QTranslator(this); 2228 QTranslator* trans = new QTranslator(this);
2227 QString tfn = qpeDir() + "/i18n/"+baseName; 2229 QString tfn = qpeDir() + "/i18n/"+baseName;
2228 if ( trans->load( tfn ) ) 2230 if ( trans->load( tfn ) )
2229 installTranslator( trans ); 2231 installTranslator( trans );
2230 else 2232 else
2231 delete trans; 2233 delete trans;
2232} 2234}
2233 2235
2234/*! 2236/*!
2235 \internal 2237 \internal
2236 User initiated quit. Makes the window 'Go Away'. If preloaded this means 2238 User initiated quit. Makes the window 'Go Away'. If preloaded this means
2237 hiding the window. If not it means quitting the application. 2239 hiding the window. If not it means quitting the application.
2238 As this is user initiated we don't need to check state. 2240 As this is user initiated we don't need to check state.
2239*/ 2241*/
2240void QPEApplication::hideOrQuit() 2242void QPEApplication::hideOrQuit()
2241{ 2243{
2242 if ( d->keep_running ) 2244 if ( d->keep_running )
2243 d->store_widget_rect(d->qpe_main_widget, d->appName); 2245 d->store_widget_rect(d->qpe_main_widget, d->appName);
2244 processEvents(); 2246 processEvents();
2245 2247
2246 // If we are a preloaded application we don't actually quit, so emit 2248 // If we are a preloaded application we don't actually quit, so emit
2247 // a System message indicating we're quasi-closing. 2249 // a System message indicating we're quasi-closing.
2248 if ( d->preloaded && d->qpe_main_widget ) 2250 if ( d->preloaded && d->qpe_main_widget )
2249#ifndef QT_NO_COP 2251#ifndef QT_NO_COP
2250 2252
2251 { 2253 {
2252 QCopEnvelope e("QPE/System", "fastAppHiding(QString)" ); 2254 QCopEnvelope e("QPE/System", "fastAppHiding(QString)" );
2253 e << d->appName; 2255 e << d->appName;
2254 d->qpe_main_widget->hide(); 2256 d->qpe_main_widget->hide();
2255 } 2257 }