author | zecke <zecke> | 2002-09-25 18:15:58 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-09-25 18:15:58 (UTC) |
commit | c96507591791d48a6d6dad3de6c15739c84e1c93 (patch) (unidiff) | |
tree | f5476860497023dd6d9e1c82c61cc6bb3f61a6da /library | |
parent | d44c455b86d6cccbc497e3e8d8aa399096eff7db (diff) | |
download | opie-c96507591791d48a6d6dad3de6c15739c84e1c93.zip opie-c96507591791d48a6d6dad3de6c15739c84e1c93.tar.gz opie-c96507591791d48a6d6dad3de6c15739c84e1c93.tar.bz2 |
ljps patch was/is correct
but for some reason TT is not using QFile
so I made it use getenv(HOME) instead
-rw-r--r-- | library/qpeapplication.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp index bdf67b9..533d7bd 100644 --- a/library/qpeapplication.cpp +++ b/library/qpeapplication.cpp | |||
@@ -555,513 +555,517 @@ QPEApplication::QPEApplication( int & argc, char **argv, Type t ) | |||
555 | } | 555 | } |
556 | #endif | 556 | #endif |
557 | 557 | ||
558 | applyStyle(); | 558 | applyStyle(); |
559 | 559 | ||
560 | if ( type() == GuiServer ) { | 560 | if ( type() == GuiServer ) { |
561 | setVolume(); | 561 | setVolume(); |
562 | } | 562 | } |
563 | 563 | ||
564 | installEventFilter( this ); | 564 | installEventFilter( this ); |
565 | 565 | ||
566 | QPEMenuToolFocusManager::initialize(); | 566 | QPEMenuToolFocusManager::initialize(); |
567 | 567 | ||
568 | #ifdef QT_NO_QWS_CURSOR | 568 | #ifdef QT_NO_QWS_CURSOR |
569 | // if we have no cursor, probably don't want tooltips | 569 | // if we have no cursor, probably don't want tooltips |
570 | QToolTip::setEnabled( FALSE ); | 570 | QToolTip::setEnabled( FALSE ); |
571 | #endif | 571 | #endif |
572 | } | 572 | } |
573 | 573 | ||
574 | static QPtrDict<void>* inputMethodDict = 0; | 574 | static QPtrDict<void>* inputMethodDict = 0; |
575 | static void createInputMethodDict() | 575 | static void createInputMethodDict() |
576 | { | 576 | { |
577 | if ( !inputMethodDict ) | 577 | if ( !inputMethodDict ) |
578 | inputMethodDict = new QPtrDict<void>; | 578 | inputMethodDict = new QPtrDict<void>; |
579 | } | 579 | } |
580 | 580 | ||
581 | /*! | 581 | /*! |
582 | Returns the currently set hint to the system as to whether | 582 | Returns the currently set hint to the system as to whether |
583 | widget \a w has any use for text input methods. | 583 | widget \a w has any use for text input methods. |
584 | 584 | ||
585 | 585 | ||
586 | \sa setInputMethodHint() InputMethodHint | 586 | \sa setInputMethodHint() InputMethodHint |
587 | */ | 587 | */ |
588 | QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w ) | 588 | QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w ) |
589 | { | 589 | { |
590 | if ( inputMethodDict && w ) | 590 | if ( inputMethodDict && w ) |
591 | return ( InputMethodHint ) ( int ) inputMethodDict->find( w ); | 591 | return ( InputMethodHint ) ( int ) inputMethodDict->find( w ); |
592 | return Normal; | 592 | return Normal; |
593 | } | 593 | } |
594 | 594 | ||
595 | /*! | 595 | /*! |
596 | \enum QPEApplication::InputMethodHint | 596 | \enum QPEApplication::InputMethodHint |
597 | 597 | ||
598 | \value Normal the application sometimes needs text input (the default). | 598 | \value Normal the application sometimes needs text input (the default). |
599 | \value AlwaysOff the application never needs text input. | 599 | \value AlwaysOff the application never needs text input. |
600 | \value AlwaysOn the application always needs text input. | 600 | \value AlwaysOn the application always needs text input. |
601 | */ | 601 | */ |
602 | 602 | ||
603 | /*! | 603 | /*! |
604 | Hints to the system that widget \a w has use for text input methods | 604 | Hints to the system that widget \a w has use for text input methods |
605 | as specified by \a mode. | 605 | as specified by \a mode. |
606 | 606 | ||
607 | \sa inputMethodHint() InputMethodHint | 607 | \sa inputMethodHint() InputMethodHint |
608 | */ | 608 | */ |
609 | void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode ) | 609 | void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode ) |
610 | { | 610 | { |
611 | createInputMethodDict(); | 611 | createInputMethodDict(); |
612 | if ( mode == Normal ) { | 612 | if ( mode == Normal ) { |
613 | inputMethodDict->remove | 613 | inputMethodDict->remove |
614 | ( w ); | 614 | ( w ); |
615 | } | 615 | } |
616 | else { | 616 | else { |
617 | inputMethodDict->insert( w, ( void* ) mode ); | 617 | inputMethodDict->insert( w, ( void* ) mode ); |
618 | } | 618 | } |
619 | } | 619 | } |
620 | 620 | ||
621 | class HackDialog : public QDialog | 621 | class HackDialog : public QDialog |
622 | { | 622 | { |
623 | public: | 623 | public: |
624 | void acceptIt() { accept(); } | 624 | void acceptIt() { accept(); } |
625 | void rejectIt() { reject(); } | 625 | void rejectIt() { reject(); } |
626 | }; | 626 | }; |
627 | 627 | ||
628 | 628 | ||
629 | void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key ) | 629 | void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key ) |
630 | { | 630 | { |
631 | // specialised actions for certain widgets. May want to | 631 | // specialised actions for certain widgets. May want to |
632 | // add more stuff here. | 632 | // add more stuff here. |
633 | if ( activePopupWidget() && activePopupWidget() ->inherits( "QListBox" ) | 633 | if ( activePopupWidget() && activePopupWidget() ->inherits( "QListBox" ) |
634 | && activePopupWidget() ->parentWidget() | 634 | && activePopupWidget() ->parentWidget() |
635 | && activePopupWidget() ->parentWidget() ->inherits( "QComboBox" ) ) | 635 | && activePopupWidget() ->parentWidget() ->inherits( "QComboBox" ) ) |
636 | key = Qt::Key_Return; | 636 | key = Qt::Key_Return; |
637 | 637 | ||
638 | if ( activePopupWidget() && activePopupWidget() ->inherits( "QPopupMenu" ) ) | 638 | if ( activePopupWidget() && activePopupWidget() ->inherits( "QPopupMenu" ) ) |
639 | key = Qt::Key_Return; | 639 | key = Qt::Key_Return; |
640 | 640 | ||
641 | #ifdef QWS | 641 | #ifdef QWS |
642 | ke->simpleData.keycode = key; | 642 | ke->simpleData.keycode = key; |
643 | #endif | 643 | #endif |
644 | } | 644 | } |
645 | 645 | ||
646 | class HackWidget : public QWidget | 646 | class HackWidget : public QWidget |
647 | { | 647 | { |
648 | public: | 648 | public: |
649 | bool needsOk() | 649 | bool needsOk() |
650 | { return ( getWState() & WState_Reserved1 ); } | 650 | { return ( getWState() & WState_Reserved1 ); } |
651 | }; | 651 | }; |
652 | 652 | ||
653 | /*! | 653 | /*! |
654 | \internal | 654 | \internal |
655 | */ | 655 | */ |
656 | 656 | ||
657 | #ifdef QWS | 657 | #ifdef QWS |
658 | bool QPEApplication::qwsEventFilter( QWSEvent * e ) | 658 | bool QPEApplication::qwsEventFilter( QWSEvent * e ) |
659 | { | 659 | { |
660 | if ( !d->notbusysent && e->type == QWSEvent::Focus ) { | 660 | if ( !d->notbusysent && e->type == QWSEvent::Focus ) { |
661 | if ( qApp->type() != QApplication::GuiServer ) { | 661 | if ( qApp->type() != QApplication::GuiServer ) { |
662 | QCopEnvelope e( "QPE/System", "notBusy(QString)" ); | 662 | QCopEnvelope e( "QPE/System", "notBusy(QString)" ); |
663 | e << d->appName; | 663 | e << d->appName; |
664 | } | 664 | } |
665 | d->notbusysent = TRUE; | 665 | d->notbusysent = TRUE; |
666 | } | 666 | } |
667 | if ( type() == GuiServer ) { | 667 | if ( type() == GuiServer ) { |
668 | switch ( e->type ) { | 668 | switch ( e->type ) { |
669 | case QWSEvent::Mouse: | 669 | case QWSEvent::Mouse: |
670 | if ( e->asMouse() ->simpleData.state && !QWidget::find( e->window() ) ) | 670 | if ( e->asMouse() ->simpleData.state && !QWidget::find( e->window() ) ) |
671 | emit clientMoused(); | 671 | emit clientMoused(); |
672 | break; | 672 | break; |
673 | default: | 673 | default: |
674 | break; | 674 | break; |
675 | } | 675 | } |
676 | } | 676 | } |
677 | if ( e->type == QWSEvent::Key ) { | 677 | if ( e->type == QWSEvent::Key ) { |
678 | if ( d->kbgrabber == 1 ) | 678 | if ( d->kbgrabber == 1 ) |
679 | return TRUE; | 679 | return TRUE; |
680 | QWSKeyEvent *ke = ( QWSKeyEvent * ) e; | 680 | QWSKeyEvent *ke = ( QWSKeyEvent * ) e; |
681 | if ( ke->simpleData.keycode == Qt::Key_F33 ) { | 681 | if ( ke->simpleData.keycode == Qt::Key_F33 ) { |
682 | // Use special "OK" key to press "OK" on top level widgets | 682 | // Use special "OK" key to press "OK" on top level widgets |
683 | QWidget * active = activeWindow(); | 683 | QWidget * active = activeWindow(); |
684 | QWidget *popup = 0; | 684 | QWidget *popup = 0; |
685 | if ( active && active->isPopup() ) { | 685 | if ( active && active->isPopup() ) { |
686 | popup = active; | 686 | popup = active; |
687 | active = active->parentWidget(); | 687 | active = active->parentWidget(); |
688 | } | 688 | } |
689 | if ( active && ( int ) active->winId() == ke->simpleData.window && | 689 | if ( active && ( int ) active->winId() == ke->simpleData.window && |
690 | !active->testWFlags( WStyle_Customize | WType_Popup | WType_Desktop ) ) { | 690 | !active->testWFlags( WStyle_Customize | WType_Popup | WType_Desktop ) ) { |
691 | if ( ke->simpleData.is_press ) { | 691 | if ( ke->simpleData.is_press ) { |
692 | if ( popup ) | 692 | if ( popup ) |
693 | popup->close(); | 693 | popup->close(); |
694 | if ( active->inherits( "QDialog" ) ) { | 694 | if ( active->inherits( "QDialog" ) ) { |
695 | HackDialog * d = ( HackDialog * ) active; | 695 | HackDialog * d = ( HackDialog * ) active; |
696 | d->acceptIt(); | 696 | d->acceptIt(); |
697 | return TRUE; | 697 | return TRUE; |
698 | } | 698 | } |
699 | else if ( ( ( HackWidget * ) active ) ->needsOk() ) { | 699 | else if ( ( ( HackWidget * ) active ) ->needsOk() ) { |
700 | QSignal s; | 700 | QSignal s; |
701 | s.connect( active, SLOT( accept() ) ); | 701 | s.connect( active, SLOT( accept() ) ); |
702 | s.activate(); | 702 | s.activate(); |
703 | } | 703 | } |
704 | else { | 704 | else { |
705 | // do the same as with the select key: Map to the default action of the widget: | 705 | // do the same as with the select key: Map to the default action of the widget: |
706 | mapToDefaultAction( ke, Qt::Key_Return ); | 706 | mapToDefaultAction( ke, Qt::Key_Return ); |
707 | } | 707 | } |
708 | } | 708 | } |
709 | } | 709 | } |
710 | } else if ( ke->simpleData.keycode == Qt::Key_F30 ) { | 710 | } else if ( ke->simpleData.keycode == Qt::Key_F30 ) { |
711 | // Use special "select" key to do whatever default action a widget has | 711 | // Use special "select" key to do whatever default action a widget has |
712 | mapToDefaultAction( ke, Qt::Key_Space ); | 712 | mapToDefaultAction( ke, Qt::Key_Space ); |
713 | } | 713 | } |
714 | else if ( ke->simpleData.keycode == Qt::Key_Escape && | 714 | else if ( ke->simpleData.keycode == Qt::Key_Escape && |
715 | ke->simpleData.is_press ) { | 715 | ke->simpleData.is_press ) { |
716 | // Escape key closes app if focus on toplevel | 716 | // Escape key closes app if focus on toplevel |
717 | QWidget * active = activeWindow(); | 717 | QWidget * active = activeWindow(); |
718 | if ( active && active->testWFlags( WType_TopLevel ) && | 718 | if ( active && active->testWFlags( WType_TopLevel ) && |
719 | ( int ) active->winId() == ke->simpleData.window && | 719 | ( int ) active->winId() == ke->simpleData.window && |
720 | !active->testWFlags( WStyle_Dialog | WStyle_Customize | WType_Popup | WType_Desktop ) ) { | 720 | !active->testWFlags( WStyle_Dialog | WStyle_Customize | WType_Popup | WType_Desktop ) ) { |
721 | if ( active->inherits( "QDialog" ) ) { | 721 | if ( active->inherits( "QDialog" ) ) { |
722 | HackDialog * d = ( HackDialog * ) active; | 722 | HackDialog * d = ( HackDialog * ) active; |
723 | d->rejectIt(); | 723 | d->rejectIt(); |
724 | return TRUE; | 724 | return TRUE; |
725 | } | 725 | } |
726 | else if ( strcmp( argv() [ 0 ], "embeddedkonsole" ) != 0 ) { | 726 | else if ( strcmp( argv() [ 0 ], "embeddedkonsole" ) != 0 ) { |
727 | active->close(); | 727 | active->close(); |
728 | } | 728 | } |
729 | } | 729 | } |
730 | } | 730 | } |
731 | 731 | ||
732 | #if QT_VERSION < 231 | 732 | #if QT_VERSION < 231 |
733 | // Filter out the F4/Launcher key from apps | 733 | // Filter out the F4/Launcher key from apps |
734 | // ### The launcher key may not always be F4 on all devices | 734 | // ### The launcher key may not always be F4 on all devices |
735 | if ( ( ( QWSKeyEvent * ) e ) ->simpleData.keycode == Qt::Key_F4 ) | 735 | if ( ( ( QWSKeyEvent * ) e ) ->simpleData.keycode == Qt::Key_F4 ) |
736 | return TRUE; | 736 | return TRUE; |
737 | #endif | 737 | #endif |
738 | 738 | ||
739 | } | 739 | } |
740 | if ( e->type == QWSEvent::Focus ) { | 740 | if ( e->type == QWSEvent::Focus ) { |
741 | QWSFocusEvent * fe = ( QWSFocusEvent* ) e; | 741 | QWSFocusEvent * fe = ( QWSFocusEvent* ) e; |
742 | QWidget* nfw = QWidget::find( e->window() ); | 742 | QWidget* nfw = QWidget::find( e->window() ); |
743 | if ( !fe->simpleData.get_focus ) { | 743 | if ( !fe->simpleData.get_focus ) { |
744 | QWidget * active = activeWindow(); | 744 | QWidget * active = activeWindow(); |
745 | while ( active && active->isPopup() ) { | 745 | while ( active && active->isPopup() ) { |
746 | active->close(); | 746 | active->close(); |
747 | active = activeWindow(); | 747 | active = activeWindow(); |
748 | } | 748 | } |
749 | if ( !nfw && d->kbgrabber == 2 ) { | 749 | if ( !nfw && d->kbgrabber == 2 ) { |
750 | ungrabKeyboard(); | 750 | ungrabKeyboard(); |
751 | d->kbregrab = TRUE; // want kb back when we're active | 751 | d->kbregrab = TRUE; // want kb back when we're active |
752 | } | 752 | } |
753 | } | 753 | } |
754 | else { | 754 | else { |
755 | // make sure our modal widget is ALWAYS on top | 755 | // make sure our modal widget is ALWAYS on top |
756 | QWidget *topm = activeModalWidget(); | 756 | QWidget *topm = activeModalWidget(); |
757 | if ( topm ) { | 757 | if ( topm ) { |
758 | topm->raise(); | 758 | topm->raise(); |
759 | } | 759 | } |
760 | if ( d->kbregrab ) { | 760 | if ( d->kbregrab ) { |
761 | grabKeyboard(); | 761 | grabKeyboard(); |
762 | d->kbregrab = FALSE; | 762 | d->kbregrab = FALSE; |
763 | } | 763 | } |
764 | } | 764 | } |
765 | if ( fe->simpleData.get_focus && inputMethodDict ) { | 765 | if ( fe->simpleData.get_focus && inputMethodDict ) { |
766 | InputMethodHint m = inputMethodHint( QWidget::find( e->window() ) ); | 766 | InputMethodHint m = inputMethodHint( QWidget::find( e->window() ) ); |
767 | if ( m == AlwaysOff ) | 767 | if ( m == AlwaysOff ) |
768 | Global::hideInputMethod(); | 768 | Global::hideInputMethod(); |
769 | if ( m == AlwaysOn ) | 769 | if ( m == AlwaysOn ) |
770 | Global::showInputMethod(); | 770 | Global::showInputMethod(); |
771 | } | 771 | } |
772 | } | 772 | } |
773 | return QApplication::qwsEventFilter( e ); | 773 | return QApplication::qwsEventFilter( e ); |
774 | } | 774 | } |
775 | #endif | 775 | #endif |
776 | 776 | ||
777 | /*! | 777 | /*! |
778 | Destroys the QPEApplication. | 778 | Destroys the QPEApplication. |
779 | */ | 779 | */ |
780 | QPEApplication::~QPEApplication() | 780 | QPEApplication::~QPEApplication() |
781 | { | 781 | { |
782 | ungrabKeyboard(); | 782 | ungrabKeyboard(); |
783 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 783 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
784 | // Need to delete QCopChannels early, since the display will | 784 | // Need to delete QCopChannels early, since the display will |
785 | // be gone by the time we get to ~QObject(). | 785 | // be gone by the time we get to ~QObject(). |
786 | delete sysChannel; | 786 | delete sysChannel; |
787 | delete pidChannel; | 787 | delete pidChannel; |
788 | #endif | 788 | #endif |
789 | 789 | ||
790 | delete d; | 790 | delete d; |
791 | } | 791 | } |
792 | 792 | ||
793 | /*! | 793 | /*! |
794 | Returns <tt>$OPIEDIR/</tt>. | 794 | Returns <tt>$OPIEDIR/</tt>. |
795 | */ | 795 | */ |
796 | QString QPEApplication::qpeDir() | 796 | QString QPEApplication::qpeDir() |
797 | { | 797 | { |
798 | const char * base = getenv( "OPIEDIR" ); | 798 | const char * base = getenv( "OPIEDIR" ); |
799 | if ( base ) | 799 | if ( base ) |
800 | return QString( base ) + "/"; | 800 | return QString( base ) + "/"; |
801 | 801 | ||
802 | return QString( "../" ); | 802 | return QString( "../" ); |
803 | } | 803 | } |
804 | 804 | ||
805 | /*! | 805 | /*! |
806 | Returns the user's current Document directory. There is a trailing "/". | 806 | Returns the user's current Document directory. There is a trailing "/". |
807 | .. well, it does now,, and there's no trailing '/' | 807 | .. well, it does now,, and there's no trailing '/' |
808 | */ | 808 | */ |
809 | QString QPEApplication::documentDir() | 809 | QString QPEApplication::documentDir() |
810 | { | 810 | { |
811 | return QString( QDir::homeDirPath() + "/Documents"); | 811 | const char* base = getenv( "HOME"); |
812 | if( base ) | ||
813 | return QString( base ) + "/Documents"; | ||
814 | |||
815 | return QString( "../Documents" ); | ||
812 | } | 816 | } |
813 | 817 | ||
814 | static int deforient = -1; | 818 | static int deforient = -1; |
815 | 819 | ||
816 | /*! | 820 | /*! |
817 | \internal | 821 | \internal |
818 | */ | 822 | */ |
819 | int QPEApplication::defaultRotation() | 823 | int QPEApplication::defaultRotation() |
820 | { | 824 | { |
821 | if ( deforient < 0 ) { | 825 | if ( deforient < 0 ) { |
822 | QString d = getenv( "QWS_DISPLAY" ); | 826 | QString d = getenv( "QWS_DISPLAY" ); |
823 | if ( d.contains( "Rot90" ) ) { | 827 | if ( d.contains( "Rot90" ) ) { |
824 | deforient = 90; | 828 | deforient = 90; |
825 | } | 829 | } |
826 | else if ( d.contains( "Rot180" ) ) { | 830 | else if ( d.contains( "Rot180" ) ) { |
827 | deforient = 180; | 831 | deforient = 180; |
828 | } | 832 | } |
829 | else if ( d.contains( "Rot270" ) ) { | 833 | else if ( d.contains( "Rot270" ) ) { |
830 | deforient = 270; | 834 | deforient = 270; |
831 | } | 835 | } |
832 | else { | 836 | else { |
833 | deforient = 0; | 837 | deforient = 0; |
834 | } | 838 | } |
835 | } | 839 | } |
836 | return deforient; | 840 | return deforient; |
837 | } | 841 | } |
838 | 842 | ||
839 | /*! | 843 | /*! |
840 | \internal | 844 | \internal |
841 | */ | 845 | */ |
842 | void QPEApplication::setDefaultRotation( int r ) | 846 | void QPEApplication::setDefaultRotation( int r ) |
843 | { | 847 | { |
844 | if ( qApp->type() == GuiServer ) { | 848 | if ( qApp->type() == GuiServer ) { |
845 | deforient = r; | 849 | deforient = r; |
846 | setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 ); | 850 | setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 ); |
847 | Config config("qpe"); | 851 | Config config("qpe"); |
848 | config.setGroup( "Rotation" ); | 852 | config.setGroup( "Rotation" ); |
849 | config.writeEntry( "Screen", getenv("QWS_DISPLAY") ); | 853 | config.writeEntry( "Screen", getenv("QWS_DISPLAY") ); |
850 | } else { | 854 | } else { |
851 | #ifndef QT_NO_COP | 855 | #ifndef QT_NO_COP |
852 | { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" ); e << r; } | 856 | { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" ); e << r; } |
853 | #endif | 857 | #endif |
854 | } | 858 | } |
855 | } | 859 | } |
856 | 860 | ||
857 | /*! | 861 | /*! |
858 | \internal | 862 | \internal |
859 | */ | 863 | */ |
860 | void QPEApplication::applyStyle() | 864 | void QPEApplication::applyStyle() |
861 | { | 865 | { |
862 | Config config( "qpe" ); | 866 | Config config( "qpe" ); |
863 | 867 | ||
864 | config.setGroup( "Appearance" ); | 868 | config.setGroup( "Appearance" ); |
865 | 869 | ||
866 | // Widget style | 870 | // Widget style |
867 | QString style = config.readEntry( "Style", "Light" ); | 871 | QString style = config.readEntry( "Style", "Light" ); |
868 | internalSetStyle( style ); | 872 | internalSetStyle( style ); |
869 | 873 | ||
870 | // Colors | 874 | // Colors |
871 | QColor bgcolor( config.readEntry( "Background", "#E5E1D5" ) ); | 875 | QColor bgcolor( config.readEntry( "Background", "#E5E1D5" ) ); |
872 | QColor btncolor( config.readEntry( "Button", "#D6CDBB" ) ); | 876 | QColor btncolor( config.readEntry( "Button", "#D6CDBB" ) ); |
873 | QPalette pal( btncolor, bgcolor ); | 877 | QPalette pal( btncolor, bgcolor ); |
874 | QString color = config.readEntry( "Highlight", "#800000" ); | 878 | QString color = config.readEntry( "Highlight", "#800000" ); |
875 | pal.setColor( QColorGroup::Highlight, QColor( color ) ); | 879 | pal.setColor( QColorGroup::Highlight, QColor( color ) ); |
876 | color = config.readEntry( "HighlightedText", "#FFFFFF" ); | 880 | color = config.readEntry( "HighlightedText", "#FFFFFF" ); |
877 | pal.setColor( QColorGroup::HighlightedText, QColor( color ) ); | 881 | pal.setColor( QColorGroup::HighlightedText, QColor( color ) ); |
878 | color = config.readEntry( "Text", "#000000" ); | 882 | color = config.readEntry( "Text", "#000000" ); |
879 | pal.setColor( QColorGroup::Text, QColor( color ) ); | 883 | pal.setColor( QColorGroup::Text, QColor( color ) ); |
880 | color = config.readEntry( "ButtonText", "#000000" ); | 884 | color = config.readEntry( "ButtonText", "#000000" ); |
881 | pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) ); | 885 | pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) ); |
882 | color = config.readEntry( "Base", "#FFFFFF" ); | 886 | color = config.readEntry( "Base", "#FFFFFF" ); |
883 | pal.setColor( QColorGroup::Base, QColor( color ) ); | 887 | pal.setColor( QColorGroup::Base, QColor( color ) ); |
884 | 888 | ||
885 | pal.setColor( QPalette::Disabled, QColorGroup::Text, | 889 | pal.setColor( QPalette::Disabled, QColorGroup::Text, |
886 | pal.color( QPalette::Active, QColorGroup::Background ).dark() ); | 890 | pal.color( QPalette::Active, QColorGroup::Background ).dark() ); |
887 | 891 | ||
888 | setPalette( pal, TRUE ); | 892 | setPalette( pal, TRUE ); |
889 | 893 | ||
890 | // Window Decoration | 894 | // Window Decoration |
891 | QString dec = config.readEntry( "Decoration", "Qtopia" ); | 895 | QString dec = config.readEntry( "Decoration", "Qtopia" ); |
892 | if ( dec != d->decorationName ) { | 896 | if ( dec != d->decorationName ) { |
893 | qwsSetDecoration( new QPEDecoration( dec ) ); | 897 | qwsSetDecoration( new QPEDecoration( dec ) ); |
894 | d->decorationName = dec; | 898 | d->decorationName = dec; |
895 | } | 899 | } |
896 | 900 | ||
897 | // Font | 901 | // Font |
898 | QString ff = config.readEntry( "FontFamily", font().family() ); | 902 | QString ff = config.readEntry( "FontFamily", font().family() ); |
899 | int fs = config.readNumEntry( "FontSize", font().pointSize() ); | 903 | int fs = config.readNumEntry( "FontSize", font().pointSize() ); |
900 | setFont( QFont(ff,fs) ); | 904 | setFont( QFont(ff,fs) ); |
901 | } | 905 | } |
902 | 906 | ||
903 | void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data ) | 907 | void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data ) |
904 | { | 908 | { |
905 | #ifdef Q_WS_QWS | 909 | #ifdef Q_WS_QWS |
906 | QDataStream stream( data, IO_ReadOnly ); | 910 | QDataStream stream( data, IO_ReadOnly ); |
907 | if ( msg == "applyStyle()" ) { | 911 | if ( msg == "applyStyle()" ) { |
908 | applyStyle(); | 912 | applyStyle(); |
909 | } else if ( msg == "setDefaultRotation(int)" ) { | 913 | } else if ( msg == "setDefaultRotation(int)" ) { |
910 | if ( type() == GuiServer ) { | 914 | if ( type() == GuiServer ) { |
911 | int r; | 915 | int r; |
912 | stream >> r; | 916 | stream >> r; |
913 | setDefaultRotation( r ); | 917 | setDefaultRotation( r ); |
914 | } | 918 | } |
915 | } else if ( msg == "shutdown()" ) { | 919 | } else if ( msg == "shutdown()" ) { |
916 | if ( type() == GuiServer ) | 920 | if ( type() == GuiServer ) |
917 | shutdown(); | 921 | shutdown(); |
918 | } else if ( msg == "quit()" ) { | 922 | } else if ( msg == "quit()" ) { |
919 | if ( type() != GuiServer ) | 923 | if ( type() != GuiServer ) |
920 | tryQuit(); | 924 | tryQuit(); |
921 | } else if ( msg == "forceQuit()" ) { | 925 | } else if ( msg == "forceQuit()" ) { |
922 | if ( type() != GuiServer ) | 926 | if ( type() != GuiServer ) |
923 | quit(); | 927 | quit(); |
924 | } else if ( msg == "restart()" ) { | 928 | } else if ( msg == "restart()" ) { |
925 | if ( type() == GuiServer ) | 929 | if ( type() == GuiServer ) |
926 | restart(); | 930 | restart(); |
927 | } else if ( msg == "grabKeyboard(QString)" ) { | 931 | } else if ( msg == "grabKeyboard(QString)" ) { |
928 | QString who; | 932 | QString who; |
929 | stream >> who; | 933 | stream >> who; |
930 | if ( who.isEmpty() ) | 934 | if ( who.isEmpty() ) |
931 | d->kbgrabber = 0; | 935 | d->kbgrabber = 0; |
932 | else if ( who != d->appName ) | 936 | else if ( who != d->appName ) |
933 | d->kbgrabber = 1; | 937 | d->kbgrabber = 1; |
934 | else | 938 | else |
935 | d->kbgrabber = 2; | 939 | d->kbgrabber = 2; |
936 | } else if ( msg == "language(QString)" ) { | 940 | } else if ( msg == "language(QString)" ) { |
937 | if ( type() == GuiServer ) { | 941 | if ( type() == GuiServer ) { |
938 | QString l; | 942 | QString l; |
939 | stream >> l; | 943 | stream >> l; |
940 | QString cl = getenv( "LANG" ); | 944 | QString cl = getenv( "LANG" ); |
941 | if ( cl != l ) { | 945 | if ( cl != l ) { |
942 | if ( l.isNull() ) | 946 | if ( l.isNull() ) |
943 | unsetenv( "LANG" ); | 947 | unsetenv( "LANG" ); |
944 | else | 948 | else |
945 | setenv( "LANG", l.latin1(), 1 ); | 949 | setenv( "LANG", l.latin1(), 1 ); |
946 | restart(); | 950 | restart(); |
947 | } | 951 | } |
948 | } | 952 | } |
949 | } else if ( msg == "timeChange(QString)" ) { | 953 | } else if ( msg == "timeChange(QString)" ) { |
950 | QString t; | 954 | QString t; |
951 | stream >> t; | 955 | stream >> t; |
952 | if ( t.isNull() ) | 956 | if ( t.isNull() ) |
953 | unsetenv( "TZ" ); | 957 | unsetenv( "TZ" ); |
954 | else | 958 | else |
955 | setenv( "TZ", t.latin1(), 1 ); | 959 | setenv( "TZ", t.latin1(), 1 ); |
956 | // emit the signal so everyone else knows... | 960 | // emit the signal so everyone else knows... |
957 | emit timeChanged(); | 961 | emit timeChanged(); |
958 | } else if ( msg == "execute(QString)" ) { | 962 | } else if ( msg == "execute(QString)" ) { |
959 | if ( type() == GuiServer ) { | 963 | if ( type() == GuiServer ) { |
960 | QString t; | 964 | QString t; |
961 | stream >> t; | 965 | stream >> t; |
962 | Global::execute( t ); | 966 | Global::execute( t ); |
963 | } | 967 | } |
964 | } else if ( msg == "execute(QString,QString)" ) { | 968 | } else if ( msg == "execute(QString,QString)" ) { |
965 | if ( type() == GuiServer ) { | 969 | if ( type() == GuiServer ) { |
966 | QString t, d; | 970 | QString t, d; |
967 | stream >> t >> d; | 971 | stream >> t >> d; |
968 | Global::execute( t, d ); | 972 | Global::execute( t, d ); |
969 | } | 973 | } |
970 | } else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) { | 974 | } else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) { |
971 | if ( type() == GuiServer ) { | 975 | if ( type() == GuiServer ) { |
972 | QDateTime when; | 976 | QDateTime when; |
973 | QCString channel, message; | 977 | QCString channel, message; |
974 | int data; | 978 | int data; |
975 | stream >> when >> channel >> message >> data; | 979 | stream >> when >> channel >> message >> data; |
976 | AlarmServer::addAlarm( when, channel, message, data ); | 980 | AlarmServer::addAlarm( when, channel, message, data ); |
977 | } | 981 | } |
978 | } else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) { | 982 | } else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) { |
979 | if ( type() == GuiServer ) { | 983 | if ( type() == GuiServer ) { |
980 | QDateTime when; | 984 | QDateTime when; |
981 | QCString channel, message; | 985 | QCString channel, message; |
982 | int data; | 986 | int data; |
983 | stream >> when >> channel >> message >> data; | 987 | stream >> when >> channel >> message >> data; |
984 | AlarmServer::deleteAlarm( when, channel, message, data ); | 988 | AlarmServer::deleteAlarm( when, channel, message, data ); |
985 | } | 989 | } |
986 | } else if ( msg == "clockChange(bool)" ) { | 990 | } else if ( msg == "clockChange(bool)" ) { |
987 | int tmp; | 991 | int tmp; |
988 | stream >> tmp; | 992 | stream >> tmp; |
989 | emit clockChanged( tmp ); | 993 | emit clockChanged( tmp ); |
990 | } else if ( msg == "weekChange(bool)" ) { | 994 | } else if ( msg == "weekChange(bool)" ) { |
991 | int tmp; | 995 | int tmp; |
992 | stream >> tmp; | 996 | stream >> tmp; |
993 | emit weekChanged( tmp ); | 997 | emit weekChanged( tmp ); |
994 | } else if ( msg == "setDateFormat(DateFormat)" ) { | 998 | } else if ( msg == "setDateFormat(DateFormat)" ) { |
995 | DateFormat tmp; | 999 | DateFormat tmp; |
996 | stream >> tmp; | 1000 | stream >> tmp; |
997 | emit dateFormatChanged( tmp ); | 1001 | emit dateFormatChanged( tmp ); |
998 | } else if ( msg == "setVolume(int,int)" ) { | 1002 | } else if ( msg == "setVolume(int,int)" ) { |
999 | int t, v; | 1003 | int t, v; |
1000 | stream >> t >> v; | 1004 | stream >> t >> v; |
1001 | setVolume( t, v ); | 1005 | setVolume( t, v ); |
1002 | emit volumeChanged( muted ); | 1006 | emit volumeChanged( muted ); |
1003 | } else if ( msg == "volumeChange(bool)" ) { | 1007 | } else if ( msg == "volumeChange(bool)" ) { |
1004 | stream >> muted; | 1008 | stream >> muted; |
1005 | setVolume(); | 1009 | setVolume(); |
1006 | emit volumeChanged( muted ); | 1010 | emit volumeChanged( muted ); |
1007 | } else if ( msg == "setMic(int,int)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> | 1011 | } else if ( msg == "setMic(int,int)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> |
1008 | int t, v; | 1012 | int t, v; |
1009 | stream >> t >> v; | 1013 | stream >> t >> v; |
1010 | setMic( t, v ); | 1014 | setMic( t, v ); |
1011 | emit micChanged( micMuted ); | 1015 | emit micChanged( micMuted ); |
1012 | } else if ( msg == "micChange(bool)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> | 1016 | } else if ( msg == "micChange(bool)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> |
1013 | stream >> micMuted; | 1017 | stream >> micMuted; |
1014 | setMic(); | 1018 | setMic(); |
1015 | emit micChanged( micMuted ); | 1019 | emit micChanged( micMuted ); |
1016 | } | 1020 | } |
1017 | #endif | 1021 | #endif |
1018 | } | 1022 | } |
1019 | 1023 | ||
1020 | /*! | 1024 | /*! |
1021 | \internal | 1025 | \internal |
1022 | */ | 1026 | */ |
1023 | bool QPEApplication::raiseAppropriateWindow() | 1027 | bool QPEApplication::raiseAppropriateWindow() |
1024 | { | 1028 | { |
1025 | bool r=FALSE; | 1029 | bool r=FALSE; |
1026 | // ########## raise()ing main window should raise and set active | 1030 | // ########## raise()ing main window should raise and set active |
1027 | // ########## it and then all childen. This belongs in Qt/Embedded | 1031 | // ########## it and then all childen. This belongs in Qt/Embedded |
1028 | QWidget *top = d->qpe_main_widget; | 1032 | QWidget *top = d->qpe_main_widget; |
1029 | if ( !top ) top =mainWidget(); | 1033 | if ( !top ) top =mainWidget(); |
1030 | if ( top && d->keep_running ) { | 1034 | if ( top && d->keep_running ) { |
1031 | if ( top->isVisible() ) | 1035 | if ( top->isVisible() ) |
1032 | r = TRUE; | 1036 | r = TRUE; |
1033 | else if (d->preloaded) { | 1037 | else if (d->preloaded) { |
1034 | // We are preloaded and not visible.. pretend we just started.. | 1038 | // We are preloaded and not visible.. pretend we just started.. |
1035 | QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); | 1039 | QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); |
1036 | e << d->appName; | 1040 | e << d->appName; |
1037 | } | 1041 | } |
1038 | 1042 | ||
1039 | d->show_mx(top,d->nomaximize); | 1043 | d->show_mx(top,d->nomaximize); |
1040 | top->raise(); | 1044 | top->raise(); |
1041 | top->setActiveWindow(); | 1045 | top->setActiveWindow(); |
1042 | } | 1046 | } |
1043 | QWidget *topm = activeModalWidget(); | 1047 | QWidget *topm = activeModalWidget(); |
1044 | if ( topm && topm != top ) { | 1048 | if ( topm && topm != top ) { |
1045 | topm->show(); | 1049 | topm->show(); |
1046 | topm->raise(); | 1050 | topm->raise(); |
1047 | topm->setActiveWindow(); | 1051 | topm->setActiveWindow(); |
1048 | // If we haven't already handled the fastAppShowing message | 1052 | // If we haven't already handled the fastAppShowing message |
1049 | if (!top && d->preloaded) { | 1053 | if (!top && d->preloaded) { |
1050 | QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); | 1054 | QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); |
1051 | e << d->appName; | 1055 | e << d->appName; |
1052 | } | 1056 | } |
1053 | r = FALSE; | 1057 | r = FALSE; |
1054 | } | 1058 | } |
1055 | return r; | 1059 | return r; |
1056 | } | 1060 | } |
1057 | 1061 | ||
1058 | void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data) | 1062 | void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data) |
1059 | { | 1063 | { |
1060 | #ifdef Q_WS_QWS | 1064 | #ifdef Q_WS_QWS |
1061 | 1065 | ||
1062 | if ( msg == "quit()" ) { | 1066 | if ( msg == "quit()" ) { |
1063 | tryQuit(); | 1067 | tryQuit(); |
1064 | } else if ( msg == "quitIfInvisible()" ) { | 1068 | } else if ( msg == "quitIfInvisible()" ) { |
1065 | if ( d->qpe_main_widget && !d->qpe_main_widget->isVisible() ) | 1069 | if ( d->qpe_main_widget && !d->qpe_main_widget->isVisible() ) |
1066 | quit(); | 1070 | quit(); |
1067 | } else if ( msg == "close()" ) { | 1071 | } else if ( msg == "close()" ) { |