Add a button to clear the current virtual library easily

This commit is contained in:
Kovid Goyal 2013-07-25 15:24:29 +05:30
parent afbfa22fe2
commit 9c0a1ca2f3
2 changed files with 11 additions and 0 deletions

View File

@ -184,6 +184,14 @@ class SearchBar(QWidget): # {{{
l.addWidget(x)
parent.virtual_library = x
x = QToolButton(self)
x.setIcon(QIcon(I('minus.png')))
x.setObjectName('clear_vl')
l.addWidget(x)
x.setVisible(False)
x.setToolTip(_('Close the Virtual Library'))
parent.clear_vl = x
x = QLabel(self)
x.setObjectName("search_count")
l.addWidget(x)

View File

@ -316,6 +316,7 @@ class SearchRestrictionMixin(object):
self.virtual_library_menu = QMenu()
self.virtual_library.clicked.connect(self.virtual_library_clicked)
self.clear_vl.clicked.connect(lambda x: (self.apply_virtual_library(), self.clear_additional_restriction()))
self.virtual_library_tooltip = \
_('Use a "virtual library" to show only a subset of the books present in this library')
@ -589,10 +590,12 @@ class SearchRestrictionMixin(object):
self.search_count.setStyleSheet(
'QLabel { border-radius: 6px; background-color: %s }' %
tweaks['highlight_virtual_library'])
self.clear_vl.setVisible(True)
else: # No restriction or not library view
t = ''
self.search_count.setStyleSheet(
'QLabel { background-color: transparent; }')
self.clear_vl.setVisible(False)
self.search_count.setText(t)
if __name__ == '__main__':