Clicking on the current Virtual library in the dropdown menu now closes the virtual library. Fixes #1864229 [[Enhancement] Close VL when clicking on the VL in the VL menu](https://bugs.launchpad.net/calibre/+bug/1864229)

This commit is contained in:
Kovid Goyal 2020-03-05 08:58:47 +05:30
parent 20cba609fc
commit 42d055e511
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -421,8 +421,12 @@ class SearchRestrictionMixin(object):
virt_libs = db.prefs.get('virtual_libraries', {})
for vl in sorted(virt_libs.keys(), key=sort_key):
a = m.addAction(self.checked if vl == current_lib else self.empty, vl.replace('&', '&&'))
a.triggered.connect(partial(self.apply_virtual_library, library=vl))
is_current = vl == current_lib
a = m.addAction(self.checked if is_current else self.empty, vl.replace('&', '&&'))
if is_current:
a.triggered.connect(self.clear_vl.click)
else:
a.triggered.connect(partial(self.apply_virtual_library, library=vl))
def virtual_library_menu_about_to_show(self):
self.build_virtual_library_menu(self.virtual_library_menu)