27 //Required Qt headers |
27 //Required Qt headers |
28 #include <QLocale> |
28 #include <QLocale> |
29 //Required Hb headers |
29 //Required Hb headers |
30 #include <hbinputkeymapfactory.h> |
30 #include <hbinputkeymapfactory.h> |
31 #include <hbinputkeymap.h> |
31 #include <hbinputkeymap.h> |
32 #include <hbinput12keytouchkeypad.h> |
|
33 #include <hbinputsettingproxy.h> |
32 #include <hbinputsettingproxy.h> |
34 #include <hbinpututils.h> |
33 #include <hbinpututils.h> |
35 #include <hbinputsctportrait.h> |
34 #include <hbinputsctkeyboard.h> |
36 #include <hbinputeditorinterface.h> |
35 #include <hbinputeditorinterface.h> |
37 #include <hbinputcandidatelist.h> |
36 #include <hbinputcandidatelist.h> |
38 #include <hbinputpredictionfactory.h> |
37 #include <hbinputpredictionfactory.h> |
39 #include <hbinputpredictionengine.h> |
38 #include <hbinputpredictionengine.h> |
|
39 #include <hbinputsettingproxy.h> |
40 #include <hbmainwindow.h> |
40 #include <hbmainwindow.h> |
41 #include <hbaction.h> |
41 #include <hbaction.h> |
42 #include <hbview.h> |
42 #include <hbview.h> |
43 #include <hbinputvkbhost.h> |
43 #include <hbinputvkbhost.h> |
44 #include <hbinputcommondialogs.h> |
44 #include <hbinputcommondialogs.h> |
|
45 #include <hbinputbutton.h> |
45 #include <hbdeviceprofile.h> |
46 #include <hbdeviceprofile.h> |
46 |
47 |
47 //User includes |
48 //User includes |
|
49 #include "hbinput12keytouchkeyboard.h" |
48 #include "hbinputthaispecialpopup.h" |
50 #include "hbinputthaispecialpopup.h" |
49 #include "hbinputbasic12keyhandler.h" |
51 #include "hbinputbasic12keyhandler.h" |
50 #include "hbinputprediction12keyhandler.h" |
52 #include "hbinputprediction12keyhandler.h" |
51 #include "hbinputnumeric12keyhandler.h" |
53 #include "hbinputnumeric12keyhandler.h" |
52 #include "hbinputbasic12keythaihandler.h" |
54 #include "hbinputbasic12keythaihandler.h" |
84 void HbVirtual12Key::initializeModeHandlers() |
85 void HbVirtual12Key::initializeModeHandlers() |
85 { |
86 { |
86 mBasicModeHandler = new HbInputBasic12KeyHandler(this); |
87 mBasicModeHandler = new HbInputBasic12KeyHandler(this); |
87 mPredictionModeHandler = new HbInputPrediction12KeyHandler(this); |
88 mPredictionModeHandler = new HbInputPrediction12KeyHandler(this); |
88 mNumericModeHandler = new HbInputNumeric12KeyHandler(this); |
89 mNumericModeHandler = new HbInputNumeric12KeyHandler(this); |
89 mBasic12keyThaiHandler = new HbInputBasic12KeyThaiHandler(this); |
90 mBasic12keyThaiHandler = new HbInputBasic12KeyThaiHandler(this); |
90 mPrediction12keyThaiHandler = new HbInputPrediction12KeyThaiHandler(this); |
91 mPrediction12keyThaiHandler = new HbInputPrediction12KeyThaiHandler(this); |
91 mActiveModeHandler = mBasicModeHandler; |
92 mActiveModeHandler = mBasicModeHandler; |
92 |
93 |
93 mBasicModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionInit); |
94 mBasicModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionInit); |
94 mPredictionModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionInit); |
95 mPredictionModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionInit); |
95 mNumericModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionInit); |
96 mNumericModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionInit); |
96 mPrediction12keyThaiHandler->actionHandler(HbInputModeHandler::HbInputModeActionInit); |
97 mPrediction12keyThaiHandler->actionHandler(HbInputModeHandler::HbInputModeActionInit); |
97 |
98 |
98 // let's connect prediction mode handler with latin basic mode handler. It is required incase we Qt::key_0 is pressed in prediction mode |
99 // let's connect prediction mode handler with latin basic mode handler. It is required incase we Qt::key_0 is pressed in prediction mode |
99 // key |
100 // key |
100 connect(mPredictionModeHandler, SIGNAL(passFilterEvent(const QKeyEvent *)), mBasicModeHandler, SLOT(filterEvent(const QKeyEvent *))); |
101 connect(mPredictionModeHandler, SIGNAL(passFilterEvent(const QKeyEvent *)), |
101 connect(mPredictionModeHandler, SIGNAL(passActionHandler(HbInputModeAction )), mBasicModeHandler, SLOT(actionHandler(HbInputModeAction ))); |
102 mBasicModeHandler, SLOT(filterEvent(const QKeyEvent *))); |
102 connect(mPrediction12keyThaiHandler, SIGNAL(passFilterEvent(const QKeyEvent *)), mBasicModeHandler, SLOT(filterEvent(const QKeyEvent *))); |
103 connect(mPredictionModeHandler, SIGNAL(passActionHandler(HbInputModeAction )), |
103 connect(mPrediction12keyThaiHandler, SIGNAL(passActionHandler(HbInputModeAction )), mBasicModeHandler, SLOT(actionHandler(HbInputModeAction ))); |
104 mBasicModeHandler, SLOT(actionHandler(HbInputModeAction ))); |
104 |
105 connect(mPrediction12keyThaiHandler, SIGNAL(passFilterEvent(const QKeyEvent *)), |
|
106 mBasicModeHandler, SLOT(filterEvent(const QKeyEvent *))); |
|
107 connect(mPrediction12keyThaiHandler, SIGNAL(passActionHandler(HbInputModeAction )), |
|
108 mBasicModeHandler, SLOT(actionHandler(HbInputModeAction ))); |
|
109 |
|
110 connect(HbInputSettingProxy::instance(), SIGNAL(predictiveInputStateChanged(HbKeyboardSettingFlags,bool)), this, SLOT(predictiveInputStateChanged(HbKeyboardSettingFlags,bool))); |
105 } |
111 } |
106 |
112 |
107 bool HbVirtual12Key::isSctModeActive() const |
113 bool HbVirtual12Key::isSctModeActive() const |
108 { |
114 { |
109 return (mCurrentKeypad == mSctKeypad); |
115 return (mCurrentKeypad == mSctKeypad); |
120 mItutKeypad = 0; |
126 mItutKeypad = 0; |
121 delete mSctKeypad; |
127 delete mSctKeypad; |
122 mSctKeypad = 0; |
128 mSctKeypad = 0; |
123 delete mCandidatePopup; |
129 delete mCandidatePopup; |
124 mCandidatePopup = 0; |
130 mCandidatePopup = 0; |
125 delete mThaiSpecialChar; |
131 delete mThaiSpecialChar; |
126 mThaiSpecialChar = 0; |
132 mThaiSpecialChar = 0; |
127 |
133 |
128 // free mode handlers |
134 // free mode handlers |
129 delete mBasicModeHandler; |
135 delete mBasicModeHandler; |
130 mBasicModeHandler = 0; |
136 mBasicModeHandler = 0; |
131 delete mPredictionModeHandler; |
137 delete mPredictionModeHandler; |
132 mPredictionModeHandler = 0; |
138 mPredictionModeHandler = 0; |
133 delete mNumericModeHandler; |
139 delete mNumericModeHandler; |
134 mNumericModeHandler = 0; |
140 mNumericModeHandler = 0; |
135 delete mBasic12keyThaiHandler; |
141 delete mBasic12keyThaiHandler; |
136 mBasic12keyThaiHandler = 0; |
142 mBasic12keyThaiHandler = 0; |
137 delete mPrediction12keyThaiHandler; |
143 delete mPrediction12keyThaiHandler; |
138 mPrediction12keyThaiHandler = 0; |
144 mPrediction12keyThaiHandler = 0; |
139 } |
145 } |
140 |
146 |
141 /*! |
147 /*! |
142 Implementation of the pure virtual QInputContext::identifierName() |
148 Implementation of the pure virtual QInputContext::identifierName() |
143 Returns a string which specifies an identifier for the input method. |
149 Returns a string which specifies an identifier for the input method. |
177 { |
183 { |
178 mActiveModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionReset); |
184 mActiveModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionReset); |
179 mOrientationAboutToChange = false; |
185 mOrientationAboutToChange = false; |
180 } |
186 } |
181 |
187 |
182 /*! |
188 Hb12KeyTouchKeyboard *HbVirtual12Key::construct12Keyboard() |
183 Construct 12key touchkeypad and make the necessary connections. |
189 { |
184 */ |
190 Hb12KeyTouchKeyboard *tempKeypad = new Hb12KeyTouchKeyboard(this, mKeymap); |
185 Hb12KeyTouchKeypad * HbVirtual12Key::construct12Keypad() |
191 connect(tempKeypad, SIGNAL(keypadCloseEventDetected(HbInputVkbWidget::HbVkbCloseMethod)), |
186 { |
192 this, SLOT(keypadCloseEventDetected(HbInputVkbWidget::HbVkbCloseMethod))); |
187 Hb12KeyTouchKeypad * tempKeypad = 0; |
|
188 tempKeypad = new Hb12KeyTouchKeypad(this, 0); |
|
189 connect(tempKeypad, SIGNAL(keypadCloseEventDetected(HbInputVkbWidget::HbVkbCloseMethod)), this, SLOT(keypadCloseEventDetected(HbInputVkbWidget::HbVkbCloseMethod))); |
|
190 connect(tempKeypad, SIGNAL(rockerDirection(int, HbInputVirtualRocker::RockerSelectionMode)), |
193 connect(tempKeypad, SIGNAL(rockerDirection(int, HbInputVirtualRocker::RockerSelectionMode)), |
191 this, SLOT(rockerDirection(int, HbInputVirtualRocker::RockerSelectionMode))); |
194 this, SLOT(rockerDirection(int, HbInputVirtualRocker::RockerSelectionMode))); |
192 //FLICKDISABLED connect(tempKeypad, SIGNAL(flickEvent(HbInputVkbWidget::FlickDirection)), this, SLOT(flickEvent(HbInputVkbWidget::FlickDirection))); |
195 //FLICKDISABLED connect(tempKeypad, SIGNAL(flickEvent(HbInputVkbWidget::FlickDirection)), this, SLOT(flickEvent(HbInputVkbWidget::FlickDirection))); |
193 connect(tempKeypad, SIGNAL(smileySelected(QString)), this, SLOT(smileySelected(QString))); |
196 connect(tempKeypad, SIGNAL(smileySelected(QString)), this, SLOT(smileySelected(QString))); |
194 connect(tempKeypad, SIGNAL(mouseMovedOutOfButton()), this, SLOT(mouseMovedOutOfButton())); |
197 connect(tempKeypad, SIGNAL(mouseMovedOutOfButton()), this, SLOT(mouseMovedOutOfButton())); |
195 connect(tempKeypad, SIGNAL(chrSelected(QString)), this, SLOT(thaiSctCharacterSelected(QString))); |
198 connect(tempKeypad, SIGNAL(chrSelected(QString)), this, SLOT(thaiSctCharacterSelected(QString))); |
196 tempKeypad->setRockerVisible(true); |
199 tempKeypad->setRockerVisible(true); |
197 return tempKeypad; |
200 return tempKeypad; |
198 } |
201 } |
199 |
202 |
200 /*! |
203 /*! |
205 table as it needs to be based on the focused editor. It also opens the virtual keypad |
208 table as it needs to be based on the focused editor. It also opens the virtual keypad |
206 and stops the timer which is used for multi tapping and detecting long key press events. |
209 and stops the timer which is used for multi tapping and detecting long key press events. |
207 */ |
210 */ |
208 void HbVirtual12Key::focusReceived() |
211 void HbVirtual12Key::focusReceived() |
209 { |
212 { |
|
213 /* Update the text case */ |
|
214 updateState(); |
210 // load the new keymappings to all keypads and all mode handlers |
215 // load the new keymappings to all keypads and all mode handlers |
211 loadKeymap(inputState().language()); |
216 loadKeymap(inputState().language()); |
212 // After loadKeyMapData call, mKeyData should have keymappings data of the current language |
217 // After loadKeyMapData call, mKeyData should have keymappings data of the current language |
213 if(!mKeymap) { |
218 if(!mKeymap) { |
214 return; // could not get keymappings. Does not make sense to continue |
219 return; // could not get keymappings. Does not make sense to continue |
236 if (mCandidatePopup) { |
240 if (mCandidatePopup) { |
237 mCandidatePopup->hide(); |
241 mCandidatePopup->hide(); |
238 } |
242 } |
239 } |
243 } |
240 |
244 |
241 // We need to check if this focusRecieved call is due to a orientation |
245 openKeypad(mItutKeypad); |
242 // switch. If yes we should get the keypad status prior to the orientation |
|
243 // switch and open the keypad in that state only. |
|
244 // For example we have minimized the keypad in Qwerty mode and change the |
|
245 // orientation to portrait then in Itu-T mode also keypad should be in minimized state. |
|
246 if (orientationContextSwitchInProgress()) { |
|
247 HbVkbHost *host = focusObject()->editorInterface().vkbHost(); |
|
248 if (host) { |
|
249 // We can get the keypad status prior to the orientation switch from vkbHost it self. |
|
250 HbVkbHost::HbVkbStatus vkbStatus = host->keypadStatusBeforeOrientationChange(); |
|
251 if (vkbStatus != HbVkbHost::HbVkbStatusClosed) { |
|
252 openKeypad(mItutKeypad,vkbStatus == HbVkbHost::HbVkbStatusMinimized); |
|
253 } |
|
254 } |
|
255 } else { |
|
256 openKeypad(mItutKeypad); |
|
257 } |
|
258 |
246 |
259 if (focusObject() && mVkbHost) { |
247 if (focusObject() && mVkbHost) { |
260 connect(&(focusObject()->editorInterface()), SIGNAL(cursorPositionChanged(int, int)), mVkbHost, SLOT(ensureCursorVisibility())); |
248 connect(&(focusObject()->editorInterface()), SIGNAL(cursorPositionChanged(int, int)), |
|
249 mVkbHost, SLOT(ensureCursorVisibility())); |
261 } |
250 } |
262 |
251 |
263 if (focusObject()) { |
252 if (focusObject()) { |
264 disconnect(&(focusObject()->editorInterface()), SIGNAL(cursorPositionChanged(int, int)), mActiveModeHandler, SLOT(cursorPositionChanged(int, int))); |
253 disconnect(&(focusObject()->editorInterface()), SIGNAL(cursorPositionChanged(int, int)), |
265 connect(&(focusObject()->editorInterface()), SIGNAL(cursorPositionChanged(int, int)), mActiveModeHandler, SLOT(cursorPositionChanged(int, int))); |
254 mActiveModeHandler, SLOT(cursorPositionChanged(int, int))); |
|
255 connect(&(focusObject()->editorInterface()), SIGNAL(cursorPositionChanged(int, int)), |
|
256 mActiveModeHandler, SLOT(cursorPositionChanged(int, int))); |
266 } |
257 } |
267 } |
258 } |
268 |
259 |
269 /*! |
260 /*! |
270 \reimp |
261 \reimp |
273 { |
264 { |
274 // inform the active mode handler about the focus lost event. |
265 // inform the active mode handler about the focus lost event. |
275 mActiveModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionFocusLost); |
266 mActiveModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionFocusLost); |
276 |
267 |
277 if (focusObject()) { |
268 if (focusObject()) { |
278 disconnect(&(focusObject()->editorInterface()), SIGNAL(cursorPositionChanged(int, int)), mActiveModeHandler, SLOT(cursorPositionChanged(int, int))); |
269 disconnect(&(focusObject()->editorInterface()), SIGNAL(cursorPositionChanged(int, int)), |
|
270 mActiveModeHandler, SLOT(cursorPositionChanged(int, int))); |
279 } |
271 } |
280 |
272 |
281 if (!focusSwitch && mVkbHost && mVkbHost->keypadStatus() != HbVkbHost::HbVkbStatusClosed) { |
273 if (!focusSwitch && mVkbHost && mVkbHost->keypadStatus() != HbVkbHost::HbVkbStatusClosed) { |
282 // Context switch has happened but the keypad is still open. |
274 // Context switch has happened but the keypad is still open. |
283 // Close it. First notify handler by sending an event and give it changes to |
275 // Close it. First notify handler by sending an event and give it changes to |
346 if (inMinimizedMode) { |
338 if (inMinimizedMode) { |
347 mVkbHost->openMinimizedKeypad(mCurrentKeypad, this); |
339 mVkbHost->openMinimizedKeypad(mCurrentKeypad, this); |
348 } else { |
340 } else { |
349 mVkbHost->openKeypad(mCurrentKeypad, this, (!stateChangeInProgress() && !wasKeypadOpen)); |
341 mVkbHost->openKeypad(mCurrentKeypad, this, (!stateChangeInProgress() && !wasKeypadOpen)); |
350 } |
342 } |
351 connect(&(focusObject()->editorInterface()), SIGNAL(cursorPositionChanged(int, int)), mVkbHost, SLOT(ensureCursorVisibility())); |
343 connect(&(focusObject()->editorInterface()), SIGNAL(cursorPositionChanged(int, int)), |
|
344 mVkbHost, SLOT(ensureCursorVisibility())); |
352 } |
345 } |
353 } |
346 } |
354 |
347 |
355 /*! |
348 /*! |
356 The mouse event handler for the input method. Launches the candidate list if the mouse is clicked on the |
349 The mouse event handler for the input method. Launches the candidate list if the mouse is clicked on the |
357 pre-editing text. |
350 pre-editing text. |
358 */ |
351 */ |
359 void HbVirtual12Key::mouseHandler(int cursorPosition, QMouseEvent* mouseEvent) |
352 void HbVirtual12Key::mouseHandler(int cursorPosition, QMouseEvent* mouseEvent) |
360 { |
353 { |
361 mActiveModeHandler->mouseHandler(cursorPosition, mouseEvent); |
354 mActiveModeHandler->mouseHandler(cursorPosition, mouseEvent); |
362 } |
|
363 |
|
364 /*! |
|
365 \deprecated HbVirtual12Key::predictiveInputStatusChanged(int newStatus) |
|
366 is deprecated. Use predictiveInputStateChanged instead. |
|
367 */ |
|
368 void HbVirtual12Key::predictiveInputStatusChanged(int newStatus) |
|
369 { |
|
370 predictiveInputStateChanged(HbKeyboardSetting12key, newStatus); |
|
371 } |
355 } |
372 |
356 |
373 /*! |
357 /*! |
374 The framework calls this method when the predictive input status changes. |
358 The framework calls this method when the predictive input status changes. |
375 */ |
359 */ |
438 |
422 |
439 HbInputLanguage inputlang = HbInputSettingProxy::instance()->globalInputLanguage(); |
423 HbInputLanguage inputlang = HbInputSettingProxy::instance()->globalInputLanguage(); |
440 |
424 |
441 switch (aDirection) { |
425 switch (aDirection) { |
442 case HbInputVirtualRocker::HbRockerDirectionLeft: |
426 case HbInputVirtualRocker::HbRockerDirectionLeft: |
443 if(inputlang.isRightToLeftLanguage()) { |
427 if (inputlang.isRightToLeftLanguage()) { |
444 focusObject()->cursorRight(modifiers); |
428 focusObject()->cursorRight(modifiers); |
445 } else { |
429 } else { |
446 focusObject()->cursorLeft(modifiers); |
430 focusObject()->cursorLeft(modifiers); |
447 } |
431 } |
448 break; |
432 break; |
449 case HbInputVirtualRocker::HbRockerDirectionRight: |
433 case HbInputVirtualRocker::HbRockerDirectionRight: |
450 if(inputlang.isRightToLeftLanguage()) { |
434 if (inputlang.isRightToLeftLanguage()) { |
451 focusObject()->cursorLeft(modifiers); |
435 focusObject()->cursorLeft(modifiers); |
452 } else { |
436 } else { |
453 focusObject()->cursorRight(modifiers); |
437 focusObject()->cursorRight(modifiers); |
454 } |
438 } |
455 break; |
439 break; |
475 void HbVirtual12Key::inputLanguageChanged(const HbInputLanguage &newLanguage) |
459 void HbVirtual12Key::inputLanguageChanged(const HbInputLanguage &newLanguage) |
476 { |
460 { |
477 // inform all the mode handler about the language change. |
461 // inform all the mode handler about the language change. |
478 mPredictionModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionCommit); |
462 mPredictionModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionCommit); |
479 // move keypad off screen |
463 // move keypad off screen |
480 if (mCurrentKeypad){ |
464 if (mCurrentKeypad) { |
481 mCurrentKeypad->keypadLanguageChangeAnimationUpdate(0); |
465 mCurrentKeypad->keypadLanguageChangeAnimationUpdate(0); |
482 } |
466 } |
483 loadKeymap(newLanguage); |
467 loadKeymap(newLanguage); |
484 // inform all the mode handler about the language change. |
468 // inform all the mode handler about the language change. |
485 mPredictionModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionPrimaryLanguageChanged); |
469 mPredictionModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionPrimaryLanguageChanged); |
486 if (mCurrentKeypad){ |
470 if (mCurrentKeypad) { |
487 mCurrentKeypad->animKeyboardChange(); |
471 mCurrentKeypad->animKeyboardChange(); |
488 } |
472 } |
489 } |
473 } |
490 |
474 |
491 /*! |
475 /*! |
528 } |
511 } |
529 } |
512 } |
530 } |
513 } |
531 |
514 |
532 HbInputModeHandler *previousModeHandler = mActiveModeHandler; |
515 HbInputModeHandler *previousModeHandler = mActiveModeHandler; |
533 if(HbInputSettingProxy::instance()->globalInputLanguage() == QLocale::Thai && usePrediction() && newState.inputMode() != HbInputModeNumeric ) { |
516 if (HbInputSettingProxy::instance()->globalInputLanguage() == QLocale::Thai && |
534 mActiveModeHandler = mPrediction12keyThaiHandler; |
517 usePrediction() && newState.inputMode() != HbInputModeNumeric) { |
535 // by passing HbInputModeActionFocusRecieved we will be setting the candidate list and keypad |
518 mActiveModeHandler = mPrediction12keyThaiHandler; |
|
519 // by passing HbInputModeActionFocusRecieved we will be setting the candidate list and keypad |
536 mActiveModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionFocusRecieved); |
520 mActiveModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionFocusRecieved); |
537 } else if (HbInputSettingProxy::instance()->globalInputLanguage() == QLocale::Thai && !usePrediction() && newState.inputMode() != HbInputModeNumeric |
521 } else if (HbInputSettingProxy::instance()->globalInputLanguage() == QLocale::Thai && |
538 && ((HbEditorConstraintLatinAlphabetOnly | HbEditorConstraintAutoCompletingField)!=focusObject()->editorInterface().constraints())) { |
522 !usePrediction() && newState.inputMode() != HbInputModeNumeric && |
539 mActiveModeHandler = mBasic12keyThaiHandler; |
523 ((HbEditorConstraintLatinAlphabetOnly | HbEditorConstraintAutoCompletingField)!=focusObject()->editorInterface().inputConstraints())) { |
540 // by passing HbInputModeActionFocusRecieved we will be setting the candidate list and keypad |
524 mActiveModeHandler = mBasic12keyThaiHandler; |
|
525 // by passing HbInputModeActionFocusRecieved we will be setting the candidate list and keypad |
541 mActiveModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionFocusRecieved); |
526 mActiveModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionFocusRecieved); |
542 } else if (newState.inputMode() == HbInputModeDefault && usePrediction()) { |
527 } else if (newState.inputMode() == HbInputModeDefault && usePrediction()) { |
543 mActiveModeHandler = mPredictionModeHandler; |
528 mActiveModeHandler = mPredictionModeHandler; |
544 // by passing HbInputModeActionFocusRecieved we will be setting the candidate list and keypad |
529 // by passing HbInputModeActionFocusRecieved we will be setting the candidate list and keypad |
545 mActiveModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionFocusRecieved); |
530 mActiveModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionFocusRecieved); |
546 } else if (newState.inputMode() == HbInputModeDefault) { |
531 } else if (newState.inputMode() == HbInputModeDefault) { |
547 mActiveModeHandler = mBasicModeHandler; |
532 mActiveModeHandler = mBasicModeHandler; |
550 } else if (newState.inputMode() == HbInputModeNumeric) { |
535 } else if (newState.inputMode() == HbInputModeNumeric) { |
551 mActiveModeHandler = mNumericModeHandler; |
536 mActiveModeHandler = mNumericModeHandler; |
552 } |
537 } |
553 |
538 |
554 if (focusObject()) { |
539 if (focusObject()) { |
555 disconnect(&(focusObject()->editorInterface()), SIGNAL(cursorPositionChanged(int, int)), previousModeHandler, SLOT(cursorPositionChanged(int, int))); |
540 disconnect(&(focusObject()->editorInterface()), SIGNAL(cursorPositionChanged(int, int)), |
556 connect(&(focusObject()->editorInterface()), SIGNAL(cursorPositionChanged(int, int)), mActiveModeHandler, SLOT(cursorPositionChanged(int, int))); |
541 previousModeHandler, SLOT(cursorPositionChanged(int, int))); |
|
542 connect(&(focusObject()->editorInterface()), SIGNAL(cursorPositionChanged(int, int)), |
|
543 mActiveModeHandler, SLOT(cursorPositionChanged(int, int))); |
557 } |
544 } |
558 |
545 |
559 // load the new keymappings to all keypads and all mode handlers |
546 // load the new keymappings to all keypads and all mode handlers |
560 loadKeymap(newState.language()); |
547 loadKeymap(newState.language()); |
561 |
548 |
562 // if there is a change in the modehandler we need send a commit in previous mode handler. |
549 // if there is a change in the modehandler we need send a commit in previous mode handler. |
563 if (previousModeHandler != mActiveModeHandler) { |
550 if (previousModeHandler != mActiveModeHandler) { |
564 // Auto Completion part needs to be committed as well on mode change. |
551 // Auto Completion part needs to be committed as well on mode change. |
565 |
552 |
566 previousModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionCommit); |
553 previousModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionCommit); |
567 if (mActiveModeHandler == mPredictionModeHandler || mActiveModeHandler == mPrediction12keyThaiHandler) { |
554 if (mActiveModeHandler == mPredictionModeHandler || |
|
555 mActiveModeHandler == mPrediction12keyThaiHandler) { |
568 // lets set candidate list and keypad type to the engine. |
556 // lets set candidate list and keypad type to the engine. |
569 mActiveModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionSetCandidateList); |
557 mActiveModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionSetCandidateList); |
570 mActiveModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionSetKeypad); |
558 mActiveModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionSetKeypad); |
571 } |
559 } |
572 } |
560 } |
578 keymappings,loads them to all avaialble keyboards and to all mode handlers |
566 keymappings,loads them to all avaialble keyboards and to all mode handlers |
579 */ |
567 */ |
580 void HbVirtual12Key::loadKeymap(const HbInputLanguage &newLanguage) |
568 void HbVirtual12Key::loadKeymap(const HbInputLanguage &newLanguage) |
581 { |
569 { |
582 //dont try to get the keymappings if we ( mKeyData) already have keymappings for newLanguage |
570 //dont try to get the keymappings if we ( mKeyData) already have keymappings for newLanguage |
583 if(!mKeymap || mKeymap->language().language() != newLanguage.language()){ |
571 if (!mKeymap || mKeymap->language().language() != newLanguage.language()) { |
584 const HbKeymap* keymap = HbKeymapFactory::instance()->keymap(newLanguage); |
572 const HbKeymap* keymap = HbKeymapFactory::instance()->keymap(newLanguage); |
585 if(keymap){ |
573 if(keymap) { |
586 mKeymap = keymap; |
574 mKeymap = keymap; |
587 if(mItutKeypad) { |
575 if (mItutKeypad) { |
588 mItutKeypad->setKeymap(mKeymap); |
576 mItutKeypad->setKeymap(mKeymap); |
589 } |
577 } |
590 if(mSctKeypad) { |
578 if (mSctKeypad) { |
591 mSctKeypad->setKeymap(mKeymap); |
579 mSctKeypad->setKeymap(mKeymap); |
592 } |
580 } |
593 |
581 |
594 // inform mode handlers about the language change. |
582 // inform mode handlers about the language change. |
595 if(mBasicModeHandler) { |
583 if (mBasicModeHandler) { |
596 mBasicModeHandler->setKeymap(mKeymap); |
584 mBasicModeHandler->setKeymap(mKeymap); |
597 } |
585 } |
598 if(mPredictionModeHandler) { |
586 if (mPredictionModeHandler) { |
599 mPredictionModeHandler->setKeymap(mKeymap); |
587 mPredictionModeHandler->setKeymap(mKeymap); |
600 } |
588 } |
601 if(mNumericModeHandler) { |
589 if (mNumericModeHandler) { |
602 mNumericModeHandler->setKeymap(mKeymap); |
590 mNumericModeHandler->setKeymap(mKeymap); |
603 } |
591 } |
604 if(mBasic12keyThaiHandler) { |
592 if (mBasic12keyThaiHandler) { |
605 mBasic12keyThaiHandler->setKeymap(mKeymap); |
593 mBasic12keyThaiHandler->setKeymap(mKeymap); |
606 } |
594 } |
607 if (mPrediction12keyThaiHandler) { |
595 if (mPrediction12keyThaiHandler) { |
608 mPrediction12keyThaiHandler->setKeymap(mKeymap); |
596 mPrediction12keyThaiHandler->setKeymap(mKeymap); |
609 } |
597 } |
610 } |
598 } |
611 } |
599 } |
612 } |
600 } |
613 |
601 |
614 /*! |
602 /*! |
620 switchToAlphaMode(); |
608 switchToAlphaMode(); |
621 } else { |
609 } else { |
622 // launch Candidate List |
610 // launch Candidate List |
623 bool ret = mPredictionModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionLaunchCandidatePopup); |
611 bool ret = mPredictionModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionLaunchCandidatePopup); |
624 // In case when candidate list is not launched i.e. when the word is not in inlline editing state, launch SCT |
612 // In case when candidate list is not launched i.e. when the word is not in inlline editing state, launch SCT |
625 if (!ret){ |
613 if (!ret) { |
626 mSctMode = HbInputVkbWidget::HbSctViewSpecialCharacter; |
|
627 displaySpecialCharacterTable(this); |
614 displaySpecialCharacterTable(this); |
628 } |
615 } |
629 } |
616 } |
630 } |
617 } |
631 |
618 |
|
619 HbKeyboardType HbVirtual12Key::currentKeyboardType() const |
|
620 { |
|
621 HbKeyboardType type = HbKeyboardNone; |
|
622 if (mCurrentKeypad) { |
|
623 type = mCurrentKeypad->keyboardType(); |
|
624 } |
|
625 return type; |
|
626 } |
|
627 |
632 /*! |
628 /*! |
633 this slot is called by the mode handlers when there is sym key or long press of Asterisk key. |
629 this slot is called by the mode handlers when there is sym key or long press of Asterisk key. |
634 */ |
630 */ |
635 void HbVirtual12Key::switchMode(int keyCode) |
631 void HbVirtual12Key::switchMode(int keyCode) |
636 { |
632 { |
637 if (keyCode == Qt::Key_Asterisk || keyCode == Qt::Key_Control){ |
633 if (keyCode == HbInputButton::ButtonKeyCodeAsterisk || |
|
634 keyCode == HbInputButton::ButtonKeyCodeSymbol || |
|
635 keyCode == HbInputButton::ButtonKeyCodeAlphabet) { |
638 if (mCandidatePopup && mCandidatePopup->isVisible()) { |
636 if (mCandidatePopup && mCandidatePopup->isVisible()) { |
639 return; |
637 return; |
640 } |
638 } |
641 |
639 |
642 if (mCurrentKeypad == mSctKeypad){ |
640 if (mCurrentKeypad == mSctKeypad){ |
643 // if sct is active keypad, then launch itu-t keypad |
641 // if sct is active keypad, then launch itu-t keypad |
644 switchToAlphaMode(); |
642 switchToAlphaMode(); |
645 } else { |
643 } else { |
646 // launch special character keypad |
644 // launch special character keypad |
647 mSctMode = HbInputVkbWidget::HbSctViewSpecialCharacter; |
|
648 displaySpecialCharacterTable(this); |
645 displaySpecialCharacterTable(this); |
649 } |
646 } |
650 } else if ( keyCode == Qt::Key_Shift) { |
647 } else if (keyCode == HbInputButton::ButtonKeyCodeShift) { |
651 HbInputState nextState = inputState(); |
648 HbInputState nextState = inputState(); |
652 if (nextState.inputMode() != HbInputModeNumeric ) { |
649 if (nextState.inputMode() != HbInputModeNumeric) { |
653 nextState.setInputMode( HbInputModeNumeric ); |
650 nextState.setInputMode(HbInputModeNumeric); |
654 } else { |
651 } else { |
655 editorRootState(nextState); |
652 editorRootState(nextState); |
656 } |
653 } |
657 activateState(nextState); |
654 activateState(nextState); |
658 switchToAlphaMode(); |
655 switchToAlphaMode(); |
661 /*! |
658 /*! |
662 Returns previous character from editor |
659 Returns previous character from editor |
663 */ |
660 */ |
664 uint HbVirtual12Key::previousChar() |
661 uint HbVirtual12Key::previousChar() |
665 { |
662 { |
666 if(focusObject()) { |
663 if (focusObject()) { |
667 int cursorPosition = focusObject()->editorCursorPosition(); |
664 int cursorPosition = focusObject()->editorCursorPosition(); |
668 if(cursorPosition) { |
665 if (cursorPosition) { |
669 QString editorText = focusObject()->editorSurroundingText(); |
666 QString editorText = focusObject()->editorSurroundingText(); |
670 return((editorText.at(cursorPosition-1)).unicode()); |
667 return((editorText.at(cursorPosition-1)).unicode()); |
671 } |
668 } |
672 } |
669 } |
673 return 0; |
670 return 0; |
674 } |
671 } |
675 /*! |
672 /*! |
676 Shows the Thai specific special characters |
673 Shows the Thai specific special characters |
677 */ |
674 */ |
678 void HbVirtual12Key::showThaiSpecialCharacters(uint buttonId) |
675 void HbVirtual12Key::showThaiSpecialCharacters(uint buttonId) |
679 { |
676 { |
680 uint prevChar = previousChar(); |
677 uint prevChar = previousChar(); |
681 int screenWidth = 0; |
678 int screenWidth = 0; |
682 int screenHeight = 0; |
679 int screenHeight = 0; |
683 //Get the sceen size from device profile |
680 //Get the sceen size from device profile |
684 if(mCurrentKeypad) { |
681 if (mCurrentKeypad) { |
685 screenWidth = HbDeviceProfile::profile(mCurrentKeypad).logicalSize().width(); |
682 screenWidth = HbDeviceProfile::profile(mCurrentKeypad).logicalSize().width(); |
686 screenHeight = HbDeviceProfile::profile(mCurrentKeypad).logicalSize().height(); |
683 screenHeight = HbDeviceProfile::profile(mCurrentKeypad).logicalSize().height(); |
687 } |
684 } |
688 //Create Thai special popup if not created |
685 //Create Thai special popup if not created |
689 if(!mThaiSpecialChar) { |
686 if( !mThaiSpecialChar) { |
690 mThaiSpecialChar = new HbInputThaiSpecialPopup(buttonId,prevChar,0); |
687 mThaiSpecialChar = new HbInputThaiSpecialPopup(buttonId,prevChar,0); |
691 connect(mThaiSpecialChar, SIGNAL(chrSelected(QString)), this, SLOT(thaiSctCharacterSelected(QString))); |
688 connect(mThaiSpecialChar, SIGNAL(chrSelected(QString)), |
692 } |
689 this, SLOT(thaiSctCharacterSelected(QString))); |
693 //Set Geometry and Layout for popup |
690 } |
694 if (mThaiSpecialChar) { |
691 //Set Geometry and Layout for popup |
695 mThaiSpecialChar->setGeometry(QRectF(0,screenHeight/2,screenWidth,screenHeight/2)); |
692 if (mThaiSpecialChar) { |
696 mThaiSpecialChar->setPopupLayout(mKeymap,prevChar,buttonId,screenWidth,screenHeight/2); |
693 mThaiSpecialChar->setGeometry(QRectF(0,screenHeight/2,screenWidth,screenHeight/2)); |
697 mThaiSpecialChar->show(); |
694 mThaiSpecialChar->setPopupLayout(mKeymap,prevChar,buttonId,screenWidth,screenHeight/2); |
698 } |
695 mThaiSpecialChar->show(); |
|
696 } |
699 } |
697 } |
700 |
698 |
701 /*! |
699 /*! |
702 Shows the special character table. Re-implements the same method from HbInputMethod. |
700 Shows the special character table. Re-implements the same method from HbInputMethod. |
703 */ |
701 */ |
704 int HbVirtual12Key::displaySpecialCharacterTable(QObject* receiver) |
702 int HbVirtual12Key::displaySpecialCharacterTable(QObject* receiver) |
705 { |
703 { |
706 Q_UNUSED(receiver); |
704 Q_UNUSED(receiver); |
707 |
705 |
708 if(!mSctKeypad) { |
706 if (!mSctKeypad) { |
709 mSctKeypad = new HbInputSctPortrait(this,mKeymap,0); |
707 mSctKeypad = new HbSctKeyboard(this, mKeymap, 0); |
710 connect(mSctKeypad, SIGNAL(keypadCloseEventDetected(HbInputVkbWidget::HbVkbCloseMethod)), this, SLOT(keypadCloseEventDetected(HbInputVkbWidget::HbVkbCloseMethod))); |
708 connect(mSctKeypad, SIGNAL(keypadCloseEventDetected(HbInputVkbWidget::HbVkbCloseMethod)), |
711 connect(mSctKeypad, SIGNAL(sctCharacterSelected(QString)), this, SLOT(sctCharacterSelected(QString))); |
709 this, SLOT(keypadCloseEventDetected(HbInputVkbWidget::HbVkbCloseMethod))); |
712 connect(mSctKeypad, SIGNAL(smileySelected(QString)), this, SLOT(smileySelected(QString))); |
710 connect(mSctKeypad, SIGNAL(smileySelected(QString)), |
|
711 this, SLOT(smileySelected(QString))); |
713 mSctKeypad->setRockerVisible(false); |
712 mSctKeypad->setRockerVisible(false); |
714 } |
713 } |
715 |
714 mSctKeypad->setMode(EModeAbc, HbModifierNone); |
716 mSctKeypad->setSct(mSctMode); |
|
717 //Open the keypad |
715 //Open the keypad |
718 openKeypad(mSctKeypad); |
716 openKeypad(mSctKeypad); |
719 |
717 |
720 return 0; |
718 return 0; |
721 } |
719 } |
750 */ |
748 */ |
751 void HbVirtual12Key::launchCandidatePopup(const QStringList& candidates) |
749 void HbVirtual12Key::launchCandidatePopup(const QStringList& candidates) |
752 { |
750 { |
753 if (!mCandidatePopup) { |
751 if (!mCandidatePopup) { |
754 mCandidatePopup = new HbCandidateList(this); |
752 mCandidatePopup = new HbCandidateList(this); |
|
753 connect(mCandidatePopup, SIGNAL(candidateSelected(int,QString)), this, SLOT(candidatePopupClosed(int,QString))); |
755 } |
754 } |
756 mCandidatePopup->populateList(candidates); |
755 mCandidatePopup->populateList(candidates); |
757 mCandidatePopup->setModal(true); |
756 mCandidatePopup->setModal(true); |
758 |
757 |
759 QSizeF candListSize = mCandidatePopup->size(); |
758 QSizeF candListSize = mCandidatePopup->size(); |
760 QPointF candListPos = mCandidatePopup->pos(); |
759 QPointF candListPos = mCandidatePopup->pos(); |
761 getCandidatePositionAndSize(mCandidatePopup, mCurrentKeypad, candListPos,candListSize); |
760 getCandidatePositionAndSize(mCandidatePopup, mCurrentKeypad, candListPos, candListSize); |
762 |
761 |
763 QRectF geom = mCandidatePopup->geometry(); |
762 QRectF geom = mCandidatePopup->geometry(); |
764 geom.setHeight(candListSize.height()); |
763 geom.setHeight(candListSize.height()); |
765 geom.setWidth(candListSize.width()); |
764 geom.setWidth(candListSize.width()); |
766 mCandidatePopup->setGeometry(geom); |
765 mCandidatePopup->setGeometry(geom); |
799 { |
795 { |
800 Q_UNUSED(newLanguage); |
796 Q_UNUSED(newLanguage); |
801 mPredictionModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionSecondaryLanguageChanged); |
797 mPredictionModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionSecondaryLanguageChanged); |
802 } |
798 } |
803 |
799 |
804 /*! |
800 void HbVirtual12Key::smileySelected(QString smiley) |
805 this slot is called by sct when a character is selected from sct. |
801 { |
806 */ |
802 mActiveModeHandler->smileySelected(smiley); |
807 void HbVirtual12Key::sctCharacterSelected(QString character) |
803 } |
808 { |
804 |
809 mActiveModeHandler->sctCharacterSelected(character); |
805 void HbVirtual12Key::thaiSctCharacterSelected(QString sctChar) |
|
806 { |
|
807 mActiveModeHandler->sctCharacterSelected(sctChar); |
810 /* Update the text case */ |
808 /* Update the text case */ |
811 updateState(); |
809 updateState(); |
812 } |
810 } |
813 |
811 |
814 void HbVirtual12Key::smileySelected(QString smiley) |
|
815 { |
|
816 mActiveModeHandler->smileySelected(smiley); |
|
817 } |
|
818 |
|
819 void HbVirtual12Key::thaiSctCharacterSelected(QString sctChar) |
|
820 { |
|
821 mActiveModeHandler->sctCharacterSelected(sctChar); |
|
822 } |
|
823 |
|
824 |
812 |
825 void HbVirtual12Key::selectSpecialCharacterTableMode() |
813 void HbVirtual12Key::selectSpecialCharacterTableMode() |
826 { |
814 { |
827 if (mItutKeypad) { |
815 if (mItutKeypad) { |
828 mItutKeypad->showSmileyPicker(HbSmileyNumberOfRows, HbSmileyNumberOfColumns); |
816 mItutKeypad->showSmileyPicker(HbSmileyNumberOfRows, HbSmileyNumberOfColumns); |
875 */ |
864 */ |
876 bool HbVirtual12Key::usePrediction() const |
865 bool HbVirtual12Key::usePrediction() const |
877 { |
866 { |
878 HbInputFocusObject *fo = focusObject(); |
867 HbInputFocusObject *fo = focusObject(); |
879 if (HbInputSettingProxy::instance()->predictiveInputStatus(HbKeyboardSetting12key) && |
868 if (HbInputSettingProxy::instance()->predictiveInputStatus(HbKeyboardSetting12key) && |
880 fo && |
869 fo && fo->editorInterface().isPredictionAllowed() && |
881 fo->editorInterface().isPredictionAllowed() && |
|
882 mPredictionModeHandler->isActive() && |
870 mPredictionModeHandler->isActive() && |
883 HbPredictionFactory::instance()->predictionEngineForLanguage(inputState().language())) { |
871 HbPredictionFactory::instance()->predictionEngineForLanguage(inputState().language())) { |
884 return true; |
872 return true; |
885 } |
873 } |
886 |
874 |
887 return false; |
875 return false; |
888 } |
876 } |
889 |
877 |
890 /*! |
878 /*! |
891 This function returns true if the latest mouse release was part of a horizontal flick event |
879 This function returns true if the latest mouse release was part of a horizontal flick event |
892 */ |
880 */ |
893 HbInputVkbWidget::HbFlickDirection HbVirtual12Key::flickDirection() const |
881 HbInputVkbWidget::HbFlickDirection HbVirtual12Key::flickDirection() const |
894 { |
882 { |
895 if ( mCurrentKeypad ) { |
883 if (mCurrentKeypad) { |
896 return mCurrentKeypad->flickDirection(); |
884 return mCurrentKeypad->flickDirection(); |
897 }else{ |
885 } else { |
898 return HbInputVkbWidget::HbFlickDirectionNone; |
886 return HbInputVkbWidget::HbFlickDirectionNone; |
899 } |
887 } |
900 } |
888 } |
901 // End of file |
889 // End of file |