summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--library/qpeapplication.cpp17
1 files changed, 12 insertions, 5 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp
index acad81d..35f433c 100644
--- a/library/qpeapplication.cpp
+++ b/library/qpeapplication.cpp
@@ -1,693 +1,696 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19*/ 19*/
20#define QTOPIA_INTERNAL_LANGLIST 20#define QTOPIA_INTERNAL_LANGLIST
21#include <stdlib.h> 21#include <stdlib.h>
22#include <unistd.h> 22#include <unistd.h>
23#ifndef Q_OS_MACX 23#ifndef Q_OS_MACX
24#include <linux/limits.h> // needed for some toolchains (PATH_MAX) 24#include <linux/limits.h> // needed for some toolchains (PATH_MAX)
25#endif 25#endif
26#include <qfile.h> 26#include <qfile.h>
27#include <qqueue.h> 27#include <qqueue.h>
28#ifdef Q_WS_QWS 28#ifdef Q_WS_QWS
29#ifndef QT_NO_COP 29#ifndef QT_NO_COP
30#if QT_VERSION <= 231 30#if QT_VERSION <= 231
31#define private public 31#define private public
32#define sendLocally processEvent 32#define sendLocally processEvent
33#include "qcopenvelope_qws.h" 33#include "qcopenvelope_qws.h"
34#undef private 34#undef private
35#else 35#else
36#include "qcopenvelope_qws.h" 36#include "qcopenvelope_qws.h"
37#endif 37#endif
38#endif 38#endif
39#include <qwindowsystem_qws.h> 39#include <qwindowsystem_qws.h>
40#endif 40#endif
41#include <qtextstream.h> 41#include <qtextstream.h>
42#include <qpalette.h> 42#include <qpalette.h>
43#include <qbuffer.h> 43#include <qbuffer.h>
44#include <qptrdict.h> 44#include <qptrdict.h>
45#include <qregexp.h> 45#include <qregexp.h>
46#include <qdir.h> 46#include <qdir.h>
47#include <qlabel.h> 47#include <qlabel.h>
48#include <qdialog.h> 48#include <qdialog.h>
49#include <qdragobject.h> 49#include <qdragobject.h>
50#include <qtextcodec.h> 50#include <qtextcodec.h>
51#include <qevent.h> 51#include <qevent.h>
52#include <qtooltip.h> 52#include <qtooltip.h>
53#include <qsignal.h> 53#include <qsignal.h>
54#include <qmainwindow.h> 54#include <qmainwindow.h>
55#include <qwidgetlist.h> 55#include <qwidgetlist.h>
56#include <qpixmapcache.h> 56#include <qpixmapcache.h>
57 57
58#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 58#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
59#define QTOPIA_INTERNAL_INITAPP 59#define QTOPIA_INTERNAL_INITAPP
60#include "qpeapplication.h" 60#include "qpeapplication.h"
61#include "qpestyle.h" 61#include "qpestyle.h"
62#include "styleinterface.h" 62#include "styleinterface.h"
63#if QT_VERSION >= 300 63#if QT_VERSION >= 300
64#include <qstylefactory.h> 64#include <qstylefactory.h>
65#else 65#else
66#include <qplatinumstyle.h> 66#include <qplatinumstyle.h>
67#include <qwindowsstyle.h> 67#include <qwindowsstyle.h>
68#include <qmotifstyle.h> 68#include <qmotifstyle.h>
69#include <qmotifplusstyle.h> 69#include <qmotifplusstyle.h>
70#include "lightstyle.h" 70#include "lightstyle.h"
71 71
72#include <qpe/qlibrary.h> 72#include <qpe/qlibrary.h>
73#endif 73#endif
74#include "global.h" 74#include "global.h"
75#include "resource.h" 75#include "resource.h"
76#if QT_VERSION <= 230 && defined(QT_NO_CODECS) 76#if QT_VERSION <= 230 && defined(QT_NO_CODECS)
77#include "qutfcodec.h" 77#include "qutfcodec.h"
78#endif 78#endif
79#include "config.h" 79#include "config.h"
80#include "network.h" 80#include "network.h"
81#ifdef QWS 81#ifdef QWS
82#include "fontmanager.h" 82#include "fontmanager.h"
83#include "fontdatabase.h" 83#include "fontdatabase.h"
84#endif 84#endif
85 85
86#include "alarmserver.h" 86#include "alarmserver.h"
87#include "applnk.h" 87#include "applnk.h"
88#include "qpemenubar.h" 88#include "qpemenubar.h"
89#include "textcodecinterface.h" 89#include "textcodecinterface.h"
90#include "imagecodecinterface.h" 90#include "imagecodecinterface.h"
91 91
92#include <unistd.h> 92#include <unistd.h>
93#include <sys/file.h> 93#include <sys/file.h>
94#include <sys/ioctl.h> 94#include <sys/ioctl.h>
95#ifndef QT_NO_SOUND 95#ifndef QT_NO_SOUND
96#include <sys/soundcard.h> 96#include <sys/soundcard.h>
97#endif 97#endif
98#include "qt_override_p.h" 98#include "qt_override_p.h"
99 99
100#include <qpe/rohfeedback.h> 100#include <qpe/rohfeedback.h>
101 101
102 102
103static bool useBigPixmaps = 0; 103static bool useBigPixmaps = 0;
104 104
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_ROHFEEDBACK
133 RoH = 0; 134 RoH = 0;
135#endif
134 } 136 }
135 137
136 int presstimer; 138 int presstimer;
137 QWidget* presswidget; 139 QWidget* presswidget;
138 QPoint presspos; 140 QPoint presspos;
141#ifdef OPIE_ROHFEEDBACK
142 Opie::Internal::RoHFeedback *RoH;
143#endif
139 144
140 bool rightpressed : 1; 145 bool rightpressed : 1;
141 bool kbgrabbed : 1; 146 bool kbgrabbed : 1;
142 bool notbusysent : 1; 147 bool notbusysent : 1;
143 bool preloaded : 1; 148 bool preloaded : 1;
144 bool forceshow : 1; 149 bool forceshow : 1;
145 bool nomaximize : 1; 150 bool nomaximize : 1;
146 bool keep_running : 1; 151 bool keep_running : 1;
147 bool qcopQok : 1; 152 bool qcopQok : 1;
148 153
149 QCString fontFamily; 154 QCString fontFamily;
150 int fontSize; 155 int fontSize;
151 int smallIconSize; 156 int smallIconSize;
152 int bigIconSize; 157 int bigIconSize;
153 158
154 QStringList langs; 159 QStringList langs;
155 QString appName; 160 QString appName;
156 struct QCopRec 161 struct QCopRec
157 { 162 {
158 QCopRec( const QCString &ch, const QCString &msg, 163 QCopRec( const QCString &ch, const QCString &msg,
159 const QByteArray &d ) : 164 const QByteArray &d ) :
160 channel( ch ), message( msg ), data( d ) 165 channel( ch ), message( msg ), data( d )
161 { } 166 { }
162 167
163 QCString channel; 168 QCString channel;
164 QCString message; 169 QCString message;
165 QByteArray data; 170 QByteArray data;
166 }; 171 };
167 QWidget* qpe_main_widget; 172 QWidget* qpe_main_widget;
168 QGuardedPtr<QWidget> lastraised; 173 QGuardedPtr<QWidget> lastraised;
169 QQueue<QCopRec> qcopq; 174 QQueue<QCopRec> qcopq;
170 QString styleName; 175 QString styleName;
171 QString decorationName; 176 QString decorationName;
172 177
173 void enqueueQCop( const QCString &ch, const QCString &msg, 178 void enqueueQCop( const QCString &ch, const QCString &msg,
174 const QByteArray &data ) 179 const QByteArray &data )
175 { 180 {
176 qcopq.enqueue( new QCopRec( ch, msg, data ) ); 181 qcopq.enqueue( new QCopRec( ch, msg, data ) );
177 } 182 }
178 void sendQCopQ() 183 void sendQCopQ()
179 { 184 {
180 if (!qcopQok ) 185 if (!qcopQok )
181 return; 186 return;
182 187
183 QCopRec * r; 188 QCopRec * r;
184 189
185 while((r=qcopq.dequeue())) { 190 while((r=qcopq.dequeue())) {
186 // remove from queue before sending... 191 // remove from queue before sending...
187 // event loop can come around again before getting 192 // event loop can come around again before getting
188 // back from sendLocally 193 // back from sendLocally
189#ifndef QT_NO_COP 194#ifndef QT_NO_COP
190 QCopChannel::sendLocally( r->channel, r->message, r->data ); 195 QCopChannel::sendLocally( r->channel, r->message, r->data );
191#endif 196#endif
192 197
193 delete r; 198 delete r;
194 } 199 }
195 } 200 }
196 201
197 static void show_mx(QWidget* mw, bool nomaximize, QString &strName) 202 static void show_mx(QWidget* mw, bool nomaximize, QString &strName)
198 { 203 {
199 if ( mw->inherits("QMainWindow") || mw->isA("QMainWindow") ) 204 if ( mw->inherits("QMainWindow") || mw->isA("QMainWindow") )
200 { 205 {
201 ( ( QMainWindow* ) mw )->setUsesBigPixmaps( useBigPixmaps ); 206 ( ( QMainWindow* ) mw )->setUsesBigPixmaps( useBigPixmaps );
202 } 207 }
203 QPoint p; 208 QPoint p;
204 QSize s; 209 QSize s;
205 bool max; 210 bool max;
206 if ( mw->isVisible() ) { 211 if ( mw->isVisible() ) {
207 if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { 212 if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) {
208 mw->resize(s); 213 mw->resize(s);
209 mw->move(p); 214 mw->move(p);
210 } 215 }
211 mw->raise(); 216 mw->raise();
212 } else { 217 } else {
213 218
214 if ( mw->layout() && mw->inherits("QDialog") ) { 219 if ( mw->layout() && mw->inherits("QDialog") ) {
215 if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { 220 if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) {
216 mw->resize(s); 221 mw->resize(s);
217 mw->move(p); 222 mw->move(p);
218 223
219 if ( max && !nomaximize ) { 224 if ( max && !nomaximize ) {
220 mw->showMaximized(); 225 mw->showMaximized();
221 } else { 226 } else {
222 mw->show(); 227 mw->show();
223 } 228 }
224 } else { 229 } else {
225 qpe_show_dialog((QDialog*)mw,nomaximize); 230 qpe_show_dialog((QDialog*)mw,nomaximize);
226 } 231 }
227 } else { 232 } else {
228 if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { 233 if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) {
229 mw->resize(s); 234 mw->resize(s);
230 mw->move(p); 235 mw->move(p);
231 } else { //no stored rectangle, make an estimation 236 } else { //no stored rectangle, make an estimation
232 int x = (qApp->desktop()->width()-mw->frameGeometry().width())/2; 237 int x = (qApp->desktop()->width()-mw->frameGeometry().width())/2;
233 int y = (qApp->desktop()->height()-mw->frameGeometry().height())/2; 238 int y = (qApp->desktop()->height()-mw->frameGeometry().height())/2;
234 mw->move( QMAX(x,0), QMAX(y,0) ); 239 mw->move( QMAX(x,0), QMAX(y,0) );
235#ifdef Q_WS_QWS 240#ifdef Q_WS_QWS
236 if ( !nomaximize ) 241 if ( !nomaximize )
237 mw->showMaximized(); 242 mw->showMaximized();
238#endif 243#endif
239 } 244 }
240 if ( max && !nomaximize ) 245 if ( max && !nomaximize )
241 mw->showMaximized(); 246 mw->showMaximized();
242 else 247 else
243 mw->show(); 248 mw->show();
244 } 249 }
245 } 250 }
246 } 251 }
247 252
248static void qpe_show_dialog( QDialog* d, bool nomax ) 253static void qpe_show_dialog( QDialog* d, bool nomax )
249{ 254{
250 QSize sh = d->sizeHint(); 255 QSize sh = d->sizeHint();
251 int w = QMAX(sh.width(),d->width()); 256 int w = QMAX(sh.width(),d->width());
252 int h = QMAX(sh.height(),d->height()); 257 int h = QMAX(sh.height(),d->height());
253 258
254 if ( d->parentWidget() && !d->parentWidget()->topLevelWidget()->isMaximized() ) 259 if ( d->parentWidget() && !d->parentWidget()->topLevelWidget()->isMaximized() )
255 nomax = TRUE; 260 nomax = TRUE;
256 261
257#ifndef Q_WS_QWS 262#ifndef Q_WS_QWS
258 QSize s(qApp->desktop()->width(), qApp->desktop()->height() ); 263 QSize s(qApp->desktop()->width(), qApp->desktop()->height() );
259#else 264#else
260 QSize s(qt_maxWindowRect.width(), qt_maxWindowRect.height() ); 265 QSize s(qt_maxWindowRect.width(), qt_maxWindowRect.height() );
261#endif 266#endif
262 267
263 int maxX = s.width() - (d->frameGeometry().width() - d->geometry().width()); 268 int maxX = s.width() - (d->frameGeometry().width() - d->geometry().width());
264 int maxY = s.height() - (d->frameGeometry().height() - d->geometry().height()); 269 int maxY = s.height() - (d->frameGeometry().height() - d->geometry().height());
265 270
266 if ( (w >= maxX && h >= maxY) || ( (!nomax) && ( w > s.width()*3/4 || h > s.height()*3/4 ) ) ) { 271 if ( (w >= maxX && h >= maxY) || ( (!nomax) && ( w > s.width()*3/4 || h > s.height()*3/4 ) ) ) {
267 d->showMaximized(); 272 d->showMaximized();
268 } else { 273 } else {
269 // try centering the dialog around its parent 274 // try centering the dialog around its parent
270 QPoint p(0,0); 275 QPoint p(0,0);
271 if ( d->parentWidget() ) { 276 if ( d->parentWidget() ) {
272 QPoint pp = d->parentWidget()->mapToGlobal( QPoint(0,0) ); 277 QPoint pp = d->parentWidget()->mapToGlobal( QPoint(0,0) );
273 p = QPoint( pp.x() + d->parentWidget()->width()/2, 278 p = QPoint( pp.x() + d->parentWidget()->width()/2,
274 pp.y() + d->parentWidget()->height()/ 2 ); 279 pp.y() + d->parentWidget()->height()/ 2 );
275 } else { 280 } else {
276 p = QPoint( maxX/2, maxY/2 ); 281 p = QPoint( maxX/2, maxY/2 );
277 } 282 }
278 283
279 p = QPoint( p.x() - w/2, p.y() - h/2 ); 284 p = QPoint( p.x() - w/2, p.y() - h/2 );
280// qDebug("p(x,y) is %d %d", p.x(), p.y() ); 285// qDebug("p(x,y) is %d %d", p.x(), p.y() );
281 286
282 if ( w >= maxX ) { 287 if ( w >= maxX ) {
283 if ( p.y() < 0 ) 288 if ( p.y() < 0 )
284 p.setY(0); 289 p.setY(0);
285 if ( p.y() + h > maxY ) 290 if ( p.y() + h > maxY )
286 p.setY( maxY - h); 291 p.setY( maxY - h);
287 292
288 d->resize(maxX, h); 293 d->resize(maxX, h);
289 d->move(0, p.y() ); 294 d->move(0, p.y() );
290 } else if ( h >= maxY ) { 295 } else if ( h >= maxY ) {
291 if ( p.x() < 0 ) 296 if ( p.x() < 0 )
292 p.setX(0); 297 p.setX(0);
293 if ( p.x() + w > maxX ) 298 if ( p.x() + w > maxX )
294 p.setX( maxX - w); 299 p.setX( maxX - w);
295 300
296 d->resize(w, maxY); 301 d->resize(w, maxY);
297 d->move(p.x(),0); 302 d->move(p.x(),0);
298 } else { 303 } else {
299 d->resize(w, h); 304 d->resize(w, h);
300 } 305 }
301 306
302 d->show(); 307 d->show();
303 } 308 }
304} 309}
305 310
306 static bool read_widget_rect(const QString &app, bool &maximized, QPoint &p, QSize &s) 311 static bool read_widget_rect(const QString &app, bool &maximized, QPoint &p, QSize &s)
307 { 312 {
308 maximized = TRUE; 313 maximized = TRUE;
309 // 350 is the trigger in qwsdefaultdecoration for providing a resize button 314 // 350 is the trigger in qwsdefaultdecoration for providing a resize button
310 if ( qApp->desktop()->width() <= 350 ) 315 if ( qApp->desktop()->width() <= 350 )
311 return FALSE; 316 return FALSE;
312 317
313 Config cfg( "qpe" ); 318 Config cfg( "qpe" );
314 cfg.setGroup("ApplicationPositions"); 319 cfg.setGroup("ApplicationPositions");
315 QString str = cfg.readEntry( app, QString::null ); 320 QString str = cfg.readEntry( app, QString::null );
316 QStringList l = QStringList::split(",", str); 321 QStringList l = QStringList::split(",", str);
317 322
318 if ( l.count() == 5) { 323 if ( l.count() == 5) {
319 p.setX( l[0].toInt() ); 324 p.setX( l[0].toInt() );
320 p.setY( l[1].toInt() ); 325 p.setY( l[1].toInt() );
321 326
322 s.setWidth( l[2].toInt() ); 327 s.setWidth( l[2].toInt() );
323 s.setHeight( l[3].toInt() ); 328 s.setHeight( l[3].toInt() );
324 329
325 maximized = l[4].toInt(); 330 maximized = l[4].toInt();
326 331
327 return TRUE; 332 return TRUE;
328 } 333 }
329 334
330 return FALSE; 335 return FALSE;
331 } 336 }
332 337
333 338
334 static bool validate_widget_size(const QWidget *w, QPoint &p, QSize &s) 339 static bool validate_widget_size(const QWidget *w, QPoint &p, QSize &s)
335 { 340 {
336#ifndef Q_WS_QWS 341#ifndef Q_WS_QWS
337 QRect qt_maxWindowRect = qApp->desktop()->geometry(); 342 QRect qt_maxWindowRect = qApp->desktop()->geometry();
338#endif 343#endif
339 int maxX = qt_maxWindowRect.width(); 344 int maxX = qt_maxWindowRect.width();
340 int maxY = qt_maxWindowRect.height(); 345 int maxY = qt_maxWindowRect.height();
341 int wWidth = s.width() + ( w->frameGeometry().width() - w->geometry().width() ); 346 int wWidth = s.width() + ( w->frameGeometry().width() - w->geometry().width() );
342 int wHeight = s.height() + ( w->frameGeometry().height() - w->geometry().height() ); 347 int wHeight = s.height() + ( w->frameGeometry().height() - w->geometry().height() );
343 348
344 // total window size is not allowed to be larger than desktop window size 349 // total window size is not allowed to be larger than desktop window size
345 if ( ( wWidth >= maxX ) && ( wHeight >= maxY ) ) 350 if ( ( wWidth >= maxX ) && ( wHeight >= maxY ) )
346 return FALSE; 351 return FALSE;
347 352
348 if ( wWidth > maxX ) { 353 if ( wWidth > maxX ) {
349 s.setWidth( maxX - (w->frameGeometry().width() - w->geometry().width() ) ); 354 s.setWidth( maxX - (w->frameGeometry().width() - w->geometry().width() ) );
350 wWidth = maxX; 355 wWidth = maxX;
351 } 356 }
352 357
353 if ( wHeight > maxY ) { 358 if ( wHeight > maxY ) {
354 s.setHeight( maxY - (w->frameGeometry().height() - w->geometry().height() ) ); 359 s.setHeight( maxY - (w->frameGeometry().height() - w->geometry().height() ) );
355 wHeight = maxY; 360 wHeight = maxY;
356 } 361 }
357 362
358 // any smaller than this and the maximize/close/help buttons will be overlapping 363 // any smaller than this and the maximize/close/help buttons will be overlapping
359 if ( wWidth < 80 || wHeight < 60 ) 364 if ( wWidth < 80 || wHeight < 60 )
360 return FALSE; 365 return FALSE;
361 366
362 if ( p.x() < 0 ) 367 if ( p.x() < 0 )
363 p.setX(0); 368 p.setX(0);
364 if ( p.y() < 0 ) 369 if ( p.y() < 0 )
365 p.setY(0); 370 p.setY(0);
366 371
367 if ( p.x() + wWidth > maxX ) 372 if ( p.x() + wWidth > maxX )
368 p.setX( maxX - wWidth ); 373 p.setX( maxX - wWidth );
369 if ( p.y() + wHeight > maxY ) 374 if ( p.y() + wHeight > maxY )
370 p.setY( maxY - wHeight ); 375 p.setY( maxY - wHeight );
371 376
372 return TRUE; 377 return TRUE;
373 } 378 }
374 379
375 static void store_widget_rect(QWidget *w, QString &app) 380 static void store_widget_rect(QWidget *w, QString &app)
376 { 381 {
377 // 350 is the trigger in qwsdefaultdecoration for providing a resize button 382 // 350 is the trigger in qwsdefaultdecoration for providing a resize button
378 if ( qApp->desktop()->width() <= 350 ) 383 if ( qApp->desktop()->width() <= 350 )
379 return; 384 return;
380 // we use these to map the offset of geometry and pos. ( we can only use normalGeometry to 385 // we use these to map the offset of geometry and pos. ( we can only use normalGeometry to
381 // get the non-maximized version, so we have to do it the hard way ) 386 // get the non-maximized version, so we have to do it the hard way )
382 int offsetX = w->x() - w->geometry().left(); 387 int offsetX = w->x() - w->geometry().left();
383 int offsetY = w->y() - w->geometry().top(); 388 int offsetY = w->y() - w->geometry().top();
384 389
385 QRect r; 390 QRect r;
386 if ( w->isMaximized() ) 391 if ( w->isMaximized() )
387 r = ( (HackWidget *) w)->normalGeometry(); 392 r = ( (HackWidget *) w)->normalGeometry();
388 else 393 else
389 r = w->geometry(); 394 r = w->geometry();
390 395
391 // Stores the window placement as pos(), size() (due to the offset mapping) 396 // Stores the window placement as pos(), size() (due to the offset mapping)
392 Config cfg( "qpe" ); 397 Config cfg( "qpe" );
393 cfg.setGroup("ApplicationPositions"); 398 cfg.setGroup("ApplicationPositions");
394 QString s; 399 QString s;
395 s.sprintf("%d,%d,%d,%d,%d", r.left() + offsetX, r.top() + offsetY, r.width(), r.height(), w->isMaximized() ); 400 s.sprintf("%d,%d,%d,%d,%d", r.left() + offsetX, r.top() + offsetY, r.width(), r.height(), w->isMaximized() );
396 cfg.writeEntry( app, s ); 401 cfg.writeEntry( app, s );
397 } 402 }
398 403
399 static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) 404 static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ )
400 { 405 {
401 /* 406 /*
402 // This works but disable it for now until it is safe to apply 407 // This works but disable it for now until it is safe to apply
403 // What is does is scan the .desktop files of all the apps for 408 // What is does is scan the .desktop files of all the apps for
404 // the applnk that has the corresponding argv[0] as this program 409 // the applnk that has the corresponding argv[0] as this program
405 // then it uses the name stored in the .desktop file as the caption 410 // then it uses the name stored in the .desktop file as the caption
406 // for the main widget. This saves duplicating translations for 411 // for the main widget. This saves duplicating translations for
407 // the app name in the program and in the .desktop files. 412 // the app name in the program and in the .desktop files.
408 413
409 AppLnkSet apps( appsPath ); 414 AppLnkSet apps( appsPath );
410 415
411 QList<AppLnk> appsList = apps.children(); 416 QList<AppLnk> appsList = apps.children();
412 for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) { 417 for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) {
413 if ( (*it)->exec() == appName ) { 418 if ( (*it)->exec() == appName ) {
414 mw->setCaption( (*it)->name() ); 419 mw->setCaption( (*it)->name() );
415 return TRUE; 420 return TRUE;
416 } 421 }
417 } 422 }
418 */ 423 */
419 return FALSE; 424 return FALSE;
420 } 425 }
421 426
422 427
423 void show(QWidget* mw, bool nomax) 428 void show(QWidget* mw, bool nomax)
424 { 429 {
425 setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" ); 430 setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" );
426 nomaximize = nomax; 431 nomaximize = nomax;
427 qpe_main_widget = mw; 432 qpe_main_widget = mw;
428 qcopQok = TRUE; 433 qcopQok = TRUE;
429#ifndef QT_NO_COP 434#ifndef QT_NO_COP
430 435
431 sendQCopQ(); 436 sendQCopQ();
432#endif 437#endif
433 438
434 if ( preloaded ) { 439 if ( preloaded ) {
435 if (forceshow) 440 if (forceshow)
436 show_mx(mw, nomax, appName); 441 show_mx(mw, nomax, appName);
437 } 442 }
438 else if ( keep_running ) { 443 else if ( keep_running ) {
439 show_mx(mw, nomax, appName); 444 show_mx(mw, nomax, appName);
440 } 445 }
441 } 446 }
442 447
443 void loadTextCodecs() 448 void loadTextCodecs()
444 { 449 {
445 QString path = QPEApplication::qpeDir() + "/plugins/textcodecs"; 450 QString path = QPEApplication::qpeDir() + "/plugins/textcodecs";
446#ifdef Q_OS_MACX 451#ifdef Q_OS_MACX
447 QDir dir( path, "lib*.dylib" ); 452 QDir dir( path, "lib*.dylib" );
448#else 453#else
449 QDir dir( path, "lib*.so" ); 454 QDir dir( path, "lib*.so" );
450#endif 455#endif
451 QStringList list; 456 QStringList list;
452 if ( dir. exists ( )) 457 if ( dir. exists ( ))
453 list = dir.entryList(); 458 list = dir.entryList();
454 QStringList::Iterator it; 459 QStringList::Iterator it;
455 for ( it = list.begin(); it != list.end(); ++it ) { 460 for ( it = list.begin(); it != list.end(); ++it ) {
456 TextCodecInterface *iface = 0; 461 TextCodecInterface *iface = 0;
457 QLibrary *lib = new QLibrary( path + "/" + *it ); 462 QLibrary *lib = new QLibrary( path + "/" + *it );
458 if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { 463 if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) {
459 QValueList<int> mibs = iface->mibEnums(); 464 QValueList<int> mibs = iface->mibEnums();
460 for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) { 465 for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) {
461 (void)iface->createForMib(*i); 466 (void)iface->createForMib(*i);
462 // ### it exists now; need to remember if we can delete it 467 // ### it exists now; need to remember if we can delete it
463 } 468 }
464 } 469 }
465 else { 470 else {
466 lib->unload(); 471 lib->unload();
467 delete lib; 472 delete lib;
468 } 473 }
469 } 474 }
470 } 475 }
471 476
472 void loadImageCodecs() 477 void loadImageCodecs()
473 { 478 {
474 QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs"; 479 QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs";
475#ifdef Q_OS_MACX 480#ifdef Q_OS_MACX
476 QDir dir( path, "lib*.dylib" ); 481 QDir dir( path, "lib*.dylib" );
477#else 482#else
478 QDir dir( path, "lib*.so" ); 483 QDir dir( path, "lib*.so" );
479#endif 484#endif
480 QStringList list; 485 QStringList list;
481 if ( dir. exists ( )) 486 if ( dir. exists ( ))
482 list = dir.entryList(); 487 list = dir.entryList();
483 QStringList::Iterator it; 488 QStringList::Iterator it;
484 for ( it = list.begin(); it != list.end(); ++it ) { 489 for ( it = list.begin(); it != list.end(); ++it ) {
485 ImageCodecInterface *iface = 0; 490 ImageCodecInterface *iface = 0;
486 QLibrary *lib = new QLibrary( path + "/" + *it ); 491 QLibrary *lib = new QLibrary( path + "/" + *it );
487 if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { 492 if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) {
488 QStringList formats = iface->keys(); 493 QStringList formats = iface->keys();
489 for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) { 494 for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) {
490 (void)iface->installIOHandler(*i); 495 (void)iface->installIOHandler(*i);
491 // ### it exists now; need to remember if we can delete it 496 // ### it exists now; need to remember if we can delete it
492 } 497 }
493 } 498 }
494 else { 499 else {
495 lib->unload(); 500 lib->unload();
496 delete lib; 501 delete lib;
497 } 502 }
498 } 503 }
499 } 504 }
500
501 Opie::Internal::RoHFeedback * RoH;
502}; 505};
503 506
504class ResourceMimeFactory : public QMimeSourceFactory 507class ResourceMimeFactory : public QMimeSourceFactory
505{ 508{
506public: 509public:
507 ResourceMimeFactory() : resImage( 0 ) 510 ResourceMimeFactory() : resImage( 0 )
508 { 511 {
509 setFilePath( Global::helpPath() ); 512 setFilePath( Global::helpPath() );
510 setExtensionType( "html", "text/html;charset=UTF-8" ); 513 setExtensionType( "html", "text/html;charset=UTF-8" );
511 } 514 }
512 ~ResourceMimeFactory() { 515 ~ResourceMimeFactory() {
513 delete resImage; 516 delete resImage;
514 } 517 }
515 518
516 const QMimeSource* data( const QString& abs_name ) const 519 const QMimeSource* data( const QString& abs_name ) const
517 { 520 {
518 const QMimeSource * r = QMimeSourceFactory::data( abs_name ); 521 const QMimeSource * r = QMimeSourceFactory::data( abs_name );
519 if ( !r ) { 522 if ( !r ) {
520 int sl = abs_name.length(); 523 int sl = abs_name.length();
521 do { 524 do {
522 sl = abs_name.findRev( '/', sl - 1 ); 525 sl = abs_name.findRev( '/', sl - 1 );
523 QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name; 526 QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name;
524 int dot = name.findRev( '.' ); 527 int dot = name.findRev( '.' );
525 if ( dot >= 0 ) 528 if ( dot >= 0 )
526 name = name.left( dot ); 529 name = name.left( dot );
527 QImage img = Resource::loadImage( name ); 530 QImage img = Resource::loadImage( name );
528 if ( !img.isNull() ) { 531 if ( !img.isNull() ) {
529 delete resImage; 532 delete resImage;
530 resImage = new QImageDrag( img ); 533 resImage = new QImageDrag( img );
531 r = resImage; 534 r = resImage;
532 } 535 }
533 } 536 }
534 while ( !r && sl > 0 ); 537 while ( !r && sl > 0 );
535 } 538 }
536 return r; 539 return r;
537 } 540 }
538private: 541private:
539 mutable QImageDrag *resImage; 542 mutable QImageDrag *resImage;
540}; 543};
541 544
542static int& hack(int& i) 545static int& hack(int& i)
543{ 546{
544#if QT_VERSION <= 230 && defined(QT_NO_CODECS) 547#if QT_VERSION <= 230 && defined(QT_NO_CODECS)
545 // These should be created, but aren't in Qt 2.3.0 548 // These should be created, but aren't in Qt 2.3.0
546 (void)new QUtf8Codec; 549 (void)new QUtf8Codec;
547 (void)new QUtf16Codec; 550 (void)new QUtf16Codec;
548#endif 551#endif
549 return i; 552 return i;
550} 553}
551 554
552static int muted = 0; 555static int muted = 0;
553static int micMuted = 0; 556static int micMuted = 0;
554 557
555static void setVolume( int t = 0, int percent = -1 ) 558static void setVolume( int t = 0, int percent = -1 )
556{ 559{
557 switch ( t ) { 560 switch ( t ) {
558 case 0: { 561 case 0: {
559 Config cfg( "qpe" ); 562 Config cfg( "qpe" );
560 cfg.setGroup( "Volume" ); 563 cfg.setGroup( "Volume" );
561 if ( percent < 0 ) 564 if ( percent < 0 )
562 percent = cfg.readNumEntry( "VolumePercent", 50 ); 565 percent = cfg.readNumEntry( "VolumePercent", 50 );
563#ifndef QT_NO_SOUND 566#ifndef QT_NO_SOUND
564 int fd = 0; 567 int fd = 0;
565 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { 568 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) {
566 int vol = muted ? 0 : percent; 569 int vol = muted ? 0 : percent;
567 // set both channels to same volume 570 // set both channels to same volume
568 vol |= vol << 8; 571 vol |= vol << 8;
569 ioctl( fd, MIXER_WRITE( SOUND_MIXER_VOLUME ), &vol ); 572 ioctl( fd, MIXER_WRITE( SOUND_MIXER_VOLUME ), &vol );
570 ::close( fd ); 573 ::close( fd );
571 } 574 }
572#endif 575#endif
573 } 576 }
574 break; 577 break;
575 } 578 }
576} 579}
577 580
578static void setMic( int t = 0, int percent = -1 ) 581static void setMic( int t = 0, int percent = -1 )
579{ 582{
580 switch ( t ) { 583 switch ( t ) {
581 case 0: { 584 case 0: {
582 Config cfg( "qpe" ); 585 Config cfg( "qpe" );
583 cfg.setGroup( "Volume" ); 586 cfg.setGroup( "Volume" );
584 if ( percent < 0 ) 587 if ( percent < 0 )
585 percent = cfg.readNumEntry( "Mic", 50 ); 588 percent = cfg.readNumEntry( "Mic", 50 );
586 589
587#ifndef QT_NO_SOUND 590#ifndef QT_NO_SOUND
588 int fd = 0; 591 int fd = 0;
589 int mic = micMuted ? 0 : percent; 592 int mic = micMuted ? 0 : percent;
590 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { 593 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) {
591 ioctl( fd, MIXER_WRITE( SOUND_MIXER_MIC ), &mic ); 594 ioctl( fd, MIXER_WRITE( SOUND_MIXER_MIC ), &mic );
592 ::close( fd ); 595 ::close( fd );
593 } 596 }
594#endif 597#endif
595 } 598 }
596 break; 599 break;
597 } 600 }
598} 601}
599 602
600 603
601static void setBass( int t = 0, int percent = -1 ) 604static void setBass( int t = 0, int percent = -1 )
602{ 605{
603 switch ( t ) { 606 switch ( t ) {
604 case 0: { 607 case 0: {
605 Config cfg( "qpe" ); 608 Config cfg( "qpe" );
606 cfg.setGroup( "Volume" ); 609 cfg.setGroup( "Volume" );
607 if ( percent < 0 ) 610 if ( percent < 0 )
608 percent = cfg.readNumEntry( "BassPercent", 50 ); 611 percent = cfg.readNumEntry( "BassPercent", 50 );
609 612
610#ifndef QT_NO_SOUND 613#ifndef QT_NO_SOUND
611 int fd = 0; 614 int fd = 0;
612 int bass = percent; 615 int bass = percent;
613 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { 616 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) {
614 ioctl( fd, MIXER_WRITE( SOUND_MIXER_BASS ), &bass ); 617 ioctl( fd, MIXER_WRITE( SOUND_MIXER_BASS ), &bass );
615 ::close( fd ); 618 ::close( fd );
616 } 619 }
617#endif 620#endif
618 } 621 }
619 break; 622 break;
620 } 623 }
621} 624}
622 625
623 626
624static void setTreble( int t = 0, int percent = -1 ) 627static void setTreble( int t = 0, int percent = -1 )
625{ 628{
626 switch ( t ) { 629 switch ( t ) {
627 case 0: { 630 case 0: {
628 Config cfg( "qpe" ); 631 Config cfg( "qpe" );
629 cfg.setGroup( "Volume" ); 632 cfg.setGroup( "Volume" );
630 if ( percent < 0 ) 633 if ( percent < 0 )
631 percent = cfg.readNumEntry( "TreblePercent", 50 ); 634 percent = cfg.readNumEntry( "TreblePercent", 50 );
632 635
633#ifndef QT_NO_SOUND 636#ifndef QT_NO_SOUND
634 int fd = 0; 637 int fd = 0;
635 int treble = percent; 638 int treble = percent;
636 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { 639 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) {
637 ioctl( fd, MIXER_WRITE( SOUND_MIXER_TREBLE ), &treble ); 640 ioctl( fd, MIXER_WRITE( SOUND_MIXER_TREBLE ), &treble );
638 ::close( fd ); 641 ::close( fd );
639 } 642 }
640#endif 643#endif
641 } 644 }
642 break; 645 break;
643 } 646 }
644} 647}
645 648
646 649
647/** 650/**
648 \class QPEApplication 651 \class QPEApplication
649 \brief The QPEApplication class implements various system services 652 \brief The QPEApplication class implements various system services
650 that are available to all Qtopia applications. 653 that are available to all Qtopia applications.
651 654
652 Simply by using QPEApplication instead of QApplication, a standard Qt 655 Simply by using QPEApplication instead of QApplication, a standard Qt
653 application becomes a Qtopia application. It automatically follows 656 application becomes a Qtopia application. It automatically follows
654 style changes, quits and raises, and in the 657 style changes, quits and raises, and in the
655 case of \link docwidget.html document-oriented\endlink applications, 658 case of \link docwidget.html document-oriented\endlink applications,
656 changes the currently displayed document in response to the environment. 659 changes the currently displayed document in response to the environment.
657 660
658 To create a \link docwidget.html document-oriented\endlink 661 To create a \link docwidget.html document-oriented\endlink
659 application use showMainDocumentWidget(); to create a 662 application use showMainDocumentWidget(); to create a
660 non-document-oriented application use showMainWidget(). The 663 non-document-oriented application use showMainWidget(). The
661 keepRunning() function indicates whether the application will 664 keepRunning() function indicates whether the application will
662 continue running after it's processed the last \link qcop.html 665 continue running after it's processed the last \link qcop.html
663 QCop\endlink message. This can be changed using setKeepRunning(). 666 QCop\endlink message. This can be changed using setKeepRunning().
664 667
665 A variety of signals are emitted when certain events occur, for 668 A variety of signals are emitted when certain events occur, for
666 example, timeChanged(), clockChanged(), weekChanged(), 669 example, timeChanged(), clockChanged(), weekChanged(),
667 dateFormatChanged() and volumeChanged(). If the application receives 670 dateFormatChanged() and volumeChanged(). If the application receives
668 a \link qcop.html QCop\endlink message on the application's 671 a \link qcop.html QCop\endlink message on the application's
669 QPE/Application/\e{appname} channel, the appMessage() signal is 672 QPE/Application/\e{appname} channel, the appMessage() signal is
670 emitted. There are also flush() and reload() signals, which 673 emitted. There are also flush() and reload() signals, which
671 are emitted when synching begins and ends respectively - upon these 674 are emitted when synching begins and ends respectively - upon these
672 signals, the application should save and reload any data 675 signals, the application should save and reload any data
673 files that are involved in synching. Most of these signals will initially 676 files that are involved in synching. Most of these signals will initially
674 be received and unfiltered through the appMessage() signal. 677 be received and unfiltered through the appMessage() signal.
675 678
676 This class also provides a set of useful static functions. The 679 This class also provides a set of useful static functions. The
677 qpeDir() and documentDir() functions return the respective paths. 680 qpeDir() and documentDir() functions return the respective paths.
678 The grabKeyboard() and ungrabKeyboard() functions are used to 681 The grabKeyboard() and ungrabKeyboard() functions are used to
679 control whether the application takes control of the device's 682 control whether the application takes control of the device's
680 physical buttons (e.g. application launch keys). The stylus' mode of 683 physical buttons (e.g. application launch keys). The stylus' mode of
681 operation is set with setStylusOperation() and retrieved with 684 operation is set with setStylusOperation() and retrieved with
682 stylusOperation(). There are also setInputMethodHint() and 685 stylusOperation(). There are also setInputMethodHint() and
683 inputMethodHint() functions. 686 inputMethodHint() functions.
684 687
685 \ingroup qtopiaemb 688 \ingroup qtopiaemb
686*/ 689*/
687 690
688/*! 691/*!
689 \fn void QPEApplication::clientMoused() 692 \fn void QPEApplication::clientMoused()
690 693
691 \internal 694 \internal
692*/ 695*/
693 696
@@ -1023,385 +1026,387 @@ void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode )
1023 ( w ); 1026 ( w );
1024 } 1027 }
1025 else { 1028 else {
1026 inputMethodDict->insert( w, ( void* ) mode ); 1029 inputMethodDict->insert( w, ( void* ) mode );
1027 } 1030 }
1028} 1031}
1029 1032
1030class HackDialog : public QDialog 1033class HackDialog : public QDialog
1031{ 1034{
1032public: 1035public:
1033 void acceptIt() 1036 void acceptIt()
1034 { 1037 {
1035 accept(); 1038 accept();
1036 } 1039 }
1037 void rejectIt() 1040 void rejectIt()
1038 { 1041 {
1039 reject(); 1042 reject();
1040 } 1043 }
1041}; 1044};
1042 1045
1043 1046
1044void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key ) 1047void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key )
1045{ 1048{
1046 // specialised actions for certain widgets. May want to 1049 // specialised actions for certain widgets. May want to
1047 // add more stuff here. 1050 // add more stuff here.
1048 if ( activePopupWidget() && activePopupWidget() ->inherits( "QListBox" ) 1051 if ( activePopupWidget() && activePopupWidget() ->inherits( "QListBox" )
1049 && activePopupWidget() ->parentWidget() 1052 && activePopupWidget() ->parentWidget()
1050 && activePopupWidget() ->parentWidget() ->inherits( "QComboBox" ) ) 1053 && activePopupWidget() ->parentWidget() ->inherits( "QComboBox" ) )
1051 key = Qt::Key_Return; 1054 key = Qt::Key_Return;
1052 1055
1053 if ( activePopupWidget() && activePopupWidget() ->inherits( "QPopupMenu" ) ) 1056 if ( activePopupWidget() && activePopupWidget() ->inherits( "QPopupMenu" ) )
1054 key = Qt::Key_Return; 1057 key = Qt::Key_Return;
1055 1058
1056#ifdef QWS 1059#ifdef QWS
1057 1060
1058 ke->simpleData.keycode = key; 1061 ke->simpleData.keycode = key;
1059#endif 1062#endif
1060} 1063}
1061 1064
1062 1065
1063/*! 1066/*!
1064 \internal 1067 \internal
1065*/ 1068*/
1066 1069
1067#ifdef QWS 1070#ifdef QWS
1068bool QPEApplication::qwsEventFilter( QWSEvent * e ) 1071bool QPEApplication::qwsEventFilter( QWSEvent * e )
1069{ 1072{
1070 if ( !d->notbusysent && e->type == QWSEvent::Focus ) { 1073 if ( !d->notbusysent && e->type == QWSEvent::Focus ) {
1071 if ( qApp->type() != QApplication::GuiServer ) { 1074 if ( qApp->type() != QApplication::GuiServer ) {
1072 QCopEnvelope e( "QPE/System", "notBusy(QString)" ); 1075 QCopEnvelope e( "QPE/System", "notBusy(QString)" );
1073 e << d->appName; 1076 e << d->appName;
1074 } 1077 }
1075 d->notbusysent = TRUE; 1078 d->notbusysent = TRUE;
1076 } 1079 }
1077 if ( type() == GuiServer ) { 1080 if ( type() == GuiServer ) {
1078 switch ( e->type ) { 1081 switch ( e->type ) {
1079 case QWSEvent::Mouse: 1082 case QWSEvent::Mouse:
1080 if ( e->asMouse() ->simpleData.state && !QWidget::find( e->window() ) ) 1083 if ( e->asMouse() ->simpleData.state && !QWidget::find( e->window() ) )
1081 emit clientMoused(); 1084 emit clientMoused();
1082 break; 1085 break;
1083 default: 1086 default:
1084 break; 1087 break;
1085 } 1088 }
1086 } 1089 }
1087 if ( e->type == QWSEvent::Key ) { 1090 if ( e->type == QWSEvent::Key ) {
1088 QWSKeyEvent *ke = ( QWSKeyEvent * ) e; 1091 QWSKeyEvent *ke = ( QWSKeyEvent * ) e;
1089 if ( ke->simpleData.keycode == Qt::Key_F33 ) { 1092 if ( ke->simpleData.keycode == Qt::Key_F33 ) {
1090 // Use special "OK" key to press "OK" on top level widgets 1093 // Use special "OK" key to press "OK" on top level widgets
1091 QWidget * active = activeWindow(); 1094 QWidget * active = activeWindow();
1092 QWidget *popup = 0; 1095 QWidget *popup = 0;
1093 if ( active && active->isPopup() ) { 1096 if ( active && active->isPopup() ) {
1094 popup = active; 1097 popup = active;
1095 active = active->parentWidget(); 1098 active = active->parentWidget();
1096 } 1099 }
1097 if ( active && ( int ) active->winId() == ke->simpleData.window && 1100 if ( active && ( int ) active->winId() == ke->simpleData.window &&
1098 !active->testWFlags( WStyle_Customize | WType_Popup | WType_Desktop ) ) { 1101 !active->testWFlags( WStyle_Customize | WType_Popup | WType_Desktop ) ) {
1099 if ( ke->simpleData.is_press ) { 1102 if ( ke->simpleData.is_press ) {
1100 if ( popup ) 1103 if ( popup )
1101 popup->close(); 1104 popup->close();
1102 if ( active->inherits( "QDialog" ) ) { 1105 if ( active->inherits( "QDialog" ) ) {
1103 HackDialog * d = ( HackDialog * ) active; 1106 HackDialog * d = ( HackDialog * ) active;
1104 d->acceptIt(); 1107 d->acceptIt();
1105 return TRUE; 1108 return TRUE;
1106 } 1109 }
1107 else if ( ( ( HackWidget * ) active ) ->needsOk() ) { 1110 else if ( ( ( HackWidget * ) active ) ->needsOk() ) {
1108 QSignal s; 1111 QSignal s;
1109 s.connect( active, SLOT( accept() ) ); 1112 s.connect( active, SLOT( accept() ) );
1110 s.activate(); 1113 s.activate();
1111 } 1114 }
1112 else { 1115 else {
1113 // do the same as with the select key: Map to the default action of the widget: 1116 // do the same as with the select key: Map to the default action of the widget:
1114 mapToDefaultAction( ke, Qt::Key_Return ); 1117 mapToDefaultAction( ke, Qt::Key_Return );
1115 } 1118 }
1116 } 1119 }
1117 } 1120 }
1118 } 1121 }
1119 else if ( ke->simpleData.keycode == Qt::Key_F30 ) { 1122 else if ( ke->simpleData.keycode == Qt::Key_F30 ) {
1120 // Use special "select" key to do whatever default action a widget has 1123 // Use special "select" key to do whatever default action a widget has
1121 mapToDefaultAction( ke, Qt::Key_Space ); 1124 mapToDefaultAction( ke, Qt::Key_Space );
1122 } 1125 }
1123 else if ( ke->simpleData.keycode == Qt::Key_Escape && 1126 else if ( ke->simpleData.keycode == Qt::Key_Escape &&
1124 ke->simpleData.is_press ) { 1127 ke->simpleData.is_press ) {
1125 // Escape key closes app if focus on toplevel 1128 // Escape key closes app if focus on toplevel
1126 QWidget * active = activeWindow(); 1129 QWidget * active = activeWindow();
1127 if ( active && active->testWFlags( WType_TopLevel ) && 1130 if ( active && active->testWFlags( WType_TopLevel ) &&
1128 ( int ) active->winId() == ke->simpleData.window && 1131 ( int ) active->winId() == ke->simpleData.window &&
1129 !active->testWFlags( WStyle_Dialog | WStyle_Customize | WType_Popup | WType_Desktop ) ) { 1132 !active->testWFlags( WStyle_Dialog | WStyle_Customize | WType_Popup | WType_Desktop ) ) {
1130 if ( active->inherits( "QDialog" ) ) { 1133 if ( active->inherits( "QDialog" ) ) {
1131 HackDialog * d = ( HackDialog * ) active; 1134 HackDialog * d = ( HackDialog * ) active;
1132 d->rejectIt(); 1135 d->rejectIt();
1133 return TRUE; 1136 return TRUE;
1134 } else /*if ( strcmp( argv() [ 0 ], "embeddedkonsole" ) != 0 )*/ { 1137 } else /*if ( strcmp( argv() [ 0 ], "embeddedkonsole" ) != 0 )*/ {
1135 active->close(); 1138 active->close();
1136 } 1139 }
1137 } 1140 }
1138 1141
1139 } 1142 }
1140 else if ( ke->simpleData.keycode >= Qt::Key_F1 && ke->simpleData.keycode <= Qt::Key_F29 ) { 1143 else if ( ke->simpleData.keycode >= Qt::Key_F1 && ke->simpleData.keycode <= Qt::Key_F29 ) {
1141 // this should be if ( ODevice::inst ( )-> buttonForKeycode ( ... )) 1144 // this should be if ( ODevice::inst ( )-> buttonForKeycode ( ... ))
1142 // but we cannot access libopie function within libqpe :( 1145 // but we cannot access libopie function within libqpe :(
1143 1146
1144 QWidget * active = activeWindow ( ); 1147 QWidget * active = activeWindow ( );
1145 if ( active && ((int) active-> winId ( ) == ke-> simpleData.window )) { 1148 if ( active && ((int) active-> winId ( ) == ke-> simpleData.window )) {
1146 if ( d-> kbgrabbed ) { // we grabbed the keyboard 1149 if ( d-> kbgrabbed ) { // we grabbed the keyboard
1147 QChar ch ( ke-> simpleData.unicode ); 1150 QChar ch ( ke-> simpleData.unicode );
1148 QKeyEvent qke ( ke-> simpleData. is_press ? QEvent::KeyPress : QEvent::KeyRelease, 1151 QKeyEvent qke ( ke-> simpleData. is_press ? QEvent::KeyPress : QEvent::KeyRelease,
1149 ke-> simpleData.keycode, 1152 ke-> simpleData.keycode,
1150 ch. latin1 ( ), 1153 ch. latin1 ( ),
1151 ke-> simpleData.modifiers, 1154 ke-> simpleData.modifiers,
1152 QString ( ch ), 1155 QString ( ch ),
1153 ke-> simpleData.is_auto_repeat, 1 ); 1156 ke-> simpleData.is_auto_repeat, 1 );
1154 1157
1155 QObject *which = QWidget::keyboardGrabber ( ); 1158 QObject *which = QWidget::keyboardGrabber ( );
1156 if ( !which ) 1159 if ( !which )
1157 which = QApplication::focusWidget ( ); 1160 which = QApplication::focusWidget ( );
1158 if ( !which ) 1161 if ( !which )
1159 which = QApplication::activeWindow ( ); 1162 which = QApplication::activeWindow ( );
1160 if ( !which ) 1163 if ( !which )
1161 which = qApp; 1164 which = qApp;
1162 1165
1163 QApplication::sendEvent ( which, &qke ); 1166 QApplication::sendEvent ( which, &qke );
1164 } 1167 }
1165 else { // we didn't grab the keyboard, so send the event to the launcher 1168 else { // we didn't grab the keyboard, so send the event to the launcher
1166 QCopEnvelope e ( "QPE/Launcher", "deviceButton(int,int,int)" ); 1169 QCopEnvelope e ( "QPE/Launcher", "deviceButton(int,int,int)" );
1167 e << int( ke-> simpleData.keycode ) << int( ke-> simpleData. is_press ) << int( ke-> simpleData.is_auto_repeat ); 1170 e << int( ke-> simpleData.keycode ) << int( ke-> simpleData. is_press ) << int( ke-> simpleData.is_auto_repeat );
1168 } 1171 }
1169 } 1172 }
1170 return true; 1173 return true;
1171 } 1174 }
1172 } 1175 }
1173 if ( e->type == QWSEvent::Focus ) { 1176 if ( e->type == QWSEvent::Focus ) {
1174 QWSFocusEvent * fe = ( QWSFocusEvent* ) e; 1177 QWSFocusEvent * fe = ( QWSFocusEvent* ) e;
1175 if ( !fe->simpleData.get_focus ) { 1178 if ( !fe->simpleData.get_focus ) {
1176 QWidget * active = activeWindow(); 1179 QWidget * active = activeWindow();
1177 while ( active && active->isPopup() ) { 1180 while ( active && active->isPopup() ) {
1178 active->close(); 1181 active->close();
1179 active = activeWindow(); 1182 active = activeWindow();
1180 } 1183 }
1181 } 1184 }
1182 else { 1185 else {
1183 // make sure our modal widget is ALWAYS on top 1186 // make sure our modal widget is ALWAYS on top
1184 QWidget *topm = activeModalWidget(); 1187 QWidget *topm = activeModalWidget();
1185 if ( topm && static_cast<int>( topm->winId() ) != fe->simpleData.window) { 1188 if ( topm && static_cast<int>( topm->winId() ) != fe->simpleData.window) {
1186 topm->raise(); 1189 topm->raise();
1187 } 1190 }
1188 } 1191 }
1189 if ( fe->simpleData.get_focus && inputMethodDict ) { 1192 if ( fe->simpleData.get_focus && inputMethodDict ) {
1190 InputMethodHint m = inputMethodHint( QWidget::find( e->window() ) ); 1193 InputMethodHint m = inputMethodHint( QWidget::find( e->window() ) );
1191 if ( m == AlwaysOff ) 1194 if ( m == AlwaysOff )
1192 Global::hideInputMethod(); 1195 Global::hideInputMethod();
1193 if ( m == AlwaysOn ) 1196 if ( m == AlwaysOn )
1194 Global::showInputMethod(); 1197 Global::showInputMethod();
1195 } 1198 }
1196 } 1199 }
1197 1200
1198 1201
1199 return QApplication::qwsEventFilter( e ); 1202 return QApplication::qwsEventFilter( e );
1200} 1203}
1201#endif 1204#endif
1202 1205
1203/*! 1206/*!
1204 Destroys the QPEApplication. 1207 Destroys the QPEApplication.
1205*/ 1208*/
1206QPEApplication::~QPEApplication() 1209QPEApplication::~QPEApplication()
1207{ 1210{
1208 ungrabKeyboard(); 1211 ungrabKeyboard();
1209#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 1212#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
1210 // Need to delete QCopChannels early, since the display will 1213 // Need to delete QCopChannels early, since the display will
1211 // be gone by the time we get to ~QObject(). 1214 // be gone by the time we get to ~QObject().
1212 delete sysChannel; 1215 delete sysChannel;
1213 delete pidChannel; 1216 delete pidChannel;
1214#endif 1217#endif
1218#ifdef OPIE_ROHFEEDBACK
1215 delete d->RoH; 1219 delete d->RoH;
1220#endif
1216 delete d; 1221 delete d;
1217} 1222}
1218 1223
1219/*! 1224/*!
1220 Returns <tt>$OPIEDIR/</tt>. 1225 Returns <tt>$OPIEDIR/</tt>.
1221*/ 1226*/
1222QString QPEApplication::qpeDir() 1227QString QPEApplication::qpeDir()
1223{ 1228{
1224 const char * base = getenv( "OPIEDIR" ); 1229 const char * base = getenv( "OPIEDIR" );
1225 if ( base ) 1230 if ( base )
1226 return QString( base ) + "/"; 1231 return QString( base ) + "/";
1227 1232
1228 return QString( "../" ); 1233 return QString( "../" );
1229} 1234}
1230 1235
1231/*! 1236/*!
1232 Returns the user's current Document directory. There is a trailing "/". 1237 Returns the user's current Document directory. There is a trailing "/".
1233 .. well, it does now,, and there's no trailing '/' 1238 .. well, it does now,, and there's no trailing '/'
1234*/ 1239*/
1235QString QPEApplication::documentDir() 1240QString QPEApplication::documentDir()
1236{ 1241{
1237 const char* base = getenv( "HOME"); 1242 const char* base = getenv( "HOME");
1238 if ( base ) 1243 if ( base )
1239 return QString( base ) + "/Documents"; 1244 return QString( base ) + "/Documents";
1240 1245
1241 return QString( "../Documents" ); 1246 return QString( "../Documents" );
1242} 1247}
1243 1248
1244static int deforient = -1; 1249static int deforient = -1;
1245 1250
1246/*! 1251/*!
1247 \internal 1252 \internal
1248*/ 1253*/
1249int QPEApplication::defaultRotation() 1254int QPEApplication::defaultRotation()
1250{ 1255{
1251 if ( deforient < 0 ) { 1256 if ( deforient < 0 ) {
1252 QString d = getenv( "QWS_DISPLAY" ); 1257 QString d = getenv( "QWS_DISPLAY" );
1253 if ( d.contains( "Rot90" ) ) { 1258 if ( d.contains( "Rot90" ) ) {
1254 deforient = 90; 1259 deforient = 90;
1255 } 1260 }
1256 else if ( d.contains( "Rot180" ) ) { 1261 else if ( d.contains( "Rot180" ) ) {
1257 deforient = 180; 1262 deforient = 180;
1258 } 1263 }
1259 else if ( d.contains( "Rot270" ) ) { 1264 else if ( d.contains( "Rot270" ) ) {
1260 deforient = 270; 1265 deforient = 270;
1261 } 1266 }
1262 else { 1267 else {
1263 deforient = 0; 1268 deforient = 0;
1264 } 1269 }
1265 } 1270 }
1266 return deforient; 1271 return deforient;
1267} 1272}
1268 1273
1269/*! 1274/*!
1270 \internal 1275 \internal
1271*/ 1276*/
1272void QPEApplication::setDefaultRotation( int r ) 1277void QPEApplication::setDefaultRotation( int r )
1273{ 1278{
1274 if ( qApp->type() == GuiServer ) { 1279 if ( qApp->type() == GuiServer ) {
1275 deforient = r; 1280 deforient = r;
1276 setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 ); 1281 setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 );
1277 Config config("qpe"); 1282 Config config("qpe");
1278 config.setGroup( "Rotation" ); 1283 config.setGroup( "Rotation" );
1279 config.writeEntry( "Rot", r ); 1284 config.writeEntry( "Rot", r );
1280 } 1285 }
1281 else { 1286 else {
1282#ifndef QT_NO_COP 1287#ifndef QT_NO_COP
1283 { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" ); 1288 { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" );
1284 e << r; 1289 e << r;
1285 } 1290 }
1286#endif 1291#endif
1287 1292
1288 } 1293 }
1289} 1294}
1290 1295
1291#include <qgfx_qws.h> 1296#include <qgfx_qws.h>
1292#include <qwindowsystem_qws.h> 1297#include <qwindowsystem_qws.h>
1293 1298
1294#if QT_VERSION > 236 1299#if QT_VERSION > 236
1295extern void qws_clearLoadedFonts(); 1300extern void qws_clearLoadedFonts();
1296#endif 1301#endif
1297 1302
1298void QPEApplication::setCurrentMode( int x, int y, int depth ) 1303void QPEApplication::setCurrentMode( int x, int y, int depth )
1299{ 1304{
1300 // Reset the caches 1305 // Reset the caches
1301#if QT_VERSION > 236 1306#if QT_VERSION > 236
1302 qws_clearLoadedFonts(); 1307 qws_clearLoadedFonts();
1303#endif 1308#endif
1304 QPixmapCache::clear(); 1309 QPixmapCache::clear();
1305 1310
1306 // Change the screen mode 1311 // Change the screen mode
1307 qt_screen->setMode(x, y, depth); 1312 qt_screen->setMode(x, y, depth);
1308 1313
1309 if ( qApp->type() == GuiServer ) { 1314 if ( qApp->type() == GuiServer ) {
1310#if QT_VERSION > 236 1315#if QT_VERSION > 236
1311 // Reconfigure the GuiServer 1316 // Reconfigure the GuiServer
1312 qwsServer->beginDisplayReconfigure(); 1317 qwsServer->beginDisplayReconfigure();
1313 qwsServer->endDisplayReconfigure(); 1318 qwsServer->endDisplayReconfigure();
1314#endif 1319#endif
1315 // Get all the running apps to reset 1320 // Get all the running apps to reset
1316 QCopEnvelope env( "QPE/System", "reset()" ); 1321 QCopEnvelope env( "QPE/System", "reset()" );
1317 } 1322 }
1318} 1323}
1319 1324
1320void QPEApplication::reset() { 1325void QPEApplication::reset() {
1321 // Reconnect to the screen 1326 // Reconnect to the screen
1322 qt_screen->disconnect(); 1327 qt_screen->disconnect();
1323 qt_screen->connect( QString::null ); 1328 qt_screen->connect( QString::null );
1324 1329
1325 // Redraw everything 1330 // Redraw everything
1326 applyStyle(); 1331 applyStyle();
1327} 1332}
1328 1333
1329#if (QT_VERSION < 238) && defined Q_OS_MACX 1334#if (QT_VERSION < 238) && defined Q_OS_MACX
1330bool qt_left_hand_scrollbars = false; 1335bool qt_left_hand_scrollbars = false;
1331#else 1336#else
1332#ifdef Q_OS_MACX 1337#ifdef Q_OS_MACX
1333#define WEAK_SYMBOL __attribute__((weak_import)) 1338#define WEAK_SYMBOL __attribute__((weak_import))
1334#else 1339#else
1335#define WEAK_SYMBOL __attribute__((weak)) 1340#define WEAK_SYMBOL __attribute__((weak))
1336#endif 1341#endif
1337extern bool qt_left_hand_scrollbars WEAK_SYMBOL; 1342extern bool qt_left_hand_scrollbars WEAK_SYMBOL;
1338#endif 1343#endif
1339 1344
1340/*! 1345/*!
1341 \internal 1346 \internal
1342*/ 1347*/
1343void QPEApplication::applyStyle() 1348void QPEApplication::applyStyle()
1344{ 1349{
1345 Config config( "qpe" ); 1350 Config config( "qpe" );
1346 config.setGroup( "Appearance" ); 1351 config.setGroup( "Appearance" );
1347 1352
1348#if QT_VERSION > 233 1353#if QT_VERSION > 233
1349#if !defined(OPIE_NO_OVERRIDE_QT) 1354#if !defined(OPIE_NO_OVERRIDE_QT)
1350 // don't block ourselves ... 1355 // don't block ourselves ...
1351 Opie::force_appearance = 0; 1356 Opie::force_appearance = 0;
1352 1357
1353 static QString appname = Opie::binaryName ( ); 1358 static QString appname = Opie::binaryName ( );
1354 1359
1355 QStringList ex = config. readListEntry ( "NoStyle", ';' ); 1360 QStringList ex = config. readListEntry ( "NoStyle", ';' );
1356 int nostyle = 0; 1361 int nostyle = 0;
1357 for ( QStringList::Iterator it = ex. begin ( ); it != ex. end ( ); ++it ) { 1362 for ( QStringList::Iterator it = ex. begin ( ); it != ex. end ( ); ++it ) {
1358 if ( QRegExp (( *it ). mid ( 1 ), false, true ). find ( appname, 0 ) >= 0 ) { 1363 if ( QRegExp (( *it ). mid ( 1 ), false, true ). find ( appname, 0 ) >= 0 ) {
1359 nostyle = ( *it ). left ( 1 ). toInt ( 0, 32 ); 1364 nostyle = ( *it ). left ( 1 ). toInt ( 0, 32 );
1360 break; 1365 break;
1361 } 1366 }
1362 } 1367 }
1363#else 1368#else
1364 int nostyle = 0; 1369 int nostyle = 0;
1365#endif 1370#endif
1366 1371
1367 // Widget style 1372 // Widget style
1368 QString style = config.readEntry( "Style", "FlatStyle" ); 1373 QString style = config.readEntry( "Style", "FlatStyle" );
1369 1374
1370 // don't set a custom style 1375 // don't set a custom style
1371 if ( nostyle & Opie::Force_Style ) 1376 if ( nostyle & Opie::Force_Style )
1372 style = "FlatStyle"; 1377 style = "FlatStyle";
1373 1378
1374 internalSetStyle ( style ); 1379 internalSetStyle ( style );
1375 1380
1376 // Colors - from /etc/colors/Liquid.scheme 1381 // Colors - from /etc/colors/Liquid.scheme
1377 QColor bgcolor( config.readEntry( "Background", "#E0E0E0" ) ); 1382 QColor bgcolor( config.readEntry( "Background", "#E0E0E0" ) );
1378 QColor btncolor( config.readEntry( "Button", "#96c8fa" ) ); 1383 QColor btncolor( config.readEntry( "Button", "#96c8fa" ) );
1379 QPalette pal( btncolor, bgcolor ); 1384 QPalette pal( btncolor, bgcolor );
1380 QString color = config.readEntry( "Highlight", "#73adef" ); 1385 QString color = config.readEntry( "Highlight", "#73adef" );
1381 pal.setColor( QColorGroup::Highlight, QColor( color ) ); 1386 pal.setColor( QColorGroup::Highlight, QColor( color ) );
1382 color = config.readEntry( "HighlightedText", "#FFFFFF" ); 1387 color = config.readEntry( "HighlightedText", "#FFFFFF" );
1383 pal.setColor( QColorGroup::HighlightedText, QColor( color ) ); 1388 pal.setColor( QColorGroup::HighlightedText, QColor( color ) );
1384 color = config.readEntry( "Text", "#000000" ); 1389 color = config.readEntry( "Text", "#000000" );
1385 pal.setColor( QColorGroup::Text, QColor( color ) ); 1390 pal.setColor( QColorGroup::Text, QColor( color ) );
1386 color = config.readEntry( "ButtonText", "#000000" ); 1391 color = config.readEntry( "ButtonText", "#000000" );
1387 pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) ); 1392 pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) );
1388 color = config.readEntry( "Base", "#FFFFFF" ); 1393 color = config.readEntry( "Base", "#FFFFFF" );
1389 pal.setColor( QColorGroup::Base, QColor( color ) ); 1394 pal.setColor( QColorGroup::Base, QColor( color ) );
1390 1395
1391 pal.setColor( QPalette::Disabled, QColorGroup::Text, 1396 pal.setColor( QPalette::Disabled, QColorGroup::Text,
1392 pal.color( QPalette::Active, QColorGroup::Background ).dark() ); 1397 pal.color( QPalette::Active, QColorGroup::Background ).dark() );
1393 1398
1394 setPalette( pal, TRUE ); 1399 setPalette( pal, TRUE );
1395 1400
1396 1401
1397 // Set the ScrollBar on the 'right' side but only if the weak symbol is present 1402 // Set the ScrollBar on the 'right' side but only if the weak symbol is present
1398 if (&qt_left_hand_scrollbars ) 1403 if (&qt_left_hand_scrollbars )
1399 qt_left_hand_scrollbars = config.readBoolEntry( "LeftHand", false ); 1404 qt_left_hand_scrollbars = config.readBoolEntry( "LeftHand", false );
1400 1405
1401 // Window Decoration 1406 // Window Decoration
1402 QString dec = config.readEntry( "Decoration", "Flat" ); 1407 QString dec = config.readEntry( "Decoration", "Flat" );
1403 1408
1404 // don't set a custom deco 1409 // don't set a custom deco
1405 if ( nostyle & Opie::Force_Decoration ) 1410 if ( nostyle & Opie::Force_Decoration )
1406 dec = ""; 1411 dec = "";
1407 1412
@@ -1846,468 +1851,470 @@ void QPEApplication::internalSetStyle( const QString &style )
1846 if ( s ) 1851 if ( s )
1847 setStyle( s ); 1852 setStyle( s );
1848 } 1853 }
1849#else 1854#else
1850 if ( style == "Windows" ) { 1855 if ( style == "Windows" ) {
1851 setStyle( new QWindowsStyle ); 1856 setStyle( new QWindowsStyle );
1852 } 1857 }
1853 else if ( style == "QPE" ) { 1858 else if ( style == "QPE" ) {
1854 setStyle( new QPEStyle ); 1859 setStyle( new QPEStyle );
1855 } 1860 }
1856 else if ( style == "Light" ) { 1861 else if ( style == "Light" ) {
1857 setStyle( new LightStyle ); 1862 setStyle( new LightStyle );
1858 } 1863 }
1859#ifndef QT_NO_STYLE_PLATINUM 1864#ifndef QT_NO_STYLE_PLATINUM
1860 else if ( style == "Platinum" ) { 1865 else if ( style == "Platinum" ) {
1861 setStyle( new QPlatinumStyle ); 1866 setStyle( new QPlatinumStyle );
1862 } 1867 }
1863#endif 1868#endif
1864#ifndef QT_NO_STYLE_MOTIF 1869#ifndef QT_NO_STYLE_MOTIF
1865 else if ( style == "Motif" ) { 1870 else if ( style == "Motif" ) {
1866 setStyle( new QMotifStyle ); 1871 setStyle( new QMotifStyle );
1867 } 1872 }
1868#endif 1873#endif
1869#ifndef QT_NO_STYLE_MOTIFPLUS 1874#ifndef QT_NO_STYLE_MOTIFPLUS
1870 else if ( style == "MotifPlus" ) { 1875 else if ( style == "MotifPlus" ) {
1871 setStyle( new QMotifPlusStyle ); 1876 setStyle( new QMotifPlusStyle );
1872 } 1877 }
1873#endif 1878#endif
1874 1879
1875 else { 1880 else {
1876 QStyle *sty = 0; 1881 QStyle *sty = 0;
1877 QString path = QPEApplication::qpeDir ( ) + "/plugins/styles/"; 1882 QString path = QPEApplication::qpeDir ( ) + "/plugins/styles/";
1878 1883
1879#ifdef Q_OS_MACX 1884#ifdef Q_OS_MACX
1880 if ( style. find ( ".dylib" ) > 0 ) 1885 if ( style. find ( ".dylib" ) > 0 )
1881 path += style; 1886 path += style;
1882 else 1887 else
1883 path = path + "lib" + style. lower ( ) + ".dylib"; // compatibility 1888 path = path + "lib" + style. lower ( ) + ".dylib"; // compatibility
1884#else 1889#else
1885 if ( style. find ( ".so" ) > 0 ) 1890 if ( style. find ( ".so" ) > 0 )
1886 path += style; 1891 path += style;
1887 else 1892 else
1888 path = path + "lib" + style. lower ( ) + ".so"; // compatibility 1893 path = path + "lib" + style. lower ( ) + ".so"; // compatibility
1889#endif 1894#endif
1890 static QLibrary *lastlib = 0; 1895 static QLibrary *lastlib = 0;
1891 static StyleInterface *lastiface = 0; 1896 static StyleInterface *lastiface = 0;
1892 1897
1893 QLibrary *lib = new QLibrary ( path ); 1898 QLibrary *lib = new QLibrary ( path );
1894 StyleInterface *iface = 0; 1899 StyleInterface *iface = 0;
1895 1900
1896 if (( lib-> queryInterface ( IID_Style, ( QUnknownInterface ** ) &iface ) == QS_OK ) && iface ) 1901 if (( lib-> queryInterface ( IID_Style, ( QUnknownInterface ** ) &iface ) == QS_OK ) && iface )
1897 sty = iface-> style ( ); 1902 sty = iface-> style ( );
1898 1903
1899 if ( sty ) { 1904 if ( sty ) {
1900 setStyle ( sty ); 1905 setStyle ( sty );
1901 1906
1902 if ( lastiface ) 1907 if ( lastiface )
1903 lastiface-> release ( ); 1908 lastiface-> release ( );
1904 lastiface = iface; 1909 lastiface = iface;
1905 1910
1906 if ( lastlib ) { 1911 if ( lastlib ) {
1907 lastlib-> unload ( ); 1912 lastlib-> unload ( );
1908 delete lastlib; 1913 delete lastlib;
1909 } 1914 }
1910 lastlib = lib; 1915 lastlib = lib;
1911 } 1916 }
1912 else { 1917 else {
1913 if ( iface ) 1918 if ( iface )
1914 iface-> release ( ); 1919 iface-> release ( );
1915 delete lib; 1920 delete lib;
1916 1921
1917 setStyle ( new LightStyle ( )); 1922 setStyle ( new LightStyle ( ));
1918 } 1923 }
1919 } 1924 }
1920#endif 1925#endif
1921} 1926}
1922 1927
1923/*! 1928/*!
1924 \internal 1929 \internal
1925*/ 1930*/
1926void QPEApplication::prepareForTermination( bool willrestart ) 1931void QPEApplication::prepareForTermination( bool willrestart )
1927{ 1932{
1928 if ( willrestart ) { 1933 if ( willrestart ) {
1929 // Draw a big wait icon, the image can be altered in later revisions 1934 // Draw a big wait icon, the image can be altered in later revisions
1930 // QWidget *d = QApplication::desktop(); 1935 // QWidget *d = QApplication::desktop();
1931 QImage img = Resource::loadImage( "launcher/new_wait" ); 1936 QImage img = Resource::loadImage( "launcher/new_wait" );
1932 QPixmap pix; 1937 QPixmap pix;
1933 pix.convertFromImage( img.smoothScale( 1 * img.width(), 1 * img.height() ) ); 1938 pix.convertFromImage( img.smoothScale( 1 * img.width(), 1 * img.height() ) );
1934 QLabel *lblWait = new QLabel( 0, "wait hack!", QWidget::WStyle_Customize | 1939 QLabel *lblWait = new QLabel( 0, "wait hack!", QWidget::WStyle_Customize |
1935 QWidget::WStyle_NoBorder | QWidget::WStyle_Tool ); 1940 QWidget::WStyle_NoBorder | QWidget::WStyle_Tool );
1936 lblWait->setPixmap( pix ); 1941 lblWait->setPixmap( pix );
1937 lblWait->setAlignment( QWidget::AlignCenter ); 1942 lblWait->setAlignment( QWidget::AlignCenter );
1938 lblWait->show(); 1943 lblWait->show();
1939 lblWait->showMaximized(); 1944 lblWait->showMaximized();
1940 } 1945 }
1941#ifndef SINGLE_APP 1946#ifndef SINGLE_APP
1942 { QCopEnvelope envelope( "QPE/System", "forceQuit()" ); 1947 { QCopEnvelope envelope( "QPE/System", "forceQuit()" );
1943 } 1948 }
1944 processEvents(); // ensure the message goes out. 1949 processEvents(); // ensure the message goes out.
1945 sleep( 1 ); // You have 1 second to comply. 1950 sleep( 1 ); // You have 1 second to comply.
1946#endif 1951#endif
1947} 1952}
1948 1953
1949/*! 1954/*!
1950 \internal 1955 \internal
1951*/ 1956*/
1952void QPEApplication::shutdown() 1957void QPEApplication::shutdown()
1953{ 1958{
1954 // Implement in server's QPEApplication subclass 1959 // Implement in server's QPEApplication subclass
1955} 1960}
1956 1961
1957/*! 1962/*!
1958 \internal 1963 \internal
1959*/ 1964*/
1960void QPEApplication::restart() 1965void QPEApplication::restart()
1961{ 1966{
1962 // Implement in server's QPEApplication subclass 1967 // Implement in server's QPEApplication subclass
1963} 1968}
1964 1969
1965static QPtrDict<void>* stylusDict = 0; 1970static QPtrDict<void>* stylusDict = 0;
1966static void createDict() 1971static void createDict()
1967{ 1972{
1968 if ( !stylusDict ) 1973 if ( !stylusDict )
1969 stylusDict = new QPtrDict<void>; 1974 stylusDict = new QPtrDict<void>;
1970} 1975}
1971 1976
1972/*! 1977/*!
1973 Returns the current StylusMode for widget \a w. 1978 Returns the current StylusMode for widget \a w.
1974 1979
1975 \sa setStylusOperation() StylusMode 1980 \sa setStylusOperation() StylusMode
1976*/ 1981*/
1977QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w ) 1982QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w )
1978{ 1983{
1979 if ( stylusDict ) 1984 if ( stylusDict )
1980 return ( StylusMode ) ( int ) stylusDict->find( w ); 1985 return ( StylusMode ) ( int ) stylusDict->find( w );
1981 return LeftOnly; 1986 return LeftOnly;
1982} 1987}
1983 1988
1984/*! 1989/*!
1985 \enum QPEApplication::StylusMode 1990 \enum QPEApplication::StylusMode
1986 1991
1987 \value LeftOnly the stylus only generates LeftButton 1992 \value LeftOnly the stylus only generates LeftButton
1988 events (the default). 1993 events (the default).
1989 \value RightOnHold the stylus generates RightButton events 1994 \value RightOnHold the stylus generates RightButton events
1990 if the user uses the press-and-hold gesture. 1995 if the user uses the press-and-hold gesture.
1991 1996
1992 \sa setStylusOperation() stylusOperation() 1997 \sa setStylusOperation() stylusOperation()
1993*/ 1998*/
1994 1999
1995/*! 2000/*!
1996 Causes widget \a w to receive mouse events according to the stylus 2001 Causes widget \a w to receive mouse events according to the stylus
1997 \a mode. 2002 \a mode.
1998 2003
1999 \sa stylusOperation() StylusMode 2004 \sa stylusOperation() StylusMode
2000*/ 2005*/
2001void QPEApplication::setStylusOperation( QWidget * w, StylusMode mode ) 2006void QPEApplication::setStylusOperation( QWidget * w, StylusMode mode )
2002{ 2007{
2003 createDict(); 2008 createDict();
2004 if ( mode == LeftOnly ) { 2009 if ( mode == LeftOnly ) {
2005 stylusDict->remove 2010 stylusDict->remove
2006 ( w ); 2011 ( w );
2007 w->removeEventFilter( qApp ); 2012 w->removeEventFilter( qApp );
2008 } 2013 }
2009 else { 2014 else {
2010 stylusDict->insert( w, ( void* ) mode ); 2015 stylusDict->insert( w, ( void* ) mode );
2011 connect( w, SIGNAL( destroyed() ), qApp, SLOT( removeSenderFromStylusDict() ) ); 2016 connect( w, SIGNAL( destroyed() ), qApp, SLOT( removeSenderFromStylusDict() ) );
2012 w->installEventFilter( qApp ); 2017 w->installEventFilter( qApp );
2013 } 2018 }
2014} 2019}
2015 2020
2016 2021
2017/*! 2022/*!
2018 \reimp 2023 \reimp
2019*/ 2024*/
2020bool QPEApplication::eventFilter( QObject *o, QEvent *e ) 2025bool QPEApplication::eventFilter( QObject *o, QEvent *e )
2021{ 2026{
2022 if ( !o->isWidgetType() ) 2027 if ( !o->isWidgetType() )
2023 return FALSE; 2028 return FALSE;
2024 2029
2025 if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) { 2030 if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) {
2026 QMouseEvent * me = ( QMouseEvent* ) e; 2031 QMouseEvent * me = ( QMouseEvent* ) e;
2027 StylusMode mode = (StylusMode)(int)stylusDict->find(o); 2032 StylusMode mode = (StylusMode)(int)stylusDict->find(o);
2028 switch (mode) { 2033 switch (mode) {
2029 case RightOnHold: 2034 case RightOnHold:
2030 switch ( me->type() ) { 2035 switch ( me->type() ) {
2031 case QEvent::MouseButtonPress: 2036 case QEvent::MouseButtonPress:
2032 if ( me->button() == LeftButton ) { 2037 if ( me->button() == LeftButton ) {
2033 d->presswidget = (QWidget*)o; 2038 d->presswidget = (QWidget*)o;
2034 d->presspos = me->pos(); 2039 d->presspos = me->pos();
2035 d->rightpressed = FALSE; 2040 d->rightpressed = FALSE;
2036 // just for the time being 2041 // just for the time being
2037 static int pref = 500; 2042 static int pref = 500;
2038#ifdef WITHROHFEEDBACK 2043#ifdef OPIE_ROHFEEDBACK
2039 if( ! d->RoH ) 2044 if( ! d->RoH )
2040 d->RoH = new Opie::Internal::RoHFeedback; 2045 d->RoH = new Opie::Internal::RoHFeedback;
2041 2046
2042 d->RoH->init( me->globalPos(), d->presswidget ); 2047 d->RoH->init( me->globalPos(), d->presswidget );
2043 pref = d->RoH->delay(); 2048 pref = d->RoH->delay();
2044#endif 2049#endif
2045 if (!d->presstimer ) 2050 if (!d->presstimer )
2046 d->presstimer = startTimer( pref ); // #### pref. 2051 d->presstimer = startTimer( pref ); // #### pref.
2047 2052
2048 } 2053 }
2049 break; 2054 break;
2050 case QEvent::MouseMove: 2055 case QEvent::MouseMove:
2051 if (d->presstimer && (me->pos() - d->presspos).manhattanLength() > 8) { 2056 if (d->presstimer && (me->pos() - d->presspos).manhattanLength() > 8) {
2052 killTimer(d->presstimer); 2057 killTimer(d->presstimer);
2053#ifdef WITHROHFEEDBACK 2058#ifdef OPIE_ROHFEEDBACK
2054 if( d->RoH ) 2059 if( d->RoH )
2055 d->RoH->stop( ); 2060 d->RoH->stop( );
2056#endif 2061#endif
2057 d->presstimer = 0; 2062 d->presstimer = 0;
2058 } 2063 }
2059 break; 2064 break;
2060 case QEvent::MouseButtonRelease: 2065 case QEvent::MouseButtonRelease:
2061 if ( me->button() == LeftButton ) { 2066 if ( me->button() == LeftButton ) {
2062 if ( d->presstimer ) { 2067 if ( d->presstimer ) {
2063 killTimer(d->presstimer); 2068 killTimer(d->presstimer);
2064#ifdef WITHROHFEEDBACK 2069#ifdef OPIE_ROHFEEDBACK
2065 if( d->RoH ) 2070 if( d->RoH )
2066 d->RoH->stop( ); 2071 d->RoH->stop( );
2067#endif 2072#endif
2068 d->presstimer = 0; 2073 d->presstimer = 0;
2069 } 2074 }
2070 if ( d->rightpressed && d->presswidget ) { 2075 if ( d->rightpressed && d->presswidget ) {
2071 // Right released 2076 // Right released
2072 postEvent( d->presswidget, 2077 postEvent( d->presswidget,
2073 new QMouseEvent( QEvent::MouseButtonRelease, me->pos(), 2078 new QMouseEvent( QEvent::MouseButtonRelease, me->pos(),
2074 RightButton, LeftButton + RightButton ) ); 2079 RightButton, LeftButton + RightButton ) );
2075 // Left released, off-widget 2080 // Left released, off-widget
2076 postEvent( d->presswidget, 2081 postEvent( d->presswidget,
2077 new QMouseEvent( QEvent::MouseMove, QPoint( -1, -1), 2082 new QMouseEvent( QEvent::MouseMove, QPoint( -1, -1),
2078 LeftButton, LeftButton ) ); 2083 LeftButton, LeftButton ) );
2079 postEvent( d->presswidget, 2084 postEvent( d->presswidget,
2080 new QMouseEvent( QEvent::MouseButtonRelease, QPoint( -1, -1), 2085 new QMouseEvent( QEvent::MouseButtonRelease, QPoint( -1, -1),
2081 LeftButton, LeftButton ) ); 2086 LeftButton, LeftButton ) );
2082 d->rightpressed = FALSE; 2087 d->rightpressed = FALSE;
2083 return TRUE; // don't send the real Left release 2088 return TRUE; // don't send the real Left release
2084 } 2089 }
2085 } 2090 }
2086 break; 2091 break;
2087 default: 2092 default:
2088 break; 2093 break;
2089 } 2094 }
2090 break; 2095 break;
2091 default: 2096 default:
2092 ; 2097 ;
2093 } 2098 }
2094 } 2099 }
2095 else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { 2100 else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) {
2096 QKeyEvent *ke = (QKeyEvent *)e; 2101 QKeyEvent *ke = (QKeyEvent *)e;
2097 if ( ke->key() == Key_Enter ) { 2102 if ( ke->key() == Key_Enter ) {
2098 if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) { 2103 if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) {
2099 postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ', 2104 postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ',
2100 ke->state(), " ", ke->isAutoRepeat(), ke->count() ) ); 2105 ke->state(), " ", ke->isAutoRepeat(), ke->count() ) );
2101 return TRUE; 2106 return TRUE;
2102 } 2107 }
2103 } 2108 }
2104 } 2109 }
2105 return FALSE; 2110 return FALSE;
2106} 2111}
2107 2112
2108/*! 2113/*!
2109 \reimp 2114 \reimp
2110*/ 2115*/
2111void QPEApplication::timerEvent( QTimerEvent *e ) 2116void QPEApplication::timerEvent( QTimerEvent *e )
2112{ 2117{
2113 if ( e->timerId() == d->presstimer && d->presswidget ) { 2118 if ( e->timerId() == d->presstimer && d->presswidget ) {
2114 // Right pressed 2119 // Right pressed
2115 postEvent( d->presswidget, 2120 postEvent( d->presswidget,
2116 new QMouseEvent( QEvent::MouseButtonPress, d->presspos, 2121 new QMouseEvent( QEvent::MouseButtonPress, d->presspos,
2117 RightButton, LeftButton ) ); 2122 RightButton, LeftButton ) );
2118 killTimer( d->presstimer ); 2123 killTimer( d->presstimer );
2119 d->presstimer = 0; 2124 d->presstimer = 0;
2120 d->rightpressed = TRUE; 2125 d->rightpressed = TRUE;
2126#ifdef OPIE_ROHFEEDBACK
2121 d->RoH->stop(); 2127 d->RoH->stop();
2128#endif
2122 } 2129 }
2123} 2130}
2124 2131
2125void QPEApplication::removeSenderFromStylusDict() 2132void QPEApplication::removeSenderFromStylusDict()
2126{ 2133{
2127 stylusDict->remove 2134 stylusDict->remove
2128 ( ( void* ) sender() ); 2135 ( ( void* ) sender() );
2129 if ( d->presswidget == sender() ) 2136 if ( d->presswidget == sender() )
2130 d->presswidget = 0; 2137 d->presswidget = 0;
2131} 2138}
2132 2139
2133/*! 2140/*!
2134 \internal 2141 \internal
2135*/ 2142*/
2136bool QPEApplication::keyboardGrabbed() const 2143bool QPEApplication::keyboardGrabbed() const
2137{ 2144{
2138 return d->kbgrabbed; 2145 return d->kbgrabbed;
2139} 2146}
2140 2147
2141 2148
2142/*! 2149/*!
2143 Reverses the effect of grabKeyboard(). This is called automatically 2150 Reverses the effect of grabKeyboard(). This is called automatically
2144 on program exit. 2151 on program exit.
2145*/ 2152*/
2146void QPEApplication::ungrabKeyboard() 2153void QPEApplication::ungrabKeyboard()
2147{ 2154{
2148 ((QPEApplication *) qApp )-> d-> kbgrabbed = false; 2155 ((QPEApplication *) qApp )-> d-> kbgrabbed = false;
2149} 2156}
2150 2157
2151/*! 2158/*!
2152 Grabs the physical keyboard keys, e.g. the application's launching 2159 Grabs the physical keyboard keys, e.g. the application's launching
2153 keys. Instead of launching applications when these keys are pressed 2160 keys. Instead of launching applications when these keys are pressed
2154 the signals emitted are sent to this application instead. Some games 2161 the signals emitted are sent to this application instead. Some games
2155 programs take over the launch keys in this way to make interaction 2162 programs take over the launch keys in this way to make interaction
2156 easier. 2163 easier.
2157 2164
2158 \sa ungrabKeyboard() 2165 \sa ungrabKeyboard()
2159*/ 2166*/
2160void QPEApplication::grabKeyboard() 2167void QPEApplication::grabKeyboard()
2161{ 2168{
2162 ((QPEApplication *) qApp )-> d-> kbgrabbed = true; 2169 ((QPEApplication *) qApp )-> d-> kbgrabbed = true;
2163} 2170}
2164 2171
2165/*! 2172/*!
2166 \reimp 2173 \reimp
2167*/ 2174*/
2168int QPEApplication::exec() 2175int QPEApplication::exec()
2169{ 2176{
2170 d->qcopQok = true; 2177 d->qcopQok = true;
2171#ifndef QT_NO_COP 2178#ifndef QT_NO_COP
2172 d->sendQCopQ(); 2179 d->sendQCopQ();
2173 if ( !d->keep_running ) 2180 if ( !d->keep_running )
2174 processEvents(); // we may have received QCop messages in the meantime. 2181 processEvents(); // we may have received QCop messages in the meantime.
2175#endif 2182#endif
2176 2183
2177 if ( d->keep_running ) 2184 if ( d->keep_running )
2178 //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() ) 2185 //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() )
2179 return QApplication::exec(); 2186 return QApplication::exec();
2180 2187
2181#ifndef QT_NO_COP 2188#ifndef QT_NO_COP
2182 2189
2183 { 2190 {
2184 QCopEnvelope e( "QPE/System", "closing(QString)" ); 2191 QCopEnvelope e( "QPE/System", "closing(QString)" );
2185 e << d->appName; 2192 e << d->appName;
2186 } 2193 }
2187#endif 2194#endif
2188 processEvents(); 2195 processEvents();
2189 return 0; 2196 return 0;
2190} 2197}
2191 2198
2192/*! 2199/*!
2193 \internal 2200 \internal
2194 External request for application to quit. Quits if possible without 2201 External request for application to quit. Quits if possible without
2195 loosing state. 2202 loosing state.
2196*/ 2203*/
2197void QPEApplication::tryQuit() 2204void QPEApplication::tryQuit()
2198{ 2205{
2199 if ( activeModalWidget() ) 2206 if ( activeModalWidget() )
2200 return ; // Inside modal loop or konsole. Too hard to save state. 2207 return ; // Inside modal loop or konsole. Too hard to save state.
2201#ifndef QT_NO_COP 2208#ifndef QT_NO_COP
2202 2209
2203 { 2210 {
2204 QCopEnvelope e( "QPE/System", "closing(QString)" ); 2211 QCopEnvelope e( "QPE/System", "closing(QString)" );
2205 e << d->appName; 2212 e << d->appName;
2206 } 2213 }
2207#endif 2214#endif
2208 if ( d->keep_running ) 2215 if ( d->keep_running )
2209 d->store_widget_rect(d->qpe_main_widget, d->appName); 2216 d->store_widget_rect(d->qpe_main_widget, d->appName);
2210 processEvents(); 2217 processEvents();
2211 2218
2212 quit(); 2219 quit();
2213} 2220}
2214 2221
2215/*! 2222/*!
2216 \internal 2223 \internal
2217*/ 2224*/
2218void QPEApplication::installTranslation( const QString& baseName ) { 2225void QPEApplication::installTranslation( const QString& baseName ) {
2219 QTranslator* trans = new QTranslator(this); 2226 QTranslator* trans = new QTranslator(this);
2220 QString tfn = qpeDir() + "/i18n/"+baseName; 2227 QString tfn = qpeDir() + "/i18n/"+baseName;
2221 if ( trans->load( tfn ) ) 2228 if ( trans->load( tfn ) )
2222 installTranslator( trans ); 2229 installTranslator( trans );
2223 else 2230 else
2224 delete trans; 2231 delete trans;
2225} 2232}
2226 2233
2227/*! 2234/*!
2228 \internal 2235 \internal
2229 User initiated quit. Makes the window 'Go Away'. If preloaded this means 2236 User initiated quit. Makes the window 'Go Away'. If preloaded this means
2230 hiding the window. If not it means quitting the application. 2237 hiding the window. If not it means quitting the application.
2231 As this is user initiated we don't need to check state. 2238 As this is user initiated we don't need to check state.
2232*/ 2239*/
2233void QPEApplication::hideOrQuit() 2240void QPEApplication::hideOrQuit()
2234{ 2241{
2235 if ( d->keep_running ) 2242 if ( d->keep_running )
2236 d->store_widget_rect(d->qpe_main_widget, d->appName); 2243 d->store_widget_rect(d->qpe_main_widget, d->appName);
2237 processEvents(); 2244 processEvents();
2238 2245
2239 // If we are a preloaded application we don't actually quit, so emit 2246 // If we are a preloaded application we don't actually quit, so emit
2240 // a System message indicating we're quasi-closing. 2247 // a System message indicating we're quasi-closing.
2241 if ( d->preloaded && d->qpe_main_widget ) 2248 if ( d->preloaded && d->qpe_main_widget )
2242#ifndef QT_NO_COP 2249#ifndef QT_NO_COP
2243 2250
2244 { 2251 {
2245 QCopEnvelope e("QPE/System", "fastAppHiding(QString)" ); 2252 QCopEnvelope e("QPE/System", "fastAppHiding(QString)" );
2246 e << d->appName; 2253 e << d->appName;
2247 d->qpe_main_widget->hide(); 2254 d->qpe_main_widget->hide();
2248 } 2255 }
2249#endif 2256#endif
2250 else 2257 else
2251 quit(); 2258 quit();
2252} 2259}
2253 2260
2254#if (__GNUC__ > 2 ) 2261#if (__GNUC__ > 2 )
2255extern "C" void __cxa_pure_virtual(); 2262extern "C" void __cxa_pure_virtual();
2256 2263
2257void __cxa_pure_virtual() 2264void __cxa_pure_virtual()
2258{ 2265{
2259 fprintf( stderr, "Pure virtual called\n"); 2266 fprintf( stderr, "Pure virtual called\n");
2260 abort(); 2267 abort();
2261 2268
2262} 2269}
2263 2270
2264#endif 2271#endif
2265 2272
2266 2273
2267#if defined(OPIE_NEW_MALLOC) 2274#if defined(OPIE_NEW_MALLOC)
2268 2275
2269// The libraries with the skiff package (and possibly others) have 2276// The libraries with the skiff package (and possibly others) have
2270// completely useless implementations of builtin new and delete that 2277// completely useless implementations of builtin new and delete that
2271// use about 50% of your CPU. Here we revert to the simple libc 2278// use about 50% of your CPU. Here we revert to the simple libc
2272// functions. 2279// functions.
2273 2280
2274void* operator new[]( size_t size ) 2281void* operator new[]( size_t size )
2275{ 2282{
2276 return malloc( size ); 2283 return malloc( size );
2277} 2284}
2278 2285
2279void* operator new( size_t size ) 2286void* operator new( size_t size )
2280{ 2287{
2281 return malloc( size ); 2288 return malloc( size );
2282} 2289}
2283 2290
2284void operator delete[]( void* p ) 2291void operator delete[]( void* p )
2285{ 2292{
2286 free( p ); 2293 free( p );
2287} 2294}
2288 2295
2289void operator delete[]( void* p, size_t /*size*/ ) 2296void operator delete[]( void* p, size_t /*size*/ )
2290{ 2297{
2291 free( p ); 2298 free( p );
2292} 2299}
2293 2300
2294 2301
2295void operator delete( void* p ) 2302void operator delete( void* p )
2296{ 2303{
2297 free( p ); 2304 free( p );
2298} 2305}
2299 2306
2300void operator delete( void* p, size_t /*size*/ ) 2307void operator delete( void* p, size_t /*size*/ )
2301{ 2308{
2302 free( p ); 2309 free( p );
2303} 2310}
2304 2311
2305#endif 2312#endif
2306 2313
2307#if ( QT_VERSION <= 230 ) && !defined(SINGLE_APP) 2314#if ( QT_VERSION <= 230 ) && !defined(SINGLE_APP)
2308#include <qwidgetlist.h> 2315#include <qwidgetlist.h>
2309#ifdef QWS 2316#ifdef QWS
2310#include <qgfx_qws.h> 2317#include <qgfx_qws.h>
2311extern QRect qt_maxWindowRect; 2318extern QRect qt_maxWindowRect;
2312void qt_setMaxWindowRect(const QRect& r ) 2319void qt_setMaxWindowRect(const QRect& r )
2313{ 2320{