aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/handlers/qquickhoverhandler_p.h
blob: 39ceb3df21bad3fd855a89c995215719cb9ae5db (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// 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 QQUICKHOVERHANDLER_H
#define QQUICKHOVERHANDLER_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 "qquickitem.h"
#include "qevent.h"
#include "qquicksinglepointhandler_p.h"
#include <QtCore/qbasictimer.h>

QT_BEGIN_NAMESPACE

class Q_QUICK_PRIVATE_EXPORT QQuickHoverHandler : public QQuickSinglePointHandler
{
    Q_OBJECT
    Q_PROPERTY(bool hovered READ isHovered NOTIFY hoveredChanged)
    Q_PROPERTY(bool blocking READ isBlocking WRITE setBlocking NOTIFY blockingChanged REVISION(6, 3))
    QML_NAMED_ELEMENT(HoverHandler)
    QML_ADDED_IN_VERSION(2, 12)

public:
    explicit QQuickHoverHandler(QQuickItem *parent = nullptr);
    ~QQuickHoverHandler();

    bool event(QEvent *) override;

    bool isHovered() const { return m_hovered; }

    bool isBlocking() const { return m_blocking; }
    void setBlocking(bool blocking);

Q_SIGNALS:
    void hoveredChanged();
    Q_REVISION(6, 3) void blockingChanged();

protected:
    void componentComplete() override;
    bool wantsPointerEvent(QPointerEvent *event) override;
    void handleEventPoint(QPointerEvent *ev, QEventPoint &point) override;

private:
    void setHovered(bool hovered);

private:
    bool m_hovered = false;
    bool m_hoveredTablet = false;
    bool m_blocking = false;
};

QT_END_NAMESPACE

QML_DECLARE_TYPE(QQuickHoverHandler)

#endif // QQUICKHOVERHANDLER_H