Allow specifying default dialog buttons

This commit is contained in:
Kovid Goyal 2021-05-04 11:43:48 +05:30
parent 62a092fd57
commit cb45bbe591
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -172,12 +172,16 @@ class Dialog(QDialog):
for the first time.
'''
def __init__(self, title, name, parent=None, prefs=gprefs):
def __init__(
self, title,
name, parent=None, prefs=gprefs,
default_buttons=QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel
):
QDialog.__init__(self, parent)
self.prefs_for_persistence = prefs
self.setWindowTitle(title)
self.name = name
self.bb = QDialogButtonBox(QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel)
self.bb = QDialogButtonBox(default_buttons)
self.bb.accepted.connect(self.accept)
self.bb.rejected.connect(self.reject)