summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/gestures/imagegestures/imagewidget.cpp11
-rw-r--r--src/gui/kernel/qstandardgestures.cpp8
2 files changed, 11 insertions, 8 deletions
diff --git a/examples/gestures/imagegestures/imagewidget.cpp b/examples/gestures/imagegestures/imagewidget.cpp
index 80bd6a6..afa0185 100644
--- a/examples/gestures/imagegestures/imagewidget.cpp
+++ b/examples/gestures/imagegestures/imagewidget.cpp
@@ -141,12 +141,11 @@ void ImageWidget::pinchTriggered(QPinchGesture *gesture)
}
if (changeFlags & QPinchGesture::ScaleFactorChanged) {
qreal value = gesture->property("scaleFactor").toReal();
- if (gesture->state() == Qt::GestureFinished) {
- scaleFactor *= currentStepScaleFactor;
- currentStepScaleFactor = 1;
- } else {
- currentStepScaleFactor = value;
- }
+ currentStepScaleFactor = value;
+ }
+ if (gesture->state() == Qt::GestureFinished) {
+ scaleFactor *= currentStepScaleFactor;
+ currentStepScaleFactor = 1;
}
update();
}
diff --git a/src/gui/kernel/qstandardgestures.cpp b/src/gui/kernel/qstandardgestures.cpp
index 3cc1b4b..0ea4764 100644
--- a/src/gui/kernel/qstandardgestures.cpp
+++ b/src/gui/kernel/qstandardgestures.cpp
@@ -205,7 +205,7 @@ QGestureRecognizer::Result QPinchGestureRecognizer::recognize(QGesture *state,
d->changeFlags |= QPinchGesture::CenterPointChanged;
const qreal scaleFactor =
- QLineF(p1.pos(), p2.pos()).length()
+ QLineF(p1.screenPos(), p2.screenPos()).length()
/ QLineF(d->startPosition[0], d->startPosition[1]).length();
if (d->isNewSequence) {
d->lastScaleFactor = scaleFactor;
@@ -236,7 +236,10 @@ QGestureRecognizer::Result QPinchGestureRecognizer::recognize(QGesture *state,
result = QGestureRecognizer::TriggerGesture;
} else {
d->isNewSequence = true;
- result = QGestureRecognizer::MayBeGesture;
+ if (q->state() == Qt::NoGesture)
+ result = QGestureRecognizer::Ignore;
+ else
+ result = QGestureRecognizer::FinishGesture;
}
break;
}
@@ -264,6 +267,7 @@ void QPinchGestureRecognizer::reset(QGesture *state)
d->totalRotationAngle = d->lastRotationAngle = d->rotationAngle = 0;
d->isNewSequence = true;
+ d->startPosition[0] = d->startPosition[1] = QPointF();
QGestureRecognizer::reset(state);
}