66 system. |
66 system. |
67 */ |
67 */ |
68 |
68 |
69 /// @cond |
69 /// @cond |
70 |
70 |
|
71 HbSettingProxyInputMethodDescriptor::HbSettingProxyInputMethodDescriptor() |
|
72 { |
|
73 pluginNameAndPathSize = 0; |
|
74 keySize = 0; |
|
75 displayNameSize = 0; |
|
76 } |
|
77 |
|
78 HbSettingProxyInputMethodDescriptor::HbSettingProxyInputMethodDescriptor(const HbInputMethodDescriptor &descriptor) |
|
79 { |
|
80 *this = descriptor; |
|
81 } |
|
82 |
|
83 void HbSettingProxyInputMethodDescriptor::operator=(const HbInputMethodDescriptor &descriptor) |
|
84 { |
|
85 pluginNameAndPathSize = 0; |
|
86 keySize = 0; |
|
87 displayNameSize = 0; |
|
88 |
|
89 if (!descriptor.pluginNameAndPath().isEmpty() && |
|
90 (descriptor.pluginNameAndPath().size() * sizeof(QChar) < HbActiveMethodNameMax)) { |
|
91 pluginNameAndPathSize = descriptor.pluginNameAndPath().size(); |
|
92 memcpy((void*)pluginNameAndPath, (void*)descriptor.pluginNameAndPath().unicode(), descriptor.pluginNameAndPath().size() * sizeof(QChar)); |
|
93 } |
|
94 if (!descriptor.key().isEmpty() && |
|
95 (descriptor.key().size() * sizeof(QChar) < HbActiveMethodKeyMax)) { |
|
96 memcpy((void*)key, (void*)descriptor.key().unicode(), descriptor.key().size() * sizeof(QChar)); |
|
97 keySize = descriptor.key().size(); |
|
98 } |
|
99 if (!descriptor.displayName().isEmpty() && |
|
100 (descriptor.displayName().size() * sizeof(QChar) < HbActiveMethodKeyMax)) { |
|
101 memcpy((void*)displayName, (void*)descriptor.displayName().unicode(), descriptor.displayName().size() * sizeof(QChar)); |
|
102 displayNameSize = descriptor.displayName().size(); |
|
103 } |
|
104 } |
|
105 |
|
106 HbInputMethodDescriptor HbSettingProxyInputMethodDescriptor::descriptor() const |
|
107 { |
|
108 HbInputMethodDescriptor result; |
|
109 |
|
110 if (pluginNameAndPathSize > 0) { |
|
111 result.setPluginNameAndPath(QString(pluginNameAndPath, pluginNameAndPathSize)); |
|
112 } |
|
113 if (keySize > 0) { |
|
114 result.setKey(QString(key, keySize)); |
|
115 } |
|
116 if (displayNameSize > 0) { |
|
117 result.setDisplayName(QString(displayName, displayNameSize)); |
|
118 } |
|
119 |
|
120 return result; |
|
121 } |
|
122 |
|
123 QByteArray HbSettingProxyInputMethodDescriptor::data() const |
|
124 { |
|
125 if (customDataSize > 0) { |
|
126 return QByteArray(customData, customDataSize); |
|
127 } |
|
128 |
|
129 return QByteArray(); |
|
130 } |
|
131 |
|
132 void HbSettingProxyInputMethodDescriptor::setData(const QByteArray &data) |
|
133 { |
|
134 customDataSize = 0; |
|
135 |
|
136 if (data.size() > 0 && data.size() <= (int)HbActiveMethodKeyMax * 2) { |
|
137 memcpy(customData, data.data(), data.size()); |
|
138 customDataSize = data.size(); |
|
139 } |
|
140 } |
|
141 |
71 // Special character classifier class for bookkeeping |
142 // Special character classifier class for bookkeeping |
72 // of how popular a SC is. |
143 // of how popular a SC is. |
73 class HbScClassifier |
144 class HbScClassifier |
74 { |
145 { |
75 public: |
146 public: |
167 prData->iVersion = HbProxyDataRequiredVersion; |
238 prData->iVersion = HbProxyDataRequiredVersion; |
168 prData->iGlobalPrimaryInputLanguage = HbInputLanguage(QLocale::English, QLocale::UnitedKingdom); |
239 prData->iGlobalPrimaryInputLanguage = HbInputLanguage(QLocale::English, QLocale::UnitedKingdom); |
169 prData->iGlobalSecondaryInputLanguage = QLocale::Language(0); |
240 prData->iGlobalSecondaryInputLanguage = QLocale::Language(0); |
170 prData->iActiveKeyboard = HbKeyboardVirtual12Key; |
241 prData->iActiveKeyboard = HbKeyboardVirtual12Key; |
171 prData->iTouchKeyboard = HbKeyboardVirtual12Key; |
242 prData->iTouchKeyboard = HbKeyboardVirtual12Key; |
172 prData->iHwKeyboard = HbKeyboardQwerty; |
243 prData->iHwKeyboard = HbKeyboardQwerty; |
173 prData->iActiveCustomMethodName[0] = 0; |
244 prData->iPredictiveInputState = (HbKeyboardSettingFlags)HbKeyboardSetting12key|HbKeyboardSettingQwerty; |
174 prData->iActiveCustomMethodKey[0] = 0; |
|
175 prData->iPredictiveInputState = HbKeyboardSettingNone; |
|
176 prData->iDigitType = HbDigitTypeLatin; |
245 prData->iDigitType = HbDigitTypeLatin; |
177 prData->iQwertyTextCasing = true; |
246 prData->iQwertyTextCasing = true; |
178 prData->iQwertyCharacterPreview = true; |
247 prData->iQwertyCharacterPreview = true; |
179 prData->iRegionalCorrectionStatus = true; |
248 prData->iRegionalCorrectionStatus = true; |
180 prData->iKeypressTimeout = 1000; |
249 prData->iKeypressTimeout = 1000; |
181 prData->iAutocompletion = (HbKeyboardSettingFlags)(HbKeyboardSetting12key | HbKeyboardSettingQwerty); |
250 prData->iAutocompletion = (HbKeyboardSettingFlags)(HbKeyboardSetting12key | HbKeyboardSettingQwerty); |
182 prData->iTypingCorrectionLevel = HbTypingCorrectionLevelHigh; |
251 prData->iTypingCorrectionLevel = HbTypingCorrectionLevelHigh; |
183 prData->iPrimaryCandidateMode = HbPrimaryCandidateModeBestPrediction; |
252 prData->iPrimaryCandidateMode = HbPrimaryCandidateModeBestPrediction; |
|
253 prData->iPreferredMethodHorizontal = HbInputMethodDescriptor(); |
|
254 prData->iPreferredMethodHorizontal.setData(QByteArray()); |
|
255 prData->iPreferredMethodVertical = HbInputMethodDescriptor(); |
|
256 prData->iPreferredMethodVertical.setData(QByteArray()); |
184 } |
257 } |
185 } |
258 } |
186 unlock(); |
259 unlock(); |
187 } |
260 } |
188 |
261 |
507 if (prData) { |
580 if (prData) { |
508 res = prData->iActiveKeyboard; |
581 res = prData->iActiveKeyboard; |
509 } |
582 } |
510 |
583 |
511 return res; |
584 return res; |
|
585 } |
|
586 |
|
587 /*! |
|
588 Returns the preferred input method for given screen orientation. Initially this value is empty |
|
589 and the framework will resolve the default handler. |
|
590 |
|
591 \sa setPreferredInputMethod |
|
592 */ |
|
593 HbInputMethodDescriptor HbInputSettingProxy::preferredInputMethod(Qt::Orientation orientation) const |
|
594 { |
|
595 Q_D(const HbInputSettingProxy); |
|
596 |
|
597 HbInputMethodDescriptor result; |
|
598 |
|
599 HbSettingProxyInternalData* prData = d->proxyData(); |
|
600 if (prData) { |
|
601 d->lock(); |
|
602 if (orientation == Qt::Horizontal) { |
|
603 result = prData->iPreferredMethodHorizontal.descriptor(); |
|
604 } else { |
|
605 result = prData->iPreferredMethodVertical.descriptor(); |
|
606 } |
|
607 d->unlock(); |
|
608 } |
|
609 |
|
610 return result; |
|
611 } |
|
612 |
|
613 /*! |
|
614 Returns the preferred input method for current screen orientation. Initially this value is empty |
|
615 and the framework will resolve the default handler. |
|
616 |
|
617 \sa setPreferredInputMethod |
|
618 */ |
|
619 HbInputMethodDescriptor HbInputSettingProxy::preferredInputMethod() const |
|
620 { |
|
621 Q_D(const HbInputSettingProxy); |
|
622 |
|
623 HbInputMethodDescriptor result; |
|
624 |
|
625 HbSettingProxyInternalData* prData = d->proxyData(); |
|
626 if (prData) { |
|
627 d->lock(); |
|
628 if (prData->iScreenOrientation == Qt::Horizontal) { |
|
629 result = prData->iPreferredMethodHorizontal.descriptor(); |
|
630 } else { |
|
631 result = prData->iPreferredMethodVertical.descriptor(); |
|
632 } |
|
633 d->unlock(); |
|
634 } |
|
635 |
|
636 return result; |
|
637 } |
|
638 |
|
639 /*! |
|
640 Returns custom data associated to preferred input method. |
|
641 |
|
642 \sa setPreferredInputMethod |
|
643 */ |
|
644 QByteArray HbInputSettingProxy::preferredInputMethodCustomData(Qt::Orientation orientation) const |
|
645 { |
|
646 Q_D(const HbInputSettingProxy); |
|
647 |
|
648 QByteArray result; |
|
649 |
|
650 HbSettingProxyInternalData* prData = d->proxyData(); |
|
651 if (prData) { |
|
652 d->lock(); |
|
653 if (orientation == Qt::Horizontal) { |
|
654 result = prData->iPreferredMethodHorizontal.data(); |
|
655 } else { |
|
656 result = prData->iPreferredMethodVertical.data(); |
|
657 } |
|
658 d->unlock(); |
|
659 } |
|
660 |
|
661 return result; |
|
662 } |
|
663 |
|
664 /*! |
|
665 Sets preferred input method for given screen orientation. The parameter \a customdata may contain |
|
666 any information the preferred input method needs to remember as part of settings data. |
|
667 Note that only 128 bytes is reserved for custom data. Larger amount of it needs to be |
|
668 handled by other means. |
|
669 This method is for input method developers only. There should never be need to call it from application code. |
|
670 |
|
671 \sa preferredInputMethod |
|
672 */ |
|
673 void HbInputSettingProxy::setPreferredInputMethod(Qt::Orientation orientation, const HbInputMethodDescriptor &inputMethod, const QByteArray &customData) |
|
674 { |
|
675 Q_D(HbInputSettingProxy); |
|
676 HbSettingProxyInternalData* prData = d->proxyData(); |
|
677 if (prData) { |
|
678 d->lock(); |
|
679 if (orientation == Qt::Horizontal) { |
|
680 prData->iPreferredMethodHorizontal = inputMethod; |
|
681 prData->iPreferredMethodHorizontal.setData(customData); |
|
682 } else { |
|
683 prData->iPreferredMethodVertical = inputMethod; |
|
684 prData->iPreferredMethodVertical.setData(customData); |
|
685 } |
|
686 d->unlock(); |
|
687 } |
512 } |
688 } |
513 |
689 |
514 /*! |
690 /*! |
515 Sets system wide input language. Will emit signal globalInputLanguageChanged if language is changed. |
691 Sets system wide input language. Will emit signal globalInputLanguageChanged if language is changed. |
516 |
692 |
767 Returns list of paths to all possible keymap plugin locations. |
943 Returns list of paths to all possible keymap plugin locations. |
768 */ |
944 */ |
769 QStringList HbInputSettingProxy::keymapPluginPaths() |
945 QStringList HbInputSettingProxy::keymapPluginPaths() |
770 { |
946 { |
771 QStringList result; |
947 QStringList result; |
|
948 QFileInfoList list = QDir::drives(); |
|
949 |
772 #ifdef Q_OS_SYMBIAN |
950 #ifdef Q_OS_SYMBIAN |
773 result.append(QString("z:/resource/keymaps")); |
951 for(int counter = 0; counter < list.count(); counter ++) { |
|
952 result.append(list.at(counter).absoluteFilePath() + QString("/resource/keymaps")); |
|
953 } |
774 #else |
954 #else |
775 result.append(HB_RESOURCES_DIR + (QDir::separator() + QString("keymaps"))); |
955 result.append(HB_RESOURCES_DIR + (QDir::separator() + QString("keymaps"))); |
|
956 for(int counter = 0; counter < list.count(); counter ++) { |
|
957 result.append(list.at(counter).absoluteFilePath() + QString("resource/keymaps")); |
|
958 } |
776 #endif |
959 #endif |
|
960 result.sort(); |
|
961 //Append the default resource at the end |
777 result.append(":/keymaps"); |
962 result.append(":/keymaps"); |
778 return QStringList(result); |
963 return QStringList(result); |
779 } |
964 } |
780 |
965 |
781 /*! |
966 /*! |
957 |
1142 |
958 \sa setActiveCustomInputMethod |
1143 \sa setActiveCustomInputMethod |
959 */ |
1144 */ |
960 HbInputMethodDescriptor HbInputSettingProxy::activeCustomInputMethod() const |
1145 HbInputMethodDescriptor HbInputSettingProxy::activeCustomInputMethod() const |
961 { |
1146 { |
962 Q_D(const HbInputSettingProxy); |
1147 return HbInputMethodDescriptor(); |
963 |
1148 } |
964 HbInputMethodDescriptor result; |
1149 |
965 |
1150 /*! |
966 d->lock(); |
|
967 HbSettingProxyInternalData* prData = d->proxyData(); |
|
968 if (prData) { |
|
969 result.setPluginNameAndPath(d->stringFromProxyDataElement(prData->iActiveCustomMethodName)); |
|
970 result.setKey(d->stringFromProxyDataElement(prData->iActiveCustomMethodKey)); |
|
971 } |
|
972 d->unlock(); |
|
973 |
|
974 return HbInputMethodDescriptor(result); |
|
975 } |
|
976 |
|
977 /*! |
|
978 |
|
979 \sa activeCustomInputMethod |
1151 \sa activeCustomInputMethod |
980 */ |
1152 */ |
981 void HbInputSettingProxy::setActiveCustomInputMethod(const HbInputMethodDescriptor &inputMethod) |
1153 void HbInputSettingProxy::setActiveCustomInputMethod(const HbInputMethodDescriptor &inputMethod) |
982 { |
1154 { |
983 Q_D(HbInputSettingProxy); |
1155 Q_UNUSED(inputMethod) |
984 |
|
985 d->lock(); |
|
986 HbSettingProxyInternalData* prData = d->proxyData(); |
|
987 if (prData) { |
|
988 d->stringToProxyDataElement(prData->iActiveCustomMethodName, inputMethod.pluginNameAndPath(), HbActiveMethodNameMax); |
|
989 d->stringToProxyDataElement(prData->iActiveCustomMethodKey, inputMethod.key(), HbActiveMethodKeyMax); |
|
990 } |
|
991 d->unlock(); |
|
992 } |
1156 } |
993 |
1157 |
994 /*! |
1158 /*! |
995 Returns the current screen orientation in settings |
1159 Returns the current screen orientation in settings |
996 */ |
1160 */ |