mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix #1449076 [Mark books with embeded metadata](https://bugs.launchpad.net/calibre/+bug/1449076)
This commit is contained in:
parent
2ce28d5f2a
commit
989c02023d
@ -11,7 +11,7 @@ from functools import partial
|
||||
from PyQt5.Qt import QTimer, QProgressDialog, Qt
|
||||
|
||||
from calibre import force_unicode
|
||||
from calibre.gui2 import warning_dialog
|
||||
from calibre.gui2 import gprefs
|
||||
from calibre.gui2.actions import InterfaceAction
|
||||
|
||||
class EmbedAction(InterfaceAction):
|
||||
@ -98,17 +98,29 @@ class EmbedAction(InterfaceAction):
|
||||
if i > 0:
|
||||
self.gui.status_bar.show_message(_('Embedded metadata in %d books') % i, 5000)
|
||||
if errors:
|
||||
det_msg = [_('The {0} format of {1}:\n\n{2}\n').format(
|
||||
(fmt or '').upper(), force_unicode(mi.title), force_unicode(tb)) for mi, fmt, tb in errors]
|
||||
warning_dialog(
|
||||
self.gui, _('Failed for some files'), _(
|
||||
'Failed to embed metadata into some book files. Click "Show details" for details.'),
|
||||
det_msg='\n\n'.join(det_msg), show=True)
|
||||
det_msg = '\n\n'.join([_('The {0} format of {1}:\n\n{2}\n').format(
|
||||
(fmt or '').upper(), force_unicode(mi.title), force_unicode(tb)) for mi, fmt, tb in errors])
|
||||
from calibre.gui2.dialogs.message_box import MessageBox
|
||||
title, msg = _('Failed for some files'), _(
|
||||
'Failed to embed metadata into some book files. Click "Show details" for details.')
|
||||
d = MessageBox(MessageBox.WARNING, _('WARNING:')+ ' ' + title, msg, det_msg, parent=self.gui, show_copy_button=True)
|
||||
tc = d.toggle_checkbox
|
||||
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_()
|
||||
gprefs['show-embed-failed-books'] = tc.isChecked()
|
||||
if tc.isChecked():
|
||||
failed_ids = {mi.book_id for mi, fmt, tb in errors}
|
||||
db = self.gui.current_db
|
||||
db.data.set_marked_ids(failed_ids)
|
||||
self.gui.search.set_search_string('marked:true')
|
||||
return
|
||||
pd.setValue(i)
|
||||
db = self.gui.current_db.new_api
|
||||
book_id = book_ids[i]
|
||||
def report_error(mi, fmt, tb):
|
||||
mi.book_id = book_id
|
||||
errors.append((mi, fmt, tb))
|
||||
db.embed_metadata((book_ids[i],), only_fmts=only_fmts, report_error=report_error)
|
||||
db.embed_metadata((book_id,), only_fmts=only_fmts, report_error=report_error)
|
||||
self.job_data = (i + 1, book_ids, pd, only_fmts, errors)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user