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 "hbinputsettingproxy.h" |
|
26 #include "hbinputsettingproxy_p.h" |
|
27 |
25 #include <qbytearray.h> |
28 #include <qbytearray.h> |
26 #include <QFile> |
29 #include <QFile> |
27 #include <QBuffer> |
30 #include <QBuffer> |
28 #include <QDataStream> |
31 #include <QDataStream> |
29 #include <QCoreApplication> |
32 #include <QCoreApplication> |
30 #include <QSharedMemory> |
33 #include <QSharedMemory> |
31 #include <QVector> |
34 #include <QVector> |
32 #include <QDir> |
35 #include <QDir> |
33 |
36 |
34 #include "hbinputsettingproxy.h" |
|
35 #include "hbinputsettingproxy_p.h" |
|
36 #include "hbinputmodecache_p.h" |
37 #include "hbinputmodecache_p.h" |
37 #include "hbinputfilter.h" |
38 #include "hbinputfilter.h" |
38 |
39 |
39 #ifdef Q_OS_SYMBIAN |
40 #ifdef Q_OS_SYMBIAN |
40 |
41 |
87 displayNameSize = 0; |
88 displayNameSize = 0; |
88 |
89 |
89 if (!descriptor.pluginNameAndPath().isEmpty() && |
90 if (!descriptor.pluginNameAndPath().isEmpty() && |
90 (descriptor.pluginNameAndPath().size() * sizeof(QChar) < HbActiveMethodNameMax)) { |
91 (descriptor.pluginNameAndPath().size() * sizeof(QChar) < HbActiveMethodNameMax)) { |
91 pluginNameAndPathSize = descriptor.pluginNameAndPath().size(); |
92 pluginNameAndPathSize = descriptor.pluginNameAndPath().size(); |
92 memcpy((void*)pluginNameAndPath, (void*)descriptor.pluginNameAndPath().unicode(), descriptor.pluginNameAndPath().size() * sizeof(QChar)); |
93 memcpy((void *)pluginNameAndPath, (void *)descriptor.pluginNameAndPath().unicode(), descriptor.pluginNameAndPath().size() * sizeof(QChar)); |
93 } |
94 } |
94 if (!descriptor.key().isEmpty() && |
95 if (!descriptor.key().isEmpty() && |
95 (descriptor.key().size() * sizeof(QChar) < HbActiveMethodKeyMax)) { |
96 (descriptor.key().size() * sizeof(QChar) < HbActiveMethodKeyMax)) { |
96 memcpy((void*)key, (void*)descriptor.key().unicode(), descriptor.key().size() * sizeof(QChar)); |
97 memcpy((void *)key, (void *)descriptor.key().unicode(), descriptor.key().size() * sizeof(QChar)); |
97 keySize = descriptor.key().size(); |
98 keySize = descriptor.key().size(); |
98 } |
99 } |
99 if (!descriptor.displayName().isEmpty() && |
100 if (!descriptor.displayName().isEmpty() && |
100 (descriptor.displayName().size() * sizeof(QChar) < HbActiveMethodKeyMax)) { |
101 (descriptor.displayName().size() * sizeof(QChar) < HbActiveMethodKeyMax)) { |
101 memcpy((void*)displayName, (void*)descriptor.displayName().unicode(), descriptor.displayName().size() * sizeof(QChar)); |
102 memcpy((void *)displayName, (void *)descriptor.displayName().unicode(), descriptor.displayName().size() * sizeof(QChar)); |
102 displayNameSize = descriptor.displayName().size(); |
103 displayNameSize = descriptor.displayName().size(); |
103 } |
104 } |
104 } |
105 } |
105 |
106 |
106 HbInputMethodDescriptor HbSettingProxyInputMethodDescriptor::descriptor() const |
107 HbInputMethodDescriptor HbSettingProxyInputMethodDescriptor::descriptor() const |
143 // of how popular a SC is. |
144 // of how popular a SC is. |
144 class HbScClassifier |
145 class HbScClassifier |
145 { |
146 { |
146 public: |
147 public: |
147 HbScClassifier(QChar aChar = 0, int aCount = 0) |
148 HbScClassifier(QChar aChar = 0, int aCount = 0) |
148 : mChar(aChar), mCount(aCount) |
149 : mChar(aChar), mCount(aCount) { |
149 { |
150 } |
150 } |
151 |
151 |
152 void operator=(const HbScClassifier &aOther) { |
152 void operator=(const HbScClassifier& aOther) |
|
153 { |
|
154 mChar = aOther.mChar; |
153 mChar = aOther.mChar; |
155 mCount = aOther.mCount; |
154 mCount = aOther.mCount; |
156 } |
155 } |
157 |
156 |
158 public: |
157 public: |
159 QChar mChar; |
158 QChar mChar; |
160 int mCount; |
159 int mCount; |
161 }; |
160 }; |
162 |
161 |
163 /// @endcond |
|
164 |
|
165 HbInputSettingProxyPrivate::HbInputSettingProxyPrivate() |
162 HbInputSettingProxyPrivate::HbInputSettingProxyPrivate() |
166 { |
163 { |
167 iSharedMemory = new QSharedMemory(KInputSettingProxyKey); |
164 iSharedMemory = new QSharedMemory(KInputSettingProxyKey); |
168 |
165 |
169 if (!iSharedMemory->attach()) { |
166 if (!iSharedMemory->attach()) { |
211 unlock(); |
208 unlock(); |
212 } |
209 } |
213 |
210 |
214 QString HbInputSettingProxyPrivate::dataFilePath() |
211 QString HbInputSettingProxyPrivate::dataFilePath() |
215 { |
212 { |
216 return HbInputSettingProxy::writablePath()+QDir::separator()+QString("settings"); |
213 return HbInputSettingProxy::writablePath() + QDir::separator() + QString("settings"); |
217 } |
214 } |
218 |
215 |
219 QString HbInputSettingProxyPrivate::dataFileNameAndPath() |
216 QString HbInputSettingProxyPrivate::dataFileNameAndPath() |
220 { |
217 { |
221 return dataFilePath()+QDir::separator()+QString("proxy.dat"); |
218 return dataFilePath() + QDir::separator() + QString("proxy.dat"); |
222 } |
219 } |
223 |
220 |
224 void HbInputSettingProxyPrivate::initializeDataArea() |
221 void HbInputSettingProxyPrivate::initializeDataArea() |
225 { |
222 { |
226 lock(); |
223 lock(); |
227 bool wasLoaded = load(); |
224 bool wasLoaded = load(); |
228 |
225 |
229 HbSettingProxyInternalData* prData = proxyData(); |
226 HbSettingProxyInternalData *prData = proxyData(); |
230 if (prData) { |
227 if (prData) { |
231 prData->iReferences = 0; |
228 prData->iReferences = 0; |
232 prData->iOrientationChangeCompleted = true; |
229 prData->iOrientationChangeCompleted = true; |
233 // Default values, real ones should be set by calling initializeOrientation() |
230 // Default values, real ones should be set by calling initializeOrientation() |
234 prData->iScreenOrientation = Qt::Vertical; |
231 prData->iScreenOrientation = Qt::Vertical; |
238 prData->iVersion = HbProxyDataRequiredVersion; |
235 prData->iVersion = HbProxyDataRequiredVersion; |
239 prData->iGlobalPrimaryInputLanguage = HbInputLanguage(QLocale::English, QLocale::UnitedKingdom); |
236 prData->iGlobalPrimaryInputLanguage = HbInputLanguage(QLocale::English, QLocale::UnitedKingdom); |
240 prData->iGlobalSecondaryInputLanguage = QLocale::Language(0); |
237 prData->iGlobalSecondaryInputLanguage = QLocale::Language(0); |
241 prData->iActiveKeyboard = HbKeyboardVirtual12Key; |
238 prData->iActiveKeyboard = HbKeyboardVirtual12Key; |
242 prData->iTouchKeyboard = HbKeyboardVirtual12Key; |
239 prData->iTouchKeyboard = HbKeyboardVirtual12Key; |
243 prData->iHwKeyboard = HbKeyboardQwerty; |
240 prData->iHwKeyboard = HbKeyboardQwerty; |
244 prData->iPredictiveInputState = (HbKeyboardSettingFlags)HbKeyboardSetting12key|HbKeyboardSettingQwerty; |
241 prData->iPredictiveInputState = (HbKeyboardSettingFlags)HbKeyboardSetting12key | HbKeyboardSettingQwerty; |
245 prData->iDigitType = HbDigitTypeLatin; |
242 prData->iDigitType = HbDigitTypeLatin; |
246 prData->iQwertyTextCasing = true; |
243 prData->iQwertyTextCasing = true; |
247 prData->iQwertyCharacterPreview = true; |
244 prData->iQwertyCharacterPreview = true; |
248 prData->iRegionalCorrectionStatus = true; |
245 prData->iRegionalCorrectionStatus = true; |
249 prData->iKeypressTimeout = 1000; |
246 prData->iKeypressTimeout = 1000; |
250 prData->iAutocompletion = (HbKeyboardSettingFlags)(HbKeyboardSetting12key | HbKeyboardSettingQwerty); |
247 prData->iAutocompletion = (HbKeyboardSettingFlags)(HbKeyboardSetting12key | HbKeyboardSettingQwerty); |
251 prData->iTypingCorrectionLevel = HbTypingCorrectionLevelHigh; |
248 prData->iTypingCorrectionLevel = HbTypingCorrectionLevelHigh; |
252 prData->iPrimaryCandidateMode = HbPrimaryCandidateModeBestPrediction; |
249 prData->iPrimaryCandidateMode = HbPrimaryCandidateModeBestPrediction; |
253 prData->iPreferredMethodHorizontal = HbInputMethodDescriptor(); |
250 prData->iPreferredMethodHorizontal = HbInputMethodDescriptor(); |
254 prData->iPreferredMethodHorizontal.setData(QByteArray()); |
251 prData->iPreferredMethodHorizontal.setData(QByteArray()); |
255 prData->iPreferredMethodVertical = HbInputMethodDescriptor(); |
252 prData->iPreferredMethodVertical = HbInputMethodDescriptor(); |
256 prData->iPreferredMethodVertical.setData(QByteArray()); |
253 prData->iPreferredMethodVertical.setData(QByteArray()); |
257 } |
254 } |
266 return false; |
263 return false; |
267 } |
264 } |
268 |
265 |
269 QByteArray rawData = file.read(sizeof(HbSettingProxyInternalData)); |
266 QByteArray rawData = file.read(sizeof(HbSettingProxyInternalData)); |
270 if (rawData.size() == sizeof(HbSettingProxyInternalData)) { |
267 if (rawData.size() == sizeof(HbSettingProxyInternalData)) { |
271 HbSettingProxyInternalData* ldData = (HbSettingProxyInternalData*)rawData.constData(); |
268 HbSettingProxyInternalData *ldData = (HbSettingProxyInternalData *)rawData.constData(); |
272 if (ldData) { |
269 if (ldData) { |
273 if (ldData->iVersion == HbProxyDataRequiredVersion) { |
270 if (ldData->iVersion == HbProxyDataRequiredVersion) { |
274 |
271 |
275 HbSettingProxyInternalData* prData = proxyData(); |
272 HbSettingProxyInternalData *prData = proxyData(); |
276 memcpy((void*)prData, (void*)ldData, sizeof(HbSettingProxyInternalData)); |
273 memcpy((void *)prData, (void *)ldData, sizeof(HbSettingProxyInternalData)); |
277 prData->iActiveKeyboard = ldData->iActiveKeyboard; |
274 prData->iActiveKeyboard = ldData->iActiveKeyboard; |
278 |
275 |
279 // Temporarily like this, will be moved as part of shared data later... |
276 // Temporarily like this, will be moved as part of shared data later... |
280 int numItems = 0; |
277 int numItems = 0; |
281 file.read((char *)&numItems, sizeof(int)); |
278 file.read((char *)&numItems, sizeof(int)); |
282 iTopScs.clear(); |
279 iTopScs.clear(); |
283 for (int jj = 0; jj < numItems; jj++) { |
280 for (int jj = 0; jj < numItems; jj++) { |
284 HbScClassifier tmpItem; |
281 HbScClassifier tmpItem; |
285 file.read((char*)&tmpItem, sizeof(HbScClassifier)); |
282 file.read((char *)&tmpItem, sizeof(HbScClassifier)); |
286 iTopScs.append(tmpItem); |
283 iTopScs.append(tmpItem); |
287 } |
284 } |
288 |
285 |
289 file.close(); |
286 file.close(); |
290 return true; |
287 return true; |
300 { |
297 { |
301 // Make sure that the path exists |
298 // Make sure that the path exists |
302 QDir settingDir; |
299 QDir settingDir; |
303 settingDir.mkpath(dataFilePath()); |
300 settingDir.mkpath(dataFilePath()); |
304 |
301 |
305 HbSettingProxyInternalData* prData = proxyData(); |
302 HbSettingProxyInternalData *prData = proxyData(); |
306 if (prData) { |
303 if (prData) { |
307 QFile file(iSaveFile); |
304 QFile file(iSaveFile); |
308 if (!file.open(QIODevice::WriteOnly)) { |
305 if (!file.open(QIODevice::WriteOnly)) { |
309 return; |
306 return; |
310 } |
307 } |
311 |
308 |
312 file.write((const char*)prData, sizeof(HbSettingProxyInternalData)); |
309 file.write((const char *)prData, sizeof(HbSettingProxyInternalData)); |
313 |
310 |
314 // Temporarily like this, will be moved to shared data later... |
311 // Temporarily like this, will be moved to shared data later... |
315 int numItems = iTopScs.count(); |
312 int numItems = iTopScs.count(); |
316 file.write((const char*)&numItems, sizeof(int)); |
313 file.write((const char *)&numItems, sizeof(int)); |
317 file.write((const char*)iTopScs.constData(), numItems * sizeof(HbScClassifier)); |
314 file.write((const char *)iTopScs.constData(), numItems * sizeof(HbScClassifier)); |
318 file.close(); |
315 file.close(); |
319 } |
316 } |
320 } |
317 } |
321 |
318 |
322 QString HbInputSettingProxyPrivate::stringFromProxyDataElement(QChar *string) const |
319 QString HbInputSettingProxyPrivate::stringFromProxyDataElement(QChar *string) const |
336 string[i] = source[i]; |
333 string[i] = source[i]; |
337 } |
334 } |
338 string[i] = 0; |
335 string[i] = 0; |
339 } |
336 } |
340 |
337 |
341 HbSettingProxyInternalData* HbInputSettingProxyPrivate::proxyData() const |
338 HbSettingProxyInternalData *HbInputSettingProxyPrivate::proxyData() const |
342 { |
339 { |
343 return static_cast<HbSettingProxyInternalData*>(iSharedMemory->data()); |
340 return static_cast<HbSettingProxyInternalData *>(iSharedMemory->data()); |
344 } |
341 } |
345 |
342 |
346 void HbInputSettingProxyPrivate::flipToggle() |
343 void HbInputSettingProxyPrivate::flipToggle() |
347 { |
344 { |
348 setFlipStatus(!flipStatus()); |
345 setFlipStatus(!flipStatus()); |
349 } |
346 } |
350 |
347 |
351 bool HbInputSettingProxyPrivate::flipStatus() |
348 bool HbInputSettingProxyPrivate::flipStatus() |
352 { |
349 { |
353 HbSettingProxyInternalData* prData = proxyData(); |
350 HbSettingProxyInternalData *prData = proxyData(); |
354 return prData->iFlipStatus; |
351 return prData->iFlipStatus; |
355 } |
352 } |
356 |
353 |
357 void HbInputSettingProxyPrivate::setFlipStatus(bool flipStatus) |
354 void HbInputSettingProxyPrivate::setFlipStatus(bool flipStatus) |
358 { |
355 { |
359 HbSettingProxyInternalData* prData = proxyData(); |
356 HbSettingProxyInternalData *prData = proxyData(); |
360 prData->iFlipStatus = flipStatus; |
357 prData->iFlipStatus = flipStatus; |
361 |
358 |
362 handleDeviceSpecificOriantationAndFlipChange(); |
359 handleDeviceSpecificOriantationAndFlipChange(); |
363 } |
360 } |
364 |
361 |
367 HbKeyboardType keyboard = HbKeyboardNone; |
364 HbKeyboardType keyboard = HbKeyboardNone; |
368 |
365 |
369 if (HbInputSettingProxy::instance()->screenOrientation() == Qt::Vertical) { |
366 if (HbInputSettingProxy::instance()->screenOrientation() == Qt::Vertical) { |
370 keyboard = HbKeyboardVirtual12Key; |
367 keyboard = HbKeyboardVirtual12Key; |
371 } else { |
368 } else { |
372 if(flipStatus()) { |
369 if (flipStatus()) { |
373 keyboard = HbKeyboardQwerty; |
370 keyboard = HbKeyboardQwerty; |
374 } else { |
371 } else { |
375 keyboard = HbKeyboardVirtualQwerty; |
372 keyboard = HbKeyboardVirtualQwerty; |
376 } |
373 } |
377 } |
374 } |
378 |
375 |
379 HbInputSettingProxy::instance()->setActiveKeyboard(keyboard); |
376 HbInputSettingProxy::instance()->setActiveKeyboard(keyboard); |
380 } |
377 } |
381 |
378 |
382 // |
379 /// @endcond |
383 // HbInputSettingProxy |
|
384 // |
|
385 |
380 |
386 /*! |
381 /*! |
387 Returns pointer to the singleton object. |
382 Returns pointer to the singleton object. |
388 */ |
383 */ |
389 HbInputSettingProxy* HbInputSettingProxy::instance() |
384 HbInputSettingProxy *HbInputSettingProxy::instance() |
390 { |
385 { |
391 static HbInputSettingProxy theProxy; |
386 static HbInputSettingProxy theProxy; |
392 return &theProxy; |
387 return &theProxy; |
393 } |
388 } |
394 |
389 |
447 \sa keypressTimeoutChanged |
442 \sa keypressTimeoutChanged |
448 \sa autocompletionStateChanged |
443 \sa autocompletionStateChanged |
449 \sa typingCorrectionLevelChanged |
444 \sa typingCorrectionLevelChanged |
450 \sa primaryCandidateModeChanged |
445 \sa primaryCandidateModeChanged |
451 */ |
446 */ |
452 void HbInputSettingProxy::connectObservingObject(QObject* aObserver) |
447 void HbInputSettingProxy::connectObservingObject(QObject *aObserver) |
453 { |
448 { |
454 if (aObserver) { |
449 if (aObserver) { |
455 connect(this, SIGNAL(globalInputLanguageChanged(const HbInputLanguage &)), aObserver, SLOT(globalInputLanguageChanged(const HbInputLanguage &))); |
450 connect(this, SIGNAL(globalInputLanguageChanged(const HbInputLanguage &)), aObserver, SLOT(globalInputLanguageChanged(const HbInputLanguage &))); |
456 connect(this, SIGNAL(globalSecondaryInputLanguageChanged(const HbInputLanguage &)), aObserver, SLOT(globalSecondaryInputLanguageChanged(const HbInputLanguage &))); |
451 connect(this, SIGNAL(globalSecondaryInputLanguageChanged(const HbInputLanguage &)), aObserver, SLOT(globalSecondaryInputLanguageChanged(const HbInputLanguage &))); |
457 connect(this, SIGNAL(activeKeyboardChanged(HbKeyboardType)), aObserver, SLOT(activeKeyboardChanged(HbKeyboardType))); |
452 connect(this, SIGNAL(activeKeyboardChanged(HbKeyboardType)), aObserver, SLOT(activeKeyboardChanged(HbKeyboardType))); |
463 /*! |
458 /*! |
464 Disconnects given object from the setting proxy. |
459 Disconnects given object from the setting proxy. |
465 |
460 |
466 \sa connectObservingObject |
461 \sa connectObservingObject |
467 */ |
462 */ |
468 void HbInputSettingProxy::disconnectObservingObject(QObject* aObserver) |
463 void HbInputSettingProxy::disconnectObservingObject(QObject *aObserver) |
469 { |
464 { |
470 if (aObserver) { |
465 if (aObserver) { |
471 disconnect(this, SIGNAL(globalInputLanguageChanged(const HbInputLanguage &)), aObserver, SLOT(globalInputLanguageChanged(const HbInputLanguage &))); |
466 disconnect(this, SIGNAL(globalInputLanguageChanged(const HbInputLanguage &)), aObserver, SLOT(globalInputLanguageChanged(const HbInputLanguage &))); |
472 disconnect(this, SIGNAL(globalSecondaryInputLanguageChanged(const HbInputLanguage &)), aObserver, SLOT(globalSecondaryInputLanguageChanged(const HbInputLanguage &))); |
467 disconnect(this, SIGNAL(globalSecondaryInputLanguageChanged(const HbInputLanguage &)), aObserver, SLOT(globalSecondaryInputLanguageChanged(const HbInputLanguage &))); |
473 disconnect(this, SIGNAL(activeKeyboardChanged(HbKeyboardType)), aObserver, SLOT(activeKeyboardChanged(HbKeyboardType))); |
468 disconnect(this, SIGNAL(activeKeyboardChanged(HbKeyboardType)), aObserver, SLOT(activeKeyboardChanged(HbKeyboardType))); |
671 \sa preferredInputMethod |
666 \sa preferredInputMethod |
672 */ |
667 */ |
673 void HbInputSettingProxy::setPreferredInputMethod(Qt::Orientation orientation, const HbInputMethodDescriptor &inputMethod, const QByteArray &customData) |
668 void HbInputSettingProxy::setPreferredInputMethod(Qt::Orientation orientation, const HbInputMethodDescriptor &inputMethod, const QByteArray &customData) |
674 { |
669 { |
675 Q_D(HbInputSettingProxy); |
670 Q_D(HbInputSettingProxy); |
676 HbSettingProxyInternalData* prData = d->proxyData(); |
671 HbSettingProxyInternalData *prData = d->proxyData(); |
677 if (prData) { |
672 if (prData) { |
678 d->lock(); |
673 d->lock(); |
679 if (orientation == Qt::Horizontal) { |
674 if (orientation == Qt::Horizontal) { |
680 prData->iPreferredMethodHorizontal = inputMethod; |
675 prData->iPreferredMethodHorizontal = inputMethod; |
681 prData->iPreferredMethodHorizontal.setData(customData); |
676 prData->iPreferredMethodHorizontal.setData(customData); |
690 /*! |
685 /*! |
691 Sets system wide input language. Will emit signal globalInputLanguageChanged if language is changed. |
686 Sets system wide input language. Will emit signal globalInputLanguageChanged if language is changed. |
692 |
687 |
693 \sa globalInputLanguage |
688 \sa globalInputLanguage |
694 */ |
689 */ |
695 void HbInputSettingProxy::setGlobalInputLanguage(const HbInputLanguage& language) |
690 void HbInputSettingProxy::setGlobalInputLanguage(const HbInputLanguage &language) |
696 { |
691 { |
697 Q_D(HbInputSettingProxy); |
692 Q_D(HbInputSettingProxy); |
698 HbSettingProxyInternalData* prData = d->proxyData(); |
693 HbSettingProxyInternalData *prData = d->proxyData(); |
699 if (prData) { |
694 if (prData) { |
700 bool notify = false; |
695 bool notify = false; |
701 d->lock(); |
696 d->lock(); |
702 if (prData->iGlobalPrimaryInputLanguage != language) { |
697 if (prData->iGlobalPrimaryInputLanguage != language) { |
703 prData->iGlobalPrimaryInputLanguage = language; |
698 prData->iGlobalPrimaryInputLanguage = language; |
837 \sa predictiveInputStatus |
832 \sa predictiveInputStatus |
838 */ |
833 */ |
839 void HbInputSettingProxy::setPredictiveInputStatus(HbKeyboardSettingFlags keyboardType, bool newStatus) |
834 void HbInputSettingProxy::setPredictiveInputStatus(HbKeyboardSettingFlags keyboardType, bool newStatus) |
840 { |
835 { |
841 Q_D(HbInputSettingProxy); |
836 Q_D(HbInputSettingProxy); |
842 HbSettingProxyInternalData* prData = d->proxyData(); |
837 HbSettingProxyInternalData *prData = d->proxyData(); |
843 if (prData) { |
838 if (prData) { |
844 bool notify = false; |
839 bool notify = false; |
845 d->lock(); |
840 d->lock(); |
846 |
841 |
847 HbKeyboardSettingFlags newValue = prData->iPredictiveInputState; |
842 HbKeyboardSettingFlags newValue = prData->iPredictiveInputState; |
848 if (newStatus) { |
843 if (newStatus) { |
849 newValue |= keyboardType; |
844 newValue |= keyboardType; |
850 } else { |
845 } else { |
851 newValue &= ~keyboardType; |
846 newValue &= ~keyboardType; |
870 bool HbInputSettingProxy::predictiveInputStatusForActiveKeyboard() const |
865 bool HbInputSettingProxy::predictiveInputStatusForActiveKeyboard() const |
871 { |
866 { |
872 Q_D(const HbInputSettingProxy); |
867 Q_D(const HbInputSettingProxy); |
873 bool res = false; |
868 bool res = false; |
874 |
869 |
875 HbSettingProxyInternalData* prData = d->proxyData(); |
870 HbSettingProxyInternalData *prData = d->proxyData(); |
876 if (prData) { |
871 if (prData) { |
877 if (activeKeyboard() & HbQwertyKeyboardMask) { |
872 if (activeKeyboard() & HbQwertyKeyboardMask) { |
878 res = prData->iPredictiveInputState & HbKeyboardSettingQwerty; |
873 res = prData->iPredictiveInputState & HbKeyboardSettingQwerty; |
879 } else { |
874 } else { |
880 res = prData->iPredictiveInputState & HbKeyboardSetting12key; |
875 res = prData->iPredictiveInputState & HbKeyboardSetting12key; |
946 { |
941 { |
947 QStringList result; |
942 QStringList result; |
948 QFileInfoList list = QDir::drives(); |
943 QFileInfoList list = QDir::drives(); |
949 |
944 |
950 #ifdef Q_OS_SYMBIAN |
945 #ifdef Q_OS_SYMBIAN |
951 for(int counter = 0; counter < list.count(); counter ++) { |
946 for (int counter = 0; counter < list.count(); counter ++) { |
952 result.append(list.at(counter).absoluteFilePath() + QString("/resource/keymaps")); |
947 result.append(list.at(counter).absoluteFilePath() + QString("/resource/keymaps")); |
953 } |
948 } |
954 #else |
949 #else |
955 result.append(HB_RESOURCES_DIR + (QDir::separator() + QString("keymaps"))); |
950 result.append(HB_RESOURCES_DIR + (QDir::separator() + QString("keymaps"))); |
956 for(int counter = 0; counter < list.count(); counter ++) { |
951 for (int counter = 0; counter < list.count(); counter ++) { |
957 result.append(list.at(counter).absoluteFilePath() + QString("resource/keymaps")); |
952 result.append(list.at(counter).absoluteFilePath() + QString("resource/keymaps")); |
958 } |
953 } |
959 #endif |
954 #endif |
960 result.sort(); |
955 result.sort(); |
961 //Append the default resource at the end |
956 //Append the default resource at the end |
1076 \sa automaticTextCasingForQwerty |
1071 \sa automaticTextCasingForQwerty |
1077 */ |
1072 */ |
1078 void HbInputSettingProxy::setAutomaticTextCasingForQwerty(bool status) |
1073 void HbInputSettingProxy::setAutomaticTextCasingForQwerty(bool status) |
1079 { |
1074 { |
1080 Q_D(HbInputSettingProxy); |
1075 Q_D(HbInputSettingProxy); |
1081 HbSettingProxyInternalData* prData = d->proxyData(); |
1076 HbSettingProxyInternalData *prData = d->proxyData(); |
1082 if (prData) { |
1077 if (prData) { |
1083 bool notify = false; |
1078 bool notify = false; |
1084 d->lock(); |
1079 d->lock(); |
1085 if (prData->iQwertyTextCasing != status) { |
1080 if (prData->iQwertyTextCasing != status) { |
1086 prData->iQwertyTextCasing = status; |
1081 prData->iQwertyTextCasing = status; |
1089 d->unlock(); |
1084 d->unlock(); |
1090 if (notify) { |
1085 if (notify) { |
1091 emit automaticTextCasingStateForQwertyChanged(status); |
1086 emit automaticTextCasingStateForQwertyChanged(status); |
1092 } |
1087 } |
1093 } |
1088 } |
1094 |
1089 |
1095 } |
1090 } |
1096 |
1091 |
1097 /*! |
1092 /*! |
1098 Enables/Disables character preview in Qwerty keypad. Will emit signal characterPreviewStateForQwertyChanged if status is changed. |
1093 Enables/Disables character preview in Qwerty keypad. Will emit signal characterPreviewStateForQwertyChanged if status is changed. |
1099 |
1094 |
1100 \sa characterPreviewForQwerty |
1095 \sa characterPreviewForQwerty |
1101 */ |
1096 */ |
1102 void HbInputSettingProxy::setCharacterPreviewForQwerty(bool previewEnabled) |
1097 void HbInputSettingProxy::setCharacterPreviewForQwerty(bool previewEnabled) |
1103 { |
1098 { |
1104 Q_D(HbInputSettingProxy); |
1099 Q_D(HbInputSettingProxy); |
1105 HbSettingProxyInternalData* prData = d->proxyData(); |
1100 HbSettingProxyInternalData *prData = d->proxyData(); |
1106 if (prData) { |
1101 if (prData) { |
1107 bool notify = false; |
1102 bool notify = false; |
1108 d->lock(); |
1103 d->lock(); |
1109 if (prData->iQwertyCharacterPreview != previewEnabled) { |
1104 if (prData->iQwertyCharacterPreview != previewEnabled) { |
1110 prData->iQwertyCharacterPreview = previewEnabled; |
1105 prData->iQwertyCharacterPreview = previewEnabled; |
1127 { |
1122 { |
1128 Q_D(HbInputSettingProxy); |
1123 Q_D(HbInputSettingProxy); |
1129 |
1124 |
1130 bool res = false; |
1125 bool res = false; |
1131 |
1126 |
1132 HbSettingProxyInternalData* prData = d->proxyData(); |
1127 HbSettingProxyInternalData *prData = d->proxyData(); |
1133 if (prData) { |
1128 if (prData) { |
1134 res = prData->iQwertyCharacterPreview; |
1129 res = prData->iQwertyCharacterPreview; |
1135 } |
1130 } |
1136 |
1131 |
1137 return res; |
1132 return res; |
1138 } |
1133 } |
1139 |
1134 |
1140 /*! |
1135 /*! |
|
1136 \deprecated HbInputSettingProxy::activeCustomInputMethod() const |
|
1137 is deprecated. Use preferredInputMethod instead. |
1141 Returns active custom input method. The pluginNameAndPath field is empty if no custom input methid is active. |
1138 Returns active custom input method. The pluginNameAndPath field is empty if no custom input methid is active. |
1142 |
1139 |
1143 \sa setActiveCustomInputMethod |
1140 \sa setActiveCustomInputMethod |
1144 */ |
1141 */ |
1145 HbInputMethodDescriptor HbInputSettingProxy::activeCustomInputMethod() const |
1142 HbInputMethodDescriptor HbInputSettingProxy::activeCustomInputMethod() const |
1146 { |
1143 { |
1147 return HbInputMethodDescriptor(); |
1144 return HbInputMethodDescriptor(); |
1148 } |
1145 } |
1149 |
1146 |
1150 /*! |
1147 /*! |
|
1148 \deprecated HbInputSettingProxy::setActiveCustomInputMethod(const HbInputMethodDescriptor&) |
|
1149 is deprecated. Use setPreferredInputMethod instead. |
1151 \sa activeCustomInputMethod |
1150 \sa activeCustomInputMethod |
1152 */ |
1151 */ |
1153 void HbInputSettingProxy::setActiveCustomInputMethod(const HbInputMethodDescriptor &inputMethod) |
1152 void HbInputSettingProxy::setActiveCustomInputMethod(const HbInputMethodDescriptor &inputMethod) |
1154 { |
1153 { |
1155 Q_UNUSED(inputMethod) |
1154 Q_UNUSED(inputMethod) |
1156 } |
1155 } |
1157 |
1156 |
1158 /*! |
1157 /*! |
1159 Returns the current screen orientation in settings |
1158 Returns the current screen orientation in settings |
1160 */ |
1159 */ |
1161 Qt::Orientation HbInputSettingProxy::screenOrientation() |
1160 Qt::Orientation HbInputSettingProxy::screenOrientation() |
1162 { |
1161 { |
1163 Q_D(HbInputSettingProxy); |
1162 Q_D(HbInputSettingProxy); |
1164 |
1163 |
1165 Qt::Orientation orientation = Qt::Vertical; |
1164 Qt::Orientation orientation = Qt::Vertical; |
1166 HbSettingProxyInternalData* prData = d->proxyData(); |
1165 HbSettingProxyInternalData *prData = d->proxyData(); |
1167 if (prData) { |
1166 if (prData) { |
1168 orientation = prData->iScreenOrientation; |
1167 orientation = prData->iScreenOrientation; |
1169 } |
1168 } |
1170 return orientation; |
1169 return orientation; |
1171 } |
1170 } |
1172 |
1171 |
1173 /*! |
1172 /*! |
1174 Sets the current screen orientation in settings. This completes orientation change |
1173 Sets the current screen orientation in settings. This completes orientation change |
1175 started with notifyScreenOrientationChange. |
1174 started with notifyScreenOrientationChange. Nothing is done, If |
|
1175 notifyScreenOrientationChange has not been called before calling this. |
1176 */ |
1176 */ |
1177 void HbInputSettingProxy::setScreenOrientation(Qt::Orientation screenOrientation) |
1177 void HbInputSettingProxy::setScreenOrientation(Qt::Orientation screenOrientation) |
1178 { |
1178 { |
1179 Q_D(HbInputSettingProxy); |
1179 Q_D(HbInputSettingProxy); |
1180 |
1180 |
1181 HbSettingProxyInternalData* prData = d->proxyData(); |
1181 HbSettingProxyInternalData *prData = d->proxyData(); |
1182 if (prData) { |
1182 if (prData) { |
1183 bool notify = false; |
1183 d->lock(); |
1184 |
1184 if (prData->iOrientationChangeCompleted) { |
1185 d->lock(); |
|
1186 if (screenOrientation != prData->iScreenOrientation) { |
|
1187 prData->iScreenOrientation = screenOrientation; |
|
1188 notify = true; |
|
1189 } |
|
1190 d->unlock(); |
|
1191 |
|
1192 if (notify) { |
|
1193 // notify everyone that the orientation has changed. |
|
1194 d->handleDeviceSpecificOriantationAndFlipChange(); |
|
1195 emit orientationChanged(screenOrientation); |
|
1196 // set orientation change operation completed. |
|
1197 d->lock(); |
|
1198 prData->iOrientationChangeCompleted = true; |
|
1199 d->unlock(); |
1185 d->unlock(); |
1200 } |
1186 return; |
|
1187 } |
|
1188 prData->iScreenOrientation = screenOrientation; |
|
1189 d->unlock(); |
|
1190 |
|
1191 // notify everyone that the orientation has changed. |
|
1192 d->handleDeviceSpecificOriantationAndFlipChange(); |
|
1193 emit orientationChanged(screenOrientation); |
|
1194 |
|
1195 // set orientation change operation completed. |
|
1196 d->lock(); |
|
1197 prData->iOrientationChangeCompleted = true; |
|
1198 d->unlock(); |
1201 } |
1199 } |
1202 } |
1200 } |
1203 |
1201 |
1204 /*! |
1202 /*! |
1205 Starts screen orientation change sequence. Emits orientationAboutToChange signal |
1203 Starts screen orientation change sequence. Emits orientationAboutToChange signal |
1211 */ |
1209 */ |
1212 void HbInputSettingProxy::notifyScreenOrientationChange() |
1210 void HbInputSettingProxy::notifyScreenOrientationChange() |
1213 { |
1211 { |
1214 Q_D(HbInputSettingProxy); |
1212 Q_D(HbInputSettingProxy); |
1215 |
1213 |
1216 HbSettingProxyInternalData* prData = d->proxyData(); |
1214 HbSettingProxyInternalData *prData = d->proxyData(); |
1217 if (prData) { |
1215 if (prData) { |
1218 d->lock(); |
1216 bool notify = false; |
1219 prData->iOrientationChangeCompleted = false; |
1217 d->lock(); |
1220 d->unlock(); |
1218 if (prData->iOrientationChangeCompleted) { |
1221 } |
1219 prData->iOrientationChangeCompleted = false; |
1222 emit orientationAboutToChange(); |
1220 notify = true; |
|
1221 } |
|
1222 d->unlock(); |
|
1223 if (notify) { |
|
1224 emit orientationAboutToChange(); |
|
1225 } |
|
1226 } |
|
1227 |
1223 } |
1228 } |
1224 |
1229 |
1225 /*! |
1230 /*! |
1226 Returns true if the orientation change is completed |
1231 Returns true if the orientation change is completed |
1227 */ |
1232 */ |
1228 bool HbInputSettingProxy::orientationChangeCompleted() const |
1233 bool HbInputSettingProxy::orientationChangeCompleted() const |
1229 { |
1234 { |
1230 Q_D(const HbInputSettingProxy); |
1235 Q_D(const HbInputSettingProxy); |
1231 |
1236 |
1232 bool completed = true; |
1237 bool completed = true; |
1233 HbSettingProxyInternalData* prData = d->proxyData(); |
1238 HbSettingProxyInternalData *prData = d->proxyData(); |
1234 if (prData) { |
1239 if (prData) { |
1235 completed = prData->iOrientationChangeCompleted; |
1240 completed = prData->iOrientationChangeCompleted; |
1236 } |
1241 } |
1237 return completed; |
1242 return completed; |
1238 } |
1243 } |
1244 void HbInputSettingProxy::initializeOrientation(Qt::Orientation screenOrientation) |
1249 void HbInputSettingProxy::initializeOrientation(Qt::Orientation screenOrientation) |
1245 { |
1250 { |
1246 Q_D(HbInputSettingProxy); |
1251 Q_D(HbInputSettingProxy); |
1247 |
1252 |
1248 // call handleDeviceSpecificOriantationAndFlipChange method |
1253 // call handleDeviceSpecificOriantationAndFlipChange method |
1249 HbSettingProxyInternalData* prData = d->proxyData(); |
1254 HbSettingProxyInternalData *prData = d->proxyData(); |
1250 if (prData) { |
1255 if (prData) { |
1251 d->lock(); |
1256 d->lock(); |
1252 prData->iScreenOrientation = screenOrientation; |
1257 prData->iScreenOrientation = screenOrientation; |
1253 if (screenOrientation == Qt::Vertical) { |
1258 if (screenOrientation == Qt::Vertical) { |
1254 prData->iActiveKeyboard = HbKeyboardVirtual12Key; |
1259 prData->iActiveKeyboard = HbKeyboardVirtual12Key; |
1281 \sa regionalCorrectionEnabled. |
1286 \sa regionalCorrectionEnabled. |
1282 */ |
1287 */ |
1283 void HbInputSettingProxy::enableRegionalCorrection(bool newStatus) |
1288 void HbInputSettingProxy::enableRegionalCorrection(bool newStatus) |
1284 { |
1289 { |
1285 Q_D(HbInputSettingProxy); |
1290 Q_D(HbInputSettingProxy); |
1286 HbSettingProxyInternalData* prData = d->proxyData(); |
1291 HbSettingProxyInternalData *prData = d->proxyData(); |
1287 if (prData) { |
1292 if (prData) { |
1288 bool notify = false; |
1293 bool notify = false; |
1289 d->lock(); |
1294 d->lock(); |
1290 if (prData->iRegionalCorrectionStatus != newStatus) { |
1295 if (prData->iRegionalCorrectionStatus != newStatus) { |
1291 prData->iRegionalCorrectionStatus = newStatus; |
1296 prData->iRegionalCorrectionStatus = newStatus; |
1304 \sa keypressTimeout. |
1309 \sa keypressTimeout. |
1305 */ |
1310 */ |
1306 void HbInputSettingProxy::setKeypressTimeout(int timeout) |
1311 void HbInputSettingProxy::setKeypressTimeout(int timeout) |
1307 { |
1312 { |
1308 Q_D(HbInputSettingProxy); |
1313 Q_D(HbInputSettingProxy); |
1309 HbSettingProxyInternalData* prData = d->proxyData(); |
1314 HbSettingProxyInternalData *prData = d->proxyData(); |
1310 if (prData) { |
1315 if (prData) { |
1311 bool notify = false; |
1316 bool notify = false; |
1312 d->lock(); |
1317 d->lock(); |
1313 if (prData->iKeypressTimeout != timeout) { |
1318 if (prData->iKeypressTimeout != timeout) { |
1314 prData->iKeypressTimeout = timeout; |
1319 prData->iKeypressTimeout = timeout; |
1343 \sa isAutocompletionEnabled. |
1348 \sa isAutocompletionEnabled. |
1344 */ |
1349 */ |
1345 void HbInputSettingProxy::setAutocompletionStatus(HbKeyboardSettingFlags keyboardType, bool state) |
1350 void HbInputSettingProxy::setAutocompletionStatus(HbKeyboardSettingFlags keyboardType, bool state) |
1346 { |
1351 { |
1347 Q_D(HbInputSettingProxy); |
1352 Q_D(HbInputSettingProxy); |
1348 HbSettingProxyInternalData* prData = d->proxyData(); |
1353 HbSettingProxyInternalData *prData = d->proxyData(); |
1349 if (prData) { |
1354 if (prData) { |
1350 bool notify = false; |
1355 bool notify = false; |
1351 d->lock(); |
1356 d->lock(); |
1352 HbKeyboardSettingFlags newValue = prData->iAutocompletion; |
1357 HbKeyboardSettingFlags newValue = prData->iAutocompletion; |
1353 if (state) { |
1358 if (state) { |
1389 \sa typingCorrectionLevel. |
1394 \sa typingCorrectionLevel. |
1390 */ |
1395 */ |
1391 void HbInputSettingProxy::setTypingCorrectionLevel(HbTypingCorrectionLevel level) |
1396 void HbInputSettingProxy::setTypingCorrectionLevel(HbTypingCorrectionLevel level) |
1392 { |
1397 { |
1393 Q_D(HbInputSettingProxy); |
1398 Q_D(HbInputSettingProxy); |
1394 HbSettingProxyInternalData* prData = d->proxyData(); |
1399 HbSettingProxyInternalData *prData = d->proxyData(); |
1395 if (prData) { |
1400 if (prData) { |
1396 bool notify = false; |
1401 bool notify = false; |
1397 d->lock(); |
1402 d->lock(); |
1398 if (prData->iTypingCorrectionLevel != level) { |
1403 if (prData->iTypingCorrectionLevel != level) { |
1399 prData->iTypingCorrectionLevel = level; |
1404 prData->iTypingCorrectionLevel = level; |
1429 \sa primaryCandidateMode. |
1434 \sa primaryCandidateMode. |
1430 */ |
1435 */ |
1431 void HbInputSettingProxy::setPrimaryCandidateMode(HbPrimaryCandidateMode mode) |
1436 void HbInputSettingProxy::setPrimaryCandidateMode(HbPrimaryCandidateMode mode) |
1432 { |
1437 { |
1433 Q_D(HbInputSettingProxy); |
1438 Q_D(HbInputSettingProxy); |
1434 HbSettingProxyInternalData* prData = d->proxyData(); |
1439 HbSettingProxyInternalData *prData = d->proxyData(); |
1435 if (prData) { |
1440 if (prData) { |
1436 bool notify = false; |
1441 bool notify = false; |
1437 d->lock(); |
1442 d->lock(); |
1438 if (prData->iPrimaryCandidateMode != mode) { |
1443 if (prData->iPrimaryCandidateMode != mode) { |
1439 prData->iPrimaryCandidateMode = mode; |
1444 prData->iPrimaryCandidateMode = mode; |