From 9ca0102b52f69bc1a929cb9e9f842cfabc7a2895 Mon Sep 17 00:00:00 2001 From: Jeremy Hu Date: Sat, 18 Jan 2020 17:43:24 +0930 Subject: [PATCH] Fix component renaming --- languages/dust3d_zh_CN.ts | 4 ++++ src/parttreewidget.cpp | 12 ++++++++++++ 2 files changed, 16 insertions(+) diff --git a/languages/dust3d_zh_CN.ts b/languages/dust3d_zh_CN.ts index e26a90e5..95f912c3 100644 --- a/languages/dust3d_zh_CN.ts +++ b/languages/dust3d_zh_CN.ts @@ -772,6 +772,10 @@ Tips: Iteration 迭代 + + Rename + 重命名 + PartWidget diff --git a/src/parttreewidget.cpp b/src/parttreewidget.cpp index 510f9d4f..90315514 100644 --- a/src/parttreewidget.cpp +++ b/src/parttreewidget.cpp @@ -767,6 +767,7 @@ void PartTreeWidget::showContextMenu(const QPoint &pos, bool shorted) contextMenu.addSeparator(); std::vector groupsActions; + QAction renameAction(tr("Rename"), this); QAction deleteAction(tr("Delete"), this); QAction moveToTopAction(tr("Top"), this); QAction moveUpAction(tr("Up"), this); @@ -845,6 +846,17 @@ void PartTreeWidget::showContextMenu(const QPoint &pos, bool shorted) }; addChildGroupsFunc(QUuid(), 0); + if (nullptr != component && nullptr == part) { + auto componentId = component->id; + connect(&renameAction, &QAction::triggered, [=]() { + auto findItem = m_componentItemMap.find(componentId); + if (findItem != m_componentItemMap.end()) { + editItem(findItem->second); + } + }); + contextMenu.addAction(&renameAction); + } + contextMenu.addSeparator(); deleteAction.setIcon(Theme::awesome()->icon(fa::trash));