summaryrefslogtreecommitdiff
authorzecke <zecke>2004-10-15 22:27:30 (UTC)
committer zecke <zecke>2004-10-15 22:27:30 (UTC)
commitbc127247d5c74f05b58610cbc94ebc8682a16c7f (patch) (unidiff)
tree433984506aa9b22f916c0ae966956fc53b29197c
parentdb5e39dbf2e81b3e4e2a7e13fa1a51c34a86e319 (diff)
downloadopie-bc127247d5c74f05b58610cbc94ebc8682a16c7f.zip
opie-bc127247d5c74f05b58610cbc94ebc8682a16c7f.tar.gz
opie-bc127247d5c74f05b58610cbc94ebc8682a16c7f.tar.bz2
Remove QPEApplication::installTranslator and use qtopia_installTranslator
patch adopted from Qtopia1.7
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--library/qpeapplication.cpp68
1 files changed, 33 insertions, 35 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp
index 0b6d56d..1117240 100644
--- a/library/qpeapplication.cpp
+++ b/library/qpeapplication.cpp
@@ -111,97 +111,96 @@ public:
111 111
112 QRect normalGeometry() 112 QRect normalGeometry()
113 { return topData()->normalGeometry; }; 113 { return topData()->normalGeometry; };
114}; 114};
115 115
116class QPEApplicationData 116class QPEApplicationData
117{ 117{
118public: 118public:
119 QPEApplicationData ( ) : 119 QPEApplicationData ( ) :
120 presstimer( 0 ), presswidget( 0 ), rightpressed( false ), kbgrabbed( false ), 120 presstimer( 0 ), presswidget( 0 ), rightpressed( false ), kbgrabbed( false ),
121 notbusysent( false ), preloaded( false ), forceshow( false ), nomaximize( false ), 121 notbusysent( false ), preloaded( false ), forceshow( false ), nomaximize( false ),
122 keep_running( true ), qcopQok( false ), 122 keep_running( true ), qcopQok( false ),
123 fontFamily( "Vera" ), fontSize( 10 ), smallIconSize( 14 ), 123 fontFamily( "Vera" ), fontSize( 10 ), smallIconSize( 14 ),
124 bigIconSize( 32 ), qpe_main_widget( 0 ) 124 bigIconSize( 32 ), qpe_main_widget( 0 )
125 { 125 {
126 Config cfg( "qpe" ); 126 Config cfg( "qpe" );
127 cfg.setGroup( "Appearance" ); 127 cfg.setGroup( "Appearance" );
128 useBigPixmaps = cfg.readBoolEntry( "useBigPixmaps", false ); 128 useBigPixmaps = cfg.readBoolEntry( "useBigPixmaps", false );
129 fontFamily = cfg.readEntry( "FontFamily", "Vera" ); 129 fontFamily = cfg.readEntry( "FontFamily", "Vera" );
130 fontSize = cfg.readNumEntry( "FontSize", 10 ); 130 fontSize = cfg.readNumEntry( "FontSize", 10 );
131 smallIconSize = cfg.readNumEntry( "SmallIconSize", 14 ); 131 smallIconSize = cfg.readNumEntry( "SmallIconSize", 14 );
132 bigIconSize = cfg.readNumEntry( "BigIconSize", 32 ); 132 bigIconSize = cfg.readNumEntry( "BigIconSize", 32 );
133#ifdef OPIE_WITHROHFEEDBACK 133#ifdef OPIE_WITHROHFEEDBACK
134 RoH = 0; 134 RoH = 0;
135#endif 135#endif
136 } 136 }
137 137
138 int presstimer; 138 int presstimer;
139 QWidget* presswidget; 139 QWidget* presswidget;
140 QPoint presspos; 140 QPoint presspos;
141#ifdef OPIE_WITHROHFEEDBACK 141#ifdef OPIE_WITHROHFEEDBACK
142 Opie::Internal::RoHFeedback *RoH; 142 Opie::Internal::RoHFeedback *RoH;
143#endif 143#endif
144 144
145 bool rightpressed : 1; 145 bool rightpressed : 1;
146 bool kbgrabbed : 1; 146 bool kbgrabbed : 1;
147 bool notbusysent : 1; 147 bool notbusysent : 1;
148 bool preloaded : 1; 148 bool preloaded : 1;
149 bool forceshow : 1; 149 bool forceshow : 1;
150 bool nomaximize : 1; 150 bool nomaximize : 1;
151 bool keep_running : 1; 151 bool keep_running : 1;
152 bool qcopQok : 1; 152 bool qcopQok : 1;
153 153
154 QCString fontFamily; 154 QCString fontFamily;
155 int fontSize; 155 int fontSize;
156 int smallIconSize; 156 int smallIconSize;
157 int bigIconSize; 157 int bigIconSize;
158 158
159 QStringList langs;
160 QString appName; 159 QString appName;
161 struct QCopRec 160 struct QCopRec
162 { 161 {
163 QCopRec( const QCString &ch, const QCString &msg, 162 QCopRec( const QCString &ch, const QCString &msg,
164 const QByteArray &d ) : 163 const QByteArray &d ) :
165 channel( ch ), message( msg ), data( d ) 164 channel( ch ), message( msg ), data( d )
166 { } 165 { }
167 166
168 QCString channel; 167 QCString channel;
169 QCString message; 168 QCString message;
170 QByteArray data; 169 QByteArray data;
171 }; 170 };
172 QWidget* qpe_main_widget; 171 QWidget* qpe_main_widget;
173 QGuardedPtr<QWidget> lastraised; 172 QGuardedPtr<QWidget> lastraised;
174 QQueue<QCopRec> qcopq; 173 QQueue<QCopRec> qcopq;
175 QString styleName; 174 QString styleName;
176 QString decorationName; 175 QString decorationName;
177 176
178 void enqueueQCop( const QCString &ch, const QCString &msg, 177 void enqueueQCop( const QCString &ch, const QCString &msg,
179 const QByteArray &data ) 178 const QByteArray &data )
180 { 179 {
181 qcopq.enqueue( new QCopRec( ch, msg, data ) ); 180 qcopq.enqueue( new QCopRec( ch, msg, data ) );
182 } 181 }
183 void sendQCopQ() 182 void sendQCopQ()
184 { 183 {
185 if (!qcopQok ) 184 if (!qcopQok )
186 return; 185 return;
187 186
188 QCopRec * r; 187 QCopRec * r;
189 188
190 while((r=qcopq.dequeue())) { 189 while((r=qcopq.dequeue())) {
191 // remove from queue before sending... 190 // remove from queue before sending...
192 // event loop can come around again before getting 191 // event loop can come around again before getting
193 // back from sendLocally 192 // back from sendLocally
194#ifndef QT_NO_COP 193#ifndef QT_NO_COP
195 QCopChannel::sendLocally( r->channel, r->message, r->data ); 194 QCopChannel::sendLocally( r->channel, r->message, r->data );
196#endif 195#endif
197 196
198 delete r; 197 delete r;
199 } 198 }
200 } 199 }
201 200
202 static void show_mx(QWidget* mw, bool nomaximize, QString &strName) 201 static void show_mx(QWidget* mw, bool nomaximize, QString &strName)
203 { 202 {
204 if ( mw->inherits("QMainWindow") || mw->isA("QMainWindow") ) 203 if ( mw->inherits("QMainWindow") || mw->isA("QMainWindow") )
205 { 204 {
206 ( ( QMainWindow* ) mw )->setUsesBigPixmaps( useBigPixmaps ); 205 ( ( QMainWindow* ) mw )->setUsesBigPixmaps( useBigPixmaps );
207 } 206 }
@@ -713,276 +712,286 @@ void QPEApplication::processQCopFile()
713 flock(f.handle(), LOCK_EX); 712 flock(f.handle(), LOCK_EX);
714#endif 713#endif
715 QDataStream ds(&f); 714 QDataStream ds(&f);
716 QCString channel, message; 715 QCString channel, message;
717 QByteArray data; 716 QByteArray data;
718 while(!ds.atEnd()) { 717 while(!ds.atEnd()) {
719 ds >> channel >> message >> data; 718 ds >> channel >> message >> data;
720 d->enqueueQCop(channel,message,data); 719 d->enqueueQCop(channel,message,data);
721 } 720 }
722 ::ftruncate(f.handle(), 0); 721 ::ftruncate(f.handle(), 0);
723#ifndef Q_OS_WIN32 722#ifndef Q_OS_WIN32
724 f.flush(); 723 f.flush();
725 flock(f.handle(), LOCK_UN); 724 flock(f.handle(), LOCK_UN);
726#endif 725#endif
727 } 726 }
728#endif 727#endif
729} 728}
730 729
731 730
732/*! 731/*!
733 \fn void QPEApplication::appMessage( const QCString& msg, const QByteArray& data ) 732 \fn void QPEApplication::appMessage( const QCString& msg, const QByteArray& data )
734 733
735 This signal is emitted when a message is received on this 734 This signal is emitted when a message is received on this
736 application's QPE/Application/<i>appname</i> \link qcop.html 735 application's QPE/Application/<i>appname</i> \link qcop.html
737 QCop\endlink channel. 736 QCop\endlink channel.
738 737
739 The slot to which you connect this signal uses \a msg and \a data 738 The slot to which you connect this signal uses \a msg and \a data
740 in the following way: 739 in the following way:
741 740
742\code 741\code
743 void MyWidget::receive( const QCString& msg, const QByteArray& data ) 742 void MyWidget::receive( const QCString& msg, const QByteArray& data )
744 { 743 {
745 QDataStream stream( data, IO_ReadOnly ); 744 QDataStream stream( data, IO_ReadOnly );
746 if ( msg == "someMessage(int,int,int)" ) { 745 if ( msg == "someMessage(int,int,int)" ) {
747 int a,b,c; 746 int a,b,c;
748 stream >> a >> b >> c; 747 stream >> a >> b >> c;
749 ... 748 ...
750 } else if ( msg == "otherMessage(QString)" ) { 749 } else if ( msg == "otherMessage(QString)" ) {
751 ... 750 ...
752 } 751 }
753 } 752 }
754\endcode 753\endcode
755 754
756 \sa qcop.html 755 \sa qcop.html
757 Note that messages received here may be processed by qpe application 756 Note that messages received here may be processed by qpe application
758 and emitted as signals, such as flush() and reload(). 757 and emitted as signals, such as flush() and reload().
759*/ 758*/
760 759
760#ifndef QT_NO_TRANSLATION
761static void qtopia_loadTranslations( const QStringList& qms )
762{
763 QStringList langs = Global::languageList();
764
765 for (QStringList::ConstIterator it = langs.begin(); it!=langs.end(); ++it) {
766 QString lang = *it;
767
768 QTranslator * trans;
769 QString tfn;
770
771 for (QStringList::ConstIterator qmit = qms.begin(); qmit!=qms.end(); ++qmit) {
772 trans = new QTranslator(qApp);
773 tfn = QPEApplication::qpeDir() + "i18n/" + lang + "/" + *qmit + ".qm";
774 if ( trans->load( tfn ))
775 qApp->installTranslator( trans );
776 else
777 delete trans;
778 }
779 }
780}
781#endif
782
761/*! 783/*!
762 Constructs a QPEApplication just as you would construct 784 Constructs a QPEApplication just as you would construct
763 a QApplication, passing \a argc, \a argv, and \a t. 785 a QApplication, passing \a argc, \a argv, and \a t.
764 786
765 For applications, \a t should be the default, GuiClient. Only 787 For applications, \a t should be the default, GuiClient. Only
766 the Qtopia server passes GuiServer. 788 the Qtopia server passes GuiServer.
767*/ 789*/
768QPEApplication::QPEApplication( int & argc, char **argv, Type t ) 790QPEApplication::QPEApplication( int & argc, char **argv, Type t )
769 : QApplication( hack(argc), argv, t ), pidChannel( 0 ) 791 : QApplication( hack(argc), argv, t ), pidChannel( 0 )
770{ 792{
771 QPixmapCache::setCacheLimit(256); // sensible default for smaller devices. 793 QPixmapCache::setCacheLimit(256); // sensible default for smaller devices.
772 794
773 d = new QPEApplicationData; 795 d = new QPEApplicationData;
774 d->loadTextCodecs(); 796 d->loadTextCodecs();
775 d->loadImageCodecs(); 797 d->loadImageCodecs();
776 798
777 setFont( QFont( d->fontFamily, d->fontSize ) ); 799 setFont( QFont( d->fontFamily, d->fontSize ) );
778 AppLnk::setSmallIconSize( d->smallIconSize ); 800 AppLnk::setSmallIconSize( d->smallIconSize );
779 AppLnk::setBigIconSize( d->bigIconSize ); 801 AppLnk::setBigIconSize( d->bigIconSize );
780 802
781 QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory ); 803 QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory );
782 804
783 connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) ); 805 connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) );
784 806
785 807
786 sysChannel = new QCopChannel( "QPE/System", this ); 808 sysChannel = new QCopChannel( "QPE/System", this );
787 connect( sysChannel, SIGNAL( received(const QCString&,const QByteArray&) ), 809 connect( sysChannel, SIGNAL( received(const QCString&,const QByteArray&) ),
788 this, SLOT( systemMessage(const QCString&,const QByteArray&) ) ); 810 this, SLOT( systemMessage(const QCString&,const QByteArray&) ) );
789 811
790/* COde now in initapp */ 812/* COde now in initapp */
791#if 0 813#if 0
792#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 814#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
793 815
794 QString qcopfn( "/tmp/qcop-msg-" ); 816 QString qcopfn( "/tmp/qcop-msg-" );
795 qcopfn += QString( argv[ 0 ] ); // append command name 817 qcopfn += QString( argv[ 0 ] ); // append command name
796 818
797 QFile f( qcopfn ); 819 QFile f( qcopfn );
798 if ( f.open( IO_ReadOnly ) ) { 820 if ( f.open( IO_ReadOnly ) ) {
799 flock( f.handle(), LOCK_EX ); 821 flock( f.handle(), LOCK_EX );
800 } 822 }
801 823
802 824
803 825
804 QCString channel = QCString( argv[ 0 ] ); 826 QCString channel = QCString( argv[ 0 ] );
805 channel.replace( QRegExp( ".*/" ), "" ); 827 channel.replace( QRegExp( ".*/" ), "" );
806 d->appName = channel; 828 d->appName = channel;
807 channel = "QPE/Application/" + channel; 829 channel = "QPE/Application/" + channel;
808 pidChannel = new QCopChannel( channel, this ); 830 pidChannel = new QCopChannel( channel, this );
809 connect( pidChannel, SIGNAL( received(const QCString&,const QByteArray&) ), 831 connect( pidChannel, SIGNAL( received(const QCString&,const QByteArray&) ),
810 this, SLOT( pidMessage(const QCString&,const QByteArray&) ) ); 832 this, SLOT( pidMessage(const QCString&,const QByteArray&) ) );
811 833
812 if ( f.isOpen() ) { 834 if ( f.isOpen() ) {
813 d->keep_running = FALSE; 835 d->keep_running = FALSE;
814 QDataStream ds( &f ); 836 QDataStream ds( &f );
815 QCString channel, message; 837 QCString channel, message;
816 QByteArray data; 838 QByteArray data;
817 while ( !ds.atEnd() ) { 839 while ( !ds.atEnd() ) {
818 ds >> channel >> message >> data; 840 ds >> channel >> message >> data;
819 d->enqueueQCop( channel, message, data ); 841 d->enqueueQCop( channel, message, data );
820 } 842 }
821 843
822 flock( f.handle(), LOCK_UN ); 844 flock( f.handle(), LOCK_UN );
823 f.close(); 845 f.close();
824 f.remove(); 846 f.remove();
825 } 847 }
826 848
827 for ( int a = 0; a < argc; a++ ) { 849 for ( int a = 0; a < argc; a++ ) {
828 if ( qstrcmp( argv[ a ], "-preload" ) == 0 ) { 850 if ( qstrcmp( argv[ a ], "-preload" ) == 0 ) {
829 argv[ a ] = argv[ a + 1 ]; 851 argv[ a ] = argv[ a + 1 ];
830 a++; 852 a++;
831 d->preloaded = TRUE; 853 d->preloaded = TRUE;
832 argc -= 1; 854 argc -= 1;
833 } 855 }
834 else if ( qstrcmp( argv[ a ], "-preload-show" ) == 0 ) { 856 else if ( qstrcmp( argv[ a ], "-preload-show" ) == 0 ) {
835 argv[ a ] = argv[ a + 1 ]; 857 argv[ a ] = argv[ a + 1 ];
836 a++; 858 a++;
837 d->preloaded = TRUE; 859 d->preloaded = TRUE;
838 d->forceshow = TRUE; 860 d->forceshow = TRUE;
839 argc -= 1; 861 argc -= 1;
840 } 862 }
841 } 863 }
842 864
843 /* overide stored arguments */ 865 /* overide stored arguments */
844 setArgs( argc, argv ); 866 setArgs( argc, argv );
845 867
846#endif 868#endif
847#else 869#else
848 initApp( argc, argv ); 870 initApp( argc, argv );
849#endif 871#endif
850#ifdef Q_WS_QWS 872#ifdef Q_WS_QWS
851 /* load the font renderer factories */ 873 /* load the font renderer factories */
852 FontDatabase::loadRenderers(); 874 FontDatabase::loadRenderers();
853#endif 875#endif
854#ifndef QT_NO_TRANSLATION 876#ifndef QT_NO_TRANSLATION
877 QStringList qms;
878 qms << "libqpe";
879 qms << "libopie";
880 qms << d->appName;
855 881
856 d->langs = Global::languageList(); 882 qtopia_loadTranslations(qms);
857 for ( QStringList::ConstIterator it = d->langs.begin(); it != d->langs.end(); ++it ) {
858 QString lang = *it;
859
860 installTranslation( lang + "/libopie.qm");
861 installTranslation( lang + "/libqpe.qm" );
862 installTranslation( lang + "/" + d->appName + ".qm" );
863
864
865 //###language/font hack; should look it up somewhere
866#ifdef QWS
867
868 if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) {
869 QFont fn = FontManager::unicodeFont( FontManager::Proportional );
870 setFont( fn );
871 }
872#endif
873 }
874#endif 883#endif
875 884
876 applyStyle(); 885 applyStyle();
877 886
878 if ( type() == GuiServer ) { 887 if ( type() == GuiServer ) {
879 setVolume(); 888 setVolume();
880 } 889 }
881 890
882 installEventFilter( this ); 891 installEventFilter( this );
883 892
884 QPEMenuToolFocusManager::initialize(); 893 QPEMenuToolFocusManager::initialize();
885 894
886#ifdef QT_NO_QWS_CURSOR 895#ifdef QT_NO_QWS_CURSOR
887 // if we have no cursor, probably don't want tooltips 896 // if we have no cursor, probably don't want tooltips
888 QToolTip::setEnabled( FALSE ); 897 QToolTip::setEnabled( FALSE );
889#endif 898#endif
890} 899}
891 900
892 901
893#ifdef QTOPIA_INTERNAL_INITAPP 902#ifdef QTOPIA_INTERNAL_INITAPP
894void QPEApplication::initApp( int argc, char **argv ) 903void QPEApplication::initApp( int argc, char **argv )
895{ 904{
896 delete pidChannel; 905 delete pidChannel;
897 d->keep_running = TRUE; 906 d->keep_running = TRUE;
898 d->preloaded = FALSE; 907 d->preloaded = FALSE;
899 d->forceshow = FALSE; 908 d->forceshow = FALSE;
900 909
901 QCString channel = QCString(argv[0]); 910 QCString channel = QCString(argv[0]);
902 911
903 channel.replace(QRegExp(".*/"),""); 912 channel.replace(QRegExp(".*/"),"");
904 d->appName = channel; 913 d->appName = channel;
905 914
915#ifndef QT_NO_TRANSLATION
916 qtopia_loadTranslations( QStringList()<<channel );
917#endif
918
906 #if QT_VERSION > 235 919 #if QT_VERSION > 235
907 qt_fbdpy->setIdentity( channel ); // In Qt/E 2.3.6 920 qt_fbdpy->setIdentity( channel ); // In Qt/E 2.3.6
908 #endif 921 #endif
909 922
910 channel = "QPE/Application/" + channel; 923 channel = "QPE/Application/" + channel;
911 pidChannel = new QCopChannel( channel, this); 924 pidChannel = new QCopChannel( channel, this);
912 connect( pidChannel, SIGNAL(received(const QCString&,const QByteArray&)), 925 connect( pidChannel, SIGNAL(received(const QCString&,const QByteArray&)),
913 this, SLOT(pidMessage(const QCString&,const QByteArray&))); 926 this, SLOT(pidMessage(const QCString&,const QByteArray&)));
914 927
915 928
916 929
917 processQCopFile(); 930 processQCopFile();
918 d->keep_running = d->qcopq.isEmpty(); 931 d->keep_running = d->qcopq.isEmpty();
919 932
920 for (int a=0; a<argc; a++) { 933 for (int a=0; a<argc; a++) {
921 if ( qstrcmp(argv[a],"-preload")==0 ) { 934 if ( qstrcmp(argv[a],"-preload")==0 ) {
922 argv[a] = argv[a+1]; 935 argv[a] = argv[a+1];
923 a++; 936 a++;
924 d->preloaded = TRUE; 937 d->preloaded = TRUE;
925 argc-=1; 938 argc-=1;
926 } else if ( qstrcmp(argv[a],"-preload-show")==0 ) { 939 } else if ( qstrcmp(argv[a],"-preload-show")==0 ) {
927 argv[a] = argv[a+1]; 940 argv[a] = argv[a+1];
928 a++; 941 a++;
929 d->preloaded = TRUE; 942 d->preloaded = TRUE;
930 d->forceshow = TRUE; 943 d->forceshow = TRUE;
931 argc-=1; 944 argc-=1;
932 } 945 }
933 } 946 }
934 947
935 /* overide stored arguments */ 948 /* overide stored arguments */
936 setArgs(argc, argv); 949 setArgs(argc, argv);
937
938 /* install translation here */
939 for ( QStringList::ConstIterator it = d->langs.begin(); it != d->langs.end(); ++it )
940 installTranslation( (*it) + "/" + d->appName + ".qm" );
941} 950}
942#endif 951#endif
943 952
944 953
945static QPtrDict<void>* inputMethodDict = 0; 954static QPtrDict<void>* inputMethodDict = 0;
946static void createInputMethodDict() 955static void createInputMethodDict()
947{ 956{
948 if ( !inputMethodDict ) 957 if ( !inputMethodDict )
949 inputMethodDict = new QPtrDict<void>; 958 inputMethodDict = new QPtrDict<void>;
950} 959}
951 960
952/*! 961/*!
953 Returns the currently set hint to the system as to whether 962 Returns the currently set hint to the system as to whether
954 widget \a w has any use for text input methods. 963 widget \a w has any use for text input methods.
955 964
956 965
957 \sa setInputMethodHint() InputMethodHint 966 \sa setInputMethodHint() InputMethodHint
958*/ 967*/
959QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w ) 968QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w )
960{ 969{
961 if ( inputMethodDict && w ) 970 if ( inputMethodDict && w )
962 return ( InputMethodHint ) ( int ) inputMethodDict->find( w ); 971 return ( InputMethodHint ) ( int ) inputMethodDict->find( w );
963 return Normal; 972 return Normal;
964} 973}
965 974
966/*! 975/*!
967 \enum QPEApplication::InputMethodHint 976 \enum QPEApplication::InputMethodHint
968 977
969 \value Normal the application sometimes needs text input (the default). 978 \value Normal the application sometimes needs text input (the default).
970 \value AlwaysOff the application never needs text input. 979 \value AlwaysOff the application never needs text input.
971 \value AlwaysOn the application always needs text input. 980 \value AlwaysOn the application always needs text input.
972*/ 981*/
973 982
974/*! 983/*!
975 Hints to the system that widget \a w has use for text input methods 984 Hints to the system that widget \a w has use for text input methods
976 as specified by \a mode. 985 as specified by \a mode.
977 986
978 \sa inputMethodHint() InputMethodHint 987 \sa inputMethodHint() InputMethodHint
979*/ 988*/
980void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode ) 989void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode )
981{ 990{
982 createInputMethodDict(); 991 createInputMethodDict();
983 if ( mode == Normal ) { 992 if ( mode == Normal ) {
984 inputMethodDict->remove 993 inputMethodDict->remove
985 ( w ); 994 ( w );
986 } 995 }
987 else { 996 else {
988 inputMethodDict->insert( w, ( void* ) mode ); 997 inputMethodDict->insert( w, ( void* ) mode );
@@ -2134,107 +2143,96 @@ void QPEApplication::grabKeyboard()
2134*/ 2143*/
2135int QPEApplication::exec() 2144int QPEApplication::exec()
2136{ 2145{
2137 d->qcopQok = true; 2146 d->qcopQok = true;
2138#ifndef QT_NO_COP 2147#ifndef QT_NO_COP
2139 d->sendQCopQ(); 2148 d->sendQCopQ();
2140 if ( !d->keep_running ) 2149 if ( !d->keep_running )
2141 processEvents(); // we may have received QCop messages in the meantime. 2150 processEvents(); // we may have received QCop messages in the meantime.
2142#endif 2151#endif
2143 2152
2144 if ( d->keep_running ) 2153 if ( d->keep_running )
2145 //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() ) 2154 //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() )
2146 return QApplication::exec(); 2155 return QApplication::exec();
2147 2156
2148#ifndef QT_NO_COP 2157#ifndef QT_NO_COP
2149 2158
2150 { 2159 {
2151 QCopEnvelope e( "QPE/System", "closing(QString)" ); 2160 QCopEnvelope e( "QPE/System", "closing(QString)" );
2152 e << d->appName; 2161 e << d->appName;
2153 } 2162 }
2154#endif 2163#endif
2155 processEvents(); 2164 processEvents();
2156 return 0; 2165 return 0;
2157} 2166}
2158 2167
2159/*! 2168/*!
2160 \internal 2169 \internal
2161 External request for application to quit. Quits if possible without 2170 External request for application to quit. Quits if possible without
2162 loosing state. 2171 loosing state.
2163*/ 2172*/
2164void QPEApplication::tryQuit() 2173void QPEApplication::tryQuit()
2165{ 2174{
2166 if ( activeModalWidget() ) 2175 if ( activeModalWidget() )
2167 return ; // Inside modal loop or konsole. Too hard to save state. 2176 return ; // Inside modal loop or konsole. Too hard to save state.
2168#ifndef QT_NO_COP 2177#ifndef QT_NO_COP
2169 2178
2170 { 2179 {
2171 QCopEnvelope e( "QPE/System", "closing(QString)" ); 2180 QCopEnvelope e( "QPE/System", "closing(QString)" );
2172 e << d->appName; 2181 e << d->appName;
2173 } 2182 }
2174#endif 2183#endif
2175 if ( d->keep_running ) 2184 if ( d->keep_running )
2176 d->store_widget_rect(d->qpe_main_widget, d->appName); 2185 d->store_widget_rect(d->qpe_main_widget, d->appName);
2177 processEvents(); 2186 processEvents();
2178 2187
2179 quit(); 2188 quit();
2180} 2189}
2181 2190
2182/*!
2183 \internal
2184*/
2185void QPEApplication::installTranslation( const QString& baseName ) {
2186 QTranslator* trans = new QTranslator(this);
2187 QString tfn = qpeDir() + "/i18n/"+baseName;
2188 if ( trans->load( tfn ) )
2189 installTranslator( trans );
2190 else
2191 delete trans;
2192}
2193 2191
2194/*! 2192/*!
2195 \internal 2193 \internal
2196 User initiated quit. Makes the window 'Go Away'. If preloaded this means 2194 User initiated quit. Makes the window 'Go Away'. If preloaded this means
2197 hiding the window. If not it means quitting the application. 2195 hiding the window. If not it means quitting the application.
2198 As this is user initiated we don't need to check state. 2196 As this is user initiated we don't need to check state.
2199*/ 2197*/
2200void QPEApplication::hideOrQuit() 2198void QPEApplication::hideOrQuit()
2201{ 2199{
2202 if ( d->keep_running ) 2200 if ( d->keep_running )
2203 d->store_widget_rect(d->qpe_main_widget, d->appName); 2201 d->store_widget_rect(d->qpe_main_widget, d->appName);
2204 processEvents(); 2202 processEvents();
2205 2203
2206 // If we are a preloaded application we don't actually quit, so emit 2204 // If we are a preloaded application we don't actually quit, so emit
2207 // a System message indicating we're quasi-closing. 2205 // a System message indicating we're quasi-closing.
2208 if ( d->preloaded && d->qpe_main_widget ) 2206 if ( d->preloaded && d->qpe_main_widget )
2209#ifndef QT_NO_COP 2207#ifndef QT_NO_COP
2210 2208
2211 { 2209 {
2212 QCopEnvelope e("QPE/System", "fastAppHiding(QString)" ); 2210 QCopEnvelope e("QPE/System", "fastAppHiding(QString)" );
2213 e << d->appName; 2211 e << d->appName;
2214 d->qpe_main_widget->hide(); 2212 d->qpe_main_widget->hide();
2215 } 2213 }
2216#endif 2214#endif
2217 else 2215 else
2218 quit(); 2216 quit();
2219} 2217}
2220 2218
2221#if (__GNUC__ > 2 ) 2219#if (__GNUC__ > 2 )
2222extern "C" void __cxa_pure_virtual(); 2220extern "C" void __cxa_pure_virtual();
2223 2221
2224void __cxa_pure_virtual() 2222void __cxa_pure_virtual()
2225{ 2223{
2226 fprintf( stderr, "Pure virtual called\n"); 2224 fprintf( stderr, "Pure virtual called\n");
2227 abort(); 2225 abort();
2228 2226
2229} 2227}
2230 2228
2231#endif 2229#endif
2232 2230
2233 2231
2234#if defined(OPIE_NEW_MALLOC) 2232#if defined(OPIE_NEW_MALLOC)
2235 2233
2236// The libraries with the skiff package (and possibly others) have 2234// The libraries with the skiff package (and possibly others) have
2237// completely useless implementations of builtin new and delete that 2235// completely useless implementations of builtin new and delete that
2238// use about 50% of your CPU. Here we revert to the simple libc 2236// use about 50% of your CPU. Here we revert to the simple libc
2239// functions. 2237// functions.
2240 2238