45 #include <hbinputbutton.h> |
45 #include <hbinputbutton.h> |
46 #include <hbdeviceprofile.h> |
46 #include <hbdeviceprofile.h> |
47 |
47 |
48 //User includes |
48 //User includes |
49 #include "hbinput12keytouchkeyboard.h" |
49 #include "hbinput12keytouchkeyboard.h" |
50 #include "hbinputthaispecialpopup.h" |
|
51 #include "hbinputbasic12keyhandler.h" |
50 #include "hbinputbasic12keyhandler.h" |
52 #include "hbinputprediction12keyhandler.h" |
51 #include "hbinputprediction12keyhandler.h" |
53 #include "hbinputnumeric12keyhandler.h" |
52 #include "hbinputnumeric12keyhandler.h" |
54 #include "hbinputbasic12keythaihandler.h" |
|
55 #include "hbinputprediction12keythaihandler.h" |
|
56 |
53 |
57 const int HbSmileyNumberOfRows = 5; |
54 const int HbSmileyNumberOfRows = 5; |
58 const int HbSmileyNumberOfColumns = 5; |
55 const int HbSmileyNumberOfColumns = 5; |
59 |
56 |
60 /*! |
57 /*! |
85 void HbVirtual12Key::initializeModeHandlers() |
81 void HbVirtual12Key::initializeModeHandlers() |
86 { |
82 { |
87 mBasicModeHandler = new HbInputBasic12KeyHandler(this); |
83 mBasicModeHandler = new HbInputBasic12KeyHandler(this); |
88 mPredictionModeHandler = new HbInputPrediction12KeyHandler(this); |
84 mPredictionModeHandler = new HbInputPrediction12KeyHandler(this); |
89 mNumericModeHandler = new HbInputNumeric12KeyHandler(this); |
85 mNumericModeHandler = new HbInputNumeric12KeyHandler(this); |
90 mBasic12keyThaiHandler = new HbInputBasic12KeyThaiHandler(this); |
86 |
91 mPrediction12keyThaiHandler = new HbInputPrediction12KeyThaiHandler(this); |
|
92 mActiveModeHandler = mBasicModeHandler; |
87 mActiveModeHandler = mBasicModeHandler; |
93 |
88 |
94 mBasicModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionInit); |
89 mBasicModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionInit); |
95 mPredictionModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionInit); |
90 mPredictionModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionInit); |
96 mNumericModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionInit); |
91 mNumericModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionInit); |
97 mPrediction12keyThaiHandler->actionHandler(HbInputModeHandler::HbInputModeActionInit); |
|
98 |
92 |
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 |
93 // let's connect prediction mode handler with latin basic mode handler. It is required incase we Qt::key_0 is pressed in prediction mode |
100 // key |
94 // key |
101 connect(mPredictionModeHandler, SIGNAL(passFilterEvent(const QKeyEvent *)), |
95 connect(mPredictionModeHandler, SIGNAL(passFilterEvent(const QKeyEvent *)), |
102 mBasicModeHandler, SLOT(filterEvent(const QKeyEvent *))); |
96 mBasicModeHandler, SLOT(filterEvent(const QKeyEvent *))); |
103 connect(mPredictionModeHandler, SIGNAL(passActionHandler(HbInputModeAction )), |
97 connect(mPredictionModeHandler, SIGNAL(passActionHandler(HbInputModeAction )), |
104 mBasicModeHandler, SLOT(actionHandler(HbInputModeAction ))); |
98 mBasicModeHandler, SLOT(actionHandler(HbInputModeAction ))); |
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 |
99 |
110 connect(HbInputSettingProxy::instance(), SIGNAL(predictiveInputStateChanged(HbKeyboardSettingFlags,bool)), this, SLOT(predictiveInputStateChanged(HbKeyboardSettingFlags,bool))); |
100 connect(HbInputSettingProxy::instance(), SIGNAL(predictiveInputStateChanged(HbKeyboardSettingFlags,bool)), this, SLOT(predictiveInputStateChanged(HbKeyboardSettingFlags,bool))); |
111 } |
101 } |
112 |
102 |
113 bool HbVirtual12Key::isSctModeActive() const |
103 bool HbVirtual12Key::isSctModeActive() const |
126 mItutKeypad = 0; |
116 mItutKeypad = 0; |
127 delete mSctKeypad; |
117 delete mSctKeypad; |
128 mSctKeypad = 0; |
118 mSctKeypad = 0; |
129 delete mCandidatePopup; |
119 delete mCandidatePopup; |
130 mCandidatePopup = 0; |
120 mCandidatePopup = 0; |
131 delete mThaiSpecialChar; |
121 |
132 mThaiSpecialChar = 0; |
|
133 |
|
134 // free mode handlers |
122 // free mode handlers |
135 delete mBasicModeHandler; |
123 delete mBasicModeHandler; |
136 mBasicModeHandler = 0; |
124 mBasicModeHandler = 0; |
137 delete mPredictionModeHandler; |
125 delete mPredictionModeHandler; |
138 mPredictionModeHandler = 0; |
126 mPredictionModeHandler = 0; |
139 delete mNumericModeHandler; |
127 delete mNumericModeHandler; |
140 mNumericModeHandler = 0; |
128 mNumericModeHandler = 0; |
141 delete mBasic12keyThaiHandler; |
|
142 mBasic12keyThaiHandler = 0; |
|
143 delete mPrediction12keyThaiHandler; |
|
144 mPrediction12keyThaiHandler = 0; |
|
145 } |
129 } |
146 |
130 |
147 /*! |
131 /*! |
148 Implementation of the pure virtual QInputContext::identifierName() |
132 Implementation of the pure virtual QInputContext::identifierName() |
149 Returns a string which specifies an identifier for the input method. |
133 Returns a string which specifies an identifier for the input method. |
193 connect(tempKeypad, SIGNAL(rockerDirection(int, HbInputVirtualRocker::RockerSelectionMode)), |
177 connect(tempKeypad, SIGNAL(rockerDirection(int, HbInputVirtualRocker::RockerSelectionMode)), |
194 this, SLOT(rockerDirection(int, HbInputVirtualRocker::RockerSelectionMode))); |
178 this, SLOT(rockerDirection(int, HbInputVirtualRocker::RockerSelectionMode))); |
195 //FLICKDISABLED connect(tempKeypad, SIGNAL(flickEvent(HbInputVkbWidget::FlickDirection)), this, SLOT(flickEvent(HbInputVkbWidget::FlickDirection))); |
179 //FLICKDISABLED connect(tempKeypad, SIGNAL(flickEvent(HbInputVkbWidget::FlickDirection)), this, SLOT(flickEvent(HbInputVkbWidget::FlickDirection))); |
196 connect(tempKeypad, SIGNAL(smileySelected(QString)), this, SLOT(smileySelected(QString))); |
180 connect(tempKeypad, SIGNAL(smileySelected(QString)), this, SLOT(smileySelected(QString))); |
197 connect(tempKeypad, SIGNAL(mouseMovedOutOfButton()), this, SLOT(mouseMovedOutOfButton())); |
181 connect(tempKeypad, SIGNAL(mouseMovedOutOfButton()), this, SLOT(mouseMovedOutOfButton())); |
198 connect(tempKeypad, SIGNAL(chrSelected(QString)), this, SLOT(thaiSctCharacterSelected(QString))); |
|
199 tempKeypad->setRockerVisible(true); |
182 tempKeypad->setRockerVisible(true); |
200 return tempKeypad; |
183 return tempKeypad; |
201 } |
184 } |
202 |
185 |
203 /*! |
186 /*! |
253 disconnect(&(focusObject()->editorInterface()), SIGNAL(cursorPositionChanged(int, int)), |
236 disconnect(&(focusObject()->editorInterface()), SIGNAL(cursorPositionChanged(int, int)), |
254 mActiveModeHandler, SLOT(cursorPositionChanged(int, int))); |
237 mActiveModeHandler, SLOT(cursorPositionChanged(int, int))); |
255 connect(&(focusObject()->editorInterface()), SIGNAL(cursorPositionChanged(int, int)), |
238 connect(&(focusObject()->editorInterface()), SIGNAL(cursorPositionChanged(int, int)), |
256 mActiveModeHandler, SLOT(cursorPositionChanged(int, int))); |
239 mActiveModeHandler, SLOT(cursorPositionChanged(int, int))); |
257 } |
240 } |
|
241 HbInputAbstractMethod::focusReceived(); |
258 } |
242 } |
259 |
243 |
260 /*! |
244 /*! |
261 \reimp |
245 \reimp |
262 */ |
246 */ |
263 void HbVirtual12Key::focusLost(bool focusSwitch) |
247 void HbVirtual12Key::focusLost(bool focusSwitch) |
264 { |
248 { |
265 // inform the active mode handler about the focus lost event. |
249 if(mActiveModeHandler) { |
266 mActiveModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionFocusLost); |
250 // inform the active mode handler about the focus lost event. |
|
251 mActiveModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionFocusLost); |
|
252 } |
267 |
253 |
268 if (focusObject()) { |
254 if (focusObject()) { |
269 disconnect(&(focusObject()->editorInterface()), SIGNAL(cursorPositionChanged(int, int)), |
255 disconnect(&(focusObject()->editorInterface()), SIGNAL(cursorPositionChanged(int, int)), |
270 mActiveModeHandler, SLOT(cursorPositionChanged(int, int))); |
256 mActiveModeHandler, SLOT(cursorPositionChanged(int, int))); |
271 } |
257 } |
309 |
292 |
310 // if null is sent, just return. |
293 // if null is sent, just return. |
311 if(!keypadToOpen) { |
294 if(!keypadToOpen) { |
312 return; |
295 return; |
313 } |
296 } |
314 bool wasKeypadOpen = false; |
297 bool disableAnimation = false; |
315 // see if we are trying to open a different keypad than what is already opened. |
298 // see if we are trying to open a different keypad than what is already opened. |
316 if (mCurrentKeypad != keypadToOpen) { |
299 if (mCurrentKeypad != keypadToOpen) { |
317 // close currently open keypad. We always close keypad without animation |
300 // close currently open keypad. We always close keypad without animation |
318 // keypad should be closed with animation only when we loses focus and this is handled |
301 // keypad should be closed with animation only when we loses focus and this is handled |
319 // in focusLost function call. |
302 // in focusLost function call. |
320 if (mVkbHost && mVkbHost->keypadStatus() != HbVkbHost::HbVkbStatusClosed) { |
303 if (mVkbHost && mVkbHost->keypadStatus() != HbVkbHost::HbVkbStatusClosed) { |
321 mVkbHost->closeKeypad(false); |
304 mVkbHost->closeKeypad(false); |
322 // when their is a keypad that needs to be closed before opening the new keypad, we don't |
305 // when their is a keypad that needs to be closed before opening the new keypad, we don't |
323 // want to animate the opening of new keypad. |
306 // want to animate the opening of new keypad. |
324 wasKeypadOpen = true; |
307 disableAnimation = true; |
325 } |
308 } |
326 } |
309 } |
327 // Close candidate popup if open |
310 // Close candidate popup if open |
328 if (mCandidatePopup) { |
311 if (mCandidatePopup) { |
329 mCandidatePopup->hide(); |
312 mCandidatePopup->hide(); |
330 } |
313 } |
|
314 |
|
315 QObject::disconnect(mCurrentKeypad,SIGNAL(aboutToActivateCustomAction(HbAction*)), |
|
316 this,SLOT(aboutToActivateCustomAction(HbAction*))); |
|
317 QObject::connect(keypadToOpen,SIGNAL(aboutToActivateCustomAction(HbAction*)), |
|
318 this,SLOT(aboutToActivateCustomAction(HbAction*))); |
|
319 |
331 // assign new keypad to be opened to varable mCurrentKeypad |
320 // assign new keypad to be opened to varable mCurrentKeypad |
332 mCurrentKeypad = keypadToOpen; |
321 mCurrentKeypad = keypadToOpen; |
333 |
322 |
334 if (mVkbHost && mVkbHost->keypadStatus() != HbVkbHost::HbVkbStatusOpened) { |
323 if (mVkbHost && mVkbHost->keypadStatus() != HbVkbHost::HbVkbStatusOpened) { |
335 connect(mVkbHost, SIGNAL(keypadClosed()), this, SLOT(keypadClosed())); |
324 connect(mVkbHost, SIGNAL(keypadClosed()), this, SLOT(keypadClosed())); |
336 connect(mVkbHost, SIGNAL(keypadOpened()), this, SLOT(keypadOpened())); |
325 connect(mVkbHost, SIGNAL(keypadOpened()), this, SLOT(keypadOpened())); |
337 |
326 |
338 if (inMinimizedMode) { |
327 if (inMinimizedMode) { |
339 mVkbHost->openMinimizedKeypad(mCurrentKeypad, this); |
328 mVkbHost->openMinimizedKeypad(mCurrentKeypad, this); |
340 } else { |
329 } else { |
341 mVkbHost->openKeypad(mCurrentKeypad, this, (!stateChangeInProgress() && !wasKeypadOpen)); |
330 mVkbHost->openKeypad(mCurrentKeypad, this, (!stateChangeInProgress() && !disableAnimation)); |
342 } |
331 } |
343 connect(&(focusObject()->editorInterface()), SIGNAL(cursorPositionChanged(int, int)), |
332 connect(&(focusObject()->editorInterface()), SIGNAL(cursorPositionChanged(int, int)), |
344 mVkbHost, SLOT(ensureCursorVisibility())); |
333 mVkbHost, SLOT(ensureCursorVisibility())); |
345 } |
334 } |
|
335 } |
|
336 |
|
337 /*! |
|
338 vkb widget is about to call a custom action that is mapped to one of the keypad buttons. |
|
339 */ |
|
340 void HbVirtual12Key::aboutToActivateCustomAction(HbAction *custAction) |
|
341 { |
|
342 Q_UNUSED(custAction); |
|
343 mActiveModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionCommit); |
346 } |
344 } |
347 |
345 |
348 /*! |
346 /*! |
349 The mouse event handler for the input method. Launches the candidate list if the mouse is clicked on the |
347 The mouse event handler for the input method. Launches the candidate list if the mouse is clicked on the |
350 pre-editing text. |
348 pre-editing text. |
511 } |
509 } |
512 } |
510 } |
513 } |
511 } |
514 |
512 |
515 HbInputModeHandler *previousModeHandler = mActiveModeHandler; |
513 HbInputModeHandler *previousModeHandler = mActiveModeHandler; |
516 if (HbInputSettingProxy::instance()->globalInputLanguage() == QLocale::Thai && |
514 if (newState.inputMode() == HbInputModeDefault && usePrediction()) { |
517 usePrediction() && newState.inputMode() != HbInputModeNumeric) { |
|
518 mActiveModeHandler = mPrediction12keyThaiHandler; |
|
519 // by passing HbInputModeActionFocusRecieved we will be setting the candidate list and keypad |
|
520 mActiveModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionFocusRecieved); |
|
521 } else if (HbInputSettingProxy::instance()->globalInputLanguage() == QLocale::Thai && |
|
522 !usePrediction() && newState.inputMode() != HbInputModeNumeric && |
|
523 ((HbEditorConstraintLatinAlphabetOnly | HbEditorConstraintAutoCompletingField)!=focusObject()->editorInterface().inputConstraints())) { |
|
524 mActiveModeHandler = mBasic12keyThaiHandler; |
|
525 // by passing HbInputModeActionFocusRecieved we will be setting the candidate list and keypad |
|
526 mActiveModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionFocusRecieved); |
|
527 } else if (newState.inputMode() == HbInputModeDefault && usePrediction()) { |
|
528 mActiveModeHandler = mPredictionModeHandler; |
515 mActiveModeHandler = mPredictionModeHandler; |
529 // by passing HbInputModeActionFocusRecieved we will be setting the candidate list and keypad |
516 // by passing HbInputModeActionFocusRecieved we will be setting the candidate list and keypad |
530 mActiveModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionFocusRecieved); |
517 mActiveModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionFocusRecieved); |
531 } else if (newState.inputMode() == HbInputModeDefault) { |
518 } else if (newState.inputMode() == HbInputModeDefault) { |
532 mActiveModeHandler = mBasicModeHandler; |
519 mActiveModeHandler = mBasicModeHandler; |
549 // if there is a change in the modehandler we need send a commit in previous mode handler. |
536 // if there is a change in the modehandler we need send a commit in previous mode handler. |
550 if (previousModeHandler != mActiveModeHandler) { |
537 if (previousModeHandler != mActiveModeHandler) { |
551 // Auto Completion part needs to be committed as well on mode change. |
538 // Auto Completion part needs to be committed as well on mode change. |
552 |
539 |
553 previousModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionCommit); |
540 previousModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionCommit); |
554 if (mActiveModeHandler == mPredictionModeHandler || |
541 if (mActiveModeHandler == mPredictionModeHandler) { |
555 mActiveModeHandler == mPrediction12keyThaiHandler) { |
|
556 // lets set candidate list and keypad type to the engine. |
542 // lets set candidate list and keypad type to the engine. |
557 mActiveModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionSetCandidateList); |
543 mActiveModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionSetCandidateList); |
558 mActiveModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionSetKeypad); |
544 mActiveModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionSetKeypad); |
559 } |
545 } |
560 } |
546 } |
653 } |
633 } |
654 activateState(nextState); |
634 activateState(nextState); |
655 switchToAlphaMode(); |
635 switchToAlphaMode(); |
656 } |
636 } |
657 } |
637 } |
658 /*! |
|
659 Returns previous character from editor |
|
660 */ |
|
661 uint HbVirtual12Key::previousChar() |
|
662 { |
|
663 if (focusObject()) { |
|
664 int cursorPosition = focusObject()->editorCursorPosition(); |
|
665 if (cursorPosition) { |
|
666 QString editorText = focusObject()->editorSurroundingText(); |
|
667 return((editorText.at(cursorPosition-1)).unicode()); |
|
668 } |
|
669 } |
|
670 return 0; |
|
671 } |
|
672 /*! |
|
673 Shows the Thai specific special characters |
|
674 */ |
|
675 void HbVirtual12Key::showThaiSpecialCharacters(uint buttonId) |
|
676 { |
|
677 uint prevChar = previousChar(); |
|
678 int screenWidth = 0; |
|
679 int screenHeight = 0; |
|
680 //Get the sceen size from device profile |
|
681 if (mCurrentKeypad) { |
|
682 screenWidth = HbDeviceProfile::profile(mCurrentKeypad).logicalSize().width(); |
|
683 screenHeight = HbDeviceProfile::profile(mCurrentKeypad).logicalSize().height(); |
|
684 } |
|
685 //Create Thai special popup if not created |
|
686 if( !mThaiSpecialChar) { |
|
687 mThaiSpecialChar = new HbInputThaiSpecialPopup(buttonId,prevChar,0); |
|
688 connect(mThaiSpecialChar, SIGNAL(chrSelected(QString)), |
|
689 this, SLOT(thaiSctCharacterSelected(QString))); |
|
690 } |
|
691 //Set Geometry and Layout for popup |
|
692 if (mThaiSpecialChar) { |
|
693 mThaiSpecialChar->setGeometry(QRectF(0,screenHeight/2,screenWidth,screenHeight/2)); |
|
694 mThaiSpecialChar->setPopupLayout(mKeymap,prevChar,buttonId,screenWidth,screenHeight/2); |
|
695 mThaiSpecialChar->show(); |
|
696 } |
|
697 } |
|
698 |
638 |
699 /*! |
639 /*! |
700 Shows the special character table. Re-implements the same method from HbInputMethod. |
640 Shows the special character table. Re-implements the same method from HbInputMethod. |
701 */ |
641 */ |
702 int HbVirtual12Key::displaySpecialCharacterTable(QObject* receiver) |
642 int HbVirtual12Key::displaySpecialCharacterTable(QObject* receiver) |
749 void HbVirtual12Key::launchCandidatePopup(const QStringList& candidates) |
689 void HbVirtual12Key::launchCandidatePopup(const QStringList& candidates) |
750 { |
690 { |
751 if (!mCandidatePopup) { |
691 if (!mCandidatePopup) { |
752 mCandidatePopup = new HbCandidateList(this); |
692 mCandidatePopup = new HbCandidateList(this); |
753 connect(mCandidatePopup, SIGNAL(candidateSelected(int,QString)), this, SLOT(candidatePopupClosed(int,QString))); |
693 connect(mCandidatePopup, SIGNAL(candidateSelected(int,QString)), this, SLOT(candidatePopupClosed(int,QString))); |
754 } |
694 QObject::connect(mCandidatePopup,SIGNAL(launchSpellQueryDialog()),mPredictionModeHandler,SLOT(launchSpellQueryDialog())); |
755 mCandidatePopup->populateList(candidates); |
695 } |
|
696 mCandidatePopup->populateList(candidates,true); |
756 mCandidatePopup->setModal(true); |
697 mCandidatePopup->setModal(true); |
757 |
698 |
758 QSizeF candListSize = mCandidatePopup->size(); |
699 QSizeF candListSize = mCandidatePopup->size(); |
759 QPointF candListPos = mCandidatePopup->pos(); |
700 QPointF candListPos = mCandidatePopup->pos(); |
760 getCandidatePositionAndSize(mCandidatePopup, mCurrentKeypad, candListPos, candListSize); |
701 getCandidatePositionAndSize(mCandidatePopup, mCurrentKeypad, candListPos, candListSize); |
841 void HbVirtual12Key::launchAutoCompletionPopup(const QStringList& candidates) |
774 void HbVirtual12Key::launchAutoCompletionPopup(const QStringList& candidates) |
842 { |
775 { |
843 if (!mCandidatePopup) { |
776 if (!mCandidatePopup) { |
844 mCandidatePopup = new HbCandidateList(this); |
777 mCandidatePopup = new HbCandidateList(this); |
845 connect(mCandidatePopup, SIGNAL(candidateSelected(int,QString)), this, SLOT(candidatePopupClosed(int,QString))); |
778 connect(mCandidatePopup, SIGNAL(candidateSelected(int,QString)), this, SLOT(candidatePopupClosed(int,QString))); |
|
779 QObject::connect(mCandidatePopup,SIGNAL(launchSpellQueryDialog()),mPredictionModeHandler,SLOT(launchSpellQueryDialog())); |
846 } |
780 } |
847 |
781 |
848 if (candidates.count() > 0) { |
782 if (candidates.count() > 0) { |
849 mCandidatePopup->populateList(candidates); |
783 mCandidatePopup->populateList(candidates); |
850 mCandidatePopup->setModal(false); |
784 mCandidatePopup->setModal(false); |