--- a/src/hbplugins/inputmethods/touchinput/virtualqwerty.cpp Tue Jul 06 14:36:53 2010 +0300
+++ b/src/hbplugins/inputmethods/touchinput/virtualqwerty.cpp Wed Aug 18 10:05:37 2010 +0300
@@ -51,6 +51,9 @@
#include "hbinputqwertynumerictouchkeyboard.h"
const int HbVirtualQwerty4x10MaxKeysCount = 32;
+const qreal HbExactPopupHeightFactor = 0.15;
+const qreal HbDeltaWidth = 12.0;
+const qreal HbEditorExtraMargin = 17.0;
HbVirtualQwerty::HbVirtualQwerty() : mCurrentKeypad(0),
mQwertyAlphaKeypad(0),
@@ -61,7 +64,6 @@
mKeymap(0),
mExactWordPopup(0),
mCandidatePopup(0),
- mOrientationAboutToChange(false),
mShiftKeyState(0),
mVkbHost(0)
{
@@ -146,6 +148,8 @@
void HbVirtualQwerty::reset()
{
mActiveModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionReset);
+ // close candidate popup if visible
+ closeCandidatePopup();
}
void HbVirtualQwerty::focusReceived()
@@ -212,6 +216,9 @@
if (focusObject()) {
disconnect(&(focusObject()->editorInterface()), SIGNAL(cursorPositionChanged(int, int)), mActiveModeHandler, SLOT(cursorPositionChanged(int, int)));
connect(&(focusObject()->editorInterface()), SIGNAL(cursorPositionChanged(int, int)), mActiveModeHandler, SLOT(cursorPositionChanged(int, int)));
+
+ disconnect(focusObject(), SIGNAL(aboutToChangeOrientation()), this, SLOT(orientationAboutToChange()));
+ connect(focusObject(), SIGNAL(aboutToChangeOrientation()), this, SLOT(orientationAboutToChange()));
}
HbInputAbstractMethod::focusReceived();
}
@@ -232,17 +239,16 @@
closeKeypad();
}
}
+ HbInputAbstractMethod::focusLost();
}
void HbVirtualQwerty::closeKeypad()
{
if (mVkbHost && mVkbHost->keypadStatus() != HbVkbHost::HbVkbStatusClosed) {
- mVkbHost->closeKeypad();
+ mVkbHost->closeKeypad(!stateChangeInProgress());
// set mCurrentKeypad to null.
mCurrentKeypad = 0;
- if (mCandidatePopup) {
- mCandidatePopup->hide();
- }
+ closeCandidatePopup();
}
}
@@ -265,10 +271,9 @@
disableAnimation = true;
}
}
+
// Close candidate popup if open
- if (mCandidatePopup) {
- mCandidatePopup->hide();
- }
+ closeCandidatePopup();
QObject::disconnect(mCurrentKeypad,SIGNAL(aboutToActivateCustomAction(HbAction*)),
this,SLOT(aboutToActivateCustomAction(HbAction*)));
@@ -276,10 +281,7 @@
this,SLOT(aboutToActivateCustomAction(HbAction*)));
// assign new keypad to be opened to varable mCurrentKeypad
- mCurrentKeypad = keypadToOpen;
- activeKeyboardChanged(currentKeyboardType());
-
-
+ mCurrentKeypad = keypadToOpen;
if (mVkbHost && mVkbHost->keypadStatus() != HbVkbHost::HbVkbStatusOpened) {
connect(mVkbHost, SIGNAL(keypadClosed()), this, SLOT(keypadClosed()));
if (inMinimizedMode) {
@@ -293,6 +295,10 @@
mVkbHost, SLOT(ensureCursorVisibility()));
}
}
+
+ if(mActiveModeHandler) {
+ mActiveModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionSetKeypad);
+ }
}
/*!
@@ -323,6 +329,7 @@
keyboard = mQwerty10x4Keypad;
}
connect(keyboard, SIGNAL(smileySelected(QString)), this, SLOT(smileySelected(QString)));
+ connect(keyboard, SIGNAL(settingsListClosed()), this, SLOT(restorePreviousState()));
//FLICKDISABLED connect(keyboard, SIGNAL(flickEvent(HbInputVkbWidget::FlickDirection)), this, SLOT(flickEvent(HbInputVkbWidget::FlickDirection)));
} else {
keyboard = new HbQwertyNumericKeyboard(this, mKeymap);
@@ -343,9 +350,7 @@
}
void HbVirtualQwerty::keypadClosed()
-{
- mOrientationAboutToChange = false;
-
+{
if (mVkbHost->keypadStatus() == HbVkbHost::HbVkbStatusMinimized) {
closeExactWordPopup();
}
@@ -358,9 +363,7 @@
if (mVkbHost && mVkbHost->keypadStatus() != HbVkbHost::HbVkbStatusMinimized) {
// We need to commit the inline word when we minimize the keypad
mActiveModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionCommit);
- if (mCandidatePopup) {
- mCandidatePopup->hide();
- }
+ closeCandidatePopup();
// Close input.
QInputContext* ic = qApp->inputContext();
@@ -417,6 +420,11 @@
mActiveModeHandler = mNumericModeHandler;
} else if (newState.inputMode() == HbInputModeDefault && usePrediction()) {
mActiveModeHandler = mPredictionModeHandler;
+ // by passing HbInputModeActionFocusRecieved we will be setting the candidate list and keypad
+ mActiveModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionFocusRecieved);
+ /* The below line should be added in orientationChanged Slot, however currently it is not working correctly
+ hence this fix is temporarily added here */
+ mPredictionModeHandler->setAutocompletionStatus(HbInputSettingProxy::instance()->isAutocompletionEnabled(HbKeyboardSettingQwerty));
} else if (newState.inputMode() == HbInputModeDefault) {
mActiveModeHandler = mBasicModeHandler;
// Auto completer setup needs following line.
@@ -530,13 +538,21 @@
}
/*!
+Closes the candidate popup if visible.
+*/
+void HbVirtualQwerty::closeCandidatePopup()
+{
+ if (mCandidatePopup && mCandidatePopup->isVisible()) {
+ mCandidatePopup->hide();
+ }
+}
+
+/*!
Slot used by mode handlers to close the autocompletion popup.
*/
void HbVirtualQwerty::closeAutoCompletionPopup()
{
- if (mCandidatePopup && mCandidatePopup->isVisible()) {
- mCandidatePopup->hide();
- }
+ closeCandidatePopup();
}
/*!
@@ -546,7 +562,7 @@
{
if (!mCandidatePopup) {
mCandidatePopup = new HbCandidateList(this);
- connect(mCandidatePopup, SIGNAL(candidatePopupCancelled()), this, SLOT(candidatePopupCancelled()));
+ connect(mCandidatePopup, SIGNAL(candidatePopupCancelled()), this, SLOT(restorePreviousState()));
connect(mCandidatePopup, SIGNAL(candidateSelected(int,const QString&)), this, SLOT(candidatePopupClosed(int, const QString&)));
}
@@ -559,8 +575,8 @@
mCandidatePopup->setBackgroundFaded(false);
mCandidatePopup->show();
}
- } else if (mCandidatePopup->isVisible()) {
- mCandidatePopup->hide();
+ } else {
+ closeCandidatePopup();
}
}
@@ -589,7 +605,7 @@
closeExactWordPopup();
if (!mCandidatePopup) {
mCandidatePopup = new HbCandidateList(this);
- connect(mCandidatePopup, SIGNAL(candidatePopupCancelled()), this, SLOT(candidatePopupCancelled()));
+ connect(mCandidatePopup, SIGNAL(candidatePopupCancelled()), this, SLOT(restorePreviousState()));
connect(mCandidatePopup, SIGNAL(candidateSelected(int,const QString&)), this, SLOT(candidatePopupClosed(int, const QString&)));
}
mCandidatePopup->populateList(candidates);
@@ -629,14 +645,6 @@
*/
void HbVirtualQwerty::orientationAboutToChange()
{
- HbInputMethod::orientationAboutToChange();
-
- if (isActiveMethod()) {
- mOrientationAboutToChange = true;
- // We need to commit the inline word before orientation change.
- mActiveModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionCommit);
- closeKeypad();
- }
}
/*!
@@ -705,7 +713,7 @@
void HbVirtualQwerty::autocompletionStateChanged(HbKeyboardSettingFlags keyboardType, bool newState)
{
- if (keyboardType & HbKeyboardSettingQwerty) {
+ if ( isActiveMethod() && (keyboardType & HbKeyboardSettingQwerty) ){
mPredictionModeHandler->setAutocompletionStatus(newState);
}
}
@@ -734,6 +742,8 @@
{
if (!mExactWordPopup) {
mExactWordPopup = HbExactWordPopup::instance();
+ mExactWordPopup->setPreferredHeight(HbDeviceProfile::profile(
+ mCurrentKeypad->mainWindow()).logicalSize().height() * HbExactPopupHeightFactor);
connect(mExactWordPopup, SIGNAL(exactWordSelected()), mPredictionModeHandler, SLOT(exactWordSelected()));
}
mExactWordPopup->setText(exactWord);
@@ -752,22 +762,48 @@
QPointF HbVirtualQwerty::getCursorCoordinatePosition()
{
+ QPointF cursorPos(0.0, 0.0);
QRectF microRect = focusObject()->microFocus();
- QPointF cursorPos = microRect.topLeft();
-
+ microRect.adjust(0.0, -HbEditorExtraMargin, 0.0, HbEditorExtraMargin);
+
if (mVkbHost) {
+ QRectF activeViewRect= mVkbHost->applicationArea();
+ qreal exactPopupHeight = HbDeviceProfile::profile(
+ mCurrentKeypad->mainWindow()).logicalSize().height() * HbExactPopupHeightFactor;
+ qreal topArea = microRect.top() - activeViewRect.top();
+ qreal bottomArea = activeViewRect.bottom() - microRect.bottom();
+ qreal xPos = microRect.left();
+ cursorPos.setX(xPos);
QSizeF exactPopupSize = mExactWordPopup->size();
- QRectF activeViewRect = mVkbHost->applicationArea();
- // if the exact word doesnt fit inside the visible area, then show it on the right side of
- // the current cursor position
- if (microRect.left() + exactPopupSize.width() > activeViewRect.width()) {
- qreal startPos = microRect.left() - exactPopupSize.width();
- cursorPos.setX((startPos > activeViewRect.left()) ? startPos : activeViewRect.left());
- }
+
+ // show the exact word popup either above or below the currently focused editor if both fits in the visible area.
+ // If enough space is not available, then show the exact word popup inside the focused editor
+ if (topArea > exactPopupHeight || bottomArea > exactPopupHeight) {
+ // show the popup above the editor if more space available
+ if (topArea > exactPopupHeight) {
+ cursorPos.setY(microRect.topLeft().y() - exactPopupHeight);
+ } else {
+ cursorPos.setY(microRect.bottomLeft().y());
+ }
+ // if there is no space to show the exact word popup in the right side of the cursor
+ // recatangle, then show it on the left side of the cursor
+ if (xPos + exactPopupSize.width() > activeViewRect.width()) {
+ cursorPos.setX(xPos - exactPopupSize.width());
+ }
+ } else {
+ // show the exact word popup inside the editor
+ cursorPos.setY(microRect.top() + (microRect.height() / 2) - (exactPopupHeight / 2));
+ xPos = xPos + HbDeltaWidth;
+ if (xPos + exactPopupSize.width() > activeViewRect.width()) {
+ qreal startPos = microRect.left() - (3 * exactPopupSize.width()) - HbDeltaWidth;
+ cursorPos.setX((startPos > activeViewRect.left()) ? startPos : activeViewRect.left());
+ }
+ }
}
return cursorPos;
}
+
/*!
Returns true if prediction is on, prediction engine is available and predictions is allowed in current editor.
*/
@@ -795,10 +831,11 @@
return mCurrentKeypad->probableKeypresses();
}
-void HbVirtualQwerty::candidatePopupCancelled()
+void HbVirtualQwerty::restorePreviousState()
{
- if(mPredictionModeHandler) {
- mPredictionModeHandler->showExactWordPopupIfNeeded();
- }
+ mActiveModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionRestorePreviousState);
}
// End of file
+
+
+