src/hbplugins/inputmethods/hardwareinput/hbhardwareqwerty.cpp
changeset 0 16d8024aca5e
child 1 f7ac710697a9
equal deleted inserted replaced
-1:000000000000 0:16d8024aca5e
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (developer.feedback@nokia.com)
       
     6 **
       
     7 ** This file is part of the HbPlugins module of the UI Extensions for Mobile.
       
     8 **
       
     9 ** GNU Lesser General Public License Usage
       
    10 ** This file may be used under the terms of the GNU Lesser General Public
       
    11 ** License version 2.1 as published by the Free Software Foundation and
       
    12 ** appearing in the file LICENSE.LGPL included in the packaging of this file.
       
    13 ** Please review the following information to ensure the GNU Lesser General
       
    14 ** Public License version 2.1 requirements will be met:
       
    15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    16 **
       
    17 ** In addition, as a special exception, Nokia gives you certain additional
       
    18 ** rights.  These rights are described in the Nokia Qt LGPL Exception
       
    19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
       
    20 **
       
    21 ** If you have questions regarding the use of this file, please contact
       
    22 ** Nokia at developer.feedback@nokia.com.
       
    23 **
       
    24 ****************************************************************************/
       
    25 
       
    26 #include <QApplication>
       
    27 #include <QLocale>
       
    28 #include <hbinputkeymapfactory.h>
       
    29 #include <hbinputcommondialogs.h>
       
    30 
       
    31 
       
    32 #include "hbhardwareqwerty.h"
       
    33 #include "hbinputkeymapdata.h"
       
    34 #include "hbinpututils.h"
       
    35 #include "hbinputsettingproxy.h"
       
    36 #include "hbinputfocusobject.h"
       
    37 #include "hbinputexactwordpopup.h"
       
    38 #include "hbinputcandidatelist.h"
       
    39 #include "hbinputcharpreviewpane.h"
       
    40 #include "hbhardwareinputbasicqwertyhandler.h"
       
    41 #include "hbhardwareinputpredictionqwertyhandler.h"
       
    42 #include "hbhardwareinputnumericqwertyhandler.h"
       
    43 
       
    44 // ---------------------------------------------------------------------------
       
    45 // HbHardwareQwerty::HbHardwareQwerty
       
    46 //
       
    47 // ---------------------------------------------------------------------------
       
    48 //
       
    49 HbHardwareQwerty::HbHardwareQwerty() :  mKeyData(0),
       
    50                                         mExactWordPopup(0),
       
    51                                         mCandidatePopup(0),
       
    52                                         mPreviewPane(0),
       
    53                                         mMode(HbInputModeDefault),
       
    54                                         mKeypad(0),
       
    55                                         mVkbHost(0)
       
    56 
       
    57 {
       
    58     // Assume that this will be the language we're going to use and cache it.
       
    59     mKeyData = HbKeyMapFactory::instance()->keymapDataForLanguage(HbInputSettingProxy::instance()->globalInputLanguage().language());
       
    60 
       
    61     if (!mKeyData) {
       
    62         qDebug("HbHardwareQwerty: ERROR: Initialization FAILED!");     
       
    63     } 
       
    64     initializeModeHandlers();
       
    65 }
       
    66 
       
    67 void HbHardwareQwerty::initializeModeHandlers()
       
    68 {
       
    69     // lets construct all the three supported mode handlers.
       
    70     mBasicModeHandler = new HbHardwareInputBasicQwertyHandler(this);
       
    71     mPredictionModeHandler = new HbHardwareInputPredictionQwertyHandler(this);
       
    72     mNumericModeHandler = new HbHardwareInputNumericQwertyHandler(this);
       
    73     // bydefault latin basic mode handler is activated.
       
    74     mActiveModeHandler = mBasicModeHandler;
       
    75 
       
    76     // init will initialize the individual mode handlers.
       
    77     mBasicModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionInit);
       
    78     mPredictionModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionInit);
       
    79     mNumericModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionInit);
       
    80 
       
    81     // exact word popup connections.
       
    82     connect(this , SIGNAL(flipStatusChange()), HbInputSettingProxy::instance(), SLOT(flipToggle()));    
       
    83 }
       
    84 
       
    85 // ---------------------------------------------------------------------------
       
    86 // HbHardwareQwerty::~HbHardwareQwerty
       
    87 //
       
    88 // ---------------------------------------------------------------------------
       
    89 //
       
    90 HbHardwareQwerty::~HbHardwareQwerty()
       
    91 {
       
    92     delete mCandidatePopup;
       
    93     mCandidatePopup = 0;
       
    94     
       
    95     delete mExactWordPopup;
       
    96     mExactWordPopup = 0;
       
    97 
       
    98     // free mode handlers
       
    99     delete mBasicModeHandler;
       
   100     mBasicModeHandler = 0;
       
   101     delete mPredictionModeHandler;
       
   102     mPredictionModeHandler = 0;
       
   103     delete mNumericModeHandler;
       
   104     mNumericModeHandler = 0;
       
   105     delete mPreviewPane;
       
   106     mPreviewPane = 0;
       
   107     delete mKeypad;
       
   108     mKeypad = 0;
       
   109 }
       
   110 
       
   111 
       
   112 // ---------------------------------------------------------------------------
       
   113 // HbHardwareQwerty::identifierName
       
   114 //
       
   115 // ---------------------------------------------------------------------------
       
   116 //
       
   117 QString HbHardwareQwerty::identifierName()
       
   118 {
       
   119     return QString("HbHardwareQwerty");
       
   120 }
       
   121 
       
   122 
       
   123 // ---------------------------------------------------------------------------
       
   124 // HbHardwareQwerty::isComposing
       
   125 //
       
   126 // ---------------------------------------------------------------------------
       
   127 //
       
   128 bool HbHardwareQwerty::isComposing() const
       
   129 {
       
   130     return mActiveModeHandler->isComposing();
       
   131 }
       
   132 
       
   133 
       
   134 // ---------------------------------------------------------------------------
       
   135 // HbHardwareQwerty::language
       
   136 //
       
   137 // ---------------------------------------------------------------------------
       
   138 //
       
   139 QString HbHardwareQwerty::language()
       
   140 {
       
   141     return QString();
       
   142 }
       
   143 
       
   144 
       
   145 // ---------------------------------------------------------------------------
       
   146 // HbHardwareQwerty::reset
       
   147 //
       
   148 // ---------------------------------------------------------------------------
       
   149 //
       
   150 void HbHardwareQwerty::reset()
       
   151 {
       
   152     mActiveModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionReset);
       
   153 }
       
   154 
       
   155 
       
   156 // ---------------------------------------------------------------------------
       
   157 // HbHardwareQwerty::filterEvent
       
   158 //
       
   159 // ---------------------------------------------------------------------------
       
   160 //
       
   161 bool HbHardwareQwerty::filterEvent(const QEvent *event)
       
   162 {
       
   163 	const QKeyEvent *keyEvent = 0;
       
   164     keyEvent = static_cast<const QKeyEvent *>(event);
       
   165 	if(keyEvent->key() == Qt::Key_F8){
       
   166 		emit flipStatusChange();
       
   167 		return false;
       
   168 	}
       
   169     if(handleEvent()){
       
   170         return mActiveModeHandler->filterEvent(event);
       
   171     } 
       
   172     return false;
       
   173 }
       
   174 
       
   175 // ---------------------------------------------------------------------------
       
   176 // HbHardwareQwerty::listInputModes
       
   177 //
       
   178 // ---------------------------------------------------------------------------
       
   179 //
       
   180 void HbHardwareQwerty::listInputModes(QVector<HbInputModeProperties>& results)
       
   181 {       
       
   182         // list out each mode handlers.
       
   183     mBasicModeHandler->listInputModes(results);
       
   184     mPredictionModeHandler->listInputModes(results);
       
   185     mNumericModeHandler->listInputModes(results);
       
   186 }
       
   187 
       
   188 
       
   189 // ---------------------------------------------------------------------------
       
   190 // HbHardwareQwerty::focusReceived
       
   191 //
       
   192 // ---------------------------------------------------------------------------
       
   193 //
       
   194 void HbHardwareQwerty::focusReceived()
       
   195 {    
       
   196         // inform active mode handler about the focusrecieve event.
       
   197     mActiveModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionFocusRecieved);
       
   198 
       
   199     HbInputLanguage lang = activeLanguage();
       
   200     if (!mKeyData ||  mKeyData->languageCode() != lang.language()) {
       
   201         mKeyData = HbKeyMapFactory::instance()->keymapDataForLanguage(lang.language());
       
   202     }
       
   203     if (focusObject()) {    
       
   204         focusObject()->syncEditorInterface();
       
   205     }
       
   206     
       
   207     if(!mKeypad) {
       
   208         mKeypad = constructKeypad();
       
   209     }
       
   210     // We need to check if this focusRecieved call is due to a orientation 
       
   211     // switch. If yes we should get the keypad status prior to the orientation
       
   212     // switch and open the keypad in that state only.
       
   213     // For example we have minimized the keypad in Qwerty mode and change the 
       
   214     // orientation to portrait then in Itu-T mode also keypad should be in minimized state.
       
   215     if (orientationContextSwitchInProgress()) {
       
   216         HbVkbHost *host = focusObject()->findVkbHost();
       
   217         if (host) {
       
   218             // We can get the keypad status prior to the orientation switch from vkbHost itself.
       
   219             HbVkbHost::HbVkbStatus vkbStatus = host->keypadStatusBeforeOrientationChange();
       
   220             if (vkbStatus != HbVkbHost::HbVkbStatusClosed) {
       
   221                 openKeypad(vkbStatus == HbVkbHost::HbVkbStatusMinimized);
       
   222             }
       
   223         }
       
   224     } else {
       
   225         openKeypad();
       
   226     }
       
   227     
       
   228     //This may not be required with the generic solution for all focusing problems
       
   229     //But, let it be there for the time being.
       
   230     if (focusObject()) {
       
   231         connect(&(focusObject()->editorInterface()), SIGNAL(cursorPositionChanged(int, int)), mVkbHost, SLOT(ensureCursorVisibility()));
       
   232     }
       
   233     qDebug("HbHardwareQwerty::focusReceived");  
       
   234 }   
       
   235 
       
   236 
       
   237 // ---------------------------------------------------------------------------
       
   238 // HbHardwareQwerty::focusLost
       
   239 //
       
   240 // ---------------------------------------------------------------------------
       
   241 //
       
   242 void HbHardwareQwerty::focusLost(bool focusSwitch)
       
   243 {
       
   244     Q_UNUSED(focusSwitch);
       
   245     mActiveModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionFocusLost);
       
   246     if (!focusSwitch) {
       
   247         if (mVkbHost && mVkbHost->keypadStatus() != HbVkbHost::HbVkbStatusClosed) {
       
   248             // Context switch has happened but the keypad is still open.
       
   249             // Close it.
       
   250             closeKeypad();
       
   251         }
       
   252     }
       
   253 }   
       
   254 
       
   255 // ---------------------------------------------------------------------------
       
   256 // HbHardwareQwerty::mouseHandler
       
   257 //
       
   258 // ---------------------------------------------------------------------------
       
   259 //
       
   260 void HbHardwareQwerty::mouseHandler(int x, QMouseEvent* event)
       
   261 {
       
   262     mActiveModeHandler->mouseHandler(x, event);
       
   263 }
       
   264 
       
   265 
       
   266 
       
   267 // ---------------------------------------------------------------------------
       
   268 // HbHardwareQwerty::sctCharacterSelected
       
   269 //
       
   270 // ---------------------------------------------------------------------------
       
   271 //
       
   272 void HbHardwareQwerty::sctCharacterSelected(QChar character)
       
   273 {
       
   274     // Needs to be handled based on how SCT is implemented (on keypad or on dialog)
       
   275     Q_UNUSED(character)
       
   276     qDebug("HbVirtual12Key::sctCharacterSelected");
       
   277 }
       
   278 
       
   279 
       
   280 // ---------------------------------------------------------------------------
       
   281 // HbHardwareQwerty::InputLanguageChanged
       
   282 //
       
   283 // ---------------------------------------------------------------------------
       
   284 //       
       
   285 void HbHardwareQwerty::InputLanguageChanged(int newLanguage)
       
   286 {
       
   287     qDebug("HbHardwareQwerty::InputLanguageChanged");   
       
   288     mKeyData = HbKeyMapFactory::instance()->keymapDataForLanguage(newLanguage);
       
   289     if (!mKeyData) {
       
   290         qDebug("HbHardwareQwerty: ERROR: Language switch FAILED for language %d", newLanguage);
       
   291     }
       
   292 
       
   293     // inform mode handlers about the language change.
       
   294     mBasicModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionPrimaryLanguageChanged);
       
   295     mPredictionModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionPrimaryLanguageChanged);
       
   296 }  
       
   297 
       
   298 
       
   299 // ---------------------------------------------------------------------------
       
   300 // HbHardwareQwerty::inputStateActivated
       
   301 //
       
   302 // ---------------------------------------------------------------------------
       
   303 //     
       
   304 void HbHardwareQwerty::inputStateActivated(const HbInputState& newState)
       
   305 {    
       
   306     // TODO: Switch editing indicator here....
       
   307     //     SetEditingIndicator(HbEditingIndicatorLatinMultitap);
       
   308     qDebug("inputStateActivated");
       
   309     HbInputLanguage lang = activeLanguage();
       
   310     if (!mKeyData || mKeyData->languageCode() != lang.language()) {
       
   311         mKeyData = HbKeyMapFactory::instance()->keymapDataForLanguage(lang.language());
       
   312     }
       
   313         HbInputModeHandler *previousModeHandler = mActiveModeHandler;
       
   314     if (newState.inputMode() == HbInputModeNumeric) {
       
   315         mActiveModeHandler = mNumericModeHandler;
       
   316     } else if (newState.inputMode() == HbInputModeDefault && usePrediction()) {
       
   317         mActiveModeHandler = mPredictionModeHandler;
       
   318     } else if (newState.inputMode() == HbInputModeDefault) {        
       
   319         mActiveModeHandler = mBasicModeHandler;
       
   320     } 
       
   321     //handle character preview pane logic here
       
   322     //Handle connection to character preview popup selected signal  
       
   323     
       
   324     // if there is a change in the modehandler we need send a commit in previous mode handler.
       
   325     if (previousModeHandler != mActiveModeHandler) {
       
   326         if (previousModeHandler == mPredictionModeHandler) {
       
   327             previousModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionHideTail);
       
   328         }
       
   329         previousModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionCommit);
       
   330         // lets set candidate list and keypad type to the engine.
       
   331         mActiveModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionSetCandidateList);
       
   332         mActiveModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionSetKeypad);
       
   333     }
       
   334     if (focusObject()) {    
       
   335         focusObject()->syncEditorInterface();
       
   336     }
       
   337 }
       
   338 
       
   339 // ---------------------------------------------------------------------------
       
   340 // HbHardwareQwerty::switchSpecialCharacterTable
       
   341 //
       
   342 // ---------------------------------------------------------------------------
       
   343 //
       
   344 void HbHardwareQwerty::switchSpecialCharacterTable()
       
   345 {
       
   346     displaySpecialCharacterTable(this);
       
   347 }
       
   348 
       
   349 // ---------------------------------------------------------------------------
       
   350 // HbHardwareQwerty::displaySpecialCharacterTable
       
   351 //
       
   352 // ---------------------------------------------------------------------------
       
   353 //
       
   354 int HbHardwareQwerty::displaySpecialCharacterTable(QObject* receiver)
       
   355 {
       
   356     Q_UNUSED(receiver)
       
   357     return 0;
       
   358 }
       
   359 
       
   360 
       
   361 /*!
       
   362 This function is called during a long key press
       
   363 for a long time.
       
   364 */
       
   365 void HbHardwareQwerty::launchCharacterPreviewPane(int key)
       
   366 {
       
   367     if(!mPreviewPane){
       
   368     mPreviewPane = new HbCharPreviewPane();
       
   369     }
       
   370     // get the characters bound to the key.
       
   371     QStringList spellList;
       
   372     mActiveModeHandler->getAndFilterCharactersBoundToKey(spellList, static_cast<Qt::Key> (key));
       
   373     
       
   374     qDebug("previrew request..!");
       
   375     if (spellList.size()) {
       
   376         // preview pane should show the correct case.
       
   377         int currentTextCase = focusObject()->editorInterface().textCase();
       
   378         for(int i = 0; i < spellList.size(); i++) {
       
   379             if (currentTextCase == HbTextCaseLower) {
       
   380                 spellList[i] = spellList.at(i).toLower();
       
   381             } else {
       
   382                 spellList[i] = spellList.at(i).toUpper();
       
   383             }
       
   384         }
       
   385 //        mPreviewPane->showCharacters(spellList, getCursorCoordinatePosition());
       
   386     }
       
   387 }
       
   388 
       
   389 /*!
       
   390 Launches the candidate list with the passed candidates.
       
   391 */
       
   392 void HbHardwareQwerty::launchCandidatePopup(QStringList *candidates)
       
   393 {
       
   394     //before launching candidate popup, close exact word popup if visible.
       
   395     closeExactWordPopup();
       
   396     if (!mCandidatePopup) {
       
   397         mCandidatePopup = new HbCandidateList(this);
       
   398     }
       
   399     mCandidatePopup->populateList(*candidates);
       
   400     mCandidatePopup->show();
       
   401 }
       
   402 
       
   403 /*!
       
   404 Commits the candidate upon closing of the candidate list.
       
   405 */
       
   406 void HbHardwareQwerty::candidatePopupClosed(int closingKey)
       
   407 {
       
   408     if (mCandidatePopup) {
       
   409         QString currentCandidate = mCandidatePopup->currentCandidate();
       
   410         if (currentCandidate.size() > 0) {
       
   411             mPredictionModeHandler->candidatePopupClosed(currentCandidate, closingKey);
       
   412         }
       
   413     }
       
   414 }
       
   415 
       
   416 
       
   417 void HbHardwareQwerty::predictiveInputStatusChanged(int newStatus)
       
   418 {
       
   419     //Q_UNUSED(newStatus);
       
   420     //HbInputFocusObject *focusedObject = 0;
       
   421     //focusedObject = focusObject();
       
   422     //if (!focusedObject) {
       
   423     //    qDebug("HbHardwareQwerty::predictiveInputStatusChanged focusObject() failed!!");
       
   424     //    return;
       
   425     //}
       
   426 
       
   427     //HbInputState inputState;
       
   428     //if (mMode == HbInputModeDefault) {
       
   429     //    mMode = HbInputModeLatinPredictive;
       
   430     //    inputState = HbInputState(HbInputModeLatinPredictive,
       
   431     //        HbTextCase(focusedObject->editorInterface().textCase()),
       
   432     //        HbInputSettingProxy::instance()->activeHwKeyboard(), HbInputSettingProxy::instance()->globalInputLanguage());
       
   433     //} else {
       
   434     //    inputState = HbInputState(HbInputModeLatinBasic,
       
   435     //        HbTextCase(focusedObject->editorInterface().textCase()),
       
   436     //        HbInputSettingProxy::instance()->activeHwKeyboard(), HbInputSettingProxy::instance()->globalInputLanguage());
       
   437     //    mMode = HbInputModeLatinBasic;
       
   438     //}
       
   439     //activateState(inputState);
       
   440     //focusedObject->editorInterface().setInputMode(mMode);
       
   441     //focusedObject->syncEditorInterface();
       
   442 	Q_UNUSED(newStatus);
       
   443 
       
   444 //    HbInputFocusObject *focusedObject = focusObject();
       
   445     /*if (focusedObject)*/ {
       
   446         // Just refresh the situation.
       
   447         inputStateActivated(inputState());   
       
   448     }     
       
   449 
       
   450 }
       
   451 
       
   452 
       
   453 /*!
       
   454 Slot used by mode handlers to set the keypad modifiers
       
   455 */
       
   456 void HbHardwareQwerty::launchExactWordPopup(QString exactWord)
       
   457 {
       
   458     if (!mExactWordPopup) {
       
   459         mExactWordPopup = HbExactWordPopup::instance();
       
   460         connect(mExactWordPopup, SIGNAL(exactWordSelected()), mPredictionModeHandler, SLOT(exactWordPopupClosed()));
       
   461     }
       
   462     mExactWordPopup->setText(exactWord);
       
   463     mExactWordPopup->showText(getCursorCoordinatePosition());
       
   464 }
       
   465 
       
   466 /*!
       
   467 Slot for hiding the exact word popup.
       
   468 */
       
   469 void HbHardwareQwerty::closeExactWordPopup()
       
   470 {
       
   471     if (mExactWordPopup && mExactWordPopup->isVisible()) {
       
   472         mExactWordPopup->hide();
       
   473     }
       
   474 }
       
   475 
       
   476 
       
   477 QPointF HbHardwareQwerty::getCursorCoordinatePosition()
       
   478 {
       
   479     QRectF microRect = focusObject()->microFocus();
       
   480     return microRect.topLeft();
       
   481 }
       
   482 
       
   483 /*!
       
   484 Call back indicating that the keypad is closed.
       
   485 */
       
   486 void HbHardwareQwerty::keypadClosed()
       
   487 {
       
   488 }
       
   489 
       
   490 /*!
       
   491 Call back indicating that the keypad is opened.
       
   492 */
       
   493 void HbHardwareQwerty::keypadOpened()
       
   494 {
       
   495 }
       
   496 
       
   497 /*!
       
   498 The call back from the VKB keypad widget before it closes the keypad.
       
   499 */
       
   500 void HbHardwareQwerty::keypadCloseEventDetected(HbInputVkbWidget::HbVkbCloseMethod vkbCloseMethod)
       
   501 {
       
   502     if (isActiveMethod()) {
       
   503         // A drag on the button meaning we need to delete character and commit.
       
   504         if (mKeypad && vkbCloseMethod == HbInputVkbWidget::HbVkbCloseMethodButtonDrag) {
       
   505             mActiveModeHandler->actionHandler(HbInputModeHandler::HbInputModeActionDeleteAndCommit); 
       
   506         }
       
   507 
       
   508         if (mVkbHost && mVkbHost->keypadStatus() != HbVkbHost::HbVkbStatusMinimized) {
       
   509             mVkbHost->minimizeKeypad(false);
       
   510             if (mCandidatePopup) {
       
   511                 mCandidatePopup->hide();
       
   512             }
       
   513         }
       
   514     }
       
   515 }
       
   516 
       
   517 /*!
       
   518 Closes the keypad if it is open.
       
   519 */
       
   520 void HbHardwareQwerty::closeKeypad()
       
   521 {
       
   522     if (mVkbHost && mVkbHost->keypadStatus() != HbVkbHost::HbVkbStatusClosed) {
       
   523         mVkbHost->closeKeypad(!stateChangeInProgress());
       
   524         if (mCandidatePopup) {
       
   525             mCandidatePopup->hide();
       
   526         }
       
   527     }
       
   528 }
       
   529 
       
   530 /*!
       
   531 The call back from framework to indicate that the orientation is about to change. This closes the keypad
       
   532 if it is already open.
       
   533 */
       
   534 void HbHardwareQwerty::orientationAboutToChange()
       
   535 {
       
   536     HbInputMethod::orientationAboutToChange();
       
   537     closeKeypad();
       
   538 }
       
   539 
       
   540 void HbHardwareQwerty::openKeypad(bool inMinimizedMode)
       
   541 {
       
   542     mKeypad->createLayout();
       
   543     
       
   544     mVkbHost = focusObject()->findVkbHost();
       
   545 
       
   546     if (mVkbHost && mVkbHost->keypadStatus() != HbVkbHost::HbVkbStatusOpened) {
       
   547         connect(mVkbHost, SIGNAL(keypadClosed()), this, SLOT(keypadClosed()));
       
   548         connect(mVkbHost, SIGNAL(keypadOpened()), this, SLOT(keypadOpened()));
       
   549         
       
   550         if (inMinimizedMode) {
       
   551             mVkbHost->openMinimizedKeypad(mKeypad, this);
       
   552         } else {
       
   553             mVkbHost->openKeypad(mKeypad, this, false);
       
   554         }
       
   555         connect(&(focusObject()->editorInterface()), SIGNAL(cursorPositionChanged(int, int)), mVkbHost, SLOT(ensureCursorVisibility()));
       
   556     }
       
   557 }
       
   558 
       
   559 HbHwToolCluster* HbHardwareQwerty::constructKeypad()
       
   560 {
       
   561 
       
   562     HbHwToolCluster* keypad = new HbHwToolCluster(this, 0);
       
   563     connect(keypad, SIGNAL(keypadCloseEventDetected(HbInputVkbWidget::HbVkbCloseMethod)),
       
   564         this, SLOT(keypadCloseEventDetected(HbInputVkbWidget::HbVkbCloseMethod)));
       
   565     return keypad;
       
   566 }
       
   567 
       
   568 /*!
       
   569 Returns true if prediction is on, prediction engine is available and predictions is allowed in current editor.
       
   570 */
       
   571 bool HbHardwareQwerty::usePrediction() const
       
   572 {
       
   573 	qDebug("in usePrediction()");
       
   574     HbInputFocusObject *fo = focusObject();
       
   575 	if(!fo){
       
   576 		qDebug("NO Focus object");
       
   577 	} else {
       
   578 		qDebug("Yes Focus object");
       
   579 	}
       
   580 	
       
   581 	if (!HbInputSettingProxy::instance()->predictiveInputStatus()){
       
   582 		qDebug("No HbInputSettingProxy::instance()->predictiveInputStatus()");
       
   583 	} else {
       
   584 		qDebug("Yes HbInputSettingProxy::instance()->predictiveInputStatus()");	
       
   585 	}
       
   586 	
       
   587 	if(!mPredictionModeHandler->isActive()){
       
   588 		qDebug("No mPredictionModeHandler->isActive()");
       
   589 
       
   590 	} else {
       
   591 		qDebug("Yes mPredictionModeHandler->isActive()");
       
   592 	}
       
   593 
       
   594 
       
   595     if (HbInputSettingProxy::instance()->predictiveInputStatus() &&
       
   596         fo &&
       
   597         fo->editorInterface().isPredictionAllowed() &&
       
   598         mPredictionModeHandler->isActive()) {
       
   599          return true;           
       
   600     }
       
   601 
       
   602     return false;
       
   603 }
       
   604 // End of file
       
   605