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