summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/src/qnamespace.qdoc2
-rw-r--r--src/corelib/global/qnamespace.h6
-rw-r--r--src/gui/kernel/qgesturerecognizer.cpp19
-rw-r--r--src/gui/kernel/qgesturestandardrecognizers.cpp27
-rw-r--r--src/gui/kernel/qgesturestandardrecognizers_p.h2
5 files changed, 33 insertions, 23 deletions
diff --git a/doc/src/qnamespace.qdoc b/doc/src/qnamespace.qdoc
index c30dc88..dcad96b 100644
--- a/doc/src/qnamespace.qdoc
+++ b/doc/src/qnamespace.qdoc
@@ -2694,7 +2694,9 @@
This enum type describes the state of a gesture.
+ \omitvalue NoGesture
\value GestureStarted The continuous gesture has started.
+ \value GestureUpdated The gesture continiues.
\value GestureFinished The gesture has finished.
\sa QGesture
diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h
index 7875fba..b5b5291 100644
--- a/src/corelib/global/qnamespace.h
+++ b/src/corelib/global/qnamespace.h
@@ -1565,8 +1565,10 @@ public:
enum GestureState
{
- GestureStarted = 0,
- GestureFinished = 1
+ NoGesture,
+ GestureStarted = 1,
+ GestureUpdated = 2,
+ GestureFinished = 3
};
enum DirectionType
diff --git a/src/gui/kernel/qgesturerecognizer.cpp b/src/gui/kernel/qgesturerecognizer.cpp
index 278389a..c6e1f65 100644
--- a/src/gui/kernel/qgesturerecognizer.cpp
+++ b/src/gui/kernel/qgesturerecognizer.cpp
@@ -73,18 +73,19 @@ QString qt_getStandardGestureTypeName(Qt::GestureType gestureType);
\value NotGesture Not a gesture.
- \value GestureStarted The long-term gesture has started. When the
- recognizer is in started state, a gesture event containing
- QGesture objects returned by the
+ \value GestureStarted The continuous gesture has started. When the
+ recognizer is in this state, a \l{QGestureEvent}{gesture event}
+ containing QGesture objects returned by the
\l{QGestureRecognizer::}{getGesture()} will be sent to a widget.
- \value GestureFinished A gesture has ended. The gesture event will
- be sent to a widget.
+ \value GestureFinished The gesture has ended. A
+ \l{QGestureEvent}{gesture event} will be sent to a widget.
- \value MaybeGesture Gesture hasn't started yet, but it might start
- soon after next events are received by the recognizer. That means
- that gesture manager shouldn't reset() the internal state of the
- gesture recognizer.
+ \value MaybeGesture Gesture recognizer hasn't decided yet if a
+ gesture has started, but it might start soon after the following
+ events are received by the recognizer. This means that gesture
+ manager shouldn't reset() the internal state of the gesture
+ recognizer.
*/
/*! \fn QGestureRecognizer::Result QGestureRecognizer::filterEvent(const QEvent *event)
diff --git a/src/gui/kernel/qgesturestandardrecognizers.cpp b/src/gui/kernel/qgesturestandardrecognizers.cpp
index cb448c5..04994cf 100644
--- a/src/gui/kernel/qgesturestandardrecognizers.cpp
+++ b/src/gui/kernel/qgesturestandardrecognizers.cpp
@@ -80,7 +80,7 @@ QString qt_getStandardGestureTypeName(Qt::GestureType gestureType)
QGestureRecognizerPan::QGestureRecognizerPan(QObject *parent)
: QGestureRecognizer(QString(), parent),
- mousePressed(false), gestureFinished(false),
+ mousePressed(false), gestureState(Qt::NoGesture),
lastDirection(Qt::NoDirection), currentDirection(Qt::NoDirection)
{
Q_D(QGestureRecognizer);
@@ -103,7 +103,7 @@ QGestureRecognizer::Result QGestureRecognizerPan::filterEvent(const QEvent *even
} else if (event->type() == QEvent::MouseButtonRelease) {
if (mousePressed && currentDirection != Qt::NoDirection) {
DEBUG() << "Pan: MouseButtonRelease: pan detected";
- gestureFinished = true;
+ gestureState = Qt::GestureFinished;
const QMouseEvent *ev = static_cast<const QMouseEvent*>(event);
currentPos = ev->pos();
internalReset();
@@ -123,12 +123,15 @@ QGestureRecognizer::Result QGestureRecognizerPan::filterEvent(const QEvent *even
DEBUG() << "Pan: MouseMove: simplerecognizer result = " << direction;
QGestureRecognizer::Result result = QGestureRecognizer::NotGesture;
if (currentDirection == Qt::NoDirection) {
- if (direction == Qt::NoDirection)
+ if (direction == Qt::NoDirection) {
result = QGestureRecognizer::MaybeGesture;
- else
+ } else {
result = QGestureRecognizer::GestureStarted;
+ gestureState = Qt::GestureStarted;
+ }
} else {
result = QGestureRecognizer::GestureStarted;
+ gestureState = Qt::GestureUpdated;
}
if (direction != Qt::NoDirection) {
if (currentDirection != direction)
@@ -149,7 +152,7 @@ QGesture* QGestureRecognizerPan::getGesture()
d->lastPos = lastPos;
d->pos = currentPos;
d->hotSpot = pressedPos;
- d->state = gestureFinished ? Qt::GestureFinished : Qt::GestureStarted;
+ d->state = gestureState;
d->lastDirection = lastDirection;
d->direction = currentDirection;
@@ -161,7 +164,7 @@ void QGestureRecognizerPan::reset()
mousePressed = false;
lastDirection = Qt::NoDirection;
currentDirection = Qt::NoDirection;
- gestureFinished = false;
+ gestureState = Qt::NoGesture;
diagonalRecognizer.reset();
simpleRecognizer.reset();
}
@@ -230,8 +233,9 @@ const int QTapAndHoldGestureRecognizer::iterationCount = 40;
const int QTapAndHoldGestureRecognizer::iterationTimeout = 50;
QTapAndHoldGestureRecognizer::QTapAndHoldGestureRecognizer(QObject *parent)
- : QGestureRecognizer(QString(), parent), iteration(0),
- gesture(0, qt_getStandardGestureTypeName(Qt::TapAndHoldGesture))
+ : QGestureRecognizer(QString(), parent),
+ gesture(0, qt_getStandardGestureTypeName(Qt::TapAndHoldGesture)),
+ iteration(0)
{
Q_D(QGestureRecognizer);
d->gestureType = Qt::TapAndHoldGesture;
@@ -263,12 +267,13 @@ void QTapAndHoldGestureRecognizer::timerEvent(QTimerEvent *event)
{
if (event->timerId() != timer.timerId())
return;
- if (++iteration == QTapAndHoldGestureRecognizer::iterationCount) {
- emit stateChanged(QGestureRecognizer::GestureFinished);
+ if (iteration == QTapAndHoldGestureRecognizer::iterationCount) {
timer.stop();
+ emit stateChanged(QGestureRecognizer::GestureFinished);
} else {
emit stateChanged(QGestureRecognizer::GestureStarted);
}
+ ++iteration;
}
QGesture* QTapAndHoldGestureRecognizer::getGesture()
@@ -281,7 +286,7 @@ QGesture* QTapAndHoldGestureRecognizer::getGesture()
if (iteration >= QTapAndHoldGestureRecognizer::iterationCount)
d->state = Qt::GestureFinished;
else
- d->state = Qt::GestureStarted;
+ d->state = iteration == 0 ? Qt::GestureStarted : Qt::GestureUpdated;
return &gesture;
}
diff --git a/src/gui/kernel/qgesturestandardrecognizers_p.h b/src/gui/kernel/qgesturestandardrecognizers_p.h
index a7a631c..81db3e6 100644
--- a/src/gui/kernel/qgesturestandardrecognizers_p.h
+++ b/src/gui/kernel/qgesturestandardrecognizers_p.h
@@ -81,7 +81,7 @@ private:
QPoint lastPos;
QPoint currentPos;
bool mousePressed;
- bool gestureFinished;
+ Qt::GestureState gestureState;
Qt::DirectionType lastDirection;
Qt::DirectionType currentDirection;
QDirectionDiagonalRecognizer diagonalRecognizer;