From 84a4558f183a9975c15c988d28d03fb2a581feb5 Mon Sep 17 00:00:00 2001 From: karxi Date: Fri, 13 Jan 2017 20:10:15 -0500 Subject: [PATCH] Default selection change (prevent accidental deletion of quirk groups) --- menus.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/menus.py b/menus.py index ccd51fc..91c7239 100644 --- a/menus.py +++ b/menus.py @@ -150,6 +150,16 @@ class PesterQuirkList(QtGui.QTreeWidget): msgbox.setWindowTitle("WARNING!") msgbox.setInformativeText("Are you sure you want to delete the quirk group: %s" % (f.text(0))) msgbox.setStandardButtons(QtGui.QMessageBox.Ok | QtGui.QMessageBox.Cancel) + # Find the Cancel button and make it default + for b in msgbox.buttons(): + if msgbox.buttonRole(b) == QtGui.QMessageBox.RejectRole: + # We found the 'OK' button, set it as the default + b.setDefault(True) + b.setAutoDefault(True) + # Actually set it as the selected option, since we're + # already stealing focus + b.setFocus() + break ret = msgbox.exec_() if ret == QtGui.QMessageBox.Ok: self.takeTopLevelItem(self.indexOfTopLevelItem(f))