author | harlekin <harlekin> | 2002-08-15 18:34:42 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2002-08-15 18:34:42 (UTC) |
commit | 8cd40434c7011022a8e1706698e5c5075681bd1e (patch) (unidiff) | |
tree | 74e8634c40c1b35cdf32620d219d3a98ec3e2ded /library | |
parent | fc0f625393128d47ef4e2baef4dfcdbe48a18ca7 (diff) | |
download | opie-8cd40434c7011022a8e1706698e5c5075681bd1e.zip opie-8cd40434c7011022a8e1706698e5c5075681bd1e.tar.gz opie-8cd40434c7011022a8e1706698e5c5075681bd1e.tar.bz2 |
applied hashs patch
-rw-r--r-- | library/qpeapplication.cpp | 76 |
1 files changed, 41 insertions, 35 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp index 187a7e2..8448352 100644 --- a/library/qpeapplication.cpp +++ b/library/qpeapplication.cpp | |||
@@ -466,100 +466,100 @@ static void setScreenSaverIntervals( int i1, int i2, int i3 ) | |||
466 | //qDebug("screen saver intervals: %d %d %d", i1, i2, i3); | 466 | //qDebug("screen saver intervals: %d %d %d", i1, i2, i3); |
467 | 467 | ||
468 | v[ 0 ] = QMAX( 1000 * i1, 100 ); | 468 | v[ 0 ] = QMAX( 1000 * i1, 100 ); |
469 | v[ 1 ] = QMAX( 1000 * i2, 100 ); | 469 | v[ 1 ] = QMAX( 1000 * i2, 100 ); |
470 | v[ 2 ] = QMAX( 1000 * i3, 100 ); | 470 | v[ 2 ] = QMAX( 1000 * i3, 100 ); |
471 | v[ 3 ] = 0; | 471 | v[ 3 ] = 0; |
472 | dim_on = ( ( i1 != 0 ) ? config.readNumEntry( "Dim", 1 ) : FALSE ); | 472 | dim_on = ( ( i1 != 0 ) ? config.readNumEntry( "Dim", 1 ) : FALSE ); |
473 | lightoff_on = ( ( i2 != 0 ) ? config.readNumEntry( "LightOff", 1 ) : FALSE ); | 473 | lightoff_on = ( ( i2 != 0 ) ? config.readNumEntry( "LightOff", 1 ) : FALSE ); |
474 | if ( !i1 && !i2 && !i3 ) | 474 | if ( !i1 && !i2 && !i3 ) |
475 | QWSServer::setScreenSaverInterval( 0 ); | 475 | QWSServer::setScreenSaverInterval( 0 ); |
476 | else | 476 | else |
477 | QWSServer::setScreenSaverIntervals( v ); | 477 | QWSServer::setScreenSaverIntervals( v ); |
478 | } | 478 | } |
479 | 479 | ||
480 | static void setScreenSaverInterval( int interval ) | 480 | static void setScreenSaverInterval( int interval ) |
481 | { | 481 | { |
482 | setScreenSaverIntervals( -1, -1, interval ); | 482 | setScreenSaverIntervals( -1, -1, interval ); |
483 | } | 483 | } |
484 | 484 | ||
485 | 485 | ||
486 | /*! | 486 | /*! |
487 | \class QPEApplication qpeapplication.h | 487 | \class QPEApplication qpeapplication.h |
488 | \brief The QPEApplication class implements various system services | 488 | \brief The QPEApplication class implements various system services |
489 | that are available to all Qtopia applications. | 489 | that are available to all Qtopia applications. |
490 | 490 | ||
491 | Simply by using QPEApplication instead of QApplication, a plain Qt | 491 | Simply by using QPEApplication instead of QApplication, a plain Qt |
492 | application becomes a Qtopia application. It automatically follows | 492 | application becomes a Qtopia application. It automatically follows |
493 | style changes, quits and raises, and in the | 493 | style changes, quits and raises, and in the |
494 | case of \link docwidget.html document-oriented\endlink applications, | 494 | case of \link docwidget.html document-oriented\endlink applications, |
495 | changes the current displayed document in response to the environment. | 495 | changes the current displayed document in response to the environment. |
496 | */ | 496 | */ |
497 | 497 | ||
498 | /*! | 498 | /*! |
499 | \fn void QPEApplication::clientMoused() | 499 | \fn void QPEApplication::clientMoused() |
500 | 500 | ||
501 | \internal | 501 | \internal |
502 | */ | 502 | */ |
503 | 503 | ||
504 | /*! | 504 | /*! |
505 | \fn void QPEApplication::timeChanged(); | 505 | \fn void QPEApplication::timeChanged(); |
506 | 506 | ||
507 | This signal is emitted when the time jumps forward or backwards | 507 | This signal is emitted when the time jumps forward or backwards |
508 | by more than the normal passage of time. | 508 | by more than the normal passage of time. |
509 | */ | 509 | */ |
510 | 510 | ||
511 | /*! | 511 | /*! |
512 | \fn void QPEApplication::clockChanged( bool ampm ); | 512 | \fn void QPEApplication::clockChanged( bool ampm ); |
513 | 513 | ||
514 | This signal is emitted when the user changes the style | 514 | This signal is emitted when the user changes the style |
515 | of clock. If \a ampm is TRUE, the user wants a 12-hour | 515 | of clock. If \a ampm is TRUE, the user wants a 12-hour |
516 | AM/PM close, otherwise, they want a 24-hour clock. | 516 | AM/PM close, otherwise, they want a 24-hour clock. |
517 | */ | 517 | */ |
518 | 518 | ||
519 | /*! | 519 | /*! |
520 | \fn void QPEApplication::appMessage( const QCString& msg, const QByteArray& data ) | 520 | \fn void QPEApplication::appMessage( const QCString& msg, const QByteArray& data ) |
521 | 521 | ||
522 | This signal is emitted when a message is received on the | 522 | This signal is emitted when a message is received on the |
523 | QPE/Application/<i>appname</i> QCop channel for this application. | 523 | QPE/Application/<i>appname</i> QCop channel for this application. |
524 | 524 | ||
525 | The slot to which you connect this signal uses \a msg and \a data | 525 | The slot to which you connect this signal uses \a msg and \a data |
526 | in the following way: | 526 | in the following way: |
527 | 527 | ||
528 | \code | 528 | \code |
529 | void MyWidget::receive( const QCString& msg, const QByteArray& data ) | 529 | void MyWidget::receive( const QCString& msg, const QByteArray& data ) |
530 | { | 530 | { |
531 | QDataStream stream( data, IO_ReadOnly ); | 531 | QDataStream stream( data, IO_ReadOnly ); |
532 | if ( msg == "someMessage(int,int,int)" ) { | 532 | if ( msg == "someMessage(int,int,int)" ) { |
533 | int a,b,c; | 533 | int a,b,c; |
534 | stream >> a >> b >> c; | 534 | stream >> a >> b >> c; |
535 | ... | 535 | ... |
536 | } else if ( msg == "otherMessage(QString)" ) { | 536 | } else if ( msg == "otherMessage(QString)" ) { |
537 | ... | 537 | ... |
538 | } | 538 | } |
539 | } | 539 | } |
540 | \endcode | 540 | \endcode |
541 | 541 | ||
542 | \sa qcop.html | 542 | \sa qcop.html |
543 | */ | 543 | */ |
544 | 544 | ||
545 | /*! | 545 | /*! |
546 | Constructs a QPEApplication just as you would construct | 546 | Constructs a QPEApplication just as you would construct |
547 | a QApplication, passing \a argc, \a argv, and \a t. | 547 | a QApplication, passing \a argc, \a argv, and \a t. |
548 | */ | 548 | */ |
549 | QPEApplication::QPEApplication( int & argc, char **argv, Type t ) | 549 | QPEApplication::QPEApplication( int & argc, char **argv, Type t ) |
550 | : QApplication( hack( argc ), argv, t ) | 550 | : QApplication( hack( argc ), argv, t ) |
551 | { | 551 | { |
552 | int dw = desktop() ->width(); | 552 | int dw = desktop() ->width(); |
553 | if ( dw < 200 ) { | 553 | if ( dw < 200 ) { |
554 | // setFont( QFont( "helvetica", 8 ) ); | 554 | // setFont( QFont( "helvetica", 8 ) ); |
555 | AppLnk::setSmallIconSize( 10 ); | 555 | AppLnk::setSmallIconSize( 10 ); |
556 | AppLnk::setBigIconSize( 28 ); | 556 | AppLnk::setBigIconSize( 28 ); |
557 | } | 557 | } |
558 | 558 | ||
559 | d = new QPEApplicationData; | 559 | d = new QPEApplicationData; |
560 | QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory ); | 560 | QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory ); |
561 | 561 | ||
562 | connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) ); | 562 | connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) ); |
563 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 563 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
564 | 564 | ||
565 | QString qcopfn( "/tmp/qcop-msg-" ); | 565 | QString qcopfn( "/tmp/qcop-msg-" ); |
@@ -622,120 +622,126 @@ QPEApplication::QPEApplication( int & argc, char **argv, Type t ) | |||
622 | 622 | ||
623 | #ifndef QT_NO_TRANSLATION | 623 | #ifndef QT_NO_TRANSLATION |
624 | 624 | ||
625 | QStringList langs = Global::languageList(); | 625 | QStringList langs = Global::languageList(); |
626 | for ( QStringList::ConstIterator it = langs.begin(); it != langs.end(); ++it ) { | 626 | for ( QStringList::ConstIterator it = langs.begin(); it != langs.end(); ++it ) { |
627 | QString lang = *it; | 627 | QString lang = *it; |
628 | 628 | ||
629 | QTranslator * trans; | 629 | QTranslator * trans; |
630 | QString tfn; | 630 | QString tfn; |
631 | 631 | ||
632 | trans = new QTranslator( this ); | 632 | trans = new QTranslator( this ); |
633 | tfn = qpeDir() + "/i18n/" + lang + "/libqpe.qm"; | 633 | tfn = qpeDir() + "/i18n/" + lang + "/libqpe.qm"; |
634 | if ( trans->load( tfn ) ) | 634 | if ( trans->load( tfn ) ) |
635 | installTranslator( trans ); | 635 | installTranslator( trans ); |
636 | else | 636 | else |
637 | delete trans; | 637 | delete trans; |
638 | 638 | ||
639 | trans = new QTranslator( this ); | 639 | trans = new QTranslator( this ); |
640 | tfn = qpeDir() + "/i18n/" + lang + "/" + d->appName + ".qm"; | 640 | tfn = qpeDir() + "/i18n/" + lang + "/" + d->appName + ".qm"; |
641 | if ( trans->load( tfn ) ) | 641 | if ( trans->load( tfn ) ) |
642 | installTranslator( trans ); | 642 | installTranslator( trans ); |
643 | else | 643 | else |
644 | delete trans; | 644 | delete trans; |
645 | 645 | ||
646 | //###language/font hack; should look it up somewhere | 646 | /* |
647 | if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) { | 647 | * not required. if using one of these languages, you might as well install |
648 | QFont fn = FontManager::unicodeFont( FontManager::Proportional ); | 648 | * a custom font. |
649 | setFont( fn ); | 649 | |
650 | } | 650 | //###language/font hack; should look it up somewhere |
651 | else { | 651 | if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) { |
652 | Config config( "qpe" ); | 652 | QFont fn = FontManager::unicodeFont( FontManager::Proportional ); |
653 | setFont( fn ); | ||
654 | } | ||
655 | |||
656 | else { | ||
657 | */ | ||
658 | Config config( "qpe" ); | ||
653 | config.setGroup( "Appearance" ); | 659 | config.setGroup( "Appearance" ); |
654 | QString familyStr = config.readEntry( "FontFamily", "helvetica" ); | 660 | QString familyStr = config.readEntry( "FontFamily", "helvetica" ); |
655 | QString styleStr = config.readEntry( "FontStyle", "Regular" ); | 661 | QString styleStr = config.readEntry( "FontStyle", "Regular" ); |
656 | QString sizeStr = config.readEntry( "FontSize", "10" ); | 662 | QString sizeStr = config.readEntry( "FontSize", "10" ); |
657 | QString charSetStr = config.readEntry( "FontCharSet", QString::null ); | 663 | QString charSetStr = config.readEntry( "FontCharSet", QString::null ); |
658 | bool ok; | 664 | bool ok; |
659 | int i_size = sizeStr.toInt( &ok, 10 ); | 665 | int i_size = sizeStr.toInt( &ok, 10 ); |
660 | FontDatabase fdb; | 666 | FontDatabase fdb; |
661 | QFont selectedFont = fdb.font( familyStr, styleStr, i_size, charSetStr ); | 667 | QFont selectedFont = fdb.font( familyStr, styleStr, i_size, charSetStr ); |
662 | setFont( selectedFont ); | 668 | setFont( selectedFont ); |
663 | } | 669 | //} |
664 | } | 670 | } |
665 | 671 | ||
666 | #endif | 672 | #endif |
667 | 673 | ||
668 | applyStyle(); | 674 | applyStyle(); |
669 | 675 | ||
670 | if ( type() == GuiServer ) { | 676 | if ( type() == GuiServer ) { |
671 | setScreenSaverInterval( -1 ); | 677 | setScreenSaverInterval( -1 ); |
672 | setVolume(); | 678 | setVolume(); |
673 | QWSServer::setScreenSaver( new QPEScreenSaver ); | 679 | QWSServer::setScreenSaver( new QPEScreenSaver ); |
674 | } | 680 | } |
675 | 681 | ||
676 | installEventFilter( this ); | 682 | installEventFilter( this ); |
677 | 683 | ||
678 | QPEMenuToolFocusManager::initialize(); | 684 | QPEMenuToolFocusManager::initialize(); |
679 | 685 | ||
680 | #ifdef QT_NO_QWS_CURSOR | 686 | #ifdef QT_NO_QWS_CURSOR |
681 | // if we have no cursor, probably don't want tooltips | 687 | // if we have no cursor, probably don't want tooltips |
682 | QToolTip::setEnabled( FALSE ); | 688 | QToolTip::setEnabled( FALSE ); |
683 | #endif | 689 | #endif |
684 | } | 690 | } |
685 | 691 | ||
686 | static QPtrDict<void>* inputMethodDict = 0; | 692 | static QPtrDict<void>* inputMethodDict = 0; |
687 | static void createInputMethodDict() | 693 | static void createInputMethodDict() |
688 | { | 694 | { |
689 | if ( !inputMethodDict ) | 695 | if ( !inputMethodDict ) |
690 | inputMethodDict = new QPtrDict<void>; | 696 | inputMethodDict = new QPtrDict<void>; |
691 | } | 697 | } |
692 | 698 | ||
693 | /*! | 699 | /*! |
694 | Returns the currently set hint to the system as to whether | 700 | Returns the currently set hint to the system as to whether |
695 | \a w has any use for text input methods. | 701 | \a w has any use for text input methods. |
696 | 702 | ||
697 | \sa setInputMethodHint() | 703 | \sa setInputMethodHint() |
698 | */ | 704 | */ |
699 | QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w ) | 705 | QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w ) |
700 | { | 706 | { |
701 | if ( inputMethodDict && w ) | 707 | if ( inputMethodDict && w ) |
702 | return ( InputMethodHint ) ( int ) inputMethodDict->find( w ); | 708 | return ( InputMethodHint ) ( int ) inputMethodDict->find( w ); |
703 | return Normal; | 709 | return Normal; |
704 | } | 710 | } |
705 | 711 | ||
706 | /*! | 712 | /*! |
707 | \enum QPEApplication::InputMethodHint | 713 | \enum QPEApplication::InputMethodHint |
708 | 714 | ||
709 | \value Normal the application sometimes needs text input (the default). | 715 | \value Normal the application sometimes needs text input (the default). |
710 | \value AlwaysOff the application never needs text input. | 716 | \value AlwaysOff the application never needs text input. |
711 | \value AlwaysOn the application always needs text input. | 717 | \value AlwaysOn the application always needs text input. |
712 | */ | 718 | */ |
713 | 719 | ||
714 | /*! | 720 | /*! |
715 | Hints to the system that \a w has use for text input methods | 721 | Hints to the system that \a w has use for text input methods |
716 | as specified by \a mode. | 722 | as specified by \a mode. |
717 | 723 | ||
718 | \sa inputMethodHint() | 724 | \sa inputMethodHint() |
719 | */ | 725 | */ |
720 | void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode ) | 726 | void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode ) |
721 | { | 727 | { |
722 | createInputMethodDict(); | 728 | createInputMethodDict(); |
723 | if ( mode == Normal ) { | 729 | if ( mode == Normal ) { |
724 | inputMethodDict->remove | 730 | inputMethodDict->remove |
725 | ( w ); | 731 | ( w ); |
726 | } | 732 | } |
727 | else { | 733 | else { |
728 | inputMethodDict->insert( w, ( void* ) mode ); | 734 | inputMethodDict->insert( w, ( void* ) mode ); |
729 | } | 735 | } |
730 | } | 736 | } |
731 | 737 | ||
732 | class HackDialog : public QDialog | 738 | class HackDialog : public QDialog |
733 | { | 739 | { |
734 | public: | 740 | public: |
735 | void acceptIt() | 741 | void acceptIt() |
736 | { | 742 | { |
737 | accept(); | 743 | accept(); |
738 | } | 744 | } |
739 | void rejectIt() | 745 | void rejectIt() |
740 | { | 746 | { |
741 | reject(); | 747 | reject(); |
@@ -1248,162 +1254,162 @@ void QPEApplication::pidMessage( const QCString &msg, const QByteArray & data ) | |||
1248 | mw = d->qpe_main_widget; | 1254 | mw = d->qpe_main_widget; |
1249 | if ( mw ) | 1255 | if ( mw ) |
1250 | Global::setDocument( mw, doc ); | 1256 | Global::setDocument( mw, doc ); |
1251 | } | 1257 | } |
1252 | else if ( msg == "nextView()" ) { | 1258 | else if ( msg == "nextView()" ) { |
1253 | if ( raiseAppropriateWindow() ) | 1259 | if ( raiseAppropriateWindow() ) |
1254 | emit appMessage( msg, data ); | 1260 | emit appMessage( msg, data ); |
1255 | } | 1261 | } |
1256 | else { | 1262 | else { |
1257 | emit appMessage( msg, data ); | 1263 | emit appMessage( msg, data ); |
1258 | } | 1264 | } |
1259 | #endif | 1265 | #endif |
1260 | } | 1266 | } |
1261 | 1267 | ||
1262 | 1268 | ||
1263 | static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) | 1269 | static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) |
1264 | { | 1270 | { |
1265 | /* | 1271 | /* |
1266 | // This works but disable it for now until it is safe to apply | 1272 | // This works but disable it for now until it is safe to apply |
1267 | // What is does is scan the .desktop files of all the apps for | 1273 | // What is does is scan the .desktop files of all the apps for |
1268 | // the applnk that has the corresponding argv[0] as this program | 1274 | // the applnk that has the corresponding argv[0] as this program |
1269 | // then it uses the name stored in the .desktop file as the caption | 1275 | // then it uses the name stored in the .desktop file as the caption |
1270 | // for the main widget. This saves duplicating translations for | 1276 | // for the main widget. This saves duplicating translations for |
1271 | // the app name in the program and in the .desktop files. | 1277 | // the app name in the program and in the .desktop files. |
1272 | 1278 | ||
1273 | AppLnkSet apps( appsPath ); | 1279 | AppLnkSet apps( appsPath ); |
1274 | 1280 | ||
1275 | QList<AppLnk> appsList = apps.children(); | 1281 | QList<AppLnk> appsList = apps.children(); |
1276 | for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) { | 1282 | for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) { |
1277 | if ( (*it)->exec() == appName ) { | 1283 | if ( (*it)->exec() == appName ) { |
1278 | mw->setCaption( (*it)->name() ); | 1284 | mw->setCaption( (*it)->name() ); |
1279 | return TRUE; | 1285 | return TRUE; |
1280 | } | 1286 | } |
1281 | } | 1287 | } |
1282 | */ | 1288 | */ |
1283 | return FALSE; | 1289 | return FALSE; |
1284 | } | 1290 | } |
1285 | 1291 | ||
1286 | 1292 | ||
1287 | /*! | 1293 | /*! |
1288 | Sets \a mw as the mainWidget() and shows it. For small windows, | 1294 | Sets \a mw as the mainWidget() and shows it. For small windows, |
1289 | consider passing TRUE for \a nomaximize rather than the default FALSE. | 1295 | consider passing TRUE for \a nomaximize rather than the default FALSE. |
1290 | 1296 | ||
1291 | \sa showMainDocumentWidget() | 1297 | \sa showMainDocumentWidget() |
1292 | */ | 1298 | */ |
1293 | void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize ) | 1299 | void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize ) |
1294 | { | 1300 | { |
1295 | setWidgetCaptionFromAppName( mw, d->appName, qpeDir() + "apps" ); | 1301 | setWidgetCaptionFromAppName( mw, d->appName, qpeDir() + "apps" ); |
1296 | 1302 | ||
1297 | d->nomaximize = nomaximize; | 1303 | d->nomaximize = nomaximize; |
1298 | d->qpe_main_widget = mw; | 1304 | d->qpe_main_widget = mw; |
1299 | d->sendQCopQ(); | 1305 | d->sendQCopQ(); |
1300 | if ( d->preloaded ) { | 1306 | if ( d->preloaded ) { |
1301 | if ( d->forceshow ) { | 1307 | if ( d->forceshow ) { |
1302 | #ifdef Q_WS_QWS | 1308 | #ifdef Q_WS_QWS |
1303 | if ( !nomaximize ) | 1309 | if ( !nomaximize ) |
1304 | mw->showMaximized(); | 1310 | mw->showMaximized(); |
1305 | else | 1311 | else |
1306 | #endif | 1312 | #endif |
1307 | 1313 | ||
1308 | mw->show(); | 1314 | mw->show(); |
1309 | } | 1315 | } |
1310 | } | 1316 | } |
1311 | else if ( d->keep_running ) { | 1317 | else if ( d->keep_running ) { |
1312 | #ifdef Q_WS_QWS | 1318 | #ifdef Q_WS_QWS |
1313 | if ( !nomaximize ) | 1319 | if ( !nomaximize ) |
1314 | mw->showMaximized(); | 1320 | mw->showMaximized(); |
1315 | else | 1321 | else |
1316 | #endif | 1322 | #endif |
1317 | 1323 | ||
1318 | mw->show(); | 1324 | mw->show(); |
1319 | } | 1325 | } |
1320 | } | 1326 | } |
1321 | 1327 | ||
1322 | /*! | 1328 | /*! |
1323 | Sets \a mw as the mainWidget() and shows it. For small windows, | 1329 | Sets \a mw as the mainWidget() and shows it. For small windows, |
1324 | consider passing TRUE for \a nomaximize rather than the default FALSE. | 1330 | consider passing TRUE for \a nomaximize rather than the default FALSE. |
1325 | 1331 | ||
1326 | This calls designates the application as | 1332 | This calls designates the application as |
1327 | a \link docwidget.html document-oriented\endlink application. | 1333 | a \link docwidget.html document-oriented\endlink application. |
1328 | 1334 | ||
1329 | The \a mw widget must have a slot: setDocument(const QString&). | 1335 | The \a mw widget must have a slot: setDocument(const QString&). |
1330 | 1336 | ||
1331 | \sa showMainWidget() | 1337 | \sa showMainWidget() |
1332 | */ | 1338 | */ |
1333 | void QPEApplication::showMainDocumentWidget( QWidget* mw, bool nomaximize ) | 1339 | void QPEApplication::showMainDocumentWidget( QWidget* mw, bool nomaximize ) |
1334 | { | 1340 | { |
1335 | setWidgetCaptionFromAppName( mw, d->appName, qpeDir() + "apps" ); | 1341 | setWidgetCaptionFromAppName( mw, d->appName, qpeDir() + "apps" ); |
1336 | 1342 | ||
1337 | if ( mw && argc() == 2 ) | 1343 | if ( mw && argc() == 2 ) |
1338 | Global::setDocument( mw, QString::fromUtf8( argv() [ 1 ] ) ); | 1344 | Global::setDocument( mw, QString::fromUtf8( argv() [ 1 ] ) ); |
1339 | d->nomaximize = nomaximize; | 1345 | d->nomaximize = nomaximize; |
1340 | d->qpe_main_widget = mw; | 1346 | d->qpe_main_widget = mw; |
1341 | d->sendQCopQ(); | 1347 | d->sendQCopQ(); |
1342 | if ( d->preloaded ) { | 1348 | if ( d->preloaded ) { |
1343 | if ( d->forceshow ) { | 1349 | if ( d->forceshow ) { |
1344 | #ifdef Q_WS_QWS | 1350 | #ifdef Q_WS_QWS |
1345 | if ( !nomaximize ) | 1351 | if ( !nomaximize ) |
1346 | mw->showMaximized(); | 1352 | mw->showMaximized(); |
1347 | else | 1353 | else |
1348 | #endif | 1354 | #endif |
1349 | 1355 | ||
1350 | mw->show(); | 1356 | mw->show(); |
1351 | } | 1357 | } |
1352 | } | 1358 | } |
1353 | else if ( d->keep_running ) { | 1359 | else if ( d->keep_running ) { |
1354 | #ifdef Q_WS_QWS | 1360 | #ifdef Q_WS_QWS |
1355 | if ( !nomaximize ) | 1361 | if ( !nomaximize ) |
1356 | mw->showMaximized(); | 1362 | mw->showMaximized(); |
1357 | else | 1363 | else |
1358 | #endif | 1364 | #endif |
1359 | 1365 | ||
1360 | mw->show(); | 1366 | mw->show(); |
1361 | } | 1367 | } |
1362 | } | 1368 | } |
1363 | 1369 | ||
1364 | 1370 | ||
1365 | /*! | 1371 | /*! |
1366 | Sets that the application should continue running after processing | 1372 | Sets that the application should continue running after processing |
1367 | qcop messages. Normally if an application is started via a qcop message, | 1373 | qcop messages. Normally if an application is started via a qcop message, |
1368 | the application will process the qcop message and then quit. If while | 1374 | the application will process the qcop message and then quit. If while |
1369 | processing the qcop message it calls this function, then the application | 1375 | processing the qcop message it calls this function, then the application |
1370 | will show and start proper once it has finished processing qcop messages. | 1376 | will show and start proper once it has finished processing qcop messages. |
1371 | 1377 | ||
1372 | \sa keepRunning() | 1378 | \sa keepRunning() |
1373 | */ | 1379 | */ |
1374 | void QPEApplication::setKeepRunning() | 1380 | void QPEApplication::setKeepRunning() |
1375 | { | 1381 | { |
1376 | if ( qApp && qApp->inherits( "QPEApplication" ) ) { | 1382 | if ( qApp && qApp->inherits( "QPEApplication" ) ) { |
1377 | QPEApplication * qpeApp = ( QPEApplication* ) qApp; | 1383 | QPEApplication * qpeApp = ( QPEApplication* ) qApp; |
1378 | qpeApp->d->keep_running = TRUE; | 1384 | qpeApp->d->keep_running = TRUE; |
1379 | } | 1385 | } |
1380 | } | 1386 | } |
1381 | 1387 | ||
1382 | /*! | 1388 | /*! |
1383 | Returns whether the application will quit after processing the current | 1389 | Returns whether the application will quit after processing the current |
1384 | list of qcop messages. | 1390 | list of qcop messages. |
1385 | 1391 | ||
1386 | \sa setKeepRunning() | 1392 | \sa setKeepRunning() |
1387 | */ | 1393 | */ |
1388 | bool QPEApplication::keepRunning() const | 1394 | bool QPEApplication::keepRunning() const |
1389 | { | 1395 | { |
1390 | return d->keep_running; | 1396 | return d->keep_running; |
1391 | } | 1397 | } |
1392 | 1398 | ||
1393 | /*! | 1399 | /*! |
1394 | \internal | 1400 | \internal |
1395 | */ | 1401 | */ |
1396 | void QPEApplication::internalSetStyle( const QString &style ) | 1402 | void QPEApplication::internalSetStyle( const QString &style ) |
1397 | { | 1403 | { |
1398 | #if QT_VERSION >= 300 | 1404 | #if QT_VERSION >= 300 |
1399 | if ( style == "QPE" ) { | 1405 | if ( style == "QPE" ) { |
1400 | setStyle( new QPEStyle ); | 1406 | setStyle( new QPEStyle ); |
1401 | } | 1407 | } |
1402 | else { | 1408 | else { |
1403 | QStyle *s = QStyleFactory::create( style ); | 1409 | QStyle *s = QStyleFactory::create( style ); |
1404 | if ( s ) | 1410 | if ( s ) |
1405 | setStyle( s ); | 1411 | setStyle( s ); |
1406 | } | 1412 | } |
1407 | #else | 1413 | #else |
1408 | if ( style == "Windows" ) { | 1414 | if ( style == "Windows" ) { |
1409 | setStyle( new QWindowsStyle ); | 1415 | setStyle( new QWindowsStyle ); |
@@ -1443,49 +1449,49 @@ void QPEApplication::internalSetStyle( const QString &style ) | |||
1443 | 1449 | ||
1444 | if ( lib-> queryInterface ( IID_Style, ( QUnknownInterface ** ) &iface ) == QS_OK ) | 1450 | if ( lib-> queryInterface ( IID_Style, ( QUnknownInterface ** ) &iface ) == QS_OK ) |
1445 | sty = iface-> create ( ); | 1451 | sty = iface-> create ( ); |
1446 | 1452 | ||
1447 | if ( sty ) { | 1453 | if ( sty ) { |
1448 | setStyle ( sty ); | 1454 | setStyle ( sty ); |
1449 | 1455 | ||
1450 | qDebug ( "Got Style: %p -- iface: %p, lib: %p\n", sty, iface, lib ); | 1456 | qDebug ( "Got Style: %p -- iface: %p, lib: %p\n", sty, iface, lib ); |
1451 | 1457 | ||
1452 | if ( lastiface ) | 1458 | if ( lastiface ) |
1453 | lastiface-> release ( ); | 1459 | lastiface-> release ( ); |
1454 | lastiface = iface; | 1460 | lastiface = iface; |
1455 | 1461 | ||
1456 | 1462 | ||
1457 | if ( lastlib ) { | 1463 | if ( lastlib ) { |
1458 | lastlib-> unload ( ); | 1464 | lastlib-> unload ( ); |
1459 | delete lastlib; | 1465 | delete lastlib; |
1460 | } | 1466 | } |
1461 | lastlib = lib; | 1467 | lastlib = lib; |
1462 | } | 1468 | } |
1463 | else { | 1469 | else { |
1464 | if ( iface ) | 1470 | if ( iface ) |
1465 | iface-> release ( ); | 1471 | iface-> release ( ); |
1466 | delete lib; | 1472 | delete lib; |
1467 | 1473 | ||
1468 | setStyle ( new QPEStyle ( )); | 1474 | setStyle ( new QPEStyle ( )); |
1469 | } | 1475 | } |
1470 | 1476 | ||
1471 | #if 0 | 1477 | #if 0 |
1472 | // style == "Liquid Style (libliquid.so)" (or "Windows XP (libxp.so)" | 1478 | // style == "Liquid Style (libliquid.so)" (or "Windows XP (libxp.so)" |
1473 | 1479 | ||
1474 | int p2 = style. findRev ( ']' ); | 1480 | int p2 = style. findRev ( ']' ); |
1475 | int p1 = style. findRev ( '[' ); | 1481 | int p1 = style. findRev ( '[' ); |
1476 | QString style2; | 1482 | QString style2; |
1477 | 1483 | ||
1478 | if ( ( p1 > 0 ) && ( p2 > 0 ) && ( ( p1 + 1 ) < p2 ) ) | 1484 | if ( ( p1 > 0 ) && ( p2 > 0 ) && ( ( p1 + 1 ) < p2 ) ) |
1479 | style2 = "lib" + style. mid ( p1 + 1, p2 - p1 - 1 ). lower ( ) + ".so"; | 1485 | style2 = "lib" + style. mid ( p1 + 1, p2 - p1 - 1 ). lower ( ) + ".so"; |
1480 | else | 1486 | else |
1481 | style2 = "lib" + style. lower ( ) + ".so"; | 1487 | style2 = "lib" + style. lower ( ) + ".so"; |
1482 | 1488 | ||
1483 | static QLibrary *currentlib = 0; | 1489 | static QLibrary *currentlib = 0; |
1484 | 1490 | ||
1485 | QString path = QPEApplication::qpeDir ( ) + "/plugins/styles/" + style2; | 1491 | QString path = QPEApplication::qpeDir ( ) + "/plugins/styles/" + style2; |
1486 | 1492 | ||
1487 | do { // try/catch simulation | 1493 | do { // try/catch simulation |
1488 | QLibrary *lib = new QLibrary ( path, QLibrary::Immediately ); | 1494 | QLibrary *lib = new QLibrary ( path, QLibrary::Immediately ); |
1489 | 1495 | ||
1490 | if ( lib ) { | 1496 | if ( lib ) { |
1491 | QStyle * ( *fpa ) ( ) = ( QStyle * ( * ) ( ) ) lib-> resolve ( "allocate" ); | 1497 | QStyle * ( *fpa ) ( ) = ( QStyle * ( * ) ( ) ) lib-> resolve ( "allocate" ); |
@@ -1543,72 +1549,72 @@ void QPEApplication::prepareForTermination( bool willrestart ) | |||
1543 | \internal | 1549 | \internal |
1544 | */ | 1550 | */ |
1545 | void QPEApplication::shutdown() | 1551 | void QPEApplication::shutdown() |
1546 | { | 1552 | { |
1547 | // Implement in server's QPEApplication subclass | 1553 | // Implement in server's QPEApplication subclass |
1548 | } | 1554 | } |
1549 | 1555 | ||
1550 | /*! | 1556 | /*! |
1551 | \internal | 1557 | \internal |
1552 | */ | 1558 | */ |
1553 | void QPEApplication::restart() | 1559 | void QPEApplication::restart() |
1554 | { | 1560 | { |
1555 | // Implement in server's QPEApplication subclass | 1561 | // Implement in server's QPEApplication subclass |
1556 | } | 1562 | } |
1557 | 1563 | ||
1558 | static QPtrDict<void>* stylusDict = 0; | 1564 | static QPtrDict<void>* stylusDict = 0; |
1559 | static void createDict() | 1565 | static void createDict() |
1560 | { | 1566 | { |
1561 | if ( !stylusDict ) | 1567 | if ( !stylusDict ) |
1562 | stylusDict = new QPtrDict<void>; | 1568 | stylusDict = new QPtrDict<void>; |
1563 | } | 1569 | } |
1564 | 1570 | ||
1565 | /*! | 1571 | /*! |
1566 | Returns the current StylusMode for \a w. | 1572 | Returns the current StylusMode for \a w. |
1567 | 1573 | ||
1568 | \sa setStylusOperation() | 1574 | \sa setStylusOperation() |
1569 | */ | 1575 | */ |
1570 | QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget * w ) | 1576 | QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget * w ) |
1571 | { | 1577 | { |
1572 | if ( stylusDict ) | 1578 | if ( stylusDict ) |
1573 | return ( StylusMode ) ( int ) stylusDict->find( w ); | 1579 | return ( StylusMode ) ( int ) stylusDict->find( w ); |
1574 | return LeftOnly; | 1580 | return LeftOnly; |
1575 | } | 1581 | } |
1576 | 1582 | ||
1577 | /*! | 1583 | /*! |
1578 | \enum QPEApplication::StylusMode | 1584 | \enum QPEApplication::StylusMode |
1579 | 1585 | ||
1580 | \value LeftOnly the stylus only generates LeftButton | 1586 | \value LeftOnly the stylus only generates LeftButton |
1581 | events (the default). | 1587 | events (the default). |
1582 | \value RightOnHold the stylus generates RightButton events | 1588 | \value RightOnHold the stylus generates RightButton events |
1583 | if the user uses the press-and-hold gesture. | 1589 | if the user uses the press-and-hold gesture. |
1584 | 1590 | ||
1585 | See setStylusOperation(). | 1591 | See setStylusOperation(). |
1586 | */ | 1592 | */ |
1587 | 1593 | ||
1588 | /*! | 1594 | /*! |
1589 | Causes \a w to receive mouse events according to \a mode. | 1595 | Causes \a w to receive mouse events according to \a mode. |
1590 | 1596 | ||
1591 | \sa stylusOperation() | 1597 | \sa stylusOperation() |
1592 | */ | 1598 | */ |
1593 | void QPEApplication::setStylusOperation( QWidget * w, StylusMode mode ) | 1599 | void QPEApplication::setStylusOperation( QWidget * w, StylusMode mode ) |
1594 | { | 1600 | { |
1595 | createDict(); | 1601 | createDict(); |
1596 | if ( mode == LeftOnly ) { | 1602 | if ( mode == LeftOnly ) { |
1597 | stylusDict->remove | 1603 | stylusDict->remove |
1598 | ( w ); | 1604 | ( w ); |
1599 | w->removeEventFilter( qApp ); | 1605 | w->removeEventFilter( qApp ); |
1600 | } | 1606 | } |
1601 | else { | 1607 | else { |
1602 | stylusDict->insert( w, ( void* ) mode ); | 1608 | stylusDict->insert( w, ( void* ) mode ); |
1603 | connect( w, SIGNAL( destroyed() ), qApp, SLOT( removeSenderFromStylusDict() ) ); | 1609 | connect( w, SIGNAL( destroyed() ), qApp, SLOT( removeSenderFromStylusDict() ) ); |
1604 | w->installEventFilter( qApp ); | 1610 | w->installEventFilter( qApp ); |
1605 | } | 1611 | } |
1606 | } | 1612 | } |
1607 | 1613 | ||
1608 | 1614 | ||
1609 | /*! | 1615 | /*! |
1610 | \reimp | 1616 | \reimp |
1611 | */ | 1617 | */ |
1612 | bool QPEApplication::eventFilter( QObject *o, QEvent *e ) | 1618 | bool QPEApplication::eventFilter( QObject *o, QEvent *e ) |
1613 | { | 1619 | { |
1614 | if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) { | 1620 | if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) { |
@@ -1699,49 +1705,49 @@ bool QPEApplication::keyboardGrabbed() const | |||
1699 | { | 1705 | { |
1700 | return d->kbgrabber; | 1706 | return d->kbgrabber; |
1701 | } | 1707 | } |
1702 | 1708 | ||
1703 | 1709 | ||
1704 | /*! | 1710 | /*! |
1705 | Reverses the effect of grabKeyboard(). This is called automatically | 1711 | Reverses the effect of grabKeyboard(). This is called automatically |
1706 | on program exit. | 1712 | on program exit. |
1707 | */ | 1713 | */ |
1708 | void QPEApplication::ungrabKeyboard() | 1714 | void QPEApplication::ungrabKeyboard() |
1709 | { | 1715 | { |
1710 | QPEApplicationData * d = ( ( QPEApplication* ) qApp ) ->d; | 1716 | QPEApplicationData * d = ( ( QPEApplication* ) qApp ) ->d; |
1711 | if ( d->kbgrabber == 2 ) { | 1717 | if ( d->kbgrabber == 2 ) { |
1712 | QCopEnvelope e( "QPE/System", "grabKeyboard(QString)" ); | 1718 | QCopEnvelope e( "QPE/System", "grabKeyboard(QString)" ); |
1713 | e << QString::null; | 1719 | e << QString::null; |
1714 | d->kbregrab = FALSE; | 1720 | d->kbregrab = FALSE; |
1715 | d->kbgrabber = 0; | 1721 | d->kbgrabber = 0; |
1716 | } | 1722 | } |
1717 | } | 1723 | } |
1718 | 1724 | ||
1719 | /*! | 1725 | /*! |
1720 | Grabs the keyboard such that the system's application launching | 1726 | Grabs the keyboard such that the system's application launching |
1721 | keys no longer work, and instead they are receivable by this | 1727 | keys no longer work, and instead they are receivable by this |
1722 | application. | 1728 | application. |
1723 | 1729 | ||
1724 | \sa ungrabKeyboard() | 1730 | \sa ungrabKeyboard() |
1725 | */ | 1731 | */ |
1726 | void QPEApplication::grabKeyboard() | 1732 | void QPEApplication::grabKeyboard() |
1727 | { | 1733 | { |
1728 | QPEApplicationData * d = ( ( QPEApplication* ) qApp ) ->d; | 1734 | QPEApplicationData * d = ( ( QPEApplication* ) qApp ) ->d; |
1729 | if ( qApp->type() == QApplication::GuiServer ) | 1735 | if ( qApp->type() == QApplication::GuiServer ) |
1730 | d->kbgrabber = 0; | 1736 | d->kbgrabber = 0; |
1731 | else { | 1737 | else { |
1732 | QCopEnvelope e( "QPE/System", "grabKeyboard(QString)" ); | 1738 | QCopEnvelope e( "QPE/System", "grabKeyboard(QString)" ); |
1733 | e << d->appName; | 1739 | e << d->appName; |
1734 | d->kbgrabber = 2; // me | 1740 | d->kbgrabber = 2; // me |
1735 | } | 1741 | } |
1736 | } | 1742 | } |
1737 | 1743 | ||
1738 | /*! | 1744 | /*! |
1739 | \reimp | 1745 | \reimp |
1740 | */ | 1746 | */ |
1741 | int QPEApplication::exec() | 1747 | int QPEApplication::exec() |
1742 | { | 1748 | { |
1743 | d->sendQCopQ(); | 1749 | d->sendQCopQ(); |
1744 | if ( d->keep_running ) | 1750 | if ( d->keep_running ) |
1745 | //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() ) | 1751 | //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() ) |
1746 | return QApplication::exec(); | 1752 | return QApplication::exec(); |
1747 | 1753 | ||