src/hbplugins/inputmethods/touchinput/virtual12key.cpp
changeset 21 4633027730f5
parent 7 923ff622b8b9
child 23 e6ad4ef83b23
equal deleted inserted replaced
7:923ff622b8b9 21:4633027730f5
    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)
    72                 mKeyboardChangeAlreadyInprogress(false)
    74 {
    73 {
   163 state of the input method.
   162 state of the input method.
   164 */
   163 */
   165 void HbVirtual12Key::reset()
   164 void HbVirtual12Key::reset()
   166 {
   165 {
   167     mActiveModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionReset);
   166     mActiveModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionReset);
   168     mOrientationAboutToChange = false;
   167     // close candidate popup if visible
       
   168     closeCandidatePopup();
   169 }
   169 }
   170 
   170 
   171 Hb12KeyTouchKeyboard *HbVirtual12Key::construct12Keyboard()
   171 Hb12KeyTouchKeyboard *HbVirtual12Key::construct12Keyboard()
   172 {
   172 {
   173     Hb12KeyTouchKeyboard *tempKeypad = new Hb12KeyTouchKeyboard(this, mKeymap);
   173     Hb12KeyTouchKeyboard *tempKeypad = new Hb12KeyTouchKeyboard(this, mKeymap);
   176     connect(tempKeypad, SIGNAL(rockerDirection(int, HbInputVirtualRocker::RockerSelectionMode)),
   176     connect(tempKeypad, SIGNAL(rockerDirection(int, HbInputVirtualRocker::RockerSelectionMode)),
   177             this, SLOT(rockerDirection(int, HbInputVirtualRocker::RockerSelectionMode)));
   177             this, SLOT(rockerDirection(int, HbInputVirtualRocker::RockerSelectionMode)));
   178     //FLICKDISABLED connect(tempKeypad, SIGNAL(flickEvent(HbInputVkbWidget::FlickDirection)), this, SLOT(flickEvent(HbInputVkbWidget::FlickDirection)));
   178     //FLICKDISABLED connect(tempKeypad, SIGNAL(flickEvent(HbInputVkbWidget::FlickDirection)), this, SLOT(flickEvent(HbInputVkbWidget::FlickDirection)));
   179     connect(tempKeypad, SIGNAL(smileySelected(QString)), this, SLOT(smileySelected(QString)));
   179     connect(tempKeypad, SIGNAL(smileySelected(QString)), this, SLOT(smileySelected(QString)));
   180     connect(tempKeypad, SIGNAL(mouseMovedOutOfButton()), this, SLOT(mouseMovedOutOfButton()));
   180     connect(tempKeypad, SIGNAL(mouseMovedOutOfButton()), this, SLOT(mouseMovedOutOfButton()));
       
   181     connect(tempKeypad, SIGNAL(settingsListClosed()), this, SLOT(restorePreviousState()));
   181     tempKeypad->setRockerVisible(true);
   182     tempKeypad->setRockerVisible(true);
   182     return tempKeypad;
   183     return tempKeypad;
   183 }
   184 }
   184 
   185 
   185 /*!
   186 /*!
   217     mActiveModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionFocusRecieved);
   218     mActiveModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionFocusRecieved);
   218 
   219 
   219     if (mCurrentlyFocused != focusObject()) {
   220     if (mCurrentlyFocused != focusObject()) {
   220         mCurrentlyFocused = focusObject();
   221         mCurrentlyFocused = focusObject();
   221         // Focus changed from one editor to another.
   222         // Focus changed from one editor to another.
   222         if (mCandidatePopup) {
   223         closeCandidatePopup();
   223             mCandidatePopup->hide();
       
   224         }
       
   225     }
   224     }
   226 
   225 
   227     openKeypad(mItutKeypad);
   226     openKeypad(mItutKeypad);
   228 
   227 
   229     if (focusObject() && mVkbHost) {
   228     if (focusObject() && mVkbHost) {
   234     if (focusObject()) {
   233     if (focusObject()) {
   235         disconnect(&(focusObject()->editorInterface()), SIGNAL(cursorPositionChanged(int, int)),
   234         disconnect(&(focusObject()->editorInterface()), SIGNAL(cursorPositionChanged(int, int)),
   236                    mActiveModeHandler, SLOT(cursorPositionChanged(int, int)));
   235                    mActiveModeHandler, SLOT(cursorPositionChanged(int, int)));
   237         connect(&(focusObject()->editorInterface()), SIGNAL(cursorPositionChanged(int, int)),
   236         connect(&(focusObject()->editorInterface()), SIGNAL(cursorPositionChanged(int, int)),
   238                 mActiveModeHandler, SLOT(cursorPositionChanged(int, int)));
   237                 mActiveModeHandler, SLOT(cursorPositionChanged(int, int)));
       
   238                 
       
   239         disconnect(focusObject(), SIGNAL(orientationChanged()), this, SLOT(orientationChanged()));
       
   240         connect(focusObject(), SIGNAL(orientationChanged()), this, SLOT(orientationChanged()));
   239     }
   241     }
   240     HbInputAbstractMethod::focusReceived();
   242     HbInputAbstractMethod::focusReceived();
   241 }
   243 }
   242 
   244 
   243 /*!
   245 /*!
   261         // do any closing related things.
   263         // do any closing related things.
   262         // Then make sure that keypad closes.
   264         // Then make sure that keypad closes.
   263         closeKeypad();
   265         closeKeypad();
   264         mVkbHost = 0;
   266         mVkbHost = 0;
   265     }
   267     }
       
   268     HbInputAbstractMethod::focusLost();
   266 }
   269 }
   267 
   270 
   268 /*!
   271 /*!
   269 Closes the keypad if it is open.
   272 Closes the keypad if it is open.
   270 */
   273 */
   272 {
   275 {
   273     if (mVkbHost && mVkbHost->keypadStatus() != HbVkbHost::HbVkbStatusClosed) {
   276     if (mVkbHost && mVkbHost->keypadStatus() != HbVkbHost::HbVkbStatusClosed) {
   274         mVkbHost->closeKeypad(!stateChangeInProgress());
   277         mVkbHost->closeKeypad(!stateChangeInProgress());
   275         // set mCurrentKeypad to null.
   278         // set mCurrentKeypad to null.
   276         mCurrentKeypad = 0;
   279         mCurrentKeypad = 0;
   277         if (mCandidatePopup) {
   280         closeCandidatePopup();
   278             mCandidatePopup->hide();
       
   279         }
       
   280     }
   281     }
   281 }
   282 }
   282 
   283 
   283 /*!
   284 /*!
   284 Opens the virtual keypad for input.
   285 Opens the virtual keypad for input.
   305             // when their is a keypad that needs to be closed before opening the new keypad, we don't
   306             // 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.
   307             // want to animate the opening of new keypad.
   307             disableAnimation = true;
   308             disableAnimation = true;
   308         }
   309         }
   309     }
   310     }
       
   311     
   310     // Close candidate popup if open
   312     // Close candidate popup if open
   311     if (mCandidatePopup) {
   313     closeCandidatePopup();
   312         mCandidatePopup->hide();
       
   313     }
       
   314 
   314 
   315     QObject::disconnect(mCurrentKeypad,SIGNAL(aboutToActivateCustomAction(HbAction*)),
   315     QObject::disconnect(mCurrentKeypad,SIGNAL(aboutToActivateCustomAction(HbAction*)),
   316         this,SLOT(aboutToActivateCustomAction(HbAction*)));
   316         this,SLOT(aboutToActivateCustomAction(HbAction*)));
   317     QObject::connect(keypadToOpen,SIGNAL(aboutToActivateCustomAction(HbAction*)),
   317     QObject::connect(keypadToOpen,SIGNAL(aboutToActivateCustomAction(HbAction*)),
   318         this,SLOT(aboutToActivateCustomAction(HbAction*)));
   318         this,SLOT(aboutToActivateCustomAction(HbAction*)));
   331         }
   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 */
   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
   407                 // We need to commit the inline word when we minimize the keypad
   405                 mActiveModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionCommit);
   408                 mActiveModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionCommit);
   406                 if (mCandidatePopup) {
   409                 // close candiatelist popup if visisble.
   407                     mCandidatePopup->hide();
   410                 closeCandidatePopup();
   408                 }
       
   409 
   411 
   410                 // Close input.
   412                 // Close input.
   411                 QInputContext* ic = qApp->inputContext();
   413                 QInputContext* ic = qApp->inputContext();
   412                 if (ic) {
   414                 if (ic) {
   413                     QEvent *closeEvent = new QEvent(QEvent::CloseSoftwareInputPanel);
   415                     QEvent *closeEvent = new QEvent(QEvent::CloseSoftwareInputPanel);
   527     HbInputModeHandler *previousModeHandler = mActiveModeHandler;
   529     HbInputModeHandler *previousModeHandler = mActiveModeHandler;
   528 	if (newState.inputMode() == HbInputModeDefault && usePrediction()) {
   530 	if (newState.inputMode() == HbInputModeDefault && usePrediction()) {
   529         mActiveModeHandler = mPredictionModeHandler;        
   531         mActiveModeHandler = mPredictionModeHandler;        
   530         // by passing HbInputModeActionFocusRecieved we will be setting the candidate list and keypad
   532         // by passing HbInputModeActionFocusRecieved we will be setting the candidate list and keypad
   531         mActiveModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionFocusRecieved);
   533         mActiveModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionFocusRecieved);
       
   534 		/* The below line should be added in orientationChanged Slot, however currently it is not working correctly
       
   535 		 hence this fix is temporarily added here */
       
   536         mPredictionModeHandler->setAutocompletionStatus(HbInputSettingProxy::instance()->isAutocompletionEnabled(HbKeyboardSetting12key));
   532     } else if (newState.inputMode() == HbInputModeDefault) {
   537     } else if (newState.inputMode() == HbInputModeDefault) {
   533         mActiveModeHandler = mBasicModeHandler;
   538         mActiveModeHandler = mBasicModeHandler;
   534         // Auto completer setup needs following line.
   539         // Auto completer setup needs following line.
   535         mActiveModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionFocusRecieved);
   540         mActiveModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionFocusRecieved);
   536     } else if (newState.inputMode() == HbInputModeNumeric) {
   541     } else if (newState.inputMode() == HbInputModeNumeric) {
   622 /*!
   627 /*!
   623 this slot is called by the mode handlers when there is sym key or long  press of Asterisk key.
   628 this slot is called by the mode handlers when there is sym key or long  press of Asterisk key.
   624 */
   629 */
   625 void HbVirtual12Key::switchMode(int keyCode)
   630 void HbVirtual12Key::switchMode(int keyCode)
   626 {
   631 {
   627     if (keyCode == HbInputButton::ButtonKeyCodeAsterisk ||
   632     if (keyCode == HbInputButton::ButtonKeyCodeAsterisk && mCandidatePopup && mCandidatePopup->isVisible() && mCandidatePopup->isModal()) {
   628         keyCode == HbInputButton::ButtonKeyCodeSymbol ||
   633         return;
   629         keyCode == HbInputButton::ButtonKeyCodeAlphabet) {
   634     } else if (keyCode == HbInputButton::ButtonKeyCodeAsterisk || keyCode == HbInputButton::ButtonKeyCodeSymbol || keyCode == HbInputButton::ButtonKeyCodeAlphabet) {
   630         if (mCandidatePopup && mCandidatePopup->isVisible()) {
       
   631             return;
       
   632         }
       
   633 
       
   634         if (mCurrentKeypad == mSctKeypad){
   635         if (mCurrentKeypad == mSctKeypad){
   635             // if sct is active keypad, then launch itu-t keypad
   636             // if sct is active keypad, then launch itu-t keypad
   636             switchToAlphaMode();
   637             switchToAlphaMode();
   637         } else {
   638         } else {
   638             // launch special character keypad
   639             // launch special character keypad
   680     //Open the keypad
   681     //Open the keypad
   681     openKeypad(mItutKeypad,openAlphaInMinimizedMode);
   682     openKeypad(mItutKeypad,openAlphaInMinimizedMode);
   682 }
   683 }
   683 
   684 
   684 /*!
   685 /*!
   685 The call back from framework to indicate that the orientation is about to change. This closes the keypad
   686 The call back from framework to indicate that the orientation is changed.
   686 if it is already open.
   687 */
   687 */
   688 void HbVirtual12Key::orientationChanged()
   688 void HbVirtual12Key::orientationAboutToChange()
   689 {
   689 {
   690     //Close the spell Query if it is visible
   690     HbInputMethod::orientationAboutToChange();
   691     //During the change of orientation focus is locked by the framework and hence the spell query 
   691     if (isActiveMethod()) {
   692     //cannot be closed. Closing spell query should result in change of focus back to the previous editor 
   692         mOrientationAboutToChange = true;
   693     //which is not possible if focus is locked.
   693         mPredictionModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionCloseSpellQuery);
   694     mPredictionModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionCloseSpellQuery);
   694         // We need to commit the inline word before orientation change.
       
   695         mActiveModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionCommit);
       
   696         closeKeypad();
       
   697     }
       
   698 }
   695 }
   699 
   696 
   700 /*!
   697 /*!
   701 Launches the candidate list.
   698 Launches the candidate list.
   702 */
   699 */
   703 void HbVirtual12Key::launchCandidatePopup(const QStringList& candidates)
   700 void HbVirtual12Key::launchCandidatePopup(const QStringList& candidates)
   704 {
   701 {
   705     if (!mCandidatePopup) {
   702     if (!mCandidatePopup) {
   706         mCandidatePopup = new HbCandidateList(this);
   703         mCandidatePopup = new HbCandidateList(this);
       
   704         connect(mCandidatePopup, SIGNAL(candidatePopupCancelled()), this, SLOT(restorePreviousState()));
   707         connect(mCandidatePopup, SIGNAL(candidateSelected(int,QString)), this, SLOT(candidatePopupClosed(int,QString)));
   705         connect(mCandidatePopup, SIGNAL(candidateSelected(int,QString)), this, SLOT(candidatePopupClosed(int,QString)));
   708         QObject::connect(mCandidatePopup,SIGNAL(launchSpellQueryDialog()),mPredictionModeHandler,SLOT(launchSpellQueryDialog()));		
   706         QObject::connect(mCandidatePopup,SIGNAL(launchSpellQueryDialog()),mPredictionModeHandler,SLOT(launchSpellQueryDialog()));       
   709     }
   707     }
   710     mCandidatePopup->populateList(candidates,true);
   708     mCandidatePopup->populateList(candidates,true);
   711     mCandidatePopup->setModal(true);
   709     mCandidatePopup->setModal(true);
   712 
   710 
   713     QSizeF candListSize = mCandidatePopup->size();
   711     QSizeF candListSize = mCandidatePopup->size();
   763         mItutKeypad->showSmileyPicker();
   761         mItutKeypad->showSmileyPicker();
   764     }
   762     }
   765 }
   763 }
   766 
   764 
   767 /*!
   765 /*!
   768 Slot used by mode handlers to close the candidate popup.
   766 Closes the candidate popup if visible.
   769 */
   767 */
   770 void HbVirtual12Key::closeCandidatePopup()
   768 void HbVirtual12Key::closeCandidatePopup()
   771 {
   769 {
   772     if (mCandidatePopup && mCandidatePopup->isVisible()) {
   770     if (mCandidatePopup && mCandidatePopup->isVisible()) {
   773         mCandidatePopup->hide();
   771         mCandidatePopup->hide();
   787 */
   785 */
   788 void HbVirtual12Key::launchAutoCompletionPopup(const QStringList& candidates)
   786 void HbVirtual12Key::launchAutoCompletionPopup(const QStringList& candidates)
   789 {
   787 {
   790     if (!mCandidatePopup) {
   788     if (!mCandidatePopup) {
   791         mCandidatePopup = new HbCandidateList(this);
   789         mCandidatePopup = new HbCandidateList(this);
       
   790         connect(mCandidatePopup, SIGNAL(candidatePopupCancelled()), this, SLOT(restorePreviousState()));
   792         connect(mCandidatePopup, SIGNAL(candidateSelected(int,QString)), this, SLOT(candidatePopupClosed(int,QString)));
   791         connect(mCandidatePopup, SIGNAL(candidateSelected(int,QString)), this, SLOT(candidatePopupClosed(int,QString)));
   793         QObject::connect(mCandidatePopup,SIGNAL(launchSpellQueryDialog()),mPredictionModeHandler,SLOT(launchSpellQueryDialog()));		
   792         QObject::connect(mCandidatePopup,SIGNAL(launchSpellQueryDialog()),mPredictionModeHandler,SLOT(launchSpellQueryDialog()));		
   794     }
   793     }
   795 
   794 
   796     if (candidates.count() > 0) {
   795     if (candidates.count() > 0) {
   800         if (mCandidatePopup->setSizeAndPositionForAutoCompletion(mVkbHost)) {
   799         if (mCandidatePopup->setSizeAndPositionForAutoCompletion(mVkbHost)) {
   801             mCandidatePopup->setDismissPolicy(HbPopup::TapInside);
   800             mCandidatePopup->setDismissPolicy(HbPopup::TapInside);
   802             mCandidatePopup->setBackgroundFaded(false);
   801             mCandidatePopup->setBackgroundFaded(false);
   803             mCandidatePopup->show();
   802             mCandidatePopup->show();
   804         }
   803         }
   805     } else if (mCandidatePopup->isVisible()) {
   804     } else {
   806         mCandidatePopup->hide();
   805         closeCandidatePopup();
   807     }
   806     }
   808 }
   807 }
   809 
   808 
   810 /*!
   809 /*!
   811 Returns true if prediction is on, prediction engine is available and predictions is allowed in current editor.
   810 Returns true if prediction is on, prediction engine is available and predictions is allowed in current editor.
   821     }
   820     }
   822 
   821 
   823     return false;
   822     return false;
   824 }
   823 }
   825 
   824 
       
   825 void HbVirtual12Key::restorePreviousState()
       
   826 {
       
   827     mActiveModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionRestorePreviousState);
       
   828 }
   826 // End of file
   829 // End of file