summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qstandardgestures.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/kernel/qstandardgestures.cpp')
-rw-r--r--src/gui/kernel/qstandardgestures.cpp63
1 files changed, 31 insertions, 32 deletions
diff --git a/src/gui/kernel/qstandardgestures.cpp b/src/gui/kernel/qstandardgestures.cpp
index 57cf12d..ba00a90 100644
--- a/src/gui/kernel/qstandardgestures.cpp
+++ b/src/gui/kernel/qstandardgestures.cpp
@@ -52,7 +52,7 @@ QPanGestureRecognizer::QPanGestureRecognizer()
{
}
-QGesture *QPanGestureRecognizer::createGesture(QObject *target)
+QGesture *QPanGestureRecognizer::create(QObject *target)
{
if (target && target->isWidgetType()) {
#if defined(Q_OS_WIN)
@@ -66,21 +66,21 @@ QGesture *QPanGestureRecognizer::createGesture(QObject *target)
return new QPanGesture;
}
-QGestureRecognizer::Result QPanGestureRecognizer::filterEvent(QGesture *state, QObject *, QEvent *event)
+QGestureRecognizer::Result QPanGestureRecognizer::recognize(QGesture *state, QObject *, QEvent *event)
{
- QPanGesture *q = static_cast<QPanGesture*>(state);
+ QPanGesture *q = static_cast<QPanGesture *>(state);
QPanGesturePrivate *d = q->d_func();
- const QTouchEvent *ev = static_cast<const QTouchEvent*>(event);
+ const QTouchEvent *ev = static_cast<const QTouchEvent *>(event);
QGestureRecognizer::Result result;
switch (event->type()) {
case QEvent::TouchBegin: {
- result = QGestureRecognizer::MaybeGesture;
+ result = QGestureRecognizer::MayBeGesture;
QTouchEvent::TouchPoint p = ev->touchPoints().at(0);
d->lastPosition = p.pos().toPoint();
- d->lastOffset = d->totalOffset = d->offset = QPointF();
+ d->lastOffset = d->offset = QPointF();
break;
}
case QEvent::TouchEnd: {
@@ -90,13 +90,12 @@ QGestureRecognizer::Result QPanGestureRecognizer::filterEvent(QGesture *state, Q
QTouchEvent::TouchPoint p2 = ev->touchPoints().at(1);
d->lastOffset = d->offset;
d->offset =
- QPointF(p1.pos().x() - p1.lastPos().x() + p2.pos().x() - p2.lastPos().x(),
- p1.pos().y() - p1.lastPos().y() + p2.pos().y() - p2.lastPos().y()) / 2;
- d->totalOffset += d->offset;
+ QPointF(p1.pos().x() - p1.startPos().x() + p2.pos().x() - p2.startPos().x(),
+ p1.pos().y() - p1.startPos().y() + p2.pos().y() - p2.startPos().y()) / 2;
}
- result = QGestureRecognizer::GestureFinished;
+ result = QGestureRecognizer::FinishGesture;
} else {
- result = QGestureRecognizer::NotGesture;
+ result = QGestureRecognizer::CancelGesture;
}
break;
}
@@ -106,14 +105,13 @@ QGestureRecognizer::Result QPanGestureRecognizer::filterEvent(QGesture *state, Q
QTouchEvent::TouchPoint p2 = ev->touchPoints().at(1);
d->lastOffset = d->offset;
d->offset =
- QPointF(p1.pos().x() - p1.lastPos().x() + p2.pos().x() - p2.lastPos().x(),
- p1.pos().y() - p1.lastPos().y() + p2.pos().y() - p2.lastPos().y()) / 2;
- d->totalOffset += d->offset;
- if (d->totalOffset.x() > 10 || d->totalOffset.y() > 10 ||
- d->totalOffset.x() < -10 || d->totalOffset.y() < -10) {
- result = QGestureRecognizer::GestureTriggered;
+ QPointF(p1.pos().x() - p1.startPos().x() + p2.pos().x() - p2.startPos().x(),
+ p1.pos().y() - p1.startPos().y() + p2.pos().y() - p2.startPos().y()) / 2;
+ if (d->offset.x() > 10 || d->offset.y() > 10 ||
+ d->offset.x() < -10 || d->offset.y() < -10) {
+ result = QGestureRecognizer::TriggerGesture;
} else {
- result = QGestureRecognizer::MaybeGesture;
+ result = QGestureRecognizer::MayBeGesture;
}
}
break;
@@ -135,7 +133,7 @@ void QPanGestureRecognizer::reset(QGesture *state)
QPanGesture *pan = static_cast<QPanGesture*>(state);
QPanGesturePrivate *d = pan->d_func();
- d->totalOffset = d->lastOffset = d->offset = QPointF();
+ d->lastOffset = d->offset = QPointF();
d->lastPosition = QPoint();
d->acceleration = 0;
@@ -151,7 +149,7 @@ QPinchGestureRecognizer::QPinchGestureRecognizer()
{
}
-QGesture *QPinchGestureRecognizer::createGesture(QObject *target)
+QGesture *QPinchGestureRecognizer::create(QObject *target)
{
if (target && target->isWidgetType()) {
static_cast<QWidget *>(target)->setAttribute(Qt::WA_AcceptTouchEvents);
@@ -159,7 +157,7 @@ QGesture *QPinchGestureRecognizer::createGesture(QObject *target)
return new QPinchGesture;
}
-QGestureRecognizer::Result QPinchGestureRecognizer::filterEvent(QGesture *state, QObject *, QEvent *event)
+QGestureRecognizer::Result QPinchGestureRecognizer::recognize(QGesture *state, QObject *, QEvent *event)
{
QPinchGesture *q = static_cast<QPinchGesture *>(state);
QPinchGesturePrivate *d = q->d_func();
@@ -170,19 +168,19 @@ QGestureRecognizer::Result QPinchGestureRecognizer::filterEvent(QGesture *state,
switch (event->type()) {
case QEvent::TouchBegin: {
- result = QGestureRecognizer::MaybeGesture;
+ result = QGestureRecognizer::MayBeGesture;
break;
}
case QEvent::TouchEnd: {
if (q->state() != Qt::NoGesture) {
- result = QGestureRecognizer::GestureFinished;
+ result = QGestureRecognizer::FinishGesture;
} else {
- result = QGestureRecognizer::NotGesture;
+ result = QGestureRecognizer::CancelGesture;
}
break;
}
case QEvent::TouchUpdate: {
- d->whatChanged = 0;
+ d->changeFlags = 0;
if (ev->touchPoints().size() == 2) {
QTouchEvent::TouchPoint p1 = ev->touchPoints().at(0);
QTouchEvent::TouchPoint p2 = ev->touchPoints().at(1);
@@ -201,7 +199,7 @@ QGestureRecognizer::Result QPinchGestureRecognizer::filterEvent(QGesture *state,
d->lastCenterPoint = d->centerPoint;
d->centerPoint = centerPoint;
- d->whatChanged |= QPinchGesture::CenterPointChanged;
+ d->changeFlags |= QPinchGesture::CenterPointChanged;
const qreal scaleFactor = QLineF(p1.pos(), p2.pos()).length()
/ QLineF(d->startPosition[0], d->startPosition[1]).length();
@@ -212,7 +210,7 @@ QGestureRecognizer::Result QPinchGestureRecognizer::filterEvent(QGesture *state,
}
d->scaleFactor = scaleFactor;
d->totalScaleFactor += d->scaleFactor - d->lastScaleFactor;
- d->whatChanged |= QPinchGesture::ScaleFactorChanged;
+ d->changeFlags |= QPinchGesture::ScaleFactorChanged;
const qreal rotationAngle = -line.angle();
if (d->isNewSequence)
@@ -221,13 +219,14 @@ QGestureRecognizer::Result QPinchGestureRecognizer::filterEvent(QGesture *state,
d->lastRotationAngle = d->rotationAngle;
d->rotationAngle = rotationAngle;
d->totalRotationAngle += d->rotationAngle - d->lastRotationAngle;
- d->whatChanged |= QPinchGesture::RotationAngleChanged;
+ d->changeFlags |= QPinchGesture::RotationAngleChanged;
+ d->totalChangeFlags |= d->changeFlags;
d->isNewSequence = false;
- result = QGestureRecognizer::GestureTriggered;
+ result = QGestureRecognizer::TriggerGesture;
} else {
d->isNewSequence = true;
- result = QGestureRecognizer::MaybeGesture;
+ result = QGestureRecognizer::MayBeGesture;
}
break;
}
@@ -245,10 +244,10 @@ QGestureRecognizer::Result QPinchGestureRecognizer::filterEvent(QGesture *state,
void QPinchGestureRecognizer::reset(QGesture *state)
{
- QPinchGesture *pinch = static_cast<QPinchGesture*>(state);
+ QPinchGesture *pinch = static_cast<QPinchGesture *>(state);
QPinchGesturePrivate *d = pinch->d_func();
- d->whatChanged = 0;
+ d->totalChangeFlags = d->changeFlags = 0;
d->startCenterPoint = d->lastCenterPoint = d->centerPoint = QPointF();
d->totalScaleFactor = d->lastScaleFactor = d->scaleFactor = 0;