Add a button to the Project Open to remove listed projects, and clarify the dialog message

This commit is contained in:
Veronica K. B. Olsen
2021-02-02 22:06:02 +01:00
parent 6949481198
commit 4562a0130a
2 changed files with 11 additions and 7 deletions
+10 -6
View File
@@ -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)
+1 -1
View File
@@ -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")