From 9235097db251a8284b6bbe0c67dc1724ea3565b5 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 28 Mar 2016 12:01:37 +0530 Subject: [PATCH] Edit metadata in bulk dialog: Allow configuring the types of generated covers. Fixes #1559257 [Generate Cover Customisation](https://bugs.launchpad.net/calibre/+bug/1559257) --- src/calibre/gui2/dialogs/metadata_bulk.py | 22 +- src/calibre/gui2/dialogs/metadata_bulk.ui | 695 ++++++++++++---------- 2 files changed, 386 insertions(+), 331 deletions(-) diff --git a/src/calibre/gui2/dialogs/metadata_bulk.py b/src/calibre/gui2/dialogs/metadata_bulk.py index b125d1eeb5..8d9a917d80 100644 --- a/src/calibre/gui2/dialogs/metadata_bulk.py +++ b/src/calibre/gui2/dialogs/metadata_bulk.py @@ -54,9 +54,12 @@ def get_cover_data(stream, ext): # {{{ return cdata, area # }}} -Settings = namedtuple('Settings', 'remove_all remove add au aus do_aus rating pub do_series do_autonumber do_remove_format ' - 'remove_format do_swap_ta do_remove_conv do_auto_author series do_series_restart series_start_value series_increment ' - 'do_title_case cover_action clear_series clear_pub pubdate adddate do_title_sort languages clear_languages restore_original comments') +Settings = namedtuple('Settings', + 'remove_all remove add au aus do_aus rating pub do_series do_autonumber do_remove_format ' + 'remove_format do_swap_ta do_remove_conv do_auto_author series do_series_restart series_start_value series_increment ' + 'do_title_case cover_action clear_series clear_pub pubdate adddate do_title_sort languages clear_languages ' + 'restore_original comments generate_cover_settings') + null = object() class MyBlockingBusy(QDialog): # {{{ @@ -179,7 +182,7 @@ class MyBlockingBusy(QDialog): # {{{ from calibre.ebooks.covers import generate_cover for book_id in self.ids: mi = self.db.get_metadata(book_id, index_is_id=True) - cdata = generate_cover(mi) + cdata = generate_cover(mi, prefs=args.generate_cover_settings) cache.set_cover({book_id:cdata}) elif args.cover_action == 'fromfmt': for book_id in self.ids: @@ -382,8 +385,17 @@ class MetadataBulkDialog(ResizableDialog, Ui_MetadataBulkDialog): self.languages.init_langs(self.db) self.languages.setEditText('') self.authors.setFocus(Qt.OtherFocusReason) + self.generate_cover_settings = None + self.button_config_cover_gen.setVisible(False) + self.button_config_cover_gen.clicked.connect(self.customize_cover_generation) self.exec_() + def customize_cover_generation(self): + from calibre.gui2.covers import CoverSettingsDialog + d = CoverSettingsDialog(parent=self) + if d.exec_() == d.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')) @@ -1004,7 +1016,7 @@ class MetadataBulkDialog(ResizableDialog, Ui_MetadataBulkDialog): do_remove_conv, do_auto_author, series, do_series_restart, series_start_value, series_increment, do_title_case, cover_action, clear_series, clear_pub, pubdate, adddate, do_title_sort, languages, clear_languages, - restore_original, self.comments) + restore_original, self.comments, self.generate_cover_settings) self.set_field_calls = defaultdict(dict) bb = MyBlockingBusy(args, self.ids, self.db, self.refresh_books, diff --git a/src/calibre/gui2/dialogs/metadata_bulk.ui b/src/calibre/gui2/dialogs/metadata_bulk.ui index 4c9b7f6657..2836445f88 100644 --- a/src/calibre/gui2/dialogs/metadata_bulk.ui +++ b/src/calibre/gui2/dialogs/metadata_bulk.ui @@ -7,7 +7,7 @@ 0 0 962 - 645 + 669 @@ -18,16 +18,6 @@ :/images/edit_input.png:/images/edit_input.png - - - - - - - Qt::AlignCenter - - - @@ -45,7 +35,7 @@ 0 0 944 - 576 + 600 @@ -71,96 +61,158 @@ &Basic metadata - - - - - 0 - 0 - - - - List of known series. You can add new series. - - - List of known series. You can add new series. - - - true - - - QComboBox::InsertAlphabetically - - - QComboBox::AdjustToMinimumContentsLengthWithIcon - - - 40 - - - - - - - If checked, the series will be cleared - + + - &Clear series - - - - - - - &Apply date - - - - - - - P&ublished: + &Author(s): Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - pubdate + authors - - + + + + true + + + + + - - - MMM yyyy + + + This will cause the author sort field to be automatically updated + based on the authors field for each selected book. Note that if + you use the control above to set authors in bulk, the author sort + field is updated anyway, regardless of the value of this checkbox. - - true + + A&utomatically set author sort - - - Clear published date - + - ... - - - - :/images/trash.png:/images/trash.png + S&wap title and author - - + + - &Apply date + Author s&ort: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + author_sort + + + + + + + Specify how the author(s) of this book should be sorted. For example Charles Dickens should be sorted as Dickens, Charles. + + + + + + + &Rating: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + rating + + + + + + + Rating of this book. 0-5 stars + + + Rating of this book. 0-5 stars + + + QAbstractSpinBox::PlusMinus + + + No change + + + stars + + + -1 + + + 5 + + + -1 + + + + + + + &Publisher: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + publisher + + + + + + + true + + + + + + + If checked, the publisher will be cleared + + + &Clear pub + + + + + + + Add ta&gs: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + tags + + + + + + + Tags categorize the book. This is particularly useful while searching. <br><br>They can be any words or phrases, separated by commas. @@ -198,62 +250,15 @@ - - - - Qt::Vertical + + + + Check this box to remove all tags from the books. - - QSizePolicy::Fixed + + Remove &all - - - 20 - 15 - - - - - - - - - - - 120 - 16777215 - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - When doing a same format to same format conversion, -for e.g., EPUB to EPUB, calibre saves the original EPUB - as ORIGINAL_EPUB. This option tells calibre to restore - the EPUB from ORIGINAL_EPUB. Useful if you did a bulk - conversion of a large number of books and something went wrong. - - - Restore pre conversion &originals, if available - - - - + @@ -271,84 +276,41 @@ for e.g., EPUB to EPUB, calibre saves the original EPUB - - + + + + + 0 + 0 + + + + List of known series. You can add new series. + + + List of known series. You can add new series. + true - - - - - - Add ta&gs: + + QComboBox::InsertAlphabetically - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + QComboBox::AdjustToMinimumContentsLengthWithIcon - - tags + + 40 - - + + - Tags categorize the book. This is particularly useful while searching. <br><br>They can be any words or phrases, separated by commas. - - - - - - - true - - - - - - - - - This will cause the author sort field to be automatically updated - based on the authors field for each selected book. Note that if - you use the control above to set authors in bulk, the author sort - field is updated anyway, regardless of the value of this checkbox. - - - A&utomatically set author sort - - - - - - - S&wap title and author - - - - - - - - - &Author(s): - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - authors - - - - - - - Check this box to remove all tags from the books. + If checked, the series will be cleared - Remove &all + &Clear series @@ -435,19 +397,6 @@ from the value in the box - - - - Qt::Vertical - - - - 20 - 40 - - - - @@ -473,80 +422,151 @@ from the value in the box - - + + - Author s&ort: + &Apply date + + + + + + + P&ublished: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - author_sort + pubdate - - - - Specify how the author(s) of this book should be sorted. For example Charles Dickens should be sorted as Dickens, Charles. - - + + + + + + MMM yyyy + + + true + + + + + + + Clear published date + + + ... + + + + :/images/trash.png:/images/trash.png + + + + - - + + - &Rating: + &Apply date + + + + + + + &Languages: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - rating + languages - - - - Rating of this book. 0-5 stars - - - Rating of this book. 0-5 stars - - - QAbstractSpinBox::PlusMinus - - - No change - - - stars - - - -1 - - - 5 - - - -1 - - + + - - + + - &Publisher: + Remove &all - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + Remove &format: - publisher + remove_format + + + + + + + 120 + 16777215 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + When doing a same format to same format conversion, +for e.g., EPUB to EPUB, calibre saves the original EPUB + as ORIGINAL_EPUB. This option tells calibre to restore + the EPUB from ORIGINAL_EPUB. Useful if you did a bulk + conversion of a large number of books and something went wrong. + + + Restore pre conversion &originals, if available + + + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 15 + + + + @@ -602,7 +622,7 @@ Future conversion of these books will use the default settings. Change &cover - + @@ -650,61 +670,58 @@ as that of the first selected book. - - - - &Languages: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - languages - - - - - - - - - - Remove &all - - - - - - - Remove &format: - - - remove_format - - - - - - - 0 - 0 - - - - Set the co&mments for all selected books - - + + + + + Control how the default generated covers are created + + + Configure co&ver generation + + + + + + + + 0 + 0 + + + + Set the co&mments for all selected books + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + - - - - If checked, the publisher will be cleared + + + + Qt::Vertical - - &Clear pub + + + 20 + 40 + - + @@ -1193,7 +1210,7 @@ not multiple and the destination field is multiple 0 0 922 - 244 + 268 @@ -1249,6 +1266,16 @@ not multiple and the destination field is multiple + + + + + + + Qt::AlignCenter + + + @@ -1367,8 +1394,8 @@ is completed. This can be slow on large libraries. accept() - 258 - 638 + 672 + 658 157 @@ -1383,8 +1410,8 @@ is completed. This can be slow on large libraries. reject() - 326 - 638 + 740 + 658 286 @@ -1399,12 +1426,12 @@ is completed. This can be slow on large libraries. setDisabled(bool) - 888 - 266 + 927 + 255 - 814 - 268 + 824 + 256 @@ -1415,12 +1442,28 @@ is completed. This can be slow on large libraries. setDisabled(bool) - 874 - 418 + 927 + 406 - 817 - 420 + 824 + 407 + + + + + cover_generate + toggled(bool) + button_config_cover_gen + setVisible(bool) + + + 100 + 532 + + + 111 + 582