src/hbinput/inputwidgets/hbinputvkbwidget.cpp
changeset 1 f7ac710697a9
parent 0 16d8024aca5e
child 2 06ff229162e9
equal deleted inserted replaced
0:16d8024aca5e 1:f7ac710697a9
    43 #include <hbdialog.h>
    43 #include <hbdialog.h>
    44 #include <hbeffect.h>
    44 #include <hbeffect.h>
    45 #include <hbstackedwidget.h>
    45 #include <hbstackedwidget.h>
    46 #include <hbframedrawer.h>
    46 #include <hbframedrawer.h>
    47 #include <hbevent.h>
    47 #include <hbevent.h>
       
    48 #include <hbdataform.h>
    48 
    49 
    49 #include <hbinputmethod.h>
    50 #include <hbinputmethod.h>
    50 #include <hbinputsettingproxy.h>
    51 #include <hbinputsettingproxy.h>
    51 #include <hbinpututils.h>
    52 #include <hbinpututils.h>
    52 #include <hbinputdef.h>
    53 #include <hbinputdef.h>
    53 #include <hbinputvkbhost.h>
    54 #include <hbinputvkbhost.h>
    54 #include <hbinputsettingdialog.h>
    55 #include <hbinputsettingwidget.h>
    55 #include <hbinputcommondialogs.h>
    56 #include <hbinputcommondialogs.h>
    56 #include <hbinputkeymap.h>
    57 #include <hbinputkeymap.h>
    57 #include <hbinputkeymapfactory.h>
    58 #include <hbinputkeymapfactory.h>
    58 #include <hbwidgetfeedback.h>
    59 #include <hbwidgetfeedback.h>
    59 #include <hbsmileyengine.h>
       
    60 #include <hbinputpredictionfactory.h>
    60 #include <hbinputpredictionfactory.h>
    61 
    61 #include <HbSwipeGesture>
       
    62 #include <HbTapGesture>
    62 #include "hbinputvirtualrocker.h"
    63 #include "hbinputvirtualrocker.h"
    63 #include "hbinputvkbwidget.h"
    64 #include "hbinputvkbwidget.h"
    64 #include "hbinputvkbwidget_p.h"
    65 #include "hbinputvkbwidget_p.h"
    65 #include "hbinputtouchkeypadbutton.h"
    66 #include "hbinputtouchkeypadbutton.h"
    66 #include "hbinputsettinglist.h"
    67 #include "hbinputsettinglist.h"
   127 mFlickAnimation(false),
   128 mFlickAnimation(false),
   128 mSettingsListOpen(false),
   129 mSettingsListOpen(false),
   129 mAnimateWhenDialogCloses(false),
   130 mAnimateWhenDialogCloses(false),
   130 mKeyboardSize(HbQwerty4x10),
   131 mKeyboardSize(HbQwerty4x10),
   131 mCloseHandleHeight(0),
   132 mCloseHandleHeight(0),
   132 mCloseHandle(NULL),
   133 mCloseHandle(0),
       
   134 mSettingView(0),
       
   135 mCurrentView(0),
   133 mKeyboardDimmed(false)
   136 mKeyboardDimmed(false)
   134 {
   137 {
       
   138     mScreenshotTimeLine.setUpdateInterval(16);
   135 }
   139 }
   136 
   140 
   137 
   141 
   138 HbInputVkbWidgetPrivate::~HbInputVkbWidgetPrivate()
   142 HbInputVkbWidgetPrivate::~HbInputVkbWidgetPrivate()
   139 {
   143 {
   171     mIconDrawer->setFrameGraphicsName(HbInputVkbHandleIcon);
   175     mIconDrawer->setFrameGraphicsName(HbInputVkbHandleIcon);
   172 
   176 
   173     mReleaseMapper = new QSignalMapper(q);
   177     mReleaseMapper = new QSignalMapper(q);
   174     mPressMapper = new QSignalMapper(q);
   178     mPressMapper = new QSignalMapper(q);
   175     mActionMapper = new QSignalMapper(q);
   179     mActionMapper = new QSignalMapper(q);
       
   180 
       
   181     q->grabGesture(Qt::SwipeGesture);
       
   182 
       
   183     // eating gestures below the panel (remove when panel starts to do this)
       
   184     q->grabGesture(Qt::TapGesture);
       
   185     q->grabGesture(Qt::PanGesture);
   176 }
   186 }
   177 
   187 
   178 // re-implemented by inherited keyboards
   188 // re-implemented by inherited keyboards
   179 int HbInputVkbWidgetPrivate::keyCode(int buttonId)
   189 int HbInputVkbWidgetPrivate::keyCode(int buttonId)
   180 {
   190 {
   305         return ret;
   315         return ret;
   306     }
   316     }
   307     if (mOwner->focusObject()->editorInterface().editor()->inherits("HbAbstractEdit")) {
   317     if (mOwner->focusObject()->editorInterface().editor()->inherits("HbAbstractEdit")) {
   308         if (!mOwner->focusObject()->editorInterface().smileyTheme().isNull()) {
   318         if (!mOwner->focusObject()->editorInterface().smileyTheme().isNull()) {
   309             ret = true;
   319             ret = true;
   310         }		
   320         }
   311     }	else {
   321     }
   312         HbSmileyEngine smileyEngine;
   322 
   313         if (!smileyEngine.defaultTheme().isNull()) {
   323     return ret;
   314             ret = true;
       
   315         }	
       
   316     }	
       
   317     return ret;	
       
   318 }
   324 }
   319 /// @endcond
   325 /// @endcond
   320 
   326 
   321 /*!
   327 /*!
   322 Costructs the object.
   328 Costructs the object.
   333 
   339 
   334 #ifdef HB_EFFECTS
   340 #ifdef HB_EFFECTS
   335     HbEffect::disable(this);
   341     HbEffect::disable(this);
   336 #endif // HB_EFFECTS
   342 #endif // HB_EFFECTS
   337 
   343 
   338 #if QT_VERSION >= 0x040600
       
   339     // Make sure the keypad never steals focus.
   344     // Make sure the keypad never steals focus.
   340     setFlag(QGraphicsItem::ItemIsPanel, true);
   345     setFlag(QGraphicsItem::ItemIsPanel, true);
   341     setActive(false);
   346     setActive(false);
   342 #endif
       
   343 }
   347 }
   344 
   348 
   345 /*!
   349 /*!
   346 Constructs the object.
   350 Constructs the object.
   347 */
   351 */
   357 
   361 
   358 #ifdef HB_EFFECTS
   362 #ifdef HB_EFFECTS
   359     HbEffect::disable(this);
   363     HbEffect::disable(this);
   360 #endif // HB_EFFECTS
   364 #endif // HB_EFFECTS
   361 
   365 
   362 #if QT_VERSION >= 0x040600
       
   363     // Make sure the keypad never steals focus.
   366     // Make sure the keypad never steals focus.
   364     setFlag(QGraphicsItem::ItemIsPanel, true);
   367     setFlag(QGraphicsItem::ItemIsPanel, true);
   365     setActive(false);
   368     setActive(false);
   366 #endif
       
   367 }
   369 }
   368 
   370 
   369 /*!
   371 /*!
   370 Destructs the object.
   372 Destructs the object.
   371 */
   373 */
   381     Q_D(HbInputVkbWidget);
   383     Q_D(HbInputVkbWidget);
   382 
   384 
   383     d->mCurrentHost = host;
   385     d->mCurrentHost = host;
   384     d->mRocker->setVisible(d->mShowRocker);
   386     d->mRocker->setVisible(d->mShowRocker);
   385     d->setRockerPosition();
   387     d->setRockerPosition();
       
   388     d->mFlickDirection = HbFlickDirectionNone;
   386 }
   389 }
   387 
   390 
   388 /*!
   391 /*!
   389 Vkb host calls this handler when the keyboard close animation has finished.
   392 Vkb host calls this handler when the keyboard close animation has finished.
   390 
   393 
   394 {
   397 {
   395     Q_UNUSED(host);
   398     Q_UNUSED(host);
   396     Q_D(HbInputVkbWidget);
   399     Q_D(HbInputVkbWidget);
   397 
   400 
   398     d->mRocker->setVisible(false);
   401     d->mRocker->setVisible(false);
       
   402     d->mFlickDirection = HbFlickDirectionNone;
   399 }
   403 }
   400 
   404 
   401 /*!
   405 /*!
   402 Vkb host calls this handler when the keyboard minimize animation has finished.
   406 Vkb host calls this handler when the keyboard minimize animation has finished.
   403 
   407 
   404 \sa HbVkbHost
   408 \sa HbVkbHost
   405 */
   409 */
   406 void HbInputVkbWidget::keyboardMinimized(HbVkbHost *host)
   410 void HbInputVkbWidget::keyboardMinimized(HbVkbHost *host)
   407 {
   411 {
   408     Q_UNUSED(host);
   412     Q_UNUSED(host);
   409 }
   413     Q_D(HbInputVkbWidget);
   410 
   414     d->mFlickDirection = HbFlickDirectionNone;
   411 /*!
   415 }
   412 handles mouse press event.
   416 
       
   417 /*!
       
   418 \deprecated HbInputVkbWidget::mousePressEvent(QGraphicsSceneMouseEvent*)
       
   419     is deprecated.
   413 */
   420 */
   414 void HbInputVkbWidget::mousePressEvent(QGraphicsSceneMouseEvent* event)
   421 void HbInputVkbWidget::mousePressEvent(QGraphicsSceneMouseEvent* event)
   415 {
   422 {
   416     Q_D(HbInputVkbWidget);
       
   417     Q_UNUSED(event);
   423     Q_UNUSED(event);
   418     if (!d->mMouseButtonPressedDown) {
   424 }
   419         d->mMouseButtonPressedDown = true;
   425 
   420         d->mMousePressTime.start();
   426 /*!
   421     }
   427 \deprecated HbInputVkbWidget::mappedKeyPress(int)
   422 }
   428     is deprecated.
   423 
       
   424 /*!
       
   425 Handles mouse release event.
       
   426 */
       
   427 void HbInputVkbWidget::mouseReleaseEvent(QGraphicsSceneMouseEvent* event)
       
   428 {
       
   429     Q_D(HbInputVkbWidget);
       
   430     d->mFlickDirection = HbFlickDirectionNone;
       
   431     d->mMouseButtonPressedDown = false;
       
   432 
       
   433     QPointF mouseDownpoint = event->buttonDownScenePos(Qt::LeftButton);
       
   434 
       
   435     if (d->mCurrentHost && d->mCurrentHost->keypadStatus() != HbVkbHost::HbVkbStatusOpened &&
       
   436         d->mCurrentHost->activeKeypad() && d->mOwner) {
       
   437         HbWidgetFeedback::triggered(this, Hb::InstantFlicked);
       
   438         d->mCurrentHost->openKeypad(d->mCurrentHost->activeKeypad(), d->mOwner);
       
   439     } else if (d->mMousePressTime.elapsed() < MaxSweepTime || mouseDownpoint.y() <= scenePos().y() + d->mCloseHandleHeight) {
       
   440         QPointF delta = event->scenePos() - mouseDownpoint;
       
   441 
       
   442         qreal height;
       
   443         if (HbInputSettingProxy::instance()->screenOrientation() == Qt::Horizontal) {
       
   444             height = geometry().height() * 0.5;
       
   445         } else {
       
   446             // For ITU-T, 40% of the scene height is considered.
       
   447             height = 0.4 * geometry().height();
       
   448         }
       
   449         // If the user drags the mouse on keypad and the
       
   450         // delta is greater than 10% of the height, keypad is closed
       
   451         height = HbMouseDragDelta * height;
       
   452 
       
   453         if (delta.y() > height) {
       
   454             HbWidgetFeedback::triggered(this, Hb::InstantFlicked);
       
   455             d->mFlickDirection = HbFlickDirectionDown;
       
   456             emit keypadCloseEventDetected(HbVkbCloseMethodButtonDrag);
       
   457         }
       
   458 
       
   459         if (qAbs(delta.x()) > SweepLength) {
       
   460 
       
   461             d->mFlickDirection = delta.x()>0 ? HbFlickDirectionRight : HbFlickDirectionLeft;
       
   462 
       
   463             if (d->mFlickAnimation){
       
   464                 HbWidgetFeedback::triggered(this, Hb::InstantFlicked);
       
   465                 animKeyboardChange();
       
   466             }
       
   467             emit flickEvent(d->mFlickDirection);
       
   468         }
       
   469     }
       
   470 }
       
   471 
       
   472 /*!
       
   473 Handles virtual key press
       
   474 */
   429 */
   475 void HbInputVkbWidget::mappedKeyPress(int buttonid)
   430 void HbInputVkbWidget::mappedKeyPress(int buttonid)
   476 {
   431 {
   477     Q_D(HbInputVkbWidget);
   432     Q_D(HbInputVkbWidget);
   478     d->handleStandardButtonPress(buttonid);
   433     d->handleStandardButtonPress(buttonid);
   479 }
   434 }
   480 
   435 
   481 /*!
   436 /*!
   482 Handles virtual key release
   437 \deprecated HbInputVkbWidget::mappedKeyRelease(int)
       
   438     is deprecated.
   483 */
   439 */
   484 void HbInputVkbWidget::mappedKeyRelease(int buttonid)
   440 void HbInputVkbWidget::mappedKeyRelease(int buttonid)
   485 {
   441 {
   486     Q_D(HbInputVkbWidget);
   442     Q_D(HbInputVkbWidget);
   487     d->handleStandardButtonRelease(buttonid);
   443     d->handleStandardButtonRelease(buttonid);
   570         d->mKeymap = keymap;
   526         d->mKeymap = keymap;
   571     }
   527     }
   572 }
   528 }
   573 
   529 
   574 /*!
   530 /*!
   575 This is called right before the keypad is about to open. This gives inheriting classes opportunity
   531 \reimp
   576 to do whatever initialization they need to do at this point.
       
   577 */
   532 */
   578 void HbInputVkbWidget::aboutToOpen(HbVkbHost *host)
   533 void HbInputVkbWidget::aboutToOpen(HbVkbHost *host)
   579 {
   534 {
   580     Q_D(HbInputVkbWidget);
   535     Q_D(HbInputVkbWidget);
   581 
   536 
   592 
   547 
   593         setLayout(d->mLayout);
   548         setLayout(d->mLayout);
   594 
   549 
   595         d->mCloseHandle = new QGraphicsWidget();
   550         d->mCloseHandle = new QGraphicsWidget();
   596         d->mCloseHandle->setObjectName("vkbHandle");
   551         d->mCloseHandle->setObjectName("vkbHandle");
   597         d->mCloseHandleHeight = HbCloseHandleHeight;
   552         d->mCloseHandleHeight = (int)HbCloseHandleHeight;
   598         d->mCloseHandle->setMinimumHeight(d->mCloseHandleHeight);
   553         d->mCloseHandle->setMinimumHeight(d->mCloseHandleHeight);
   599         d->mCloseHandle->setMaximumHeight(d->mCloseHandleHeight);
   554         d->mCloseHandle->setMaximumHeight(d->mCloseHandleHeight);
   600 
   555 
   601         d->mLayout->addItem(d->mCloseHandle);
   556         d->mLayout->addItem(d->mCloseHandle);
   602         d->mLayout->addItem(keypadLayout());
   557         d->mLayout->addItem(keypadLayout());
   611 
   566 
   612     show();
   567     show();
   613 }
   568 }
   614 
   569 
   615 /*!
   570 /*!
   616 This is called right before the keypad is about to close.
   571 \reimp
   617 */
   572 */
   618 void HbInputVkbWidget::aboutToClose(HbVkbHost *host)
   573 void HbInputVkbWidget::aboutToClose(HbVkbHost *host)
   619 {
   574 {
   620     Q_D(HbInputVkbWidget);
   575     Q_D(HbInputVkbWidget);
   621 
   576 
   660     d->mSettingsListOpen = true;
   615     d->mSettingsListOpen = true;
   661     d->captureScreenshot();
   616     d->captureScreenshot();
   662 
   617 
   663     if (!d->mSettingList) {
   618     if (!d->mSettingList) {
   664         d->mSettingList = new HbInputSettingList();
   619         d->mSettingList = new HbInputSettingList();
   665         connect(d->mSettingList, SIGNAL(aboutToClose()), this, SLOT(settingsClosed()));
   620         connect(d->mSettingList, SIGNAL(inputSettingsButtonClicked()), this, SLOT(showSettingsView()));
   666         connect(d->mSettingList, SIGNAL(inputSettingsButtonClicked()), this, SLOT(executeSettingsDialog()));
       
   667         connect(d->mSettingList, SIGNAL(inputMethodsButtonClicked()), this, SLOT(executeMethodDialog()));
   621         connect(d->mSettingList, SIGNAL(inputMethodsButtonClicked()), this, SLOT(executeMethodDialog()));
   668     }
   622     }
   669 
   623 
   670 #if QT_VERSION >= 0x040600
       
   671     HbInputFocusObject *focusObject = d->mOwner->focusObject();
   624     HbInputFocusObject *focusObject = d->mOwner->focusObject();
   672     if (focusObject &&
   625     if (focusObject &&
   673         focusObject->editorInterface().isPredictionAllowed() &&
   626         focusObject->editorInterface().isPredictionAllowed() &&
   674         !focusObject->editorInterface().isNumericEditor() &&
       
   675         predFactory->predictionEngineForLanguage(HbInputSettingProxy::instance()->globalInputLanguage())) {
   627         predFactory->predictionEngineForLanguage(HbInputSettingProxy::instance()->globalInputLanguage())) {
   676         d->mSettingList->setPredictionSelectionEnabled(true);
   628         d->mSettingList->setPredictionSelectionEnabled(true);
   677     } else {
   629     } else {
   678         d->mSettingList->setPredictionSelectionEnabled(false);
   630         d->mSettingList->setPredictionSelectionEnabled(false);
   679     }
   631     }
   680 #endif
       
   681 
   632 
   682     d->mSettingsButton->setBackgroundAttributes(HbTouchKeypadButton::HbTouchButtonLatched);
   633     d->mSettingsButton->setBackgroundAttributes(HbTouchKeypadButton::HbTouchButtonLatched);
   683     qreal x = d->mSettingsButton->scenePos().x() + d->mSettingsButton->rect().width();
   634     qreal x = d->mSettingsButton->scenePos().x() + d->mSettingsButton->rect().width();
   684     qreal y = d->mSettingsButton->scenePos().y();
   635     qreal y = d->mSettingsButton->scenePos().y();
   685     d->mSettingList->setPreferredPos(QPointF(x, y), HbPopup::BottomRightCorner);
   636     d->mSettingList->setPreferredPos(QPointF(x, y), HbPopup::BottomRightCorner);
   686     d->mSettingList->showSettingList();
   637     d->mSettingList->updateSettingList();
       
   638     d->mSettingList->open(this, SLOT(settingsClosed()));
       
   639 }
       
   640 
       
   641 /*!
       
   642 Slot which is called when settings list is closed.
       
   643 */
       
   644 void HbInputVkbWidget::settingsClosed()
       
   645 {
       
   646     Q_D(HbInputVkbWidget);
       
   647 
       
   648     d->mSettingsButton->setBackgroundAttributes(HbTouchKeypadButton::HbTouchButtonReleased);
       
   649 
   687     d->mSettingsListOpen = false;
   650     d->mSettingsListOpen = false;
   688     if ( d->mAnimateWhenDialogCloses ) {
   651     if ( d->mAnimateWhenDialogCloses ) {
   689         animKeyboardChange();
   652         animKeyboardChange();
   690         d->mAnimateWhenDialogCloses = false;
   653         d->mAnimateWhenDialogCloses = false;
   691     } else if(d->mScreenshotTimeLine.state() != QTimeLine::Running) {
   654     } else if(d->mScreenshotTimeLine.state() != QTimeLine::Running) {
   692         keypadLanguageChangeFinished();
   655         keypadLanguageChangeFinished();
   693     }
   656     }
   694 }
   657 }
   695 
   658 
   696 /*!
   659 /*!
   697 Slot to connect aboutToClose of settings list to update keyboard graphics.
       
   698 */
       
   699 void HbInputVkbWidget::settingsClosed()
       
   700 {
       
   701     Q_D(HbInputVkbWidget);
       
   702     d->mSettingsButton->setBackgroundAttributes(HbTouchKeypadButton::HbTouchButtonReleased);
       
   703 }
       
   704 
       
   705 /*!
       
   706 Closes settings list
   660 Closes settings list
   707 */
   661 */
   708 void HbInputVkbWidget::closeSettingList()
   662 void HbInputVkbWidget::closeSettingList()
   709 {
   663 {
   710     Q_D(HbInputVkbWidget);
   664     Q_D(HbInputVkbWidget);
   711     d->mSettingList->close();
   665     d->mSettingList->close();
   712     d->mSettingsButton->setBackgroundAttributes(HbTouchKeypadButton::HbTouchButtonReleased);
   666     d->mSettingsButton->setBackgroundAttributes(HbTouchKeypadButton::HbTouchButtonReleased);
   713 }
   667 }
   714 
   668 
   715 /*!
   669 /*!
   716 Toggles prediction status.
   670 \deprecated HbInputVkbWidget::togglePredictionStatus()
       
   671     is deprecated.
   717 */
   672 */
   718 void HbInputVkbWidget::togglePredictionStatus()
   673 void HbInputVkbWidget::togglePredictionStatus()
   719 {
   674 {
   720     closeSettingList();
   675     closeSettingList();
   721     bool predictionStatus = HbInputSettingProxy::instance()->predictiveInputStatus();
   676     HbInputSettingProxy::instance()->togglePrediction();
   722     HbInputSettingProxy::instance()->setPredictiveInputStatus(!predictionStatus);
       
   723     update();
   677     update();
   724 }
   678 }
   725 
   679 
   726 /*!
   680 /*!
   727 Executes settingsDialog
   681 \deprecated HbInputVkbWidget::executeSettingsDialog()
       
   682     is deprecated. Use showSettingsView instead.
   728 */
   683 */
   729 void HbInputVkbWidget::executeSettingsDialog()
   684 void HbInputVkbWidget::executeSettingsDialog()
   730 {
   685 {
       
   686 }
       
   687 
       
   688 /*!
       
   689 Shows settings view
       
   690 */
       
   691 void HbInputVkbWidget::showSettingsView()
       
   692 {
   731     Q_D(HbInputVkbWidget);
   693     Q_D(HbInputVkbWidget);
   732 
   694 
   733     closeSettingList();
   695     closeSettingList();
   734     HbInputSettingDialog::HbSettingItems items = HbInputSettingDialog::HbSettingItemAll;
   696 
   735     if (d->mOwner->focusObject()->editorInterface().isNumericEditor()) {
   697     d->mSettingView = new HbView(this);
   736         items &=  (~HbInputSettingDialog::HbSettingItemPrediction);
   698     d->mSettingView->setTitle(tr("Input Settings"));
   737     }
   699     mainWindow()->addView(d->mSettingView);
   738     HbInputSettingDialog* settings = new HbInputSettingDialog(items);
   700 
   739     d->mSettingsListOpen = true;
   701     HbAction *backAction = new HbAction(Hb::BackNaviAction, d->mSettingView);
   740     settings->exec();
   702     backAction->setText(tr("Back"));
   741     delete settings;
   703     connect(backAction, SIGNAL(triggered(bool)), this, SLOT(closeSettingsView()));
   742     d->mSettingsListOpen = false;
   704     d->mSettingView->setNavigationAction(backAction);
   743     if ( d->mAnimateWhenDialogCloses ) {
   705 
   744         animKeyboardChange();
   706     HbDataForm *dataForm = new HbDataForm();
   745         d->mAnimateWhenDialogCloses = false;
   707     d->mSettingView->setWidget(dataForm);
   746     } else {
   708     HbInputSettingWidget *settingWidget = new HbInputSettingWidget(dataForm, d->mSettingView);
   747         keypadLanguageChangeFinished();
   709     settingWidget->initializeWidget();
   748     }
   710 
       
   711     d->mCurrentView = mainWindow()->currentView();
       
   712     mainWindow()->setCurrentView(d->mSettingView);
       
   713 }
       
   714 
       
   715 /*!
       
   716 Closes settings view and returns to previous view
       
   717 */
       
   718 void HbInputVkbWidget::closeSettingsView()
       
   719 {
       
   720     Q_D(HbInputVkbWidget);
       
   721 
       
   722     mainWindow()->setCurrentView(d->mCurrentView);
       
   723     mainWindow()->removeView(d->mSettingView);
       
   724     delete d->mSettingView;
       
   725     d->mSettingView = 0;
   749 }
   726 }
   750 
   727 
   751 /*!
   728 /*!
   752 Executes input method selection dialog
   729 Executes input method selection dialog
   753 */
   730 */
   762         d->mOwner->activateInputMethod(method);
   739         d->mOwner->activateInputMethod(method);
   763     }
   740     }
   764 }
   741 }
   765 
   742 
   766 /*!
   743 /*!
   767 Virtual function, each derived keypads should calculate and provide the
   744 \deprecated HbInputVkbWidget::keypadLayout()
   768 layout information through this functions. This layout information is used
   745     is deprecated.
   769 by HbInputVkbWidget for layouting different components of vkb.
       
   770 */
   746 */
   771 QGraphicsLayout *HbInputVkbWidget::keypadLayout()
   747 QGraphicsLayout *HbInputVkbWidget::keypadLayout()
   772 {
   748 {
   773     Q_D(HbInputVkbWidget);
   749     Q_D(HbInputVkbWidget);
   774     return d->mButtonLayout;
   750     return d->mButtonLayout;
   775 }
   751 }
   776 
   752 
   777 /*!
   753 /*!
   778 Returns the keypad in QWidget form.
   754 \reimp
   779 */
   755 */
   780 QWidget* HbInputVkbWidget::asWidget()
   756 QWidget* HbInputVkbWidget::asWidget()
   781 {
   757 {
   782     return HbInputUtils::createWrapperWidget(this);
   758     return HbInputUtils::createWrapperWidget(this);
   783 }
   759 }
   784 
   760 
   785 /*!
   761 /*!
   786 Returns the keypad in QGraphicsWidget form.
   762 \reimp
   787 */
   763 */
   788 QGraphicsWidget* HbInputVkbWidget::asGraphicsWidget()
   764 QGraphicsWidget* HbInputVkbWidget::asGraphicsWidget()
   789 {
   765 {
   790     return this;
   766     return this;
   791 }
   767 }
   792 
   768 
   793 /*!
   769 /*!
   794 Returns preferred keyboard size. HbVkbHost uses this information when it opens the keyboard.
   770 \reimp
   795 */
   771 */
   796 QSizeF HbInputVkbWidget::preferredKeyboardSize()
   772 QSizeF HbInputVkbWidget::preferredKeyboardSize()
   797 {
   773 {
   798     Q_D(HbInputVkbWidget);
   774     Q_D(HbInputVkbWidget);
   799 
   775 
   805 
   781 
   806     return QSizeF(0.0, 0.0);
   782     return QSizeF(0.0, 0.0);
   807 }
   783 }
   808 
   784 
   809 /*!
   785 /*!
   810 This method is called every time vkb host draws an opening animation frame.
   786 \reimp
   811 */
   787 */
   812 void HbInputVkbWidget::keyboardAnimationFrame(HbVkbAnimationType type, qreal x)
   788 void HbInputVkbWidget::keyboardAnimationFrame(HbVkbAnimationType type, qreal x)
   813 {
   789 {
   814     Q_UNUSED(type);
   790     Q_UNUSED(type);
   815     Q_UNUSED(x);
   791     Q_UNUSED(x);
   825 {
   801 {
   826     Q_D(HbInputVkbWidget);
   802     Q_D(HbInputVkbWidget);
   827     QSizeF ret = preferredKeyboardSize();
   803     QSizeF ret = preferredKeyboardSize();
   828     if (ret.height() >  d->mCloseHandleHeight) {
   804     if (ret.height() >  d->mCloseHandleHeight) {
   829         ret.setHeight(ret.height() - d->mCloseHandleHeight);
   805         ret.setHeight(ret.height() - d->mCloseHandleHeight);
   830 	}
   806     }
   831 
   807 
   832     return ret;
   808     return ret;
   833 }
   809 }
   834 
   810 
   835 /*!
   811 /*!
   841 void HbInputVkbWidget::setBackgroundDrawing(bool backgroundEnabled)
   817 void HbInputVkbWidget::setBackgroundDrawing(bool backgroundEnabled)
   842 {
   818 {
   843     Q_D(HbInputVkbWidget);
   819     Q_D(HbInputVkbWidget);
   844     d->mDrawbackground = backgroundEnabled;
   820     d->mDrawbackground = backgroundEnabled;
   845 }
   821 }
   846 
       
   847 
   822 
   848 /*!
   823 /*!
   849 Returns all possible keys those the user could have intended to press
   824 Returns all possible keys those the user could have intended to press
   850 for the last registered touch along with their corresponding probability.
   825 for the last registered touch along with their corresponding probability.
   851 One issue of thecurrent API implementation is that it does not always
   826 One issue of thecurrent API implementation is that it does not always
   913     d->normalizeProbabilities(probableKeys);
   888     d->normalizeProbabilities(probableKeys);
   914     return probableKeys;
   889     return probableKeys;
   915 }
   890 }
   916 
   891 
   917 /*!
   892 /*!
   918 Sets up the common buttons in the tool cluster (settings and application buttons).
   893 \deprecated HbInputVkbWidget::setupToolCluster()
       
   894     is deprecated.
   919 */
   895 */
   920 void HbInputVkbWidget::setupToolCluster()
   896 void HbInputVkbWidget::setupToolCluster()
   921 {
   897 {
   922     Q_D(HbInputVkbWidget);
   898     Q_D(HbInputVkbWidget);
   923     if(!d->mOwner || !d->mOwner->focusObject()) {
   899     if(!d->mOwner || !d->mOwner->focusObject()) {
   991             d->mApplicationButton->disconnect(SIGNAL(pressed()));
   967             d->mApplicationButton->disconnect(SIGNAL(pressed()));
   992             d->mApplicationButton->disconnect(SIGNAL(released()));
   968             d->mApplicationButton->disconnect(SIGNAL(released()));
   993             d->mApplicationButton->setText(QString());
   969             d->mApplicationButton->setText(QString());
   994             d->mApplicationButton->setIcon(HbIcon());
   970             d->mApplicationButton->setIcon(HbIcon());
   995             d->mApplicationButton->setToolTip(QString());
   971             d->mApplicationButton->setToolTip(QString());
   996 			d->mApplicationButtonAction = 0;
   972             d->mApplicationButtonAction = 0;
   997         } else {
   973         } else {
   998             d->mApplicationButton = new HbTouchKeypadButton(this, QString());
   974             d->mApplicationButton = new HbTouchKeypadButton(this, QString());
   999             d->mApplicationButton->setButtonType(HbTouchKeypadButton::HbTouchButtonFunction);
   975             d->mApplicationButton->setButtonType(HbTouchKeypadButton::HbTouchButtonFunction);
  1000             d->mApplicationButton->setBackgroundAttributes(HbTouchKeypadButton::HbTouchButtonReleased);
   976             d->mApplicationButton->setBackgroundAttributes(HbTouchKeypadButton::HbTouchButtonReleased);
  1001         }
   977         }
  1002         d->mApplicationButtonAction = NULL;
   978         d->mApplicationButtonAction = 0;
  1003     }
   979     }
  1004 }
   980 }
  1005 
   981 
  1006 /*!
   982 /*!
  1007 shape function actually refines the bounding rect. This function is used for collision detection
   983 Refines the bounding rect. This function is used for collision detection
  1008 and hit test.
   984 and hit test.
  1009 */
   985 */
  1010 QPainterPath HbInputVkbWidget::shape() const
   986 QPainterPath HbInputVkbWidget::shape() const
  1011 {
   987 {
  1012     QRectF rect = boundingRect();
   988     QRectF rect = boundingRect();
  1013     QPainterPath path;
   989     QPainterPath path;
  1014     path.addRect(rect);
   990     path.addRect(rect);
  1015     return path;
   991     return path;
  1016 }
   992 }
  1017 
   993 
       
   994 /*!
       
   995 \reimp
       
   996 */
  1018 QSizeF HbInputVkbWidget::minimizedKeyboardSize()
   997 QSizeF HbInputVkbWidget::minimizedKeyboardSize()
  1019 {
   998 {
  1020     Q_D(HbInputVkbWidget);
   999     Q_D(HbInputVkbWidget);
  1021     return QSizeF(0.0, d->mCloseHandleHeight);
  1000     return QSizeF(0.0, d->mCloseHandleHeight);
  1022 }
  1001 }
  1023 
  1002 
       
  1003 /*!
       
  1004 Shows smiley picker widget.
       
  1005 */
  1024 void HbInputVkbWidget::showSmileyPicker(int rows, int columns)
  1006 void HbInputVkbWidget::showSmileyPicker(int rows, int columns)
  1025 {
  1007 {
  1026     Q_D(HbInputVkbWidget);
  1008     Q_D(HbInputVkbWidget);
  1027     if (!d->mOwner || !d->mOwner->focusObject()) {
  1009     if (!d->mOwner || !d->mOwner->focusObject()) {
  1028         return;
  1010         return;
  1029     }
  1011     }
  1030     // check whether the smiley recognition is enabled 	in the currently focused editor.
  1012     // check whether the smiley recognition is enabled  in the currently focused editor.
  1031     if (!d->isSmileysEnabled()) {
  1013     if (!d->isSmileysEnabled()) {
  1032         return;
  1014         return;
  1033     }
  1015     }
  1034     HbInputFocusObject *focusObject = d->mOwner->focusObject();
  1016     HbInputFocusObject *focusObject = d->mOwner->focusObject();
  1035 	
  1017 
  1036     if (!d->mSmileyPicker || d->mFocusedObject != focusObject) {
  1018     if (!d->mSmileyPicker || d->mFocusedObject != focusObject) {
  1037         d->mFocusedObject = focusObject;
  1019         d->mFocusedObject = focusObject;
  1038         if (d->mSmileyPicker) {
  1020         if (d->mSmileyPicker) {
  1039             delete d->mSmileyPicker;
  1021             delete d->mSmileyPicker;
  1040         }
  1022         }
  1041         // get the smiley list from editor interface smiley theme.
  1023         // get the smiley list from editor interface smiley theme.
  1042         QStringList smileys = focusObject->editorInterface().smileyTheme().smileys();
  1024         QStringList smileys = focusObject->editorInterface().smileyTheme().smileys();
  1043         // if the smiley list is empty and the editor is not a Hb editor, 
       
  1044         // then get the default smiley list from smiley engine.
       
  1045         if (smileys.isEmpty() && !focusObject->editorInterface().editor()->inherits("HbAbstractEdit")) {
       
  1046             HbSmileyEngine smileyEngine;
       
  1047             smileys = smileyEngine.defaultTheme().smileys();
       
  1048         }
       
  1049 
  1025 
  1050         if (!smileys.isEmpty()) {
  1026         if (!smileys.isEmpty()) {
  1051             d->mSmileyPicker = new HbInputSmileyPicker(rows, columns, 0, smileys);
  1027             d->mSmileyPicker = new HbInputSmileyPicker(rows, columns, 0, smileys);
  1052             d->mSmileyPicker->setObjectName("vkbwidget_smiley_picker");
  1028             d->mSmileyPicker->setObjectName("vkbwidget_smiley_picker");
  1053             connect(d->mSmileyPicker, SIGNAL(selected(QString)), this, SIGNAL(smileySelected(QString)));
  1029             connect(d->mSmileyPicker, SIGNAL(selected(QString)), this, SIGNAL(smileySelected(QString)));
  1054         }			
  1030         }
  1055     }
  1031     }
  1056 
  1032 
  1057     if (d->mSmileyPicker) {
  1033     if (d->mSmileyPicker) {
  1058         d->mSmileyPicker->setGeometry(QRectF(0, pos().y(), geometry().width(),
  1034         d->mSmileyPicker->setGeometry(QRectF(0, pos().y(), geometry().width(),
  1059             geometry().height()));
  1035             geometry().height()));
  1060         d->mSmileyPicker->show();
  1036         d->mSmileyPicker->show();
  1061     }		
  1037     }
  1062 }
  1038 }
  1063 
  1039 
       
  1040 /*!
       
  1041 \deprecated HbInputVkbWidget::flickDirection()
       
  1042     is deprecated.
       
  1043 */
  1064 HbInputVkbWidget::HbFlickDirection HbInputVkbWidget::flickDirection()
  1044 HbInputVkbWidget::HbFlickDirection HbInputVkbWidget::flickDirection()
  1065 {
  1045 {
  1066     Q_D(HbInputVkbWidget);
  1046     Q_D(HbInputVkbWidget);
  1067     return d->mFlickDirection;
  1047     return d->mFlickDirection;
  1068 }
  1048 }
  1069 
  1049 
  1070 /*!
  1050 /*!
  1071     Intended for internal use only
  1051 \deprecated HbInputVkbWidget::refreshApplicationButton()
       
  1052     is deprecated.
  1072 */
  1053 */
  1073 void HbInputVkbWidget::refreshApplicationButton()
  1054 void HbInputVkbWidget::refreshApplicationButton()
  1074 {
  1055 {
  1075     Q_D(HbInputVkbWidget);
  1056     Q_D(HbInputVkbWidget);
  1076 
  1057 
  1089         d->mApplicationButton->disconnect(SIGNAL(clicked()));
  1070         d->mApplicationButton->disconnect(SIGNAL(clicked()));
  1090         d->mApplicationButton->setFade(true);
  1071         d->mApplicationButton->setFade(true);
  1091     }
  1072     }
  1092 }
  1073 }
  1093 
  1074 
  1094 void HbInputVkbWidget::keypadLanguageChangeAnimationUpdate(qreal aValue)
  1075 void HbInputVkbWidget::keypadLanguageChangeAnimationUpdate(qreal value)
  1095 {
  1076 {
  1096     Q_D(HbInputVkbWidget);
  1077     Q_D(HbInputVkbWidget);
  1097 
  1078 
  1098     int direction = 1;
  1079     int direction = 1;
  1099     if (flickDirection() == HbFlickDirectionLeft) {
  1080     if (flickDirection() == HbFlickDirectionLeft) {
  1100         direction = -1;
  1081         direction = -1;
  1101     }
  1082     }
  1102 
  1083 
  1103     QRectF rect = boundingRect();
  1084     QRectF rect = boundingRect();
  1104     QPointF position = pos();
  1085     QPointF position = pos();
  1105     position.setX(direction * (-rect.width() + rect.width() * aValue));
  1086     position.setX(direction * (-rect.width() + rect.width() * value));
  1106     if (d->mScreenshotWidget) {
  1087     if (d->mScreenshotWidget) {
  1107        d->mScreenshotWidget->setPos(position.x() + direction * rect.width(), position.y());
  1088        d->mScreenshotWidget->setPos(position.x() + direction * rect.width(), position.y());
  1108        setPos(position);
  1089        setPos(position);
  1109     }
  1090     }
  1110 }
  1091 }
  1111 
  1092 
  1112 void HbInputVkbWidget::keypadLanguageChangeFinished()
  1093 void HbInputVkbWidget::keypadLanguageChangeFinished()
  1113 {
  1094 {
  1114     Q_D(HbInputVkbWidget);
  1095     Q_D(HbInputVkbWidget);
  1115     delete d->mScreenshotWidget;
  1096     delete d->mScreenshotWidget;
  1116     d->mScreenshotWidget = NULL;
  1097     d->mScreenshotWidget = 0;
       
  1098     d->mFlickDirection = HbFlickDirectionNone;
  1117 }
  1099 }
  1118 
  1100 
  1119 void HbInputVkbWidget::animKeyboardChange()
  1101 void HbInputVkbWidget::animKeyboardChange()
  1120 {
  1102 {
  1121     Q_D(HbInputVkbWidget);
  1103     Q_D(HbInputVkbWidget);
  1131             d->mScreenshotTimeLine.start();
  1113             d->mScreenshotTimeLine.start();
  1132         }
  1114         }
  1133     }
  1115     }
  1134 }
  1116 }
  1135 
  1117 
       
  1118 /*!
       
  1119 \reimp
       
  1120 */
  1136 QSizeF HbInputVkbWidget::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const
  1121 QSizeF HbInputVkbWidget::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const
  1137 {
  1122 {
  1138     Q_UNUSED(constraint);
  1123     Q_UNUSED(constraint);
  1139     Q_D(const HbInputVkbWidget);
  1124     Q_D(const HbInputVkbWidget);
  1140 
  1125 
  1157     }
  1142     }
  1158     return sh;
  1143     return sh;
  1159 }
  1144 }
  1160 
  1145 
  1161 /*!
  1146 /*!
  1162     \reimp
  1147 \reimp
  1163  */
  1148  */
  1164 void HbInputVkbWidget::changeEvent(QEvent *event)
  1149 void HbInputVkbWidget::changeEvent(QEvent *event)
  1165 {
  1150 {
  1166     Q_D(HbInputVkbWidget);
  1151     Q_D(HbInputVkbWidget);
  1167     if (event->type() == HbEvent::ThemeChanged) {
  1152     if (event->type() == HbEvent::ThemeChanged) {
  1169         d->mIconDrawer->themeChanged();
  1154         d->mIconDrawer->themeChanged();
  1170     }
  1155     }
  1171     HbWidget::changeEvent(event);
  1156     HbWidget::changeEvent(event);
  1172 }
  1157 }
  1173 
  1158 
       
  1159 /*!
       
  1160 \reimp
       
  1161 */
       
  1162 void HbInputVkbWidget::gestureEvent(QGestureEvent *event)
       
  1163 {
       
  1164     Q_D(HbInputVkbWidget);
       
  1165 
       
  1166     if(HbSwipeGesture *gesture = qobject_cast<HbSwipeGesture *>(event->gesture(Qt::SwipeGesture))) {
       
  1167         if (gesture->state() == Qt::GestureFinished) {
       
  1168             HbWidgetFeedback::triggered(this, Hb::InstantFlicked);
       
  1169             // vertical swipes
       
  1170             if (gesture->sceneSwipeAngle() > 250 && gesture->sceneSwipeAngle() < 290 &&
       
  1171                     gesture->sceneVerticalDirection() == QSwipeGesture::Down) {
       
  1172                 d->mFlickDirection = HbFlickDirectionDown;
       
  1173                 emit keypadCloseEventDetected(HbVkbCloseMethodCloseGesture);
       
  1174             } else if (gesture->sceneSwipeAngle() > 70 && gesture->sceneSwipeAngle() < 110 &&
       
  1175                            gesture->sceneVerticalDirection() == QSwipeGesture::Up) {
       
  1176                 d->mFlickDirection = HbFlickDirectionUp;
       
  1177                 d->mCurrentHost->openKeypad(d->mCurrentHost->activeKeypad(), d->mOwner);
       
  1178             } else {
       
  1179                 d->mFlickDirection = (HbInputVkbWidget::HbFlickDirection)gesture->sceneHorizontalDirection();
       
  1180                 // horizontal swipes
       
  1181                 if (d->mFlickAnimation){
       
  1182                     animKeyboardChange();
       
  1183                 }
       
  1184                 emit flickEvent(d->mFlickDirection);
       
  1185             }
       
  1186         }
       
  1187     } else if(HbTapGesture *gesture = qobject_cast<HbTapGesture *>(event->gesture(Qt::TapGesture))) {
       
  1188         if (gesture->state() == Qt::GestureFinished) {        
       
  1189             // if keypad is minimized, open it 
       
  1190             if ( d->mCurrentHost->keypadStatus() == HbVkbHost::HbVkbStatusMinimized ) {
       
  1191                 d->mCurrentHost->openKeypad(this, d->mOwner);
       
  1192             }
       
  1193         }
       
  1194     }
       
  1195 }
       
  1196 
  1174 // End of file
  1197 // End of file