summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlli Werwolff <qt-info@nokia.com>2011-04-19 14:29:14 +0200
committerOlli Werwolff <qt-info@nokia.com>2011-04-19 14:29:14 +0200
commitf5e8d10f8a3e4c841985a3a28642a457c856ae80 (patch)
treece33f4d999db5877a4f2cb9b83db15ad2a54989b
parentd430373aa92a15f483eac5b2963d309936bec9ce (diff)
More intuitive touch input modes
-rw-r--r--src/other/mouseindicator.cpp7
-rw-r--r--src/other/panmodefilter.cpp17
-rw-r--r--src/other/pinchmodefilter.cpp13
-rw-r--r--src/other/swipemodefilter.cpp26
4 files changed, 32 insertions, 31 deletions
diff --git a/src/other/mouseindicator.cpp b/src/other/mouseindicator.cpp
index 3956e86..c6af699 100644
--- a/src/other/mouseindicator.cpp
+++ b/src/other/mouseindicator.cpp
@@ -34,6 +34,7 @@
#include "mouseindicator.h"
#include <QtGui/QBrush>
+#include <QtGui/QCursor>
MouseIndicator::MouseIndicator(QGraphicsItem *parent)
: QGraphicsEllipseItem(parent)
@@ -44,14 +45,16 @@ MouseIndicator::MouseIndicator(qreal x, qreal y, QGraphicsItem *parent)
: QGraphicsEllipseItem(0, 0, 15, 15, parent)
{
setCenter(QPointF(x, y));
- setBrush(Qt::gray);
+ setBrush(Qt::red);
+ setCursor(Qt::OpenHandCursor);
}
MouseIndicator::MouseIndicator(QPointF center, QGraphicsItem *parent)
: QGraphicsEllipseItem(0, 0, 15, 15, parent)
{
setCenter(center);
- setBrush(Qt::gray);
+ setBrush(Qt::red);
+ setCursor(Qt::OpenHandCursor);
}
MouseIndicator::~MouseIndicator()
diff --git a/src/other/panmodefilter.cpp b/src/other/panmodefilter.cpp
index 715e273..49d8be0 100644
--- a/src/other/panmodefilter.cpp
+++ b/src/other/panmodefilter.cpp
@@ -60,20 +60,15 @@ bool PanModeFilter::sceneEventFilter(QGraphicsItem *watched, QEvent *event)
case setFirstPoint:
mState = updateFirstPoint;
mValuePoints.append(new MouseIndicator(ev->pos(), widget));
- mValuePoints[0]->setBrush(Qt::red);
+ mValuePoints[0]->setCursor(Qt::ClosedHandCursor);
return true;
case setSecondPoint:
if (mValuePoints[0]->contains(mapToItem(mValuePoints[0], ev->pos()))) {
mState = updateFirstPoint;
- if (mValuePoints.length() == 2)
- mValuePoints[1]->setVisible(false);
+ mValuePoints[0]->setCursor(Qt::ClosedHandCursor);
} else {
- if (mValuePoints.length() == 1) {
- mValuePoints.append(new MouseIndicator(ev->pos(), this));
- } else {
- mValuePoints[1]->setCenter(ev->pos());
- mValuePoints[1]->setVisible(true);
- }
+ mValuePoints.append(new MouseIndicator(ev->pos(), this));
+ mValuePoints[1]->setCursor(Qt::ClosedHandCursor);
mPanDiff = ev->pos() - mValuePoints[0]->center();
mValuePoints[0]->setStartPos(mValuePoints[0]->center());
mValuePoints[1]->setStartPos(mValuePoints[1]->center());
@@ -95,6 +90,7 @@ bool PanModeFilter::sceneEventFilter(QGraphicsItem *watched, QEvent *event)
switch (mState) {
case updateFirstPoint:
mState = setSecondPoint;
+ mValuePoints[0]->setCursor(Qt::OpenHandCursor);
return true;
case updateSecondPoint:
touchEvent = createTouchEventFromMouseEvent(widget, ev);
@@ -103,7 +99,8 @@ bool PanModeFilter::sceneEventFilter(QGraphicsItem *watched, QEvent *event)
"dispatchTouchEvent",
widget->widgetId,
touchEvent);
- mState = setSecondPoint;
+ removeValuePoints();
+ mState = setFirstPoint;
return true;
default:
return true;
diff --git a/src/other/pinchmodefilter.cpp b/src/other/pinchmodefilter.cpp
index 69e6f54..aae7616 100644
--- a/src/other/pinchmodefilter.cpp
+++ b/src/other/pinchmodefilter.cpp
@@ -44,8 +44,7 @@ PinchModeFilter::PinchModeFilter(QGraphicsItem *parent)
{
mReferencePoint = new MouseIndicator(0, 0, this);
mReferencePoint->setVisible(false);
- mReferencePoint->setBrush(Qt::red);
- mReferencePoint->setCursor(Qt::OpenHandCursor);
+ mReferencePoint->setBrush(Qt::gray);
}
PinchModeFilter::~PinchModeFilter()
@@ -64,16 +63,18 @@ bool PinchModeFilter::sceneEventFilter(QGraphicsItem *watched, QEvent *event)
switch (mState) {
case setReferencePoint:
mState = updateReferencePoint;
+ mReferencePoint->setCursor(Qt::ClosedHandCursor);
mReferencePoint->setCenter(ev->pos());
mReferencePoint->setVisible(true);
return true;
case setTouchPoints:
- removeValuePoints();
if (mReferencePoint->contains(mapToItem(mReferencePoint, ev->pos()))) {
+ mReferencePoint->setCursor(Qt::ClosedHandCursor);
mState = updateReferencePoint;
} else {
mValuePoints.append(new MouseIndicator(ev->pos(), widget));
mValuePoints[0]->setStartPos(mValuePoints[0]->center());
+ mValuePoints[0]->setCursor(Qt::ClosedHandCursor);
QPointF diff = ev->pos() - mReferencePoint->center();
mValuePoints.append(new MouseIndicator(mReferencePoint->center() - diff, widget));
mValuePoints[1]->setStartPos(mValuePoints[1]->center());
@@ -94,6 +95,7 @@ bool PinchModeFilter::sceneEventFilter(QGraphicsItem *watched, QEvent *event)
ev = static_cast<QGraphicsSceneMouseEvent *>(event);
switch (mState) {
case updateReferencePoint:
+ mReferencePoint->setCursor(Qt::OpenHandCursor);
mState = setTouchPoints;
return true;
case updateTouchPoints:
@@ -103,7 +105,10 @@ bool PinchModeFilter::sceneEventFilter(QGraphicsItem *watched, QEvent *event)
"dispatchTouchEvent",
widget->widgetId,
touchEvent);
- mState = setTouchPoints;
+
+ removeValuePoints();
+ mReferencePoint->setVisible(false);
+ mState = setReferencePoint;
return true;
default:
return true;
diff --git a/src/other/swipemodefilter.cpp b/src/other/swipemodefilter.cpp
index 21cbd83..6d5593d 100644
--- a/src/other/swipemodefilter.cpp
+++ b/src/other/swipemodefilter.cpp
@@ -60,36 +60,29 @@ bool SwipeModeFilter::sceneEventFilter(QGraphicsItem *watched, QEvent *event)
case setFirstPoint:
mState = updateFirstPoint;
mValuePoints.append(new MouseIndicator(ev->pos(), this));
- mValuePoints.last()->setBrush(Qt::red);
+ mValuePoints[0]->setCursor(Qt::ClosedHandCursor);
return true;
case setSecondPoint:
if (mValuePoints[0]->contains(mapToItem(mValuePoints[0], ev->pos()))) {
mState = updateFirstPoint;
- if (mValuePoints.length() == 3)
- mValuePoints[2]->setVisible(false);
+ mValuePoints[0]->setCursor(Qt::ClosedHandCursor);
} else {
mState = updateSecondPoint;
mValuePoints.append(new MouseIndicator(ev->pos(), this));
- mValuePoints.last()->setBrush(Qt::red);
+ mValuePoints[1]->setCursor(Qt::ClosedHandCursor);
}
return true;
break;
case setThirdPoint:
if (mValuePoints[0]->contains(mapToItem(mValuePoints[0], ev->pos()))) {
mState = updateFirstPoint;
- if (mValuePoints.length() == 3)
- mValuePoints[2]->setVisible(false);
+ mValuePoints[0]->setCursor(Qt::ClosedHandCursor);
} else if (mValuePoints[1]->contains(mapToItem(mValuePoints[1], ev->pos()))) {
mState = updateSecondPoint;
- if (mValuePoints.length() == 3)
- mValuePoints[2]->setVisible(false);
+ mValuePoints[1]->setCursor(Qt::ClosedHandCursor);
} else {
- if (mValuePoints.length() == 2) {
- mValuePoints.append(new MouseIndicator(ev->pos(), this));
- } else {
- mValuePoints[2]->setCenter(ev->pos());
- mValuePoints[2]->setVisible(true);
- }
+ mValuePoints.append(new MouseIndicator(ev->pos(), this));
+ mValuePoints[2]->setCursor(Qt::ClosedHandCursor);
mDiff1 = ev->pos() - mValuePoints[0]->center();
mDiff2 = ev->pos() - mValuePoints[1]->center();
mValuePoints[0]->setStartPos(mValuePoints[0]->center());
@@ -116,9 +109,11 @@ bool SwipeModeFilter::sceneEventFilter(QGraphicsItem *watched, QEvent *event)
mState = setSecondPoint;
else
mState = setThirdPoint;
+ mValuePoints[0]->setCursor(Qt::OpenHandCursor);
return true;
case updateSecondPoint:
mState = setThirdPoint;
+ mValuePoints[1]->setCursor(Qt::OpenHandCursor);
return true;
case updateThirdPoint:
touchEvent = createTouchEventFromMouseEvent(widget, ev);
@@ -127,7 +122,8 @@ bool SwipeModeFilter::sceneEventFilter(QGraphicsItem *watched, QEvent *event)
"dispatchTouchEvent",
widget->widgetId,
touchEvent);
- mState = setThirdPoint;
+ removeValuePoints();
+ mState = setFirstPoint;
return true;
default:
return true;