From 597f021139c3cdfcd143116fdc11d0f17d7999fe Mon Sep 17 00:00:00 2001 From: Ronan Le Tiec Date: Thu, 29 Mar 2018 23:13:33 +0200 Subject: [PATCH] issue 826 improvement to be able to add --HG-- branch : feature --- src/libs/vtools/tools/drawTools/vdrawtool.h | 11 +++++++++-- src/libs/vwidgets/vsimplecurve.cpp | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/libs/vtools/tools/drawTools/vdrawtool.h b/src/libs/vtools/tools/drawTools/vdrawtool.h index affc64300..ef611c385 100644 --- a/src/libs/vtools/tools/drawTools/vdrawtool.h +++ b/src/libs/vtools/tools/drawTools/vdrawtool.h @@ -146,6 +146,13 @@ void VDrawTool::ContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 itemI return; } + GOType itemType = GOType::Unknown; + if(itemId != NULL_ID) + { + const auto obj = data.GetGObject(itemId); + itemType = obj->getType(); + } + qCDebug(vTool, "Creating tool context menu."); QMenu menu; QAction *actionOption = menu.addAction(QIcon::fromTheme("preferences-other"), tr("Options")); @@ -193,10 +200,10 @@ void VDrawTool::ContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 itemI } } - QAction *actionShowLabel = menu.addAction(tr("Show label")); actionShowLabel->setCheckable(true); - if (itemId != NULL_ID) + + if (itemType == GOType::Point) { actionShowLabel->setChecked(IsLabelVisible(itemId)); } diff --git a/src/libs/vwidgets/vsimplecurve.cpp b/src/libs/vwidgets/vsimplecurve.cpp index 6f6f80bb7..570de348d 100644 --- a/src/libs/vwidgets/vsimplecurve.cpp +++ b/src/libs/vwidgets/vsimplecurve.cpp @@ -155,7 +155,7 @@ QVariant VSimpleCurve::itemChange(QGraphicsItem::GraphicsItemChange change, cons //--------------------------------------------------------------------------------------------------------------------- void VSimpleCurve::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) { - emit ShowContextMenu(event); + emit ShowContextMenu(event, id); } //---------------------------------------------------------------------------------------------------------------------