This commit is contained in:
Kovid Goyal 2021-05-26 22:15:36 +05:30
parent f9cfc4d6a0
commit 1575a29101
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 15 additions and 6 deletions

View File

@ -11,7 +11,7 @@ from collections import defaultdict
from functools import partial from functools import partial
from qt.core import QApplication, QDialog, QPixmap, QTimer from qt.core import QApplication, QDialog, QPixmap, QTimer
from calibre import as_unicode, guess_type from calibre import as_unicode, guess_type, prepare_string_for_xml
from calibre.constants import iswindows from calibre.constants import iswindows
from calibre.ebooks import BOOK_EXTENSIONS from calibre.ebooks import BOOK_EXTENSIONS
from calibre.ebooks.metadata import MetaInformation, normalize_isbn from calibre.ebooks.metadata import MetaInformation, normalize_isbn
@ -574,10 +574,10 @@ class AddAction(InterfaceAction):
merged[author].append(title) merged[author].append(title)
lines = [] lines = []
for author in sorted(merged, key=sort_key): for author in sorted(merged, key=sort_key):
lines.append(author) lines.append(f'<b><i>{prepare_string_for_xml(author)}</i></b><ol style="margin-top: 0">')
for title in sorted(merged[author], key=sort_key): for title in sorted(merged[author]):
lines.append(' ' + title) lines.append(f'<li>{prepare_string_for_xml(title)}</li>')
lines.append('') lines.append('</ol>')
pm = ngettext('The following duplicate book was found.', pm = ngettext('The following duplicate book was found.',
'The following {} duplicate books were found.', 'The following {} duplicate books were found.',
len(adder.merged_books)).format(len(adder.merged_books)) len(adder.merged_books)).format(len(adder.merged_books))

View File

@ -494,7 +494,16 @@ class JobError(QDialog): # {{{
if __name__ == '__main__': if __name__ == '__main__':
from calibre.gui2 import Application, question_dialog from calibre.gui2 import Application, question_dialog
from calibre import prepare_string_for_xml
app = Application([]) app = Application([])
merged = {'Kovid Goyal': ['Waterloo', 'Doomed'], 'Someone Else': ['Some other book ' * 1000]}
lines = []
for author in sorted(merged):
lines.append(f'<b><i>{prepare_string_for_xml(author)}</i></b><ol style="margin-top: 0">')
for title in sorted(merged[author]):
lines.append(f'<li>{prepare_string_for_xml(title)}</li>')
lines.append('</ol>')
print(question_dialog(None, 'title', 'msg <a href="http://google.com">goog</a> ', print(question_dialog(None, 'title', 'msg <a href="http://google.com">goog</a> ',
det_msg='<p>hi there <b>guy</b> '*1000, det_msg='\n'.join(lines),
show_copy_button=True)) show_copy_button=True))