src/hbplugins/inputmethods/common/hbinputabstractbase.cpp
changeset 34 ed14f46c0e55
parent 5 627c4a0fd0e7
equal deleted inserted replaced
31:7516d6d86cf5 34:ed14f46c0e55
    39 //
    39 //
    40 // ---------------------------------------------------------------------------
    40 // ---------------------------------------------------------------------------
    41 HbInputAbstractMethod::HbInputAbstractMethod()
    41 HbInputAbstractMethod::HbInputAbstractMethod()
    42 {
    42 {
    43     mVanillQwertySwitch = new HbAction(QString("QTY"));
    43     mVanillQwertySwitch = new HbAction(QString("QTY"));
       
    44     mIsFocusOnVanillaQtEditor = false;
    44 }
    45 }
    45 
    46 
    46 // ---------------------------------------------------------------------------
    47 // ---------------------------------------------------------------------------
    47 // HbInputAbstractMethod::~HbInputAbstractMethod
    48 // HbInputAbstractMethod::~HbInputAbstractMethod
    48 //
    49 //
   161 }
   162 }
   162 
   163 
   163 
   164 
   164 bool HbInputAbstractMethod::isSctModeActive() const
   165 bool HbInputAbstractMethod::isSctModeActive() const
   165 {
   166 {
   166 	return false;
   167     return false;
   167 }
   168 }
   168 
   169 
   169 
   170 
   170 HbKeyboardType HbInputAbstractMethod::currentKeyboardType() const
   171 HbKeyboardType HbInputAbstractMethod::currentKeyboardType() const
   171 {
   172 {
   172     return HbKeyboardNone;
   173     return HbKeyboardNone;
   173 }
   174 }
   174 
   175 
   175 void HbInputAbstractMethod::focusReceived()
   176 void HbInputAbstractMethod::focusReceived()
   176 {
   177 {
   177     bool isVannilaApp = false;
   178     mIsFocusOnVanillaQtEditor = false;
   178     QInputContext* context = qApp->inputContext();
   179     QInputContext* context = qApp->inputContext();
   179     if (context && context->focusWidget()) {
   180     if (context && context->focusWidget()) {
   180         QWidget *focusedWidget = context->focusWidget();
   181         QWidget *focusedWidget = context->focusWidget();
   181         if (!focusedWidget->inherits("HbMainWindow")) {
   182         if (!focusedWidget->inherits("HbMainWindow")) {
   182             isVannilaApp = true;
   183             mIsFocusOnVanillaQtEditor = true;
   183         }
   184         }
   184     }
   185     }
   185     
   186     
   186     if(isVannilaApp && focusObject() ) {
   187     if(mIsFocusOnVanillaQtEditor && focusObject() ) {
   187         QList<HbAction*> customActions= focusObject()->editorInterface().actions();
   188         QList<HbAction*> customActions= focusObject()->editorInterface().actions();
   188         if(!customActions.contains(mVanillQwertySwitch)) {
   189         if(!customActions.contains(mVanillQwertySwitch)) {
   189             disconnect(mVanillQwertySwitch, SIGNAL(triggered(bool)));
   190             disconnect(mVanillQwertySwitch, SIGNAL(triggered(bool)));
   190             connect(mVanillQwertySwitch, SIGNAL(triggered(bool)), this, SLOT(switchKeypad(bool)));
   191             connect(mVanillQwertySwitch, SIGNAL(triggered(bool)), this, SLOT(switchKeypad(bool)));
   191             focusObject()->editorInterface().addAction(mVanillQwertySwitch);
   192             focusObject()->editorInterface().addAction(mVanillQwertySwitch);
   192         }
   193         }
   193     }
   194     }
   194 }
   195 }
   195 
   196 
       
   197 
       
   198 void HbInputAbstractMethod::focusLost()
       
   199 {
       
   200     
       
   201     if(mIsFocusOnVanillaQtEditor &&  focusObject()) {
       
   202         QList<HbAction*> customActions= focusObject()->editorInterface().actions();
       
   203         if(customActions.contains(mVanillQwertySwitch)) {
       
   204             disconnect(mVanillQwertySwitch, SIGNAL(triggered(bool)));
       
   205             disconnect(mVanillQwertySwitch, SIGNAL(triggered(bool)), this, SLOT(switchKeypad(bool)));
       
   206             focusObject()->editorInterface().removeAction(mVanillQwertySwitch);            
       
   207         }
       
   208     }
       
   209 }
       
   210 
   196 void HbInputAbstractMethod::switchKeypad(bool isActive)
   211 void HbInputAbstractMethod::switchKeypad(bool isActive)
   197 {
   212 {
   198     Q_UNUSED(isActive);
   213     Q_UNUSED(isActive);
   199     HbKeyboardType keyboard = HbInputSettingProxy::instance()->activeKeyboard();
   214     HbInputState state = inputState();
   200     if (keyboard == HbKeyboardVirtual12Key) {
   215     if (currentKeyboardType() == HbKeyboardVirtual12Key) {
   201         HbInputSettingProxy::instance()->setActiveKeyboard(HbKeyboardVirtualQwerty);
   216         state.setKeyboard(HbKeyboardVirtualQwerty);
   202     } else if (keyboard == HbKeyboardVirtualQwerty) {
   217         activateState(state);
   203         HbInputSettingProxy::instance()->setActiveKeyboard(HbKeyboardVirtual12Key);
   218     } else if (currentKeyboardType() == HbKeyboardVirtualQwerty) {
   204     }
   219         state.setKeyboard(HbKeyboardVirtual12Key);
   205 }
   220         activateState(state);
       
   221     }
       
   222 }
       
   223 
       
   224 QChar HbInputAbstractMethod ::previousChar()
       
   225 {
       
   226     return QChar();
       
   227 }
       
   228 
   206 
   229 
   207 // EOF
   230 // EOF
   208 
   231 
   209 
       
   210 
       
   211    
       
   212 QChar HbInputAbstractMethod ::previousChar()
       
   213 {
       
   214 	return QChar();
       
   215 }
       
   216 
       
   217 
       
   218 // EOF
       
   219