src/hbplugins/inputmethods/touchinput/virtualqwerty.cpp
changeset 21 4633027730f5
parent 7 923ff622b8b9
child 23 e6ad4ef83b23
equal deleted inserted replaced
7:923ff622b8b9 21:4633027730f5
    49 #include "hbinputqwerty10x4touchkeyboard.h"
    49 #include "hbinputqwerty10x4touchkeyboard.h"
    50 #include "hbinputqwerty11x4touchkeyboard.h"
    50 #include "hbinputqwerty11x4touchkeyboard.h"
    51 #include "hbinputqwertynumerictouchkeyboard.h"
    51 #include "hbinputqwertynumerictouchkeyboard.h"
    52 
    52 
    53 const int HbVirtualQwerty4x10MaxKeysCount = 32;
    53 const int HbVirtualQwerty4x10MaxKeysCount = 32;
       
    54 const qreal HbExactPopupHeightFactor = 0.15;
       
    55 const qreal HbDeltaWidth = 12.0;
       
    56 const qreal HbEditorExtraMargin = 17.0;
    54 
    57 
    55 HbVirtualQwerty::HbVirtualQwerty() : mCurrentKeypad(0),
    58 HbVirtualQwerty::HbVirtualQwerty() : mCurrentKeypad(0),
    56                                      mQwertyAlphaKeypad(0),
    59                                      mQwertyAlphaKeypad(0),
    57                                      mQwerty10x4Keypad(0),
    60                                      mQwerty10x4Keypad(0),
    58                                      mQwerty11x4Keypad(0),
    61                                      mQwerty11x4Keypad(0),
    59                                      mQwertyNumericKeypad(0),
    62                                      mQwertyNumericKeypad(0),
    60                                      mSctKeypad(0),
    63                                      mSctKeypad(0),
    61                                      mKeymap(0),
    64                                      mKeymap(0),
    62                                      mExactWordPopup(0),
    65                                      mExactWordPopup(0),
    63                                      mCandidatePopup(0),
    66                                      mCandidatePopup(0),
    64                                      mOrientationAboutToChange(false),
       
    65                                      mShiftKeyState(0),
    67                                      mShiftKeyState(0),
    66                                      mVkbHost(0)
    68                                      mVkbHost(0)
    67 {
    69 {
    68     initializeModeHandlers();
    70     initializeModeHandlers();
    69 }
    71 }
   144 }
   146 }
   145 
   147 
   146 void HbVirtualQwerty::reset()
   148 void HbVirtualQwerty::reset()
   147 {
   149 {
   148     mActiveModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionReset);
   150     mActiveModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionReset);
       
   151     // close candidate popup if visible
       
   152     closeCandidatePopup();
   149 }
   153 }
   150 
   154 
   151 void HbVirtualQwerty::focusReceived()
   155 void HbVirtualQwerty::focusReceived()
   152 {
   156 {
   153     /* Update the text case */
   157     /* Update the text case */
   210     }
   214     }
   211 
   215 
   212     if (focusObject()) {
   216     if (focusObject()) {
   213         disconnect(&(focusObject()->editorInterface()), SIGNAL(cursorPositionChanged(int, int)), mActiveModeHandler, SLOT(cursorPositionChanged(int, int)));
   217         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)));
   218         connect(&(focusObject()->editorInterface()), SIGNAL(cursorPositionChanged(int, int)), mActiveModeHandler, SLOT(cursorPositionChanged(int, int)));
       
   219         
       
   220         disconnect(focusObject(), SIGNAL(aboutToChangeOrientation()), this, SLOT(orientationAboutToChange()));
       
   221         connect(focusObject(), SIGNAL(aboutToChangeOrientation()), this, SLOT(orientationAboutToChange()));
   215     }
   222     }
   216     HbInputAbstractMethod::focusReceived();
   223     HbInputAbstractMethod::focusReceived();
   217 }
   224 }
   218 
   225 
   219 void HbVirtualQwerty::focusLost(bool focusSwitch)
   226 void HbVirtualQwerty::focusLost(bool focusSwitch)
   230             // Context switch has happened but the keypad is still open.
   237             // Context switch has happened but the keypad is still open.
   231             // Close it.
   238             // Close it.
   232             closeKeypad();
   239             closeKeypad();
   233         }
   240         }
   234     }
   241     }
       
   242     HbInputAbstractMethod::focusLost();
   235 }
   243 }
   236 
   244 
   237 void HbVirtualQwerty::closeKeypad()
   245 void HbVirtualQwerty::closeKeypad()
   238 {
   246 {
   239     if (mVkbHost && mVkbHost->keypadStatus() != HbVkbHost::HbVkbStatusClosed) {
   247     if (mVkbHost && mVkbHost->keypadStatus() != HbVkbHost::HbVkbStatusClosed) {
   240         mVkbHost->closeKeypad();
   248         mVkbHost->closeKeypad(!stateChangeInProgress());
   241         // set mCurrentKeypad to null.
   249         // set mCurrentKeypad to null.
   242         mCurrentKeypad = 0;
   250         mCurrentKeypad = 0;
   243         if (mCandidatePopup) {
   251         closeCandidatePopup();
   244             mCandidatePopup->hide();
       
   245         }
       
   246     }
   252     }
   247 }
   253 }
   248 
   254 
   249 void HbVirtualQwerty::openKeypad(HbInputVkbWidget * keypadToOpen,bool inMinimizedMode )
   255 void HbVirtualQwerty::openKeypad(HbInputVkbWidget * keypadToOpen,bool inMinimizedMode )
   250 {
   256 {
   263             // when their is a keypad that needs to be closed before opening the new keypad, we don't
   269             // 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.
   270             // want to animate the opening of new keypad.
   265             disableAnimation = true;
   271             disableAnimation = true;
   266         }
   272         }
   267     }
   273     }
       
   274 
   268     // Close candidate popup if open
   275     // Close candidate popup if open
   269     if (mCandidatePopup) {
   276     closeCandidatePopup();
   270         mCandidatePopup->hide();
       
   271     }
       
   272 
   277 
   273     QObject::disconnect(mCurrentKeypad,SIGNAL(aboutToActivateCustomAction(HbAction*)),
   278     QObject::disconnect(mCurrentKeypad,SIGNAL(aboutToActivateCustomAction(HbAction*)),
   274         this,SLOT(aboutToActivateCustomAction(HbAction*)));
   279         this,SLOT(aboutToActivateCustomAction(HbAction*)));
   275     QObject::connect(keypadToOpen,SIGNAL(aboutToActivateCustomAction(HbAction*)),
   280     QObject::connect(keypadToOpen,SIGNAL(aboutToActivateCustomAction(HbAction*)),
   276         this,SLOT(aboutToActivateCustomAction(HbAction*)));
   281         this,SLOT(aboutToActivateCustomAction(HbAction*)));
   277 
   282 
   278     // assign new keypad to be opened to varable mCurrentKeypad
   283     // assign new keypad to be opened to varable mCurrentKeypad
   279     mCurrentKeypad =  keypadToOpen;
   284     mCurrentKeypad =  keypadToOpen; 
   280     activeKeyboardChanged(currentKeyboardType());
       
   281 
       
   282 
       
   283     if (mVkbHost && mVkbHost->keypadStatus() != HbVkbHost::HbVkbStatusOpened) {
   285     if (mVkbHost && mVkbHost->keypadStatus() != HbVkbHost::HbVkbStatusOpened) {
   284         connect(mVkbHost, SIGNAL(keypadClosed()), this, SLOT(keypadClosed()));
   286         connect(mVkbHost, SIGNAL(keypadClosed()), this, SLOT(keypadClosed()));
   285         if (inMinimizedMode) {
   287         if (inMinimizedMode) {
   286             mVkbHost->openMinimizedKeypad(mCurrentKeypad, this);
   288             mVkbHost->openMinimizedKeypad(mCurrentKeypad, this);
   287         } else {
   289         } else {
   291         if (focusObject()) {
   293         if (focusObject()) {
   292             connect(&(focusObject()->editorInterface()), SIGNAL(cursorPositionChanged(int, int)),
   294             connect(&(focusObject()->editorInterface()), SIGNAL(cursorPositionChanged(int, int)),
   293                     mVkbHost, SLOT(ensureCursorVisibility()));
   295                     mVkbHost, SLOT(ensureCursorVisibility()));
   294         }
   296         }
   295     }
   297     }
       
   298 
       
   299     if(mActiveModeHandler) {
       
   300         mActiveModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionSetKeypad);
       
   301     }
   296 }
   302 }
   297 
   303 
   298 /*!
   304 /*!
   299 vkb widget is about to call a custom action that is mapped to one of the keypad buttons.
   305 vkb widget is about to call a custom action that is mapped to one of the keypad buttons.
   300 */
   306 */
   321             }
   327             }
   322             mQwerty10x4Keypad = new HbQwerty10x4Keyboard(this, mKeymap);
   328             mQwerty10x4Keypad = new HbQwerty10x4Keyboard(this, mKeymap);
   323             keyboard = mQwerty10x4Keypad;
   329             keyboard = mQwerty10x4Keypad;
   324         }
   330         }
   325         connect(keyboard, SIGNAL(smileySelected(QString)), this, SLOT(smileySelected(QString)));
   331         connect(keyboard, SIGNAL(smileySelected(QString)), this, SLOT(smileySelected(QString)));
       
   332         connect(keyboard, SIGNAL(settingsListClosed()), this, SLOT(restorePreviousState()));
   326         //FLICKDISABLED connect(keyboard, SIGNAL(flickEvent(HbInputVkbWidget::FlickDirection)), this, SLOT(flickEvent(HbInputVkbWidget::FlickDirection)));
   333         //FLICKDISABLED connect(keyboard, SIGNAL(flickEvent(HbInputVkbWidget::FlickDirection)), this, SLOT(flickEvent(HbInputVkbWidget::FlickDirection)));
   327     } else {
   334     } else {
   328         keyboard = new HbQwertyNumericKeyboard(this, mKeymap);
   335         keyboard = new HbQwertyNumericKeyboard(this, mKeymap);
   329     }    
   336     }    
   330     connect(keyboard, SIGNAL(keypadCloseEventDetected(HbInputVkbWidget::HbVkbCloseMethod)),
   337     connect(keyboard, SIGNAL(keypadCloseEventDetected(HbInputVkbWidget::HbVkbCloseMethod)),
   341 {
   348 {
   342     mActiveModeHandler->mouseHandler(x, event);
   349     mActiveModeHandler->mouseHandler(x, event);
   343 }
   350 }
   344 
   351 
   345 void HbVirtualQwerty::keypadClosed()
   352 void HbVirtualQwerty::keypadClosed()
   346 {
   353 {    
   347     mOrientationAboutToChange = false;
       
   348     
       
   349     if (mVkbHost->keypadStatus() == HbVkbHost::HbVkbStatusMinimized) {
   354     if (mVkbHost->keypadStatus() == HbVkbHost::HbVkbStatusMinimized) {
   350         closeExactWordPopup();
   355         closeExactWordPopup();
   351     }	
   356     }	
   352 }
   357 }
   353 
   358 
   356     Q_UNUSED(vkbCloseMethod);
   361     Q_UNUSED(vkbCloseMethod);
   357     if (isActiveMethod()) {
   362     if (isActiveMethod()) {
   358         if (mVkbHost && mVkbHost->keypadStatus() != HbVkbHost::HbVkbStatusMinimized) {
   363         if (mVkbHost && mVkbHost->keypadStatus() != HbVkbHost::HbVkbStatusMinimized) {
   359             // We need to commit the inline word when we minimize the keypad
   364             // We need to commit the inline word when we minimize the keypad
   360             mActiveModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionCommit);
   365             mActiveModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionCommit);
   361             if (mCandidatePopup) {
   366             closeCandidatePopup();
   362                 mCandidatePopup->hide();
       
   363             }
       
   364 
   367 
   365             // Close input.
   368             // Close input.
   366             QInputContext* ic = qApp->inputContext();
   369             QInputContext* ic = qApp->inputContext();
   367             if (ic) {
   370             if (ic) {
   368                 QEvent *closeEvent = new QEvent(QEvent::CloseSoftwareInputPanel);
   371                 QEvent *closeEvent = new QEvent(QEvent::CloseSoftwareInputPanel);
   415     HbInputModeHandler *previousModeHandler = mActiveModeHandler;
   418     HbInputModeHandler *previousModeHandler = mActiveModeHandler;
   416     if (newState.inputMode() == HbInputModeNumeric) {
   419     if (newState.inputMode() == HbInputModeNumeric) {
   417         mActiveModeHandler = mNumericModeHandler;
   420         mActiveModeHandler = mNumericModeHandler;
   418     }  else if (newState.inputMode() == HbInputModeDefault && usePrediction()) {
   421     }  else if (newState.inputMode() == HbInputModeDefault && usePrediction()) {
   419         mActiveModeHandler = mPredictionModeHandler;
   422         mActiveModeHandler = mPredictionModeHandler;
       
   423 		// by passing HbInputModeActionFocusRecieved we will be setting the candidate list and keypad
       
   424         mActiveModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionFocusRecieved);
       
   425 		/* The below line should be added in orientationChanged Slot, however currently it is not working correctly
       
   426 		 hence this fix is temporarily added here */
       
   427         mPredictionModeHandler->setAutocompletionStatus(HbInputSettingProxy::instance()->isAutocompletionEnabled(HbKeyboardSettingQwerty));
   420     } else if (newState.inputMode() == HbInputModeDefault) {
   428     } else if (newState.inputMode() == HbInputModeDefault) {
   421         mActiveModeHandler = mBasicModeHandler;
   429         mActiveModeHandler = mBasicModeHandler;
   422         // Auto completer setup needs following line.
   430         // Auto completer setup needs following line.
   423         mActiveModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionFocusRecieved);
   431         mActiveModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionFocusRecieved);
   424     }
   432     }
   528     mQwertyAlphaKeypad = constructKeyboard(EModeAbc);
   536     mQwertyAlphaKeypad = constructKeyboard(EModeAbc);
   529     mQwertyAlphaKeypad->showSmileyPicker();
   537     mQwertyAlphaKeypad->showSmileyPicker();
   530 }
   538 }
   531 
   539 
   532 /*!
   540 /*!
   533 Slot used by mode handlers to close the autocompletion popup.
   541 Closes the candidate popup if visible.
   534 */
   542 */
   535 void HbVirtualQwerty::closeAutoCompletionPopup()
   543 void HbVirtualQwerty::closeCandidatePopup()
   536 {
   544 {
   537     if (mCandidatePopup && mCandidatePopup->isVisible()) {
   545     if (mCandidatePopup && mCandidatePopup->isVisible()) {
   538         mCandidatePopup->hide();
   546         mCandidatePopup->hide();
   539     }
   547     }
   540 }
   548 }
   541 
   549 
   542 /*!
   550 /*!
       
   551 Slot used by mode handlers to close the autocompletion popup.
       
   552 */
       
   553 void HbVirtualQwerty::closeAutoCompletionPopup()
       
   554 {
       
   555     closeCandidatePopup();
       
   556 }
       
   557 
       
   558 /*!
   543 Launches auto-completion popup if there are candidates available.
   559 Launches auto-completion popup if there are candidates available.
   544 */
   560 */
   545 void HbVirtualQwerty::launchAutoCompletionPopup(const QStringList& candidates)
   561 void HbVirtualQwerty::launchAutoCompletionPopup(const QStringList& candidates)
   546 {
   562 {
   547     if (!mCandidatePopup) {
   563     if (!mCandidatePopup) {
   548         mCandidatePopup = new HbCandidateList(this);
   564         mCandidatePopup = new HbCandidateList(this);
   549         connect(mCandidatePopup, SIGNAL(candidatePopupCancelled()), this, SLOT(candidatePopupCancelled()));
   565         connect(mCandidatePopup, SIGNAL(candidatePopupCancelled()), this, SLOT(restorePreviousState()));
   550         connect(mCandidatePopup, SIGNAL(candidateSelected(int,const QString&)), this, SLOT(candidatePopupClosed(int, const QString&)));
   566         connect(mCandidatePopup, SIGNAL(candidateSelected(int,const QString&)), this, SLOT(candidatePopupClosed(int, const QString&)));
   551     }
   567     }
   552 
   568 
   553     if (candidates.count() > 0) {
   569     if (candidates.count() > 0) {
   554         mCandidatePopup->populateList(candidates);
   570         mCandidatePopup->populateList(candidates);
   557         if (mCandidatePopup->setSizeAndPositionForAutoCompletion(mVkbHost)) {
   573         if (mCandidatePopup->setSizeAndPositionForAutoCompletion(mVkbHost)) {
   558             mCandidatePopup->setDismissPolicy(HbPopup::TapInside);
   574             mCandidatePopup->setDismissPolicy(HbPopup::TapInside);
   559             mCandidatePopup->setBackgroundFaded(false);
   575             mCandidatePopup->setBackgroundFaded(false);
   560             mCandidatePopup->show();
   576             mCandidatePopup->show();
   561         }
   577         }
   562     } else if (mCandidatePopup->isVisible()) {
   578     } else {
   563         mCandidatePopup->hide();
   579         closeCandidatePopup();
   564     }
   580     }
   565 }
   581 }
   566 
   582 
   567 HbKeyboardType HbVirtualQwerty::currentKeyboardType() const
   583 HbKeyboardType HbVirtualQwerty::currentKeyboardType() const
   568 {
   584 {
   587 {
   603 {
   588     //before launching candidate popup, close exact word popup if visible.
   604     //before launching candidate popup, close exact word popup if visible.
   589     closeExactWordPopup();
   605     closeExactWordPopup();
   590     if (!mCandidatePopup) {
   606     if (!mCandidatePopup) {
   591         mCandidatePopup = new HbCandidateList(this);
   607         mCandidatePopup = new HbCandidateList(this);
   592         connect(mCandidatePopup, SIGNAL(candidatePopupCancelled()), this, SLOT(candidatePopupCancelled()));
   608         connect(mCandidatePopup, SIGNAL(candidatePopupCancelled()), this, SLOT(restorePreviousState()));
   593         connect(mCandidatePopup, SIGNAL(candidateSelected(int,const QString&)), this, SLOT(candidatePopupClosed(int, const QString&)));
   609         connect(mCandidatePopup, SIGNAL(candidateSelected(int,const QString&)), this, SLOT(candidatePopupClosed(int, const QString&)));
   594     }
   610     }
   595     mCandidatePopup->populateList(candidates);
   611     mCandidatePopup->populateList(candidates);
   596     mCandidatePopup->setModal(true);
   612     mCandidatePopup->setModal(true);
   597 
   613 
   627 The call back from framework to indicate that the orientation is about to change. This closes the keypad
   643 The call back from framework to indicate that the orientation is about to change. This closes the keypad
   628 if it is already open.
   644 if it is already open.
   629 */
   645 */
   630 void HbVirtualQwerty::orientationAboutToChange()
   646 void HbVirtualQwerty::orientationAboutToChange()
   631 {
   647 {
   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 }
   648 }
   641 
   649 
   642 /*!
   650 /*!
   643 Slot used by virtual rocker to move cursor.
   651 Slot used by virtual rocker to move cursor.
   644 */
   652 */
   703 	mPredictionModeHandler->setPrimaryCandidateMode(mode);
   711 	mPredictionModeHandler->setPrimaryCandidateMode(mode);
   704 }
   712 }
   705 
   713 
   706 void HbVirtualQwerty::autocompletionStateChanged(HbKeyboardSettingFlags keyboardType, bool newState)
   714 void HbVirtualQwerty::autocompletionStateChanged(HbKeyboardSettingFlags keyboardType, bool newState)
   707 {
   715 {
   708     if (keyboardType & HbKeyboardSettingQwerty) {
   716     if ( isActiveMethod() && (keyboardType & HbKeyboardSettingQwerty) ){
   709         mPredictionModeHandler->setAutocompletionStatus(newState);
   717         mPredictionModeHandler->setAutocompletionStatus(newState);
   710     }
   718     }
   711 }
   719 }
   712 
   720 
   713 void HbVirtualQwerty::typingCorrectionLevelChanged(HbTypingCorrectionLevel correctionLevel)
   721 void HbVirtualQwerty::typingCorrectionLevelChanged(HbTypingCorrectionLevel correctionLevel)
   732 */
   740 */
   733 void HbVirtualQwerty::launchExactWordPopup(QString exactWord)
   741 void HbVirtualQwerty::launchExactWordPopup(QString exactWord)
   734 {
   742 {
   735     if (!mExactWordPopup) {
   743     if (!mExactWordPopup) {
   736         mExactWordPopup = HbExactWordPopup::instance();
   744         mExactWordPopup = HbExactWordPopup::instance();
       
   745         mExactWordPopup->setPreferredHeight(HbDeviceProfile::profile(
       
   746             mCurrentKeypad->mainWindow()).logicalSize().height() * HbExactPopupHeightFactor);
   737         connect(mExactWordPopup, SIGNAL(exactWordSelected()), mPredictionModeHandler, SLOT(exactWordSelected()));
   747         connect(mExactWordPopup, SIGNAL(exactWordSelected()), mPredictionModeHandler, SLOT(exactWordSelected()));
   738     }
   748     }
   739     mExactWordPopup->setText(exactWord);
   749     mExactWordPopup->setText(exactWord);
   740     mExactWordPopup->showText(getCursorCoordinatePosition());
   750     mExactWordPopup->showText(getCursorCoordinatePosition());
   741 }
   751 }
   750     }
   760     }
   751 }
   761 }
   752 
   762 
   753 QPointF HbVirtualQwerty::getCursorCoordinatePosition()
   763 QPointF HbVirtualQwerty::getCursorCoordinatePosition()
   754 {
   764 {
       
   765     QPointF cursorPos(0.0, 0.0);
   755     QRectF microRect = focusObject()->microFocus();
   766     QRectF microRect = focusObject()->microFocus();
   756     QPointF cursorPos = microRect.topLeft();
   767     microRect.adjust(0.0, -HbEditorExtraMargin, 0.0, HbEditorExtraMargin);
   757 	
   768 
   758     if (mVkbHost) {
   769     if (mVkbHost) {
       
   770         QRectF activeViewRect= mVkbHost->applicationArea();
       
   771         qreal exactPopupHeight = HbDeviceProfile::profile(
       
   772             mCurrentKeypad->mainWindow()).logicalSize().height() * HbExactPopupHeightFactor;
       
   773         qreal topArea = microRect.top() - activeViewRect.top();
       
   774         qreal bottomArea = activeViewRect.bottom() - microRect.bottom();
       
   775         qreal xPos = microRect.left();
       
   776         cursorPos.setX(xPos);
   759         QSizeF exactPopupSize = mExactWordPopup->size();
   777         QSizeF exactPopupSize = mExactWordPopup->size();
   760         QRectF activeViewRect = mVkbHost->applicationArea();
   778 
   761         // if the exact word doesnt fit inside the visible area, then show it on the right side of
   779         // 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        
   780         // If enough space is not available, then show the exact word popup inside the focused editor        
   763         if (microRect.left() + exactPopupSize.width() > activeViewRect.width()) {
   781         if (topArea > exactPopupHeight || bottomArea > exactPopupHeight) {
   764             qreal startPos = microRect.left() - exactPopupSize.width();
   782             // show the popup above the editor if more space available
   765 			cursorPos.setX((startPos > activeViewRect.left()) ? startPos : activeViewRect.left());
   783             if (topArea > exactPopupHeight) {
   766 		} 		
   784                 cursorPos.setY(microRect.topLeft().y() - exactPopupHeight);
       
   785             } else {
       
   786                 cursorPos.setY(microRect.bottomLeft().y());
       
   787             }
       
   788             // if there is no space to show the exact word popup in the right side of the cursor
       
   789             // recatangle, then show it on the left side of the cursor            
       
   790             if (xPos + exactPopupSize.width() > activeViewRect.width()) {
       
   791                 cursorPos.setX(xPos - exactPopupSize.width());
       
   792             }
       
   793         } else {
       
   794             // show the exact word popup inside the editor
       
   795             cursorPos.setY(microRect.top() + (microRect.height() / 2) - (exactPopupHeight / 2));
       
   796             xPos = xPos + HbDeltaWidth;
       
   797             if (xPos + exactPopupSize.width() > activeViewRect.width()) {
       
   798                 qreal startPos = microRect.left() - (3 * exactPopupSize.width()) - HbDeltaWidth;
       
   799                 cursorPos.setX((startPos > activeViewRect.left()) ? startPos : activeViewRect.left());
       
   800             }
       
   801         }
   767     }
   802     }
   768     return cursorPos;
   803     return cursorPos;
   769 }
   804 }
       
   805 
   770 
   806 
   771 /*!
   807 /*!
   772 Returns true if prediction is on, prediction engine is available and predictions is allowed in current editor.
   808 Returns true if prediction is on, prediction engine is available and predictions is allowed in current editor.
   773 */
   809 */
   774 bool HbVirtualQwerty::usePrediction() const
   810 bool HbVirtualQwerty::usePrediction() const
   793 QList<HbKeyPressProbability> HbVirtualQwerty::probableKeypresses()
   829 QList<HbKeyPressProbability> HbVirtualQwerty::probableKeypresses()
   794 {
   830 {
   795     return mCurrentKeypad->probableKeypresses();
   831     return mCurrentKeypad->probableKeypresses();
   796 }
   832 }
   797 
   833 
   798 void HbVirtualQwerty::candidatePopupCancelled()
   834 void HbVirtualQwerty::restorePreviousState()
   799 {
   835 {
   800     if(mPredictionModeHandler) {
   836     mActiveModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionRestorePreviousState);
   801         mPredictionModeHandler->showExactWordPopupIfNeeded();
       
   802     }
       
   803 }
   837 }
   804 // End of file
   838 // End of file
       
   839 
       
   840 
       
   841