From 8489f36322c585ec78199e6eb183000c74afae19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antti=20H=C3=B6ltt=C3=A4?= Date: Tue, 19 Feb 2019 15:36:39 +0100 Subject: 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. --- plugin/redirect.h | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 plugin/redirect.h (limited to 'plugin/redirect.h') 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 + +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 -- cgit v1.2.3