summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZeno Albisser <zeno.albisser@nokia.com>2010-09-10 08:20:55 (GMT)
committerZeno Albisser <zeno.albisser@nokia.com>2010-09-13 14:40:36 (GMT)
commitdc343981c65af9d279a08ae4a664ec664dbb3cea (patch)
tree1f6bff50f2f71e12497f56f09c9c1f24c2d4d911
parent7f96f211d15d7af28146682356ad1363c5d9f4a9 (diff)
downloadQt-dc343981c65af9d279a08ae4a664ec664dbb3cea.zip
Qt-dc343981c65af9d279a08ae4a664ec664dbb3cea.tar.gz
Qt-dc343981c65af9d279a08ae4a664ec664dbb3cea.tar.bz2
Changed the speed property on QSwipeGesture to velocity
Reviewed-by: Denis Dzyubenko
-rw-r--r--src/gui/kernel/qgesture.cpp2
-rw-r--r--src/gui/kernel/qgesture.h1
-rw-r--r--src/gui/kernel/qgesture_p.h7
-rw-r--r--src/gui/kernel/qstandardgestures.cpp6
4 files changed, 11 insertions, 5 deletions
diff --git a/src/gui/kernel/qgesture.cpp b/src/gui/kernel/qgesture.cpp
index 13274c4..5725a22 100644
--- a/src/gui/kernel/qgesture.cpp
+++ b/src/gui/kernel/qgesture.cpp
@@ -775,4 +775,6 @@ int QTapAndHoldGesturePrivate::Timeout = 700; // in ms
QT_END_NAMESPACE
+#include <moc_qgesture.cpp>
+
#endif // QT_NO_GESTURES
diff --git a/src/gui/kernel/qgesture.h b/src/gui/kernel/qgesture.h
index dcb0264..1ba6e10 100644
--- a/src/gui/kernel/qgesture.h
+++ b/src/gui/kernel/qgesture.h
@@ -210,6 +210,7 @@ class Q_GUI_EXPORT QSwipeGesture : public QGesture
Q_PROPERTY(SwipeDirection horizontalDirection READ horizontalDirection STORED false)
Q_PROPERTY(SwipeDirection verticalDirection READ verticalDirection STORED false)
Q_PROPERTY(qreal swipeAngle READ swipeAngle WRITE setSwipeAngle)
+ Q_PRIVATE_PROPERTY(QSwipeGesture::d_func(), qreal velocity READ velocity WRITE setVelocity)
public:
enum SwipeDirection { NoDirection, Left, Right, Up, Down };
diff --git a/src/gui/kernel/qgesture_p.h b/src/gui/kernel/qgesture_p.h
index 29b923e..7d6ea87 100644
--- a/src/gui/kernel/qgesture_p.h
+++ b/src/gui/kernel/qgesture_p.h
@@ -139,17 +139,20 @@ public:
: horizontalDirection(QSwipeGesture::NoDirection),
verticalDirection(QSwipeGesture::NoDirection),
swipeAngle(0),
- started(false), speed(0)
+ started(false), velocityValue(0),
{
}
+ qreal velocity() const { return velocityValue; }
+ void setVelocity(qreal value) { velocityValue = value; }
+
QSwipeGesture::SwipeDirection horizontalDirection;
QSwipeGesture::SwipeDirection verticalDirection;
qreal swipeAngle;
QPoint lastPositions[3];
bool started;
- qreal speed;
+ qreal velocityValue;
QElapsedTimer time;
};
diff --git a/src/gui/kernel/qstandardgestures.cpp b/src/gui/kernel/qstandardgestures.cpp
index 127e150..503fa18 100644
--- a/src/gui/kernel/qstandardgestures.cpp
+++ b/src/gui/kernel/qstandardgestures.cpp
@@ -304,7 +304,7 @@ QGestureRecognizer::Result QSwipeGestureRecognizer::recognize(QGesture *state,
switch (event->type()) {
case QEvent::TouchBegin: {
- d->speed = 1;
+ d->velocityValue = 1;
d->time.start();
d->started = true;
result = QGestureRecognizer::MayBeGesture;
@@ -345,7 +345,7 @@ QGestureRecognizer::Result QSwipeGestureRecognizer::recognize(QGesture *state,
int elapsedTime = d->time.restart();
if (!elapsedTime)
elapsedTime = 1;
- d->speed = 0.9 * d->speed + distance / elapsedTime;
+ d->velocityValue = 0.9 * d->velocityValue + distance / elapsedTime;
d->swipeAngle = QLineF(p1.startScreenPos(), p1.screenPos()).angle();
static const int MoveThreshold = 50;
@@ -407,7 +407,7 @@ void QSwipeGestureRecognizer::reset(QGesture *state)
d->lastPositions[0] = d->lastPositions[1] = d->lastPositions[2] = QPoint();
d->started = false;
- d->speed = 0;
+ d->velocityValue = 0;
d->time.invalidate();
QGestureRecognizer::reset(state);