src/hbinput/inputwidgets/hbinputvkbwidget.cpp
changeset 7 923ff622b8b9
parent 6 c3690ec91ef8
child 21 4633027730f5
child 34 ed14f46c0e55
equal deleted inserted replaced
6:c3690ec91ef8 7:923ff622b8b9
    45 #include <hbeffect.h>
    45 #include <hbeffect.h>
    46 #include <hbframedrawer.h>
    46 #include <hbframedrawer.h>
    47 #include <hbevent.h>
    47 #include <hbevent.h>
    48 #include <hbdataform.h>
    48 #include <hbdataform.h>
    49 #include <hbinputregioncollector_p.h>
    49 #include <hbinputregioncollector_p.h>
       
    50 #include <hbfeedbackmanager.h>
    50 
    51 
    51 #include <hbinputmethod.h>
    52 #include <hbinputmethod.h>
    52 #include <hbinputsettingproxy.h>
    53 #include <hbinputsettingproxy.h>
    53 #include <hbinpututils.h>
    54 #include <hbinpututils.h>
    54 #include <hbinputdef.h>
    55 #include <hbinputdef.h>
    65 #include <HbSwipeGesture>
    66 #include <HbSwipeGesture>
    66 #include <HbTapGesture>
    67 #include <HbTapGesture>
    67 #include <HbSelectionDialog>
    68 #include <HbSelectionDialog>
    68 #include <HbListWidgetItem>
    69 #include <HbListWidgetItem>
    69 
    70 
    70 #include "hbinputvirtualrocker.h"
       
    71 #include "hbinputsettinglist.h"
    71 #include "hbinputsettinglist.h"
    72 #include "hbinputmodeindicator.h"
    72 #include "hbinputmodeindicator.h"
    73 #include <hbfeedbackmanager.h>
       
    74 #include "hbinputsmileypicker.h"
    73 #include "hbinputsmileypicker.h"
    75 #include "hbinputscreenshotwidget.h"
    74 #include "hbinputscreenshotwidget.h"
    76 
    75 
    77 #define HB_DIGIT_LATIN_START_VALUE          0x0030
    76 const int HB_DIGIT_LATIN_START_VALUE          = 0x0030;
    78 #define HB_DIGIT_ARABIC_INDIC_START_VALUE   0x0660
    77 const int HB_DIGIT_ARABIC_INDIC_START_VALUE   = 0x0660;
    79 #define HB_DIGIT_EASTERN_ARABIC_START_VALUE 0x06F0
    78 const int HB_DIGIT_EASTERN_ARABIC_START_VALUE = 0x06F0;
    80 #define HB_DIGIT_DEVANAGARI_START_VALUE     0x0966
    79 const int HB_DIGIT_DEVANAGARI_START_VALUE     = 0x0966;
    81 
    80 
    82 const qreal HbRockerWidth = 50.0;
    81 const qreal HbPortraitSmileyPickerHeightInUnits = 43.7;
       
    82 const qreal HbPortraitSmileyPickerWidthInUnits = 47.8;
       
    83 const qreal HbLandscapeSmileyPickerHeightInUnits = 31.9;
       
    84 const qreal HbLandscapeSmileyPickerWidthInUnits = 83.4;
       
    85 const qreal HbSmileyPickerMarginInUnits = 0.9;
    83 
    86 
    84 
    87 
    85 /*!
    88 /*!
    86 @proto
    89 @proto
    87 @hbinput
    90 @hbinput
   111       mKeymap(0),
   114       mKeymap(0),
   112       mModifiers(0),
   115       mModifiers(0),
   113       mInputModeIndicator(0),
   116       mInputModeIndicator(0),
   114       mSettingList(0),
   117       mSettingList(0),
   115       mButtonLayout(0),
   118       mButtonLayout(0),
   116       mRocker(0),
       
   117       mBackgroundDrawer(0),
   119       mBackgroundDrawer(0),
   118       mIconDrawer(0),
   120       mIconDrawer(0),
   119       mMainWinConnected(false),
   121       mMainWinConnected(false),
   120       mShowRocker(false),
       
   121       mLayout(0),
   122       mLayout(0),
   122       mCurrentHost(0),
   123       mCurrentHost(0),
   123       mDrawbackground(true),
   124       mDrawbackground(true),
   124       mMouseButtonPressedDown(false),
   125       mMouseButtonPressedDown(false),
   125       mFlickDirection(HbInputVkbWidget::HbFlickDirectionNone),
   126       mFlickDirection(HbInputVkbWidget::HbFlickDirectionNone),
   127       mScreenshotWidget(0),
   128       mScreenshotWidget(0),
   128       mScreenshotTimeLine(250),
   129       mScreenshotTimeLine(250),
   129       mMostRecentlyAccessedButton(0),
   130       mMostRecentlyAccessedButton(0),
   130       mMostRecentlyClickedLocation(0.0, 0.0),
   131       mMostRecentlyClickedLocation(0.0, 0.0),
   131       mFocusedObject(0),
   132       mFocusedObject(0),
       
   133       mCurrentFocusedObject(0),
   132       mFlickAnimation(false),
   134       mFlickAnimation(false),
   133       mSettingsListOpen(false),
   135       mSettingsListOpen(false),
   134       mAnimateWhenDialogCloses(false),
   136       mAnimateWhenDialogCloses(false),
   135       mKeyboardSize(HbQwerty4x10),
   137       mKeyboardSize(HbQwerty4x10),
   136       mCloseHandleHeight(0),
   138       mCloseHandleHeight(0),
   137       mCloseHandle(0),
   139       mCloseHandle(0),
   138       mSettingView(0),
   140       mSettingView(0),
   139       mCurrentView(0),
   141       mCurrentView(0),
   140       mKeyboardDimmed(false),
   142       mKeyboardDimmed(false),
   141       mImSelectionDialog(0),
   143 	  mSettingWidget(0)
   142       mSettingWidget(0)
       
   143 {
   144 {
   144     mScreenshotTimeLine.setUpdateInterval(16);
   145     mScreenshotTimeLine.setUpdateInterval(16);
   145 }
   146 }
   146 
   147 
   147 
   148 
   150     delete mSettingList;
   151     delete mSettingList;
   151     delete mBackgroundDrawer;
   152     delete mBackgroundDrawer;
   152     delete mIconDrawer;
   153     delete mIconDrawer;
   153     delete mSmileyPicker;
   154     delete mSmileyPicker;
   154     delete mScreenshotWidget;
   155     delete mScreenshotWidget;
   155     delete mRocker;
       
   156     delete mImSelectionDialog;
       
   157 }
   156 }
   158 
   157 
   159 void HbInputVkbWidgetPrivate::initLayout()
   158 void HbInputVkbWidgetPrivate::initLayout()
   160 {
   159 {
   161     Q_Q(HbInputVkbWidget);
   160     Q_Q(HbInputVkbWidget);
   179 }
   178 }
   180 
   179 
   181 void HbInputVkbWidgetPrivate::init()
   180 void HbInputVkbWidgetPrivate::init()
   182 {
   181 {
   183     Q_Q(HbInputVkbWidget);
   182     Q_Q(HbInputVkbWidget);
   184     q->setFlag(QGraphicsItem::ItemHasNoContents, false);
   183     QGraphicsItem::GraphicsItemFlags itemFlags = q->flags();
   185 
   184 #if QT_VERSION >= 0x040600
   186     mRocker = new HbInputVirtualRocker();
   185     itemFlags |= QGraphicsItem::ItemSendsGeometryChanges;
       
   186 #endif
       
   187     // Make sure the keypad never steals focus.
       
   188     itemFlags |= QGraphicsItem::ItemIsPanel;
       
   189     q->setFlags(itemFlags);
       
   190 
   187     HbInputButtonGroup *buttonGroup = static_cast<HbInputButtonGroup *>(q->contentItem());
   191     HbInputButtonGroup *buttonGroup = static_cast<HbInputButtonGroup *>(q->contentItem());
   188     QObject::connect(buttonGroup, SIGNAL(aboutToActivateCustomAction(HbAction *)),
   192     QObject::connect(buttonGroup, SIGNAL(aboutToActivateCustomAction(HbAction *)),
   189                      q, SIGNAL(aboutToActivateCustomAction(HbAction *)));
   193                      q, SIGNAL(aboutToActivateCustomAction(HbAction *)));
   190 
       
   191     mRocker->setObjectName("VirtualRocker");
       
   192     QSizeF rockerSize(HbRockerWidth, HbRockerWidth);
       
   193     mRocker->resize(rockerSize);
       
   194     mRocker->setMinimumSize(HbRockerWidth, HbRockerWidth);
       
   195     mRocker->setMaximumSize(HbRockerWidth * 20, HbRockerWidth * 20);
       
   196     if (q->mainWindow()) {
       
   197         q->mainWindow()->scene()->addItem(mRocker);
       
   198     }
       
   199 
       
   200     QObject::connect(mRocker, SIGNAL(rockerDirection(int, HbInputVirtualRocker::RockerSelectionMode)),
       
   201                      q, SLOT(_q_handleRockerChange(int, HbInputVirtualRocker::RockerSelectionMode)));
       
   202 
       
   203     mRocker->setVisible(false);
       
   204 
   194 
   205     mBackgroundDrawer = new HbFrameDrawer();
   195     mBackgroundDrawer = new HbFrameDrawer();
   206     mBackgroundDrawer->setFrameGraphicsName(backgroundGraphics);
   196     mBackgroundDrawer->setFrameGraphicsName(backgroundGraphics);
   207     mBackgroundDrawer->setFrameType(HbFrameDrawer::ThreePiecesVertical);
   197     mBackgroundDrawer->setFrameType(HbFrameDrawer::ThreePiecesVertical);
   208     mBackgroundDrawer->setFillWholeRect(true);
   198     mBackgroundDrawer->setFillWholeRect(true);
   361             placement = HbPopup::BottomRightCorner;
   351             placement = HbPopup::BottomRightCorner;
   362         }
   352         }
   363     }
   353     }
   364 }
   354 }
   365 
   355 
   366 void HbInputVkbWidgetPrivate::setRockerPosition()
       
   367 {
       
   368     Q_Q(HbInputVkbWidget);
       
   369     mRocker->setPos(q->rockerPosition());
       
   370 }
       
   371 
       
   372 void HbInputVkbWidgetPrivate::captureScreenshot()
   356 void HbInputVkbWidgetPrivate::captureScreenshot()
   373 {
   357 {
   374     Q_Q(HbInputVkbWidget);
   358     Q_Q(HbInputVkbWidget);
   375 
   359 
   376     if (!mScreenshotWidget) {
   360     if (!mScreenshotWidget) {
   428     }
   412     }
   429 
   413 
   430     return ret;
   414     return ret;
   431 }
   415 }
   432 
   416 
   433 void HbInputVkbWidgetPrivate::showInputMethodSelectionDialog()
   417 void HbInputVkbWidgetPrivate::_q_activateInputMethod(const HbInputMethodDescriptor &descriptor, const QByteArray &customData)
   434 {
   418 {
   435     Q_Q(HbInputVkbWidget);
   419     Q_Q(HbInputVkbWidget);
   436 
   420 
   437     delete mImSelectionDialog;
   421     if (!descriptor.isEmpty() && mOwner) {
   438     mImSelectionDialog = new HbSelectionDialog();
   422         // Set as active input method.
   439 
   423         HbInputSettingProxy::instance()->setPreferredInputMethod(q->mainWindow()->orientation(), descriptor, customData);
   440     mImSelectionDialog->setObjectName("Input method dialog");
   424         // Activate immediately.
   441 
   425         mOwner->activateInputMethod(descriptor);
   442     // Make sure the language dialog never steals focus.
   426     }
   443     mImSelectionDialog->setFlag(QGraphicsItem::ItemIsPanel, true);
   427 }
   444     mImSelectionDialog->setActive(false);
   428 
   445 
   429 void HbInputVkbWidgetPrivate::_q_smileyPickerClosed()
   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 {
   430 {
   502     Q_Q(HbInputVkbWidget);
   431     Q_Q(HbInputVkbWidget);
   503 
   432 
   504     if (direction == HbInputVirtualRocker::HbRockerDirectionRelease) {
   433     q->setKeyboardDimmed(false);
   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 }
   434 }
   512 
   435 
   513 QChar HbInputVkbWidgetPrivate::numberCharacterBoundToKey(int key)
   436 QChar HbInputVkbWidgetPrivate::numberCharacterBoundToKey(int key)
   514 {
   437 {
   515     QChar numChr;
   438     QChar numChr;
   588 
   511 
   589 #ifdef HB_EFFECTS
   512 #ifdef HB_EFFECTS
   590     HbEffect::disable(this);
   513     HbEffect::disable(this);
   591 #endif // HB_EFFECTS
   514 #endif // HB_EFFECTS
   592 
   515 
   593     // Make sure the keypad never steals focus.
       
   594     setFlag(QGraphicsItem::ItemIsPanel, true);
       
   595     setActive(false);
   516     setActive(false);
       
   517 
       
   518     if (!d->mOwner) {
       
   519         d->mOwner = HbInputMethod::activeInputMethod();
       
   520     }
   596 }
   521 }
   597 
   522 
   598 /*!
   523 /*!
   599 Constructs the object.
   524 Constructs the object.
   600 */
   525 */
   611 
   536 
   612 #ifdef HB_EFFECTS
   537 #ifdef HB_EFFECTS
   613     HbEffect::disable(this);
   538     HbEffect::disable(this);
   614 #endif // HB_EFFECTS
   539 #endif // HB_EFFECTS
   615 
   540 
   616     // Make sure the keypad never steals focus.
       
   617     setFlag(QGraphicsItem::ItemIsPanel, true);
       
   618     setActive(false);
   541     setActive(false);
   619 }
   542 }
   620 
   543 
   621 /*!
   544 /*!
   622 Destructs the object.
   545 Destructs the object.
   631 void HbInputVkbWidget::keyboardOpened(HbVkbHost *host)
   554 void HbInputVkbWidget::keyboardOpened(HbVkbHost *host)
   632 {
   555 {
   633     Q_D(HbInputVkbWidget);
   556     Q_D(HbInputVkbWidget);
   634 
   557 
   635     d->mCurrentHost = host;
   558     d->mCurrentHost = host;
   636     d->mRocker->setVisible(d->mShowRocker);
       
   637     d->setRockerPosition();
       
   638     d->mFlickDirection = HbFlickDirectionNone;
   559     d->mFlickDirection = HbFlickDirectionNone;
   639 }
   560 }
   640 
   561 
   641 /*!
   562 /*!
   642 Vkb host calls this handler when the keyboard close animation has finished.
   563 Vkb host calls this handler when the keyboard close animation has finished.
   646 void HbInputVkbWidget::keyboardClosed(HbVkbHost *host)
   567 void HbInputVkbWidget::keyboardClosed(HbVkbHost *host)
   647 {
   568 {
   648     Q_UNUSED(host);
   569     Q_UNUSED(host);
   649     Q_D(HbInputVkbWidget);
   570     Q_D(HbInputVkbWidget);
   650 
   571 
   651     d->mRocker->setVisible(false);
       
   652     d->mFlickDirection = HbFlickDirectionNone;
   572     d->mFlickDirection = HbFlickDirectionNone;
   653 }
   573 }
   654 
   574 
   655 /*!
   575 /*!
   656 Vkb host calls this handler when the keyboard minimize animation has finished.
   576 Vkb host calls this handler when the keyboard minimize animation has finished.
   725     }
   645     }
   726     return item;
   646     return item;
   727 }
   647 }
   728 
   648 
   729 /*!
   649 /*!
       
   650 \deprecated HbInputVkbWidget::setRockerVisible(bool)
       
   651     is deprecated.
       
   652 
   730 Sets virtual rocker visibility.
   653 Sets virtual rocker visibility.
   731 */
   654 */
   732 void HbInputVkbWidget::setRockerVisible(bool visible)
   655 void HbInputVkbWidget::setRockerVisible(bool visible)
   733 {
   656 {
   734     Q_D(HbInputVkbWidget);
   657     Q_UNUSED(visible);
   735     d->mShowRocker = visible;
   658 }
   736 }
   659 
   737 
   660 /*!
   738 /*!
   661 \deprecated HbInputVkbWidget::isRockerVisible() const
       
   662     is deprecated.
       
   663 
   739 Returns true if virtual rocker is allowed to be visible.
   664 Returns true if virtual rocker is allowed to be visible.
   740 */
   665 */
   741 bool HbInputVkbWidget::isRockerVisible() const
   666 bool HbInputVkbWidget::isRockerVisible() const
   742 {
   667 {
   743     Q_D(const HbInputVkbWidget);
   668     return false;
   744     if (d->mShowRocker) {
       
   745         return d->mRocker->isVisible();
       
   746     } else {
       
   747         return false;
       
   748     }
       
   749 }
   669 }
   750 
   670 
   751 /*!
   671 /*!
   752 Returns active keypad mode. Possible values are EModeAbc, EModeNumeric and EModeSct.
   672 Returns active keypad mode. Possible values are EModeAbc, EModeNumeric and EModeSct.
   753 */
   673 */
   819     d->mCurrentHost = host;
   739     d->mCurrentHost = host;
   820 
   740 
   821     if (d->mOwner && d->mOwner->focusObject()) {
   741     if (d->mOwner && d->mOwner->focusObject()) {
   822         qreal vkbZValue = d->mOwner->focusObject()->findVkbZValue();
   742         qreal vkbZValue = d->mOwner->focusObject()->findVkbZValue();
   823         setZValue(vkbZValue);
   743         setZValue(vkbZValue);
   824         d->mRocker->setZValue(vkbZValue + 0.5);
       
   825     }
   744     }
   826 
   745 
   827     show();
   746     show();
   828 }
   747 }
   829 
   748 
   837     d->mCurrentHost = host;
   756     d->mCurrentHost = host;
   838 
   757 
   839     if (d->mSmileyPicker && d->mSmileyPicker->isVisible()) {
   758     if (d->mSmileyPicker && d->mSmileyPicker->isVisible()) {
   840         d->mSmileyPicker->hide();
   759         d->mSmileyPicker->hide();
   841     }
   760     }
   842     d->mRocker->setVisible(false);
       
   843     if (d->mSettingList) {
   761     if (d->mSettingList) {
   844         d->mSettingList->close();
   762         d->mSettingList->close();
   845     }
   763     }
   846 }
   764 }
   847 
   765 
   848 /*!
   766 /*!
   849 Enables or disabled all buttons in the keyboard that have not been disabled directly.
   767 Enables or disables all buttons in the keyboard that have not been disabled directly.
   850 */
   768 */
   851 void HbInputVkbWidget::setKeyboardDimmed(bool dimmed)
   769 void HbInputVkbWidget::setKeyboardDimmed(bool dimmed)
   852 {
   770 {
   853     HbInputButtonGroup *buttonGroup = static_cast<HbInputButtonGroup *>(contentItem());
   771     HbInputButtonGroup *buttonGroup = static_cast<HbInputButtonGroup *>(contentItem());
   854     if (buttonGroup) {
   772     if (buttonGroup) {
   868     d->captureScreenshot();
   786     d->captureScreenshot();
   869 
   787 
   870     if (!d->mSettingList) {
   788     if (!d->mSettingList) {
   871         d->mSettingList = new HbInputSettingList();
   789         d->mSettingList = new HbInputSettingList();
   872         connect(d->mSettingList, SIGNAL(inputSettingsButtonClicked()), this, SLOT(showSettingsView()));
   790         connect(d->mSettingList, SIGNAL(inputSettingsButtonClicked()), this, SLOT(showSettingsView()));
   873         connect(d->mSettingList, SIGNAL(inputMethodsButtonClicked()), this, SLOT(executeMethodDialog()));
   791         connect(d->mSettingList, SIGNAL(inputMethodSelected(const HbInputMethodDescriptor &, const QByteArray &)),
       
   792                 this, SLOT(_q_activateInputMethod(const HbInputMethodDescriptor &, const QByteArray &)));
   874     }
   793     }
   875 
   794 
   876     HbInputFocusObject *focusObject = d->mOwner->focusObject();
   795     HbInputFocusObject *focusObject = d->mOwner->focusObject();
   877     if (focusObject) {
   796     if (focusObject) {
   878         if (focusObject->editorInterface().inputConstraints() & HbEditorConstraintLatinAlphabetOnly) {
   797         if (focusObject->editorInterface().inputConstraints() & HbEditorConstraintLatinAlphabetOnly) {
   945 */
   864 */
   946 void HbInputVkbWidget::showSettingsView()
   865 void HbInputVkbWidget::showSettingsView()
   947 {
   866 {
   948     Q_D(HbInputVkbWidget);
   867     Q_D(HbInputVkbWidget);
   949 
   868 
   950     //HbVkbHostBridge::instance()->minimizeKeypad(true);
       
   951     /*
   869     /*
   952     Added for vanilla input
   870     Added for vanilla input
   953     When settings dialog is launched, keypad is not closed.
   871     When settings dialog is launched, keypad is not closed.
   954     */
   872     */
   955     HbInputFocusObject *focusObject = 0;
   873     HbInputFocusObject *focusObject = 0;
   958     }
   876     }
   959     HbVkbHost *vkbHost = focusObject->editorInterface().vkbHost();
   877     HbVkbHost *vkbHost = focusObject->editorInterface().vkbHost();
   960     if (vkbHost && vkbHost->keypadStatus() != HbVkbHost::HbVkbStatusClosed) {
   878     if (vkbHost && vkbHost->keypadStatus() != HbVkbHost::HbVkbStatusClosed) {
   961         vkbHost->closeKeypad();
   879         vkbHost->closeKeypad();
   962     }
   880     }
       
   881     d->mCurrentFocusedObject = focusObject->object();
   963 
   882 
   964     closeSettingList();
   883     closeSettingList();
   965     hide();
       
   966     if(!d->mSettingView) {
   884     if(!d->mSettingView) {
   967         d->mSettingView = new HbView(this);
   885         d->mSettingView = new HbView(this);
   968         HbAction *backAction = new HbAction(Hb::BackNaviAction, d->mSettingView);
   886         HbAction *backAction = new HbAction(Hb::BackNaviAction, d->mSettingView);
   969         backAction->setText(tr("Back"));
   887         backAction->setText(tr("Back"));
   970         connect(backAction, SIGNAL(triggered(bool)), this, SLOT(closeSettingsView()));
   888         connect(backAction, SIGNAL(triggered(bool)), this, SLOT(closeSettingsView()));
   976     d->mSettingWidget->initializeWidget();
   894     d->mSettingWidget->initializeWidget();
   977     HbInputRegionCollector::instance()->attach(d->mSettingView);
   895     HbInputRegionCollector::instance()->attach(d->mSettingView);
   978     d->mSettingView->setTitle(tr("Input Settings"));
   896     d->mSettingView->setTitle(tr("Input Settings"));
   979     mainWindow()->addView(d->mSettingView);
   897     mainWindow()->addView(d->mSettingView);
   980     d->mCurrentView = mainWindow()->currentView();
   898     d->mCurrentView = mainWindow()->currentView();
   981     mainWindow()->clearFocus();
       
   982     mainWindow()->setCurrentView(d->mSettingView);
   899     mainWindow()->setCurrentView(d->mSettingView);
   983 }
   900 }
   984 
   901 
   985 /*!
   902 /*!
   986 Closes settings view and returns to previous view
   903 Closes settings view and returns to previous view
   989 {
   906 {
   990     Q_D(HbInputVkbWidget);
   907     Q_D(HbInputVkbWidget);
   991 
   908 
   992     mainWindow()->setCurrentView(d->mCurrentView);
   909     mainWindow()->setCurrentView(d->mCurrentView);
   993     mainWindow()->removeView(d->mSettingView);
   910     mainWindow()->removeView(d->mSettingView);
       
   911     if (d->mSettingView->scene()) {
       
   912         d->mSettingView->scene()->removeItem(d->mSettingView);
       
   913     }
   994     HbInputRegionCollector::instance()->detach(d->mSettingView);
   914     HbInputRegionCollector::instance()->detach(d->mSettingView);
   995     d->mSettingWidget->resetWidget();
   915     d->mSettingWidget->resetWidget();
   996 
   916 
   997     /***** To be removed, Added for vanilla input.
   917     if (d->mCurrentFocusedObject) {
   998     HbInputFocusObject *focusObject = 0;
   918         HbInputFocusObject *focusObject = new HbInputFocusObject(d->mCurrentFocusedObject);
   999     if (!d->mOwner || !(focusObject = d->mOwner->focusObject())) {
   919         d->mOwner->setFocusObject(focusObject);
  1000         return;
   920         d->mCurrentFocusedObject = 0;
  1001     }
   921     }
  1002     HbVkbHost *vkbHost = focusObject->editorInterface().vkbHost();
   922 }
  1003     if (vkbHost && vkbHost->keypadStatus() != HbVkbHost::HbVkbStatusOpened) {
   923 
  1004         vkbHost->openKeypad();
   924 /*!
  1005     }
   925 \deprecated HbInputVkbWidget::executeMethodDialog()
  1006     *****/
   926     is deprecated.
  1007 }
       
  1008 
       
  1009 /*!
       
  1010 Executes input method selection dialog
   927 Executes input method selection dialog
  1011 */
   928 */
  1012 void HbInputVkbWidget::executeMethodDialog()
   929 void HbInputVkbWidget::executeMethodDialog()
  1013 {
   930 {
  1014     Q_D(HbInputVkbWidget);
       
  1015 
       
  1016     closeSettingList();
       
  1017     d->showInputMethodSelectionDialog();
       
  1018 }
   931 }
  1019 
   932 
  1020 /*!
   933 /*!
  1021 \reimp
   934 \reimp
  1022 */
   935 */
  1054 */
   967 */
  1055 void HbInputVkbWidget::keyboardAnimationFrame(HbVkbAnimationType type, qreal x)
   968 void HbInputVkbWidget::keyboardAnimationFrame(HbVkbAnimationType type, qreal x)
  1056 {
   969 {
  1057     Q_UNUSED(type);
   970     Q_UNUSED(type);
  1058     Q_UNUSED(x);
   971     Q_UNUSED(x);
  1059 
       
  1060     Q_D(HbInputVkbWidget);
       
  1061     d->setRockerPosition();
       
  1062 }
   972 }
  1063 
   973 
  1064 /*!
   974 /*!
  1065 Returns the size of the keypad button area.
   975 Returns the size of the keypad button area.
  1066 */
   976 */
  1074 
   984 
  1075     return ret;
   985     return ret;
  1076 }
   986 }
  1077 
   987 
  1078 /*!
   988 /*!
  1079 Returns the virtual rocker position. The default psition is in the middle
   989 \deprecated HbInputVkbWidget::rockerPosition()
       
   990     is deprecated.
       
   991 
       
   992 Returns the virtual rocker position. The default position is in the middle
  1080 of keypad button area.
   993 of keypad button area.
  1081 */
   994 */
  1082 QPointF HbInputVkbWidget::rockerPosition()
   995 QPointF HbInputVkbWidget::rockerPosition()
  1083 {
   996 {
  1084     Q_D(const HbInputVkbWidget);
   997     return QPointF();
  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 }
   998 }
  1097 
   999 
  1098 /*!
  1000 /*!
  1099 Sets the status of the background drawing. This method can be used to
  1001 Sets the status of the background drawing. This method can be used to
  1100 optimize vkb widget drawing. If it is known that the widget will cover whole
  1002 optimize vkb widget drawing. If it is known that the widget will cover whole
  1107     d->mDrawbackground = backgroundEnabled;
  1009     d->mDrawbackground = backgroundEnabled;
  1108 }
  1010 }
  1109 
  1011 
  1110 
  1012 
  1111 /*!
  1013 /*!
  1112 Returns all possible keys those the user could have intended to press
  1014 Returns all possible keys that the user could have intended to press
  1113 for the last registered touch along with their corresponding probability.
  1015 for the last registered touch along with their corresponding probability.
  1114 */
  1016 */
  1115 QList<HbKeyPressProbability> HbInputVkbWidget::probableKeypresses()
  1017 QList<HbKeyPressProbability> HbInputVkbWidget::probableKeypresses()
  1116 {
  1018 {
  1117     QList<HbKeyPressProbability> probabilities;
  1019     QList<HbKeyPressProbability> probabilities;
  1172             connect(d->mSmileyPicker, SIGNAL(selected(QString)), this, SIGNAL(smileySelected(QString)));
  1074             connect(d->mSmileyPicker, SIGNAL(selected(QString)), this, SIGNAL(smileySelected(QString)));
  1173         }
  1075         }
  1174     }
  1076     }
  1175 
  1077 
  1176     if (d->mSmileyPicker) {
  1078     if (d->mSmileyPicker) {
  1177         d->mSmileyPicker->setGeometry(QRectF(0, pos().y(), geometry().width(),
  1079         qreal unitValue = HbDeviceProfile::profile(mainWindow()).unitValue();
  1178                                              geometry().height()));
  1080         QSizeF screenSize = HbDeviceProfile::profile(mainWindow()).logicalSize();
  1179         d->mSmileyPicker->show();
  1081 
       
  1082         qreal width = HbPortraitSmileyPickerWidthInUnits * unitValue;
       
  1083         qreal height = HbPortraitSmileyPickerHeightInUnits * unitValue;
       
  1084         if (mainWindow()->orientation() == Qt::Horizontal) {
       
  1085             width = HbLandscapeSmileyPickerWidthInUnits * unitValue;
       
  1086             height = HbLandscapeSmileyPickerHeightInUnits * unitValue;
       
  1087         }
       
  1088 
       
  1089         d->mSmileyPicker->setPreferredSize(QSizeF(width, height));
       
  1090         d->mSmileyPicker->setPos((screenSize.width() - width) * 0.5,
       
  1091                                  screenSize.height() - height - HbSmileyPickerMarginInUnits * unitValue);
       
  1092         d->mSmileyPicker->open(this, SLOT(_q_smileyPickerClosed()));
       
  1093         setKeyboardDimmed(true);
  1180 
  1094 
  1181         HbInputButtonGroup *buttonGroup = static_cast<HbInputButtonGroup *>(contentItem());
  1095         HbInputButtonGroup *buttonGroup = static_cast<HbInputButtonGroup *>(contentItem());
  1182         if (buttonGroup) {
  1096         if (buttonGroup) {
  1183             buttonGroup->cancelButtonPress();
  1097             buttonGroup->cancelButtonPress();
  1184         }
  1098         }
  1220 */
  1134 */
  1221 void HbInputVkbWidget::sendKeyReleaseEvent(const QKeyEvent &event)
  1135 void HbInputVkbWidget::sendKeyReleaseEvent(const QKeyEvent &event)
  1222 {
  1136 {
  1223     Q_D(HbInputVkbWidget);
  1137     Q_D(HbInputVkbWidget);
  1224 
  1138 
       
  1139     if (d->mOwner && event.key() > 0) {
       
  1140         d->mOwner->filterEvent(&event);
       
  1141     }
       
  1142 
  1225     if (event.key() == HbInputButton::ButtonKeyCodeSettings) {
  1143     if (event.key() == HbInputButton::ButtonKeyCodeSettings) {
  1226         showSettingList();
  1144         showSettingList();
  1227     } else if (d->mOwner && event.key() > 0) {
  1145     }
  1228         d->mOwner->filterEvent(&event);
       
  1229     }
       
  1230 
       
  1231     
       
  1232 }
  1146 }
  1233 
  1147 
  1234 /*!
  1148 /*!
  1235 Sends key event to owning input method.
  1149 Sends key event to owning input method.
  1236 */
  1150 */