| 1 | // Copyright (C) 2018 The Qt Company Ltd. |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 3 | |
| 4 | #ifndef QQUICKHOVERHANDLER_H |
| 5 | #define QQUICKHOVERHANDLER_H |
| 6 | |
| 7 | // |
| 8 | // W A R N I N G |
| 9 | // ------------- |
| 10 | // |
| 11 | // This file is not part of the Qt API. It exists purely as an |
| 12 | // implementation detail. This header file may change from version to |
| 13 | // version without notice, or even be removed. |
| 14 | // |
| 15 | // We mean it. |
| 16 | // |
| 17 | |
| 18 | #include <QtCore/qbasictimer.h> |
| 19 | #include <QtGui/qevent.h> |
| 20 | #include <QtQuick/qquickitem.h> |
| 21 | |
| 22 | #include "qquicksinglepointhandler_p.h" |
| 23 | |
| 24 | QT_BEGIN_NAMESPACE |
| 25 | |
| 26 | class QQuickHoverHandlerPrivate; |
| 27 | |
| 28 | class Q_QUICK_EXPORT QQuickHoverHandler : public QQuickSinglePointHandler |
| 29 | { |
| 30 | Q_OBJECT |
| 31 | Q_PROPERTY(bool hovered READ isHovered NOTIFY hoveredChanged) |
| 32 | Q_PROPERTY(bool blocking READ isBlocking WRITE setBlocking NOTIFY blockingChanged REVISION(6, 3)) |
| 33 | QML_NAMED_ELEMENT(HoverHandler) |
| 34 | QML_ADDED_IN_VERSION(2, 12) |
| 35 | |
| 36 | public: |
| 37 | explicit QQuickHoverHandler(QQuickItem *parent = nullptr); |
| 38 | ~QQuickHoverHandler(); |
| 39 | |
| 40 | bool event(QEvent *) override; |
| 41 | |
| 42 | bool isHovered() const { return m_hovered; } |
| 43 | |
| 44 | bool isBlocking() const { return m_blocking; } |
| 45 | void setBlocking(bool blocking); |
| 46 | |
| 47 | Q_SIGNALS: |
| 48 | void hoveredChanged(); |
| 49 | Q_REVISION(6, 3) void blockingChanged(); |
| 50 | |
| 51 | protected: |
| 52 | void componentComplete() override; |
| 53 | bool wantsPointerEvent(QPointerEvent *event) override; |
| 54 | void handleEventPoint(QPointerEvent *ev, QEventPoint &point) override; |
| 55 | |
| 56 | Q_DECLARE_PRIVATE(QQuickHoverHandler) |
| 57 | |
| 58 | private: |
| 59 | void setHovered(bool hovered); |
| 60 | |
| 61 | private: |
| 62 | bool m_hovered = false; |
| 63 | bool m_hoveredTablet = false; |
| 64 | bool m_blocking = false; |
| 65 | }; |
| 66 | |
| 67 | QT_END_NAMESPACE |
| 68 | |
| 69 | #endif // QQUICKHOVERHANDLER_H |
| 70 | |