From 306bd245fcb4050f76c01c4d09f8c727cd2ac050 Mon Sep 17 00:00:00 2001 From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com> Date: Wed, 22 Jan 2025 00:58:55 +0100 Subject: [PATCH] Block tree context menu in blank area --- novelwriter/gui/projtree.py | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/novelwriter/gui/projtree.py b/novelwriter/gui/projtree.py index 53470897..2bc13a41 100644 --- a/novelwriter/gui/projtree.py +++ b/novelwriter/gui/projtree.py @@ -955,23 +955,18 @@ class GuiProjectTree(QTreeView): if model := self._getModel(): if point is None: point = self.visualRect(self.currentIndex()).center() - - if ( - point is not None - and (node := self._getNode(self.currentIndex())) - and (indices := self._selectedRows()) - ): - ctxMenu = _TreeContextMenu(self, model, node, indices) - if node is SHARED.project.tree.trash: - ctxMenu.buildTrashMenu() - elif len(indices) > 1: - ctxMenu.buildMultiSelectMenu() - else: - ctxMenu.buildSingleSelectMenu() - - ctxMenu.exec(self.viewport().mapToGlobal(point)) - ctxMenu.setParent(None) - + if point is not None: + index = self.indexAt(point) + if (node := self._getNode(index)) and (indices := self._selectedRows()): + ctxMenu = _TreeContextMenu(self, model, node, indices) + if node is SHARED.project.tree.trash: + ctxMenu.buildTrashMenu() + elif len(indices) > 1: + ctxMenu.buildMultiSelectMenu() + else: + ctxMenu.buildSingleSelectMenu() + ctxMenu.exec(self.viewport().mapToGlobal(point)) + ctxMenu.setParent(None) return ##