From cb45bbe591643abe1d469f15dc80f91ec8c5f463 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 4 May 2021 11:43:48 +0530 Subject: [PATCH] Allow specifying default dialog buttons --- src/calibre/gui2/widgets2.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/calibre/gui2/widgets2.py b/src/calibre/gui2/widgets2.py index 69d3c14c16..279c77b0a2 100644 --- a/src/calibre/gui2/widgets2.py +++ b/src/calibre/gui2/widgets2.py @@ -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)