src/hbplugins/inputmethods/touchinput/hbinputbasic12keyhandler.cpp
changeset 1 f7ac710697a9
parent 0 16d8024aca5e
child 2 06ff229162e9
equal deleted inserted replaced
0:16d8024aca5e 1:f7ac710697a9
    30 #include <hbinputpredictionengine.h>
    30 #include <hbinputpredictionengine.h>
    31 #include <hbinputsettingproxy.h>
    31 #include <hbinputsettingproxy.h>
    32 #include <hbinputpredictionfactory.h>
    32 #include <hbinputpredictionfactory.h>
    33 #include "hbinputabstractbase.h"
    33 #include "hbinputabstractbase.h"
    34 #include "hbinputbasic12keyhandler.h"
    34 #include "hbinputbasic12keyhandler.h"
    35 #include "hbinputbasichandler_p.h"
    35 #include "hbinputbasic12keyhandler_p.h"
    36 
       
    37 class HbInputBasic12KeyHandlerPrivate: public HbInputBasicHandlerPrivate
       
    38 {
       
    39     Q_DECLARE_PUBLIC(HbInputBasic12KeyHandler)
       
    40 
       
    41 public:
       
    42     HbInputBasic12KeyHandlerPrivate();
       
    43     ~HbInputBasic12KeyHandlerPrivate();
       
    44 
       
    45     void handleAlphaEvent(int buttonId);
       
    46     bool buttonPressed(const QKeyEvent *keyEvent);
       
    47     bool buttonReleased(const QKeyEvent *keyEvent);
       
    48     bool actionHandler(HbInputModeHandler::HbInputModeAction action);
       
    49 
       
    50     void _q_timeout();
       
    51 
       
    52 public:
       
    53     int mLastKey;
       
    54     QChar mCurrentChar;
       
    55     int mNumChr;
       
    56     int mDownKey;
       
    57     HbInputFocusObject *mCurrentlyFocused;
       
    58     bool mLongPressHappened;
       
    59 	bool mShiftKeyDoubleTapped;
       
    60 };
       
    61 
    36 
    62 HbInputBasic12KeyHandlerPrivate::HbInputBasic12KeyHandlerPrivate()
    37 HbInputBasic12KeyHandlerPrivate::HbInputBasic12KeyHandlerPrivate()
    63 :    mLastKey(0),
    38 :    mLastKey(0),
    64     mCurrentChar(0),
    39     mCurrentChar(0),
    65     mNumChr(0),
    40     mNumChr(0),
    81     HbInputFocusObject *focusObject = 0;
    56     HbInputFocusObject *focusObject = 0;
    82     focusObject = mInputMethod->focusObject();
    57     focusObject = mInputMethod->focusObject();
    83     if (!focusObject) {
    58     if (!focusObject) {
    84         return;
    59         return;
    85     }
    60     }
    86 
    61 	//This condition is to avoid get the characters mapped to Asterisk
    87     mCurrentChar = q->getNthCharacterInKey(mNumChr, buttonId);
    62 	//Especially for Thai language we have mapped character to Asterisk
    88 
    63 	if(buttonId != Qt::Key_Asterisk) {
       
    64 		mCurrentChar = q->getNthCharacterInKey(mNumChr, buttonId);
       
    65 	}
    89 
    66 
    90     if (mCurrentChar != 0) {
    67     if (mCurrentChar != 0) {
    91         QString str;
    68         QString str;
    92         str += mCurrentChar;
    69         str += mCurrentChar;
    93 
    70 
   165 			// click a button and before the multitap timer expires click on
   142 			// click a button and before the multitap timer expires click on
   166 			// another button.
   143 			// another button.
   167 			// Need to check for shift key : In empty editor, click on editor
   144 			// Need to check for shift key : In empty editor, click on editor
   168 			// press shift, multitap on a button. The char is entered in upper case.
   145 			// press shift, multitap on a button. The char is entered in upper case.
   169 			// It should be entered in lower case.
   146 			// It should be entered in lower case.
   170             if (Qt::Key_Shift != mLastKey) {
   147             if (mLastKey && (Qt::Key_Shift != mLastKey)) {
   171 			    mInputMethod->updateState();
   148 			    mInputMethod->updateState();
   172             }
   149             }
   173 			refreshAutoCompleter();
   150 			refreshAutoCompleter();
   174 		}
   151 		}
   175 
   152 
   177 			mInputMethod->closeKeypad();
   154 			mInputMethod->closeKeypad();
   178 			mLastKey = buttonId;
   155 			mLastKey = buttonId;
   179 			return true;
   156 			return true;
   180 		} else if (buttonId == Qt::Key_Shift) {
   157 		} else if (buttonId == Qt::Key_Shift) {
   181             // single tap of shift key toggles prediction status in case insensitive languages
   158             // single tap of shift key toggles prediction status in case insensitive languages
   182             if (!HbInputSettingProxy::instance()->globalInputLanguage().isCaseSensitiveLanguage() && 
   159 			// The Editor should not be Web or URL which allows only Latin Alphabet
       
   160             if (!HbInputSettingProxy::instance()->globalInputLanguage().isCaseSensitiveLanguage() &&
       
   161 				((HbEditorConstraintLatinAlphabetOnly | HbEditorConstraintAutoCompletingField)!=focusObject->editorInterface().constraints()) &&
   183                 // when the language does not support prediction in that case we should not update the state and prediction
   162                 // when the language does not support prediction in that case we should not update the state and prediction
   184                 HbPredictionFactory::instance()->predictionEngineForLanguage(mInputMethod->inputState().language())) {
   163                 HbPredictionFactory::instance()->predictionEngineForLanguage(mInputMethod->inputState().language())) {
   185                 HbInputSettingProxy::instance()->togglePrediction();
   164                 HbInputSettingProxy::instance()->togglePrediction();
   186             } else {
   165             } else {
   187                 // For single key press, change the text input case. If the second shift key press is 
   166                 // For single key press, change the text input case. If the second shift key press is 
   188 				// received within long key press time out interval, then activate the next state
   167 				// received within long key press time out interval, then activate the next state
   189                 if (mShiftKeyDoubleTapped){
   168                 if (mShiftKeyDoubleTapped){
   190                     mShiftKeyDoubleTapped = false;
   169                     mShiftKeyDoubleTapped = false;
   191                     mTimer->stop();
   170                     mTimer->stop();
   192                     if( HbInputSettingProxy::instance()->globalInputLanguage() == mInputMethod->inputState().language() ||
   171                     if( HbInputSettingProxy::instance()->globalInputLanguage() == mInputMethod->inputState().language() ||
   193                         HbInputSettingProxy::instance()->globalSecondaryInputLanguage() == mInputMethod->inputState().language() ){
   172                         HbInputSettingProxy::instance()->globalSecondaryInputLanguage() == mInputMethod->inputState().language() ||
       
   173 						((HbEditorConstraintLatinAlphabetOnly | HbEditorConstraintAutoCompletingField)==focusObject->editorInterface().constraints())){
   194                         // in latin variants , double tap of shift key toggles the prediction status	
   174                         // in latin variants , double tap of shift key toggles the prediction status	
   195                         // revert back to the old case as this is a double tap 
   175                         // revert back to the old case as this is a double tap 
   196                         // (the case was changed on the single tap)
   176                         // (the case was changed on the single tap)
   197                         updateTextCase();
   177                         updateTextCase();
   198                         // when the language does not support prediction in that case we should not update the state and prediction
   178                         // when the language does not support prediction in that case we should not update the state and prediction
   199                         if(HbPredictionFactory::instance()->predictionEngineForLanguage(mInputMethod->inputState().language())) {
   179                         if(HbPredictionFactory::instance()->predictionEngineForLanguage(mInputMethod->inputState().language())) {
   200                             HbInputSettingProxy::instance()->togglePrediction();
   180                             q->togglePrediction();
   201                         }
   181                         }
   202                     } else {
   182                     } else {
   203 					    // if the global language is different from the input mode language, we should 
   183 					    // if the global language is different from the input mode language, we should 
   204                         // go back to the root state
   184                         // go back to the root state
   205                         // e.g. double tap of hash/shift key is used to change 
   185                         // e.g. double tap of hash/shift key is used to change 
   388 {
   368 {
   389     Q_D(HbInputBasic12KeyHandler);
   369     Q_D(HbInputBasic12KeyHandler);
   390     d->q_ptr = this;
   370     d->q_ptr = this;
   391 }
   371 }
   392 
   372 
       
   373 HbInputBasic12KeyHandler::HbInputBasic12KeyHandler(HbInputBasic12KeyHandlerPrivate &dd, HbInputAbstractMethod* inputMethod)
       
   374 :HbInputBasicHandler(dd, inputMethod)
       
   375 {
       
   376     Q_D(HbInputBasic12KeyHandler);
       
   377     d->q_ptr = this;
       
   378     d->init();
       
   379 }
       
   380 
   393 HbInputBasic12KeyHandler::~HbInputBasic12KeyHandler()
   381 HbInputBasic12KeyHandler::~HbInputBasic12KeyHandler()
   394 {
   382 {
   395 }
   383 }
   396 
   384 
   397 /*!
   385 /*!
   413 */
   401 */
   414 bool HbInputBasic12KeyHandler::isComposing() const
   402 bool HbInputBasic12KeyHandler::isComposing() const
   415 {
   403 {
   416     Q_D(const HbInputBasic12KeyHandler);
   404     Q_D(const HbInputBasic12KeyHandler);
   417     return d->mTimer->isActive();
   405     return d->mTimer->isActive();
   418 }
       
   419 
       
   420 /*!
       
   421  list different input modes.
       
   422 */
       
   423 void HbInputBasic12KeyHandler::listInputModes(QVector<HbInputModeProperties>& modes) const
       
   424 {
       
   425     HbInputModeProperties binding;
       
   426     binding.iMode = HbInputModeDefault;
       
   427     binding.iKeyboard = HbKeyboardVirtual12Key;
       
   428 
       
   429     QList<HbInputLanguage> languages = HbKeymapFactory::availableLanguages();
       
   430     foreach (HbInputLanguage language, languages) {
       
   431         binding.iLanguage = language;
       
   432         modes.push_back(binding);
       
   433     }
       
   434 }
   406 }
   435 
   407 
   436 /*!
   408 /*!
   437 Action Handler
   409 Action Handler
   438 */
   410 */