diff --git a/src/calibre/gui2/book_details.py b/src/calibre/gui2/book_details.py index f9c8fd892d..72269e40cc 100644 --- a/src/calibre/gui2/book_details.py +++ b/src/calibre/gui2/book_details.py @@ -240,7 +240,11 @@ def details_context_menu_event(view, ev, book_info): # {{{ if not fmt.upper().startswith('ORIGINAL_'): from calibre.gui2.open_with import populate_menu, edit_programs m = QMenu(_('Open %s with...') % fmt.upper()) - populate_menu(m, partial(book_info.open_with, book_id, fmt), fmt) + + def connect_action(ac, entry): + connect_lambda(ac.triggered, book_info, lambda book_info: book_info.open_with(book_id, fmt, entry)) + + populate_menu(m, connect_action, fmt) if len(m.actions()) == 0: menu.addAction(_('Open %s with...') % fmt.upper(), partial(book_info.choose_open_with, book_id, fmt)) else: @@ -423,7 +427,11 @@ class CoverView(QWidget): # {{{ save.triggered.connect(self.save_cover) m = QMenu(_('Open cover with...')) - populate_menu(m, self.open_with, 'cover_image') + + def connect_action(ac, entry): + connect_lambda(ac.triggered, self, lambda self: self.open_with(entry)) + + populate_menu(m, connect_action, 'cover_image') if len(m.actions()) == 0: cm.addAction(_('Open cover with...'), self.choose_open_with) else: diff --git a/src/calibre/gui2/dialogs/choose_format.py b/src/calibre/gui2/dialogs/choose_format.py index a01783a04f..e90232b281 100644 --- a/src/calibre/gui2/dialogs/choose_format.py +++ b/src/calibre/gui2/dialogs/choose_format.py @@ -54,7 +54,11 @@ class ChooseFormatDialog(QDialog): menu = self.own menu.clear() fmt = self._formats[self.formats.currentRow()] - populate_menu(menu, self.open_with, fmt) + + def connect_action(ac, entry): + connect_lambda(ac.triggered, self, lambda self: self.open_with(entry)) + + populate_menu(menu, connect_action, fmt) if len(menu.actions()) == 0: menu.addAction(_('Open %s with...') % fmt.upper(), self.choose_open_with) else: diff --git a/src/calibre/gui2/open_with.py b/src/calibre/gui2/open_with.py index fc4a4a3b4a..ee22819216 100644 --- a/src/calibre/gui2/open_with.py +++ b/src/calibre/gui2/open_with.py @@ -327,7 +327,7 @@ def choose_program(file_type='jpeg', parent=None, prefs=oprefs): return entry -def populate_menu(menu, receiver, file_type): +def populate_menu(menu, connect_action, file_type): file_type = file_type.lower() for entry in oprefs['entries'].get(file_type, ()): icon, text = entry_to_icon_text(entry) @@ -336,8 +336,7 @@ def populate_menu(menu, receiver, file_type): if sa is not None: text += '\t' + sa.shortcut().toString(QKeySequence.NativeText) ac = menu.addAction(icon, text) - - ac.triggered.connect(partial(receiver, entry)) + connect_action(ac, entry) return menu # }}}