diff options
author | Antti Hölttä <AHoelttae@luxoft.com> | 2018-11-12 15:25:03 +0100 |
---|---|---|
committer | Antti Hölttä <AHoelttae@luxoft.com> | 2019-03-18 16:32:22 +0100 |
commit | 4e53c46500bdbe9f6fd7228f14b27fb7262b0350 (patch) | |
tree | 932b38e06cac020db92f60849f38ca4ef88aec85 /plugin | |
parent | fbe75056a6ca179504b33c74d741c540f5b22dcd (diff) |
CursorNavigationAttached now implements the control interface
CursorNavigationAttached now implements the functions for moving the
cursor and for giving commands. This makes it possible to reassign the
control keys, or use other input sources as well
Diffstat (limited to 'plugin')
-rw-r--r-- | plugin/cursornavigation.h | 4 | ||||
-rw-r--r-- | plugin/cursornavigationattached.cpp | 68 | ||||
-rw-r--r-- | plugin/cursornavigationattached.h | 11 | ||||
-rw-r--r-- | plugin/inputtypes.cpp | 4 | ||||
-rw-r--r-- | plugin/inputtypes.h | 2 |
5 files changed, 77 insertions, 12 deletions
diff --git a/plugin/cursornavigation.h b/plugin/cursornavigation.h index 12468e4..96c5e67 100644 --- a/plugin/cursornavigation.h +++ b/plugin/cursornavigation.h @@ -20,8 +20,6 @@ public: CursorNavigation(QQuickWindow *parent); bool inputCommand(const CursorNavigationCommand &cmd); - void move(QVector2D moveVector); - void action(); static CursorNavigationAttached *qmlAttachedProperties(QObject *object); @@ -46,7 +44,7 @@ private: QList<CursorNavigationAlgorithm*> m_algorithms; //a root item that is not tied to any actual QQuickItem CursorNavigationAttached *m_rootItem; - QStack<CursorNavigationAttached*> m_scopeStack; + //QStack<CursorNavigationAttached*> m_scopeStack; friend class CursorNavigationAttached; }; diff --git a/plugin/cursornavigationattached.cpp b/plugin/cursornavigationattached.cpp index 9a939ff..c015cd3 100644 --- a/plugin/cursornavigationattached.cpp +++ b/plugin/cursornavigationattached.cpp @@ -59,6 +59,65 @@ void CursorNavigationAttached::setTrapsCursor(bool trapsCursor) } } +void CursorNavigationAttached::setEscapeTarget(QQuickItem *escapeTarget) +{ + if (m_escapeTarget == escapeTarget) + return; + + m_escapeTarget = escapeTarget; + emit escapeTargetChanged(m_escapeTarget); +} + +void CursorNavigationAttached::move(int angle, float magnitude) +{ + CursorNavigationCommand cmd(magnitude, angle); + m_cursorNavigation->inputCommand(cmd); +} + +void CursorNavigationAttached::moveUp() +{ + m_cursorNavigation->inputCommand(CursorNavigationCommand::Up); +} + +void CursorNavigationAttached::moveDown() +{ + m_cursorNavigation->inputCommand(CursorNavigationCommand::Down); +} + +void CursorNavigationAttached::moveRight() +{ + m_cursorNavigation->inputCommand(CursorNavigationCommand::Right); +} + +void CursorNavigationAttached::moveLeft() +{ + m_cursorNavigation->inputCommand(CursorNavigationCommand::Left); +} + +void CursorNavigationAttached::activate() +{ + CursorNavigationCommand cmd(CursorNavigationCommand::Activate); + m_cursorNavigation->inputCommand(cmd); +} + +void CursorNavigationAttached::forward() +{ + CursorNavigationCommand cmd(CursorNavigationCommand::Forward); + m_cursorNavigation->inputCommand(cmd); +} + +void CursorNavigationAttached::back() +{ + CursorNavigationCommand cmd(CursorNavigationCommand::Back); + m_cursorNavigation->inputCommand(cmd); +} + +void CursorNavigationAttached::escape() +{ + CursorNavigationCommand cmd(CursorNavigationCommand::Escape); + m_cursorNavigation->inputCommand(cmd); +} + void CursorNavigationAttached::onWindowChanged(QQuickWindow *window) { qDebug() << "window changed, window = " << window; @@ -88,15 +147,6 @@ QQuickItem *CursorNavigationAttached::escapeTarget() const return m_escapeTarget; } -void CursorNavigationAttached::setEscapeTarget(QQuickItem *escapeTarget) -{ - if (m_escapeTarget == escapeTarget) - return; - - m_escapeTarget = escapeTarget; - emit escapeTargetChanged(m_escapeTarget); -} - void CursorNavigationAttached::setHasCursor(bool hasCursor) { if (hasCursor != m_hasCursor) { diff --git a/plugin/cursornavigationattached.h b/plugin/cursornavigationattached.h index 0f3f927..344b4fa 100644 --- a/plugin/cursornavigationattached.h +++ b/plugin/cursornavigationattached.h @@ -40,6 +40,17 @@ public slots: void setTrapsCursor(bool trapsCursor); void setEscapeTarget(QQuickItem * escapeTarget); + void move(int angle, float magnitude); + void moveUp(); + void moveDown(); + void moveRight(); + void moveLeft(); + void activate(); + void forward(); + void back(); + void escape(); + + signals: void acceptsCursorChanged(bool acceptsCursor); void hasCursorChanged(bool hasCursor); diff --git a/plugin/inputtypes.cpp b/plugin/inputtypes.cpp index 770b03d..344254b 100644 --- a/plugin/inputtypes.cpp +++ b/plugin/inputtypes.cpp @@ -13,6 +13,10 @@ CursorNavigationCommand::CursorNavigationCommand(float magnitude, int angle) :magnitude(magnitude), angle(angle), action(NoAction) {} +CursorNavigationCommand::CursorNavigationCommand(Action a) + :magnitude(-1), angle(-1), action(a) +{} + //test if this commands angle is between given angles. clockwise from begin to end bool CursorNavigationCommand::angleIsBetween(int begin, int end) const { diff --git a/plugin/inputtypes.h b/plugin/inputtypes.h index efe7f8a..c6cc532 100644 --- a/plugin/inputtypes.h +++ b/plugin/inputtypes.h @@ -19,6 +19,8 @@ struct CursorNavigationCommand CursorNavigationCommand(float magnitude, int angle); + CursorNavigationCommand(Action a); + //test if this commands angle is between given angles. clockwise from begin to end bool angleIsBetween(int begin, int end) const; |