30 auto *g =
static_cast<QPinchGesture *>(gesture);
32 QGestureRecognizer::Result result = QGestureRecognizer::Ignore;
33 if (event->type() == QEvent::NativeGesture) {
34 const auto *ev =
static_cast<QNativeGestureEvent *>(event);
36 switch (ev->gestureType()) {
37 case Qt::BeginNativeGesture:
38 g->setStartCenterPoint(ev->globalPosition().toPoint());
39 result = QGestureRecognizer::MayBeGesture;
42 case Qt::EndNativeGesture:
43 result = (g->state() != Qt::NoGesture)
44 ? QGestureRecognizer::FinishGesture
45 : QGestureRecognizer::CancelGesture;
47 case Qt::ZoomNativeGesture:
48 g->setChangeFlags({});
49 g->setHotSpot(ev->globalPosition());
51 if (g->centerPoint() != ev->globalPosition().toPoint()) {
52 g->setLastCenterPoint(g->centerPoint());
53 g->setCenterPoint(ev->globalPosition().toPoint());
54 g->setChangeFlags(g->changeFlags() | QPinchGesture::CenterPointChanged);
57 if (g->scaleFactor() != ev->value()) {
58 g->setLastScaleFactor(g->scaleFactor());
59 g->setScaleFactor(ev->value());
60 g->setTotalScaleFactor(g->totalScaleFactor() * g->scaleFactor());
61 g->setChangeFlags(g->changeFlags() | QPinchGesture::ScaleFactorChanged);
64 if (g->changeFlags() != 0)
65 result = QGestureRecognizer::TriggerGesture | QGestureRecognizer::ConsumeEventHint;
67 case Qt::RotateNativeGesture:
68 g->setChangeFlags({});
69 g->setHotSpot(ev->globalPosition());
71 if (g->centerPoint() != ev->globalPosition().toPoint()) {
72 g->setLastCenterPoint(g->centerPoint());
73 g->setCenterPoint(ev->globalPosition().toPoint());
74 g->setChangeFlags(g->changeFlags() | QPinchGesture::CenterPointChanged);
77 if (g->rotationAngle() != ev->value()) {
78 g->setLastRotationAngle(g->rotationAngle());
79 g->setRotationAngle(ev->value());
80 g->setTotalRotationAngle(g->rotationAngle());
81 g->setChangeFlags(g->changeFlags() | QPinchGesture::RotationAngleChanged);
84 if (g->changeFlags() != 0)
85 result = QGestureRecognizer::TriggerGesture | QGestureRecognizer::ConsumeEventHint;
92 g->setTotalChangeFlags(g->totalChangeFlags() |= g->changeFlags());
99 auto *g =
static_cast<QPinchGesture *>(gesture);
100 g->setChangeFlags({});
101 g->setTotalChangeFlags({});
102 g->setScaleFactor(1.0f);
103 g->setTotalScaleFactor(1.0f);
104 g->setLastScaleFactor(1.0f);
105 g->setRotationAngle(0.0f);
106 g->setTotalRotationAngle(0.0f);
107 g->setLastRotationAngle(0.0f);
108 g->setCenterPoint(QPointF());
109 g->setStartCenterPoint(QPointF());
110 g->setLastCenterPoint(QPointF());
111 QGestureRecognizer::reset(gesture);