summaryrefslogtreecommitdiff
path: root/library
authorzecke <zecke>2004-06-27 19:36:48 (UTC)
committer zecke <zecke>2004-06-27 19:36:48 (UTC)
commit78cd13f15c6057e18b6f095841a90bb438dd6fd2 (patch) (unidiff)
tree08376c584867032bc4fa5725467d46615b02e700 /library
parent0ef75ca5409d290df36d1c0bbf0413e37bfd4124 (diff)
downloadopie-78cd13f15c6057e18b6f095841a90bb438dd6fd2.zip
opie-78cd13f15c6057e18b6f095841a90bb438dd6fd2.tar.gz
opie-78cd13f15c6057e18b6f095841a90bb438dd6fd2.tar.bz2
Safe eilers some time for weak symbols on MacOS X
Diffstat (limited to 'library') (more/less context) (ignore whitespace changes)
-rw-r--r--library/qpeapplication.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp
index 4bc0c5f..b686e2e 100644
--- a/library/qpeapplication.cpp
+++ b/library/qpeapplication.cpp
@@ -548,1537 +548,1543 @@ static void setVolume( int t = 0, int percent = -1 )
548{ 548{
549 switch ( t ) { 549 switch ( t ) {
550 case 0: { 550 case 0: {
551 Config cfg( "qpe" ); 551 Config cfg( "qpe" );
552 cfg.setGroup( "Volume" ); 552 cfg.setGroup( "Volume" );
553 if ( percent < 0 ) 553 if ( percent < 0 )
554 percent = cfg.readNumEntry( "VolumePercent", 50 ); 554 percent = cfg.readNumEntry( "VolumePercent", 50 );
555#ifndef QT_NO_SOUND 555#ifndef QT_NO_SOUND
556 int fd = 0; 556 int fd = 0;
557 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { 557 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) {
558 int vol = muted ? 0 : percent; 558 int vol = muted ? 0 : percent;
559 // set both channels to same volume 559 // set both channels to same volume
560 vol |= vol << 8; 560 vol |= vol << 8;
561 ioctl( fd, MIXER_WRITE( SOUND_MIXER_VOLUME ), &vol ); 561 ioctl( fd, MIXER_WRITE( SOUND_MIXER_VOLUME ), &vol );
562 ::close( fd ); 562 ::close( fd );
563 } 563 }
564#endif 564#endif
565 } 565 }
566 break; 566 break;
567 } 567 }
568} 568}
569 569
570static void setMic( int t = 0, int percent = -1 ) 570static void setMic( int t = 0, int percent = -1 )
571{ 571{
572 switch ( t ) { 572 switch ( t ) {
573 case 0: { 573 case 0: {
574 Config cfg( "qpe" ); 574 Config cfg( "qpe" );
575 cfg.setGroup( "Volume" ); 575 cfg.setGroup( "Volume" );
576 if ( percent < 0 ) 576 if ( percent < 0 )
577 percent = cfg.readNumEntry( "Mic", 50 ); 577 percent = cfg.readNumEntry( "Mic", 50 );
578 578
579#ifndef QT_NO_SOUND 579#ifndef QT_NO_SOUND
580 int fd = 0; 580 int fd = 0;
581 int mic = micMuted ? 0 : percent; 581 int mic = micMuted ? 0 : percent;
582 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { 582 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) {
583 ioctl( fd, MIXER_WRITE( SOUND_MIXER_MIC ), &mic ); 583 ioctl( fd, MIXER_WRITE( SOUND_MIXER_MIC ), &mic );
584 ::close( fd ); 584 ::close( fd );
585 } 585 }
586#endif 586#endif
587 } 587 }
588 break; 588 break;
589 } 589 }
590} 590}
591 591
592 592
593static void setBass( int t = 0, int percent = -1 ) 593static void setBass( int t = 0, int percent = -1 )
594{ 594{
595 switch ( t ) { 595 switch ( t ) {
596 case 0: { 596 case 0: {
597 Config cfg( "qpe" ); 597 Config cfg( "qpe" );
598 cfg.setGroup( "Volume" ); 598 cfg.setGroup( "Volume" );
599 if ( percent < 0 ) 599 if ( percent < 0 )
600 percent = cfg.readNumEntry( "BassPercent", 50 ); 600 percent = cfg.readNumEntry( "BassPercent", 50 );
601 601
602#ifndef QT_NO_SOUND 602#ifndef QT_NO_SOUND
603 int fd = 0; 603 int fd = 0;
604 int bass = percent; 604 int bass = percent;
605 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { 605 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) {
606 ioctl( fd, MIXER_WRITE( SOUND_MIXER_BASS ), &bass ); 606 ioctl( fd, MIXER_WRITE( SOUND_MIXER_BASS ), &bass );
607 ::close( fd ); 607 ::close( fd );
608 } 608 }
609#endif 609#endif
610 } 610 }
611 break; 611 break;
612 } 612 }
613} 613}
614 614
615 615
616static void setTreble( int t = 0, int percent = -1 ) 616static void setTreble( int t = 0, int percent = -1 )
617{ 617{
618 switch ( t ) { 618 switch ( t ) {
619 case 0: { 619 case 0: {
620 Config cfg( "qpe" ); 620 Config cfg( "qpe" );
621 cfg.setGroup( "Volume" ); 621 cfg.setGroup( "Volume" );
622 if ( percent < 0 ) 622 if ( percent < 0 )
623 percent = cfg.readNumEntry( "TreblePercent", 50 ); 623 percent = cfg.readNumEntry( "TreblePercent", 50 );
624 624
625#ifndef QT_NO_SOUND 625#ifndef QT_NO_SOUND
626 int fd = 0; 626 int fd = 0;
627 int treble = percent; 627 int treble = percent;
628 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { 628 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) {
629 ioctl( fd, MIXER_WRITE( SOUND_MIXER_TREBLE ), &treble ); 629 ioctl( fd, MIXER_WRITE( SOUND_MIXER_TREBLE ), &treble );
630 ::close( fd ); 630 ::close( fd );
631 } 631 }
632#endif 632#endif
633 } 633 }
634 break; 634 break;
635 } 635 }
636} 636}
637 637
638 638
639/** 639/**
640 \class QPEApplication 640 \class QPEApplication
641 \brief The QPEApplication class implements various system services 641 \brief The QPEApplication class implements various system services
642 that are available to all Qtopia applications. 642 that are available to all Qtopia applications.
643 643
644 Simply by using QPEApplication instead of QApplication, a standard Qt 644 Simply by using QPEApplication instead of QApplication, a standard Qt
645 application becomes a Qtopia application. It automatically follows 645 application becomes a Qtopia application. It automatically follows
646 style changes, quits and raises, and in the 646 style changes, quits and raises, and in the
647 case of \link docwidget.html document-oriented\endlink applications, 647 case of \link docwidget.html document-oriented\endlink applications,
648 changes the currently displayed document in response to the environment. 648 changes the currently displayed document in response to the environment.
649 649
650 To create a \link docwidget.html document-oriented\endlink 650 To create a \link docwidget.html document-oriented\endlink
651 application use showMainDocumentWidget(); to create a 651 application use showMainDocumentWidget(); to create a
652 non-document-oriented application use showMainWidget(). The 652 non-document-oriented application use showMainWidget(). The
653 keepRunning() function indicates whether the application will 653 keepRunning() function indicates whether the application will
654 continue running after it's processed the last \link qcop.html 654 continue running after it's processed the last \link qcop.html
655 QCop\endlink message. This can be changed using setKeepRunning(). 655 QCop\endlink message. This can be changed using setKeepRunning().
656 656
657 A variety of signals are emitted when certain events occur, for 657 A variety of signals are emitted when certain events occur, for
658 example, timeChanged(), clockChanged(), weekChanged(), 658 example, timeChanged(), clockChanged(), weekChanged(),
659 dateFormatChanged() and volumeChanged(). If the application receives 659 dateFormatChanged() and volumeChanged(). If the application receives
660 a \link qcop.html QCop\endlink message on the application's 660 a \link qcop.html QCop\endlink message on the application's
661 QPE/Application/\e{appname} channel, the appMessage() signal is 661 QPE/Application/\e{appname} channel, the appMessage() signal is
662 emitted. There are also flush() and reload() signals, which 662 emitted. There are also flush() and reload() signals, which
663 are emitted when synching begins and ends respectively - upon these 663 are emitted when synching begins and ends respectively - upon these
664 signals, the application should save and reload any data 664 signals, the application should save and reload any data
665 files that are involved in synching. Most of these signals will initially 665 files that are involved in synching. Most of these signals will initially
666 be received and unfiltered through the appMessage() signal. 666 be received and unfiltered through the appMessage() signal.
667 667
668 This class also provides a set of useful static functions. The 668 This class also provides a set of useful static functions. The
669 qpeDir() and documentDir() functions return the respective paths. 669 qpeDir() and documentDir() functions return the respective paths.
670 The grabKeyboard() and ungrabKeyboard() functions are used to 670 The grabKeyboard() and ungrabKeyboard() functions are used to
671 control whether the application takes control of the device's 671 control whether the application takes control of the device's
672 physical buttons (e.g. application launch keys). The stylus' mode of 672 physical buttons (e.g. application launch keys). The stylus' mode of
673 operation is set with setStylusOperation() and retrieved with 673 operation is set with setStylusOperation() and retrieved with
674 stylusOperation(). There are also setInputMethodHint() and 674 stylusOperation(). There are also setInputMethodHint() and
675 inputMethodHint() functions. 675 inputMethodHint() functions.
676 676
677 \ingroup qtopiaemb 677 \ingroup qtopiaemb
678*/ 678*/
679 679
680/*! 680/*!
681 \fn void QPEApplication::clientMoused() 681 \fn void QPEApplication::clientMoused()
682 682
683 \internal 683 \internal
684*/ 684*/
685 685
686/*! 686/*!
687 \fn void QPEApplication::timeChanged(); 687 \fn void QPEApplication::timeChanged();
688 This signal is emitted when the time changes outside the normal 688 This signal is emitted when the time changes outside the normal
689 passage of time, i.e. if the time is set backwards or forwards. 689 passage of time, i.e. if the time is set backwards or forwards.
690*/ 690*/
691 691
692/*! 692/*!
693 \fn void QPEApplication::clockChanged( bool ampm ); 693 \fn void QPEApplication::clockChanged( bool ampm );
694 694
695 This signal is emitted when the user changes the clock's style. If 695 This signal is emitted when the user changes the clock's style. If
696 \a ampm is TRUE, the user wants a 12-hour AM/PM clock, otherwise, 696 \a ampm is TRUE, the user wants a 12-hour AM/PM clock, otherwise,
697 they want a 24-hour clock. 697 they want a 24-hour clock.
698*/ 698*/
699 699
700/*! 700/*!
701 \fn void QPEApplication::volumeChanged( bool muted ) 701 \fn void QPEApplication::volumeChanged( bool muted )
702 702
703 This signal is emitted whenever the mute state is changed. If \a 703 This signal is emitted whenever the mute state is changed. If \a
704 muted is TRUE, then sound output has been muted. 704 muted is TRUE, then sound output has been muted.
705*/ 705*/
706 706
707/*! 707/*!
708 \fn void QPEApplication::weekChanged( bool startOnMonday ) 708 \fn void QPEApplication::weekChanged( bool startOnMonday )
709 709
710 This signal is emitted if the week start day is changed. If \a 710 This signal is emitted if the week start day is changed. If \a
711 startOnMonday is TRUE then the first day of the week is Monday; if 711 startOnMonday is TRUE then the first day of the week is Monday; if
712 \a startOnMonday is FALSE then the first day of the week is 712 \a startOnMonday is FALSE then the first day of the week is
713 Sunday. 713 Sunday.
714*/ 714*/
715 715
716/*! 716/*!
717 \fn void QPEApplication::dateFormatChanged(DateFormat) 717 \fn void QPEApplication::dateFormatChanged(DateFormat)
718 718
719 This signal is emitted whenever the date format is changed. 719 This signal is emitted whenever the date format is changed.
720*/ 720*/
721 721
722/*! 722/*!
723 \fn void QPEApplication::flush() 723 \fn void QPEApplication::flush()
724 724
725 ### 725 ###
726*/ 726*/
727 727
728/*! 728/*!
729 \fn void QPEApplication::reload() 729 \fn void QPEApplication::reload()
730 730
731*/ 731*/
732 732
733 733
734 734
735void QPEApplication::processQCopFile() 735void QPEApplication::processQCopFile()
736{ 736{
737 QString qcopfn("/tmp/qcop-msg-"); 737 QString qcopfn("/tmp/qcop-msg-");
738 qcopfn += d->appName; // append command name 738 qcopfn += d->appName; // append command name
739 739
740 QFile f(qcopfn); 740 QFile f(qcopfn);
741 if ( f.open(IO_ReadWrite) ) { 741 if ( f.open(IO_ReadWrite) ) {
742#ifndef Q_OS_WIN32 742#ifndef Q_OS_WIN32
743 flock(f.handle(), LOCK_EX); 743 flock(f.handle(), LOCK_EX);
744#endif 744#endif
745 QDataStream ds(&f); 745 QDataStream ds(&f);
746 QCString channel, message; 746 QCString channel, message;
747 QByteArray data; 747 QByteArray data;
748 while(!ds.atEnd()) { 748 while(!ds.atEnd()) {
749 ds >> channel >> message >> data; 749 ds >> channel >> message >> data;
750 d->enqueueQCop(channel,message,data); 750 d->enqueueQCop(channel,message,data);
751 } 751 }
752 ::ftruncate(f.handle(), 0); 752 ::ftruncate(f.handle(), 0);
753#ifndef Q_OS_WIN32 753#ifndef Q_OS_WIN32
754 f.flush(); 754 f.flush();
755 flock(f.handle(), LOCK_UN); 755 flock(f.handle(), LOCK_UN);
756#endif 756#endif
757 } 757 }
758#endif 758#endif
759} 759}
760 760
761 761
762/*! 762/*!
763 \fn void QPEApplication::appMessage( const QCString& msg, const QByteArray& data ) 763 \fn void QPEApplication::appMessage( const QCString& msg, const QByteArray& data )
764 764
765 This signal is emitted when a message is received on this 765 This signal is emitted when a message is received on this
766 application's QPE/Application/<i>appname</i> \link qcop.html 766 application's QPE/Application/<i>appname</i> \link qcop.html
767 QCop\endlink channel. 767 QCop\endlink channel.
768 768
769 The slot to which you connect this signal uses \a msg and \a data 769 The slot to which you connect this signal uses \a msg and \a data
770 in the following way: 770 in the following way:
771 771
772\code 772\code
773 void MyWidget::receive( const QCString& msg, const QByteArray& data ) 773 void MyWidget::receive( const QCString& msg, const QByteArray& data )
774 { 774 {
775 QDataStream stream( data, IO_ReadOnly ); 775 QDataStream stream( data, IO_ReadOnly );
776 if ( msg == "someMessage(int,int,int)" ) { 776 if ( msg == "someMessage(int,int,int)" ) {
777 int a,b,c; 777 int a,b,c;
778 stream >> a >> b >> c; 778 stream >> a >> b >> c;
779 ... 779 ...
780 } else if ( msg == "otherMessage(QString)" ) { 780 } else if ( msg == "otherMessage(QString)" ) {
781 ... 781 ...
782 } 782 }
783 } 783 }
784\endcode 784\endcode
785 785
786 \sa qcop.html 786 \sa qcop.html
787 Note that messages received here may be processed by qpe application 787 Note that messages received here may be processed by qpe application
788 and emitted as signals, such as flush() and reload(). 788 and emitted as signals, such as flush() and reload().
789*/ 789*/
790 790
791/*! 791/*!
792 Constructs a QPEApplication just as you would construct 792 Constructs a QPEApplication just as you would construct
793 a QApplication, passing \a argc, \a argv, and \a t. 793 a QApplication, passing \a argc, \a argv, and \a t.
794 794
795 For applications, \a t should be the default, GuiClient. Only 795 For applications, \a t should be the default, GuiClient. Only
796 the Qtopia server passes GuiServer. 796 the Qtopia server passes GuiServer.
797*/ 797*/
798QPEApplication::QPEApplication( int & argc, char **argv, Type t ) 798QPEApplication::QPEApplication( int & argc, char **argv, Type t )
799 : QApplication( hack(argc), argv, t ), pidChannel( 0 ) 799 : QApplication( hack(argc), argv, t ), pidChannel( 0 )
800{ 800{
801 QPixmapCache::setCacheLimit(256); // sensible default for smaller devices. 801 QPixmapCache::setCacheLimit(256); // sensible default for smaller devices.
802 802
803 d = new QPEApplicationData; 803 d = new QPEApplicationData;
804 d->loadTextCodecs(); 804 d->loadTextCodecs();
805 d->loadImageCodecs(); 805 d->loadImageCodecs();
806 int dw = desktop() ->width(); 806 int dw = desktop() ->width();
807 807
808 setFont( QFont( d->fontFamily, d->fontSize ) ); 808 setFont( QFont( d->fontFamily, d->fontSize ) );
809 AppLnk::setSmallIconSize( d->smallIconSize ); 809 AppLnk::setSmallIconSize( d->smallIconSize );
810 AppLnk::setBigIconSize( d->bigIconSize ); 810 AppLnk::setBigIconSize( d->bigIconSize );
811 811
812 QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory ); 812 QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory );
813 813
814 connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) ); 814 connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) );
815 815
816 816
817 sysChannel = new QCopChannel( "QPE/System", this ); 817 sysChannel = new QCopChannel( "QPE/System", this );
818 connect( sysChannel, SIGNAL( received(const QCString&,const QByteArray&) ), 818 connect( sysChannel, SIGNAL( received(const QCString&,const QByteArray&) ),
819 this, SLOT( systemMessage(const QCString&,const QByteArray&) ) ); 819 this, SLOT( systemMessage(const QCString&,const QByteArray&) ) );
820 820
821/* COde now in initapp */ 821/* COde now in initapp */
822#if 0 822#if 0
823#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 823#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
824 824
825 QString qcopfn( "/tmp/qcop-msg-" ); 825 QString qcopfn( "/tmp/qcop-msg-" );
826 qcopfn += QString( argv[ 0 ] ); // append command name 826 qcopfn += QString( argv[ 0 ] ); // append command name
827 827
828 QFile f( qcopfn ); 828 QFile f( qcopfn );
829 if ( f.open( IO_ReadOnly ) ) { 829 if ( f.open( IO_ReadOnly ) ) {
830 flock( f.handle(), LOCK_EX ); 830 flock( f.handle(), LOCK_EX );
831 } 831 }
832 832
833 833
834 834
835 QCString channel = QCString( argv[ 0 ] ); 835 QCString channel = QCString( argv[ 0 ] );
836 channel.replace( QRegExp( ".*/" ), "" ); 836 channel.replace( QRegExp( ".*/" ), "" );
837 d->appName = channel; 837 d->appName = channel;
838 channel = "QPE/Application/" + channel; 838 channel = "QPE/Application/" + channel;
839 pidChannel = new QCopChannel( channel, this ); 839 pidChannel = new QCopChannel( channel, this );
840 connect( pidChannel, SIGNAL( received(const QCString&,const QByteArray&) ), 840 connect( pidChannel, SIGNAL( received(const QCString&,const QByteArray&) ),
841 this, SLOT( pidMessage(const QCString&,const QByteArray&) ) ); 841 this, SLOT( pidMessage(const QCString&,const QByteArray&) ) );
842 842
843 if ( f.isOpen() ) { 843 if ( f.isOpen() ) {
844 d->keep_running = FALSE; 844 d->keep_running = FALSE;
845 QDataStream ds( &f ); 845 QDataStream ds( &f );
846 QCString channel, message; 846 QCString channel, message;
847 QByteArray data; 847 QByteArray data;
848 while ( !ds.atEnd() ) { 848 while ( !ds.atEnd() ) {
849 ds >> channel >> message >> data; 849 ds >> channel >> message >> data;
850 d->enqueueQCop( channel, message, data ); 850 d->enqueueQCop( channel, message, data );
851 } 851 }
852 852
853 flock( f.handle(), LOCK_UN ); 853 flock( f.handle(), LOCK_UN );
854 f.close(); 854 f.close();
855 f.remove(); 855 f.remove();
856 } 856 }
857 857
858 for ( int a = 0; a < argc; a++ ) { 858 for ( int a = 0; a < argc; a++ ) {
859 if ( qstrcmp( argv[ a ], "-preload" ) == 0 ) { 859 if ( qstrcmp( argv[ a ], "-preload" ) == 0 ) {
860 argv[ a ] = argv[ a + 1 ]; 860 argv[ a ] = argv[ a + 1 ];
861 a++; 861 a++;
862 d->preloaded = TRUE; 862 d->preloaded = TRUE;
863 argc -= 1; 863 argc -= 1;
864 } 864 }
865 else if ( qstrcmp( argv[ a ], "-preload-show" ) == 0 ) { 865 else if ( qstrcmp( argv[ a ], "-preload-show" ) == 0 ) {
866 argv[ a ] = argv[ a + 1 ]; 866 argv[ a ] = argv[ a + 1 ];
867 a++; 867 a++;
868 d->preloaded = TRUE; 868 d->preloaded = TRUE;
869 d->forceshow = TRUE; 869 d->forceshow = TRUE;
870 argc -= 1; 870 argc -= 1;
871 } 871 }
872 } 872 }
873 873
874 /* overide stored arguments */ 874 /* overide stored arguments */
875 setArgs( argc, argv ); 875 setArgs( argc, argv );
876 876
877#endif 877#endif
878#else 878#else
879 initApp( argc, argv ); 879 initApp( argc, argv );
880#endif 880#endif
881 // qwsSetDecoration( new QPEDecoration() ); 881 // qwsSetDecoration( new QPEDecoration() );
882 882
883#ifndef QT_NO_TRANSLATION 883#ifndef QT_NO_TRANSLATION
884 884
885 d->langs = Global::languageList(); 885 d->langs = Global::languageList();
886 for ( QStringList::ConstIterator it = d->langs.begin(); it != d->langs.end(); ++it ) { 886 for ( QStringList::ConstIterator it = d->langs.begin(); it != d->langs.end(); ++it ) {
887 QString lang = *it; 887 QString lang = *it;
888 888
889 installTranslation( lang + "/libopie.qm"); 889 installTranslation( lang + "/libopie.qm");
890 installTranslation( lang + "/libqpe.qm" ); 890 installTranslation( lang + "/libqpe.qm" );
891 installTranslation( lang + "/" + d->appName + ".qm" ); 891 installTranslation( lang + "/" + d->appName + ".qm" );
892 892
893 893
894 //###language/font hack; should look it up somewhere 894 //###language/font hack; should look it up somewhere
895#ifdef QWS 895#ifdef QWS
896 896
897 if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) { 897 if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) {
898 QFont fn = FontManager::unicodeFont( FontManager::Proportional ); 898 QFont fn = FontManager::unicodeFont( FontManager::Proportional );
899 setFont( fn ); 899 setFont( fn );
900 } 900 }
901#endif 901#endif
902 } 902 }
903#endif 903#endif
904 904
905 applyStyle(); 905 applyStyle();
906 906
907 if ( type() == GuiServer ) { 907 if ( type() == GuiServer ) {
908 setVolume(); 908 setVolume();
909 } 909 }
910 910
911 installEventFilter( this ); 911 installEventFilter( this );
912 912
913 QPEMenuToolFocusManager::initialize(); 913 QPEMenuToolFocusManager::initialize();
914 914
915#ifdef QT_NO_QWS_CURSOR 915#ifdef QT_NO_QWS_CURSOR
916 // if we have no cursor, probably don't want tooltips 916 // if we have no cursor, probably don't want tooltips
917 QToolTip::setEnabled( FALSE ); 917 QToolTip::setEnabled( FALSE );
918#endif 918#endif
919} 919}
920 920
921 921
922#ifdef QTOPIA_INTERNAL_INITAPP 922#ifdef QTOPIA_INTERNAL_INITAPP
923void QPEApplication::initApp( int argc, char **argv ) 923void QPEApplication::initApp( int argc, char **argv )
924{ 924{
925 delete pidChannel; 925 delete pidChannel;
926 d->keep_running = TRUE; 926 d->keep_running = TRUE;
927 d->preloaded = FALSE; 927 d->preloaded = FALSE;
928 d->forceshow = FALSE; 928 d->forceshow = FALSE;
929 929
930 QCString channel = QCString(argv[0]); 930 QCString channel = QCString(argv[0]);
931 931
932 channel.replace(QRegExp(".*/"),""); 932 channel.replace(QRegExp(".*/"),"");
933 d->appName = channel; 933 d->appName = channel;
934 934
935 #if QT_VERSION > 235 935 #if QT_VERSION > 235
936 qt_fbdpy->setIdentity( channel ); // In Qt/E 2.3.6 936 qt_fbdpy->setIdentity( channel ); // In Qt/E 2.3.6
937 #endif 937 #endif
938 938
939 channel = "QPE/Application/" + channel; 939 channel = "QPE/Application/" + channel;
940 pidChannel = new QCopChannel( channel, this); 940 pidChannel = new QCopChannel( channel, this);
941 connect( pidChannel, SIGNAL(received(const QCString&,const QByteArray&)), 941 connect( pidChannel, SIGNAL(received(const QCString&,const QByteArray&)),
942 this, SLOT(pidMessage(const QCString&,const QByteArray&))); 942 this, SLOT(pidMessage(const QCString&,const QByteArray&)));
943 943
944 944
945 945
946 processQCopFile(); 946 processQCopFile();
947 d->keep_running = d->qcopq.isEmpty(); 947 d->keep_running = d->qcopq.isEmpty();
948 948
949 for (int a=0; a<argc; a++) { 949 for (int a=0; a<argc; a++) {
950 if ( qstrcmp(argv[a],"-preload")==0 ) { 950 if ( qstrcmp(argv[a],"-preload")==0 ) {
951 argv[a] = argv[a+1]; 951 argv[a] = argv[a+1];
952 a++; 952 a++;
953 d->preloaded = TRUE; 953 d->preloaded = TRUE;
954 argc-=1; 954 argc-=1;
955 } else if ( qstrcmp(argv[a],"-preload-show")==0 ) { 955 } else if ( qstrcmp(argv[a],"-preload-show")==0 ) {
956 argv[a] = argv[a+1]; 956 argv[a] = argv[a+1];
957 a++; 957 a++;
958 d->preloaded = TRUE; 958 d->preloaded = TRUE;
959 d->forceshow = TRUE; 959 d->forceshow = TRUE;
960 argc-=1; 960 argc-=1;
961 } 961 }
962 } 962 }
963 963
964 /* overide stored arguments */ 964 /* overide stored arguments */
965 setArgs(argc, argv); 965 setArgs(argc, argv);
966 966
967 /* install translation here */ 967 /* install translation here */
968 for ( QStringList::ConstIterator it = d->langs.begin(); it != d->langs.end(); ++it ) 968 for ( QStringList::ConstIterator it = d->langs.begin(); it != d->langs.end(); ++it )
969 installTranslation( (*it) + "/" + d->appName + ".qm" ); 969 installTranslation( (*it) + "/" + d->appName + ".qm" );
970} 970}
971#endif 971#endif
972 972
973 973
974static QPtrDict<void>* inputMethodDict = 0; 974static QPtrDict<void>* inputMethodDict = 0;
975static void createInputMethodDict() 975static void createInputMethodDict()
976{ 976{
977 if ( !inputMethodDict ) 977 if ( !inputMethodDict )
978 inputMethodDict = new QPtrDict<void>; 978 inputMethodDict = new QPtrDict<void>;
979} 979}
980 980
981/*! 981/*!
982 Returns the currently set hint to the system as to whether 982 Returns the currently set hint to the system as to whether
983 widget \a w has any use for text input methods. 983 widget \a w has any use for text input methods.
984 984
985 985
986 \sa setInputMethodHint() InputMethodHint 986 \sa setInputMethodHint() InputMethodHint
987*/ 987*/
988QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w ) 988QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w )
989{ 989{
990 if ( inputMethodDict && w ) 990 if ( inputMethodDict && w )
991 return ( InputMethodHint ) ( int ) inputMethodDict->find( w ); 991 return ( InputMethodHint ) ( int ) inputMethodDict->find( w );
992 return Normal; 992 return Normal;
993} 993}
994 994
995/*! 995/*!
996 \enum QPEApplication::InputMethodHint 996 \enum QPEApplication::InputMethodHint
997 997
998 \value Normal the application sometimes needs text input (the default). 998 \value Normal the application sometimes needs text input (the default).
999 \value AlwaysOff the application never needs text input. 999 \value AlwaysOff the application never needs text input.
1000 \value AlwaysOn the application always needs text input. 1000 \value AlwaysOn the application always needs text input.
1001*/ 1001*/
1002 1002
1003/*! 1003/*!
1004 Hints to the system that widget \a w has use for text input methods 1004 Hints to the system that widget \a w has use for text input methods
1005 as specified by \a mode. 1005 as specified by \a mode.
1006 1006
1007 \sa inputMethodHint() InputMethodHint 1007 \sa inputMethodHint() InputMethodHint
1008*/ 1008*/
1009void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode ) 1009void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode )
1010{ 1010{
1011 createInputMethodDict(); 1011 createInputMethodDict();
1012 if ( mode == Normal ) { 1012 if ( mode == Normal ) {
1013 inputMethodDict->remove 1013 inputMethodDict->remove
1014 ( w ); 1014 ( w );
1015 } 1015 }
1016 else { 1016 else {
1017 inputMethodDict->insert( w, ( void* ) mode ); 1017 inputMethodDict->insert( w, ( void* ) mode );
1018 } 1018 }
1019} 1019}
1020 1020
1021class HackDialog : public QDialog 1021class HackDialog : public QDialog
1022{ 1022{
1023public: 1023public:
1024 void acceptIt() 1024 void acceptIt()
1025 { 1025 {
1026 accept(); 1026 accept();
1027 } 1027 }
1028 void rejectIt() 1028 void rejectIt()
1029 { 1029 {
1030 reject(); 1030 reject();
1031 } 1031 }
1032}; 1032};
1033 1033
1034 1034
1035void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key ) 1035void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key )
1036{ 1036{
1037 // specialised actions for certain widgets. May want to 1037 // specialised actions for certain widgets. May want to
1038 // add more stuff here. 1038 // add more stuff here.
1039 if ( activePopupWidget() && activePopupWidget() ->inherits( "QListBox" ) 1039 if ( activePopupWidget() && activePopupWidget() ->inherits( "QListBox" )
1040 && activePopupWidget() ->parentWidget() 1040 && activePopupWidget() ->parentWidget()
1041 && activePopupWidget() ->parentWidget() ->inherits( "QComboBox" ) ) 1041 && activePopupWidget() ->parentWidget() ->inherits( "QComboBox" ) )
1042 key = Qt::Key_Return; 1042 key = Qt::Key_Return;
1043 1043
1044 if ( activePopupWidget() && activePopupWidget() ->inherits( "QPopupMenu" ) ) 1044 if ( activePopupWidget() && activePopupWidget() ->inherits( "QPopupMenu" ) )
1045 key = Qt::Key_Return; 1045 key = Qt::Key_Return;
1046 1046
1047#ifdef QWS 1047#ifdef QWS
1048 1048
1049 ke->simpleData.keycode = key; 1049 ke->simpleData.keycode = key;
1050#endif 1050#endif
1051} 1051}
1052 1052
1053 1053
1054/*! 1054/*!
1055 \internal 1055 \internal
1056*/ 1056*/
1057 1057
1058#ifdef QWS 1058#ifdef QWS
1059bool QPEApplication::qwsEventFilter( QWSEvent * e ) 1059bool QPEApplication::qwsEventFilter( QWSEvent * e )
1060{ 1060{
1061 if ( !d->notbusysent && e->type == QWSEvent::Focus ) { 1061 if ( !d->notbusysent && e->type == QWSEvent::Focus ) {
1062 if ( qApp->type() != QApplication::GuiServer ) { 1062 if ( qApp->type() != QApplication::GuiServer ) {
1063 QCopEnvelope e( "QPE/System", "notBusy(QString)" ); 1063 QCopEnvelope e( "QPE/System", "notBusy(QString)" );
1064 e << d->appName; 1064 e << d->appName;
1065 } 1065 }
1066 d->notbusysent = TRUE; 1066 d->notbusysent = TRUE;
1067 } 1067 }
1068 if ( type() == GuiServer ) { 1068 if ( type() == GuiServer ) {
1069 switch ( e->type ) { 1069 switch ( e->type ) {
1070 case QWSEvent::Mouse: 1070 case QWSEvent::Mouse:
1071 if ( e->asMouse() ->simpleData.state && !QWidget::find( e->window() ) ) 1071 if ( e->asMouse() ->simpleData.state && !QWidget::find( e->window() ) )
1072 emit clientMoused(); 1072 emit clientMoused();
1073 break; 1073 break;
1074 default: 1074 default:
1075 break; 1075 break;
1076 } 1076 }
1077 } 1077 }
1078 if ( e->type == QWSEvent::Key ) { 1078 if ( e->type == QWSEvent::Key ) {
1079 QWSKeyEvent *ke = ( QWSKeyEvent * ) e; 1079 QWSKeyEvent *ke = ( QWSKeyEvent * ) e;
1080 if ( ke->simpleData.keycode == Qt::Key_F33 ) { 1080 if ( ke->simpleData.keycode == Qt::Key_F33 ) {
1081 // Use special "OK" key to press "OK" on top level widgets 1081 // Use special "OK" key to press "OK" on top level widgets
1082 QWidget * active = activeWindow(); 1082 QWidget * active = activeWindow();
1083 QWidget *popup = 0; 1083 QWidget *popup = 0;
1084 if ( active && active->isPopup() ) { 1084 if ( active && active->isPopup() ) {
1085 popup = active; 1085 popup = active;
1086 active = active->parentWidget(); 1086 active = active->parentWidget();
1087 } 1087 }
1088 if ( active && ( int ) active->winId() == ke->simpleData.window && 1088 if ( active && ( int ) active->winId() == ke->simpleData.window &&
1089 !active->testWFlags( WStyle_Customize | WType_Popup | WType_Desktop ) ) { 1089 !active->testWFlags( WStyle_Customize | WType_Popup | WType_Desktop ) ) {
1090 if ( ke->simpleData.is_press ) { 1090 if ( ke->simpleData.is_press ) {
1091 if ( popup ) 1091 if ( popup )
1092 popup->close(); 1092 popup->close();
1093 if ( active->inherits( "QDialog" ) ) { 1093 if ( active->inherits( "QDialog" ) ) {
1094 HackDialog * d = ( HackDialog * ) active; 1094 HackDialog * d = ( HackDialog * ) active;
1095 d->acceptIt(); 1095 d->acceptIt();
1096 return TRUE; 1096 return TRUE;
1097 } 1097 }
1098 else if ( ( ( HackWidget * ) active ) ->needsOk() ) { 1098 else if ( ( ( HackWidget * ) active ) ->needsOk() ) {
1099 QSignal s; 1099 QSignal s;
1100 s.connect( active, SLOT( accept() ) ); 1100 s.connect( active, SLOT( accept() ) );
1101 s.activate(); 1101 s.activate();
1102 } 1102 }
1103 else { 1103 else {
1104 // do the same as with the select key: Map to the default action of the widget: 1104 // do the same as with the select key: Map to the default action of the widget:
1105 mapToDefaultAction( ke, Qt::Key_Return ); 1105 mapToDefaultAction( ke, Qt::Key_Return );
1106 } 1106 }
1107 } 1107 }
1108 } 1108 }
1109 } 1109 }
1110 else if ( ke->simpleData.keycode == Qt::Key_F30 ) { 1110 else if ( ke->simpleData.keycode == Qt::Key_F30 ) {
1111 // Use special "select" key to do whatever default action a widget has 1111 // Use special "select" key to do whatever default action a widget has
1112 mapToDefaultAction( ke, Qt::Key_Space ); 1112 mapToDefaultAction( ke, Qt::Key_Space );
1113 } 1113 }
1114 else if ( ke->simpleData.keycode == Qt::Key_Escape && 1114 else if ( ke->simpleData.keycode == Qt::Key_Escape &&
1115 ke->simpleData.is_press ) { 1115 ke->simpleData.is_press ) {
1116 // Escape key closes app if focus on toplevel 1116 // Escape key closes app if focus on toplevel
1117 QWidget * active = activeWindow(); 1117 QWidget * active = activeWindow();
1118 if ( active && active->testWFlags( WType_TopLevel ) && 1118 if ( active && active->testWFlags( WType_TopLevel ) &&
1119 ( int ) active->winId() == ke->simpleData.window && 1119 ( int ) active->winId() == ke->simpleData.window &&
1120 !active->testWFlags( WStyle_Dialog | WStyle_Customize | WType_Popup | WType_Desktop ) ) { 1120 !active->testWFlags( WStyle_Dialog | WStyle_Customize | WType_Popup | WType_Desktop ) ) {
1121 if ( active->inherits( "QDialog" ) ) { 1121 if ( active->inherits( "QDialog" ) ) {
1122 HackDialog * d = ( HackDialog * ) active; 1122 HackDialog * d = ( HackDialog * ) active;
1123 d->rejectIt(); 1123 d->rejectIt();
1124 return TRUE; 1124 return TRUE;
1125 } else /*if ( strcmp( argv() [ 0 ], "embeddedkonsole" ) != 0 )*/ { 1125 } else /*if ( strcmp( argv() [ 0 ], "embeddedkonsole" ) != 0 )*/ {
1126 active->close(); 1126 active->close();
1127 } 1127 }
1128 } 1128 }
1129 1129
1130 } 1130 }
1131 else if ( ke->simpleData.keycode >= Qt::Key_F1 && ke->simpleData.keycode <= Qt::Key_F29 ) { 1131 else if ( ke->simpleData.keycode >= Qt::Key_F1 && ke->simpleData.keycode <= Qt::Key_F29 ) {
1132 // this should be if ( ODevice::inst ( )-> buttonForKeycode ( ... )) 1132 // this should be if ( ODevice::inst ( )-> buttonForKeycode ( ... ))
1133 // but we cannot access libopie function within libqpe :( 1133 // but we cannot access libopie function within libqpe :(
1134 1134
1135 QWidget * active = activeWindow ( ); 1135 QWidget * active = activeWindow ( );
1136 if ( active && ((int) active-> winId ( ) == ke-> simpleData.window )) { 1136 if ( active && ((int) active-> winId ( ) == ke-> simpleData.window )) {
1137 if ( d-> kbgrabbed ) { // we grabbed the keyboard 1137 if ( d-> kbgrabbed ) { // we grabbed the keyboard
1138 QChar ch ( ke-> simpleData.unicode ); 1138 QChar ch ( ke-> simpleData.unicode );
1139 QKeyEvent qke ( ke-> simpleData. is_press ? QEvent::KeyPress : QEvent::KeyRelease, 1139 QKeyEvent qke ( ke-> simpleData. is_press ? QEvent::KeyPress : QEvent::KeyRelease,
1140 ke-> simpleData.keycode, 1140 ke-> simpleData.keycode,
1141 ch. latin1 ( ), 1141 ch. latin1 ( ),
1142 ke-> simpleData.modifiers, 1142 ke-> simpleData.modifiers,
1143 QString ( ch ), 1143 QString ( ch ),
1144 ke-> simpleData.is_auto_repeat, 1 ); 1144 ke-> simpleData.is_auto_repeat, 1 );
1145 1145
1146 QObject *which = QWidget::keyboardGrabber ( ); 1146 QObject *which = QWidget::keyboardGrabber ( );
1147 if ( !which ) 1147 if ( !which )
1148 which = QApplication::focusWidget ( ); 1148 which = QApplication::focusWidget ( );
1149 if ( !which ) 1149 if ( !which )
1150 which = QApplication::activeWindow ( ); 1150 which = QApplication::activeWindow ( );
1151 if ( !which ) 1151 if ( !which )
1152 which = qApp; 1152 which = qApp;
1153 1153
1154 QApplication::sendEvent ( which, &qke ); 1154 QApplication::sendEvent ( which, &qke );
1155 } 1155 }
1156 else { // we didn't grab the keyboard, so send the event to the launcher 1156 else { // we didn't grab the keyboard, so send the event to the launcher
1157 QCopEnvelope e ( "QPE/Launcher", "deviceButton(int,int,int)" ); 1157 QCopEnvelope e ( "QPE/Launcher", "deviceButton(int,int,int)" );
1158 e << int( ke-> simpleData.keycode ) << int( ke-> simpleData. is_press ) << int( ke-> simpleData.is_auto_repeat ); 1158 e << int( ke-> simpleData.keycode ) << int( ke-> simpleData. is_press ) << int( ke-> simpleData.is_auto_repeat );
1159 } 1159 }
1160 } 1160 }
1161 return true; 1161 return true;
1162 } 1162 }
1163 } 1163 }
1164 if ( e->type == QWSEvent::Focus ) { 1164 if ( e->type == QWSEvent::Focus ) {
1165 QWSFocusEvent * fe = ( QWSFocusEvent* ) e; 1165 QWSFocusEvent * fe = ( QWSFocusEvent* ) e;
1166 if ( !fe->simpleData.get_focus ) { 1166 if ( !fe->simpleData.get_focus ) {
1167 QWidget * active = activeWindow(); 1167 QWidget * active = activeWindow();
1168 while ( active && active->isPopup() ) { 1168 while ( active && active->isPopup() ) {
1169 active->close(); 1169 active->close();
1170 active = activeWindow(); 1170 active = activeWindow();
1171 } 1171 }
1172 } 1172 }
1173 else { 1173 else {
1174 // make sure our modal widget is ALWAYS on top 1174 // make sure our modal widget is ALWAYS on top
1175 QWidget *topm = activeModalWidget(); 1175 QWidget *topm = activeModalWidget();
1176 if ( topm && static_cast<int>( topm->winId() ) != fe->simpleData.window) { 1176 if ( topm && static_cast<int>( topm->winId() ) != fe->simpleData.window) {
1177 topm->raise(); 1177 topm->raise();
1178 } 1178 }
1179 } 1179 }
1180 if ( fe->simpleData.get_focus && inputMethodDict ) { 1180 if ( fe->simpleData.get_focus && inputMethodDict ) {
1181 InputMethodHint m = inputMethodHint( QWidget::find( e->window() ) ); 1181 InputMethodHint m = inputMethodHint( QWidget::find( e->window() ) );
1182 if ( m == AlwaysOff ) 1182 if ( m == AlwaysOff )
1183 Global::hideInputMethod(); 1183 Global::hideInputMethod();
1184 if ( m == AlwaysOn ) 1184 if ( m == AlwaysOn )
1185 Global::showInputMethod(); 1185 Global::showInputMethod();
1186 } 1186 }
1187 } 1187 }
1188 1188
1189 1189
1190 return QApplication::qwsEventFilter( e ); 1190 return QApplication::qwsEventFilter( e );
1191} 1191}
1192#endif 1192#endif
1193 1193
1194/*! 1194/*!
1195 Destroys the QPEApplication. 1195 Destroys the QPEApplication.
1196*/ 1196*/
1197QPEApplication::~QPEApplication() 1197QPEApplication::~QPEApplication()
1198{ 1198{
1199 ungrabKeyboard(); 1199 ungrabKeyboard();
1200#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 1200#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
1201 // Need to delete QCopChannels early, since the display will 1201 // Need to delete QCopChannels early, since the display will
1202 // be gone by the time we get to ~QObject(). 1202 // be gone by the time we get to ~QObject().
1203 delete sysChannel; 1203 delete sysChannel;
1204 delete pidChannel; 1204 delete pidChannel;
1205#endif 1205#endif
1206 1206
1207 delete d; 1207 delete d;
1208} 1208}
1209 1209
1210/*! 1210/*!
1211 Returns <tt>$OPIEDIR/</tt>. 1211 Returns <tt>$OPIEDIR/</tt>.
1212*/ 1212*/
1213QString QPEApplication::qpeDir() 1213QString QPEApplication::qpeDir()
1214{ 1214{
1215 const char * base = getenv( "OPIEDIR" ); 1215 const char * base = getenv( "OPIEDIR" );
1216 if ( base ) 1216 if ( base )
1217 return QString( base ) + "/"; 1217 return QString( base ) + "/";
1218 1218
1219 return QString( "../" ); 1219 return QString( "../" );
1220} 1220}
1221 1221
1222/*! 1222/*!
1223 Returns the user's current Document directory. There is a trailing "/". 1223 Returns the user's current Document directory. There is a trailing "/".
1224 .. well, it does now,, and there's no trailing '/' 1224 .. well, it does now,, and there's no trailing '/'
1225*/ 1225*/
1226QString QPEApplication::documentDir() 1226QString QPEApplication::documentDir()
1227{ 1227{
1228 const char* base = getenv( "HOME"); 1228 const char* base = getenv( "HOME");
1229 if ( base ) 1229 if ( base )
1230 return QString( base ) + "/Documents"; 1230 return QString( base ) + "/Documents";
1231 1231
1232 return QString( "../Documents" ); 1232 return QString( "../Documents" );
1233} 1233}
1234 1234
1235static int deforient = -1; 1235static int deforient = -1;
1236 1236
1237/*! 1237/*!
1238 \internal 1238 \internal
1239*/ 1239*/
1240int QPEApplication::defaultRotation() 1240int QPEApplication::defaultRotation()
1241{ 1241{
1242 if ( deforient < 0 ) { 1242 if ( deforient < 0 ) {
1243 QString d = getenv( "QWS_DISPLAY" ); 1243 QString d = getenv( "QWS_DISPLAY" );
1244 if ( d.contains( "Rot90" ) ) { 1244 if ( d.contains( "Rot90" ) ) {
1245 deforient = 90; 1245 deforient = 90;
1246 } 1246 }
1247 else if ( d.contains( "Rot180" ) ) { 1247 else if ( d.contains( "Rot180" ) ) {
1248 deforient = 180; 1248 deforient = 180;
1249 } 1249 }
1250 else if ( d.contains( "Rot270" ) ) { 1250 else if ( d.contains( "Rot270" ) ) {
1251 deforient = 270; 1251 deforient = 270;
1252 } 1252 }
1253 else { 1253 else {
1254 deforient = 0; 1254 deforient = 0;
1255 } 1255 }
1256 } 1256 }
1257 return deforient; 1257 return deforient;
1258} 1258}
1259 1259
1260/*! 1260/*!
1261 \internal 1261 \internal
1262*/ 1262*/
1263void QPEApplication::setDefaultRotation( int r ) 1263void QPEApplication::setDefaultRotation( int r )
1264{ 1264{
1265 if ( qApp->type() == GuiServer ) { 1265 if ( qApp->type() == GuiServer ) {
1266 deforient = r; 1266 deforient = r;
1267 setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 ); 1267 setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 );
1268 Config config("qpe"); 1268 Config config("qpe");
1269 config.setGroup( "Rotation" ); 1269 config.setGroup( "Rotation" );
1270 config.writeEntry( "Rot", r ); 1270 config.writeEntry( "Rot", r );
1271 } 1271 }
1272 else { 1272 else {
1273#ifndef QT_NO_COP 1273#ifndef QT_NO_COP
1274 { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" ); 1274 { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" );
1275 e << r; 1275 e << r;
1276 } 1276 }
1277#endif 1277#endif
1278 1278
1279 } 1279 }
1280} 1280}
1281 1281
1282#include <qgfx_qws.h> 1282#include <qgfx_qws.h>
1283#include <qwindowsystem_qws.h> 1283#include <qwindowsystem_qws.h>
1284 1284
1285extern void qws_clearLoadedFonts(); 1285extern void qws_clearLoadedFonts();
1286 1286
1287void QPEApplication::setCurrentMode( int x, int y, int depth ) 1287void QPEApplication::setCurrentMode( int x, int y, int depth )
1288{ 1288{
1289 // Reset the caches 1289 // Reset the caches
1290 qws_clearLoadedFonts(); 1290 qws_clearLoadedFonts();
1291 QPixmapCache::clear(); 1291 QPixmapCache::clear();
1292 1292
1293 // Change the screen mode 1293 // Change the screen mode
1294 qt_screen->setMode(x, y, depth); 1294 qt_screen->setMode(x, y, depth);
1295 1295
1296 if ( qApp->type() == GuiServer ) { 1296 if ( qApp->type() == GuiServer ) {
1297 // Reconfigure the GuiServer 1297 // Reconfigure the GuiServer
1298 qwsServer->beginDisplayReconfigure(); 1298 qwsServer->beginDisplayReconfigure();
1299 qwsServer->endDisplayReconfigure(); 1299 qwsServer->endDisplayReconfigure();
1300 1300
1301 // Get all the running apps to reset 1301 // Get all the running apps to reset
1302 QCopEnvelope env( "QPE/System", "reset()" ); 1302 QCopEnvelope env( "QPE/System", "reset()" );
1303 } 1303 }
1304} 1304}
1305 1305
1306void QPEApplication::reset() { 1306void QPEApplication::reset() {
1307 // Reconnect to the screen 1307 // Reconnect to the screen
1308 qt_screen->disconnect(); 1308 qt_screen->disconnect();
1309 qt_screen->connect( QString::null ); 1309 qt_screen->connect( QString::null );
1310 1310
1311 // Redraw everything 1311 // Redraw everything
1312 applyStyle(); 1312 applyStyle();
1313} 1313}
1314 1314
1315 1315
1316extern bool qt_left_hand_scrollbars __attribute__(( weak )); 1316#ifdef Q_OS_MACX
1317#define WEAK_SYMBOL __attribute__((weak_import))
1318#else
1319#define WEAK_SYMBOL __attribute__((weak))
1320#endif
1321
1322extern bool qt_left_hand_scrollbars WEAK_SYMBOL;
1317/*! 1323/*!
1318 \internal 1324 \internal
1319*/ 1325*/
1320void QPEApplication::applyStyle() 1326void QPEApplication::applyStyle()
1321{ 1327{
1322 Config config( "qpe" ); 1328 Config config( "qpe" );
1323 config.setGroup( "Appearance" ); 1329 config.setGroup( "Appearance" );
1324 1330
1325#if QT_VERSION > 233 1331#if QT_VERSION > 233
1326#if !defined(OPIE_NO_OVERRIDE_QT) 1332#if !defined(OPIE_NO_OVERRIDE_QT)
1327 // don't block ourselves ... 1333 // don't block ourselves ...
1328 Opie::force_appearance = 0; 1334 Opie::force_appearance = 0;
1329 1335
1330 static QString appname = Opie::binaryName ( ); 1336 static QString appname = Opie::binaryName ( );
1331 1337
1332 QStringList ex = config. readListEntry ( "NoStyle", ';' ); 1338 QStringList ex = config. readListEntry ( "NoStyle", ';' );
1333 int nostyle = 0; 1339 int nostyle = 0;
1334 for ( QStringList::Iterator it = ex. begin ( ); it != ex. end ( ); ++it ) { 1340 for ( QStringList::Iterator it = ex. begin ( ); it != ex. end ( ); ++it ) {
1335 if ( QRegExp (( *it ). mid ( 1 ), false, true ). find ( appname, 0 ) >= 0 ) { 1341 if ( QRegExp (( *it ). mid ( 1 ), false, true ). find ( appname, 0 ) >= 0 ) {
1336 nostyle = ( *it ). left ( 1 ). toInt ( 0, 32 ); 1342 nostyle = ( *it ). left ( 1 ). toInt ( 0, 32 );
1337 break; 1343 break;
1338 } 1344 }
1339 } 1345 }
1340#else 1346#else
1341 int nostyle = 0; 1347 int nostyle = 0;
1342#endif 1348#endif
1343 1349
1344 // Widget style 1350 // Widget style
1345 QString style = config.readEntry( "Style", "FlatStyle" ); 1351 QString style = config.readEntry( "Style", "FlatStyle" );
1346 1352
1347 // don't set a custom style 1353 // don't set a custom style
1348 if ( nostyle & Opie::Force_Style ) 1354 if ( nostyle & Opie::Force_Style )
1349 style = "FlatStyle"; 1355 style = "FlatStyle";
1350 1356
1351 internalSetStyle ( style ); 1357 internalSetStyle ( style );
1352 1358
1353 // Colors - from /etc/colors/Liquid.scheme 1359 // Colors - from /etc/colors/Liquid.scheme
1354 QColor bgcolor( config.readEntry( "Background", "#E0E0E0" ) ); 1360 QColor bgcolor( config.readEntry( "Background", "#E0E0E0" ) );
1355 QColor btncolor( config.readEntry( "Button", "#96c8fa" ) ); 1361 QColor btncolor( config.readEntry( "Button", "#96c8fa" ) );
1356 QPalette pal( btncolor, bgcolor ); 1362 QPalette pal( btncolor, bgcolor );
1357 QString color = config.readEntry( "Highlight", "#73adef" ); 1363 QString color = config.readEntry( "Highlight", "#73adef" );
1358 pal.setColor( QColorGroup::Highlight, QColor( color ) ); 1364 pal.setColor( QColorGroup::Highlight, QColor( color ) );
1359 color = config.readEntry( "HighlightedText", "#FFFFFF" ); 1365 color = config.readEntry( "HighlightedText", "#FFFFFF" );
1360 pal.setColor( QColorGroup::HighlightedText, QColor( color ) ); 1366 pal.setColor( QColorGroup::HighlightedText, QColor( color ) );
1361 color = config.readEntry( "Text", "#000000" ); 1367 color = config.readEntry( "Text", "#000000" );
1362 pal.setColor( QColorGroup::Text, QColor( color ) ); 1368 pal.setColor( QColorGroup::Text, QColor( color ) );
1363 color = config.readEntry( "ButtonText", "#000000" ); 1369 color = config.readEntry( "ButtonText", "#000000" );
1364 pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) ); 1370 pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) );
1365 color = config.readEntry( "Base", "#FFFFFF" ); 1371 color = config.readEntry( "Base", "#FFFFFF" );
1366 pal.setColor( QColorGroup::Base, QColor( color ) ); 1372 pal.setColor( QColorGroup::Base, QColor( color ) );
1367 1373
1368 pal.setColor( QPalette::Disabled, QColorGroup::Text, 1374 pal.setColor( QPalette::Disabled, QColorGroup::Text,
1369 pal.color( QPalette::Active, QColorGroup::Background ).dark() ); 1375 pal.color( QPalette::Active, QColorGroup::Background ).dark() );
1370 1376
1371 setPalette( pal, TRUE ); 1377 setPalette( pal, TRUE );
1372 1378
1373 1379
1374 // Set the ScrollBar on the 'right' side but only if the weak symbol is present 1380 // Set the ScrollBar on the 'right' side but only if the weak symbol is present
1375 if (&qt_left_hand_scrollbars ) 1381 if (&qt_left_hand_scrollbars )
1376 qt_left_hand_scrollbars = config.readBoolEntry( "LeftHand", false ); 1382 qt_left_hand_scrollbars = config.readBoolEntry( "LeftHand", false );
1377 1383
1378 // Window Decoration 1384 // Window Decoration
1379 QString dec = config.readEntry( "Decoration", "Flat" ); 1385 QString dec = config.readEntry( "Decoration", "Flat" );
1380 1386
1381 // don't set a custom deco 1387 // don't set a custom deco
1382 if ( nostyle & Opie::Force_Decoration ) 1388 if ( nostyle & Opie::Force_Decoration )
1383 dec = ""; 1389 dec = "";
1384 1390
1385 1391
1386 if ( dec != d->decorationName ) { 1392 if ( dec != d->decorationName ) {
1387 qwsSetDecoration( new QPEDecoration( dec ) ); 1393 qwsSetDecoration( new QPEDecoration( dec ) );
1388 d->decorationName = dec; 1394 d->decorationName = dec;
1389 } 1395 }
1390 1396
1391 // Font 1397 // Font
1392 QString ff = config.readEntry( "FontFamily", font().family() ); 1398 QString ff = config.readEntry( "FontFamily", font().family() );
1393 int fs = config.readNumEntry( "FontSize", font().pointSize() ); 1399 int fs = config.readNumEntry( "FontSize", font().pointSize() );
1394 1400
1395 // don't set a custom font 1401 // don't set a custom font
1396 if ( nostyle & Opie::Force_Font ) { 1402 if ( nostyle & Opie::Force_Font ) {
1397 ff = "Vera"; 1403 ff = "Vera";
1398 fs = 10; 1404 fs = 10;
1399 } 1405 }
1400 1406
1401 setFont ( QFont ( ff, fs ), true ); 1407 setFont ( QFont ( ff, fs ), true );
1402 1408
1403#if !defined(OPIE_NO_OVERRIDE_QT) 1409#if !defined(OPIE_NO_OVERRIDE_QT)
1404 // revert to global blocking policy ... 1410 // revert to global blocking policy ...
1405 Opie::force_appearance = config. readBoolEntry ( "ForceStyle", false ) ? Opie::Force_All : Opie::Force_None; 1411 Opie::force_appearance = config. readBoolEntry ( "ForceStyle", false ) ? Opie::Force_All : Opie::Force_None;
1406 Opie::force_appearance &= ~nostyle; 1412 Opie::force_appearance &= ~nostyle;
1407#endif 1413#endif
1408#endif 1414#endif
1409} 1415}
1410 1416
1411void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data ) 1417void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data )
1412{ 1418{
1413#ifdef Q_WS_QWS 1419#ifdef Q_WS_QWS
1414 QDataStream stream( data, IO_ReadOnly ); 1420 QDataStream stream( data, IO_ReadOnly );
1415 if ( msg == "applyStyle()" ) { 1421 if ( msg == "applyStyle()" ) {
1416 applyStyle(); 1422 applyStyle();
1417 } 1423 }
1418 else if ( msg == "toggleApplicationMenu()" ) { 1424 else if ( msg == "toggleApplicationMenu()" ) {
1419 QWidget *active = activeWindow ( ); 1425 QWidget *active = activeWindow ( );
1420 1426
1421 if ( active ) { 1427 if ( active ) {
1422 QPEMenuToolFocusManager *man = QPEMenuToolFocusManager::manager ( ); 1428 QPEMenuToolFocusManager *man = QPEMenuToolFocusManager::manager ( );
1423 bool oldactive = man-> isActive ( ); 1429 bool oldactive = man-> isActive ( );
1424 1430
1425 man-> setActive( !man-> isActive() ); 1431 man-> setActive( !man-> isActive() );
1426 1432
1427 if ( !oldactive && !man-> isActive ( )) { // no menubar to toggle -> try O-Menu 1433 if ( !oldactive && !man-> isActive ( )) { // no menubar to toggle -> try O-Menu
1428 QCopEnvelope e ( "QPE/TaskBar", "toggleStartMenu()" ); 1434 QCopEnvelope e ( "QPE/TaskBar", "toggleStartMenu()" );
1429 } 1435 }
1430 } 1436 }
1431 } 1437 }
1432 else if ( msg == "setDefaultRotation(int)" ) { 1438 else if ( msg == "setDefaultRotation(int)" ) {
1433 if ( type() == GuiServer ) { 1439 if ( type() == GuiServer ) {
1434 int r; 1440 int r;
1435 stream >> r; 1441 stream >> r;
1436 setDefaultRotation( r ); 1442 setDefaultRotation( r );
1437 } 1443 }
1438 } 1444 }
1439 else if ( msg == "setCurrentMode(int,int,int)" ) { // Added: 2003-06-11 by Tim Ansell <mithro@mithis.net> 1445 else if ( msg == "setCurrentMode(int,int,int)" ) { // Added: 2003-06-11 by Tim Ansell <mithro@mithis.net>
1440 if ( type() == GuiServer ) { 1446 if ( type() == GuiServer ) {
1441 int x, y, depth; 1447 int x, y, depth;
1442 stream >> x; 1448 stream >> x;
1443 stream >> y; 1449 stream >> y;
1444 stream >> depth; 1450 stream >> depth;
1445 setCurrentMode( x, y, depth ); 1451 setCurrentMode( x, y, depth );
1446 } 1452 }
1447 } 1453 }
1448 else if ( msg == "reset()" ) { 1454 else if ( msg == "reset()" ) {
1449 if ( type() != GuiServer ) 1455 if ( type() != GuiServer )
1450 reset(); 1456 reset();
1451 } 1457 }
1452 else if ( msg == "setCurrentRotation(int)" ) { 1458 else if ( msg == "setCurrentRotation(int)" ) {
1453 int r; 1459 int r;
1454 stream >> r; 1460 stream >> r;
1455 setCurrentRotation( r ); 1461 setCurrentRotation( r );
1456 } 1462 }
1457 else if ( msg == "shutdown()" ) { 1463 else if ( msg == "shutdown()" ) {
1458 if ( type() == GuiServer ) 1464 if ( type() == GuiServer )
1459 shutdown(); 1465 shutdown();
1460 } 1466 }
1461 else if ( msg == "quit()" ) { 1467 else if ( msg == "quit()" ) {
1462 if ( type() != GuiServer ) 1468 if ( type() != GuiServer )
1463 tryQuit(); 1469 tryQuit();
1464 } 1470 }
1465 else if ( msg == "forceQuit()" ) { 1471 else if ( msg == "forceQuit()" ) {
1466 if ( type() != GuiServer ) 1472 if ( type() != GuiServer )
1467 quit(); 1473 quit();
1468 } 1474 }
1469 else if ( msg == "restart()" ) { 1475 else if ( msg == "restart()" ) {
1470 if ( type() == GuiServer ) 1476 if ( type() == GuiServer )
1471 restart(); 1477 restart();
1472 } 1478 }
1473 else if ( msg == "language(QString)" ) { 1479 else if ( msg == "language(QString)" ) {
1474 if ( type() == GuiServer ) { 1480 if ( type() == GuiServer ) {
1475 QString l; 1481 QString l;
1476 stream >> l; 1482 stream >> l;
1477 QString cl = getenv( "LANG" ); 1483 QString cl = getenv( "LANG" );
1478 if ( cl != l ) { 1484 if ( cl != l ) {
1479 if ( l.isNull() ) 1485 if ( l.isNull() )
1480 unsetenv( "LANG" ); 1486 unsetenv( "LANG" );
1481 else 1487 else
1482 setenv( "LANG", l.latin1(), 1 ); 1488 setenv( "LANG", l.latin1(), 1 );
1483 restart(); 1489 restart();
1484 } 1490 }
1485 } 1491 }
1486 } 1492 }
1487 else if ( msg == "timeChange(QString)" ) { 1493 else if ( msg == "timeChange(QString)" ) {
1488 QString t; 1494 QString t;
1489 stream >> t; 1495 stream >> t;
1490 if ( t.isNull() ) 1496 if ( t.isNull() )
1491 unsetenv( "TZ" ); 1497 unsetenv( "TZ" );
1492 else 1498 else
1493 setenv( "TZ", t.latin1(), 1 ); 1499 setenv( "TZ", t.latin1(), 1 );
1494 // emit the signal so everyone else knows... 1500 // emit the signal so everyone else knows...
1495 emit timeChanged(); 1501 emit timeChanged();
1496 } 1502 }
1497 else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) { 1503 else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) {
1498 if ( type() == GuiServer ) { 1504 if ( type() == GuiServer ) {
1499 QDateTime when; 1505 QDateTime when;
1500 QCString channel, message; 1506 QCString channel, message;
1501 int data; 1507 int data;
1502 stream >> when >> channel >> message >> data; 1508 stream >> when >> channel >> message >> data;
1503 AlarmServer::addAlarm( when, channel, message, data ); 1509 AlarmServer::addAlarm( when, channel, message, data );
1504 } 1510 }
1505 } 1511 }
1506 else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) { 1512 else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) {
1507 if ( type() == GuiServer ) { 1513 if ( type() == GuiServer ) {
1508 QDateTime when; 1514 QDateTime when;
1509 QCString channel, message; 1515 QCString channel, message;
1510 int data; 1516 int data;
1511 stream >> when >> channel >> message >> data; 1517 stream >> when >> channel >> message >> data;
1512 AlarmServer::deleteAlarm( when, channel, message, data ); 1518 AlarmServer::deleteAlarm( when, channel, message, data );
1513 } 1519 }
1514 } 1520 }
1515 else if ( msg == "clockChange(bool)" ) { 1521 else if ( msg == "clockChange(bool)" ) {
1516 int tmp; 1522 int tmp;
1517 stream >> tmp; 1523 stream >> tmp;
1518 emit clockChanged( tmp ); 1524 emit clockChanged( tmp );
1519 } 1525 }
1520 else if ( msg == "weekChange(bool)" ) { 1526 else if ( msg == "weekChange(bool)" ) {
1521 int tmp; 1527 int tmp;
1522 stream >> tmp; 1528 stream >> tmp;
1523 emit weekChanged( tmp ); 1529 emit weekChanged( tmp );
1524 } 1530 }
1525 else if ( msg == "setDateFormat(DateFormat)" ) { 1531 else if ( msg == "setDateFormat(DateFormat)" ) {
1526 DateFormat tmp; 1532 DateFormat tmp;
1527 stream >> tmp; 1533 stream >> tmp;
1528 emit dateFormatChanged( tmp ); 1534 emit dateFormatChanged( tmp );
1529 } 1535 }
1530 else if ( msg == "setVolume(int,int)" ) { 1536 else if ( msg == "setVolume(int,int)" ) {
1531 int t, v; 1537 int t, v;
1532 stream >> t >> v; 1538 stream >> t >> v;
1533 setVolume( t, v ); 1539 setVolume( t, v );
1534 emit volumeChanged( muted ); 1540 emit volumeChanged( muted );
1535 } 1541 }
1536 else if ( msg == "volumeChange(bool)" ) { 1542 else if ( msg == "volumeChange(bool)" ) {
1537 stream >> muted; 1543 stream >> muted;
1538 setVolume(); 1544 setVolume();
1539 emit volumeChanged( muted ); 1545 emit volumeChanged( muted );
1540 } 1546 }
1541 else if ( msg == "setMic(int,int)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> 1547 else if ( msg == "setMic(int,int)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com>
1542 int t, v; 1548 int t, v;
1543 stream >> t >> v; 1549 stream >> t >> v;
1544 setMic( t, v ); 1550 setMic( t, v );
1545 emit micChanged( micMuted ); 1551 emit micChanged( micMuted );
1546 } 1552 }
1547 else if ( msg == "micChange(bool)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> 1553 else if ( msg == "micChange(bool)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com>
1548 stream >> micMuted; 1554 stream >> micMuted;
1549 setMic(); 1555 setMic();
1550 emit micChanged( micMuted ); 1556 emit micChanged( micMuted );
1551 } 1557 }
1552 else if ( msg == "setBass(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> 1558 else if ( msg == "setBass(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org>
1553 int t, v; 1559 int t, v;
1554 stream >> t >> v; 1560 stream >> t >> v;
1555 setBass( t, v ); 1561 setBass( t, v );
1556 } 1562 }
1557 else if ( msg == "bassChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> 1563 else if ( msg == "bassChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org>
1558 setBass(); 1564 setBass();
1559 } 1565 }
1560 else if ( msg == "setTreble(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> 1566 else if ( msg == "setTreble(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org>
1561 int t, v; 1567 int t, v;
1562 stream >> t >> v; 1568 stream >> t >> v;
1563 setTreble( t, v ); 1569 setTreble( t, v );
1564 } 1570 }
1565 else if ( msg == "trebleChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> 1571 else if ( msg == "trebleChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org>
1566 setTreble(); 1572 setTreble();
1567 } else if ( msg == "getMarkedText()" ) { 1573 } else if ( msg == "getMarkedText()" ) {
1568 if ( type() == GuiServer ) { 1574 if ( type() == GuiServer ) {
1569 const ushort unicode = 'C'-'@'; 1575 const ushort unicode = 'C'-'@';
1570 const int scan = Key_C; 1576 const int scan = Key_C;
1571 qwsServer->processKeyEvent( unicode, scan, ControlButton, TRUE, FALSE ); 1577 qwsServer->processKeyEvent( unicode, scan, ControlButton, TRUE, FALSE );
1572 qwsServer->processKeyEvent( unicode, scan, ControlButton, FALSE, FALSE ); 1578 qwsServer->processKeyEvent( unicode, scan, ControlButton, FALSE, FALSE );
1573 } 1579 }
1574 } else if ( msg == "newChannel(QString)") { 1580 } else if ( msg == "newChannel(QString)") {
1575 QString myChannel = "QPE/Application/" + d->appName; 1581 QString myChannel = "QPE/Application/" + d->appName;
1576 QString channel; 1582 QString channel;
1577 stream >> channel; 1583 stream >> channel;
1578 if (channel == myChannel) { 1584 if (channel == myChannel) {
1579 processQCopFile(); 1585 processQCopFile();
1580 d->sendQCopQ(); 1586 d->sendQCopQ();
1581 } 1587 }
1582 } 1588 }
1583 1589
1584 1590
1585#endif 1591#endif
1586} 1592}
1587 1593
1588 1594
1589 1595
1590 1596
1591 1597
1592/*! 1598/*!
1593 \internal 1599 \internal
1594*/ 1600*/
1595bool QPEApplication::raiseAppropriateWindow() 1601bool QPEApplication::raiseAppropriateWindow()
1596{ 1602{
1597 bool r=FALSE; 1603 bool r=FALSE;
1598 1604
1599 // 1. Raise the main widget 1605 // 1. Raise the main widget
1600 QWidget *top = d->qpe_main_widget; 1606 QWidget *top = d->qpe_main_widget;
1601 if ( !top ) top = mainWidget(); 1607 if ( !top ) top = mainWidget();
1602 1608
1603 if ( top && d->keep_running ) { 1609 if ( top && d->keep_running ) {
1604 if ( top->isVisible() ) 1610 if ( top->isVisible() )
1605 r = TRUE; 1611 r = TRUE;
1606 else if (d->preloaded) { 1612 else if (d->preloaded) {
1607 // We are preloaded and not visible.. pretend we just started.. 1613 // We are preloaded and not visible.. pretend we just started..
1608#ifndef QT_NO_COP 1614#ifndef QT_NO_COP
1609 QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); 1615 QCopEnvelope e("QPE/System", "fastAppShowing(QString)");
1610 e << d->appName; 1616 e << d->appName;
1611#endif 1617#endif
1612 } 1618 }
1613 1619
1614 d->show_mx(top,d->nomaximize, d->appName); 1620 d->show_mx(top,d->nomaximize, d->appName);
1615 top->raise(); 1621 top->raise();
1616 } 1622 }
1617 1623
1618 QWidget *topm = activeModalWidget(); 1624 QWidget *topm = activeModalWidget();
1619 1625
1620 // 2. Raise any parentless widgets (except top and topm, as they 1626 // 2. Raise any parentless widgets (except top and topm, as they
1621 // are raised before and after this loop). Order from most 1627 // are raised before and after this loop). Order from most
1622 // recently raised as deepest to least recently as top, so 1628 // recently raised as deepest to least recently as top, so
1623 // that repeated calls cycle through widgets. 1629 // that repeated calls cycle through widgets.
1624 QWidgetList *list = topLevelWidgets(); 1630 QWidgetList *list = topLevelWidgets();
1625 if ( list ) { 1631 if ( list ) {
1626 bool foundlast = FALSE; 1632 bool foundlast = FALSE;
1627 QWidget* topsub = 0; 1633 QWidget* topsub = 0;
1628 if ( d->lastraised ) { 1634 if ( d->lastraised ) {
1629 for (QWidget* w = list->first(); w; w = list->next()) { 1635 for (QWidget* w = list->first(); w; w = list->next()) {
1630 if ( !w->parentWidget() && w != topm && w->isVisible() && !w->isDesktop() ) { 1636 if ( !w->parentWidget() && w != topm && w->isVisible() && !w->isDesktop() ) {
1631 if ( w == d->lastraised ) 1637 if ( w == d->lastraised )
1632 foundlast = TRUE; 1638 foundlast = TRUE;
1633 if ( foundlast ) { 1639 if ( foundlast ) {
1634 w->raise(); 1640 w->raise();
1635 topsub = w; 1641 topsub = w;
1636 } 1642 }
1637 } 1643 }
1638 } 1644 }
1639 } 1645 }
1640 for (QWidget* w = list->first(); w; w = list->next()) { 1646 for (QWidget* w = list->first(); w; w = list->next()) {
1641 if ( !w->parentWidget() && w != topm && w->isVisible() && !w->isDesktop() ) { 1647 if ( !w->parentWidget() && w != topm && w->isVisible() && !w->isDesktop() ) {
1642 if ( w == d->lastraised ) 1648 if ( w == d->lastraised )
1643 break; 1649 break;
1644 w->raise(); 1650 w->raise();
1645 topsub = w; 1651 topsub = w;
1646 } 1652 }
1647 } 1653 }
1648 d->lastraised = topsub; 1654 d->lastraised = topsub;
1649 delete list; 1655 delete list;
1650 } 1656 }
1651 1657
1652 // 3. Raise the active modal widget. 1658 // 3. Raise the active modal widget.
1653 if ( topm ) { 1659 if ( topm ) {
1654 topm->show(); 1660 topm->show();
1655 topm->raise(); 1661 topm->raise();
1656 // If we haven't already handled the fastAppShowing message 1662 // If we haven't already handled the fastAppShowing message
1657 if (!top && d->preloaded) { 1663 if (!top && d->preloaded) {
1658#ifndef QT_NO_COP 1664#ifndef QT_NO_COP
1659 QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); 1665 QCopEnvelope e("QPE/System", "fastAppShowing(QString)");
1660 e << d->appName; 1666 e << d->appName;
1661#endif 1667#endif
1662 } 1668 }
1663 r = FALSE; 1669 r = FALSE;
1664 } 1670 }
1665 1671
1666 return r; 1672 return r;
1667} 1673}
1668 1674
1669 1675
1670void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data) 1676void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data)
1671{ 1677{
1672#ifdef Q_WS_QWS 1678#ifdef Q_WS_QWS
1673 1679
1674 if ( msg == "quit()" ) { 1680 if ( msg == "quit()" ) {
1675 tryQuit(); 1681 tryQuit();
1676 } 1682 }
1677 else if ( msg == "quitIfInvisible()" ) { 1683 else if ( msg == "quitIfInvisible()" ) {
1678 if ( d->qpe_main_widget && !d->qpe_main_widget->isVisible() ) 1684 if ( d->qpe_main_widget && !d->qpe_main_widget->isVisible() )
1679 quit(); 1685 quit();
1680 } 1686 }
1681 else if ( msg == "close()" ) { 1687 else if ( msg == "close()" ) {
1682 hideOrQuit(); 1688 hideOrQuit();
1683 } 1689 }
1684 else if ( msg == "disablePreload()" ) { 1690 else if ( msg == "disablePreload()" ) {
1685 d->preloaded = FALSE; 1691 d->preloaded = FALSE;
1686 d->keep_running = TRUE; 1692 d->keep_running = TRUE;
1687 /* so that quit will quit */ 1693 /* so that quit will quit */
1688 } 1694 }
1689 else if ( msg == "enablePreload()" ) { 1695 else if ( msg == "enablePreload()" ) {
1690 if (d->qpe_main_widget) 1696 if (d->qpe_main_widget)
1691 d->preloaded = TRUE; 1697 d->preloaded = TRUE;
1692 d->keep_running = TRUE; 1698 d->keep_running = TRUE;
1693 /* so next quit won't quit */ 1699 /* so next quit won't quit */
1694 } 1700 }
1695 else if ( msg == "raise()" ) { 1701 else if ( msg == "raise()" ) {
1696 d->keep_running = TRUE; 1702 d->keep_running = TRUE;
1697 d->notbusysent = FALSE; 1703 d->notbusysent = FALSE;
1698 raiseAppropriateWindow(); 1704 raiseAppropriateWindow();
1699 // Tell the system we're still chugging along... 1705 // Tell the system we're still chugging along...
1700 QCopEnvelope e("QPE/System", "appRaised(QString)"); 1706 QCopEnvelope e("QPE/System", "appRaised(QString)");
1701 e << d->appName; 1707 e << d->appName;
1702 } 1708 }
1703 else if ( msg == "flush()" ) { 1709 else if ( msg == "flush()" ) {
1704 emit flush(); 1710 emit flush();
1705 // we need to tell the desktop 1711 // we need to tell the desktop
1706 QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" ); 1712 QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" );
1707 e << d->appName; 1713 e << d->appName;
1708 } 1714 }
1709 else if ( msg == "reload()" ) { 1715 else if ( msg == "reload()" ) {
1710 emit reload(); 1716 emit reload();
1711 } 1717 }
1712 else if ( msg == "setDocument(QString)" ) { 1718 else if ( msg == "setDocument(QString)" ) {
1713 d->keep_running = TRUE; 1719 d->keep_running = TRUE;
1714 QDataStream stream( data, IO_ReadOnly ); 1720 QDataStream stream( data, IO_ReadOnly );
1715 QString doc; 1721 QString doc;
1716 stream >> doc; 1722 stream >> doc;
1717 QWidget *mw = mainWidget(); 1723 QWidget *mw = mainWidget();
1718 if ( !mw ) 1724 if ( !mw )
1719 mw = d->qpe_main_widget; 1725 mw = d->qpe_main_widget;
1720 if ( mw ) 1726 if ( mw )
1721 Global::setDocument( mw, doc ); 1727 Global::setDocument( mw, doc );
1722 1728
1723 } else if ( msg == "QPEProcessQCop()" ) { 1729 } else if ( msg == "QPEProcessQCop()" ) {
1724 processQCopFile(); 1730 processQCopFile();
1725 d->sendQCopQ(); 1731 d->sendQCopQ();
1726 }else 1732 }else
1727 { 1733 {
1728 bool p = d->keep_running; 1734 bool p = d->keep_running;
1729 d->keep_running = FALSE; 1735 d->keep_running = FALSE;
1730 emit appMessage( msg, data); 1736 emit appMessage( msg, data);
1731 if ( d->keep_running ) { 1737 if ( d->keep_running ) {
1732 d->notbusysent = FALSE; 1738 d->notbusysent = FALSE;
1733 raiseAppropriateWindow(); 1739 raiseAppropriateWindow();
1734 if ( !p ) { 1740 if ( !p ) {
1735 // Tell the system we're still chugging along... 1741 // Tell the system we're still chugging along...
1736#ifndef QT_NO_COP 1742#ifndef QT_NO_COP
1737 QCopEnvelope e("QPE/System", "appRaised(QString)"); 1743 QCopEnvelope e("QPE/System", "appRaised(QString)");
1738 e << d->appName; 1744 e << d->appName;
1739#endif 1745#endif
1740 } 1746 }
1741 } 1747 }
1742 if ( p ) 1748 if ( p )
1743 d->keep_running = p; 1749 d->keep_running = p;
1744 } 1750 }
1745#endif 1751#endif
1746} 1752}
1747 1753
1748 1754
1749/*! 1755/*!
1750 Sets widget \a mw as the mainWidget() and shows it. For small windows, 1756 Sets widget \a mw as the mainWidget() and shows it. For small windows,
1751 consider passing TRUE for \a nomaximize rather than the default FALSE. 1757 consider passing TRUE for \a nomaximize rather than the default FALSE.
1752 1758
1753 \sa showMainDocumentWidget() 1759 \sa showMainDocumentWidget()
1754*/ 1760*/
1755void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize ) 1761void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize )
1756{ 1762{
1757// setMainWidget(mw); this breaks FastLoading because lastWindowClose() would quit 1763// setMainWidget(mw); this breaks FastLoading because lastWindowClose() would quit
1758 d->show(mw, nomaximize ); 1764 d->show(mw, nomaximize );
1759} 1765}
1760 1766
1761/*! 1767/*!
1762 Sets widget \a mw as the mainWidget() and shows it. For small windows, 1768 Sets widget \a mw as the mainWidget() and shows it. For small windows,
1763 consider passing TRUE for \a nomaximize rather than the default FALSE. 1769 consider passing TRUE for \a nomaximize rather than the default FALSE.
1764 1770
1765 This calls designates the application as 1771 This calls designates the application as
1766 a \link docwidget.html document-oriented\endlink application. 1772 a \link docwidget.html document-oriented\endlink application.
1767 1773
1768 The \a mw widget \e must have this slot: setDocument(const QString&). 1774 The \a mw widget \e must have this slot: setDocument(const QString&).
1769 1775
1770 \sa showMainWidget() 1776 \sa showMainWidget()
1771*/ 1777*/
1772void QPEApplication::showMainDocumentWidget( QWidget* mw, bool nomaximize ) 1778void QPEApplication::showMainDocumentWidget( QWidget* mw, bool nomaximize )
1773{ 1779{
1774 if ( mw && argc() == 2 ) 1780 if ( mw && argc() == 2 )
1775 Global::setDocument( mw, QString::fromUtf8(argv()[1]) ); 1781 Global::setDocument( mw, QString::fromUtf8(argv()[1]) );
1776 1782
1777 1783
1778// setMainWidget(mw); see above 1784// setMainWidget(mw); see above
1779 d->show(mw, nomaximize ); 1785 d->show(mw, nomaximize );
1780} 1786}
1781 1787
1782 1788
1783/*! 1789/*!
1784 If an application is started via a \link qcop.html QCop\endlink 1790 If an application is started via a \link qcop.html QCop\endlink
1785 message, the application will process the \link qcop.html 1791 message, the application will process the \link qcop.html
1786 QCop\endlink message and then quit. If the application calls this 1792 QCop\endlink message and then quit. If the application calls this
1787 function while processing a \link qcop.html QCop\endlink message, 1793 function while processing a \link qcop.html QCop\endlink message,
1788 after processing its outstanding \link qcop.html QCop\endlink 1794 after processing its outstanding \link qcop.html QCop\endlink
1789 messages the application will start 'properly' and show itself. 1795 messages the application will start 'properly' and show itself.
1790 1796
1791 \sa keepRunning() 1797 \sa keepRunning()
1792*/ 1798*/
1793void QPEApplication::setKeepRunning() 1799void QPEApplication::setKeepRunning()
1794{ 1800{
1795 if ( qApp && qApp->inherits( "QPEApplication" ) ) { 1801 if ( qApp && qApp->inherits( "QPEApplication" ) ) {
1796 QPEApplication * qpeApp = ( QPEApplication* ) qApp; 1802 QPEApplication * qpeApp = ( QPEApplication* ) qApp;
1797 qpeApp->d->keep_running = TRUE; 1803 qpeApp->d->keep_running = TRUE;
1798 } 1804 }
1799} 1805}
1800 1806
1801/*! 1807/*!
1802 Returns TRUE if the application will quit after processing the 1808 Returns TRUE if the application will quit after processing the
1803 current list of qcop messages; otherwise returns FALSE. 1809 current list of qcop messages; otherwise returns FALSE.
1804 1810
1805 \sa setKeepRunning() 1811 \sa setKeepRunning()
1806*/ 1812*/
1807bool QPEApplication::keepRunning() const 1813bool QPEApplication::keepRunning() const
1808{ 1814{
1809 return d->keep_running; 1815 return d->keep_running;
1810} 1816}
1811 1817
1812/*! 1818/*!
1813 \internal 1819 \internal
1814*/ 1820*/
1815void QPEApplication::internalSetStyle( const QString &style ) 1821void QPEApplication::internalSetStyle( const QString &style )
1816{ 1822{
1817#if QT_VERSION >= 300 1823#if QT_VERSION >= 300
1818 if ( style == "QPE" ) { 1824 if ( style == "QPE" ) {
1819 setStyle( new QPEStyle ); 1825 setStyle( new QPEStyle );
1820 } 1826 }
1821 else { 1827 else {
1822 QStyle *s = QStyleFactory::create( style ); 1828 QStyle *s = QStyleFactory::create( style );
1823 if ( s ) 1829 if ( s )
1824 setStyle( s ); 1830 setStyle( s );
1825 } 1831 }
1826#else 1832#else
1827 if ( style == "Windows" ) { 1833 if ( style == "Windows" ) {
1828 setStyle( new QWindowsStyle ); 1834 setStyle( new QWindowsStyle );
1829 } 1835 }
1830 else if ( style == "QPE" ) { 1836 else if ( style == "QPE" ) {
1831 setStyle( new QPEStyle ); 1837 setStyle( new QPEStyle );
1832 } 1838 }
1833 else if ( style == "Light" ) { 1839 else if ( style == "Light" ) {
1834 setStyle( new LightStyle ); 1840 setStyle( new LightStyle );
1835 } 1841 }
1836#ifndef QT_NO_STYLE_PLATINUM 1842#ifndef QT_NO_STYLE_PLATINUM
1837 else if ( style == "Platinum" ) { 1843 else if ( style == "Platinum" ) {
1838 setStyle( new QPlatinumStyle ); 1844 setStyle( new QPlatinumStyle );
1839 } 1845 }
1840#endif 1846#endif
1841#ifndef QT_NO_STYLE_MOTIF 1847#ifndef QT_NO_STYLE_MOTIF
1842 else if ( style == "Motif" ) { 1848 else if ( style == "Motif" ) {
1843 setStyle( new QMotifStyle ); 1849 setStyle( new QMotifStyle );
1844 } 1850 }
1845#endif 1851#endif
1846#ifndef QT_NO_STYLE_MOTIFPLUS 1852#ifndef QT_NO_STYLE_MOTIFPLUS
1847 else if ( style == "MotifPlus" ) { 1853 else if ( style == "MotifPlus" ) {
1848 setStyle( new QMotifPlusStyle ); 1854 setStyle( new QMotifPlusStyle );
1849 } 1855 }
1850#endif 1856#endif
1851 1857
1852 else { 1858 else {
1853 QStyle *sty = 0; 1859 QStyle *sty = 0;
1854 QString path = QPEApplication::qpeDir ( ) + "/plugins/styles/"; 1860 QString path = QPEApplication::qpeDir ( ) + "/plugins/styles/";
1855 1861
1856#ifdef Q_OS_MACX 1862#ifdef Q_OS_MACX
1857 if ( style. find ( ".dylib" ) > 0 ) 1863 if ( style. find ( ".dylib" ) > 0 )
1858 path += style; 1864 path += style;
1859 else 1865 else
1860 path = path + "lib" + style. lower ( ) + ".dylib"; // compatibility 1866 path = path + "lib" + style. lower ( ) + ".dylib"; // compatibility
1861#else 1867#else
1862 if ( style. find ( ".so" ) > 0 ) 1868 if ( style. find ( ".so" ) > 0 )
1863 path += style; 1869 path += style;
1864 else 1870 else
1865 path = path + "lib" + style. lower ( ) + ".so"; // compatibility 1871 path = path + "lib" + style. lower ( ) + ".so"; // compatibility
1866#endif 1872#endif
1867 static QLibrary *lastlib = 0; 1873 static QLibrary *lastlib = 0;
1868 static StyleInterface *lastiface = 0; 1874 static StyleInterface *lastiface = 0;
1869 1875
1870 QLibrary *lib = new QLibrary ( path ); 1876 QLibrary *lib = new QLibrary ( path );
1871 StyleInterface *iface = 0; 1877 StyleInterface *iface = 0;
1872 1878
1873 if (( lib-> queryInterface ( IID_Style, ( QUnknownInterface ** ) &iface ) == QS_OK ) && iface ) 1879 if (( lib-> queryInterface ( IID_Style, ( QUnknownInterface ** ) &iface ) == QS_OK ) && iface )
1874 sty = iface-> style ( ); 1880 sty = iface-> style ( );
1875 1881
1876 if ( sty ) { 1882 if ( sty ) {
1877 setStyle ( sty ); 1883 setStyle ( sty );
1878 1884
1879 if ( lastiface ) 1885 if ( lastiface )
1880 lastiface-> release ( ); 1886 lastiface-> release ( );
1881 lastiface = iface; 1887 lastiface = iface;
1882 1888
1883 if ( lastlib ) { 1889 if ( lastlib ) {
1884 lastlib-> unload ( ); 1890 lastlib-> unload ( );
1885 delete lastlib; 1891 delete lastlib;
1886 } 1892 }
1887 lastlib = lib; 1893 lastlib = lib;
1888 } 1894 }
1889 else { 1895 else {
1890 if ( iface ) 1896 if ( iface )
1891 iface-> release ( ); 1897 iface-> release ( );
1892 delete lib; 1898 delete lib;
1893 1899
1894 setStyle ( new LightStyle ( )); 1900 setStyle ( new LightStyle ( ));
1895 } 1901 }
1896 } 1902 }
1897#endif 1903#endif
1898} 1904}
1899 1905
1900/*! 1906/*!
1901 \internal 1907 \internal
1902*/ 1908*/
1903void QPEApplication::prepareForTermination( bool willrestart ) 1909void QPEApplication::prepareForTermination( bool willrestart )
1904{ 1910{
1905 if ( willrestart ) { 1911 if ( willrestart ) {
1906 // Draw a big wait icon, the image can be altered in later revisions 1912 // Draw a big wait icon, the image can be altered in later revisions
1907 // QWidget *d = QApplication::desktop(); 1913 // QWidget *d = QApplication::desktop();
1908 QImage img = Resource::loadImage( "launcher/new_wait" ); 1914 QImage img = Resource::loadImage( "launcher/new_wait" );
1909 QPixmap pix; 1915 QPixmap pix;
1910 pix.convertFromImage( img.smoothScale( 1 * img.width(), 1 * img.height() ) ); 1916 pix.convertFromImage( img.smoothScale( 1 * img.width(), 1 * img.height() ) );
1911 QLabel *lblWait = new QLabel( 0, "wait hack!", QWidget::WStyle_Customize | 1917 QLabel *lblWait = new QLabel( 0, "wait hack!", QWidget::WStyle_Customize |
1912 QWidget::WStyle_NoBorder | QWidget::WStyle_Tool ); 1918 QWidget::WStyle_NoBorder | QWidget::WStyle_Tool );
1913 lblWait->setPixmap( pix ); 1919 lblWait->setPixmap( pix );
1914 lblWait->setAlignment( QWidget::AlignCenter ); 1920 lblWait->setAlignment( QWidget::AlignCenter );
1915 lblWait->show(); 1921 lblWait->show();
1916 lblWait->showMaximized(); 1922 lblWait->showMaximized();
1917 } 1923 }
1918#ifndef SINGLE_APP 1924#ifndef SINGLE_APP
1919 { QCopEnvelope envelope( "QPE/System", "forceQuit()" ); 1925 { QCopEnvelope envelope( "QPE/System", "forceQuit()" );
1920 } 1926 }
1921 processEvents(); // ensure the message goes out. 1927 processEvents(); // ensure the message goes out.
1922 sleep( 1 ); // You have 1 second to comply. 1928 sleep( 1 ); // You have 1 second to comply.
1923#endif 1929#endif
1924} 1930}
1925 1931
1926/*! 1932/*!
1927 \internal 1933 \internal
1928*/ 1934*/
1929void QPEApplication::shutdown() 1935void QPEApplication::shutdown()
1930{ 1936{
1931 // Implement in server's QPEApplication subclass 1937 // Implement in server's QPEApplication subclass
1932} 1938}
1933 1939
1934/*! 1940/*!
1935 \internal 1941 \internal
1936*/ 1942*/
1937void QPEApplication::restart() 1943void QPEApplication::restart()
1938{ 1944{
1939 // Implement in server's QPEApplication subclass 1945 // Implement in server's QPEApplication subclass
1940} 1946}
1941 1947
1942static QPtrDict<void>* stylusDict = 0; 1948static QPtrDict<void>* stylusDict = 0;
1943static void createDict() 1949static void createDict()
1944{ 1950{
1945 if ( !stylusDict ) 1951 if ( !stylusDict )
1946 stylusDict = new QPtrDict<void>; 1952 stylusDict = new QPtrDict<void>;
1947} 1953}
1948 1954
1949/*! 1955/*!
1950 Returns the current StylusMode for widget \a w. 1956 Returns the current StylusMode for widget \a w.
1951 1957
1952 \sa setStylusOperation() StylusMode 1958 \sa setStylusOperation() StylusMode
1953*/ 1959*/
1954QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w ) 1960QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w )
1955{ 1961{
1956 if ( stylusDict ) 1962 if ( stylusDict )
1957 return ( StylusMode ) ( int ) stylusDict->find( w ); 1963 return ( StylusMode ) ( int ) stylusDict->find( w );
1958 return LeftOnly; 1964 return LeftOnly;
1959} 1965}
1960 1966
1961/*! 1967/*!
1962 \enum QPEApplication::StylusMode 1968 \enum QPEApplication::StylusMode
1963 1969
1964 \value LeftOnly the stylus only generates LeftButton 1970 \value LeftOnly the stylus only generates LeftButton
1965 events (the default). 1971 events (the default).
1966 \value RightOnHold the stylus generates RightButton events 1972 \value RightOnHold the stylus generates RightButton events
1967 if the user uses the press-and-hold gesture. 1973 if the user uses the press-and-hold gesture.
1968 1974
1969 \sa setStylusOperation() stylusOperation() 1975 \sa setStylusOperation() stylusOperation()
1970*/ 1976*/
1971 1977
1972/*! 1978/*!
1973 Causes widget \a w to receive mouse events according to the stylus 1979 Causes widget \a w to receive mouse events according to the stylus
1974 \a mode. 1980 \a mode.
1975 1981
1976 \sa stylusOperation() StylusMode 1982 \sa stylusOperation() StylusMode
1977*/ 1983*/
1978void QPEApplication::setStylusOperation( QWidget * w, StylusMode mode ) 1984void QPEApplication::setStylusOperation( QWidget * w, StylusMode mode )
1979{ 1985{
1980 createDict(); 1986 createDict();
1981 if ( mode == LeftOnly ) { 1987 if ( mode == LeftOnly ) {
1982 stylusDict->remove 1988 stylusDict->remove
1983 ( w ); 1989 ( w );
1984 w->removeEventFilter( qApp ); 1990 w->removeEventFilter( qApp );
1985 } 1991 }
1986 else { 1992 else {
1987 stylusDict->insert( w, ( void* ) mode ); 1993 stylusDict->insert( w, ( void* ) mode );
1988 connect( w, SIGNAL( destroyed() ), qApp, SLOT( removeSenderFromStylusDict() ) ); 1994 connect( w, SIGNAL( destroyed() ), qApp, SLOT( removeSenderFromStylusDict() ) );
1989 w->installEventFilter( qApp ); 1995 w->installEventFilter( qApp );
1990 } 1996 }
1991} 1997}
1992 1998
1993 1999
1994/*! 2000/*!
1995 \reimp 2001 \reimp
1996*/ 2002*/
1997bool QPEApplication::eventFilter( QObject *o, QEvent *e ) 2003bool QPEApplication::eventFilter( QObject *o, QEvent *e )
1998{ 2004{
1999 if ( !o->isWidgetType() ) 2005 if ( !o->isWidgetType() )
2000 return FALSE; 2006 return FALSE;
2001 2007
2002 if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) { 2008 if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) {
2003 QMouseEvent * me = ( QMouseEvent* ) e; 2009 QMouseEvent * me = ( QMouseEvent* ) e;
2004 StylusMode mode = (StylusMode)(int)stylusDict->find(o); 2010 StylusMode mode = (StylusMode)(int)stylusDict->find(o);
2005 switch (mode) { 2011 switch (mode) {
2006 case RightOnHold: 2012 case RightOnHold:
2007 switch ( me->type() ) { 2013 switch ( me->type() ) {
2008 case QEvent::MouseButtonPress: 2014 case QEvent::MouseButtonPress:
2009 if ( me->button() == LeftButton ) { 2015 if ( me->button() == LeftButton ) {
2010 if (!d->presstimer ) 2016 if (!d->presstimer )
2011 d->presstimer = startTimer(500); // #### pref. 2017 d->presstimer = startTimer(500); // #### pref.
2012 d->presswidget = (QWidget*)o; 2018 d->presswidget = (QWidget*)o;
2013 d->presspos = me->pos(); 2019 d->presspos = me->pos();
2014 d->rightpressed = FALSE; 2020 d->rightpressed = FALSE;
2015 } 2021 }
2016 break; 2022 break;
2017 case QEvent::MouseMove: 2023 case QEvent::MouseMove:
2018 if (d->presstimer && (me->pos() - d->presspos).manhattanLength() > 8) { 2024 if (d->presstimer && (me->pos() - d->presspos).manhattanLength() > 8) {
2019 killTimer(d->presstimer); 2025 killTimer(d->presstimer);
2020 d->presstimer = 0; 2026 d->presstimer = 0;
2021 } 2027 }
2022 break; 2028 break;
2023 case QEvent::MouseButtonRelease: 2029 case QEvent::MouseButtonRelease:
2024 if ( me->button() == LeftButton ) { 2030 if ( me->button() == LeftButton ) {
2025 if ( d->presstimer ) { 2031 if ( d->presstimer ) {
2026 killTimer(d->presstimer); 2032 killTimer(d->presstimer);
2027 d->presstimer = 0; 2033 d->presstimer = 0;
2028 } 2034 }
2029 if ( d->rightpressed && d->presswidget ) { 2035 if ( d->rightpressed && d->presswidget ) {
2030 // Right released 2036 // Right released
2031 postEvent( d->presswidget, 2037 postEvent( d->presswidget,
2032 new QMouseEvent( QEvent::MouseButtonRelease, me->pos(), 2038 new QMouseEvent( QEvent::MouseButtonRelease, me->pos(),
2033 RightButton, LeftButton + RightButton ) ); 2039 RightButton, LeftButton + RightButton ) );
2034 // Left released, off-widget 2040 // Left released, off-widget
2035 postEvent( d->presswidget, 2041 postEvent( d->presswidget,
2036 new QMouseEvent( QEvent::MouseMove, QPoint( -1, -1), 2042 new QMouseEvent( QEvent::MouseMove, QPoint( -1, -1),
2037 LeftButton, LeftButton ) ); 2043 LeftButton, LeftButton ) );
2038 postEvent( d->presswidget, 2044 postEvent( d->presswidget,
2039 new QMouseEvent( QEvent::MouseButtonRelease, QPoint( -1, -1), 2045 new QMouseEvent( QEvent::MouseButtonRelease, QPoint( -1, -1),
2040 LeftButton, LeftButton ) ); 2046 LeftButton, LeftButton ) );
2041 d->rightpressed = FALSE; 2047 d->rightpressed = FALSE;
2042 return TRUE; // don't send the real Left release 2048 return TRUE; // don't send the real Left release
2043 } 2049 }
2044 } 2050 }
2045 break; 2051 break;
2046 default: 2052 default:
2047 break; 2053 break;
2048 } 2054 }
2049 break; 2055 break;
2050 default: 2056 default:
2051 ; 2057 ;
2052 } 2058 }
2053 } 2059 }
2054 else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { 2060 else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) {
2055 QKeyEvent *ke = (QKeyEvent *)e; 2061 QKeyEvent *ke = (QKeyEvent *)e;
2056 if ( ke->key() == Key_Enter ) { 2062 if ( ke->key() == Key_Enter ) {
2057 if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) { 2063 if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) {
2058 postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ', 2064 postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ',
2059 ke->state(), " ", ke->isAutoRepeat(), ke->count() ) ); 2065 ke->state(), " ", ke->isAutoRepeat(), ke->count() ) );
2060 return TRUE; 2066 return TRUE;
2061 } 2067 }
2062 } 2068 }
2063 } 2069 }
2064 return FALSE; 2070 return FALSE;
2065} 2071}
2066 2072
2067/*! 2073/*!
2068 \reimp 2074 \reimp
2069*/ 2075*/
2070void QPEApplication::timerEvent( QTimerEvent *e ) 2076void QPEApplication::timerEvent( QTimerEvent *e )
2071{ 2077{
2072 if ( e->timerId() == d->presstimer && d->presswidget ) { 2078 if ( e->timerId() == d->presstimer && d->presswidget ) {
2073 // Right pressed 2079 // Right pressed
2074 postEvent( d->presswidget, 2080 postEvent( d->presswidget,
2075 new QMouseEvent( QEvent::MouseButtonPress, d->presspos, 2081 new QMouseEvent( QEvent::MouseButtonPress, d->presspos,
2076 RightButton, LeftButton ) ); 2082 RightButton, LeftButton ) );
2077 killTimer( d->presstimer ); 2083 killTimer( d->presstimer );
2078 d->presstimer = 0; 2084 d->presstimer = 0;
2079 d->rightpressed = TRUE; 2085 d->rightpressed = TRUE;
2080 } 2086 }
2081} 2087}
2082 2088
2083void QPEApplication::removeSenderFromStylusDict() 2089void QPEApplication::removeSenderFromStylusDict()
2084{ 2090{