diff --git a/src/libs/vtools/tools/drawTools/operation/vtoolrotation.cpp b/src/libs/vtools/tools/drawTools/operation/vtoolrotation.cpp index 162f1cb04..0f1d26dc3 100644 --- a/src/libs/vtools/tools/drawTools/operation/vtoolrotation.cpp +++ b/src/libs/vtools/tools/drawTools/operation/vtoolrotation.cpp @@ -953,6 +953,7 @@ VSimpleCurve *VToolRotation::InitCurve(quint32 id, VContainer *data, GOType curv curve->SetType(curveType); connect(curve, &VSimpleCurve::Selected, this, &VToolRotation::ObjectSelected); connect(curve, &VSimpleCurve::ShowContextMenu, this, &VToolRotation::contextMenuEvent); + connect(curve, &VSimpleCurve::Delete, this, &VToolRotation::DeleteFromLabel); curve->RefreshGeometry(VAbstractTool::data.GeometricObject(id)); rObjects.insert(id, curve); return curve; diff --git a/src/libs/vwidgets/vabstractsimple.h b/src/libs/vwidgets/vabstractsimple.h index 42820d60d..b4c9600fd 100644 --- a/src/libs/vwidgets/vabstractsimple.h +++ b/src/libs/vwidgets/vabstractsimple.h @@ -58,6 +58,7 @@ public: signals: void ShowContextMenu(QGraphicsSceneContextMenuEvent * event); + void Delete(); public slots: void ContextMenu(QGraphicsSceneContextMenuEvent * event); diff --git a/src/libs/vwidgets/vsimplecurve.cpp b/src/libs/vwidgets/vsimplecurve.cpp index a6ce5908b..40ec7992b 100644 --- a/src/libs/vwidgets/vsimplecurve.cpp +++ b/src/libs/vwidgets/vsimplecurve.cpp @@ -33,6 +33,7 @@ #include #include #include +#include //--------------------------------------------------------------------------------------------------------------------- VSimpleCurve::VSimpleCurve(quint32 id, const QColor ¤tColor, Unit patternUnit, qreal *factor, QObject *parent) @@ -44,6 +45,7 @@ VSimpleCurve::VSimpleCurve(quint32 id, const QColor ¤tColor, Unit patternU this->setBrush(QBrush(Qt::NoBrush)); SetPen(this, currentColor, WidthHairLine(patternUnit)); this->setAcceptHoverEvents(true); + this->setFlag(QGraphicsItem::ItemIsFocusable, true);// For keyboard input focus } //--------------------------------------------------------------------------------------------------------------------- @@ -155,6 +157,20 @@ void VSimpleCurve::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) emit ShowContextMenu(event); } +//--------------------------------------------------------------------------------------------------------------------- +void VSimpleCurve::keyReleaseEvent(QKeyEvent *event) +{ + switch (event->key()) + { + case Qt::Key_Delete: + emit Delete(); + return; //Leave this method immediately after call!!! + default: + break; + } + QGraphicsPathItem::keyReleaseEvent ( event ); +} + //--------------------------------------------------------------------------------------------------------------------- void VSimpleCurve::ShowPath() { diff --git a/src/libs/vwidgets/vsimplecurve.h b/src/libs/vwidgets/vsimplecurve.h index 45b11e70b..98ad0c6b0 100644 --- a/src/libs/vwidgets/vsimplecurve.h +++ b/src/libs/vwidgets/vsimplecurve.h @@ -57,19 +57,19 @@ signals: */ void Choosed(quint32 id); void Selected(bool selected, quint32 id); - void Delete(); public slots: void CurveChoosed(); void CurveSelected(bool selected); protected: - virtual void mousePressEvent( QGraphicsSceneMouseEvent * event ) Q_DECL_OVERRIDE; - virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ) Q_DECL_OVERRIDE; - virtual void hoverEnterEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE; - virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE; + virtual void mousePressEvent( QGraphicsSceneMouseEvent * event ) Q_DECL_OVERRIDE; + virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ) Q_DECL_OVERRIDE; + virtual void hoverEnterEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE; + virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE; virtual QVariant itemChange ( GraphicsItemChange change, const QVariant &value ) Q_DECL_OVERRIDE; virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE; + virtual void keyReleaseEvent ( QKeyEvent * event ) Q_DECL_OVERRIDE; private: Q_DISABLE_COPY(VSimpleCurve) diff --git a/src/libs/vwidgets/vsimplepoint.h b/src/libs/vwidgets/vsimplepoint.h index 887c4507a..87e7e92e1 100644 --- a/src/libs/vwidgets/vsimplepoint.h +++ b/src/libs/vwidgets/vsimplepoint.h @@ -64,7 +64,6 @@ signals: */ void Choosed(quint32 id); void Selected(bool selected, quint32 id); - void Delete(); void NameChangedPosition(const QPointF &pos, quint32 id); public slots: