src/hbinput/inputwidgets/hbinputsettingwidget.cpp
changeset 7 923ff622b8b9
parent 6 c3690ec91ef8
child 23 e6ad4ef83b23
child 34 ed14f46c0e55
equal deleted inserted replaced
6:c3690ec91ef8 7:923ff622b8b9
    27 #include <hbdataform.h>
    27 #include <hbdataform.h>
    28 #include <hbdataformmodel.h>
    28 #include <hbdataformmodel.h>
    29 #include <hbinpututils.h>
    29 #include <hbinpututils.h>
    30 #include <hbinputsettingproxy.h>
    30 #include <hbinputsettingproxy.h>
    31 #include <hbinputpredictionfactory.h>
    31 #include <hbinputpredictionfactory.h>
       
    32 #include <QInputContextPlugin>
       
    33 #include <QLibrary>
       
    34 #include <QPluginLoader>
       
    35 #include <QDir>
    32 #include <QtAlgorithms>
    36 #include <QtAlgorithms>
    33 
    37 
    34 #include "hbinputcheckboxlist_p.h"
    38 #include "hbinputcheckboxlist_p.h"
       
    39 #include "hbinputsettingproxy_p.h"
       
    40 #include <hbinputmethoddescriptor.h>
    35 
    41 
    36 const QString statusOff = QObject::tr("Off");
    42 const QString statusOff = QObject::tr("Off");
    37 const QString statusOn = QObject::tr("On");
    43 const QString statusOn = QObject::tr("On");
    38 const QString bestPrediction = QObject::tr("Best prediction");
    44 const QString bestPrediction = QObject::tr("Best prediction");
    39 const QString exactTyping = QObject::tr("Exact typing");
    45 const QString exactTyping = QObject::tr("Exact typing");
    40 
    46 
    41 
       
    42 /// @cond
    47 /// @cond
       
    48 // input modes name for chinese
       
    49 const QString KPinyinName("Pinyin");
       
    50 const QString KStrokeName("Stroke");
       
    51 const QString KZhuyinName("Zhuyin");
       
    52 const QString KCangjieNormalName("CangjieNormal");
       
    53 const QString KCangjieEasyName("CangjieEasy");
       
    54 const QString KCangjieAdvancedName("CangjieAdvanced");
       
    55 const QString KHwrName("Handwriting");
       
    56 const QString KHwrVerySlowName("VerySlow");
       
    57 const QString KHwrSlowName("Slow");
       
    58 const QString KHwrNormalName("Normal");
       
    59 const QString KHwrFastName("Fast");
       
    60 const QString KHwrVeryFastName("VeryFast");
       
    61 
       
    62 // strings used for represent cangjie
       
    63 const QString KCangjieGeneralName("Cangjie");
       
    64 const QString KEasy("Easy");
       
    65 const QString KNormal("Normal");
       
    66 const QString KAdvanced("Advanced");
       
    67 
       
    68 // input modes value for chinese
       
    69 const int KChineseInputModeNone = -1;
       
    70 const int KPinyinMode = 0;
       
    71 const int KStrokeMode = 1;
       
    72 const int KZhuyinMode = 2;
       
    73 const int KCangjieNormalMode = 3;
       
    74 const int KCangjieEasyMode = 4;
       
    75 const int KCangjieAdvancedMode = 5;
       
    76 const int KHwrMode = 6;
       
    77 
       
    78 // define chinese input plugin name
       
    79 #ifdef Q_OS_WIN
       
    80 const QString KCnHwrPluginName("HbChineseHwrd.dll");
       
    81 #else
       
    82 #ifdef Q_OS_SYMBIAN
       
    83 const QString KCnHwrPluginName("HbChineseHwr.qtplugin");
       
    84 #else
       
    85 const QString KCnHwrPluginName("HbChineseHwr.dll");
       
    86 #endif
       
    87 #endif
       
    88 
       
    89 #ifdef Q_OS_WIN
       
    90 const QString KCnVItutPluginName("HbChineseVItutd.dll");
       
    91 #else
       
    92 #ifdef Q_OS_SYMBIAN
       
    93 const QString KCnVItutPluginName("HbChineseVItut.qtplugin");
       
    94 #else
       
    95 const QString KCnVItutPluginName("HbChineseVItut.dll");
       
    96 #endif
       
    97 #endif
       
    98 
       
    99 #ifdef Q_OS_WIN
       
   100 const QString KCnVkbPluginName("HbChineseVkbd.dll");
       
   101 #else
       
   102 #ifdef Q_OS_SYMBIAN
       
   103 const QString KCnVkbPluginName("HbChineseVkb.qtplugin");
       
   104 #else
       
   105 const QString KCnVkbPluginName("HbChineseVkb.dll");
       
   106 #endif
       
   107 #endif
    43 
   108 
    44 class HbInputSettingWidgetPrivate
   109 class HbInputSettingWidgetPrivate
    45 {
   110 {
    46     Q_DECLARE_PUBLIC(HbInputSettingWidget)
   111     Q_DECLARE_PUBLIC(HbInputSettingWidget)
    47 
   112 
    53     void fillLanguageList(QStringList &list, QList<HbInputLanguage> &languageList, const QString &replace = QString(" "));
   118     void fillLanguageList(QStringList &list, QList<HbInputLanguage> &languageList, const QString &replace = QString(" "));
    54     int languageToIndex(const HbInputLanguage &language, const QList<HbInputLanguage> &languageList);
   119     int languageToIndex(const HbInputLanguage &language, const QList<HbInputLanguage> &languageList);
    55     HbInputLanguage indexToLanguage(int index, const QList<HbInputLanguage> &languageList);
   120     HbInputLanguage indexToLanguage(int index, const QList<HbInputLanguage> &languageList);
    56     void createSecondaryLanguageList();
   121     void createSecondaryLanguageList();
    57     void updateContentWidgetData();
   122     void updateContentWidgetData();
       
   123     int inputModeToIndex(const int &inputMode, const QList<int> &inputModeList);
       
   124     int indexToInputmode(int index, const QList<int> &inputModeList);
       
   125     void createChineseSettingGroup(HbDataFormModel *model);
       
   126 
       
   127     QInputContextPlugin *pluginInstance(const QString &pluginFileName) const;
       
   128     HbInputMethodDescriptor findInputMethodDescriptor(const QString &inputMethodString);
       
   129     void setInputMethodVar(Qt::Orientation orientation, QString &inputMethodString, QByteArray &num);
       
   130     QByteArray createHwrSpeedData(QByteArray preferredCustomData, int index);
    58 public:
   131 public:
    59     HbDataForm *mForm;
   132     HbDataForm *mForm;
    60     HbDataFormModelItem *mPrimaryLanguageItem;
   133     HbDataFormModelItem *mPrimaryLanguageItem;
    61     HbDataFormModelItem *mSecondaryLanguageItem;
   134     HbDataFormModelItem *mSecondaryLanguageItem;
    62     HbDataFormModelItem *mKeypressTimeoutItem;
   135     HbDataFormModelItem *mKeypressTimeoutItem;
    77     bool mAutocompletionForQwerty;
   150     bool mAutocompletionForQwerty;
    78     HbTypingCorrectionLevel mTypingCorrectionLevel;
   151     HbTypingCorrectionLevel mTypingCorrectionLevel;
    79     HbPrimaryCandidateMode mPrimaryCandidateMode;
   152     HbPrimaryCandidateMode mPrimaryCandidateMode;
    80     HbInputSettingWidget *q_ptr;
   153     HbInputSettingWidget *q_ptr;
    81     HbDataFormModel *mModel;
   154     HbDataFormModel *mModel;
       
   155 
       
   156     // member variables for chinese
       
   157     HbDataFormModelItem *mLanguageGroup;
       
   158     HbDataFormModelItem *mChineseInputGroup;
       
   159     HbDataFormModelItem *mPortraitInputMethodItem;
       
   160     HbDataFormModelItem *mLandscapeInputMethodItem;
       
   161     HbDataFormModelItem *mHwrSpeedItem;
       
   162     HbDataFormModelItem *mCangjieItem;
       
   163     int mCnPortraitInputMode;
       
   164     int mCnLandscapeInputMode;
       
   165     int mCnCangjieInputMode;
       
   166 
       
   167     int mHwrSpeed;
       
   168     QList<int> mCnPortraitInputModeList;
       
   169     QList<int> mCnLandscapeInputModeList;
       
   170     QList<int> mCangjieInputModeList;
       
   171     QStringList mCnPortraitInputModeNames;
       
   172     QStringList mCnLandscapeInputModeNames;
       
   173     QStringList mCnCangjieInputModeNames;
       
   174     QStringList mHwrSpeedNames;
    82 };
   175 };
    83 
   176 
    84 /*!
   177 /*!
    85 Constructs setting widget
   178 Constructs setting widget
    86 */
   179 */
    87 HbInputSettingWidgetPrivate::HbInputSettingWidgetPrivate(HbDataForm *dataForm)
   180 HbInputSettingWidgetPrivate::HbInputSettingWidgetPrivate(HbDataForm *dataForm)
    88  : mForm(dataForm), mPrimaryLanguageItem(NULL),
   181     : mForm(dataForm),
    89    mSecondaryLanguageItem(NULL), mKeypressTimeoutItem(NULL),
   182       mPrimaryLanguageItem(0),
    90    mCharacterPreviewItem(NULL), mPredictionItem(NULL),
   183       mSecondaryLanguageItem(0),
    91    mAutoCompletionItem(NULL), mCorrectionLevelItem(NULL),
   184       mKeypressTimeoutItem(0),
    92    mPrimaryCandidateItem(NULL), q_ptr(NULL), mModel(0)
   185       mCharacterPreviewItem(0),
       
   186       mPredictionItem(0),
       
   187       mAutoCompletionItem(0),
       
   188       mCorrectionLevelItem(0),
       
   189       mPrimaryCandidateItem(0),
       
   190       q_ptr(0),
       
   191       mModel(0),
       
   192       mLanguageGroup(0),
       
   193       mChineseInputGroup(0),
       
   194       mPortraitInputMethodItem(0),
       
   195       mLandscapeInputMethodItem(0),
       
   196       mHwrSpeedItem(0),
       
   197       mCangjieItem(0)
    93 {
   198 {
    94 }
   199 }
    95 
   200 
    96 /*!
   201 /*!
    97 Initializes setting widget
   202 Initializes setting widget
   126         index = mModel->indexFromItem(mPredictionItem->parent());
   231         index = mModel->indexFromItem(mPredictionItem->parent());
   127         mForm->setExpanded(index, false);        
   232         mForm->setExpanded(index, false);        
   128     }
   233     }
   129 }
   234 }
   130 
   235 
   131 void HbInputSettingWidgetPrivate::updateContentWidgetData() 
   236 void HbInputSettingWidgetPrivate::createChineseSettingGroup(HbDataFormModel *model)
       
   237 {
       
   238     Q_Q(HbInputSettingWidget);
       
   239     int imMode = KChineseInputModeNone;
       
   240     QByteArray ba = HbInputSettingProxy::instance()->preferredInputMethodCustomData(Qt::Vertical);
       
   241     QString portraitCustomData(ba);
       
   242     QString imName = portraitCustomData.split(" ").at(0);
       
   243     HbInputLanguage lang = HbInputSettingProxy::instance()->globalInputLanguage();
       
   244 
       
   245     if (imName == KPinyinName) {
       
   246         imMode = KPinyinMode;
       
   247     } else if (imName == KStrokeName) {
       
   248         imMode = KStrokeMode;
       
   249     } else if (imName == KZhuyinName) {
       
   250         imMode = KZhuyinMode;
       
   251     } else if (imName == KHwrName) {
       
   252         imMode = KHwrMode;
       
   253     } else {
       
   254         if (lang.variant() == QLocale::China) {
       
   255             imMode = KPinyinMode;
       
   256         } else if (lang.variant() == QLocale::HongKong) {
       
   257             imMode = KStrokeMode;
       
   258         } else if (lang.variant() == QLocale::Taiwan) {
       
   259             imMode = KZhuyinMode;
       
   260         }
       
   261     }
       
   262 
       
   263     mCnPortraitInputMode = imMode;
       
   264 
       
   265     ba = HbInputSettingProxy::instance()->preferredInputMethodCustomData(Qt::Horizontal);
       
   266     QString landscapeCustomData(ba);
       
   267     imName = landscapeCustomData.split(" ").at(0);
       
   268 
       
   269     mCnCangjieInputMode = KCangjieNormalMode;
       
   270     if (imName == KPinyinName) {
       
   271         mCnLandscapeInputMode = KPinyinMode;
       
   272     } else if (imName == KStrokeName) {
       
   273         mCnLandscapeInputMode = KStrokeMode;
       
   274     } else if (imName == KZhuyinName) {
       
   275         mCnLandscapeInputMode = KZhuyinMode;
       
   276     } else if (imName == KCangjieNormalName) {
       
   277         mCnLandscapeInputMode = KCangjieNormalMode;
       
   278         mCnCangjieInputMode = KCangjieNormalMode;
       
   279     } else if (imName == KCangjieEasyName) {
       
   280         mCnLandscapeInputMode = KCangjieNormalMode;
       
   281         mCnCangjieInputMode = KCangjieEasyMode;
       
   282     } else if (imName == KCangjieAdvancedName) {
       
   283         mCnLandscapeInputMode = KCangjieNormalMode;
       
   284         mCnCangjieInputMode = KCangjieAdvancedMode;
       
   285     } else if (imName == KHwrName) {
       
   286         mCnLandscapeInputMode = KHwrMode;
       
   287     } else {
       
   288         if (lang.variant() == QLocale::China) {
       
   289             mCnLandscapeInputMode = KPinyinMode;
       
   290         } else if (lang.variant() == QLocale::HongKong) {
       
   291             mCnLandscapeInputMode = KStrokeMode;
       
   292         } else if (lang.variant() == QLocale::Taiwan) {
       
   293             mCnLandscapeInputMode = KZhuyinMode;
       
   294         }
       
   295     }
       
   296 
       
   297     Qt::Orientation orientation = HbInputSettingProxy::instance()->screenOrientation();
       
   298     ba = HbInputSettingProxy::instance()->preferredInputMethodCustomData(orientation);
       
   299     QString customData(ba);
       
   300     if (customData.split(" ").count() > 1) {
       
   301         imName = customData.split(" ").at(1);
       
   302         if (imName == KHwrVerySlowName) {
       
   303             mHwrSpeed = 0;
       
   304         } else if (imName == KHwrSlowName) {
       
   305             mHwrSpeed = 1;
       
   306         } else if (imName == KHwrNormalName) {
       
   307             mHwrSpeed = 2;
       
   308         } else if (imName == KHwrFastName) {
       
   309             mHwrSpeed = 3;
       
   310         } else if (imName == KHwrVeryFastName) {
       
   311             mHwrSpeed = 4;
       
   312         } else {
       
   313             mHwrSpeed = 2;
       
   314         }
       
   315     } else {
       
   316         mHwrSpeed = 2;
       
   317     }
       
   318 
       
   319     mHwrSpeedNames.clear();
       
   320     mCnPortraitInputModeList.clear();
       
   321     mCnLandscapeInputModeList.clear();
       
   322     mCnPortraitInputModeNames.clear();
       
   323     mCnLandscapeInputModeNames.clear();
       
   324     mCnCangjieInputModeNames.clear();
       
   325 
       
   326     mHwrSpeedNames << "Very slow" << "Slow" << "Normal" << "Fast" << "Very Fast";
       
   327     if (mPrimaryInputLanguage == HbInputLanguage(QLocale::Chinese, QLocale::China)) {
       
   328         mCnPortraitInputModeList << KPinyinMode << KStrokeMode << KHwrMode;
       
   329         mCnLandscapeInputModeList << KPinyinMode << KStrokeMode << KHwrMode;
       
   330         mCnPortraitInputModeNames << KPinyinName << KStrokeName << KHwrName;
       
   331         mCnLandscapeInputModeNames << KPinyinName << KStrokeName << KHwrName;
       
   332     } else if (mPrimaryInputLanguage == HbInputLanguage(QLocale::Chinese, QLocale::HongKong)) {
       
   333         mCnPortraitInputModeList << KStrokeMode << KHwrMode;
       
   334         mCnLandscapeInputModeList << KStrokeMode << KCangjieNormalMode << KHwrMode;
       
   335         mCangjieInputModeList << KCangjieEasyMode << KCangjieNormalMode << KCangjieAdvancedMode;
       
   336         mCnPortraitInputModeNames << KStrokeName << KHwrName;
       
   337         mCnLandscapeInputModeNames << KStrokeName << KCangjieGeneralName << KHwrName;
       
   338         mCnCangjieInputModeNames << KEasy << KNormal << KAdvanced;
       
   339     } else if (mPrimaryInputLanguage == HbInputLanguage(QLocale::Chinese, QLocale::Taiwan)) {
       
   340         mCnPortraitInputModeList << KZhuyinMode << KHwrMode;
       
   341         mCnLandscapeInputModeList << KZhuyinMode << KHwrMode;
       
   342         mCnPortraitInputModeNames << KZhuyinName << KHwrName;
       
   343         mCnLandscapeInputModeNames << KZhuyinName << KHwrName;
       
   344     }
       
   345 
       
   346     if (!mChineseInputGroup) {
       
   347         mChineseInputGroup = model->appendDataFormGroup(QObject::tr("Chinese Input"));
       
   348         mPortraitInputMethodItem = new HbDataFormModelItem(HbDataFormModelItem::ComboBoxItem, QObject::tr("Portrait mode input method"));
       
   349         mChineseInputGroup->appendChild(mPortraitInputMethodItem);
       
   350         mPortraitInputMethodItem->setContentWidgetData(QString("items"), mCnPortraitInputModeNames);
       
   351         int imIdx = inputModeToIndex(mCnPortraitInputMode, mCnPortraitInputModeList);
       
   352         QVariant varPor;
       
   353         varPor.setValue(imIdx);
       
   354         mPortraitInputMethodItem->setContentWidgetData(QString("currentIndex"), varPor);
       
   355         mPortraitInputMethodItem->setContentWidgetData(QString("objectName"), QString("portrait_input_method"));
       
   356         mForm->addConnection(mPortraitInputMethodItem, SIGNAL(currentIndexChanged(int)), q, SLOT(setPortraitInputMethod(int)));
       
   357 
       
   358         mLandscapeInputMethodItem = new HbDataFormModelItem(HbDataFormModelItem::ComboBoxItem, QObject::tr("Landscape mode input method"));
       
   359         mChineseInputGroup->appendChild(mLandscapeInputMethodItem);
       
   360         mLandscapeInputMethodItem->setContentWidgetData(QString("items"), mCnLandscapeInputModeNames);
       
   361         int imIdx_lan = inputModeToIndex(mCnLandscapeInputMode, mCnLandscapeInputModeList);
       
   362         QVariant varLan;
       
   363         varLan.setValue(imIdx_lan);
       
   364         mLandscapeInputMethodItem->setContentWidgetData(QString("currentIndex"), varLan);
       
   365         mLandscapeInputMethodItem->setContentWidgetData(QString("objectName"), QString("landscape_input_method"));
       
   366         mForm->addConnection(mLandscapeInputMethodItem, SIGNAL(currentIndexChanged(int)), q, SLOT(setLandscapeInputMethod(int)));
       
   367 
       
   368         mHwrSpeedItem = new HbDataFormModelItem(HbDataFormModelItem::ComboBoxItem, QObject::tr("Handwriting speed"));
       
   369         mChineseInputGroup->appendChild(mHwrSpeedItem);
       
   370         mHwrSpeedItem->setContentWidgetData(QString("items"), mHwrSpeedNames);
       
   371         int hwr = mHwrSpeed;
       
   372         mHwrSpeedItem->setContentWidgetData(QString("currentIndex"), hwr);
       
   373         mHwrSpeedItem->setContentWidgetData(QString("objectName"), QString("handwriting_speed"));
       
   374         mForm->addConnection(mHwrSpeedItem, SIGNAL(currentIndexChanged(int)), q, SLOT(setHwrSpeed(int)));
       
   375     }
       
   376 
       
   377     if (mPrimaryInputLanguage == HbInputLanguage(QLocale::Chinese, QLocale::HongKong)) {
       
   378         mCangjieItem = new HbDataFormModelItem(HbDataFormModelItem::ComboBoxItem, QObject::tr("Cangjie mode"));
       
   379         mChineseInputGroup->appendChild(mCangjieItem);
       
   380         mCangjieItem->setContentWidgetData(QString("items"), mCnCangjieInputModeNames);
       
   381         int cangjieIdx = inputModeToIndex(mCnCangjieInputMode, mCangjieInputModeList);
       
   382         QVariant varCang;
       
   383         varCang.setValue(cangjieIdx);
       
   384         mCangjieItem->setContentWidgetData(QString("currentIndex"), varCang);
       
   385         mCangjieItem->setContentWidgetData(QString("objectName"), QString("cangjie_mode"));
       
   386         mForm->addConnection(mCangjieItem, SIGNAL(currentIndexChanged(int)), q, SLOT(setCangjieMode(int)));
       
   387     }
       
   388 }
       
   389 
       
   390 void HbInputSettingWidgetPrivate::updateContentWidgetData()
   132 {
   391 {
   133     // current primary language
   392     // current primary language
   134     mPrimaryLanguageItem->setContentWidgetData(QString("currentIndex"), languageToIndex(mPrimaryInputLanguage, mPrimaryLanguages));
   393     mPrimaryLanguageItem->setContentWidgetData(QString("currentIndex"), languageToIndex(mPrimaryInputLanguage, mPrimaryLanguages));
   135 
   394 
   136     mSecondaryLanguageItem->setContentWidgetData(QString("currentIndex"), languageToIndex(mSecondaryInputLanguage, mSecondaryLanguages));
   395     mSecondaryLanguageItem->setContentWidgetData(QString("currentIndex"), languageToIndex(mSecondaryInputLanguage, mSecondaryLanguages));
   170     Q_Q(HbInputSettingWidget);
   429     Q_Q(HbInputSettingWidget);
   171 
   430 
   172     mModel = new HbDataFormModel();
   431     mModel = new HbDataFormModel();
   173 
   432 
   174     HbInputCheckBoxList *customPrototype = new HbInputCheckBoxList(mForm);
   433     HbInputCheckBoxList *customPrototype = new HbInputCheckBoxList(mForm);
   175     QList<HbAbstractViewItem*> prototypes = mForm->itemPrototypes();
   434     QList<HbAbstractViewItem *> prototypes = mForm->itemPrototypes();
   176     prototypes.append(customPrototype);
   435     prototypes.append(customPrototype);
   177     mForm->setItemPrototypes(prototypes);
   436     mForm->setItemPrototypes(prototypes);
   178 
   437 
   179     HbDataFormModelItem *languageGroup = mModel->appendDataFormGroup(QObject::tr("Language"));
   438     mLanguageGroup = mModel->appendDataFormGroup(QObject::tr("Language"));
   180 
   439 
   181     mPrimaryLanguageItem = new HbDataFormModelItem(HbDataFormModelItem::ComboBoxItem, QObject::tr("Primary Writing language"));
   440     mPrimaryLanguageItem = new HbDataFormModelItem(HbDataFormModelItem::ComboBoxItem, QObject::tr("Primary Writing language"));
   182     languageGroup->appendChild(mPrimaryLanguageItem);
   441     mLanguageGroup->appendChild(mPrimaryLanguageItem);
   183     QStringList writingLanguageItems;
   442     QStringList writingLanguageItems;
   184     fillLanguageList(writingLanguageItems, mPrimaryLanguages);
   443     fillLanguageList(writingLanguageItems, mPrimaryLanguages);
   185     mPrimaryLanguageItem->setContentWidgetData(QString("items"), writingLanguageItems);
   444     mPrimaryLanguageItem->setContentWidgetData(QString("items"), writingLanguageItems);
   186     mPrimaryLanguageItem->setContentWidgetData(QString("currentIndex"), languageToIndex(mPrimaryInputLanguage, mPrimaryLanguages));
   445     mPrimaryLanguageItem->setContentWidgetData(QString("currentIndex"), languageToIndex(mPrimaryInputLanguage, mPrimaryLanguages));
   187     mPrimaryLanguageItem->setContentWidgetData(QString("objectName"), QString("primary_writing_language"));
   446     mPrimaryLanguageItem->setContentWidgetData(QString("objectName"), QString("primary_writing_language"));
   188     mForm->addConnection(mPrimaryLanguageItem, SIGNAL(currentIndexChanged(int)), q, SLOT(setPrimaryLanguage(int)));
   447     mForm->addConnection(mPrimaryLanguageItem, SIGNAL(currentIndexChanged(int)), q, SLOT(setPrimaryLanguage(int)));
   189 
   448 
   190     mSecondaryLanguageItem = new HbDataFormModelItem(HbDataFormModelItem::ComboBoxItem, QObject::tr("Secondary Writing language"));
   449     if (mPrimaryInputLanguage.language() != QLocale::Chinese) {
   191     languageGroup->appendChild(mSecondaryLanguageItem);
   450         mSecondaryLanguageItem = new HbDataFormModelItem(HbDataFormModelItem::ComboBoxItem, QObject::tr("Secondary Writing language"));
   192     QStringList secondaryLanguageItems;
   451         mLanguageGroup->appendChild(mSecondaryLanguageItem);
   193     fillLanguageList(secondaryLanguageItems, mSecondaryLanguages, QObject::tr("None"));
   452         QStringList secondaryLanguageItems;
   194     mSecondaryLanguageItem->setContentWidgetData(QString("items"), secondaryLanguageItems);
   453         fillLanguageList(secondaryLanguageItems, mSecondaryLanguages, QObject::tr("None"));
   195     mSecondaryLanguageItem->setContentWidgetData(QString("currentIndex"), languageToIndex(mSecondaryInputLanguage, mSecondaryLanguages));
   454         mSecondaryLanguageItem->setContentWidgetData(QString("items"), secondaryLanguageItems);
   196     mSecondaryLanguageItem->setContentWidgetData(QString("objectName"), QString("secondary_writing_language"));
   455         mSecondaryLanguageItem->setContentWidgetData(QString("currentIndex"), languageToIndex(mSecondaryInputLanguage, mSecondaryLanguages));
   197     mForm->addConnection(mSecondaryLanguageItem, SIGNAL(currentIndexChanged(int)), q, SLOT(setSecondaryLanguage(int)));
   456         mSecondaryLanguageItem->setContentWidgetData(QString("objectName"), QString("secondary_writing_language"));
   198 
   457         mForm->addConnection(mSecondaryLanguageItem, SIGNAL(currentIndexChanged(int)), q, SLOT(setSecondaryLanguage(int)));
       
   458     }
   199     HbDataFormModelItem *keyboardGroup = mModel->appendDataFormGroup(QObject::tr("Keyboard"));
   459     HbDataFormModelItem *keyboardGroup = mModel->appendDataFormGroup(QObject::tr("Keyboard"));
   200 
   460 
   201     mKeypressTimeoutItem = new HbDataFormModelItem(HbDataFormModelItem::SliderItem, QObject::tr("Keypress Timeout"));
   461     mKeypressTimeoutItem = new HbDataFormModelItem(HbDataFormModelItem::SliderItem, QObject::tr("Keypress Timeout"));
   202     keyboardGroup->appendChild(mKeypressTimeoutItem);
   462     keyboardGroup->appendChild(mKeypressTimeoutItem);
   203     mKeypressTimeoutItem->setContentWidgetData(QString("minimum"), HbInputMinKeypressTimeout);
   463     mKeypressTimeoutItem->setContentWidgetData(QString("minimum"), HbInputMinKeypressTimeout);
   214     } else {
   474     } else {
   215         mCharacterPreviewItem->setContentWidgetData(QString("text"), statusOff);
   475         mCharacterPreviewItem->setContentWidgetData(QString("text"), statusOff);
   216         mCharacterPreviewItem->setContentWidgetData(QString("additionalText"), statusOn);
   476         mCharacterPreviewItem->setContentWidgetData(QString("additionalText"), statusOn);
   217     }
   477     }
   218     mCharacterPreviewItem->setContentWidgetData(QString("objectName"), QString("character_bubble"));
   478     mCharacterPreviewItem->setContentWidgetData(QString("objectName"), QString("character_bubble"));
   219     
       
   220 
       
   221 
   479 
   222     HbDataFormModelItem *textInputGroup = mModel->appendDataFormGroup(QObject::tr("Intelligent Text Input"));
   480     HbDataFormModelItem *textInputGroup = mModel->appendDataFormGroup(QObject::tr("Intelligent Text Input"));
   223 
   481 
   224     HbDataFormModelItem::DataItemType checkboxList =
   482     HbDataFormModelItem::DataItemType checkboxList =
   225         static_cast<HbDataFormModelItem::DataItemType>(HbDataFormModelItem::CustomItemBase);
   483         static_cast<HbDataFormModelItem::DataItemType>(HbDataFormModelItem::CustomItemBase);
   247     mForm->addConnection(mAutoCompletionItem, SIGNAL(activated(const QModelIndex &)), q, SLOT(setAutocompletionState(const QModelIndex &)));
   505     mForm->addConnection(mAutoCompletionItem, SIGNAL(activated(const QModelIndex &)), q, SLOT(setAutocompletionState(const QModelIndex &)));
   248 
   506 
   249     mCorrectionLevelItem = new HbDataFormModelItem(HbDataFormModelItem::RadioButtonListItem, QObject::tr("Typing Correction"));
   507     mCorrectionLevelItem = new HbDataFormModelItem(HbDataFormModelItem::RadioButtonListItem, QObject::tr("Typing Correction"));
   250     textInputGroup->appendChild(mCorrectionLevelItem);
   508     textInputGroup->appendChild(mCorrectionLevelItem);
   251     QStringList correctionLevels;
   509     QStringList correctionLevels;
   252     correctionLevels << QObject::tr("Low") << QObject::tr("Medium") << QObject::tr("High");
   510     correctionLevels << QObject::tr("Off") << QObject::tr("Medium") << QObject::tr("High");
   253     mCorrectionLevelItem->setContentWidgetData(QString("items"), correctionLevels);
   511     mCorrectionLevelItem->setContentWidgetData(QString("items"), correctionLevels);
   254     mCorrectionLevelItem->setContentWidgetData(QString("selected"), mTypingCorrectionLevel);
   512     mCorrectionLevelItem->setContentWidgetData(QString("selected"), mTypingCorrectionLevel);
   255     mCorrectionLevelItem->setContentWidgetData(QString("objectName"), QString("typing_correction"));
   513     mCorrectionLevelItem->setContentWidgetData(QString("objectName"), QString("typing_correction"));
   256     mForm->addConnection(mCorrectionLevelItem, SIGNAL(itemSelected(int)), q, SLOT(setCorrectionLevel(int)));
   514     mForm->addConnection(mCorrectionLevelItem, SIGNAL(itemSelected(int)), q, SLOT(setCorrectionLevel(int)));
   257 
   515 
   263     } else {
   521     } else {
   264         mPrimaryCandidateItem->setContentWidgetData(QString("text"), exactTyping);
   522         mPrimaryCandidateItem->setContentWidgetData(QString("text"), exactTyping);
   265         mPrimaryCandidateItem->setContentWidgetData(QString("additionalText"), bestPrediction);
   523         mPrimaryCandidateItem->setContentWidgetData(QString("additionalText"), bestPrediction);
   266     }
   524     }
   267     mPrimaryCandidateItem->setContentWidgetData(QString("objectName"), QString("primary_candidate"));
   525     mPrimaryCandidateItem->setContentWidgetData(QString("objectName"), QString("primary_candidate"));
   268     mForm->setModel(mModel);    
   526 
       
   527     if (mPrimaryInputLanguage.language() == QLocale::Chinese) {
       
   528         createChineseSettingGroup(mModel);
       
   529     }
       
   530     mForm->setModel(mModel);
   269     QObject::connect(mModel, SIGNAL(dataChanged(QModelIndex, QModelIndex)), q, SLOT(dataChange(QModelIndex, QModelIndex)));
   531     QObject::connect(mModel, SIGNAL(dataChanged(QModelIndex, QModelIndex)), q, SLOT(dataChange(QModelIndex, QModelIndex)));
   270 }
   532 }
   271 
   533 
   272 /*!
   534 /*!
   273 Fills given list with language names in the language list
   535 Fills given list with language names in the language list
   325             }
   587             }
   326         }
   588         }
   327     }
   589     }
   328 }
   590 }
   329 
   591 
       
   592 /*!
       
   593 Returns index of the given inputmode at the inputmode list
       
   594 */
       
   595 int HbInputSettingWidgetPrivate::inputModeToIndex(const int &inputMode, const QList<int> &inputModeList)
       
   596 {
       
   597     for (int i = 0; i < inputModeList.count(); ++i) {
       
   598         if (inputModeList.at(i) == inputMode) {
       
   599             return i;
       
   600         }
       
   601     }
       
   602     return -1;
       
   603 }
       
   604 
       
   605 /*!
       
   606 Returns inputmode in the given index at the inputmode list
       
   607 */
       
   608 int HbInputSettingWidgetPrivate::indexToInputmode(int index, const QList<int> &inputModeList)
       
   609 {
       
   610     if (index >= 0 && index < inputModeList.count()) {
       
   611         return inputModeList.at(index);
       
   612     } else {
       
   613         return KChineseInputModeNone;
       
   614     }
       
   615 }
       
   616 
       
   617 QInputContextPlugin *HbInputSettingWidgetPrivate::pluginInstance(const QString &pluginFileName) const
       
   618 {
       
   619     if (QLibrary::isLibrary(pluginFileName)) {
       
   620         QPluginLoader loader(pluginFileName);
       
   621         QObject *plugin = loader.instance();
       
   622         if (plugin) {
       
   623             return qobject_cast<QInputContextPlugin *>(plugin);
       
   624         }
       
   625     }
       
   626 
       
   627     return 0;
       
   628 }
       
   629 
       
   630 HbInputMethodDescriptor HbInputSettingWidgetPrivate::findInputMethodDescriptor(const QString &inputMethodString)
       
   631 {
       
   632     HbInputMethodDescriptor descriptor;
       
   633     // Query plugin paths and scan the folders.
       
   634     QStringList folders = HbInputSettingProxy::instance()->inputMethodPluginPaths();
       
   635     foreach(const QString &folder, folders) {
       
   636         QDir dir(folder);
       
   637         for (unsigned int i = 0; i < dir.count(); i++) {
       
   638             QString path = QString(dir.absolutePath());
       
   639             if (path.right(1) != "\\" && path.right(1) != "/") {
       
   640                 path += QDir::separator();
       
   641             }
       
   642             path += inputMethodString;
       
   643             QInputContextPlugin *inputContextPlugin = pluginInstance(path);
       
   644             if (inputContextPlugin) {
       
   645                 descriptor.setPluginNameAndPath(dir.absolutePath() + QDir::separator() + inputMethodString);
       
   646 
       
   647                 // For each found plugin, check if there is already a list item for it.
       
   648                 // If not, then add one.
       
   649                 QStringList contextKeys = inputContextPlugin->keys();
       
   650                 foreach(QString key, contextKeys) {
       
   651                     descriptor.setKey(key);
       
   652                     descriptor.setDisplayName(inputContextPlugin->displayName(key));
       
   653                 }
       
   654                 break;
       
   655             }
       
   656         }
       
   657     }
       
   658     return descriptor;
       
   659 }
       
   660 
       
   661 void HbInputSettingWidgetPrivate::setInputMethodVar(Qt::Orientation orientation, QString &inputMethodString, QByteArray &customData)
       
   662 {
       
   663     int inputMode = KChineseInputModeNone;
       
   664     if (orientation == Qt::Vertical) {
       
   665         inputMode = mCnPortraitInputMode;
       
   666     } else if (orientation == Qt::Horizontal) {
       
   667         inputMode = mCnLandscapeInputMode;
       
   668     } else {
       
   669         return;
       
   670     }
       
   671 
       
   672     switch (inputMode) {
       
   673     case KPinyinMode: {
       
   674         orientation == Qt::Vertical ? inputMethodString = KCnVItutPluginName : inputMethodString = KCnVkbPluginName;
       
   675         customData.append(KPinyinName.toLatin1().data());
       
   676     }
       
   677     break;
       
   678     case KStrokeMode: {
       
   679         orientation == Qt::Vertical ? inputMethodString = KCnVItutPluginName : inputMethodString = KCnVkbPluginName;
       
   680         customData.append(KStrokeName.toLatin1().data());
       
   681     }
       
   682     break;
       
   683     case KZhuyinMode: {
       
   684         orientation == Qt::Vertical ? inputMethodString = KCnVItutPluginName : inputMethodString = KCnVkbPluginName;
       
   685         customData.append(KZhuyinName.toLatin1().data());
       
   686     }
       
   687     break;
       
   688     case KHwrMode: {
       
   689         inputMethodString = KCnHwrPluginName;
       
   690         customData.append(KHwrName.toLatin1().data());
       
   691     }
       
   692     break;
       
   693     case KCangjieNormalMode: {
       
   694         inputMethodString = KCnVkbPluginName;
       
   695         customData.append(KCangjieNormalName.toLatin1().data());
       
   696     }
       
   697     break;
       
   698     case KCangjieEasyMode: {
       
   699         inputMethodString = KCnVkbPluginName;
       
   700         customData.append(KCangjieEasyName.toLatin1().data());
       
   701     }
       
   702     break;
       
   703     case KCangjieAdvancedMode: {
       
   704         inputMethodString = KCnVkbPluginName;
       
   705         customData.append(KCangjieAdvancedName.toLatin1().data());
       
   706     }
       
   707     break;
       
   708     default:
       
   709         break;
       
   710     }
       
   711 
       
   712     QByteArray preferredCustomData = HbInputSettingProxy::instance()->preferredInputMethodCustomData(orientation);
       
   713     QString imName(preferredCustomData);
       
   714     QStringList temp = imName.split(" ");
       
   715     if (temp.count() > 1) {
       
   716         customData.append(" ");
       
   717         customData.append(temp.at(1).toLatin1().data());	
       
   718     } else {
       
   719         customData.append(" ");
       
   720         customData.append(KHwrNormalName.toLatin1().data());
       
   721     }
       
   722     customData.append((char)0);
       
   723     return;
       
   724 }
       
   725 
       
   726 QByteArray HbInputSettingWidgetPrivate::createHwrSpeedData(QByteArray preferredCustomData, int index)
       
   727 {
       
   728     QString imName(preferredCustomData);
       
   729     QStringList temp = imName.split(" ");
       
   730 
       
   731     QByteArray customData;
       
   732     customData.append(temp.at(0).toLatin1().data());
       
   733     customData.append(" ");
       
   734     switch (index) {
       
   735     case 0:
       
   736         customData.append(KHwrVerySlowName.toLatin1().data());
       
   737         break;
       
   738     case 1:
       
   739         customData.append(KHwrSlowName.toLatin1().data());
       
   740         break;
       
   741     case 2:
       
   742         customData.append(KHwrNormalName.toLatin1().data());
       
   743         break;
       
   744     case 3:
       
   745         customData.append(KHwrFastName.toLatin1().data());
       
   746         break;
       
   747     case 4:
       
   748         customData.append(KHwrVeryFastName.toLatin1().data());
       
   749         break;
       
   750     default:
       
   751         break;
       
   752     }
       
   753     customData.append((char)0);
       
   754     return customData;
       
   755 }
       
   756 
   330 /// @endcond
   757 /// @endcond
   331 
   758 
   332 /*!
   759 /*!
   333 Constructs input setting widget
   760 Constructs input setting widget
   334 */
   761 */
   335 HbInputSettingWidget::HbInputSettingWidget(HbDataForm *dataForm, QGraphicsWidget* parent)
   762 HbInputSettingWidget::HbInputSettingWidget(HbDataForm *dataForm, QGraphicsWidget *parent)
   336  : QObject(parent), d_ptr(new HbInputSettingWidgetPrivate(dataForm))
   763     : QObject(parent), d_ptr(new HbInputSettingWidgetPrivate(dataForm))
   337 {
   764 {
   338     Q_D(HbInputSettingWidget);
   765     Q_D(HbInputSettingWidget);
   339     d->q_ptr = this;
   766     d->q_ptr = this;
   340 }
   767 }
   341 
   768 
   404     if (keyboardType & HbKeyboardSetting12key &&
   831     if (keyboardType & HbKeyboardSetting12key &&
   405         d->mPredictionStatusForITUT != newState) {
   832         d->mPredictionStatusForITUT != newState) {
   406         d->mPredictionStatusForITUT = newState;
   833         d->mPredictionStatusForITUT = newState;
   407         changed = true;
   834         changed = true;
   408     } else if (keyboardType & HbKeyboardSettingQwerty &&
   835     } else if (keyboardType & HbKeyboardSettingQwerty &&
   409         d->mPredictionStatusForQwerty != newState) {
   836                d->mPredictionStatusForQwerty != newState) {
   410         d->mPredictionStatusForQwerty = newState;
   837         d->mPredictionStatusForQwerty = newState;
   411         changed = true;
   838         changed = true;
   412     }
   839     }
   413 
   840 
   414     if (changed) {
   841     if (changed) {
   461     if (keyboardType & HbKeyboardSetting12key &&
   888     if (keyboardType & HbKeyboardSetting12key &&
   462         d->mAutocompletionForITUT != newState) {
   889         d->mAutocompletionForITUT != newState) {
   463         d->mAutocompletionForITUT = newState;
   890         d->mAutocompletionForITUT = newState;
   464         changed = true;
   891         changed = true;
   465     } else if (keyboardType & HbKeyboardSettingQwerty &&
   892     } else if (keyboardType & HbKeyboardSettingQwerty &&
   466         d->mAutocompletionForQwerty != newState) {
   893                d->mAutocompletionForQwerty != newState) {
   467         d->mAutocompletionForQwerty = newState;
   894         d->mAutocompletionForQwerty = newState;
   468         changed = true;
   895         changed = true;
   469     }
   896     }
   470 
   897 
   471     if (changed) {
   898     if (changed) {
   512 */
   939 */
   513 void HbInputSettingWidget::setPrimaryLanguage(int index)
   940 void HbInputSettingWidget::setPrimaryLanguage(int index)
   514 {
   941 {
   515     Q_D(HbInputSettingWidget);
   942     Q_D(HbInputSettingWidget);
   516 
   943 
   517 	HbInputSettingProxy *settings = HbInputSettingProxy::instance();
   944     HbInputSettingProxy *settings = HbInputSettingProxy::instance();
   518     HbPredictionFactory *predFactory = HbPredictionFactory::instance();
   945     HbPredictionFactory *predFactory = HbPredictionFactory::instance();
   519     bool oldPLangSupportsPrediction = (predFactory->predictionEngineForLanguage(d->mPrimaryInputLanguage) != NULL);		
   946     bool oldPLangSupportsPrediction = (predFactory->predictionEngineForLanguage(d->mPrimaryInputLanguage) != NULL);
   520     d->mPrimaryInputLanguage = d->indexToLanguage(index, d->mPrimaryLanguages);
   947     d->mPrimaryInputLanguage = d->indexToLanguage(index, d->mPrimaryLanguages);
   521     HbInputSettingProxy::instance()->setGlobalInputLanguage(d->mPrimaryInputLanguage);
   948     HbInputSettingProxy::instance()->setGlobalInputLanguage(d->mPrimaryInputLanguage);
   522     bool langSupportsPrediction = (predFactory->predictionEngineForLanguage(d->mPrimaryInputLanguage) != NULL);		
   949     bool langSupportsPrediction = (predFactory->predictionEngineForLanguage(d->mPrimaryInputLanguage) != NULL);
   523 	if( oldPLangSupportsPrediction != langSupportsPrediction) {
   950     if (oldPLangSupportsPrediction != langSupportsPrediction) {
   524 		if(settings->predictiveInputStatus(HbKeyboardSetting12key) != langSupportsPrediction) {
   951         if (settings->predictiveInputStatus(HbKeyboardSetting12key) != langSupportsPrediction) {
   525 			settings->setPredictiveInputStatus(HbKeyboardSetting12key, langSupportsPrediction);
   952             settings->setPredictiveInputStatus(HbKeyboardSetting12key, langSupportsPrediction);
   526 		} 
   953         }
   527 		if (settings->predictiveInputStatus(HbKeyboardSettingQwerty) != langSupportsPrediction) {
   954         if (settings->predictiveInputStatus(HbKeyboardSettingQwerty) != langSupportsPrediction) {
   528 			settings->setPredictiveInputStatus(HbKeyboardSettingQwerty, langSupportsPrediction);
   955             settings->setPredictiveInputStatus(HbKeyboardSettingQwerty, langSupportsPrediction);
   529 		}
   956         }
   530 	} 	
   957     }
   531 
   958 
   532     HbInputLanguage secondaryLanguage = d->mSecondaryInputLanguage;
   959     if (d->mPrimaryInputLanguage.language() != QLocale::Chinese) {
   533     // Update secondary language list
   960         HbInputLanguage secondaryLanguage = d->mSecondaryInputLanguage;
   534     d->createSecondaryLanguageList();
   961         // Update secondary language list
   535     QStringList secondaryLanguageItems;
   962         d->createSecondaryLanguageList();
   536     d->fillLanguageList(secondaryLanguageItems, d->mSecondaryLanguages, tr("None"));
   963         QStringList secondaryLanguageItems;
   537     d->mSecondaryLanguageItem->setContentWidgetData(QString("items"), secondaryLanguageItems);
   964         d->fillLanguageList(secondaryLanguageItems, d->mSecondaryLanguages, tr("None"));
   538 
   965         if (d->mSecondaryLanguageItem) {
   539     if (d->mPrimaryInputLanguage != secondaryLanguage) {
   966             d->mSecondaryLanguageItem->setContentWidgetData(QString("items"), secondaryLanguageItems);
   540         d->mSecondaryLanguageItem->setContentWidgetData(QString("currentIndex"), d->languageToIndex(secondaryLanguage, d->mSecondaryLanguages));
   967             if (d->mPrimaryInputLanguage != secondaryLanguage) {
       
   968                 d->mSecondaryLanguageItem->setContentWidgetData(QString("currentIndex"), d->languageToIndex(secondaryLanguage, d->mSecondaryLanguages));
       
   969             }
       
   970         } else {
       
   971             d->mSecondaryLanguageItem = new HbDataFormModelItem(HbDataFormModelItem::ComboBoxItem, QObject::tr("Secondary Writing language"));
       
   972             d->mLanguageGroup->appendChild(d->mSecondaryLanguageItem);
       
   973             d->mSecondaryLanguageItem->setContentWidgetData(QString("items"), secondaryLanguageItems);
       
   974             d->mSecondaryLanguageItem->setContentWidgetData(QString("currentIndex"), d->languageToIndex(secondaryLanguage, d->mSecondaryLanguages));
       
   975             d->mSecondaryLanguageItem->setContentWidgetData(QString("objectName"), QString("secondary_writing_language"));
       
   976             d->mForm->addConnection(d->mSecondaryLanguageItem, SIGNAL(currentIndexChanged(int)), this, SLOT(setSecondaryLanguage(int)));
       
   977         }
       
   978 
       
   979         HbDataFormModel *model = qobject_cast<HbDataFormModel *>(d->mForm->model());
       
   980         if (d->mChineseInputGroup) {
       
   981             model->removeItem(d->mChineseInputGroup);
       
   982             d->mChineseInputGroup = NULL;
       
   983         }
       
   984     } else {
       
   985         HbDataFormModel *model = qobject_cast<HbDataFormModel *>(d->mForm->model());
       
   986         if (d->mChineseInputGroup) {
       
   987             model->removeItem(d->mChineseInputGroup);
       
   988             d->mChineseInputGroup = NULL;
       
   989         }
       
   990 
       
   991         if (d->mSecondaryLanguageItem) {
       
   992             model->removeItem(d->mSecondaryLanguageItem);
       
   993             d->mSecondaryLanguageItem = NULL;
       
   994         }
       
   995 
       
   996         resetChineseInputMode();
       
   997         d->createChineseSettingGroup(model);
       
   998         d->mForm->setModel(model);
   541     }
   999     }
   542 }
  1000 }
   543 
  1001 
   544 /*!
  1002 /*!
   545 Saves the new secondary language
  1003 Saves the new secondary language
   629     } else {
  1087     } else {
   630         d->mPrimaryCandidateMode = HbPrimaryCandidateModeBestPrediction;
  1088         d->mPrimaryCandidateMode = HbPrimaryCandidateModeBestPrediction;
   631     }
  1089     }
   632     HbInputSettingProxy::instance()->setPrimaryCandidateMode(d->mPrimaryCandidateMode);
  1090     HbInputSettingProxy::instance()->setPrimaryCandidateMode(d->mPrimaryCandidateMode);
   633 }
  1091 }
       
  1092 
       
  1093 /*!
       
  1094 Saves the portrait input method
       
  1095 */
       
  1096 void HbInputSettingWidget::setPortraitInputMethod(int index)
       
  1097 {
       
  1098     Q_D(HbInputSettingWidget);
       
  1099     d->mCnPortraitInputMode = d->indexToInputmode(index, d->mCnPortraitInputModeList);
       
  1100     QString inputMethodString;
       
  1101     QByteArray customData;
       
  1102     d->setInputMethodVar(Qt::Vertical, inputMethodString, customData);
       
  1103 
       
  1104     const HbInputMethodDescriptor descriptor = d->findInputMethodDescriptor(inputMethodString);
       
  1105     HbInputSettingProxy::instance()->setPreferredInputMethod(Qt::Vertical, (const HbInputMethodDescriptor &)descriptor, customData);
       
  1106 }
       
  1107 
       
  1108 /*!
       
  1109 Saves the landscape input method
       
  1110 */
       
  1111 void HbInputSettingWidget::setLandscapeInputMethod(int index)
       
  1112 {
       
  1113     Q_D(HbInputSettingWidget);
       
  1114     d->mCnLandscapeInputMode = d->indexToInputmode(index, d->mCnLandscapeInputModeList);
       
  1115     QString inputMethodString;
       
  1116     QByteArray customData;
       
  1117     d->setInputMethodVar(Qt::Horizontal, inputMethodString, customData);
       
  1118 
       
  1119     const HbInputMethodDescriptor descriptor = d->findInputMethodDescriptor(inputMethodString);
       
  1120     HbInputSettingProxy::instance()->setPreferredInputMethod(Qt::Horizontal, descriptor, customData);
       
  1121 }
       
  1122 
       
  1123 /*!
       
  1124 Saves the cangjie input mode
       
  1125 */
       
  1126 void HbInputSettingWidget::setCangjieMode(int index)
       
  1127 {
       
  1128     Q_D(HbInputSettingWidget);
       
  1129     d->mCnCangjieInputMode = d->indexToInputmode(index, d->mCangjieInputModeList);
       
  1130     d->mCnLandscapeInputMode = d->mCnCangjieInputMode;
       
  1131 
       
  1132     QString inputMethodString;
       
  1133     QByteArray customData;
       
  1134     d->setInputMethodVar(Qt::Horizontal, inputMethodString, customData);
       
  1135 
       
  1136     const HbInputMethodDescriptor descriptor = d->findInputMethodDescriptor(inputMethodString);
       
  1137     HbInputSettingProxy::instance()->setPreferredInputMethod(Qt::Horizontal, descriptor, customData);
       
  1138 }
       
  1139 
       
  1140 
       
  1141 /*!
       
  1142 Saves the handwriting speed
       
  1143 */
       
  1144 void HbInputSettingWidget::setHwrSpeed(int index)
       
  1145 {
       
  1146     Q_D(HbInputSettingWidget);
       
  1147     Qt::Orientation currentOrientation = HbInputSettingProxy::instance()->screenOrientation();
       
  1148     QByteArray portraitCustomData = HbInputSettingProxy::instance()->preferredInputMethodCustomData(Qt::Vertical);
       
  1149     QByteArray landscapeCustomData = HbInputSettingProxy::instance()->preferredInputMethodCustomData(Qt::Horizontal);
       
  1150     HbInputMethodDescriptor portraitDes = HbInputSettingProxy::instance()->preferredInputMethod(Qt::Vertical);
       
  1151     HbInputMethodDescriptor landscapeDes = HbInputSettingProxy::instance()->preferredInputMethod(Qt::Horizontal);
       
  1152     QByteArray portraitHwrspeed = d->createHwrSpeedData(portraitCustomData, index);
       
  1153     QByteArray landscapeHwrspeed = d->createHwrSpeedData(landscapeCustomData, index);
       
  1154 
       
  1155     if (currentOrientation == Qt::Vertical) {
       
  1156         HbInputSettingProxy::instance()->setPreferredInputMethod(Qt::Horizontal, landscapeDes, landscapeHwrspeed);
       
  1157         HbInputSettingProxy::instance()->setPreferredInputMethod(Qt::Vertical, portraitDes, portraitHwrspeed);
       
  1158 
       
  1159     } if (currentOrientation == Qt::Horizontal) {
       
  1160         HbInputSettingProxy::instance()->setPreferredInputMethod(Qt::Vertical, portraitDes, portraitHwrspeed);
       
  1161         HbInputSettingProxy::instance()->setPreferredInputMethod(Qt::Horizontal, landscapeDes, landscapeHwrspeed);
       
  1162     }
       
  1163 }
       
  1164 
       
  1165 /*!
       
  1166 Saves the portrait input method
       
  1167 */
       
  1168 void HbInputSettingWidget::resetChineseInputMode()
       
  1169 {
       
  1170     Q_D(HbInputSettingWidget);
       
  1171     HbInputLanguage lang = HbInputSettingProxy::instance()->globalInputLanguage();
       
  1172 
       
  1173     if (lang.variant() == QLocale::China) {
       
  1174         d->mCnPortraitInputMode = KPinyinMode;
       
  1175         d->mCnLandscapeInputMode = KPinyinMode;
       
  1176     } else if (lang.variant() == QLocale::HongKong) {
       
  1177         d->mCnPortraitInputMode = KStrokeMode;
       
  1178         d->mCnLandscapeInputMode = KStrokeMode;
       
  1179     } else if (lang.variant() == QLocale::Taiwan) {
       
  1180         d->mCnPortraitInputMode = KZhuyinMode;
       
  1181         d->mCnLandscapeInputMode = KZhuyinMode;
       
  1182     }
       
  1183 
       
  1184     QString portraitInputMethodString;
       
  1185     QString landscapeInputMethodString;
       
  1186     QByteArray portraitCustomData;
       
  1187     QByteArray landscapeCustomData;
       
  1188     d->setInputMethodVar(Qt::Vertical, portraitInputMethodString, portraitCustomData);
       
  1189     d->setInputMethodVar(Qt::Horizontal, landscapeInputMethodString, landscapeCustomData);
       
  1190 
       
  1191     const HbInputMethodDescriptor portraitDescriptor = d->findInputMethodDescriptor(portraitInputMethodString);
       
  1192     const HbInputMethodDescriptor landscapeDescriptor = d->findInputMethodDescriptor(landscapeInputMethodString);
       
  1193     HbInputSettingProxy::instance()->setPreferredInputMethod(Qt::Vertical, (const HbInputMethodDescriptor &)portraitDescriptor, portraitCustomData);
       
  1194     HbInputSettingProxy::instance()->setPreferredInputMethod(Qt::Horizontal, (const HbInputMethodDescriptor &)landscapeDescriptor, landscapeCustomData);
       
  1195 }
       
  1196 
   634 /*
  1197 /*
   635     This slot is called when ever data in the form model is changed
  1198     This slot is called when ever data in the form model is changed
   636 */
  1199 */
   637 void HbInputSettingWidget::dataChange(const QModelIndex &startIn, const QModelIndex &endIn)
  1200 void HbInputSettingWidget::dataChange(const QModelIndex &startIn, const QModelIndex &endIn)
   638 {
  1201 {
   639     Q_D(HbInputSettingWidget);
  1202     Q_D(HbInputSettingWidget);
   640     Q_UNUSED(endIn);
  1203     Q_UNUSED(endIn);
   641     HbDataFormModelItem *item = d->mModel->itemFromIndex(startIn);    
  1204     HbDataFormModelItem *item = d->mModel->itemFromIndex(startIn);
   642     if(item == d->mPrimaryCandidateItem) {
  1205     if(item == d->mPrimaryCandidateItem) {
   643         setPrimaryCandidateMode();
  1206         setPrimaryCandidateMode();
   644     } else if(item == d->mCharacterPreviewItem) {
  1207     } else if(item == d->mCharacterPreviewItem) {
   645         setCharacterPreviewState();
  1208         setCharacterPreviewState();
   646     } 
  1209     } 
   658     disconnect(settings, SIGNAL(predictiveInputStateChanged(HbKeyboardSettingFlags, bool)), this, SLOT(updatePredictiveInputState(HbKeyboardSettingFlags, bool)));
  1221     disconnect(settings, SIGNAL(predictiveInputStateChanged(HbKeyboardSettingFlags, bool)), this, SLOT(updatePredictiveInputState(HbKeyboardSettingFlags, bool)));
   659     disconnect(settings, SIGNAL(characterPreviewStateForQwertyChanged(bool)), this, SLOT(updateCharacterPreviewStateForQwerty(bool)));
  1222     disconnect(settings, SIGNAL(characterPreviewStateForQwertyChanged(bool)), this, SLOT(updateCharacterPreviewStateForQwerty(bool)));
   660     disconnect(settings, SIGNAL(keypressTimeoutChanged(int)), this, SLOT(updateKeypressTimeout(int)));
  1223     disconnect(settings, SIGNAL(keypressTimeoutChanged(int)), this, SLOT(updateKeypressTimeout(int)));
   661     disconnect(settings, SIGNAL(autocompletionStateChanged(HbKeyboardSettingFlags, bool)), this, SLOT(updateAutocompletionState(HbKeyboardSettingFlags, bool)));
  1224     disconnect(settings, SIGNAL(autocompletionStateChanged(HbKeyboardSettingFlags, bool)), this, SLOT(updateAutocompletionState(HbKeyboardSettingFlags, bool)));
   662     disconnect(settings, SIGNAL(typingCorrectionLevelChanged(HbTypingCorrectionLevel)), this, SLOT(updateTypingCorrectionLevel(HbTypingCorrectionLevel)));
  1225     disconnect(settings, SIGNAL(typingCorrectionLevelChanged(HbTypingCorrectionLevel)), this, SLOT(updateTypingCorrectionLevel(HbTypingCorrectionLevel)));
   663     disconnect(settings, SIGNAL(primaryCandidateModeChanged(HbPrimaryCandidateMode)), this, SLOT(updatePrimaryCandidateMode(HbPrimaryCandidateMode)));    
  1226     disconnect(settings, SIGNAL(primaryCandidateModeChanged(HbPrimaryCandidateMode)), this, SLOT(updatePrimaryCandidateMode(HbPrimaryCandidateMode)));
   664 }
  1227 }
   665 
       
   666 
  1228 
   667 // End of file
  1229 // End of file