src/hbplugins/inputmethods/common/hbinputabstractbase.cpp
changeset 34 ed14f46c0e55
parent 5 627c4a0fd0e7
--- a/src/hbplugins/inputmethods/common/hbinputabstractbase.cpp	Mon Oct 04 17:49:30 2010 +0300
+++ b/src/hbplugins/inputmethods/common/hbinputabstractbase.cpp	Mon Oct 18 18:23:13 2010 +0300
@@ -41,6 +41,7 @@
 HbInputAbstractMethod::HbInputAbstractMethod()
 {
     mVanillQwertySwitch = new HbAction(QString("QTY"));
+    mIsFocusOnVanillaQtEditor = false;
 }
 
 // ---------------------------------------------------------------------------
@@ -163,7 +164,7 @@
 
 bool HbInputAbstractMethod::isSctModeActive() const
 {
-	return false;
+    return false;
 }
 
 
@@ -174,16 +175,16 @@
 
 void HbInputAbstractMethod::focusReceived()
 {
-    bool isVannilaApp = false;
+    mIsFocusOnVanillaQtEditor = false;
     QInputContext* context = qApp->inputContext();
     if (context && context->focusWidget()) {
         QWidget *focusedWidget = context->focusWidget();
         if (!focusedWidget->inherits("HbMainWindow")) {
-            isVannilaApp = true;
+            mIsFocusOnVanillaQtEditor = true;
         }
     }
     
-    if(isVannilaApp && focusObject() ) {
+    if(mIsFocusOnVanillaQtEditor && focusObject() ) {
         QList<HbAction*> customActions= focusObject()->editorInterface().actions();
         if(!customActions.contains(mVanillQwertySwitch)) {
             disconnect(mVanillQwertySwitch, SIGNAL(triggered(bool)));
@@ -193,25 +194,36 @@
     }
 }
 
+
+void HbInputAbstractMethod::focusLost()
+{
+    
+    if(mIsFocusOnVanillaQtEditor &&  focusObject()) {
+        QList<HbAction*> customActions= focusObject()->editorInterface().actions();
+        if(customActions.contains(mVanillQwertySwitch)) {
+            disconnect(mVanillQwertySwitch, SIGNAL(triggered(bool)));
+            disconnect(mVanillQwertySwitch, SIGNAL(triggered(bool)), this, SLOT(switchKeypad(bool)));
+            focusObject()->editorInterface().removeAction(mVanillQwertySwitch);            
+        }
+    }
+}
+
 void HbInputAbstractMethod::switchKeypad(bool isActive)
 {
     Q_UNUSED(isActive);
-    HbKeyboardType keyboard = HbInputSettingProxy::instance()->activeKeyboard();
-    if (keyboard == HbKeyboardVirtual12Key) {
-        HbInputSettingProxy::instance()->setActiveKeyboard(HbKeyboardVirtualQwerty);
-    } else if (keyboard == HbKeyboardVirtualQwerty) {
-        HbInputSettingProxy::instance()->setActiveKeyboard(HbKeyboardVirtual12Key);
+    HbInputState state = inputState();
+    if (currentKeyboardType() == HbKeyboardVirtual12Key) {
+        state.setKeyboard(HbKeyboardVirtualQwerty);
+        activateState(state);
+    } else if (currentKeyboardType() == HbKeyboardVirtualQwerty) {
+        state.setKeyboard(HbKeyboardVirtual12Key);
+        activateState(state);
     }
 }
 
-// EOF
-
-
-
-   
 QChar HbInputAbstractMethod ::previousChar()
 {
-	return QChar();
+    return QChar();
 }