From 56e0fc69fbe3630475f886dc257c1b9fed0b6c9a Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 24 Nov 2020 21:29:55 +0530 Subject: [PATCH] Fix #1904392 [[Enhancement] Add ability to remove author by right clicking in the Book details panel](https://bugs.launchpad.net/calibre/+bug/1904392) --- src/calibre/gui2/actions/edit_metadata.py | 5 +++++ src/calibre/gui2/book_details.py | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/calibre/gui2/actions/edit_metadata.py b/src/calibre/gui2/actions/edit_metadata.py index d27aebb4ad..8f396c855d 100644 --- a/src/calibre/gui2/actions/edit_metadata.py +++ b/src/calibre/gui2/actions/edit_metadata.py @@ -884,6 +884,11 @@ class EditMetadataAction(InterfaceAction): identifiers = db.field_for(field, book_id) if identifiers.pop(value, False) is not False: affected_books = db.set_field(field, {book_id:identifiers}) + elif field == 'authors': + authors = db.field_for(field, book_id) + new_authors = [x for x in authors if x != value] or [_('Unknown')] + if new_authors != authors: + affected_books = db.set_field(field, {book_id:new_authors}) elif fm['is_multiple']: item_id = db.get_item_id(field, value) if item_id is not None: diff --git a/src/calibre/gui2/book_details.py b/src/calibre/gui2/book_details.py index ac63011b36..f8b3e9023e 100644 --- a/src/calibre/gui2/book_details.py +++ b/src/calibre/gui2/book_details.py @@ -245,6 +245,7 @@ def add_format_entries(menu, data, book_info): def add_item_specific_entries(menu, data, book_info): + from calibre.gui2.ui import get_gui search_internet_added = False find_action = book_info.find_in_tag_browser_action dt = data['type'] @@ -271,8 +272,12 @@ def add_item_specific_entries(menu, data, book_info): if hasattr(book_info, 'search_requested'): menu.addAction(_('Search calibre for %s') % author, lambda : book_info.search_requested('authors:"={}"'.format(author.replace('"', r'\"')))) + ac = book_info.remove_item_action + book_id = get_gui().library_view.current_id + ac.data = ('authors', author, book_id) + ac.setText(_('Remove %s from this book') % escape_for_menu(author)) + menu.addAction(ac) elif dt in ('path', 'devpath'): - from calibre.gui2.ui import get_gui path = data['loc'] ac = book_info.copy_link_action if isinstance(path, int):