diff options
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/kernel/qgesture_p.h | 2 | ||||
-rw-r--r-- | src/gui/kernel/qstandardgestures.cpp | 10 |
2 files changed, 6 insertions, 6 deletions
diff --git a/src/gui/kernel/qgesture_p.h b/src/gui/kernel/qgesture_p.h index baf0d33..e8f8fe3 100644 --- a/src/gui/kernel/qgesture_p.h +++ b/src/gui/kernel/qgesture_p.h @@ -112,7 +112,7 @@ class QPinchGesturePrivate : public QGesturePrivate public: QPinchGesturePrivate() : totalChangeFlags(0), changeFlags(0), - totalScaleFactor(0), lastScaleFactor(0), scaleFactor(0), + totalScaleFactor(1), lastScaleFactor(1), scaleFactor(1), totalRotationAngle(0), lastRotationAngle(0), rotationAngle(0), isNewSequence(true) { diff --git a/src/gui/kernel/qstandardgestures.cpp b/src/gui/kernel/qstandardgestures.cpp index 503fa18..893ba2b 100644 --- a/src/gui/kernel/qstandardgestures.cpp +++ b/src/gui/kernel/qstandardgestures.cpp @@ -199,6 +199,7 @@ QGestureRecognizer::Result QPinchGestureRecognizer::recognize(QGesture *state, d->startPosition[1] = p2.screenPos(); } QLineF line(p1.screenPos(), p2.screenPos()); + QLineF lastLine(p1.lastScreenPos(), p2.lastScreenPos()); QLineF tmp(line); tmp.setLength(line.length() / 2.); QPointF centerPoint = tmp.p2(); @@ -207,16 +208,15 @@ QGestureRecognizer::Result QPinchGestureRecognizer::recognize(QGesture *state, d->centerPoint = centerPoint; d->changeFlags |= QPinchGesture::CenterPointChanged; - const qreal scaleFactor = - QLineF(p1.screenPos(), p2.screenPos()).length() - / QLineF(d->startPosition[0], d->startPosition[1]).length(); + const qreal scaleFactor = line.length() / lastLine.length(); + if (d->isNewSequence) { d->lastScaleFactor = scaleFactor; } else { d->lastScaleFactor = d->scaleFactor; } d->scaleFactor = scaleFactor; - d->totalScaleFactor += d->scaleFactor - d->lastScaleFactor; + d->totalScaleFactor = d->totalScaleFactor * scaleFactor; d->changeFlags |= QPinchGesture::ScaleFactorChanged; qreal angle = QLineF(p1.screenPos(), p2.screenPos()).angle(); @@ -266,7 +266,7 @@ void QPinchGestureRecognizer::reset(QGesture *state) d->totalChangeFlags = d->changeFlags = 0; d->startCenterPoint = d->lastCenterPoint = d->centerPoint = QPointF(); - d->totalScaleFactor = d->lastScaleFactor = d->scaleFactor = 0; + d->totalScaleFactor = d->lastScaleFactor = d->scaleFactor = 1; d->totalRotationAngle = d->lastRotationAngle = d->rotationAngle = 0; d->isNewSequence = true; |