From 6c4b499740dd9fe48d64ddfef7bb6a90f2f9defd Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 19 Dec 2020 09:01:57 +0530 Subject: [PATCH] More stupid PyQt enums --- src/calibre/gui2/__init__.py | 4 ++-- src/calibre/gui2/actions/choose_library.py | 6 +++--- src/calibre/gui2/actions/copy_to_library.py | 10 +++++----- src/calibre/gui2/actions/polish.py | 10 +++++----- src/calibre/gui2/actions/toc_edit.py | 2 +- src/calibre/gui2/actions/tweak_epub.py | 2 +- src/calibre/gui2/covers.py | 2 +- src/calibre/gui2/device_drivers/mtp_config.py | 4 ++-- .../gui2/device_drivers/mtp_folder_browser.py | 4 ++-- src/calibre/gui2/dialogs/add_empty_book.py | 2 +- src/calibre/gui2/dialogs/book_info.py | 8 ++++---- src/calibre/gui2/dialogs/custom_recipes.py | 4 ++-- src/calibre/gui2/dialogs/duplicates.py | 6 +++--- src/calibre/gui2/dialogs/message_box.py | 16 ++++++++-------- src/calibre/gui2/dialogs/plugin_updater.py | 2 +- src/calibre/gui2/dialogs/saved_search_editor.py | 8 ++++---- src/calibre/gui2/dialogs/scheduler.py | 2 +- src/calibre/gui2/font_family_chooser.py | 2 +- src/calibre/gui2/icon_theme.py | 6 +++--- src/calibre/gui2/image_popup.py | 8 ++++---- src/calibre/gui2/jobs.py | 4 ++-- src/calibre/gui2/library/annotations.py | 8 ++++---- src/calibre/gui2/metadata/bulk_download.py | 8 ++++---- src/calibre/gui2/metadata/diff.py | 10 +++++----- src/calibre/gui2/metadata/single.py | 4 ++-- src/calibre/gui2/metadata/single_download.py | 6 +++--- src/calibre/gui2/open_with.py | 10 +++++----- src/calibre/gui2/preferences/coloring.py | 2 +- src/calibre/gui2/preferences/look_feel.py | 8 ++++---- src/calibre/gui2/preferences/main.py | 2 +- src/calibre/gui2/preferences/server.py | 6 +++--- src/calibre/gui2/preferences/texture_chooser.py | 4 ++-- src/calibre/gui2/proceed.py | 8 ++++---- src/calibre/gui2/tag_mapper.py | 8 ++++---- src/calibre/gui2/toc/main.py | 6 +++--- src/calibre/gui2/tts/develop.py | 8 ++++---- src/calibre/gui2/tweak_book/boss.py | 2 +- src/calibre/gui2/tweak_book/char_select.py | 4 ++-- src/calibre/gui2/tweak_book/check_links.py | 4 ++-- src/calibre/gui2/tweak_book/diff/main.py | 4 ++-- src/calibre/gui2/tweak_book/download.py | 2 +- .../gui2/tweak_book/editor/insert_resource.py | 14 +++++++------- src/calibre/gui2/tweak_book/file_list.py | 2 +- src/calibre/gui2/tweak_book/function_replace.py | 4 ++-- src/calibre/gui2/tweak_book/manage_fonts.py | 4 ++-- src/calibre/gui2/tweak_book/polish.py | 4 ++-- src/calibre/gui2/tweak_book/preferences.py | 6 +++--- src/calibre/gui2/tweak_book/reports.py | 6 +++--- src/calibre/gui2/tweak_book/search.py | 4 ++-- src/calibre/gui2/tweak_book/spell.py | 10 +++++----- src/calibre/gui2/tweak_book/toc.py | 2 +- src/calibre/gui2/tweak_book/widgets.py | 4 ++-- src/calibre/gui2/update.py | 4 ++-- src/calibre/gui2/viewer/lookup.py | 6 +++--- src/calibre/gui2/viewer/toolbars.py | 4 ++-- 55 files changed, 150 insertions(+), 150 deletions(-) diff --git a/src/calibre/gui2/__init__.py b/src/calibre/gui2/__init__.py index 767bd2cc48..67091bc79f 100644 --- a/src/calibre/gui2/__init__.py +++ b/src/calibre/gui2/__init__.py @@ -18,7 +18,7 @@ from PyQt5.Qt import ( QDesktopServices, QDialog, QEvent, QFileDialog, QFileIconProvider, QFileInfo, QPalette, QFont, QFontDatabase, QFontInfo, QFontMetrics, QIcon, QLocale, QColor, QNetworkProxyFactory, QObject, QSettings, QSocketNotifier, QStringListModel, Qt, - QThread, QTimer, QTranslator, QUrl, pyqtSignal, QIODevice + QThread, QTimer, QTranslator, QUrl, pyqtSignal, QIODevice, QDialogButtonBox ) from PyQt5.QtWidgets import QStyle # Gives a nicer error message than import from Qt @@ -458,7 +458,7 @@ def info_dialog(parent, title, msg, det_msg='', show=False, def show_restart_warning(msg, parent=None): d = warning_dialog(parent, _('Restart needed'), msg, show_copy_button=False) - b = d.bb.addButton(_('&Restart calibre now'), d.bb.AcceptRole) + b = d.bb.addButton(_('&Restart calibre now'), QDialogButtonBox.ButtonRole.AcceptRole) b.setIcon(QIcon(I('lt.png'))) d.do_restart = False diff --git a/src/calibre/gui2/actions/choose_library.py b/src/calibre/gui2/actions/choose_library.py index aaff10690b..5d9ae42f32 100644 --- a/src/calibre/gui2/actions/choose_library.py +++ b/src/calibre/gui2/actions/choose_library.py @@ -124,9 +124,9 @@ class MovedDialog(QDialog): # {{{ self.cd.clicked.connect(self.choose_dir) l.addWidget(self.cd, l.rowCount() - 1, 1, 1, 1) self.bb = QDialogButtonBox(QDialogButtonBox.StandardButton.Abort) - b = self.bb.addButton(_('Library moved'), self.bb.AcceptRole) + b = self.bb.addButton(_('Library moved'), QDialogButtonBox.ButtonRole.AcceptRole) b.setIcon(QIcon(I('ok.png'))) - b = self.bb.addButton(_('Forget library'), self.bb.RejectRole) + b = self.bb.addButton(_('Forget library'), QDialogButtonBox.ButtonRole.RejectRole) b.setIcon(QIcon(I('edit-clear.png'))) b.clicked.connect(self.forget_library) self.bb.accepted.connect(self.accept) @@ -167,7 +167,7 @@ class BackupStatus(QDialog): # {{{ self.bb = bb = QDialogButtonBox(QDialogButtonBox.StandardButton.Close) bb.accepted.connect(self.accept) bb.rejected.connect(self.reject) - b = bb.addButton(_('Queue &all books for backup'), bb.ActionRole) + b = bb.addButton(_('Queue &all books for backup'), QDialogButtonBox.ButtonRole.ActionRole) b.clicked.connect(self.mark_all_dirty) b.setIcon(QIcon(I('lt.png'))) l.addWidget(bb) diff --git a/src/calibre/gui2/actions/copy_to_library.py b/src/calibre/gui2/actions/copy_to_library.py index 578f2e7b72..762a5d3f62 100644 --- a/src/calibre/gui2/actions/copy_to_library.py +++ b/src/calibre/gui2/actions/copy_to_library.py @@ -235,10 +235,10 @@ class ChooseLibrary(Dialog): # {{{ bb = self.bb bb.setStandardButtons(QDialogButtonBox.StandardButton.Cancel) self.delete_after_copy = False - b = bb.addButton(_('&Copy'), bb.AcceptRole) + b = bb.addButton(_('&Copy'), QDialogButtonBox.ButtonRole.AcceptRole) b.setIcon(QIcon(I('edit-copy.png'))) b.setToolTip(_('Copy to the specified library')) - b2 = bb.addButton(_('&Move'), bb.AcceptRole) + b2 = bb.addButton(_('&Move'), QDialogButtonBox.ButtonRole.AcceptRole) connect_lambda(b2.clicked, self, lambda self: setattr(self, 'delete_after_copy', True)) b2.setIcon(QIcon(I('edit-cut.png'))) b2.setToolTip(_('Copy to the specified library and delete from the current library')) @@ -291,11 +291,11 @@ class DuplicatesQuestion(QDialog): # {{{ self.bb = bb = QDialogButtonBox(QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel) bb.accepted.connect(self.accept) bb.rejected.connect(self.reject) - self.a = b = bb.addButton(_('Select &all'), bb.ActionRole) + self.a = b = bb.addButton(_('Select &all'), QDialogButtonBox.ButtonRole.ActionRole) b.clicked.connect(self.select_all), b.setIcon(QIcon(I('plus.png'))) - self.n = b = bb.addButton(_('Select &none'), bb.ActionRole) + self.n = b = bb.addButton(_('Select &none'), QDialogButtonBox.ButtonRole.ActionRole) b.clicked.connect(self.select_none), b.setIcon(QIcon(I('minus.png'))) - self.ctc = b = bb.addButton(_('&Copy to clipboard'), bb.ActionRole) + self.ctc = b = bb.addButton(_('&Copy to clipboard'), QDialogButtonBox.ButtonRole.ActionRole) b.clicked.connect(self.copy_to_clipboard), b.setIcon(QIcon(I('edit-copy.png'))) l.addWidget(bb) self.resize(600, 400) diff --git a/src/calibre/gui2/actions/polish.py b/src/calibre/gui2/actions/polish.py index 139bb9e39a..10d2830a18 100644 --- a/src/calibre/gui2/actions/polish.py +++ b/src/calibre/gui2/actions/polish.py @@ -130,14 +130,14 @@ class Polish(QDialog): # {{{ self.bb = bb = QDialogButtonBox(QDialogButtonBox.StandardButton.Ok|QDialogButtonBox.StandardButton.Cancel) bb.accepted.connect(self.accept) bb.rejected.connect(self.reject) - self.save_button = sb = bb.addButton(_('&Save settings'), bb.ActionRole) + self.save_button = sb = bb.addButton(_('&Save settings'), QDialogButtonBox.ButtonRole.ActionRole) sb.clicked.connect(self.save_settings) - self.load_button = lb = bb.addButton(_('&Load settings'), bb.ActionRole) + self.load_button = lb = bb.addButton(_('&Load settings'), QDialogButtonBox.ButtonRole.ActionRole) self.load_menu = QMenu(lb) lb.setMenu(self.load_menu) - self.all_button = b = bb.addButton(_('Select &all'), bb.ActionRole) + self.all_button = b = bb.addButton(_('Select &all'), QDialogButtonBox.ButtonRole.ActionRole) connect_lambda(b.clicked, self, lambda self: self.select_all(True)) - self.none_button = b = bb.addButton(_('Select &none'), bb.ActionRole) + self.none_button = b = bb.addButton(_('Select &none'), QDialogButtonBox.ButtonRole.ActionRole) connect_lambda(b.clicked, self, lambda self: self.select_all(False)) l.addWidget(bb, count+1, 1, 1, -1) self.setup_load_button() @@ -334,7 +334,7 @@ class Report(QDialog): # {{{ bb = self.bb = QDialogButtonBox(QDialogButtonBox.StandardButton.Close) bb.accepted.connect(self.accept) bb.rejected.connect(self.reject) - b = self.log_button = bb.addButton(_('View full &log'), bb.ActionRole) + b = self.log_button = bb.addButton(_('View full &log'), QDialogButtonBox.ButtonRole.ActionRole) b.clicked.connect(self.view_log) bb.button(bb.Close).setDefault(True) l.addWidget(bb, 2, 1) diff --git a/src/calibre/gui2/actions/toc_edit.py b/src/calibre/gui2/actions/toc_edit.py index 695ebf70b1..b2d0ccea2e 100644 --- a/src/calibre/gui2/actions/toc_edit.py +++ b/src/calibre/gui2/actions/toc_edit.py @@ -40,7 +40,7 @@ class ChooseFormat(QDialog): # {{{ bb = self.bb = QDialogButtonBox( QDialogButtonBox.StandardButton.Ok|QDialogButtonBox.StandardButton.Cancel) bb.addButton(_('&All formats'), - bb.ActionRole).clicked.connect(self.do_all) + QDialogButtonBox.ButtonRole.ActionRole).clicked.connect(self.do_all) bb.accepted.connect(self.accept) bb.rejected.connect(self.reject) l.addWidget(bb, l.rowCount(), 0, 1, -1) diff --git a/src/calibre/gui2/actions/tweak_epub.py b/src/calibre/gui2/actions/tweak_epub.py index f7aa1aa2fd..6ca2eff8c3 100644 --- a/src/calibre/gui2/actions/tweak_epub.py +++ b/src/calibre/gui2/actions/tweak_epub.py @@ -36,7 +36,7 @@ class Choose(QDialog): bb.rejected.connect(self.reject) self.buts = buts = [] for fmt in fmts: - b = bb.addButton(fmt.upper(), bb.AcceptRole) + b = bb.addButton(fmt.upper(), QDialogButtonBox.ButtonRole.AcceptRole) b.setObjectName(fmt) connect_lambda(b.clicked, self, lambda self: self.chosen(self.sender().objectName())) buts.append(b) diff --git a/src/calibre/gui2/covers.py b/src/calibre/gui2/covers.py index 2f2248d15d..64cd4acc75 100644 --- a/src/calibre/gui2/covers.py +++ b/src/calibre/gui2/covers.py @@ -520,7 +520,7 @@ class CoverSettingsDialog(QDialog): self.bb = bb = QDialogButtonBox(QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel) l.addWidget(bb) bb.accepted.connect(self.accept), bb.rejected.connect(self.reject) - bb.b = b = bb.addButton(_('Restore &defaults'), bb.ActionRole) + bb.b = b = bb.addButton(_('Restore &defaults'), QDialogButtonBox.ButtonRole.ActionRole) b.clicked.connect(self.restore_defaults) ss.setToolTip('

' + _( 'Save the current settings as the settings to use always instead of just this time. Remember that' diff --git a/src/calibre/gui2/device_drivers/mtp_config.py b/src/calibre/gui2/device_drivers/mtp_config.py index 2ed7b34ed5..a12c9d8526 100644 --- a/src/calibre/gui2/device_drivers/mtp_config.py +++ b/src/calibre/gui2/device_drivers/mtp_config.py @@ -425,7 +425,7 @@ class MTPConfig(QTabWidget): bb.accepted.connect(d.accept) bb.rejected.connect(d.reject) l.addWidget(bb) - bb.addButton(_('Copy to clipboard'), bb.ActionRole) + bb.addButton(_('Copy to clipboard'), QDialogButtonBox.ButtonRole.ActionRole) bb.clicked.connect(lambda : QApplication.clipboard().setText(v.toPlainText())) d.exec_() @@ -510,7 +510,7 @@ class SendError(QDialog): la.setMinimumWidth(500) l.addWidget(la) self.bb = bb = QDialogButtonBox(QDialogButtonBox.StandardButton.Close) - self.b = bb.addButton(_('Configure'), bb.AcceptRole) + self.b = bb.addButton(_('Configure'), QDialogButtonBox.ButtonRole.AcceptRole) bb.accepted.connect(self.accept) bb.rejected.connect(self.reject) l.addWidget(bb) diff --git a/src/calibre/gui2/device_drivers/mtp_folder_browser.py b/src/calibre/gui2/device_drivers/mtp_folder_browser.py index 120bfe58b7..cc6b1f4e68 100644 --- a/src/calibre/gui2/device_drivers/mtp_folder_browser.py +++ b/src/calibre/gui2/device_drivers/mtp_folder_browser.py @@ -135,9 +135,9 @@ class IgnoredFolders(QDialog): QDialogButtonBox.StandardButton.Cancel) self.bb.accepted.connect(self.accept) self.bb.rejected.connect(self.reject) - self.sab = self.bb.addButton(_('Select &all'), self.bb.ActionRole) + self.sab = self.bb.addButton(_('Select &all'), QDialogButtonBox.ButtonRole.ActionRole) self.sab.clicked.connect(self.select_all) - self.snb = self.bb.addButton(_('Select &none'), self.bb.ActionRole) + self.snb = self.bb.addButton(_('Select &none'), QDialogButtonBox.ButtonRole.ActionRole) self.snb.clicked.connect(self.select_none) l.addWidget(self.bb) self.setWindowTitle(_('Choose folders to scan')) diff --git a/src/calibre/gui2/dialogs/add_empty_book.py b/src/calibre/gui2/dialogs/add_empty_book.py index 03aaf1288f..1dbe1abe44 100644 --- a/src/calibre/gui2/dialogs/add_empty_book.py +++ b/src/calibre/gui2/dialogs/add_empty_book.py @@ -110,7 +110,7 @@ class AddEmptyBookDialog(QDialog): button_box.rejected.connect(self.reject) self._layout.addWidget(button_box, 11, 0, 1, -1) if dup_title: - self.dup_button = b = button_box.addButton(_('&Duplicate current book'), button_box.ActionRole) + self.dup_button = b = button_box.addButton(_('&Duplicate current book'), QDialogButtonBox.ButtonRole.ActionRole) b.clicked.connect(self.do_duplicate_book) b.setIcon(QIcon(I('edit-copy.png'))) b.setToolTip(_( diff --git a/src/calibre/gui2/dialogs/book_info.py b/src/calibre/gui2/dialogs/book_info.py index 23aadb294a..30e8664849 100644 --- a/src/calibre/gui2/dialogs/book_info.py +++ b/src/calibre/gui2/dialogs/book_info.py @@ -7,7 +7,7 @@ from PyQt5.Qt import ( QAction, QApplication, QBrush, QCheckBox, QCoreApplication, QDialog, QGridLayout, QHBoxLayout, QIcon, QKeySequence, QLabel, QListView, QModelIndex, QPalette, QPixmap, QPushButton, QShortcut, QSize, QSplitter, Qt, QTimer, QToolButton, - QVBoxLayout, QWidget, pyqtSignal + QVBoxLayout, QWidget, pyqtSignal, QDialogButtonBox ) from calibre import fit_image @@ -80,11 +80,11 @@ class Configure(Dialog): self.l.addWidget(QLabel('

' + _( 'Note that comments will always be displayed at the end, regardless of the order you assign here'))) - b = self.bb.addButton(_('Restore &defaults'), self.bb.ActionRole) + b = self.bb.addButton(_('Restore &defaults'), QDialogButtonBox.ButtonRole.ActionRole) b.clicked.connect(self.restore_defaults) - b = self.bb.addButton(_('Select &all'), self.bb.ActionRole) + b = self.bb.addButton(_('Select &all'), QDialogButtonBox.ButtonRole.ActionRole) b.clicked.connect(self.select_all) - b = self.bb.addButton(_('Select &none'), self.bb.ActionRole) + b = self.bb.addButton(_('Select &none'), QDialogButtonBox.ButtonRole.ActionRole) b.clicked.connect(self.select_none) self.l.addWidget(self.bb) self.setMinimumHeight(500) diff --git a/src/calibre/gui2/dialogs/custom_recipes.py b/src/calibre/gui2/dialogs/custom_recipes.py index d97a2cead7..2d057fd20f 100644 --- a/src/calibre/gui2/dialogs/custom_recipes.py +++ b/src/calibre/gui2/dialogs/custom_recipes.py @@ -585,7 +585,7 @@ class CustomRecipes(Dialog): if index == 0: bb.setStandardButtons(bb.Close) for icon, text, tooltip, receiver in self.list_actions: - b = bb.addButton(text, bb.ActionRole) + b = bb.addButton(text, QDialogButtonBox.ButtonRole.ActionRole) b.setIcon(QIcon(I(icon))), b.setToolTip(tooltip) b.clicked.connect(receiver) else: @@ -594,7 +594,7 @@ class CustomRecipes(Dialog): text = _('S&witch to advanced mode') tooltip = _('Edit this recipe in advanced mode') receiver = self.switch_to_advanced - b = bb.addButton(text, bb.ActionRole) + b = bb.addButton(text, QDialogButtonBox.ButtonRole.ActionRole) b.setToolTip(tooltip) b.clicked.connect(receiver) diff --git a/src/calibre/gui2/dialogs/duplicates.py b/src/calibre/gui2/dialogs/duplicates.py index c253384f8e..3cbb6e55b2 100644 --- a/src/calibre/gui2/dialogs/duplicates.py +++ b/src/calibre/gui2/dialogs/duplicates.py @@ -52,11 +52,11 @@ class DuplicatesQuestion(QDialog): bb.rejected.connect(self.reject) l.addWidget(bb, 2, 0, 1, 2) l.setColumnStretch(1, 10) - self.ab = ab = bb.addButton(_('Select &all'), bb.ActionRole) + self.ab = ab = bb.addButton(_('Select &all'), QDialogButtonBox.ButtonRole.ActionRole) ab.clicked.connect(self.select_all), ab.setIcon(QIcon(I('plus.png'))) - self.nb = ab = bb.addButton(_('Select &none'), bb.ActionRole) + self.nb = ab = bb.addButton(_('Select &none'), QDialogButtonBox.ButtonRole.ActionRole) ab.clicked.connect(self.select_none), ab.setIcon(QIcon(I('minus.png'))) - self.cb = cb = bb.addButton(_('&Copy to clipboard'), bb.ActionRole) + self.cb = cb = bb.addButton(_('&Copy to clipboard'), QDialogButtonBox.ButtonRole.ActionRole) cb.setIcon(QIcon(I('edit-copy.png'))) cb.clicked.connect(self.copy_to_clipboard) diff --git a/src/calibre/gui2/dialogs/message_box.py b/src/calibre/gui2/dialogs/message_box.py index c1d6991671..d0d5fe5381 100644 --- a/src/calibre/gui2/dialogs/message_box.py +++ b/src/calibre/gui2/dialogs/message_box.py @@ -107,12 +107,12 @@ class MessageBox(QDialog): # {{{ if show_copy_button: self.ctc_button = self.bb.addButton(_('&Copy to clipboard'), - self.bb.ActionRole) + QDialogButtonBox.ButtonRole.ActionRole) self.ctc_button.clicked.connect(self.copy_to_clipboard) self.show_det_msg = _('Show &details') self.hide_det_msg = _('Hide &details') - self.det_msg_toggle = self.bb.addButton(self.show_det_msg, self.bb.ActionRole) + self.det_msg_toggle = self.bb.addButton(self.show_det_msg, QDialogButtonBox.ButtonRole.ActionRole) self.det_msg_toggle.clicked.connect(self.toggle_det_msg) self.det_msg_toggle.setToolTip( _('Show detailed information about this error')) @@ -207,7 +207,7 @@ class ViewLog(QDialog): # {{{ self.bb.accepted.connect(self.accept) self.bb.rejected.connect(self.reject) self.copy_button = self.bb.addButton(_('Copy to clipboard'), - self.bb.ActionRole) + QDialogButtonBox.ButtonRole.ActionRole) self.copy_button.setIcon(QIcon(I('edit-copy.png'))) self.copy_button.clicked.connect(self.copy_to_clipboard) l.addWidget(self.bb) @@ -273,7 +273,7 @@ class ProceedNotification(MessageBox): # {{{ self.log_is_file = log_is_file self.log_viewer_title = log_viewer_title - self.vlb = self.bb.addButton(_('&View log'), self.bb.ActionRole) + self.vlb = self.bb.addButton(_('&View log'), QDialogButtonBox.ButtonRole.ActionRole) self.vlb.setIcon(QIcon(I('debug.png'))) self.vlb.clicked.connect(self.show_log) self.det_msg_toggle.setVisible(bool(det_msg)) @@ -329,7 +329,7 @@ class ErrorNotification(MessageBox): # {{{ self.log_viewer_title = log_viewer_title self.finished.connect(self.do_close, type=Qt.ConnectionType.QueuedConnection) - self.vlb = self.bb.addButton(_('&View log'), self.bb.ActionRole) + self.vlb = self.bb.addButton(_('&View log'), QDialogButtonBox.ButtonRole.ActionRole) self.vlb.setIcon(QIcon(I('debug.png'))) self.vlb.clicked.connect(self.show_log) self.det_msg_toggle.setVisible(bool(det_msg)) @@ -377,14 +377,14 @@ class JobError(QDialog): # {{{ self.bb.accepted.connect(self.accept) self.bb.rejected.connect(self.reject) self.ctc_button = self.bb.addButton(_('&Copy to clipboard'), - self.bb.ActionRole) + QDialogButtonBox.ButtonRole.ActionRole) self.ctc_button.clicked.connect(self.copy_to_clipboard) - self.retry_button = self.bb.addButton(_('&Retry'), self.bb.ActionRole) + self.retry_button = self.bb.addButton(_('&Retry'), QDialogButtonBox.ButtonRole.ActionRole) self.retry_button.clicked.connect(self.retry) self.retry_func = None self.show_det_msg = _('Show &details') self.hide_det_msg = _('Hide &details') - self.det_msg_toggle = self.bb.addButton(self.show_det_msg, self.bb.ActionRole) + self.det_msg_toggle = self.bb.addButton(self.show_det_msg, QDialogButtonBox.ButtonRole.ActionRole) self.det_msg_toggle.clicked.connect(self.toggle_det_msg) self.det_msg_toggle.setToolTip( _('Show detailed information about this error')) diff --git a/src/calibre/gui2/dialogs/plugin_updater.py b/src/calibre/gui2/dialogs/plugin_updater.py index f31c129329..e870574d9d 100644 --- a/src/calibre/gui2/dialogs/plugin_updater.py +++ b/src/calibre/gui2/dialogs/plugin_updater.py @@ -720,7 +720,7 @@ class PluginUpdaterDialog(SizePersistedDialog): ' {1} plugins. You may have to restart calibre ' 'for the plugin to take effect.').format(plugin.name, plugin.type), show_copy_button=False) - b = d.bb.addButton(_('&Restart calibre now'), d.bb.AcceptRole) + b = d.bb.addButton(_('&Restart calibre now'), QDialogButtonBox.ButtonRole.AcceptRole) b.setIcon(QIcon(I('lt.png'))) d.do_restart = False diff --git a/src/calibre/gui2/dialogs/saved_search_editor.py b/src/calibre/gui2/dialogs/saved_search_editor.py index 45c3bd8402..df1e42b80b 100644 --- a/src/calibre/gui2/dialogs/saved_search_editor.py +++ b/src/calibre/gui2/dialogs/saved_search_editor.py @@ -4,7 +4,7 @@ from PyQt5.Qt import ( - QFormLayout, QIcon, QLabel, QLineEdit, QListWidget, Qt, QVBoxLayout, QDialog + QFormLayout, QIcon, QLabel, QLineEdit, QListWidget, Qt, QVBoxLayout, QDialog, QDialogButtonBox ) from calibre import prepare_string_for_xml @@ -99,15 +99,15 @@ class SavedSearchEditor(Dialog): from calibre.gui2.ui import get_gui db = get_gui().current_db self.l = l = QVBoxLayout(self) - b = self.bb.addButton(_('&Add search'), self.bb.ActionRole) + b = self.bb.addButton(_('&Add search'), QDialogButtonBox.ButtonRole.ActionRole) b.setIcon(QIcon(I('plus.png'))) b.clicked.connect(self.add_search) - b = self.bb.addButton(_('&Remove search'), self.bb.ActionRole) + b = self.bb.addButton(_('&Remove search'), QDialogButtonBox.ButtonRole.ActionRole) b.setIcon(QIcon(I('minus.png'))) b.clicked.connect(self.del_search) - b = self.bb.addButton(_('&Edit search'), self.bb.ActionRole) + b = self.bb.addButton(_('&Edit search'), QDialogButtonBox.ButtonRole.ActionRole) b.setIcon(QIcon(I('modified.png'))) b.clicked.connect(self.edit_search) diff --git a/src/calibre/gui2/dialogs/scheduler.py b/src/calibre/gui2/dialogs/scheduler.py index 6cf993f60e..318ec6af30 100644 --- a/src/calibre/gui2/dialogs/scheduler.py +++ b/src/calibre/gui2/dialogs/scheduler.py @@ -357,7 +357,7 @@ class SchedulerDialog(QDialog): self.l.addWidget(b, 3, 0, 1, 1) self.bb = bb = QDialogButtonBox(QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel, self) bb.accepted.connect(self.accept), bb.rejected.connect(self.reject) - self.download_button = b = bb.addButton(_('&Download now'), bb.ActionRole) + self.download_button = b = bb.addButton(_('&Download now'), QDialogButtonBox.ButtonRole.ActionRole) b.setIcon(QIcon(I('arrow-down.png'))), b.setVisible(False) b.clicked.connect(self.download_clicked) self.l.addWidget(bb, 3, 1, 1, 1) diff --git a/src/calibre/gui2/font_family_chooser.py b/src/calibre/gui2/font_family_chooser.py index b60f8650a6..060933a651 100644 --- a/src/calibre/gui2/font_family_chooser.py +++ b/src/calibre/gui2/font_family_chooser.py @@ -225,7 +225,7 @@ class FontFamilyDialog(QDialog): self.bb.accepted.connect(self.accept) self.bb.rejected.connect(self.reject) self.add_fonts_button = afb = self.bb.addButton(_('Add &fonts'), - self.bb.ActionRole) + QDialogButtonBox.ButtonRole.ActionRole) afb.setIcon(QIcon(I('plus.png'))) afb.clicked.connect(self.add_fonts) self.ml = QLabel(_('Choose a font family from the list below:')) diff --git a/src/calibre/gui2/icon_theme.py b/src/calibre/gui2/icon_theme.py index 2cf3dff55f..a58180849a 100644 --- a/src/calibre/gui2/icon_theme.py +++ b/src/calibre/gui2/icon_theme.py @@ -16,7 +16,7 @@ from PyQt5.Qt import ( QLineEdit, QSpinBox, QTextEdit, QSize, QListWidgetItem, QIcon, QImage, pyqtSignal, QStackedLayout, QWidget, QLabel, Qt, QComboBox, QPixmap, QDialog, QGridLayout, QStyledItemDelegate, QApplication, QStaticText, - QStyle, QPen, QProgressDialog, QAbstractItemView + QStyle, QPen, QProgressDialog, QAbstractItemView, QDialogButtonBox ) try: from PyQt5 import sip @@ -237,7 +237,7 @@ class ThemeCreateDialog(Dialog): ' Creative Commons or Public Domain.')) self.description = QTextEdit(self) l.addRow(self.description) - self.refresh_button = rb = self.bb.addButton(_('&Refresh'), self.bb.ActionRole) + self.refresh_button = rb = self.bb.addButton(_('&Refresh'), QDialogButtonBox.ButtonRole.ActionRole) rb.setIcon(QIcon(I('view-refresh.png'))) rb.clicked.connect(self.refresh) @@ -605,7 +605,7 @@ class ChooseTheme(Dialog): self.stack = l = QStackedLayout() self.pi = pi = ProgressIndicator(self, 256) vl.addLayout(l), vl.addWidget(self.bb) - self.restore_defs_button = b = self.bb.addButton(_('Restore &default icons'), self.bb.ActionRole) + self.restore_defs_button = b = self.bb.addButton(_('Restore &default icons'), QDialogButtonBox.ButtonRole.ActionRole) b.clicked.connect(self.restore_defaults) b.setIcon(QIcon(I('view-refresh.png'))) self.c = c = QWidget(self) diff --git a/src/calibre/gui2/image_popup.py b/src/calibre/gui2/image_popup.py index 972c6be9cf..e4e575b2f3 100644 --- a/src/calibre/gui2/image_popup.py +++ b/src/calibre/gui2/image_popup.py @@ -59,10 +59,10 @@ class ImageView(QDialog): self.bb = bb = QDialogButtonBox(QDialogButtonBox.StandardButton.Close) bb.accepted.connect(self.accept) bb.rejected.connect(self.reject) - self.zi_button = zi = bb.addButton(_('Zoom &in'), bb.ActionRole) - self.zo_button = zo = bb.addButton(_('Zoom &out'), bb.ActionRole) - self.save_button = so = bb.addButton(_('&Save as'), bb.ActionRole) - self.rotate_button = ro = bb.addButton(_('&Rotate'), bb.ActionRole) + self.zi_button = zi = bb.addButton(_('Zoom &in'), QDialogButtonBox.ButtonRole.ActionRole) + self.zo_button = zo = bb.addButton(_('Zoom &out'), QDialogButtonBox.ButtonRole.ActionRole) + self.save_button = so = bb.addButton(_('&Save as'), QDialogButtonBox.ButtonRole.ActionRole) + self.rotate_button = ro = bb.addButton(_('&Rotate'), QDialogButtonBox.ButtonRole.ActionRole) zi.setIcon(QIcon(I('plus.png'))) zo.setIcon(QIcon(I('minus.png'))) so.setIcon(QIcon(I('save.png'))) diff --git a/src/calibre/gui2/jobs.py b/src/calibre/gui2/jobs.py index a6082970d7..850835b373 100644 --- a/src/calibre/gui2/jobs.py +++ b/src/calibre/gui2/jobs.py @@ -15,7 +15,7 @@ from PyQt5.Qt import (QAbstractTableModel, QModelIndex, Qt, QPainter, QTimer, pyqtSignal, QIcon, QDialog, QAbstractItemDelegate, QApplication, QSize, QStyleOptionProgressBar, QStyle, QToolTip, QWidget, QStyleOption, QHBoxLayout, QVBoxLayout, QSizePolicy, QLabel, QCoreApplication, QAction, - QByteArray, QSortFilterProxyModel, QTextBrowser, QPlainTextEdit) + QByteArray, QSortFilterProxyModel, QTextBrowser, QPlainTextEdit, QDialogButtonBox) from calibre import strftime from calibre.constants import islinux, isbsd @@ -465,7 +465,7 @@ class DetailView(Dialog): # {{{ l.addWidget(w) l.addWidget(self.bb) self.bb.clear(), self.bb.setStandardButtons(self.bb.Close) - self.copy_button = b = self.bb.addButton(_('&Copy to clipboard'), self.bb.ActionRole) + self.copy_button = b = self.bb.addButton(_('&Copy to clipboard'), QDialogButtonBox.ButtonRole.ActionRole) b.setIcon(QIcon(I('edit-copy.png'))) b.clicked.connect(self.copy_to_clipboard) self.next_pos = 0 diff --git a/src/calibre/gui2/library/annotations.py b/src/calibre/gui2/library/annotations.py index 00fb7a8463..4dd0e9fe22 100644 --- a/src/calibre/gui2/library/annotations.py +++ b/src/calibre/gui2/library/annotations.py @@ -124,10 +124,10 @@ class Export(Dialog): # {{{ l.addRow(self.bb) self.bb.clear() self.bb.addButton(QDialogButtonBox.StandardButton.Cancel) - b = self.bb.addButton(_('Copy to clipboard'), self.bb.ActionRole) + b = self.bb.addButton(_('Copy to clipboard'), QDialogButtonBox.ButtonRole.ActionRole) b.clicked.connect(self.copy_to_clipboard) b.setIcon(QIcon(I('edit-copy.png'))) - b = self.bb.addButton(_('Save to file'), self.bb.ActionRole) + b = self.bb.addButton(_('Save to file'), QDialogButtonBox.ButtonRole.ActionRole) b.clicked.connect(self.save_to_file) b.setIcon(QIcon(I('save.png'))) @@ -769,11 +769,11 @@ class AnnotationsBrowser(Dialog): h = QHBoxLayout() l.addLayout(h) h.addWidget(us), h.addStretch(10), h.addWidget(self.bb) - self.delete_button = b = self.bb.addButton(_('Delete all selected'), self.bb.ActionRole) + self.delete_button = b = self.bb.addButton(_('Delete all selected'), QDialogButtonBox.ButtonRole.ActionRole) b.setToolTip(_('Delete the selected annotations')) b.setIcon(QIcon(I('trash.png'))) b.clicked.connect(self.delete_selected) - self.export_button = b = self.bb.addButton(_('Export all selected'), self.bb.ActionRole) + self.export_button = b = self.bb.addButton(_('Export all selected'), QDialogButtonBox.ButtonRole.ActionRole) b.setToolTip(_('Export the selected annotations')) b.setIcon(QIcon(I('save.png'))) b.clicked.connect(self.export_selected) diff --git a/src/calibre/gui2/metadata/bulk_download.py b/src/calibre/gui2/metadata/bulk_download.py index 8bdc946eff..7dfcf7858d 100644 --- a/src/calibre/gui2/metadata/bulk_download.py +++ b/src/calibre/gui2/metadata/bulk_download.py @@ -86,19 +86,19 @@ class ConfirmDialog(QDialog): self.bb = QDialogButtonBox(QDialogButtonBox.StandardButton.Cancel) self.bb.rejected.connect(self.reject) b = self.bb.addButton(_('Download only &metadata'), - self.bb.AcceptRole) + QDialogButtonBox.ButtonRole.AcceptRole) b.clicked.connect(self.only_metadata) b.setIcon(QIcon(I('edit_input.png'))) b = self.bb.addButton(_('Download only &covers'), - self.bb.AcceptRole) + QDialogButtonBox.ButtonRole.AcceptRole) b.clicked.connect(self.only_covers) b.setIcon(QIcon(I('default_cover.png'))) - b = self.b = self.bb.addButton(_('&Configure download'), self.bb.ActionRole) + b = self.b = self.bb.addButton(_('&Configure download'), QDialogButtonBox.ButtonRole.ActionRole) b.setIcon(QIcon(I('config.png'))) connect_lambda(b.clicked, self, lambda self: show_config(self)) l.addWidget(self.bb, 1, 0, 1, 2) b = self.bb.addButton(_('Download &both'), - self.bb.AcceptRole) + QDialogButtonBox.ButtonRole.AcceptRole) b.clicked.connect(self.accept) b.setDefault(True) b.setAutoDefault(True) diff --git a/src/calibre/gui2/metadata/diff.py b/src/calibre/gui2/metadata/diff.py index ed0d277add..b7126dcb7f 100644 --- a/src/calibre/gui2/metadata/diff.py +++ b/src/calibre/gui2/metadata/diff.py @@ -560,17 +560,17 @@ class CompareMany(QDialog): bb.button(QDialogButtonBox.StandardButton.Cancel).setAutoDefault(False) bb.rejected.connect(self.reject) if self.total > 1: - self.aarb = b = bb.addButton(_('&Accept all remaining'), bb.YesRole) + self.aarb = b = bb.addButton(_('&Accept all remaining'), QDialogButtonBox.ButtonRole.YesRole) b.setIcon(QIcon(I('ok.png'))), b.setAutoDefault(False) if accept_all_tooltip: b.setToolTip(accept_all_tooltip) b.clicked.connect(self.accept_all_remaining) - self.rarb = b = bb.addButton(_('Re&ject all remaining'), bb.ActionRole) + self.rarb = b = bb.addButton(_('Re&ject all remaining'), QDialogButtonBox.ButtonRole.ActionRole) b.setIcon(QIcon(I('minus.png'))), b.setAutoDefault(False) if reject_all_tooltip: b.setToolTip(reject_all_tooltip) b.clicked.connect(self.reject_all_remaining) - self.sb = b = bb.addButton(_('R&eject'), bb.ActionRole) + self.sb = b = bb.addButton(_('R&eject'), QDialogButtonBox.ButtonRole.ActionRole) connect_lambda(b.clicked, self, lambda self: self.next_item(False)) b.setIcon(QIcon(I('minus.png'))), b.setAutoDefault(False) if reject_button_tooltip: @@ -579,11 +579,11 @@ class CompareMany(QDialog): ac.setShortcut(QKeySequence(Qt.Modifier.ALT | Qt.Key.Key_Right)) self.addAction(ac) if action_button is not None: - self.acb = b = bb.addButton(action_button[0], bb.ActionRole) + self.acb = b = bb.addButton(action_button[0], QDialogButtonBox.ButtonRole.ActionRole) b.setIcon(QIcon(action_button[1])) self.action_button_action = action_button[2] b.clicked.connect(self.action_button_clicked) - self.nb = b = bb.addButton(_('&Next') if self.total > 1 else _('&OK'), bb.ActionRole) + self.nb = b = bb.addButton(_('&Next') if self.total > 1 else _('&OK'), QDialogButtonBox.ButtonRole.ActionRole) if self.total > 1: b.setToolTip(_('Move to next [%s]') % self.next_action.shortcut().toString(QKeySequence.SequenceFormat.NativeText)) self.next_action.triggered.connect(b.click) diff --git a/src/calibre/gui2/metadata/single.py b/src/calibre/gui2/metadata/single.py index 064554bbdb..1fdec05fb1 100644 --- a/src/calibre/gui2/metadata/single.py +++ b/src/calibre/gui2/metadata/single.py @@ -92,8 +92,8 @@ class MetadataSingleDialogBase(QDialog): self) self.prev_button.setShortcut(QKeySequence('Alt+Left')) - self.button_box.addButton(self.prev_button, bb.ActionRole) - self.button_box.addButton(self.next_button, bb.ActionRole) + self.button_box.addButton(self.prev_button, QDialogButtonBox.ButtonRole.ActionRole) + self.button_box.addButton(self.next_button, QDialogButtonBox.ButtonRole.ActionRole) self.prev_button.clicked.connect(self.prev_clicked) bb.setStandardButtons(QDialogButtonBox.StandardButton.Ok|QDialogButtonBox.StandardButton.Cancel) bb.button(QDialogButtonBox.StandardButton.Ok).setDefault(True) diff --git a/src/calibre/gui2/metadata/single_download.py b/src/calibre/gui2/metadata/single_download.py index 3d009eb46e..01cfaf0004 100644 --- a/src/calibre/gui2/metadata/single_download.py +++ b/src/calibre/gui2/metadata/single_download.py @@ -978,7 +978,7 @@ class LogViewer(QDialog): # {{{ self.bb = QDialogButtonBox(QDialogButtonBox.StandardButton.Close) l.addWidget(self.bb) self.copy_button = self.bb.addButton(_('Copy to clipboard'), - self.bb.ActionRole) + QDialogButtonBox.ButtonRole.ActionRole) self.copy_button.clicked.connect(self.copy_to_clipboard) self.copy_button.setIcon(QIcon(I('edit-copy.png'))) self.bb.rejected.connect(self.reject) @@ -1040,7 +1040,7 @@ class FullFetch(QDialog): # {{{ self.prev_button = pb = QPushButton(QIcon(I('back.png')), _('&Back'), self) pb.clicked.connect(self.back_clicked) pb.setSizePolicy(QSizePolicy.Policy.Fixed, QSizePolicy.Policy.Fixed) - self.log_button = self.bb.addButton(_('&View log'), self.bb.ActionRole) + self.log_button = self.bb.addButton(_('&View log'), QDialogButtonBox.ButtonRole.ActionRole) self.log_button.clicked.connect(self.view_log) self.log_button.setIcon(QIcon(I('debug.png'))) self.prev_button.setVisible(False) @@ -1154,7 +1154,7 @@ class CoverFetch(QDialog): # {{{ self.bb = QDialogButtonBox(QDialogButtonBox.StandardButton.Cancel|QDialogButtonBox.StandardButton.Ok) l.addWidget(self.bb) - self.log_button = self.bb.addButton(_('&View log'), self.bb.ActionRole) + self.log_button = self.bb.addButton(_('&View log'), QDialogButtonBox.ButtonRole.ActionRole) self.log_button.clicked.connect(self.view_log) self.log_button.setIcon(QIcon(I('debug.png'))) self.bb.rejected.connect(self.reject) diff --git a/src/calibre/gui2/open_with.py b/src/calibre/gui2/open_with.py index d7263c6026..2d5e758f21 100644 --- a/src/calibre/gui2/open_with.py +++ b/src/calibre/gui2/open_with.py @@ -12,7 +12,7 @@ from functools import partial from PyQt5.Qt import ( QAction, QBuffer, QByteArray, QIcon, QInputDialog, QKeySequence, QLabel, QListWidget, QListWidgetItem, QPixmap, QSize, QStackedLayout, Qt, QVBoxLayout, - QWidget, pyqtSignal, QIODevice + QWidget, pyqtSignal, QIODevice, QDialogButtonBox ) from threading import Thread @@ -311,7 +311,7 @@ class ChooseProgram(Dialog): # {{{ l.addWidget(la), l.addWidget(pl) la.setBuddy(pl) - b = self.bb.addButton(_('&Browse computer for program'), self.bb.ActionRole) + b = self.bb.addButton(_('&Browse computer for program'), QDialogButtonBox.ButtonRole.ActionRole) b.clicked.connect(self.manual) l.addWidget(self.bb) @@ -401,11 +401,11 @@ class EditPrograms(Dialog): # {{{ l.addWidget(pl) self.bb.clear(), self.bb.setStandardButtons(self.bb.Close) - self.rb = b = self.bb.addButton(_('&Remove'), self.bb.ActionRole) + self.rb = b = self.bb.addButton(_('&Remove'), QDialogButtonBox.ButtonRole.ActionRole) b.clicked.connect(self.remove), b.setIcon(QIcon(I('list_remove.png'))) - self.cb = b = self.bb.addButton(_('Change &icon'), self.bb.ActionRole) + self.cb = b = self.bb.addButton(_('Change &icon'), QDialogButtonBox.ButtonRole.ActionRole) b.clicked.connect(self.change_icon), b.setIcon(QIcon(I('icon_choose.png'))) - self.cb = b = self.bb.addButton(_('Change &name'), self.bb.ActionRole) + self.cb = b = self.bb.addButton(_('Change &name'), QDialogButtonBox.ButtonRole.ActionRole) b.clicked.connect(self.change_name), b.setIcon(QIcon(I('modified.png'))) l.addWidget(self.bb) diff --git a/src/calibre/gui2/preferences/coloring.py b/src/calibre/gui2/preferences/coloring.py index b697428d67..64261b11d9 100644 --- a/src/calibre/gui2/preferences/coloring.py +++ b/src/calibre/gui2/preferences/coloring.py @@ -419,7 +419,7 @@ class RuleEditor(QDialog): # {{{ bb.rejected.connect(self.reject) l.addWidget(bb, 7, 0, 1, 8) if self.rule_kind != 'color': - self.remove_button = b = bb.addButton(_('&Remove icon'), bb.ActionRole) + self.remove_button = b = bb.addButton(_('&Remove icon'), QDialogButtonBox.ButtonRole.ActionRole) b.setIcon(QIcon(I('minus.png'))) b.setMenu(QMenu(b)) b.setToolTip('

' + _('Remove a previously added icon. Note that doing so will cause rules that use it to stop working.')) diff --git a/src/calibre/gui2/preferences/look_feel.py b/src/calibre/gui2/preferences/look_feel.py index 1a40224b7d..b827c15537 100644 --- a/src/calibre/gui2/preferences/look_feel.py +++ b/src/calibre/gui2/preferences/look_feel.py @@ -15,7 +15,7 @@ from PyQt5.Qt import ( QApplication, QFont, QFontInfo, QFontDialog, QColorDialog, QPainter, QDialog, QAbstractListModel, Qt, QIcon, QKeySequence, QColor, pyqtSignal, QCursor, QWidget, QSizePolicy, QBrush, QPixmap, QSize, QPushButton, QVBoxLayout, - QTableWidget, QTableWidgetItem, QLabel, QFormLayout, QLineEdit, QComboBox + QTableWidget, QTableWidgetItem, QLabel, QFormLayout, QLineEdit, QComboBox, QDialogButtonBox ) from calibre import human_readable @@ -179,13 +179,13 @@ class IdLinksEditor(Dialog): t.horizontalHeader().setSectionResizeMode(2, t.horizontalHeader().Stretch) self.cb = b = QPushButton(QIcon(I('plus.png')), _('&Add rule'), self) connect_lambda(b.clicked, self, lambda self: self.edit_rule()) - self.bb.addButton(b, self.bb.ActionRole) + self.bb.addButton(b, QDialogButtonBox.ButtonRole.ActionRole) self.rb = b = QPushButton(QIcon(I('minus.png')), _('&Remove rule'), self) connect_lambda(b.clicked, self, lambda self: self.remove_rule()) - self.bb.addButton(b, self.bb.ActionRole) + self.bb.addButton(b, QDialogButtonBox.ButtonRole.ActionRole) self.eb = b = QPushButton(QIcon(I('modified.png')), _('&Edit rule'), self) connect_lambda(b.clicked, self, lambda self: self.edit_rule(self.table.currentRow())) - self.bb.addButton(b, self.bb.ActionRole) + self.bb.addButton(b, QDialogButtonBox.ButtonRole.ActionRole) l.addWidget(self.bb) def sizeHint(self): diff --git a/src/calibre/gui2/preferences/main.py b/src/calibre/gui2/preferences/main.py index cbeca65d0b..1033810439 100644 --- a/src/calibre/gui2/preferences/main.py +++ b/src/calibre/gui2/preferences/main.py @@ -244,7 +244,7 @@ class Preferences(QDialog): self.bb.button(self.bb.Discard).clicked.connect(self.reject) self.bb.button(self.bb.RestoreDefaults).setIcon(QIcon(I('clear_left.png'))) self.bb.button(self.bb.RestoreDefaults).clicked.connect(self.restore_defaults) - self.wizard_button = self.bb.addButton(_('Run Welcome &wizard'), self.bb.ActionRole) + self.wizard_button = self.bb.addButton(_('Run Welcome &wizard'), QDialogButtonBox.ButtonRole.ActionRole) self.wizard_button.setIcon(QIcon(I('wizard.png'))) self.wizard_button.clicked.connect(self.run_wizard, type=Qt.ConnectionType.QueuedConnection) self.wizard_button.setAutoDefault(False) diff --git a/src/calibre/gui2/preferences/server.py b/src/calibre/gui2/preferences/server.py index e0ed3ac904..c1cb8e981a 100644 --- a/src/calibre/gui2/preferences/server.py +++ b/src/calibre/gui2/preferences/server.py @@ -938,9 +938,9 @@ class CustomList(QWidget): # {{{ l.addRow(t) t.textChanged.connect(self.changed_signal) self.imex = bb = QDialogButtonBox(self) - b = bb.addButton(_('&Import template'), bb.ActionRole) + b = bb.addButton(_('&Import template'), QDialogButtonBox.ButtonRole.ActionRole) b.clicked.connect(self.import_template) - b = bb.addButton(_('E&xport template'), bb.ActionRole) + b = bb.addButton(_('E&xport template'), QDialogButtonBox.ButtonRole.ActionRole) b.clicked.connect(self.export_template) l.addRow(bb) @@ -1346,7 +1346,7 @@ class ConfigWidget(ConfigWidgetBase): bx = QDialogButtonBox(QDialogButtonBox.StandardButton.Ok) layout.addWidget(bx) bx.accepted.connect(d.accept) - b = bx.addButton(_('&Clear logs'), bx.ActionRole) + b = bx.addButton(_('&Clear logs'), QDialogButtonBox.ButtonRole.ActionRole) def clear_logs(): if getattr(self.server, 'is_running', False): diff --git a/src/calibre/gui2/preferences/texture_chooser.py b/src/calibre/gui2/preferences/texture_chooser.py index 32ec471981..405eef2614 100644 --- a/src/calibre/gui2/preferences/texture_chooser.py +++ b/src/calibre/gui2/preferences/texture_chooser.py @@ -60,10 +60,10 @@ class TextureChooser(QDialog): self.bb = bb = QDialogButtonBox(QDialogButtonBox.StandardButton.Ok|QDialogButtonBox.StandardButton.Cancel) bb.accepted.connect(self.accept) bb.rejected.connect(self.reject) - b = self.add_button = bb.addButton(_('Add texture'), bb.ActionRole) + b = self.add_button = bb.addButton(_('Add texture'), QDialogButtonBox.ButtonRole.ActionRole) b.setIcon(QIcon(I('plus.png'))) b.clicked.connect(self.add_texture) - b = self.remove_button = bb.addButton(_('Remove texture'), bb.ActionRole) + b = self.remove_button = bb.addButton(_('Remove texture'), QDialogButtonBox.ButtonRole.ActionRole) b.setIcon(QIcon(I('minus.png'))) b.clicked.connect(self.remove_texture) l.addWidget(bb) diff --git a/src/calibre/gui2/proceed.py b/src/calibre/gui2/proceed.py index e97db93ee5..80116b13ff 100644 --- a/src/calibre/gui2/proceed.py +++ b/src/calibre/gui2/proceed.py @@ -114,17 +114,17 @@ class ProceedQuestion(QWidget): self.bb = QDialogButtonBox() self.bb.accepted.connect(self.accept) self.bb.rejected.connect(self.reject) - self.log_button = self.bb.addButton(_('View log'), self.bb.ActionRole) + self.log_button = self.bb.addButton(_('View log'), QDialogButtonBox.ButtonRole.ActionRole) self.log_button.setIcon(QIcon(I('debug.png'))) self.log_button.clicked.connect(self.show_log) self.copy_button = self.bb.addButton(_('&Copy to clipboard'), - self.bb.ActionRole) + QDialogButtonBox.ButtonRole.ActionRole) self.copy_button.clicked.connect(self.copy_to_clipboard) - self.action_button = self.bb.addButton('', self.bb.ActionRole) + self.action_button = self.bb.addButton('', QDialogButtonBox.ButtonRole.ActionRole) self.action_button.clicked.connect(self.action_clicked) self.show_det_msg = _('Show &details') self.hide_det_msg = _('Hide &details') - self.det_msg_toggle = self.bb.addButton(self.show_det_msg, self.bb.ActionRole) + self.det_msg_toggle = self.bb.addButton(self.show_det_msg, QDialogButtonBox.ButtonRole.ActionRole) self.det_msg_toggle.clicked.connect(self.toggle_det_msg) self.det_msg_toggle.setToolTip( _('Show detailed information about this error')) diff --git a/src/calibre/gui2/tag_mapper.py b/src/calibre/gui2/tag_mapper.py index f33dc751ed..8a51368f8f 100644 --- a/src/calibre/gui2/tag_mapper.py +++ b/src/calibre/gui2/tag_mapper.py @@ -9,7 +9,7 @@ import textwrap from PyQt5.Qt import ( QWidget, QVBoxLayout, QHBoxLayout, QPushButton, QLabel, QListWidget, QIcon, QDialog, QSize, QComboBox, QLineEdit, QListWidgetItem, QStyledItemDelegate, QAbstractItemView, - QStaticText, Qt, QStyle, QToolButton, QInputDialog, QMenu, pyqtSignal, QPalette, QItemSelectionModel + QStaticText, Qt, QStyle, QToolButton, QInputDialog, QMenu, pyqtSignal, QPalette, QItemSelectionModel, QDialogButtonBox ) from calibre.ebooks.metadata.tag_mapper import map_tags, compile_pat @@ -495,15 +495,15 @@ class RulesDialog(Dialog, SaveLoadMixin): self.edit_widget = w = self.RulesClass(self) l.addWidget(w) l.addWidget(self.bb) - self.save_button = b = self.bb.addButton(_('&Save'), self.bb.ActionRole) + self.save_button = b = self.bb.addButton(_('&Save'), QDialogButtonBox.ButtonRole.ActionRole) b.setToolTip(_('Save this ruleset for later re-use')) b.clicked.connect(self.save_ruleset) - self.load_button = b = self.bb.addButton(_('&Load'), self.bb.ActionRole) + self.load_button = b = self.bb.addButton(_('&Load'), QDialogButtonBox.ButtonRole.ActionRole) b.setToolTip(_('Load a previously saved ruleset')) self.load_menu = QMenu(self) b.setMenu(self.load_menu) self.build_load_menu() - self.test_button = b = self.bb.addButton(_('&Test rules'), self.bb.ActionRole) + self.test_button = b = self.bb.addButton(_('&Test rules'), QDialogButtonBox.ButtonRole.ActionRole) b.clicked.connect(self.test_rules) @property diff --git a/src/calibre/gui2/toc/main.py b/src/calibre/gui2/toc/main.py index ac4fcbb58f..eba2ac313f 100644 --- a/src/calibre/gui2/toc/main.py +++ b/src/calibre/gui2/toc/main.py @@ -59,9 +59,9 @@ class XPathDialog(QDialog): # {{{ self.bb = bb = QDialogButtonBox(QDialogButtonBox.StandardButton.Ok|QDialogButtonBox.StandardButton.Cancel) bb.accepted.connect(self.accept) bb.rejected.connect(self.reject) - self.ssb = b = bb.addButton(_('&Save settings'), bb.ActionRole) + self.ssb = b = bb.addButton(_('&Save settings'), QDialogButtonBox.ButtonRole.ActionRole) b.clicked.connect(self.save_settings) - self.load_button = b = bb.addButton(_('&Load settings'), bb.ActionRole) + self.load_button = b = bb.addButton(_('&Load settings'), QDialogButtonBox.ButtonRole.ActionRole) self.load_menu = QMenu(b) b.setMenu(self.load_menu) self.setup_load_button() @@ -1019,7 +1019,7 @@ class TOCEditor(QDialog): # {{{ l.addWidget(bb) bb.accepted.connect(self.accept) bb.rejected.connect(self.reject) - self.undo_button = b = bb.addButton(_('&Undo'), bb.ActionRole) + self.undo_button = b = bb.addButton(_('&Undo'), QDialogButtonBox.ButtonRole.ActionRole) b.setToolTip(_('Undo the last action, if any')) b.setIcon(QIcon(I('edit-undo.png'))) b.clicked.connect(self.toc_view.undo) diff --git a/src/calibre/gui2/tts/develop.py b/src/calibre/gui2/tts/develop.py index e90365e02a..1541098817 100644 --- a/src/calibre/gui2/tts/develop.py +++ b/src/calibre/gui2/tts/develop.py @@ -88,13 +88,13 @@ example, which of. l.addWidget(la) self.bb = bb = QDialogButtonBox(self) l.addWidget(bb) - self.play_button = b = bb.addButton('Play', bb.ActionRole) + self.play_button = b = bb.addButton('Play', QDialogButtonBox.ButtonRole.ActionRole) b.clicked.connect(self.play_clicked) - self.pause_button = b = bb.addButton('Pause', bb.ActionRole) + self.pause_button = b = bb.addButton('Pause', QDialogButtonBox.ButtonRole.ActionRole) b.clicked.connect(self.pause_clicked) - self.resume_button = b = bb.addButton('Resume', bb.ActionRole) + self.resume_button = b = bb.addButton('Resume', QDialogButtonBox.ButtonRole.ActionRole) b.clicked.connect(self.resume_clicked) - self.stop_button = b = bb.addButton('Stop', bb.ActionRole) + self.stop_button = b = bb.addButton('Stop', QDialogButtonBox.ButtonRole.ActionRole) b.clicked.connect(self.stop_clicked) self.render_text() diff --git a/src/calibre/gui2/tweak_book/boss.py b/src/calibre/gui2/tweak_book/boss.py index c40bf9b625..bcaa72dbba 100644 --- a/src/calibre/gui2/tweak_book/boss.py +++ b/src/calibre/gui2/tweak_book/boss.py @@ -835,7 +835,7 @@ class Boss(QObject): k.addWidget(bb) bb.accepted.connect(d.accept) bb.rejected.connect(d.reject) - d.b = b = bb.addButton(_('See what &changed'), bb.AcceptRole) + d.b = b = bb.addButton(_('See what &changed'), QDialogButtonBox.ButtonRole.AcceptRole) b.setIcon(QIcon(I('diff.png'))), b.setAutoDefault(False) bb.button(bb.Close).setDefault(True) if d.exec_() == QDialog.DialogCode.Accepted: diff --git a/src/calibre/gui2/tweak_book/char_select.py b/src/calibre/gui2/tweak_book/char_select.py index 813f65e8b0..2acef50575 100644 --- a/src/calibre/gui2/tweak_book/char_select.py +++ b/src/calibre/gui2/tweak_book/char_select.py @@ -13,7 +13,7 @@ from PyQt5.Qt import ( QAbstractItemModel, QAbstractListModel, QApplication, QCheckBox, QGridLayout, QHBoxLayout, QIcon, QInputMethodEvent, QLabel, QListView, QMenu, QMimeData, QModelIndex, QPen, QPushButton, QSize, QSizePolicy, QSplitter, - QStyledItemDelegate, Qt, QToolButton, QTreeView, pyqtSignal, QAbstractItemView + QStyledItemDelegate, Qt, QToolButton, QTreeView, pyqtSignal, QAbstractItemView, QDialogButtonBox ) from calibre.gui2.tweak_book import tprefs @@ -704,7 +704,7 @@ class CharSelect(Dialog): self.setLayout(l) self.bb.setStandardButtons(self.bb.Close) - self.rearrange_button = b = self.bb.addButton(_('Re-arrange favorites'), self.bb.ActionRole) + self.rearrange_button = b = self.bb.addButton(_('Re-arrange favorites'), QDialogButtonBox.ButtonRole.ActionRole) b.setCheckable(True) b.setChecked(False) b.setVisible(False) diff --git a/src/calibre/gui2/tweak_book/check_links.py b/src/calibre/gui2/tweak_book/check_links.py index 0fad39d3be..b707ce10e5 100644 --- a/src/calibre/gui2/tweak_book/check_links.py +++ b/src/calibre/gui2/tweak_book/check_links.py @@ -8,7 +8,7 @@ from threading import Thread from PyQt5.Qt import ( QCheckBox, QHBoxLayout, QIcon, QInputDialog, QLabel, QProgressBar, QSizePolicy, - QStackedWidget, Qt, QTextBrowser, QVBoxLayout, QWidget, pyqtSignal + QStackedWidget, Qt, QTextBrowser, QVBoxLayout, QWidget, pyqtSignal, QDialogButtonBox ) from calibre.gui2 import error_dialog @@ -84,7 +84,7 @@ class CheckExternalLinks(Dialog): h.addWidget(ca), h.addStretch(100), h.addWidget(self.bb) l.addLayout(h) self.bb.setStandardButtons(self.bb.Close) - self.rb = b = self.bb.addButton(_('&Refresh'), self.bb.ActionRole) + self.rb = b = self.bb.addButton(_('&Refresh'), QDialogButtonBox.ButtonRole.ActionRole) b.setIcon(QIcon(I('view-refresh.png'))) b.clicked.connect(self.refresh) diff --git a/src/calibre/gui2/tweak_book/diff/main.py b/src/calibre/gui2/tweak_book/diff/main.py index 28cbeb7dbc..26f8cf082e 100644 --- a/src/calibre/gui2/tweak_book/diff/main.py +++ b/src/calibre/gui2/tweak_book/diff/main.py @@ -11,7 +11,7 @@ from functools import partial from PyQt5.Qt import ( QGridLayout, QToolButton, QIcon, QRadioButton, QMenu, QApplication, Qt, QSize, QWidget, QLabel, QStackedLayout, QPainter, QRect, QVBoxLayout, - QCursor, QEventLoop, QKeySequence, pyqtSignal, QTimer, QHBoxLayout) + QCursor, QEventLoop, QKeySequence, pyqtSignal, QTimer, QHBoxLayout, QDialogButtonBox) from calibre.ebooks.oeb.polish.container import Container from calibre.ebooks.oeb.polish.utils import guess_type @@ -299,7 +299,7 @@ class Diff(Dialog): self.bb.setStandardButtons(self.bb.Close) if self.revert_button_msg is not None: - self.rvb = b = self.bb.addButton(self.revert_button_msg, self.bb.ActionRole) + self.rvb = b = self.bb.addButton(self.revert_button_msg, QDialogButtonBox.ButtonRole.ActionRole) b.setIcon(QIcon(I('edit-undo.png'))), b.setAutoDefault(False) b.clicked.connect(self.revert_requested) b.clicked.connect(self.reject) diff --git a/src/calibre/gui2/tweak_book/download.py b/src/calibre/gui2/tweak_book/download.py index e93d082695..85fad49faa 100644 --- a/src/calibre/gui2/tweak_book/download.py +++ b/src/calibre/gui2/tweak_book/download.py @@ -123,7 +123,7 @@ class DownloadResources(Dialog): self.wait.addWidget(ds), self.wait.addWidget(s) self.wait.start() for t, f in ((_('Select &none'), cr.select_none), (_('Select &all'), cr.select_all)): - b = self.bb.addButton(t, self.bb.ActionRole) + b = self.bb.addButton(t, QDialogButtonBox.ButtonRole.ActionRole) b.clicked.connect(f), b.setAutoDefault(False) self.bb.setVisible(False) l.addWidget(self.wait), l.addWidget(self.bb) diff --git a/src/calibre/gui2/tweak_book/editor/insert_resource.py b/src/calibre/gui2/tweak_book/editor/insert_resource.py index d60713f7f5..06b1506c30 100644 --- a/src/calibre/gui2/tweak_book/editor/insert_resource.py +++ b/src/calibre/gui2/tweak_book/editor/insert_resource.py @@ -246,17 +246,17 @@ class InsertImage(Dialog): if self.for_browsing: self.bb.clear() self.bb.addButton(self.bb.Close) - b = self.refresh_button = self.bb.addButton(_('&Refresh'), self.bb.ActionRole) + b = self.refresh_button = self.bb.addButton(_('&Refresh'), QDialogButtonBox.ButtonRole.ActionRole) b.clicked.connect(self.refresh) b.setIcon(QIcon(I('view-refresh.png'))) b.setToolTip(_('Refresh the displayed images')) self.setAttribute(Qt.WidgetAttribute.WA_DeleteOnClose, False) else: - b = self.import_button = self.bb.addButton(_('&Import image'), self.bb.ActionRole) + b = self.import_button = self.bb.addButton(_('&Import image'), QDialogButtonBox.ButtonRole.ActionRole) b.clicked.connect(self.import_image) b.setIcon(QIcon(I('view-image.png'))) b.setToolTip(_('Import an image from elsewhere in your computer')) - b = self.paste_button = self.bb.addButton(_('&Paste image'), self.bb.ActionRole) + b = self.paste_button = self.bb.addButton(_('&Paste image'), QDialogButtonBox.ButtonRole.ActionRole) b.clicked.connect(self.paste_image) b.setIcon(QIcon(I('edit-paste.png'))) b.setToolTip(_('Paste an image from the clipboard')) @@ -272,10 +272,10 @@ class InsertImage(Dialog): h = QHBoxLayout() l.addLayout(h, 3, 0, 1, -1) h.addWidget(f), h.addStretch(10), h.addWidget(a) - b = self.bb.addButton(_('&Zoom in'), self.bb.ActionRole) + b = self.bb.addButton(_('&Zoom in'), QDialogButtonBox.ButtonRole.ActionRole) b.clicked.connect(self.zoom_in) b.setIcon(QIcon(I('plus.png'))) - b = self.bb.addButton(_('Zoom &out'), self.bb.ActionRole) + b = self.bb.addButton(_('Zoom &out'), QDialogButtonBox.ButtonRole.ActionRole) b.clicked.connect(self.zoom_out) b.setIcon(QIcon(I('minus.png'))) l.addWidget(self.bb, 4, 0, 1, 2) @@ -466,9 +466,9 @@ class NewBook(Dialog): # {{{ l.addRow(bb) bb.clear() bb.addButton(QDialogButtonBox.StandardButton.Cancel) - b = bb.addButton('&EPUB', bb.AcceptRole) + b = bb.addButton('&EPUB', QDialogButtonBox.ButtonRole.AcceptRole) connect_lambda(b.clicked, self, lambda self: self.set_fmt('epub')) - b = bb.addButton('&AZW3', bb.AcceptRole) + b = bb.addButton('&AZW3', QDialogButtonBox.ButtonRole.AcceptRole) connect_lambda(b.clicked, self, lambda self: self.set_fmt('azw3')) def set_fmt(self, fmt): diff --git a/src/calibre/gui2/tweak_book/file_list.py b/src/calibre/gui2/tweak_book/file_list.py index 473b9d511f..3bde86dea8 100644 --- a/src/calibre/gui2/tweak_book/file_list.py +++ b/src/calibre/gui2/tweak_book/file_list.py @@ -974,7 +974,7 @@ class NewFileDialog(QDialog): # {{{ l.addWidget(bb) bb.accepted.connect(self.accept) bb.rejected.connect(self.reject) - self.imp_button = b = bb.addButton(_('Import resource file (image/font/etc.)'), bb.ActionRole) + self.imp_button = b = bb.addButton(_('Import resource file (image/font/etc.)'), QDialogButtonBox.ButtonRole.ActionRole) b.setIcon(QIcon(I('view-image.png'))) b.setToolTip(_('Import a file from your computer as a new' ' file into the book.')) diff --git a/src/calibre/gui2/tweak_book/function_replace.py b/src/calibre/gui2/tweak_book/function_replace.py index a3b07cf9c1..7a4bd63c7d 100644 --- a/src/calibre/gui2/tweak_book/function_replace.py +++ b/src/calibre/gui2/tweak_book/function_replace.py @@ -9,7 +9,7 @@ import re, io, weakref, sys from PyQt5.Qt import ( pyqtSignal, QVBoxLayout, QHBoxLayout, QPlainTextEdit, QLabel, QFontMetrics, - QSize, Qt, QApplication, QIcon) + QSize, Qt, QApplication, QIcon, QDialogButtonBox) from calibre.ebooks.oeb.polish.utils import apply_func_to_match_groups, apply_func_to_html_text from calibre.gui2 import error_dialog @@ -117,7 +117,7 @@ class DebugOutput(Dialog): l.addWidget(t) l.addWidget(self.bb) self.bb.setStandardButtons(self.bb.Close) - self.cb = b = self.bb.addButton(_('&Copy to clipboard'), self.bb.ActionRole) + self.cb = b = self.bb.addButton(_('&Copy to clipboard'), QDialogButtonBox.ButtonRole.ActionRole) b.clicked.connect(self.copy_to_clipboard) b.setIcon(QIcon(I('edit-copy.png'))) diff --git a/src/calibre/gui2/tweak_book/manage_fonts.py b/src/calibre/gui2/tweak_book/manage_fonts.py index d3ece09270..c020a6d616 100644 --- a/src/calibre/gui2/tweak_book/manage_fonts.py +++ b/src/calibre/gui2/tweak_book/manage_fonts.py @@ -11,7 +11,7 @@ from io import BytesIO from PyQt5.Qt import ( QSplitter, QVBoxLayout, QTableView, QWidget, QLabel, QAbstractTableModel, Qt, QTimer, QPushButton, pyqtSignal, QFormLayout, QLineEdit, QIcon, QSize, - QHBoxLayout, QTextEdit, QApplication, QMessageBox, QAbstractItemView, QDialog) + QHBoxLayout, QTextEdit, QApplication, QMessageBox, QAbstractItemView, QDialog, QDialogButtonBox) from calibre.ebooks.oeb.polish.container import get_container from calibre.ebooks.oeb.polish.fonts import font_family_data, change_font @@ -277,7 +277,7 @@ class ManageFonts(Dialog): b.setIcon(QIcon(I('subset-fonts.png'))) b.clicked.connect(self.subset_fonts) l.addWidget(b) - self.refresh_button = b = self.bb.addButton(_('&Refresh'), self.bb.ActionRole) + self.refresh_button = b = self.bb.addButton(_('&Refresh'), QDialogButtonBox.ButtonRole.ActionRole) b.setToolTip(_('Rescan the book for fonts in case you have made changes')) b.setIcon(QIcon(I('view-refresh.png'))) b.clicked.connect(self.refresh) diff --git a/src/calibre/gui2/tweak_book/polish.py b/src/calibre/gui2/tweak_book/polish.py index 43f73de3a8..79b45adcad 100644 --- a/src/calibre/gui2/tweak_book/polish.py +++ b/src/calibre/gui2/tweak_book/polish.py @@ -112,10 +112,10 @@ def show_report(changed, title, report, parent, show_current_diff): d.bb = QDialogButtonBox(QDialogButtonBox.StandardButton.Close) d.show_changes = False if changed: - b = d.b = d.bb.addButton(_('See what &changed'), d.bb.AcceptRole) + b = d.b = d.bb.addButton(_('See what &changed'), QDialogButtonBox.ButtonRole.AcceptRole) b.setIcon(QIcon(I('diff.png'))), b.setAutoDefault(False) connect_lambda(b.clicked, d, lambda d: setattr(d, 'show_changes', True)) - b = d.bb.addButton(_('&Copy to clipboard'), d.bb.ActionRole) + b = d.bb.addButton(_('&Copy to clipboard'), QDialogButtonBox.ButtonRole.ActionRole) b.setIcon(QIcon(I('edit-copy.png'))), b.setAutoDefault(False) def copy_report(): diff --git a/src/calibre/gui2/tweak_book/preferences.py b/src/calibre/gui2/tweak_book/preferences.py index 672d3a015d..8cb8fad225 100644 --- a/src/calibre/gui2/tweak_book/preferences.py +++ b/src/calibre/gui2/tweak_book/preferences.py @@ -744,13 +744,13 @@ class Preferences(QDialog): self.bb = bb = QDialogButtonBox(QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel) bb.accepted.connect(self.accept) bb.rejected.connect(self.reject) - self.rdb = b = bb.addButton(_('Restore all &defaults'), bb.ResetRole) + self.rdb = b = bb.addButton(_('Restore all &defaults'), QDialogButtonBox.ButtonRole.ResetRole) b.setToolTip(_('Restore defaults for all preferences')) b.clicked.connect(self.restore_all_defaults) - self.rcdb = b = bb.addButton(_('Restore ¤t defaults'), bb.ResetRole) + self.rcdb = b = bb.addButton(_('Restore ¤t defaults'), QDialogButtonBox.ButtonRole.ResetRole) b.setToolTip(_('Restore defaults for currently displayed preferences')) b.clicked.connect(self.restore_current_defaults) - self.rconfs = b = bb.addButton(_('Restore c&onfirmations'), bb.ResetRole) + self.rconfs = b = bb.addButton(_('Restore c&onfirmations'), QDialogButtonBox.ButtonRole.ResetRole) b.setToolTip(_('Restore all disabled confirmation prompts')) b.clicked.connect(self.restore_confirmations) diff --git a/src/calibre/gui2/tweak_book/reports.py b/src/calibre/gui2/tweak_book/reports.py index ce2e60084e..972a995732 100644 --- a/src/calibre/gui2/tweak_book/reports.py +++ b/src/calibre/gui2/tweak_book/reports.py @@ -20,7 +20,7 @@ from PyQt5.Qt import ( QListWidgetItem, QLineEdit, QStackedWidget, QSplitter, QByteArray, QPixmap, QStyledItemDelegate, QModelIndex, QRect, QStyle, QPalette, QTimer, QMenu, QAbstractItemModel, QTreeView, QFont, QRadioButton, QHBoxLayout, - QFontDatabase, QComboBox, QUrl, QAbstractItemView) + QFontDatabase, QComboBox, QUrl, QAbstractItemView, QDialogButtonBox) from calibre import human_readable, fit_image from calibre.constants import DEBUG @@ -1396,10 +1396,10 @@ class Reports(Dialog): l.addWidget(la, alignment=Qt.AlignmentFlag.AlignHCenter), l.addStretch(1) self.bb.setStandardButtons(self.bb.Close) - self.refresh_button = b = self.bb.addButton(_('&Refresh'), self.bb.ActionRole) + self.refresh_button = b = self.bb.addButton(_('&Refresh'), QDialogButtonBox.ButtonRole.ActionRole) b.clicked.connect(self.refresh) b.setIcon(QIcon(I('view-refresh.png'))) - self.save_button = b = self.bb.addButton(_('&Save'), self.bb.ActionRole) + self.save_button = b = self.bb.addButton(_('&Save'), QDialogButtonBox.ButtonRole.ActionRole) b.clicked.connect(self.reports.to_csv) b.setIcon(QIcon(I('save.png'))) b.setToolTip(_('Export the currently shown report as a CSV file')) diff --git a/src/calibre/gui2/tweak_book/search.py b/src/calibre/gui2/tweak_book/search.py index c0d4b3af3b..36066de248 100644 --- a/src/calibre/gui2/tweak_book/search.py +++ b/src/calibre/gui2/tweak_book/search.py @@ -14,7 +14,7 @@ from PyQt5.Qt import ( QGridLayout, QHBoxLayout, QIcon, QItemSelection, QKeySequence, QLabel, QLineEdit, QListView, QMenu, QMimeData, QModelIndex, QPushButton, QScrollArea, QSize, QSizePolicy, QStackedLayout, QStyledItemDelegate, Qt, QTimer, QToolBar, QDialog, - QToolButton, QVBoxLayout, QWidget, pyqtSignal, QAbstractItemView, QEvent + QToolButton, QVBoxLayout, QWidget, pyqtSignal, QAbstractItemView, QEvent, QDialogButtonBox ) from calibre import prepare_string_for_xml @@ -1493,7 +1493,7 @@ def run_search( det_msg += _('{0}: {1} occurrences').format(k, count_map[k]) + '\n' if show_diff and count > 0: d = MessageBox(MessageBox.INFO, _('Searching done'), '

'+msg, parent=gui_parent, show_copy_button=False, det_msg=det_msg) - d.diffb = b = d.bb.addButton(_('See what &changed'), d.bb.AcceptRole) + d.diffb = b = d.bb.addButton(_('See what &changed'), QDialogButtonBox.ButtonRole.AcceptRole) d.show_changes = False b.setIcon(QIcon(I('diff.png'))), b.clicked.connect(d.accept) connect_lambda(b.clicked, d, lambda d: setattr(d, 'show_changes', True)) diff --git a/src/calibre/gui2/tweak_book/spell.py b/src/calibre/gui2/tweak_book/spell.py index 35f183b29f..a1150038a7 100644 --- a/src/calibre/gui2/tweak_book/spell.py +++ b/src/calibre/gui2/tweak_book/spell.py @@ -187,7 +187,7 @@ class ManageUserDictionaries(Dialog): l.addLayout(h) l.addWidget(self.bb) self.bb.clear(), self.bb.addButton(self.bb.Close) - b = self.bb.addButton(_('&New dictionary'), self.bb.ActionRole) + b = self.bb.addButton(_('&New dictionary'), QDialogButtonBox.ButtonRole.ActionRole) b.setIcon(QIcon(I('spell-check.png'))) b.clicked.connect(self.new_dictionary) @@ -454,12 +454,12 @@ class ManageDictionaries(Dialog): # {{{ self.bb.clear() self.bb.addButton(self.bb.Close) - b = self.bb.addButton(_('Manage &user dictionaries'), self.bb.ActionRole) + b = self.bb.addButton(_('Manage &user dictionaries'), QDialogButtonBox.ButtonRole.ActionRole) b.setIcon(QIcon(I('user_profile.png'))) b.setToolTip(_( 'Manage the list of user dictionaries (dictionaries to which you can add words)')) b.clicked.connect(self.manage_user_dictionaries) - b = self.bb.addButton(_('&Add dictionary'), self.bb.ActionRole) + b = self.bb.addButton(_('&Add dictionary'), QDialogButtonBox.ButtonRole.ActionRole) b.setToolTip(_( 'Add a new dictionary that you downloaded from the internet')) b.setIcon(QIcon(I('plus.png'))) @@ -941,11 +941,11 @@ class SpellCheck(Dialog): l.addWidget(self.bb) self.bb.clear() self.bb.addButton(self.bb.Close) - b = self.bb.addButton(_('&Refresh'), self.bb.ActionRole) + b = self.bb.addButton(_('&Refresh'), QDialogButtonBox.ButtonRole.ActionRole) b.setToolTip('

' + _('Re-scan the book for words, useful if you have edited the book since opening this dialog')) b.setIcon(QIcon(I('view-refresh.png'))) connect_lambda(b.clicked, self, lambda self: self.refresh(change_request=None)) - b = self.bb.addButton(_('&Undo last change'), self.bb.ActionRole) + b = self.bb.addButton(_('&Undo last change'), QDialogButtonBox.ButtonRole.ActionRole) b.setToolTip('

' + _('Undo the last spell check word replacement, if any')) b.setIcon(QIcon(I('edit-undo.png'))) b.clicked.connect(self.undo_last_change) diff --git a/src/calibre/gui2/tweak_book/toc.py b/src/calibre/gui2/tweak_book/toc.py index 4f200d16f5..b5668145b2 100644 --- a/src/calibre/gui2/tweak_book/toc.py +++ b/src/calibre/gui2/tweak_book/toc.py @@ -47,7 +47,7 @@ class TOCEditor(QDialog): l.addWidget(bb) bb.accepted.connect(self.accept) bb.rejected.connect(self.reject) - self.undo_button = b = bb.addButton(_('&Undo'), bb.ActionRole) + self.undo_button = b = bb.addButton(_('&Undo'), QDialogButtonBox.ButtonRole.ActionRole) b.setToolTip(_('Undo the last action, if any')) b.setIcon(QIcon(I('edit-undo.png'))) b.clicked.connect(self.toc_view.undo) diff --git a/src/calibre/gui2/tweak_book/widgets.py b/src/calibre/gui2/tweak_book/widgets.py index 2df294a958..cb5a02c877 100644 --- a/src/calibre/gui2/tweak_book/widgets.py +++ b/src/calibre/gui2/tweak_book/widgets.py @@ -14,7 +14,7 @@ from PyQt5.Qt import ( QPainter, QStaticText, pyqtSignal, QTextOption, QAbstractListModel, QModelIndex, QStyledItemDelegate, QStyle, QCheckBox, QListView, QTextDocument, QSize, QComboBox, QFrame, QCursor, QGroupBox, QSplitter, - QPixmap, QRect, QPlainTextEdit, QMimeData, QDialog, QEvent) + QPixmap, QRect, QPlainTextEdit, QMimeData, QDialog, QEvent, QDialogButtonBox) from calibre import prepare_string_for_xml, human_readable from calibre.constants import iswindows @@ -1142,7 +1142,7 @@ class AddCover(Dialog): l.addLayout(h) l.addWidget(self.bb) - b = self.bb.addButton(_('Import &image'), self.bb.ActionRole) + b = self.bb.addButton(_('Import &image'), QDialogButtonBox.ButtonRole.ActionRole) b.clicked.connect(self.import_image) b.setIcon(QIcon(I('document_open.png'))) self.names.setFocus(Qt.FocusReason.OtherFocusReason) diff --git a/src/calibre/gui2/update.py b/src/calibre/gui2/update.py index ce69ae9fba..c753eae7ba 100644 --- a/src/calibre/gui2/update.py +++ b/src/calibre/gui2/update.py @@ -156,11 +156,11 @@ class UpdateNotification(QDialog): self.cb.setChecked(config.get('new_version_notification')) self.cb.stateChanged.connect(self.show_future) self.bb = QDialogButtonBox(self) - b = self.bb.addButton(_('&Get update'), self.bb.AcceptRole) + b = self.bb.addButton(_('&Get update'), QDialogButtonBox.ButtonRole.AcceptRole) b.setDefault(True) b.setIcon(QIcon(I('arrow-down.png'))) if plugin_updates > 0: - b = self.bb.addButton(_('Update &plugins'), self.bb.ActionRole) + b = self.bb.addButton(_('Update &plugins'), QDialogButtonBox.ButtonRole.ActionRole) b.setIcon(QIcon(I('plugins/plugin_updater.png'))) b.clicked.connect(self.get_plugins, type=Qt.ConnectionType.QueuedConnection) self.bb.addButton(QDialogButtonBox.StandardButton.Cancel) diff --git a/src/calibre/gui2/viewer/lookup.py b/src/calibre/gui2/viewer/lookup.py index a6b69993fc..27a0b311fc 100644 --- a/src/calibre/gui2/viewer/lookup.py +++ b/src/calibre/gui2/viewer/lookup.py @@ -133,13 +133,13 @@ class SourcesEditor(Dialog): l.addWidget(self.bb) self.build_entries(vprefs['lookup_locations']) - self.add_button = b = self.bb.addButton(_('Add'), self.bb.ActionRole) + self.add_button = b = self.bb.addButton(_('Add'), QDialogButtonBox.ButtonRole.ActionRole) b.setIcon(QIcon(I('plus.png'))) b.clicked.connect(self.add_source) - self.remove_button = b = self.bb.addButton(_('Remove'), self.bb.ActionRole) + self.remove_button = b = self.bb.addButton(_('Remove'), QDialogButtonBox.ButtonRole.ActionRole) b.setIcon(QIcon(I('minus.png'))) b.clicked.connect(self.remove_source) - self.restore_defaults_button = b = self.bb.addButton(_('Restore defaults'), self.bb.ActionRole) + self.restore_defaults_button = b = self.bb.addButton(_('Restore defaults'), QDialogButtonBox.ButtonRole.ActionRole) b.clicked.connect(self.restore_defaults) def add_entry(self, entry, prepend=False): diff --git a/src/calibre/gui2/viewer/toolbars.py b/src/calibre/gui2/viewer/toolbars.py index 9ada5436f1..9c98323377 100644 --- a/src/calibre/gui2/viewer/toolbars.py +++ b/src/calibre/gui2/viewer/toolbars.py @@ -9,7 +9,7 @@ from functools import partial from PyQt5.Qt import ( QAction, QGroupBox, QHBoxLayout, QIcon, QKeySequence, QLabel, QListWidget, QListWidgetItem, QMenu, Qt, QToolBar, QToolButton, QVBoxLayout, pyqtSignal, QDialog, - QAbstractItemView + QAbstractItemView, QDialogButtonBox ) from PyQt5.QtWebEngineWidgets import QWebEnginePage @@ -414,7 +414,7 @@ class ConfigureToolBar(Dialog): v.addWidget(self.current_actions) h.addLayout(bv), h.addWidget(rg) l.addWidget(self.bb) - self.rdb = b = self.bb.addButton(_('Restore defaults'), self.bb.ActionRole) + self.rdb = b = self.bb.addButton(_('Restore defaults'), QDialogButtonBox.ButtonRole.ActionRole) b.clicked.connect(self.restore_defaults) def remove_actions(self):