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,351 +1,350 @@
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
@@ -569,564 +568,574 @@ static void setBass( int t = 0, int percent = -1 )
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;
@@ -1990,308 +1999,297 @@ bool QPEApplication::eventFilter( QObject *o, QEvent *e )
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