From 9d344f7f86032aa7e489fce45c31c6c63443c02d Mon Sep 17 00:00:00 2001 From: Calum Matheson Date: Wed, 7 Oct 2026 14:02:23 +0200 Subject: [PATCH] PolylinePlot - reworking cancel logic --- .../qml/Muse/UiComponents/polylineplot.cpp | 15 ++++----------- .../qml/Muse/UiComponents/polylineplot.h | 11 ++--------- 2 files changed, 6 insertions(+), 20 deletions(-) diff --git a/framework/uicomponents/qml/Muse/UiComponents/polylineplot.cpp b/framework/uicomponents/qml/Muse/UiComponents/polylineplot.cpp index cfb6f41c65..9f085df51d 100644 --- a/framework/uicomponents/qml/Muse/UiComponents/polylineplot.cpp +++ b/framework/uicomponents/qml/Muse/UiComponents/polylineplot.cpp @@ -138,7 +138,7 @@ static double valueAtX(const QVector& sortedPoints, double x) } PolylinePlot::PolylinePlot(QQuickItem* parent) - : QQuickPaintedItem(parent), muse::Contextable(muse::iocCtxForQmlObject(this)) + : QQuickPaintedItem(parent) { setAcceptHoverEvents(true); setAcceptedMouseButtons(Qt::LeftButton); @@ -162,17 +162,10 @@ PolylinePlot::PolylinePlot(QQuickItem* parent) }); } -void PolylinePlot::init() +void PolylinePlot::cancelEdit() { - dispatcher()->reg(this, "action://cancel", [this](){ - // emit signal and let decide model what to do - emit dragCancelled(); - // Qt suppresses hover events while a mouse button is held, so the - // ghost-point preview would otherwise stay painted at the press - // position until the user releases and moves the mouse. - m_hoveredOnLine = false; - resetGestureState(); - }); + m_hoveredOnLine = false; + resetGestureState(); } PolylinePointStyle* PolylinePlot::standardPointStyle() diff --git a/framework/uicomponents/qml/Muse/UiComponents/polylineplot.h b/framework/uicomponents/qml/Muse/UiComponents/polylineplot.h index 95f69e89dc..6f9a88ef0c 100644 --- a/framework/uicomponents/qml/Muse/UiComponents/polylineplot.h +++ b/framework/uicomponents/qml/Muse/UiComponents/polylineplot.h @@ -28,11 +28,7 @@ #include #include -#include "actions/actionable.h" -#include "async/asyncable.h" - #include "modularity/ioc.h" -#include "actions/iactionsdispatcher.h" #include "ui/iuiconfiguration.h" #include "internal/polylinepointstyle.h" @@ -45,7 +41,7 @@ struct GhostPoint { qreal distToSegment = 1e18; }; -class PolylinePlot : public QQuickPaintedItem, public muse::async::Asyncable, public muse::actions::Actionable, public muse::Contextable +class PolylinePlot : public QQuickPaintedItem { Q_OBJECT @@ -94,12 +90,10 @@ class PolylinePlot : public QQuickPaintedItem, public muse::async::Asyncable, pu muse::GlobalInject uiConfiguration; - muse::ContextInject dispatcher { this }; - public: explicit PolylinePlot(QQuickItem* parent = nullptr); - Q_INVOKABLE void init(); + Q_INVOKABLE void cancelEdit(); PolylinePointStyle* standardPointStyle(); PolylinePointStyle* ghostPointStyle(); @@ -186,7 +180,6 @@ class PolylinePlot : public QQuickPaintedItem, public muse::async::Asyncable, pu void pointAdded(qreal x, qreal y, bool completed); void pointMoved(int index, qreal x, qreal y, bool completed); void pointRemoved(int index, bool completed); - void dragCancelled(); void interactionFinished(); void xRangeFromChanged();