summaryrefslogtreecommitdiff
path: root/library/qpeapplication.cpp
authorllornkcor <llornkcor>2004-04-25 08:45:33 (UTC)
committer llornkcor <llornkcor>2004-04-25 08:45:33 (UTC)
commitfc1f0001f53f57b625f337a68532984959e6d8dd (patch) (unidiff)
treec333201e13d7b17a64fcdb1af5805a8b19af6b73 /library/qpeapplication.cpp
parent73f0c227fc94bc4dea12e4eb2384bdff2e9561eb (diff)
downloadopie-fc1f0001f53f57b625f337a68532984959e6d8dd.zip
opie-fc1f0001f53f57b625f337a68532984959e6d8dd.tar.gz
opie-fc1f0001f53f57b625f337a68532984959e6d8dd.tar.bz2
fix persistence in other widgets
Diffstat (limited to 'library/qpeapplication.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--library/qpeapplication.cpp24
1 files changed, 14 insertions, 10 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp
index 90cd5f1..ae1632e 100644
--- a/library/qpeapplication.cpp
+++ b/library/qpeapplication.cpp
@@ -1,761 +1,765 @@
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#endif 83#endif
84 84
85#include "alarmserver.h" 85#include "alarmserver.h"
86#include "applnk.h" 86#include "applnk.h"
87#include "qpemenubar.h" 87#include "qpemenubar.h"
88#include "textcodecinterface.h" 88#include "textcodecinterface.h"
89#include "imagecodecinterface.h" 89#include "imagecodecinterface.h"
90 90
91#include <unistd.h> 91#include <unistd.h>
92#include <sys/file.h> 92#include <sys/file.h>
93#include <sys/ioctl.h> 93#include <sys/ioctl.h>
94#ifndef QT_NO_SOUND 94#ifndef QT_NO_SOUND
95#include <sys/soundcard.h> 95#include <sys/soundcard.h>
96#endif 96#endif
97#include "qt_override_p.h" 97#include "qt_override_p.h"
98 98
99class HackWidget : public QWidget 99class HackWidget : public QWidget
100{ 100{
101public: 101public:
102 bool needsOk() 102 bool needsOk()
103 { return (getWState() & WState_Reserved1 ); } 103 { return (getWState() & WState_Reserved1 ); }
104 104
105 QRect normalGeometry() 105 QRect normalGeometry()
106 { return topData()->normalGeometry; }; 106 { return topData()->normalGeometry; };
107}; 107};
108 108
109class QPEApplicationData 109class QPEApplicationData
110{ 110{
111public: 111public:
112 QPEApplicationData ( ) 112 QPEApplicationData ( )
113 : presstimer( 0 ), presswidget( 0 ), rightpressed( false ), kbgrabbed( false ), 113 : presstimer( 0 ), presswidget( 0 ), rightpressed( false ), kbgrabbed( false ),
114 notbusysent( false ), preloaded( false ), forceshow( false ), nomaximize( false ), 114 notbusysent( false ), preloaded( false ), forceshow( false ), nomaximize( false ),
115 keep_running( true ), qcopQok( false ), qpe_main_widget( 0 ) 115 keep_running( true ), qcopQok( false ), qpe_main_widget( 0 )
116 116
117 {} 117 {}
118 118
119 int presstimer; 119 int presstimer;
120 QWidget* presswidget; 120 QWidget* presswidget;
121 QPoint presspos; 121 QPoint presspos;
122 122
123 bool rightpressed : 1; 123 bool rightpressed : 1;
124 bool kbgrabbed : 1; 124 bool kbgrabbed : 1;
125 bool notbusysent : 1; 125 bool notbusysent : 1;
126 bool preloaded : 1; 126 bool preloaded : 1;
127 bool forceshow : 1; 127 bool forceshow : 1;
128 bool nomaximize : 1; 128 bool nomaximize : 1;
129 bool keep_running : 1; 129 bool keep_running : 1;
130 bool qcopQok : 1; 130 bool qcopQok : 1;
131 131
132 132
133 QStringList langs; 133 QStringList langs;
134 QString appName; 134 QString appName;
135 struct QCopRec 135 struct QCopRec
136 { 136 {
137 QCopRec( const QCString &ch, const QCString &msg, 137 QCopRec( const QCString &ch, const QCString &msg,
138 const QByteArray &d ) : 138 const QByteArray &d ) :
139 channel( ch ), message( msg ), data( d ) 139 channel( ch ), message( msg ), data( d )
140 { } 140 { }
141 141
142 QCString channel; 142 QCString channel;
143 QCString message; 143 QCString message;
144 QByteArray data; 144 QByteArray data;
145 }; 145 };
146 QWidget* qpe_main_widget; 146 QWidget* qpe_main_widget;
147 QGuardedPtr<QWidget> lastraised; 147 QGuardedPtr<QWidget> lastraised;
148 QQueue<QCopRec> qcopq; 148 QQueue<QCopRec> qcopq;
149 QString styleName; 149 QString styleName;
150 QString decorationName; 150 QString decorationName;
151 151
152 void enqueueQCop( const QCString &ch, const QCString &msg, 152 void enqueueQCop( const QCString &ch, const QCString &msg,
153 const QByteArray &data ) 153 const QByteArray &data )
154 { 154 {
155 qcopq.enqueue( new QCopRec( ch, msg, data ) ); 155 qcopq.enqueue( new QCopRec( ch, msg, data ) );
156 } 156 }
157 void sendQCopQ() 157 void sendQCopQ()
158 { 158 {
159 if (!qcopQok ) 159 if (!qcopQok )
160 return; 160 return;
161 161
162 QCopRec * r; 162 QCopRec * r;
163 163
164 while((r=qcopq.dequeue())) { 164 while((r=qcopq.dequeue())) {
165 // remove from queue before sending... 165 // remove from queue before sending...
166 // event loop can come around again before getting 166 // event loop can come around again before getting
167 // back from sendLocally 167 // back from sendLocally
168#ifndef QT_NO_COP 168#ifndef QT_NO_COP
169 QCopChannel::sendLocally( r->channel, r->message, r->data ); 169 QCopChannel::sendLocally( r->channel, r->message, r->data );
170#endif 170#endif
171 171
172 delete r; 172 delete r;
173 } 173 }
174 } 174 }
175 175
176 static void show_mx(QWidget* mw, bool nomaximize, QString &strName/* = QString::null */) 176 static void show_mx(QWidget* mw, bool nomaximize, QString &strName/* = QString::null */)
177 { 177 {
178 if ( mw->isVisible() ) {
179 mw->raise();
180 } else {
181 QPoint p; 178 QPoint p;
182 QSize s; 179 QSize s;
180 bool max;
181 if ( mw->isVisible() ) {
182 if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) {
183 mw->resize(s);
184 mw->move(p);
185 }
186 mw->raise();
187 } else {
183 188
184 if ( mw->layout() && mw->inherits("QDialog") ) { 189 if ( mw->layout() && mw->inherits("QDialog") ) {
185 bool max;
186 if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { 190 if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) {
187 mw->resize(s); 191 mw->resize(s);
188 mw->move(p); 192 mw->move(p);
189 193
190 if ( max && !nomaximize ) 194 if ( max && !nomaximize ) {
191 mw->showMaximized(); 195 mw->showMaximized();
192 else 196 } else {
193 mw->show(); 197 mw->show();
198 }
194 } else { 199 } else {
195 qpe_show_dialog((QDialog*)mw,nomaximize); 200 qpe_show_dialog((QDialog*)mw,nomaximize);
196 } 201 }
197 } else { 202 } else {
198 bool max;
199 if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { 203 if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) {
200 mw->resize(s); 204 mw->resize(s);
201 mw->move(p); 205 mw->move(p);
202 } else { //no stored rectangle, make an estimation 206 } else { //no stored rectangle, make an estimation
203 int x = (qApp->desktop()->width()-mw->frameGeometry().width())/2; 207 int x = (qApp->desktop()->width()-mw->frameGeometry().width())/2;
204 int y = (qApp->desktop()->height()-mw->frameGeometry().height())/2; 208 int y = (qApp->desktop()->height()-mw->frameGeometry().height())/2;
205 mw->move( QMAX(x,0), QMAX(y,0) ); 209 mw->move( QMAX(x,0), QMAX(y,0) );
206#ifdef Q_WS_QWS 210#ifdef Q_WS_QWS
207 if ( !nomaximize ) 211 if ( !nomaximize )
208 mw->showMaximized(); 212 mw->showMaximized();
209#endif 213#endif
210 } 214 }
211 if ( max && !nomaximize ) 215 if ( max && !nomaximize )
212 mw->showMaximized(); 216 mw->showMaximized();
213 else 217 else
214 mw->show(); 218 mw->show();
215 } 219 }
216 } 220 }
217 } 221 }
218// // ugly hack, remove that later after finding a sane solution 222// // ugly hack, remove that later after finding a sane solution
219// // Addendum: Only Sharp currently has models with high resolution but (physically) small displays, 223// // Addendum: Only Sharp currently has models with high resolution but (physically) small displays,
220// // so this is only useful if QT_QWS_SIMPAD is NOT defined. E.g. SIMpad has 800x600 but has 224// // so this is only useful if QT_QWS_SIMPAD is NOT defined. E.g. SIMpad has 800x600 but has
221// // a (physically) large enough display to use the small icons 225// // a (physically) large enough display to use the small icons
222// #if defined(OPIE_HIGH_RES_SMALL_PHY) 226// #if defined(OPIE_HIGH_RES_SMALL_PHY)
223// if ( QPEApplication::desktop() ->width() >= 600 && ( mw->inherits("QMainWindow") || mw->isA("QMainWindow") ) ) { 227// if ( QPEApplication::desktop() ->width() >= 600 && ( mw->inherits("QMainWindow") || mw->isA("QMainWindow") ) ) {
224// ( ( QMainWindow* ) mw )->setUsesBigPixmaps( true ); 228// ( ( QMainWindow* ) mw )->setUsesBigPixmaps( true );
225// } 229// }
226// #endif 230// #endif
227 231
228 // if ( mw->layout() && mw->inherits("QDialog") ) { 232 // if ( mw->layout() && mw->inherits("QDialog") ) {
229 // QPEApplication::showDialog((QDialog*)mw, nomaximize); 233 // QPEApplication::showDialog((QDialog*)mw, nomaximize);
230 // } 234 // }
231 // else { 235 // else {
232// #ifdef Q_WS_QWS 236// #ifdef Q_WS_QWS
233 // if ( !nomaximize ) { 237 // if ( !nomaximize ) {
234 // qDebug("QDialog special case XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); 238 // qDebug("QDialog special case XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
235 // mw->showMaximized(); 239 // mw->showMaximized();
236 // //QPEApplication::showWidget( mw, !nomaximize ); 240 // //QPEApplication::showWidget( mw, !nomaximize );
237 // }else 241 // }else
238// #endif 242// #endif
239 // mw->show(); 243 // mw->show();
240 // } 244 // }
241 //} 245 //}
242 246
243 247
244static void qpe_show_dialog( QDialog* d, bool nomax ) 248static void qpe_show_dialog( QDialog* d, bool nomax )
245{ 249{
246 QSize sh = d->sizeHint(); 250 QSize sh = d->sizeHint();
247 int w = QMAX(sh.width(),d->width()); 251 int w = QMAX(sh.width(),d->width());
248 int h = QMAX(sh.height(),d->height()); 252 int h = QMAX(sh.height(),d->height());
249 253
250 if ( d->parentWidget() && !d->parentWidget()->topLevelWidget()->isMaximized() ) 254 if ( d->parentWidget() && !d->parentWidget()->topLevelWidget()->isMaximized() )
251 nomax = TRUE; 255 nomax = TRUE;
252 256
253#ifndef Q_WS_QWS 257#ifndef Q_WS_QWS
254 QSize s(qApp->desktop()->width(), qApp->desktop()->height() ); 258 QSize s(qApp->desktop()->width(), qApp->desktop()->height() );
255#else 259#else
256 QSize s(qt_maxWindowRect.width(), qt_maxWindowRect.height() ); 260 QSize s(qt_maxWindowRect.width(), qt_maxWindowRect.height() );
257#endif 261#endif
258 262
259 int maxX = s.width() - (d->frameGeometry().width() - d->geometry().width()); 263 int maxX = s.width() - (d->frameGeometry().width() - d->geometry().width());
260 int maxY = s.height() - (d->frameGeometry().height() - d->geometry().height()); 264 int maxY = s.height() - (d->frameGeometry().height() - d->geometry().height());
261 265
262 if ( (w >= maxX && h >= maxY) || ( (!nomax) && ( w > s.width()*3/4 || h > s.height()*3/4 ) ) ) { 266 if ( (w >= maxX && h >= maxY) || ( (!nomax) && ( w > s.width()*3/4 || h > s.height()*3/4 ) ) ) {
263 d->showMaximized(); 267 d->showMaximized();
264 } else { 268 } else {
265 // try centering the dialog around its parent 269 // try centering the dialog around its parent
266 QPoint p(0,0); 270 QPoint p(0,0);
267 if ( d->parentWidget() ) { 271 if ( d->parentWidget() ) {
268 QPoint pp = d->parentWidget()->mapToGlobal( QPoint(0,0) ); 272 QPoint pp = d->parentWidget()->mapToGlobal( QPoint(0,0) );
269 p = QPoint( pp.x() + d->parentWidget()->width()/2, 273 p = QPoint( pp.x() + d->parentWidget()->width()/2,
270 pp.y() + d->parentWidget()->height()/ 2 ); 274 pp.y() + d->parentWidget()->height()/ 2 );
271 } else { 275 } else {
272 p = QPoint( maxX/2, maxY/2 ); 276 p = QPoint( maxX/2, maxY/2 );
273 } 277 }
274 278
275 p = QPoint( p.x() - w/2, p.y() - h/2 ); 279 p = QPoint( p.x() - w/2, p.y() - h/2 );
276 //qDebug("p(x,y) is %d %d", p.x(), p.y() ); 280 //qDebug("p(x,y) is %d %d", p.x(), p.y() );
277 281
278 if ( w >= maxX ) { 282 if ( w >= maxX ) {
279 if ( p.y() < 0 ) 283 if ( p.y() < 0 )
280 p.setY(0); 284 p.setY(0);
281 if ( p.y() + h > maxY ) 285 if ( p.y() + h > maxY )
282 p.setY( maxY - h); 286 p.setY( maxY - h);
283 287
284 d->resize(maxX, h); 288 d->resize(maxX, h);
285 d->move(0, p.y() ); 289 d->move(0, p.y() );
286 } else if ( h >= maxY ) { 290 } else if ( h >= maxY ) {
287 if ( p.x() < 0 ) 291 if ( p.x() < 0 )
288 p.setX(0); 292 p.setX(0);
289 if ( p.x() + w > maxX ) 293 if ( p.x() + w > maxX )
290 p.setX( maxX - w); 294 p.setX( maxX - w);
291 295
292 d->resize(w, maxY); 296 d->resize(w, maxY);
293 d->move(p.x(),0); 297 d->move(p.x(),0);
294 } else { 298 } else {
295 d->resize(w, h); 299 d->resize(w, h);
296 } 300 }
297 301
298 d->show(); 302 d->show();
299 } 303 }
300} 304}
301 305
302 static bool read_widget_rect(const QString &app, bool &maximized, QPoint &p, QSize &s) 306 static bool read_widget_rect(const QString &app, bool &maximized, QPoint &p, QSize &s)
303 { 307 {
304 maximized = TRUE; 308 maximized = TRUE;
305 309 qDebug("read_widget_rect");
306 // 350 is the trigger in qwsdefaultdecoration for providing a resize button 310 // 350 is the trigger in qwsdefaultdecoration for providing a resize button
307 if ( qApp->desktop()->width() <= 350 ) 311 if ( qApp->desktop()->width() <= 350 )
308 return FALSE; 312 return FALSE;
309 313
310 Config cfg( "qpe" ); 314 Config cfg( "qpe" );
311 cfg.setGroup("ApplicationPositions"); 315 cfg.setGroup("ApplicationPositions");
312 QString str = cfg.readEntry( app, QString::null ); 316 QString str = cfg.readEntry( app, QString::null );
313 QStringList l = QStringList::split(",", str); 317 QStringList l = QStringList::split(",", str);
314 318
315 if ( l.count() == 5) { 319 if ( l.count() == 5) {
316 p.setX( l[0].toInt() ); 320 p.setX( l[0].toInt() );
317 p.setY( l[1].toInt() ); 321 p.setY( l[1].toInt() );
318 322
319 s.setWidth( l[2].toInt() ); 323 s.setWidth( l[2].toInt() );
320 s.setHeight( l[3].toInt() ); 324 s.setHeight( l[3].toInt() );
321 325
322 maximized = l[4].toInt(); 326 maximized = l[4].toInt();
323 327
324 return TRUE; 328 return TRUE;
325 } 329 }
326 330
327 return FALSE; 331 return FALSE;
328 } 332 }
329 333
330 334
331 static bool validate_widget_size(const QWidget *w, QPoint &p, QSize &s) 335 static bool validate_widget_size(const QWidget *w, QPoint &p, QSize &s)
332 { 336 {
333#ifndef Q_WS_QWS 337#ifndef Q_WS_QWS
334 QRect qt_maxWindowRect = qApp->desktop()->geometry(); 338 QRect qt_maxWindowRect = qApp->desktop()->geometry();
335#endif 339#endif
336 int maxX = qt_maxWindowRect.width(); 340 int maxX = qt_maxWindowRect.width();
337 int maxY = qt_maxWindowRect.height(); 341 int maxY = qt_maxWindowRect.height();
338 int wWidth = s.width() + ( w->frameGeometry().width() - w->geometry().width() ); 342 int wWidth = s.width() + ( w->frameGeometry().width() - w->geometry().width() );
339 int wHeight = s.height() + ( w->frameGeometry().height() - w->geometry().height() ); 343 int wHeight = s.height() + ( w->frameGeometry().height() - w->geometry().height() );
340 344
341 // total window size is not allowed to be larger than desktop window size 345 // total window size is not allowed to be larger than desktop window size
342 if ( ( wWidth >= maxX ) && ( wHeight >= maxY ) ) 346 if ( ( wWidth >= maxX ) && ( wHeight >= maxY ) )
343 return FALSE; 347 return FALSE;
344 348
345 if ( wWidth > maxX ) { 349 if ( wWidth > maxX ) {
346 s.setWidth( maxX - (w->frameGeometry().width() - w->geometry().width() ) ); 350 s.setWidth( maxX - (w->frameGeometry().width() - w->geometry().width() ) );
347 wWidth = maxX; 351 wWidth = maxX;
348 } 352 }
349 353
350 if ( wHeight > maxY ) { 354 if ( wHeight > maxY ) {
351 s.setHeight( maxY - (w->frameGeometry().height() - w->geometry().height() ) ); 355 s.setHeight( maxY - (w->frameGeometry().height() - w->geometry().height() ) );
352 wHeight = maxY; 356 wHeight = maxY;
353 } 357 }
354 358
355 // any smaller than this and the maximize/close/help buttons will be overlapping 359 // any smaller than this and the maximize/close/help buttons will be overlapping
356 if ( wWidth < 80 || wHeight < 60 ) 360 if ( wWidth < 80 || wHeight < 60 )
357 return FALSE; 361 return FALSE;
358 362
359 if ( p.x() < 0 ) 363 if ( p.x() < 0 )
360 p.setX(0); 364 p.setX(0);
361 if ( p.y() < 0 ) 365 if ( p.y() < 0 )
362 p.setY(0); 366 p.setY(0);
363 367
364 if ( p.x() + wWidth > maxX ) 368 if ( p.x() + wWidth > maxX )
365 p.setX( maxX - wWidth ); 369 p.setX( maxX - wWidth );
366 if ( p.y() + wHeight > maxY ) 370 if ( p.y() + wHeight > maxY )
367 p.setY( maxY - wHeight ); 371 p.setY( maxY - wHeight );
368 372
369 return TRUE; 373 return TRUE;
370 } 374 }
371 375
372 static void store_widget_rect(QWidget *w, QString &app) 376 static void store_widget_rect(QWidget *w, QString &app)
373 { 377 {
374 // 350 is the trigger in qwsdefaultdecoration for providing a resize button 378 // 350 is the trigger in qwsdefaultdecoration for providing a resize button
375 if ( qApp->desktop()->width() <= 350 ) 379 if ( qApp->desktop()->width() <= 350 )
376 return; 380 return;
377 381 qDebug("store_widget_rect");
378 // we use these to map the offset of geometry and pos. ( we can only use normalGeometry to 382 // we use these to map the offset of geometry and pos. ( we can only use normalGeometry to
379 // get the non-maximized version, so we have to do it the hard way ) 383 // get the non-maximized version, so we have to do it the hard way )
380 int offsetX = w->x() - w->geometry().left(); 384 int offsetX = w->x() - w->geometry().left();
381 int offsetY = w->y() - w->geometry().top(); 385 int offsetY = w->y() - w->geometry().top();
382 386
383 QRect r; 387 QRect r;
384 if ( w->isMaximized() ) 388 if ( w->isMaximized() )
385 r = ( (HackWidget *) w)->normalGeometry(); 389 r = ( (HackWidget *) w)->normalGeometry();
386 else 390 else
387 r = w->geometry(); 391 r = w->geometry();
388 392
389 // Stores the window placement as pos(), size() (due to the offset mapping) 393 // Stores the window placement as pos(), size() (due to the offset mapping)
390 Config cfg( "qpe" ); 394 Config cfg( "qpe" );
391 cfg.setGroup("ApplicationPositions"); 395 cfg.setGroup("ApplicationPositions");
392 QString s; 396 QString s;
393 s.sprintf("%d,%d,%d,%d,%d", r.left() + offsetX, r.top() + offsetY, r.width(), r.height(), w->isMaximized() ); 397 s.sprintf("%d,%d,%d,%d,%d", r.left() + offsetX, r.top() + offsetY, r.width(), r.height(), w->isMaximized() );
394 cfg.writeEntry( app, s ); 398 cfg.writeEntry( app, s );
395 } 399 }
396 400
397 static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) 401 static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ )
398 { 402 {
399 /* 403 /*
400 // This works but disable it for now until it is safe to apply 404 // This works but disable it for now until it is safe to apply
401 // What is does is scan the .desktop files of all the apps for 405 // What is does is scan the .desktop files of all the apps for
402 // the applnk that has the corresponding argv[0] as this program 406 // the applnk that has the corresponding argv[0] as this program
403 // then it uses the name stored in the .desktop file as the caption 407 // then it uses the name stored in the .desktop file as the caption
404 // for the main widget. This saves duplicating translations for 408 // for the main widget. This saves duplicating translations for
405 // the app name in the program and in the .desktop files. 409 // the app name in the program and in the .desktop files.
406 410
407 AppLnkSet apps( appsPath ); 411 AppLnkSet apps( appsPath );
408 412
409 QList<AppLnk> appsList = apps.children(); 413 QList<AppLnk> appsList = apps.children();
410 for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) { 414 for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) {
411 if ( (*it)->exec() == appName ) { 415 if ( (*it)->exec() == appName ) {
412 mw->setCaption( (*it)->name() ); 416 mw->setCaption( (*it)->name() );
413 return TRUE; 417 return TRUE;
414 } 418 }
415 } 419 }
416 */ 420 */
417 return FALSE; 421 return FALSE;
418 } 422 }
419 423
420 424
421 void show(QWidget* mw, bool nomax) 425 void show(QWidget* mw, bool nomax)
422 { 426 {
423 setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" ); 427 setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" );
424 nomaximize = nomax; 428 nomaximize = nomax;
425 qpe_main_widget = mw; 429 qpe_main_widget = mw;
426 qcopQok = TRUE; 430 qcopQok = TRUE;
427#ifndef QT_NO_COP 431#ifndef QT_NO_COP
428 432
429 sendQCopQ(); 433 sendQCopQ();
430#endif 434#endif
431 435
432 if ( preloaded ) { 436 if ( preloaded ) {
433 if (forceshow) 437 if (forceshow)
434 show_mx(mw, nomax, appName); 438 show_mx(mw, nomax, appName);
435 } 439 }
436 else if ( keep_running ) { 440 else if ( keep_running ) {
437 show_mx(mw, nomax, appName); 441 show_mx(mw, nomax, appName);
438 } 442 }
439 } 443 }
440 444
441 void loadTextCodecs() 445 void loadTextCodecs()
442 { 446 {
443 QString path = QPEApplication::qpeDir() + "/plugins/textcodecs"; 447 QString path = QPEApplication::qpeDir() + "/plugins/textcodecs";
444#ifdef Q_OS_MACX 448#ifdef Q_OS_MACX
445 QDir dir( path, "lib*.dylib" ); 449 QDir dir( path, "lib*.dylib" );
446#else 450#else
447 QDir dir( path, "lib*.so" ); 451 QDir dir( path, "lib*.so" );
448#endif 452#endif
449 QStringList list; 453 QStringList list;
450 if ( dir. exists ( )) 454 if ( dir. exists ( ))
451 list = dir.entryList(); 455 list = dir.entryList();
452 QStringList::Iterator it; 456 QStringList::Iterator it;
453 for ( it = list.begin(); it != list.end(); ++it ) { 457 for ( it = list.begin(); it != list.end(); ++it ) {
454 TextCodecInterface *iface = 0; 458 TextCodecInterface *iface = 0;
455 QLibrary *lib = new QLibrary( path + "/" + *it ); 459 QLibrary *lib = new QLibrary( path + "/" + *it );
456 if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { 460 if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) {
457 QValueList<int> mibs = iface->mibEnums(); 461 QValueList<int> mibs = iface->mibEnums();
458 for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) { 462 for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) {
459 (void)iface->createForMib(*i); 463 (void)iface->createForMib(*i);
460 // ### it exists now; need to remember if we can delete it 464 // ### it exists now; need to remember if we can delete it
461 } 465 }
462 } 466 }
463 else { 467 else {
464 lib->unload(); 468 lib->unload();
465 delete lib; 469 delete lib;
466 } 470 }
467 } 471 }
468 } 472 }
469 473
470 void loadImageCodecs() 474 void loadImageCodecs()
471 { 475 {
472 QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs"; 476 QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs";
473#ifdef Q_OS_MACX 477#ifdef Q_OS_MACX
474 QDir dir( path, "lib*.dylib" ); 478 QDir dir( path, "lib*.dylib" );
475#else 479#else
476 QDir dir( path, "lib*.so" ); 480 QDir dir( path, "lib*.so" );
477#endif 481#endif
478 QStringList list; 482 QStringList list;
479 if ( dir. exists ( )) 483 if ( dir. exists ( ))
480 list = dir.entryList(); 484 list = dir.entryList();
481 QStringList::Iterator it; 485 QStringList::Iterator it;
482 for ( it = list.begin(); it != list.end(); ++it ) { 486 for ( it = list.begin(); it != list.end(); ++it ) {
483 ImageCodecInterface *iface = 0; 487 ImageCodecInterface *iface = 0;
484 QLibrary *lib = new QLibrary( path + "/" + *it ); 488 QLibrary *lib = new QLibrary( path + "/" + *it );
485 if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { 489 if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) {
486 QStringList formats = iface->keys(); 490 QStringList formats = iface->keys();
487 for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) { 491 for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) {
488 (void)iface->installIOHandler(*i); 492 (void)iface->installIOHandler(*i);
489 // ### it exists now; need to remember if we can delete it 493 // ### it exists now; need to remember if we can delete it
490 } 494 }
491 } 495 }
492 else { 496 else {
493 lib->unload(); 497 lib->unload();
494 delete lib; 498 delete lib;
495 } 499 }
496 } 500 }
497 } 501 }
498}; 502};
499 503
500class ResourceMimeFactory : public QMimeSourceFactory 504class ResourceMimeFactory : public QMimeSourceFactory
501{ 505{
502public: 506public:
503 ResourceMimeFactory() : resImage( 0 ) 507 ResourceMimeFactory() : resImage( 0 )
504 { 508 {
505 setFilePath( Global::helpPath() ); 509 setFilePath( Global::helpPath() );
506 setExtensionType( "html", "text/html;charset=UTF-8" ); 510 setExtensionType( "html", "text/html;charset=UTF-8" );
507 } 511 }
508 ~ResourceMimeFactory() { 512 ~ResourceMimeFactory() {
509 delete resImage; 513 delete resImage;
510 } 514 }
511 515
512 const QMimeSource* data( const QString& abs_name ) const 516 const QMimeSource* data( const QString& abs_name ) const
513 { 517 {
514 const QMimeSource * r = QMimeSourceFactory::data( abs_name ); 518 const QMimeSource * r = QMimeSourceFactory::data( abs_name );
515 if ( !r ) { 519 if ( !r ) {
516 int sl = abs_name.length(); 520 int sl = abs_name.length();
517 do { 521 do {
518 sl = abs_name.findRev( '/', sl - 1 ); 522 sl = abs_name.findRev( '/', sl - 1 );
519 QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name; 523 QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name;
520 int dot = name.findRev( '.' ); 524 int dot = name.findRev( '.' );
521 if ( dot >= 0 ) 525 if ( dot >= 0 )
522 name = name.left( dot ); 526 name = name.left( dot );
523 QImage img = Resource::loadImage( name ); 527 QImage img = Resource::loadImage( name );
524 if ( !img.isNull() ) { 528 if ( !img.isNull() ) {
525 delete resImage; 529 delete resImage;
526 resImage = new QImageDrag( img ); 530 resImage = new QImageDrag( img );
527 r = resImage; 531 r = resImage;
528 } 532 }
529 } 533 }
530 while ( !r && sl > 0 ); 534 while ( !r && sl > 0 );
531 } 535 }
532 return r; 536 return r;
533 } 537 }
534private: 538private:
535 mutable QImageDrag *resImage; 539 mutable QImageDrag *resImage;
536}; 540};
537 541
538static int& hack(int& i) 542static int& hack(int& i)
539{ 543{
540#if QT_VERSION <= 230 && defined(QT_NO_CODECS) 544#if QT_VERSION <= 230 && defined(QT_NO_CODECS)
541 // These should be created, but aren't in Qt 2.3.0 545 // These should be created, but aren't in Qt 2.3.0
542 (void)new QUtf8Codec; 546 (void)new QUtf8Codec;
543 (void)new QUtf16Codec; 547 (void)new QUtf16Codec;
544#endif 548#endif
545 return i; 549 return i;
546} 550}
547 551
548static int muted = 0; 552static int muted = 0;
549static int micMuted = 0; 553static int micMuted = 0;
550 554
551static void setVolume( int t = 0, int percent = -1 ) 555static void setVolume( int t = 0, int percent = -1 )
552{ 556{
553 switch ( t ) { 557 switch ( t ) {
554 case 0: { 558 case 0: {
555 Config cfg( "qpe" ); 559 Config cfg( "qpe" );
556 cfg.setGroup( "Volume" ); 560 cfg.setGroup( "Volume" );
557 if ( percent < 0 ) 561 if ( percent < 0 )
558 percent = cfg.readNumEntry( "VolumePercent", 50 ); 562 percent = cfg.readNumEntry( "VolumePercent", 50 );
559#ifndef QT_NO_SOUND 563#ifndef QT_NO_SOUND
560 int fd = 0; 564 int fd = 0;
561 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { 565 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) {
562 int vol = muted ? 0 : percent; 566 int vol = muted ? 0 : percent;
563 // set both channels to same volume 567 // set both channels to same volume
564 vol |= vol << 8; 568 vol |= vol << 8;
565 ioctl( fd, MIXER_WRITE( SOUND_MIXER_VOLUME ), &vol ); 569 ioctl( fd, MIXER_WRITE( SOUND_MIXER_VOLUME ), &vol );
566 ::close( fd ); 570 ::close( fd );
567 } 571 }
568#endif 572#endif
569 } 573 }
570 break; 574 break;
571 } 575 }
572} 576}
573 577
574static void setMic( int t = 0, int percent = -1 ) 578static void setMic( int t = 0, int percent = -1 )
575{ 579{
576 switch ( t ) { 580 switch ( t ) {
577 case 0: { 581 case 0: {
578 Config cfg( "qpe" ); 582 Config cfg( "qpe" );
579 cfg.setGroup( "Volume" ); 583 cfg.setGroup( "Volume" );
580 if ( percent < 0 ) 584 if ( percent < 0 )
581 percent = cfg.readNumEntry( "Mic", 50 ); 585 percent = cfg.readNumEntry( "Mic", 50 );
582 586
583#ifndef QT_NO_SOUND 587#ifndef QT_NO_SOUND
584 int fd = 0; 588 int fd = 0;
585 int mic = micMuted ? 0 : percent; 589 int mic = micMuted ? 0 : percent;
586 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { 590 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) {
587 ioctl( fd, MIXER_WRITE( SOUND_MIXER_MIC ), &mic ); 591 ioctl( fd, MIXER_WRITE( SOUND_MIXER_MIC ), &mic );
588 ::close( fd ); 592 ::close( fd );
589 } 593 }
590#endif 594#endif
591 } 595 }
592 break; 596 break;
593 } 597 }
594} 598}
595 599
596 600
597static void setBass( int t = 0, int percent = -1 ) 601static void setBass( int t = 0, int percent = -1 )
598{ 602{
599 switch ( t ) { 603 switch ( t ) {
600 case 0: { 604 case 0: {
601 Config cfg( "qpe" ); 605 Config cfg( "qpe" );
602 cfg.setGroup( "Volume" ); 606 cfg.setGroup( "Volume" );
603 if ( percent < 0 ) 607 if ( percent < 0 )
604 percent = cfg.readNumEntry( "BassPercent", 50 ); 608 percent = cfg.readNumEntry( "BassPercent", 50 );
605 609
606#ifndef QT_NO_SOUND 610#ifndef QT_NO_SOUND
607 int fd = 0; 611 int fd = 0;
608 int bass = percent; 612 int bass = percent;
609 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { 613 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) {
610 ioctl( fd, MIXER_WRITE( SOUND_MIXER_BASS ), &bass ); 614 ioctl( fd, MIXER_WRITE( SOUND_MIXER_BASS ), &bass );
611 ::close( fd ); 615 ::close( fd );
612 } 616 }
613#endif 617#endif
614 } 618 }
615 break; 619 break;
616 } 620 }
617} 621}
618 622
619 623
620static void setTreble( int t = 0, int percent = -1 ) 624static void setTreble( int t = 0, int percent = -1 )
621{ 625{
622 switch ( t ) { 626 switch ( t ) {
623 case 0: { 627 case 0: {
624 Config cfg( "qpe" ); 628 Config cfg( "qpe" );
625 cfg.setGroup( "Volume" ); 629 cfg.setGroup( "Volume" );
626 if ( percent < 0 ) 630 if ( percent < 0 )
627 percent = cfg.readNumEntry( "TreblePercent", 50 ); 631 percent = cfg.readNumEntry( "TreblePercent", 50 );
628 632
629#ifndef QT_NO_SOUND 633#ifndef QT_NO_SOUND
630 int fd = 0; 634 int fd = 0;
631 int treble = percent; 635 int treble = percent;
632 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { 636 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) {
633 ioctl( fd, MIXER_WRITE( SOUND_MIXER_TREBLE ), &treble ); 637 ioctl( fd, MIXER_WRITE( SOUND_MIXER_TREBLE ), &treble );
634 ::close( fd ); 638 ::close( fd );
635 } 639 }
636#endif 640#endif
637 } 641 }
638 break; 642 break;
639 } 643 }
640} 644}
641 645
642 646
643/** 647/**
644 \class QPEApplication 648 \class QPEApplication
645 \brief The QPEApplication class implements various system services 649 \brief The QPEApplication class implements various system services
646 that are available to all Qtopia applications. 650 that are available to all Qtopia applications.
647 651
648 Simply by using QPEApplication instead of QApplication, a standard Qt 652 Simply by using QPEApplication instead of QApplication, a standard Qt
649 application becomes a Qtopia application. It automatically follows 653 application becomes a Qtopia application. It automatically follows
650 style changes, quits and raises, and in the 654 style changes, quits and raises, and in the
651 case of \link docwidget.html document-oriented\endlink applications, 655 case of \link docwidget.html document-oriented\endlink applications,
652 changes the currently displayed document in response to the environment. 656 changes the currently displayed document in response to the environment.
653 657
654 To create a \link docwidget.html document-oriented\endlink 658 To create a \link docwidget.html document-oriented\endlink
655 application use showMainDocumentWidget(); to create a 659 application use showMainDocumentWidget(); to create a
656 non-document-oriented application use showMainWidget(). The 660 non-document-oriented application use showMainWidget(). The
657 keepRunning() function indicates whether the application will 661 keepRunning() function indicates whether the application will
658 continue running after it's processed the last \link qcop.html 662 continue running after it's processed the last \link qcop.html
659 QCop\endlink message. This can be changed using setKeepRunning(). 663 QCop\endlink message. This can be changed using setKeepRunning().
660 664
661 A variety of signals are emitted when certain events occur, for 665 A variety of signals are emitted when certain events occur, for
662 example, timeChanged(), clockChanged(), weekChanged(), 666 example, timeChanged(), clockChanged(), weekChanged(),
663 dateFormatChanged() and volumeChanged(). If the application receives 667 dateFormatChanged() and volumeChanged(). If the application receives
664 a \link qcop.html QCop\endlink message on the application's 668 a \link qcop.html QCop\endlink message on the application's
665 QPE/Application/\e{appname} channel, the appMessage() signal is 669 QPE/Application/\e{appname} channel, the appMessage() signal is
666 emitted. There are also flush() and reload() signals, which 670 emitted. There are also flush() and reload() signals, which
667 are emitted when synching begins and ends respectively - upon these 671 are emitted when synching begins and ends respectively - upon these
668 signals, the application should save and reload any data 672 signals, the application should save and reload any data
669 files that are involved in synching. Most of these signals will initially 673 files that are involved in synching. Most of these signals will initially
670 be received and unfiltered through the appMessage() signal. 674 be received and unfiltered through the appMessage() signal.
671 675
672 This class also provides a set of useful static functions. The 676 This class also provides a set of useful static functions. The
673 qpeDir() and documentDir() functions return the respective paths. 677 qpeDir() and documentDir() functions return the respective paths.
674 The grabKeyboard() and ungrabKeyboard() functions are used to 678 The grabKeyboard() and ungrabKeyboard() functions are used to
675 control whether the application takes control of the device's 679 control whether the application takes control of the device's
676 physical buttons (e.g. application launch keys). The stylus' mode of 680 physical buttons (e.g. application launch keys). The stylus' mode of
677 operation is set with setStylusOperation() and retrieved with 681 operation is set with setStylusOperation() and retrieved with
678 stylusOperation(). There are also setInputMethodHint() and 682 stylusOperation(). There are also setInputMethodHint() and
679 inputMethodHint() functions. 683 inputMethodHint() functions.
680 684
681 \ingroup qtopiaemb 685 \ingroup qtopiaemb
682*/ 686*/
683 687
684/*! 688/*!
685 \fn void QPEApplication::clientMoused() 689 \fn void QPEApplication::clientMoused()
686 690
687 \internal 691 \internal
688*/ 692*/
689 693
690/*! 694/*!
691 \fn void QPEApplication::timeChanged(); 695 \fn void QPEApplication::timeChanged();
692 This signal is emitted when the time changes outside the normal 696 This signal is emitted when the time changes outside the normal
693 passage of time, i.e. if the time is set backwards or forwards. 697 passage of time, i.e. if the time is set backwards or forwards.
694*/ 698*/
695 699
696/*! 700/*!
697 \fn void QPEApplication::clockChanged( bool ampm ); 701 \fn void QPEApplication::clockChanged( bool ampm );
698 702
699 This signal is emitted when the user changes the clock's style. If 703 This signal is emitted when the user changes the clock's style. If
700 \a ampm is TRUE, the user wants a 12-hour AM/PM clock, otherwise, 704 \a ampm is TRUE, the user wants a 12-hour AM/PM clock, otherwise,
701 they want a 24-hour clock. 705 they want a 24-hour clock.
702*/ 706*/
703 707
704/*! 708/*!
705 \fn void QPEApplication::volumeChanged( bool muted ) 709 \fn void QPEApplication::volumeChanged( bool muted )
706 710
707 This signal is emitted whenever the mute state is changed. If \a 711 This signal is emitted whenever the mute state is changed. If \a
708 muted is TRUE, then sound output has been muted. 712 muted is TRUE, then sound output has been muted.
709*/ 713*/
710 714
711/*! 715/*!
712 \fn void QPEApplication::weekChanged( bool startOnMonday ) 716 \fn void QPEApplication::weekChanged( bool startOnMonday )
713 717
714 This signal is emitted if the week start day is changed. If \a 718 This signal is emitted if the week start day is changed. If \a
715 startOnMonday is TRUE then the first day of the week is Monday; if 719 startOnMonday is TRUE then the first day of the week is Monday; if
716 \a startOnMonday is FALSE then the first day of the week is 720 \a startOnMonday is FALSE then the first day of the week is
717 Sunday. 721 Sunday.
718*/ 722*/
719 723
720/*! 724/*!
721 \fn void QPEApplication::dateFormatChanged(DateFormat) 725 \fn void QPEApplication::dateFormatChanged(DateFormat)
722 726
723 This signal is emitted whenever the date format is changed. 727 This signal is emitted whenever the date format is changed.
724*/ 728*/
725 729
726/*! 730/*!
727 \fn void QPEApplication::flush() 731 \fn void QPEApplication::flush()
728 732
729 ### 733 ###
730*/ 734*/
731 735
732/*! 736/*!
733 \fn void QPEApplication::reload() 737 \fn void QPEApplication::reload()
734 738
735*/ 739*/
736 740
737 741
738 742
739void QPEApplication::processQCopFile() 743void QPEApplication::processQCopFile()
740{ 744{
741 QString qcopfn("/tmp/qcop-msg-"); 745 QString qcopfn("/tmp/qcop-msg-");
742 qcopfn += d->appName; // append command name 746 qcopfn += d->appName; // append command name
743 747
744 QFile f(qcopfn); 748 QFile f(qcopfn);
745 if ( f.open(IO_ReadWrite) ) { 749 if ( f.open(IO_ReadWrite) ) {
746#ifndef Q_OS_WIN32 750#ifndef Q_OS_WIN32
747 flock(f.handle(), LOCK_EX); 751 flock(f.handle(), LOCK_EX);
748#endif 752#endif
749 QDataStream ds(&f); 753 QDataStream ds(&f);
750 QCString channel, message; 754 QCString channel, message;
751 QByteArray data; 755 QByteArray data;
752 while(!ds.atEnd()) { 756 while(!ds.atEnd()) {
753 ds >> channel >> message >> data; 757 ds >> channel >> message >> data;
754 d->enqueueQCop(channel,message,data); 758 d->enqueueQCop(channel,message,data);
755 } 759 }
756 ::ftruncate(f.handle(), 0); 760 ::ftruncate(f.handle(), 0);
757#ifndef Q_OS_WIN32 761#ifndef Q_OS_WIN32
758 f.flush(); 762 f.flush();
759 flock(f.handle(), LOCK_UN); 763 flock(f.handle(), LOCK_UN);
760#endif 764#endif
761 } 765 }