73 HbInputMethod *methodInstance(const QString &pluginFileName, const QString &key) const; |
73 HbInputMethod *methodInstance(const QString &pluginFileName, const QString &key) const; |
74 HbInputModeProperties propertiesFromString(const QString &entry) const; |
74 HbInputModeProperties propertiesFromString(const QString &entry) const; |
75 HbInputModeProperties propertiesFromState(const HbInputState &state) const; |
75 HbInputModeProperties propertiesFromState(const HbInputState &state) const; |
76 HbInputMethod *cachedMethod(HbInputMethodListItem &item); |
76 HbInputMethod *cachedMethod(HbInputMethodListItem &item); |
77 void updateMonitoredPaths(); |
77 void updateMonitoredPaths(); |
|
78 bool isMappedLanguage(const HbInputLanguage &language) const; |
78 |
79 |
79 public: |
80 public: |
80 QFileSystemWatcher *mWatcher; |
81 QFileSystemWatcher *mWatcher; |
81 QList<HbInputMethodListItem> mMethods; |
82 QList<HbInputMethodListItem> mMethods; |
82 bool mShuttingDown; |
83 bool mShuttingDown; |
169 if (mMethods[i].toBeRemoved) { |
170 if (mMethods[i].toBeRemoved) { |
170 if (mMethods[i].cached && mMethods[i].cached->isActiveMethod()) { |
171 if (mMethods[i].cached && mMethods[i].cached->isActiveMethod()) { |
171 // If the item to be removed happens to be the active one, |
172 // If the item to be removed happens to be the active one, |
172 // try to deal with the situation. |
173 // try to deal with the situation. |
173 mMethods[i].cached->forceUnfocus(); |
174 mMethods[i].cached->forceUnfocus(); |
174 if (mMethods[i].descriptor.pluginNameAndPath() == HbInputSettingProxy::instance()->activeCustomInputMethod().pluginNameAndPath()) { |
175 // The active custom method is being removed. |
175 // The active custom method is being removed. |
176 // Clear out related setting proxy values. |
176 // Clear out related setting proxy values. |
177 if (mMethods[i].descriptor.pluginNameAndPath() == HbInputSettingProxy::instance()->preferredInputMethod(Qt::Horizontal).pluginNameAndPath()) { |
177 HbInputSettingProxy::instance()->setActiveCustomInputMethod(HbInputMethodDescriptor()); |
178 HbInputSettingProxy::instance()->setPreferredInputMethod(Qt::Horizontal, HbInputMethodDescriptor()); |
|
179 } |
|
180 if (mMethods[i].descriptor.pluginNameAndPath() == HbInputSettingProxy::instance()->preferredInputMethod(Qt::Vertical).pluginNameAndPath()) { |
|
181 HbInputSettingProxy::instance()->setPreferredInputMethod(Qt::Vertical, HbInputMethodDescriptor()); |
178 } |
182 } |
179 |
183 |
180 // Replace it with null input context. |
184 // Replace it with null input context. |
181 HbInputMethod *master = HbInputMethodNull::Instance(); |
185 HbInputMethod *master = HbInputMethodNull::Instance(); |
182 master->d_ptr->mIsActive = true; |
186 master->d_ptr->mIsActive = true; |
183 QInputContext* proxy = master->d_ptr->newProxy(); |
187 QInputContext* proxy = master->d_ptr->proxy(); |
184 qApp->setInputContext(proxy); |
188 if (proxy != qApp->inputContext()) |
|
189 qApp->setInputContext(proxy); |
185 } |
190 } |
186 delete mMethods[i].cached; |
191 delete mMethods[i].cached; |
187 mMethods.removeAt(i); |
192 mMethods.removeAt(i); |
188 i--; |
193 i--; |
189 } |
194 } |
468 } |
488 } |
469 |
489 |
470 return result; |
490 return result; |
471 } |
491 } |
472 |
492 |
|
493 /*! |
|
494 \internal |
|
495 Returns true if given input method is able to handle given input state. |
|
496 */ |
|
497 bool HbInputModeCache::acceptsState(const HbInputMethod *inputMethod, const HbInputState &state) const |
|
498 { |
|
499 Q_D(const HbInputModeCache); |
|
500 |
|
501 foreach (const HbInputMethodListItem item, d->mMethods) { |
|
502 if (item.cached == inputMethod) { |
|
503 foreach (const QString language, item.languages) { |
|
504 HbInputModeProperties mode = d->propertiesFromString(language); |
|
505 // Check if keyboard type matches. |
|
506 if (mode.keyboard() == state.keyboard()) { |
|
507 // Check if input mode matches or it is a custom input method but |
|
508 // state's mode is not numeric. |
|
509 if (mode.inputMode() == state.inputMode() || |
|
510 ((mode.inputMode() == HbInputModeCustom) && |
|
511 (state.inputMode() != HbInputModeNumeric))) { |
|
512 // Check if language matches or input method supports |
|
513 // all mapped languages and state's language is among them. |
|
514 if (mode.language() == state.language() || |
|
515 (mode.language().undefined() && d->isMappedLanguage(state.language()))) { |
|
516 return true; |
|
517 } |
|
518 } |
|
519 } |
|
520 } |
|
521 } |
|
522 } |
|
523 |
|
524 return false; |
|
525 } |
|
526 |
|
527 /*! |
|
528 \internal |
|
529 Returns input method descriptor for given input method. Returns empty descriptor if the framework |
|
530 doesn't recognize given input method. |
|
531 */ |
|
532 HbInputMethodDescriptor HbInputModeCache::descriptor(const HbInputMethod *inputMethod) const |
|
533 { |
|
534 Q_D(const HbInputModeCache); |
|
535 |
|
536 foreach (HbInputMethodListItem item, d->mMethods) { |
|
537 if (item.cached == inputMethod) { |
|
538 return item.descriptor; |
|
539 } |
|
540 } |
|
541 |
|
542 return HbInputMethodDescriptor(); |
|
543 } |
|
544 |
|
545 |
473 // End of file |
546 // End of file |
|
547 |