aboutsummaryrefslogtreecommitdiffstats
path: root/plugin/cursornavigation.h
blob: 22176792c56686ba127291c3b674846140fd9e8b (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
#ifndef CURSORNAVIGATION_H
#define CURSORNAVIGATION_H

#include "cursornavigationattached.h"
#include "itemregister.h"
#include "inputtypes.h"
#include "inputadapter.h"

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

class QQuickItem;
class CursorNavigationAlgorithm;

class CursorNavigation : public QObject
{
    Q_OBJECT

public:
    CursorNavigation(QQuickWindow *parent);

    bool inputCommand(CursorNavigationCommand cmd);

    static CursorNavigationAttached *qmlAttachedProperties(QObject *object);

    static CursorNavigation *cursorNavigationForWindow(QQuickWindow *window);

private:
    void setCursorOnItem(QQuickItem *item);
    void onActiveFocusItemChanged();

    static CursorNavigationAttached *cursorNavigationAttachment(QQuickItem *item);

private:
    static const char windowPropertyName[];
    QQuickWindow *m_window;
    InputAdapter m_inputAdapter;
    QQuickItem *m_currentItem; //item that currently has the cursor
    QList<CursorNavigationAlgorithm*> m_algorithms;
    ItemRegister m_itemRegister;


    friend class CursorNavigationAttached;
};

QML_DECLARE_TYPEINFO(CursorNavigation, QML_HAS_ATTACHED_PROPERTIES)

#endif // CURSORNAVIGATION_H