--- a/homescreenapp/stateplugins/hshomescreenstateplugin/src/hsidlestate.cpp Wed Aug 18 10:33:57 2010 +0300
+++ b/homescreenapp/stateplugins/hshomescreenstateplugin/src/hsidlestate.cpp Mon Sep 13 13:03:23 2010 +0300
@@ -20,17 +20,21 @@
#include <QPropertyAnimation>
#include <QApplication>
#include <QVariantHash>
+#include <QInputContext>
#include <HbMainWindow>
#include <HbView>
#include <HbMenu>
#include <HbAction>
#include <HbMessageBox>
+#include <HbInstance>
#include <HbLabel>
#include <HbInstantFeedback>
#include <HbContinuousFeedback>
#include <HbPanGesture>
#include <HbTapAndHoldGesture>
+#include <HbVkbHostBridge>
+#include <HbInputFocusObject>
#ifdef Q_OS_SYMBIAN
#include <XQSettingsManager>
@@ -292,11 +296,13 @@
ENTRY_ACTION(state_moveWidget, action_moveWidget_reparentToControlLayer)
ENTRY_ACTION(state_moveWidget, action_moveWidget_startWidgetDragEffect)
ENTRY_ACTION(state_moveWidget, action_moveWidget_connectGestureHandlers)
+ ENTRY_ACTION(state_moveWidget, action_moveWidget_connectOrientationChangeEventHandler)
ENTRY_ACTION(state_moveWidget, action_moveWidget_setWidgetSnap)
EXIT_ACTION(state_moveWidget, action_moveWidget_reparentToPage)
EXIT_ACTION(state_moveWidget, action_moveWidget_startWidgetDropEffect)
EXIT_ACTION(state_moveWidget, action_moveWidget_disconnectGestureHandlers)
+ EXIT_ACTION(state_moveWidget, action_moveWidget_disconnectOrientationChangeEventHandler)
EXIT_ACTION(state_moveWidget, action_moveWidget_preventZoneAnimation)
EXIT_ACTION(state_moveWidget, action_moveWidget_deleteWidgetSnap)
@@ -329,6 +335,7 @@
*/
void HsIdleState::startPageChangeAnimation(int targetPageIndex, int duration)
{
+ hbInstance->allMainWindows().first()->setInteractive(false);
HsPropertyAnimationWrapper *animation = HsGui::instance()->pageChangeAnimation();
if (animation->isRunning()) {
animation->stop();
@@ -605,12 +612,16 @@
emit event_waitInput();
}
-void HsIdleState::onWidgetTapStarted(HsWidgetHost *widget)
+void HsIdleState::onWidgetTapStarted(QPointF point, HsWidgetHost *widget)
{
HsScene *scene = HsScene::instance();
scene->setActiveWidget(widget);
HsPage *page = scene->activePage();
QMetaObject::invokeMethod(page, "updateZValues", Qt::QueuedConnection);
+ HbVkbHost::HbVkbStatus status = HbVkbHostBridge::instance()->keypadStatus();
+ if ( status == HbVkbHost::HbVkbStatusOpened && !isEditor(point, widget) ) {
+ closeVirtualKeyboard();
+ }
}
void HsIdleState::onWidgetTapAndHoldFinished(QGestureEvent *event, HsWidgetHost *widget)
@@ -872,6 +883,15 @@
HsScene *scene = HsScene::instance();
connect(scene,
+ SIGNAL(pageTapFinished(QGestureEvent*)),
+ SLOT(closeVirtualKeyboard()),
+ Qt::UniqueConnection);
+ connect(scene,
+ SIGNAL(pagePanStarted(QGestureEvent*)),
+ SLOT(closeVirtualKeyboard()),
+ Qt::UniqueConnection);
+
+ connect(scene,
SIGNAL(pageTapAndHoldFinished(QGestureEvent*)),
SLOT(onPageTapAndHoldFinished(QGestureEvent*)),
Qt::UniqueConnection);
@@ -882,8 +902,8 @@
Qt::UniqueConnection);
connect(scene,
- SIGNAL(widgetTapStarted(HsWidgetHost*)),
- SLOT(onWidgetTapStarted(HsWidgetHost*)),
+ SIGNAL(widgetTapStarted(QPointF, HsWidgetHost*)),
+ SLOT(onWidgetTapStarted(QPointF, HsWidgetHost*)),
Qt::UniqueConnection);
connect(scene,
@@ -929,6 +949,8 @@
mAllowZoneAnimation = true;
}
+/*!
+*/
void HsIdleState::action_moveWidget_connectGestureHandlers()
{
HsScene *scene = HsScene::instance();
@@ -945,6 +967,17 @@
}
/*!
+ Connects the SIGNAL for changing the orientation for moveWidget state
+ to update the snapping algorithm accordingly.
+*/
+void HsIdleState::action_moveWidget_connectOrientationChangeEventHandler()
+{
+ connect(HsGui::instance(),
+ SIGNAL(orientationChanged(Qt::Orientation)),
+ SLOT(updateSnapAlgorithmParameters()));
+}
+
+/*!
Initializes the presentation to the snapping algorithm
Connects the SIGNAL for changing the presentation on active page changed
Connects the timer for showing the snap lines
@@ -962,7 +995,7 @@
updatePagePresentationToWidgetSnap();
connect(HsScene::instance(), SIGNAL(activePageChanged()),
- SLOT(onActivePageChanged()));
+ SLOT(updateSnapAlgorithmParameters()));
if (HSCONFIGURATION_GET(isSnapEffectsEnabled)) {
mVerticalSnapLineTimer.setInterval(HSCONFIGURATION_GET(snapTimeout));
@@ -1065,6 +1098,9 @@
}
}
+/*!
+ Disconnects gesture handlers
+*/
void HsIdleState::action_moveWidget_disconnectGestureHandlers()
{
HsScene *scene = HsScene::instance();
@@ -1072,6 +1108,17 @@
}
/*!
+ Disconnects orientation change on moveWidget state
+*/
+void HsIdleState::action_moveWidget_disconnectOrientationChangeEventHandler()
+{
+ disconnect(HsGui::instance(),
+ SIGNAL(orientationChanged(Qt::Orientation)),
+ this, SLOT(updateSnapAlgorithmParameters()));
+
+}
+
+/*!
Resets the snap position
Disconnect the Active Page Changed SIGNAL
Disconnects the timers to show snap lines
@@ -1082,7 +1129,7 @@
resetSnapPosition();
disconnect(HsScene::instance(), SIGNAL(activePageChanged()),
- this, SLOT(onActivePageChanged()));
+ this, SLOT(updateSnapAlgorithmParameters()));
if (HSCONFIGURATION_GET(isSnapEffectsEnabled)) {
disconnect(&mVerticalSnapLineTimer, SIGNAL(timeout()),
@@ -1323,6 +1370,7 @@
*/
void HsIdleState::pageChangeAnimationFinished()
{
+ hbInstance->allMainWindows().first()->setInteractive(true);
updateZoneAnimation();
}
@@ -1422,10 +1470,45 @@
/*!
Handles updating the Snap algorithm with page presentation on page change
*/
-void HsIdleState::onActivePageChanged()
+void HsIdleState::updateSnapAlgorithmParameters()
{
updatePagePresentationToWidgetSnap();
resetSnapPosition();
}
+/*!
+ Closes virtual keyboard
+*/
+void HsIdleState::closeVirtualKeyboard()
+{
+ HbVkbHost::HbVkbStatus status = HbVkbHostBridge::instance()->keypadStatus();
+ if (status == HbVkbHost::HbVkbStatusOpened ) {
+ QInputContext *ic = qApp->inputContext();
+ if (ic) {
+ QEvent *event = new QEvent(QEvent::CloseSoftwareInputPanel);
+ ic->filterEvent(event);
+ delete event;
+ }
+ }
+}
+/*!
+ Returns true if \a widget has editor field under \a point.
+*/
+bool HsIdleState::isEditor(const QPointF &point, HsWidgetHost *widget)
+{
+ bool isWidgetEditor = false;
+ QList<QGraphicsItem *> items;
+ if ( widget->visual()->scene() ) {
+ items = widget->visual()->scene()->items(point);
+ }
+ int count = items.count();
+ for (int i=0; i<count && !isWidgetEditor; i++ ) {
+ QGraphicsItem *item = items.at(i);
+ if (item->isWidget()) {
+ isWidgetEditor = HbInputFocusObject::isEditor(item->toGraphicsObject()) &&
+ qobject_cast<QGraphicsWidget *>(widget->visual()->widget())->isAncestorOf(item);
+ }
+ }
+ return isWidgetEditor;
+}