mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-31 14:33:54 -04:00
Prevent calling edit metadata from locked book details windows. EM edits the currently selected book, which is almost certainly not the book in the locked window.
This commit is contained in:
parent
cdc4a0a4d3
commit
663ccc2166
@ -561,8 +561,11 @@ def details_context_menu_event(view, ev, book_info, add_popup_action=False, edit
|
|||||||
if add_popup_action:
|
if add_popup_action:
|
||||||
menu.addMenu(get_gui().iactions['Show Book Details'].qaction.menu())
|
menu.addMenu(get_gui().iactions['Show Book Details'].qaction.menu())
|
||||||
else:
|
else:
|
||||||
ema = get_gui().iactions['Edit Metadata'].menuless_qaction
|
# We can't open edit metadata from a locked window because EM expects to
|
||||||
menu.addAction(_('Open the Edit metadata window') + '\t' + ema.shortcut().toString(QKeySequence.SequenceFormat.NativeText), edit_metadata)
|
# be editing the current book, which this book probably isn't
|
||||||
|
if edit_metadata is not None:
|
||||||
|
ema = get_gui().iactions['Edit Metadata'].menuless_qaction
|
||||||
|
menu.addAction(_('Open the Edit metadata window') + '\t' + ema.shortcut().toString(QKeySequence.SequenceFormat.NativeText), edit_metadata)
|
||||||
if not reindex_fmt_added:
|
if not reindex_fmt_added:
|
||||||
menu.addSeparator()
|
menu.addSeparator()
|
||||||
menu.addAction(_(
|
menu.addAction(_(
|
||||||
|
@ -119,19 +119,21 @@ class Configure(Dialog):
|
|||||||
|
|
||||||
class Details(HTMLDisplay):
|
class Details(HTMLDisplay):
|
||||||
|
|
||||||
def __init__(self, book_info, parent=None, allow_context_menu=True):
|
def __init__(self, book_info, parent=None, allow_context_menu=True, is_locked=False):
|
||||||
HTMLDisplay.__init__(self, parent)
|
HTMLDisplay.__init__(self, parent)
|
||||||
self.book_info = book_info
|
self.book_info = book_info
|
||||||
self.edit_metadata = getattr(parent, 'edit_metadata', None)
|
self.edit_metadata = getattr(parent, 'edit_metadata', None)
|
||||||
self.setDefaultStyleSheet(css())
|
self.setDefaultStyleSheet(css())
|
||||||
self.allow_context_menu = allow_context_menu
|
self.allow_context_menu = allow_context_menu
|
||||||
|
self.is_locked = is_locked
|
||||||
|
|
||||||
def sizeHint(self):
|
def sizeHint(self):
|
||||||
return QSize(350, 350)
|
return QSize(350, 350)
|
||||||
|
|
||||||
def contextMenuEvent(self, ev):
|
def contextMenuEvent(self, ev):
|
||||||
if self.allow_context_menu:
|
if self.allow_context_menu:
|
||||||
details_context_menu_event(self, ev, self.book_info, edit_metadata=self.edit_metadata)
|
details_context_menu_event(self, ev, self.book_info,
|
||||||
|
edit_metadata=None if self.is_locked else self.edit_metadata)
|
||||||
|
|
||||||
|
|
||||||
class DialogNumbers(IntEnum):
|
class DialogNumbers(IntEnum):
|
||||||
@ -167,7 +169,8 @@ class BookInfo(QDialog):
|
|||||||
self.splitter.addWidget(self.cover)
|
self.splitter.addWidget(self.cover)
|
||||||
|
|
||||||
self.details = Details(parent.book_details.book_info, self,
|
self.details = Details(parent.book_details.book_info, self,
|
||||||
allow_context_menu=library_path is None)
|
allow_context_menu=library_path is None,
|
||||||
|
is_locked = dialog_number == DialogNumbers.Locked)
|
||||||
self.details.anchor_clicked.connect(self.on_link_clicked)
|
self.details.anchor_clicked.connect(self.on_link_clicked)
|
||||||
self.link_delegate = link_delegate
|
self.link_delegate = link_delegate
|
||||||
self.details.setAttribute(Qt.WidgetAttribute.WA_OpaquePaintEvent, False)
|
self.details.setAttribute(Qt.WidgetAttribute.WA_OpaquePaintEvent, False)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user