-rw-r--r-- | library/qpeapplication.cpp | 27 |
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 | |||
@@ -264,286 +264,286 @@ public: | |||
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 | ||
450 | class ResourceMimeFactory : public QMimeSourceFactory | 450 | class ResourceMimeFactory : public QMimeSourceFactory |
451 | { | 451 | { |
452 | public: | 452 | public: |
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 | } |
484 | private: | 484 | private: |
485 | mutable QImageDrag *resImage; | 485 | mutable QImageDrag *resImage; |
486 | }; | 486 | }; |
487 | 487 | ||
488 | static int& hack(int& i) | 488 | static 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 | ||
498 | static int muted = 0; | 498 | static int muted = 0; |
499 | static int micMuted = 0; | 499 | static int micMuted = 0; |
500 | 500 | ||
501 | static void setVolume( int t = 0, int percent = -1 ) | 501 | static 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 | ||
528 | static void setMic( int t = 0, int percent = -1 ) | 528 | static 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 | } |
@@ -1062,261 +1062,274 @@ bool QPEApplication::qwsEventFilter( QWSEvent * e ) | |||
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 | */ |
1168 | QPEApplication::~QPEApplication() | 1168 | QPEApplication::~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 | */ |
1188 | QString QPEApplication::qpeDir() | 1188 | QString 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 | */ |
1201 | QString QPEApplication::documentDir() | 1214 | QString 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 | ||
1210 | static int deforient = -1; | 1223 | static int deforient = -1; |
1211 | 1224 | ||
1212 | /*! | 1225 | /*! |
1213 | \internal | 1226 | \internal |
1214 | */ | 1227 | */ |
1215 | int QPEApplication::defaultRotation() | 1228 | int 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 | */ |
1238 | void QPEApplication::setDefaultRotation( int r ) | 1251 | void 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 |
1261 | extern void qws_clearLoadedFonts(); | 1274 | extern void qws_clearLoadedFonts(); |
1262 | #endif | 1275 | #endif |
1263 | 1276 | ||
1264 | void QPEApplication::setCurrentMode( int x, int y, int depth ) | 1277 | void 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 | ||
1286 | void QPEApplication::reset() { | 1299 | void 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 |
1296 | bool qt_left_hand_scrollbars = false; | 1309 | bool qt_left_hand_scrollbars = false; |
1297 | #else | 1310 | #else |
1298 | extern bool qt_left_hand_scrollbars QPE_WEAK_SYMBOL; | 1311 | extern bool qt_left_hand_scrollbars QPE_WEAK_SYMBOL; |
1299 | #endif | 1312 | #endif |
1300 | 1313 | ||
1301 | /*! | 1314 | /*! |
1302 | \internal | 1315 | \internal |
1303 | */ | 1316 | */ |
1304 | void QPEApplication::applyStyle() | 1317 | void 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 | } |
@@ -1710,257 +1723,257 @@ void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data) | |||
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 | */ |
1739 | void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize ) | 1752 | void 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 | */ |
1756 | void QPEApplication::showMainDocumentWidget( QWidget* mw, bool nomaximize ) | 1769 | void 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 | */ |
1777 | void QPEApplication::setKeepRunning() | 1790 | void 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 | */ |
1791 | bool QPEApplication::keepRunning() const | 1804 | bool 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 | */ |
1799 | void QPEApplication::internalSetStyle( const QString &style ) | 1812 | void 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 | */ |
1887 | void QPEApplication::prepareForTermination( bool willrestart ) | 1900 | void 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 | */ |
1904 | void QPEApplication::shutdown() | 1917 | void 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 | */ |
1912 | void QPEApplication::restart() | 1925 | void QPEApplication::restart() |
1913 | { | 1926 | { |
1914 | // Implement in server's QPEApplication subclass | 1927 | // Implement in server's QPEApplication subclass |
1915 | } | 1928 | } |
1916 | 1929 | ||
1917 | static QPtrDict<void>* stylusDict = 0; | 1930 | static QPtrDict<void>* stylusDict = 0; |
1918 | static void createDict() | 1931 | static 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 | */ |
1929 | QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w ) | 1942 | QPEApplication::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 | */ |
1953 | void QPEApplication::setStylusOperation( QWidget * w, StylusMode mode ) | 1966 | void 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 | } |