src/hbplugins/inputmethods/touchinput/virtual12key.cpp
changeset 23 e6ad4ef83b23
parent 21 4633027730f5
child 30 80e4d18b72f5
equal deleted inserted replaced
21:4633027730f5 23:e6ad4ef83b23
    66                 mItutKeypad(0),
    66                 mItutKeypad(0),
    67                 mSctKeypad(0),
    67                 mSctKeypad(0),
    68                 mKeymap(0),
    68                 mKeymap(0),
    69                 mCandidatePopup(0),
    69                 mCandidatePopup(0),
    70                 mCurrentlyFocused(0),
    70                 mCurrentlyFocused(0),
    71                 mVkbHost(0),
    71                 mVkbHost(0)
    72                 mKeyboardChangeAlreadyInprogress(false)
       
    73 {
    72 {
    74     initializeModeHandlers();
    73     initializeModeHandlers();
    75 }
    74 }
    76 
    75 
    77 void HbVirtual12Key::initializeModeHandlers()
    76 void HbVirtual12Key::initializeModeHandlers()
    78 {
    77 {
    79     mBasicModeHandler = new HbInputBasic12KeyHandler(this);
    78     mBasicModeHandler = new HbInputBasic12KeyHandler(this);
    80     mPredictionModeHandler = new HbInputPrediction12KeyHandler(this);
    79     mPredictionModeHandler = new HbInputPrediction12KeyHandler(this);
    81     mNumericModeHandler = new HbInputNumeric12KeyHandler(this);
    80     mNumericModeHandler = new HbInputNumeric12KeyHandler(this);
    82 	   
    81        
    83     mActiveModeHandler = mBasicModeHandler;
    82     mActiveModeHandler = mBasicModeHandler;
    84 
    83 
    85     mBasicModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionInit);
    84     mBasicModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionInit);
    86     mPredictionModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionInit);
    85     mPredictionModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionInit);
    87     mNumericModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionInit);
    86     mNumericModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionInit);
   121     delete mBasicModeHandler;
   120     delete mBasicModeHandler;
   122     mBasicModeHandler = 0;
   121     mBasicModeHandler = 0;
   123     delete mPredictionModeHandler;
   122     delete mPredictionModeHandler;
   124     mPredictionModeHandler = 0;
   123     mPredictionModeHandler = 0;
   125     delete mNumericModeHandler;
   124     delete mNumericModeHandler;
   126     mNumericModeHandler = 0;	
   125     mNumericModeHandler = 0;    
   127 }
   126 }
   128 
   127 
   129 /*!
   128 /*!
   130 Implementation of the pure virtual QInputContext::identifierName()
   129 Implementation of the pure virtual QInputContext::identifierName()
   131 Returns a string which specifies an identifier for the input method.
   130 Returns a string which specifies an identifier for the input method.
   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     connect(tempKeypad, SIGNAL(settingsListClosed()), this, SLOT(restorePreviousState()));
   178     connect(tempKeypad, SIGNAL(settingsListClosed()), this, SLOT(restorePreviousState()));
   182     tempKeypad->setRockerVisible(true);
   179 
   183     return tempKeypad;
   180     return tempKeypad;
   184 }
   181 }
   185 
   182 
   186 /*!
   183 /*!
   187 Virtual 12-key specific implementation of HbInputMethod::focusReceived().
   184 Virtual 12-key specific implementation of HbInputMethod::focusReceived().
   288 {
   285 {
   289     // if null is sent, just return.
   286     // if null is sent, just return.
   290     if(!keypadToOpen || !focusObject()) {
   287     if(!keypadToOpen || !focusObject()) {
   291         return;
   288         return;
   292     }
   289     }
   293 
       
   294     mKeyboardChangeAlreadyInprogress = true;
       
   295     HbInputSettingProxy::instance()->setActiveKeyboard(HbKeyboardVirtual12Key);
       
   296     mKeyboardChangeAlreadyInprogress = false;
       
   297 
   290 
   298     bool disableAnimation = false;
   291     bool disableAnimation = false;
   299     // see if we are trying to open a different keypad than what is already opened.
   292     // see if we are trying to open a different keypad than what is already opened.
   300     if (mCurrentKeypad != keypadToOpen) {
   293     if (mCurrentKeypad != keypadToOpen) {
   301         // close currently open keypad. We always close keypad without animation
   294         // close currently open keypad. We always close keypad without animation
   420         }
   413         }
   421     }
   414     }
   422 }
   415 }
   423 
   416 
   424 /*!
   417 /*!
   425 The rocker widget emits the signal rockerDirection when there is any rocker movement. This method catches the emitted
       
   426 signal and makes the cursor movements according to the rcker movement.
       
   427 */
       
   428 void HbVirtual12Key::rockerDirection(int aDirection, HbInputVirtualRocker::RockerSelectionMode aSelectionMode)
       
   429 {
       
   430     Qt::KeyboardModifiers modifiers = 0;
       
   431     if (aSelectionMode == HbInputVirtualRocker::RockerSelectionModeOn) {
       
   432         modifiers = Qt::ShiftModifier;
       
   433     }
       
   434     // commit any character/word which is in inline edit.
       
   435     mActiveModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionCommit);
       
   436 
       
   437     HbInputLanguage inputlang = HbInputSettingProxy::instance()->globalInputLanguage();
       
   438 
       
   439     switch (aDirection) {
       
   440     case HbInputVirtualRocker::HbRockerDirectionLeft:
       
   441         if (inputlang.isRightToLeftLanguage()) {
       
   442             focusObject()->cursorRight(modifiers);
       
   443         } else {
       
   444             focusObject()->cursorLeft(modifiers);
       
   445         }
       
   446         break;
       
   447     case HbInputVirtualRocker::HbRockerDirectionRight:
       
   448         if (inputlang.isRightToLeftLanguage()) {
       
   449             focusObject()->cursorLeft(modifiers);
       
   450         } else {
       
   451             focusObject()->cursorRight(modifiers);
       
   452         }
       
   453         break;
       
   454     case HbInputVirtualRocker::HbRockerDirectionUp: {
       
   455         QKeyEvent keyEvent(QEvent::KeyPress, Qt::Key_Up, modifiers);
       
   456         focusObject()->sendEvent(keyEvent);
       
   457         }
       
   458         break;
       
   459     case HbInputVirtualRocker::HbRockerDirectionDown: {
       
   460         QKeyEvent keyEvent(QEvent::KeyPress, Qt::Key_Down, modifiers);
       
   461         focusObject()->sendEvent(keyEvent);
       
   462         }
       
   463         break;
       
   464     default:
       
   465         break;
       
   466     }
       
   467 }
       
   468 
       
   469 /*!
       
   470 Notification from the generic input method framework indicating a change of input language.
   418 Notification from the generic input method framework indicating a change of input language.
   471 The VKB keypad needs to refreshed to show the renewed key mapping.
   419 The VKB keypad needs to refreshed to show the renewed key mapping.
   472 */
   420 */
   473 void HbVirtual12Key::inputLanguageChanged(const HbInputLanguage &newLanguage)
   421 void HbVirtual12Key::inputLanguageChanged(const HbInputLanguage &newLanguage)
   474 {
   422 {
   507 /*!
   455 /*!
   508 Notification from the generic input method framework to indicate the activation of a state.
   456 Notification from the generic input method framework to indicate the activation of a state.
   509 */
   457 */
   510 void HbVirtual12Key::inputStateActivated(const HbInputState& newState)
   458 void HbVirtual12Key::inputStateActivated(const HbInputState& newState)
   511 {
   459 {
   512     if (!isActiveMethod() || mKeyboardChangeAlreadyInprogress) {
   460     if (!isActiveMethod()) {
   513         return;  // Just to be sure...
   461         return;  // Just to be sure...
   514     }
   462     }
   515 
   463 
   516     if (mItutKeypad) {
   464     if (mItutKeypad) {
   517         if (newState.inputMode() == HbInputModeNumeric) {
   465         if (newState.inputMode() == HbInputModeNumeric) {
   525             }
   473             }
   526         }
   474         }
   527     }
   475     }
   528 
   476 
   529     HbInputModeHandler *previousModeHandler = mActiveModeHandler;
   477     HbInputModeHandler *previousModeHandler = mActiveModeHandler;
   530 	if (newState.inputMode() == HbInputModeDefault && usePrediction()) {
   478     if (newState.inputMode() == HbInputModeDefault && usePrediction()) {
   531         mActiveModeHandler = mPredictionModeHandler;        
   479         mActiveModeHandler = mPredictionModeHandler;        
   532         // by passing HbInputModeActionFocusRecieved we will be setting the candidate list and keypad
   480         // by passing HbInputModeActionFocusRecieved we will be setting the candidate list and keypad
   533         mActiveModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionFocusRecieved);
   481         mActiveModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionFocusRecieved);
   534 		/* The below line should be added in orientationChanged Slot, however currently it is not working correctly
   482         /* The below line should be added in orientationChanged Slot, however currently it is not working correctly
   535 		 hence this fix is temporarily added here */
   483          hence this fix is temporarily added here */
   536         mPredictionModeHandler->setAutocompletionStatus(HbInputSettingProxy::instance()->isAutocompletionEnabled(HbKeyboardSetting12key));
   484         mPredictionModeHandler->setAutocompletionStatus(HbInputSettingProxy::instance()->isAutocompletionEnabled(HbKeyboardSetting12key));
   537     } else if (newState.inputMode() == HbInputModeDefault) {
   485     } else if (newState.inputMode() == HbInputModeDefault) {
   538         mActiveModeHandler = mBasicModeHandler;
   486         mActiveModeHandler = mBasicModeHandler;
   539         // Auto completer setup needs following line.
   487         // Auto completer setup needs following line.
   540         mActiveModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionFocusRecieved);
   488         mActiveModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionFocusRecieved);
   591             if (mPredictionModeHandler) {
   539             if (mPredictionModeHandler) {
   592                 mPredictionModeHandler->setKeymap(mKeymap);
   540                 mPredictionModeHandler->setKeymap(mKeymap);
   593             }
   541             }
   594             if(mNumericModeHandler) {
   542             if(mNumericModeHandler) {
   595                 mNumericModeHandler->setKeymap(mKeymap);
   543                 mNumericModeHandler->setKeymap(mKeymap);
   596             }			
   544             }           
   597         }
   545         }
   598     }
   546     }
   599 }
   547 }
   600 
   548 
   601 /*!
   549 /*!
   634     } else if (keyCode == HbInputButton::ButtonKeyCodeAsterisk || keyCode == HbInputButton::ButtonKeyCodeSymbol || keyCode == HbInputButton::ButtonKeyCodeAlphabet) {
   582     } else if (keyCode == HbInputButton::ButtonKeyCodeAsterisk || keyCode == HbInputButton::ButtonKeyCodeSymbol || keyCode == HbInputButton::ButtonKeyCodeAlphabet) {
   635         if (mCurrentKeypad == mSctKeypad){
   583         if (mCurrentKeypad == mSctKeypad){
   636             // if sct is active keypad, then launch itu-t keypad
   584             // if sct is active keypad, then launch itu-t keypad
   637             switchToAlphaMode();
   585             switchToAlphaMode();
   638         } else {
   586         } else {
   639             // launch special character keypad
   587              if (keyCode == HbInputButton::ButtonKeyCodeSymbol && HbInputSettingProxy::instance()->globalInputLanguage().language() == QLocale::Chinese) {
   640             displaySpecialCharacterTable(this);
   588                  HbInputLanguage primaryInputLanguage = HbInputSettingProxy::instance()->globalInputLanguage();
       
   589                  HbInputMethod::activeInputMethod()->activateState(HbInputState(HbInputModeDefault,
       
   590                                        HbTextCaseAutomatic,
       
   591                                        HbKeyboardTouchPortrait,
       
   592                                        primaryInputLanguage));
       
   593              } else {
       
   594                  // launch special character keypad
       
   595                  displaySpecialCharacterTable(this);
       
   596              }
   641         }
   597         }
   642     } else if (keyCode == HbInputButton::ButtonKeyCodeShift) {
   598     } else if (keyCode == HbInputButton::ButtonKeyCodeShift) {
   643         HbInputState nextState = inputState();
   599         HbInputState nextState = inputState();
   644         if (nextState.inputMode() != HbInputModeNumeric) {
   600         if (nextState.inputMode() != HbInputModeNumeric) {
   645             nextState.setInputMode(HbInputModeNumeric);
   601             nextState.setInputMode(HbInputModeNumeric);
   661     if (!mSctKeypad) {
   617     if (!mSctKeypad) {
   662         mSctKeypad = new HbSctKeyboard(this, mKeymap, 0);
   618         mSctKeypad = new HbSctKeyboard(this, mKeymap, 0);
   663         connect(mSctKeypad, SIGNAL(keypadCloseEventDetected(HbInputVkbWidget::HbVkbCloseMethod)),
   619         connect(mSctKeypad, SIGNAL(keypadCloseEventDetected(HbInputVkbWidget::HbVkbCloseMethod)),
   664                 this, SLOT(keypadCloseEventDetected(HbInputVkbWidget::HbVkbCloseMethod)));
   620                 this, SLOT(keypadCloseEventDetected(HbInputVkbWidget::HbVkbCloseMethod)));
   665         connect(mSctKeypad, SIGNAL(smileySelected(QString)),
   621         connect(mSctKeypad, SIGNAL(smileySelected(QString)),
   666                 this, SLOT(smileySelected(QString)));
   622                 this, SLOT(smileySelected(QString)));     
   667         mSctKeypad->setRockerVisible(false);
       
   668     }
   623     }
   669     mSctKeypad->setMode(EModeAbc, HbModifierNone);
   624     mSctKeypad->setMode(EModeAbc, HbModifierNone);
   670     //Open the keypad
   625     //Open the keypad
   671     openKeypad(mSctKeypad);
   626     openKeypad(mSctKeypad);
   672 
   627 
   787 {
   742 {
   788     if (!mCandidatePopup) {
   743     if (!mCandidatePopup) {
   789         mCandidatePopup = new HbCandidateList(this);
   744         mCandidatePopup = new HbCandidateList(this);
   790         connect(mCandidatePopup, SIGNAL(candidatePopupCancelled()), this, SLOT(restorePreviousState()));
   745         connect(mCandidatePopup, SIGNAL(candidatePopupCancelled()), this, SLOT(restorePreviousState()));
   791         connect(mCandidatePopup, SIGNAL(candidateSelected(int,QString)), this, SLOT(candidatePopupClosed(int,QString)));
   746         connect(mCandidatePopup, SIGNAL(candidateSelected(int,QString)), this, SLOT(candidatePopupClosed(int,QString)));
   792         QObject::connect(mCandidatePopup,SIGNAL(launchSpellQueryDialog()),mPredictionModeHandler,SLOT(launchSpellQueryDialog()));		
   747         QObject::connect(mCandidatePopup,SIGNAL(launchSpellQueryDialog()),mPredictionModeHandler,SLOT(launchSpellQueryDialog()));       
   793     }
   748     }
   794 
   749 
   795     if (candidates.count() > 0) {
   750     if (candidates.count() > 0) {
   796         mCandidatePopup->populateList(candidates);
   751         mCandidatePopup->populateList(candidates);
   797         mCandidatePopup->setModal(false);
   752         mCandidatePopup->setModal(false);