summaryrefslogtreecommitdiff
authorzecke <zecke>2004-10-15 21:04:08 (UTC)
committer zecke <zecke>2004-10-15 21:04:08 (UTC)
commit0bdebb46227ea403a07707cf0a967c8ea036e03f (patch) (unidiff)
treed6e724a055475f3938ee5a8955692209d490ba37
parentac36bfe2794741188da1d6d4b471f96fd15d47ee (diff)
downloadopie-0bdebb46227ea403a07707cf0a967c8ea036e03f.zip
opie-0bdebb46227ea403a07707cf0a967c8ea036e03f.tar.gz
opie-0bdebb46227ea403a07707cf0a967c8ea036e03f.tar.bz2
Make sure that qpeDir() has a QDir::seperator() as last character. This code
comes from Qtopia1.7 Conversion to it is done by myself
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--library/qpeapplication.cpp27
1 files changed, 20 insertions, 7 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp
index 3efba20..0b6d56d 100644
--- a/library/qpeapplication.cpp
+++ b/library/qpeapplication.cpp
@@ -136,542 +136,542 @@ public:
136 } 136 }
137 137
138 int presstimer; 138 int presstimer;
139 QWidget* presswidget; 139 QWidget* presswidget;
140 QPoint presspos; 140 QPoint presspos;
141#ifdef OPIE_WITHROHFEEDBACK 141#ifdef OPIE_WITHROHFEEDBACK
142 Opie::Internal::RoHFeedback *RoH; 142 Opie::Internal::RoHFeedback *RoH;
143#endif 143#endif
144 144
145 bool rightpressed : 1; 145 bool rightpressed : 1;
146 bool kbgrabbed : 1; 146 bool kbgrabbed : 1;
147 bool notbusysent : 1; 147 bool notbusysent : 1;
148 bool preloaded : 1; 148 bool preloaded : 1;
149 bool forceshow : 1; 149 bool forceshow : 1;
150 bool nomaximize : 1; 150 bool nomaximize : 1;
151 bool keep_running : 1; 151 bool keep_running : 1;
152 bool qcopQok : 1; 152 bool qcopQok : 1;
153 153
154 QCString fontFamily; 154 QCString fontFamily;
155 int fontSize; 155 int fontSize;
156 int smallIconSize; 156 int smallIconSize;
157 int bigIconSize; 157 int bigIconSize;
158 158
159 QStringList langs; 159 QStringList langs;
160 QString appName; 160 QString appName;
161 struct QCopRec 161 struct QCopRec
162 { 162 {
163 QCopRec( const QCString &ch, const QCString &msg, 163 QCopRec( const QCString &ch, const QCString &msg,
164 const QByteArray &d ) : 164 const QByteArray &d ) :
165 channel( ch ), message( msg ), data( d ) 165 channel( ch ), message( msg ), data( d )
166 { } 166 { }
167 167
168 QCString channel; 168 QCString channel;
169 QCString message; 169 QCString message;
170 QByteArray data; 170 QByteArray data;
171 }; 171 };
172 QWidget* qpe_main_widget; 172 QWidget* qpe_main_widget;
173 QGuardedPtr<QWidget> lastraised; 173 QGuardedPtr<QWidget> lastraised;
174 QQueue<QCopRec> qcopq; 174 QQueue<QCopRec> qcopq;
175 QString styleName; 175 QString styleName;
176 QString decorationName; 176 QString decorationName;
177 177
178 void enqueueQCop( const QCString &ch, const QCString &msg, 178 void enqueueQCop( const QCString &ch, const QCString &msg,
179 const QByteArray &data ) 179 const QByteArray &data )
180 { 180 {
181 qcopq.enqueue( new QCopRec( ch, msg, data ) ); 181 qcopq.enqueue( new QCopRec( ch, msg, data ) );
182 } 182 }
183 void sendQCopQ() 183 void sendQCopQ()
184 { 184 {
185 if (!qcopQok ) 185 if (!qcopQok )
186 return; 186 return;
187 187
188 QCopRec * r; 188 QCopRec * r;
189 189
190 while((r=qcopq.dequeue())) { 190 while((r=qcopq.dequeue())) {
191 // remove from queue before sending... 191 // remove from queue before sending...
192 // event loop can come around again before getting 192 // event loop can come around again before getting
193 // back from sendLocally 193 // back from sendLocally
194#ifndef QT_NO_COP 194#ifndef QT_NO_COP
195 QCopChannel::sendLocally( r->channel, r->message, r->data ); 195 QCopChannel::sendLocally( r->channel, r->message, r->data );
196#endif 196#endif
197 197
198 delete r; 198 delete r;
199 } 199 }
200 } 200 }
201 201
202 static void show_mx(QWidget* mw, bool nomaximize, QString &strName) 202 static void show_mx(QWidget* mw, bool nomaximize, QString &strName)
203 { 203 {
204 if ( mw->inherits("QMainWindow") || mw->isA("QMainWindow") ) 204 if ( mw->inherits("QMainWindow") || mw->isA("QMainWindow") )
205 { 205 {
206 ( ( QMainWindow* ) mw )->setUsesBigPixmaps( useBigPixmaps ); 206 ( ( QMainWindow* ) mw )->setUsesBigPixmaps( useBigPixmaps );
207 } 207 }
208 QPoint p; 208 QPoint p;
209 QSize s; 209 QSize s;
210 bool max; 210 bool max;
211 if ( mw->isVisible() ) { 211 if ( mw->isVisible() ) {
212 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) ) {
213 mw->resize(s); 213 mw->resize(s);
214 mw->move(p); 214 mw->move(p);
215 } 215 }
216 mw->raise(); 216 mw->raise();
217 } else { 217 } else {
218 218
219 if ( mw->layout() && mw->inherits("QDialog") ) { 219 if ( mw->layout() && mw->inherits("QDialog") ) {
220 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) ) {
221 mw->resize(s); 221 mw->resize(s);
222 mw->move(p); 222 mw->move(p);
223 223
224 if ( max && !nomaximize ) { 224 if ( max && !nomaximize ) {
225 mw->showMaximized(); 225 mw->showMaximized();
226 } else { 226 } else {
227 mw->show(); 227 mw->show();
228 } 228 }
229 } else { 229 } else {
230 QPEApplication::showDialog((QDialog*)mw,nomaximize); 230 QPEApplication::showDialog((QDialog*)mw,nomaximize);
231 } 231 }
232 } else { 232 } else {
233 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) ) {
234 mw->resize(s); 234 mw->resize(s);
235 mw->move(p); 235 mw->move(p);
236 } else { //no stored rectangle, make an estimation 236 } else { //no stored rectangle, make an estimation
237 int x = (qApp->desktop()->width()-mw->frameGeometry().width())/2; 237 int x = (qApp->desktop()->width()-mw->frameGeometry().width())/2;
238 int y = (qApp->desktop()->height()-mw->frameGeometry().height())/2; 238 int y = (qApp->desktop()->height()-mw->frameGeometry().height())/2;
239 mw->move( QMAX(x,0), QMAX(y,0) ); 239 mw->move( QMAX(x,0), QMAX(y,0) );
240#ifdef Q_WS_QWS 240#ifdef Q_WS_QWS
241 if ( !nomaximize ) 241 if ( !nomaximize )
242 mw->showMaximized(); 242 mw->showMaximized();
243#endif 243#endif
244 } 244 }
245 if ( max && !nomaximize ) 245 if ( max && !nomaximize )
246 mw->showMaximized(); 246 mw->showMaximized();
247 else 247 else
248 mw->show(); 248 mw->show();
249 } 249 }
250 } 250 }
251 } 251 }
252 252
253 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)
254 { 254 {
255 maximized = TRUE; 255 maximized = TRUE;
256 // 350 is the trigger in qwsdefaultdecoration for providing a resize button 256 // 350 is the trigger in qwsdefaultdecoration for providing a resize button
257 if ( qApp->desktop()->width() <= 350 ) 257 if ( qApp->desktop()->width() <= 350 )
258 return FALSE; 258 return FALSE;
259 259
260 Config cfg( "qpe" ); 260 Config cfg( "qpe" );
261 cfg.setGroup("ApplicationPositions"); 261 cfg.setGroup("ApplicationPositions");
262 QString str = cfg.readEntry( app, QString::null ); 262 QString str = cfg.readEntry( app, QString::null );
263 QStringList l = QStringList::split(",", str); 263 QStringList l = QStringList::split(",", str);
264 264
265 if ( l.count() == 5) { 265 if ( l.count() == 5) {
266 p.setX( l[0].toInt() ); 266 p.setX( l[0].toInt() );
267 p.setY( l[1].toInt() ); 267 p.setY( l[1].toInt() );
268 268
269 s.setWidth( l[2].toInt() ); 269 s.setWidth( l[2].toInt() );
270 s.setHeight( l[3].toInt() ); 270 s.setHeight( l[3].toInt() );
271 271
272 maximized = l[4].toInt(); 272 maximized = l[4].toInt();
273 273
274 return TRUE; 274 return TRUE;
275 } 275 }
276 276
277 return FALSE; 277 return FALSE;
278 } 278 }
279 279
280 280
281 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)
282 { 282 {
283#ifndef Q_WS_QWS 283#ifndef Q_WS_QWS
284 QRect qt_maxWindowRect = qApp->desktop()->geometry(); 284 QRect qt_maxWindowRect = qApp->desktop()->geometry();
285#endif 285#endif
286 int maxX = qt_maxWindowRect.width(); 286 int maxX = qt_maxWindowRect.width();
287 int maxY = qt_maxWindowRect.height(); 287 int maxY = qt_maxWindowRect.height();
288 int wWidth = s.width() + ( w->frameGeometry().width() - w->geometry().width() ); 288 int wWidth = s.width() + ( w->frameGeometry().width() - w->geometry().width() );
289 int wHeight = s.height() + ( w->frameGeometry().height() - w->geometry().height() ); 289 int wHeight = s.height() + ( w->frameGeometry().height() - w->geometry().height() );
290 290
291 // 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
292 if ( ( wWidth >= maxX ) && ( wHeight >= maxY ) ) 292 if ( ( wWidth >= maxX ) && ( wHeight >= maxY ) )
293 return FALSE; 293 return FALSE;
294 294
295 if ( wWidth > maxX ) { 295 if ( wWidth > maxX ) {
296 s.setWidth( maxX - (w->frameGeometry().width() - w->geometry().width() ) ); 296 s.setWidth( maxX - (w->frameGeometry().width() - w->geometry().width() ) );
297 wWidth = maxX; 297 wWidth = maxX;
298 } 298 }
299 299
300 if ( wHeight > maxY ) { 300 if ( wHeight > maxY ) {
301 s.setHeight( maxY - (w->frameGeometry().height() - w->geometry().height() ) ); 301 s.setHeight( maxY - (w->frameGeometry().height() - w->geometry().height() ) );
302 wHeight = maxY; 302 wHeight = maxY;
303 } 303 }
304 304
305 // 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
306 if ( wWidth < 80 || wHeight < 60 ) 306 if ( wWidth < 80 || wHeight < 60 )
307 return FALSE; 307 return FALSE;
308 308
309 if ( p.x() < 0 ) 309 if ( p.x() < 0 )
310 p.setX(0); 310 p.setX(0);
311 if ( p.y() < 0 ) 311 if ( p.y() < 0 )
312 p.setY(0); 312 p.setY(0);
313 313
314 if ( p.x() + wWidth > maxX ) 314 if ( p.x() + wWidth > maxX )
315 p.setX( maxX - wWidth ); 315 p.setX( maxX - wWidth );
316 if ( p.y() + wHeight > maxY ) 316 if ( p.y() + wHeight > maxY )
317 p.setY( maxY - wHeight ); 317 p.setY( maxY - wHeight );
318 318
319 return TRUE; 319 return TRUE;
320 } 320 }
321 321
322 static void store_widget_rect(QWidget *w, QString &app) 322 static void store_widget_rect(QWidget *w, QString &app)
323 { 323 {
324 // 350 is the trigger in qwsdefaultdecoration for providing a resize button 324 // 350 is the trigger in qwsdefaultdecoration for providing a resize button
325 if ( qApp->desktop()->width() <= 350 ) 325 if ( qApp->desktop()->width() <= 350 )
326 return; 326 return;
327 // we use these to map the offset of geometry and pos. ( we can only use normalGeometry to 327 // we use these to map the offset of geometry and pos. ( we can only use normalGeometry to
328 // get the non-maximized version, so we have to do it the hard way ) 328 // get the non-maximized version, so we have to do it the hard way )
329 int offsetX = w->x() - w->geometry().left(); 329 int offsetX = w->x() - w->geometry().left();
330 int offsetY = w->y() - w->geometry().top(); 330 int offsetY = w->y() - w->geometry().top();
331 331
332 QRect r; 332 QRect r;
333 if ( w->isMaximized() ) 333 if ( w->isMaximized() )
334 r = ( (HackWidget *) w)->normalGeometry(); 334 r = ( (HackWidget *) w)->normalGeometry();
335 else 335 else
336 r = w->geometry(); 336 r = w->geometry();
337 337
338 // Stores the window placement as pos(), size() (due to the offset mapping) 338 // Stores the window placement as pos(), size() (due to the offset mapping)
339 Config cfg( "qpe" ); 339 Config cfg( "qpe" );
340 cfg.setGroup("ApplicationPositions"); 340 cfg.setGroup("ApplicationPositions");
341 QString s; 341 QString s;
342 s.sprintf("%d,%d,%d,%d,%d", r.left() + offsetX, r.top() + offsetY, r.width(), r.height(), w->isMaximized() ); 342 s.sprintf("%d,%d,%d,%d,%d", r.left() + offsetX, r.top() + offsetY, r.width(), r.height(), w->isMaximized() );
343 cfg.writeEntry( app, s ); 343 cfg.writeEntry( app, s );
344 } 344 }
345 345
346 static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) 346 static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ )
347 { 347 {
348 /* 348 /*
349 // This works but disable it for now until it is safe to apply 349 // This works but disable it for now until it is safe to apply
350 // What is does is scan the .desktop files of all the apps for 350 // What is does is scan the .desktop files of all the apps for
351 // the applnk that has the corresponding argv[0] as this program 351 // the applnk that has the corresponding argv[0] as this program
352 // then it uses the name stored in the .desktop file as the caption 352 // then it uses the name stored in the .desktop file as the caption
353 // for the main widget. This saves duplicating translations for 353 // for the main widget. This saves duplicating translations for
354 // the app name in the program and in the .desktop files. 354 // the app name in the program and in the .desktop files.
355 355
356 AppLnkSet apps( appsPath ); 356 AppLnkSet apps( appsPath );
357 357
358 QList<AppLnk> appsList = apps.children(); 358 QList<AppLnk> appsList = apps.children();
359 for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) { 359 for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) {
360 if ( (*it)->exec() == appName ) { 360 if ( (*it)->exec() == appName ) {
361 mw->setCaption( (*it)->name() ); 361 mw->setCaption( (*it)->name() );
362 return TRUE; 362 return TRUE;
363 } 363 }
364 } 364 }
365 */ 365 */
366 return FALSE; 366 return FALSE;
367 } 367 }
368 368
369 369
370 void show(QWidget* mw, bool nomax) 370 void show(QWidget* mw, bool nomax)
371 { 371 {
372 setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" ); 372 setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" );
373 nomaximize = nomax; 373 nomaximize = nomax;
374 qpe_main_widget = mw; 374 qpe_main_widget = mw;
375 qcopQok = TRUE; 375 qcopQok = TRUE;
376#ifndef QT_NO_COP 376#ifndef QT_NO_COP
377 377
378 sendQCopQ(); 378 sendQCopQ();
379#endif 379#endif
380 380
381 if ( preloaded ) { 381 if ( preloaded ) {
382 if (forceshow) 382 if (forceshow)
383 show_mx(mw, nomax, appName); 383 show_mx(mw, nomax, appName);
384 } 384 }
385 else if ( keep_running ) { 385 else if ( keep_running ) {
386 show_mx(mw, nomax, appName); 386 show_mx(mw, nomax, appName);
387 } 387 }
388 } 388 }
389 389
390 void loadTextCodecs() 390 void loadTextCodecs()
391 { 391 {
392 QString path = QPEApplication::qpeDir() + "/plugins/textcodecs"; 392 QString path = QPEApplication::qpeDir() + "plugins/textcodecs";
393#ifdef Q_OS_MACX 393#ifdef Q_OS_MACX
394 QDir dir( path, "lib*.dylib" ); 394 QDir dir( path, "lib*.dylib" );
395#else 395#else
396 QDir dir( path, "lib*.so" ); 396 QDir dir( path, "lib*.so" );
397#endif 397#endif
398 QStringList list; 398 QStringList list;
399 if ( dir. exists ( )) 399 if ( dir. exists ( ))
400 list = dir.entryList(); 400 list = dir.entryList();
401 QStringList::Iterator it; 401 QStringList::Iterator it;
402 for ( it = list.begin(); it != list.end(); ++it ) { 402 for ( it = list.begin(); it != list.end(); ++it ) {
403 TextCodecInterface *iface = 0; 403 TextCodecInterface *iface = 0;
404 QLibrary *lib = new QLibrary( path + "/" + *it ); 404 QLibrary *lib = new QLibrary( path + "/" + *it );
405 if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { 405 if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) {
406 QValueList<int> mibs = iface->mibEnums(); 406 QValueList<int> mibs = iface->mibEnums();
407 for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) { 407 for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) {
408 (void)iface->createForMib(*i); 408 (void)iface->createForMib(*i);
409 // ### it exists now; need to remember if we can delete it 409 // ### it exists now; need to remember if we can delete it
410 } 410 }
411 } 411 }
412 else { 412 else {
413 lib->unload(); 413 lib->unload();
414 delete lib; 414 delete lib;
415 } 415 }
416 } 416 }
417 } 417 }
418 418
419 void loadImageCodecs() 419 void loadImageCodecs()
420 { 420 {
421 QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs"; 421 QString path = QPEApplication::qpeDir() + "plugins/imagecodecs";
422#ifdef Q_OS_MACX 422#ifdef Q_OS_MACX
423 QDir dir( path, "lib*.dylib" ); 423 QDir dir( path, "lib*.dylib" );
424#else 424#else
425 QDir dir( path, "lib*.so" ); 425 QDir dir( path, "lib*.so" );
426#endif 426#endif
427 QStringList list; 427 QStringList list;
428 if ( dir. exists ( )) 428 if ( dir. exists ( ))
429 list = dir.entryList(); 429 list = dir.entryList();
430 QStringList::Iterator it; 430 QStringList::Iterator it;
431 for ( it = list.begin(); it != list.end(); ++it ) { 431 for ( it = list.begin(); it != list.end(); ++it ) {
432 ImageCodecInterface *iface = 0; 432 ImageCodecInterface *iface = 0;
433 QLibrary *lib = new QLibrary( path + "/" + *it ); 433 QLibrary *lib = new QLibrary( path + "/" + *it );
434 if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { 434 if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) {
435 QStringList formats = iface->keys(); 435 QStringList formats = iface->keys();
436 for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) { 436 for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) {
437 (void)iface->installIOHandler(*i); 437 (void)iface->installIOHandler(*i);
438 // ### it exists now; need to remember if we can delete it 438 // ### it exists now; need to remember if we can delete it
439 } 439 }
440 } 440 }
441 else { 441 else {
442 lib->unload(); 442 lib->unload();
443 delete lib; 443 delete lib;
444 } 444 }
445 } 445 }
446 } 446 }
447 447
448}; 448};
449 449
450class ResourceMimeFactory : public QMimeSourceFactory 450class ResourceMimeFactory : public QMimeSourceFactory
451{ 451{
452public: 452public:
453 ResourceMimeFactory() : resImage( 0 ) 453 ResourceMimeFactory() : resImage( 0 )
454 { 454 {
455 setFilePath( Global::helpPath() ); 455 setFilePath( Global::helpPath() );
456 setExtensionType( "html", "text/html;charset=UTF-8" ); 456 setExtensionType( "html", "text/html;charset=UTF-8" );
457 } 457 }
458 ~ResourceMimeFactory() { 458 ~ResourceMimeFactory() {
459 delete resImage; 459 delete resImage;
460 } 460 }
461 461
462 const QMimeSource* data( const QString& abs_name ) const 462 const QMimeSource* data( const QString& abs_name ) const
463 { 463 {
464 const QMimeSource * r = QMimeSourceFactory::data( abs_name ); 464 const QMimeSource * r = QMimeSourceFactory::data( abs_name );
465 if ( !r ) { 465 if ( !r ) {
466 int sl = abs_name.length(); 466 int sl = abs_name.length();
467 do { 467 do {
468 sl = abs_name.findRev( '/', sl - 1 ); 468 sl = abs_name.findRev( '/', sl - 1 );
469 QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name; 469 QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name;
470 int dot = name.findRev( '.' ); 470 int dot = name.findRev( '.' );
471 if ( dot >= 0 ) 471 if ( dot >= 0 )
472 name = name.left( dot ); 472 name = name.left( dot );
473 QImage img = Resource::loadImage( name ); 473 QImage img = Resource::loadImage( name );
474 if ( !img.isNull() ) { 474 if ( !img.isNull() ) {
475 delete resImage; 475 delete resImage;
476 resImage = new QImageDrag( img ); 476 resImage = new QImageDrag( img );
477 r = resImage; 477 r = resImage;
478 } 478 }
479 } 479 }
480 while ( !r && sl > 0 ); 480 while ( !r && sl > 0 );
481 } 481 }
482 return r; 482 return r;
483 } 483 }
484private: 484private:
485 mutable QImageDrag *resImage; 485 mutable QImageDrag *resImage;
486}; 486};
487 487
488static int& hack(int& i) 488static int& hack(int& i)
489{ 489{
490#if QT_VERSION <= 230 && defined(QT_NO_CODECS) 490#if QT_VERSION <= 230 && defined(QT_NO_CODECS)
491 // These should be created, but aren't in Qt 2.3.0 491 // These should be created, but aren't in Qt 2.3.0
492 (void)new QUtf8Codec; 492 (void)new QUtf8Codec;
493 (void)new QUtf16Codec; 493 (void)new QUtf16Codec;
494#endif 494#endif
495 return i; 495 return i;
496} 496}
497 497
498static int muted = 0; 498static int muted = 0;
499static int micMuted = 0; 499static int micMuted = 0;
500 500
501static void setVolume( int t = 0, int percent = -1 ) 501static void setVolume( int t = 0, int percent = -1 )
502{ 502{
503 switch ( t ) { 503 switch ( t ) {
504 case 0: { 504 case 0: {
505 Config cfg( "qpe" ); 505 Config cfg( "qpe" );
506 cfg.setGroup( "Volume" ); 506 cfg.setGroup( "Volume" );
507 if ( percent < 0 ) 507 if ( percent < 0 )
508 percent = cfg.readNumEntry( "VolumePercent", 50 ); 508 percent = cfg.readNumEntry( "VolumePercent", 50 );
509#ifndef QT_NO_SOUND 509#ifndef QT_NO_SOUND
510 int fd = 0; 510 int fd = 0;
511#ifdef QT_QWS_DEVFS 511#ifdef QT_QWS_DEVFS
512 if ( ( fd = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) { 512 if ( ( fd = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) {
513#else 513#else
514 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { 514 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) {
515#endif 515#endif
516 int vol = muted ? 0 : percent; 516 int vol = muted ? 0 : percent;
517 // set both channels to same volume 517 // set both channels to same volume
518 vol |= vol << 8; 518 vol |= vol << 8;
519 ioctl( fd, MIXER_WRITE( SOUND_MIXER_VOLUME ), &vol ); 519 ioctl( fd, MIXER_WRITE( SOUND_MIXER_VOLUME ), &vol );
520 ::close( fd ); 520 ::close( fd );
521 } 521 }
522#endif 522#endif
523 } 523 }
524 break; 524 break;
525 } 525 }
526} 526}
527 527
528static void setMic( int t = 0, int percent = -1 ) 528static void setMic( int t = 0, int percent = -1 )
529{ 529{
530 switch ( t ) { 530 switch ( t ) {
531 case 0: { 531 case 0: {
532 Config cfg( "qpe" ); 532 Config cfg( "qpe" );
533 cfg.setGroup( "Volume" ); 533 cfg.setGroup( "Volume" );
534 if ( percent < 0 ) 534 if ( percent < 0 )
535 percent = cfg.readNumEntry( "Mic", 50 ); 535 percent = cfg.readNumEntry( "Mic", 50 );
536 536
537#ifndef QT_NO_SOUND 537#ifndef QT_NO_SOUND
538 int fd = 0; 538 int fd = 0;
539 int mic = micMuted ? 0 : percent; 539 int mic = micMuted ? 0 : percent;
540#ifdef QT_QWS_DEVFS 540#ifdef QT_QWS_DEVFS
541 if ( ( fd = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) { 541 if ( ( fd = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) {
542#else 542#else
543 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { 543 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) {
544#endif 544#endif
545 ioctl( fd, MIXER_WRITE( SOUND_MIXER_MIC ), &mic ); 545 ioctl( fd, MIXER_WRITE( SOUND_MIXER_MIC ), &mic );
546 ::close( fd ); 546 ::close( fd );
547 } 547 }
548#endif 548#endif
549 } 549 }
550 break; 550 break;
551 } 551 }
552} 552}
553 553
554 554
555static void setBass( int t = 0, int percent = -1 ) 555static void setBass( int t = 0, int percent = -1 )
556{ 556{
557 switch ( t ) { 557 switch ( t ) {
558 case 0: { 558 case 0: {
559 Config cfg( "qpe" ); 559 Config cfg( "qpe" );
560 cfg.setGroup( "Volume" ); 560 cfg.setGroup( "Volume" );
561 if ( percent < 0 ) 561 if ( percent < 0 )
562 percent = cfg.readNumEntry( "BassPercent", 50 ); 562 percent = cfg.readNumEntry( "BassPercent", 50 );
563 563
564#ifndef QT_NO_SOUND 564#ifndef QT_NO_SOUND
565 int fd = 0; 565 int fd = 0;
566 int bass = percent; 566 int bass = percent;
567#ifdef QT_QWS_DEVFS 567#ifdef QT_QWS_DEVFS
568 if ( ( fd = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) { 568 if ( ( fd = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) {
569#else 569#else
570 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { 570 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) {
571#endif 571#endif
572 ioctl( fd, MIXER_WRITE( SOUND_MIXER_BASS ), &bass ); 572 ioctl( fd, MIXER_WRITE( SOUND_MIXER_BASS ), &bass );
573 ::close( fd ); 573 ::close( fd );
574 } 574 }
575#endif 575#endif
576 } 576 }
577 break; 577 break;
578 } 578 }
579} 579}
580 580
581 581
582static void setTreble( int t = 0, int percent = -1 ) 582static void setTreble( int t = 0, int percent = -1 )
583{ 583{
584 switch ( t ) { 584 switch ( t ) {
585 case 0: { 585 case 0: {
586 Config cfg( "qpe" ); 586 Config cfg( "qpe" );
587 cfg.setGroup( "Volume" ); 587 cfg.setGroup( "Volume" );
588 if ( percent < 0 ) 588 if ( percent < 0 )
589 percent = cfg.readNumEntry( "TreblePercent", 50 ); 589 percent = cfg.readNumEntry( "TreblePercent", 50 );
590 590
591#ifndef QT_NO_SOUND 591#ifndef QT_NO_SOUND
592 int fd = 0; 592 int fd = 0;
593 int treble = percent; 593 int treble = percent;
594#ifdef QT_QWS_DEVFS 594#ifdef QT_QWS_DEVFS
595 if ( ( fd = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) { 595 if ( ( fd = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) {
596#else 596#else
597 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { 597 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) {
598#endif 598#endif
599 ioctl( fd, MIXER_WRITE( SOUND_MIXER_TREBLE ), &treble ); 599 ioctl( fd, MIXER_WRITE( SOUND_MIXER_TREBLE ), &treble );
600 ::close( fd ); 600 ::close( fd );
601 } 601 }
602#endif 602#endif
603 } 603 }
604 break; 604 break;
605 } 605 }
606} 606}
607 607
608 608
609/** 609/**
610 \class QPEApplication 610 \class QPEApplication
611 \brief The QPEApplication class implements various system services 611 \brief The QPEApplication class implements various system services
612 that are available to all Qtopia applications. 612 that are available to all Qtopia applications.
613 613
614 Simply by using QPEApplication instead of QApplication, a standard Qt 614 Simply by using QPEApplication instead of QApplication, a standard Qt
615 application becomes a Qtopia application. It automatically follows 615 application becomes a Qtopia application. It automatically follows
616 style changes, quits and raises, and in the 616 style changes, quits and raises, and in the
617 case of \link docwidget.html document-oriented\endlink applications, 617 case of \link docwidget.html document-oriented\endlink applications,
618 changes the currently displayed document in response to the environment. 618 changes the currently displayed document in response to the environment.
619 619
620 To create a \link docwidget.html document-oriented\endlink 620 To create a \link docwidget.html document-oriented\endlink
621 application use showMainDocumentWidget(); to create a 621 application use showMainDocumentWidget(); to create a
622 non-document-oriented application use showMainWidget(). The 622 non-document-oriented application use showMainWidget(). The
623 keepRunning() function indicates whether the application will 623 keepRunning() function indicates whether the application will
624 continue running after it's processed the last \link qcop.html 624 continue running after it's processed the last \link qcop.html
625 QCop\endlink message. This can be changed using setKeepRunning(). 625 QCop\endlink message. This can be changed using setKeepRunning().
626 626
627 A variety of signals are emitted when certain events occur, for 627 A variety of signals are emitted when certain events occur, for
628 example, timeChanged(), clockChanged(), weekChanged(), 628 example, timeChanged(), clockChanged(), weekChanged(),
629 dateFormatChanged() and volumeChanged(). If the application receives 629 dateFormatChanged() and volumeChanged(). If the application receives
630 a \link qcop.html QCop\endlink message on the application's 630 a \link qcop.html QCop\endlink message on the application's
631 QPE/Application/\e{appname} channel, the appMessage() signal is 631 QPE/Application/\e{appname} channel, the appMessage() signal is
632 emitted. There are also flush() and reload() signals, which 632 emitted. There are also flush() and reload() signals, which
633 are emitted when synching begins and ends respectively - upon these 633 are emitted when synching begins and ends respectively - upon these
634 signals, the application should save and reload any data 634 signals, the application should save and reload any data
635 files that are involved in synching. Most of these signals will initially 635 files that are involved in synching. Most of these signals will initially
636 be received and unfiltered through the appMessage() signal. 636 be received and unfiltered through the appMessage() signal.
637 637
638 This class also provides a set of useful static functions. The 638 This class also provides a set of useful static functions. The
639 qpeDir() and documentDir() functions return the respective paths. 639 qpeDir() and documentDir() functions return the respective paths.
640 The grabKeyboard() and ungrabKeyboard() functions are used to 640 The grabKeyboard() and ungrabKeyboard() functions are used to
641 control whether the application takes control of the device's 641 control whether the application takes control of the device's
642 physical buttons (e.g. application launch keys). The stylus' mode of 642 physical buttons (e.g. application launch keys). The stylus' mode of
643 operation is set with setStylusOperation() and retrieved with 643 operation is set with setStylusOperation() and retrieved with
644 stylusOperation(). There are also setInputMethodHint() and 644 stylusOperation(). There are also setInputMethodHint() and
645 inputMethodHint() functions. 645 inputMethodHint() functions.
646 646
647 \ingroup qtopiaemb 647 \ingroup qtopiaemb
648*/ 648*/
649 649
650/*! 650/*!
651 \fn void QPEApplication::clientMoused() 651 \fn void QPEApplication::clientMoused()
652 652
653 \internal 653 \internal
654*/ 654*/
655 655
656/*! 656/*!
657 \fn void QPEApplication::timeChanged(); 657 \fn void QPEApplication::timeChanged();
658 This signal is emitted when the time changes outside the normal 658 This signal is emitted when the time changes outside the normal
659 passage of time, i.e. if the time is set backwards or forwards. 659 passage of time, i.e. if the time is set backwards or forwards.
660*/ 660*/
661 661
662/*! 662/*!
663 \fn void QPEApplication::clockChanged( bool ampm ); 663 \fn void QPEApplication::clockChanged( bool ampm );
664 664
665 This signal is emitted when the user changes the clock's style. If 665 This signal is emitted when the user changes the clock's style. If
666 \a ampm is TRUE, the user wants a 12-hour AM/PM clock, otherwise, 666 \a ampm is TRUE, the user wants a 12-hour AM/PM clock, otherwise,
667 they want a 24-hour clock. 667 they want a 24-hour clock.
668*/ 668*/
669 669
670/*! 670/*!
671 \fn void QPEApplication::volumeChanged( bool muted ) 671 \fn void QPEApplication::volumeChanged( bool muted )
672 672
673 This signal is emitted whenever the mute state is changed. If \a 673 This signal is emitted whenever the mute state is changed. If \a
674 muted is TRUE, then sound output has been muted. 674 muted is TRUE, then sound output has been muted.
675*/ 675*/
676 676
677/*! 677/*!
@@ -934,517 +934,530 @@ void QPEApplication::initApp( int argc, char **argv )
934 934
935 /* overide stored arguments */ 935 /* overide stored arguments */
936 setArgs(argc, argv); 936 setArgs(argc, argv);
937 937
938 /* install translation here */ 938 /* install translation here */
939 for ( QStringList::ConstIterator it = d->langs.begin(); it != d->langs.end(); ++it ) 939 for ( QStringList::ConstIterator it = d->langs.begin(); it != d->langs.end(); ++it )
940 installTranslation( (*it) + "/" + d->appName + ".qm" ); 940 installTranslation( (*it) + "/" + d->appName + ".qm" );
941} 941}
942#endif 942#endif
943 943
944 944
945static QPtrDict<void>* inputMethodDict = 0; 945static QPtrDict<void>* inputMethodDict = 0;
946static void createInputMethodDict() 946static void createInputMethodDict()
947{ 947{
948 if ( !inputMethodDict ) 948 if ( !inputMethodDict )
949 inputMethodDict = new QPtrDict<void>; 949 inputMethodDict = new QPtrDict<void>;
950} 950}
951 951
952/*! 952/*!
953 Returns the currently set hint to the system as to whether 953 Returns the currently set hint to the system as to whether
954 widget \a w has any use for text input methods. 954 widget \a w has any use for text input methods.
955 955
956 956
957 \sa setInputMethodHint() InputMethodHint 957 \sa setInputMethodHint() InputMethodHint
958*/ 958*/
959QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w ) 959QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w )
960{ 960{
961 if ( inputMethodDict && w ) 961 if ( inputMethodDict && w )
962 return ( InputMethodHint ) ( int ) inputMethodDict->find( w ); 962 return ( InputMethodHint ) ( int ) inputMethodDict->find( w );
963 return Normal; 963 return Normal;
964} 964}
965 965
966/*! 966/*!
967 \enum QPEApplication::InputMethodHint 967 \enum QPEApplication::InputMethodHint
968 968
969 \value Normal the application sometimes needs text input (the default). 969 \value Normal the application sometimes needs text input (the default).
970 \value AlwaysOff the application never needs text input. 970 \value AlwaysOff the application never needs text input.
971 \value AlwaysOn the application always needs text input. 971 \value AlwaysOn the application always needs text input.
972*/ 972*/
973 973
974/*! 974/*!
975 Hints to the system that widget \a w has use for text input methods 975 Hints to the system that widget \a w has use for text input methods
976 as specified by \a mode. 976 as specified by \a mode.
977 977
978 \sa inputMethodHint() InputMethodHint 978 \sa inputMethodHint() InputMethodHint
979*/ 979*/
980void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode ) 980void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode )
981{ 981{
982 createInputMethodDict(); 982 createInputMethodDict();
983 if ( mode == Normal ) { 983 if ( mode == Normal ) {
984 inputMethodDict->remove 984 inputMethodDict->remove
985 ( w ); 985 ( w );
986 } 986 }
987 else { 987 else {
988 inputMethodDict->insert( w, ( void* ) mode ); 988 inputMethodDict->insert( w, ( void* ) mode );
989 } 989 }
990} 990}
991 991
992class HackDialog : public QDialog 992class HackDialog : public QDialog
993{ 993{
994public: 994public:
995 void acceptIt() 995 void acceptIt()
996 { 996 {
997 accept(); 997 accept();
998 } 998 }
999 void rejectIt() 999 void rejectIt()
1000 { 1000 {
1001 reject(); 1001 reject();
1002 } 1002 }
1003}; 1003};
1004 1004
1005 1005
1006void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key ) 1006void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key )
1007{ 1007{
1008 // specialised actions for certain widgets. May want to 1008 // specialised actions for certain widgets. May want to
1009 // add more stuff here. 1009 // add more stuff here.
1010 if ( activePopupWidget() && activePopupWidget() ->inherits( "QListBox" ) 1010 if ( activePopupWidget() && activePopupWidget() ->inherits( "QListBox" )
1011 && activePopupWidget() ->parentWidget() 1011 && activePopupWidget() ->parentWidget()
1012 && activePopupWidget() ->parentWidget() ->inherits( "QComboBox" ) ) 1012 && activePopupWidget() ->parentWidget() ->inherits( "QComboBox" ) )
1013 key = Qt::Key_Return; 1013 key = Qt::Key_Return;
1014 1014
1015 if ( activePopupWidget() && activePopupWidget() ->inherits( "QPopupMenu" ) ) 1015 if ( activePopupWidget() && activePopupWidget() ->inherits( "QPopupMenu" ) )
1016 key = Qt::Key_Return; 1016 key = Qt::Key_Return;
1017 1017
1018#ifdef QWS 1018#ifdef QWS
1019 1019
1020 ke->simpleData.keycode = key; 1020 ke->simpleData.keycode = key;
1021#endif 1021#endif
1022} 1022}
1023 1023
1024 1024
1025/*! 1025/*!
1026 \internal 1026 \internal
1027*/ 1027*/
1028 1028
1029#ifdef QWS 1029#ifdef QWS
1030bool QPEApplication::qwsEventFilter( QWSEvent * e ) 1030bool QPEApplication::qwsEventFilter( QWSEvent * e )
1031{ 1031{
1032 if ( !d->notbusysent && e->type == QWSEvent::Focus ) { 1032 if ( !d->notbusysent && e->type == QWSEvent::Focus ) {
1033 if ( qApp->type() != QApplication::GuiServer ) { 1033 if ( qApp->type() != QApplication::GuiServer ) {
1034 QCopEnvelope e( "QPE/System", "notBusy(QString)" ); 1034 QCopEnvelope e( "QPE/System", "notBusy(QString)" );
1035 e << d->appName; 1035 e << d->appName;
1036 } 1036 }
1037 d->notbusysent = TRUE; 1037 d->notbusysent = TRUE;
1038 } 1038 }
1039 if ( type() == GuiServer ) { 1039 if ( type() == GuiServer ) {
1040 switch ( e->type ) { 1040 switch ( e->type ) {
1041 case QWSEvent::Mouse: 1041 case QWSEvent::Mouse:
1042 if ( e->asMouse() ->simpleData.state && !QWidget::find( e->window() ) ) 1042 if ( e->asMouse() ->simpleData.state && !QWidget::find( e->window() ) )
1043 emit clientMoused(); 1043 emit clientMoused();
1044 break; 1044 break;
1045 default: 1045 default:
1046 break; 1046 break;
1047 } 1047 }
1048 } 1048 }
1049 if ( e->type == QWSEvent::Key ) { 1049 if ( e->type == QWSEvent::Key ) {
1050 QWSKeyEvent *ke = ( QWSKeyEvent * ) e; 1050 QWSKeyEvent *ke = ( QWSKeyEvent * ) e;
1051 if ( ke->simpleData.keycode == Qt::Key_F33 ) { 1051 if ( ke->simpleData.keycode == Qt::Key_F33 ) {
1052 // Use special "OK" key to press "OK" on top level widgets 1052 // Use special "OK" key to press "OK" on top level widgets
1053 QWidget * active = activeWindow(); 1053 QWidget * active = activeWindow();
1054 QWidget *popup = 0; 1054 QWidget *popup = 0;
1055 if ( active && active->isPopup() ) { 1055 if ( active && active->isPopup() ) {
1056 popup = active; 1056 popup = active;
1057 active = active->parentWidget(); 1057 active = active->parentWidget();
1058 } 1058 }
1059 if ( active && ( int ) active->winId() == ke->simpleData.window && 1059 if ( active && ( int ) active->winId() == ke->simpleData.window &&
1060 !active->testWFlags( WStyle_Customize | WType_Popup | WType_Desktop ) ) { 1060 !active->testWFlags( WStyle_Customize | WType_Popup | WType_Desktop ) ) {
1061 if ( ke->simpleData.is_press ) { 1061 if ( ke->simpleData.is_press ) {
1062 if ( popup ) 1062 if ( popup )
1063 popup->close(); 1063 popup->close();
1064 if ( active->inherits( "QDialog" ) ) { 1064 if ( active->inherits( "QDialog" ) ) {
1065 HackDialog * d = ( HackDialog * ) active; 1065 HackDialog * d = ( HackDialog * ) active;
1066 d->acceptIt(); 1066 d->acceptIt();
1067 return TRUE; 1067 return TRUE;
1068 } 1068 }
1069 else if ( ( ( HackWidget * ) active ) ->needsOk() ) { 1069 else if ( ( ( HackWidget * ) active ) ->needsOk() ) {
1070 QSignal s; 1070 QSignal s;
1071 s.connect( active, SLOT( accept() ) ); 1071 s.connect( active, SLOT( accept() ) );
1072 s.activate(); 1072 s.activate();
1073 } 1073 }
1074 else { 1074 else {
1075 // do the same as with the select key: Map to the default action of the widget: 1075 // do the same as with the select key: Map to the default action of the widget:
1076 mapToDefaultAction( ke, Qt::Key_Return ); 1076 mapToDefaultAction( ke, Qt::Key_Return );
1077 } 1077 }
1078 } 1078 }
1079 } 1079 }
1080 } 1080 }
1081 else if ( ke->simpleData.keycode == Qt::Key_F30 ) { 1081 else if ( ke->simpleData.keycode == Qt::Key_F30 ) {
1082 // Use special "select" key to do whatever default action a widget has 1082 // Use special "select" key to do whatever default action a widget has
1083 mapToDefaultAction( ke, Qt::Key_Space ); 1083 mapToDefaultAction( ke, Qt::Key_Space );
1084 } 1084 }
1085 else if ( ke->simpleData.keycode == Qt::Key_Escape && 1085 else if ( ke->simpleData.keycode == Qt::Key_Escape &&
1086 ke->simpleData.is_press ) { 1086 ke->simpleData.is_press ) {
1087 // Escape key closes app if focus on toplevel 1087 // Escape key closes app if focus on toplevel
1088 QWidget * active = activeWindow(); 1088 QWidget * active = activeWindow();
1089 if ( active && active->testWFlags( WType_TopLevel ) && 1089 if ( active && active->testWFlags( WType_TopLevel ) &&
1090 ( int ) active->winId() == ke->simpleData.window && 1090 ( int ) active->winId() == ke->simpleData.window &&
1091 !active->testWFlags( WStyle_Dialog | WStyle_Customize | WType_Popup | WType_Desktop ) ) { 1091 !active->testWFlags( WStyle_Dialog | WStyle_Customize | WType_Popup | WType_Desktop ) ) {
1092 if ( active->inherits( "QDialog" ) ) { 1092 if ( active->inherits( "QDialog" ) ) {
1093 HackDialog * d = ( HackDialog * ) active; 1093 HackDialog * d = ( HackDialog * ) active;
1094 d->rejectIt(); 1094 d->rejectIt();
1095 return TRUE; 1095 return TRUE;
1096 } else /*if ( strcmp( argv() [ 0 ], "embeddedkonsole" ) != 0 )*/ { 1096 } else /*if ( strcmp( argv() [ 0 ], "embeddedkonsole" ) != 0 )*/ {
1097 active->close(); 1097 active->close();
1098 } 1098 }
1099 } 1099 }
1100 1100
1101 } 1101 }
1102 else if ( ke->simpleData.keycode >= Qt::Key_F1 && ke->simpleData.keycode <= Qt::Key_F29 ) { 1102 else if ( ke->simpleData.keycode >= Qt::Key_F1 && ke->simpleData.keycode <= Qt::Key_F29 ) {
1103 // this should be if ( ODevice::inst ( )-> buttonForKeycode ( ... )) 1103 // this should be if ( ODevice::inst ( )-> buttonForKeycode ( ... ))
1104 // but we cannot access libopie function within libqpe :( 1104 // but we cannot access libopie function within libqpe :(
1105 1105
1106 QWidget * active = activeWindow ( ); 1106 QWidget * active = activeWindow ( );
1107 if ( active && ((int) active-> winId ( ) == ke-> simpleData.window )) { 1107 if ( active && ((int) active-> winId ( ) == ke-> simpleData.window )) {
1108 if ( d-> kbgrabbed ) { // we grabbed the keyboard 1108 if ( d-> kbgrabbed ) { // we grabbed the keyboard
1109 QChar ch ( ke-> simpleData.unicode ); 1109 QChar ch ( ke-> simpleData.unicode );
1110 QKeyEvent qke ( ke-> simpleData. is_press ? QEvent::KeyPress : QEvent::KeyRelease, 1110 QKeyEvent qke ( ke-> simpleData. is_press ? QEvent::KeyPress : QEvent::KeyRelease,
1111 ke-> simpleData.keycode, 1111 ke-> simpleData.keycode,
1112 ch. latin1 ( ), 1112 ch. latin1 ( ),
1113 ke-> simpleData.modifiers, 1113 ke-> simpleData.modifiers,
1114 QString ( ch ), 1114 QString ( ch ),
1115 ke-> simpleData.is_auto_repeat, 1 ); 1115 ke-> simpleData.is_auto_repeat, 1 );
1116 1116
1117 QObject *which = QWidget::keyboardGrabber ( ); 1117 QObject *which = QWidget::keyboardGrabber ( );
1118 if ( !which ) 1118 if ( !which )
1119 which = QApplication::focusWidget ( ); 1119 which = QApplication::focusWidget ( );
1120 if ( !which ) 1120 if ( !which )
1121 which = QApplication::activeWindow ( ); 1121 which = QApplication::activeWindow ( );
1122 if ( !which ) 1122 if ( !which )
1123 which = qApp; 1123 which = qApp;
1124 1124
1125 QApplication::sendEvent ( which, &qke ); 1125 QApplication::sendEvent ( which, &qke );
1126 } 1126 }
1127 else { // we didn't grab the keyboard, so send the event to the launcher 1127 else { // we didn't grab the keyboard, so send the event to the launcher
1128 QCopEnvelope e ( "QPE/Launcher", "deviceButton(int,int,int)" ); 1128 QCopEnvelope e ( "QPE/Launcher", "deviceButton(int,int,int)" );
1129 e << int( ke-> simpleData.keycode ) << int( ke-> simpleData. is_press ) << int( ke-> simpleData.is_auto_repeat ); 1129 e << int( ke-> simpleData.keycode ) << int( ke-> simpleData. is_press ) << int( ke-> simpleData.is_auto_repeat );
1130 } 1130 }
1131 } 1131 }
1132 return true; 1132 return true;
1133 } 1133 }
1134 } 1134 }
1135 if ( e->type == QWSEvent::Focus ) { 1135 if ( e->type == QWSEvent::Focus ) {
1136 QWSFocusEvent * fe = ( QWSFocusEvent* ) e; 1136 QWSFocusEvent * fe = ( QWSFocusEvent* ) e;
1137 if ( !fe->simpleData.get_focus ) { 1137 if ( !fe->simpleData.get_focus ) {
1138 QWidget * active = activeWindow(); 1138 QWidget * active = activeWindow();
1139 while ( active && active->isPopup() ) { 1139 while ( active && active->isPopup() ) {
1140 active->close(); 1140 active->close();
1141 active = activeWindow(); 1141 active = activeWindow();
1142 } 1142 }
1143 } 1143 }
1144 else { 1144 else {
1145 // make sure our modal widget is ALWAYS on top 1145 // make sure our modal widget is ALWAYS on top
1146 QWidget *topm = activeModalWidget(); 1146 QWidget *topm = activeModalWidget();
1147 if ( topm && static_cast<int>( topm->winId() ) != fe->simpleData.window) { 1147 if ( topm && static_cast<int>( topm->winId() ) != fe->simpleData.window) {
1148 topm->raise(); 1148 topm->raise();
1149 } 1149 }
1150 } 1150 }
1151 if ( fe->simpleData.get_focus && inputMethodDict ) { 1151 if ( fe->simpleData.get_focus && inputMethodDict ) {
1152 InputMethodHint m = inputMethodHint( QWidget::find( e->window() ) ); 1152 InputMethodHint m = inputMethodHint( QWidget::find( e->window() ) );
1153 if ( m == AlwaysOff ) 1153 if ( m == AlwaysOff )
1154 Global::hideInputMethod(); 1154 Global::hideInputMethod();
1155 if ( m == AlwaysOn ) 1155 if ( m == AlwaysOn )
1156 Global::showInputMethod(); 1156 Global::showInputMethod();
1157 } 1157 }
1158 } 1158 }
1159 1159
1160 1160
1161 return QApplication::qwsEventFilter( e ); 1161 return QApplication::qwsEventFilter( e );
1162} 1162}
1163#endif 1163#endif
1164 1164
1165/*! 1165/*!
1166 Destroys the QPEApplication. 1166 Destroys the QPEApplication.
1167*/ 1167*/
1168QPEApplication::~QPEApplication() 1168QPEApplication::~QPEApplication()
1169{ 1169{
1170 ungrabKeyboard(); 1170 ungrabKeyboard();
1171#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 1171#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
1172 // Need to delete QCopChannels early, since the display will 1172 // Need to delete QCopChannels early, since the display will
1173 // be gone by the time we get to ~QObject(). 1173 // be gone by the time we get to ~QObject().
1174 delete sysChannel; 1174 delete sysChannel;
1175 delete pidChannel; 1175 delete pidChannel;
1176#endif 1176#endif
1177 1177
1178#ifdef OPIE_WITHROHFEEDBACK 1178#ifdef OPIE_WITHROHFEEDBACK
1179 if( d->RoH ) 1179 if( d->RoH )
1180 delete d->RoH; 1180 delete d->RoH;
1181#endif 1181#endif
1182 delete d; 1182 delete d;
1183} 1183}
1184 1184
1185/*! 1185/*!
1186 Returns <tt>$OPIEDIR/</tt>. 1186 Returns <tt>$OPIEDIR/</tt>.
1187*/ 1187*/
1188QString QPEApplication::qpeDir() 1188QString QPEApplication::qpeDir()
1189{ 1189{
1190 const char * base = getenv( "OPIEDIR" ); 1190 QString base, dir;
1191 if ( base ) 1191
1192 return QString( base ) + "/"; 1192 if (getenv( "OPIEDIR" ))
1193 base = QString(getenv("OPIEDIR")).stripWhiteSpace();
1194 if ( !base.isNull() && (base.length() > 0 )){
1195#ifdef Q_OS_WIN32
1196 QString temp(base);
1197 if (temp[(int)temp.length()-1] != QDir::separator())
1198 temp.append(QDir::separator());
1199 dir = temp;
1200#else
1201 dir = QString( base ) + "/";
1202#endif
1203 }else{
1204 dir = QString( ".." ) + QDir::separator();
1205 }
1193 1206
1194 return QString( "../" ); 1207 return dir;
1195} 1208}
1196 1209
1197/*! 1210/*!
1198 Returns the user's current Document directory. There is a trailing "/". 1211 Returns the user's current Document directory. There is a trailing "/".
1199 .. well, it does now,, and there's no trailing '/' 1212 .. well, it does now,, and there's no trailing '/'
1200*/ 1213*/
1201QString QPEApplication::documentDir() 1214QString QPEApplication::documentDir()
1202{ 1215{
1203 const char* base = getenv( "HOME"); 1216 const char* base = getenv( "HOME");
1204 if ( base ) 1217 if ( base )
1205 return QString( base ) + "/Documents"; 1218 return QString( base ) + "/Documents";
1206 1219
1207 return QString( "../Documents" ); 1220 return QString( "../Documents" );
1208} 1221}
1209 1222
1210static int deforient = -1; 1223static int deforient = -1;
1211 1224
1212/*! 1225/*!
1213 \internal 1226 \internal
1214*/ 1227*/
1215int QPEApplication::defaultRotation() 1228int QPEApplication::defaultRotation()
1216{ 1229{
1217 if ( deforient < 0 ) { 1230 if ( deforient < 0 ) {
1218 QString d = getenv( "QWS_DISPLAY" ); 1231 QString d = getenv( "QWS_DISPLAY" );
1219 if ( d.contains( "Rot90" ) ) { 1232 if ( d.contains( "Rot90" ) ) {
1220 deforient = 90; 1233 deforient = 90;
1221 } 1234 }
1222 else if ( d.contains( "Rot180" ) ) { 1235 else if ( d.contains( "Rot180" ) ) {
1223 deforient = 180; 1236 deforient = 180;
1224 } 1237 }
1225 else if ( d.contains( "Rot270" ) ) { 1238 else if ( d.contains( "Rot270" ) ) {
1226 deforient = 270; 1239 deforient = 270;
1227 } 1240 }
1228 else { 1241 else {
1229 deforient = 0; 1242 deforient = 0;
1230 } 1243 }
1231 } 1244 }
1232 return deforient; 1245 return deforient;
1233} 1246}
1234 1247
1235/*! 1248/*!
1236 \internal 1249 \internal
1237*/ 1250*/
1238void QPEApplication::setDefaultRotation( int r ) 1251void QPEApplication::setDefaultRotation( int r )
1239{ 1252{
1240 if ( qApp->type() == GuiServer ) { 1253 if ( qApp->type() == GuiServer ) {
1241 deforient = r; 1254 deforient = r;
1242 setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 ); 1255 setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 );
1243 Config config("qpe"); 1256 Config config("qpe");
1244 config.setGroup( "Rotation" ); 1257 config.setGroup( "Rotation" );
1245 config.writeEntry( "Rot", r ); 1258 config.writeEntry( "Rot", r );
1246 } 1259 }
1247 else { 1260 else {
1248#ifndef QT_NO_COP 1261#ifndef QT_NO_COP
1249 { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" ); 1262 { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" );
1250 e << r; 1263 e << r;
1251 } 1264 }
1252#endif 1265#endif
1253 1266
1254 } 1267 }
1255} 1268}
1256 1269
1257#include <qgfx_qws.h> 1270#include <qgfx_qws.h>
1258#include <qwindowsystem_qws.h> 1271#include <qwindowsystem_qws.h>
1259 1272
1260#if QT_VERSION > 236 1273#if QT_VERSION > 236
1261extern void qws_clearLoadedFonts(); 1274extern void qws_clearLoadedFonts();
1262#endif 1275#endif
1263 1276
1264void QPEApplication::setCurrentMode( int x, int y, int depth ) 1277void QPEApplication::setCurrentMode( int x, int y, int depth )
1265{ 1278{
1266 // Reset the caches 1279 // Reset the caches
1267#if QT_VERSION > 236 1280#if QT_VERSION > 236
1268 qws_clearLoadedFonts(); 1281 qws_clearLoadedFonts();
1269#endif 1282#endif
1270 QPixmapCache::clear(); 1283 QPixmapCache::clear();
1271 1284
1272 // Change the screen mode 1285 // Change the screen mode
1273 qt_screen->setMode(x, y, depth); 1286 qt_screen->setMode(x, y, depth);
1274 1287
1275 if ( qApp->type() == GuiServer ) { 1288 if ( qApp->type() == GuiServer ) {
1276#if QT_VERSION > 236 1289#if QT_VERSION > 236
1277 // Reconfigure the GuiServer 1290 // Reconfigure the GuiServer
1278 qwsServer->beginDisplayReconfigure(); 1291 qwsServer->beginDisplayReconfigure();
1279 qwsServer->endDisplayReconfigure(); 1292 qwsServer->endDisplayReconfigure();
1280#endif 1293#endif
1281 // Get all the running apps to reset 1294 // Get all the running apps to reset
1282 QCopEnvelope env( "QPE/System", "reset()" ); 1295 QCopEnvelope env( "QPE/System", "reset()" );
1283 } 1296 }
1284} 1297}
1285 1298
1286void QPEApplication::reset() { 1299void QPEApplication::reset() {
1287 // Reconnect to the screen 1300 // Reconnect to the screen
1288 qt_screen->disconnect(); 1301 qt_screen->disconnect();
1289 qt_screen->connect( QString::null ); 1302 qt_screen->connect( QString::null );
1290 1303
1291 // Redraw everything 1304 // Redraw everything
1292 applyStyle(); 1305 applyStyle();
1293} 1306}
1294 1307
1295#if (QT_VERSION < 238) && defined Q_OS_MACX 1308#if (QT_VERSION < 238) && defined Q_OS_MACX
1296bool qt_left_hand_scrollbars = false; 1309bool qt_left_hand_scrollbars = false;
1297#else 1310#else
1298extern bool qt_left_hand_scrollbars QPE_WEAK_SYMBOL; 1311extern bool qt_left_hand_scrollbars QPE_WEAK_SYMBOL;
1299#endif 1312#endif
1300 1313
1301/*! 1314/*!
1302 \internal 1315 \internal
1303*/ 1316*/
1304void QPEApplication::applyStyle() 1317void QPEApplication::applyStyle()
1305{ 1318{
1306 Config config( "qpe" ); 1319 Config config( "qpe" );
1307 config.setGroup( "Appearance" ); 1320 config.setGroup( "Appearance" );
1308 1321
1309#if QT_VERSION > 233 1322#if QT_VERSION > 233
1310#if !defined(OPIE_NO_OVERRIDE_QT) 1323#if !defined(OPIE_NO_OVERRIDE_QT)
1311 // don't block ourselves ... 1324 // don't block ourselves ...
1312 Opie::force_appearance = 0; 1325 Opie::force_appearance = 0;
1313 1326
1314 static QString appname = Opie::binaryName ( ); 1327 static QString appname = Opie::binaryName ( );
1315 1328
1316 QStringList ex = config. readListEntry ( "NoStyle", ';' ); 1329 QStringList ex = config. readListEntry ( "NoStyle", ';' );
1317 int nostyle = 0; 1330 int nostyle = 0;
1318 for ( QStringList::Iterator it = ex. begin ( ); it != ex. end ( ); ++it ) { 1331 for ( QStringList::Iterator it = ex. begin ( ); it != ex. end ( ); ++it ) {
1319 if ( QRegExp (( *it ). mid ( 1 ), false, true ). find ( appname, 0 ) >= 0 ) { 1332 if ( QRegExp (( *it ). mid ( 1 ), false, true ). find ( appname, 0 ) >= 0 ) {
1320 nostyle = ( *it ). left ( 1 ). toInt ( 0, 32 ); 1333 nostyle = ( *it ). left ( 1 ). toInt ( 0, 32 );
1321 break; 1334 break;
1322 } 1335 }
1323 } 1336 }
1324#else 1337#else
1325 int nostyle = 0; 1338 int nostyle = 0;
1326#endif 1339#endif
1327 1340
1328 // Widget style 1341 // Widget style
1329 QString style = config.readEntry( "Style", "FlatStyle" ); 1342 QString style = config.readEntry( "Style", "FlatStyle" );
1330 1343
1331 // don't set a custom style 1344 // don't set a custom style
1332 if ( nostyle & Opie::Force_Style ) 1345 if ( nostyle & Opie::Force_Style )
1333 style = "FlatStyle"; 1346 style = "FlatStyle";
1334 1347
1335 internalSetStyle ( style ); 1348 internalSetStyle ( style );
1336 1349
1337 // Colors - from /etc/colors/Liquid.scheme 1350 // Colors - from /etc/colors/Liquid.scheme
1338 QColor bgcolor( config.readEntry( "Background", "#E0E0E0" ) ); 1351 QColor bgcolor( config.readEntry( "Background", "#E0E0E0" ) );
1339 QColor btncolor( config.readEntry( "Button", "#96c8fa" ) ); 1352 QColor btncolor( config.readEntry( "Button", "#96c8fa" ) );
1340 QPalette pal( btncolor, bgcolor ); 1353 QPalette pal( btncolor, bgcolor );
1341 QString color = config.readEntry( "Highlight", "#73adef" ); 1354 QString color = config.readEntry( "Highlight", "#73adef" );
1342 pal.setColor( QColorGroup::Highlight, QColor( color ) ); 1355 pal.setColor( QColorGroup::Highlight, QColor( color ) );
1343 color = config.readEntry( "HighlightedText", "#FFFFFF" ); 1356 color = config.readEntry( "HighlightedText", "#FFFFFF" );
1344 pal.setColor( QColorGroup::HighlightedText, QColor( color ) ); 1357 pal.setColor( QColorGroup::HighlightedText, QColor( color ) );
1345 color = config.readEntry( "Text", "#000000" ); 1358 color = config.readEntry( "Text", "#000000" );
1346 pal.setColor( QColorGroup::Text, QColor( color ) ); 1359 pal.setColor( QColorGroup::Text, QColor( color ) );
1347 color = config.readEntry( "ButtonText", "#000000" ); 1360 color = config.readEntry( "ButtonText", "#000000" );
1348 pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) ); 1361 pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) );
1349 color = config.readEntry( "Base", "#FFFFFF" ); 1362 color = config.readEntry( "Base", "#FFFFFF" );
1350 pal.setColor( QColorGroup::Base, QColor( color ) ); 1363 pal.setColor( QColorGroup::Base, QColor( color ) );
1351 1364
1352 pal.setColor( QPalette::Disabled, QColorGroup::Text, 1365 pal.setColor( QPalette::Disabled, QColorGroup::Text,
1353 pal.color( QPalette::Active, QColorGroup::Background ).dark() ); 1366 pal.color( QPalette::Active, QColorGroup::Background ).dark() );
1354 1367
1355 setPalette( pal, TRUE ); 1368 setPalette( pal, TRUE );
1356 1369
1357 1370
1358 // Set the ScrollBar on the 'right' side but only if the weak symbol is present 1371 // Set the ScrollBar on the 'right' side but only if the weak symbol is present
1359 if (&qt_left_hand_scrollbars ) 1372 if (&qt_left_hand_scrollbars )
1360 qt_left_hand_scrollbars = config.readBoolEntry( "LeftHand", false ); 1373 qt_left_hand_scrollbars = config.readBoolEntry( "LeftHand", false );
1361 1374
1362 // Window Decoration 1375 // Window Decoration
1363 QString dec = config.readEntry( "Decoration", "Flat" ); 1376 QString dec = config.readEntry( "Decoration", "Flat" );
1364 1377
1365 // don't set a custom deco 1378 // don't set a custom deco
1366 if ( nostyle & Opie::Force_Decoration ) 1379 if ( nostyle & Opie::Force_Decoration )
1367 dec = ""; 1380 dec = "";
1368 1381
1369 1382
1370 if ( dec != d->decorationName ) { 1383 if ( dec != d->decorationName ) {
1371 qwsSetDecoration( new QPEDecoration( dec ) ); 1384 qwsSetDecoration( new QPEDecoration( dec ) );
1372 d->decorationName = dec; 1385 d->decorationName = dec;
1373 } 1386 }
1374 1387
1375 // Font 1388 // Font
1376 QString ff = config.readEntry( "FontFamily", font().family() ); 1389 QString ff = config.readEntry( "FontFamily", font().family() );
1377 int fs = config.readNumEntry( "FontSize", font().pointSize() ); 1390 int fs = config.readNumEntry( "FontSize", font().pointSize() );
1378 1391
1379 // don't set a custom font 1392 // don't set a custom font
1380 if ( nostyle & Opie::Force_Font ) { 1393 if ( nostyle & Opie::Force_Font ) {
1381 ff = "Vera"; 1394 ff = "Vera";
1382 fs = 10; 1395 fs = 10;
1383 } 1396 }
1384 1397
1385 setFont ( QFont ( ff, fs ), true ); 1398 setFont ( QFont ( ff, fs ), true );
1386 1399
1387#if !defined(OPIE_NO_OVERRIDE_QT) 1400#if !defined(OPIE_NO_OVERRIDE_QT)
1388 // revert to global blocking policy ... 1401 // revert to global blocking policy ...
1389 Opie::force_appearance = config. readBoolEntry ( "ForceStyle", false ) ? Opie::Force_All : Opie::Force_None; 1402 Opie::force_appearance = config. readBoolEntry ( "ForceStyle", false ) ? Opie::Force_All : Opie::Force_None;
1390 Opie::force_appearance &= ~nostyle; 1403 Opie::force_appearance &= ~nostyle;
1391#endif 1404#endif
1392#endif 1405#endif
1393} 1406}
1394 1407
1395void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data ) 1408void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data )
1396{ 1409{
1397#ifdef Q_WS_QWS 1410#ifdef Q_WS_QWS
1398 QDataStream stream( data, IO_ReadOnly ); 1411 QDataStream stream( data, IO_ReadOnly );
1399 if ( msg == "applyStyle()" ) { 1412 if ( msg == "applyStyle()" ) {
1400 applyStyle(); 1413 applyStyle();
1401 } 1414 }
1402 else if ( msg == "toggleApplicationMenu()" ) { 1415 else if ( msg == "toggleApplicationMenu()" ) {
1403 QWidget *active = activeWindow ( ); 1416 QWidget *active = activeWindow ( );
1404 1417
1405 if ( active ) { 1418 if ( active ) {
1406 QPEMenuToolFocusManager *man = QPEMenuToolFocusManager::manager ( ); 1419 QPEMenuToolFocusManager *man = QPEMenuToolFocusManager::manager ( );
1407 bool oldactive = man-> isActive ( ); 1420 bool oldactive = man-> isActive ( );
1408 1421
1409 man-> setActive( !man-> isActive() ); 1422 man-> setActive( !man-> isActive() );
1410 1423
1411 if ( !oldactive && !man-> isActive ( )) { // no menubar to toggle -> try O-Menu 1424 if ( !oldactive && !man-> isActive ( )) { // no menubar to toggle -> try O-Menu
1412 QCopEnvelope e ( "QPE/TaskBar", "toggleStartMenu()" ); 1425 QCopEnvelope e ( "QPE/TaskBar", "toggleStartMenu()" );
1413 } 1426 }
1414 } 1427 }
1415 } 1428 }
1416 else if ( msg == "setDefaultRotation(int)" ) { 1429 else if ( msg == "setDefaultRotation(int)" ) {
1417 if ( type() == GuiServer ) { 1430 if ( type() == GuiServer ) {
1418 int r; 1431 int r;
1419 stream >> r; 1432 stream >> r;
1420 setDefaultRotation( r ); 1433 setDefaultRotation( r );
1421 } 1434 }
1422 } 1435 }
1423 else if ( msg == "setCurrentMode(int,int,int)" ) { // Added: 2003-06-11 by Tim Ansell <mithro@mithis.net> 1436 else if ( msg == "setCurrentMode(int,int,int)" ) { // Added: 2003-06-11 by Tim Ansell <mithro@mithis.net>
1424 if ( type() == GuiServer ) { 1437 if ( type() == GuiServer ) {
1425 int x, y, depth; 1438 int x, y, depth;
1426 stream >> x; 1439 stream >> x;
1427 stream >> y; 1440 stream >> y;
1428 stream >> depth; 1441 stream >> depth;
1429 setCurrentMode( x, y, depth ); 1442 setCurrentMode( x, y, depth );
1430 } 1443 }
1431 } 1444 }
1432 else if ( msg == "reset()" ) { 1445 else if ( msg == "reset()" ) {
1433 if ( type() != GuiServer ) 1446 if ( type() != GuiServer )
1434 reset(); 1447 reset();
1435 } 1448 }
1436 else if ( msg == "setCurrentRotation(int)" ) { 1449 else if ( msg == "setCurrentRotation(int)" ) {
1437 int r; 1450 int r;
1438 stream >> r; 1451 stream >> r;
1439 setCurrentRotation( r ); 1452 setCurrentRotation( r );
1440 } 1453 }
1441 else if ( msg == "shutdown()" ) { 1454 else if ( msg == "shutdown()" ) {
1442 if ( type() == GuiServer ) 1455 if ( type() == GuiServer )
1443 shutdown(); 1456 shutdown();
1444 } 1457 }
1445 else if ( msg == "quit()" ) { 1458 else if ( msg == "quit()" ) {
1446 if ( type() != GuiServer ) 1459 if ( type() != GuiServer )
1447 tryQuit(); 1460 tryQuit();
1448 } 1461 }
1449 else if ( msg == "forceQuit()" ) { 1462 else if ( msg == "forceQuit()" ) {
1450 if ( type() != GuiServer ) 1463 if ( type() != GuiServer )
@@ -1582,513 +1595,513 @@ bool QPEApplication::raiseAppropriateWindow()
1582 1595
1583 // 1. Raise the main widget 1596 // 1. Raise the main widget
1584 QWidget *top = d->qpe_main_widget; 1597 QWidget *top = d->qpe_main_widget;
1585 if ( !top ) top = mainWidget(); 1598 if ( !top ) top = mainWidget();
1586 1599
1587 if ( top && d->keep_running ) { 1600 if ( top && d->keep_running ) {
1588 if ( top->isVisible() ) 1601 if ( top->isVisible() )
1589 r = TRUE; 1602 r = TRUE;
1590 else if (d->preloaded) { 1603 else if (d->preloaded) {
1591 // We are preloaded and not visible.. pretend we just started.. 1604 // We are preloaded and not visible.. pretend we just started..
1592#ifndef QT_NO_COP 1605#ifndef QT_NO_COP
1593 QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); 1606 QCopEnvelope e("QPE/System", "fastAppShowing(QString)");
1594 e << d->appName; 1607 e << d->appName;
1595#endif 1608#endif
1596 } 1609 }
1597 1610
1598 d->show_mx(top,d->nomaximize, d->appName); 1611 d->show_mx(top,d->nomaximize, d->appName);
1599 top->raise(); 1612 top->raise();
1600 } 1613 }
1601 1614
1602 QWidget *topm = activeModalWidget(); 1615 QWidget *topm = activeModalWidget();
1603 1616
1604 // 2. Raise any parentless widgets (except top and topm, as they 1617 // 2. Raise any parentless widgets (except top and topm, as they
1605 // are raised before and after this loop). Order from most 1618 // are raised before and after this loop). Order from most
1606 // recently raised as deepest to least recently as top, so 1619 // recently raised as deepest to least recently as top, so
1607 // that repeated calls cycle through widgets. 1620 // that repeated calls cycle through widgets.
1608 QWidgetList *list = topLevelWidgets(); 1621 QWidgetList *list = topLevelWidgets();
1609 if ( list ) { 1622 if ( list ) {
1610 bool foundlast = FALSE; 1623 bool foundlast = FALSE;
1611 QWidget* topsub = 0; 1624 QWidget* topsub = 0;
1612 if ( d->lastraised ) { 1625 if ( d->lastraised ) {
1613 for (QWidget* w = list->first(); w; w = list->next()) { 1626 for (QWidget* w = list->first(); w; w = list->next()) {
1614 if ( !w->parentWidget() && w != topm && w->isVisible() && !w->isDesktop() ) { 1627 if ( !w->parentWidget() && w != topm && w->isVisible() && !w->isDesktop() ) {
1615 if ( w == d->lastraised ) 1628 if ( w == d->lastraised )
1616 foundlast = TRUE; 1629 foundlast = TRUE;
1617 if ( foundlast ) { 1630 if ( foundlast ) {
1618 w->raise(); 1631 w->raise();
1619 topsub = w; 1632 topsub = w;
1620 } 1633 }
1621 } 1634 }
1622 } 1635 }
1623 } 1636 }
1624 for (QWidget* w = list->first(); w; w = list->next()) { 1637 for (QWidget* w = list->first(); w; w = list->next()) {
1625 if ( !w->parentWidget() && w != topm && w->isVisible() && !w->isDesktop() ) { 1638 if ( !w->parentWidget() && w != topm && w->isVisible() && !w->isDesktop() ) {
1626 if ( w == d->lastraised ) 1639 if ( w == d->lastraised )
1627 break; 1640 break;
1628 w->raise(); 1641 w->raise();
1629 topsub = w; 1642 topsub = w;
1630 } 1643 }
1631 } 1644 }
1632 d->lastraised = topsub; 1645 d->lastraised = topsub;
1633 delete list; 1646 delete list;
1634 } 1647 }
1635 1648
1636 // 3. Raise the active modal widget. 1649 // 3. Raise the active modal widget.
1637 if ( topm ) { 1650 if ( topm ) {
1638 topm->show(); 1651 topm->show();
1639 topm->raise(); 1652 topm->raise();
1640 // If we haven't already handled the fastAppShowing message 1653 // If we haven't already handled the fastAppShowing message
1641 if (!top && d->preloaded) { 1654 if (!top && d->preloaded) {
1642#ifndef QT_NO_COP 1655#ifndef QT_NO_COP
1643 QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); 1656 QCopEnvelope e("QPE/System", "fastAppShowing(QString)");
1644 e << d->appName; 1657 e << d->appName;
1645#endif 1658#endif
1646 } 1659 }
1647 r = FALSE; 1660 r = FALSE;
1648 } 1661 }
1649 1662
1650 return r; 1663 return r;
1651} 1664}
1652 1665
1653 1666
1654void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data) 1667void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data)
1655{ 1668{
1656#ifdef Q_WS_QWS 1669#ifdef Q_WS_QWS
1657 1670
1658 if ( msg == "quit()" ) { 1671 if ( msg == "quit()" ) {
1659 tryQuit(); 1672 tryQuit();
1660 } 1673 }
1661 else if ( msg == "quitIfInvisible()" ) { 1674 else if ( msg == "quitIfInvisible()" ) {
1662 if ( d->qpe_main_widget && !d->qpe_main_widget->isVisible() ) 1675 if ( d->qpe_main_widget && !d->qpe_main_widget->isVisible() )
1663 quit(); 1676 quit();
1664 } 1677 }
1665 else if ( msg == "close()" ) { 1678 else if ( msg == "close()" ) {
1666 hideOrQuit(); 1679 hideOrQuit();
1667 } 1680 }
1668 else if ( msg == "disablePreload()" ) { 1681 else if ( msg == "disablePreload()" ) {
1669 d->preloaded = FALSE; 1682 d->preloaded = FALSE;
1670 d->keep_running = TRUE; 1683 d->keep_running = TRUE;
1671 /* so that quit will quit */ 1684 /* so that quit will quit */
1672 } 1685 }
1673 else if ( msg == "enablePreload()" ) { 1686 else if ( msg == "enablePreload()" ) {
1674 if (d->qpe_main_widget) 1687 if (d->qpe_main_widget)
1675 d->preloaded = TRUE; 1688 d->preloaded = TRUE;
1676 d->keep_running = TRUE; 1689 d->keep_running = TRUE;
1677 /* so next quit won't quit */ 1690 /* so next quit won't quit */
1678 } 1691 }
1679 else if ( msg == "raise()" ) { 1692 else if ( msg == "raise()" ) {
1680 d->keep_running = TRUE; 1693 d->keep_running = TRUE;
1681 d->notbusysent = FALSE; 1694 d->notbusysent = FALSE;
1682 raiseAppropriateWindow(); 1695 raiseAppropriateWindow();
1683 // Tell the system we're still chugging along... 1696 // Tell the system we're still chugging along...
1684 QCopEnvelope e("QPE/System", "appRaised(QString)"); 1697 QCopEnvelope e("QPE/System", "appRaised(QString)");
1685 e << d->appName; 1698 e << d->appName;
1686 } 1699 }
1687 else if ( msg == "flush()" ) { 1700 else if ( msg == "flush()" ) {
1688 emit flush(); 1701 emit flush();
1689 // we need to tell the desktop 1702 // we need to tell the desktop
1690 QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" ); 1703 QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" );
1691 e << d->appName; 1704 e << d->appName;
1692 } 1705 }
1693 else if ( msg == "reload()" ) { 1706 else if ( msg == "reload()" ) {
1694 emit reload(); 1707 emit reload();
1695 } 1708 }
1696 else if ( msg == "setDocument(QString)" ) { 1709 else if ( msg == "setDocument(QString)" ) {
1697 d->keep_running = TRUE; 1710 d->keep_running = TRUE;
1698 QDataStream stream( data, IO_ReadOnly ); 1711 QDataStream stream( data, IO_ReadOnly );
1699 QString doc; 1712 QString doc;
1700 stream >> doc; 1713 stream >> doc;
1701 QWidget *mw = mainWidget(); 1714 QWidget *mw = mainWidget();
1702 if ( !mw ) 1715 if ( !mw )
1703 mw = d->qpe_main_widget; 1716 mw = d->qpe_main_widget;
1704 if ( mw ) 1717 if ( mw )
1705 Global::setDocument( mw, doc ); 1718 Global::setDocument( mw, doc );
1706 1719
1707 } else if ( msg == "QPEProcessQCop()" ) { 1720 } else if ( msg == "QPEProcessQCop()" ) {
1708 processQCopFile(); 1721 processQCopFile();
1709 d->sendQCopQ(); 1722 d->sendQCopQ();
1710 }else 1723 }else
1711 { 1724 {
1712 bool p = d->keep_running; 1725 bool p = d->keep_running;
1713 d->keep_running = FALSE; 1726 d->keep_running = FALSE;
1714 emit appMessage( msg, data); 1727 emit appMessage( msg, data);
1715 if ( d->keep_running ) { 1728 if ( d->keep_running ) {
1716 d->notbusysent = FALSE; 1729 d->notbusysent = FALSE;
1717 raiseAppropriateWindow(); 1730 raiseAppropriateWindow();
1718 if ( !p ) { 1731 if ( !p ) {
1719 // Tell the system we're still chugging along... 1732 // Tell the system we're still chugging along...
1720#ifndef QT_NO_COP 1733#ifndef QT_NO_COP
1721 QCopEnvelope e("QPE/System", "appRaised(QString)"); 1734 QCopEnvelope e("QPE/System", "appRaised(QString)");
1722 e << d->appName; 1735 e << d->appName;
1723#endif 1736#endif
1724 } 1737 }
1725 } 1738 }
1726 if ( p ) 1739 if ( p )
1727 d->keep_running = p; 1740 d->keep_running = p;
1728 } 1741 }
1729#endif 1742#endif
1730} 1743}
1731 1744
1732 1745
1733/*! 1746/*!
1734 Sets widget \a mw as the mainWidget() and shows it. For small windows, 1747 Sets widget \a mw as the mainWidget() and shows it. For small windows,
1735 consider passing TRUE for \a nomaximize rather than the default FALSE. 1748 consider passing TRUE for \a nomaximize rather than the default FALSE.
1736 1749
1737 \sa showMainDocumentWidget() 1750 \sa showMainDocumentWidget()
1738*/ 1751*/
1739void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize ) 1752void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize )
1740{ 1753{
1741// setMainWidget(mw); this breaks FastLoading because lastWindowClose() would quit 1754// setMainWidget(mw); this breaks FastLoading because lastWindowClose() would quit
1742 d->show(mw, nomaximize ); 1755 d->show(mw, nomaximize );
1743} 1756}
1744 1757
1745/*! 1758/*!
1746 Sets widget \a mw as the mainWidget() and shows it. For small windows, 1759 Sets widget \a mw as the mainWidget() and shows it. For small windows,
1747 consider passing TRUE for \a nomaximize rather than the default FALSE. 1760 consider passing TRUE for \a nomaximize rather than the default FALSE.
1748 1761
1749 This calls designates the application as 1762 This calls designates the application as
1750 a \link docwidget.html document-oriented\endlink application. 1763 a \link docwidget.html document-oriented\endlink application.
1751 1764
1752 The \a mw widget \e must have this slot: setDocument(const QString&). 1765 The \a mw widget \e must have this slot: setDocument(const QString&).
1753 1766
1754 \sa showMainWidget() 1767 \sa showMainWidget()
1755*/ 1768*/
1756void QPEApplication::showMainDocumentWidget( QWidget* mw, bool nomaximize ) 1769void QPEApplication::showMainDocumentWidget( QWidget* mw, bool nomaximize )
1757{ 1770{
1758 if ( mw && argc() == 2 ) 1771 if ( mw && argc() == 2 )
1759 Global::setDocument( mw, QString::fromUtf8(argv()[1]) ); 1772 Global::setDocument( mw, QString::fromUtf8(argv()[1]) );
1760 1773
1761 1774
1762// setMainWidget(mw); see above 1775// setMainWidget(mw); see above
1763 d->show(mw, nomaximize ); 1776 d->show(mw, nomaximize );
1764} 1777}
1765 1778
1766 1779
1767/*! 1780/*!
1768 If an application is started via a \link qcop.html QCop\endlink 1781 If an application is started via a \link qcop.html QCop\endlink
1769 message, the application will process the \link qcop.html 1782 message, the application will process the \link qcop.html
1770 QCop\endlink message and then quit. If the application calls this 1783 QCop\endlink message and then quit. If the application calls this
1771 function while processing a \link qcop.html QCop\endlink message, 1784 function while processing a \link qcop.html QCop\endlink message,
1772 after processing its outstanding \link qcop.html QCop\endlink 1785 after processing its outstanding \link qcop.html QCop\endlink
1773 messages the application will start 'properly' and show itself. 1786 messages the application will start 'properly' and show itself.
1774 1787
1775 \sa keepRunning() 1788 \sa keepRunning()
1776*/ 1789*/
1777void QPEApplication::setKeepRunning() 1790void QPEApplication::setKeepRunning()
1778{ 1791{
1779 if ( qApp && qApp->inherits( "QPEApplication" ) ) { 1792 if ( qApp && qApp->inherits( "QPEApplication" ) ) {
1780 QPEApplication * qpeApp = ( QPEApplication* ) qApp; 1793 QPEApplication * qpeApp = ( QPEApplication* ) qApp;
1781 qpeApp->d->keep_running = TRUE; 1794 qpeApp->d->keep_running = TRUE;
1782 } 1795 }
1783} 1796}
1784 1797
1785/*! 1798/*!
1786 Returns TRUE if the application will quit after processing the 1799 Returns TRUE if the application will quit after processing the
1787 current list of qcop messages; otherwise returns FALSE. 1800 current list of qcop messages; otherwise returns FALSE.
1788 1801
1789 \sa setKeepRunning() 1802 \sa setKeepRunning()
1790*/ 1803*/
1791bool QPEApplication::keepRunning() const 1804bool QPEApplication::keepRunning() const
1792{ 1805{
1793 return d->keep_running; 1806 return d->keep_running;
1794} 1807}
1795 1808
1796/*! 1809/*!
1797 \internal 1810 \internal
1798*/ 1811*/
1799void QPEApplication::internalSetStyle( const QString &style ) 1812void QPEApplication::internalSetStyle( const QString &style )
1800{ 1813{
1801#if QT_VERSION >= 300 1814#if QT_VERSION >= 300
1802 if ( style == "QPE" ) { 1815 if ( style == "QPE" ) {
1803 setStyle( new QPEStyle ); 1816 setStyle( new QPEStyle );
1804 } 1817 }
1805 else { 1818 else {
1806 QStyle *s = QStyleFactory::create( style ); 1819 QStyle *s = QStyleFactory::create( style );
1807 if ( s ) 1820 if ( s )
1808 setStyle( s ); 1821 setStyle( s );
1809 } 1822 }
1810#else 1823#else
1811 if ( style == "Windows" ) { 1824 if ( style == "Windows" ) {
1812 setStyle( new QWindowsStyle ); 1825 setStyle( new QWindowsStyle );
1813 } 1826 }
1814 else if ( style == "QPE" ) { 1827 else if ( style == "QPE" ) {
1815 setStyle( new QPEStyle ); 1828 setStyle( new QPEStyle );
1816 } 1829 }
1817 else if ( style == "Light" ) { 1830 else if ( style == "Light" ) {
1818 setStyle( new LightStyle ); 1831 setStyle( new LightStyle );
1819 } 1832 }
1820#ifndef QT_NO_STYLE_PLATINUM 1833#ifndef QT_NO_STYLE_PLATINUM
1821 else if ( style == "Platinum" ) { 1834 else if ( style == "Platinum" ) {
1822 setStyle( new QPlatinumStyle ); 1835 setStyle( new QPlatinumStyle );
1823 } 1836 }
1824#endif 1837#endif
1825#ifndef QT_NO_STYLE_MOTIF 1838#ifndef QT_NO_STYLE_MOTIF
1826 else if ( style == "Motif" ) { 1839 else if ( style == "Motif" ) {
1827 setStyle( new QMotifStyle ); 1840 setStyle( new QMotifStyle );
1828 } 1841 }
1829#endif 1842#endif
1830#ifndef QT_NO_STYLE_MOTIFPLUS 1843#ifndef QT_NO_STYLE_MOTIFPLUS
1831 else if ( style == "MotifPlus" ) { 1844 else if ( style == "MotifPlus" ) {
1832 setStyle( new QMotifPlusStyle ); 1845 setStyle( new QMotifPlusStyle );
1833 } 1846 }
1834#endif 1847#endif
1835 1848
1836 else { 1849 else {
1837 QStyle *sty = 0; 1850 QStyle *sty = 0;
1838 QString path = QPEApplication::qpeDir ( ) + "/plugins/styles/"; 1851 QString path = QPEApplication::qpeDir ( ) + "plugins/styles/";
1839 1852
1840#ifdef Q_OS_MACX 1853#ifdef Q_OS_MACX
1841 if ( style. find ( ".dylib" ) > 0 ) 1854 if ( style. find ( ".dylib" ) > 0 )
1842 path += style; 1855 path += style;
1843 else 1856 else
1844 path = path + "lib" + style. lower ( ) + ".dylib"; // compatibility 1857 path = path + "lib" + style. lower ( ) + ".dylib"; // compatibility
1845#else 1858#else
1846 if ( style. find ( ".so" ) > 0 ) 1859 if ( style. find ( ".so" ) > 0 )
1847 path += style; 1860 path += style;
1848 else 1861 else
1849 path = path + "lib" + style. lower ( ) + ".so"; // compatibility 1862 path = path + "lib" + style. lower ( ) + ".so"; // compatibility
1850#endif 1863#endif
1851 static QLibrary *lastlib = 0; 1864 static QLibrary *lastlib = 0;
1852 static StyleInterface *lastiface = 0; 1865 static StyleInterface *lastiface = 0;
1853 1866
1854 QLibrary *lib = new QLibrary ( path ); 1867 QLibrary *lib = new QLibrary ( path );
1855 StyleInterface *iface = 0; 1868 StyleInterface *iface = 0;
1856 1869
1857 if (( lib-> queryInterface ( IID_Style, ( QUnknownInterface ** ) &iface ) == QS_OK ) && iface ) 1870 if (( lib-> queryInterface ( IID_Style, ( QUnknownInterface ** ) &iface ) == QS_OK ) && iface )
1858 sty = iface-> style ( ); 1871 sty = iface-> style ( );
1859 1872
1860 if ( sty ) { 1873 if ( sty ) {
1861 setStyle ( sty ); 1874 setStyle ( sty );
1862 1875
1863 if ( lastiface ) 1876 if ( lastiface )
1864 lastiface-> release ( ); 1877 lastiface-> release ( );
1865 lastiface = iface; 1878 lastiface = iface;
1866 1879
1867 if ( lastlib ) { 1880 if ( lastlib ) {
1868 lastlib-> unload ( ); 1881 lastlib-> unload ( );
1869 delete lastlib; 1882 delete lastlib;
1870 } 1883 }
1871 lastlib = lib; 1884 lastlib = lib;
1872 } 1885 }
1873 else { 1886 else {
1874 if ( iface ) 1887 if ( iface )
1875 iface-> release ( ); 1888 iface-> release ( );
1876 delete lib; 1889 delete lib;
1877 1890
1878 setStyle ( new LightStyle ( )); 1891 setStyle ( new LightStyle ( ));
1879 } 1892 }
1880 } 1893 }
1881#endif 1894#endif
1882} 1895}
1883 1896
1884/*! 1897/*!
1885 \internal 1898 \internal
1886*/ 1899*/
1887void QPEApplication::prepareForTermination( bool willrestart ) 1900void QPEApplication::prepareForTermination( bool willrestart )
1888{ 1901{
1889 if ( willrestart ) { 1902 if ( willrestart ) {
1890 QLabel *lblWait = new QLabel( tr( "Please wait..." ), 0, "wait hack", QWidget::WStyle_Customize | 1903 QLabel *lblWait = new QLabel( tr( "Please wait..." ), 0, "wait hack", QWidget::WStyle_Customize |
1891 QWidget::WStyle_NoBorder | QWidget::WStyle_Tool ); 1904 QWidget::WStyle_NoBorder | QWidget::WStyle_Tool );
1892 lblWait->setAlignment( QWidget::AlignCenter ); 1905 lblWait->setAlignment( QWidget::AlignCenter );
1893 lblWait->show(); 1906 lblWait->show();
1894 lblWait->showMaximized(); 1907 lblWait->showMaximized();
1895 } 1908 }
1896 { QCopEnvelope envelope( "QPE/System", "forceQuit()" ); 1909 { QCopEnvelope envelope( "QPE/System", "forceQuit()" );
1897 } 1910 }
1898 processEvents(); // ensure the message goes out. 1911 processEvents(); // ensure the message goes out.
1899} 1912}
1900 1913
1901/*! 1914/*!
1902 \internal 1915 \internal
1903*/ 1916*/
1904void QPEApplication::shutdown() 1917void QPEApplication::shutdown()
1905{ 1918{
1906 // Implement in server's QPEApplication subclass 1919 // Implement in server's QPEApplication subclass
1907} 1920}
1908 1921
1909/*! 1922/*!
1910 \internal 1923 \internal
1911*/ 1924*/
1912void QPEApplication::restart() 1925void QPEApplication::restart()
1913{ 1926{
1914 // Implement in server's QPEApplication subclass 1927 // Implement in server's QPEApplication subclass
1915} 1928}
1916 1929
1917static QPtrDict<void>* stylusDict = 0; 1930static QPtrDict<void>* stylusDict = 0;
1918static void createDict() 1931static void createDict()
1919{ 1932{
1920 if ( !stylusDict ) 1933 if ( !stylusDict )
1921 stylusDict = new QPtrDict<void>; 1934 stylusDict = new QPtrDict<void>;
1922} 1935}
1923 1936
1924/*! 1937/*!
1925 Returns the current StylusMode for widget \a w. 1938 Returns the current StylusMode for widget \a w.
1926 1939
1927 \sa setStylusOperation() StylusMode 1940 \sa setStylusOperation() StylusMode
1928*/ 1941*/
1929QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w ) 1942QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w )
1930{ 1943{
1931 if ( stylusDict ) 1944 if ( stylusDict )
1932 return ( StylusMode ) ( int ) stylusDict->find( w ); 1945 return ( StylusMode ) ( int ) stylusDict->find( w );
1933 return LeftOnly; 1946 return LeftOnly;
1934} 1947}
1935 1948
1936/*! 1949/*!
1937 \enum QPEApplication::StylusMode 1950 \enum QPEApplication::StylusMode
1938 1951
1939 \value LeftOnly the stylus only generates LeftButton 1952 \value LeftOnly the stylus only generates LeftButton
1940 events (the default). 1953 events (the default).
1941 \value RightOnHold the stylus generates RightButton events 1954 \value RightOnHold the stylus generates RightButton events
1942 if the user uses the press-and-hold gesture. 1955 if the user uses the press-and-hold gesture.
1943 1956
1944 \sa setStylusOperation() stylusOperation() 1957 \sa setStylusOperation() stylusOperation()
1945*/ 1958*/
1946 1959
1947/*! 1960/*!
1948 Causes widget \a w to receive mouse events according to the stylus 1961 Causes widget \a w to receive mouse events according to the stylus
1949 \a mode. 1962 \a mode.
1950 1963
1951 \sa stylusOperation() StylusMode 1964 \sa stylusOperation() StylusMode
1952*/ 1965*/
1953void QPEApplication::setStylusOperation( QWidget * w, StylusMode mode ) 1966void QPEApplication::setStylusOperation( QWidget * w, StylusMode mode )
1954{ 1967{
1955 createDict(); 1968 createDict();
1956 if ( mode == LeftOnly ) { 1969 if ( mode == LeftOnly ) {
1957 stylusDict->remove 1970 stylusDict->remove
1958 ( w ); 1971 ( w );
1959 w->removeEventFilter( qApp ); 1972 w->removeEventFilter( qApp );
1960 } 1973 }
1961 else { 1974 else {
1962 stylusDict->insert( w, ( void* ) mode ); 1975 stylusDict->insert( w, ( void* ) mode );
1963 connect( w, SIGNAL( destroyed() ), qApp, SLOT( removeSenderFromStylusDict() ) ); 1976 connect( w, SIGNAL( destroyed() ), qApp, SLOT( removeSenderFromStylusDict() ) );
1964 w->installEventFilter( qApp ); 1977 w->installEventFilter( qApp );
1965 } 1978 }
1966} 1979}
1967 1980
1968 1981
1969/*! 1982/*!
1970 \reimp 1983 \reimp
1971*/ 1984*/
1972bool QPEApplication::eventFilter( QObject *o, QEvent *e ) 1985bool QPEApplication::eventFilter( QObject *o, QEvent *e )
1973{ 1986{
1974 if ( !o->isWidgetType() ) 1987 if ( !o->isWidgetType() )
1975 return FALSE; 1988 return FALSE;
1976 1989
1977 if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) { 1990 if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) {
1978 QMouseEvent * me = ( QMouseEvent* ) e; 1991 QMouseEvent * me = ( QMouseEvent* ) e;
1979 StylusMode mode = (StylusMode)(int)stylusDict->find(o); 1992 StylusMode mode = (StylusMode)(int)stylusDict->find(o);
1980 switch (mode) { 1993 switch (mode) {
1981 case RightOnHold: 1994 case RightOnHold:
1982 switch ( me->type() ) { 1995 switch ( me->type() ) {
1983 case QEvent::MouseButtonPress: 1996 case QEvent::MouseButtonPress:
1984 if ( me->button() == LeftButton ) { 1997 if ( me->button() == LeftButton ) {
1985 static long Pref = 500; // #### pref. 1998 static long Pref = 500; // #### pref.
1986 d->presswidget = (QWidget*)o; 1999 d->presswidget = (QWidget*)o;
1987 d->presspos = me->pos(); 2000 d->presspos = me->pos();
1988 d->rightpressed = FALSE; 2001 d->rightpressed = FALSE;
1989#ifdef OPIE_WITHROHFEEDBACK 2002#ifdef OPIE_WITHROHFEEDBACK
1990 if( ! d->RoH ) 2003 if( ! d->RoH )
1991 d->RoH = new Opie::Internal::RoHFeedback; 2004 d->RoH = new Opie::Internal::RoHFeedback;
1992 2005
1993 d->RoH->init( me->globalPos(), d->presswidget ); 2006 d->RoH->init( me->globalPos(), d->presswidget );
1994 Pref = d->RoH->delay(); 2007 Pref = d->RoH->delay();
1995 2008
1996#endif 2009#endif
1997 if (!d->presstimer ) 2010 if (!d->presstimer )
1998 d->presstimer = startTimer( Pref ); // #### pref. 2011 d->presstimer = startTimer( Pref ); // #### pref.
1999 2012
2000 } 2013 }
2001 break; 2014 break;
2002 case QEvent::MouseMove: 2015 case QEvent::MouseMove:
2003 if (d->presstimer && (me->pos() - d->presspos).manhattanLength() > 8) { 2016 if (d->presstimer && (me->pos() - d->presspos).manhattanLength() > 8) {
2004 killTimer(d->presstimer); 2017 killTimer(d->presstimer);
2005#ifdef OPIE_WITHROHFEEDBACK 2018#ifdef OPIE_WITHROHFEEDBACK
2006 d->RoH->stop(); 2019 d->RoH->stop();
2007#endif 2020#endif
2008 d->presstimer = 0; 2021 d->presstimer = 0;
2009 } 2022 }
2010 break; 2023 break;
2011 case QEvent::MouseButtonRelease: 2024 case QEvent::MouseButtonRelease:
2012 if ( me->button() == LeftButton ) { 2025 if ( me->button() == LeftButton ) {
2013 if ( d->presstimer ) { 2026 if ( d->presstimer ) {
2014 killTimer(d->presstimer); 2027 killTimer(d->presstimer);
2015#ifdef OPIE_WITHROHFEEDBACK 2028#ifdef OPIE_WITHROHFEEDBACK
2016 d->RoH->stop( ); 2029 d->RoH->stop( );
2017#endif 2030#endif
2018 d->presstimer = 0; 2031 d->presstimer = 0;
2019 } 2032 }
2020 if ( d->rightpressed && d->presswidget ) { 2033 if ( d->rightpressed && d->presswidget ) {
2021 printf( "Send ButtonRelease\n" ); 2034 printf( "Send ButtonRelease\n" );
2022 // Right released 2035 // Right released
2023 postEvent( d->presswidget, 2036 postEvent( d->presswidget,
2024 new QMouseEvent( QEvent::MouseButtonRelease, me->pos(), 2037 new QMouseEvent( QEvent::MouseButtonRelease, me->pos(),
2025 RightButton, LeftButton + RightButton ) ); 2038 RightButton, LeftButton + RightButton ) );
2026 // Left released, off-widget 2039 // Left released, off-widget
2027 postEvent( d->presswidget, 2040 postEvent( d->presswidget,
2028 new QMouseEvent( QEvent::MouseMove, QPoint( -1, -1), 2041 new QMouseEvent( QEvent::MouseMove, QPoint( -1, -1),
2029 LeftButton, LeftButton ) ); 2042 LeftButton, LeftButton ) );
2030 postEvent( d->presswidget, 2043 postEvent( d->presswidget,
2031 new QMouseEvent( QEvent::MouseButtonRelease, QPoint( -1, -1), 2044 new QMouseEvent( QEvent::MouseButtonRelease, QPoint( -1, -1),
2032 LeftButton, LeftButton ) ); 2045 LeftButton, LeftButton ) );
2033 d->rightpressed = FALSE; 2046 d->rightpressed = FALSE;
2034 return TRUE; // don't send the real Left release 2047 return TRUE; // don't send the real Left release
2035 } 2048 }
2036 } 2049 }
2037 break; 2050 break;
2038 default: 2051 default:
2039 break; 2052 break;
2040 } 2053 }
2041 break; 2054 break;
2042 default: 2055 default:
2043 ; 2056 ;
2044 } 2057 }
2045 } 2058 }
2046 else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { 2059 else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) {
2047 QKeyEvent *ke = (QKeyEvent *)e; 2060 QKeyEvent *ke = (QKeyEvent *)e;
2048 if ( ke->key() == Key_Enter ) { 2061 if ( ke->key() == Key_Enter ) {
2049 if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) { 2062 if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) {
2050 postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ', 2063 postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ',
2051 ke->state(), " ", ke->isAutoRepeat(), ke->count() ) ); 2064 ke->state(), " ", ke->isAutoRepeat(), ke->count() ) );
2052 return TRUE; 2065 return TRUE;
2053 } 2066 }
2054 } 2067 }
2055 } 2068 }
2056 return FALSE; 2069 return FALSE;
2057} 2070}
2058 2071
2059/*! 2072/*!
2060 \reimp 2073 \reimp
2061*/ 2074*/
2062void QPEApplication::timerEvent( QTimerEvent *e ) 2075void QPEApplication::timerEvent( QTimerEvent *e )
2063{ 2076{
2064 if ( e->timerId() == d->presstimer && d->presswidget ) { 2077 if ( e->timerId() == d->presstimer && d->presswidget ) {
2065 2078
2066 // Right pressed 2079 // Right pressed
2067 postEvent( d->presswidget, 2080 postEvent( d->presswidget,
2068 new QMouseEvent( QEvent::MouseButtonPress, d->presspos, 2081 new QMouseEvent( QEvent::MouseButtonPress, d->presspos,
2069 RightButton, LeftButton ) ); 2082 RightButton, LeftButton ) );
2070 killTimer( d->presstimer ); 2083 killTimer( d->presstimer );
2071 d->presstimer = 0; 2084 d->presstimer = 0;
2072 d->rightpressed = TRUE; 2085 d->rightpressed = TRUE;
2073#ifdef OPIE_WITHROHFEEDBACK 2086#ifdef OPIE_WITHROHFEEDBACK
2074 d->RoH->stop(); 2087 d->RoH->stop();
2075#endif 2088#endif
2076 } 2089 }
2077} 2090}
2078 2091
2079void QPEApplication::removeSenderFromStylusDict() 2092void QPEApplication::removeSenderFromStylusDict()
2080{ 2093{
2081 stylusDict->remove 2094 stylusDict->remove
2082 ( ( void* ) sender() ); 2095 ( ( void* ) sender() );
2083 if ( d->presswidget == sender() ) 2096 if ( d->presswidget == sender() )
2084 d->presswidget = 0; 2097 d->presswidget = 0;
2085} 2098}
2086 2099
2087/*! 2100/*!
2088 \internal 2101 \internal
2089*/ 2102*/
2090bool QPEApplication::keyboardGrabbed() const 2103bool QPEApplication::keyboardGrabbed() const
2091{ 2104{
2092 return d->kbgrabbed; 2105 return d->kbgrabbed;
2093} 2106}
2094 2107