aboutsummaryrefslogtreecommitdiffstats
path: root/plugin/cursornavigationattached.h
blob: 2be0f729c55f4e932d7015eb9a518ee2bdcd380b (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
#ifndef CURSORNAVIGATIONATTACHED_H
#define CURSORNAVIGATIONATTACHED_H

//#include <qqml.h>
#include <QObject>

class CursorNavigation;
class QQuickItem;
class QQuickWindow;

class CursorNavigationAttached : public QObject
{
    Q_OBJECT
    //is available for cursor navigation
    Q_PROPERTY(bool acceptsCursor READ acceptsCursor WRITE setAcceptsCursor NOTIFY acceptsCursorChanged)
    //is available for cursor navigation
    Q_PROPERTY(bool hasCursor READ hasCursor NOTIFY hasCursorChanged)
    //traps cursor. a trapped cursor can not be traversed outside of the item that traps it
    Q_PROPERTY(bool trapsCursor READ trapsCursor WRITE setTrapsCursor NOTIFY trapsCursorChanged)
    //proxy cursor to other items
    //Q_PROPERTY(QQmlListProperty<QQuickItem> preferredCursorTargets READ preferredCursorTargetsQML)

public:
    CursorNavigationAttached(QQuickItem *parent);

    bool acceptsCursor() const;
    void setAcceptsCursor(bool acceptsCursor);

    bool hasCursor() const;

    bool trapsCursor() const;
    void setTrapsCursor(bool trapsCursor);

signals:
    void acceptsCursorChanged(bool acceptsCursor);
    void hasCursorChanged(bool hasCursor);
    void trapsCursorChanged(bool trapsCursor);

private slots:
    void onWindowChanged(QQuickWindow *window);

private:
    QQuickItem *item() const;
    void setHasCursor(bool hasCursor);

    CursorNavigation *m_cursorNavigation;
    bool m_acceptsCursor;
    bool m_hasCursor;
    bool m_trapsCursor;

    friend class CursorNavigation;
};

#endif // CURSORNAVIGATIONATTACHED_H