diff options
author | Antti Hölttä <AHoelttae@luxoft.com> | 2019-02-19 15:36:39 +0100 |
---|---|---|
committer | Antti Hölttä <AHoelttae@luxoft.com> | 2019-03-18 16:42:31 +0100 |
commit | 8489f36322c585ec78199e6eb183000c74afae19 (patch) | |
tree | 8989b7cf6275b8b6cbffaa3b44467f5bd4ecdbf5 /plugin/cursornavigationattached.h | |
parent | a5120f26d509a3464c79404de84e9428b8ddc690 (diff) |
Add redirect feature for manually fine tuning the cursor's movement
Cursornavigation now has a property redirects, that allows defining
exceptions to the navigation behaviour. A redirect allows defining
a starting and an ending angle and a target object.
If the move command's direction falls between the limits, the algorithm
is bypassed and cursor is moved to the target object.
Diffstat (limited to 'plugin/cursornavigationattached.h')
-rw-r--r-- | plugin/cursornavigationattached.h | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/plugin/cursornavigationattached.h b/plugin/cursornavigationattached.h index f3c729d..7c5e99a 100644 --- a/plugin/cursornavigationattached.h +++ b/plugin/cursornavigationattached.h @@ -4,6 +4,8 @@ //#include <qqml.h> #include <QObject> #include <QList> +#include <QQmlListProperty> +#include "redirect.h" class CursorNavigation; class QQuickItem; @@ -22,7 +24,7 @@ class CursorNavigationAttached : public QObject Q_PROPERTY(bool trapsCursor READ trapsCursor WRITE setTrapsCursor NOTIFY trapsCursorChanged) //item to select when Q_PROPERTY(QQuickItem *escapeTarget READ escapeTarget WRITE setEscapeTarget NOTIFY escapeTargetChanged) - + Q_PROPERTY(QQmlListProperty<Redirect> redirects READ redirects) public: CursorNavigationAttached(QQuickItem *parent); @@ -32,6 +34,8 @@ public: bool hasCursor() const; bool trapsCursor() const; QQuickItem *escapeTarget() const; + QQmlListProperty<Redirect> redirects(); + /* indicates if the item is currently available for the navigation. * item might not be availble if it is disabled, invisible, outside of its * parent's geometry or simply not accepting cursor @@ -93,6 +97,11 @@ private: void setHasCursor(bool hasCursor); //QList<CursorNavigationAttached*> &siblings(); + static void appendRedirect(QQmlListProperty<Redirect> *property, Redirect *redirect); + static int redirectCount(QQmlListProperty<Redirect> *property); + static Redirect *redirect(QQmlListProperty<Redirect> *property, int index); + static void clearRedirects(QQmlListProperty<Redirect> *property); + CursorNavigation *m_cursorNavigation; CursorNavigationAttached *m_parentNavigable; QList<CursorNavigationAttached*> m_children; @@ -103,6 +112,7 @@ private: friend class CursorNavigation; QQuickItem * m_escapeTarget; + QVector<Redirect*> m_redirects; }; #endif // CURSORNAVIGATIONATTACHED_H |