more meaningless pyqt busywork

PyQt6 makes exec_() no longer available as an alias for exec(). Just to
waste my time, I suppose.
This commit is contained in:
Kovid Goyal 2021-11-19 20:56:09 +05:30
parent 2ba2439e6f
commit 7d85958b57
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
231 changed files with 512 additions and 508 deletions

View File

@ -18,4 +18,4 @@ def main(url):
w.setUrl(QUrl(url))
w.show()
w.raise_()
app.exec_()
app.exec()

View File

@ -177,7 +177,7 @@ class Plugin: # {{{
v.addWidget(config_widget)
v.addWidget(button_box)
size_dialog()
config_dialog.exec_()
config_dialog.exec()
if config_dialog.result() == QDialog.DialogCode.Accepted:
if hasattr(config_widget, 'validate'):
@ -202,7 +202,7 @@ class Plugin: # {{{
v.addWidget(sc)
v.addWidget(button_box)
size_dialog()
config_dialog.exec_()
config_dialog.exec()
if config_dialog.result() == QDialog.DialogCode.Accepted:
sc = str(sc.text()).strip()

View File

@ -586,7 +586,7 @@ class MetadataGroupBox(DeviceOptionsGroupBox):
def edit_template(self):
t = TemplateDialog(self, self.template)
t.setWindowTitle(_('Edit template'))
if t.exec_():
if t.exec():
self.t.setText(t.rule[1])
def validate(self):
@ -646,7 +646,7 @@ class TemplateConfig(QWidget): # {{{
def edit_template(self):
t = TemplateDialog(self, self.template)
t.setWindowTitle(_('Edit template'))
if t.exec_():
if t.exec():
self.t.setText(t.rule[1])
def validate(self):
@ -686,6 +686,6 @@ if __name__ == '__main__':
d.l.addWidget(bb)
bb.accepted.connect(d.accept)
bb.rejected.connect(d.reject)
if d.exec_() == QDialog.DialogCode.Accepted:
if d.exec() == QDialog.DialogCode.Accepted:
cw.commit()
dev.shutdown()

View File

@ -755,7 +755,7 @@ def test(scale=0.25):
m.setCentralWidget(sa)
w.resize(w.sizeHint())
m.show()
app.exec_()
app.exec()
if __name__ == '__main__':

View File

@ -110,7 +110,7 @@ every time you add an HTML file to the library.\
v.addWidget(bf)
v.addWidget(button_box)
size_dialog()
config_dialog.exec_()
config_dialog.exec()
if config_dialog.result() == QDialog.DialogCode.Accepted:
sc = str(sc.text()).strip()

View File

@ -35,7 +35,7 @@ def main():
renderer = Renderer()
renderer.setUrl(QUrl.fromLocalFile(sys.argv[-1]))
renderer.loadFinished.connect(renderer.do_print)
QApplication.instance().exec_()
QApplication.instance().exec()
print('Output written to:', OUTPUT)

View File

@ -309,7 +309,7 @@ class RenderManager(QObject):
def run_loop(self):
self.block_signal_handlers()
try:
return QApplication.exec_()
return QApplication.exec()
finally:
self.restore_signal_handlers()
@ -336,7 +336,7 @@ class RenderManager(QObject):
w = self.workers[0]
self.evaljs_result = None
w.runJavaScript(js, self.evaljs_callback)
QApplication.exec_()
QApplication.exec()
return self.evaljs_result
def evaljs_callback(self, result):

View File

@ -104,7 +104,7 @@ def main(path_to_html, tdir, image_format='jpeg'):
os.chdir(tdir)
renderer = Render()
renderer.start_load(path_to_html)
ret = QApplication.instance().exec_()
ret = QApplication.instance().exec()
if ret == 0:
page_images('rendered.pdf', image_format=image_format)
ext = {'jpeg': 'jpg'}.get(image_format, image_format)

View File

@ -382,7 +382,7 @@ def warning_dialog(parent, title, msg, det_msg='', show=False,
)+ ' ' + title, msg, det_msg, parent=parent,
show_copy_button=show_copy_button)
if show:
return d.exec_()
return d.exec()
return d
@ -393,7 +393,7 @@ def error_dialog(parent, title, msg, det_msg='', show=False,
) + ' ' + title, msg, det_msg, parent=parent,
show_copy_button=show_copy_button)
if show:
return d.exec_()
return d.exec()
return d
@ -441,7 +441,7 @@ def question_dialog(parent, title, msg, det_msg='', show_copy_button=False,
tc.setChecked(bool(skip_dialog_skip_precheck))
d.resize_needed.emit()
ret = d.exec_() == QDialog.DialogCode.Accepted
ret = d.exec() == QDialog.DialogCode.Accepted
if add_abort_button and d.aborted:
raise Aborted()
@ -459,7 +459,7 @@ def info_dialog(parent, title, msg, det_msg='', show=False,
show_copy_button=show_copy_button, only_copy_details=only_copy_details)
if show:
return d.exec_()
return d.exec()
return d
@ -474,7 +474,7 @@ def show_restart_warning(msg, parent=None):
d.do_restart = True
b.clicked.connect(rf)
d.set_details('')
d.exec_()
d.exec()
b.clicked.disconnect()
return d.do_restart

View File

@ -207,7 +207,7 @@ class AddAction(InterfaceAction):
from calibre.ebooks.oeb.polish.create import valid_empty_formats
from calibre.gui2.dialogs.choose_format import ChooseFormatDialog
d = ChooseFormatDialog(self.gui, _('Choose format of empty file'), sorted(valid_empty_formats))
if d.exec_() != QDialog.DialogCode.Accepted or not d.format():
if d.exec() != QDialog.DialogCode.Accepted or not d.format():
return
self._add_empty_format(d.format())
@ -321,7 +321,7 @@ class AddAction(InterfaceAction):
title = index.model().db.title(index.row())
dlg = AddEmptyBookDialog(self.gui, self.gui.library_view.model().db,
author, series, dup_title=title)
if dlg.exec_() == QDialog.DialogCode.Accepted:
if dlg.exec() == QDialog.DialogCode.Accepted:
temp_files = []
num = dlg.qty_to_add
series = dlg.selected_series
@ -398,7 +398,7 @@ class AddAction(InterfaceAction):
self.isbn_add_dialog = ProgressDialog(_('Adding'),
_('Creating book records from ISBNs'), max=len(books),
cancelable=False, parent=self.gui)
self.isbn_add_dialog.exec_()
self.isbn_add_dialog.exec()
def do_one_isbn_add(self):
try:
@ -516,7 +516,7 @@ class AddAction(InterfaceAction):
def add_from_isbn(self, *args):
from calibre.gui2.dialogs.add_from_isbn import AddFromISBN
d = AddFromISBN(self.gui)
if d.exec_() == QDialog.DialogCode.Accepted and d.books:
if d.exec() == QDialog.DialogCode.Accepted and d.books:
self.add_isbns(d.books, add_tags=d.set_tags, check_for_existing=d.check_for_existing)
def add_books(self, *args):
@ -612,7 +612,7 @@ class AddAction(InterfaceAction):
rows = view.selectionModel().selectedRows()
if not rows or len(rows) == 0:
d = error_dialog(self.gui, _('Add to library'), _('No book selected'))
d.exec_()
d.exec()
return
paths = [p for p in view.model().paths(rows) if p is not None]
ve = self.gui.device_manager.device.VIRTUAL_BOOK_EXTENSIONS
@ -632,7 +632,7 @@ class AddAction(InterfaceAction):
return
if not paths or len(paths) == 0:
d = error_dialog(self.gui, _('Add to library'), _('No book files found'))
d.exec_()
d.exec()
return
self.gui.device_manager.prepare_addable_books(self.Dispatcher(partial(

View File

@ -42,7 +42,7 @@ class AuthorMapAction(InterfaceAction):
'The changes will be applied to <b>one book in the library</b>',
'The changes will be applied to <b>{} books in the library</b>', len(book_ids))
d.edit_widget.msg_label.setText(d.edit_widget.msg_label.text() + '<p>' + txt.format(len(book_ids)))
if d.exec_() != QDialog.DialogCode.Accepted:
if d.exec() != QDialog.DialogCode.Accepted:
return
with BusyCursor():
rules = d.rules

View File

@ -327,7 +327,7 @@ class ChooseLibraryAction(InterfaceAction):
_('Cannot export/import data while there are running jobs.'), show=True)
from calibre.gui2.dialogs.exim import EximDialog
d = EximDialog(parent=self.gui)
if d.exec_() == QDialog.DialogCode.Accepted:
if d.exec() == QDialog.DialogCode.Accepted:
if d.restart_needed:
self.gui.iactions['Restart'].restart()
@ -629,7 +629,7 @@ class ChooseLibraryAction(InterfaceAction):
if not exists:
d = MovedDialog(self.stats, location, self.gui)
ret = d.exec_()
ret = d.exec()
self.build_menus()
self.gui.iactions['Copy To Library'].build_menus()
if ret == QDialog.DialogCode.Accepted:
@ -673,7 +673,7 @@ class ChooseLibraryAction(InterfaceAction):
location = self.stats.canonicalize_path(db.library_path)
self.pre_choose_dialog_location = location
c = ChooseLibrary(db, self.choose_library_callback, self.gui)
c.exec_()
c.exec()
def choose_library_callback(self, newloc, copy_structure=False, library_renamed=False):
self.gui.library_moved(newloc, copy_structure=copy_structure,

View File

@ -150,7 +150,7 @@ class ConvertAction(InterfaceAction):
if not rows or len(rows) == 0:
d = error_dialog(self.gui, _('Cannot convert'),
_('No books selected'))
d.exec_()
d.exec()
return None
return [self.gui.library_view.model().db.id(r) for r in rows]

View File

@ -84,7 +84,7 @@ def ask_about_cc_mismatch(gui, db, newdb, missing_cols, incompatible_cols): # {
d.bb.accepted.connect(d.accept)
d.bb.rejected.connect(d.reject)
d.resize(d.sizeHint())
if d.exec_() == QDialog.DialogCode.Accepted:
if d.exec() == QDialog.DialogCode.Accepted:
changes_made = False
for k, cb in missing_widgets:
if cb.isChecked():
@ -382,7 +382,7 @@ class CopyToLibraryAction(InterfaceAction):
db = self.gui.library_view.model().db
locations = list(self.stats.locations(db))
d = ChooseLibrary(self.gui, locations)
if d.exec_() == QDialog.DialogCode.Accepted:
if d.exec() == QDialog.DialogCode.Accepted:
path, delete_after = d.args
if not path:
return
@ -447,7 +447,7 @@ class CopyToLibraryAction(InterfaceAction):
duplicate_ids = self.do_copy(ids, db, loc, delete_after, False)
if duplicate_ids:
d = DuplicatesQuestion(self.gui, duplicate_ids, loc)
if d.exec_() == QDialog.DialogCode.Accepted:
if d.exec() == QDialog.DialogCode.Accepted:
ids = d.ids
if ids:
self.do_copy(list(ids), db, loc, delete_after, add_duplicates=True)
@ -467,7 +467,7 @@ class CopyToLibraryAction(InterfaceAction):
self.worker.start()
self.pd.canceled_signal.connect(self.worker.cancel_processing)
self.pd.exec_()
self.pd.exec()
self.pd.canceled_signal.disconnect()
if self.worker.left_after_cancel:

View File

@ -162,7 +162,7 @@ class DeleteAction(InterfaceAction):
c[x] += 1
d = SelectFormats(c, msg, parent=self.gui, exclude=exclude,
single=single)
if d.exec_() != QDialog.DialogCode.Accepted:
if d.exec() != QDialog.DialogCode.Accepted:
return None
return d.selected_formats
@ -170,7 +170,7 @@ class DeleteAction(InterfaceAction):
rows = self.gui.library_view.selectionModel().selectedRows()
if not rows or len(rows) == 0:
d = error_dialog(self.gui, err_title, _('No book selected'))
d.exec_()
d.exec()
return set()
return set(map(self.gui.library_view.model().id, rows))
@ -269,7 +269,7 @@ class DeleteAction(InterfaceAction):
if not self.gui.device_manager.is_device_present:
d = error_dialog(self.gui, _('Cannot delete books'),
_('No device is connected'))
d.exec_()
d.exec()
return
ids = self._get_selected_ids()
if not ids:
@ -287,10 +287,10 @@ class DeleteAction(InterfaceAction):
if not some_to_delete:
d = error_dialog(self.gui, _('No books to delete'),
_('None of the selected books are on the device'))
d.exec_()
d.exec()
return
d = DeleteMatchingFromDeviceDialog(self.gui, to_delete)
if d.exec_():
if d.exec():
paths = {}
ids = {}
for (model, id, path) in d.result:

View File

@ -243,7 +243,7 @@ class ConnectShareAction(InterfaceAction):
_('Stopping server, this could take up to a minute, please wait...'),
show_copy_button=False)
QTimer.singleShot(1000, self.check_exited)
self.stopping_msg.exec_()
self.stopping_msg.exec()
def check_exited(self):
if getattr(self.gui.content_server, 'is_running', False):
@ -264,7 +264,7 @@ class ConnectShareAction(InterfaceAction):
dm.set_option('smartdevice', 'autostart', False)
else:
sd_dialog = SmartdeviceDialog(self.gui)
sd_dialog.exec_()
sd_dialog.exec()
self.set_smartdevice_action_state()
def check_smartdevice_menus(self):

View File

@ -369,7 +369,7 @@ class EditMetadataAction(InterfaceAction):
action_button=(_('&View book'), I('view.png'), self.gui.iactions['View'].view_historical),
db=db
)
if d.exec_() == QDialog.DialogCode.Accepted:
if d.exec() == QDialog.DialogCode.Accepted:
if d.mark_rejected:
failed_ids |= d.rejected_ids
restrict_to_failed = True
@ -416,7 +416,7 @@ class EditMetadataAction(InterfaceAction):
if not rows or len(rows) == 0:
d = error_dialog(self.gui, _('Cannot edit metadata'),
_('No books selected'))
d.exec_()
d.exec()
return
row_list = [r.row() for r in rows]
m = self.gui.library_view.model()
@ -508,7 +508,7 @@ class EditMetadataAction(InterfaceAction):
if not rows or len(rows) == 0:
d = error_dialog(self.gui, _('Cannot edit metadata'),
_('No books selected'))
d.exec_()
d.exec()
return
self.do_edit_bulk_metadata(rows, ids)
@ -776,7 +776,7 @@ class EditMetadataAction(InterfaceAction):
model = view.model()
result = model.get_collections_with_ids()
d = DeviceCategoryEditor(self.gui, tag_to_match=None, data=result, key=sort_key)
d.exec_()
d.exec()
if d.result() == QDialog.DialogCode.Accepted:
to_rename = d.to_rename # dict of new text to old ids
to_delete = d.to_delete # list of ids
@ -965,7 +965,7 @@ class EditMetadataAction(InterfaceAction):
'Cannot read cover as the %s file is missing from this book') % 'PDF', show=True)
from calibre.gui2.metadata.pdf_covers import PDFCovers
d = PDFCovers(pdfpath, parent=self.gui)
ret = d.exec_()
ret = d.exec()
if ret == QDialog.DialogCode.Accepted:
cpath = d.cover_path
if cpath:

View File

@ -110,7 +110,7 @@ class EmbedAction(InterfaceAction):
tc.setVisible(True), tc.setText(_('Show the &failed books in the main book list'))
tc.setChecked(gprefs.get('show-embed-failed-books', False))
d.resize_needed.emit()
d.exec_()
d.exec()
gprefs['show-embed-failed-books'] = tc.isChecked()
if tc.isChecked():
failed_ids = {mi.book_id for mi, fmt, tb in errors}

View File

@ -107,7 +107,7 @@ class MarkBooksAction(InterfaceAction):
rows = self.gui.library_view.selectionModel().selectedRows()
if not rows or len(rows) == 0:
d = error_dialog(self.gui, _('Cannot mark'), _('No books selected'))
d.exec_()
d.exec()
return set()
return set(map(self.gui.library_view.model().id, rows))

View File

@ -33,11 +33,11 @@ class MatchBookAction(InterfaceAction):
rows = view.selectionModel().selectedRows()
if not rows or len(rows) != 1:
d = error_dialog(self.gui, _('Match books'), _('You must select one book'))
d.exec_()
d.exec()
return
id_ = view.model().indices(rows)[0]
MatchBooks(self.gui, view, id_, rows[0]).exec_()
MatchBooks(self.gui, view, id_, rows[0]).exec()
class ShowMatchedBookAction(InterfaceAction):
@ -62,7 +62,7 @@ class ShowMatchedBookAction(InterfaceAction):
rows = view.selectionModel().selectedRows()
if not rows or len(rows) != 1:
d = error_dialog(self.gui, _('Match books'), _('You must select one book'))
d.exec_()
d.exec()
return
device_book_index = view.model().indices(rows)[0]
@ -74,7 +74,7 @@ class ShowMatchedBookAction(InterfaceAction):
if question_dialog(self.gui, _('No matching books'), _(
'No matching books found in the calibre library. Do you want to specify the'
' matching book manually?')):
MatchBooks(self.gui, view, device_book_index, rows[0]).exec_()
MatchBooks(self.gui, view, device_book_index, rows[0]).exec()
return
ids = tuple(sorted(matching_book_ids, reverse=True))
self.gui.library_view.select_rows(ids)

View File

@ -30,6 +30,6 @@ class PluginUpdaterAction(InterfaceAction):
initial_filter = FILTER_ALL
d = PluginUpdaterDialog(self.gui, initial_filter=initial_filter)
d.exec_()
d.exec()
if d.do_restart:
self.gui.quit(restart=True)

View File

@ -251,7 +251,7 @@ class Polish(QDialog): # {{{
self.pd = ProgressDialog(_('Queueing books for polishing'),
max=len(self.queue), parent=self)
QTimer.singleShot(0, self.do_one)
self.pd.exec_()
self.pd.exec()
def do_one(self):
if not self.queue:
@ -458,7 +458,7 @@ class PolishAction(InterfaceAction):
if not rows or len(rows) == 0:
d = error_dialog(self.gui, _('Cannot polish'),
_('No books selected'))
d.exec_()
d.exec()
return None
db = self.gui.library_view.model().db
ans = (db.id(r) for r in rows)
@ -506,7 +506,7 @@ class PolishAction(InterfaceAction):
def do_polish(self, book_id_map):
d = Polish(self.gui.library_view.model().db, book_id_map, parent=self.gui)
if d.exec_() == QDialog.DialogCode.Accepted and d.jobs:
if d.exec() == QDialog.DialogCode.Accepted and d.jobs:
show_reports = bool(d.show_reports.isChecked())
for desc, data, book_id, base, is_orig in reversed(d.jobs):
job = self.gui.job_manager.run_job(
@ -562,4 +562,4 @@ if __name__ == '__main__':
app
from calibre.library import db
d = Polish(db(), {1:{'EPUB'}, 2:{'AZW3'}})
d.exec_()
d.exec()

View File

@ -48,7 +48,7 @@ class PreferencesAction(InterfaceAction):
FILTER_NOT_INSTALLED)
d = PluginUpdaterDialog(self.gui,
initial_filter=FILTER_NOT_INSTALLED)
d.exec_()
d.exec()
if d.do_restart:
self.gui.quit(restart=True)
@ -57,7 +57,7 @@ class PreferencesAction(InterfaceAction):
if self.gui.job_manager.has_jobs():
d = error_dialog(self.gui, _('Cannot configure'),
_('Cannot configure while there are running jobs.'))
d.exec_()
d.exec()
return
if self.gui.must_restart_before_config:
do_restart = show_restart_warning(_('Cannot configure before calibre is restarted.'))
@ -68,7 +68,7 @@ class PreferencesAction(InterfaceAction):
close_after_initial=close_after_initial)
d.run_wizard_requested.connect(self.gui.run_wizard,
type=Qt.ConnectionType.QueuedConnection)
d.exec_()
d.exec()
if d.do_restart:
self.gui.quit(restart=True)

View File

@ -29,7 +29,7 @@ class ShowBookDetailsAction(InterfaceAction):
if self.gui.current_view() is not self.gui.library_view:
error_dialog(self.gui, _('No detailed info available'),
_('No detailed information is available for books '
'on the device.')).exec_()
'on the device.')).exec()
return
index = self.gui.library_view.currentIndex()
if index.isValid():

View File

@ -130,7 +130,7 @@ class ShowQuickviewAction(InterfaceAction):
if self.gui.current_view() is not self.gui.library_view:
error_dialog(self.gui, _('No quickview available'),
_('Quickview is not available for books '
'on the device.')).exec_()
'on the device.')).exec()
return
self.qv_button.set_state_to_hide()
index = self.gui.library_view.currentIndex()

View File

@ -21,4 +21,4 @@ class ShowTemplateFunctionsAction(InterfaceAction):
def show_template_editor(self, *args):
d = Preferences(self.gui, initial_plugin=('Advanced', 'TemplateFunctions'),
close_after_initial=True)
d.exec_()
d.exec()

View File

@ -33,7 +33,7 @@ class ShowTemplateTesterAction(InterfaceAction):
if view is not self.gui.library_view:
return error_dialog(self.gui, _('No template tester available'),
_('Template tester is not available for books '
'on the device.')).exec_()
'on the device.')).exec()
rows = view.selectionModel().selectedRows()
if not rows:
@ -48,6 +48,6 @@ class ShowTemplateTesterAction(InterfaceAction):
t = TemplateDialog(self.gui, self.previous_text,
mi, text_is_placeholder=self.first_time)
t.setWindowTitle(_('Template tester'))
if t.exec_() == QDialog.DialogCode.Accepted:
if t.exec() == QDialog.DialogCode.Accepted:
self.previous_text = t.rule[1]
self.first_time = False

View File

@ -128,7 +128,7 @@ class SortByAction(InterfaceAction):
def choose_multisort(self):
from calibre.gui2.dialogs.multisort import ChooseMultiSort
d = ChooseMultiSort(self.gui.current_db, parent=self.gui, is_device_connected=self.gui.device_connected)
if d.exec_() == QDialog.DialogCode.Accepted:
if d.exec() == QDialog.DialogCode.Accepted:
self.gui.library_view.multisort(d.current_sort_spec)
def sort_requested(self, key, ascending):

View File

@ -57,7 +57,7 @@ class StoreAction(InterfaceAction):
self.show_disclaimer()
from calibre.gui2.store.search.search import SearchDialog
sd = SearchDialog(self.gui, self.gui, query)
sd.exec_()
sd.exec()
def _get_selected_row(self):
rows = self.gui.current_view().selectionModel().selectedRows()
@ -118,7 +118,7 @@ class StoreAction(InterfaceAction):
def choose(self):
from calibre.gui2.store.config.chooser.chooser_dialog import StoreChooserDialog
d = StoreChooserDialog(self.gui)
d.exec_()
d.exec()
self.gui.load_store_plugins()
self.load_menu()

View File

@ -43,7 +43,7 @@ class TagMapAction(InterfaceAction):
'The changes will be applied to <b>one book in the library</b>',
'The changes will be applied to <b>{} books in the library</b>', len(book_ids))
d.edit_widget.msg_label.setText(d.edit_widget.msg_label.text() + '<p>' + txt.format(len(book_ids)))
if d.exec_() != QDialog.DialogCode.Accepted:
if d.exec() != QDialog.DialogCode.Accepted:
return
with BusyCursor():
rules = d.rules

View File

@ -130,7 +130,7 @@ class ToCEditAction(InterfaceAction):
if not rows or len(rows) == 0:
d = error_dialog(self.gui, _('Cannot edit ToC'),
_('No books selected'))
d.exec_()
d.exec()
return None
db = self.gui.current_db
ans = (db.id(r) for r in rows)
@ -140,7 +140,7 @@ class ToCEditAction(InterfaceAction):
for book_id, fmts in iteritems(book_id_map):
if len(fmts) > 1:
d = ChooseFormat(fmts, self.gui)
if d.exec_() != QDialog.DialogCode.Accepted:
if d.exec() != QDialog.DialogCode.Accepted:
return
fmts = d.formats
for fmt in fmts:

View File

@ -127,7 +127,7 @@ class TweakEpubAction(InterfaceAction):
if len(tweakable_fmts) > 1:
if tprefs['choose_tweak_fmt']:
d = Choose(sorted(tweakable_fmts, key=tprefs.defaults['tweak_fmt_order'].index), self.gui)
if d.exec_() != QDialog.DialogCode.Accepted:
if d.exec() != QDialog.DialogCode.Accepted:
return
tweakable_fmts = {d.fmt}
else:

View File

@ -343,5 +343,5 @@ class UnpackBookAction(InterfaceAction):
'\n\nFirst convert the book to one of these formats.'),
show=True)
dlg = UnpackBook(self.gui, book_id, tweakable_fmts, db)
dlg.exec_()
dlg.exec()
dlg.cleanup()

View File

@ -209,7 +209,7 @@ class ViewAction(InterfaceAction):
rows = list(self.gui.library_view.selectionModel().selectedRows())
if not rows or len(rows) == 0:
d = error_dialog(self.gui, _('Cannot view'), _('No book selected'))
d.exec_()
d.exec()
return
db = self.gui.library_view.model().db
@ -228,7 +228,7 @@ class ViewAction(InterfaceAction):
d = ChooseFormatDialog(self.gui, _('Choose the format to view'),
list(sorted(all_fmts)), show_open_with=True)
self.gui.book_converted.connect(d.book_converted)
if d.exec_() == QDialog.DialogCode.Accepted:
if d.exec() == QDialog.DialogCode.Accepted:
formats = [[x.upper() for x in db.new_api.formats(book_id)] for book_id in book_ids]
fmt = d.format()
orig_num = len(rows)
@ -266,7 +266,7 @@ class ViewAction(InterfaceAction):
if not rows or len(rows) == 0:
d = error_dialog(self.gui, _('Cannot open folder'),
_('No book selected'))
d.exec_()
d.exec()
return
if not self._view_check(len(rows), max_=10, skip_dialog_name='open-folder-many-check'):
return

View File

@ -146,7 +146,7 @@ if __name__ == '__main__':
{'action':'ignore', 'query':'ignore-me', 'match_type':'startswith'},
{'action':'add', 'query':'*.moose', 'match_type':'glob'},
]
d.exec_()
d.exec()
from pprint import pprint
pprint(d.rules)
del d, app

View File

@ -131,7 +131,7 @@ if __name__ == '__main__':
d.rules = [
{'action':'replace', 'query':'alice B & alice bob', 'match_type':'one_of', 'replace':'Alice Bob'},
]
d.exec_()
d.exec()
from pprint import pprint
pprint(d.rules)
del d, app

View File

@ -466,7 +466,7 @@ def details_context_menu_event(view, ev, book_info, add_popup_action=False, edit
ema = get_gui().iactions['Edit Metadata'].menuless_qaction
menu.addAction(_('Open the Edit metadata window') + '\t' + ema.shortcut().toString(QKeySequence.SequenceFormat.NativeText), edit_metadata)
if len(menu.actions()) > 0:
menu.exec_(ev.globalPos())
menu.exec(ev.globalPos())
# }}}
@ -613,7 +613,7 @@ class CoverView(QWidget): # {{{
create_open_cover_with_menu(self, cm)
cm.si = m = create_search_internet_menu(self.search_internet.emit)
cm.addMenu(m)
cm.exec_(ev.globalPos())
cm.exec(ev.globalPos())
def open_with(self, entry):
id_ = self.data.get('id', None)

View File

@ -691,7 +691,7 @@ class EditorWidget(QTextEdit, LineEditECM): # {{{
d.bb.rejected.connect(d.reject)
d.resize(d.sizeHint())
link, name, is_image = None, None, False
if d.exec_() == QDialog.DialogCode.Accepted:
if d.exec() == QDialog.DialogCode.Accepted:
link, name = str(d.url.text()).strip(), str(d.name.text()).strip()
is_image = d.treat_as_image.isChecked()
return link, name, is_image
@ -832,7 +832,7 @@ class EditorWidget(QTextEdit, LineEditECM): # {{{
am.addAction(self.action_background)
am.addAction(self.action_color)
menu.addAction(_('Smarten punctuation'), parent.smarten_punctuation)
menu.exec_(ev.globalPos())
menu.exec(ev.globalPos())
# }}}
@ -1228,5 +1228,5 @@ if __name__ == '__main__':
set <u>out</u> to have an <em>affair</em>, <span style="font-style:italic; background-color:red">
much</span> less a <s>long-term</s>, <b>devoted</b> one.</span><p>hello'''
w.html = '<div><p id="moo">Testing <em>a</em> link.</p><p>\xa0</p><p>ss</p></div>'
app.exec_()
app.exec()
# print w.html

View File

@ -535,4 +535,4 @@ if __name__ == '__main__':
'oothree', 'a1', 'a2','Edgas', 'Èdgar', 'Édgaq', 'Edgar', 'Édgar']
le.update_items_cache(items)
le.show_initial_value('')
d.exec_()
d.exec()

View File

@ -104,5 +104,5 @@ if __name__ == '__main__':
from qt.core import QApplication
app = QApplication([])
d = FontKeyChooser()
d.exec_()
d.exec()
del app

View File

@ -115,7 +115,7 @@ class LookAndFeelWidget(Widget, Ui_Form):
from calibre.gui2.convert.font_key import FontKeyChooser
d = FontKeyChooser(self, self.opt_base_font_size.value(),
str(self.opt_font_size_mapping.text()).strip())
if d.exec_() == QDialog.DialogCode.Accepted:
if d.exec() == QDialog.DialogCode.Accepted:
self.opt_font_size_mapping.setText(', '.join(['%.1f'%x for x in
d.fsizes]))
self.opt_base_font_size.setValue(d.dbase)

View File

@ -198,7 +198,7 @@ class MetadataWidget(Widget, Ui_Form):
if not os.access(_file, os.R_OK):
d = error_dialog(self.parent(), _('Cannot read'),
_('You do not have permission to read the file: ') + _file)
d.exec_()
d.exec()
return
cover = None
try:
@ -207,7 +207,7 @@ class MetadataWidget(Widget, Ui_Form):
except OSError as e:
d = error_dialog(self.parent(), _('Error reading file'),
_("<p>There was an error reading from file: <br /><b>") + _file + "</b></p><br />"+str(e))
d.exec_()
d.exec()
if cover:
pix = QPixmap()
pix.loadFromData(cover)
@ -215,7 +215,7 @@ class MetadataWidget(Widget, Ui_Form):
if pix.isNull():
d = error_dialog(self.parent(), _('Error reading file'),
_file + _(" is not a valid picture"))
d.exec_()
d.exec()
else:
self.cover_path.setText(_file)
self.set_cover_tooltip(pix)

View File

@ -151,7 +151,7 @@ class RegexBuilder(QDialog, Ui_RegexBuilder):
format = formats[0]
elif len(formats) > 1:
d = ChooseFormatDialog(self, _('Choose the format to view'), formats)
d.exec_()
d.exec()
if d.result() == QDialog.DialogCode.Accepted:
format = d.format()
else:
@ -236,7 +236,7 @@ class RegexEdit(XPathEdit):
if not self.doc_cache:
self.doc_cache = bld.doc()
self.doc_update.emit(self.doc_cache)
if bld.exec_() == QDialog.DialogCode.Accepted:
if bld.exec() == QDialog.DialogCode.Accepted:
self.edit.setText(bld.regex.text())
def doc(self):
@ -285,6 +285,6 @@ if __name__ == '__main__':
app = Application([])
d = RegexBuilder(None, None, 'a', doc='😉123abc XYZabc')
d.do_test()
d.exec_()
d.exec()
del d
del app

View File

@ -40,6 +40,6 @@ class StructureDetectionWidget(Widget, Ui_Form):
x = getattr(self, 'opt_'+x)
if not x.check():
error_dialog(self, _('Invalid XPath'),
_('The XPath expression %s is invalid.')%x.text).exec_()
_('The XPath expression %s is invalid.')%x.text).exec()
return False
return True

View File

@ -39,6 +39,6 @@ class TOCWidget(Widget, Ui_Form):
x = getattr(self, 'opt_'+x+'_toc')
if not x.check():
error_dialog(self, _('Invalid XPath'),
_('The XPath expression %s is invalid.')%x.text).exec_()
_('The XPath expression %s is invalid.')%x.text).exec()
return False
return True

View File

@ -102,7 +102,7 @@ class XPathEdit(QWidget):
def wizard(self):
wiz = Wizard(self)
if wiz.exec_() == QDialog.DialogCode.Accepted:
if wiz.exec() == QDialog.DialogCode.Accepted:
self.edit.setText(wiz.xpath)
def setObjectName(self, *args):
@ -144,5 +144,5 @@ if __name__ == '__main__':
w = XPathEdit()
w.setObjectName('test')
w.show()
app.exec_()
app.exec()
print(w.xpath)

View File

@ -506,7 +506,7 @@ def test():
w.show()
cf.setFocus(Qt.FocusReason.OtherFocusReason)
sys.exit(app.exec_())
sys.exit(app.exec())
def main(args=sys.argv):
@ -528,4 +528,4 @@ if __name__ == '__main__':
w.show()
cf.setFocus(Qt.FocusReason.OtherFocusReason)
sys.exit(app.exec_())
sys.exit(app.exec())

View File

@ -400,7 +400,7 @@ class CoverSettingsWidget(QWidget):
def create_color_scheme(self):
scheme = self.colors_map[self.current_colors].data(Qt.ItemDataRole.UserRole)
d = CreateColorScheme('#' + _('My Color Scheme'), scheme, set(self.colors_map), parent=self)
if d.exec_() == QDialog.DialogCode.Accepted:
if d.exec() == QDialog.DialogCode.Accepted:
name, scheme = d.data
li = QListWidgetItem(name)
li.setData(Qt.ItemDataRole.UserRole, scheme), li.setFlags(li.flags() | Qt.ItemFlag.ItemIsUserCheckable), li.setCheckState(Qt.CheckState.Checked)
@ -416,7 +416,7 @@ class CoverSettingsWidget(QWidget):
' color scheme instead.'), show=True)
li = self.colors_map[cs]
d = CreateColorScheme(cs, li.data(Qt.ItemDataRole.UserRole), set(self.colors_map), edit_scheme=True, parent=self)
if d.exec_() == QDialog.DialogCode.Accepted:
if d.exec() == QDialog.DialogCode.Accepted:
name, scheme = d.data
li.setText(name)
li.setData(Qt.ItemDataRole.UserRole, scheme)
@ -454,7 +454,7 @@ class CoverSettingsWidget(QWidget):
attr = which + '_template'
templ = getattr(self, attr).text()
d = TemplateDialog(self, templ, mi=self.mi, fm=field_metadata)
if d.exec_() == QDialog.DialogCode.Accepted:
if d.exec() == QDialog.DialogCode.Accepted:
templ = d.rule[1]
getattr(self, attr).setText(templ)
self.emit_changed()
@ -613,6 +613,6 @@ if __name__ == '__main__':
app = Application([])
d = CoverSettingsDialog()
d.show()
app.exec_()
app.exec()
del d
del app

View File

@ -336,7 +336,7 @@ class RulesWidget(QWidget, SaveLoadMixin): # {{{
self.changed.emit()
def test_rules(self):
self.TesterClass(self.rules_widget.rules, self).exec_()
self.TesterClass(self.rules_widget.rules, self).exec()
@property
def rules(self):
@ -360,7 +360,7 @@ if __name__ == '__main__':
d.rules = [
{'property':'color', 'match_type':'*', 'query':'', 'action':'change', 'action_data':'green'},
]
d.exec_()
d.exec()
from pprint import pprint
pprint(d.rules)
del d, app

View File

@ -489,7 +489,7 @@ def _save_dialog(parent, title, msg, det_msg=''):
d.setWindowTitle(title)
d.setText(msg)
d.setStandardButtons(QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No | QMessageBox.StandardButton.Cancel)
return d.exec_()
return d.exec()
class Text(Base):
@ -576,7 +576,7 @@ class Text(Base):
self.initialize(self.book_id)
else:
d = TagEditor(self.parent, self.db, self.book_id, self.key)
if d.exec_() == QDialog.DialogCode.Accepted:
if d.exec() == QDialog.DialogCode.Accepted:
self.setter(d.tags)
def connect_data_changed(self, slot):
@ -1494,7 +1494,7 @@ class BulkText(BulkBase):
return
widget.setText('')
d = TagEditor(self.parent, self.db, key=('#'+self.col_metadata['label']))
if d.exec_() == QDialog.DialogCode.Accepted:
if d.exec() == QDialog.DialogCode.Accepted:
val = d.tags
if not val:
val = []

View File

@ -989,7 +989,7 @@ class DeviceMixin: # {{{
if cw.validate():
QDialog.accept(config_dialog)
config_dialog.accept = validate
if config_dialog.exec_() == QDialog.DialogCode.Accepted:
if config_dialog.exec() == QDialog.DialogCode.Accepted:
dev.save_settings(cw)
do_restart = show_restart_warning(_('Restart calibre for the changes to %s'
@ -1042,7 +1042,7 @@ class DeviceMixin: # {{{
if getattr(job, 'exception', None).__class__.__name__ == 'MTPInvalidSendPathError':
try:
from calibre.gui2.device_drivers.mtp_config import SendError
return SendError(self, job.exception).exec_()
return SendError(self, job.exception).exec()
except:
traceback.print_exc()
try:
@ -1234,7 +1234,7 @@ class DeviceMixin: # {{{
rows = self.library_view.selectionModel().selectedRows()
if not rows or len(rows) == 0:
error_dialog(self, _('No books'), _('No books')+' '+
_('selected to send')).exec_()
_('selected to send')).exec()
return
fmt = None
@ -1264,7 +1264,7 @@ class DeviceMixin: # {{{
elif f in aval_out_formats:
formats.append((f, _('0 of %i books') % len(rows), True))
d = ChooseFormatDeviceDialog(self, _('Choose format to send to device'), formats)
if d.exec_() != QDialog.DialogCode.Accepted:
if d.exec() != QDialog.DialogCode.Accepted:
return
if d.format():
fmt = d.format().lower()
@ -1272,15 +1272,15 @@ class DeviceMixin: # {{{
if dest in ('main', 'carda', 'cardb'):
if not self.device_connected or not self.device_manager:
error_dialog(self, _('No device'),
_('Cannot send: No device is connected')).exec_()
_('Cannot send: No device is connected')).exec()
return
if dest == 'carda' and not self.device_manager.has_card():
error_dialog(self, _('No card'),
_('Cannot send: Device has no storage card')).exec_()
_('Cannot send: Device has no storage card')).exec()
return
if dest == 'cardb' and not self.device_manager.has_card():
error_dialog(self, _('No card'),
_('Cannot send: Device has no storage card')).exec_()
_('Cannot send: Device has no storage card')).exec()
return
if dest == 'main':
on_card = None
@ -1567,7 +1567,7 @@ class DeviceMixin: # {{{
'as no suitable formats were found. Convert the book(s) to a '
'format supported by your device first.'
), bad)
d.exec_()
d.exec()
def upload_dirtied_booklists(self):
'''
@ -1645,7 +1645,7 @@ class DeviceMixin: # {{{
_('<p>Cannot upload books to device there '
'is no more free space available ')+where+
'</p>\n<ul>%s</ul>'%(titles,))
d.exec_()
d.exec()
elif isinstance(job.exception, WrongDestinationError):
error_dialog(self, _('Incorrect destination'),
str(job.exception), show=True)

View File

@ -102,7 +102,7 @@ class TemplateConfig(QWidget): # {{{
def edit_template(self):
t = TemplateDialog(self, self.template)
t.setWindowTitle(_('Edit template'))
if t.exec_():
if t.exec():
self.t.setText(t.rule[1])
def validate(self):
@ -149,7 +149,7 @@ class SendToConfig(QWidget): # {{{
def browse(self):
b = Browser(self.device.filesystem_cache, show_files=False,
parent=self)
if b.exec_() == QDialog.DialogCode.Accepted and b.current_item is not None:
if b.exec() == QDialog.DialogCode.Accepted and b.current_item is not None:
sid, path = b.current_item
self.t.setText('/'.join(path[1:]))
@ -255,7 +255,7 @@ class Rule(QWidget):
def browse(self):
b = Browser(self.device.filesystem_cache, show_files=False,
parent=self)
if b.exec_() == QDialog.DialogCode.Accepted and b.current_item is not None:
if b.exec() == QDialog.DialogCode.Accepted and b.current_item is not None:
sid, path = b.current_item
self.folder.setText('/'.join(path[1:]))
@ -428,12 +428,12 @@ class MTPConfig(QTabWidget):
bb.addButton(_('Copy to clipboard'), QDialogButtonBox.ButtonRole.ActionRole)
bb.clicked.connect(lambda :
QApplication.clipboard().setText(v.toPlainText()))
d.exec_()
d.exec()
def change_ignored_folders(self):
d = IgnoredFolders(self.device,
self.current_ignored_folders, parent=self)
if d.exec_() == QDialog.DialogCode.Accepted:
if d.exec() == QDialog.DialogCode.Accepted:
self.current_ignored_folders = d.ignored_folders
def ignore_device(self):
@ -547,6 +547,6 @@ if __name__ == '__main__':
d.l.addWidget(bb)
bb.accepted.connect(d.accept)
bb.rejected.connect(d.reject)
if d.exec_() == QDialog.DialogCode.Accepted:
if d.exec() == QDialog.DialogCode.Accepted:
cw.commit()
dev.shutdown()

View File

@ -226,7 +226,7 @@ def browse():
app
dev = setup_device()
d = Browser(dev.filesystem_cache)
d.exec_()
d.exec()
dev.shutdown()
return d.current_item
@ -237,7 +237,7 @@ def ignored_folders():
app
dev = setup_device()
d = IgnoredFolders(dev)
d.exec_()
d.exec()
dev.shutdown()
return d.ignored_folders

View File

@ -389,6 +389,6 @@ if __name__ == '__main__':
d.l.addWidget(bb)
bb.accepted.connect(d.accept)
bb.rejected.connect(d.reject)
if d.exec_() == QDialog.DialogCode.Accepted:
if d.exec() == QDialog.DialogCode.Accepted:
cw.commit()
dev.shutdown()

View File

@ -179,4 +179,4 @@ if __name__ == '__main__':
db = db()
app = QApplication([])
d = AddEmptyBookDialog(None, db, 'Test Author')
d.exec_()
d.exec()

View File

@ -199,5 +199,5 @@ class AuthorsEdit(QDialog):
if __name__ == '__main__':
app = QApplication([])
d = AuthorsEdit(['kovid goyal', 'divok layog', 'other author'], ['kovid goyal', 'other author'])
d.exec_()
d.exec()
print(d.authors)

View File

@ -223,7 +223,7 @@ class BookInfo(QDialog):
def configure(self):
d = Configure(get_gui().current_db, self)
if d.exec_() == QDialog.DialogCode.Accepted:
if d.exec() == QDialog.DialogCode.Accepted:
if self.current_row is not None:
mi = self.view.model().get_book_display_info(self.current_row)
if mi is not None:
@ -364,6 +364,6 @@ if __name__ == '__main__':
app.current_db = db()
get_gui.ans = app
d = Configure(app.current_db)
d.exec_()
d.exec()
del d
del app

View File

@ -46,7 +46,7 @@ class DBCheck(QDialog): # {{{
t.daemon = True
t.start()
QTimer.singleShot(100, self.check)
self.exec_()
self.exec()
def vacuum(self):
try:
@ -233,7 +233,7 @@ class CheckLibraryDialog(QDialog):
probs += self.problem_count[c]
if probs == 0:
return False
self.exec_()
self.exec()
return True
def accept(self):
@ -467,4 +467,4 @@ if __name__ == '__main__':
app = QApplication([])
from calibre.library import db
d = CheckLibraryDialog(None, db())
d.exec_()
d.exec()

View File

@ -104,6 +104,6 @@ if __name__ == '__main__':
from calibre.gui2 import Application
app = Application([])
d = ChooseFormatDialog(None, 'Testing choose format', ['epub', 'mobi', 'docx'], show_open_with=True)
d.exec_()
d.exec()
print(d._format)
del app

View File

@ -150,7 +150,7 @@ class ChooseLibrary(QDialog, Ui_Dialog):
t = Thread(name='MoveLibrary', target=do_move)
QTimer.singleShot(0, t.start)
pd.exec_()
pd.exec()
if abort_move.is_set():
self.callback(self.db.library_path)
return

View File

@ -81,6 +81,6 @@ class PlainTextDialog(Dialog):
if __name__ == '__main__':
app = Application([])
d = CommentsDialog(None, 'testing', 'Comments')
d.exec_()
d.exec()
del d
del app

View File

@ -78,7 +78,7 @@ def confirm(msg, name, parent=None, pixmap='dialog_warning.png', title=None,
return True
d = Dialog(msg, name, parent, config_set=config_set, icon=pixmap, extra_button=extra_button,
title=title, confirm_msg=confirm_msg, show_cancel_button=show_cancel_button)
ret = d.exec_() == QDialog.DialogCode.Accepted
ret = d.exec() == QDialog.DialogCode.Accepted
if extra_button:
ret = ret, d.extra_button_clicked
return ret

View File

@ -45,7 +45,7 @@ def confirm_location(msg, name, parent=None, pixmap='dialog_warning.png'):
d.label.setPixmap(QPixmap(I(pixmap)))
d.setWindowIcon(QIcon(I(pixmap)))
d.resize(d.sizeHint())
ret = d.exec_()
ret = d.exec()
d.break_cycles()
if ret == QDialog.DialogCode.Accepted:
return d.choice()

View File

@ -91,7 +91,7 @@ def confirm_merge(msg, name, parent, mi):
if not config_set.get(confirm_config_name(name), True):
return True
d = ConfirmMerge(msg, name, parent, mi)
return d.exec_() == QDialog.DialogCode.Accepted
return d.exec() == QDialog.DialogCode.Accepted
class ChooseMerge(Dialog):
@ -189,6 +189,6 @@ class ChooseMerge(Dialog):
def merge_drop(dest_id, src_ids, gui):
d = ChooseMerge(dest_id, src_ids, gui)
if d.exec_() != QDialog.DialogCode.Accepted:
if d.exec() != QDialog.DialogCode.Accepted:
return None, None, None
return d.merge_type

View File

@ -658,7 +658,7 @@ class CustomRecipes(Dialog):
def customize_recipe(self):
d = ChooseBuiltinRecipe(self.recipe_model, self)
if d.exec_() != QDialog.DialogCode.Accepted:
if d.exec() != QDialog.DialogCode.Accepted:
return
id_ = d.selected_recipe
@ -690,7 +690,7 @@ class CustomRecipes(Dialog):
def import_opml(self):
from calibre.gui2.dialogs.opml import ImportOPML
d = ImportOPML(parent=self)
if d.exec_() != QDialog.DialogCode.Accepted:
if d.exec() != QDialog.DialogCode.Accepted:
return
oldest_article, max_articles_per_feed, replace_existing = d.oldest_article, d.articles_per_feed, d.replace_existing
failed_recipes, replace_recipes, add_recipes = {}, {}, {}
@ -737,5 +737,5 @@ if __name__ == '__main__':
from calibre.gui2 import Application
from calibre.web.feeds.recipes.model import RecipeModel
app = Application([])
CustomRecipes(RecipeModel()).exec_()
CustomRecipes(RecipeModel()).exec()
del app

View File

@ -85,7 +85,7 @@ class DeviceCategoryEditor(QDialog, Ui_DeviceCategoryEditor):
def finish_editing(self, item):
if not item.text():
error_dialog(self, _('Item is blank'),
_('An item cannot be set to nothing. Delete it instead.')).exec_()
_('An item cannot be set to nothing. Delete it instead.')).exec()
item.setText(item.previous_text())
return
if item.text() != item.initial_text():
@ -99,7 +99,7 @@ class DeviceCategoryEditor(QDialog, Ui_DeviceCategoryEditor):
def _rename_tag(self, item):
if item is None:
error_dialog(self, _('No item selected'),
_('You must select one item from the list of available items.')).exec_()
_('You must select one item from the list of available items.')).exec()
return
self.available_tags.editItem(item)
@ -107,7 +107,7 @@ class DeviceCategoryEditor(QDialog, Ui_DeviceCategoryEditor):
deletes = self.available_tags.selectedItems()
if not deletes:
error_dialog(self, _('No items selected'),
_('You must select at least one item from the list.')).exec_()
_('You must select at least one item from the list.')).exec()
return
ct = ', '.join([str(item.text()) for item in deletes])
if not question_dialog(self, _('Are you sure?'),

View File

@ -32,5 +32,5 @@ if __name__ == '__main__':
from calibre.gui2 import Application
app = Application([])
d = DRMErrorMessage(title='testing title')
d.exec_()
d.exec()
del d

View File

@ -63,7 +63,7 @@ class DuplicatesQuestion(QDialog):
geom = gprefs.get('duplicates-question-dialog-geometry', None)
if geom is not None:
QApplication.instance().safe_restore_geometry(self, geom)
self.exec_()
self.exec()
def copy_to_clipboard(self):
QApplication.clipboard().setText(self.as_text)

View File

@ -330,7 +330,7 @@ class EditAuthorsDialog(QDialog, Ui_EditAuthorsDialog):
ca.triggered.connect(self.copy_aus_to_au)
m.addSeparator()
m.addMenu(case_menu)
m.exec_(self.table.mapToGlobal(point))
m.exec(self.table.mapToGlobal(point))
def undo_cell(self, old_value):
self.context_item.setText(old_value)
@ -481,7 +481,7 @@ class EditAuthorsDialog(QDialog, Ui_EditAuthorsDialog):
aut_list = string_to_authors(aut)
if len(aut_list) != 1:
error_dialog(self.parent(), _('Invalid author name'),
_('You cannot change an author to multiple authors.')).exec_()
_('You cannot change an author to multiple authors.')).exec()
aut = ' % '.join(aut_list)
self.table.item(row, 0).setText(aut)
item.set_sort_key()

View File

@ -361,7 +361,7 @@ class EximDialog(Dialog):
dbmap[db.library_path] = db.new_api
return RunAction(_('Exporting all calibre data...'), _(
'Failed to export data.'), partial(export, self.export_dir, library_paths=library_paths, dbmap=dbmap),
parent=self).exec_() == QDialog.DialogCode.Accepted
parent=self).exec() == QDialog.DialogCode.Accepted
def run_import_action(self):
library_path_map = {}
@ -369,7 +369,7 @@ class EximDialog(Dialog):
if w.path:
library_path_map[w.lpath] = w.path
return RunAction(_('Importing all calibre data...'), _(
'Failed to import data.'), partial(import_data, self.importer, library_path_map), parent=self).exec_() == QDialog.DialogCode.Accepted
'Failed to import data.'), partial(import_data, self.importer, library_path_map), parent=self).exec() == QDialog.DialogCode.Accepted
def accept(self):
if not self.validate():
@ -388,5 +388,5 @@ if __name__ == '__main__':
from calibre.gui2 import Application
app = Application([])
d = EximDialog(initial_panel='import')
d.exec_()
d.exec()
del app

View File

@ -129,7 +129,7 @@ class MatchBooks(QDialog, Ui_MatchBooks):
if not query:
d = error_dialog(self.gui, _('Match books'),
_('You must enter a search expression into the search field'))
d.exec_()
d.exec()
return
try:
self.search_button.setEnabled(False)
@ -200,7 +200,7 @@ class MatchBooks(QDialog, Ui_MatchBooks):
if not self.current_library_book_id:
d = error_dialog(self.gui, _('Match books'),
_('You must select a matching book'))
d.exec_()
d.exec()
return
mi = self.library_db.get_metadata(self.current_library_book_id,
index_is_id=True, get_user_categories=False,

View File

@ -162,10 +162,11 @@ class MyBlockingBusy(QDialog): # {{{
self.error = (err, traceback.format_exc())
QDialog.accept(self)
def exec_(self):
def exec(self):
self.thread = Thread(target=self.do_it)
self.thread.start()
return QDialog.exec_(self)
return QDialog.exec(self)
exec_ = exec
def do_it(self):
try:
@ -575,7 +576,7 @@ class MetadataBulkDialog(QDialog, Ui_MetadataBulkDialog):
self.authors.setFocus(Qt.FocusReason.OtherFocusReason)
self.generate_cover_settings = None
self.button_config_cover_gen.clicked.connect(self.customize_cover_generation)
self.exec_()
self.exec()
def sizeHint(self):
desktop = QCoreApplication.instance().desktop()
@ -586,13 +587,13 @@ class MetadataBulkDialog(QDialog, Ui_MetadataBulkDialog):
def customize_cover_generation(self):
from calibre.gui2.covers import CoverSettingsDialog
d = CoverSettingsDialog(parent=self)
if d.exec_() == QDialog.DialogCode.Accepted:
if d.exec() == QDialog.DialogCode.Accepted:
self.generate_cover_settings = d.prefs_for_rendering
def set_comments(self):
from calibre.gui2.dialogs.comments_dialog import CommentsDialog
d = CommentsDialog(self, '' if self.comments is null else (self.comments or ''), _('Comments'))
if d.exec_() == QDialog.DialogCode.Accepted:
if d.exec() == QDialog.DialogCode.Accepted:
self.comments = d.textbox.html
b = self.comments_button
b.setStyleSheet('QPushButton { font-weight: bold }')
@ -1139,7 +1140,7 @@ class MetadataBulkDialog(QDialog, Ui_MetadataBulkDialog):
def tag_editor(self, *args):
d = TagEditor(self, self.db, None)
d.exec_()
d.exec()
if d.result() == QDialog.DialogCode.Accepted:
tag_string = ', '.join(d.tags)
self.tags.setText(tag_string)
@ -1253,7 +1254,7 @@ class MetadataBulkDialog(QDialog, Ui_MetadataBulkDialog):
# which can slow down bulk editing of large numbers of books
self.model.stop_metadata_backup()
try:
bb.exec_()
bb.exec()
finally:
self.model.start_metadata_backup()
@ -1274,7 +1275,7 @@ class MetadataBulkDialog(QDialog, Ui_MetadataBulkDialog):
'Covers were compressed by {percent:.1%} from a total size of'
' {old} to {new}.').format(
percent=percent, old=human_readable(total_old), new=human_readable(total_new))
).exec_()
).exec()
return QDialog.accept(self)
def series_changed(self, *args):

View File

@ -201,7 +201,7 @@ if __name__ == '__main__':
app = Application([])
from calibre.library import db
d = ChooseMultiSort(db())
d.exec_()
d.exec()
print(d.current_sort_spec)
del d
del app

View File

@ -732,7 +732,7 @@ class PluginUpdaterDialog(SizePersistedDialog):
d.do_restart = True
b.clicked.connect(rf)
d.set_details('')
d.exec_()
d.exec()
b.clicked.disconnect()
do_restart = d.do_restart

View File

@ -172,4 +172,4 @@ if __name__ == '__main__':
d = ProgressDialog('A title', 'A message', icon='lt.png')
d.show(), d.canceled_signal.connect(app.quit)
QTimer.singleShot(1000, lambda : (setattr(d, 'value', 10), setattr(d, 'msg', ('A message ' * 100))))
app.exec_()
app.exec()

View File

@ -111,7 +111,7 @@ def restore_database(db, parent=None):
return False
db.close()
d = DBRestore(parent, db.library_path)
d.exec_()
d.exec()
r = d.restorer
d.restorer = None
if d.rejected:
@ -127,7 +127,7 @@ def restore_database(db, parent=None):
def repair_library_at(library_path, parent=None, wait_time=2):
d = DBRestore(parent, library_path, wait_time=wait_time)
d.exec_()
d.exec()
if d.rejected:
return False
r = d.restorer

View File

@ -155,7 +155,7 @@ class SavedSearchEditor(Dialog):
def add_search(self):
d = AddSavedSearch(parent=self, commit_changes=False, validate=self.validate_add)
if d.exec_() != QDialog.DialogCode.Accepted:
if d.exec() != QDialog.DialogCode.Accepted:
return
name, expression = d.accepted_data
self.searches[name] = expression
@ -184,7 +184,7 @@ class SavedSearchEditor(Dialog):
d.setWindowTitle(_('Edit saved search'))
d.sname.setText(n)
d.search.setPlainText(self.searches[n])
if d.exec_() != QDialog.DialogCode.Accepted:
if d.exec() != QDialog.DialogCode.Accepted:
return
name, expression = d.accepted_data
self.slist.currentItem().setText(name)

View File

@ -628,7 +628,7 @@ class Scheduler(QObject):
try:
d = SchedulerDialog(self.recipe_model)
d.download.connect(self.download_clicked)
d.exec_()
d.exec()
gconf['oldest_news'] = self.oldest = d.old_news.value()
d.break_cycles()
finally:
@ -638,7 +638,7 @@ class Scheduler(QObject):
from calibre.gui2.dialogs.custom_recipes import CustomRecipes
d = CustomRecipes(self.recipe_model, self._parent)
try:
d.exec_()
d.exec()
finally:
d.deleteLater()
@ -729,5 +729,5 @@ if __name__ == '__main__':
from calibre.gui2 import Application
app = Application([])
d = SchedulerDialog(RecipeModel())
d.exec_()
d.exec()
del app

View File

@ -490,6 +490,6 @@ if __name__ == '__main__':
from calibre.gui2 import Application
app = Application([])
d = SearchDialog(None, db)
d.exec_()
d.exec()
print(d.search_string())

View File

@ -98,5 +98,5 @@ if __name__ == '__main__':
from calibre.gui2 import Application
app = Application([])
d = SelectFormats(['epub', 'lrf', 'lit', 'mobi'], 'Choose a format')
d.exec_()
d.exec()
print(d.selected_formats)

View File

@ -236,14 +236,14 @@ class TagCategories(QDialog, Ui_TagCategories):
error_dialog(self, _('Invalid name'),
_('That name contains leading or trailing periods, '
'multiple periods in a row or spaces before '
'or after periods.')).exec_()
'or after periods.')).exec()
return False
for c in sorted(self.categories.keys(), key=sort_key):
if strcmp(c, cat_name) == 0 or \
(icu_lower(cat_name).startswith(icu_lower(c) + '.') and
not cat_name.startswith(c + '.')):
error_dialog(self, _('Name already used'),
_('That name is already used, perhaps with different case.')).exec_()
_('That name is already used, perhaps with different case.')).exec()
return False
if cat_name not in self.categories:
self.category_box.clear()
@ -267,13 +267,13 @@ class TagCategories(QDialog, Ui_TagCategories):
error_dialog(self, _('Invalid name'),
_('That name contains leading or trailing periods, '
'multiple periods in a row or spaces before '
'or after periods.')).exec_()
'or after periods.')).exec()
return False
for c in self.categories:
if strcmp(c, cat_name) == 0:
error_dialog(self, _('Name already used'),
_('That name is already used, perhaps with different case.')).exec_()
_('That name is already used, perhaps with different case.')).exec()
return False
# The order below is important because of signals
self.categories[cat_name] = self.categories[self.current_cat_name]

View File

@ -114,7 +114,7 @@ class TagEditor(QDialog, Ui_TagEditor):
confirms, deletes = [], []
items = self.available_tags.selectedItems() if item is None else [item]
if not items:
error_dialog(self, 'No tags selected', 'You must select at least one tag from the list of Available tags.').exec_()
error_dialog(self, 'No tags selected', 'You must select at least one tag from the list of Available tags.').exec()
return
if not confirm(
_('Deleting tags is done immediately and there is no undo.'),
@ -258,5 +258,5 @@ if __name__ == '__main__':
db = db()
app = Application([])
d = TagEditor(None, db, current_tags='a b c'.split())
if d.exec_() == QDialog.DialogCode.Accepted:
if d.exec() == QDialog.DialogCode.Accepted:
print(d.tags)

View File

@ -323,7 +323,7 @@ class TagListEditor(QDialog, Ui_TagListEditor):
action_title_case.triggered.connect(partial(self.do_case, titlecase))
action_capitalize.triggered.connect(partial(self.do_case, capitalize))
m.addMenu(case_menu)
m.exec_(self.table.mapToGlobal(point))
m.exec(self.table.mapToGlobal(point))
def search_for_books(self, item):
from calibre.gui2.ui import get_gui
@ -564,7 +564,7 @@ class TagListEditor(QDialog, Ui_TagListEditor):
indexes = self.table.selectionModel().selectedRows()
if not indexes:
error_dialog(self, _('No item selected'),
_('You must select one item from the list of available items.')).exec_()
_('You must select one item from the list of available items.')).exec()
return
if not confirm(
@ -589,7 +589,7 @@ class TagListEditor(QDialog, Ui_TagListEditor):
def _rename_tag(self, item):
if item is None:
error_dialog(self, _('No item selected'),
_('You must select one item from the list of available items.')).exec_()
_('You must select one item from the list of available items.')).exec()
return
for col_zero_item in self.table.selectedItems():
if col_zero_item.is_deleted:
@ -616,7 +616,7 @@ class TagListEditor(QDialog, Ui_TagListEditor):
deletes = self.table.selectedItems()
if not deletes:
error_dialog(self, _('No items selected'),
_('You must select at least one item from the list.')).exec_()
_('You must select at least one item from the list.')).exec()
return
to_del = []

View File

@ -494,7 +494,7 @@ class TemplateDialog(QDialog, Ui_TemplateDialog):
ca.triggered.connect(self.load_template_from_file)
ca = m.addAction(_('Save template to file'))
ca.triggered.connect(self.save_template)
m.exec_(self.textbox.mapToGlobal(point))
m.exec(self.textbox.mapToGlobal(point))
def load_last_template_text(self):
from calibre.customize.ui import find_plugin
@ -606,7 +606,7 @@ class TemplateDialog(QDialog, Ui_TemplateDialog):
return
self.break_reporter_dialog = BreakReporter(self, mi_to_use,
txt, val, locals_, line_number)
if not self.break_reporter_dialog.exec_():
if not self.break_reporter_dialog.exec():
raise StopException()
def filename_button_clicked(self):
@ -887,5 +887,5 @@ if __name__ == '__main__':
app = Application([])
from calibre.ebooks.metadata.book.base import field_metadata
d = TemplateDialog(None, '{title}', fm=field_metadata)
d.exec_()
d.exec()
del app

View File

@ -34,7 +34,7 @@ class TemplateLineEditor(QLineEdit):
action_clear_field.triggered.connect(self.clear_field)
action_open_editor = menu.addAction(_('Open template editor'))
action_open_editor.triggered.connect(self.open_editor)
menu.exec_(event.globalPos())
menu.exec(event.globalPos())
def clear_field(self):
self.setText('')
@ -42,5 +42,5 @@ class TemplateLineEditor(QLineEdit):
def open_editor(self):
t = TemplateDialog(self, self.text(), mi=self.mi)
t.setWindowTitle(_('Edit template'))
if t.exec_():
if t.exec():
self.setText(t.rule[1])

View File

@ -119,7 +119,7 @@ if __name__ == '__main__':
with open(fname, 'rb') as f:
data = f.read()
d = TrimImage(data)
if d.exec_() == QDialog.DialogCode.Accepted and d.image_data is not None:
if d.exec() == QDialog.DialogCode.Accepted and d.image_data is not None:
b, ext = os.path.splitext(fname)
fname = b + '-trimmed' + ext
with open(fname, 'wb') as f:

View File

@ -94,7 +94,7 @@ class DownloadDialog(QDialog): # {{{
def start_download(self):
self.worker.start()
QTimer.singleShot(50, self.update)
self.exec_()
self.exec()
if self.worker.err is not None:
error_dialog(self.parent(), _('Download failed'),
_('Failed to download from %(url)r with error: %(err)s')%dict(

View File

@ -43,7 +43,7 @@ class DownloadInfo(MessageBox):
def show_download_info(filename, parent=None):
if not gprefs.get('show_get_books_download_info', True):
return
DownloadInfo(filename, parent).exec_()
DownloadInfo(filename, parent).exec()
def get_download_filename(response):

View File

@ -306,7 +306,7 @@ class SelectRecipients(QDialog): # {{{
def select_recipients(parent=None):
d = SelectRecipients(parent)
if d.exec_() == QDialog.DialogCode.Accepted:
if d.exec() == QDialog.DialogCode.Accepted:
return d.ans
return ()
# }}}
@ -469,7 +469,7 @@ class EmailMixin: # {{{
d = warning_dialog(self, _('No suitable formats'),
_('Could not email the following books '
'as no suitable formats were found:'), bad)
d.exec_()
d.exec()
def email_sent(self, job, remove=[]):
if job.failed:

View File

@ -365,7 +365,7 @@ class FontFamilyChooser(QWidget):
def show_chooser(self):
d = FontFamilyDialog(self.font_family, self)
if d.exec_() == QDialog.DialogCode.Accepted:
if d.exec() == QDialog.DialogCode.Accepted:
self.font_family = d.font_family
@ -376,7 +376,7 @@ def test():
d.setLayout(QVBoxLayout())
d.layout().addWidget(FontFamilyChooser(d))
d.layout().addWidget(QFontComboBox(d))
d.exec_()
d.exec()
if __name__ == '__main__':

View File

@ -375,7 +375,7 @@ if __name__ == '__main__':
d.rules = [
{'match_type':'xpath', 'query':'//h:h2', 'actions':[{'type': 'remove'}]},
]
d.exec_()
d.exec()
from pprint import pprint
pprint(d.rules)
del d, app

View File

@ -416,11 +416,11 @@ def create_theme(folder=None, parent=None):
return
report = read_theme_from_folder(folder)
d = ThemeCreateDialog(parent, report)
if d.exec_() != QDialog.DialogCode.Accepted:
if d.exec() != QDialog.DialogCode.Accepted:
return
d.save_metadata()
d = Compress(d.report, parent=parent)
d.exec_()
d.exec()
if d.wasCanceled() or d.raw is None:
return
raw, prefix = d.raw, d.prefix
@ -798,7 +798,7 @@ class ChooseTheme(Dialog):
t = Thread(name='DownloadIconTheme', target=download)
t.daemon = True
t.start()
ret = d.exec_()
ret = d.exec()
if self.downloaded_theme and not isinstance(self.downloaded_theme, BytesIO):
return error_dialog(self, _('Download failed'), _(
@ -880,6 +880,6 @@ if __name__ == '__main__':
app = Application([])
# create_theme('.')
d = ChooseTheme()
if d.exec_() == QDialog.DialogCode.Accepted and d.commit_changes is not None:
if d.exec() == QDialog.DialogCode.Accepted and d.commit_changes is not None:
d.commit_changes()
del app

View File

@ -256,7 +256,7 @@ class ImageView(QDialog):
title = _('Image: {name} {resolution}').format(name=self.current_image_name, resolution=reso)
self.setWindowTitle(title)
if use_exec:
self.exec_()
self.exec()
else:
self.show()
@ -314,4 +314,4 @@ if __name__ == '__main__':
u = QUrl.fromLocalFile(sys.argv[-1])
d = ImageView(None, p, u)
d()
app.exec_()
app.exec()

View File

@ -541,7 +541,7 @@ class VLTabs(QTabBar): # {{{
m.addSeparator()
m.addAction(_('Edit "%s"') % vln, partial(self.gui.do_create_edit, name=vl))
m.addAction(_('Delete "%s"') % vln, partial(self.gui.remove_vl_triggered, name=vl))
m.exec_(ev.globalPos())
m.exec(ev.globalPos())
def sort_alphabetically(self):
self.current_db.new_api.set_pref('virt_libs_order', ())
@ -705,7 +705,7 @@ class LayoutMixin: # {{{
identifiers = db.field_for('identifiers', book_id, default_value={})
from calibre.gui2.metadata.basic_widgets import Identifiers
d = Identifiers(identifiers, self)
if d.exec_() == QDialog.DialogCode.Accepted:
if d.exec() == QDialog.DialogCode.Accepted:
identifiers = d.get_identifiers()
db.set_field('identifiers', {book_id: identifiers})
self.iactions['Edit Metadata'].refresh_books_after_metadata_edit({book_id})

View File

@ -308,10 +308,10 @@ class JobManager(QAbstractTableModel, AdaptSQP): # {{{
def kill_job(self, job, view):
if isinstance(job, DeviceJob):
return error_dialog(view, _('Cannot kill job'),
_('Cannot kill jobs that communicate with the device')).exec_()
_('Cannot kill jobs that communicate with the device')).exec()
if job.duration is not None:
return error_dialog(view, _('Cannot kill job'),
_('Job has already run')).exec_()
_('Job has already run')).exec()
if not getattr(job, 'killable', True):
return error_dialog(view, _('Cannot kill job'),
_('This job cannot be stopped'), show=True)
@ -321,7 +321,7 @@ class JobManager(QAbstractTableModel, AdaptSQP): # {{{
devjobs = [j for j in jobs if isinstance(j, DeviceJob)]
if devjobs:
error_dialog(view, _('Cannot kill job'),
_('Cannot kill jobs that communicate with the device')).exec_()
_('Cannot kill jobs that communicate with the device')).exec()
jobs = [j for j in jobs if not isinstance(j, DeviceJob)]
jobs = [j for j in jobs if j.duration is None]
unkillable = [j for j in jobs if not getattr(j, 'killable', True)]
@ -673,7 +673,7 @@ class JobsDialog(QDialog, Ui_JobsDialog):
row = index.row()
job = self.model.row_to_job(row)
d = DetailView(self, job)
d.exec_()
d.exec()
d.timer.stop()
def show_details(self, *args):

View File

@ -683,7 +683,7 @@ class ShortcutConfig(QWidget): # {{{
menu = QMenu(self)
menu.addAction(_('Expand all'), self.view.expandAll)
menu.addAction(_('Collapse all'), self.view.collapseAll)
menu.exec_(self.view.mapToGlobal(pos))
menu.exec(self.view.mapToGlobal(pos))
def restore_defaults(self):
self._model.restore_defaults()

View File

@ -142,4 +142,4 @@ if __name__ == '__main__':
app = Application([])
w = LayoutMenu()
w.show()
w.exec_()
w.exec()

View File

@ -208,7 +208,7 @@ def mouseMoveEvent(self, event):
if not index.isValid():
return
drag = self.drag_data()
drag.exec_(Qt.DropAction.CopyAction)
drag.exec(Qt.DropAction.CopyAction)
self.drag_start_pos = None

View File

@ -376,7 +376,7 @@ class ResultsList(QTreeWidget):
m.addSeparator()
m.addAction(_('Expand all'), self.expandAll)
m.addAction(_('Collapse all'), self.collapseAll)
m.exec_(self.mapToGlobal(pos))
m.exec(self.mapToGlobal(pos))
def edit_notes(self, item):
r = item.data(0, Qt.ItemDataRole.UserRole)
@ -998,7 +998,7 @@ class AnnotationsBrowser(Dialog):
if not annots:
return error_dialog(self, _('No selected annotations'), _(
'No annotations have been selected'), show=True)
Export(annots, self).exec_()
Export(annots, self).exec()
def delete_annotations(self, ids):
if confirm(ngettext(
@ -1019,7 +1019,7 @@ class AnnotationsBrowser(Dialog):
'Editing is only supported for the notes associated with highlights'), show=True)
notes = annot.get('notes')
d = EditNotes(notes, self)
if d.exec_() == QDialog.DialogCode.Accepted:
if d.exec() == QDialog.DialogCode.Accepted:
notes = d.notes
if notes and notes.strip():
annot['notes'] = notes.strip()
@ -1032,7 +1032,7 @@ class AnnotationsBrowser(Dialog):
def show_dialog(self, restrict_to_book_ids=None):
if self.parent() is None:
self.browse_panel.effective_query_changed()
self.exec_()
self.exec()
else:
self.reinitialize(restrict_to_book_ids)
self.show()

View File

@ -353,7 +353,7 @@ class CompleteDelegate(QStyledItemDelegate, UpdateEditorGeometry): # {{{
if check_key_modifier(Qt.KeyboardModifier.ShiftModifier) and col != 'authors':
key = col if m.is_custom_column(col) else None
d = TagEditor(parent, self.db, m.id(index.row()), key=key)
if d.exec_() == QDialog.DialogCode.Accepted:
if d.exec() == QDialog.DialogCode.Accepted:
m.setData(index, self.sep.join(d.tags), Qt.ItemDataRole.EditRole)
return None
editor = EditWithComplete(parent)
@ -523,7 +523,7 @@ class CcLongTextDelegate(QStyledItemDelegate): # {{{
else:
text = m.db.data[index.row()][m.custom_columns[col]['rec_index']]
d = PlainTextDialog(parent, text, column_name=m.custom_columns[col]['name'])
if d.exec_() == QDialog.DialogCode.Accepted:
if d.exec() == QDialog.DialogCode.Accepted:
m.setData(index, d.text, Qt.ItemDataRole.EditRole)
return None
@ -671,7 +671,7 @@ class CcCommentsDelegate(QStyledItemDelegate): # {{{
else:
text = m.db.data[index.row()][m.custom_columns[col]['rec_index']]
editor = CommentsDialog(parent, text, column_name=m.custom_columns[col]['name'])
d = editor.exec_()
d = editor.exec()
if d:
m.setData(index, (editor.textbox.html), Qt.ItemDataRole.EditRole)
return None
@ -758,7 +758,7 @@ class CcTemplateDelegate(QStyledItemDelegate): # {{{
editor.setWindowTitle(_("Edit template"))
editor.textbox.setTabChangesFocus(False)
editor.textbox.setTabStopWidth(20)
d = editor.exec_()
d = editor.exec()
if d:
m.setData(index, (editor.rule[1]), Qt.ItemDataRole.EditRole)
return None

Some files were not shown because too many files have changed in this diff Show More