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 = self.buttonBox.addButton("New", QDialogButtonBox.ActionRole)
self.newButton.clicked.connect(self._doNewProject) 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.addLayout(self.innerBox)
self.outerBox.addWidget(self.buttonBox) self.outerBox.addWidget(self.buttonBox)
self.setLayout(self.outerBox) self.setLayout(self.outerBox)
@@ -138,7 +141,7 @@ class GuiProjectLoad(QDialog):
keyDelete = QShortcut(self.listBox) keyDelete = QShortcut(self.listBox)
keyDelete.setKey(QKeySequence(Qt.Key_Delete)) keyDelete.setKey(QKeySequence(Qt.Key_Delete))
keyDelete.activated.connect(self._keyPressDelete) keyDelete.activated.connect(self._doDeleteRecent)
logger.debug("GuiProjectLoad initialisation complete") logger.debug("GuiProjectLoad initialisation complete")
@@ -212,15 +215,16 @@ class GuiProjectLoad(QDialog):
self.accept() self.accept()
return return
def _keyPressDelete(self): def _doDeleteRecent(self):
"""Remove an entry from the recent projects list. """Remove an entry from the recent projects list.
""" """
selList = self.listBox.selectedItems() selList = self.listBox.selectedItems()
if selList: if selList:
msgYes = self.theParent.askQuestion( projName = selList[0].text(self.C_NAME)
"Remove Entry", msgYes = self.theParent.askQuestion("Remove Entry", (
"Remove the selected entry from the recent projects list?" "Remove '%s' from the recent projects list? "
) "The project files will not be deleted."
) % projName)
if msgYes: if msgYes:
self.mainConf.removeFromRecentCache( self.mainConf.removeFromRecentCache(
selList[0].data(self.C_NAME, Qt.UserRole) 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) qtbot.wait(stepDelay)
nwLoad.show() nwLoad.show()
nwLoad._keyPressDelete() nwLoad._doDeleteRecent()
assert nwLoad.listBox.topLevelItemCount() == recentCount - 1 assert nwLoad.listBox.topLevelItemCount() == recentCount - 1
getFile = os.path.join(nwMinimal, "nwProject.nwx") getFile = os.path.join(nwMinimal, "nwProject.nwx")