src/hbinput/inputwidgets/hbinputsettingwidget.cpp
changeset 7 923ff622b8b9
parent 6 c3690ec91ef8
child 23 e6ad4ef83b23
child 34 ed14f46c0e55
--- a/src/hbinput/inputwidgets/hbinputsettingwidget.cpp	Wed Jun 23 18:33:25 2010 +0300
+++ b/src/hbinput/inputwidgets/hbinputsettingwidget.cpp	Tue Jul 06 14:36:53 2010 +0300
@@ -29,17 +29,82 @@
 #include <hbinpututils.h>
 #include <hbinputsettingproxy.h>
 #include <hbinputpredictionfactory.h>
+#include <QInputContextPlugin>
+#include <QLibrary>
+#include <QPluginLoader>
+#include <QDir>
 #include <QtAlgorithms>
 
 #include "hbinputcheckboxlist_p.h"
+#include "hbinputsettingproxy_p.h"
+#include <hbinputmethoddescriptor.h>
 
 const QString statusOff = QObject::tr("Off");
 const QString statusOn = QObject::tr("On");
 const QString bestPrediction = QObject::tr("Best prediction");
 const QString exactTyping = QObject::tr("Exact typing");
 
+/// @cond
+// input modes name for chinese
+const QString KPinyinName("Pinyin");
+const QString KStrokeName("Stroke");
+const QString KZhuyinName("Zhuyin");
+const QString KCangjieNormalName("CangjieNormal");
+const QString KCangjieEasyName("CangjieEasy");
+const QString KCangjieAdvancedName("CangjieAdvanced");
+const QString KHwrName("Handwriting");
+const QString KHwrVerySlowName("VerySlow");
+const QString KHwrSlowName("Slow");
+const QString KHwrNormalName("Normal");
+const QString KHwrFastName("Fast");
+const QString KHwrVeryFastName("VeryFast");
 
-/// @cond
+// strings used for represent cangjie
+const QString KCangjieGeneralName("Cangjie");
+const QString KEasy("Easy");
+const QString KNormal("Normal");
+const QString KAdvanced("Advanced");
+
+// input modes value for chinese
+const int KChineseInputModeNone = -1;
+const int KPinyinMode = 0;
+const int KStrokeMode = 1;
+const int KZhuyinMode = 2;
+const int KCangjieNormalMode = 3;
+const int KCangjieEasyMode = 4;
+const int KCangjieAdvancedMode = 5;
+const int KHwrMode = 6;
+
+// define chinese input plugin name
+#ifdef Q_OS_WIN
+const QString KCnHwrPluginName("HbChineseHwrd.dll");
+#else
+#ifdef Q_OS_SYMBIAN
+const QString KCnHwrPluginName("HbChineseHwr.qtplugin");
+#else
+const QString KCnHwrPluginName("HbChineseHwr.dll");
+#endif
+#endif
+
+#ifdef Q_OS_WIN
+const QString KCnVItutPluginName("HbChineseVItutd.dll");
+#else
+#ifdef Q_OS_SYMBIAN
+const QString KCnVItutPluginName("HbChineseVItut.qtplugin");
+#else
+const QString KCnVItutPluginName("HbChineseVItut.dll");
+#endif
+#endif
+
+#ifdef Q_OS_WIN
+const QString KCnVkbPluginName("HbChineseVkbd.dll");
+#else
+#ifdef Q_OS_SYMBIAN
+const QString KCnVkbPluginName("HbChineseVkb.qtplugin");
+#else
+const QString KCnVkbPluginName("HbChineseVkb.dll");
+#endif
+#endif
 
 class HbInputSettingWidgetPrivate
 {
@@ -55,6 +120,14 @@
     HbInputLanguage indexToLanguage(int index, const QList<HbInputLanguage> &languageList);
     void createSecondaryLanguageList();
     void updateContentWidgetData();
+    int inputModeToIndex(const int &inputMode, const QList<int> &inputModeList);
+    int indexToInputmode(int index, const QList<int> &inputModeList);
+    void createChineseSettingGroup(HbDataFormModel *model);
+
+    QInputContextPlugin *pluginInstance(const QString &pluginFileName) const;
+    HbInputMethodDescriptor findInputMethodDescriptor(const QString &inputMethodString);
+    void setInputMethodVar(Qt::Orientation orientation, QString &inputMethodString, QByteArray &num);
+    QByteArray createHwrSpeedData(QByteArray preferredCustomData, int index);
 public:
     HbDataForm *mForm;
     HbDataFormModelItem *mPrimaryLanguageItem;
@@ -79,17 +152,49 @@
     HbPrimaryCandidateMode mPrimaryCandidateMode;
     HbInputSettingWidget *q_ptr;
     HbDataFormModel *mModel;
+
+    // member variables for chinese
+    HbDataFormModelItem *mLanguageGroup;
+    HbDataFormModelItem *mChineseInputGroup;
+    HbDataFormModelItem *mPortraitInputMethodItem;
+    HbDataFormModelItem *mLandscapeInputMethodItem;
+    HbDataFormModelItem *mHwrSpeedItem;
+    HbDataFormModelItem *mCangjieItem;
+    int mCnPortraitInputMode;
+    int mCnLandscapeInputMode;
+    int mCnCangjieInputMode;
+
+    int mHwrSpeed;
+    QList<int> mCnPortraitInputModeList;
+    QList<int> mCnLandscapeInputModeList;
+    QList<int> mCangjieInputModeList;
+    QStringList mCnPortraitInputModeNames;
+    QStringList mCnLandscapeInputModeNames;
+    QStringList mCnCangjieInputModeNames;
+    QStringList mHwrSpeedNames;
 };
 
 /*!
 Constructs setting widget
 */
 HbInputSettingWidgetPrivate::HbInputSettingWidgetPrivate(HbDataForm *dataForm)
- : mForm(dataForm), mPrimaryLanguageItem(NULL),
-   mSecondaryLanguageItem(NULL), mKeypressTimeoutItem(NULL),
-   mCharacterPreviewItem(NULL), mPredictionItem(NULL),
-   mAutoCompletionItem(NULL), mCorrectionLevelItem(NULL),
-   mPrimaryCandidateItem(NULL), q_ptr(NULL), mModel(0)
+    : mForm(dataForm),
+      mPrimaryLanguageItem(0),
+      mSecondaryLanguageItem(0),
+      mKeypressTimeoutItem(0),
+      mCharacterPreviewItem(0),
+      mPredictionItem(0),
+      mAutoCompletionItem(0),
+      mCorrectionLevelItem(0),
+      mPrimaryCandidateItem(0),
+      q_ptr(0),
+      mModel(0),
+      mLanguageGroup(0),
+      mChineseInputGroup(0),
+      mPortraitInputMethodItem(0),
+      mLandscapeInputMethodItem(0),
+      mHwrSpeedItem(0),
+      mCangjieItem(0)
 {
 }
 
@@ -128,7 +233,161 @@
     }
 }
 
-void HbInputSettingWidgetPrivate::updateContentWidgetData() 
+void HbInputSettingWidgetPrivate::createChineseSettingGroup(HbDataFormModel *model)
+{
+    Q_Q(HbInputSettingWidget);
+    int imMode = KChineseInputModeNone;
+    QByteArray ba = HbInputSettingProxy::instance()->preferredInputMethodCustomData(Qt::Vertical);
+    QString portraitCustomData(ba);
+    QString imName = portraitCustomData.split(" ").at(0);
+    HbInputLanguage lang = HbInputSettingProxy::instance()->globalInputLanguage();
+
+    if (imName == KPinyinName) {
+        imMode = KPinyinMode;
+    } else if (imName == KStrokeName) {
+        imMode = KStrokeMode;
+    } else if (imName == KZhuyinName) {
+        imMode = KZhuyinMode;
+    } else if (imName == KHwrName) {
+        imMode = KHwrMode;
+    } else {
+        if (lang.variant() == QLocale::China) {
+            imMode = KPinyinMode;
+        } else if (lang.variant() == QLocale::HongKong) {
+            imMode = KStrokeMode;
+        } else if (lang.variant() == QLocale::Taiwan) {
+            imMode = KZhuyinMode;
+        }
+    }
+
+    mCnPortraitInputMode = imMode;
+
+    ba = HbInputSettingProxy::instance()->preferredInputMethodCustomData(Qt::Horizontal);
+    QString landscapeCustomData(ba);
+    imName = landscapeCustomData.split(" ").at(0);
+
+    mCnCangjieInputMode = KCangjieNormalMode;
+    if (imName == KPinyinName) {
+        mCnLandscapeInputMode = KPinyinMode;
+    } else if (imName == KStrokeName) {
+        mCnLandscapeInputMode = KStrokeMode;
+    } else if (imName == KZhuyinName) {
+        mCnLandscapeInputMode = KZhuyinMode;
+    } else if (imName == KCangjieNormalName) {
+        mCnLandscapeInputMode = KCangjieNormalMode;
+        mCnCangjieInputMode = KCangjieNormalMode;
+    } else if (imName == KCangjieEasyName) {
+        mCnLandscapeInputMode = KCangjieNormalMode;
+        mCnCangjieInputMode = KCangjieEasyMode;
+    } else if (imName == KCangjieAdvancedName) {
+        mCnLandscapeInputMode = KCangjieNormalMode;
+        mCnCangjieInputMode = KCangjieAdvancedMode;
+    } else if (imName == KHwrName) {
+        mCnLandscapeInputMode = KHwrMode;
+    } else {
+        if (lang.variant() == QLocale::China) {
+            mCnLandscapeInputMode = KPinyinMode;
+        } else if (lang.variant() == QLocale::HongKong) {
+            mCnLandscapeInputMode = KStrokeMode;
+        } else if (lang.variant() == QLocale::Taiwan) {
+            mCnLandscapeInputMode = KZhuyinMode;
+        }
+    }
+
+    Qt::Orientation orientation = HbInputSettingProxy::instance()->screenOrientation();
+    ba = HbInputSettingProxy::instance()->preferredInputMethodCustomData(orientation);
+    QString customData(ba);
+    if (customData.split(" ").count() > 1) {
+        imName = customData.split(" ").at(1);
+        if (imName == KHwrVerySlowName) {
+            mHwrSpeed = 0;
+        } else if (imName == KHwrSlowName) {
+            mHwrSpeed = 1;
+        } else if (imName == KHwrNormalName) {
+            mHwrSpeed = 2;
+        } else if (imName == KHwrFastName) {
+            mHwrSpeed = 3;
+        } else if (imName == KHwrVeryFastName) {
+            mHwrSpeed = 4;
+        } else {
+            mHwrSpeed = 2;
+        }
+    } else {
+        mHwrSpeed = 2;
+    }
+
+    mHwrSpeedNames.clear();
+    mCnPortraitInputModeList.clear();
+    mCnLandscapeInputModeList.clear();
+    mCnPortraitInputModeNames.clear();
+    mCnLandscapeInputModeNames.clear();
+    mCnCangjieInputModeNames.clear();
+
+    mHwrSpeedNames << "Very slow" << "Slow" << "Normal" << "Fast" << "Very Fast";
+    if (mPrimaryInputLanguage == HbInputLanguage(QLocale::Chinese, QLocale::China)) {
+        mCnPortraitInputModeList << KPinyinMode << KStrokeMode << KHwrMode;
+        mCnLandscapeInputModeList << KPinyinMode << KStrokeMode << KHwrMode;
+        mCnPortraitInputModeNames << KPinyinName << KStrokeName << KHwrName;
+        mCnLandscapeInputModeNames << KPinyinName << KStrokeName << KHwrName;
+    } else if (mPrimaryInputLanguage == HbInputLanguage(QLocale::Chinese, QLocale::HongKong)) {
+        mCnPortraitInputModeList << KStrokeMode << KHwrMode;
+        mCnLandscapeInputModeList << KStrokeMode << KCangjieNormalMode << KHwrMode;
+        mCangjieInputModeList << KCangjieEasyMode << KCangjieNormalMode << KCangjieAdvancedMode;
+        mCnPortraitInputModeNames << KStrokeName << KHwrName;
+        mCnLandscapeInputModeNames << KStrokeName << KCangjieGeneralName << KHwrName;
+        mCnCangjieInputModeNames << KEasy << KNormal << KAdvanced;
+    } else if (mPrimaryInputLanguage == HbInputLanguage(QLocale::Chinese, QLocale::Taiwan)) {
+        mCnPortraitInputModeList << KZhuyinMode << KHwrMode;
+        mCnLandscapeInputModeList << KZhuyinMode << KHwrMode;
+        mCnPortraitInputModeNames << KZhuyinName << KHwrName;
+        mCnLandscapeInputModeNames << KZhuyinName << KHwrName;
+    }
+
+    if (!mChineseInputGroup) {
+        mChineseInputGroup = model->appendDataFormGroup(QObject::tr("Chinese Input"));
+        mPortraitInputMethodItem = new HbDataFormModelItem(HbDataFormModelItem::ComboBoxItem, QObject::tr("Portrait mode input method"));
+        mChineseInputGroup->appendChild(mPortraitInputMethodItem);
+        mPortraitInputMethodItem->setContentWidgetData(QString("items"), mCnPortraitInputModeNames);
+        int imIdx = inputModeToIndex(mCnPortraitInputMode, mCnPortraitInputModeList);
+        QVariant varPor;
+        varPor.setValue(imIdx);
+        mPortraitInputMethodItem->setContentWidgetData(QString("currentIndex"), varPor);
+        mPortraitInputMethodItem->setContentWidgetData(QString("objectName"), QString("portrait_input_method"));
+        mForm->addConnection(mPortraitInputMethodItem, SIGNAL(currentIndexChanged(int)), q, SLOT(setPortraitInputMethod(int)));
+
+        mLandscapeInputMethodItem = new HbDataFormModelItem(HbDataFormModelItem::ComboBoxItem, QObject::tr("Landscape mode input method"));
+        mChineseInputGroup->appendChild(mLandscapeInputMethodItem);
+        mLandscapeInputMethodItem->setContentWidgetData(QString("items"), mCnLandscapeInputModeNames);
+        int imIdx_lan = inputModeToIndex(mCnLandscapeInputMode, mCnLandscapeInputModeList);
+        QVariant varLan;
+        varLan.setValue(imIdx_lan);
+        mLandscapeInputMethodItem->setContentWidgetData(QString("currentIndex"), varLan);
+        mLandscapeInputMethodItem->setContentWidgetData(QString("objectName"), QString("landscape_input_method"));
+        mForm->addConnection(mLandscapeInputMethodItem, SIGNAL(currentIndexChanged(int)), q, SLOT(setLandscapeInputMethod(int)));
+
+        mHwrSpeedItem = new HbDataFormModelItem(HbDataFormModelItem::ComboBoxItem, QObject::tr("Handwriting speed"));
+        mChineseInputGroup->appendChild(mHwrSpeedItem);
+        mHwrSpeedItem->setContentWidgetData(QString("items"), mHwrSpeedNames);
+        int hwr = mHwrSpeed;
+        mHwrSpeedItem->setContentWidgetData(QString("currentIndex"), hwr);
+        mHwrSpeedItem->setContentWidgetData(QString("objectName"), QString("handwriting_speed"));
+        mForm->addConnection(mHwrSpeedItem, SIGNAL(currentIndexChanged(int)), q, SLOT(setHwrSpeed(int)));
+    }
+
+    if (mPrimaryInputLanguage == HbInputLanguage(QLocale::Chinese, QLocale::HongKong)) {
+        mCangjieItem = new HbDataFormModelItem(HbDataFormModelItem::ComboBoxItem, QObject::tr("Cangjie mode"));
+        mChineseInputGroup->appendChild(mCangjieItem);
+        mCangjieItem->setContentWidgetData(QString("items"), mCnCangjieInputModeNames);
+        int cangjieIdx = inputModeToIndex(mCnCangjieInputMode, mCangjieInputModeList);
+        QVariant varCang;
+        varCang.setValue(cangjieIdx);
+        mCangjieItem->setContentWidgetData(QString("currentIndex"), varCang);
+        mCangjieItem->setContentWidgetData(QString("objectName"), QString("cangjie_mode"));
+        mForm->addConnection(mCangjieItem, SIGNAL(currentIndexChanged(int)), q, SLOT(setCangjieMode(int)));
+    }
+}
+
+void HbInputSettingWidgetPrivate::updateContentWidgetData()
 {
     // current primary language
     mPrimaryLanguageItem->setContentWidgetData(QString("currentIndex"), languageToIndex(mPrimaryInputLanguage, mPrimaryLanguages));
@@ -172,14 +431,14 @@
     mModel = new HbDataFormModel();
 
     HbInputCheckBoxList *customPrototype = new HbInputCheckBoxList(mForm);
-    QList<HbAbstractViewItem*> prototypes = mForm->itemPrototypes();
+    QList<HbAbstractViewItem *> prototypes = mForm->itemPrototypes();
     prototypes.append(customPrototype);
     mForm->setItemPrototypes(prototypes);
 
-    HbDataFormModelItem *languageGroup = mModel->appendDataFormGroup(QObject::tr("Language"));
+    mLanguageGroup = mModel->appendDataFormGroup(QObject::tr("Language"));
 
     mPrimaryLanguageItem = new HbDataFormModelItem(HbDataFormModelItem::ComboBoxItem, QObject::tr("Primary Writing language"));
-    languageGroup->appendChild(mPrimaryLanguageItem);
+    mLanguageGroup->appendChild(mPrimaryLanguageItem);
     QStringList writingLanguageItems;
     fillLanguageList(writingLanguageItems, mPrimaryLanguages);
     mPrimaryLanguageItem->setContentWidgetData(QString("items"), writingLanguageItems);
@@ -187,15 +446,16 @@
     mPrimaryLanguageItem->setContentWidgetData(QString("objectName"), QString("primary_writing_language"));
     mForm->addConnection(mPrimaryLanguageItem, SIGNAL(currentIndexChanged(int)), q, SLOT(setPrimaryLanguage(int)));
 
-    mSecondaryLanguageItem = new HbDataFormModelItem(HbDataFormModelItem::ComboBoxItem, QObject::tr("Secondary Writing language"));
-    languageGroup->appendChild(mSecondaryLanguageItem);
-    QStringList secondaryLanguageItems;
-    fillLanguageList(secondaryLanguageItems, mSecondaryLanguages, QObject::tr("None"));
-    mSecondaryLanguageItem->setContentWidgetData(QString("items"), secondaryLanguageItems);
-    mSecondaryLanguageItem->setContentWidgetData(QString("currentIndex"), languageToIndex(mSecondaryInputLanguage, mSecondaryLanguages));
-    mSecondaryLanguageItem->setContentWidgetData(QString("objectName"), QString("secondary_writing_language"));
-    mForm->addConnection(mSecondaryLanguageItem, SIGNAL(currentIndexChanged(int)), q, SLOT(setSecondaryLanguage(int)));
-
+    if (mPrimaryInputLanguage.language() != QLocale::Chinese) {
+        mSecondaryLanguageItem = new HbDataFormModelItem(HbDataFormModelItem::ComboBoxItem, QObject::tr("Secondary Writing language"));
+        mLanguageGroup->appendChild(mSecondaryLanguageItem);
+        QStringList secondaryLanguageItems;
+        fillLanguageList(secondaryLanguageItems, mSecondaryLanguages, QObject::tr("None"));
+        mSecondaryLanguageItem->setContentWidgetData(QString("items"), secondaryLanguageItems);
+        mSecondaryLanguageItem->setContentWidgetData(QString("currentIndex"), languageToIndex(mSecondaryInputLanguage, mSecondaryLanguages));
+        mSecondaryLanguageItem->setContentWidgetData(QString("objectName"), QString("secondary_writing_language"));
+        mForm->addConnection(mSecondaryLanguageItem, SIGNAL(currentIndexChanged(int)), q, SLOT(setSecondaryLanguage(int)));
+    }
     HbDataFormModelItem *keyboardGroup = mModel->appendDataFormGroup(QObject::tr("Keyboard"));
 
     mKeypressTimeoutItem = new HbDataFormModelItem(HbDataFormModelItem::SliderItem, QObject::tr("Keypress Timeout"));
@@ -216,8 +476,6 @@
         mCharacterPreviewItem->setContentWidgetData(QString("additionalText"), statusOn);
     }
     mCharacterPreviewItem->setContentWidgetData(QString("objectName"), QString("character_bubble"));
-    
-
 
     HbDataFormModelItem *textInputGroup = mModel->appendDataFormGroup(QObject::tr("Intelligent Text Input"));
 
@@ -249,7 +507,7 @@
     mCorrectionLevelItem = new HbDataFormModelItem(HbDataFormModelItem::RadioButtonListItem, QObject::tr("Typing Correction"));
     textInputGroup->appendChild(mCorrectionLevelItem);
     QStringList correctionLevels;
-    correctionLevels << QObject::tr("Low") << QObject::tr("Medium") << QObject::tr("High");
+    correctionLevels << QObject::tr("Off") << QObject::tr("Medium") << QObject::tr("High");
     mCorrectionLevelItem->setContentWidgetData(QString("items"), correctionLevels);
     mCorrectionLevelItem->setContentWidgetData(QString("selected"), mTypingCorrectionLevel);
     mCorrectionLevelItem->setContentWidgetData(QString("objectName"), QString("typing_correction"));
@@ -265,7 +523,11 @@
         mPrimaryCandidateItem->setContentWidgetData(QString("additionalText"), bestPrediction);
     }
     mPrimaryCandidateItem->setContentWidgetData(QString("objectName"), QString("primary_candidate"));
-    mForm->setModel(mModel);    
+
+    if (mPrimaryInputLanguage.language() == QLocale::Chinese) {
+        createChineseSettingGroup(mModel);
+    }
+    mForm->setModel(mModel);
     QObject::connect(mModel, SIGNAL(dataChanged(QModelIndex, QModelIndex)), q, SLOT(dataChange(QModelIndex, QModelIndex)));
 }
 
@@ -327,13 +589,178 @@
     }
 }
 
+/*!
+Returns index of the given inputmode at the inputmode list
+*/
+int HbInputSettingWidgetPrivate::inputModeToIndex(const int &inputMode, const QList<int> &inputModeList)
+{
+    for (int i = 0; i < inputModeList.count(); ++i) {
+        if (inputModeList.at(i) == inputMode) {
+            return i;
+        }
+    }
+    return -1;
+}
+
+/*!
+Returns inputmode in the given index at the inputmode list
+*/
+int HbInputSettingWidgetPrivate::indexToInputmode(int index, const QList<int> &inputModeList)
+{
+    if (index >= 0 && index < inputModeList.count()) {
+        return inputModeList.at(index);
+    } else {
+        return KChineseInputModeNone;
+    }
+}
+
+QInputContextPlugin *HbInputSettingWidgetPrivate::pluginInstance(const QString &pluginFileName) const
+{
+    if (QLibrary::isLibrary(pluginFileName)) {
+        QPluginLoader loader(pluginFileName);
+        QObject *plugin = loader.instance();
+        if (plugin) {
+            return qobject_cast<QInputContextPlugin *>(plugin);
+        }
+    }
+
+    return 0;
+}
+
+HbInputMethodDescriptor HbInputSettingWidgetPrivate::findInputMethodDescriptor(const QString &inputMethodString)
+{
+    HbInputMethodDescriptor descriptor;
+    // Query plugin paths and scan the folders.
+    QStringList folders = HbInputSettingProxy::instance()->inputMethodPluginPaths();
+    foreach(const QString &folder, folders) {
+        QDir dir(folder);
+        for (unsigned int i = 0; i < dir.count(); i++) {
+            QString path = QString(dir.absolutePath());
+            if (path.right(1) != "\\" && path.right(1) != "/") {
+                path += QDir::separator();
+            }
+            path += inputMethodString;
+            QInputContextPlugin *inputContextPlugin = pluginInstance(path);
+            if (inputContextPlugin) {
+                descriptor.setPluginNameAndPath(dir.absolutePath() + QDir::separator() + inputMethodString);
+
+                // For each found plugin, check if there is already a list item for it.
+                // If not, then add one.
+                QStringList contextKeys = inputContextPlugin->keys();
+                foreach(QString key, contextKeys) {
+                    descriptor.setKey(key);
+                    descriptor.setDisplayName(inputContextPlugin->displayName(key));
+                }
+                break;
+            }
+        }
+    }
+    return descriptor;
+}
+
+void HbInputSettingWidgetPrivate::setInputMethodVar(Qt::Orientation orientation, QString &inputMethodString, QByteArray &customData)
+{
+    int inputMode = KChineseInputModeNone;
+    if (orientation == Qt::Vertical) {
+        inputMode = mCnPortraitInputMode;
+    } else if (orientation == Qt::Horizontal) {
+        inputMode = mCnLandscapeInputMode;
+    } else {
+        return;
+    }
+
+    switch (inputMode) {
+    case KPinyinMode: {
+        orientation == Qt::Vertical ? inputMethodString = KCnVItutPluginName : inputMethodString = KCnVkbPluginName;
+        customData.append(KPinyinName.toLatin1().data());
+    }
+    break;
+    case KStrokeMode: {
+        orientation == Qt::Vertical ? inputMethodString = KCnVItutPluginName : inputMethodString = KCnVkbPluginName;
+        customData.append(KStrokeName.toLatin1().data());
+    }
+    break;
+    case KZhuyinMode: {
+        orientation == Qt::Vertical ? inputMethodString = KCnVItutPluginName : inputMethodString = KCnVkbPluginName;
+        customData.append(KZhuyinName.toLatin1().data());
+    }
+    break;
+    case KHwrMode: {
+        inputMethodString = KCnHwrPluginName;
+        customData.append(KHwrName.toLatin1().data());
+    }
+    break;
+    case KCangjieNormalMode: {
+        inputMethodString = KCnVkbPluginName;
+        customData.append(KCangjieNormalName.toLatin1().data());
+    }
+    break;
+    case KCangjieEasyMode: {
+        inputMethodString = KCnVkbPluginName;
+        customData.append(KCangjieEasyName.toLatin1().data());
+    }
+    break;
+    case KCangjieAdvancedMode: {
+        inputMethodString = KCnVkbPluginName;
+        customData.append(KCangjieAdvancedName.toLatin1().data());
+    }
+    break;
+    default:
+        break;
+    }
+
+    QByteArray preferredCustomData = HbInputSettingProxy::instance()->preferredInputMethodCustomData(orientation);
+    QString imName(preferredCustomData);
+    QStringList temp = imName.split(" ");
+    if (temp.count() > 1) {
+        customData.append(" ");
+        customData.append(temp.at(1).toLatin1().data());	
+    } else {
+        customData.append(" ");
+        customData.append(KHwrNormalName.toLatin1().data());
+    }
+    customData.append((char)0);
+    return;
+}
+
+QByteArray HbInputSettingWidgetPrivate::createHwrSpeedData(QByteArray preferredCustomData, int index)
+{
+    QString imName(preferredCustomData);
+    QStringList temp = imName.split(" ");
+
+    QByteArray customData;
+    customData.append(temp.at(0).toLatin1().data());
+    customData.append(" ");
+    switch (index) {
+    case 0:
+        customData.append(KHwrVerySlowName.toLatin1().data());
+        break;
+    case 1:
+        customData.append(KHwrSlowName.toLatin1().data());
+        break;
+    case 2:
+        customData.append(KHwrNormalName.toLatin1().data());
+        break;
+    case 3:
+        customData.append(KHwrFastName.toLatin1().data());
+        break;
+    case 4:
+        customData.append(KHwrVeryFastName.toLatin1().data());
+        break;
+    default:
+        break;
+    }
+    customData.append((char)0);
+    return customData;
+}
+
 /// @endcond
 
 /*!
 Constructs input setting widget
 */
-HbInputSettingWidget::HbInputSettingWidget(HbDataForm *dataForm, QGraphicsWidget* parent)
- : QObject(parent), d_ptr(new HbInputSettingWidgetPrivate(dataForm))
+HbInputSettingWidget::HbInputSettingWidget(HbDataForm *dataForm, QGraphicsWidget *parent)
+    : QObject(parent), d_ptr(new HbInputSettingWidgetPrivate(dataForm))
 {
     Q_D(HbInputSettingWidget);
     d->q_ptr = this;
@@ -406,7 +833,7 @@
         d->mPredictionStatusForITUT = newState;
         changed = true;
     } else if (keyboardType & HbKeyboardSettingQwerty &&
-        d->mPredictionStatusForQwerty != newState) {
+               d->mPredictionStatusForQwerty != newState) {
         d->mPredictionStatusForQwerty = newState;
         changed = true;
     }
@@ -463,7 +890,7 @@
         d->mAutocompletionForITUT = newState;
         changed = true;
     } else if (keyboardType & HbKeyboardSettingQwerty &&
-        d->mAutocompletionForQwerty != newState) {
+               d->mAutocompletionForQwerty != newState) {
         d->mAutocompletionForQwerty = newState;
         changed = true;
     }
@@ -514,30 +941,61 @@
 {
     Q_D(HbInputSettingWidget);
 
-	HbInputSettingProxy *settings = HbInputSettingProxy::instance();
+    HbInputSettingProxy *settings = HbInputSettingProxy::instance();
     HbPredictionFactory *predFactory = HbPredictionFactory::instance();
-    bool oldPLangSupportsPrediction = (predFactory->predictionEngineForLanguage(d->mPrimaryInputLanguage) != NULL);		
+    bool oldPLangSupportsPrediction = (predFactory->predictionEngineForLanguage(d->mPrimaryInputLanguage) != NULL);
     d->mPrimaryInputLanguage = d->indexToLanguage(index, d->mPrimaryLanguages);
     HbInputSettingProxy::instance()->setGlobalInputLanguage(d->mPrimaryInputLanguage);
-    bool langSupportsPrediction = (predFactory->predictionEngineForLanguage(d->mPrimaryInputLanguage) != NULL);		
-	if( oldPLangSupportsPrediction != langSupportsPrediction) {
-		if(settings->predictiveInputStatus(HbKeyboardSetting12key) != langSupportsPrediction) {
-			settings->setPredictiveInputStatus(HbKeyboardSetting12key, langSupportsPrediction);
-		} 
-		if (settings->predictiveInputStatus(HbKeyboardSettingQwerty) != langSupportsPrediction) {
-			settings->setPredictiveInputStatus(HbKeyboardSettingQwerty, langSupportsPrediction);
-		}
-	} 	
+    bool langSupportsPrediction = (predFactory->predictionEngineForLanguage(d->mPrimaryInputLanguage) != NULL);
+    if (oldPLangSupportsPrediction != langSupportsPrediction) {
+        if (settings->predictiveInputStatus(HbKeyboardSetting12key) != langSupportsPrediction) {
+            settings->setPredictiveInputStatus(HbKeyboardSetting12key, langSupportsPrediction);
+        }
+        if (settings->predictiveInputStatus(HbKeyboardSettingQwerty) != langSupportsPrediction) {
+            settings->setPredictiveInputStatus(HbKeyboardSettingQwerty, langSupportsPrediction);
+        }
+    }
 
-    HbInputLanguage secondaryLanguage = d->mSecondaryInputLanguage;
-    // Update secondary language list
-    d->createSecondaryLanguageList();
-    QStringList secondaryLanguageItems;
-    d->fillLanguageList(secondaryLanguageItems, d->mSecondaryLanguages, tr("None"));
-    d->mSecondaryLanguageItem->setContentWidgetData(QString("items"), secondaryLanguageItems);
+    if (d->mPrimaryInputLanguage.language() != QLocale::Chinese) {
+        HbInputLanguage secondaryLanguage = d->mSecondaryInputLanguage;
+        // Update secondary language list
+        d->createSecondaryLanguageList();
+        QStringList secondaryLanguageItems;
+        d->fillLanguageList(secondaryLanguageItems, d->mSecondaryLanguages, tr("None"));
+        if (d->mSecondaryLanguageItem) {
+            d->mSecondaryLanguageItem->setContentWidgetData(QString("items"), secondaryLanguageItems);
+            if (d->mPrimaryInputLanguage != secondaryLanguage) {
+                d->mSecondaryLanguageItem->setContentWidgetData(QString("currentIndex"), d->languageToIndex(secondaryLanguage, d->mSecondaryLanguages));
+            }
+        } else {
+            d->mSecondaryLanguageItem = new HbDataFormModelItem(HbDataFormModelItem::ComboBoxItem, QObject::tr("Secondary Writing language"));
+            d->mLanguageGroup->appendChild(d->mSecondaryLanguageItem);
+            d->mSecondaryLanguageItem->setContentWidgetData(QString("items"), secondaryLanguageItems);
+            d->mSecondaryLanguageItem->setContentWidgetData(QString("currentIndex"), d->languageToIndex(secondaryLanguage, d->mSecondaryLanguages));
+            d->mSecondaryLanguageItem->setContentWidgetData(QString("objectName"), QString("secondary_writing_language"));
+            d->mForm->addConnection(d->mSecondaryLanguageItem, SIGNAL(currentIndexChanged(int)), this, SLOT(setSecondaryLanguage(int)));
+        }
 
-    if (d->mPrimaryInputLanguage != secondaryLanguage) {
-        d->mSecondaryLanguageItem->setContentWidgetData(QString("currentIndex"), d->languageToIndex(secondaryLanguage, d->mSecondaryLanguages));
+        HbDataFormModel *model = qobject_cast<HbDataFormModel *>(d->mForm->model());
+        if (d->mChineseInputGroup) {
+            model->removeItem(d->mChineseInputGroup);
+            d->mChineseInputGroup = NULL;
+        }
+    } else {
+        HbDataFormModel *model = qobject_cast<HbDataFormModel *>(d->mForm->model());
+        if (d->mChineseInputGroup) {
+            model->removeItem(d->mChineseInputGroup);
+            d->mChineseInputGroup = NULL;
+        }
+
+        if (d->mSecondaryLanguageItem) {
+            model->removeItem(d->mSecondaryLanguageItem);
+            d->mSecondaryLanguageItem = NULL;
+        }
+
+        resetChineseInputMode();
+        d->createChineseSettingGroup(model);
+        d->mForm->setModel(model);
     }
 }
 
@@ -631,6 +1089,111 @@
     }
     HbInputSettingProxy::instance()->setPrimaryCandidateMode(d->mPrimaryCandidateMode);
 }
+
+/*!
+Saves the portrait input method
+*/
+void HbInputSettingWidget::setPortraitInputMethod(int index)
+{
+    Q_D(HbInputSettingWidget);
+    d->mCnPortraitInputMode = d->indexToInputmode(index, d->mCnPortraitInputModeList);
+    QString inputMethodString;
+    QByteArray customData;
+    d->setInputMethodVar(Qt::Vertical, inputMethodString, customData);
+
+    const HbInputMethodDescriptor descriptor = d->findInputMethodDescriptor(inputMethodString);
+    HbInputSettingProxy::instance()->setPreferredInputMethod(Qt::Vertical, (const HbInputMethodDescriptor &)descriptor, customData);
+}
+
+/*!
+Saves the landscape input method
+*/
+void HbInputSettingWidget::setLandscapeInputMethod(int index)
+{
+    Q_D(HbInputSettingWidget);
+    d->mCnLandscapeInputMode = d->indexToInputmode(index, d->mCnLandscapeInputModeList);
+    QString inputMethodString;
+    QByteArray customData;
+    d->setInputMethodVar(Qt::Horizontal, inputMethodString, customData);
+
+    const HbInputMethodDescriptor descriptor = d->findInputMethodDescriptor(inputMethodString);
+    HbInputSettingProxy::instance()->setPreferredInputMethod(Qt::Horizontal, descriptor, customData);
+}
+
+/*!
+Saves the cangjie input mode
+*/
+void HbInputSettingWidget::setCangjieMode(int index)
+{
+    Q_D(HbInputSettingWidget);
+    d->mCnCangjieInputMode = d->indexToInputmode(index, d->mCangjieInputModeList);
+    d->mCnLandscapeInputMode = d->mCnCangjieInputMode;
+
+    QString inputMethodString;
+    QByteArray customData;
+    d->setInputMethodVar(Qt::Horizontal, inputMethodString, customData);
+
+    const HbInputMethodDescriptor descriptor = d->findInputMethodDescriptor(inputMethodString);
+    HbInputSettingProxy::instance()->setPreferredInputMethod(Qt::Horizontal, descriptor, customData);
+}
+
+
+/*!
+Saves the handwriting speed
+*/
+void HbInputSettingWidget::setHwrSpeed(int index)
+{
+    Q_D(HbInputSettingWidget);
+    Qt::Orientation currentOrientation = HbInputSettingProxy::instance()->screenOrientation();
+    QByteArray portraitCustomData = HbInputSettingProxy::instance()->preferredInputMethodCustomData(Qt::Vertical);
+    QByteArray landscapeCustomData = HbInputSettingProxy::instance()->preferredInputMethodCustomData(Qt::Horizontal);
+    HbInputMethodDescriptor portraitDes = HbInputSettingProxy::instance()->preferredInputMethod(Qt::Vertical);
+    HbInputMethodDescriptor landscapeDes = HbInputSettingProxy::instance()->preferredInputMethod(Qt::Horizontal);
+    QByteArray portraitHwrspeed = d->createHwrSpeedData(portraitCustomData, index);
+    QByteArray landscapeHwrspeed = d->createHwrSpeedData(landscapeCustomData, index);
+
+    if (currentOrientation == Qt::Vertical) {
+        HbInputSettingProxy::instance()->setPreferredInputMethod(Qt::Horizontal, landscapeDes, landscapeHwrspeed);
+        HbInputSettingProxy::instance()->setPreferredInputMethod(Qt::Vertical, portraitDes, portraitHwrspeed);
+
+    } if (currentOrientation == Qt::Horizontal) {
+        HbInputSettingProxy::instance()->setPreferredInputMethod(Qt::Vertical, portraitDes, portraitHwrspeed);
+        HbInputSettingProxy::instance()->setPreferredInputMethod(Qt::Horizontal, landscapeDes, landscapeHwrspeed);
+    }
+}
+
+/*!
+Saves the portrait input method
+*/
+void HbInputSettingWidget::resetChineseInputMode()
+{
+    Q_D(HbInputSettingWidget);
+    HbInputLanguage lang = HbInputSettingProxy::instance()->globalInputLanguage();
+
+    if (lang.variant() == QLocale::China) {
+        d->mCnPortraitInputMode = KPinyinMode;
+        d->mCnLandscapeInputMode = KPinyinMode;
+    } else if (lang.variant() == QLocale::HongKong) {
+        d->mCnPortraitInputMode = KStrokeMode;
+        d->mCnLandscapeInputMode = KStrokeMode;
+    } else if (lang.variant() == QLocale::Taiwan) {
+        d->mCnPortraitInputMode = KZhuyinMode;
+        d->mCnLandscapeInputMode = KZhuyinMode;
+    }
+
+    QString portraitInputMethodString;
+    QString landscapeInputMethodString;
+    QByteArray portraitCustomData;
+    QByteArray landscapeCustomData;
+    d->setInputMethodVar(Qt::Vertical, portraitInputMethodString, portraitCustomData);
+    d->setInputMethodVar(Qt::Horizontal, landscapeInputMethodString, landscapeCustomData);
+
+    const HbInputMethodDescriptor portraitDescriptor = d->findInputMethodDescriptor(portraitInputMethodString);
+    const HbInputMethodDescriptor landscapeDescriptor = d->findInputMethodDescriptor(landscapeInputMethodString);
+    HbInputSettingProxy::instance()->setPreferredInputMethod(Qt::Vertical, (const HbInputMethodDescriptor &)portraitDescriptor, portraitCustomData);
+    HbInputSettingProxy::instance()->setPreferredInputMethod(Qt::Horizontal, (const HbInputMethodDescriptor &)landscapeDescriptor, landscapeCustomData);
+}
+
 /*
     This slot is called when ever data in the form model is changed
 */
@@ -638,7 +1201,7 @@
 {
     Q_D(HbInputSettingWidget);
     Q_UNUSED(endIn);
-    HbDataFormModelItem *item = d->mModel->itemFromIndex(startIn);    
+    HbDataFormModelItem *item = d->mModel->itemFromIndex(startIn);
     if(item == d->mPrimaryCandidateItem) {
         setPrimaryCandidateMode();
     } else if(item == d->mCharacterPreviewItem) {
@@ -660,8 +1223,7 @@
     disconnect(settings, SIGNAL(keypressTimeoutChanged(int)), this, SLOT(updateKeypressTimeout(int)));
     disconnect(settings, SIGNAL(autocompletionStateChanged(HbKeyboardSettingFlags, bool)), this, SLOT(updateAutocompletionState(HbKeyboardSettingFlags, bool)));
     disconnect(settings, SIGNAL(typingCorrectionLevelChanged(HbTypingCorrectionLevel)), this, SLOT(updateTypingCorrectionLevel(HbTypingCorrectionLevel)));
-    disconnect(settings, SIGNAL(primaryCandidateModeChanged(HbPrimaryCandidateMode)), this, SLOT(updatePrimaryCandidateMode(HbPrimaryCandidateMode)));    
+    disconnect(settings, SIGNAL(primaryCandidateModeChanged(HbPrimaryCandidateMode)), this, SLOT(updatePrimaryCandidateMode(HbPrimaryCandidateMode)));
 }
 
-
 // End of file