From 72ba4ae74dba6063bbf4ed22ea5a05efdac6e2d5 Mon Sep 17 00:00:00 2001 From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com> Date: Sun, 3 Mar 2024 20:37:44 +0100 Subject: [PATCH] Use "Duplicate" for both context menu types in project tree --- novelwriter/gui/projtree.py | 8 +++----- tests/test_gui/test_gui_projtree.py | 12 +++++------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/novelwriter/gui/projtree.py b/novelwriter/gui/projtree.py index 4227c3bf..4d2dbff9 100644 --- a/novelwriter/gui/projtree.py +++ b/novelwriter/gui/projtree.py @@ -1949,11 +1949,9 @@ class _TreeContextMenu(QMenu): action.triggered.connect(lambda: tree.setExpandedFromHandle(tHandle, True)) action = self.addAction(self.tr("Collapse All")) action.triggered.connect(lambda: tree.setExpandedFromHandle(tHandle, False)) - action = self.addAction(self.tr("Duplicate from Here")) - action.triggered.connect(lambda: tree._duplicateFromHandle(tHandle)) - elif isFile: - action = self.addAction(self.tr("Duplicate Document")) - action.triggered.connect(lambda: tree._duplicateFromHandle(tHandle)) + + action = self.addAction(self.tr("Duplicate")) + action.triggered.connect(lambda: tree._duplicateFromHandle(tHandle)) if self._item.itemClass == nwItemClass.TRASH or isRoot or (isFolder and not hasChild): action = self.addAction(self.tr("Delete Permanently")) diff --git a/tests/test_gui/test_gui_projtree.py b/tests/test_gui/test_gui_projtree.py index 59ac257d..3422beea 100644 --- a/tests/test_gui/test_gui_projtree.py +++ b/tests/test_gui/test_gui_projtree.py @@ -1196,7 +1196,7 @@ def testGuiProjTree_ContextMenu(qtbot, monkeypatch, nwGUI, projPath, mockRnd): actions = [x.text() for x in ctxMenu.actions() if x.text()] assert actions == [ "Create New ...", "Rename", "Set Status to ...", "Expand All", - "Collapse All", "Duplicate from Here", "Delete Permanently", + "Collapse All", "Duplicate", "Delete Permanently", ] # Context Menu on Folder Item @@ -1207,7 +1207,7 @@ def testGuiProjTree_ContextMenu(qtbot, monkeypatch, nwGUI, projPath, mockRnd): actions = [x.text() for x in ctxMenu.actions() if x.text()] assert actions == [ "Create New ...", "Rename", "Set Status to ...", "Transform ...", "Expand All", - "Collapse All", "Duplicate from Here", "Move to Trash", + "Collapse All", "Duplicate", "Move to Trash", ] def getTransformSubMenu(menu: QMenu) -> list[str]: @@ -1225,7 +1225,7 @@ def testGuiProjTree_ContextMenu(qtbot, monkeypatch, nwGUI, projPath, mockRnd): assert actions == [ "Open Document", "View Document", "Create New ...", "Rename", "Rename to Heading", "Toggle Active", "Set Status to ...", "Transform ...", "Expand All", "Collapse All", - "Duplicate from Here", "Move to Trash", + "Duplicate", "Move to Trash", ] assert getTransformSubMenu(ctxMenu) == [ "Convert to Project Note", "Merge Child Items into Self", @@ -1240,8 +1240,7 @@ def testGuiProjTree_ContextMenu(qtbot, monkeypatch, nwGUI, projPath, mockRnd): actions = [x.text() for x in ctxMenu.actions() if x.text()] assert actions == [ "Open Document", "View Document", "Create New ...", "Rename", "Rename to Heading", - "Toggle Active", "Set Importance to ...", "Transform ...", "Duplicate Document", - "Move to Trash", + "Toggle Active", "Set Importance to ...", "Transform ...", "Duplicate", "Move to Trash", ] assert getTransformSubMenu(ctxMenu) == [ "Split Document by Headings", @@ -1255,8 +1254,7 @@ def testGuiProjTree_ContextMenu(qtbot, monkeypatch, nwGUI, projPath, mockRnd): actions = [x.text() for x in ctxMenu.actions() if x.text()] assert actions == [ "Open Document", "View Document", "Create New ...", "Rename", "Rename to Heading", - "Toggle Active", "Set Status to ...", "Transform ...", "Duplicate Document", - "Move to Trash", + "Toggle Active", "Set Status to ...", "Transform ...", "Duplicate", "Move to Trash", ] assert getTransformSubMenu(ctxMenu) == [ "Convert to Novel Document", "Split Document by Headings",