src/hbinput/inputwidgets/hbinputvkbwidget.cpp
changeset 6 c3690ec91ef8
parent 5 627c4a0fd0e7
child 7 923ff622b8b9
equal deleted inserted replaced
5:627c4a0fd0e7 6:c3690ec91ef8
    20 **
    20 **
    21 ** If you have questions regarding the use of this file, please contact
    21 ** If you have questions regarding the use of this file, please contact
    22 ** Nokia at developer.feedback@nokia.com.
    22 ** Nokia at developer.feedback@nokia.com.
    23 **
    23 **
    24 ****************************************************************************/
    24 ****************************************************************************/
       
    25 #include "hbinputvkbwidget.h"
       
    26 #include "hbinputvkbwidget_p.h"
       
    27 
    25 #include <QPixmap>
    28 #include <QPixmap>
    26 #include <QBitmap>
    29 #include <QBitmap>
    27 #include <QPainter>
    30 #include <QPainter>
    28 #include <QGraphicsItemAnimation>
    31 #include <QGraphicsItemAnimation>
    29 #include <QGraphicsSceneMouseEvent>
    32 #include <QGraphicsSceneMouseEvent>
    61 #include <hbinputbutton.h>
    64 #include <hbinputbutton.h>
    62 #include <HbSwipeGesture>
    65 #include <HbSwipeGesture>
    63 #include <HbTapGesture>
    66 #include <HbTapGesture>
    64 #include <HbSelectionDialog>
    67 #include <HbSelectionDialog>
    65 #include <HbListWidgetItem>
    68 #include <HbListWidgetItem>
       
    69 
    66 #include "hbinputvirtualrocker.h"
    70 #include "hbinputvirtualrocker.h"
    67 #include "hbinputvkbwidget.h"
       
    68 #include "hbinputvkbwidget_p.h"
       
    69 #include "hbinputsettinglist.h"
    71 #include "hbinputsettinglist.h"
    70 #include "hbinputmodeindicator.h"
    72 #include "hbinputmodeindicator.h"
    71 #include <hbfeedbackmanager.h>
    73 #include <hbfeedbackmanager.h>
    72 #include "hbinputsmileypicker.h"
    74 #include "hbinputsmileypicker.h"
    73 #include "hbinputscreenshotwidget.h"
    75 #include "hbinputscreenshotwidget.h"
    93 with a finger. This class also implements background drawing for touch keypads.
    95 with a finger. This class also implements background drawing for touch keypads.
    94 */
    96 */
    95 
    97 
    96 /// @cond
    98 /// @cond
    97 
    99 
    98 inline HbWidget* hbwidget_cast(QGraphicsItem *item)
   100 inline HbWidget *hbwidget_cast(QGraphicsItem *item)
    99 {
   101 {
   100     if( item->isWidget() && static_cast<QGraphicsWidget*>(item)->inherits("HbWidget") ) {
   102     if (item->isWidget() && static_cast<QGraphicsWidget *>(item)->inherits("HbWidget")) {
   101         return static_cast<HbWidget*>(item);
   103         return static_cast<HbWidget *>(item);
   102     }
   104     }
   103     return 0;
   105     return 0;
   104 }
   106 }
   105 
   107 
   106 HbInputVkbWidgetPrivate::HbInputVkbWidgetPrivate()
   108 HbInputVkbWidgetPrivate::HbInputVkbWidgetPrivate()
   107 : mOwner(0),
   109     : mOwner(0),
   108 mMode(EModeAbc),
   110       mMode(EModeAbc),
   109 mKeymap(0),
   111       mKeymap(0),
   110 mModifiers(0),
   112       mModifiers(0),
   111 mInputModeIndicator(0),
   113       mInputModeIndicator(0),
   112 mSettingList(0),
   114       mSettingList(0),
   113 mButtonLayout(0),
   115       mButtonLayout(0),
   114 mRocker(0),
   116       mRocker(0),
   115 mBackgroundDrawer(0),
   117       mBackgroundDrawer(0),
   116 mIconDrawer(0),
   118       mIconDrawer(0),
   117 mMainWinConnected(false),
   119       mMainWinConnected(false),
   118 mShowRocker(false),
   120       mShowRocker(false),
   119 mLayout(0),
   121       mLayout(0),
   120 mCurrentHost(0),
   122       mCurrentHost(0),
   121 mDrawbackground(true),
   123       mDrawbackground(true),
   122 mMouseButtonPressedDown(false),
   124       mMouseButtonPressedDown(false),
   123 mFlickDirection(HbInputVkbWidget::HbFlickDirectionNone),
   125       mFlickDirection(HbInputVkbWidget::HbFlickDirectionNone),
   124 mSmileyPicker(0),
   126       mSmileyPicker(0),
   125 mScreenshotWidget(0),
   127       mScreenshotWidget(0),
   126 mScreenshotTimeLine(250),
   128       mScreenshotTimeLine(250),
   127 mMostRecentlyAccessedButton(0),
   129       mMostRecentlyAccessedButton(0),
   128 mMostRecentlyClickedLocation(0.0,0.0),
   130       mMostRecentlyClickedLocation(0.0, 0.0),
   129 mFocusedObject(0),
   131       mFocusedObject(0),
   130 mFlickAnimation(false),
   132       mFlickAnimation(false),
   131 mSettingsListOpen(false),
   133       mSettingsListOpen(false),
   132 mAnimateWhenDialogCloses(false),
   134       mAnimateWhenDialogCloses(false),
   133 mKeyboardSize(HbQwerty4x10),
   135       mKeyboardSize(HbQwerty4x10),
   134 mCloseHandleHeight(0),
   136       mCloseHandleHeight(0),
   135 mCloseHandle(0),
   137       mCloseHandle(0),
   136 mSettingView(0),
   138       mSettingView(0),
   137 mCurrentView(0),
   139       mCurrentView(0),
   138 mKeyboardDimmed(false),
   140       mKeyboardDimmed(false),
   139 mImSelectionDialog(0)
   141       mImSelectionDialog(0),
       
   142       mSettingWidget(0)
   140 {
   143 {
   141     mScreenshotTimeLine.setUpdateInterval(16);
   144     mScreenshotTimeLine.setUpdateInterval(16);
   142 }
   145 }
   143 
   146 
   144 
   147 
   146 {
   149 {
   147     delete mSettingList;
   150     delete mSettingList;
   148     delete mBackgroundDrawer;
   151     delete mBackgroundDrawer;
   149     delete mIconDrawer;
   152     delete mIconDrawer;
   150     delete mSmileyPicker;
   153     delete mSmileyPicker;
   151     delete mScreenshotWidget; 
   154     delete mScreenshotWidget;
       
   155     delete mRocker;
   152     delete mImSelectionDialog;
   156     delete mImSelectionDialog;
   153 }
   157 }
   154 
   158 
   155 void HbInputVkbWidgetPrivate::initLayout()
   159 void HbInputVkbWidgetPrivate::initLayout()
   156 {
   160 {
   175 }
   179 }
   176 
   180 
   177 void HbInputVkbWidgetPrivate::init()
   181 void HbInputVkbWidgetPrivate::init()
   178 {
   182 {
   179     Q_Q(HbInputVkbWidget);
   183     Q_Q(HbInputVkbWidget);
   180 
   184     q->setFlag(QGraphicsItem::ItemHasNoContents, false);
   181     HbInputButtonGroup *buttonGroup = static_cast<HbInputButtonGroup*>(q->contentItem());
   185 
   182     QObject::connect(buttonGroup,SIGNAL(aboutToActivateCustomAction(HbAction*)),
   186     mRocker = new HbInputVirtualRocker();
   183                                 q,SIGNAL(aboutToActivateCustomAction(HbAction*)));
   187     HbInputButtonGroup *buttonGroup = static_cast<HbInputButtonGroup *>(q->contentItem());
   184 
   188     QObject::connect(buttonGroup, SIGNAL(aboutToActivateCustomAction(HbAction *)),
   185     mRocker = new HbInputVirtualRocker(q);
   189                      q, SIGNAL(aboutToActivateCustomAction(HbAction *)));
       
   190 
   186     mRocker->setObjectName("VirtualRocker");
   191     mRocker->setObjectName("VirtualRocker");
   187     QSizeF rockerSize(HbRockerWidth, HbRockerWidth);
   192     QSizeF rockerSize(HbRockerWidth, HbRockerWidth);
   188     mRocker->resize(rockerSize);
   193     mRocker->resize(rockerSize);
   189     mRocker->setMinimumSize(HbRockerWidth, HbRockerWidth);
   194     mRocker->setMinimumSize(HbRockerWidth, HbRockerWidth);
   190     mRocker->setMaximumSize(HbRockerWidth*20, HbRockerWidth*20);
   195     mRocker->setMaximumSize(HbRockerWidth * 20, HbRockerWidth * 20);
       
   196     if (q->mainWindow()) {
       
   197         q->mainWindow()->scene()->addItem(mRocker);
       
   198     }
   191 
   199 
   192     QObject::connect(mRocker, SIGNAL(rockerDirection(int, HbInputVirtualRocker::RockerSelectionMode)),
   200     QObject::connect(mRocker, SIGNAL(rockerDirection(int, HbInputVirtualRocker::RockerSelectionMode)),
   193         q, SIGNAL(rockerDirection(int, HbInputVirtualRocker::RockerSelectionMode)));
   201                      q, SLOT(_q_handleRockerChange(int, HbInputVirtualRocker::RockerSelectionMode)));
   194 
   202 
   195     mRocker->setVisible(false);
   203     mRocker->setVisible(false);
   196 
   204 
   197     mBackgroundDrawer = new HbFrameDrawer();
   205     mBackgroundDrawer = new HbFrameDrawer();
   198     mBackgroundDrawer->setFrameGraphicsName(backgroundGraphics);
   206     mBackgroundDrawer->setFrameGraphicsName(backgroundGraphics);
   255     if (mOwner) {
   263     if (mOwner) {
   256         mOwner->filterEvent(&event);
   264         mOwner->filterEvent(&event);
   257     }
   265     }
   258 }
   266 }
   259 
   267 
   260 void HbInputVkbWidgetPrivate::addCustomButtonToLayout( HbTouchKeypadButton* button,
   268 void HbInputVkbWidgetPrivate::addCustomButtonToLayout(HbTouchKeypadButton *button,
   261                                                        int index)
   269         int index)
   262 {
   270 {
   263     Q_UNUSED(button);
   271     Q_UNUSED(button);
   264     Q_UNUSED(index);
   272     Q_UNUSED(index);
   265 }
   273 }
   266 
   274 
   281 
   289 
   282 void HbInputVkbWidgetPrivate::updateKeyCodes()
   290 void HbInputVkbWidgetPrivate::updateKeyCodes()
   283 {
   291 {
   284     Q_Q(HbInputVkbWidget);
   292     Q_Q(HbInputVkbWidget);
   285 
   293 
   286     HbInputButtonGroup *buttonGroup = static_cast<HbInputButtonGroup*>(q->contentItem());
   294     HbInputButtonGroup *buttonGroup = static_cast<HbInputButtonGroup *>(q->contentItem());
   287     if (buttonGroup) {
   295     if (buttonGroup) {
   288         int key = 0;
   296         int key = 0;
   289         QList<HbInputButton*> buttons = buttonGroup->buttons();
   297         QList<HbInputButton *> buttons = buttonGroup->buttons();
   290         for (int i = 0; i < buttons.count(); ++i) {
   298         for (int i = 0; i < buttons.count(); ++i) {
   291             if (keyCode(i) == HbInputButton::ButtonKeyCodeCharacter) {
   299             if (keyCode(i) == HbInputButton::ButtonKeyCodeCharacter) {
   292                 HbInputButton *item = buttons.at(i);
   300                 HbInputButton *item = buttons.at(i);
   293 
   301 
   294                 const HbKeyboardMap *keyboardMap = mKeymap->keyboard(q->keyboardType());
   302                 const HbKeyboardMap *keyboardMap = mKeymap->keyboard(q->keyboardType());
   305 
   313 
   306 void HbInputVkbWidgetPrivate::updateButtons()
   314 void HbInputVkbWidgetPrivate::updateButtons()
   307 {
   315 {
   308     Q_Q(HbInputVkbWidget);
   316     Q_Q(HbInputVkbWidget);
   309 
   317 
   310     HbInputButtonGroup *buttonGroup = static_cast<HbInputButtonGroup*>(q->contentItem());
   318     HbInputButtonGroup *buttonGroup = static_cast<HbInputButtonGroup *>(q->contentItem());
   311     if (buttonGroup) {
   319     if (buttonGroup) {
   312         int key = 0;
   320         int key = 0;
   313         QList<HbInputButton*> buttons = buttonGroup->buttons();
   321         QList<HbInputButton *> buttons = buttonGroup->buttons();
   314         for (int i = 0; i < buttons.count(); ++i) {
   322         for (int i = 0; i < buttons.count(); ++i) {
   315             if (keyCode(i) == HbInputButton::ButtonKeyCodeCharacter) {
   323             if (keyCode(i) == HbInputButton::ButtonKeyCodeCharacter) {
   316                 HbInputButton *item = buttons.at(i);
   324                 HbInputButton *item = buttons.at(i);
   317 
   325 
   318                 const HbKeyboardMap *keyboardMap = mKeymap->keyboard(q->keyboardType());
   326                 const HbKeyboardMap *keyboardMap = mKeymap->keyboard(q->keyboardType());
   319                 if (keyboardMap && key < keyboardMap->keys.count() && keyboardMap->keys.at(key)->characters(mModifiers)!= QString("")) {
   327                 if (keyboardMap && key < keyboardMap->keys.count() && keyboardMap->keys.at(key)->characters(mModifiers) != QString("")) {
   320                     QString keydata = keyboardMap->keys.at(key)->characters(mModifiers);
   328                     QString keydata = keyboardMap->keys.at(key)->characters(mModifiers);
   321                     item->setText(keydata.at(0), HbInputButton::ButtonTextIndexPrimary);
   329                     item->setText(keydata.at(0), HbInputButton::ButtonTextIndexPrimary);
   322 
   330 
   323                     QString mappedCharacters;
   331                     QString mappedCharacters;
   324                     keydata.append(keyboardMap->keys.at(key)->characters(mModifiers | HbModifierFnPressed));
   332                     keydata.append(keyboardMap->keys.at(key)->characters(mModifiers | HbModifierFnPressed));
   342 
   350 
   343 void HbInputVkbWidgetPrivate::settingListPosition(QPointF &position, HbPopup::Placement &placement)
   351 void HbInputVkbWidgetPrivate::settingListPosition(QPointF &position, HbPopup::Placement &placement)
   344 {
   352 {
   345     Q_Q(HbInputVkbWidget);
   353     Q_Q(HbInputVkbWidget);
   346 
   354 
   347     HbInputButtonGroup *buttonGroup = static_cast<HbInputButtonGroup*>(q->contentItem());
   355     HbInputButtonGroup *buttonGroup = static_cast<HbInputButtonGroup *>(q->contentItem());
   348     if (buttonGroup) {
   356     if (buttonGroup) {
   349         HbInputButton *item = buttonGroup->button(HbInputButton::ButtonKeyCodeSettings);
   357         HbInputButton *item = buttonGroup->button(HbInputButton::ButtonKeyCodeSettings);
   350         if (item) {
   358         if (item) {
   351             position.setX(buttonGroup->scenePos().x() + item->boundingRect().x() + item->boundingRect().width());
   359             position.setX(buttonGroup->scenePos().x() + item->boundingRect().x() + item->boundingRect().width());
   352             position.setY(buttonGroup->scenePos().y() + item->boundingRect().y());
   360             position.setY(buttonGroup->scenePos().y() + item->boundingRect().y());
   356 }
   364 }
   357 
   365 
   358 void HbInputVkbWidgetPrivate::setRockerPosition()
   366 void HbInputVkbWidgetPrivate::setRockerPosition()
   359 {
   367 {
   360     Q_Q(HbInputVkbWidget);
   368     Q_Q(HbInputVkbWidget);
   361 
   369     mRocker->setPos(q->rockerPosition());
   362     // Set rocker position.
       
   363     QSizeF padArea = q->keypadButtonAreaSize();
       
   364     QPointF point((padArea.width() * 0.5) - (mRocker->size().width() * 0.5),
       
   365         (padArea.height() * 0.5) - (mRocker->size().height() * 0.5));
       
   366     point.setY(point.y() + mCloseHandleHeight);
       
   367 
       
   368     mRocker->setPos(point);
       
   369 }
   370 }
   370 
   371 
   371 void HbInputVkbWidgetPrivate::captureScreenshot()
   372 void HbInputVkbWidgetPrivate::captureScreenshot()
   372 {
   373 {
   373     Q_Q(HbInputVkbWidget);
   374     Q_Q(HbInputVkbWidget);
   378         mScreenshotWidget->setGeometry(q->geometry());
   379         mScreenshotWidget->setGeometry(q->geometry());
   379         q->mainWindow()->scene()->addItem(mScreenshotWidget);
   380         q->mainWindow()->scene()->addItem(mScreenshotWidget);
   380     }
   381     }
   381 
   382 
   382     QPointF position = q->pos();
   383     QPointF position = q->pos();
   383     QRectF rect = QRectF(position.x(), position.y()+ mCloseHandleHeight, q->boundingRect().width(), q->boundingRect().height()- mCloseHandleHeight);
   384     QRectF rect = QRectF(position.x(), position.y() + mCloseHandleHeight, q->boundingRect().width(), q->boundingRect().height() - mCloseHandleHeight);
   384     QTransform rotateTrans;
   385     QTransform rotateTrans;
   385     rotateTrans = q->mainWindow()->viewportTransform();
   386     rotateTrans = q->mainWindow()->viewportTransform();
   386     QRectF transRect = rotateTrans.mapRect(rect);
   387     QRectF transRect = rotateTrans.mapRect(rect);
   387     QPixmap pixmap;
   388     QPixmap pixmap;
   388     pixmap = QPixmap::grabWidget(q->mainWindow(), (int)transRect.x(), (int)transRect.y(), (int)transRect.width(), (int)transRect.height());
   389     pixmap = QPixmap::grabWidget(q->mainWindow(), (int)transRect.x(), (int)transRect.y(), (int)transRect.width(), (int)transRect.height());
   398 }
   399 }
   399 
   400 
   400 void HbInputVkbWidgetPrivate::normalizeProbabilities(QList<HbKeyPressProbability> &allProbableKeys)
   401 void HbInputVkbWidgetPrivate::normalizeProbabilities(QList<HbKeyPressProbability> &allProbableKeys)
   401 {
   402 {
   402     qreal sum = 0.0;
   403     qreal sum = 0.0;
   403     foreach (HbKeyPressProbability key, allProbableKeys) {
   404     foreach(const HbKeyPressProbability &key, allProbableKeys) {
   404         sum += key.probability;
   405         sum += key.probability;
   405     }
   406     }
   406 
   407 
   407     for (int count=0;count<allProbableKeys.size();count++) {
   408     for (int count = 0; count < allProbableKeys.size(); count++) {
   408         allProbableKeys[count].probability = allProbableKeys[count].probability / sum;
   409         allProbableKeys[count].probability = allProbableKeys[count].probability / sum;
   409     }
   410     }
   410 }
   411 }
   411 
   412 
   412 bool HbInputVkbWidgetPrivate::isKeyboardDimmed()
   413 bool HbInputVkbWidgetPrivate::isKeyboardDimmed()
   427     }
   428     }
   428 
   429 
   429     return ret;
   430     return ret;
   430 }
   431 }
   431 
   432 
       
   433 void HbInputVkbWidgetPrivate::showInputMethodSelectionDialog()
       
   434 {
       
   435     Q_Q(HbInputVkbWidget);
       
   436 
       
   437     delete mImSelectionDialog;
       
   438     mImSelectionDialog = new HbSelectionDialog();
       
   439 
       
   440     mImSelectionDialog->setObjectName("Input method dialog");
       
   441 
       
   442     // Make sure the language dialog never steals focus.
       
   443     mImSelectionDialog->setFlag(QGraphicsItem::ItemIsPanel, true);
       
   444     mImSelectionDialog->setActive(false);
       
   445 
       
   446     QList<HbInputMethodDescriptor> customList = HbInputMethod::listCustomInputMethods();
       
   447 
       
   448     QList<HbListWidgetItem *> listItems;
       
   449     HbListWidgetItem *item = new HbListWidgetItem();
       
   450     QString methodName("Default");
       
   451     item->setText(methodName);
       
   452     listItems.append(item);
       
   453 
       
   454     foreach(const HbInputMethodDescriptor &descriptor, customList) {
       
   455         QString displayName = descriptor.displayName();
       
   456         if (displayName.length() == 0) {
       
   457             displayName = QString("Unknown");
       
   458         }
       
   459         item = new HbListWidgetItem();
       
   460         item->setText(displayName);
       
   461         listItems.append(item);
       
   462     }
       
   463     mImSelectionDialog->setWidgetItems(listItems, true);
       
   464     mImSelectionDialog->setSelectionMode(HbAbstractItemView::SingleSelection);
       
   465     mImSelectionDialog->setDismissPolicy(HbPopup::NoDismiss);
       
   466     mImSelectionDialog->setModal(true);
       
   467 
       
   468     q->connect(mImSelectionDialog, SIGNAL(finished(HbAction *)), q, SLOT(_q_inputMethodSelectionDialogFinished(HbAction *)));
       
   469 
       
   470     mImSelectionDialog->open();
       
   471 }
       
   472 
       
   473 void HbInputVkbWidgetPrivate::_q_inputMethodSelectionDialogFinished(HbAction *action)
       
   474 {
       
   475     Q_UNUSED(action);
       
   476 
       
   477     QList<QVariant> selectedItems = mImSelectionDialog->selectedItems();
       
   478     if (selectedItems.count()) {
       
   479         HbInputMethodDescriptor result;
       
   480         int selection = selectedItems.first().toInt();
       
   481         if (selection == 0) {
       
   482             result.setDefault();
       
   483         } else {
       
   484             QList<HbInputMethodDescriptor> customList = HbInputMethod::listCustomInputMethods();
       
   485             if (customList.count() <= selection) {
       
   486                 result = customList[selection-1];
       
   487             }
       
   488         }
       
   489 
       
   490         if (!result.isEmpty() && mOwner) {
       
   491             // Set as active custom input method.
       
   492             HbInputSettingProxy::instance()->setPreferredInputMethod(Qt::Horizontal, result);
       
   493             HbInputSettingProxy::instance()->setPreferredInputMethod(Qt::Vertical, result);
       
   494             // And finally activate immediately.
       
   495             mOwner->activateInputMethod(result);
       
   496         }
       
   497     }
       
   498 }
       
   499 
       
   500 void HbInputVkbWidgetPrivate::_q_handleRockerChange(int direction, HbInputVirtualRocker::RockerSelectionMode selectionMode)
       
   501 {
       
   502     Q_Q(HbInputVkbWidget);
       
   503 
       
   504     if (direction == HbInputVirtualRocker::HbRockerDirectionRelease) {
       
   505         q->setKeyboardDimmed(false);
       
   506     } else if (direction == HbInputVirtualRocker::HbRockerDirectionPress ||
       
   507                direction == HbInputVirtualRocker::HbRockerDirectionDoubleClick) {
       
   508         q->setKeyboardDimmed(true);
       
   509     }
       
   510     emit q->rockerDirection(direction, selectionMode);
       
   511 }
       
   512 
   432 QChar HbInputVkbWidgetPrivate::numberCharacterBoundToKey(int key)
   513 QChar HbInputVkbWidgetPrivate::numberCharacterBoundToKey(int key)
   433 {
   514 {
   434     QChar numChr;
   515     QChar numChr;
   435     if (!mKeymap || !mOwner) {
   516     if (!mKeymap || !mOwner) {
   436         return numChr;
   517         return numChr;
   437     }
   518     }
   438 
   519 
   439     HbInputFocusObject *focusObject = mOwner->focusObject();
   520     HbInputFocusObject *focusObject = mOwner->focusObject();
   440     if (!focusObject) {
   521     if (!focusObject) {
   441         return numChr;
   522         return numChr;
   442     }	
   523     }
   443     HbInputLanguage language = mKeymap->language();
   524     HbInputLanguage language = mKeymap->language();
   444     if (language.language()  != (QLocale::Language)0) {
   525     if (language.language()  != (QLocale::Language)0) {
   445         HbInputDigitType digitType = HbInputUtils::inputDigitType(language);
   526         HbInputDigitType digitType = HbInputUtils::inputDigitType(language);
   446         	
   527 
   447         // In number editors, show the native digits only when both device and writing languages are same,
   528         // In number editors, show the native digits only when both device and writing languages are same,
   448         // else show latin digits
   529         // else show latin digits
   449         if (focusObject->editorInterface().isNumericEditor()) {
   530         if (focusObject->editorInterface().isNumericEditor()) {
   450             QLocale::Language systemLanguage = QLocale::system().language();
   531             QLocale::Language systemLanguage = QLocale::system().language();
   451             if (language.language() != systemLanguage) {
   532             if (language.language() != systemLanguage) {
   452                 digitType = HbDigitTypeLatin;
   533                 digitType = HbDigitTypeLatin;
   453             }	
   534             }
   454         }
   535         }
   455 			
   536 
   456         HbKeyboardType keyboardType = mOwner->inputState().keyboard();
   537         HbKeyboardType keyboardType = mOwner->inputState().keyboard();
   457         
   538 
   458         if (keyboardType == HbKeyboardVirtual12Key) {
   539         if (keyboardType == HbKeyboardVirtual12Key) {
   459             numChr = HbInputUtils::findFirstNumberCharacterBoundToKey(
   540             numChr = HbInputUtils::findFirstNumberCharacterBoundToKey(
   460             mKeymap->keyboard(keyboardType)->keys.at(key),
   541                          mKeymap->keyboard(keyboardType)->keys.at(key),
   461             language, digitType);
   542                          language, digitType);
   462         } else if (keyboardType == HbKeyboardVirtualQwerty) {
   543         } else if (keyboardType == HbKeyboardVirtualQwerty) {
   463             switch (digitType) {
   544             switch (digitType) {
   464             case HbDigitTypeLatin:
   545             case HbDigitTypeLatin:
   465                 numChr = HB_DIGIT_LATIN_START_VALUE + key;
   546                 numChr = HB_DIGIT_LATIN_START_VALUE + key;
   466                 break;
   547                 break;
   479         }
   560         }
   480     }
   561     }
   481     return numChr;
   562     return numChr;
   482 }
   563 }
   483 
   564 
   484 void HbInputVkbWidgetPrivate::showInputMethodSelectionDialog()
   565 void HbInputVkbWidgetPrivate::_q_settingsClosed(HbAction* action)
   485 {
   566 {
       
   567     Q_UNUSED(action);
   486     Q_Q(HbInputVkbWidget);
   568     Q_Q(HbInputVkbWidget);
   487 
   569 
   488     delete mImSelectionDialog;
   570     q->settingsClosed();
   489     mImSelectionDialog = new HbSelectionDialog();
       
   490 
       
   491     mImSelectionDialog->setObjectName("Input method dialog");
       
   492 
       
   493     // Make sure the language dialog never steals focus.
       
   494     mImSelectionDialog->setFlag(QGraphicsItem::ItemIsPanel, true);
       
   495     mImSelectionDialog->setActive(false);
       
   496 
       
   497     QList<HbInputMethodDescriptor> customList = HbInputMethod::listCustomInputMethods();
       
   498 
       
   499     QList<HbListWidgetItem*> listItems;
       
   500     HbListWidgetItem* item = new HbListWidgetItem();
       
   501     QString methodName("Default");
       
   502     item->setText(methodName);
       
   503     listItems.append(item);
       
   504 
       
   505     foreach (HbInputMethodDescriptor descriptor, customList) {
       
   506     QString displayName = descriptor.displayName();
       
   507         if (displayName.length() == 0) {
       
   508             displayName = QString("Unknown");
       
   509         }
       
   510         item = new HbListWidgetItem();
       
   511         item->setText(displayName);
       
   512         listItems.append(item);
       
   513     }
       
   514     mImSelectionDialog->setWidgetItems(listItems, true);
       
   515     mImSelectionDialog->setSelectionMode(HbAbstractItemView::SingleSelection);
       
   516     mImSelectionDialog->setDismissPolicy(HbPopup::NoDismiss);
       
   517     mImSelectionDialog->setModal(true);
       
   518 
       
   519     q->connect(mImSelectionDialog, SIGNAL(finished(HbAction*)), q, SLOT(_q_inputMethodSelectionDialogFinished(HbAction*)));
       
   520 
       
   521     mImSelectionDialog->open();
       
   522 }
       
   523 
       
   524 void HbInputVkbWidgetPrivate::_q_inputMethodSelectionDialogFinished(HbAction *action)
       
   525 {
       
   526     Q_UNUSED(action);
       
   527 
       
   528     QList<QVariant> selectedItems = mImSelectionDialog->selectedItems();
       
   529     if (selectedItems.count()) {
       
   530         HbInputMethodDescriptor result;
       
   531         int selection = selectedItems.first().toInt();
       
   532         if (selection == 0) {
       
   533            result.setDefault();
       
   534         } else {
       
   535            QList<HbInputMethodDescriptor> customList = HbInputMethod::listCustomInputMethods();
       
   536            if (customList.count() <= selection) {
       
   537                result = customList[selection-1];
       
   538            }
       
   539         }
       
   540 
       
   541         if (!result.isEmpty() && mOwner) {
       
   542             mOwner->activateInputMethod(result);
       
   543         }
       
   544     }
       
   545 }
   571 }
   546 
   572 
   547 /// @endcond
   573 /// @endcond
   548 
   574 
   549 /*!
   575 /*!
   550 Costructs the object.
   576 Costructs the object.
   551 */
   577 */
   552 HbInputVkbWidget::HbInputVkbWidget(QGraphicsItem* parent)
   578 HbInputVkbWidget::HbInputVkbWidget(QGraphicsItem *parent)
   553     : HbWidget(*new HbInputVkbWidgetPrivate, parent)
   579     : HbWidget(*new HbInputVkbWidgetPrivate, parent)
   554 {
   580 {
   555     Q_D(HbInputVkbWidget);
   581     Q_D(HbInputVkbWidget);
   556     d->q_ptr = this;
   582     d->q_ptr = this;
   557     d->initLayout();
   583     d->initLayout();
   558     d->init();
   584     d->init();
   559 
   585 
   560     setFocusPolicy(Qt::ClickFocus);
   586     setFocusPolicy(Qt::ClickFocus);
   561     setPos(QPointF(0,0));
   587     setPos(QPointF(0, 0));
   562 
   588 
   563 #ifdef HB_EFFECTS
   589 #ifdef HB_EFFECTS
   564     HbEffect::disable(this);
   590     HbEffect::disable(this);
   565 #endif // HB_EFFECTS
   591 #endif // HB_EFFECTS
   566 
   592 
   570 }
   596 }
   571 
   597 
   572 /*!
   598 /*!
   573 Constructs the object.
   599 Constructs the object.
   574 */
   600 */
   575 HbInputVkbWidget::HbInputVkbWidget(HbInputVkbWidgetPrivate& dd, QGraphicsItem* parent)
   601 HbInputVkbWidget::HbInputVkbWidget(HbInputVkbWidgetPrivate &dd, QGraphicsItem *parent)
   576   : HbWidget(dd, parent)
   602     : HbWidget(dd, parent)
   577 {
   603 {
   578     Q_D(HbInputVkbWidget);
   604     Q_D(HbInputVkbWidget);
   579     d->q_ptr = this;
   605     d->q_ptr = this;
   580     d->initLayout();
   606     d->initLayout();
   581     d->init();
   607     d->init();
   582 
   608 
   583     setFocusPolicy(Qt::ClickFocus);
   609     setFocusPolicy(Qt::ClickFocus);
   584     setPos(QPointF(0,0));
   610     setPos(QPointF(0, 0));
   585 
   611 
   586 #ifdef HB_EFFECTS
   612 #ifdef HB_EFFECTS
   587     HbEffect::disable(this);
   613     HbEffect::disable(this);
   588 #endif // HB_EFFECTS
   614 #endif // HB_EFFECTS
   589 
   615 
   639 }
   665 }
   640 
   666 
   641 /*!
   667 /*!
   642 The paint method. Draws the widget.
   668 The paint method. Draws the widget.
   643 */
   669 */
   644 void HbInputVkbWidget::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
   670 void HbInputVkbWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
   645 {
   671 {
   646     Q_UNUSED(option);
   672     Q_UNUSED(option);
   647     Q_UNUSED(widget);
   673     Q_UNUSED(widget);
   648 
   674 
   649     Q_D(HbInputVkbWidget);
   675     Q_D(HbInputVkbWidget);
   748     Q_D(HbInputVkbWidget);
   774     Q_D(HbInputVkbWidget);
   749     d->mMode = mode;
   775     d->mMode = mode;
   750     d->mModifiers = modifiers;
   776     d->mModifiers = modifiers;
   751 
   777 
   752     d->updateButtons();
   778     d->updateButtons();
   753 	d->updateKeyCodes();
   779     d->updateKeyCodes();
   754     d->applyEditorConstraints();
   780     d->applyEditorConstraints();
   755 
   781 
   756     HbInputButtonGroup *buttonGroup = static_cast<HbInputButtonGroup*>(contentItem());
   782     HbInputButtonGroup *buttonGroup = static_cast<HbInputButtonGroup *>(contentItem());
   757     if (buttonGroup && d->mOwner->focusObject()) {
   783     if (buttonGroup && d->mOwner->focusObject()) {
   758         buttonGroup->setCustomButtonActions(d->mOwner->focusObject()->editorInterface().actions());
   784         buttonGroup->setCustomButtonActions(d->mOwner->focusObject()->editorInterface().actions());
   759     }
   785     }
   760 
   786 
   761     if (d->mInputModeIndicator) {
   787     if (d->mInputModeIndicator) {
   765 
   791 
   766 /*!
   792 /*!
   767 Sets key map data object. Given key map data will be used as a source for button titles.
   793 Sets key map data object. Given key map data will be used as a source for button titles.
   768 Usually the key map data for active input language is used.
   794 Usually the key map data for active input language is used.
   769 */
   795 */
   770 void HbInputVkbWidget::setKeymap(const HbKeymap* keymap)
   796 void HbInputVkbWidget::setKeymap(const HbKeymap *keymap)
   771 {
   797 {
   772     Q_D(HbInputVkbWidget);
   798     Q_D(HbInputVkbWidget);
   773     if (keymap) {
   799     if (keymap) {
   774         d->mKeymap = keymap;
   800         d->mKeymap = keymap;
   775         d->updateKeyCodes();
   801         d->updateKeyCodes();
   810 
   836 
   811     d->mCurrentHost = host;
   837     d->mCurrentHost = host;
   812 
   838 
   813     if (d->mSmileyPicker && d->mSmileyPicker->isVisible()) {
   839     if (d->mSmileyPicker && d->mSmileyPicker->isVisible()) {
   814         d->mSmileyPicker->hide();
   840         d->mSmileyPicker->hide();
   815     }	
   841     }
   816     d->mRocker->setVisible(false);
   842     d->mRocker->setVisible(false);
   817     if (d->mSettingList) {
   843     if (d->mSettingList) {
   818         d->mSettingList->close();
   844         d->mSettingList->close();
   819     }
   845     }
   820 }
   846 }
   822 /*!
   848 /*!
   823 Enables or disabled all buttons in the keyboard that have not been disabled directly.
   849 Enables or disabled all buttons in the keyboard that have not been disabled directly.
   824 */
   850 */
   825 void HbInputVkbWidget::setKeyboardDimmed(bool dimmed)
   851 void HbInputVkbWidget::setKeyboardDimmed(bool dimmed)
   826 {
   852 {
   827     HbInputButtonGroup *buttonGroup = static_cast<HbInputButtonGroup*>(contentItem());
   853     HbInputButtonGroup *buttonGroup = static_cast<HbInputButtonGroup *>(contentItem());
   828     if (buttonGroup) {
   854     if (buttonGroup) {
   829         buttonGroup->setEnabled(!dimmed);
   855         buttonGroup->setEnabled(!dimmed);
   830     }
   856     }
   831 }
   857 }
   832 
   858 
   861         } else {
   887         } else {
   862             d->mSettingList->setPredictionSelectionEnabled(false);
   888             d->mSettingList->setPredictionSelectionEnabled(false);
   863         }
   889         }
   864     }
   890     }
   865 
   891 
   866     HbInputButtonGroup *buttonGroup = static_cast<HbInputButtonGroup*>(contentItem());
   892     HbInputButtonGroup *buttonGroup = static_cast<HbInputButtonGroup *>(contentItem());
   867     if (buttonGroup) {
   893     if (buttonGroup) {
   868         HbInputButton *item = buttonGroup->button(HbInputButton::ButtonKeyCodeSettings);
   894         HbInputButton *item = buttonGroup->button(HbInputButton::ButtonKeyCodeSettings);
   869         if (item) {
   895         if (item) {
   870             item->setState(HbInputButton::ButtonStateLatched);
   896             item->setState(HbInputButton::ButtonStateLatched);
   871             buttonGroup->setButton(item, HbInputButton::ButtonKeyCodeSettings);
   897             buttonGroup->setButton(item, HbInputButton::ButtonKeyCodeSettings);
   875     QPointF position;
   901     QPointF position;
   876     HbPopup::Placement placement;
   902     HbPopup::Placement placement;
   877     d->settingListPosition(position, placement);
   903     d->settingListPosition(position, placement);
   878     d->mSettingList->setPreferredPos(position, placement);
   904     d->mSettingList->setPreferredPos(position, placement);
   879     d->mSettingList->updateSettingList();
   905     d->mSettingList->updateSettingList();
   880     d->mSettingList->open(this, SLOT(settingsClosed()));
   906     d->mSettingList->open(this, SLOT(_q_settingsClosed(HbAction*)));
   881 }
   907 }
   882 
   908 
   883 /*!
   909 /*!
   884 Slot which is called when settings list is closed.
   910 Slot which is called when settings list is closed.
   885 */
   911 */
   886 void HbInputVkbWidget::settingsClosed()
   912 void HbInputVkbWidget::settingsClosed()
   887 {
   913 {
   888     Q_D(HbInputVkbWidget);
   914     Q_D(HbInputVkbWidget);
   889 
   915 
   890     HbInputButtonGroup *buttonGroup = static_cast<HbInputButtonGroup*>(contentItem());
   916     HbInputButtonGroup *buttonGroup = static_cast<HbInputButtonGroup *>(contentItem());
   891     if (buttonGroup) {
   917     if (buttonGroup) {
   892         HbInputButton *item = buttonGroup->button(HbInputButton::ButtonKeyCodeSettings);
   918         HbInputButton *item = buttonGroup->button(HbInputButton::ButtonKeyCodeSettings);
   893         if (item) {
   919         if (item) {
   894             item->setState(HbInputButton::ButtonStateReleased);
   920             item->setState(HbInputButton::ButtonStateReleased);
   895             buttonGroup->setButton(item, HbInputButton::ButtonKeyCodeSettings);
   921             buttonGroup->setButton(item, HbInputButton::ButtonKeyCodeSettings);
   896         }
   922         }
   897     }
   923     }
   898 
   924 
   899     d->mSettingsListOpen = false;
   925     d->mSettingsListOpen = false;
   900     if ( d->mAnimateWhenDialogCloses ) {
   926     if (d->mAnimateWhenDialogCloses) {
   901         animKeyboardChange();
   927         animKeyboardChange();
   902         d->mAnimateWhenDialogCloses = false;
   928         d->mAnimateWhenDialogCloses = false;
   903     } else if(d->mScreenshotTimeLine.state() != QTimeLine::Running) {
   929     } else if (d->mScreenshotTimeLine.state() != QTimeLine::Running) {
   904         keypadLanguageChangeFinished();
   930         keypadLanguageChangeFinished();
   905     }
   931     }
   906 }
   932 }
   907 
   933 
   908 /*!
   934 /*!
   918 Shows settings view
   944 Shows settings view
   919 */
   945 */
   920 void HbInputVkbWidget::showSettingsView()
   946 void HbInputVkbWidget::showSettingsView()
   921 {
   947 {
   922     Q_D(HbInputVkbWidget);
   948     Q_D(HbInputVkbWidget);
   923     
   949 
   924     //HbVkbHostBridge::instance()->minimizeKeypad(true);
   950     //HbVkbHostBridge::instance()->minimizeKeypad(true);
   925     /*
   951     /*
   926     Added for vanilla input
   952     Added for vanilla input
   927     When settings dialog is launched, keypad is not closed.
   953     When settings dialog is launched, keypad is not closed.
   928     */
   954     */
   935         vkbHost->closeKeypad();
   961         vkbHost->closeKeypad();
   936     }
   962     }
   937 
   963 
   938     closeSettingList();
   964     closeSettingList();
   939     hide();
   965     hide();
   940 
   966     if(!d->mSettingView) {
   941     d->mSettingView = new HbView(this);
   967         d->mSettingView = new HbView(this);
       
   968         HbAction *backAction = new HbAction(Hb::BackNaviAction, d->mSettingView);
       
   969         backAction->setText(tr("Back"));
       
   970         connect(backAction, SIGNAL(triggered(bool)), this, SLOT(closeSettingsView()));
       
   971         d->mSettingView->setNavigationAction(backAction);
       
   972         HbDataForm *dataForm = new HbDataForm();
       
   973         d->mSettingView->setWidget(dataForm);
       
   974         d->mSettingWidget = new HbInputSettingWidget(dataForm, d->mSettingView);        
       
   975     }    
       
   976     d->mSettingWidget->initializeWidget();
   942     HbInputRegionCollector::instance()->attach(d->mSettingView);
   977     HbInputRegionCollector::instance()->attach(d->mSettingView);
   943     d->mSettingView->setTitle(tr("Input Settings"));
   978     d->mSettingView->setTitle(tr("Input Settings"));
   944     mainWindow()->addView(d->mSettingView);
   979     mainWindow()->addView(d->mSettingView);
   945 
       
   946     HbAction *backAction = new HbAction(Hb::BackNaviAction, d->mSettingView);
       
   947     backAction->setText(tr("Back"));
       
   948     connect(backAction, SIGNAL(triggered(bool)), this, SLOT(closeSettingsView()));
       
   949     d->mSettingView->setNavigationAction(backAction);
       
   950 
       
   951     HbDataForm *dataForm = new HbDataForm();
       
   952     d->mSettingView->setWidget(dataForm);
       
   953     HbInputSettingWidget *settingWidget = new HbInputSettingWidget(dataForm, d->mSettingView);
       
   954     settingWidget->initializeWidget();
       
   955 
       
   956     d->mCurrentView = mainWindow()->currentView();
   980     d->mCurrentView = mainWindow()->currentView();
   957     mainWindow()->clearFocus();
   981     mainWindow()->clearFocus();
   958     mainWindow()->setCurrentView(d->mSettingView);
   982     mainWindow()->setCurrentView(d->mSettingView);
   959 }
   983 }
   960 
   984 
   966     Q_D(HbInputVkbWidget);
   990     Q_D(HbInputVkbWidget);
   967 
   991 
   968     mainWindow()->setCurrentView(d->mCurrentView);
   992     mainWindow()->setCurrentView(d->mCurrentView);
   969     mainWindow()->removeView(d->mSettingView);
   993     mainWindow()->removeView(d->mSettingView);
   970     HbInputRegionCollector::instance()->detach(d->mSettingView);
   994     HbInputRegionCollector::instance()->detach(d->mSettingView);
   971     delete d->mSettingView;
   995     d->mSettingWidget->resetWidget();
   972     d->mSettingView = 0;
   996 
   973     
       
   974     /***** To be removed, Added for vanilla input.
   997     /***** To be removed, Added for vanilla input.
   975     HbInputFocusObject *focusObject = 0;
   998     HbInputFocusObject *focusObject = 0;
   976     if (!d->mOwner || !(focusObject = d->mOwner->focusObject())) {
   999     if (!d->mOwner || !(focusObject = d->mOwner->focusObject())) {
   977         return;
  1000         return;
   978     }
  1001     }
   995 }
  1018 }
   996 
  1019 
   997 /*!
  1020 /*!
   998 \reimp
  1021 \reimp
   999 */
  1022 */
  1000 QWidget* HbInputVkbWidget::asWidget()
  1023 QWidget *HbInputVkbWidget::asWidget()
  1001 {
  1024 {
  1002     return HbInputUtils::createWrapperWidget(this);
  1025     return HbInputUtils::createWrapperWidget(this);
  1003 }
  1026 }
  1004 
  1027 
  1005 /*!
  1028 /*!
  1006 \reimp
  1029 \reimp
  1007 */
  1030 */
  1008 QGraphicsWidget* HbInputVkbWidget::asGraphicsWidget()
  1031 QGraphicsWidget *HbInputVkbWidget::asGraphicsWidget()
  1009 {
  1032 {
  1010     return this;
  1033     return this;
  1011 }
  1034 }
  1012 
  1035 
  1013 /*!
  1036 /*!
  1051 
  1074 
  1052     return ret;
  1075     return ret;
  1053 }
  1076 }
  1054 
  1077 
  1055 /*!
  1078 /*!
       
  1079 Returns the virtual rocker position. The default psition is in the middle
       
  1080 of keypad button area.
       
  1081 */
       
  1082 QPointF HbInputVkbWidget::rockerPosition()
       
  1083 {
       
  1084     Q_D(const HbInputVkbWidget);
       
  1085 
       
  1086     QPointF result;
       
  1087 
       
  1088     if (d->mRocker) {
       
  1089         QSizeF padArea = keypadButtonAreaSize();
       
  1090         result = QPointF(scenePos().x() + (padArea.width() * 0.5) - (d->mRocker->size().width() * 0.5),
       
  1091                          scenePos().y() + (padArea.height() * 0.5) - (d->mRocker->size().height() * 0.5));
       
  1092         result.setY(result.y() + d->mCloseHandleHeight);
       
  1093     }
       
  1094 
       
  1095     return result;
       
  1096 }
       
  1097 
       
  1098 /*!
  1056 Sets the status of the background drawing. This method can be used to
  1099 Sets the status of the background drawing. This method can be used to
  1057 optimize vkb widget drawing. If it is known that the widget will cover whole
  1100 optimize vkb widget drawing. If it is known that the widget will cover whole
  1058 vkb area and there are no places where the background shows through, then the background
  1101 vkb area and there are no places where the background shows through, then the background
  1059 drawing can be turned off to speed up paint method.
  1102 drawing can be turned off to speed up paint method.
  1060 */
  1103 */
  1070 for the last registered touch along with their corresponding probability.
  1113 for the last registered touch along with their corresponding probability.
  1071 */
  1114 */
  1072 QList<HbKeyPressProbability> HbInputVkbWidget::probableKeypresses()
  1115 QList<HbKeyPressProbability> HbInputVkbWidget::probableKeypresses()
  1073 {
  1116 {
  1074     QList<HbKeyPressProbability> probabilities;
  1117     QList<HbKeyPressProbability> probabilities;
  1075     HbInputButtonGroup *buttonGroup = static_cast<HbInputButtonGroup*>(contentItem());
  1118     HbInputButtonGroup *buttonGroup = static_cast<HbInputButtonGroup *>(contentItem());
  1076     if (buttonGroup) {
  1119     if (buttonGroup) {
  1077         probabilities = buttonGroup->buttonProbabilities(); 
  1120         probabilities = buttonGroup->buttonProbabilities();
  1078     }
  1121     }
  1079     return probabilities;
  1122     return probabilities;
  1080 }
  1123 }
  1081 
  1124 
  1082 /*!
  1125 /*!
  1130         }
  1173         }
  1131     }
  1174     }
  1132 
  1175 
  1133     if (d->mSmileyPicker) {
  1176     if (d->mSmileyPicker) {
  1134         d->mSmileyPicker->setGeometry(QRectF(0, pos().y(), geometry().width(),
  1177         d->mSmileyPicker->setGeometry(QRectF(0, pos().y(), geometry().width(),
  1135             geometry().height()));
  1178                                              geometry().height()));
  1136         d->mSmileyPicker->show();
  1179         d->mSmileyPicker->show();
  1137 
  1180 
  1138         HbInputButtonGroup *buttonGroup = static_cast<HbInputButtonGroup*>(contentItem());
  1181         HbInputButtonGroup *buttonGroup = static_cast<HbInputButtonGroup *>(contentItem());
  1139         if (buttonGroup) {
  1182         if (buttonGroup) {
  1140             buttonGroup->cancelButtonPress();
  1183             buttonGroup->cancelButtonPress();
  1141         }
  1184         }
  1142     }
  1185     }
  1143 }
  1186 }
  1177 */
  1220 */
  1178 void HbInputVkbWidget::sendKeyReleaseEvent(const QKeyEvent &event)
  1221 void HbInputVkbWidget::sendKeyReleaseEvent(const QKeyEvent &event)
  1179 {
  1222 {
  1180     Q_D(HbInputVkbWidget);
  1223     Q_D(HbInputVkbWidget);
  1181 
  1224 
  1182 	if (d->mOwner && event.key() > 0) {
       
  1183 		d->mOwner->filterEvent(&event);
       
  1184 	}
       
  1185 
       
  1186     if (event.key() == HbInputButton::ButtonKeyCodeSettings) {
  1225     if (event.key() == HbInputButton::ButtonKeyCodeSettings) {
  1187         showSettingList();
  1226         showSettingList();
  1188     } 
  1227     } else if (d->mOwner && event.key() > 0) {
       
  1228         d->mOwner->filterEvent(&event);
       
  1229     }
       
  1230 
       
  1231     
  1189 }
  1232 }
  1190 
  1233 
  1191 /*!
  1234 /*!
  1192 Sends key event to owning input method.
  1235 Sends key event to owning input method.
  1193 */
  1236 */
  1223         direction = -1;
  1266         direction = -1;
  1224     }
  1267     }
  1225 
  1268 
  1226     QRectF rect = boundingRect();
  1269     QRectF rect = boundingRect();
  1227     QPointF position = pos();
  1270     QPointF position = pos();
  1228     position.setX(direction * (-rect.width() + rect.width() * value));
  1271     position.setX(direction *(-rect.width() + rect.width() * value));
  1229     if (d->mScreenshotWidget) {
  1272     if (d->mScreenshotWidget) {
  1230        d->mScreenshotWidget->setPos(position.x() + direction * rect.width(), position.y());
  1273         d->mScreenshotWidget->setPos(position.x() + direction * rect.width(), position.y());
  1231        setPos(position);
  1274         setPos(position);
  1232     }
  1275     }
  1233 }
  1276 }
  1234 
  1277 
  1235 void HbInputVkbWidget::keypadLanguageChangeFinished()
  1278 void HbInputVkbWidget::keypadLanguageChangeFinished()
  1236 {
  1279 {
  1242 
  1285 
  1243 void HbInputVkbWidget::animKeyboardChange()
  1286 void HbInputVkbWidget::animKeyboardChange()
  1244 {
  1287 {
  1245     Q_D(HbInputVkbWidget);
  1288     Q_D(HbInputVkbWidget);
  1246     if (mainWindow()) {
  1289     if (mainWindow()) {
  1247         if (d->mSettingsListOpen){
  1290         if (d->mSettingsListOpen) {
  1248             d->mAnimateWhenDialogCloses = true;
  1291             d->mAnimateWhenDialogCloses = true;
  1249         } else {
  1292         } else {
  1250             if (!d->mAnimateWhenDialogCloses) {
  1293             if (!d->mAnimateWhenDialogCloses) {
  1251                 d->captureScreenshot();
  1294                 d->captureScreenshot();
  1252             }
  1295             }
  1265     Q_UNUSED(constraint);
  1308     Q_UNUSED(constraint);
  1266     Q_D(const HbInputVkbWidget);
  1309     Q_D(const HbInputVkbWidget);
  1267 
  1310 
  1268     QSizeF sh;
  1311     QSizeF sh;
  1269     switch (which) {
  1312     switch (which) {
  1270         case Qt::MinimumSize:
  1313     case Qt::MinimumSize:
  1271             sh = QSizeF(0, 0);
  1314         sh = QSizeF(0, 0);
  1272             break;
  1315         break;
  1273         case Qt::PreferredSize:
  1316     case Qt::PreferredSize:
  1274             if (d->mCurrentHost) {
  1317         if (d->mCurrentHost) {
  1275                 sh = d->mCurrentHost->keyboardArea();
  1318             sh = d->mCurrentHost->keyboardArea();
  1276             }
  1319         }
  1277             break;
  1320         break;
  1278         case Qt::MaximumSize:
  1321     case Qt::MaximumSize:
  1279             sh = QSizeF(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
  1322         sh = QSizeF(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
  1280             break;
  1323         break;
  1281         default:
  1324     default:
  1282             qWarning("HbInputVkbWidget::sizeHint(): Don't know how to handle the value of 'which'");
  1325         qWarning("HbInputVkbWidget::sizeHint(): Don't know how to handle the value of 'which'");
  1283             break;
  1326         break;
  1284     }
  1327     }
  1285     return sh;
  1328     return sh;
  1286 }
  1329 }
  1287 
  1330 
  1288 /*!
  1331 /*!
  1303 */
  1346 */
  1304 void HbInputVkbWidget::gestureEvent(QGestureEvent *event)
  1347 void HbInputVkbWidget::gestureEvent(QGestureEvent *event)
  1305 {
  1348 {
  1306     Q_D(HbInputVkbWidget);
  1349     Q_D(HbInputVkbWidget);
  1307 
  1350 
  1308     if(HbSwipeGesture *gesture = qobject_cast<HbSwipeGesture *>(event->gesture(Qt::SwipeGesture))) {
  1351     if (HbSwipeGesture *gesture = qobject_cast<HbSwipeGesture *>(event->gesture(Qt::SwipeGesture))) {
  1309         if (gesture->state() == Qt::GestureFinished) {
  1352         if (gesture->state() == Qt::GestureFinished) {
  1310             HbWidgetFeedback::triggered(this, Hb::InstantFlicked);
  1353             HbWidgetFeedback::triggered(this, Hb::InstantFlicked);
  1311             // vertical swipes
  1354             // vertical swipes
  1312             if (gesture->sceneVerticalDirection() == QSwipeGesture::Down) {
  1355             if (gesture->sceneVerticalDirection() == QSwipeGesture::Down) {
  1313                 d->mFlickDirection = HbFlickDirectionDown;
  1356                 d->mFlickDirection = HbFlickDirectionDown;
  1318                 emit flickEvent(d->mFlickDirection);
  1361                 emit flickEvent(d->mFlickDirection);
  1319                 d->mCurrentHost->openKeypad(d->mCurrentHost->activeKeypad(), d->mOwner);
  1362                 d->mCurrentHost->openKeypad(d->mCurrentHost->activeKeypad(), d->mOwner);
  1320             } else {
  1363             } else {
  1321                 d->mFlickDirection = (HbInputVkbWidget::HbFlickDirection)gesture->sceneHorizontalDirection();
  1364                 d->mFlickDirection = (HbInputVkbWidget::HbFlickDirection)gesture->sceneHorizontalDirection();
  1322                 // horizontal swipes
  1365                 // horizontal swipes
  1323                 if (d->mFlickAnimation){
  1366                 if (d->mFlickAnimation) {
  1324                     animKeyboardChange();
  1367                     animKeyboardChange();
  1325                 }
  1368                 }
  1326                 emit flickEvent(d->mFlickDirection);
  1369                 emit flickEvent(d->mFlickDirection);
  1327             }
  1370             }
  1328         }
  1371         }
  1329     } else if(HbTapGesture *gesture = qobject_cast<HbTapGesture *>(event->gesture(Qt::TapGesture))) {
  1372     } else if (HbTapGesture *gesture = qobject_cast<HbTapGesture *>(event->gesture(Qt::TapGesture))) {
  1330         if (gesture->state() == Qt::GestureFinished) {        
  1373         if (gesture->state() == Qt::GestureFinished) {
  1331             // if keypad is minimized, open it 
  1374             // if keypad is minimized, open it
  1332             if (d->mCurrentHost && d->mCurrentHost->keypadStatus() == HbVkbHost::HbVkbStatusMinimized ) {
  1375             if (d->mCurrentHost && d->mCurrentHost->keypadStatus() == HbVkbHost::HbVkbStatusMinimized) {
  1333                 d->mCurrentHost->openKeypad(this, d->mOwner);
  1376                 d->mCurrentHost->openKeypad(this, d->mOwner);
  1334             }
  1377             }
  1335         }
  1378         }
  1336     }
  1379     }
  1337 }
  1380 }
  1338 
  1381 
  1339 #include "moc_hbinputvkbwidget.cpp"
  1382 #include "moc_hbinputvkbwidget.cpp"
       
  1383 
  1340 // End of file
  1384 // End of file