Make default options take focus (in case of mistypes)

This commit is contained in:
karxi 2017-01-09 19:26:37 -05:00
parent 43e8a589f1
commit 483af0f1e5
3 changed files with 12 additions and 1 deletions

View file

@ -1032,7 +1032,11 @@ class PesterMemo(PesterConvo):
for b in msgbox.buttons():
if msgbox.buttonRole(b) == QtGui.QMessageBox.AcceptRole:
# 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:

View file

@ -1763,6 +1763,9 @@ class LoadingScreen(QtGui.QDialog):
layout_1.addWidget(self.ok)
self.layout.addLayout(layout_1)
self.setLayout(self.layout)
# Help reduce the number of accidental Pesterchum closures... :|
self.cancel.setDefault(False)
self.ok.setDefault(True)
def hideReconnect(self):
self.ok.hide()

View file

@ -2058,8 +2058,12 @@ class PesterWindow(MovingWindow):
# Find the Cancel button and make it default
for b in msgbox.buttons():
if msgbox.buttonRole(b) == QtGui.QMessageBox.RejectRole:
# We found the 'Cancel' button, set it as the default
# 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: