From 529128326536a548aa0c8504761aad9c8971f506 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 14 Nov 2013 15:05:06 +0530 Subject: [PATCH] Add a keyboard shortcut (Ctrl+*) to convert the current search into a temporary virtual library. Fixes #1249773 [[Enhancement] Virtual library for all current searches](https://bugs.launchpad.net/calibre/+bug/1249773) --- manual/gui.rst | 2 ++ src/calibre/gui2/search_restriction_mixin.py | 13 ++++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/manual/gui.rst b/manual/gui.rst index 03e012f31e..6f25b66004 100755 --- a/manual/gui.rst +++ b/manual/gui.rst @@ -621,6 +621,8 @@ Calibre has several keyboard shortcuts to save you time and mouse movement. Thes - Clear the virtual library * - :kbd:`Alt+Esc` - Clear the additional restriction + * - :kbd:`Ctrl+*` + - Create a temporary virtual library based on the current search * - :kbd:`N or F3` - Find the next book that matches the current search (only works if the highlight checkbox next to the search bar is checked) * - :kbd:`Shift+N or Shift+F3` diff --git a/src/calibre/gui2/search_restriction_mixin.py b/src/calibre/gui2/search_restriction_mixin.py index 05cc266cef..fe5e379691 100644 --- a/src/calibre/gui2/search_restriction_mixin.py +++ b/src/calibre/gui2/search_restriction_mixin.py @@ -10,7 +10,7 @@ from functools import partial from PyQt4.Qt import ( Qt, QMenu, QPoint, QIcon, QDialog, QGridLayout, QLabel, QLineEdit, QComboBox, - QDialogButtonBox, QSize, QVBoxLayout, QListWidget, QStringList, QRadioButton) + QDialogButtonBox, QSize, QVBoxLayout, QListWidget, QStringList, QRadioButton, QAction) from calibre.gui2 import error_dialog, question_dialog, gprefs from calibre.gui2.dialogs.confirm_delete import confirm @@ -311,6 +311,14 @@ class SearchRestrictionMixin(object): def __init__(self): self.checked = QIcon(I('ok.png')) self.empty = QIcon(I('blank.png')) + self.current_search_action = QAction(self.empty, _('*current search'), self) + self.current_search_action.triggered.connect(partial(self.apply_virtual_library, library='*')) + self.addAction(self.current_search_action) + self.keyboard.register_shortcut( + 'vl-from-current-search', _('Virtual library from current search'), description=_( + 'Create a temporary Virtual library from the current search'), group=_('Miscellaneous'), + default_keys=('Ctrl+*',), action=self.current_search_action) + self.search_based_vl_name = None self.search_based_vl = None @@ -387,8 +395,7 @@ class SearchRestrictionMixin(object): a = m.addAction(self.empty, self.no_restriction) a.triggered.connect(partial(self.apply_virtual_library, library='')) - a = m.addAction(self.empty, _('*current search')) - a.triggered.connect(partial(self.apply_virtual_library, library='*')) + a = m.addAction(self.current_search_action) if self.search_based_vl_name: a = m.addAction(