More work on lambda slots

This commit is contained in:
Kovid Goyal 2018-07-26 10:22:02 +05:30
parent 81de667d54
commit 11253f23b8
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
3 changed files with 13 additions and 13 deletions

View File

@ -65,10 +65,12 @@ class AddAction(InterfaceAction):
'e-book file is a different book)')).triggered.connect(
self.add_recursive_multiple)
arm = self.add_archive_menu = self.add_menu.addMenu(_('Add multiple books from archive (ZIP/RAR)'))
self.create_menu_action(arm, 'recursive-single-archive', _(
'One book per directory in the archive')).triggered.connect(partial(self.add_archive, True))
self.create_menu_action(arm, 'recursive-multiple-archive', _(
'Multiple books per directory in the archive')).triggered.connect(partial(self.add_archive, False))
connect_lambda(self.create_menu_action(
arm, 'recursive-single-archive', _('One book per directory in the archive')).triggered,
self, lambda self: self.add_archive(True))
connect_lambda(self.create_menu_action(
arm, 'recursive-multiple-archive', _('Multiple books per directory in the archive')).triggered,
self, lambda self: self.add_archive(False))
self.add_menu.addSeparator()
ma('add-empty', _('Add empty book (Book entry with no formats)'),
shortcut='Shift+Ctrl+E').triggered.connect(self.add_empty)
@ -79,9 +81,9 @@ class AddAction(InterfaceAction):
arm = self.add_archive_menu = self.add_menu.addMenu(_('Add an empty file to selected book records'))
from calibre.ebooks.oeb.polish.create import valid_empty_formats
for fmt in sorted(valid_empty_formats):
self.create_menu_action(arm, 'add-empty-' + fmt,
_('Add empty {}').format(fmt.upper())).triggered.connect(
partial(self.add_empty_format, fmt))
connect_lambda(self.create_menu_action(
arm, 'add-empty-' + fmt, _('Add empty {}').format(fmt.upper())).triggered,
self, lambda self: self.add_empty_format(fmt))
self.add_menu.addSeparator()
ma('add-config', _('Control the adding of books'),
triggered=self.add_config)

View File

@ -4,7 +4,6 @@
from __future__ import absolute_import, division, print_function, unicode_literals
import sys, os
from functools import partial
from PyQt5.Qt import (
QApplication, QEvent, QMouseEvent, QObject, QPointF, QScroller, Qt, QTouchDevice,
@ -156,9 +155,9 @@ class GestureManager(QObject):
self.state = State()
self.state.tapped.connect(self.handle_tap, type=Qt.QueuedConnection) # has to be queued otherwise QApplication.keyboardModifiers() does not work
self.state.flicking.connect(self.handle_flicking)
self.state.tap_hold_started.connect(partial(self.handle_tap_hold, 'start'))
self.state.tap_hold_updated.connect(partial(self.handle_tap_hold, 'update'))
self.state.tap_hold_finished.connect(partial(self.handle_tap_hold, 'end'))
connect_lambda(self.state.tap_hold_started, self, lambda self, tp: self.handle_tap_hold('start', tp))
connect_lambda(self.state.tap_hold_updated, self, lambda self, tp: self.handle_tap_hold('update', tp))
connect_lambda(self.state.tap_hold_finished, self, lambda self, tp: self.handle_tap_hold('end', tp))
self.evmap = {QEvent.TouchBegin: 'start', QEvent.TouchUpdate: 'update', QEvent.TouchEnd: 'end'}
self.last_tap_at = 0
if touch_supported:

View File

@ -623,8 +623,7 @@ class JobsDialog(QDialog, Ui_JobsDialog):
self.search.initialize('jobs_search_history',
help_text=_('Search for a job by name'))
self.search.search.connect(self.find)
self.search_button.clicked.connect(lambda :
self.find(self.search.current_text))
connect_lambda(self.search_button.clicked, self, lambda self: self.find(self.search.current_text))
self.restore_state()
def restore_state(self):