diff options
Diffstat (limited to 'src/quick/handlers')
-rw-r--r-- | src/quick/handlers/handlers.pri | 1 | ||||
-rw-r--r-- | src/quick/handlers/qquickdragaxis.cpp | 3 | ||||
-rw-r--r-- | src/quick/handlers/qquickdragaxis_p.h | 11 | ||||
-rw-r--r-- | src/quick/handlers/qquickdraghandler_p.h | 2 | ||||
-rw-r--r-- | src/quick/handlers/qquickhoverhandler_p.h | 2 | ||||
-rw-r--r-- | src/quick/handlers/qquickmultipointhandler_p.h | 2 | ||||
-rw-r--r-- | src/quick/handlers/qquickpinchhandler_p.h | 2 | ||||
-rw-r--r-- | src/quick/handlers/qquickpointerdevicehandler_p.h | 2 | ||||
-rw-r--r-- | src/quick/handlers/qquickpointerdevicehandler_p_p.h | 2 | ||||
-rw-r--r-- | src/quick/handlers/qquickpointhandler_p.h | 2 | ||||
-rw-r--r-- | src/quick/handlers/qquicksinglepointhandler.cpp | 62 | ||||
-rw-r--r-- | src/quick/handlers/qquicksinglepointhandler_p.h | 15 | ||||
-rw-r--r-- | src/quick/handlers/qquicksinglepointhandler_p_p.h | 79 | ||||
-rw-r--r-- | src/quick/handlers/qquicktaphandler.cpp | 3 | ||||
-rw-r--r-- | src/quick/handlers/qquicktaphandler_p.h | 2 |
15 files changed, 151 insertions, 39 deletions
diff --git a/src/quick/handlers/handlers.pri b/src/quick/handlers/handlers.pri index 1258822f40..226cca22cb 100644 --- a/src/quick/handlers/handlers.pri +++ b/src/quick/handlers/handlers.pri @@ -10,6 +10,7 @@ HEADERS += \ $$PWD/qquickpointerhandler_p_p.h \ $$PWD/qquickpointhandler_p.h \ $$PWD/qquicksinglepointhandler_p.h \ + $$PWD/qquicksinglepointhandler_p_p.h \ $$PWD/qquicktaphandler_p.h \ $$PWD/qquickdragaxis_p.h diff --git a/src/quick/handlers/qquickdragaxis.cpp b/src/quick/handlers/qquickdragaxis.cpp index 5efe19b2fe..88470c8a7d 100644 --- a/src/quick/handlers/qquickdragaxis.cpp +++ b/src/quick/handlers/qquickdragaxis.cpp @@ -39,6 +39,8 @@ #include "qquickdragaxis_p.h" #include <limits> +QT_BEGIN_NAMESPACE + QQuickDragAxis::QQuickDragAxis() : m_minimum(-std::numeric_limits<qreal>::max()) , m_maximum(std::numeric_limits<qreal>::max()) @@ -73,3 +75,4 @@ void QQuickDragAxis::setEnabled(bool enabled) emit enabledChanged(); } +QT_END_NAMESPACE diff --git a/src/quick/handlers/qquickdragaxis_p.h b/src/quick/handlers/qquickdragaxis_p.h index 2c2e0a426d..a4649d5eb9 100644 --- a/src/quick/handlers/qquickdragaxis_p.h +++ b/src/quick/handlers/qquickdragaxis_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2019 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtQuick module of the Qt Toolkit. @@ -51,10 +51,11 @@ // We mean it. // -#include <QtCore/qobject.h> -#include <QtCore/qglobal.h> +#include <private/qtquickglobal_p.h> -class Q_AUTOTEST_EXPORT QQuickDragAxis : public QObject +QT_BEGIN_NAMESPACE + +class Q_QUICK_PRIVATE_EXPORT QQuickDragAxis : public QObject { Q_OBJECT Q_PROPERTY(qreal minimum READ minimum WRITE setMinimum NOTIFY minimumChanged) @@ -84,4 +85,6 @@ private: bool m_enabled; }; +QT_END_NAMESPACE + #endif // QQUICKDRAGAXIS_P_H diff --git a/src/quick/handlers/qquickdraghandler_p.h b/src/quick/handlers/qquickdraghandler_p.h index 387a81eb43..748026488a 100644 --- a/src/quick/handlers/qquickdraghandler_p.h +++ b/src/quick/handlers/qquickdraghandler_p.h @@ -56,7 +56,7 @@ QT_BEGIN_NAMESPACE -class Q_AUTOTEST_EXPORT QQuickDragHandler : public QQuickMultiPointHandler +class Q_QUICK_PRIVATE_EXPORT QQuickDragHandler : public QQuickMultiPointHandler { Q_OBJECT Q_PROPERTY(QQuickDragAxis * xAxis READ xAxis CONSTANT) diff --git a/src/quick/handlers/qquickhoverhandler_p.h b/src/quick/handlers/qquickhoverhandler_p.h index 1ee2aeb7e6..d8e5fc00a1 100644 --- a/src/quick/handlers/qquickhoverhandler_p.h +++ b/src/quick/handlers/qquickhoverhandler_p.h @@ -58,7 +58,7 @@ QT_BEGIN_NAMESPACE -class Q_AUTOTEST_EXPORT QQuickHoverHandler : public QQuickSinglePointHandler +class Q_QUICK_PRIVATE_EXPORT QQuickHoverHandler : public QQuickSinglePointHandler { Q_OBJECT Q_PROPERTY(bool hovered READ isHovered NOTIFY hoveredChanged) diff --git a/src/quick/handlers/qquickmultipointhandler_p.h b/src/quick/handlers/qquickmultipointhandler_p.h index 94142013cc..06f170154b 100644 --- a/src/quick/handlers/qquickmultipointhandler_p.h +++ b/src/quick/handlers/qquickmultipointhandler_p.h @@ -58,7 +58,7 @@ QT_BEGIN_NAMESPACE -class Q_AUTOTEST_EXPORT QQuickMultiPointHandler : public QQuickPointerDeviceHandler +class Q_QUICK_PRIVATE_EXPORT QQuickMultiPointHandler : public QQuickPointerDeviceHandler { Q_OBJECT Q_PROPERTY(int minimumPointCount READ minimumPointCount WRITE setMinimumPointCount NOTIFY minimumPointCountChanged) diff --git a/src/quick/handlers/qquickpinchhandler_p.h b/src/quick/handlers/qquickpinchhandler_p.h index 1afc028758..766d57f892 100644 --- a/src/quick/handlers/qquickpinchhandler_p.h +++ b/src/quick/handlers/qquickpinchhandler_p.h @@ -59,7 +59,7 @@ QT_BEGIN_NAMESPACE -class Q_AUTOTEST_EXPORT QQuickPinchHandler : public QQuickMultiPointHandler +class Q_QUICK_PRIVATE_EXPORT QQuickPinchHandler : public QQuickMultiPointHandler { Q_OBJECT Q_PROPERTY(qreal minimumScale READ minimumScale WRITE setMinimumScale NOTIFY minimumScaleChanged) diff --git a/src/quick/handlers/qquickpointerdevicehandler_p.h b/src/quick/handlers/qquickpointerdevicehandler_p.h index 82b24369d3..bb15142824 100644 --- a/src/quick/handlers/qquickpointerdevicehandler_p.h +++ b/src/quick/handlers/qquickpointerdevicehandler_p.h @@ -56,7 +56,7 @@ QT_BEGIN_NAMESPACE class QQuickPointerDeviceHandlerPrivate; -class Q_AUTOTEST_EXPORT QQuickPointerDeviceHandler : public QQuickPointerHandler +class Q_QUICK_PRIVATE_EXPORT QQuickPointerDeviceHandler : public QQuickPointerHandler { Q_OBJECT Q_PROPERTY(QQuickPointerDevice::DeviceTypes acceptedDevices READ acceptedDevices WRITE setAcceptedDevices NOTIFY acceptedDevicesChanged) diff --git a/src/quick/handlers/qquickpointerdevicehandler_p_p.h b/src/quick/handlers/qquickpointerdevicehandler_p_p.h index 6a950590f3..03272d9f69 100644 --- a/src/quick/handlers/qquickpointerdevicehandler_p_p.h +++ b/src/quick/handlers/qquickpointerdevicehandler_p_p.h @@ -56,7 +56,7 @@ QT_BEGIN_NAMESPACE -class Q_AUTOTEST_EXPORT QQuickPointerDeviceHandlerPrivate : public QQuickPointerHandlerPrivate +class Q_QUICK_PRIVATE_EXPORT QQuickPointerDeviceHandlerPrivate : public QQuickPointerHandlerPrivate { Q_DECLARE_PUBLIC(QQuickPointerDeviceHandler) diff --git a/src/quick/handlers/qquickpointhandler_p.h b/src/quick/handlers/qquickpointhandler_p.h index 380ce1f90f..c197cb4f20 100644 --- a/src/quick/handlers/qquickpointhandler_p.h +++ b/src/quick/handlers/qquickpointhandler_p.h @@ -55,7 +55,7 @@ QT_BEGIN_NAMESPACE -class Q_AUTOTEST_EXPORT QQuickPointHandler : public QQuickSinglePointHandler +class Q_QUICK_PRIVATE_EXPORT QQuickPointHandler : public QQuickSinglePointHandler { Q_OBJECT Q_PROPERTY(QVector2D translation READ translation NOTIFY translationChanged) diff --git a/src/quick/handlers/qquicksinglepointhandler.cpp b/src/quick/handlers/qquicksinglepointhandler.cpp index ae162bed87..c0fa39fad3 100644 --- a/src/quick/handlers/qquicksinglepointhandler.cpp +++ b/src/quick/handlers/qquicksinglepointhandler.cpp @@ -38,6 +38,7 @@ ****************************************************************************/ #include "qquicksinglepointhandler_p.h" +#include "qquicksinglepointhandler_p_p.h" QT_BEGIN_NAMESPACE Q_DECLARE_LOGGING_CATEGORY(DBG_TOUCH_TARGET) @@ -59,19 +60,25 @@ Q_DECLARE_LOGGING_CATEGORY(DBG_TOUCH_TARGET) */ QQuickSinglePointHandler::QQuickSinglePointHandler(QQuickItem *parent) - : QQuickPointerDeviceHandler(parent) + : QQuickPointerDeviceHandler(*(new QQuickSinglePointHandlerPrivate), parent) +{ +} + +QQuickSinglePointHandler::QQuickSinglePointHandler(QQuickSinglePointHandlerPrivate &dd, QQuickItem *parent) + : QQuickPointerDeviceHandler(dd, parent) { } bool QQuickSinglePointHandler::wantsPointerEvent(QQuickPointerEvent *event) { + Q_D(QQuickSinglePointHandler); if (!QQuickPointerDeviceHandler::wantsPointerEvent(event)) return false; if (event->device()->pointerType() != QQuickPointerDevice::Finger && (event->buttons() & acceptedButtons()) == 0 && (event->button() & acceptedButtons()) == 0) return false; - if (m_pointInfo.m_id) { + if (d->pointInfo.id()) { // We already know which one we want, so check whether it's there. // It's expected to be an update or a release. // If we no longer want it, cancel the grab. @@ -81,7 +88,7 @@ bool QQuickSinglePointHandler::wantsPointerEvent(QQuickPointerEvent *event) int c = event->pointCount(); for (int i = 0; i < c; ++i) { QQuickEventPoint *p = event->point(i); - const bool found = (p->pointId() == m_pointInfo.m_id); + const bool found = (p->pointId() == d->pointInfo.id()); if (found) missing = false; if (wantsEventPoint(p)) { @@ -91,10 +98,10 @@ bool QQuickSinglePointHandler::wantsPointerEvent(QQuickPointerEvent *event) } } if (missing) - qCWarning(DBG_TOUCH_TARGET) << this << "pointId" << hex << m_pointInfo.m_id + qCWarning(DBG_TOUCH_TARGET) << this << "pointId" << hex << d->pointInfo.id() << "is missing from current event, but was neither canceled nor released"; if (point) { - if (candidatePointCount == 1 || (candidatePointCount > 1 && m_ignoreAdditionalPoints)) { + if (candidatePointCount == 1 || (candidatePointCount > 1 && d->ignoreAdditionalPoints)) { point->setAccepted(); return true; } else { @@ -121,35 +128,37 @@ bool QQuickSinglePointHandler::wantsPointerEvent(QQuickPointerEvent *event) chosen->setAccepted(); } } - return m_pointInfo.m_id; + return d->pointInfo.id(); } void QQuickSinglePointHandler::handlePointerEventImpl(QQuickPointerEvent *event) { + Q_D(QQuickSinglePointHandler); QQuickPointerDeviceHandler::handlePointerEventImpl(event); - QQuickEventPoint *currentPoint = event->pointById(m_pointInfo.m_id); + QQuickEventPoint *currentPoint = event->pointById(d->pointInfo.id()); Q_ASSERT(currentPoint); - m_pointInfo.reset(currentPoint); + d->pointInfo.reset(currentPoint); handleEventPoint(currentPoint); if (currentPoint->state() == QQuickEventPoint::Released && (event->buttons() & acceptedButtons()) == Qt::NoButton) { setExclusiveGrab(currentPoint, false); - reset(); + d->reset(); } emit pointChanged(); } void QQuickSinglePointHandler::onGrabChanged(QQuickPointerHandler *grabber, QQuickEventPoint::GrabTransition transition, QQuickEventPoint *point) { + Q_D(QQuickSinglePointHandler); if (grabber != this) return; switch (transition) { case QQuickEventPoint::GrabExclusive: - m_pointInfo.m_sceneGrabPosition = point->sceneGrabPosition(); + d->pointInfo.m_sceneGrabPosition = point->sceneGrabPosition(); setActive(true); QQuickPointerHandler::onGrabChanged(grabber, transition, point); break; case QQuickEventPoint::GrabPassive: - m_pointInfo.m_sceneGrabPosition = point->sceneGrabPosition(); + d->pointInfo.m_sceneGrabPosition = point->sceneGrabPosition(); QQuickPointerHandler::onGrabChanged(grabber, transition, point); break; case QQuickEventPoint::OverrideGrabPassive: @@ -160,32 +169,35 @@ void QQuickSinglePointHandler::onGrabChanged(QQuickPointerHandler *grabber, QQui case QQuickEventPoint::CancelGrabExclusive: // the grab is lost or relinquished, so the point is no longer relevant QQuickPointerHandler::onGrabChanged(grabber, transition, point); - reset(); + d->reset(); break; } } void QQuickSinglePointHandler::setIgnoreAdditionalPoints(bool v) { - m_ignoreAdditionalPoints = v; + Q_D(QQuickSinglePointHandler); + d->ignoreAdditionalPoints = v; } void QQuickSinglePointHandler::moveTarget(QPointF pos, QQuickEventPoint *point) { + Q_D(QQuickSinglePointHandler); target()->setPosition(pos); - m_pointInfo.m_scenePosition = point->scenePosition(); - m_pointInfo.m_position = target()->mapFromScene(m_pointInfo.m_scenePosition); + d->pointInfo.m_scenePosition = point->scenePosition(); + d->pointInfo.m_position = target()->mapFromScene(d->pointInfo.m_scenePosition); } void QQuickSinglePointHandler::setPointId(int id) { - m_pointInfo.m_id = id; + Q_D(QQuickSinglePointHandler); + d->pointInfo.m_id = id; } -void QQuickSinglePointHandler::reset() +QQuickHandlerPoint QQuickSinglePointHandler::point() const { - setActive(false); - m_pointInfo.reset(); + Q_D(const QQuickSinglePointHandler); + return d->pointInfo; } /*! @@ -196,4 +208,16 @@ void QQuickSinglePointHandler::reset() handled, this object is reset to default values (all coordinates are 0). */ +QQuickSinglePointHandlerPrivate::QQuickSinglePointHandlerPrivate() + : QQuickPointerDeviceHandlerPrivate() +{ +} + +void QQuickSinglePointHandlerPrivate::reset() +{ + Q_Q(QQuickSinglePointHandler); + q->setActive(false); + pointInfo.reset(); +} + QT_END_NAMESPACE diff --git a/src/quick/handlers/qquicksinglepointhandler_p.h b/src/quick/handlers/qquicksinglepointhandler_p.h index 7bf8eff999..edc55aaaf6 100644 --- a/src/quick/handlers/qquicksinglepointhandler_p.h +++ b/src/quick/handlers/qquicksinglepointhandler_p.h @@ -56,24 +56,29 @@ QT_BEGIN_NAMESPACE +class QQuickSinglePointHandlerPrivate; + class Q_QUICK_PRIVATE_EXPORT QQuickSinglePointHandler : public QQuickPointerDeviceHandler { Q_OBJECT Q_PROPERTY(QQuickHandlerPoint point READ point NOTIFY pointChanged) + public: explicit QQuickSinglePointHandler(QQuickItem *parent = nullptr); - QQuickHandlerPoint point() const { return m_pointInfo; } + QQuickHandlerPoint point() const; Q_SIGNALS: void pointChanged(); protected: + QQuickSinglePointHandler(QQuickSinglePointHandlerPrivate &dd, QQuickItem *parent); + bool wantsPointerEvent(QQuickPointerEvent *event) override; void handlePointerEventImpl(QQuickPointerEvent *event) override; virtual void handleEventPoint(QQuickEventPoint *point) = 0; - QQuickEventPoint *currentPoint(QQuickPointerEvent *ev) { return ev->pointById(m_pointInfo.m_id); } + QQuickEventPoint *currentPoint(QQuickPointerEvent *ev); void onGrabChanged(QQuickPointerHandler *grabber, QQuickEventPoint::GrabTransition transition, QQuickEventPoint *point) override; void setIgnoreAdditionalPoints(bool v = true); @@ -82,11 +87,7 @@ protected: void setPointId(int id); - void reset(); - -private: - QQuickHandlerPoint m_pointInfo; - bool m_ignoreAdditionalPoints = false; + Q_DECLARE_PRIVATE(QQuickSinglePointHandler) }; QT_END_NAMESPACE diff --git a/src/quick/handlers/qquicksinglepointhandler_p_p.h b/src/quick/handlers/qquicksinglepointhandler_p_p.h new file mode 100644 index 0000000000..1e66c25e14 --- /dev/null +++ b/src/quick/handlers/qquicksinglepointhandler_p_p.h @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtQuick 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$ +** +****************************************************************************/ + +#ifndef QQUICKPOINTERSINGLEHANDLER_P_H +#define QQUICKPOINTERSINGLEHANDLER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qquickhandlerpoint_p.h" +#include "qquickpointerdevicehandler_p_p.h" +#include "qquicksinglepointhandler_p.h" + +QT_BEGIN_NAMESPACE + +class Q_QUICK_PRIVATE_EXPORT QQuickSinglePointHandlerPrivate : public QQuickPointerDeviceHandlerPrivate +{ + Q_DECLARE_PUBLIC(QQuickSinglePointHandler) + +public: + static QQuickSinglePointHandlerPrivate* get(QQuickSinglePointHandler *q) { return q->d_func(); } + static const QQuickSinglePointHandlerPrivate* get(const QQuickSinglePointHandler *q) { return q->d_func(); } + + QQuickSinglePointHandlerPrivate(); + + void reset(); + + QQuickHandlerPoint pointInfo; + bool ignoreAdditionalPoints = false; +}; + +QT_END_NAMESPACE + +#endif // QQUICKPOINTERSINGLEHANDLER_P_H + diff --git a/src/quick/handlers/qquicktaphandler.cpp b/src/quick/handlers/qquicktaphandler.cpp index 41ac294df3..081645da71 100644 --- a/src/quick/handlers/qquicktaphandler.cpp +++ b/src/quick/handlers/qquicktaphandler.cpp @@ -38,6 +38,7 @@ ****************************************************************************/ #include "qquicktaphandler_p.h" +#include "qquicksinglepointhandler_p_p.h" #include <qpa/qplatformtheme.h> #include <private/qguiapplication_p.h> #include <QtGui/qstylehints.h> @@ -317,7 +318,7 @@ void QQuickTapHandler::setPressed(bool press, bool cancel, QQuickEventPoint *poi setExclusiveGrab(point, false); // In case there is a filtering parent (Flickable), we should not give up the passive grab, // so that it can continue to filter future events. - reset(); + d_func()->reset(); emit pointChanged(); } } diff --git a/src/quick/handlers/qquicktaphandler_p.h b/src/quick/handlers/qquicktaphandler_p.h index 6ec5d55227..56e08590b2 100644 --- a/src/quick/handlers/qquicktaphandler_p.h +++ b/src/quick/handlers/qquicktaphandler_p.h @@ -58,7 +58,7 @@ QT_BEGIN_NAMESPACE -class Q_AUTOTEST_EXPORT QQuickTapHandler : public QQuickSinglePointHandler +class Q_QUICK_PRIVATE_EXPORT QQuickTapHandler : public QQuickSinglePointHandler { Q_OBJECT Q_PROPERTY(bool pressed READ isPressed NOTIFY pressedChanged) |