mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
more lambda slots
This commit is contained in:
parent
b60e76aa48
commit
f87199f661
@ -240,7 +240,11 @@ def details_context_menu_event(view, ev, book_info): # {{{
|
|||||||
if not fmt.upper().startswith('ORIGINAL_'):
|
if not fmt.upper().startswith('ORIGINAL_'):
|
||||||
from calibre.gui2.open_with import populate_menu, edit_programs
|
from calibre.gui2.open_with import populate_menu, edit_programs
|
||||||
m = QMenu(_('Open %s with...') % fmt.upper())
|
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:
|
if len(m.actions()) == 0:
|
||||||
menu.addAction(_('Open %s with...') % fmt.upper(), partial(book_info.choose_open_with, book_id, fmt))
|
menu.addAction(_('Open %s with...') % fmt.upper(), partial(book_info.choose_open_with, book_id, fmt))
|
||||||
else:
|
else:
|
||||||
@ -423,7 +427,11 @@ class CoverView(QWidget): # {{{
|
|||||||
save.triggered.connect(self.save_cover)
|
save.triggered.connect(self.save_cover)
|
||||||
|
|
||||||
m = QMenu(_('Open cover with...'))
|
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:
|
if len(m.actions()) == 0:
|
||||||
cm.addAction(_('Open cover with...'), self.choose_open_with)
|
cm.addAction(_('Open cover with...'), self.choose_open_with)
|
||||||
else:
|
else:
|
||||||
|
@ -54,7 +54,11 @@ class ChooseFormatDialog(QDialog):
|
|||||||
menu = self.own
|
menu = self.own
|
||||||
menu.clear()
|
menu.clear()
|
||||||
fmt = self._formats[self.formats.currentRow()]
|
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:
|
if len(menu.actions()) == 0:
|
||||||
menu.addAction(_('Open %s with...') % fmt.upper(), self.choose_open_with)
|
menu.addAction(_('Open %s with...') % fmt.upper(), self.choose_open_with)
|
||||||
else:
|
else:
|
||||||
|
@ -327,7 +327,7 @@ def choose_program(file_type='jpeg', parent=None, prefs=oprefs):
|
|||||||
return entry
|
return entry
|
||||||
|
|
||||||
|
|
||||||
def populate_menu(menu, receiver, file_type):
|
def populate_menu(menu, connect_action, file_type):
|
||||||
file_type = file_type.lower()
|
file_type = file_type.lower()
|
||||||
for entry in oprefs['entries'].get(file_type, ()):
|
for entry in oprefs['entries'].get(file_type, ()):
|
||||||
icon, text = entry_to_icon_text(entry)
|
icon, text = entry_to_icon_text(entry)
|
||||||
@ -336,8 +336,7 @@ def populate_menu(menu, receiver, file_type):
|
|||||||
if sa is not None:
|
if sa is not None:
|
||||||
text += '\t' + sa.shortcut().toString(QKeySequence.NativeText)
|
text += '\t' + sa.shortcut().toString(QKeySequence.NativeText)
|
||||||
ac = menu.addAction(icon, text)
|
ac = menu.addAction(icon, text)
|
||||||
|
connect_action(ac, entry)
|
||||||
ac.triggered.connect(partial(receiver, entry))
|
|
||||||
return menu
|
return menu
|
||||||
|
|
||||||
# }}}
|
# }}}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user