mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
More stupid PyQt enums
This commit is contained in:
parent
b30f58703b
commit
63fbb991e1
@ -361,7 +361,7 @@ class Report(QDialog): # {{{
|
||||
self.setWindowTitle(_('Polishing of %s')%book_title)
|
||||
self.view.setText(markdown('# %s\n\n'%book_title + report,
|
||||
output_format='html4'))
|
||||
self.bb.button(self.bb.Close).setFocus(Qt.FocusReason.OtherFocusReason)
|
||||
self.bb.button(QDialogButtonBox.StandardButton.Close).setFocus(Qt.FocusReason.OtherFocusReason)
|
||||
self.backup_msg.setVisible(bool(fmts))
|
||||
if fmts:
|
||||
m = ngettext('The original file has been saved as %s.',
|
||||
|
@ -7,7 +7,7 @@ __docformat__ = 'restructuredtext en'
|
||||
|
||||
import shutil
|
||||
|
||||
from PyQt5.Qt import QModelIndex, QDialog, QApplication
|
||||
from PyQt5.Qt import QModelIndex, QDialog, QApplication, QDialogButtonBox
|
||||
|
||||
from calibre.gui2.convert.single import Config, GroupModel, gprefs
|
||||
from calibre.gui2.convert.look_and_feel import LookAndFeelWidget
|
||||
@ -55,7 +55,7 @@ class BulkConfig(Config):
|
||||
self.groups.activated[(QModelIndex)].connect(self.show_pane)
|
||||
self.groups.clicked[(QModelIndex)].connect(self.show_pane)
|
||||
self.groups.entered[(QModelIndex)].connect(self.show_group_help)
|
||||
rb = self.buttonBox.button(self.buttonBox.RestoreDefaults)
|
||||
rb = self.buttonBox.button(QDialogButtonBox.StandardButton.RestoreDefaults)
|
||||
rb.setVisible(False)
|
||||
self.groups.setMouseTracking(True)
|
||||
if not has_saved_settings:
|
||||
|
@ -6,7 +6,7 @@ __license__ = 'GPL v3'
|
||||
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
from PyQt5.Qt import QDialog
|
||||
from PyQt5.Qt import QDialog, QDialogButtonBox
|
||||
|
||||
from calibre.gui2.convert.font_key_ui import Ui_Dialog
|
||||
from calibre.utils.localization import localize_user_manual_link
|
||||
@ -48,7 +48,7 @@ class FontKeyChooser(QDialog, Ui_Dialog):
|
||||
self.calculate()
|
||||
|
||||
def button_clicked(self, button):
|
||||
if button is self.buttonBox.button(self.buttonBox.RestoreDefaults):
|
||||
if button is self.buttonBox.button(QDialogButtonBox.StandardButton.RestoreDefaults):
|
||||
self.output_base_font_size.setValue(0.0)
|
||||
self.font_size_key.setText('')
|
||||
self.calculate()
|
||||
|
@ -87,7 +87,7 @@ class Config(QDialog):
|
||||
self.groups.activated[(QModelIndex)].connect(self.show_pane)
|
||||
self.groups.clicked[(QModelIndex)].connect(self.show_pane)
|
||||
self.groups.entered[(QModelIndex)].connect(self.show_group_help)
|
||||
rb = self.buttonBox.button(self.buttonBox.RestoreDefaults)
|
||||
rb = self.buttonBox.button(QDialogButtonBox.StandardButton.RestoreDefaults)
|
||||
rb.setText(_('Restore &defaults'))
|
||||
rb.clicked.connect(self.restore_defaults)
|
||||
self.groups.setMouseTracking(True)
|
||||
|
@ -8,7 +8,7 @@ __docformat__ = 'restructuredtext en'
|
||||
|
||||
import os, sys, importlib, weakref
|
||||
|
||||
from PyQt5.Qt import QDialog, QCoreApplication, QSize, QScrollArea, QApplication
|
||||
from PyQt5.Qt import QDialog, QCoreApplication, QSize, QScrollArea, QApplication, QDialogButtonBox
|
||||
|
||||
from calibre.customize.ui import config
|
||||
from calibre.gui2.dialogs.catalog_ui import Ui_Dialog
|
||||
@ -124,8 +124,8 @@ class Catalog(QDialog, Ui_Dialog):
|
||||
self.add_to_library.setChecked(dynamic.get('catalog_add_to_library', True))
|
||||
|
||||
self.format.currentIndexChanged.connect(self.show_plugin_tab)
|
||||
self.buttonBox.button(self.buttonBox.Apply).clicked.connect(self.apply)
|
||||
self.buttonBox.button(self.buttonBox.Help).clicked.connect(self.help)
|
||||
self.buttonBox.button(QDialogButtonBox.StandardButton.Apply).clicked.connect(self.apply)
|
||||
self.buttonBox.button(QDialogButtonBox.StandardButton.Help).clicked.connect(self.help)
|
||||
self.show_plugin_tab(None)
|
||||
|
||||
geom = dynamic.get('catalog_window_geom', None)
|
||||
@ -165,9 +165,9 @@ class Catalog(QDialog, Ui_Dialog):
|
||||
self.tabs.addTab(s, pw.TITLE)
|
||||
break
|
||||
if hasattr(self.options_widget, 'show_help'):
|
||||
self.buttonBox.button(self.buttonBox.Help).setVisible(True)
|
||||
self.buttonBox.button(QDialogButtonBox.StandardButton.Help).setVisible(True)
|
||||
else:
|
||||
self.buttonBox.button(self.buttonBox.Help).setVisible(False)
|
||||
self.buttonBox.button(QDialogButtonBox.StandardButton.Help).setVisible(False)
|
||||
|
||||
def format_changed(self, idx):
|
||||
cf = unicode_type(self.format.currentText())
|
||||
|
@ -441,7 +441,7 @@ class JobError(QDialog): # {{{
|
||||
|
||||
def showEvent(self, ev):
|
||||
ret = QDialog.showEvent(self, ev)
|
||||
self.bb.button(self.bb.Close).setFocus(Qt.FocusReason.OtherFocusReason)
|
||||
self.bb.button(QDialogButtonBox.StandardButton.Close).setFocus(Qt.FocusReason.OtherFocusReason)
|
||||
return ret
|
||||
|
||||
def show_error(self, title, msg, det_msg='', retry_func=None):
|
||||
|
@ -240,10 +240,10 @@ class Preferences(QDialog):
|
||||
QDialogButtonBox.StandardButton.Close | QDialogButtonBox.StandardButton.Apply |
|
||||
QDialogButtonBox.StandardButton.Discard | QDialogButtonBox.StandardButton.RestoreDefaults
|
||||
)
|
||||
self.bb.button(self.bb.Apply).clicked.connect(self.accept)
|
||||
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.bb.button(QDialogButtonBox.StandardButton.Apply).clicked.connect(self.accept)
|
||||
self.bb.button(QDialogButtonBox.StandardButton.Discard).clicked.connect(self.reject)
|
||||
self.bb.button(QDialogButtonBox.StandardButton.RestoreDefaults).setIcon(QIcon(I('clear_left.png')))
|
||||
self.bb.button(QDialogButtonBox.StandardButton.RestoreDefaults).clicked.connect(self.restore_defaults)
|
||||
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)
|
||||
@ -321,23 +321,23 @@ class Preferences(QDialog):
|
||||
self.title_bar.show_plugin(plugin)
|
||||
self.setWindowIcon(QIcon(plugin.icon))
|
||||
|
||||
self.bb.button(self.bb.Close).setVisible(False)
|
||||
self.bb.button(QDialogButtonBox.StandardButton.Close).setVisible(False)
|
||||
self.wizard_button.setVisible(False)
|
||||
for button in (self.bb.Apply, self.bb.RestoreDefaults, self.bb.Discard):
|
||||
button = self.bb.button(button)
|
||||
button.setVisible(True)
|
||||
|
||||
self.bb.button(self.bb.Apply).setEnabled(False)
|
||||
self.bb.button(self.bb.Apply).setDefault(False), self.bb.button(self.bb.Apply).setDefault(True)
|
||||
self.bb.button(self.bb.RestoreDefaults).setEnabled(self.showing_widget.supports_restoring_to_defaults)
|
||||
self.bb.button(self.bb.RestoreDefaults).setToolTip(
|
||||
self.bb.button(QDialogButtonBox.StandardButton.Apply).setEnabled(False)
|
||||
self.bb.button(QDialogButtonBox.StandardButton.Apply).setDefault(False), self.bb.button(QDialogButtonBox.StandardButton.Apply).setDefault(True)
|
||||
self.bb.button(QDialogButtonBox.StandardButton.RestoreDefaults).setEnabled(self.showing_widget.supports_restoring_to_defaults)
|
||||
self.bb.button(QDialogButtonBox.StandardButton.RestoreDefaults).setToolTip(
|
||||
self.showing_widget.restore_defaults_desc if self.showing_widget.supports_restoring_to_defaults else
|
||||
(_('Restoring to defaults not supported for') + ' ' + plugin.gui_name))
|
||||
self.bb.button(self.bb.RestoreDefaults).setText(_('Restore &defaults'))
|
||||
self.bb.button(QDialogButtonBox.StandardButton.RestoreDefaults).setText(_('Restore &defaults'))
|
||||
self.showing_widget.changed_signal.connect(self.changed_signal)
|
||||
|
||||
def changed_signal(self):
|
||||
b = self.bb.button(self.bb.Apply)
|
||||
b = self.bb.button(QDialogButtonBox.StandardButton.Apply)
|
||||
b.setEnabled(True)
|
||||
|
||||
def hide_plugin(self):
|
||||
@ -357,8 +357,8 @@ class Preferences(QDialog):
|
||||
button = self.bb.button(button)
|
||||
button.setVisible(False)
|
||||
|
||||
self.bb.button(self.bb.Close).setVisible(True)
|
||||
self.bb.button(self.bb.Close).setDefault(False), self.bb.button(self.bb.Close).setDefault(True)
|
||||
self.bb.button(QDialogButtonBox.StandardButton.Close).setVisible(True)
|
||||
self.bb.button(QDialogButtonBox.StandardButton.Close).setDefault(False), self.bb.button(QDialogButtonBox.StandardButton.Close).setDefault(True)
|
||||
self.wizard_button.setVisible(True)
|
||||
|
||||
def restart_now(self):
|
||||
|
@ -837,7 +837,7 @@ class Boss(QObject):
|
||||
bb.rejected.connect(d.reject)
|
||||
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)
|
||||
bb.button(QDialogButtonBox.StandardButton.Close).setDefault(True)
|
||||
if d.exec_() == QDialog.DialogCode.Accepted:
|
||||
self.show_current_diff(allow_revert=allow_revert, to_container=to_container)
|
||||
|
||||
|
@ -303,7 +303,7 @@ class Diff(Dialog):
|
||||
b.setIcon(QIcon(I('edit-undo.png'))), b.setAutoDefault(False)
|
||||
b.clicked.connect(self.revert_requested)
|
||||
b.clicked.connect(self.reject)
|
||||
self.bb.button(self.bb.Close).setDefault(True)
|
||||
self.bb.button(QDialogButtonBox.StandardButton.Close).setDefault(True)
|
||||
self.hl.addWidget(self.bb, r)
|
||||
|
||||
self.view.setFocus(Qt.FocusReason.OtherFocusReason)
|
||||
|
@ -245,7 +245,7 @@ class InsertImage(Dialog):
|
||||
|
||||
if self.for_browsing:
|
||||
self.bb.clear()
|
||||
self.bb.addButton(self.bb.Close)
|
||||
self.bb.addButton(QDialogButtonBox.StandardButton.Close)
|
||||
b = self.refresh_button = self.bb.addButton(_('&Refresh'), QDialogButtonBox.ButtonRole.ActionRole)
|
||||
b.clicked.connect(self.refresh)
|
||||
b.setIcon(QIcon(I('view-refresh.png')))
|
||||
|
@ -11,7 +11,7 @@ from PyQt5.Qt import (
|
||||
QColor, QBrush, QFont, QApplication, QPalette, QComboBox,
|
||||
QPushButton, QIcon, QFormLayout, QLineEdit, QWidget, QScrollArea,
|
||||
QVBoxLayout, Qt, QHBoxLayout, pyqtSignal, QPixmap, QColorDialog, QDialog,
|
||||
QToolButton, QCheckBox, QSize, QLabel, QSplitter, QTextCharFormat)
|
||||
QToolButton, QCheckBox, QSize, QLabel, QSplitter, QTextCharFormat, QDialogButtonBox)
|
||||
|
||||
from calibre.gui2 import error_dialog
|
||||
from calibre.gui2.tweak_book import tprefs
|
||||
@ -603,7 +603,7 @@ class ThemeEditor(Dialog):
|
||||
sp.addWidget(s), sp.addWidget(p)
|
||||
|
||||
self.bb.clear()
|
||||
self.bb.addButton(self.bb.Close)
|
||||
self.bb.addButton(QDialogButtonBox.StandardButton.Close)
|
||||
l.addWidget(self.bb)
|
||||
|
||||
if self.theme.count() > 0:
|
||||
|
@ -235,7 +235,7 @@ class ManageFonts(Dialog):
|
||||
self.setLayout(l)
|
||||
|
||||
self.bb.clear()
|
||||
self.bb.addButton(self.bb.Close)
|
||||
self.bb.addButton(QDialogButtonBox.StandardButton.Close)
|
||||
self.splitter = s = QSplitter(self)
|
||||
self.h = h = QHBoxLayout()
|
||||
h.setContentsMargins(0, 0, 0, 0)
|
||||
|
@ -125,7 +125,7 @@ def show_report(changed, title, report, parent, show_current_diff):
|
||||
cp.setText(text)
|
||||
|
||||
b.clicked.connect(copy_report)
|
||||
d.bb.button(d.bb.Close).setDefault(True)
|
||||
d.bb.button(QDialogButtonBox.StandardButton.Close).setDefault(True)
|
||||
d.l.addWidget(d.bb)
|
||||
d.bb.rejected.connect(d.reject)
|
||||
d.bb.accepted.connect(d.accept)
|
||||
|
@ -680,8 +680,8 @@ class TemplatesDialog(Dialog): # {{{
|
||||
self.show_template()
|
||||
|
||||
self.bb.clear()
|
||||
self.bb.addButton(self.bb.Close)
|
||||
self.rd = b = self.bb.addButton(self.bb.RestoreDefaults)
|
||||
self.bb.addButton(QDialogButtonBox.StandardButton.Close)
|
||||
self.rd = b = self.bb.addButton(QDialogButtonBox.StandardButton.RestoreDefaults)
|
||||
b.clicked.connect(self.restore_defaults)
|
||||
l.addWidget(self.bb)
|
||||
|
||||
|
@ -186,7 +186,7 @@ class ManageUserDictionaries(Dialog):
|
||||
self.h = h = QHBoxLayout()
|
||||
l.addLayout(h)
|
||||
l.addWidget(self.bb)
|
||||
self.bb.clear(), self.bb.addButton(self.bb.Close)
|
||||
self.bb.clear(), self.bb.addButton(QDialogButtonBox.StandardButton.Close)
|
||||
b = self.bb.addButton(_('&New dictionary'), QDialogButtonBox.ButtonRole.ActionRole)
|
||||
b.setIcon(QIcon(I('spell-check.png')))
|
||||
b.clicked.connect(self.new_dictionary)
|
||||
@ -453,7 +453,7 @@ class ManageDictionaries(Dialog): # {{{
|
||||
l.addLayout(s, 0, 1)
|
||||
|
||||
self.bb.clear()
|
||||
self.bb.addButton(self.bb.Close)
|
||||
self.bb.addButton(QDialogButtonBox.StandardButton.Close)
|
||||
b = self.bb.addButton(_('Manage &user dictionaries'), QDialogButtonBox.ButtonRole.ActionRole)
|
||||
b.setIcon(QIcon(I('user_profile.png')))
|
||||
b.setToolTip(_(
|
||||
@ -940,7 +940,7 @@ class SpellCheck(Dialog):
|
||||
l.addLayout(s)
|
||||
l.addWidget(self.bb)
|
||||
self.bb.clear()
|
||||
self.bb.addButton(self.bb.Close)
|
||||
self.bb.addButton(QDialogButtonBox.StandardButton.Close)
|
||||
b = self.bb.addButton(_('&Refresh'), QDialogButtonBox.ButtonRole.ActionRole)
|
||||
b.setToolTip('<p>' + _('Re-scan the book for words, useful if you have edited the book since opening this dialog'))
|
||||
b.setIcon(QIcon(I('view-refresh.png')))
|
||||
|
@ -872,7 +872,7 @@ class InsertSemantics(Dialog):
|
||||
fnl.addWidget(la), fnl.addWidget(f), fnl.addWidget(fn)
|
||||
h.addLayout(fnl), h.setStretch(1, 1)
|
||||
|
||||
self.bb.addButton(self.bb.Help)
|
||||
self.bb.addButton(QDialogButtonBox.StandardButton.Help)
|
||||
self.bb.helpRequested.connect(self.help_requested)
|
||||
l.addWidget(self.bb)
|
||||
self.semantic_type_changed()
|
||||
|
Loading…
x
Reference in New Issue
Block a user