summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenis Dzyubenko <denis.dzyubenko@nokia.com>2009-11-05 11:46:12 (GMT)
committerDenis Dzyubenko <denis.dzyubenko@nokia.com>2009-11-05 11:54:55 (GMT)
commit75da4b5855c63b41060886c7b8ed7856888e4e35 (patch)
treecd1b55ffb3491fa7647c37949b0f03d14af6759a
parent6777135b2cacd3a72a60ff372749837b67762fbe (diff)
downloadQt-75da4b5855c63b41060886c7b8ed7856888e4e35.zip
Qt-75da4b5855c63b41060886c7b8ed7856888e4e35.tar.gz
Qt-75da4b5855c63b41060886c7b8ed7856888e4e35.tar.bz2
Fixed pinching in the imagegestures example.
When the gesture finishes it might not necessery set the ScaleFactorChanged flag. Also fixed the touch-event based pinch gesture. Reviewed-by: trustme
-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);
}