Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 4 additions & 11 deletions framework/uicomponents/qml/Muse/UiComponents/polylineplot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ static double valueAtX(const QVector<QPointF>& sortedPoints, double x)
}

PolylinePlot::PolylinePlot(QQuickItem* parent)
: QQuickPaintedItem(parent), muse::Contextable(muse::iocCtxForQmlObject(this))
: QQuickPaintedItem(parent)
{
setAcceptHoverEvents(true);
setAcceptedMouseButtons(Qt::LeftButton);
Expand All @@ -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()
Expand Down
11 changes: 2 additions & 9 deletions framework/uicomponents/qml/Muse/UiComponents/polylineplot.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,7 @@
#include <QVector>
#include <qqmlintegration.h>

#include "actions/actionable.h"
#include "async/asyncable.h"

#include "modularity/ioc.h"
#include "actions/iactionsdispatcher.h"
#include "ui/iuiconfiguration.h"

#include "internal/polylinepointstyle.h"
Expand All @@ -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

Expand Down Expand Up @@ -94,12 +90,10 @@ class PolylinePlot : public QQuickPaintedItem, public muse::async::Asyncable, pu

muse::GlobalInject<muse::ui::IUiConfiguration> uiConfiguration;

muse::ContextInject<muse::actions::IActionsDispatcher> dispatcher { this };

public:
explicit PolylinePlot(QQuickItem* parent = nullptr);

Q_INVOKABLE void init();
Q_INVOKABLE void cancelEdit();

PolylinePointStyle* standardPointStyle();
PolylinePointStyle* ghostPointStyle();
Expand Down Expand Up @@ -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();
Expand Down