diff options
Diffstat (limited to 'src/gui/kernel/qstandardgestures.cpp')
-rw-r--r-- | src/gui/kernel/qstandardgestures.cpp | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/src/gui/kernel/qstandardgestures.cpp b/src/gui/kernel/qstandardgestures.cpp index 893ba2b..1821c3d 100644 --- a/src/gui/kernel/qstandardgestures.cpp +++ b/src/gui/kernel/qstandardgestures.cpp @@ -198,25 +198,22 @@ QGestureRecognizer::Result QPinchGestureRecognizer::recognize(QGesture *state, d->startPosition[0] = p1.screenPos(); 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(); d->lastCenterPoint = d->centerPoint; - d->centerPoint = centerPoint; - d->changeFlags |= QPinchGesture::CenterPointChanged; + d->centerPoint = (p1.screenPos() + p2.screenPos()) / 2.0; - const qreal scaleFactor = line.length() / lastLine.length(); + d->changeFlags |= QPinchGesture::CenterPointChanged; if (d->isNewSequence) { - d->lastScaleFactor = scaleFactor; + d->scaleFactor = 1.0; + d->lastScaleFactor = 1.0; } else { d->lastScaleFactor = d->scaleFactor; + QLineF line(p1.screenPos(), p2.screenPos()); + QLineF lastLine(p1.lastScreenPos(), p2.lastScreenPos()); + d->scaleFactor = line.length() / lastLine.length(); } - d->scaleFactor = scaleFactor; - d->totalScaleFactor = d->totalScaleFactor * scaleFactor; + d->totalScaleFactor = d->totalScaleFactor * d->scaleFactor; d->changeFlags |= QPinchGesture::ScaleFactorChanged; qreal angle = QLineF(p1.screenPos(), p2.screenPos()).angle(); |