20 ** |
20 ** |
21 ** If you have questions regarding the use of this file, please contact |
21 ** If you have questions regarding the use of this file, please contact |
22 ** Nokia at developer.feedback@nokia.com. |
22 ** Nokia at developer.feedback@nokia.com. |
23 ** |
23 ** |
24 ****************************************************************************/ |
24 ****************************************************************************/ |
|
25 #include "hbinputsettingwidget.h" |
25 |
26 |
26 #include <hbdataform.h> |
27 #include <hbdataform.h> |
27 #include <hbdataformmodel.h> |
28 #include <hbdataformmodel.h> |
28 #include <hbinpututils.h> |
29 #include <hbinpututils.h> |
29 #include <hbinputsettingproxy.h> |
30 #include <hbinputsettingproxy.h> |
30 #include <hbinputpredictionfactory.h> |
31 #include <hbinputpredictionfactory.h> |
31 |
32 #include <QInputContextPlugin> |
32 #include "hbinputsettingwidget.h" |
33 #include <QLibrary> |
|
34 #include <QPluginLoader> |
|
35 #include <QDir> |
|
36 #include <QtAlgorithms> |
|
37 |
33 #include "hbinputcheckboxlist_p.h" |
38 #include "hbinputcheckboxlist_p.h" |
|
39 #include "hbinputsettingproxy_p.h" |
|
40 #include <hbinputmethoddescriptor.h> |
34 |
41 |
35 const QString statusOff = QObject::tr("Off"); |
42 const QString statusOff = QObject::tr("Off"); |
36 const QString statusOn = QObject::tr("On"); |
43 const QString statusOn = QObject::tr("On"); |
37 const QString bestPrediction = QObject::tr("Best prediction"); |
44 const QString bestPrediction = QObject::tr("Best prediction"); |
38 const QString exactTyping = QObject::tr("Exact typing"); |
45 const QString exactTyping = QObject::tr("Exact typing"); |
39 |
46 |
40 /// @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 |
41 |
108 |
42 class HbInputSettingWidgetPrivate |
109 class HbInputSettingWidgetPrivate |
43 { |
110 { |
44 Q_DECLARE_PUBLIC(HbInputSettingWidget) |
111 Q_DECLARE_PUBLIC(HbInputSettingWidget) |
45 |
112 |
107 mPrimaryCandidateMode = settings->primaryCandidateMode(); |
215 mPrimaryCandidateMode = settings->primaryCandidateMode(); |
108 mTypingCorrectionLevel = settings->typingCorrectionLevel(); |
216 mTypingCorrectionLevel = settings->typingCorrectionLevel(); |
109 |
217 |
110 HbInputUtils::listSupportedInputLanguages(mPrimaryLanguages); |
218 HbInputUtils::listSupportedInputLanguages(mPrimaryLanguages); |
111 createSecondaryLanguageList(); |
219 createSecondaryLanguageList(); |
112 |
220 // if the model is already constructed we do not need to recreate the setting items |
113 createSettingItems(); |
221 if (!mModel) { |
|
222 createSettingItems(); |
|
223 } else { |
|
224 // simply update the settings dependant content widget data of all the items |
|
225 updateContentWidgetData(); |
|
226 //make sure that the items are not expanded |
|
227 QModelIndex index = mModel->indexFromItem(mSecondaryLanguageItem->parent()); |
|
228 mForm->setExpanded(index, false); |
|
229 index = mModel->indexFromItem(mKeypressTimeoutItem->parent()); |
|
230 mForm->setExpanded(index, false); |
|
231 index = mModel->indexFromItem(mPredictionItem->parent()); |
|
232 mForm->setExpanded(index, false); |
|
233 } |
|
234 } |
|
235 |
|
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() |
|
391 { |
|
392 // current primary language |
|
393 mPrimaryLanguageItem->setContentWidgetData(QString("currentIndex"), languageToIndex(mPrimaryInputLanguage, mPrimaryLanguages)); |
|
394 |
|
395 mSecondaryLanguageItem->setContentWidgetData(QString("currentIndex"), languageToIndex(mSecondaryInputLanguage, mSecondaryLanguages)); |
|
396 // key press timeout |
|
397 mKeypressTimeoutItem->setContentWidgetData(QString("sliderPosition"), mKeypressTimeout); |
|
398 if (mCharacterPreviewEnabled) { |
|
399 mCharacterPreviewItem->setContentWidgetData(QString("text"), statusOn); |
|
400 mCharacterPreviewItem->setContentWidgetData(QString("additionalText"), statusOff); |
|
401 } else { |
|
402 mCharacterPreviewItem->setContentWidgetData(QString("text"), statusOff); |
|
403 mCharacterPreviewItem->setContentWidgetData(QString("additionalText"), statusOn); |
|
404 } |
|
405 QList<QVariant> predictionEnabled; |
|
406 predictionEnabled << mPredictionStatusForQwerty << mPredictionStatusForITUT; |
|
407 mPredictionItem->setContentWidgetData(QString("selectedItems"), predictionEnabled); |
|
408 |
|
409 QList<QVariant> autocompletionEnabled; |
|
410 autocompletionEnabled << mAutocompletionForQwerty << mAutocompletionForITUT; |
|
411 mAutoCompletionItem->setContentWidgetData(QString("selectedItems"), autocompletionEnabled); |
|
412 |
|
413 mCorrectionLevelItem->setContentWidgetData(QString("selected"), mTypingCorrectionLevel); |
|
414 |
|
415 if (mPrimaryCandidateMode == HbPrimaryCandidateModeBestPrediction) { |
|
416 mPrimaryCandidateItem->setContentWidgetData(QString("text"), bestPrediction); |
|
417 mPrimaryCandidateItem->setContentWidgetData(QString("additionalText"), exactTyping); |
|
418 } else { |
|
419 mPrimaryCandidateItem->setContentWidgetData(QString("text"), exactTyping); |
|
420 mPrimaryCandidateItem->setContentWidgetData(QString("additionalText"), bestPrediction); |
|
421 } |
114 } |
422 } |
115 |
423 |
116 /*! |
424 /*! |
117 Creates setting items to this widget |
425 Creates setting items to this widget |
118 */ |
426 */ |
119 void HbInputSettingWidgetPrivate::createSettingItems() |
427 void HbInputSettingWidgetPrivate::createSettingItems() |
120 { |
428 { |
121 Q_Q(HbInputSettingWidget); |
429 Q_Q(HbInputSettingWidget); |
122 |
430 |
123 HbDataFormModel *model = new HbDataFormModel(); |
431 mModel = new HbDataFormModel(); |
124 |
432 |
125 HbInputCheckBoxList *customPrototype = new HbInputCheckBoxList(mForm); |
433 HbInputCheckBoxList *customPrototype = new HbInputCheckBoxList(mForm); |
126 QList<HbAbstractViewItem*> prototypes = mForm->itemPrototypes(); |
434 QList<HbAbstractViewItem *> prototypes = mForm->itemPrototypes(); |
127 prototypes.append(customPrototype); |
435 prototypes.append(customPrototype); |
128 mForm->setItemPrototypes(prototypes); |
436 mForm->setItemPrototypes(prototypes); |
129 |
437 |
130 HbDataFormModelItem *languageGroup = model->appendDataFormGroup(QObject::tr("Language")); |
438 mLanguageGroup = mModel->appendDataFormGroup(QObject::tr("Language")); |
131 |
439 |
132 mPrimaryLanguageItem = new HbDataFormModelItem(HbDataFormModelItem::ComboBoxItem, QObject::tr("Primary Writing language")); |
440 mPrimaryLanguageItem = new HbDataFormModelItem(HbDataFormModelItem::ComboBoxItem, QObject::tr("Primary Writing language")); |
133 languageGroup->appendChild(mPrimaryLanguageItem); |
441 mLanguageGroup->appendChild(mPrimaryLanguageItem); |
134 QStringList writingLanguageItems; |
442 QStringList writingLanguageItems; |
135 fillLanguageList(writingLanguageItems, mPrimaryLanguages); |
443 fillLanguageList(writingLanguageItems, mPrimaryLanguages); |
136 mPrimaryLanguageItem->setContentWidgetData(QString("items"), writingLanguageItems); |
444 mPrimaryLanguageItem->setContentWidgetData(QString("items"), writingLanguageItems); |
137 mPrimaryLanguageItem->setContentWidgetData(QString("currentIndex"), languageToIndex(mPrimaryInputLanguage, mPrimaryLanguages)); |
445 mPrimaryLanguageItem->setContentWidgetData(QString("currentIndex"), languageToIndex(mPrimaryInputLanguage, mPrimaryLanguages)); |
138 mPrimaryLanguageItem->setContentWidgetData(QString("objectName"), QString("primary_writing_language")); |
446 mPrimaryLanguageItem->setContentWidgetData(QString("objectName"), QString("primary_writing_language")); |
139 mForm->addConnection(mPrimaryLanguageItem, SIGNAL(currentIndexChanged(int)), q, SLOT(setPrimaryLanguage(int))); |
447 mForm->addConnection(mPrimaryLanguageItem, SIGNAL(currentIndexChanged(int)), q, SLOT(setPrimaryLanguage(int))); |
140 |
448 |
141 mSecondaryLanguageItem = new HbDataFormModelItem(HbDataFormModelItem::ComboBoxItem, QObject::tr("Secondary Writing language")); |
449 if (mPrimaryInputLanguage.language() != QLocale::Chinese) { |
142 languageGroup->appendChild(mSecondaryLanguageItem); |
450 mSecondaryLanguageItem = new HbDataFormModelItem(HbDataFormModelItem::ComboBoxItem, QObject::tr("Secondary Writing language")); |
143 QStringList secondaryLanguageItems; |
451 mLanguageGroup->appendChild(mSecondaryLanguageItem); |
144 fillLanguageList(secondaryLanguageItems, mSecondaryLanguages, QObject::tr("None")); |
452 QStringList secondaryLanguageItems; |
145 mSecondaryLanguageItem->setContentWidgetData(QString("items"), secondaryLanguageItems); |
453 fillLanguageList(secondaryLanguageItems, mSecondaryLanguages, QObject::tr("None")); |
146 mSecondaryLanguageItem->setContentWidgetData(QString("currentIndex"), languageToIndex(mSecondaryInputLanguage, mSecondaryLanguages)); |
454 mSecondaryLanguageItem->setContentWidgetData(QString("items"), secondaryLanguageItems); |
147 mSecondaryLanguageItem->setContentWidgetData(QString("objectName"), QString("secondary_writing_language")); |
455 mSecondaryLanguageItem->setContentWidgetData(QString("currentIndex"), languageToIndex(mSecondaryInputLanguage, mSecondaryLanguages)); |
148 mForm->addConnection(mSecondaryLanguageItem, SIGNAL(currentIndexChanged(int)), q, SLOT(setSecondaryLanguage(int))); |
456 mSecondaryLanguageItem->setContentWidgetData(QString("objectName"), QString("secondary_writing_language")); |
149 |
457 mForm->addConnection(mSecondaryLanguageItem, SIGNAL(currentIndexChanged(int)), q, SLOT(setSecondaryLanguage(int))); |
150 HbDataFormModelItem *keyboardGroup = model->appendDataFormGroup(QObject::tr("Keyboard")); |
458 } |
|
459 HbDataFormModelItem *keyboardGroup = mModel->appendDataFormGroup(QObject::tr("Keyboard")); |
151 |
460 |
152 mKeypressTimeoutItem = new HbDataFormModelItem(HbDataFormModelItem::SliderItem, QObject::tr("Keypress Timeout")); |
461 mKeypressTimeoutItem = new HbDataFormModelItem(HbDataFormModelItem::SliderItem, QObject::tr("Keypress Timeout")); |
153 keyboardGroup->appendChild(mKeypressTimeoutItem); |
462 keyboardGroup->appendChild(mKeypressTimeoutItem); |
154 mKeypressTimeoutItem->setContentWidgetData(QString("minimum"), HbInputMinKeypressTimeout); |
463 mKeypressTimeoutItem->setContentWidgetData(QString("minimum"), HbInputMinKeypressTimeout); |
155 mKeypressTimeoutItem->setContentWidgetData(QString("maximum"), HbInputMaxKeypressTimeout); |
464 mKeypressTimeoutItem->setContentWidgetData(QString("maximum"), HbInputMaxKeypressTimeout); |
276 } |
587 } |
277 } |
588 } |
278 } |
589 } |
279 } |
590 } |
280 |
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 |
281 /// @endcond |
757 /// @endcond |
282 |
758 |
283 /*! |
759 /*! |
284 Constructs input setting widget |
760 Constructs input setting widget |
285 */ |
761 */ |
286 HbInputSettingWidget::HbInputSettingWidget(HbDataForm *dataForm, QGraphicsWidget* parent) |
762 HbInputSettingWidget::HbInputSettingWidget(HbDataForm *dataForm, QGraphicsWidget *parent) |
287 : QObject(parent), d_ptr(new HbInputSettingWidgetPrivate(dataForm)) |
763 : QObject(parent), d_ptr(new HbInputSettingWidgetPrivate(dataForm)) |
288 { |
764 { |
289 Q_D(HbInputSettingWidget); |
765 Q_D(HbInputSettingWidget); |
290 d->q_ptr = this; |
766 d->q_ptr = this; |
291 } |
767 } |
292 |
768 |
463 */ |
939 */ |
464 void HbInputSettingWidget::setPrimaryLanguage(int index) |
940 void HbInputSettingWidget::setPrimaryLanguage(int index) |
465 { |
941 { |
466 Q_D(HbInputSettingWidget); |
942 Q_D(HbInputSettingWidget); |
467 |
943 |
468 HbInputSettingProxy *settings = HbInputSettingProxy::instance(); |
944 HbInputSettingProxy *settings = HbInputSettingProxy::instance(); |
469 HbPredictionFactory *predFactory = HbPredictionFactory::instance(); |
945 HbPredictionFactory *predFactory = HbPredictionFactory::instance(); |
470 bool oldPLangSupportsPrediction = (predFactory->predictionEngineForLanguage(d->mPrimaryInputLanguage) != NULL); |
946 bool oldPLangSupportsPrediction = (predFactory->predictionEngineForLanguage(d->mPrimaryInputLanguage) != NULL); |
471 d->mPrimaryInputLanguage = d->indexToLanguage(index, d->mPrimaryLanguages); |
947 d->mPrimaryInputLanguage = d->indexToLanguage(index, d->mPrimaryLanguages); |
472 HbInputSettingProxy::instance()->setGlobalInputLanguage(d->mPrimaryInputLanguage); |
948 HbInputSettingProxy::instance()->setGlobalInputLanguage(d->mPrimaryInputLanguage); |
473 bool langSupportsPrediction = (predFactory->predictionEngineForLanguage(d->mPrimaryInputLanguage) != NULL); |
949 bool langSupportsPrediction = (predFactory->predictionEngineForLanguage(d->mPrimaryInputLanguage) != NULL); |
474 if( oldPLangSupportsPrediction != langSupportsPrediction) { |
950 if (oldPLangSupportsPrediction != langSupportsPrediction) { |
475 if(settings->predictiveInputStatus(HbKeyboardSetting12key) != langSupportsPrediction) { |
951 if (settings->predictiveInputStatus(HbKeyboardSetting12key) != langSupportsPrediction) { |
476 settings->setPredictiveInputStatus(HbKeyboardSetting12key, langSupportsPrediction); |
952 settings->setPredictiveInputStatus(HbKeyboardSetting12key, langSupportsPrediction); |
477 } |
953 } |
478 if (settings->predictiveInputStatus(HbKeyboardSettingQwerty) != langSupportsPrediction) { |
954 if (settings->predictiveInputStatus(HbKeyboardSettingQwerty) != langSupportsPrediction) { |
479 settings->setPredictiveInputStatus(HbKeyboardSettingQwerty, langSupportsPrediction); |
955 settings->setPredictiveInputStatus(HbKeyboardSettingQwerty, langSupportsPrediction); |
480 } |
956 } |
481 } |
957 } |
482 |
958 |
483 HbInputLanguage secondaryLanguage = d->mSecondaryInputLanguage; |
959 if (d->mPrimaryInputLanguage.language() != QLocale::Chinese) { |
484 // Update secondary language list |
960 HbInputLanguage secondaryLanguage = d->mSecondaryInputLanguage; |
485 d->createSecondaryLanguageList(); |
961 // Update secondary language list |
486 QStringList secondaryLanguageItems; |
962 d->createSecondaryLanguageList(); |
487 d->fillLanguageList(secondaryLanguageItems, d->mSecondaryLanguages, tr("None")); |
963 QStringList secondaryLanguageItems; |
488 d->mSecondaryLanguageItem->setContentWidgetData(QString("items"), secondaryLanguageItems); |
964 d->fillLanguageList(secondaryLanguageItems, d->mSecondaryLanguages, tr("None")); |
489 |
965 if (d->mSecondaryLanguageItem) { |
490 if (d->mPrimaryInputLanguage != secondaryLanguage) { |
966 d->mSecondaryLanguageItem->setContentWidgetData(QString("items"), secondaryLanguageItems); |
491 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); |
492 } |
999 } |
493 } |
1000 } |
494 |
1001 |
495 /*! |
1002 /*! |
496 Saves the new secondary language |
1003 Saves the new secondary language |
581 d->mPrimaryCandidateMode = HbPrimaryCandidateModeBestPrediction; |
1088 d->mPrimaryCandidateMode = HbPrimaryCandidateModeBestPrediction; |
582 } |
1089 } |
583 HbInputSettingProxy::instance()->setPrimaryCandidateMode(d->mPrimaryCandidateMode); |
1090 HbInputSettingProxy::instance()->setPrimaryCandidateMode(d->mPrimaryCandidateMode); |
584 } |
1091 } |
585 |
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 |
|
1197 /* |
|
1198 This slot is called when ever data in the form model is changed |
|
1199 */ |
|
1200 void HbInputSettingWidget::dataChange(const QModelIndex &startIn, const QModelIndex &endIn) |
|
1201 { |
|
1202 Q_D(HbInputSettingWidget); |
|
1203 Q_UNUSED(endIn); |
|
1204 HbDataFormModelItem *item = d->mModel->itemFromIndex(startIn); |
|
1205 if(item == d->mPrimaryCandidateItem) { |
|
1206 setPrimaryCandidateMode(); |
|
1207 } else if(item == d->mCharacterPreviewItem) { |
|
1208 setCharacterPreviewState(); |
|
1209 } |
|
1210 } |
|
1211 |
|
1212 /* |
|
1213 Resets the widget and disconnects the signals connected to the settings proxy |
|
1214 */ |
|
1215 |
|
1216 void HbInputSettingWidget::resetWidget() |
|
1217 { |
|
1218 HbInputSettingProxy *settings = HbInputSettingProxy::instance(); |
|
1219 disconnect(settings, SIGNAL(globalInputLanguageChanged(const HbInputLanguage &)), this, SLOT(updateGlobalInputLanguage(const HbInputLanguage &))); |
|
1220 disconnect(settings, SIGNAL(globalSecondaryInputLanguageChanged(const HbInputLanguage &)), this, SLOT(updateGlobalSecondaryInputLanguage(const HbInputLanguage &))); |
|
1221 disconnect(settings, SIGNAL(predictiveInputStateChanged(HbKeyboardSettingFlags, bool)), this, SLOT(updatePredictiveInputState(HbKeyboardSettingFlags, bool))); |
|
1222 disconnect(settings, SIGNAL(characterPreviewStateForQwertyChanged(bool)), this, SLOT(updateCharacterPreviewStateForQwerty(bool))); |
|
1223 disconnect(settings, SIGNAL(keypressTimeoutChanged(int)), this, SLOT(updateKeypressTimeout(int))); |
|
1224 disconnect(settings, SIGNAL(autocompletionStateChanged(HbKeyboardSettingFlags, bool)), this, SLOT(updateAutocompletionState(HbKeyboardSettingFlags, bool))); |
|
1225 disconnect(settings, SIGNAL(typingCorrectionLevelChanged(HbTypingCorrectionLevel)), this, SLOT(updateTypingCorrectionLevel(HbTypingCorrectionLevel))); |
|
1226 disconnect(settings, SIGNAL(primaryCandidateModeChanged(HbPrimaryCandidateMode)), this, SLOT(updatePrimaryCandidateMode(HbPrimaryCandidateMode))); |
|
1227 } |
|
1228 |
586 // End of file |
1229 // End of file |