author | llornkcor <llornkcor> | 2002-03-16 22:22:53 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-03-16 22:22:53 (UTC) |
commit | 152ca79d3a2d0277934eb0c844c15f0170de2044 (patch) (unidiff) | |
tree | 5cf8fd5c17e14a6266912103d125153a3b860bf6 | |
parent | 8111d4bf6281420b7f44ae70c26d2531cfe34401 (diff) | |
download | opie-152ca79d3a2d0277934eb0c844c15f0170de2044.zip opie-152ca79d3a2d0277934eb0c844c15f0170de2044.tar.gz opie-152ca79d3a2d0277934eb0c844c15f0170de2044.tar.bz2 |
added ability to remember the preferred (last used) input method on qpe restart
-rw-r--r-- | core/launcher/inputmethods.cpp | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/core/launcher/inputmethods.cpp b/core/launcher/inputmethods.cpp index 003dc77..da98e07 100644 --- a/core/launcher/inputmethods.cpp +++ b/core/launcher/inputmethods.cpp | |||
@@ -18,12 +18,14 @@ | |||
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #define QTOPIA_INTERNAL_LANGLIST | ||
21 | #include "inputmethods.h" | 22 | #include "inputmethods.h" |
22 | 23 | ||
23 | #include <qpe/config.h> | 24 | #include <qpe/config.h> |
24 | #include <qpe/qpeapplication.h> | 25 | #include <qpe/qpeapplication.h> |
25 | #include <qpe/inputmethodinterface.h> | 26 | #include <qpe/inputmethodinterface.h> |
26 | #include <qpe/qlibrary.h> | 27 | #include <qpe/qlibrary.h> |
28 | #include <qpe/global.h> | ||
27 | 29 | ||
28 | #include <qpopupmenu.h> | 30 | #include <qpopupmenu.h> |
29 | #include <qpushbutton.h> | 31 | #include <qpushbutton.h> |
@@ -178,15 +180,18 @@ void InputMethods::loadInputMethods() | |||
178 | input.widget = input.interface->inputMethod( 0, inputWidgetStyle ); | 180 | input.widget = input.interface->inputMethod( 0, inputWidgetStyle ); |
179 | input.interface->onKeyPress( this, SLOT(sendKey(ushort,ushort,ushort,bool,bool)) ); | 181 | input.interface->onKeyPress( this, SLOT(sendKey(ushort,ushort,ushort,bool,bool)) ); |
180 | inputMethodList.append( input ); | 182 | inputMethodList.append( input ); |
181 | QString lang = getenv( "LANG" ); | 183 | |
182 | QTranslator * trans = new QTranslator(qApp); | ||
183 | QString type = (*it).left( (*it).find(".") ); | 184 | QString type = (*it).left( (*it).find(".") ); |
185 | QStringList langs = Global::languageList(); | ||
186 | for (QStringList::ConstIterator lit = langs.begin(); lit!=langs.end(); ++lit) { | ||
187 | QString lang = *lit; | ||
188 | QTranslator * trans = new QTranslator(qApp); | ||
184 | QString tfn = QPEApplication::qpeDir()+"/i18n/"+lang+"/"+type+".qm"; | 189 | QString tfn = QPEApplication::qpeDir()+"/i18n/"+lang+"/"+type+".qm"; |
185 | qDebug("tr for inputmethod: %s", tfn.latin1() ); | ||
186 | if ( trans->load( tfn )) | 190 | if ( trans->load( tfn )) |
187 | qApp->installTranslator( trans ); | 191 | qApp->installTranslator( trans ); |
188 | else | 192 | else |
189 | delete trans; | 193 | delete trans; |
194 | } | ||
190 | } else { | 195 | } else { |
191 | delete lib; | 196 | delete lib; |
192 | } | 197 | } |
@@ -207,7 +212,21 @@ void InputMethods::loadInputMethods() | |||
207 | inputMethodList.append( input ); | 212 | inputMethodList.append( input ); |
208 | #endif | 213 | #endif |
209 | if ( !inputMethodList.isEmpty() ) { | 214 | if ( !inputMethodList.isEmpty() ) { |
215 | Config cfg("qpe"); | ||
216 | cfg.setGroup("InputMethod"); | ||
217 | QString curMethod = cfg.readEntry("current",""); | ||
218 | if(curMethod.isEmpty()) { | ||
210 | method = &inputMethodList[0]; | 219 | method = &inputMethodList[0]; |
220 | } else { | ||
221 | int i = 0; | ||
222 | QValueList<InputMethod>::Iterator it; | ||
223 | for ( it = inputMethodList.begin(); it != inputMethodList.end(); ++it, i++ ) { | ||
224 | if((*it).interface->name() == curMethod) { | ||
225 | method = &inputMethodList[i]; | ||
226 | // qDebug(curMethod); | ||
227 | } | ||
228 | } | ||
229 | } | ||
211 | kbdButton->setPixmap( *method->interface->icon() ); | 230 | kbdButton->setPixmap( *method->interface->icon() ); |
212 | } | 231 | } |
213 | if ( !inputMethodList.isEmpty() ) | 232 | if ( !inputMethodList.isEmpty() ) |
@@ -249,6 +268,9 @@ void InputMethods::chooseMethod(InputMethod* im) | |||
249 | if ( method && method->widget->isVisible() ) | 268 | if ( method && method->widget->isVisible() ) |
250 | method->widget->hide(); | 269 | method->widget->hide(); |
251 | method = im; | 270 | method = im; |
271 | Config cfg("qpe"); | ||
272 | cfg.setGroup("InputMethod"); | ||
273 | cfg.writeEntry("current", method->interface->name()); | ||
252 | kbdButton->setPixmap( *method->interface->icon() ); | 274 | kbdButton->setPixmap( *method->interface->icon() ); |
253 | } | 275 | } |
254 | if ( !kbdButton->isOn() ) | 276 | if ( !kbdButton->isOn() ) |