author | alwin <alwin> | 2004-03-02 12:21:11 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-03-02 12:21:11 (UTC) |
commit | b6b1c97559c0ed9f2e33632272426bf98f289232 (patch) (unidiff) | |
tree | d3a9987704770cdf5eb14e1136f6e3ecb2f36a04 /library/qpeapplication.cpp | |
parent | 0d59c780513da78033f4d9040475dee9db0256d4 (diff) | |
download | opie-b6b1c97559c0ed9f2e33632272426bf98f289232.zip opie-b6b1c97559c0ed9f2e33632272426bf98f289232.tar.gz opie-b6b1c97559c0ed9f2e33632272426bf98f289232.tar.bz2 |
applied the patch generated by the optimize_connect script from
TT.
-rw-r--r-- | library/qpeapplication.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp index 262221e..c339a78 100644 --- a/library/qpeapplication.cpp +++ b/library/qpeapplication.cpp | |||
@@ -439,509 +439,509 @@ static void setTreble( int t = 0, int percent = -1 ) | |||
439 | \class QPEApplication | 439 | \class QPEApplication |
440 | \brief The QPEApplication class implements various system services | 440 | \brief The QPEApplication class implements various system services |
441 | that are available to all Qtopia applications. | 441 | that are available to all Qtopia applications. |
442 | 442 | ||
443 | Simply by using QPEApplication instead of QApplication, a standard Qt | 443 | Simply by using QPEApplication instead of QApplication, a standard Qt |
444 | application becomes a Qtopia application. It automatically follows | 444 | application becomes a Qtopia application. It automatically follows |
445 | style changes, quits and raises, and in the | 445 | style changes, quits and raises, and in the |
446 | case of \link docwidget.html document-oriented\endlink applications, | 446 | case of \link docwidget.html document-oriented\endlink applications, |
447 | changes the currently displayed document in response to the environment. | 447 | changes the currently displayed document in response to the environment. |
448 | 448 | ||
449 | To create a \link docwidget.html document-oriented\endlink | 449 | To create a \link docwidget.html document-oriented\endlink |
450 | application use showMainDocumentWidget(); to create a | 450 | application use showMainDocumentWidget(); to create a |
451 | non-document-oriented application use showMainWidget(). The | 451 | non-document-oriented application use showMainWidget(). The |
452 | keepRunning() function indicates whether the application will | 452 | keepRunning() function indicates whether the application will |
453 | continue running after it's processed the last \link qcop.html | 453 | continue running after it's processed the last \link qcop.html |
454 | QCop\endlink message. This can be changed using setKeepRunning(). | 454 | QCop\endlink message. This can be changed using setKeepRunning(). |
455 | 455 | ||
456 | A variety of signals are emitted when certain events occur, for | 456 | A variety of signals are emitted when certain events occur, for |
457 | example, timeChanged(), clockChanged(), weekChanged(), | 457 | example, timeChanged(), clockChanged(), weekChanged(), |
458 | dateFormatChanged() and volumeChanged(). If the application receives | 458 | dateFormatChanged() and volumeChanged(). If the application receives |
459 | a \link qcop.html QCop\endlink message on the application's | 459 | a \link qcop.html QCop\endlink message on the application's |
460 | QPE/Application/\e{appname} channel, the appMessage() signal is | 460 | QPE/Application/\e{appname} channel, the appMessage() signal is |
461 | emitted. There are also flush() and reload() signals, which | 461 | emitted. There are also flush() and reload() signals, which |
462 | are emitted when synching begins and ends respectively - upon these | 462 | are emitted when synching begins and ends respectively - upon these |
463 | signals, the application should save and reload any data | 463 | signals, the application should save and reload any data |
464 | files that are involved in synching. Most of these signals will initially | 464 | files that are involved in synching. Most of these signals will initially |
465 | be received and unfiltered through the appMessage() signal. | 465 | be received and unfiltered through the appMessage() signal. |
466 | 466 | ||
467 | This class also provides a set of useful static functions. The | 467 | This class also provides a set of useful static functions. The |
468 | qpeDir() and documentDir() functions return the respective paths. | 468 | qpeDir() and documentDir() functions return the respective paths. |
469 | The grabKeyboard() and ungrabKeyboard() functions are used to | 469 | The grabKeyboard() and ungrabKeyboard() functions are used to |
470 | control whether the application takes control of the device's | 470 | control whether the application takes control of the device's |
471 | physical buttons (e.g. application launch keys). The stylus' mode of | 471 | physical buttons (e.g. application launch keys). The stylus' mode of |
472 | operation is set with setStylusOperation() and retrieved with | 472 | operation is set with setStylusOperation() and retrieved with |
473 | stylusOperation(). There are also setInputMethodHint() and | 473 | stylusOperation(). There are also setInputMethodHint() and |
474 | inputMethodHint() functions. | 474 | inputMethodHint() functions. |
475 | 475 | ||
476 | \ingroup qtopiaemb | 476 | \ingroup qtopiaemb |
477 | */ | 477 | */ |
478 | 478 | ||
479 | /*! | 479 | /*! |
480 | \fn void QPEApplication::clientMoused() | 480 | \fn void QPEApplication::clientMoused() |
481 | 481 | ||
482 | \internal | 482 | \internal |
483 | */ | 483 | */ |
484 | 484 | ||
485 | /*! | 485 | /*! |
486 | \fn void QPEApplication::timeChanged(); | 486 | \fn void QPEApplication::timeChanged(); |
487 | This signal is emitted when the time changes outside the normal | 487 | This signal is emitted when the time changes outside the normal |
488 | passage of time, i.e. if the time is set backwards or forwards. | 488 | passage of time, i.e. if the time is set backwards or forwards. |
489 | */ | 489 | */ |
490 | 490 | ||
491 | /*! | 491 | /*! |
492 | \fn void QPEApplication::clockChanged( bool ampm ); | 492 | \fn void QPEApplication::clockChanged( bool ampm ); |
493 | 493 | ||
494 | This signal is emitted when the user changes the clock's style. If | 494 | This signal is emitted when the user changes the clock's style. If |
495 | \a ampm is TRUE, the user wants a 12-hour AM/PM clock, otherwise, | 495 | \a ampm is TRUE, the user wants a 12-hour AM/PM clock, otherwise, |
496 | they want a 24-hour clock. | 496 | they want a 24-hour clock. |
497 | */ | 497 | */ |
498 | 498 | ||
499 | /*! | 499 | /*! |
500 | \fn void QPEApplication::volumeChanged( bool muted ) | 500 | \fn void QPEApplication::volumeChanged( bool muted ) |
501 | 501 | ||
502 | This signal is emitted whenever the mute state is changed. If \a | 502 | This signal is emitted whenever the mute state is changed. If \a |
503 | muted is TRUE, then sound output has been muted. | 503 | muted is TRUE, then sound output has been muted. |
504 | */ | 504 | */ |
505 | 505 | ||
506 | /*! | 506 | /*! |
507 | \fn void QPEApplication::weekChanged( bool startOnMonday ) | 507 | \fn void QPEApplication::weekChanged( bool startOnMonday ) |
508 | 508 | ||
509 | This signal is emitted if the week start day is changed. If \a | 509 | This signal is emitted if the week start day is changed. If \a |
510 | startOnMonday is TRUE then the first day of the week is Monday; if | 510 | startOnMonday is TRUE then the first day of the week is Monday; if |
511 | \a startOnMonday is FALSE then the first day of the week is | 511 | \a startOnMonday is FALSE then the first day of the week is |
512 | Sunday. | 512 | Sunday. |
513 | */ | 513 | */ |
514 | 514 | ||
515 | /*! | 515 | /*! |
516 | \fn void QPEApplication::dateFormatChanged(DateFormat) | 516 | \fn void QPEApplication::dateFormatChanged(DateFormat) |
517 | 517 | ||
518 | This signal is emitted whenever the date format is changed. | 518 | This signal is emitted whenever the date format is changed. |
519 | */ | 519 | */ |
520 | 520 | ||
521 | /*! | 521 | /*! |
522 | \fn void QPEApplication::flush() | 522 | \fn void QPEApplication::flush() |
523 | 523 | ||
524 | ### | 524 | ### |
525 | */ | 525 | */ |
526 | 526 | ||
527 | /*! | 527 | /*! |
528 | \fn void QPEApplication::reload() | 528 | \fn void QPEApplication::reload() |
529 | 529 | ||
530 | */ | 530 | */ |
531 | 531 | ||
532 | 532 | ||
533 | 533 | ||
534 | void QPEApplication::processQCopFile() | 534 | void QPEApplication::processQCopFile() |
535 | { | 535 | { |
536 | QString qcopfn("/tmp/qcop-msg-"); | 536 | QString qcopfn("/tmp/qcop-msg-"); |
537 | qcopfn += d->appName; // append command name | 537 | qcopfn += d->appName; // append command name |
538 | 538 | ||
539 | QFile f(qcopfn); | 539 | QFile f(qcopfn); |
540 | if ( f.open(IO_ReadWrite) ) { | 540 | if ( f.open(IO_ReadWrite) ) { |
541 | #ifndef Q_OS_WIN32 | 541 | #ifndef Q_OS_WIN32 |
542 | flock(f.handle(), LOCK_EX); | 542 | flock(f.handle(), LOCK_EX); |
543 | #endif | 543 | #endif |
544 | QDataStream ds(&f); | 544 | QDataStream ds(&f); |
545 | QCString channel, message; | 545 | QCString channel, message; |
546 | QByteArray data; | 546 | QByteArray data; |
547 | while(!ds.atEnd()) { | 547 | while(!ds.atEnd()) { |
548 | ds >> channel >> message >> data; | 548 | ds >> channel >> message >> data; |
549 | d->enqueueQCop(channel,message,data); | 549 | d->enqueueQCop(channel,message,data); |
550 | } | 550 | } |
551 | ::ftruncate(f.handle(), 0); | 551 | ::ftruncate(f.handle(), 0); |
552 | #ifndef Q_OS_WIN32 | 552 | #ifndef Q_OS_WIN32 |
553 | f.flush(); | 553 | f.flush(); |
554 | flock(f.handle(), LOCK_UN); | 554 | flock(f.handle(), LOCK_UN); |
555 | #endif | 555 | #endif |
556 | } | 556 | } |
557 | #endif | 557 | #endif |
558 | } | 558 | } |
559 | 559 | ||
560 | 560 | ||
561 | /*! | 561 | /*! |
562 | \fn void QPEApplication::appMessage( const QCString& msg, const QByteArray& data ) | 562 | \fn void QPEApplication::appMessage( const QCString& msg, const QByteArray& data ) |
563 | 563 | ||
564 | This signal is emitted when a message is received on this | 564 | This signal is emitted when a message is received on this |
565 | application's QPE/Application/<i>appname</i> \link qcop.html | 565 | application's QPE/Application/<i>appname</i> \link qcop.html |
566 | QCop\endlink channel. | 566 | QCop\endlink channel. |
567 | 567 | ||
568 | The slot to which you connect this signal uses \a msg and \a data | 568 | The slot to which you connect this signal uses \a msg and \a data |
569 | in the following way: | 569 | in the following way: |
570 | 570 | ||
571 | \code | 571 | \code |
572 | void MyWidget::receive( const QCString& msg, const QByteArray& data ) | 572 | void MyWidget::receive( const QCString& msg, const QByteArray& data ) |
573 | { | 573 | { |
574 | QDataStream stream( data, IO_ReadOnly ); | 574 | QDataStream stream( data, IO_ReadOnly ); |
575 | if ( msg == "someMessage(int,int,int)" ) { | 575 | if ( msg == "someMessage(int,int,int)" ) { |
576 | int a,b,c; | 576 | int a,b,c; |
577 | stream >> a >> b >> c; | 577 | stream >> a >> b >> c; |
578 | ... | 578 | ... |
579 | } else if ( msg == "otherMessage(QString)" ) { | 579 | } else if ( msg == "otherMessage(QString)" ) { |
580 | ... | 580 | ... |
581 | } | 581 | } |
582 | } | 582 | } |
583 | \endcode | 583 | \endcode |
584 | 584 | ||
585 | \sa qcop.html | 585 | \sa qcop.html |
586 | Note that messages received here may be processed by qpe application | 586 | Note that messages received here may be processed by qpe application |
587 | and emitted as signals, such as flush() and reload(). | 587 | and emitted as signals, such as flush() and reload(). |
588 | */ | 588 | */ |
589 | 589 | ||
590 | /*! | 590 | /*! |
591 | Constructs a QPEApplication just as you would construct | 591 | Constructs a QPEApplication just as you would construct |
592 | a QApplication, passing \a argc, \a argv, and \a t. | 592 | a QApplication, passing \a argc, \a argv, and \a t. |
593 | 593 | ||
594 | For applications, \a t should be the default, GuiClient. Only | 594 | For applications, \a t should be the default, GuiClient. Only |
595 | the Qtopia server passes GuiServer. | 595 | the Qtopia server passes GuiServer. |
596 | */ | 596 | */ |
597 | QPEApplication::QPEApplication( int & argc, char **argv, Type t ) | 597 | QPEApplication::QPEApplication( int & argc, char **argv, Type t ) |
598 | : QApplication( hack(argc), argv, t ), pidChannel( 0 ) | 598 | : QApplication( hack(argc), argv, t ), pidChannel( 0 ) |
599 | { | 599 | { |
600 | QPixmapCache::setCacheLimit(256); // sensible default for smaller devices. | 600 | QPixmapCache::setCacheLimit(256); // sensible default for smaller devices. |
601 | 601 | ||
602 | d = new QPEApplicationData; | 602 | d = new QPEApplicationData; |
603 | d->loadTextCodecs(); | 603 | d->loadTextCodecs(); |
604 | d->loadImageCodecs(); | 604 | d->loadImageCodecs(); |
605 | int dw = desktop() ->width(); | 605 | int dw = desktop() ->width(); |
606 | 606 | ||
607 | if ( dw < 200 ) { | 607 | if ( dw < 200 ) { |
608 | setFont( QFont( "vera", 8 ) ); | 608 | setFont( QFont( "vera", 8 ) ); |
609 | AppLnk::setSmallIconSize( 10 ); | 609 | AppLnk::setSmallIconSize( 10 ); |
610 | AppLnk::setBigIconSize( 28 ); | 610 | AppLnk::setBigIconSize( 28 ); |
611 | } | 611 | } |
612 | #if defined(OPIE_HIGH_RES_SMALL_PHY) | 612 | #if defined(OPIE_HIGH_RES_SMALL_PHY) |
613 | else if ( dw > 600 ) { | 613 | else if ( dw > 600 ) { |
614 | setFont( QFont( "vera", 16 ) ); | 614 | setFont( QFont( "vera", 16 ) ); |
615 | AppLnk::setSmallIconSize( 24 ); | 615 | AppLnk::setSmallIconSize( 24 ); |
616 | AppLnk::setBigIconSize( 48 ); | 616 | AppLnk::setBigIconSize( 48 ); |
617 | } | 617 | } |
618 | #endif | 618 | #endif |
619 | else if ( dw > 200 ) { | 619 | else if ( dw > 200 ) { |
620 | setFont( QFont( "vera", 10 ) ); | 620 | setFont( QFont( "vera", 10 ) ); |
621 | AppLnk::setSmallIconSize( 14 ); | 621 | AppLnk::setSmallIconSize( 14 ); |
622 | AppLnk::setBigIconSize( 32 ); | 622 | AppLnk::setBigIconSize( 32 ); |
623 | } | 623 | } |
624 | 624 | ||
625 | QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory ); | 625 | QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory ); |
626 | 626 | ||
627 | connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) ); | 627 | connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) ); |
628 | 628 | ||
629 | 629 | ||
630 | sysChannel = new QCopChannel( "QPE/System", this ); | 630 | sysChannel = new QCopChannel( "QPE/System", this ); |
631 | connect( sysChannel, SIGNAL( received( const QCString &, const QByteArray & ) ), | 631 | connect( sysChannel, SIGNAL( received(const QCString&,const QByteArray&) ), |
632 | this, SLOT( systemMessage( const QCString &, const QByteArray & ) ) ); | 632 | this, SLOT( systemMessage(const QCString&,const QByteArray&) ) ); |
633 | 633 | ||
634 | /* COde now in initapp */ | 634 | /* COde now in initapp */ |
635 | #if 0 | 635 | #if 0 |
636 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 636 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
637 | 637 | ||
638 | QString qcopfn( "/tmp/qcop-msg-" ); | 638 | QString qcopfn( "/tmp/qcop-msg-" ); |
639 | qcopfn += QString( argv[ 0 ] ); // append command name | 639 | qcopfn += QString( argv[ 0 ] ); // append command name |
640 | 640 | ||
641 | QFile f( qcopfn ); | 641 | QFile f( qcopfn ); |
642 | if ( f.open( IO_ReadOnly ) ) { | 642 | if ( f.open( IO_ReadOnly ) ) { |
643 | flock( f.handle(), LOCK_EX ); | 643 | flock( f.handle(), LOCK_EX ); |
644 | } | 644 | } |
645 | 645 | ||
646 | 646 | ||
647 | 647 | ||
648 | QCString channel = QCString( argv[ 0 ] ); | 648 | QCString channel = QCString( argv[ 0 ] ); |
649 | channel.replace( QRegExp( ".*/" ), "" ); | 649 | channel.replace( QRegExp( ".*/" ), "" ); |
650 | d->appName = channel; | 650 | d->appName = channel; |
651 | channel = "QPE/Application/" + channel; | 651 | channel = "QPE/Application/" + channel; |
652 | pidChannel = new QCopChannel( channel, this ); | 652 | pidChannel = new QCopChannel( channel, this ); |
653 | connect( pidChannel, SIGNAL( received( const QCString &, const QByteArray & ) ), | 653 | connect( pidChannel, SIGNAL( received(const QCString&,const QByteArray&) ), |
654 | this, SLOT( pidMessage( const QCString &, const QByteArray & ) ) ); | 654 | this, SLOT( pidMessage(const QCString&,const QByteArray&) ) ); |
655 | 655 | ||
656 | if ( f.isOpen() ) { | 656 | if ( f.isOpen() ) { |
657 | d->keep_running = FALSE; | 657 | d->keep_running = FALSE; |
658 | QDataStream ds( &f ); | 658 | QDataStream ds( &f ); |
659 | QCString channel, message; | 659 | QCString channel, message; |
660 | QByteArray data; | 660 | QByteArray data; |
661 | while ( !ds.atEnd() ) { | 661 | while ( !ds.atEnd() ) { |
662 | ds >> channel >> message >> data; | 662 | ds >> channel >> message >> data; |
663 | d->enqueueQCop( channel, message, data ); | 663 | d->enqueueQCop( channel, message, data ); |
664 | } | 664 | } |
665 | 665 | ||
666 | flock( f.handle(), LOCK_UN ); | 666 | flock( f.handle(), LOCK_UN ); |
667 | f.close(); | 667 | f.close(); |
668 | f.remove(); | 668 | f.remove(); |
669 | } | 669 | } |
670 | 670 | ||
671 | for ( int a = 0; a < argc; a++ ) { | 671 | for ( int a = 0; a < argc; a++ ) { |
672 | if ( qstrcmp( argv[ a ], "-preload" ) == 0 ) { | 672 | if ( qstrcmp( argv[ a ], "-preload" ) == 0 ) { |
673 | argv[ a ] = argv[ a + 1 ]; | 673 | argv[ a ] = argv[ a + 1 ]; |
674 | a++; | 674 | a++; |
675 | d->preloaded = TRUE; | 675 | d->preloaded = TRUE; |
676 | argc -= 1; | 676 | argc -= 1; |
677 | } | 677 | } |
678 | else if ( qstrcmp( argv[ a ], "-preload-show" ) == 0 ) { | 678 | else if ( qstrcmp( argv[ a ], "-preload-show" ) == 0 ) { |
679 | argv[ a ] = argv[ a + 1 ]; | 679 | argv[ a ] = argv[ a + 1 ]; |
680 | a++; | 680 | a++; |
681 | d->preloaded = TRUE; | 681 | d->preloaded = TRUE; |
682 | d->forceshow = TRUE; | 682 | d->forceshow = TRUE; |
683 | argc -= 1; | 683 | argc -= 1; |
684 | } | 684 | } |
685 | } | 685 | } |
686 | 686 | ||
687 | /* overide stored arguments */ | 687 | /* overide stored arguments */ |
688 | setArgs( argc, argv ); | 688 | setArgs( argc, argv ); |
689 | 689 | ||
690 | #endif | 690 | #endif |
691 | #else | 691 | #else |
692 | initApp( argc, argv ); | 692 | initApp( argc, argv ); |
693 | #endif | 693 | #endif |
694 | // qwsSetDecoration( new QPEDecoration() ); | 694 | // qwsSetDecoration( new QPEDecoration() ); |
695 | 695 | ||
696 | #ifndef QT_NO_TRANSLATION | 696 | #ifndef QT_NO_TRANSLATION |
697 | 697 | ||
698 | d->langs = Global::languageList(); | 698 | d->langs = Global::languageList(); |
699 | for ( QStringList::ConstIterator it = d->langs.begin(); it != d->langs.end(); ++it ) { | 699 | for ( QStringList::ConstIterator it = d->langs.begin(); it != d->langs.end(); ++it ) { |
700 | QString lang = *it; | 700 | QString lang = *it; |
701 | 701 | ||
702 | installTranslation( lang + "/libopie.qm"); | 702 | installTranslation( lang + "/libopie.qm"); |
703 | installTranslation( lang + "/libqpe.qm" ); | 703 | installTranslation( lang + "/libqpe.qm" ); |
704 | installTranslation( lang + "/" + d->appName + ".qm" ); | 704 | installTranslation( lang + "/" + d->appName + ".qm" ); |
705 | 705 | ||
706 | 706 | ||
707 | //###language/font hack; should look it up somewhere | 707 | //###language/font hack; should look it up somewhere |
708 | #ifdef QWS | 708 | #ifdef QWS |
709 | 709 | ||
710 | if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) { | 710 | if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) { |
711 | QFont fn = FontManager::unicodeFont( FontManager::Proportional ); | 711 | QFont fn = FontManager::unicodeFont( FontManager::Proportional ); |
712 | setFont( fn ); | 712 | setFont( fn ); |
713 | } | 713 | } |
714 | #endif | 714 | #endif |
715 | } | 715 | } |
716 | #endif | 716 | #endif |
717 | 717 | ||
718 | applyStyle(); | 718 | applyStyle(); |
719 | 719 | ||
720 | if ( type() == GuiServer ) { | 720 | if ( type() == GuiServer ) { |
721 | setVolume(); | 721 | setVolume(); |
722 | } | 722 | } |
723 | 723 | ||
724 | installEventFilter( this ); | 724 | installEventFilter( this ); |
725 | 725 | ||
726 | QPEMenuToolFocusManager::initialize(); | 726 | QPEMenuToolFocusManager::initialize(); |
727 | 727 | ||
728 | #ifdef QT_NO_QWS_CURSOR | 728 | #ifdef QT_NO_QWS_CURSOR |
729 | // if we have no cursor, probably don't want tooltips | 729 | // if we have no cursor, probably don't want tooltips |
730 | QToolTip::setEnabled( FALSE ); | 730 | QToolTip::setEnabled( FALSE ); |
731 | #endif | 731 | #endif |
732 | } | 732 | } |
733 | 733 | ||
734 | 734 | ||
735 | #ifdef QTOPIA_INTERNAL_INITAPP | 735 | #ifdef QTOPIA_INTERNAL_INITAPP |
736 | void QPEApplication::initApp( int argc, char **argv ) | 736 | void QPEApplication::initApp( int argc, char **argv ) |
737 | { | 737 | { |
738 | delete pidChannel; | 738 | delete pidChannel; |
739 | d->keep_running = TRUE; | 739 | d->keep_running = TRUE; |
740 | d->preloaded = FALSE; | 740 | d->preloaded = FALSE; |
741 | d->forceshow = FALSE; | 741 | d->forceshow = FALSE; |
742 | 742 | ||
743 | QCString channel = QCString(argv[0]); | 743 | QCString channel = QCString(argv[0]); |
744 | 744 | ||
745 | channel.replace(QRegExp(".*/"),""); | 745 | channel.replace(QRegExp(".*/"),""); |
746 | d->appName = channel; | 746 | d->appName = channel; |
747 | 747 | ||
748 | #if QT_VERSION > 235 | 748 | #if QT_VERSION > 235 |
749 | qt_fbdpy->setIdentity( channel ); // In Qt/E 2.3.6 | 749 | qt_fbdpy->setIdentity( channel ); // In Qt/E 2.3.6 |
750 | #endif | 750 | #endif |
751 | 751 | ||
752 | channel = "QPE/Application/" + channel; | 752 | channel = "QPE/Application/" + channel; |
753 | pidChannel = new QCopChannel( channel, this); | 753 | pidChannel = new QCopChannel( channel, this); |
754 | connect( pidChannel, SIGNAL(received(const QCString &, const QByteArray &)), | 754 | connect( pidChannel, SIGNAL(received(const QCString&,const QByteArray&)), |
755 | this, SLOT(pidMessage(const QCString &, const QByteArray &))); | 755 | this, SLOT(pidMessage(const QCString&,const QByteArray&))); |
756 | 756 | ||
757 | 757 | ||
758 | 758 | ||
759 | processQCopFile(); | 759 | processQCopFile(); |
760 | d->keep_running = d->qcopq.isEmpty(); | 760 | d->keep_running = d->qcopq.isEmpty(); |
761 | 761 | ||
762 | for (int a=0; a<argc; a++) { | 762 | for (int a=0; a<argc; a++) { |
763 | if ( qstrcmp(argv[a],"-preload")==0 ) { | 763 | if ( qstrcmp(argv[a],"-preload")==0 ) { |
764 | argv[a] = argv[a+1]; | 764 | argv[a] = argv[a+1]; |
765 | a++; | 765 | a++; |
766 | d->preloaded = TRUE; | 766 | d->preloaded = TRUE; |
767 | argc-=1; | 767 | argc-=1; |
768 | } else if ( qstrcmp(argv[a],"-preload-show")==0 ) { | 768 | } else if ( qstrcmp(argv[a],"-preload-show")==0 ) { |
769 | argv[a] = argv[a+1]; | 769 | argv[a] = argv[a+1]; |
770 | a++; | 770 | a++; |
771 | d->preloaded = TRUE; | 771 | d->preloaded = TRUE; |
772 | d->forceshow = TRUE; | 772 | d->forceshow = TRUE; |
773 | argc-=1; | 773 | argc-=1; |
774 | } | 774 | } |
775 | } | 775 | } |
776 | 776 | ||
777 | /* overide stored arguments */ | 777 | /* overide stored arguments */ |
778 | setArgs(argc, argv); | 778 | setArgs(argc, argv); |
779 | 779 | ||
780 | /* install translation here */ | 780 | /* install translation here */ |
781 | for ( QStringList::ConstIterator it = d->langs.begin(); it != d->langs.end(); ++it ) | 781 | for ( QStringList::ConstIterator it = d->langs.begin(); it != d->langs.end(); ++it ) |
782 | installTranslation( (*it) + "/" + d->appName + ".qm" ); | 782 | installTranslation( (*it) + "/" + d->appName + ".qm" ); |
783 | } | 783 | } |
784 | #endif | 784 | #endif |
785 | 785 | ||
786 | 786 | ||
787 | static QPtrDict<void>* inputMethodDict = 0; | 787 | static QPtrDict<void>* inputMethodDict = 0; |
788 | static void createInputMethodDict() | 788 | static void createInputMethodDict() |
789 | { | 789 | { |
790 | if ( !inputMethodDict ) | 790 | if ( !inputMethodDict ) |
791 | inputMethodDict = new QPtrDict<void>; | 791 | inputMethodDict = new QPtrDict<void>; |
792 | } | 792 | } |
793 | 793 | ||
794 | /*! | 794 | /*! |
795 | Returns the currently set hint to the system as to whether | 795 | Returns the currently set hint to the system as to whether |
796 | widget \a w has any use for text input methods. | 796 | widget \a w has any use for text input methods. |
797 | 797 | ||
798 | 798 | ||
799 | \sa setInputMethodHint() InputMethodHint | 799 | \sa setInputMethodHint() InputMethodHint |
800 | */ | 800 | */ |
801 | QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w ) | 801 | QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w ) |
802 | { | 802 | { |
803 | if ( inputMethodDict && w ) | 803 | if ( inputMethodDict && w ) |
804 | return ( InputMethodHint ) ( int ) inputMethodDict->find( w ); | 804 | return ( InputMethodHint ) ( int ) inputMethodDict->find( w ); |
805 | return Normal; | 805 | return Normal; |
806 | } | 806 | } |
807 | 807 | ||
808 | /*! | 808 | /*! |
809 | \enum QPEApplication::InputMethodHint | 809 | \enum QPEApplication::InputMethodHint |
810 | 810 | ||
811 | \value Normal the application sometimes needs text input (the default). | 811 | \value Normal the application sometimes needs text input (the default). |
812 | \value AlwaysOff the application never needs text input. | 812 | \value AlwaysOff the application never needs text input. |
813 | \value AlwaysOn the application always needs text input. | 813 | \value AlwaysOn the application always needs text input. |
814 | */ | 814 | */ |
815 | 815 | ||
816 | /*! | 816 | /*! |
817 | Hints to the system that widget \a w has use for text input methods | 817 | Hints to the system that widget \a w has use for text input methods |
818 | as specified by \a mode. | 818 | as specified by \a mode. |
819 | 819 | ||
820 | \sa inputMethodHint() InputMethodHint | 820 | \sa inputMethodHint() InputMethodHint |
821 | */ | 821 | */ |
822 | void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode ) | 822 | void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode ) |
823 | { | 823 | { |
824 | createInputMethodDict(); | 824 | createInputMethodDict(); |
825 | if ( mode == Normal ) { | 825 | if ( mode == Normal ) { |
826 | inputMethodDict->remove | 826 | inputMethodDict->remove |
827 | ( w ); | 827 | ( w ); |
828 | } | 828 | } |
829 | else { | 829 | else { |
830 | inputMethodDict->insert( w, ( void* ) mode ); | 830 | inputMethodDict->insert( w, ( void* ) mode ); |
831 | } | 831 | } |
832 | } | 832 | } |
833 | 833 | ||
834 | class HackDialog : public QDialog | 834 | class HackDialog : public QDialog |
835 | { | 835 | { |
836 | public: | 836 | public: |
837 | void acceptIt() | 837 | void acceptIt() |
838 | { | 838 | { |
839 | accept(); | 839 | accept(); |
840 | } | 840 | } |
841 | void rejectIt() | 841 | void rejectIt() |
842 | { | 842 | { |
843 | reject(); | 843 | reject(); |
844 | } | 844 | } |
845 | }; | 845 | }; |
846 | 846 | ||
847 | 847 | ||
848 | void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key ) | 848 | void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key ) |
849 | { | 849 | { |
850 | // specialised actions for certain widgets. May want to | 850 | // specialised actions for certain widgets. May want to |
851 | // add more stuff here. | 851 | // add more stuff here. |
852 | if ( activePopupWidget() && activePopupWidget() ->inherits( "QListBox" ) | 852 | if ( activePopupWidget() && activePopupWidget() ->inherits( "QListBox" ) |
853 | && activePopupWidget() ->parentWidget() | 853 | && activePopupWidget() ->parentWidget() |
854 | && activePopupWidget() ->parentWidget() ->inherits( "QComboBox" ) ) | 854 | && activePopupWidget() ->parentWidget() ->inherits( "QComboBox" ) ) |
855 | key = Qt::Key_Return; | 855 | key = Qt::Key_Return; |
856 | 856 | ||
857 | if ( activePopupWidget() && activePopupWidget() ->inherits( "QPopupMenu" ) ) | 857 | if ( activePopupWidget() && activePopupWidget() ->inherits( "QPopupMenu" ) ) |
858 | key = Qt::Key_Return; | 858 | key = Qt::Key_Return; |
859 | 859 | ||
860 | #ifdef QWS | 860 | #ifdef QWS |
861 | 861 | ||
862 | ke->simpleData.keycode = key; | 862 | ke->simpleData.keycode = key; |
863 | #endif | 863 | #endif |
864 | } | 864 | } |
865 | 865 | ||
866 | class HackWidget : public QWidget | 866 | class HackWidget : public QWidget |
867 | { | 867 | { |
868 | public: | 868 | public: |
869 | bool needsOk() | 869 | bool needsOk() |
870 | { | 870 | { |
871 | return ( getWState() & WState_Reserved1 ); | 871 | return ( getWState() & WState_Reserved1 ); |
872 | } | 872 | } |
873 | }; | 873 | }; |
874 | 874 | ||
875 | /*! | 875 | /*! |
876 | \internal | 876 | \internal |
877 | */ | 877 | */ |
878 | 878 | ||
879 | #ifdef QWS | 879 | #ifdef QWS |
880 | bool QPEApplication::qwsEventFilter( QWSEvent * e ) | 880 | bool QPEApplication::qwsEventFilter( QWSEvent * e ) |
881 | { | 881 | { |
882 | if ( !d->notbusysent && e->type == QWSEvent::Focus ) { | 882 | if ( !d->notbusysent && e->type == QWSEvent::Focus ) { |
883 | if ( qApp->type() != QApplication::GuiServer ) { | 883 | if ( qApp->type() != QApplication::GuiServer ) { |
884 | QCopEnvelope e( "QPE/System", "notBusy(QString)" ); | 884 | QCopEnvelope e( "QPE/System", "notBusy(QString)" ); |
885 | e << d->appName; | 885 | e << d->appName; |
886 | } | 886 | } |
887 | d->notbusysent = TRUE; | 887 | d->notbusysent = TRUE; |
888 | } | 888 | } |
889 | if ( type() == GuiServer ) { | 889 | if ( type() == GuiServer ) { |
890 | switch ( e->type ) { | 890 | switch ( e->type ) { |
891 | case QWSEvent::Mouse: | 891 | case QWSEvent::Mouse: |
892 | if ( e->asMouse() ->simpleData.state && !QWidget::find( e->window() ) ) | 892 | if ( e->asMouse() ->simpleData.state && !QWidget::find( e->window() ) ) |
893 | emit clientMoused(); | 893 | emit clientMoused(); |
894 | break; | 894 | break; |
895 | default: | 895 | default: |
896 | break; | 896 | break; |
897 | } | 897 | } |
898 | } | 898 | } |
899 | if ( e->type == QWSEvent::Key ) { | 899 | if ( e->type == QWSEvent::Key ) { |
900 | QWSKeyEvent *ke = ( QWSKeyEvent * ) e; | 900 | QWSKeyEvent *ke = ( QWSKeyEvent * ) e; |
901 | if ( ke->simpleData.keycode == Qt::Key_F33 ) { | 901 | if ( ke->simpleData.keycode == Qt::Key_F33 ) { |
902 | // Use special "OK" key to press "OK" on top level widgets | 902 | // Use special "OK" key to press "OK" on top level widgets |
903 | QWidget * active = activeWindow(); | 903 | QWidget * active = activeWindow(); |
904 | QWidget *popup = 0; | 904 | QWidget *popup = 0; |
905 | if ( active && active->isPopup() ) { | 905 | if ( active && active->isPopup() ) { |
906 | popup = active; | 906 | popup = active; |
907 | active = active->parentWidget(); | 907 | active = active->parentWidget(); |
908 | } | 908 | } |
909 | if ( active && ( int ) active->winId() == ke->simpleData.window && | 909 | if ( active && ( int ) active->winId() == ke->simpleData.window && |
910 | !active->testWFlags( WStyle_Customize | WType_Popup | WType_Desktop ) ) { | 910 | !active->testWFlags( WStyle_Customize | WType_Popup | WType_Desktop ) ) { |
911 | if ( ke->simpleData.is_press ) { | 911 | if ( ke->simpleData.is_press ) { |
912 | if ( popup ) | 912 | if ( popup ) |
913 | popup->close(); | 913 | popup->close(); |
914 | if ( active->inherits( "QDialog" ) ) { | 914 | if ( active->inherits( "QDialog" ) ) { |
915 | HackDialog * d = ( HackDialog * ) active; | 915 | HackDialog * d = ( HackDialog * ) active; |
916 | d->acceptIt(); | 916 | d->acceptIt(); |
917 | return TRUE; | 917 | return TRUE; |
918 | } | 918 | } |
919 | else if ( ( ( HackWidget * ) active ) ->needsOk() ) { | 919 | else if ( ( ( HackWidget * ) active ) ->needsOk() ) { |
920 | QSignal s; | 920 | QSignal s; |
921 | s.connect( active, SLOT( accept() ) ); | 921 | s.connect( active, SLOT( accept() ) ); |
922 | s.activate(); | 922 | s.activate(); |
923 | } | 923 | } |
924 | else { | 924 | else { |
925 | // do the same as with the select key: Map to the default action of the widget: | 925 | // do the same as with the select key: Map to the default action of the widget: |
926 | mapToDefaultAction( ke, Qt::Key_Return ); | 926 | mapToDefaultAction( ke, Qt::Key_Return ); |
927 | } | 927 | } |
928 | } | 928 | } |
929 | } | 929 | } |
930 | } | 930 | } |
931 | else if ( ke->simpleData.keycode == Qt::Key_F30 ) { | 931 | else if ( ke->simpleData.keycode == Qt::Key_F30 ) { |
932 | // Use special "select" key to do whatever default action a widget has | 932 | // Use special "select" key to do whatever default action a widget has |
933 | mapToDefaultAction( ke, Qt::Key_Space ); | 933 | mapToDefaultAction( ke, Qt::Key_Space ); |
934 | } | 934 | } |
935 | else if ( ke->simpleData.keycode == Qt::Key_Escape && | 935 | else if ( ke->simpleData.keycode == Qt::Key_Escape && |
936 | ke->simpleData.is_press ) { | 936 | ke->simpleData.is_press ) { |
937 | // Escape key closes app if focus on toplevel | 937 | // Escape key closes app if focus on toplevel |
938 | QWidget * active = activeWindow(); | 938 | QWidget * active = activeWindow(); |
939 | if ( active && active->testWFlags( WType_TopLevel ) && | 939 | if ( active && active->testWFlags( WType_TopLevel ) && |
940 | ( int ) active->winId() == ke->simpleData.window && | 940 | ( int ) active->winId() == ke->simpleData.window && |
941 | !active->testWFlags( WStyle_Dialog | WStyle_Customize | WType_Popup | WType_Desktop ) ) { | 941 | !active->testWFlags( WStyle_Dialog | WStyle_Customize | WType_Popup | WType_Desktop ) ) { |
942 | if ( active->inherits( "QDialog" ) ) { | 942 | if ( active->inherits( "QDialog" ) ) { |
943 | HackDialog * d = ( HackDialog * ) active; | 943 | HackDialog * d = ( HackDialog * ) active; |
944 | d->rejectIt(); | 944 | d->rejectIt(); |
945 | return TRUE; | 945 | return TRUE; |
946 | } | 946 | } |
947 | else if ( strcmp( argv() [ 0 ], "embeddedkonsole" ) != 0 ) { | 947 | else if ( strcmp( argv() [ 0 ], "embeddedkonsole" ) != 0 ) { |