18 #include <QStateMachine> |
18 #include <QStateMachine> |
19 #include <QGraphicsSceneMouseEvent> |
19 #include <QGraphicsSceneMouseEvent> |
20 #include <QPropertyAnimation> |
20 #include <QPropertyAnimation> |
21 #include <QApplication> |
21 #include <QApplication> |
22 #include <QVariantHash> |
22 #include <QVariantHash> |
|
23 #include <QInputContext> |
23 |
24 |
24 #include <HbMainWindow> |
25 #include <HbMainWindow> |
25 #include <HbView> |
26 #include <HbView> |
26 #include <HbMenu> |
27 #include <HbMenu> |
27 #include <HbAction> |
28 #include <HbAction> |
28 #include <HbMessageBox> |
29 #include <HbMessageBox> |
|
30 #include <HbInstance> |
29 #include <HbLabel> |
31 #include <HbLabel> |
30 #include <HbInstantFeedback> |
32 #include <HbInstantFeedback> |
31 #include <HbContinuousFeedback> |
33 #include <HbContinuousFeedback> |
32 #include <HbPanGesture> |
34 #include <HbPanGesture> |
33 #include <HbTapAndHoldGesture> |
35 #include <HbTapAndHoldGesture> |
|
36 #include <HbVkbHostBridge> |
|
37 #include <HbInputFocusObject> |
34 |
38 |
35 #ifdef Q_OS_SYMBIAN |
39 #ifdef Q_OS_SYMBIAN |
36 #include <XQSettingsManager> |
40 #include <XQSettingsManager> |
37 #include <startupdomainpskeys.h> |
41 #include <startupdomainpskeys.h> |
38 #endif |
42 #endif |
290 EXIT_ACTION(state_waitInput, action_waitInput_resetNewWidgets) |
294 EXIT_ACTION(state_waitInput, action_waitInput_resetNewWidgets) |
291 |
295 |
292 ENTRY_ACTION(state_moveWidget, action_moveWidget_reparentToControlLayer) |
296 ENTRY_ACTION(state_moveWidget, action_moveWidget_reparentToControlLayer) |
293 ENTRY_ACTION(state_moveWidget, action_moveWidget_startWidgetDragEffect) |
297 ENTRY_ACTION(state_moveWidget, action_moveWidget_startWidgetDragEffect) |
294 ENTRY_ACTION(state_moveWidget, action_moveWidget_connectGestureHandlers) |
298 ENTRY_ACTION(state_moveWidget, action_moveWidget_connectGestureHandlers) |
|
299 ENTRY_ACTION(state_moveWidget, action_moveWidget_connectOrientationChangeEventHandler) |
295 ENTRY_ACTION(state_moveWidget, action_moveWidget_setWidgetSnap) |
300 ENTRY_ACTION(state_moveWidget, action_moveWidget_setWidgetSnap) |
296 |
301 |
297 EXIT_ACTION(state_moveWidget, action_moveWidget_reparentToPage) |
302 EXIT_ACTION(state_moveWidget, action_moveWidget_reparentToPage) |
298 EXIT_ACTION(state_moveWidget, action_moveWidget_startWidgetDropEffect) |
303 EXIT_ACTION(state_moveWidget, action_moveWidget_startWidgetDropEffect) |
299 EXIT_ACTION(state_moveWidget, action_moveWidget_disconnectGestureHandlers) |
304 EXIT_ACTION(state_moveWidget, action_moveWidget_disconnectGestureHandlers) |
|
305 EXIT_ACTION(state_moveWidget, action_moveWidget_disconnectOrientationChangeEventHandler) |
300 EXIT_ACTION(state_moveWidget, action_moveWidget_preventZoneAnimation) |
306 EXIT_ACTION(state_moveWidget, action_moveWidget_preventZoneAnimation) |
301 EXIT_ACTION(state_moveWidget, action_moveWidget_deleteWidgetSnap) |
307 EXIT_ACTION(state_moveWidget, action_moveWidget_deleteWidgetSnap) |
302 |
308 |
303 ENTRY_ACTION(state_moveScene, action_moveScene_connectGestureHandlers) |
309 ENTRY_ACTION(state_moveScene, action_moveScene_connectGestureHandlers) |
304 EXIT_ACTION(state_moveScene, action_moveScene_moveToNearestPage) |
310 EXIT_ACTION(state_moveScene, action_moveScene_moveToNearestPage) |
327 Starts the page change animation based on the given \a targetPageIndex |
333 Starts the page change animation based on the given \a targetPageIndex |
328 and \a duration. |
334 and \a duration. |
329 */ |
335 */ |
330 void HsIdleState::startPageChangeAnimation(int targetPageIndex, int duration) |
336 void HsIdleState::startPageChangeAnimation(int targetPageIndex, int duration) |
331 { |
337 { |
|
338 hbInstance->allMainWindows().first()->setInteractive(false); |
332 HsPropertyAnimationWrapper *animation = HsGui::instance()->pageChangeAnimation(); |
339 HsPropertyAnimationWrapper *animation = HsGui::instance()->pageChangeAnimation(); |
333 if (animation->isRunning()) { |
340 if (animation->isRunning()) { |
334 animation->stop(); |
341 animation->stop(); |
335 } |
342 } |
336 animation->disconnect(this); |
343 animation->disconnect(this); |
603 event->gesture(Qt::PanGesture)); |
610 event->gesture(Qt::PanGesture)); |
604 mDeltaX = gesture->sceneOffset().x(); |
611 mDeltaX = gesture->sceneOffset().x(); |
605 emit event_waitInput(); |
612 emit event_waitInput(); |
606 } |
613 } |
607 |
614 |
608 void HsIdleState::onWidgetTapStarted(HsWidgetHost *widget) |
615 void HsIdleState::onWidgetTapStarted(QPointF point, HsWidgetHost *widget) |
609 { |
616 { |
610 HsScene *scene = HsScene::instance(); |
617 HsScene *scene = HsScene::instance(); |
611 scene->setActiveWidget(widget); |
618 scene->setActiveWidget(widget); |
612 HsPage *page = scene->activePage(); |
619 HsPage *page = scene->activePage(); |
613 QMetaObject::invokeMethod(page, "updateZValues", Qt::QueuedConnection); |
620 QMetaObject::invokeMethod(page, "updateZValues", Qt::QueuedConnection); |
|
621 HbVkbHost::HbVkbStatus status = HbVkbHostBridge::instance()->keypadStatus(); |
|
622 if ( status == HbVkbHost::HbVkbStatusOpened && !isEditor(point, widget) ) { |
|
623 closeVirtualKeyboard(); |
|
624 } |
614 } |
625 } |
615 |
626 |
616 void HsIdleState::onWidgetTapAndHoldFinished(QGestureEvent *event, HsWidgetHost *widget) |
627 void HsIdleState::onWidgetTapAndHoldFinished(QGestureEvent *event, HsWidgetHost *widget) |
617 { |
628 { |
618 HsScene *scene = HsScene::instance(); |
629 HsScene *scene = HsScene::instance(); |
870 void HsIdleState::action_waitInput_connectGestureHandlers() |
881 void HsIdleState::action_waitInput_connectGestureHandlers() |
871 { |
882 { |
872 HsScene *scene = HsScene::instance(); |
883 HsScene *scene = HsScene::instance(); |
873 |
884 |
874 connect(scene, |
885 connect(scene, |
|
886 SIGNAL(pageTapFinished(QGestureEvent*)), |
|
887 SLOT(closeVirtualKeyboard()), |
|
888 Qt::UniqueConnection); |
|
889 connect(scene, |
|
890 SIGNAL(pagePanStarted(QGestureEvent*)), |
|
891 SLOT(closeVirtualKeyboard()), |
|
892 Qt::UniqueConnection); |
|
893 |
|
894 connect(scene, |
875 SIGNAL(pageTapAndHoldFinished(QGestureEvent*)), |
895 SIGNAL(pageTapAndHoldFinished(QGestureEvent*)), |
876 SLOT(onPageTapAndHoldFinished(QGestureEvent*)), |
896 SLOT(onPageTapAndHoldFinished(QGestureEvent*)), |
877 Qt::UniqueConnection); |
897 Qt::UniqueConnection); |
878 |
898 |
879 connect(scene, |
899 connect(scene, |
880 SIGNAL(pagePanStarted(QGestureEvent*)), |
900 SIGNAL(pagePanStarted(QGestureEvent*)), |
881 SLOT(onPagePanStarted(QGestureEvent*)), |
901 SLOT(onPagePanStarted(QGestureEvent*)), |
882 Qt::UniqueConnection); |
902 Qt::UniqueConnection); |
883 |
903 |
884 connect(scene, |
904 connect(scene, |
885 SIGNAL(widgetTapStarted(HsWidgetHost*)), |
905 SIGNAL(widgetTapStarted(QPointF, HsWidgetHost*)), |
886 SLOT(onWidgetTapStarted(HsWidgetHost*)), |
906 SLOT(onWidgetTapStarted(QPointF, HsWidgetHost*)), |
887 Qt::UniqueConnection); |
907 Qt::UniqueConnection); |
888 |
908 |
889 connect(scene, |
909 connect(scene, |
890 SIGNAL(widgetTapAndHoldFinished(QGestureEvent*,HsWidgetHost*)), |
910 SIGNAL(widgetTapAndHoldFinished(QGestureEvent*,HsWidgetHost*)), |
891 SLOT(onWidgetTapAndHoldFinished(QGestureEvent*,HsWidgetHost*)), |
911 SLOT(onWidgetTapAndHoldFinished(QGestureEvent*,HsWidgetHost*)), |
943 SLOT(onWidgetMoveFinished(const QPointF&,HsWidgetHost*)), |
965 SLOT(onWidgetMoveFinished(const QPointF&,HsWidgetHost*)), |
944 Qt::UniqueConnection); |
966 Qt::UniqueConnection); |
945 } |
967 } |
946 |
968 |
947 /*! |
969 /*! |
|
970 Connects the SIGNAL for changing the orientation for moveWidget state |
|
971 to update the snapping algorithm accordingly. |
|
972 */ |
|
973 void HsIdleState::action_moveWidget_connectOrientationChangeEventHandler() |
|
974 { |
|
975 connect(HsGui::instance(), |
|
976 SIGNAL(orientationChanged(Qt::Orientation)), |
|
977 SLOT(updateSnapAlgorithmParameters())); |
|
978 } |
|
979 |
|
980 /*! |
948 Initializes the presentation to the snapping algorithm |
981 Initializes the presentation to the snapping algorithm |
949 Connects the SIGNAL for changing the presentation on active page changed |
982 Connects the SIGNAL for changing the presentation on active page changed |
950 Connects the timer for showing the snap lines |
983 Connects the timer for showing the snap lines |
951 */ |
984 */ |
952 void HsIdleState::action_moveWidget_setWidgetSnap() |
985 void HsIdleState::action_moveWidget_setWidgetSnap() |
960 HsWidgetPositioningOnWidgetMove::instance()->setConfiguration(snapConfiguration); |
993 HsWidgetPositioningOnWidgetMove::instance()->setConfiguration(snapConfiguration); |
961 |
994 |
962 updatePagePresentationToWidgetSnap(); |
995 updatePagePresentationToWidgetSnap(); |
963 |
996 |
964 connect(HsScene::instance(), SIGNAL(activePageChanged()), |
997 connect(HsScene::instance(), SIGNAL(activePageChanged()), |
965 SLOT(onActivePageChanged())); |
998 SLOT(updateSnapAlgorithmParameters())); |
966 |
999 |
967 if (HSCONFIGURATION_GET(isSnapEffectsEnabled)) { |
1000 if (HSCONFIGURATION_GET(isSnapEffectsEnabled)) { |
968 mVerticalSnapLineTimer.setInterval(HSCONFIGURATION_GET(snapTimeout)); |
1001 mVerticalSnapLineTimer.setInterval(HSCONFIGURATION_GET(snapTimeout)); |
969 mHorizontalSnapLineTimer.setInterval(HSCONFIGURATION_GET(snapTimeout)); |
1002 mHorizontalSnapLineTimer.setInterval(HSCONFIGURATION_GET(snapTimeout)); |
970 |
1003 |
1063 if (widget) { |
1096 if (widget) { |
1064 widget->startDropEffect(); |
1097 widget->startDropEffect(); |
1065 } |
1098 } |
1066 } |
1099 } |
1067 |
1100 |
|
1101 /*! |
|
1102 Disconnects gesture handlers |
|
1103 */ |
1068 void HsIdleState::action_moveWidget_disconnectGestureHandlers() |
1104 void HsIdleState::action_moveWidget_disconnectGestureHandlers() |
1069 { |
1105 { |
1070 HsScene *scene = HsScene::instance(); |
1106 HsScene *scene = HsScene::instance(); |
1071 scene->disconnect(this); |
1107 scene->disconnect(this); |
|
1108 } |
|
1109 |
|
1110 /*! |
|
1111 Disconnects orientation change on moveWidget state |
|
1112 */ |
|
1113 void HsIdleState::action_moveWidget_disconnectOrientationChangeEventHandler() |
|
1114 { |
|
1115 disconnect(HsGui::instance(), |
|
1116 SIGNAL(orientationChanged(Qt::Orientation)), |
|
1117 this, SLOT(updateSnapAlgorithmParameters())); |
|
1118 |
1072 } |
1119 } |
1073 |
1120 |
1074 /*! |
1121 /*! |
1075 Resets the snap position |
1122 Resets the snap position |
1076 Disconnect the Active Page Changed SIGNAL |
1123 Disconnect the Active Page Changed SIGNAL |
1080 { |
1127 { |
1081 if (HSCONFIGURATION_GET(isSnapEnabled)) { |
1128 if (HSCONFIGURATION_GET(isSnapEnabled)) { |
1082 resetSnapPosition(); |
1129 resetSnapPosition(); |
1083 |
1130 |
1084 disconnect(HsScene::instance(), SIGNAL(activePageChanged()), |
1131 disconnect(HsScene::instance(), SIGNAL(activePageChanged()), |
1085 this, SLOT(onActivePageChanged())); |
1132 this, SLOT(updateSnapAlgorithmParameters())); |
1086 |
1133 |
1087 if (HSCONFIGURATION_GET(isSnapEffectsEnabled)) { |
1134 if (HSCONFIGURATION_GET(isSnapEffectsEnabled)) { |
1088 disconnect(&mVerticalSnapLineTimer, SIGNAL(timeout()), |
1135 disconnect(&mVerticalSnapLineTimer, SIGNAL(timeout()), |
1089 this, SLOT(onVerticalSnapLineTimerTimeout())); |
1136 this, SLOT(onVerticalSnapLineTimerTimeout())); |
1090 disconnect(&mHorizontalSnapLineTimer, SIGNAL(timeout()), |
1137 disconnect(&mHorizontalSnapLineTimer, SIGNAL(timeout()), |
1420 } |
1468 } |
1421 |
1469 |
1422 /*! |
1470 /*! |
1423 Handles updating the Snap algorithm with page presentation on page change |
1471 Handles updating the Snap algorithm with page presentation on page change |
1424 */ |
1472 */ |
1425 void HsIdleState::onActivePageChanged() |
1473 void HsIdleState::updateSnapAlgorithmParameters() |
1426 { |
1474 { |
1427 updatePagePresentationToWidgetSnap(); |
1475 updatePagePresentationToWidgetSnap(); |
1428 resetSnapPosition(); |
1476 resetSnapPosition(); |
1429 } |
1477 } |
1430 |
1478 |
1431 |
1479 /*! |
|
1480 Closes virtual keyboard |
|
1481 */ |
|
1482 void HsIdleState::closeVirtualKeyboard() |
|
1483 { |
|
1484 HbVkbHost::HbVkbStatus status = HbVkbHostBridge::instance()->keypadStatus(); |
|
1485 if (status == HbVkbHost::HbVkbStatusOpened ) { |
|
1486 QInputContext *ic = qApp->inputContext(); |
|
1487 if (ic) { |
|
1488 QEvent *event = new QEvent(QEvent::CloseSoftwareInputPanel); |
|
1489 ic->filterEvent(event); |
|
1490 delete event; |
|
1491 } |
|
1492 } |
|
1493 } |
|
1494 |
|
1495 /*! |
|
1496 Returns true if \a widget has editor field under \a point. |
|
1497 */ |
|
1498 bool HsIdleState::isEditor(const QPointF &point, HsWidgetHost *widget) |
|
1499 { |
|
1500 bool isWidgetEditor = false; |
|
1501 QList<QGraphicsItem *> items; |
|
1502 if ( widget->visual()->scene() ) { |
|
1503 items = widget->visual()->scene()->items(point); |
|
1504 } |
|
1505 int count = items.count(); |
|
1506 for (int i=0; i<count && !isWidgetEditor; i++ ) { |
|
1507 QGraphicsItem *item = items.at(i); |
|
1508 if (item->isWidget()) { |
|
1509 isWidgetEditor = HbInputFocusObject::isEditor(item->toGraphicsObject()) && |
|
1510 qobject_cast<QGraphicsWidget *>(widget->visual()->widget())->isAncestorOf(item); |
|
1511 } |
|
1512 } |
|
1513 return isWidgetEditor; |
|
1514 } |