From eb113a892862bebf59c2945f5cb5735b9a6248f7 Mon Sep 17 00:00:00 2001 From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com> Date: Wed, 22 Jan 2025 00:48:03 +0100 Subject: [PATCH 1/4] Make sure status label in item details panel can wrap --- novelwriter/gui/itemdetails.py | 1 + 1 file changed, 1 insertion(+) diff --git a/novelwriter/gui/itemdetails.py b/novelwriter/gui/itemdetails.py index c95db8e0..feb09938 100644 --- a/novelwriter/gui/itemdetails.py +++ b/novelwriter/gui/itemdetails.py @@ -93,6 +93,7 @@ class GuiItemDetails(QWidget): self.statusData = QLabel("", self) self.statusData.setFont(fntValue) self.statusData.setAlignment(QtAlignLeft) + self.statusData.setWordWrap(True) # Class self.className = QLabel(self.tr("Class"), self) From 53dfdb3a2e532122389fd593455345595b6b7b82 Mon Sep 17 00:00:00 2001 From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com> Date: Wed, 22 Jan 2025 00:48:59 +0100 Subject: [PATCH 2/4] Fix potential undefined variable in editor --- novelwriter/gui/doceditor.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/novelwriter/gui/doceditor.py b/novelwriter/gui/doceditor.py index c95023d9..63be85b1 100644 --- a/novelwriter/gui/doceditor.py +++ b/novelwriter/gui/doceditor.py @@ -1104,10 +1104,10 @@ class GuiDocEditor(QPlainTextEdit): else: self._completer.setVisible(False) - if self._doReplace and added == 1: - cursor = self.textCursor() - if self._autoReplace.process(text, cursor): - self._qDocument.syntaxHighlighter.rehighlightBlock(cursor.block()) + if self._doReplace and added == 1: + cursor = self.textCursor() + if self._autoReplace.process(text, cursor): + self._qDocument.syntaxHighlighter.rehighlightBlock(cursor.block()) return From 7e42d04e3696bb9d9005960ae0c20de05322d1cb Mon Sep 17 00:00:00 2001 From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com> Date: Wed, 22 Jan 2025 00:53:18 +0100 Subject: [PATCH 3/4] Drop deleteLater for context menus --- novelwriter/gui/doceditor.py | 2 +- novelwriter/gui/docviewer.py | 2 +- novelwriter/gui/projtree.py | 2 +- novelwriter/tools/welcome.py | 2 +- tests/test_gui/test_gui_doceditor.py | 2 ++ tests/test_tools/test_tools_welcome.py | 1 + 6 files changed, 7 insertions(+), 4 deletions(-) diff --git a/novelwriter/gui/doceditor.py b/novelwriter/gui/doceditor.py index 63be85b1..52e0180a 100644 --- a/novelwriter/gui/doceditor.py +++ b/novelwriter/gui/doceditor.py @@ -1217,7 +1217,7 @@ class GuiDocEditor(QPlainTextEdit): # Execute the context menu ctxMenu.exec(self.viewport().mapToGlobal(pos)) - ctxMenu.deleteLater() + ctxMenu.setParent(None) return diff --git a/novelwriter/gui/docviewer.py b/novelwriter/gui/docviewer.py index b43c7b7c..389aac2c 100644 --- a/novelwriter/gui/docviewer.py +++ b/novelwriter/gui/docviewer.py @@ -424,7 +424,7 @@ class GuiDocViewer(QTextBrowser): # Open the context menu ctxMenu.exec(self.viewport().mapToGlobal(point)) - ctxMenu.deleteLater() + ctxMenu.setParent(None) return diff --git a/novelwriter/gui/projtree.py b/novelwriter/gui/projtree.py index db04e3dd..53470897 100644 --- a/novelwriter/gui/projtree.py +++ b/novelwriter/gui/projtree.py @@ -970,7 +970,7 @@ class GuiProjectTree(QTreeView): ctxMenu.buildSingleSelectMenu() ctxMenu.exec(self.viewport().mapToGlobal(point)) - ctxMenu.deleteLater() + ctxMenu.setParent(None) return diff --git a/novelwriter/tools/welcome.py b/novelwriter/tools/welcome.py index 74f57971..837e76e5 100644 --- a/novelwriter/tools/welcome.py +++ b/novelwriter/tools/welcome.py @@ -376,7 +376,7 @@ class _OpenProjectPage(QWidget): action = ctxMenu.addAction(self.tr("Remove Project")) action.triggered.connect(self._deleteSelectedItem) ctxMenu.exec(self.mapToGlobal(pos)) - ctxMenu.deleteLater() + ctxMenu.setParent(None) return ## diff --git a/tests/test_gui/test_gui_doceditor.py b/tests/test_gui/test_gui_doceditor.py index 611f0145..efd4345e 100644 --- a/tests/test_gui/test_gui_doceditor.py +++ b/tests/test_gui/test_gui_doceditor.py @@ -332,6 +332,7 @@ def testGuiEditor_MetaData(qtbot, nwGUI, projPath, mockRnd): def testGuiEditor_ContextMenu(monkeypatch, qtbot, nwGUI, projPath, mockRnd): """Test the editor context menu.""" monkeypatch.setattr(QMenu, "exec", lambda *a: None) + monkeypatch.setattr(QMenu, "setParent", lambda *a: None) buildTestProject(nwGUI, projPath) assert nwGUI.openDocument(C.hSceneDoc) is True @@ -471,6 +472,7 @@ def testGuiEditor_ContextMenu(monkeypatch, qtbot, nwGUI, projPath, mockRnd): def testGuiEditor_SpellChecking(qtbot, monkeypatch, nwGUI, projPath, ipsumText, mockRnd): """Test the document spell checker.""" monkeypatch.setattr(QMenu, "exec", lambda *a: None) + monkeypatch.setattr(QMenu, "setParent", lambda *a: None) buildTestProject(nwGUI, projPath) assert nwGUI.openDocument(C.hSceneDoc) is True diff --git a/tests/test_tools/test_tools_welcome.py b/tests/test_tools/test_tools_welcome.py index eb30fcb7..e827d0cb 100644 --- a/tests/test_tools/test_tools_welcome.py +++ b/tests/test_tools/test_tools_welcome.py @@ -70,6 +70,7 @@ def testToolWelcome_Main(qtbot: QtBot, monkeypatch, nwGUI, fncPath): def testToolWelcome_Open(qtbot: QtBot, monkeypatch, nwGUI, fncPath): """Test the open tab in the Welcome window.""" monkeypatch.setattr(QMenu, "exec", lambda *a: None) + monkeypatch.setattr(QMenu, "setParent", lambda *a: None) CONFIG.recentProjects.update("/stuff/project_one", "Project One", 12345, 1690000000) CONFIG.recentProjects.update("/stuff/project_two", "Project Two", 54321, 1700000000) 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 4/4] 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 ##