src/hbplugins/inputmethods/touchinput/virtual12key.cpp
changeset 34 ed14f46c0e55
parent 7 923ff622b8b9
equal deleted inserted replaced
31:7516d6d86cf5 34:ed14f46c0e55
    64 HbVirtual12Key::HbVirtual12Key()
    64 HbVirtual12Key::HbVirtual12Key()
    65               : mCurrentKeypad(0),
    65               : mCurrentKeypad(0),
    66                 mItutKeypad(0),
    66                 mItutKeypad(0),
    67                 mSctKeypad(0),
    67                 mSctKeypad(0),
    68                 mKeymap(0),
    68                 mKeymap(0),
    69                 mOrientationAboutToChange(false),
       
    70                 mCandidatePopup(0),
    69                 mCandidatePopup(0),
    71                 mCurrentlyFocused(0),
    70                 mCurrentlyFocused(0),
    72                 mVkbHost(0),
    71                 mVkbHost(0)
    73                 mKeyboardChangeAlreadyInprogress(false)
       
    74 {
    72 {
    75     initializeModeHandlers();
    73     initializeModeHandlers();
    76 }
    74 }
    77 
    75 
    78 void HbVirtual12Key::initializeModeHandlers()
    76 void HbVirtual12Key::initializeModeHandlers()
    79 {
    77 {
    80     mBasicModeHandler = new HbInputBasic12KeyHandler(this);
    78     mBasicModeHandler = new HbInputBasic12KeyHandler(this);
    81     mPredictionModeHandler = new HbInputPrediction12KeyHandler(this);
    79     mPredictionModeHandler = new HbInputPrediction12KeyHandler(this);
    82     mNumericModeHandler = new HbInputNumeric12KeyHandler(this);
    80     mNumericModeHandler = new HbInputNumeric12KeyHandler(this);
    83 	   
    81        
    84     mActiveModeHandler = mBasicModeHandler;
    82     mActiveModeHandler = mBasicModeHandler;
    85 
    83 
    86     mBasicModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionInit);
    84     mBasicModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionInit);
    87     mPredictionModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionInit);
    85     mPredictionModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionInit);
    88     mNumericModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionInit);
    86     mNumericModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionInit);
   122     delete mBasicModeHandler;
   120     delete mBasicModeHandler;
   123     mBasicModeHandler = 0;
   121     mBasicModeHandler = 0;
   124     delete mPredictionModeHandler;
   122     delete mPredictionModeHandler;
   125     mPredictionModeHandler = 0;
   123     mPredictionModeHandler = 0;
   126     delete mNumericModeHandler;
   124     delete mNumericModeHandler;
   127     mNumericModeHandler = 0;	
   125     mNumericModeHandler = 0;    
   128 }
   126 }
   129 
   127 
   130 /*!
   128 /*!
   131 Implementation of the pure virtual QInputContext::identifierName()
   129 Implementation of the pure virtual QInputContext::identifierName()
   132 Returns a string which specifies an identifier for the input method.
   130 Returns a string which specifies an identifier for the input method.
   163 state of the input method.
   161 state of the input method.
   164 */
   162 */
   165 void HbVirtual12Key::reset()
   163 void HbVirtual12Key::reset()
   166 {
   164 {
   167     mActiveModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionReset);
   165     mActiveModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionReset);
   168     mOrientationAboutToChange = false;
   166     // close candidate popup if visible
       
   167     closeCandidatePopup();
   169 }
   168 }
   170 
   169 
   171 Hb12KeyTouchKeyboard *HbVirtual12Key::construct12Keyboard()
   170 Hb12KeyTouchKeyboard *HbVirtual12Key::construct12Keyboard()
   172 {
   171 {
   173     Hb12KeyTouchKeyboard *tempKeypad = new Hb12KeyTouchKeyboard(this, mKeymap);
   172     Hb12KeyTouchKeyboard *tempKeypad = new Hb12KeyTouchKeyboard(this, mKeymap);
   174     connect(tempKeypad, SIGNAL(keypadCloseEventDetected(HbInputVkbWidget::HbVkbCloseMethod)),
   173     connect(tempKeypad, SIGNAL(keypadCloseEventDetected(HbInputVkbWidget::HbVkbCloseMethod)),
   175             this, SLOT(keypadCloseEventDetected(HbInputVkbWidget::HbVkbCloseMethod)));
   174             this, SLOT(keypadCloseEventDetected(HbInputVkbWidget::HbVkbCloseMethod)));
   176     connect(tempKeypad, SIGNAL(rockerDirection(int, HbInputVirtualRocker::RockerSelectionMode)),
       
   177             this, SLOT(rockerDirection(int, HbInputVirtualRocker::RockerSelectionMode)));
       
   178     //FLICKDISABLED connect(tempKeypad, SIGNAL(flickEvent(HbInputVkbWidget::FlickDirection)), this, SLOT(flickEvent(HbInputVkbWidget::FlickDirection)));
   175     //FLICKDISABLED connect(tempKeypad, SIGNAL(flickEvent(HbInputVkbWidget::FlickDirection)), this, SLOT(flickEvent(HbInputVkbWidget::FlickDirection)));
   179     connect(tempKeypad, SIGNAL(smileySelected(QString)), this, SLOT(smileySelected(QString)));
   176     connect(tempKeypad, SIGNAL(smileySelected(QString)), this, SLOT(smileySelected(QString)));
   180     connect(tempKeypad, SIGNAL(mouseMovedOutOfButton()), this, SLOT(mouseMovedOutOfButton()));
   177     connect(tempKeypad, SIGNAL(mouseMovedOutOfButton()), this, SLOT(mouseMovedOutOfButton()));
   181     tempKeypad->setRockerVisible(true);
   178     connect(tempKeypad, SIGNAL(settingsListClosed()), this, SLOT(restorePreviousState()));
       
   179 
   182     return tempKeypad;
   180     return tempKeypad;
   183 }
   181 }
   184 
   182 
   185 /*!
   183 /*!
   186 Virtual 12-key specific implementation of HbInputMethod::focusReceived().
   184 Virtual 12-key specific implementation of HbInputMethod::focusReceived().
   202     }
   200     }
   203 
   201 
   204     //Get vkbhost
   202     //Get vkbhost
   205     mVkbHost = focusObject()->editorInterface().vkbHost();
   203     mVkbHost = focusObject()->editorInterface().vkbHost();
   206 
   204 
       
   205     // See if the editor prefers numeric mode when focused.  
       
   206     Qt::InputMethodHints hints = focusObject()->inputMethodHints();
       
   207     if(hints & Qt::ImhPreferNumbers && HbInputModeNumeric != inputState().inputMode()) {
       
   208         HbInputState inputstate = inputState();
       
   209         inputstate.setInputMode(HbInputModeNumeric);
       
   210         activateState(inputstate);
       
   211     }
       
   212 
   207     if(!mItutKeypad){
   213     if(!mItutKeypad){
   208         mItutKeypad = construct12Keyboard();
   214         mItutKeypad = construct12Keyboard();
   209     }
   215     }
   210 
   216 
   211     if (!mItutKeypad) {
   217     if (!mItutKeypad) {
   217     mActiveModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionFocusRecieved);
   223     mActiveModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionFocusRecieved);
   218 
   224 
   219     if (mCurrentlyFocused != focusObject()) {
   225     if (mCurrentlyFocused != focusObject()) {
   220         mCurrentlyFocused = focusObject();
   226         mCurrentlyFocused = focusObject();
   221         // Focus changed from one editor to another.
   227         // Focus changed from one editor to another.
   222         if (mCandidatePopup) {
   228         closeCandidatePopup();
   223             mCandidatePopup->hide();
       
   224         }
       
   225     }
   229     }
   226 
   230 
   227     openKeypad(mItutKeypad);
   231     openKeypad(mItutKeypad);
   228 
   232 
   229     if (focusObject() && mVkbHost) {
   233     if (focusObject() && mVkbHost) {
   234     if (focusObject()) {
   238     if (focusObject()) {
   235         disconnect(&(focusObject()->editorInterface()), SIGNAL(cursorPositionChanged(int, int)),
   239         disconnect(&(focusObject()->editorInterface()), SIGNAL(cursorPositionChanged(int, int)),
   236                    mActiveModeHandler, SLOT(cursorPositionChanged(int, int)));
   240                    mActiveModeHandler, SLOT(cursorPositionChanged(int, int)));
   237         connect(&(focusObject()->editorInterface()), SIGNAL(cursorPositionChanged(int, int)),
   241         connect(&(focusObject()->editorInterface()), SIGNAL(cursorPositionChanged(int, int)),
   238                 mActiveModeHandler, SLOT(cursorPositionChanged(int, int)));
   242                 mActiveModeHandler, SLOT(cursorPositionChanged(int, int)));
       
   243                 
       
   244         disconnect(focusObject(), SIGNAL(orientationChanged()), this, SLOT(orientationChanged()));
       
   245         connect(focusObject(), SIGNAL(orientationChanged()), this, SLOT(orientationChanged()));
   239     }
   246     }
   240     HbInputAbstractMethod::focusReceived();
   247     HbInputAbstractMethod::focusReceived();
   241 }
   248 }
   242 
   249 
   243 /*!
   250 /*!
   261         // do any closing related things.
   268         // do any closing related things.
   262         // Then make sure that keypad closes.
   269         // Then make sure that keypad closes.
   263         closeKeypad();
   270         closeKeypad();
   264         mVkbHost = 0;
   271         mVkbHost = 0;
   265     }
   272     }
       
   273     HbInputAbstractMethod::focusLost();
   266 }
   274 }
   267 
   275 
   268 /*!
   276 /*!
   269 Closes the keypad if it is open.
   277 Closes the keypad if it is open.
   270 */
   278 */
   272 {
   280 {
   273     if (mVkbHost && mVkbHost->keypadStatus() != HbVkbHost::HbVkbStatusClosed) {
   281     if (mVkbHost && mVkbHost->keypadStatus() != HbVkbHost::HbVkbStatusClosed) {
   274         mVkbHost->closeKeypad(!stateChangeInProgress());
   282         mVkbHost->closeKeypad(!stateChangeInProgress());
   275         // set mCurrentKeypad to null.
   283         // set mCurrentKeypad to null.
   276         mCurrentKeypad = 0;
   284         mCurrentKeypad = 0;
   277         if (mCandidatePopup) {
   285         closeCandidatePopup();
   278             mCandidatePopup->hide();
       
   279         }
       
   280     }
   286     }
   281 }
   287 }
   282 
   288 
   283 /*!
   289 /*!
   284 Opens the virtual keypad for input.
   290 Opens the virtual keypad for input.
   285 */
   291 */
   286 void HbVirtual12Key::openKeypad(HbInputVkbWidget * keypadToOpen,bool inMinimizedMode)
   292 void HbVirtual12Key::openKeypad(HbInputVkbWidget * keypadToOpen)
   287 {
   293 {
   288     // if null is sent, just return.
   294     // if null is sent, just return.
   289     if(!keypadToOpen || !focusObject()) {
   295     if(!keypadToOpen || !focusObject()) {
   290         return;
   296         return;
   291     }
   297     }
   292 
       
   293     mKeyboardChangeAlreadyInprogress = true;
       
   294     HbInputSettingProxy::instance()->setActiveKeyboard(HbKeyboardVirtual12Key);
       
   295     mKeyboardChangeAlreadyInprogress = false;
       
   296 
   298 
   297     bool disableAnimation = false;
   299     bool disableAnimation = false;
   298     // see if we are trying to open a different keypad than what is already opened.
   300     // see if we are trying to open a different keypad than what is already opened.
   299     if (mCurrentKeypad != keypadToOpen) {
   301     if (mCurrentKeypad != keypadToOpen) {
   300         // close currently open keypad. We always close keypad without animation
   302         // close currently open keypad. We always close keypad without animation
   305             // when their is a keypad that needs to be closed before opening the new keypad, we don't
   307             // when their is a keypad that needs to be closed before opening the new keypad, we don't
   306             // want to animate the opening of new keypad.
   308             // want to animate the opening of new keypad.
   307             disableAnimation = true;
   309             disableAnimation = true;
   308         }
   310         }
   309     }
   311     }
       
   312     
   310     // Close candidate popup if open
   313     // Close candidate popup if open
   311     if (mCandidatePopup) {
   314     closeCandidatePopup();
   312         mCandidatePopup->hide();
   315 
   313     }
   316     if (mCurrentKeypad) {
   314 
   317         QObject::disconnect(mCurrentKeypad,SIGNAL(aboutToActivateCustomAction(HbAction*)),
   315     QObject::disconnect(mCurrentKeypad,SIGNAL(aboutToActivateCustomAction(HbAction*)),
   318             this,SLOT(aboutToActivateCustomAction(HbAction*)));
   316         this,SLOT(aboutToActivateCustomAction(HbAction*)));
   319     }
   317     QObject::connect(keypadToOpen,SIGNAL(aboutToActivateCustomAction(HbAction*)),
   320     QObject::connect(keypadToOpen,SIGNAL(aboutToActivateCustomAction(HbAction*)),
   318         this,SLOT(aboutToActivateCustomAction(HbAction*)));
   321         this,SLOT(aboutToActivateCustomAction(HbAction*)));
   319 
   322 
   320     // assign new keypad to be opened to varable mCurrentKeypad
   323     // assign new keypad to be opened to varable mCurrentKeypad
   321     mCurrentKeypad =  keypadToOpen;
   324     mCurrentKeypad =  keypadToOpen;
   322 
   325 
   323     if (mVkbHost && mVkbHost->keypadStatus() != HbVkbHost::HbVkbStatusOpened) {
   326     if (mVkbHost && mVkbHost->keypadStatus() != HbVkbHost::HbVkbStatusOpened) {
   324         connect(mVkbHost, SIGNAL(keypadClosed()), this, SLOT(keypadClosed()));
   327         connect(mVkbHost, SIGNAL(keypadClosed()), this, SLOT(keypadClosed()));
   325         connect(mVkbHost, SIGNAL(keypadOpened()), this, SLOT(keypadOpened()));
   328         connect(mVkbHost, SIGNAL(keypadOpened()), this, SLOT(keypadOpened()));
   326 
   329 
   327         if (inMinimizedMode) {
   330         mVkbHost->openKeypad(mCurrentKeypad, this, (!stateChangeInProgress() && !disableAnimation));
   328             mVkbHost->openMinimizedKeypad(mCurrentKeypad, this);
   331 
   329         } else {
       
   330             mVkbHost->openKeypad(mCurrentKeypad, this, (!stateChangeInProgress() && !disableAnimation));
       
   331         }
       
   332         if (focusObject()) {
   332         if (focusObject()) {
   333             connect(&(focusObject()->editorInterface()), SIGNAL(cursorPositionChanged(int, int)),
   333             connect(&(focusObject()->editorInterface()), SIGNAL(cursorPositionChanged(int, int)),
   334                     mVkbHost, SLOT(ensureCursorVisibility()));
   334                     mVkbHost, SLOT(ensureCursorVisibility()));
   335         }
   335         }
       
   336     }
       
   337 
       
   338     if(mActiveModeHandler) {
       
   339         mActiveModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionSetKeypad);
   336     }
   340     }
   337 }
   341 }
   338 
   342 
   339 /*!
   343 /*!
   340 vkb widget is about to call a custom action that is mapped to one of the keypad buttons.
   344 vkb widget is about to call a custom action that is mapped to one of the keypad buttons.
   370     }
   374     }
   371 }
   375 }
   372 
   376 
   373 void HbVirtual12Key::autocompletionStateChanged(HbKeyboardSettingFlags keyboardType, bool newState)
   377 void HbVirtual12Key::autocompletionStateChanged(HbKeyboardSettingFlags keyboardType, bool newState)
   374 {
   378 {
   375     if (keyboardType & HbKeyboardSetting12key) {
   379     if ( isActiveMethod() && (keyboardType & HbKeyboardSetting12key) ) {
   376         mPredictionModeHandler->setAutocompletionStatus(newState);
   380         mPredictionModeHandler->setAutocompletionStatus(newState);
   377     }
   381     }
   378 }
   382 }
   379 
   383 
   380 /*!
   384 /*!
   381 Call back indicating that the keypad is closed.
   385 Call back indicating that the keypad is closed.
   382 */
   386 */
   383 void HbVirtual12Key::keypadClosed()
   387 void HbVirtual12Key::keypadClosed()
   384 {
   388 {
   385     mOrientationAboutToChange = false;
       
   386 }
   389 }
   387 
   390 
   388 /*!
   391 /*!
   389 Call back indicating that the keypad is opened.
   392 Call back indicating that the keypad is opened.
   390 */
   393 */
   399 {
   402 {
   400     Q_UNUSED(vkbCloseMethod);
   403     Q_UNUSED(vkbCloseMethod);
   401     if (isActiveMethod()) {
   404     if (isActiveMethod()) {
   402         if (mVkbHost) {
   405         if (mVkbHost) {
   403             if (mVkbHost->keypadStatus() == HbVkbHost::HbVkbStatusOpened) {
   406             if (mVkbHost->keypadStatus() == HbVkbHost::HbVkbStatusOpened) {
   404                 // We need to commit the inline word when we minimize the keypad
       
   405                 mActiveModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionCommit);
   407                 mActiveModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionCommit);
   406                 if (mCandidatePopup) {
   408                 // close candiatelist popup if visisble.
   407                     mCandidatePopup->hide();
   409                 closeCandidatePopup();
   408                 }
       
   409 
   410 
   410                 // Close input.
   411                 // Close input.
   411                 QInputContext* ic = qApp->inputContext();
   412                 QInputContext* ic = qApp->inputContext();
   412                 if (ic) {
   413                 if (ic) {
   413                     QEvent *closeEvent = new QEvent(QEvent::CloseSoftwareInputPanel);
   414                     QEvent *closeEvent = new QEvent(QEvent::CloseSoftwareInputPanel);
   418         }
   419         }
   419     }
   420     }
   420 }
   421 }
   421 
   422 
   422 /*!
   423 /*!
   423 The rocker widget emits the signal rockerDirection when there is any rocker movement. This method catches the emitted
       
   424 signal and makes the cursor movements according to the rcker movement.
       
   425 */
       
   426 void HbVirtual12Key::rockerDirection(int aDirection, HbInputVirtualRocker::RockerSelectionMode aSelectionMode)
       
   427 {
       
   428     Qt::KeyboardModifiers modifiers = 0;
       
   429     if (aSelectionMode == HbInputVirtualRocker::RockerSelectionModeOn) {
       
   430         modifiers = Qt::ShiftModifier;
       
   431     }
       
   432     // commit any character/word which is in inline edit.
       
   433     mActiveModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionCommit);
       
   434 
       
   435     HbInputLanguage inputlang = HbInputSettingProxy::instance()->globalInputLanguage();
       
   436 
       
   437     switch (aDirection) {
       
   438     case HbInputVirtualRocker::HbRockerDirectionLeft:
       
   439         if (inputlang.isRightToLeftLanguage()) {
       
   440             focusObject()->cursorRight(modifiers);
       
   441         } else {
       
   442             focusObject()->cursorLeft(modifiers);
       
   443         }
       
   444         break;
       
   445     case HbInputVirtualRocker::HbRockerDirectionRight:
       
   446         if (inputlang.isRightToLeftLanguage()) {
       
   447             focusObject()->cursorLeft(modifiers);
       
   448         } else {
       
   449             focusObject()->cursorRight(modifiers);
       
   450         }
       
   451         break;
       
   452     case HbInputVirtualRocker::HbRockerDirectionUp: {
       
   453         QKeyEvent keyEvent(QEvent::KeyPress, Qt::Key_Up, modifiers);
       
   454         focusObject()->sendEvent(keyEvent);
       
   455         }
       
   456         break;
       
   457     case HbInputVirtualRocker::HbRockerDirectionDown: {
       
   458         QKeyEvent keyEvent(QEvent::KeyPress, Qt::Key_Down, modifiers);
       
   459         focusObject()->sendEvent(keyEvent);
       
   460         }
       
   461         break;
       
   462     default:
       
   463         break;
       
   464     }
       
   465 }
       
   466 
       
   467 /*!
       
   468 Notification from the generic input method framework indicating a change of input language.
   424 Notification from the generic input method framework indicating a change of input language.
   469 The VKB keypad needs to refreshed to show the renewed key mapping.
   425 The VKB keypad needs to refreshed to show the renewed key mapping.
   470 */
   426 */
   471 void HbVirtual12Key::inputLanguageChanged(const HbInputLanguage &newLanguage)
   427 void HbVirtual12Key::inputLanguageChanged(const HbInputLanguage &newLanguage)
   472 {
   428 {
   505 /*!
   461 /*!
   506 Notification from the generic input method framework to indicate the activation of a state.
   462 Notification from the generic input method framework to indicate the activation of a state.
   507 */
   463 */
   508 void HbVirtual12Key::inputStateActivated(const HbInputState& newState)
   464 void HbVirtual12Key::inputStateActivated(const HbInputState& newState)
   509 {
   465 {
   510     if (!isActiveMethod() || mKeyboardChangeAlreadyInprogress) {
   466     if (!isActiveMethod()) {
   511         return;  // Just to be sure...
   467         return;  // Just to be sure...
   512     }
   468     }
   513 
   469 
   514     if (mItutKeypad) {
   470     if (mItutKeypad) {
   515         if (newState.inputMode() == HbInputModeNumeric) {
   471         if (newState.inputMode() == HbInputModeNumeric) {
   521             } else {
   477             } else {
   522                 mItutKeypad->setMode(EModeAbc, HbModifierNone);
   478                 mItutKeypad->setMode(EModeAbc, HbModifierNone);
   523             }
   479             }
   524         }
   480         }
   525     }
   481     }
   526 
   482     // need to make sure that the prediction mode handler has the input state's language set 
       
   483     // it is the global input language by default
       
   484 
       
   485     if(mPredictionModeHandler && newState.language().language() != HbInputSettingProxy::instance()->globalInputLanguage().language()) {
       
   486         HbInputLanguage inputStateLang = newState.language();
       
   487         mPredictionModeHandler->setLanguage(inputStateLang);
       
   488     }
   527     HbInputModeHandler *previousModeHandler = mActiveModeHandler;
   489     HbInputModeHandler *previousModeHandler = mActiveModeHandler;
   528 	if (newState.inputMode() == HbInputModeDefault && usePrediction()) {
   490     if (newState.inputMode() == HbInputModeDefault && usePrediction()) {
   529         mActiveModeHandler = mPredictionModeHandler;        
   491         mActiveModeHandler = mPredictionModeHandler;        
   530         // by passing HbInputModeActionFocusRecieved we will be setting the candidate list and keypad
   492         // by passing HbInputModeActionFocusRecieved we will be setting the candidate list and keypad
   531         mActiveModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionFocusRecieved);
   493         mActiveModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionFocusRecieved);
       
   494         /* The below line should be added in orientationChanged Slot, however currently it is not working correctly
       
   495          hence this fix is temporarily added here */
       
   496         mPredictionModeHandler->setAutocompletionStatus(HbInputSettingProxy::instance()->isAutocompletionEnabled(HbKeyboardSetting12key));
   532     } else if (newState.inputMode() == HbInputModeDefault) {
   497     } else if (newState.inputMode() == HbInputModeDefault) {
   533         mActiveModeHandler = mBasicModeHandler;
   498         mActiveModeHandler = mBasicModeHandler;
   534         // Auto completer setup needs following line.
   499         // Auto completer setup needs following line.
   535         mActiveModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionFocusRecieved);
   500         mActiveModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionFocusRecieved);
   536     } else if (newState.inputMode() == HbInputModeNumeric) {
   501     } else if (newState.inputMode() == HbInputModeNumeric) {
   586             if (mPredictionModeHandler) {
   551             if (mPredictionModeHandler) {
   587                 mPredictionModeHandler->setKeymap(mKeymap);
   552                 mPredictionModeHandler->setKeymap(mKeymap);
   588             }
   553             }
   589             if(mNumericModeHandler) {
   554             if(mNumericModeHandler) {
   590                 mNumericModeHandler->setKeymap(mKeymap);
   555                 mNumericModeHandler->setKeymap(mKeymap);
   591             }			
   556             }           
   592         }
   557         }
   593     }
   558     }
   594 }
   559 }
   595 
   560 
   596 /*!
   561 /*!
   622 /*!
   587 /*!
   623 this slot is called by the mode handlers when there is sym key or long  press of Asterisk key.
   588 this slot is called by the mode handlers when there is sym key or long  press of Asterisk key.
   624 */
   589 */
   625 void HbVirtual12Key::switchMode(int keyCode)
   590 void HbVirtual12Key::switchMode(int keyCode)
   626 {
   591 {
   627     if (keyCode == HbInputButton::ButtonKeyCodeAsterisk ||
   592     if (keyCode == HbInputButton::ButtonKeyCodeAsterisk && mCandidatePopup && mCandidatePopup->isVisible() && mCandidatePopup->isModal()) {
   628         keyCode == HbInputButton::ButtonKeyCodeSymbol ||
   593         return;
   629         keyCode == HbInputButton::ButtonKeyCodeAlphabet) {
   594     } else if (keyCode == HbInputButton::ButtonKeyCodeAsterisk || keyCode == HbInputButton::ButtonKeyCodeSymbol || keyCode == HbInputButton::ButtonKeyCodeAlphabet) {
   630         if (mCandidatePopup && mCandidatePopup->isVisible()) {
       
   631             return;
       
   632         }
       
   633 
       
   634         if (mCurrentKeypad == mSctKeypad){
   595         if (mCurrentKeypad == mSctKeypad){
   635             // if sct is active keypad, then launch itu-t keypad
   596             // if sct is active keypad, then launch itu-t keypad
   636             switchToAlphaMode();
   597             switchToAlphaMode();
   637         } else {
   598         } else {
   638             // launch special character keypad
   599              if (keyCode == HbInputButton::ButtonKeyCodeSymbol && HbInputSettingProxy::instance()->globalInputLanguage().language() == QLocale::Chinese) {
   639             displaySpecialCharacterTable(this);
   600                  HbInputLanguage primaryInputLanguage = HbInputSettingProxy::instance()->globalInputLanguage();
       
   601                  HbInputMethod::activeInputMethod()->activateState(HbInputState(HbInputModeDefault,
       
   602                                        HbTextCaseAutomatic,
       
   603                                        HbKeyboardTouchPortrait,
       
   604                                        primaryInputLanguage));
       
   605              } else {
       
   606                  // launch special character keypad
       
   607                  displaySpecialCharacterTable(this);
       
   608              }
   640         }
   609         }
   641     } else if (keyCode == HbInputButton::ButtonKeyCodeShift) {
   610     } else if (keyCode == HbInputButton::ButtonKeyCodeShift) {
   642         HbInputState nextState = inputState();
   611         HbInputState nextState = inputState();
   643         if (nextState.inputMode() != HbInputModeNumeric) {
   612         if (nextState.inputMode() != HbInputModeNumeric) {
   644             nextState.setInputMode(HbInputModeNumeric);
   613             nextState.setInputMode(HbInputModeNumeric);
   660     if (!mSctKeypad) {
   629     if (!mSctKeypad) {
   661         mSctKeypad = new HbSctKeyboard(this, mKeymap, 0);
   630         mSctKeypad = new HbSctKeyboard(this, mKeymap, 0);
   662         connect(mSctKeypad, SIGNAL(keypadCloseEventDetected(HbInputVkbWidget::HbVkbCloseMethod)),
   631         connect(mSctKeypad, SIGNAL(keypadCloseEventDetected(HbInputVkbWidget::HbVkbCloseMethod)),
   663                 this, SLOT(keypadCloseEventDetected(HbInputVkbWidget::HbVkbCloseMethod)));
   632                 this, SLOT(keypadCloseEventDetected(HbInputVkbWidget::HbVkbCloseMethod)));
   664         connect(mSctKeypad, SIGNAL(smileySelected(QString)),
   633         connect(mSctKeypad, SIGNAL(smileySelected(QString)),
   665                 this, SLOT(smileySelected(QString)));
   634                 this, SLOT(smileySelected(QString)));     
   666         mSctKeypad->setRockerVisible(false);
       
   667     }
   635     }
   668     mSctKeypad->setMode(EModeAbc, HbModifierNone);
   636     mSctKeypad->setMode(EModeAbc, HbModifierNone);
   669     //Open the keypad
   637     //Open the keypad
   670     openKeypad(mSctKeypad);
   638     openKeypad(mSctKeypad);
   671 
   639 
   673 }
   641 }
   674 
   642 
   675 /*!
   643 /*!
   676 Switches the keypad to the alphabetic / normal input mode.
   644 Switches the keypad to the alphabetic / normal input mode.
   677 */
   645 */
   678 void HbVirtual12Key::switchToAlphaMode( bool openAlphaInMinimizedMode)
   646 void HbVirtual12Key::switchToAlphaMode()
   679 {
   647 {
   680     //Open the keypad
   648     //Open the keypad
   681     openKeypad(mItutKeypad,openAlphaInMinimizedMode);
   649     openKeypad(mItutKeypad);
   682 }
   650 }
   683 
   651 
   684 /*!
   652 /*!
   685 The call back from framework to indicate that the orientation is about to change. This closes the keypad
   653 The call back from framework to indicate that the orientation is changed.
   686 if it is already open.
   654 */
   687 */
   655 void HbVirtual12Key::orientationChanged()
   688 void HbVirtual12Key::orientationAboutToChange()
   656 {
   689 {
   657     //Close the spell Query if it is visible
   690     HbInputMethod::orientationAboutToChange();
   658     //During the change of orientation focus is locked by the framework and hence the spell query 
   691     if (isActiveMethod()) {
   659     //cannot be closed. Closing spell query should result in change of focus back to the previous editor 
   692         mOrientationAboutToChange = true;
   660     //which is not possible if focus is locked.
   693         mPredictionModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionCloseSpellQuery);
   661     mPredictionModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionCloseSpellQuery);
   694         // We need to commit the inline word before orientation change.
       
   695         mActiveModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionCommit);
       
   696         closeKeypad();
       
   697     }
       
   698 }
   662 }
   699 
   663 
   700 /*!
   664 /*!
   701 Launches the candidate list.
   665 Launches the candidate list.
   702 */
   666 */
   703 void HbVirtual12Key::launchCandidatePopup(const QStringList& candidates)
   667 void HbVirtual12Key::launchCandidatePopup(const QStringList& candidates)
   704 {
   668 {
   705     if (!mCandidatePopup) {
   669     if (!mCandidatePopup) {
   706         mCandidatePopup = new HbCandidateList(this);
   670         mCandidatePopup = new HbCandidateList(this);
       
   671         connect(mCandidatePopup, SIGNAL(candidatePopupCancelled()), this, SLOT(restorePreviousState()));
   707         connect(mCandidatePopup, SIGNAL(candidateSelected(int,QString)), this, SLOT(candidatePopupClosed(int,QString)));
   672         connect(mCandidatePopup, SIGNAL(candidateSelected(int,QString)), this, SLOT(candidatePopupClosed(int,QString)));
   708         QObject::connect(mCandidatePopup,SIGNAL(launchSpellQueryDialog()),mPredictionModeHandler,SLOT(launchSpellQueryDialog()));		
   673         QObject::connect(mCandidatePopup,SIGNAL(launchSpellQueryDialog()),mPredictionModeHandler,SLOT(launchSpellQueryDialog()));       
   709     }
   674     }
   710     mCandidatePopup->populateList(candidates,true);
   675     mCandidatePopup->populateList(candidates,true);
   711     mCandidatePopup->setModal(true);
   676     mCandidatePopup->setModal(true);
   712 
   677 
   713     QSizeF candListSize = mCandidatePopup->size();
   678     QSizeF candListSize = mCandidatePopup->size();
   747 }
   712 }
   748 
   713 
   749 void HbVirtual12Key::secondaryInputLanguageChanged(const HbInputLanguage &newLanguage)
   714 void HbVirtual12Key::secondaryInputLanguageChanged(const HbInputLanguage &newLanguage)
   750 {
   715 {
   751     Q_UNUSED(newLanguage);
   716     Q_UNUSED(newLanguage);
       
   717     // inform mode handler about the language change.
       
   718     mPredictionModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionCommit);
   752     mPredictionModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionSecondaryLanguageChanged);
   719     mPredictionModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionSecondaryLanguageChanged);
   753 }
   720 }
   754 
   721 
   755 void HbVirtual12Key::smileySelected(QString smiley)
   722 void HbVirtual12Key::smileySelected(QString smiley)
   756 {
   723 {
   763         mItutKeypad->showSmileyPicker();
   730         mItutKeypad->showSmileyPicker();
   764     }
   731     }
   765 }
   732 }
   766 
   733 
   767 /*!
   734 /*!
   768 Slot used by mode handlers to close the candidate popup.
   735 Closes the candidate popup if visible.
   769 */
   736 */
   770 void HbVirtual12Key::closeCandidatePopup()
   737 void HbVirtual12Key::closeCandidatePopup()
   771 {
   738 {
   772     if (mCandidatePopup && mCandidatePopup->isVisible()) {
   739     if (mCandidatePopup && mCandidatePopup->isVisible()) {
   773         mCandidatePopup->hide();
   740         mCandidatePopup->hide();
   787 */
   754 */
   788 void HbVirtual12Key::launchAutoCompletionPopup(const QStringList& candidates)
   755 void HbVirtual12Key::launchAutoCompletionPopup(const QStringList& candidates)
   789 {
   756 {
   790     if (!mCandidatePopup) {
   757     if (!mCandidatePopup) {
   791         mCandidatePopup = new HbCandidateList(this);
   758         mCandidatePopup = new HbCandidateList(this);
       
   759         connect(mCandidatePopup, SIGNAL(candidatePopupCancelled()), this, SLOT(restorePreviousState()));
   792         connect(mCandidatePopup, SIGNAL(candidateSelected(int,QString)), this, SLOT(candidatePopupClosed(int,QString)));
   760         connect(mCandidatePopup, SIGNAL(candidateSelected(int,QString)), this, SLOT(candidatePopupClosed(int,QString)));
   793         QObject::connect(mCandidatePopup,SIGNAL(launchSpellQueryDialog()),mPredictionModeHandler,SLOT(launchSpellQueryDialog()));		
   761         QObject::connect(mCandidatePopup,SIGNAL(launchSpellQueryDialog()),mPredictionModeHandler,SLOT(launchSpellQueryDialog()));       
   794     }
   762     }
   795 
   763 
   796     if (candidates.count() > 0) {
   764     if (candidates.count() > 0) {
   797         mCandidatePopup->populateList(candidates);
   765         mCandidatePopup->populateList(candidates);
   798         mCandidatePopup->setModal(false);
   766         mCandidatePopup->setModal(false);
   800         if (mCandidatePopup->setSizeAndPositionForAutoCompletion(mVkbHost)) {
   768         if (mCandidatePopup->setSizeAndPositionForAutoCompletion(mVkbHost)) {
   801             mCandidatePopup->setDismissPolicy(HbPopup::TapInside);
   769             mCandidatePopup->setDismissPolicy(HbPopup::TapInside);
   802             mCandidatePopup->setBackgroundFaded(false);
   770             mCandidatePopup->setBackgroundFaded(false);
   803             mCandidatePopup->show();
   771             mCandidatePopup->show();
   804         }
   772         }
   805     } else if (mCandidatePopup->isVisible()) {
   773     } else {
   806         mCandidatePopup->hide();
   774         closeCandidatePopup();
   807     }
   775     }
   808 }
   776 }
   809 
   777 
   810 /*!
   778 /*!
   811 Returns true if prediction is on, prediction engine is available and predictions is allowed in current editor.
   779 Returns true if prediction is on, prediction engine is available and predictions is allowed in current editor.
   821     }
   789     }
   822 
   790 
   823     return false;
   791     return false;
   824 }
   792 }
   825 
   793 
       
   794 void HbVirtual12Key::restorePreviousState()
       
   795 {
       
   796     mActiveModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionRestorePreviousState);
       
   797 }
   826 // End of file
   798 // End of file