src/hbplugins/inputmethods/common/hbinputpredictionhandler.cpp
changeset 30 80e4d18b72f5
parent 28 b7da29130b0e
equal deleted inserted replaced
28:b7da29130b0e 30:80e4d18b72f5
   387 }
   387 }
   388 
   388 
   389 void HbInputPredictionHandlerPrivate::init()
   389 void HbInputPredictionHandlerPrivate::init()
   390 {
   390 {
   391     mEngine = 0;
   391     mEngine = 0;
   392     HbInputLanguage language = HbInputSettingProxy::instance()->globalInputLanguage();
   392     HbInputLanguage language = mInputMethod->inputState().language();
   393     mEngine = HbPredictionFactory::instance()->predictionEngineForLanguage(language.language());
   393     if(!language.language()) {
       
   394         language = HbInputSettingProxy::instance()->globalInputLanguage();
       
   395     }
       
   396     mEngine = HbPredictionFactory::instance()->predictionEngineForLanguage(language.language());    
   394     if (mEngine && !mCandidates) {
   397     if (mEngine && !mCandidates) {
   395         mCandidates = new QStringList();
   398         mCandidates = new QStringList();
   396     }
   399     }
   397 }
   400 }
   398 
   401 
   640                 d->mEngine->setSecondaryLanguage(HbInputSettingProxy::instance()->globalSecondaryInputLanguage());
   643                 d->mEngine->setSecondaryLanguage(HbInputSettingProxy::instance()->globalSecondaryInputLanguage());
   641             }
   644             }
   642             break;
   645             break;
   643         case HbInputModeActionPrimaryLanguageChanged:
   646         case HbInputModeActionPrimaryLanguageChanged:
   644             if(!d->mEngine) {
   647             if(!d->mEngine) {
   645             d->init();
   648                 d->init();
   646             }
   649             }
   647             if (d->mEngine) {
   650             if (d->mEngine) {
   648                 d->mEngine->setLanguage(HbInputSettingProxy::instance()->globalInputLanguage());
   651                 d->mEngine->setLanguage(HbInputSettingProxy::instance()->globalInputLanguage());
   649             }
   652             }
   650             break;
   653             break;
   834 
   837 
   835     Q_D(HbInputPredictionHandler);
   838     Q_D(HbInputPredictionHandler);
   836     // set the focus back to the editor which caused the launch of spell dialog.
   839     // set the focus back to the editor which caused the launch of spell dialog.
   837     HbInputFocusObject *newFocusObject = new HbInputFocusObject(savedFocusObject);
   840     HbInputFocusObject *newFocusObject = new HbInputFocusObject(savedFocusObject);
   838     newFocusObject->releaseFocus();
   841     newFocusObject->releaseFocus();
   839     newFocusObject->setFocus();
   842     if(HbInputMethod::activeInputMethod()->isFocusLocked()) {
       
   843         HbInputMethod::activeInputMethod()->unlockFocus();
       
   844         newFocusObject->setFocus();
       
   845         HbInputMethod::activeInputMethod()->setFocusObject(newFocusObject);
       
   846         HbInputMethod::activeInputMethod()->lockFocus();
       
   847     } else {
       
   848         newFocusObject->setFocus();
       
   849         HbInputMethod::activeInputMethod()->setFocusObject(newFocusObject);
       
   850     }
   840     HbAbstractEdit *abstractEdit = qobject_cast<HbAbstractEdit*>(savedFocusObject);
   851     HbAbstractEdit *abstractEdit = qobject_cast<HbAbstractEdit*>(savedFocusObject);
   841     if(abstractEdit) {
   852     if(abstractEdit) {
   842         abstractEdit->setCursorPosition(abstractEdit->cursorPosition());
   853         abstractEdit->setCursorPosition(abstractEdit->cursorPosition());
   843     }
       
   844     if(HbInputMethod::activeInputMethod()->isFocusLocked()) {
       
   845         HbInputMethod::activeInputMethod()->unlockFocus();
       
   846     HbInputMethod::activeInputMethod()->setFocusObject(newFocusObject);
       
   847         HbInputMethod::activeInputMethod()->lockFocus();
       
   848     } else {
       
   849         HbInputMethod::activeInputMethod()->setFocusObject(newFocusObject);
       
   850     }
   854     }
   851 
   855 
   852     if (closeReason == HbInputSpellQuery::HbOkPressed) {
   856     if (closeReason == HbInputSpellQuery::HbOkPressed) {
   853         d->commit(string,true);
   857         d->commit(string,true);
   854     } else if(closeReason == HbInputSpellQuery::HbCancelPressed) {
   858     } else if(closeReason == HbInputSpellQuery::HbCancelPressed) {
   885     } else {
   889     } else {
   886         d->mEngine->enableFeature(HbPredFeatureWordCompletion);
   890         d->mEngine->enableFeature(HbPredFeatureWordCompletion);
   887     }
   891     }
   888 
   892 
   889 }
   893 }
       
   894 
       
   895 void HbInputPredictionHandler::setLanguage(HbInputLanguage& language)
       
   896 {
       
   897     Q_D(HbInputPredictionHandler);
       
   898     if(!d->mEngine) {
       
   899         d->init();
       
   900     }
       
   901     // set the engines language only if the current language is different
       
   902     if(d->mEngine && d->mEngine->language().language() != language.language()) { 
       
   903         d->mEngine->setLanguage(language);
       
   904     }
       
   905 }
   890 // EOF
   906 // EOF