Fix #1906093 [Error: No books selected when I trying to open the Edit metadata window](https://bugs.launchpad.net/calibre/+bug/1906093)

This commit is contained in:
Kovid Goyal 2020-11-28 13:41:49 +05:30
parent 5e12d32755
commit da172232bb
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 10 additions and 4 deletions

View File

@ -343,7 +343,7 @@ def create_copy_links(menu, data=None):
link(_('View {} format of book').format(fmt.upper()), f'calibre://view-book/{library_id}/{book_id}/{fmt}')
def details_context_menu_event(view, ev, book_info, add_popup_action=False):
def details_context_menu_event(view, ev, book_info, add_popup_action=False, edit_metadata=None):
url = view.anchorAt(ev.pos())
menu = QMenu(view)
menu.addAction(QIcon(I('edit-copy.png')), _('Copy all book details'), partial(copy_all, view))
@ -380,7 +380,7 @@ def details_context_menu_event(view, ev, book_info, add_popup_action=False):
else:
from calibre.gui2.ui import get_gui
ema = get_gui().iactions['Edit Metadata'].menuless_qaction
menu.addAction(_('Open the Edit metadata window') + '\t' + ema.shortcut().toString(QKeySequence.NativeText), ema.trigger)
menu.addAction(_('Open the Edit metadata window') + '\t' + ema.shortcut().toString(QKeySequence.NativeText), edit_metadata)
if len(menu.actions()) > 0:
menu.exec_(ev.globalPos())
# }}}

View File

@ -108,13 +108,14 @@ class Details(HTMLDisplay):
def __init__(self, book_info, parent=None):
HTMLDisplay.__init__(self, parent)
self.book_info = book_info
self.edit_metadata = getattr(parent, 'edit_metadata', None)
self.setDefaultStyleSheet(css())
def sizeHint(self):
return QSize(350, 350)
def contextMenuEvent(self, ev):
details_context_menu_event(self, ev, self.book_info)
details_context_menu_event(self, ev, self.book_info, edit_metadata=self.edit_metadata)
class BookInfo(QDialog):
@ -206,7 +207,12 @@ class BookInfo(QDialog):
a = self.ema = QAction('edit metadata', self)
a.setShortcut(ema.shortcut())
self.addAction(a)
a.triggered.connect(ema.trigger)
a.triggered.connect(self.edit_metadata)
def edit_metadata(self):
if self.current_row is not None:
book_id = self.view.model().id(self.current_row)
get_gui().iactions['Edit Metadata'].edit_metadata_for([self.current_row], [book_id], bulk=False)
def configure(self):
d = Configure(get_gui().current_db, self)