33 #include <hbinputkeymapfactory.h> |
33 #include <hbinputkeymapfactory.h> |
34 #include <hbinputkeymap.h> |
34 #include <hbinputkeymap.h> |
35 #include <hbinputcandidatelist.h> |
35 #include <hbinputcandidatelist.h> |
36 #include <hbinputsettingproxy.h> |
36 #include <hbinputsettingproxy.h> |
37 #include <hbinpututils.h> |
37 #include <hbinpututils.h> |
38 #include <hbinputvirtualrocker.h> |
|
39 #include <hbinputsctkeyboard.h> |
38 #include <hbinputsctkeyboard.h> |
40 #include <hbinputeditorinterface.h> |
39 #include <hbinputeditorinterface.h> |
41 #include <hbinputdef.h> |
40 #include <hbinputdef.h> |
42 #include <hbinputvkbhost.h> |
41 #include <hbinputvkbhost.h> |
43 #include <hbinputcommondialogs.h> |
42 #include <hbinputcommondialogs.h> |
49 #include "hbinputqwerty10x4touchkeyboard.h" |
48 #include "hbinputqwerty10x4touchkeyboard.h" |
50 #include "hbinputqwerty11x4touchkeyboard.h" |
49 #include "hbinputqwerty11x4touchkeyboard.h" |
51 #include "hbinputqwertynumerictouchkeyboard.h" |
50 #include "hbinputqwertynumerictouchkeyboard.h" |
52 |
51 |
53 const int HbVirtualQwerty4x10MaxKeysCount = 32; |
52 const int HbVirtualQwerty4x10MaxKeysCount = 32; |
|
53 const qreal HbExactPopupHeightFactor = 0.15; |
|
54 const qreal HbDeltaWidth = 12.0; |
|
55 const qreal HbEditorExtraMargin = 5.0; |
54 |
56 |
55 HbVirtualQwerty::HbVirtualQwerty() : mCurrentKeypad(0), |
57 HbVirtualQwerty::HbVirtualQwerty() : mCurrentKeypad(0), |
56 mQwertyAlphaKeypad(0), |
58 mQwertyAlphaKeypad(0), |
57 mQwerty10x4Keypad(0), |
59 mQwerty10x4Keypad(0), |
58 mQwerty11x4Keypad(0), |
60 mQwerty11x4Keypad(0), |
59 mQwertyNumericKeypad(0), |
61 mQwertyNumericKeypad(0), |
60 mSctKeypad(0), |
62 mSctKeypad(0), |
61 mKeymap(0), |
63 mKeymap(0), |
62 mExactWordPopup(0), |
64 mExactWordPopup(0), |
63 mCandidatePopup(0), |
65 mCandidatePopup(0), |
64 mOrientationAboutToChange(false), |
|
65 mShiftKeyState(0), |
66 mShiftKeyState(0), |
66 mVkbHost(0) |
67 mVkbHost(0) |
67 { |
68 { |
68 initializeModeHandlers(); |
69 initializeModeHandlers(); |
69 } |
70 } |
84 |
85 |
85 // autocompleter connection |
86 // autocompleter connection |
86 connect(this, SIGNAL(autoCompletionPopupClosed(QString, int)), mBasicModeHandler, SLOT(autoCompletionPopupClosed(QString, int))); |
87 connect(this, SIGNAL(autoCompletionPopupClosed(QString, int)), mBasicModeHandler, SLOT(autoCompletionPopupClosed(QString, int))); |
87 |
88 |
88 connect(HbInputSettingProxy::instance(), SIGNAL(predictiveInputStateChanged(HbKeyboardSettingFlags,bool)), this, SLOT(predictiveInputStateChanged(HbKeyboardSettingFlags,bool))); |
89 connect(HbInputSettingProxy::instance(), SIGNAL(predictiveInputStateChanged(HbKeyboardSettingFlags,bool)), this, SLOT(predictiveInputStateChanged(HbKeyboardSettingFlags,bool))); |
89 connect(HbInputSettingProxy::instance(), SIGNAL(primaryCandidateModeChanged(HbPrimaryCandidateMode)), this, SLOT(primaryCandidateModeChanged(HbPrimaryCandidateMode))); |
90 connect(HbInputSettingProxy::instance(), SIGNAL(primaryCandidateModeChanged(HbPrimaryCandidateMode)), this, SLOT(primaryCandidateModeChanged(HbPrimaryCandidateMode))); |
90 connect(HbInputSettingProxy::instance(), SIGNAL(autocompletionStateChanged(HbKeyboardSettingFlags,bool)), this, SLOT(autocompletionStateChanged(HbKeyboardSettingFlags,bool))); |
91 connect(HbInputSettingProxy::instance(), SIGNAL(autocompletionStateChanged(HbKeyboardSettingFlags,bool)), this, SLOT(autocompletionStateChanged(HbKeyboardSettingFlags,bool))); |
91 connect(HbInputSettingProxy::instance(), SIGNAL(typingCorrectionLevelChanged(HbTypingCorrectionLevel)), this, SLOT(typingCorrectionLevelChanged(HbTypingCorrectionLevel))); |
92 connect(HbInputSettingProxy::instance(), SIGNAL(typingCorrectionLevelChanged(HbTypingCorrectionLevel)), this, SLOT(typingCorrectionLevelChanged(HbTypingCorrectionLevel))); |
92 mPredictionModeHandler->setPrimaryCandidateMode(HbInputSettingProxy::instance()->primaryCandidateMode()); |
93 mPredictionModeHandler->setPrimaryCandidateMode(HbInputSettingProxy::instance()->primaryCandidateMode()); |
93 mPredictionModeHandler->setAutocompletionStatus(HbInputSettingProxy::instance()->isAutocompletionEnabled(HbKeyboardSettingQwerty)); |
94 mPredictionModeHandler->setAutocompletionStatus(HbInputSettingProxy::instance()->isAutocompletionEnabled(HbKeyboardSettingQwerty)); |
94 mPredictionModeHandler->setTypingCorrectionLevel(HbInputSettingProxy::instance()->typingCorrectionLevel()); |
95 |
95 } |
96 } |
96 |
97 |
97 // --------------------------------------------------------------------------- |
98 // --------------------------------------------------------------------------- |
98 // HbVirtualQwerty::~HbVirtualQwerty |
99 // HbVirtualQwerty::~HbVirtualQwerty |
99 // |
100 // |
184 currentInputType = EModeNumeric; |
187 currentInputType = EModeNumeric; |
185 } |
188 } |
186 |
189 |
187 HbInputVkbWidget* keypadToOpen = 0; |
190 HbInputVkbWidget* keypadToOpen = 0; |
188 if (currentInputType == EModeAbc) { |
191 if (currentInputType == EModeAbc) { |
189 mQwertyAlphaKeypad = constructKeyboard(EModeAbc); |
192 // See if the editor prefers numeric mode when focused. |
190 keypadToOpen = mQwertyAlphaKeypad; |
193 Qt::InputMethodHints hints = focusObject()->inputMethodHints(); |
|
194 if(hints & Qt::ImhPreferNumbers) { |
|
195 createSctKeypad(); |
|
196 keypadToOpen = mSctKeypad; |
|
197 } |
|
198 else { |
|
199 mQwertyAlphaKeypad = constructKeyboard(EModeAbc); |
|
200 keypadToOpen = mQwertyAlphaKeypad; |
|
201 } |
191 } else if(currentInputType == EModeNumeric) { |
202 } else if(currentInputType == EModeNumeric) { |
192 if(!mQwertyNumericKeypad) { |
203 if(!mQwertyNumericKeypad) { |
193 mQwertyNumericKeypad = static_cast<HbQwertyNumericKeyboard*>(constructKeyboard(EModeNumeric)); |
204 mQwertyNumericKeypad = static_cast<HbQwertyNumericKeyboard*>(constructKeyboard(EModeNumeric)); |
194 mQwertyNumericKeypad->setBackgroundDrawing(true); |
205 mQwertyNumericKeypad->setBackgroundDrawing(true); |
195 } |
206 } |
210 } |
221 } |
211 |
222 |
212 if (focusObject()) { |
223 if (focusObject()) { |
213 disconnect(&(focusObject()->editorInterface()), SIGNAL(cursorPositionChanged(int, int)), mActiveModeHandler, SLOT(cursorPositionChanged(int, int))); |
224 disconnect(&(focusObject()->editorInterface()), SIGNAL(cursorPositionChanged(int, int)), mActiveModeHandler, SLOT(cursorPositionChanged(int, int))); |
214 connect(&(focusObject()->editorInterface()), SIGNAL(cursorPositionChanged(int, int)), mActiveModeHandler, SLOT(cursorPositionChanged(int, int))); |
225 connect(&(focusObject()->editorInterface()), SIGNAL(cursorPositionChanged(int, int)), mActiveModeHandler, SLOT(cursorPositionChanged(int, int))); |
|
226 |
|
227 disconnect(focusObject(), SIGNAL(aboutToChangeOrientation()), this, SLOT(orientationAboutToChange())); |
|
228 connect(focusObject(), SIGNAL(aboutToChangeOrientation()), this, SLOT(orientationAboutToChange())); |
215 } |
229 } |
216 HbInputAbstractMethod::focusReceived(); |
230 HbInputAbstractMethod::focusReceived(); |
217 } |
231 } |
218 |
232 |
219 void HbVirtualQwerty::focusLost(bool focusSwitch) |
233 void HbVirtualQwerty::focusLost(bool focusSwitch) |
230 // Context switch has happened but the keypad is still open. |
244 // Context switch has happened but the keypad is still open. |
231 // Close it. |
245 // Close it. |
232 closeKeypad(); |
246 closeKeypad(); |
233 } |
247 } |
234 } |
248 } |
|
249 HbInputAbstractMethod::focusLost(); |
235 } |
250 } |
236 |
251 |
237 void HbVirtualQwerty::closeKeypad() |
252 void HbVirtualQwerty::closeKeypad() |
238 { |
253 { |
239 if (mVkbHost && mVkbHost->keypadStatus() != HbVkbHost::HbVkbStatusClosed) { |
254 if (mVkbHost && mVkbHost->keypadStatus() != HbVkbHost::HbVkbStatusClosed) { |
240 mVkbHost->closeKeypad(); |
255 mVkbHost->closeKeypad(!stateChangeInProgress()); |
241 // set mCurrentKeypad to null. |
256 // set mCurrentKeypad to null. |
242 mCurrentKeypad = 0; |
257 mCurrentKeypad = 0; |
243 if (mCandidatePopup) { |
258 closeCandidatePopup(); |
244 mCandidatePopup->hide(); |
259 } |
245 } |
260 } |
246 } |
261 |
247 } |
262 void HbVirtualQwerty::openKeypad(HbInputVkbWidget *keypadToOpen) |
248 |
|
249 void HbVirtualQwerty::openKeypad(HbInputVkbWidget * keypadToOpen,bool inMinimizedMode ) |
|
250 { |
263 { |
251 // if null is sent, just return. |
264 // if null is sent, just return. |
252 if(!keypadToOpen || !focusObject()) { |
265 if(!keypadToOpen || !focusObject()) { |
253 return; |
266 return; |
254 } |
267 } |
263 // when their is a keypad that needs to be closed before opening the new keypad, we don't |
276 // when their is a keypad that needs to be closed before opening the new keypad, we don't |
264 // want to animate the opening of new keypad. |
277 // want to animate the opening of new keypad. |
265 disableAnimation = true; |
278 disableAnimation = true; |
266 } |
279 } |
267 } |
280 } |
|
281 |
268 // Close candidate popup if open |
282 // Close candidate popup if open |
269 if (mCandidatePopup) { |
283 closeCandidatePopup(); |
270 mCandidatePopup->hide(); |
|
271 } |
|
272 |
284 |
273 QObject::disconnect(mCurrentKeypad,SIGNAL(aboutToActivateCustomAction(HbAction*)), |
285 QObject::disconnect(mCurrentKeypad,SIGNAL(aboutToActivateCustomAction(HbAction*)), |
274 this,SLOT(aboutToActivateCustomAction(HbAction*))); |
286 this,SLOT(aboutToActivateCustomAction(HbAction*))); |
275 QObject::connect(keypadToOpen,SIGNAL(aboutToActivateCustomAction(HbAction*)), |
287 QObject::connect(keypadToOpen,SIGNAL(aboutToActivateCustomAction(HbAction*)), |
276 this,SLOT(aboutToActivateCustomAction(HbAction*))); |
288 this,SLOT(aboutToActivateCustomAction(HbAction*))); |
277 |
289 |
278 // assign new keypad to be opened to varable mCurrentKeypad |
290 // assign new keypad to be opened to varable mCurrentKeypad |
279 mCurrentKeypad = keypadToOpen; |
291 mCurrentKeypad = keypadToOpen; |
280 activeKeyboardChanged(currentKeyboardType()); |
|
281 |
|
282 |
|
283 if (mVkbHost && mVkbHost->keypadStatus() != HbVkbHost::HbVkbStatusOpened) { |
292 if (mVkbHost && mVkbHost->keypadStatus() != HbVkbHost::HbVkbStatusOpened) { |
284 connect(mVkbHost, SIGNAL(keypadClosed()), this, SLOT(keypadClosed())); |
293 connect(mVkbHost, SIGNAL(keypadClosed()), this, SLOT(keypadClosed())); |
285 if (inMinimizedMode) { |
294 |
286 mVkbHost->openMinimizedKeypad(mCurrentKeypad, this); |
295 mVkbHost->openKeypad(mCurrentKeypad, this, !disableAnimation); |
287 } else { |
|
288 mVkbHost->openKeypad(mCurrentKeypad, this, !disableAnimation); |
|
289 } |
|
290 |
296 |
291 if (focusObject()) { |
297 if (focusObject()) { |
292 connect(&(focusObject()->editorInterface()), SIGNAL(cursorPositionChanged(int, int)), |
298 connect(&(focusObject()->editorInterface()), SIGNAL(cursorPositionChanged(int, int)), |
293 mVkbHost, SLOT(ensureCursorVisibility())); |
299 mVkbHost, SLOT(ensureCursorVisibility())); |
294 } |
300 } |
|
301 } |
|
302 |
|
303 if(mActiveModeHandler) { |
|
304 mActiveModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionSetKeypad); |
|
305 } |
|
306 |
|
307 if(mCurrentKeypad && mCurrentKeypad == mQwertyAlphaKeypad) { |
|
308 mPredictionModeHandler->setTypingCorrectionLevel(HbInputSettingProxy::instance()->typingCorrectionLevel()); |
|
309 } |
|
310 else { |
|
311 mPredictionModeHandler->setTypingCorrectionLevel(HbTypingCorrectionLevelLow); |
295 } |
312 } |
296 } |
313 } |
297 |
314 |
298 /*! |
315 /*! |
299 vkb widget is about to call a custom action that is mapped to one of the keypad buttons. |
316 vkb widget is about to call a custom action that is mapped to one of the keypad buttons. |
321 } |
338 } |
322 mQwerty10x4Keypad = new HbQwerty10x4Keyboard(this, mKeymap); |
339 mQwerty10x4Keypad = new HbQwerty10x4Keyboard(this, mKeymap); |
323 keyboard = mQwerty10x4Keypad; |
340 keyboard = mQwerty10x4Keypad; |
324 } |
341 } |
325 connect(keyboard, SIGNAL(smileySelected(QString)), this, SLOT(smileySelected(QString))); |
342 connect(keyboard, SIGNAL(smileySelected(QString)), this, SLOT(smileySelected(QString))); |
|
343 connect(keyboard, SIGNAL(settingsListClosed()), this, SLOT(restorePreviousState())); |
326 //FLICKDISABLED connect(keyboard, SIGNAL(flickEvent(HbInputVkbWidget::FlickDirection)), this, SLOT(flickEvent(HbInputVkbWidget::FlickDirection))); |
344 //FLICKDISABLED connect(keyboard, SIGNAL(flickEvent(HbInputVkbWidget::FlickDirection)), this, SLOT(flickEvent(HbInputVkbWidget::FlickDirection))); |
327 } else { |
345 } else { |
328 keyboard = new HbQwertyNumericKeyboard(this, mKeymap); |
346 keyboard = new HbQwertyNumericKeyboard(this, mKeymap); |
329 } |
347 } |
330 connect(keyboard, SIGNAL(keypadCloseEventDetected(HbInputVkbWidget::HbVkbCloseMethod)), |
348 connect(keyboard, SIGNAL(keypadCloseEventDetected(HbInputVkbWidget::HbVkbCloseMethod)), |
331 this, SLOT(keypadCloseEventDetected(HbInputVkbWidget::HbVkbCloseMethod))); |
349 this, SLOT(keypadCloseEventDetected(HbInputVkbWidget::HbVkbCloseMethod))); |
332 connect(keyboard, SIGNAL(rockerDirection(int, HbInputVirtualRocker::RockerSelectionMode)), |
350 connect(keyboard, SIGNAL(rockerDirection(int, HbInputVirtualRocker::RockerSelectionMode)), |
333 this, SLOT(rockerDirection(int, HbInputVirtualRocker::RockerSelectionMode))); |
351 this, SLOT(rockerDirection(int, HbInputVirtualRocker::RockerSelectionMode))); |
334 connect(keyboard, SIGNAL(mouseMovedOutOfButton()), this, SLOT(mouseMovedOutOfButton())); |
352 connect(keyboard, SIGNAL(mouseMovedOutOfButton()), this, SLOT(mouseMovedOutOfButton())); |
335 keyboard->setRockerVisible(true); |
|
336 |
353 |
337 return keyboard; |
354 return keyboard; |
338 } |
355 } |
339 |
356 |
340 void HbVirtualQwerty::mouseHandler(int x, QMouseEvent* event) |
357 void HbVirtualQwerty::mouseHandler(int x, QMouseEvent* event) |
342 mActiveModeHandler->mouseHandler(x, event); |
359 mActiveModeHandler->mouseHandler(x, event); |
343 } |
360 } |
344 |
361 |
345 void HbVirtualQwerty::keypadClosed() |
362 void HbVirtualQwerty::keypadClosed() |
346 { |
363 { |
347 mOrientationAboutToChange = false; |
|
348 |
|
349 if (mVkbHost->keypadStatus() == HbVkbHost::HbVkbStatusMinimized) { |
|
350 closeExactWordPopup(); |
|
351 } |
|
352 } |
364 } |
353 |
365 |
354 void HbVirtualQwerty::keypadCloseEventDetected(HbInputVkbWidget::HbVkbCloseMethod vkbCloseMethod) |
366 void HbVirtualQwerty::keypadCloseEventDetected(HbInputVkbWidget::HbVkbCloseMethod vkbCloseMethod) |
355 { |
367 { |
356 Q_UNUSED(vkbCloseMethod); |
368 Q_UNUSED(vkbCloseMethod); |
357 if (isActiveMethod()) { |
369 if (isActiveMethod()) { |
358 if (mVkbHost && mVkbHost->keypadStatus() != HbVkbHost::HbVkbStatusMinimized) { |
370 if (mVkbHost) { |
359 // We need to commit the inline word when we minimize the keypad |
|
360 mActiveModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionCommit); |
371 mActiveModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionCommit); |
361 if (mCandidatePopup) { |
372 closeCandidatePopup(); |
362 mCandidatePopup->hide(); |
|
363 } |
|
364 |
373 |
365 // Close input. |
374 // Close input. |
366 QInputContext* ic = qApp->inputContext(); |
375 QInputContext* ic = qApp->inputContext(); |
367 if (ic) { |
376 if (ic) { |
368 QEvent *closeEvent = new QEvent(QEvent::CloseSoftwareInputPanel); |
377 QEvent *closeEvent = new QEvent(QEvent::CloseSoftwareInputPanel); |
374 } |
383 } |
375 |
384 |
376 void HbVirtualQwerty::inputLanguageChanged(const HbInputLanguage &aNewLanguage) |
385 void HbVirtualQwerty::inputLanguageChanged(const HbInputLanguage &aNewLanguage) |
377 { |
386 { |
378 mPredictionModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionCommit); |
387 mPredictionModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionCommit); |
379 if (mExactWordPopup && mExactWordPopup->isVisible()) |
388 if (mExactWordPopup && mExactWordPopup->isVisible()) |
380 closeExactWordPopup(); |
389 closeExactWordPopup(); |
381 // move keypad off screen |
390 // move keypad off screen |
382 if (mCurrentKeypad){ |
391 if (mCurrentKeypad){ |
383 mCurrentKeypad->keypadLanguageChangeAnimationUpdate(0); |
392 mCurrentKeypad->keypadLanguageChangeAnimationUpdate(0); |
384 } |
393 } |
409 mQwertyAlphaKeypad->setMode(EModeAbc, HbModifierShiftPressed); |
418 mQwertyAlphaKeypad->setMode(EModeAbc, HbModifierShiftPressed); |
410 } else { |
419 } else { |
411 mQwertyAlphaKeypad->setMode(EModeAbc, HbModifierNone); |
420 mQwertyAlphaKeypad->setMode(EModeAbc, HbModifierNone); |
412 } |
421 } |
413 } |
422 } |
414 |
423 // need to make sure that the prediction mode handler has the input state's language set |
|
424 // it is the global input language by default |
|
425 if(mPredictionModeHandler && newState.language().language() != HbInputSettingProxy::instance()->globalInputLanguage().language()) { |
|
426 HbInputLanguage inputStateLang = newState.language(); |
|
427 mPredictionModeHandler->setLanguage(inputStateLang); |
|
428 } |
415 HbInputModeHandler *previousModeHandler = mActiveModeHandler; |
429 HbInputModeHandler *previousModeHandler = mActiveModeHandler; |
416 if (newState.inputMode() == HbInputModeNumeric) { |
430 if (newState.inputMode() == HbInputModeNumeric) { |
417 mActiveModeHandler = mNumericModeHandler; |
431 mActiveModeHandler = mNumericModeHandler; |
418 } else if (newState.inputMode() == HbInputModeDefault && usePrediction()) { |
432 } else if (newState.inputMode() == HbInputModeDefault && usePrediction()) { |
419 mActiveModeHandler = mPredictionModeHandler; |
433 mActiveModeHandler = mPredictionModeHandler; |
|
434 // by passing HbInputModeActionFocusRecieved we will be setting the candidate list and keypad |
|
435 mActiveModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionFocusRecieved); |
|
436 /* The below line should be added in orientationChanged Slot, however currently it is not working correctly |
|
437 hence this fix is temporarily added here */ |
|
438 mPredictionModeHandler->setAutocompletionStatus(HbInputSettingProxy::instance()->isAutocompletionEnabled(HbKeyboardSettingQwerty)); |
420 } else if (newState.inputMode() == HbInputModeDefault) { |
439 } else if (newState.inputMode() == HbInputModeDefault) { |
421 mActiveModeHandler = mBasicModeHandler; |
440 mActiveModeHandler = mBasicModeHandler; |
422 // Auto completer setup needs following line. |
441 // Auto completer setup needs following line. |
423 mActiveModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionFocusRecieved); |
442 mActiveModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionFocusRecieved); |
424 } |
443 } |
494 } |
513 } |
495 |
514 |
496 void HbVirtualQwerty::secondaryInputLanguageChanged(const HbInputLanguage &newLanguage) |
515 void HbVirtualQwerty::secondaryInputLanguageChanged(const HbInputLanguage &newLanguage) |
497 { |
516 { |
498 Q_UNUSED(newLanguage); |
517 Q_UNUSED(newLanguage); |
|
518 // inform mode handler about the language change. |
|
519 mPredictionModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionCommit); |
499 mPredictionModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionSecondaryLanguageChanged); |
520 mPredictionModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionSecondaryLanguageChanged); |
500 } |
521 } |
501 |
522 |
502 int HbVirtualQwerty::displaySpecialCharacterTable(QObject* aReceiver) |
523 int HbVirtualQwerty::displaySpecialCharacterTable(QObject* aReceiver) |
503 { |
524 { |
504 Q_UNUSED(aReceiver); |
525 Q_UNUSED(aReceiver); |
505 |
526 |
506 if (!mSctKeypad) { |
527 createSctKeypad(); |
507 mSctKeypad = new HbSctKeyboard(this, mKeymap); |
|
508 connect(mSctKeypad, SIGNAL(smileySelected(QString)), this, SLOT(smileySelected(QString))); |
|
509 connect(mSctKeypad, SIGNAL(keypadCloseEventDetected(HbInputVkbWidget::HbVkbCloseMethod)), this, SLOT(keypadCloseEventDetected(HbInputVkbWidget::HbVkbCloseMethod))); |
|
510 connect(mSctKeypad, SIGNAL(rockerDirection(int, HbInputVirtualRocker::RockerSelectionMode)), |
|
511 this, SLOT(rockerDirection(int, HbInputVirtualRocker::RockerSelectionMode))); |
|
512 mSctKeypad->setRockerVisible(true); |
|
513 } |
|
514 mSctKeypad->setMode(EModeAbc, HbModifierNone); |
|
515 //open the keypad |
528 //open the keypad |
516 openKeypad(mSctKeypad); |
529 openKeypad(mSctKeypad); |
517 |
530 |
518 return 0; |
531 return 0; |
519 } |
532 } |
528 mQwertyAlphaKeypad = constructKeyboard(EModeAbc); |
541 mQwertyAlphaKeypad = constructKeyboard(EModeAbc); |
529 mQwertyAlphaKeypad->showSmileyPicker(); |
542 mQwertyAlphaKeypad->showSmileyPicker(); |
530 } |
543 } |
531 |
544 |
532 /*! |
545 /*! |
533 Slot used by mode handlers to close the autocompletion popup. |
546 Closes the candidate popup if visible. |
534 */ |
547 */ |
535 void HbVirtualQwerty::closeAutoCompletionPopup() |
548 void HbVirtualQwerty::closeCandidatePopup() |
536 { |
549 { |
537 if (mCandidatePopup && mCandidatePopup->isVisible()) { |
550 if (mCandidatePopup && mCandidatePopup->isVisible()) { |
538 mCandidatePopup->hide(); |
551 mCandidatePopup->hide(); |
539 } |
552 } |
540 } |
553 } |
541 |
554 |
542 /*! |
555 /*! |
|
556 Slot used by mode handlers to close the autocompletion popup. |
|
557 */ |
|
558 void HbVirtualQwerty::closeAutoCompletionPopup() |
|
559 { |
|
560 closeCandidatePopup(); |
|
561 } |
|
562 |
|
563 /*! |
543 Launches auto-completion popup if there are candidates available. |
564 Launches auto-completion popup if there are candidates available. |
544 */ |
565 */ |
545 void HbVirtualQwerty::launchAutoCompletionPopup(const QStringList& candidates) |
566 void HbVirtualQwerty::launchAutoCompletionPopup(const QStringList& candidates) |
546 { |
567 { |
547 if (!mCandidatePopup) { |
568 if (!mCandidatePopup) { |
548 mCandidatePopup = new HbCandidateList(this); |
569 mCandidatePopup = new HbCandidateList(this); |
549 connect(mCandidatePopup, SIGNAL(candidatePopupCancelled()), this, SLOT(candidatePopupCancelled())); |
570 connect(mCandidatePopup, SIGNAL(candidatePopupCancelled()), this, SLOT(restorePreviousState())); |
550 connect(mCandidatePopup, SIGNAL(candidateSelected(int,const QString&)), this, SLOT(candidatePopupClosed(int, const QString&))); |
571 connect(mCandidatePopup, SIGNAL(candidateSelected(int,const QString&)), this, SLOT(candidatePopupClosed(int, const QString&))); |
551 } |
572 } |
552 |
573 |
553 if (candidates.count() > 0) { |
574 if (candidates.count() > 0) { |
554 mCandidatePopup->populateList(candidates); |
575 mCandidatePopup->populateList(candidates); |
557 if (mCandidatePopup->setSizeAndPositionForAutoCompletion(mVkbHost)) { |
578 if (mCandidatePopup->setSizeAndPositionForAutoCompletion(mVkbHost)) { |
558 mCandidatePopup->setDismissPolicy(HbPopup::TapInside); |
579 mCandidatePopup->setDismissPolicy(HbPopup::TapInside); |
559 mCandidatePopup->setBackgroundFaded(false); |
580 mCandidatePopup->setBackgroundFaded(false); |
560 mCandidatePopup->show(); |
581 mCandidatePopup->show(); |
561 } |
582 } |
562 } else if (mCandidatePopup->isVisible()) { |
583 } else { |
563 mCandidatePopup->hide(); |
584 closeCandidatePopup(); |
564 } |
585 } |
565 } |
586 } |
566 |
587 |
567 HbKeyboardType HbVirtualQwerty::currentKeyboardType() const |
588 HbKeyboardType HbVirtualQwerty::currentKeyboardType() const |
568 { |
589 { |
587 { |
608 { |
588 //before launching candidate popup, close exact word popup if visible. |
609 //before launching candidate popup, close exact word popup if visible. |
589 closeExactWordPopup(); |
610 closeExactWordPopup(); |
590 if (!mCandidatePopup) { |
611 if (!mCandidatePopup) { |
591 mCandidatePopup = new HbCandidateList(this); |
612 mCandidatePopup = new HbCandidateList(this); |
592 connect(mCandidatePopup, SIGNAL(candidatePopupCancelled()), this, SLOT(candidatePopupCancelled())); |
613 connect(mCandidatePopup, SIGNAL(candidatePopupCancelled()), this, SLOT(restorePreviousState())); |
593 connect(mCandidatePopup, SIGNAL(candidateSelected(int,const QString&)), this, SLOT(candidatePopupClosed(int, const QString&))); |
614 connect(mCandidatePopup, SIGNAL(candidateSelected(int,const QString&)), this, SLOT(candidatePopupClosed(int, const QString&))); |
594 } |
615 } |
595 mCandidatePopup->populateList(candidates); |
616 mCandidatePopup->populateList(candidates); |
596 mCandidatePopup->setModal(true); |
617 mCandidatePopup->setModal(true); |
597 |
618 |
627 The call back from framework to indicate that the orientation is about to change. This closes the keypad |
648 The call back from framework to indicate that the orientation is about to change. This closes the keypad |
628 if it is already open. |
649 if it is already open. |
629 */ |
650 */ |
630 void HbVirtualQwerty::orientationAboutToChange() |
651 void HbVirtualQwerty::orientationAboutToChange() |
631 { |
652 { |
632 HbInputMethod::orientationAboutToChange(); |
|
633 |
|
634 if (isActiveMethod()) { |
|
635 mOrientationAboutToChange = true; |
|
636 // We need to commit the inline word before orientation change. |
|
637 mActiveModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionCommit); |
|
638 closeKeypad(); |
|
639 } |
|
640 } |
|
641 |
|
642 /*! |
|
643 Slot used by virtual rocker to move cursor. |
|
644 */ |
|
645 void HbVirtualQwerty::rockerDirection(int aDirection, HbInputVirtualRocker::RockerSelectionMode aSelectionMode) |
|
646 { |
|
647 Qt::KeyboardModifiers modifiers = 0; |
|
648 if (aSelectionMode == HbInputVirtualRocker::RockerSelectionModeOn) { |
|
649 modifiers = Qt::ShiftModifier; |
|
650 } |
|
651 // commit any character/word which is in inline edit. |
|
652 mActiveModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionCommit); |
|
653 HbInputLanguage inputlang = HbInputSettingProxy::instance()->globalInputLanguage(); |
|
654 |
|
655 switch (aDirection) { |
|
656 case HbInputVirtualRocker::HbRockerDirectionLeft: |
|
657 if(inputlang.isRightToLeftLanguage()) { |
|
658 focusObject()->cursorRight(modifiers); |
|
659 } else { |
|
660 focusObject()->cursorLeft(modifiers); |
|
661 } |
|
662 break; |
|
663 case HbInputVirtualRocker::HbRockerDirectionRight: |
|
664 if(inputlang.isRightToLeftLanguage()) { |
|
665 focusObject()->cursorLeft(modifiers); |
|
666 } else { |
|
667 focusObject()->cursorRight(modifiers); |
|
668 } |
|
669 break; |
|
670 case HbInputVirtualRocker::HbRockerDirectionUp: { |
|
671 QKeyEvent keyEvent(QEvent::KeyPress, Qt::Key_Up, modifiers); |
|
672 focusObject()->sendEvent(keyEvent); |
|
673 } |
|
674 break; |
|
675 case HbInputVirtualRocker::HbRockerDirectionDown: { |
|
676 QKeyEvent keyEvent(QEvent::KeyPress, Qt::Key_Down, modifiers); |
|
677 focusObject()->sendEvent(keyEvent); |
|
678 } |
|
679 break; |
|
680 default: |
|
681 break; |
|
682 } |
|
683 } |
653 } |
684 |
654 |
685 /*! |
655 /*! |
686 The framework calls this method when the predictive input status changes. |
656 The framework calls this method when the predictive input status changes. |
687 */ |
657 */ |
698 } |
668 } |
699 } |
669 } |
700 |
670 |
701 void HbVirtualQwerty::primaryCandidateModeChanged(HbPrimaryCandidateMode mode) |
671 void HbVirtualQwerty::primaryCandidateModeChanged(HbPrimaryCandidateMode mode) |
702 { |
672 { |
703 mPredictionModeHandler->setPrimaryCandidateMode(mode); |
673 mPredictionModeHandler->setPrimaryCandidateMode(mode); |
704 } |
674 } |
705 |
675 |
706 void HbVirtualQwerty::autocompletionStateChanged(HbKeyboardSettingFlags keyboardType, bool newState) |
676 void HbVirtualQwerty::autocompletionStateChanged(HbKeyboardSettingFlags keyboardType, bool newState) |
707 { |
677 { |
708 if (keyboardType & HbKeyboardSettingQwerty) { |
678 if ( isActiveMethod() && (keyboardType & HbKeyboardSettingQwerty) ){ |
709 mPredictionModeHandler->setAutocompletionStatus(newState); |
679 mPredictionModeHandler->setAutocompletionStatus(newState); |
710 } |
680 } |
711 } |
681 } |
712 |
682 |
713 void HbVirtualQwerty::typingCorrectionLevelChanged(HbTypingCorrectionLevel correctionLevel) |
683 void HbVirtualQwerty::typingCorrectionLevelChanged(HbTypingCorrectionLevel correctionLevel) |
732 */ |
702 */ |
733 void HbVirtualQwerty::launchExactWordPopup(QString exactWord) |
703 void HbVirtualQwerty::launchExactWordPopup(QString exactWord) |
734 { |
704 { |
735 if (!mExactWordPopup) { |
705 if (!mExactWordPopup) { |
736 mExactWordPopup = HbExactWordPopup::instance(); |
706 mExactWordPopup = HbExactWordPopup::instance(); |
|
707 mExactWordPopup->setPreferredHeight(HbDeviceProfile::profile( |
|
708 mCurrentKeypad->mainWindow()).logicalSize().height() * HbExactPopupHeightFactor); |
737 connect(mExactWordPopup, SIGNAL(exactWordSelected()), mPredictionModeHandler, SLOT(exactWordSelected())); |
709 connect(mExactWordPopup, SIGNAL(exactWordSelected()), mPredictionModeHandler, SLOT(exactWordSelected())); |
738 } |
710 } |
739 mExactWordPopup->setText(exactWord); |
711 mExactWordPopup->setText(exactWord); |
740 mExactWordPopup->showText(getCursorCoordinatePosition()); |
712 mExactWordPopup->showText(getCursorCoordinatePosition()); |
741 } |
713 } |
750 } |
722 } |
751 } |
723 } |
752 |
724 |
753 QPointF HbVirtualQwerty::getCursorCoordinatePosition() |
725 QPointF HbVirtualQwerty::getCursorCoordinatePosition() |
754 { |
726 { |
|
727 QPointF cursorPos(0.0, 0.0); |
755 QRectF microRect = focusObject()->microFocus(); |
728 QRectF microRect = focusObject()->microFocus(); |
756 QPointF cursorPos = microRect.topLeft(); |
729 microRect.adjust(0.0, -HbEditorExtraMargin, 0.0, HbEditorExtraMargin); |
757 |
730 |
758 if (mVkbHost) { |
731 if (mVkbHost) { |
|
732 QRectF activeViewRect= mVkbHost->applicationArea(); |
|
733 qreal exactPopupHeight = HbDeviceProfile::profile( |
|
734 mCurrentKeypad->mainWindow()).logicalSize().height() * HbExactPopupHeightFactor; |
|
735 qreal topArea = microRect.top() - activeViewRect.top(); |
|
736 qreal bottomArea = activeViewRect.bottom() - microRect.bottom(); |
|
737 qreal xPos = microRect.left(); |
|
738 cursorPos.setX(xPos); |
759 QSizeF exactPopupSize = mExactWordPopup->size(); |
739 QSizeF exactPopupSize = mExactWordPopup->size(); |
760 QRectF activeViewRect = mVkbHost->applicationArea(); |
740 |
761 // if the exact word doesnt fit inside the visible area, then show it on the right side of |
741 // show the exact word popup either above or below the currently focused editor if both fits in the visible area. |
762 // the current cursor position |
742 // If enough space is not available, then show the exact word popup inside the focused editor |
763 if (microRect.left() + exactPopupSize.width() > activeViewRect.width()) { |
743 if (topArea > exactPopupHeight || bottomArea > exactPopupHeight) { |
764 qreal startPos = microRect.left() - exactPopupSize.width(); |
744 // show the popup above the editor if more space available |
765 cursorPos.setX((startPos > activeViewRect.left()) ? startPos : activeViewRect.left()); |
745 if (topArea > exactPopupHeight) { |
766 } |
746 cursorPos.setY(microRect.topLeft().y() - exactPopupHeight); |
|
747 } else { |
|
748 cursorPos.setY(microRect.bottomLeft().y()); |
|
749 } |
|
750 // if there is no space to show the exact word popup in the right side of the cursor |
|
751 // recatangle, then show it on the left side of the cursor |
|
752 if (xPos + exactPopupSize.width() > activeViewRect.width()) { |
|
753 cursorPos.setX(xPos - exactPopupSize.width()); |
|
754 } |
|
755 } else { |
|
756 // show the exact word popup inside the editor |
|
757 cursorPos.setY(microRect.top() + (microRect.height() / 2) - (exactPopupHeight / 2)); |
|
758 xPos = xPos + HbDeltaWidth; |
|
759 if (xPos + exactPopupSize.width() > activeViewRect.width()) { |
|
760 qreal startPos = microRect.left() - (3 * exactPopupSize.width()) - HbDeltaWidth; |
|
761 cursorPos.setX((startPos > activeViewRect.left()) ? startPos : activeViewRect.left()); |
|
762 } |
|
763 } |
767 } |
764 } |
768 return cursorPos; |
765 return cursorPos; |
769 } |
766 } |
|
767 |
770 |
768 |
771 /*! |
769 /*! |
772 Returns true if prediction is on, prediction engine is available and predictions is allowed in current editor. |
770 Returns true if prediction is on, prediction engine is available and predictions is allowed in current editor. |
773 */ |
771 */ |
774 bool HbVirtualQwerty::usePrediction() const |
772 bool HbVirtualQwerty::usePrediction() const |
793 QList<HbKeyPressProbability> HbVirtualQwerty::probableKeypresses() |
791 QList<HbKeyPressProbability> HbVirtualQwerty::probableKeypresses() |
794 { |
792 { |
795 return mCurrentKeypad->probableKeypresses(); |
793 return mCurrentKeypad->probableKeypresses(); |
796 } |
794 } |
797 |
795 |
798 void HbVirtualQwerty::candidatePopupCancelled() |
796 void HbVirtualQwerty::restorePreviousState() |
799 { |
797 { |
800 if(mPredictionModeHandler) { |
798 mActiveModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionRestorePreviousState); |
801 mPredictionModeHandler->showExactWordPopupIfNeeded(); |
799 } |
802 } |
800 |
803 } |
801 void HbVirtualQwerty::createSctKeypad() |
|
802 { |
|
803 if (!mSctKeypad) { |
|
804 mSctKeypad = new HbSctKeyboard(this, mKeymap); |
|
805 connect(mSctKeypad, SIGNAL(smileySelected(QString)), this, SLOT(smileySelected(QString))); |
|
806 connect(mSctKeypad, SIGNAL(keypadCloseEventDetected(HbInputVkbWidget::HbVkbCloseMethod)), this, SLOT(keypadCloseEventDetected(HbInputVkbWidget::HbVkbCloseMethod))); |
|
807 } |
|
808 mSctKeypad->setMode(EModeAbc, HbModifierNone); |
|
809 } |
|
810 |
804 // End of file |
811 // End of file |
|
812 |
|
813 |
|
814 |