118 void fillLanguageList(QStringList &list, QList<HbInputLanguage> &languageList, const QString &replace = QString(" ")); |
124 void fillLanguageList(QStringList &list, QList<HbInputLanguage> &languageList, const QString &replace = QString(" ")); |
119 int languageToIndex(const HbInputLanguage &language, const QList<HbInputLanguage> &languageList); |
125 int languageToIndex(const HbInputLanguage &language, const QList<HbInputLanguage> &languageList); |
120 HbInputLanguage indexToLanguage(int index, const QList<HbInputLanguage> &languageList); |
126 HbInputLanguage indexToLanguage(int index, const QList<HbInputLanguage> &languageList); |
121 void createSecondaryLanguageList(); |
127 void createSecondaryLanguageList(); |
122 void updateContentWidgetData(); |
128 void updateContentWidgetData(); |
|
129 // following API used by chinese |
123 int inputModeToIndex(const int &inputMode, const QList<int> &inputModeList); |
130 int inputModeToIndex(const int &inputMode, const QList<int> &inputModeList); |
124 int indexToInputmode(int index, const QList<int> &inputModeList); |
131 int indexToInputmode(int index, const QList<int> &inputModeList); |
125 void createChineseSettingGroup(HbDataFormModel *model); |
132 void createChineseSettingGroup(HbDataFormModel *model); |
126 |
133 void createValidModesList(QStringList &imModeNames, QList<int> &imModeList); |
127 QInputContextPlugin *pluginInstance(const QString &pluginFileName) const; |
134 QString inputModeName(int mode) const; |
128 HbInputMethodDescriptor findInputMethodDescriptor(const QString &inputMethodString); |
135 int inputModeByGivenName(const QString& imName) const; |
129 void setInputMethodVar(Qt::Orientation orientation, QString &inputMethodString, QByteArray &num); |
136 int defaultModeByGivenLang(const HbInputLanguage &lang) const; |
130 QByteArray createHwrSpeedData(QByteArray preferredCustomData, int index); |
137 |
131 public: |
138 public: |
132 HbDataForm *mForm; |
139 HbDataForm *mForm; |
133 HbDataFormModelItem *mPrimaryLanguageItem; |
140 HbDataFormModelItem *mPrimaryLanguageItem; |
134 HbDataFormModelItem *mSecondaryLanguageItem; |
141 HbDataFormModelItem *mSecondaryLanguageItem; |
135 HbDataFormModelItem *mKeypressTimeoutItem; |
142 HbDataFormModelItem *mKeypressTimeoutItem; |
136 HbDataFormModelItem *mCharacterPreviewItem; |
143 HbDataFormModelItem *mCharacterPreviewItem; |
222 createSettingItems(); |
234 createSettingItems(); |
223 } else { |
235 } else { |
224 // simply update the settings dependant content widget data of all the items |
236 // simply update the settings dependant content widget data of all the items |
225 updateContentWidgetData(); |
237 updateContentWidgetData(); |
226 //make sure that the items are not expanded |
238 //make sure that the items are not expanded |
227 QModelIndex index = mModel->indexFromItem(mSecondaryLanguageItem->parent()); |
239 QModelIndex index = mModel->indexFromItem(mSecondaryLanguageItem ? mSecondaryLanguageItem->parent(): mPrimaryLanguageItem->parent()); |
228 mForm->setExpanded(index, false); |
240 mForm->setExpanded(index, false); |
229 index = mModel->indexFromItem(mKeypressTimeoutItem->parent()); |
241 index = mModel->indexFromItem(mKeypressTimeoutItem->parent()); |
230 mForm->setExpanded(index, false); |
242 mForm->setExpanded(index, false); |
231 index = mModel->indexFromItem(mPredictionItem->parent()); |
243 index = mModel->indexFromItem(mPredictionItem->parent()); |
232 mForm->setExpanded(index, false); |
244 mForm->setExpanded(index, false); |
233 } |
245 } |
234 } |
246 } |
235 |
247 |
|
248 void HbInputSettingWidgetPrivate::createValidModesList(QStringList &imModeNames, QList<int> &imModeList) |
|
249 { |
|
250 Qt::Orientation orientation = Qt::Horizontal; |
|
251 if (mForm) { |
|
252 orientation = mForm->mainWindow()->orientation(); |
|
253 } |
|
254 |
|
255 QList<HbInputMethodDescriptor> methodList = HbInputMethod::listCustomInputMethods(orientation, |
|
256 HbInputSettingProxy::instance()->globalInputLanguage()); |
|
257 methodList.insert(0, HbInputMethod::defaultInputMethod(orientation)); |
|
258 |
|
259 foreach(const HbInputMethodDescriptor &des, methodList) { |
|
260 QStringList displayNames = des.displayNames(); |
|
261 if (!displayNames.isEmpty()) { |
|
262 imModeNames += displayNames; |
|
263 } else { |
|
264 QString displayName = des.displayName(); |
|
265 imModeNames.append(displayName); |
|
266 } |
|
267 } |
|
268 |
|
269 imModeNames.removeDuplicates(); |
|
270 // filter out the input mode that not valid to current screen orientation |
|
271 if (imModeNames.contains(KCangjieGeneralName)) { |
|
272 imModeNames.removeOne(KCangjieGeneralName); |
|
273 } |
|
274 |
|
275 for (int i = 0; i < imModeNames.count(); ++i) { |
|
276 imModeList.append(inputModeByGivenName(imModeNames.at(i))); |
|
277 } |
|
278 } |
|
279 |
|
280 QString HbInputSettingWidgetPrivate::inputModeName(int mode) const |
|
281 { |
|
282 int cnImCnts = sizeof(modesMap) / sizeof(modesMap[0]); |
|
283 if (mode >= 0 && mode < cnImCnts) { |
|
284 return modesMap[mode].mModeName; |
|
285 } |
|
286 |
|
287 return QString(); |
|
288 } |
|
289 |
|
290 int HbInputSettingWidgetPrivate::inputModeByGivenName(const QString& imName) const |
|
291 { |
|
292 int cnMode = KChineseInputModeNone; |
|
293 |
|
294 if (imName == KCangjieGeneralName) { |
|
295 HbCangjieDetailMode cjDetail = HbInputSettingProxy::instance()->detailedCangjieMode(); |
|
296 switch (cjDetail) { |
|
297 case HbCangjieEasy: { |
|
298 cnMode = KCangjieEasyMode; |
|
299 } |
|
300 break; |
|
301 case HbCangjieAdvanced: { |
|
302 cnMode = KCangjieAdvancedMode; |
|
303 } |
|
304 break; |
|
305 case HbCangjieNormal: |
|
306 default: { |
|
307 cnMode = KCangjieNormalMode; |
|
308 } |
|
309 break; |
|
310 } |
|
311 } else { |
|
312 int cnImCnts = sizeof(modesMap) / sizeof(modesMap[0]); |
|
313 for (int i = 0; i < cnImCnts; ++i) { |
|
314 if (modesMap[i].mModeName == imName) { |
|
315 cnMode = modesMap[i].mMode; |
|
316 } |
|
317 } |
|
318 } |
|
319 |
|
320 if (KChineseInputModeNone == cnMode) { |
|
321 HbInputLanguage lang = HbInputSettingProxy::instance()->globalInputLanguage(); |
|
322 cnMode = defaultModeByGivenLang(lang); |
|
323 } |
|
324 |
|
325 return cnMode; |
|
326 } |
|
327 |
|
328 int HbInputSettingWidgetPrivate::defaultModeByGivenLang(const HbInputLanguage &lang) const |
|
329 { |
|
330 int imMode = KChineseInputModeNone; |
|
331 if (lang.variant() == QLocale::China) { |
|
332 imMode = KPinyinMode; |
|
333 } else if (lang.variant() == QLocale::HongKong) { |
|
334 imMode = KStrokeMode; |
|
335 } else if (lang.variant() == QLocale::Taiwan) { |
|
336 imMode = KZhuyinMode; |
|
337 } |
|
338 |
|
339 return imMode; |
|
340 } |
|
341 |
236 void HbInputSettingWidgetPrivate::createChineseSettingGroup(HbDataFormModel *model) |
342 void HbInputSettingWidgetPrivate::createChineseSettingGroup(HbDataFormModel *model) |
237 { |
343 { |
238 Q_Q(HbInputSettingWidget); |
344 Q_Q(HbInputSettingWidget); |
239 int imMode = KChineseInputModeNone; |
|
240 QByteArray ba = HbInputSettingProxy::instance()->preferredInputMethodCustomData(Qt::Vertical); |
345 QByteArray ba = HbInputSettingProxy::instance()->preferredInputMethodCustomData(Qt::Vertical); |
241 QString portraitCustomData(ba); |
346 QString imName(ba); |
242 QString imName = portraitCustomData.split(" ").at(0); |
|
243 HbInputLanguage lang = HbInputSettingProxy::instance()->globalInputLanguage(); |
347 HbInputLanguage lang = HbInputSettingProxy::instance()->globalInputLanguage(); |
244 |
348 mCnPortraitInputMode = inputModeByGivenName(imName); |
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 |
349 |
265 ba = HbInputSettingProxy::instance()->preferredInputMethodCustomData(Qt::Horizontal); |
350 ba = HbInputSettingProxy::instance()->preferredInputMethodCustomData(Qt::Horizontal); |
266 QString landscapeCustomData(ba); |
351 imName = QString(ba); |
267 imName = landscapeCustomData.split(" ").at(0); |
352 mCnLandscapeInputMode = inputModeByGivenName(imName); |
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 |
353 |
319 mHwrSpeedNames.clear(); |
354 mHwrSpeedNames.clear(); |
320 mCnPortraitInputModeList.clear(); |
355 mCnPortraitInputModeList.clear(); |
321 mCnLandscapeInputModeList.clear(); |
356 mCnLandscapeInputModeList.clear(); |
322 mCnPortraitInputModeNames.clear(); |
357 mCnPortraitInputModeNames.clear(); |
323 mCnLandscapeInputModeNames.clear(); |
358 mCnLandscapeInputModeNames.clear(); |
324 mCnCangjieInputModeNames.clear(); |
359 mCnCangjieInputModeNames.clear(); |
325 |
360 mCnDefaultLanguageNames.clear(); |
326 mHwrSpeedNames << "Very slow" << "Slow" << "Normal" << "Fast" << "Very Fast"; |
361 |
327 if (mPrimaryInputLanguage == HbInputLanguage(QLocale::Chinese, QLocale::China)) { |
362 createValidModesList(mCnPortraitInputModeNames, mCnPortraitInputModeList); |
328 mCnPortraitInputModeList << KPinyinMode << KStrokeMode << KHwrMode; |
363 mCnLandscapeInputModeNames = mCnPortraitInputModeNames; |
329 mCnLandscapeInputModeList << KPinyinMode << KStrokeMode << KHwrMode; |
364 mCnLandscapeInputModeList = mCnPortraitInputModeList; |
330 mCnPortraitInputModeNames << KPinyinName << KStrokeName << KHwrName; |
365 |
331 mCnLandscapeInputModeNames << KPinyinName << KStrokeName << KHwrName; |
366 // append cangjie to landscape related list if need |
332 } else if (mPrimaryInputLanguage == HbInputLanguage(QLocale::Chinese, QLocale::HongKong)) { |
367 if (mPrimaryInputLanguage == HbInputLanguage(QLocale::Chinese, QLocale::HongKong) && |
333 mCnPortraitInputModeList << KStrokeMode << KHwrMode; |
368 !mCnLandscapeInputModeNames.contains(KCangjieGeneralName)) { |
334 mCnLandscapeInputModeList << KStrokeMode << KCangjieNormalMode << KHwrMode; |
369 |
|
370 int index = HbInputSettingProxy::instance()->detailedCangjieMode(); |
|
371 switch(index) { |
|
372 case 0: |
|
373 mCnCangjieInputMode = KCangjieEasyMode; |
|
374 break; |
|
375 case 1: |
|
376 mCnCangjieInputMode = KCangjieNormalMode; |
|
377 break; |
|
378 case 2: |
|
379 mCnCangjieInputMode = KCangjieAdvancedMode; |
|
380 break; |
|
381 default: |
|
382 break; |
|
383 } |
|
384 |
|
385 QStringList tmpInputmodeNames; |
|
386 QList<int> tmpInputmode; |
|
387 tmpInputmodeNames << mCnLandscapeInputModeNames.at(0) << KCangjieGeneralName << mCnLandscapeInputModeNames.at(1); |
|
388 tmpInputmode << mCnLandscapeInputModeList.at(0) << mCnCangjieInputMode << mCnLandscapeInputModeList.at(1); |
|
389 mCnLandscapeInputModeList.clear(); |
|
390 mCnLandscapeInputModeNames.clear(); |
|
391 mCnLandscapeInputModeList = tmpInputmode; |
|
392 mCnLandscapeInputModeNames = tmpInputmodeNames; |
335 mCangjieInputModeList << KCangjieEasyMode << KCangjieNormalMode << KCangjieAdvancedMode; |
393 mCangjieInputModeList << KCangjieEasyMode << KCangjieNormalMode << KCangjieAdvancedMode; |
336 mCnPortraitInputModeNames << KStrokeName << KHwrName; |
|
337 mCnLandscapeInputModeNames << KStrokeName << KCangjieGeneralName << KHwrName; |
|
338 mCnCangjieInputModeNames << KEasy << KNormal << KAdvanced; |
394 mCnCangjieInputModeNames << KEasy << KNormal << KAdvanced; |
339 } else if (mPrimaryInputLanguage == HbInputLanguage(QLocale::Chinese, QLocale::Taiwan)) { |
395 } |
340 mCnPortraitInputModeList << KZhuyinMode << KHwrMode; |
396 |
341 mCnLandscapeInputModeList << KZhuyinMode << KHwrMode; |
397 mHwrSpeed = HbInputSettingProxy::instance()->hwrWritingSpeed(); |
342 mCnPortraitInputModeNames << KZhuyinName << KHwrName; |
398 mHwrSpeedNames << KHwrVerySlowName << KHwrSlowName << KHwrNormalName << KHwrFastName << KHwrVeryFastName; |
343 mCnLandscapeInputModeNames << KZhuyinName << KHwrName; |
399 mCnDefaultLanguageNames << KDefaultChineseName << KDefaultEnglishName; |
344 } |
|
345 |
400 |
346 if (!mChineseInputGroup) { |
401 if (!mChineseInputGroup) { |
347 mChineseInputGroup = model->appendDataFormGroup(QObject::tr("Chinese Input")); |
402 mChineseInputGroup = model->appendDataFormGroup(QObject::tr("Chinese Input")); |
348 mPortraitInputMethodItem = new HbDataFormModelItem(HbDataFormModelItem::ComboBoxItem, QObject::tr("Portrait mode input method")); |
403 mPortraitInputMethodItem = new HbDataFormModelItem(HbDataFormModelItem::ComboBoxItem, QObject::tr("Portrait mode input method")); |
349 mChineseInputGroup->appendChild(mPortraitInputMethodItem); |
404 mChineseInputGroup->appendChild(mPortraitInputMethodItem); |
366 mForm->addConnection(mLandscapeInputMethodItem, SIGNAL(currentIndexChanged(int)), q, SLOT(setLandscapeInputMethod(int))); |
421 mForm->addConnection(mLandscapeInputMethodItem, SIGNAL(currentIndexChanged(int)), q, SLOT(setLandscapeInputMethod(int))); |
367 |
422 |
368 mHwrSpeedItem = new HbDataFormModelItem(HbDataFormModelItem::ComboBoxItem, QObject::tr("Handwriting speed")); |
423 mHwrSpeedItem = new HbDataFormModelItem(HbDataFormModelItem::ComboBoxItem, QObject::tr("Handwriting speed")); |
369 mChineseInputGroup->appendChild(mHwrSpeedItem); |
424 mChineseInputGroup->appendChild(mHwrSpeedItem); |
370 mHwrSpeedItem->setContentWidgetData(QString("items"), mHwrSpeedNames); |
425 mHwrSpeedItem->setContentWidgetData(QString("items"), mHwrSpeedNames); |
371 int hwr = mHwrSpeed; |
426 mHwrSpeedItem->setContentWidgetData(QString("currentIndex"), mHwrSpeed); |
372 mHwrSpeedItem->setContentWidgetData(QString("currentIndex"), hwr); |
|
373 mHwrSpeedItem->setContentWidgetData(QString("objectName"), QString("handwriting_speed")); |
427 mHwrSpeedItem->setContentWidgetData(QString("objectName"), QString("handwriting_speed")); |
374 mForm->addConnection(mHwrSpeedItem, SIGNAL(currentIndexChanged(int)), q, SLOT(setHwrSpeed(int))); |
428 mForm->addConnection(mHwrSpeedItem, SIGNAL(currentIndexChanged(int)), q, SLOT(setHwrSpeed(int))); |
375 } |
429 |
376 |
430 mCnDefaultLanguageItem = new HbDataFormModelItem(HbDataFormModelItem::ComboBoxItem, QObject::tr("Default language for keyboard input")); |
|
431 mChineseInputGroup->appendChild(mCnDefaultLanguageItem); |
|
432 int defaultLanguageIndex = HbInputSettingProxy::instance()->useWesternDefaultKeypadForChinese() ? 1 : 0; |
|
433 mCnDefaultLanguageItem->setContentWidgetData(QString("items"), mCnDefaultLanguageNames); |
|
434 mCnDefaultLanguageItem->setContentWidgetData(QString("currentIndex"), defaultLanguageIndex); |
|
435 mCnDefaultLanguageItem->setContentWidgetData(QString("objectName"), QString("default_language_for_keyboard_input")); |
|
436 mForm->addConnection(mCnDefaultLanguageItem, SIGNAL(currentIndexChanged(int)), q, SLOT(setDefaultLanguageForKeyboardInput(int))); |
|
437 } |
|
438 |
|
439 int cangjieIdx = HbInputSettingProxy::instance()->detailedCangjieMode(); |
377 if (mPrimaryInputLanguage == HbInputLanguage(QLocale::Chinese, QLocale::HongKong)) { |
440 if (mPrimaryInputLanguage == HbInputLanguage(QLocale::Chinese, QLocale::HongKong)) { |
378 mCangjieItem = new HbDataFormModelItem(HbDataFormModelItem::ComboBoxItem, QObject::tr("Cangjie mode")); |
441 mCangjieItem = new HbDataFormModelItem(HbDataFormModelItem::ComboBoxItem, QObject::tr("Cangjie mode")); |
379 mChineseInputGroup->appendChild(mCangjieItem); |
442 mChineseInputGroup->appendChild(mCangjieItem); |
380 mCangjieItem->setContentWidgetData(QString("items"), mCnCangjieInputModeNames); |
443 mCangjieItem->setContentWidgetData(QString("items"), mCnCangjieInputModeNames); |
381 int cangjieIdx = inputModeToIndex(mCnCangjieInputMode, mCangjieInputModeList); |
|
382 QVariant varCang; |
444 QVariant varCang; |
383 varCang.setValue(cangjieIdx); |
445 varCang.setValue(cangjieIdx); |
384 mCangjieItem->setContentWidgetData(QString("currentIndex"), varCang); |
446 mCangjieItem->setContentWidgetData(QString("currentIndex"), varCang); |
385 mCangjieItem->setContentWidgetData(QString("objectName"), QString("cangjie_mode")); |
447 mCangjieItem->setContentWidgetData(QString("objectName"), QString("cangjie_mode")); |
386 mForm->addConnection(mCangjieItem, SIGNAL(currentIndexChanged(int)), q, SLOT(setCangjieMode(int))); |
448 mForm->addConnection(mCangjieItem, SIGNAL(currentIndexChanged(int)), q, SLOT(setCangjieMode(int))); |
387 } |
449 } |
388 } |
450 } |
389 |
451 |
390 void HbInputSettingWidgetPrivate::updateContentWidgetData() |
452 void HbInputSettingWidgetPrivate::updateContentWidgetData() |
391 { |
453 { |
392 // current primary language |
454 // current primary language |
393 mPrimaryLanguageItem->setContentWidgetData(QString("currentIndex"), languageToIndex(mPrimaryInputLanguage, mPrimaryLanguages)); |
455 mPrimaryLanguageItem->setContentWidgetData(QString("currentIndex"), languageToIndex(mPrimaryInputLanguage, mPrimaryLanguages)); |
394 |
456 |
395 mSecondaryLanguageItem->setContentWidgetData(QString("currentIndex"), languageToIndex(mSecondaryInputLanguage, mSecondaryLanguages)); |
457 if (mSecondaryLanguageItem) { |
|
458 mSecondaryLanguageItem->setContentWidgetData(QString("currentIndex"), languageToIndex(mSecondaryInputLanguage, mSecondaryLanguages)); |
|
459 } |
396 // key press timeout |
460 // key press timeout |
397 mKeypressTimeoutItem->setContentWidgetData(QString("sliderPosition"), mKeypressTimeout); |
461 mKeypressTimeoutItem->setContentWidgetData(QString("sliderPosition"), mKeypressTimeout); |
398 if (mCharacterPreviewEnabled) { |
462 if (mCharacterPreviewEnabled) { |
399 mCharacterPreviewItem->setContentWidgetData(QString("text"), statusOn); |
463 mCharacterPreviewItem->setContentWidgetData(QString("text"), statusOn); |
400 mCharacterPreviewItem->setContentWidgetData(QString("additionalText"), statusOff); |
464 mCharacterPreviewItem->setContentWidgetData(QString("additionalText"), statusOff); |
610 if (index >= 0 && index < inputModeList.count()) { |
684 if (index >= 0 && index < inputModeList.count()) { |
611 return inputModeList.at(index); |
685 return inputModeList.at(index); |
612 } else { |
686 } else { |
613 return KChineseInputModeNone; |
687 return KChineseInputModeNone; |
614 } |
688 } |
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 } |
689 } |
756 |
690 |
757 /// @endcond |
691 /// @endcond |
758 |
692 |
759 /*! |
693 /*! |
1095 */ |
1035 */ |
1096 void HbInputSettingWidget::setPortraitInputMethod(int index) |
1036 void HbInputSettingWidget::setPortraitInputMethod(int index) |
1097 { |
1037 { |
1098 Q_D(HbInputSettingWidget); |
1038 Q_D(HbInputSettingWidget); |
1099 d->mCnPortraitInputMode = d->indexToInputmode(index, d->mCnPortraitInputModeList); |
1039 d->mCnPortraitInputMode = d->indexToInputmode(index, d->mCnPortraitInputModeList); |
1100 QString inputMethodString; |
|
1101 QByteArray customData; |
1040 QByteArray customData; |
1102 d->setInputMethodVar(Qt::Vertical, inputMethodString, customData); |
1041 HbInputMethodDescriptor descriptor; |
1103 |
1042 |
1104 const HbInputMethodDescriptor descriptor = d->findInputMethodDescriptor(inputMethodString); |
1043 if (d->mCnPortraitInputMode != KHwrMode) { |
1105 HbInputSettingProxy::instance()->setPreferredInputMethod(Qt::Vertical, (const HbInputMethodDescriptor &)descriptor, customData); |
1044 QString imName = d->inputModeName(d->mCnPortraitInputMode); |
|
1045 customData.append(imName.toLatin1().data()); |
|
1046 customData.append((char)0); |
|
1047 descriptor = HbInputMethod::defaultInputMethod(Qt::Vertical); |
|
1048 } else { |
|
1049 customData.append(KHwrName.toLatin1().data()); |
|
1050 customData.append((char)0); |
|
1051 QList<HbInputMethodDescriptor> methodList = HbInputMethod::listCustomInputMethods(Qt::Vertical, HbInputSettingProxy::instance()->globalInputLanguage()); |
|
1052 foreach(const HbInputMethodDescriptor &des, methodList) { |
|
1053 if (des.displayName() == "Chinese Hand Writing Recognition") { |
|
1054 descriptor = des; |
|
1055 break; |
|
1056 } |
|
1057 } |
|
1058 } |
|
1059 |
|
1060 Qt::Orientation orientation = Qt::Vertical; |
|
1061 if (d->mForm) { |
|
1062 orientation = d->mForm->mainWindow()->orientation(); |
|
1063 } |
|
1064 |
|
1065 HbInputSettingProxy::instance()->setPreferredInputMethod(Qt::Vertical, descriptor, customData); |
|
1066 if (orientation == Qt::Vertical) { |
|
1067 HbInputMethod::activeInputMethod()->activateInputMethod(descriptor); |
|
1068 } |
1106 } |
1069 } |
1107 |
1070 |
1108 /*! |
1071 /*! |
1109 Saves the landscape input method |
1072 Saves the landscape input method |
1110 */ |
1073 */ |
1111 void HbInputSettingWidget::setLandscapeInputMethod(int index) |
1074 void HbInputSettingWidget::setLandscapeInputMethod(int index) |
1112 { |
1075 { |
1113 Q_D(HbInputSettingWidget); |
1076 Q_D(HbInputSettingWidget); |
1114 d->mCnLandscapeInputMode = d->indexToInputmode(index, d->mCnLandscapeInputModeList); |
1077 d->mCnLandscapeInputMode = d->indexToInputmode(index, d->mCnLandscapeInputModeList); |
1115 QString inputMethodString; |
|
1116 QByteArray customData; |
1078 QByteArray customData; |
1117 d->setInputMethodVar(Qt::Horizontal, inputMethodString, customData); |
1079 HbInputMethodDescriptor descriptor; |
1118 |
1080 |
1119 const HbInputMethodDescriptor descriptor = d->findInputMethodDescriptor(inputMethodString); |
1081 if (d->mCnLandscapeInputMode != KHwrMode) { |
|
1082 QString imName; |
|
1083 if (d->mCnLandscapeInputMode == KCangjieNormalMode || |
|
1084 d->mCnLandscapeInputMode == KCangjieEasyMode || |
|
1085 d->mCnLandscapeInputMode == KCangjieAdvancedMode) { |
|
1086 imName = KCangjieGeneralName; |
|
1087 } else { |
|
1088 imName = d->inputModeName(d->mCnLandscapeInputMode); |
|
1089 } |
|
1090 |
|
1091 customData.append(imName.toLatin1().data()); |
|
1092 customData.append((char)0); |
|
1093 descriptor = HbInputMethod::defaultInputMethod(Qt::Horizontal); |
|
1094 } else { |
|
1095 customData.append(KHwrName.toLatin1().data()); |
|
1096 customData.append((char)0); |
|
1097 QList<HbInputMethodDescriptor> methodList = HbInputMethod::listCustomInputMethods(Qt::Horizontal, HbInputSettingProxy::instance()->globalInputLanguage()); |
|
1098 foreach(const HbInputMethodDescriptor &des, methodList) { |
|
1099 if (des.displayName() == "Chinese Hand Writing Recognition") { |
|
1100 descriptor = des; |
|
1101 break; |
|
1102 } |
|
1103 } |
|
1104 } |
|
1105 |
|
1106 Qt::Orientation orientation = Qt::Horizontal; |
|
1107 if (d->mForm) { |
|
1108 orientation = d->mForm->mainWindow()->orientation(); |
|
1109 } |
|
1110 |
1120 HbInputSettingProxy::instance()->setPreferredInputMethod(Qt::Horizontal, descriptor, customData); |
1111 HbInputSettingProxy::instance()->setPreferredInputMethod(Qt::Horizontal, descriptor, customData); |
|
1112 if (orientation == Qt::Horizontal) { |
|
1113 HbInputMethod::activeInputMethod()->activateInputMethod(descriptor); |
|
1114 } |
1121 } |
1115 } |
1122 |
1116 |
1123 /*! |
1117 /*! |
1124 Saves the cangjie input mode |
1118 Saves the cangjie input mode |
1125 */ |
1119 */ |
1127 { |
1121 { |
1128 Q_D(HbInputSettingWidget); |
1122 Q_D(HbInputSettingWidget); |
1129 d->mCnCangjieInputMode = d->indexToInputmode(index, d->mCangjieInputModeList); |
1123 d->mCnCangjieInputMode = d->indexToInputmode(index, d->mCangjieInputModeList); |
1130 d->mCnLandscapeInputMode = d->mCnCangjieInputMode; |
1124 d->mCnLandscapeInputMode = d->mCnCangjieInputMode; |
1131 |
1125 |
1132 QString inputMethodString; |
1126 QString imName = KCangjieGeneralName; |
1133 QByteArray customData; |
1127 QByteArray customData; |
1134 d->setInputMethodVar(Qt::Horizontal, inputMethodString, customData); |
1128 customData.append(imName.toLatin1().data()); |
1135 |
1129 customData.append((char)0); |
1136 const HbInputMethodDescriptor descriptor = d->findInputMethodDescriptor(inputMethodString); |
1130 |
|
1131 HbInputMethodDescriptor descriptor; |
|
1132 descriptor = HbInputMethod::defaultInputMethod(Qt::Horizontal); |
|
1133 |
1137 HbInputSettingProxy::instance()->setPreferredInputMethod(Qt::Horizontal, descriptor, customData); |
1134 HbInputSettingProxy::instance()->setPreferredInputMethod(Qt::Horizontal, descriptor, customData); |
1138 } |
1135 HbInputSettingProxy::instance()->setDetailedCangjieMode(HbCangjieDetailMode(index)); |
1139 |
1136 } |
1140 |
1137 |
1141 /*! |
1138 /*! |
1142 Saves the handwriting speed |
1139 Saves the handwriting speed |
1143 */ |
1140 */ |
1144 void HbInputSettingWidget::setHwrSpeed(int index) |
1141 void HbInputSettingWidget::setHwrSpeed(int index) |
1145 { |
1142 { |
1146 Q_D(HbInputSettingWidget); |
1143 // hwr speed index in setting widget are exactly same as enum HbHwrWritingSpeed of setting proxy |
1147 Qt::Orientation currentOrientation = HbInputSettingProxy::instance()->screenOrientation(); |
1144 if (index >= 0 && index < KHwrSpeedCount) { |
1148 QByteArray portraitCustomData = HbInputSettingProxy::instance()->preferredInputMethodCustomData(Qt::Vertical); |
1145 HbInputSettingProxy::instance()->setHwrWritingSpeed(HbHwrWritingSpeed(index)); |
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 } |
1146 } |
1163 } |
1147 } |
1164 |
1148 |
1165 /*! |
1149 /*! |
1166 Saves the portrait input method |
1150 Saves the portrait input method |
1167 */ |
1151 */ |
1168 void HbInputSettingWidget::resetChineseInputMode() |
1152 void HbInputSettingWidget::resetChineseInputMode(HbInputLanguage lang) |
1169 { |
1153 { |
1170 Q_D(HbInputSettingWidget); |
1154 Q_D(HbInputSettingWidget); |
1171 HbInputLanguage lang = HbInputSettingProxy::instance()->globalInputLanguage(); |
1155 d->mCnPortraitInputMode = d->defaultModeByGivenLang(lang); |
1172 |
1156 d->mCnLandscapeInputMode = d->defaultModeByGivenLang(lang); |
1173 if (lang.variant() == QLocale::China) { |
1157 HbInputSettingProxy::instance()->setDetailedCangjieMode(HbCangjieNormal); |
1174 d->mCnPortraitInputMode = KPinyinMode; |
1158 |
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; |
1159 QByteArray portraitCustomData; |
1187 QByteArray landscapeCustomData; |
1160 QByteArray landscapeCustomData; |
1188 d->setInputMethodVar(Qt::Vertical, portraitInputMethodString, portraitCustomData); |
1161 QString imName = d->inputModeName(d->mCnPortraitInputMode); |
1189 d->setInputMethodVar(Qt::Horizontal, landscapeInputMethodString, landscapeCustomData); |
1162 portraitCustomData.append(imName.toLatin1().data()); |
1190 |
1163 portraitCustomData.append((char)0); |
1191 const HbInputMethodDescriptor portraitDescriptor = d->findInputMethodDescriptor(portraitInputMethodString); |
1164 HbInputMethodDescriptor portraitDescriptor = HbInputMethod::defaultInputMethod(Qt::Vertical); |
1192 const HbInputMethodDescriptor landscapeDescriptor = d->findInputMethodDescriptor(landscapeInputMethodString); |
1165 |
|
1166 if (d->mCnLandscapeInputMode == KCangjieNormalMode || |
|
1167 d->mCnLandscapeInputMode == KCangjieEasyMode || |
|
1168 d->mCnLandscapeInputMode == KCangjieAdvancedMode) { |
|
1169 imName = KCangjieGeneralName; |
|
1170 } else { |
|
1171 imName = d->inputModeName(d->mCnLandscapeInputMode); |
|
1172 } |
|
1173 |
|
1174 landscapeCustomData.append(imName.toLatin1().data()); |
|
1175 landscapeCustomData.append((char)0); |
|
1176 HbInputMethodDescriptor landscapeDescriptor = HbInputMethod::defaultInputMethod(Qt::Horizontal); |
|
1177 |
1193 HbInputSettingProxy::instance()->setPreferredInputMethod(Qt::Vertical, (const HbInputMethodDescriptor &)portraitDescriptor, portraitCustomData); |
1178 HbInputSettingProxy::instance()->setPreferredInputMethod(Qt::Vertical, (const HbInputMethodDescriptor &)portraitDescriptor, portraitCustomData); |
1194 HbInputSettingProxy::instance()->setPreferredInputMethod(Qt::Horizontal, (const HbInputMethodDescriptor &)landscapeDescriptor, landscapeCustomData); |
1179 HbInputSettingProxy::instance()->setPreferredInputMethod(Qt::Horizontal, (const HbInputMethodDescriptor &)landscapeDescriptor, landscapeCustomData); |
|
1180 |
|
1181 return; |
1195 } |
1182 } |
1196 |
1183 |
1197 /* |
1184 /* |
1198 This slot is called when ever data in the form model is changed |
1185 This slot is called when ever data in the form model is changed |
1199 */ |
1186 */ |