src/hbinput/inputwidgets/hbinputsettinglist.cpp
changeset 21 4633027730f5
parent 7 923ff622b8b9
child 23 e6ad4ef83b23
equal deleted inserted replaced
7:923ff622b8b9 21:4633027730f5
    66     HbListWidget *mOptionList;
    66     HbListWidget *mOptionList;
    67     HbInputLanguage mPrimaryLanguage;
    67     HbInputLanguage mPrimaryLanguage;
    68     HbInputLanguage mSecondaryLanguage;
    68     HbInputLanguage mSecondaryLanguage;
    69     QList<QString> mPredictionValues;
    69     QList<QString> mPredictionValues;
    70     HbInputMethodSelectionList *mInputMethodSelectionList;
    70     HbInputMethodSelectionList *mInputMethodSelectionList;
       
    71     bool mIsPredictionDisabled;
    71 };
    72 };
    72 
    73 
    73 HbInputSettingListPrivate::HbInputSettingListPrivate()
    74 HbInputSettingListPrivate::HbInputSettingListPrivate()
    74  : mLanguageButton(0), mPredictionButton(0), mOptionList(0), mInputMethodSelectionList(0)
    75  : mLanguageButton(0), mPredictionButton(0), mOptionList(0), mInputMethodSelectionList(0), mIsPredictionDisabled(false)
    75 {
    76 {
    76 }
    77 }
    77 
    78 
    78 HbInputSettingListPrivate::~HbInputSettingListPrivate()
    79 HbInputSettingListPrivate::~HbInputSettingListPrivate()
    79 {
    80 {
   191     setContentsMargins(margin, margin, margin, margin);
   192     setContentsMargins(margin, margin, margin, margin);
   192     setPreferredWidth(listWidth);
   193     setPreferredWidth(listWidth);
   193 
   194 
   194     // Make sure the input settings list never steals focus.
   195     // Make sure the input settings list never steals focus.
   195     setFlag(QGraphicsItem::ItemIsPanel, true);
   196     setFlag(QGraphicsItem::ItemIsPanel, true);
       
   197     d->mActivePopup = false;
   196     setActive(false);
   198     setActive(false);
   197 
   199 
   198     connect(d->mLanguageButton, SIGNAL(clicked(bool)), this, SLOT(languageButtonClicked()));
   200     connect(d->mLanguageButton, SIGNAL(clicked(bool)), this, SLOT(languageButtonClicked()));
   199     connect(d->mPredictionButton, SIGNAL(clicked(bool)), this, SLOT(predictionButtonClicked()));
   201     connect(d->mPredictionButton, SIGNAL(clicked(bool)), this, SLOT(predictionButtonClicked()));
   200     connect(d->mOptionList, SIGNAL(activated(HbListWidgetItem *)), this, SLOT(listItemActivated(HbListWidgetItem *)));
   202     connect(d->mOptionList, SIGNAL(activated(HbListWidgetItem *)), this, SLOT(listItemActivated(HbListWidgetItem *)));
   238     if (d->mOptionList->count() == 1 && showInputMethod) {
   240     if (d->mOptionList->count() == 1 && showInputMethod) {
   239         d->mOptionList->insertItem(0, HbIcon(inputMethodIcon), tr("Input methods"));
   241         d->mOptionList->insertItem(0, HbIcon(inputMethodIcon), tr("Input methods"));
   240     } else if (d->mOptionList->count() == 2 && !showInputMethod) {
   242     } else if (d->mOptionList->count() == 2 && !showInputMethod) {
   241         delete d->mOptionList->takeItem(0);
   243         delete d->mOptionList->takeItem(0);
   242     }
   244     }
       
   245 
       
   246     HbInputMethod* input = HbInputMethod::activeInputMethod();
       
   247 
       
   248     if (input && input->focusObject() && input->focusObject()->editorInterface().inputConstraints() & HbEditorConstraintLatinAlphabetOnly){
       
   249         setLanguageSelectionEnabled(false);
       
   250     } else {
       
   251         setLanguageSelectionEnabled(true);
       
   252     }
       
   253 
   243 }
   254 }
   244 
   255 
   245 /*!
   256 /*!
   246 Enables/disables language selection button
   257 Enables/disables language selection button
   247 */
   258 */
   285     HbPredictionFactory *predFactory = HbPredictionFactory::instance();
   296     HbPredictionFactory *predFactory = HbPredictionFactory::instance();
   286     if (d->mSecondaryLanguage == HbInputLanguage()) {
   297     if (d->mSecondaryLanguage == HbInputLanguage()) {
   287         emit inputSettingsButtonClicked();
   298         emit inputSettingsButtonClicked();
   288     } else {
   299     } else {
   289         HbInputLanguage language = d->mPrimaryLanguage;
   300         HbInputLanguage language = d->mPrimaryLanguage;
   290         bool oldPLangSupportsPrediction = (predFactory->predictionEngineForLanguage(language) != NULL);
       
   291         d->mPrimaryLanguage = d->mSecondaryLanguage;
   301         d->mPrimaryLanguage = d->mSecondaryLanguage;
   292         d->mSecondaryLanguage = language;
   302         d->mSecondaryLanguage = language;
   293 
   303 
   294         HbInputSettingProxy::instance()->setGlobalInputLanguage(d->mPrimaryLanguage);
   304         HbInputSettingProxy::instance()->setGlobalInputLanguage(d->mPrimaryLanguage);
   295         bool langSupportsPrediction = (predFactory->predictionEngineForLanguage(d->mPrimaryLanguage) != NULL);
   305         bool langSupportsPrediction = (predFactory->predictionEngineForLanguage(d->mPrimaryLanguage) != NULL);
   296         HbInputSettingProxy::instance()->setGlobalSecondaryInputLanguage(d->mSecondaryLanguage);
   306         HbInputSettingProxy::instance()->setGlobalSecondaryInputLanguage(d->mSecondaryLanguage);
   297 
   307 
   298         if (oldPLangSupportsPrediction != langSupportsPrediction) {
   308 		bool predictionStatus = settings->predictiveInputStatusForActiveKeyboard();
   299             settings->setPredictiveInputStatusForActiveKeyboard(langSupportsPrediction);
   309         if (!langSupportsPrediction && predictionStatus) {
       
   310             d->mIsPredictionDisabled = true;
       
   311             settings->setPredictiveInputStatusForActiveKeyboard(false);
       
   312         } else if(d->mIsPredictionDisabled){
       
   313             settings->setPredictiveInputStatusForActiveKeyboard(true);
       
   314             d->mIsPredictionDisabled = false;
   300         }
   315         }
   301     }
   316     }
   302 
   317 
   303     close();
   318     close();
   304 }
   319 }