summaryrefslogtreecommitdiffstats
path: root/src/widgets/kernel/qstandardgestures.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets/kernel/qstandardgestures.cpp')
-rw-r--r--src/widgets/kernel/qstandardgestures.cpp82
1 files changed, 22 insertions, 60 deletions
diff --git a/src/widgets/kernel/qstandardgestures.cpp b/src/widgets/kernel/qstandardgestures.cpp
index 48a2770df3..4effc1a2d1 100644
--- a/src/widgets/kernel/qstandardgestures.cpp
+++ b/src/widgets/kernel/qstandardgestures.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtWidgets module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qstandardgestures_p.h"
#include "qgesture.h"
@@ -90,9 +54,7 @@ QGestureRecognizer::Result QPanGestureRecognizer::recognize(QGesture *state,
QGestureRecognizer::Result result = QGestureRecognizer::Ignore;
switch (event->type()) {
case QEvent::TouchBegin: {
- const QTouchEvent *ev = static_cast<const QTouchEvent *>(event);
result = QGestureRecognizer::MayBeGesture;
- QEventPoint p = ev->touchPoints().at(0);
d->lastOffset = d->offset = QPointF();
d->pointCount = m_pointCount;
break;
@@ -100,9 +62,9 @@ QGestureRecognizer::Result QPanGestureRecognizer::recognize(QGesture *state,
case QEvent::TouchEnd: {
if (q->state() != Qt::NoGesture) {
const QTouchEvent *ev = static_cast<const QTouchEvent *>(event);
- if (ev->touchPoints().size() == d->pointCount) {
+ if (ev->points().size() == d->pointCount) {
d->lastOffset = d->offset;
- d->offset = panOffset(ev->touchPoints(), d->pointCount);
+ d->offset = panOffset(ev->points(), d->pointCount);
}
result = QGestureRecognizer::FinishGesture;
} else {
@@ -112,12 +74,12 @@ QGestureRecognizer::Result QPanGestureRecognizer::recognize(QGesture *state,
}
case QEvent::TouchUpdate: {
const QTouchEvent *ev = static_cast<const QTouchEvent *>(event);
- if (ev->touchPoints().size() >= d->pointCount) {
+ if (ev->points().size() >= d->pointCount) {
d->lastOffset = d->offset;
- d->offset = panOffset(ev->touchPoints(), d->pointCount);
+ d->offset = panOffset(ev->points(), d->pointCount);
if (d->offset.x() > 10 || d->offset.y() > 10 ||
d->offset.x() < -10 || d->offset.y() < -10) {
- q->setHotSpot(ev->touchPoints().first().globalPressPosition());
+ q->setHotSpot(ev->points().first().globalPressPosition());
result = QGestureRecognizer::TriggerGesture;
} else {
result = QGestureRecognizer::MayBeGesture;
@@ -184,9 +146,9 @@ QGestureRecognizer::Result QPinchGestureRecognizer::recognize(QGesture *state,
case QEvent::TouchUpdate: {
const QTouchEvent *ev = static_cast<const QTouchEvent *>(event);
d->changeFlags = { };
- if (ev->touchPoints().size() == 2) {
- QEventPoint p1 = ev->touchPoints().at(0);
- QEventPoint p2 = ev->touchPoints().at(1);
+ if (ev->points().size() == 2) {
+ const QEventPoint &p1 = ev->points().at(0);
+ const QEventPoint &p2 = ev->points().at(1);
d->hotSpot = p1.globalPosition();
d->isHotSpotSet = true;
@@ -313,11 +275,11 @@ QGestureRecognizer::Result QSwipeGestureRecognizer::recognize(QGesture *state,
const QTouchEvent *ev = static_cast<const QTouchEvent *>(event);
if (d->state == QSwipeGesturePrivate::NoGesture)
result = QGestureRecognizer::CancelGesture;
- else if (ev->touchPoints().size() == 3) {
+ else if (ev->points().size() == 3) {
d->state = QSwipeGesturePrivate::ThreePointsReached;
- QEventPoint p1 = ev->touchPoints().at(0);
- QEventPoint p2 = ev->touchPoints().at(1);
- QEventPoint p3 = ev->touchPoints().at(2);
+ const QEventPoint &p1 = ev->points().at(0);
+ const QEventPoint &p2 = ev->points().at(1);
+ const QEventPoint &p3 = ev->points().at(2);
if (d->lastPositions[0].isNull()) {
d->lastPositions[0] = p1.globalPressPosition().toPoint();
@@ -370,7 +332,7 @@ QGestureRecognizer::Result QSwipeGestureRecognizer::recognize(QGesture *state,
else
result = QGestureRecognizer::MayBeGesture;
}
- } else if (ev->touchPoints().size() > 3) {
+ } else if (ev->points().size() > 3) {
result = QGestureRecognizer::CancelGesture;
} else { // less than 3 touch points
switch (d->state) {
@@ -439,15 +401,15 @@ QGestureRecognizer::Result QTapGestureRecognizer::recognize(QGesture *state,
switch (event->type()) {
case QEvent::TouchBegin: {
- d->position = ev->touchPoints().at(0).position();
- q->setHotSpot(ev->touchPoints().at(0).globalPosition());
+ d->position = ev->points().at(0).position();
+ q->setHotSpot(ev->points().at(0).globalPosition());
result = QGestureRecognizer::TriggerGesture;
break;
}
case QEvent::TouchUpdate:
case QEvent::TouchEnd: {
- if (q->state() != Qt::NoGesture && ev->touchPoints().size() == 1) {
- QEventPoint p = ev->touchPoints().at(0);
+ if (q->state() != Qt::NoGesture && ev->points().size() == 1) {
+ const QEventPoint &p = ev->points().at(0);
QPoint delta = p.position().toPoint() - p.pressPosition().toPoint();
enum { TapRadius = 40 };
if (delta.manhattanLength() <= TapRadius) {
@@ -535,7 +497,7 @@ QTapAndHoldGestureRecognizer::recognize(QGesture *state, QObject *object,
}
case QEvent::TouchBegin: {
const QTouchEvent *ev = static_cast<const QTouchEvent *>(event);
- d->position = ev->touchPoints().at(0).globalPressPosition();
+ d->position = ev->points().at(0).globalPressPosition();
q->setHotSpot(d->position);
if (d->timerId)
q->killTimer(d->timerId);
@@ -550,8 +512,8 @@ QTapAndHoldGestureRecognizer::recognize(QGesture *state, QObject *object,
return QGestureRecognizer::CancelGesture; // get out of the MayBeGesture state
case QEvent::TouchUpdate: {
const QTouchEvent *ev = static_cast<const QTouchEvent *>(event);
- if (d->timerId && ev->touchPoints().size() == 1) {
- QEventPoint p = ev->touchPoints().at(0);
+ if (d->timerId && ev->points().size() == 1) {
+ const QEventPoint &p = ev->points().at(0);
QPoint delta = p.position().toPoint() - p.pressPosition().toPoint();
if (delta.manhattanLength() <= TapRadius)
return QGestureRecognizer::MayBeGesture;