src/hbinput/inputwidgets/hbinputsettingwidget.cpp
changeset 1 f7ac710697a9
child 5 627c4a0fd0e7
equal deleted inserted replaced
0:16d8024aca5e 1:f7ac710697a9
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (developer.feedback@nokia.com)
       
     6 **
       
     7 ** This file is part of the HbInput module of the UI Extensions for Mobile.
       
     8 **
       
     9 ** GNU Lesser General Public License Usage
       
    10 ** This file may be used under the terms of the GNU Lesser General Public
       
    11 ** License version 2.1 as published by the Free Software Foundation and
       
    12 ** appearing in the file LICENSE.LGPL included in the packaging of this file.
       
    13 ** Please review the following information to ensure the GNU Lesser General
       
    14 ** Public License version 2.1 requirements will be met:
       
    15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    16 **
       
    17 ** In addition, as a special exception, Nokia gives you certain additional
       
    18 ** rights.  These rights are described in the Nokia Qt LGPL Exception
       
    19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
       
    20 **
       
    21 ** If you have questions regarding the use of this file, please contact
       
    22 ** Nokia at developer.feedback@nokia.com.
       
    23 **
       
    24 ****************************************************************************/
       
    25 
       
    26 #include <hbdataform.h>
       
    27 #include <hbdataformmodel.h>
       
    28 #include <hbinpututils.h>
       
    29 #include <hbinputsettingproxy.h>
       
    30 #include <hbinputpredictionfactory.h>
       
    31 
       
    32 #include "hbinputsettingwidget.h"
       
    33 #include "hbinputcheckboxlist_p.h"
       
    34 
       
    35 const QString statusOff = QObject::tr("Off");
       
    36 const QString statusOn = QObject::tr("On");
       
    37 const QString bestPrediction = QObject::tr("Best prediction");
       
    38 const QString exactTyping = QObject::tr("Exact typing");
       
    39 
       
    40 /// @cond
       
    41 
       
    42 class HbInputSettingWidgetPrivate
       
    43 {
       
    44     Q_DECLARE_PUBLIC(HbInputSettingWidget)
       
    45 
       
    46 public:
       
    47     HbInputSettingWidgetPrivate(HbDataForm *dataForm);
       
    48 
       
    49     void initialize();
       
    50     void createSettingItems();
       
    51     void fillLanguageList(QStringList &list, QList<HbInputLanguage> &languageList, const QString &replace = QString(" "));
       
    52     int languageToIndex(const HbInputLanguage &language, const QList<HbInputLanguage> &languageList);
       
    53     HbInputLanguage indexToLanguage(int index, const QList<HbInputLanguage> &languageList);
       
    54     void createSecondaryLanguageList();
       
    55 
       
    56 public:
       
    57     HbDataForm *mForm;
       
    58     HbDataFormModelItem *mPrimaryLanguageItem;
       
    59     HbDataFormModelItem *mSecondaryLanguageItem;
       
    60     HbDataFormModelItem *mKeypressTimeoutItem;
       
    61     HbDataFormModelItem *mCharacterPreviewItem;
       
    62     HbDataFormModelItem *mPredictionItem;
       
    63     HbDataFormModelItem *mAutoCompletionItem;
       
    64     HbDataFormModelItem *mCorrectionLevelItem;
       
    65     HbDataFormModelItem *mPrimaryCandidateItem;
       
    66     HbInputLanguage mPrimaryInputLanguage;
       
    67     HbInputLanguage mSecondaryInputLanguage;
       
    68     QList<HbInputLanguage> mPrimaryLanguages;
       
    69     QList<HbInputLanguage> mSecondaryLanguages;
       
    70     bool mPredictionStatusForITUT;
       
    71     bool mPredictionStatusForQwerty;
       
    72     bool mCharacterPreviewEnabled;
       
    73     int mKeypressTimeout;
       
    74     bool mAutocompletionForITUT;
       
    75     bool mAutocompletionForQwerty;
       
    76     HbTypingCorrectionLevel mTypingCorrectionLevel;
       
    77     HbPrimaryCandidateMode mPrimaryCandidateMode;
       
    78     HbInputSettingWidget *q_ptr;
       
    79 };
       
    80 
       
    81 /*!
       
    82 Constructs setting widget
       
    83 */
       
    84 HbInputSettingWidgetPrivate::HbInputSettingWidgetPrivate(HbDataForm *dataForm)
       
    85  : mForm(dataForm), mPrimaryLanguageItem(NULL),
       
    86    mSecondaryLanguageItem(NULL), mKeypressTimeoutItem(NULL),
       
    87    mCharacterPreviewItem(NULL), mPredictionItem(NULL),
       
    88    mAutoCompletionItem(NULL), mCorrectionLevelItem(NULL),
       
    89    mPrimaryCandidateItem(NULL), q_ptr(NULL)
       
    90 {
       
    91 }
       
    92 
       
    93 /*!
       
    94 Initializes setting widget
       
    95 */
       
    96 void HbInputSettingWidgetPrivate::initialize()
       
    97 {
       
    98     HbInputSettingProxy *settings = HbInputSettingProxy::instance();
       
    99     mPrimaryInputLanguage = settings->globalInputLanguage();
       
   100     mSecondaryInputLanguage = settings->globalSecondaryInputLanguage();
       
   101     mPredictionStatusForITUT = settings->predictiveInputStatus(HbKeyboardSetting12key);
       
   102     mPredictionStatusForQwerty = settings->predictiveInputStatus(HbKeyboardSettingQwerty);
       
   103     mCharacterPreviewEnabled = settings->isCharacterPreviewForQwertyEnabled();
       
   104     mKeypressTimeout = settings->keypressTimeout();
       
   105     mAutocompletionForITUT = settings->isAutocompletionEnabled(HbKeyboardSetting12key);
       
   106     mAutocompletionForQwerty = settings->isAutocompletionEnabled(HbKeyboardSettingQwerty);
       
   107     mPrimaryCandidateMode = settings->primaryCandidateMode();
       
   108     mTypingCorrectionLevel = settings->typingCorrectionLevel();
       
   109 
       
   110     HbInputUtils::listSupportedInputLanguages(mPrimaryLanguages);
       
   111     createSecondaryLanguageList();
       
   112 
       
   113     createSettingItems();
       
   114 }
       
   115 
       
   116 /*!
       
   117 Creates setting items to this widget
       
   118 */
       
   119 void HbInputSettingWidgetPrivate::createSettingItems()
       
   120 {
       
   121     Q_Q(HbInputSettingWidget);
       
   122 
       
   123     HbDataFormModel *model = new HbDataFormModel();
       
   124 
       
   125     HbInputCheckBoxList *customPrototype = new HbInputCheckBoxList(mForm);
       
   126     QList<HbAbstractViewItem*> prototypes = mForm->itemPrototypes();
       
   127     prototypes.append(customPrototype);
       
   128     mForm->setItemPrototypes(prototypes);
       
   129 
       
   130     HbDataFormModelItem *languageGroup = model->appendDataFormGroup(QObject::tr("Language"));
       
   131 
       
   132     mPrimaryLanguageItem = new HbDataFormModelItem(HbDataFormModelItem::ComboBoxItem, QObject::tr("Primary Writing language"));
       
   133     languageGroup->appendChild(mPrimaryLanguageItem);
       
   134     QStringList writingLanguageItems;
       
   135     fillLanguageList(writingLanguageItems, mPrimaryLanguages);
       
   136     mPrimaryLanguageItem->setContentWidgetData(QString("items"), writingLanguageItems);
       
   137     mPrimaryLanguageItem->setContentWidgetData(QString("currentIndex"), languageToIndex(mPrimaryInputLanguage, mPrimaryLanguages));
       
   138     mPrimaryLanguageItem->setContentWidgetData(QString("objectName"), QString("primary_writing_language"));
       
   139     mForm->addConnection(mPrimaryLanguageItem, SIGNAL(currentIndexChanged(int)), q, SLOT(setPrimaryLanguage(int)));
       
   140 
       
   141     mSecondaryLanguageItem = new HbDataFormModelItem(HbDataFormModelItem::ComboBoxItem, QObject::tr("Secondary Writing language"));
       
   142     languageGroup->appendChild(mSecondaryLanguageItem);
       
   143     QStringList secondaryLanguageItems;
       
   144     fillLanguageList(secondaryLanguageItems, mSecondaryLanguages, QObject::tr("None"));
       
   145     mSecondaryLanguageItem->setContentWidgetData(QString("items"), secondaryLanguageItems);
       
   146     mSecondaryLanguageItem->setContentWidgetData(QString("currentIndex"), languageToIndex(mSecondaryInputLanguage, mSecondaryLanguages));
       
   147     mSecondaryLanguageItem->setContentWidgetData(QString("objectName"), QString("secondary_writing_language"));
       
   148     mForm->addConnection(mSecondaryLanguageItem, SIGNAL(currentIndexChanged(int)), q, SLOT(setSecondaryLanguage(int)));
       
   149 
       
   150     HbDataFormModelItem *keyboardGroup = model->appendDataFormGroup(QObject::tr("Keyboard"));
       
   151 
       
   152     mKeypressTimeoutItem = new HbDataFormModelItem(HbDataFormModelItem::SliderItem, QObject::tr("Keypress Timeout"));
       
   153     keyboardGroup->appendChild(mKeypressTimeoutItem);
       
   154     mKeypressTimeoutItem->setContentWidgetData(QString("minimum"), HbInputMinKeypressTimeout);
       
   155     mKeypressTimeoutItem->setContentWidgetData(QString("maximum"), HbInputMaxKeypressTimeout);
       
   156     mKeypressTimeoutItem->setContentWidgetData(QString("sliderPosition"), mKeypressTimeout);
       
   157     mKeypressTimeoutItem->setContentWidgetData(QString("objectName"), QString("keypress_timeout"));
       
   158     mForm->addConnection(mKeypressTimeoutItem, SIGNAL(valueChanged(int)), q, SLOT(setKeypressTimeoutValue(int)));
       
   159 
       
   160     mCharacterPreviewItem = new HbDataFormModelItem(HbDataFormModelItem::ToggleValueItem, QObject::tr("Character bubble"));
       
   161     keyboardGroup->appendChild(mCharacterPreviewItem);
       
   162     if (mCharacterPreviewEnabled) {
       
   163         mCharacterPreviewItem->setContentWidgetData(QString("text"), statusOn);
       
   164         mCharacterPreviewItem->setContentWidgetData(QString("additionalText"), statusOff);
       
   165     } else {
       
   166         mCharacterPreviewItem->setContentWidgetData(QString("text"), statusOff);
       
   167         mCharacterPreviewItem->setContentWidgetData(QString("additionalText"), statusOn);
       
   168     }
       
   169     mCharacterPreviewItem->setContentWidgetData(QString("objectName"), QString("character_bubble"));
       
   170     mForm->addConnection(mCharacterPreviewItem, SIGNAL(clicked(bool)), q, SLOT(setCharacterPreviewState()));
       
   171 
       
   172     HbDataFormModelItem *textInputGroup = model->appendDataFormGroup(QObject::tr("Intelligent Text Input"));
       
   173 
       
   174     HbDataFormModelItem::DataItemType checkboxList =
       
   175         static_cast<HbDataFormModelItem::DataItemType>(HbDataFormModelItem::CustomItemBase);
       
   176 
       
   177     mPredictionItem = new HbDataFormModelItem(checkboxList, QObject::tr("Prediction"));
       
   178     textInputGroup->appendChild(mPredictionItem);
       
   179     QStringList predictionValues;
       
   180     predictionValues << QObject::tr("Qwerty") << QObject::tr("Virtual ITU-T");
       
   181     mPredictionItem->setContentWidgetData(QString("items"), predictionValues);
       
   182     QList<QVariant> predictionEnabled;
       
   183     predictionEnabled << mPredictionStatusForQwerty << mPredictionStatusForITUT;
       
   184     mPredictionItem->setContentWidgetData(QString("selectedItems"), predictionEnabled);
       
   185     mPredictionItem->setContentWidgetData(QString("objectName"), QString("prediction"));
       
   186     mForm->addConnection(mPredictionItem, SIGNAL(activated(const QModelIndex &)), q, SLOT(setPredictionState(const QModelIndex &)));
       
   187 
       
   188     mAutoCompletionItem = new HbDataFormModelItem(checkboxList, QObject::tr("Autocompletion"));
       
   189     textInputGroup->appendChild(mAutoCompletionItem);
       
   190     QStringList autoCompletionValues;
       
   191     autoCompletionValues << QObject::tr("Qwerty") << QObject::tr("Virtual ITU-T");
       
   192     mAutoCompletionItem->setContentWidgetData(QString("items"), autoCompletionValues);
       
   193     QList<QVariant> autocompletionEnabled;
       
   194     autocompletionEnabled << mAutocompletionForQwerty << mAutocompletionForITUT;
       
   195     mAutoCompletionItem->setContentWidgetData(QString("selectedItems"), autocompletionEnabled);
       
   196     mAutoCompletionItem->setContentWidgetData(QString("objectName"), QString("autocompletion"));
       
   197     mForm->addConnection(mAutoCompletionItem, SIGNAL(activated(const QModelIndex &)), q, SLOT(setAutocompletionState(const QModelIndex &)));
       
   198 
       
   199     mCorrectionLevelItem = new HbDataFormModelItem(HbDataFormModelItem::RadioButtonListItem, QObject::tr("Typing Correction"));
       
   200     textInputGroup->appendChild(mCorrectionLevelItem);
       
   201     QStringList correctionLevels;
       
   202     correctionLevels << QObject::tr("Low") << QObject::tr("Medium") << QObject::tr("High");
       
   203     mCorrectionLevelItem->setContentWidgetData(QString("items"), correctionLevels);
       
   204     mCorrectionLevelItem->setContentWidgetData(QString("selected"), mTypingCorrectionLevel);
       
   205     mCorrectionLevelItem->setContentWidgetData(QString("objectName"), QString("typing_correction"));
       
   206     mForm->addConnection(mCorrectionLevelItem, SIGNAL(itemSelected(int)), q, SLOT(setCorrectionLevel(int)));
       
   207 
       
   208     mPrimaryCandidateItem = new HbDataFormModelItem(HbDataFormModelItem::ToggleValueItem, QObject::tr("Primary Candidate"));
       
   209     textInputGroup->appendChild(mPrimaryCandidateItem);
       
   210     if (mPrimaryCandidateMode == HbPrimaryCandidateModeBestPrediction) {
       
   211         mPrimaryCandidateItem->setContentWidgetData(QString("text"), bestPrediction);
       
   212         mPrimaryCandidateItem->setContentWidgetData(QString("additionalText"), exactTyping);
       
   213     } else {
       
   214         mPrimaryCandidateItem->setContentWidgetData(QString("text"), exactTyping);
       
   215         mPrimaryCandidateItem->setContentWidgetData(QString("additionalText"), bestPrediction);
       
   216     }
       
   217     mPrimaryCandidateItem->setContentWidgetData(QString("objectName"), QString("primary_candidate"));
       
   218     mForm->addConnection(mPrimaryCandidateItem, SIGNAL(clicked(bool)), q, SLOT(setPrimaryCandidateMode()));
       
   219 
       
   220     mForm->setModel(model);
       
   221 }
       
   222 
       
   223 /*!
       
   224 Fills given list with language names in the language list
       
   225 */
       
   226 void HbInputSettingWidgetPrivate::fillLanguageList(QStringList &list, QList<HbInputLanguage> &languageList, const QString &replace)
       
   227 {
       
   228     foreach(HbInputLanguage language, languageList) {
       
   229         QString langName = language.localisedName();
       
   230         if (langName.length() == 0) {
       
   231             langName = replace;
       
   232         }
       
   233         list << langName;
       
   234     }
       
   235 }
       
   236 
       
   237 /*!
       
   238 Returns index of the given language at the language list
       
   239 */
       
   240 int HbInputSettingWidgetPrivate::languageToIndex(const HbInputLanguage &language, const QList<HbInputLanguage> &languageList)
       
   241 {
       
   242     for (int i = 0; i < languageList.count(); ++i) {
       
   243         if (languageList.at(i) == language) {
       
   244             return i;
       
   245         }
       
   246     }
       
   247     return -1;
       
   248 }
       
   249 
       
   250 /*!
       
   251 Returns language in the given index at the language list
       
   252 */
       
   253 HbInputLanguage HbInputSettingWidgetPrivate::indexToLanguage(int index, const QList<HbInputLanguage> &languageList)
       
   254 {
       
   255     if (index >= 0 && index < languageList.count()) {
       
   256         return languageList.at(index);
       
   257     } else {
       
   258         return HbInputLanguage();
       
   259     }
       
   260 }
       
   261 
       
   262 /*!
       
   263 Creates list of secondary languages
       
   264 */
       
   265 void HbInputSettingWidgetPrivate::createSecondaryLanguageList()
       
   266 {
       
   267     mSecondaryLanguages.clear();
       
   268 
       
   269     mSecondaryLanguages.append(HbInputLanguage());
       
   270 
       
   271     if (mPrimaryInputLanguage.language() != QLocale::Chinese) {
       
   272         foreach(HbInputLanguage language, mPrimaryLanguages) {
       
   273             if (language != mPrimaryInputLanguage &&
       
   274                 language != QLocale::Chinese) {
       
   275                 mSecondaryLanguages.append(language);
       
   276             }
       
   277         }
       
   278     }
       
   279 }
       
   280 
       
   281 /// @endcond
       
   282 
       
   283 /*!
       
   284 Constructs input setting widget
       
   285 */
       
   286 HbInputSettingWidget::HbInputSettingWidget(HbDataForm *dataForm, QGraphicsWidget* parent)
       
   287  : QObject(parent), d_ptr(new HbInputSettingWidgetPrivate(dataForm))
       
   288 {
       
   289     Q_D(HbInputSettingWidget);
       
   290     d->q_ptr = this;
       
   291 }
       
   292 
       
   293 /*!
       
   294 Destructs the object
       
   295 */
       
   296 HbInputSettingWidget::~HbInputSettingWidget()
       
   297 {
       
   298     delete d_ptr;
       
   299 }
       
   300 
       
   301 /*!
       
   302 Initializes the data form object with input settings
       
   303 */
       
   304 void HbInputSettingWidget::initializeWidget()
       
   305 {
       
   306     Q_D(HbInputSettingWidget);
       
   307 
       
   308     d->initialize();
       
   309 
       
   310     HbInputSettingProxy *settings = HbInputSettingProxy::instance();
       
   311     connect(settings, SIGNAL(globalInputLanguageChanged(const HbInputLanguage &)), this, SLOT(updateGlobalInputLanguage(const HbInputLanguage &)));
       
   312     connect(settings, SIGNAL(globalSecondaryInputLanguageChanged(const HbInputLanguage &)), this, SLOT(updateGlobalSecondaryInputLanguage(const HbInputLanguage &)));
       
   313     connect(settings, SIGNAL(predictiveInputStateChanged(HbKeyboardSettingFlags, bool)), this, SLOT(updatePredictiveInputState(HbKeyboardSettingFlags, bool)));
       
   314     connect(settings, SIGNAL(characterPreviewStateForQwertyChanged(bool)), this, SLOT(updateCharacterPreviewStateForQwerty(bool)));
       
   315     connect(settings, SIGNAL(keypressTimeoutChanged(int)), this, SLOT(updateKeypressTimeout(int)));
       
   316     connect(settings, SIGNAL(autocompletionStateChanged(HbKeyboardSettingFlags, bool)), this, SLOT(updateAutocompletionState(HbKeyboardSettingFlags, bool)));
       
   317     connect(settings, SIGNAL(typingCorrectionLevelChanged(HbTypingCorrectionLevel)), this, SLOT(updateTypingCorrectionLevel(HbTypingCorrectionLevel)));
       
   318     connect(settings, SIGNAL(primaryCandidateModeChanged(HbPrimaryCandidateMode)), this, SLOT(updatePrimaryCandidateMode(HbPrimaryCandidateMode)));
       
   319 }
       
   320 
       
   321 /*!
       
   322 Called by framework when primary language is changed
       
   323 */
       
   324 void HbInputSettingWidget::updateGlobalInputLanguage(const HbInputLanguage &newLanguage)
       
   325 {
       
   326     Q_D(HbInputSettingWidget);
       
   327 
       
   328     if (d->mPrimaryInputLanguage != newLanguage) {
       
   329         setPrimaryLanguage(d->languageToIndex(newLanguage, d->mPrimaryLanguages));
       
   330         d->mPrimaryLanguageItem->setContentWidgetData(QString("currentIndex"), d->languageToIndex(d->mPrimaryInputLanguage, d->mPrimaryLanguages));
       
   331     }
       
   332 }
       
   333 
       
   334 /*!
       
   335 Called by framework when secondary language is changed
       
   336 */
       
   337 void HbInputSettingWidget::updateGlobalSecondaryInputLanguage(const HbInputLanguage &newLanguage)
       
   338 {
       
   339     Q_D(HbInputSettingWidget);
       
   340 
       
   341     if (d->mSecondaryInputLanguage != newLanguage) {
       
   342         setSecondaryLanguage(d->languageToIndex(newLanguage, d->mSecondaryLanguages));
       
   343         d->mSecondaryLanguageItem->setContentWidgetData(QString("currentIndex"), d->languageToIndex(d->mSecondaryInputLanguage, d->mSecondaryLanguages));
       
   344     }
       
   345 }
       
   346 
       
   347 /*!
       
   348 Called by framework when prediction status is changed
       
   349 */
       
   350 void HbInputSettingWidget::updatePredictiveInputState(HbKeyboardSettingFlags keyboardType, bool newState)
       
   351 {
       
   352     Q_D(HbInputSettingWidget);
       
   353 
       
   354     bool changed = false;
       
   355     if (keyboardType & HbKeyboardSetting12key &&
       
   356         d->mPredictionStatusForITUT != newState) {
       
   357         d->mPredictionStatusForITUT = newState;
       
   358         changed = true;
       
   359     } else if (keyboardType & HbKeyboardSettingQwerty &&
       
   360         d->mPredictionStatusForQwerty != newState) {
       
   361         d->mPredictionStatusForQwerty = newState;
       
   362         changed = true;
       
   363     }
       
   364 
       
   365     if (changed) {
       
   366         QList<QVariant> predictionEnabled;
       
   367         predictionEnabled << d->mPredictionStatusForQwerty << d->mPredictionStatusForITUT;
       
   368         d->mPredictionItem->setContentWidgetData(QString("selectedItems"), predictionEnabled);
       
   369     }
       
   370 }
       
   371 
       
   372 /*!
       
   373 Called by framework when character preview state is changed
       
   374 */
       
   375 void HbInputSettingWidget::updateCharacterPreviewStateForQwerty(bool newState)
       
   376 {
       
   377     Q_D(HbInputSettingWidget);
       
   378 
       
   379     if (d->mCharacterPreviewEnabled != newState) {
       
   380         d->mCharacterPreviewEnabled = newState;
       
   381         if (d->mCharacterPreviewEnabled) {
       
   382             d->mCharacterPreviewItem->setContentWidgetData(QString("text"), statusOn);
       
   383             d->mCharacterPreviewItem->setContentWidgetData(QString("additionalText"), statusOff);
       
   384         } else {
       
   385             d->mCharacterPreviewItem->setContentWidgetData(QString("text"), statusOff);
       
   386             d->mCharacterPreviewItem->setContentWidgetData(QString("additionalText"), statusOn);
       
   387         }
       
   388     }
       
   389 }
       
   390 
       
   391 /*!
       
   392 Called by framework when keypress timeout is changed
       
   393 */
       
   394 void HbInputSettingWidget::updateKeypressTimeout(int newTimeout)
       
   395 {
       
   396     Q_D(HbInputSettingWidget);
       
   397 
       
   398     if (d->mKeypressTimeout != newTimeout) {
       
   399         d->mKeypressTimeout = newTimeout;
       
   400         d->mKeypressTimeoutItem->setContentWidgetData(QString("sliderPosition"), d->mKeypressTimeout);
       
   401     }
       
   402 }
       
   403 
       
   404 /*!
       
   405 Called by framework when autocompletion state is changed
       
   406 */
       
   407 void HbInputSettingWidget::updateAutocompletionState(HbKeyboardSettingFlags keyboardType, bool newState)
       
   408 {
       
   409     Q_D(HbInputSettingWidget);
       
   410 
       
   411     bool changed = false;
       
   412     if (keyboardType & HbKeyboardSetting12key &&
       
   413         d->mAutocompletionForITUT != newState) {
       
   414         d->mAutocompletionForITUT = newState;
       
   415         changed = true;
       
   416     } else if (keyboardType & HbKeyboardSettingQwerty &&
       
   417         d->mAutocompletionForQwerty != newState) {
       
   418         d->mAutocompletionForQwerty = newState;
       
   419         changed = true;
       
   420     }
       
   421 
       
   422     if (changed) {
       
   423         QList<QVariant> autocompletionEnabled;
       
   424         autocompletionEnabled << d->mAutocompletionForQwerty << d->mAutocompletionForITUT;
       
   425         d->mAutoCompletionItem->setContentWidgetData(QString("selectedItems"), autocompletionEnabled);
       
   426     }
       
   427 }
       
   428 
       
   429 /*!
       
   430 Called by framework when typing correction level is changed
       
   431 */
       
   432 void HbInputSettingWidget::updateTypingCorrectionLevel(HbTypingCorrectionLevel newLevel)
       
   433 {
       
   434     Q_D(HbInputSettingWidget);
       
   435 
       
   436     if (d->mTypingCorrectionLevel != newLevel) {
       
   437         d->mTypingCorrectionLevel = newLevel;
       
   438         d->mCorrectionLevelItem->setContentWidgetData(QString("selected"), d->mTypingCorrectionLevel);
       
   439     }
       
   440 }
       
   441 
       
   442 /*!
       
   443 Called by framework when primary candidate mode is changed
       
   444 */
       
   445 void HbInputSettingWidget::updatePrimaryCandidateMode(HbPrimaryCandidateMode newMode)
       
   446 {
       
   447     Q_D(HbInputSettingWidget);
       
   448 
       
   449     if (d->mPrimaryCandidateMode != newMode) {
       
   450         d->mPrimaryCandidateMode = newMode;
       
   451         if (d->mPrimaryCandidateMode == HbPrimaryCandidateModeBestPrediction) {
       
   452             d->mPrimaryCandidateItem->setContentWidgetData(QString("text"), bestPrediction);
       
   453             d->mPrimaryCandidateItem->setContentWidgetData(QString("additionalText"), exactTyping);
       
   454         } else {
       
   455             d->mPrimaryCandidateItem->setContentWidgetData(QString("text"), exactTyping);
       
   456             d->mPrimaryCandidateItem->setContentWidgetData(QString("additionalText"), bestPrediction);
       
   457         }
       
   458     }
       
   459 }
       
   460 
       
   461 /*!
       
   462 Saves the new primary language and modifies the secondary language list if necessary
       
   463 */
       
   464 void HbInputSettingWidget::setPrimaryLanguage(int index)
       
   465 {
       
   466     Q_D(HbInputSettingWidget);
       
   467 
       
   468 	HbInputSettingProxy *settings = HbInputSettingProxy::instance();
       
   469     HbPredictionFactory *predFactory = HbPredictionFactory::instance();
       
   470     bool oldPLangSupportsPrediction = (predFactory->predictionEngineForLanguage(d->mPrimaryInputLanguage) != NULL);		
       
   471     d->mPrimaryInputLanguage = d->indexToLanguage(index, d->mPrimaryLanguages);
       
   472     HbInputSettingProxy::instance()->setGlobalInputLanguage(d->mPrimaryInputLanguage);
       
   473     bool langSupportsPrediction = (predFactory->predictionEngineForLanguage(d->mPrimaryInputLanguage) != NULL);		
       
   474 	if( oldPLangSupportsPrediction != langSupportsPrediction) {
       
   475 		if(settings->predictiveInputStatus(HbKeyboardSetting12key) != langSupportsPrediction) {
       
   476 			settings->setPredictiveInputStatus(HbKeyboardSetting12key, langSupportsPrediction);
       
   477 		} 
       
   478 		if (settings->predictiveInputStatus(HbKeyboardSettingQwerty) != langSupportsPrediction) {
       
   479 			settings->setPredictiveInputStatus(HbKeyboardSettingQwerty, langSupportsPrediction);
       
   480 		}
       
   481 	} 	
       
   482 
       
   483     HbInputLanguage secondaryLanguage = d->mSecondaryInputLanguage;
       
   484     // Update secondary language list
       
   485     d->createSecondaryLanguageList();
       
   486     QStringList secondaryLanguageItems;
       
   487     d->fillLanguageList(secondaryLanguageItems, d->mSecondaryLanguages, tr("None"));
       
   488     d->mSecondaryLanguageItem->setContentWidgetData(QString("items"), secondaryLanguageItems);
       
   489 
       
   490     if (d->mPrimaryInputLanguage != secondaryLanguage) {
       
   491         d->mSecondaryLanguageItem->setContentWidgetData(QString("currentIndex"), d->languageToIndex(secondaryLanguage, d->mSecondaryLanguages));
       
   492     }
       
   493 }
       
   494 
       
   495 /*!
       
   496 Saves the new secondary language
       
   497 */
       
   498 void HbInputSettingWidget::setSecondaryLanguage(int index)
       
   499 {
       
   500     Q_D(HbInputSettingWidget);
       
   501 
       
   502     d->mSecondaryInputLanguage = d->indexToLanguage(index, d->mSecondaryLanguages);
       
   503     HbInputSettingProxy::instance()->setGlobalSecondaryInputLanguage(d->mSecondaryInputLanguage);
       
   504 }
       
   505 
       
   506 /*!
       
   507 Saves the keypress timeout value
       
   508 */
       
   509 void HbInputSettingWidget::setKeypressTimeoutValue(int value)
       
   510 {
       
   511     Q_D(HbInputSettingWidget);
       
   512 
       
   513     d->mKeypressTimeout = value;
       
   514     HbInputSettingProxy::instance()->setKeypressTimeout(d->mKeypressTimeout);
       
   515 }
       
   516 
       
   517 /*!
       
   518 Saves the new character preview state
       
   519 */
       
   520 void HbInputSettingWidget::setCharacterPreviewState()
       
   521 {
       
   522     Q_D(HbInputSettingWidget);
       
   523 
       
   524     d->mCharacterPreviewEnabled = !d->mCharacterPreviewEnabled;
       
   525     HbInputSettingProxy::instance()->setCharacterPreviewForQwerty(d->mCharacterPreviewEnabled);
       
   526 }
       
   527 
       
   528 /*!
       
   529 Saves the new prediction state for selected keyboard
       
   530 */
       
   531 void HbInputSettingWidget::setPredictionState(const QModelIndex &index)
       
   532 {
       
   533     Q_D(HbInputSettingWidget);
       
   534 
       
   535     if (index.row() == 0) {
       
   536         d->mPredictionStatusForQwerty = !d->mPredictionStatusForQwerty;
       
   537         HbInputSettingProxy::instance()->setPredictiveInputStatus(HbKeyboardSettingQwerty, d->mPredictionStatusForQwerty);
       
   538     } else {
       
   539         d->mPredictionStatusForITUT = !d->mPredictionStatusForITUT;
       
   540         HbInputSettingProxy::instance()->setPredictiveInputStatus(HbKeyboardSetting12key, d->mPredictionStatusForITUT);
       
   541     }
       
   542 }
       
   543 
       
   544 /*!
       
   545 Saves the new autocompletion state for selected keyboard
       
   546 */
       
   547 void HbInputSettingWidget::setAutocompletionState(const QModelIndex &index)
       
   548 {
       
   549     Q_D(HbInputSettingWidget);
       
   550 
       
   551     if (index.row() == 0) {
       
   552         d->mAutocompletionForQwerty = !d->mAutocompletionForQwerty;
       
   553         HbInputSettingProxy::instance()->setAutocompletionStatus(HbKeyboardSettingQwerty, d->mAutocompletionForQwerty);
       
   554     } else {
       
   555         d->mAutocompletionForITUT = !d->mAutocompletionForITUT;
       
   556         HbInputSettingProxy::instance()->setAutocompletionStatus(HbKeyboardSetting12key, d->mAutocompletionForITUT);
       
   557     }
       
   558 }
       
   559 
       
   560 /*!
       
   561 Saves the new typing correction level
       
   562 */
       
   563 void HbInputSettingWidget::setCorrectionLevel(int index)
       
   564 {
       
   565     Q_D(HbInputSettingWidget);
       
   566 
       
   567     d->mTypingCorrectionLevel = static_cast<HbTypingCorrectionLevel>(index);
       
   568     HbInputSettingProxy::instance()->setTypingCorrectionLevel(d->mTypingCorrectionLevel);
       
   569 }
       
   570 
       
   571 /*!
       
   572 Saves the new primary candidate mode
       
   573 */
       
   574 void HbInputSettingWidget::setPrimaryCandidateMode()
       
   575 {
       
   576     Q_D(HbInputSettingWidget);
       
   577 
       
   578     if (d->mPrimaryCandidateMode == HbPrimaryCandidateModeBestPrediction) {
       
   579         d->mPrimaryCandidateMode = HbPrimaryCandidateModeExactTyping;
       
   580     } else {
       
   581         d->mPrimaryCandidateMode = HbPrimaryCandidateModeBestPrediction;
       
   582     }
       
   583     HbInputSettingProxy::instance()->setPrimaryCandidateMode(d->mPrimaryCandidateMode);
       
   584 }
       
   585 
       
   586 // End of file