summaryrefslogtreecommitdiffstats
path: root/plugin/redirect.h
diff options
context:
space:
mode:
authorAntti Hölttä <AHoelttae@luxoft.com>2019-02-19 15:36:39 +0100
committerAntti Hölttä <AHoelttae@luxoft.com>2019-03-18 16:42:31 +0100
commit8489f36322c585ec78199e6eb183000c74afae19 (patch)
tree8989b7cf6275b8b6cbffaa3b44467f5bd4ecdbf5 /plugin/redirect.h
parenta5120f26d509a3464c79404de84e9428b8ddc690 (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/redirect.h')
-rw-r--r--plugin/redirect.h41
1 files changed, 41 insertions, 0 deletions
diff --git a/plugin/redirect.h b/plugin/redirect.h
new file mode 100644
index 0000000..232f07b
--- /dev/null
+++ b/plugin/redirect.h
@@ -0,0 +1,41 @@
+#ifndef REDIRECT_H
+#define REDIRECT_H
+
+#include <QObject>
+
+class QQuickItem;
+
+class Redirect : public QObject
+{
+ Q_OBJECT
+
+ Q_PROPERTY(qreal start READ start WRITE setStart)
+ Q_PROPERTY(qreal end READ end WRITE setEnd)
+ Q_PROPERTY(QQuickItem *target READ target WRITE setTarget)
+public:
+ Redirect(QObject *parent = nullptr);
+ virtual ~Redirect();
+
+ qreal start() const;
+ qreal end() const;
+ QQuickItem *target() const;
+
+ void setStart(qreal start);
+ void setEnd(qreal end);
+ void setTarget(QQuickItem *target);
+
+ bool angleIsIncluded(qreal angle);
+
+private slots:
+ void onTargetDestroyed();
+
+private:
+ qreal m_start;
+ qreal m_end;
+ //fitted angles in radians
+ qreal m_startR;
+ qreal m_endR;
+ QQuickItem *m_target;
+};
+
+#endif // REDIRECT_H