summaryrefslogtreecommitdiff
authorerik <erik>2007-01-19 01:15:31 (UTC)
committer erik <erik>2007-01-19 01:15:31 (UTC)
commitac0ce844e90a64247c0adb210e0a23021b011d57 (patch) (unidiff)
tree1fd3b8d0c24d8f2054ed45e7e2e102f940343462
parent1ab92f1d2b346de7da8ca5c3aaa6bc75b43981e7 (diff)
downloadopie-ac0ce844e90a64247c0adb210e0a23021b011d57.zip
opie-ac0ce844e90a64247c0adb210e0a23021b011d57.tar.gz
opie-ac0ce844e90a64247c0adb210e0a23021b011d57.tar.bz2
Commit of Paul's patch to remove a macro and substitute it with a
class variable.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--library/qpeapplication.cpp16
-rw-r--r--library/qpeapplication.h2
-rw-r--r--library/widget_showing.cpp9
3 files changed, 15 insertions, 12 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp
index dcc1001..34f5e6a 100644
--- a/library/qpeapplication.cpp
+++ b/library/qpeapplication.cpp
@@ -1,474 +1,475 @@
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 >= 0x030000 63#if QT_VERSION >= 0x030000
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 99
100#include <backend/rohfeedback.h> 100#include <backend/rohfeedback.h>
101 101
102 102
103static bool useBigPixmaps = 0; 103static bool useBigPixmaps = 0;
104static bool saveWindowsPos = 0;
104 105
105class HackWidget : public QWidget 106class HackWidget : public QWidget
106{ 107{
107public: 108public:
108 bool needsOk() 109 bool needsOk()
109 { return (getWState() & WState_Reserved1 ); } 110 { return (getWState() & WState_Reserved1 ); }
110 111
111 QRect normalGeometry() 112 QRect normalGeometry()
112 { return topData()->normalGeometry; }; 113 { return topData()->normalGeometry; };
113}; 114};
114 115
115class QPEApplicationData 116class QPEApplicationData
116{ 117{
117public: 118public:
118 QPEApplicationData ( ) : 119 QPEApplicationData ( ) :
119 presstimer( 0 ), presswidget( 0 ), rightpressed( false ), kbgrabbed( false ), 120 presstimer( 0 ), presswidget( 0 ), rightpressed( false ), kbgrabbed( false ),
120 notbusysent( false ), preloaded( false ), forceshow( false ), nomaximize( false ), 121 notbusysent( false ), preloaded( false ), forceshow( false ), nomaximize( false ),
121 keep_running( true ), qcopQok( false ), 122 keep_running( true ), qcopQok( false ),
122 fontFamily( "Vera" ), fontSize( 10 ), smallIconSize( 14 ), 123 fontFamily( "Vera" ), fontSize( 10 ), smallIconSize( 14 ),
123 bigIconSize( 32 ), qpe_main_widget( 0 ) 124 bigIconSize( 32 ), qpe_main_widget( 0 )
124 { 125 {
125 Config cfg( "qpe" ); 126 Config cfg( "qpe" );
126 cfg.setGroup( "Appearance" ); 127 cfg.setGroup( "Appearance" );
127 useBigPixmaps = cfg.readBoolEntry( "useBigPixmaps", false ); 128 useBigPixmaps = cfg.readBoolEntry( "useBigPixmaps", false );
128 fontFamily = cfg.readEntry( "FontFamily", "Vera" ); 129 fontFamily = cfg.readEntry( "FontFamily", "Vera" );
129 fontSize = cfg.readNumEntry( "FontSize", 10 ); 130 fontSize = cfg.readNumEntry( "FontSize", 10 );
130 smallIconSize = cfg.readNumEntry( "SmallIconSize", 14 ); 131 smallIconSize = cfg.readNumEntry( "SmallIconSize", 14 );
131 bigIconSize = cfg.readNumEntry( "BigIconSize", 32 ); 132 bigIconSize = cfg.readNumEntry( "BigIconSize", 32 );
133 saveWindowsPos = cfg.readBoolEntry( "AllowWindowed", false );
132#ifdef OPIE_WITHROHFEEDBACK 134#ifdef OPIE_WITHROHFEEDBACK
133 RoH = 0; 135 RoH = 0;
134#endif 136#endif
135 } 137 }
136 138
137 int presstimer; 139 int presstimer;
138 QWidget* presswidget; 140 QWidget* presswidget;
139 QPoint presspos; 141 QPoint presspos;
140#ifdef OPIE_WITHROHFEEDBACK 142#ifdef OPIE_WITHROHFEEDBACK
141 Opie::Internal::RoHFeedback *RoH; 143 Opie::Internal::RoHFeedback *RoH;
142#endif 144#endif
143 145
144 bool rightpressed : 1; 146 bool rightpressed : 1;
145 bool kbgrabbed : 1; 147 bool kbgrabbed : 1;
146 bool notbusysent : 1; 148 bool notbusysent : 1;
147 bool preloaded : 1; 149 bool preloaded : 1;
148 bool forceshow : 1; 150 bool forceshow : 1;
149 bool nomaximize : 1; 151 bool nomaximize : 1;
150 bool keep_running : 1; 152 bool keep_running : 1;
151 bool qcopQok : 1; 153 bool qcopQok : 1;
152 154
153 QCString fontFamily; 155 QCString fontFamily;
154 int fontSize; 156 int fontSize;
155 int smallIconSize; 157 int smallIconSize;
156 int bigIconSize; 158 int bigIconSize;
157 159
158 QString appName; 160 QString appName;
159 struct QCopRec 161 struct QCopRec
160 { 162 {
161 QCopRec( const QCString &ch, const QCString &msg, 163 QCopRec( const QCString &ch, const QCString &msg,
162 const QByteArray &d ) : 164 const QByteArray &d ) :
163 channel( ch ), message( msg ), data( d ) 165 channel( ch ), message( msg ), data( d )
164 { } 166 { }
165 167
166 QCString channel; 168 QCString channel;
167 QCString message; 169 QCString message;
168 QByteArray data; 170 QByteArray data;
169 }; 171 };
170 QGuardedPtr<QWidget> qpe_main_widget; 172 QGuardedPtr<QWidget> qpe_main_widget;
171 QGuardedPtr<QWidget> lastraised; 173 QGuardedPtr<QWidget> lastraised;
172 QQueue<QCopRec> qcopq; 174 QQueue<QCopRec> qcopq;
173 QString styleName; 175 QString styleName;
174 QString decorationName; 176 QString decorationName;
175 177
176 void enqueueQCop( const QCString &ch, const QCString &msg, 178 void enqueueQCop( const QCString &ch, const QCString &msg,
177 const QByteArray &data ) 179 const QByteArray &data )
178 { 180 {
179 qcopq.enqueue( new QCopRec( ch, msg, data ) ); 181 qcopq.enqueue( new QCopRec( ch, msg, data ) );
180 } 182 }
181 void sendQCopQ() 183 void sendQCopQ()
182 { 184 {
183 if (!qcopQok ) 185 if (!qcopQok )
184 return; 186 return;
185 187
186 QCopRec * r; 188 QCopRec * r;
187 189
188 while((r=qcopq.dequeue())) { 190 while((r=qcopq.dequeue())) {
189 // remove from queue before sending... 191 // remove from queue before sending...
190 // event loop can come around again before getting 192 // event loop can come around again before getting
191 // back from sendLocally 193 // back from sendLocally
192#ifndef QT_NO_COP 194#ifndef QT_NO_COP
193 QCopChannel::sendLocally( r->channel, r->message, r->data ); 195 QCopChannel::sendLocally( r->channel, r->message, r->data );
194#endif 196#endif
195 197
196 delete r; 198 delete r;
197 } 199 }
198 } 200 }
199 201
200 static void show_mx(QWidget* mw, bool nomaximize, QString &strName) { 202 static void show_mx(QWidget* mw, bool nomaximize, QString &strName) {
201 if ( mw->inherits("QMainWindow") || mw->isA("QMainWindow") ) 203 if ( mw->inherits("QMainWindow") || mw->isA("QMainWindow") )
202 { 204 {
203 ( ( QMainWindow* ) mw )->setUsesBigPixmaps( useBigPixmaps ); 205 ( ( QMainWindow* ) mw )->setUsesBigPixmaps( useBigPixmaps );
204 } 206 }
205 QPoint p; 207 QPoint p;
206 QSize s; 208 QSize s;
207 bool max; 209 bool max;
208 210
209 if ( mw->isVisible() ) { 211 if ( mw->isVisible() ) {
210 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) ) {
211 mw->resize(s); 213 mw->resize(s);
212 mw->move(p); 214 mw->move(p);
213 } 215 }
214 mw->raise(); 216 mw->raise();
215 } else { 217 } else {
216 218
217 if ( mw->layout() && mw->inherits("QDialog") ) { 219 if ( mw->layout() && mw->inherits("QDialog") ) {
218 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) ) {
219 mw->resize(s); 221 mw->resize(s);
220 mw->move(p); 222 mw->move(p);
221 223
222 if ( max && !nomaximize ) { 224 if ( max && !nomaximize ) {
223 mw->showMaximized(); 225 mw->showMaximized();
224 } else { 226 } else {
225 mw->show(); 227 mw->show();
226 } 228 }
227 } else { 229 } else {
228 QPEApplication::showDialog((QDialog*)mw,nomaximize); 230 QPEApplication::showDialog((QDialog*)mw,nomaximize);
229 } 231 }
230 } else { 232 } else {
231 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) ) {
232 mw->resize(s); 234 mw->resize(s);
233 mw->move(p); 235 mw->move(p);
234 } else { //no stored rectangle, make an estimation 236 } else { //no stored rectangle, make an estimation
235 int x = (qApp->desktop()->width()-mw->frameGeometry().width())/2; 237 int x = (qApp->desktop()->width()-mw->frameGeometry().width())/2;
236 int y = (qApp->desktop()->height()-mw->frameGeometry().height())/2; 238 int y = (qApp->desktop()->height()-mw->frameGeometry().height())/2;
237 mw->move( QMAX(x,0), QMAX(y,0) ); 239 mw->move( QMAX(x,0), QMAX(y,0) );
238#ifdef Q_WS_QWS 240#ifdef Q_WS_QWS
239 if ( !nomaximize ) 241 if ( !nomaximize )
240 mw->showMaximized(); 242 mw->showMaximized();
241#endif 243#endif
242 } 244 }
243 if ( max && !nomaximize ) 245 if ( max && !nomaximize )
244 mw->showMaximized(); 246 mw->showMaximized();
245 else 247 else
246 mw->show(); 248 mw->show();
247 } 249 }
248 } 250 }
249 } 251 }
250 252
251 static bool read_widget_rect(const QString &app, bool &maximized, QPoint &p, QSize &s) 253 static bool read_widget_rect(const QString &app, bool &maximized, QPoint &p, QSize &s)
252 { 254 {
253#ifndef OPIE_NO_WINDOWED 255 if (!saveWindowsPos)
256 return FALSE;
254 maximized = TRUE; 257 maximized = TRUE;
255 // 350 is the trigger in qwsdefaultdecoration for providing a resize button 258 // 350 is the trigger in qwsdefaultdecoration for providing a resize button
256 if ( qApp->desktop()->width() <= 350 ) 259 if ( qApp->desktop()->width() <= 350 )
257 return FALSE; 260 return FALSE;
258 261
259 Config cfg( "qpe" ); 262 Config cfg( "qpe" );
260 cfg.setGroup("ApplicationPositions"); 263 cfg.setGroup("ApplicationPositions");
261 QString str = cfg.readEntry( app, QString::null ); 264 QString str = cfg.readEntry( app, QString::null );
262 QStringList l = QStringList::split(",", str); 265 QStringList l = QStringList::split(",", str);
263 266
264 if ( l.count() == 5) { 267 if ( l.count() == 5) {
265 p.setX( l[0].toInt() ); 268 p.setX( l[0].toInt() );
266 p.setY( l[1].toInt() ); 269 p.setY( l[1].toInt() );
267 270
268 s.setWidth( l[2].toInt() ); 271 s.setWidth( l[2].toInt() );
269 s.setHeight( l[3].toInt() ); 272 s.setHeight( l[3].toInt() );
270 273
271 maximized = l[4].toInt(); 274 maximized = l[4].toInt();
272 275
273 return TRUE; 276 return TRUE;
274 } 277 }
275#endif
276 return FALSE;
277 } 278 }
278 279
279 280
280 static bool validate_widget_size(const QWidget *w, QPoint &p, QSize &s) 281 static bool validate_widget_size(const QWidget *w, QPoint &p, QSize &s)
281 { 282 {
282#ifndef Q_WS_QWS 283#ifndef Q_WS_QWS
283 QRect qt_maxWindowRect = qApp->desktop()->geometry(); 284 QRect qt_maxWindowRect = qApp->desktop()->geometry();
284#endif 285#endif
285 int maxX = qt_maxWindowRect.width(); 286 int maxX = qt_maxWindowRect.width();
286 int maxY = qt_maxWindowRect.height(); 287 int maxY = qt_maxWindowRect.height();
287 int wWidth = s.width() + ( w->frameGeometry().width() - w->geometry().width() ); 288 int wWidth = s.width() + ( w->frameGeometry().width() - w->geometry().width() );
288 int wHeight = s.height() + ( w->frameGeometry().height() - w->geometry().height() ); 289 int wHeight = s.height() + ( w->frameGeometry().height() - w->geometry().height() );
289 290
290 // total window size is not allowed to be larger than desktop window size 291 // total window size is not allowed to be larger than desktop window size
291 if ( ( wWidth >= maxX ) && ( wHeight >= maxY ) ) 292 if ( ( wWidth >= maxX ) && ( wHeight >= maxY ) )
292 return FALSE; 293 return FALSE;
293 294
294 if ( wWidth > maxX ) { 295 if ( wWidth > maxX ) {
295 s.setWidth( maxX - (w->frameGeometry().width() - w->geometry().width() ) ); 296 s.setWidth( maxX - (w->frameGeometry().width() - w->geometry().width() ) );
296 wWidth = maxX; 297 wWidth = maxX;
297 } 298 }
298 299
299 if ( wHeight > maxY ) { 300 if ( wHeight > maxY ) {
300 s.setHeight( maxY - (w->frameGeometry().height() - w->geometry().height() ) ); 301 s.setHeight( maxY - (w->frameGeometry().height() - w->geometry().height() ) );
301 wHeight = maxY; 302 wHeight = maxY;
302 } 303 }
303 304
304 // any smaller than this and the maximize/close/help buttons will be overlapping 305 // any smaller than this and the maximize/close/help buttons will be overlapping
305 if ( wWidth < 80 || wHeight < 60 ) 306 if ( wWidth < 80 || wHeight < 60 )
306 return FALSE; 307 return FALSE;
307 308
308 if ( p.x() < 0 ) 309 if ( p.x() < 0 )
309 p.setX(0); 310 p.setX(0);
310 if ( p.y() < 0 ) 311 if ( p.y() < 0 )
311 p.setY(0); 312 p.setY(0);
312 313
313 if ( p.x() + wWidth > maxX ) 314 if ( p.x() + wWidth > maxX )
314 p.setX( maxX - wWidth ); 315 p.setX( maxX - wWidth );
315 if ( p.y() + wHeight > maxY ) 316 if ( p.y() + wHeight > maxY )
316 p.setY( maxY - wHeight ); 317 p.setY( maxY - wHeight );
317 318
318 return TRUE; 319 return TRUE;
319 } 320 }
320 321
321 static void store_widget_rect(QWidget *w, QString &app) 322 static void store_widget_rect(QWidget *w, QString &app)
322 { 323 {
323 if( !w ) 324 if( !w )
324 return; 325 return;
325#ifndef OPIE_NO_WINDOWED 326 if (!saveWindowsPos)
327 return;
326 // 350 is the trigger in qwsdefaultdecoration for providing a resize button 328 // 350 is the trigger in qwsdefaultdecoration for providing a resize button
327 if ( qApp->desktop()->width() <= 350 ) 329 if ( qApp->desktop()->width() <= 350 )
328 return; 330 return;
329 // we use these to map the offset of geometry and pos. ( we can only use normalGeometry to 331 // we use these to map the offset of geometry and pos. ( we can only use normalGeometry to
330 // get the non-maximized version, so we have to do it the hard way ) 332 // get the non-maximized version, so we have to do it the hard way )
331 int offsetX = w->x() - w->geometry().left(); 333 int offsetX = w->x() - w->geometry().left();
332 int offsetY = w->y() - w->geometry().top(); 334 int offsetY = w->y() - w->geometry().top();
333 335
334 QRect r; 336 QRect r;
335 if ( w->isMaximized() ) 337 if ( w->isMaximized() )
336 r = ( (HackWidget *) w)->normalGeometry(); 338 r = ( (HackWidget *) w)->normalGeometry();
337 else 339 else
338 r = w->geometry(); 340 r = w->geometry();
339 341
340 // Stores the window placement as pos(), size() (due to the offset mapping) 342 // Stores the window placement as pos(), size() (due to the offset mapping)
341 Config cfg( "qpe" ); 343 Config cfg( "qpe" );
342 cfg.setGroup("ApplicationPositions"); 344 cfg.setGroup("ApplicationPositions");
343 QString s; 345 QString s;
344 s.sprintf("%d,%d,%d,%d,%d", r.left() + offsetX, r.top() + offsetY, r.width(), r.height(), w->isMaximized() ); 346 s.sprintf("%d,%d,%d,%d,%d", r.left() + offsetX, r.top() + offsetY, r.width(), r.height(), w->isMaximized() );
345 cfg.writeEntry( app, s ); 347 cfg.writeEntry( app, s );
346#endif
347 } 348 }
348 349
349 static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) 350 static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ )
350 { 351 {
351 /* 352 /*
352 // This works but disable it for now until it is safe to apply 353 // This works but disable it for now until it is safe to apply
353 // What is does is scan the .desktop files of all the apps for 354 // What is does is scan the .desktop files of all the apps for
354 // the applnk that has the corresponding argv[0] as this program 355 // the applnk that has the corresponding argv[0] as this program
355 // then it uses the name stored in the .desktop file as the caption 356 // then it uses the name stored in the .desktop file as the caption
356 // for the main widget. This saves duplicating translations for 357 // for the main widget. This saves duplicating translations for
357 // the app name in the program and in the .desktop files. 358 // the app name in the program and in the .desktop files.
358 359
359 AppLnkSet apps( appsPath ); 360 AppLnkSet apps( appsPath );
360 361
361 QList<AppLnk> appsList = apps.children(); 362 QList<AppLnk> appsList = apps.children();
362 for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) { 363 for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) {
363 if ( (*it)->exec() == appName ) { 364 if ( (*it)->exec() == appName ) {
364 mw->setCaption( (*it)->name() ); 365 mw->setCaption( (*it)->name() );
365 return TRUE; 366 return TRUE;
366 } 367 }
367 } 368 }
368 */ 369 */
369 return FALSE; 370 return FALSE;
370 } 371 }
371 372
372 373
373 void show(QWidget* mw, bool nomax) 374 void show(QWidget* mw, bool nomax)
374 { 375 {
375 setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" ); 376 setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" );
376 nomaximize = nomax; 377 nomaximize = nomax;
377 qpe_main_widget = mw; 378 qpe_main_widget = mw;
378 qcopQok = TRUE; 379 qcopQok = TRUE;
379#ifndef QT_NO_COP 380#ifndef QT_NO_COP
380 381
381 sendQCopQ(); 382 sendQCopQ();
382#endif 383#endif
383 384
384 if ( preloaded ) { 385 if ( preloaded ) {
385 if (forceshow) 386 if (forceshow)
386 show_mx(mw, nomax, appName); 387 show_mx(mw, nomax, appName);
387 } 388 }
388 else if ( keep_running ) { 389 else if ( keep_running ) {
389 show_mx(mw, nomax, appName); 390 show_mx(mw, nomax, appName);
390 } 391 }
391 } 392 }
392 393
393 void loadTextCodecs() 394 void loadTextCodecs()
394 { 395 {
395 QString path = QPEApplication::qpeDir() + "plugins/textcodecs"; 396 QString path = QPEApplication::qpeDir() + "plugins/textcodecs";
396#ifdef Q_OS_MACX 397#ifdef Q_OS_MACX
397 QDir dir( path, "lib*.dylib" ); 398 QDir dir( path, "lib*.dylib" );
398#else 399#else
399 QDir dir( path, "lib*.so" ); 400 QDir dir( path, "lib*.so" );
400#endif 401#endif
401 QStringList list; 402 QStringList list;
402 if ( dir. exists ( )) 403 if ( dir. exists ( ))
403 list = dir.entryList(); 404 list = dir.entryList();
404 QStringList::Iterator it; 405 QStringList::Iterator it;
405 for ( it = list.begin(); it != list.end(); ++it ) { 406 for ( it = list.begin(); it != list.end(); ++it ) {
406 TextCodecInterface *iface = 0; 407 TextCodecInterface *iface = 0;
407 QLibrary *lib = new QLibrary( path + "/" + *it ); 408 QLibrary *lib = new QLibrary( path + "/" + *it );
408 if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { 409 if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) {
409 QValueList<int> mibs = iface->mibEnums(); 410 QValueList<int> mibs = iface->mibEnums();
410 for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) { 411 for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) {
411 (void)iface->createForMib(*i); 412 (void)iface->createForMib(*i);
412 // ### it exists now; need to remember if we can delete it 413 // ### it exists now; need to remember if we can delete it
413 } 414 }
414 } 415 }
415 else { 416 else {
416 lib->unload(); 417 lib->unload();
417 delete lib; 418 delete lib;
418 } 419 }
419 } 420 }
420 } 421 }
421 422
422 void loadImageCodecs() 423 void loadImageCodecs()
423 { 424 {
424 QString path = QPEApplication::qpeDir() + "plugins/imagecodecs"; 425 QString path = QPEApplication::qpeDir() + "plugins/imagecodecs";
425#ifdef Q_OS_MACX 426#ifdef Q_OS_MACX
426 QDir dir( path, "lib*.dylib" ); 427 QDir dir( path, "lib*.dylib" );
427#else 428#else
428 QDir dir( path, "lib*.so" ); 429 QDir dir( path, "lib*.so" );
429#endif 430#endif
430 QStringList list; 431 QStringList list;
431 if ( dir. exists ( )) 432 if ( dir. exists ( ))
432 list = dir.entryList(); 433 list = dir.entryList();
433 QStringList::Iterator it; 434 QStringList::Iterator it;
434 for ( it = list.begin(); it != list.end(); ++it ) { 435 for ( it = list.begin(); it != list.end(); ++it ) {
435 ImageCodecInterface *iface = 0; 436 ImageCodecInterface *iface = 0;
436 QLibrary *lib = new QLibrary( path + "/" + *it ); 437 QLibrary *lib = new QLibrary( path + "/" + *it );
437 if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { 438 if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) {
438 QStringList formats = iface->keys(); 439 QStringList formats = iface->keys();
439 for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) { 440 for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) {
440 (void)iface->installIOHandler(*i); 441 (void)iface->installIOHandler(*i);
441 // ### it exists now; need to remember if we can delete it 442 // ### it exists now; need to remember if we can delete it
442 } 443 }
443 } 444 }
444 else { 445 else {
445 lib->unload(); 446 lib->unload();
446 delete lib; 447 delete lib;
447 } 448 }
448 } 449 }
449 } 450 }
450 451
451}; 452};
452 453
453class ResourceMimeFactory : public QMimeSourceFactory 454class ResourceMimeFactory : public QMimeSourceFactory
454{ 455{
455public: 456public:
456 ResourceMimeFactory() : resImage( 0 ) 457 ResourceMimeFactory() : resImage( 0 )
457 { 458 {
458 setFilePath( Global::helpPath() ); 459 setFilePath( Global::helpPath() );
459 setExtensionType( "html", "text/html;charset=UTF-8" ); 460 setExtensionType( "html", "text/html;charset=UTF-8" );
460 } 461 }
461 ~ResourceMimeFactory() { 462 ~ResourceMimeFactory() {
462 delete resImage; 463 delete resImage;
463 } 464 }
464 465
465 const QMimeSource* data( const QString& abs_name ) const 466 const QMimeSource* data( const QString& abs_name ) const
466 { 467 {
467 const QMimeSource * r = QMimeSourceFactory::data( abs_name ); 468 const QMimeSource * r = QMimeSourceFactory::data( abs_name );
468 if ( !r ) { 469 if ( !r ) {
469 int sl = abs_name.length(); 470 int sl = abs_name.length();
470 do { 471 do {
471 sl = abs_name.findRev( '/', sl - 1 ); 472 sl = abs_name.findRev( '/', sl - 1 );
472 QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name; 473 QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name;
473 int dot = name.findRev( '.' ); 474 int dot = name.findRev( '.' );
474 if ( dot >= 0 ) 475 if ( dot >= 0 )
@@ -2082,209 +2083,214 @@ void QPEApplication::timerEvent( QTimerEvent *e )
2082 RightButton, LeftButton ) ); 2083 RightButton, LeftButton ) );
2083 killTimer( d->presstimer ); 2084 killTimer( d->presstimer );
2084 d->presstimer = 0; 2085 d->presstimer = 0;
2085 d->rightpressed = TRUE; 2086 d->rightpressed = TRUE;
2086#ifdef OPIE_WITHROHFEEDBACK 2087#ifdef OPIE_WITHROHFEEDBACK
2087 d->RoH->stop(); 2088 d->RoH->stop();
2088#endif 2089#endif
2089 } 2090 }
2090} 2091}
2091 2092
2092void QPEApplication::removeSenderFromStylusDict() 2093void QPEApplication::removeSenderFromStylusDict()
2093{ 2094{
2094 stylusDict->remove 2095 stylusDict->remove
2095 ( ( void* ) sender() ); 2096 ( ( void* ) sender() );
2096 if ( d->presswidget == sender() ) 2097 if ( d->presswidget == sender() )
2097 d->presswidget = 0; 2098 d->presswidget = 0;
2098} 2099}
2099 2100
2100/*! 2101/*!
2101 \internal 2102 \internal
2102*/ 2103*/
2103bool QPEApplication::keyboardGrabbed() const 2104bool QPEApplication::keyboardGrabbed() const
2104{ 2105{
2105 return d->kbgrabbed; 2106 return d->kbgrabbed;
2106} 2107}
2107 2108
2108 2109
2109/*! 2110/*!
2110 Reverses the effect of grabKeyboard(). This is called automatically 2111 Reverses the effect of grabKeyboard(). This is called automatically
2111 on program exit. 2112 on program exit.
2112*/ 2113*/
2113void QPEApplication::ungrabKeyboard() 2114void QPEApplication::ungrabKeyboard()
2114{ 2115{
2115 ((QPEApplication *) qApp )-> d-> kbgrabbed = false; 2116 ((QPEApplication *) qApp )-> d-> kbgrabbed = false;
2116} 2117}
2117 2118
2118/*! 2119/*!
2119 Grabs the physical keyboard keys, e.g. the application's launching 2120 Grabs the physical keyboard keys, e.g. the application's launching
2120 keys. Instead of launching applications when these keys are pressed 2121 keys. Instead of launching applications when these keys are pressed
2121 the signals emitted are sent to this application instead. Some games 2122 the signals emitted are sent to this application instead. Some games
2122 programs take over the launch keys in this way to make interaction 2123 programs take over the launch keys in this way to make interaction
2123 easier. 2124 easier.
2124 2125
2125 \sa ungrabKeyboard() 2126 \sa ungrabKeyboard()
2126*/ 2127*/
2127void QPEApplication::grabKeyboard() 2128void QPEApplication::grabKeyboard()
2128{ 2129{
2129 ((QPEApplication *) qApp )-> d-> kbgrabbed = true; 2130 ((QPEApplication *) qApp )-> d-> kbgrabbed = true;
2130} 2131}
2131 2132
2132/*! 2133/*!
2133 \reimp 2134 \reimp
2134*/ 2135*/
2135int QPEApplication::exec() 2136int QPEApplication::exec()
2136{ 2137{
2137 d->qcopQok = true; 2138 d->qcopQok = true;
2138#ifndef QT_NO_COP 2139#ifndef QT_NO_COP
2139 d->sendQCopQ(); 2140 d->sendQCopQ();
2140 if ( !d->keep_running ) 2141 if ( !d->keep_running )
2141 processEvents(); // we may have received QCop messages in the meantime. 2142 processEvents(); // we may have received QCop messages in the meantime.
2142#endif 2143#endif
2143 2144
2144 if ( d->keep_running ) 2145 if ( d->keep_running )
2145 //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() ) 2146 //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() )
2146 return QApplication::exec(); 2147 return QApplication::exec();
2147 2148
2148#ifndef QT_NO_COP 2149#ifndef QT_NO_COP
2149 2150
2150 { 2151 {
2151 QCopEnvelope e( "QPE/System", "closing(QString)" ); 2152 QCopEnvelope e( "QPE/System", "closing(QString)" );
2152 e << d->appName; 2153 e << d->appName;
2153 } 2154 }
2154#endif 2155#endif
2155 processEvents(); 2156 processEvents();
2156 return 0; 2157 return 0;
2157} 2158}
2158 2159
2159/*! 2160/*!
2160 \internal 2161 \internal
2161 External request for application to quit. Quits if possible without 2162 External request for application to quit. Quits if possible without
2162 loosing state. 2163 loosing state.
2163*/ 2164*/
2164void QPEApplication::tryQuit() 2165void QPEApplication::tryQuit()
2165{ 2166{
2166 if ( activeModalWidget() ) 2167 if ( activeModalWidget() )
2167 return ; // Inside modal loop or konsole. Too hard to save state. 2168 return ; // Inside modal loop or konsole. Too hard to save state.
2168#ifndef QT_NO_COP 2169#ifndef QT_NO_COP
2169 2170
2170 { 2171 {
2171 QCopEnvelope e( "QPE/System", "closing(QString)" ); 2172 QCopEnvelope e( "QPE/System", "closing(QString)" );
2172 e << d->appName; 2173 e << d->appName;
2173 } 2174 }
2174#endif 2175#endif
2175 if ( d->keep_running ) 2176 if ( d->keep_running )
2176 d->store_widget_rect(d->qpe_main_widget, d->appName); 2177 d->store_widget_rect(d->qpe_main_widget, d->appName);
2177 processEvents(); 2178 processEvents();
2178 2179
2179 quit(); 2180 quit();
2180} 2181}
2181 2182
2182 2183
2183/*! 2184/*!
2184 \internal 2185 \internal
2185 User initiated quit. Makes the window 'Go Away'. If preloaded this means 2186 User initiated quit. Makes the window 'Go Away'. If preloaded this means
2186 hiding the window. If not it means quitting the application. 2187 hiding the window. If not it means quitting the application.
2187 As this is user initiated we don't need to check state. 2188 As this is user initiated we don't need to check state.
2188*/ 2189*/
2189void QPEApplication::hideOrQuit() 2190void QPEApplication::hideOrQuit()
2190{ 2191{
2191 if ( d->keep_running ) 2192 if ( d->keep_running )
2192 d->store_widget_rect(d->qpe_main_widget, d->appName); 2193 d->store_widget_rect(d->qpe_main_widget, d->appName);
2193 processEvents(); 2194 processEvents();
2194 2195
2195 // If we are a preloaded application we don't actually quit, so emit 2196 // If we are a preloaded application we don't actually quit, so emit
2196 // a System message indicating we're quasi-closing. 2197 // a System message indicating we're quasi-closing.
2197 if ( d->preloaded && d->qpe_main_widget ) 2198 if ( d->preloaded && d->qpe_main_widget )
2198#ifndef QT_NO_COP 2199#ifndef QT_NO_COP
2199 2200
2200 { 2201 {
2201 QCopEnvelope e("QPE/System", "fastAppHiding(QString)" ); 2202 QCopEnvelope e("QPE/System", "fastAppHiding(QString)" );
2202 e << d->appName; 2203 e << d->appName;
2203 d->qpe_main_widget->hide(); 2204 d->qpe_main_widget->hide();
2204 } 2205 }
2205#endif 2206#endif
2206 else 2207 else
2207 quit(); 2208 quit();
2208} 2209}
2209 2210
2211bool QPEApplication::isSaveWindowsPos()
2212{
2213 return saveWindowsPos;
2214}
2215
2210#if (__GNUC__ > 2 ) && !defined(_OS_MACX_) 2216#if (__GNUC__ > 2 ) && !defined(_OS_MACX_)
2211extern "C" void __cxa_pure_virtual(); 2217extern "C" void __cxa_pure_virtual();
2212 2218
2213void __cxa_pure_virtual() 2219void __cxa_pure_virtual()
2214{ 2220{
2215 fprintf( stderr, "Pure virtual called\n"); 2221 fprintf( stderr, "Pure virtual called\n");
2216 abort(); 2222 abort();
2217 2223
2218} 2224}
2219 2225
2220#endif 2226#endif
2221 2227
2222 2228
2223#if defined(OPIE_NEW_MALLOC) 2229#if defined(OPIE_NEW_MALLOC)
2224 2230
2225// The libraries with the skiff package (and possibly others) have 2231// The libraries with the skiff package (and possibly others) have
2226// completely useless implementations of builtin new and delete that 2232// completely useless implementations of builtin new and delete that
2227// use about 50% of your CPU. Here we revert to the simple libc 2233// use about 50% of your CPU. Here we revert to the simple libc
2228// functions. 2234// functions.
2229 2235
2230void* operator new[]( size_t size ) 2236void* operator new[]( size_t size )
2231{ 2237{
2232 return malloc( size ); 2238 return malloc( size );
2233} 2239}
2234 2240
2235void* operator new( size_t size ) 2241void* operator new( size_t size )
2236{ 2242{
2237 return malloc( size ); 2243 return malloc( size );
2238} 2244}
2239 2245
2240void operator delete[]( void* p ) 2246void operator delete[]( void* p )
2241{ 2247{
2242 if ( p ) 2248 if ( p )
2243 free( p ); 2249 free( p );
2244} 2250}
2245 2251
2246void operator delete[]( void* p, size_t /*size*/ ) 2252void operator delete[]( void* p, size_t /*size*/ )
2247{ 2253{
2248 if ( p ) 2254 if ( p )
2249 free( p ); 2255 free( p );
2250} 2256}
2251 2257
2252 2258
2253void operator delete( void* p ) 2259void operator delete( void* p )
2254{ 2260{
2255 if ( p ) 2261 if ( p )
2256 free( p ); 2262 free( p );
2257} 2263}
2258 2264
2259void operator delete( void* p, size_t /*size*/ ) 2265void operator delete( void* p, size_t /*size*/ )
2260{ 2266{
2261 if ( p ) 2267 if ( p )
2262 free( p ); 2268 free( p );
2263} 2269}
2264 2270
2265#endif 2271#endif
2266 2272
2267#if ( QT_VERSION <= 230 ) && !defined(SINGLE_APP) 2273#if ( QT_VERSION <= 230 ) && !defined(SINGLE_APP)
2268#include <qwidgetlist.h> 2274#include <qwidgetlist.h>
2269#ifdef QWS 2275#ifdef QWS
2270#include <qgfx_qws.h> 2276#include <qgfx_qws.h>
2271extern QRect qt_maxWindowRect; 2277extern QRect qt_maxWindowRect;
2272void qt_setMaxWindowRect(const QRect& r ) 2278void qt_setMaxWindowRect(const QRect& r )
2273{ 2279{
2274 qt_maxWindowRect = qt_screen->mapFromDevice( r, 2280 qt_maxWindowRect = qt_screen->mapFromDevice( r,
2275 qt_screen->mapToDevice( QSize( qt_screen->width(), qt_screen->height() ) ) ); 2281 qt_screen->mapToDevice( QSize( qt_screen->width(), qt_screen->height() ) ) );
2276 // Re-resize any maximized windows 2282 // Re-resize any maximized windows
2277 QWidgetList* l = QApplication::topLevelWidgets(); 2283 QWidgetList* l = QApplication::topLevelWidgets();
2278 if ( l ) { 2284 if ( l ) {
2279 QWidget * w = l->first(); 2285 QWidget * w = l->first();
2280 while ( w ) { 2286 while ( w ) {
2281 if ( w->isVisible() && w->isMaximized() ) { 2287 if ( w->isVisible() && w->isMaximized() ) {
2282 w->showMaximized(); 2288 w->showMaximized();
2283 } 2289 }
2284 w = l->next(); 2290 w = l->next();
2285 } 2291 }
2286 delete l; 2292 delete l;
2287 } 2293 }
2288} 2294}
2289#endif 2295#endif
2290#endif 2296#endif
diff --git a/library/qpeapplication.h b/library/qpeapplication.h
index 6486cad..7c99a9a 100644
--- a/library/qpeapplication.h
+++ b/library/qpeapplication.h
@@ -12,231 +12,233 @@
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#ifndef __QPE_APPLICATION_H__ 20#ifndef __QPE_APPLICATION_H__
21#define __QPE_APPLICATION_H__ 21#define __QPE_APPLICATION_H__
22 22
23#include <stdlib.h> // for setenv() 23#include <stdlib.h> // for setenv()
24 24
25#include <qglobal.h> 25#include <qglobal.h>
26#include <qapplication.h> 26#include <qapplication.h>
27#include <qdialog.h> 27#include <qdialog.h>
28#include <qwsdisplay_qws.h> 28#include <qwsdisplay_qws.h>
29#if defined(_WS_QWS_) && !defined(Q_WS_QWS) 29#if defined(_WS_QWS_) && !defined(Q_WS_QWS)
30#define Q_WS_QWS 30#define Q_WS_QWS
31#endif 31#endif
32#include "qpedecoration_qws.h" 32#include "qpedecoration_qws.h"
33#include "timestring.h" 33#include "timestring.h"
34#include "qpeglobal.h" 34#include "qpeglobal.h"
35 35
36class QCopChannel; 36class QCopChannel;
37class QPEApplicationData; 37class QPEApplicationData;
38class QWSEvent; 38class QWSEvent;
39class QWSKeyEvent; 39class QWSKeyEvent;
40 40
41/** 41/**
42 \brief The QPEApplication class implements various system services 42 \brief The QPEApplication class implements various system services
43 that are available to all Qtopia applications. 43 that are available to all Qtopia applications.
44 44
45 Simply by using QPEApplication instead of QApplication, a standard Qt 45 Simply by using QPEApplication instead of QApplication, a standard Qt
46 application becomes a Qtopia application. It automatically follows 46 application becomes a Qtopia application. It automatically follows
47 style changes, quits and raises, and in the 47 style changes, quits and raises, and in the
48 case of \link docwidget.html document-oriented\endlink applications, 48 case of \link docwidget.html document-oriented\endlink applications,
49 changes the currently displayed document in response to the environment. 49 changes the currently displayed document in response to the environment.
50 50
51 To create a \link docwidget.html document-oriented\endlink 51 To create a \link docwidget.html document-oriented\endlink
52 application use showMainDocumentWidget(); to create a 52 application use showMainDocumentWidget(); to create a
53 non-document-oriented application use showMainWidget(). The 53 non-document-oriented application use showMainWidget(). The
54 keepRunning() function indicates whether the application will 54 keepRunning() function indicates whether the application will
55 continue running after it's processed the last \link qcop.html 55 continue running after it's processed the last \link qcop.html
56 QCop\endlink message. This can be changed using setKeepRunning(). 56 QCop\endlink message. This can be changed using setKeepRunning().
57 57
58 A variety of signals are emitted when certain events occur, for 58 A variety of signals are emitted when certain events occur, for
59 example, timeChanged(), clockChanged(), weekChanged(), 59 example, timeChanged(), clockChanged(), weekChanged(),
60 dateFormatChanged() and volumeChanged(). If the application receives 60 dateFormatChanged() and volumeChanged(). If the application receives
61 a \link qcop.html QCop\endlink message on the application's 61 a \link qcop.html QCop\endlink message on the application's
62 QPE/Application/\e{appname} channel, the appMessage() signal is 62 QPE/Application/\e{appname} channel, the appMessage() signal is
63 emitted. There are also flush() and reload() signals, which 63 emitted. There are also flush() and reload() signals, which
64 are emitted when synching begins and ends respectively - upon these 64 are emitted when synching begins and ends respectively - upon these
65 signals, the application should save and reload any data 65 signals, the application should save and reload any data
66 files that are involved in synching. Most of these signals will initially 66 files that are involved in synching. Most of these signals will initially
67 be received and unfiltered through the appMessage() signal. 67 be received and unfiltered through the appMessage() signal.
68 68
69 This class also provides a set of useful static functions. The 69 This class also provides a set of useful static functions. The
70 qpeDir() and documentDir() functions return the respective paths. 70 qpeDir() and documentDir() functions return the respective paths.
71 The grabKeyboard() and ungrabKeyboard() functions are used to 71 The grabKeyboard() and ungrabKeyboard() functions are used to
72 control whether the application takes control of the device's 72 control whether the application takes control of the device's
73 physical buttons (e.g. application launch keys). The stylus' mode of 73 physical buttons (e.g. application launch keys). The stylus' mode of
74 operation is set with setStylusOperation() and retrieved with 74 operation is set with setStylusOperation() and retrieved with
75 stylusOperation(). There are also setInputMethodHint() and 75 stylusOperation(). There are also setInputMethodHint() and
76 inputMethodHint() functions. 76 inputMethodHint() functions.
77 77
78 \ingroup qtopiaemb 78 \ingroup qtopiaemb
79*/ 79*/
80class QPEApplication : public QApplication 80class QPEApplication : public QApplication
81{ 81{
82 Q_OBJECT 82 Q_OBJECT
83public: 83public:
84 QPEApplication( int& argc, char **argv, Type=GuiClient ); 84 QPEApplication( int& argc, char **argv, Type=GuiClient );
85 ~QPEApplication(); 85 ~QPEApplication();
86 86
87 static QString qpeDir(); 87 static QString qpeDir();
88 static QString documentDir(); 88 static QString documentDir();
89 void applyStyle(); 89 void applyStyle();
90 void reset(); 90 void reset();
91 static int defaultRotation(); 91 static int defaultRotation();
92 static void setDefaultRotation(int r); 92 static void setDefaultRotation(int r);
93 static void setCurrentRotation(int r); 93 static void setCurrentRotation(int r);
94 static void setCurrentMode(int x, int y, int depth ); 94 static void setCurrentMode(int x, int y, int depth );
95 static void grabKeyboard(); 95 static void grabKeyboard();
96 static void ungrabKeyboard(); 96 static void ungrabKeyboard();
97 97
98 enum StylusMode { 98 enum StylusMode {
99 LeftOnly, 99 LeftOnly,
100 RightOnHold 100 RightOnHold
101 // RightOnHoldLeftDelayed, etc. 101 // RightOnHoldLeftDelayed, etc.
102 }; 102 };
103 static void setStylusOperation( QWidget*, StylusMode ); 103 static void setStylusOperation( QWidget*, StylusMode );
104 static StylusMode stylusOperation( QWidget* ); 104 static StylusMode stylusOperation( QWidget* );
105 105
106 enum InputMethodHint { 106 enum InputMethodHint {
107 Normal, 107 Normal,
108 AlwaysOff, 108 AlwaysOff,
109 AlwaysOn 109 AlwaysOn
110 }; 110 };
111 111
112 enum screenSaverHint { 112 enum screenSaverHint {
113 Disable = 0, 113 Disable = 0,
114 DisableLightOff = 1, 114 DisableLightOff = 1,
115 DisableSuspend = 2, 115 DisableSuspend = 2,
116 Enable = 100 116 Enable = 100
117 }; 117 };
118 118
119 static void setInputMethodHint( QWidget *, InputMethodHint ); 119 static void setInputMethodHint( QWidget *, InputMethodHint );
120 static InputMethodHint inputMethodHint( QWidget * ); 120 static InputMethodHint inputMethodHint( QWidget * );
121 121
122 void showMainWidget( QWidget*, bool nomax=FALSE ); 122 void showMainWidget( QWidget*, bool nomax=FALSE );
123 void showMainDocumentWidget( QWidget*, bool nomax=FALSE ); 123 void showMainDocumentWidget( QWidget*, bool nomax=FALSE );
124 124
125 static void showDialog( QDialog*, bool nomax=FALSE ) QPE_WEAK_SYMBOL; 125 static void showDialog( QDialog*, bool nomax=FALSE ) QPE_WEAK_SYMBOL;
126 static int execDialog ( QDialog*, bool nomax=FALSE ) QPE_WEAK_SYMBOL; 126 static int execDialog ( QDialog*, bool nomax=FALSE ) QPE_WEAK_SYMBOL;
127 static void showWidget( QWidget*, bool nomax=FALSE ) QPE_WEAK_SYMBOL; 127 static void showWidget( QWidget*, bool nomax=FALSE ) QPE_WEAK_SYMBOL;
128 /* Merge setTempScreenSaverMode */ 128 /* Merge setTempScreenSaverMode */
129#ifdef QTOPIA_INTERNAL_INITAPP 129#ifdef QTOPIA_INTERNAL_INITAPP
130 void initApp( int argv, char **argv ); 130 void initApp( int argv, char **argv );
131#endif 131#endif
132 132
133 static void setKeepRunning(); 133 static void setKeepRunning();
134 bool keepRunning() const; 134 bool keepRunning() const;
135 135
136 bool keyboardGrabbed() const; 136 bool keyboardGrabbed() const;
137 137
138 int exec(); 138 int exec();
139 139
140 static bool isSaveWindowsPos();
141
140signals: 142signals:
141 void clientMoused(); 143 void clientMoused();
142 void timeChanged(); 144 void timeChanged();
143 void clockChanged( bool pm ); 145 void clockChanged( bool pm );
144 void micChanged( bool muted ); 146 void micChanged( bool muted );
145 void volumeChanged( bool muted ); 147 void volumeChanged( bool muted );
146 void appMessage( const QCString& msg, const QByteArray& data); 148 void appMessage( const QCString& msg, const QByteArray& data);
147 void weekChanged( bool startOnMonday ); 149 void weekChanged( bool startOnMonday );
148 void dateFormatChanged( DateFormat ); 150 void dateFormatChanged( DateFormat );
149 void flush(); 151 void flush();
150 void reload(); 152 void reload();
151 /* linkChanged signal */ 153 /* linkChanged signal */
152 154
153private slots: 155private slots:
154 void systemMessage( const QCString &msg, const QByteArray &data ); 156 void systemMessage( const QCString &msg, const QByteArray &data );
155 void pidMessage( const QCString &msg, const QByteArray &data ); 157 void pidMessage( const QCString &msg, const QByteArray &data );
156 void removeSenderFromStylusDict(); 158 void removeSenderFromStylusDict();
157 void hideOrQuit(); 159 void hideOrQuit();
158 160
159protected: 161protected:
160 bool qwsEventFilter( QWSEvent * ); 162 bool qwsEventFilter( QWSEvent * );
161 void internalSetStyle( const QString &style ); 163 void internalSetStyle( const QString &style );
162 void prepareForTermination(bool willrestart); 164 void prepareForTermination(bool willrestart);
163 virtual void restart(); 165 virtual void restart();
164 virtual void shutdown(); 166 virtual void shutdown();
165 bool eventFilter( QObject *, QEvent * ); 167 bool eventFilter( QObject *, QEvent * );
166 void timerEvent( QTimerEvent * ); 168 void timerEvent( QTimerEvent * );
167 bool raiseAppropriateWindow(); 169 bool raiseAppropriateWindow();
168 virtual void tryQuit(); 170 virtual void tryQuit();
169private: 171private:
170 void mapToDefaultAction( QWSKeyEvent *ke, int defKey ); 172 void mapToDefaultAction( QWSKeyEvent *ke, int defKey );
171 void processQCopFile(); 173 void processQCopFile();
172 174
173#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 175#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
174 QCopChannel *sysChannel; 176 QCopChannel *sysChannel;
175 QCopChannel *pidChannel; 177 QCopChannel *pidChannel;
176#endif 178#endif
177 QPEApplicationData *d; 179 QPEApplicationData *d;
178 180
179 bool reserved_sh; 181 bool reserved_sh;
180 182
181}; 183};
182 184
183 185
184 186
185enum Transformation { Rot0, Rot90, Rot180, Rot270 }; /* from qgfxtransformed_qws.cpp */ 187enum Transformation { Rot0, Rot90, Rot180, Rot270 }; /* from qgfxtransformed_qws.cpp */
186 188
187inline int TransToDeg ( Transformation t ) 189inline int TransToDeg ( Transformation t )
188{ 190{
189 int d = static_cast<int>( t ); 191 int d = static_cast<int>( t );
190 return d * 90; 192 return d * 90;
191} 193}
192 194
193inline Transformation DegToTrans ( int d ) 195inline Transformation DegToTrans ( int d )
194{ 196{
195 Transformation t = static_cast<Transformation>( d / 90 ); 197 Transformation t = static_cast<Transformation>( d / 90 );
196 return t; 198 return t;
197} 199}
198 200
199/* 201/*
200 * Set current rotation of Opie, and rotation for newly started apps. 202 * Set current rotation of Opie, and rotation for newly started apps.
201 * Differs from setDefaultRotation in that 1) it rotates currently running apps, 203 * Differs from setDefaultRotation in that 1) it rotates currently running apps,
202 * and 2) does not set deforient or save orientation to qpe.conf. 204 * and 2) does not set deforient or save orientation to qpe.conf.
203 */ 205 */
204 206
205inline void QPEApplication::setCurrentRotation( int r ) 207inline void QPEApplication::setCurrentRotation( int r )
206{ 208{
207 // setTransformation has been introduced in Qt/Embedded 2.3.4 snapshots 209 // setTransformation has been introduced in Qt/Embedded 2.3.4 snapshots
208 // for compatibility with the SharpROM use fallback to setDefaultTransformation() 210 // for compatibility with the SharpROM use fallback to setDefaultTransformation()
209#if QT_VERSION > 233 211#if QT_VERSION > 233
210 Transformation e = DegToTrans( r ); 212 Transformation e = DegToTrans( r );
211 QCString old = getenv("QWS_DISPLAY") ? getenv( "QWS_DISPLAY" ) : "Transformed"; 213 QCString old = getenv("QWS_DISPLAY") ? getenv( "QWS_DISPLAY" ) : "Transformed";
212 int j = 0; 214 int j = 0;
213 QString driver( old.left( ( ( j = old.find( ':' ) ) >= 0 ) ? j : old.size() ).data() ); 215 QString driver( old.left( ( ( j = old.find( ':' ) ) >= 0 ) ? j : old.size() ).data() );
214 ::setenv( "QWS_DISPLAY", QString( "%1:Rot%2:0" ).arg( driver ).arg( r ).latin1(), 1 ); 216 ::setenv( "QWS_DISPLAY", QString( "%1:Rot%2:0" ).arg( driver ).arg( r ).latin1(), 1 );
215 qApp->desktop()->qwsDisplay()->setTransformation( e ); 217 qApp->desktop()->qwsDisplay()->setTransformation( e );
216#else 218#else
217 setDefaultRotation( r ); 219 setDefaultRotation( r );
218#endif 220#endif
219} 221}
220 222
221/* 223/*
222 * Qtopia 1.7 SDK compatibility macros 224 * Qtopia 1.7 SDK compatibility macros
223 * FIXME: Support Opie Quicklaunch Interface 225 * FIXME: Support Opie Quicklaunch Interface
224 */ 226 */
225 #define QTOPIA_ADD_APPLICATION(NAME,IMPLEMENTATION) \ 227 #define QTOPIA_ADD_APPLICATION(NAME,IMPLEMENTATION) \
226 int main( int argc, char** argv ) \ 228 int main( int argc, char** argv ) \
227 { \ 229 { \
228 QPEApplication app( argc, argv );\ 230 QPEApplication app( argc, argv );\
229 IMPLEMENTATION* mw = new IMPLEMENTATION(); \ 231 IMPLEMENTATION* mw = new IMPLEMENTATION(); \
230 app.showMainWidget( mw ); \ 232 app.showMainWidget( mw ); \
231 app.exec(); \ 233 app.exec(); \
232 } 234 }
233#define QTOPIA_MAIN // Bee-Bop-Alula 235#define QTOPIA_MAIN // Bee-Bop-Alula
234 236
235/* 237/*
236 * -remove me 238 * -remove me
237 */ 239 */
238#ifdef Q_WS_QWS 240#ifdef Q_WS_QWS
239extern Q_EXPORT QRect qt_maxWindowRect; 241extern Q_EXPORT QRect qt_maxWindowRect;
240#endif 242#endif
241 243
242#endif 244#endif
diff --git a/library/widget_showing.cpp b/library/widget_showing.cpp
index e43a16a..cc1bfb2 100644
--- a/library/widget_showing.cpp
+++ b/library/widget_showing.cpp
@@ -1,79 +1,74 @@
1/* 1/*
2 This file is part of the OPIE Project 2 This file is part of the OPIE Project
3 Copyright (c) 2004 Andreas Richter <ar@handhelds.org> 3 Copyright (c) 2004 Andreas Richter <ar@handhelds.org>
4 Copyright (c) 2004 Holger Hans Peter Freyther <freyther@handhelds.org> 4 Copyright (c) 2004 Holger Hans Peter Freyther <freyther@handhelds.org>
5               =. 5               =.
6             .=l. 6             .=l.
7           .>+-= 7           .>+-=
8 _;:,     .>    :=|. This library is free software; you can 8 _;:,     .>    :=|. This library is free software; you can
9.> <`_,   >  .   <= redistribute it and/or modify it under 9.> <`_,   >  .   <= redistribute it and/or modify it under
10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
11.="- .-=="i,     .._ License as published by the Free Software 11.="- .-=="i,     .._ License as published by the Free Software
12 - .   .-<_>     .<> Foundation; either version 2 of the License, 12 - .   .-<_>     .<> Foundation; either version 2 of the License,
13     ._= =}       : or (at your option) any later version. 13     ._= =}       : or (at your option) any later version.
14    .%`+i>       _;_. 14    .%`+i>       _;_.
15    .i_,=:_.      -<s. This library is distributed in the hope that 15    .i_,=:_.      -<s. This library is distributed in the hope that
16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
17    : ..    .:,     . . . without even the implied warranty of 17    : ..    .:,     . . . without even the implied warranty of
18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; Library General Public License for more 20..}^=.=       =       ; Library General Public License for more
21++=   -.     .`     .: details. 21++=   -.     .`     .: details.
22 :     =  ...= . :.=- 22 :     =  ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU 23 -.   .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = Library General Public License along with 24  -_. . .   )=.  = Library General Public License along with
25    --        :-=` this library; see the file COPYING.LIB. 25    --        :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation, 26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330, 27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA. 28 Boston, MA 02111-1307, USA.
29 29
30*/ 30*/
31 31
32#include <qtopia/qpeapplication.h> 32#include <qtopia/qpeapplication.h>
33 33
34#ifdef Q_WS_QWS 34#ifdef Q_WS_QWS
35extern Q_EXPORT QRect qt_maxWindowRect; 35extern Q_EXPORT QRect qt_maxWindowRect;
36#endif 36#endif
37 37
38void QPEApplication::showDialog( QDialog* d, bool nomax ) 38void QPEApplication::showDialog( QDialog* d, bool nomax )
39{ 39{
40 showWidget( d, nomax ); 40 showWidget( d, nomax );
41} 41}
42 42
43int QPEApplication::execDialog( QDialog* d, bool nomax ) 43int QPEApplication::execDialog( QDialog* d, bool nomax )
44{ 44{
45 showDialog( d, nomax ); 45 showDialog( d, nomax );
46 return d->exec(); 46 return d->exec();
47} 47}
48 48
49void QPEApplication::showWidget( QWidget* wg, bool nomax ) { 49void QPEApplication::showWidget( QWidget* wg, bool nomax ) {
50 if ( wg->isVisible() ) { 50 if ( wg->isVisible() ) {
51 wg->show(); 51 wg->show();
52 return; 52 return;
53 } 53 }
54 54
55#ifdef OPIE_NO_WINDOWED 55 if ( !isSaveWindowsPos() || (!nomax
56 Q_UNUSED( nomax ) 56 && ( qApp->desktop()->width() <= 30 )) ){
57 if ( TRUE ) {
58#else
59 if ( !nomax
60 && ( qApp->desktop()->width() <= 320 ) ){
61#endif
62 wg->showMaximized(); 57 wg->showMaximized();
63 } else { 58 } else {
64#ifdef Q_WS_QWS 59#ifdef Q_WS_QWS
65 QSize desk = QSize( qApp->desktop()->width(), qApp->desktop()->height() ); 60 QSize desk = QSize( qApp->desktop()->width(), qApp->desktop()->height() );
66#else 61#else
67 QSize desk = QSize( qt_maxWindowRect.width(), qt_maxWindowRect.height() ); 62 QSize desk = QSize( qt_maxWindowRect.width(), qt_maxWindowRect.height() );
68#endif 63#endif
69 64
70 QSize sh = wg->sizeHint(); 65 QSize sh = wg->sizeHint();
71 int w = QMAX( sh.width(), wg->width() ); 66 int w = QMAX( sh.width(), wg->width() );
72 int h = QMAX( sh.height(), wg->height() ); 67 int h = QMAX( sh.height(), wg->height() );
73// desktop widget-frame taskbar 68// desktop widget-frame taskbar
74 w = QMIN( w, ( desk.width() - ( wg->frameGeometry().width() - wg->geometry().width() ) - 25 ) ); 69 w = QMIN( w, ( desk.width() - ( wg->frameGeometry().width() - wg->geometry().width() ) - 25 ) );
75 h = QMIN( h, ( desk.height() - ( wg->frameGeometry().height() - wg->geometry().height() ) - 25 ) ); 70 h = QMIN( h, ( desk.height() - ( wg->frameGeometry().height() - wg->geometry().height() ) - 25 ) );
76 wg->resize( w, h ); 71 wg->resize( w, h );
77 wg->show(); 72 wg->show();
78 } 73 }
79} 74}