From 124fd657e3c39512e3bdb91873ce2ec1d71905f3 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Tue, 18 Apr 2017 11:06:17 +0300 Subject: [PATCH] Suppress scene item context menu if a tool was activated. A context menu is allowed only if the Arrow tool is active. --HG-- branch : release --- src/app/valentina/mainwindow.cpp | 2 ++ src/libs/vtools/tools/drawTools/vdrawtool.h | 5 +++++ src/libs/vtools/tools/vinteractivetool.cpp | 2 ++ src/libs/vtools/tools/vinteractivetool.h | 2 ++ src/libs/vtools/tools/vtoolseamallowance.cpp | 5 +++++ 5 files changed, 16 insertions(+) diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index 0895da04f..52ef03972 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -1917,6 +1917,7 @@ void MainWindow::CancelTool() // https://bitbucket.org/dismine/valentina/issues/454/crash-using-crtl-z-while-using-line-tool undoAction->setEnabled(false); redoAction->setEnabled(false); + VInteractiveTool::m_suppressContextMenu = true; return; case Tool::BasePoint: case Tool::SinglePoint: @@ -2082,6 +2083,7 @@ void MainWindow::ArrowTool() currentTool = Tool::Arrow; emit EnableItemMove(true); emit ItemsSelection(SelectionType::ByMouseRelease); + VInteractiveTool::m_suppressContextMenu = false; // Only true for rubber band selection emit EnableLabelSelection(true); diff --git a/src/libs/vtools/tools/drawTools/vdrawtool.h b/src/libs/vtools/tools/drawTools/vdrawtool.h index 918b15634..c1f428fb2 100644 --- a/src/libs/vtools/tools/drawTools/vdrawtool.h +++ b/src/libs/vtools/tools/drawTools/vdrawtool.h @@ -141,6 +141,11 @@ void VDrawTool::ContextMenu(Tool *tool, QGraphicsSceneContextMenuEvent *event, c SCASSERT(tool != nullptr) SCASSERT(event != nullptr) + if (m_suppressContextMenu) + { + return; + } + qCDebug(vTool, "Creating tool context menu."); QMenu menu; QAction *actionOption = menu.addAction(QIcon::fromTheme("preferences-other"), tr("Options")); diff --git a/src/libs/vtools/tools/vinteractivetool.cpp b/src/libs/vtools/tools/vinteractivetool.cpp index 10cc5016f..bcc4de888 100644 --- a/src/libs/vtools/tools/vinteractivetool.cpp +++ b/src/libs/vtools/tools/vinteractivetool.cpp @@ -28,6 +28,8 @@ #include "vinteractivetool.h" +bool VInteractiveTool::m_suppressContextMenu = false; + //--------------------------------------------------------------------------------------------------------------------- VInteractiveTool::VInteractiveTool(VAbstractPattern *doc, VContainer *data, quint32 id, QObject *parent) : VAbstractTool(doc, data, id, parent), diff --git a/src/libs/vtools/tools/vinteractivetool.h b/src/libs/vtools/tools/vinteractivetool.h index becb50b06..d68c05152 100644 --- a/src/libs/vtools/tools/vinteractivetool.h +++ b/src/libs/vtools/tools/vinteractivetool.h @@ -43,6 +43,8 @@ public: void DialogLinkDestroy(); + static bool m_suppressContextMenu; + public slots: void FullUpdateFromGuiOk(int result); void FullUpdateFromGuiApply(); diff --git a/src/libs/vtools/tools/vtoolseamallowance.cpp b/src/libs/vtools/tools/vtoolseamallowance.cpp index 08c4d6d73..bb2441ceb 100644 --- a/src/libs/vtools/tools/vtoolseamallowance.cpp +++ b/src/libs/vtools/tools/vtoolseamallowance.cpp @@ -1061,6 +1061,11 @@ void VToolSeamAllowance::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) //--------------------------------------------------------------------------------------------------------------------- void VToolSeamAllowance::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) { + if (m_suppressContextMenu) + { + return; + } + QMenu menu; QAction *actionOption = menu.addAction(QIcon::fromTheme("preferences-other"), tr("Options"));