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);
58 if (!qFuzzyIsNull(ev->value())) {
59 g->setLastScaleFactor(g->scaleFactor());
60 g->setScaleFactor(1.0 + ev->value());
61 g->setTotalScaleFactor(g->totalScaleFactor() * g->scaleFactor());
62 g->setChangeFlags(g->changeFlags() | QPinchGesture::ScaleFactorChanged);
65 if (g->changeFlags() != 0)
66 result = QGestureRecognizer::TriggerGesture | QGestureRecognizer::ConsumeEventHint;
68 case Qt::RotateNativeGesture:
69 g->setChangeFlags({});
70 g->setHotSpot(ev->globalPosition());
72 if (g->centerPoint() != ev->globalPosition().toPoint()) {
73 g->setLastCenterPoint(g->centerPoint());
74 g->setCenterPoint(ev->globalPosition().toPoint());
75 g->setChangeFlags(g->changeFlags() | QPinchGesture::CenterPointChanged);
79 if (!qFuzzyIsNull(ev->value())) {
80 g->setLastRotationAngle(g->rotationAngle());
81 g->setRotationAngle(g->rotationAngle() + ev->value());
82 g->setTotalRotationAngle(g->totalRotationAngle() + ev->value());
83 g->setChangeFlags(g->changeFlags() | QPinchGesture::RotationAngleChanged);
86 if (g->changeFlags() != 0)
87 result = QGestureRecognizer::TriggerGesture | QGestureRecognizer::ConsumeEventHint;
94 g->setTotalChangeFlags(g->totalChangeFlags() |= g->changeFlags());
101 auto *g =
static_cast<QPinchGesture *>(gesture);
102 g->setChangeFlags({});
103 g->setTotalChangeFlags({});
104 g->setScaleFactor(1.0f);
105 g->setTotalScaleFactor(1.0f);
106 g->setLastScaleFactor(1.0f);
107 g->setRotationAngle(0.0f);
108 g->setTotalRotationAngle(0.0f);
109 g->setLastRotationAngle(0.0f);
110 g->setCenterPoint(QPointF());
111 g->setStartCenterPoint(QPointF());
112 g->setLastCenterPoint(QPointF());
113 QGestureRecognizer::reset(gesture);