From 4562a0130a5fc3dfb636cc9ef5485df37e2e838b Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Tue, 2 Feb 2021 22:06:02 +0100 Subject: [PATCH] Add a button to the Project Open to remove listed projects, and clarify the dialog message --- nw/gui/projload.py | 16 ++++++++++------ tests/test_gui/test_gui_projload.py | 2 +- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/nw/gui/projload.py b/nw/gui/projload.py index d8d72c7e..29401de3 100644 --- a/nw/gui/projload.py +++ b/nw/gui/projload.py @@ -129,6 +129,9 @@ class GuiProjectLoad(QDialog): self.newButton = self.buttonBox.addButton("New", QDialogButtonBox.ActionRole) self.newButton.clicked.connect(self._doNewProject) + self.delButton = self.buttonBox.addButton("Remove", QDialogButtonBox.ActionRole) + self.delButton.clicked.connect(self._doDeleteRecent) + self.outerBox.addLayout(self.innerBox) self.outerBox.addWidget(self.buttonBox) self.setLayout(self.outerBox) @@ -138,7 +141,7 @@ class GuiProjectLoad(QDialog): keyDelete = QShortcut(self.listBox) keyDelete.setKey(QKeySequence(Qt.Key_Delete)) - keyDelete.activated.connect(self._keyPressDelete) + keyDelete.activated.connect(self._doDeleteRecent) logger.debug("GuiProjectLoad initialisation complete") @@ -212,15 +215,16 @@ class GuiProjectLoad(QDialog): self.accept() return - def _keyPressDelete(self): + def _doDeleteRecent(self): """Remove an entry from the recent projects list. """ selList = self.listBox.selectedItems() if selList: - msgYes = self.theParent.askQuestion( - "Remove Entry", - "Remove the selected entry from the recent projects list?" - ) + projName = selList[0].text(self.C_NAME) + msgYes = self.theParent.askQuestion("Remove Entry", ( + "Remove '%s' from the recent projects list? " + "The project files will not be deleted." + ) % projName) if msgYes: self.mainConf.removeFromRecentCache( selList[0].data(self.C_NAME, Qt.UserRole) diff --git a/tests/test_gui/test_gui_projload.py b/tests/test_gui/test_gui_projload.py index 1776a6a7..41458d9d 100644 --- a/tests/test_gui/test_gui_projload.py +++ b/tests/test_gui/test_gui_projload.py @@ -102,7 +102,7 @@ def testGuiLoadProject_Main(qtbot, monkeypatch, nwGUI, nwMinimal): qtbot.wait(stepDelay) nwLoad.show() - nwLoad._keyPressDelete() + nwLoad._doDeleteRecent() assert nwLoad.listBox.topLevelItemCount() == recentCount - 1 getFile = os.path.join(nwMinimal, "nwProject.nwx")