Forgot about the clear virtual library button on the search bar. Should also be flat

This commit is contained in:
Kovid Goyal 2017-06-10 21:43:01 +05:30
parent 932079f1e9
commit 2e90c865ff
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
3 changed files with 12 additions and 25 deletions

View File

@ -531,12 +531,6 @@ numeric_collation = False
# number here. The default is ten libraries.
many_libraries = 10
#: Highlight the virtual library name when using a Virtual library
# The virtual library name next to the Virtual library button is highlighted in
# yellow when using a Virtual library. You can choose the color used for the
# highlight with this tweak. Set it to 'transparent' to disable highlighting.
highlight_virtual_library = 'yellow'
#: Choose available output formats for conversion
# Restrict the list of available output formats in the conversion dialogs.
# For example, if you only want to convert to EPUB and AZW3, change this to

View File

@ -174,11 +174,10 @@ class SearchBar(QWidget): # {{{
def __init__(self, parent):
QWidget.__init__(self, parent)
self._layout = l = QHBoxLayout()
self.setLayout(self._layout)
self._layout.setContentsMargins(0,5,0,0)
self._layout = l = QHBoxLayout(self)
l.setContentsMargins(0,5,0,0)
x = QToolButton(self)
x = parent.virtual_library = QToolButton(self)
x.setCursor(Qt.PointingHandCursor)
x.setText(_('Virtual library'))
x.setAutoRaise(True)
@ -186,19 +185,20 @@ class SearchBar(QWidget): # {{{
x.setObjectName("virtual_library")
x.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
l.addWidget(x)
self.vl_sep = QFrame(self)
self.vl_sep.setFrameShape(QFrame.VLine)
self.vl_sep.setFrameShadow(QFrame.Sunken)
l.addWidget(self.vl_sep)
parent.virtual_library = x
x = QToolButton(self)
x.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
x.setAutoRaise(True)
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
self.vl_sep = QFrame(self)
self.vl_sep.setFrameShape(QFrame.VLine)
self.vl_sep.setFrameShadow(QFrame.Sunken)
l.addWidget(self.vl_sep)
x = QLabel(self)
x.setObjectName("search_count")

View File

@ -15,7 +15,6 @@ from PyQt5.Qt import (
from calibre.gui2 import error_dialog, question_dialog, gprefs
from calibre.gui2.dialogs.confirm_delete import confirm
from calibre.gui2.widgets import ComboBoxWithHelp
from calibre.utils.config_base import tweaks
from calibre.utils.icu import sort_key
from calibre.utils.search_query_parser import ParseException
from calibre.utils.localization import localize_user_manual_link
@ -342,7 +341,7 @@ class SearchRestrictionMixin(object):
self.search_restriction = ComboBoxWithHelp(self)
self.search_restriction.setVisible(False)
self.search_count.setText(_("(all books)"))
self.clear_vl.setText(_("(all books)"))
self.ar_menu = QMenu(_('Additional restriction'))
self.edit_menu = QMenu(_('Edit Virtual library'))
self.rm_menu = QMenu(_('Remove Virtual library'))
@ -624,18 +623,12 @@ class SearchRestrictionMixin(object):
t = ' :: '.join(restrictions)
if len(t) > 20:
t = t[:19] + u''
self.search_count.setStyleSheet(
'QLabel { border-radius: 6px; background-color: %s }' %
tweaks['highlight_virtual_library'])
self.clear_vl.setVisible(True)
self.search_count.setVisible(not gprefs['show_vl_tabs'])
self.clear_vl.setVisible(not gprefs['show_vl_tabs'])
else: # No restriction or not library view
t = ''
self.search_count.setStyleSheet(
'QLabel { background-color: transparent; }')
self.clear_vl.setVisible(False)
self.search_count.setVisible(False)
self.search_count.setText(t)
self.clear_vl.setText(t.replace('&', '&&'))
if __name__ == '__main__':