diff options
Diffstat (limited to 'src/quick/handlers/qquickpointerhandler_p.h')
-rw-r--r-- | src/quick/handlers/qquickpointerhandler_p.h | 122 |
1 files changed, 61 insertions, 61 deletions
diff --git a/src/quick/handlers/qquickpointerhandler_p.h b/src/quick/handlers/qquickpointerhandler_p.h index c600e42491..e54338f677 100644 --- a/src/quick/handlers/qquickpointerhandler_p.h +++ b/src/quick/handlers/qquickpointerhandler_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2018 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 #ifndef QQUICKPOINTERHANDLER_H #define QQUICKPOINTERHANDLER_H @@ -51,16 +15,25 @@ // We mean it. // -#include <QtQuick/private/qquickevents_p_p.h> -#include <QtQuick/private/qquickitem_p.h> +#include <QtCore/QObject> +#include <QtCore/qloggingcategory.h> +#include <QtCore/qtconfigmacros.h> +#include <QtGui/qeventpoint.h> +#include <QtGui/qpointingdevice.h> +#include <QtQml/QQmlParserStatus> +#include <QtQml/qqmlregistration.h> +#include <QtQuick/qtquickglobal.h> +#include <QtQuick/qtquickexports.h> QT_BEGIN_NAMESPACE Q_DECLARE_LOGGING_CATEGORY(lcPointerHandlerDispatch) +class QQuickItem; class QQuickPointerHandlerPrivate; +class QPointerEvent; -class Q_QUICK_PRIVATE_EXPORT QQuickPointerHandler : public QObject, public QQmlParserStatus +class Q_QUICK_EXPORT QQuickPointerHandler : public QObject, public QQmlParserStatus { Q_OBJECT Q_INTERFACES(QQmlParserStatus) @@ -68,9 +41,18 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPointerHandler : public QObject, public QQmlP Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged) Q_PROPERTY(bool active READ active NOTIFY activeChanged) Q_PROPERTY(QQuickItem * target READ target WRITE setTarget NOTIFY targetChanged) - Q_PROPERTY(QQuickItem * parent READ parentItem CONSTANT) + Q_PROPERTY(QQuickItem * parent READ parentItem WRITE setParentItem NOTIFY parentChanged) Q_PROPERTY(GrabPermissions grabPermissions READ grabPermissions WRITE setGrabPermissions NOTIFY grabPermissionChanged) Q_PROPERTY(qreal margin READ margin WRITE setMargin NOTIFY marginChanged) + Q_PROPERTY(int dragThreshold READ dragThreshold WRITE setDragThreshold RESET resetDragThreshold NOTIFY dragThresholdChanged REVISION(2, 15)) +#if QT_CONFIG(cursor) + Q_PROPERTY(Qt::CursorShape cursorShape READ cursorShape WRITE setCursorShape RESET resetCursorShape NOTIFY cursorShapeChanged REVISION(2, 15)) +#endif + + Q_CLASSINFO("ParentProperty", "parent") + QML_NAMED_ELEMENT(PointerHandler) + QML_UNCREATABLE("PointerHandler is an abstract base class.") + QML_ADDED_IN_VERSION(2, 12) public: explicit QQuickPointerHandler(QQuickItem *parent = nullptr); @@ -101,8 +83,9 @@ public: void setTarget(QQuickItem *target); QQuickItem * parentItem() const; + void setParentItem(QQuickItem *p); - void handlePointerEvent(QQuickPointerEvent *event); + void handlePointerEvent(QPointerEvent *event); GrabPermissions grabPermissions() const; void setGrabPermissions(GrabPermissions grabPermissions); @@ -110,38 +93,57 @@ public: qreal margin() const; void setMargin(qreal pointDistanceThreshold); + int dragThreshold() const; + void setDragThreshold(int t); + void resetDragThreshold(); + +#if QT_CONFIG(cursor) + Qt::CursorShape cursorShape() const; + void setCursorShape(Qt::CursorShape shape); + void resetCursorShape(); + bool isCursorShapeExplicitlySet() const; +#endif + Q_SIGNALS: void enabledChanged(); void activeChanged(); void targetChanged(); void marginChanged(); - void grabChanged(QQuickEventPoint::GrabTransition transition, QQuickEventPoint *point); + Q_REVISION(2, 15) void dragThresholdChanged(); + void grabChanged(QPointingDevice::GrabTransition transition, QEventPoint point); void grabPermissionChanged(); - void canceled(QQuickEventPoint *point); + void canceled(QEventPoint point); +#if QT_CONFIG(cursor) + Q_REVISION(2, 15) void cursorShapeChanged(); +#endif + Q_REVISION(6, 3) void parentChanged(); protected: QQuickPointerHandler(QQuickPointerHandlerPrivate &dd, QQuickItem *parent); void classBegin() override; void componentComplete() override; + bool event(QEvent *) override; - QQuickPointerEvent *currentEvent(); - virtual bool wantsPointerEvent(QQuickPointerEvent *event); - virtual bool wantsEventPoint(QQuickEventPoint *point); - virtual void handlePointerEventImpl(QQuickPointerEvent *event); + QPointerEvent *currentEvent(); + virtual bool wantsPointerEvent(QPointerEvent *event); + virtual bool wantsEventPoint(const QPointerEvent *event, const QEventPoint &point); + virtual void handlePointerEventImpl(QPointerEvent *event); void setActive(bool active); virtual void onTargetChanged(QQuickItem *oldTarget) { Q_UNUSED(oldTarget); } virtual void onActiveChanged() { } - virtual void onGrabChanged(QQuickPointerHandler *grabber, QQuickEventPoint::GrabTransition transition, QQuickEventPoint *point); - virtual bool canGrab(QQuickEventPoint *point); - virtual bool approveGrabTransition(QQuickEventPoint *point, QObject *proposedGrabber); - void setPassiveGrab(QQuickEventPoint *point, bool grab = true); - bool setExclusiveGrab(QQuickEventPoint *point, bool grab = true); - void cancelAllGrabs(QQuickEventPoint *point); - QPointF eventPos(const QQuickEventPoint *point) const; - bool parentContains(const QQuickEventPoint *point) const; - - friend class QQuickEventPoint; + virtual void onGrabChanged(QQuickPointerHandler *grabber, QPointingDevice::GrabTransition transition, + QPointerEvent *event, QEventPoint &point); + virtual bool canGrab(QPointerEvent *event, const QEventPoint &point); + virtual bool approveGrabTransition(QPointerEvent *event, const QEventPoint &point, QObject *proposedGrabber); + void setPassiveGrab(QPointerEvent *event, const QEventPoint &point, bool grab = true); + bool setExclusiveGrab(QPointerEvent *ev, const QEventPoint &point, bool grab = true); + void cancelAllGrabs(QPointerEvent *event, QEventPoint &point); + QPointF eventPos(const QEventPoint &point) const; + bool parentContains(const QEventPoint &point) const; + bool parentContains(const QPointF &scenePosition) const; + + friend class QQuickDeliveryAgentPrivate; friend class QQuickItemPrivate; friend class QQuickWindowPrivate; @@ -152,6 +154,4 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(QQuickPointerHandler::GrabPermissions) QT_END_NAMESPACE -QML_DECLARE_TYPE(QQuickPointerHandler) - #endif // QQUICKPOINTERHANDLER_H |