Allow controlling the Virtual library with calibre://search URLs

This commit is contained in:
Kovid Goyal 2020-11-22 11:48:43 +05:30
parent 31c7ef4167
commit 7ebfb0f248
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 17 additions and 0 deletions

View File

@ -81,6 +81,18 @@ search expression is complicated, :ref:`encode it as a hex string <hex_encoding>
and use ``eq`` instead. Leaving out the query will cause the current search to
be cleared.
By default, if a Virtual library is selected, calibre will clear it before
doing the search to ensure all books are found. If you want to preserve the
Virtual library, use::
calibre://search/Library_Name?q=query&virtual_library=_
If you want to switch to a particular Virtual library, use::
calibre://search/Library_Name?virtual_library=Library%20Name
replacing spaces in the Virtual library name by ``%20``.
.. _hex_encoding:

View File

@ -718,8 +718,13 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin, # {{{
if sq:
sq = sq[0]
sq = sq or ''
vl = (query.get('virtual_library') or ['-'])[0]
if vl == '-':
vl = None
def doit():
if vl != '_':
self.apply_virtual_library(vl)
self.search.set_search_string(sq)
self.perform_url_action(library_id, library_path, doit)