From f77c3bf3a6c3949a95b96c06c7b0deeea61c4736 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 21 Feb 2020 11:47:40 +0530 Subject: [PATCH] Fix #1864152 [[Enhancement] Look of the Choose Virtual library](https://bugs.launchpad.net/calibre/+bug/1864152) --- src/calibre/gui2/search_restriction_mixin.py | 6 +++--- src/calibre/gui2/tweak_book/widgets.py | 16 +++++++++++----- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/calibre/gui2/search_restriction_mixin.py b/src/calibre/gui2/search_restriction_mixin.py index 83aa172b90..e2ab1c1594 100644 --- a/src/calibre/gui2/search_restriction_mixin.py +++ b/src/calibre/gui2/search_restriction_mixin.py @@ -495,15 +495,15 @@ class SearchRestrictionMixin(object): self._remove_vl(name, reapply=True) def choose_vl_triggerred(self): - from calibre.gui2.tweak_book.widgets import QuickOpen, Results + from calibre.gui2.tweak_book.widgets import QuickOpen, emphasis_style db = self.library_view.model().db virt_libs = db.prefs.get('virtual_libraries', {}) if not virt_libs: return error_dialog(self, _('No virtual libraries'), _( 'No Virtual libraries present, create some first'), show=True) example = '
{0}S{1}ome {0}B{1}ook {0}C{1}ollection
'.format( - '' % Results.EMPH, '') - chars = '
sbc
' % Results.EMPH + '' % emphasis_style(), '') + chars = '
sbc
' % emphasis_style() help_text = _('''

Quickly choose a Virtual library by typing in just a few characters from the file name into the field above. For example, if want to choose the VL: {example} diff --git a/src/calibre/gui2/tweak_book/widgets.py b/src/calibre/gui2/tweak_book/widgets.py index ad0bcb2b5f..a0f302a4d2 100644 --- a/src/calibre/gui2/tweak_book/widgets.py +++ b/src/calibre/gui2/tweak_book/widgets.py @@ -275,9 +275,13 @@ def make_highlighted_text(emph, text, positions): return text +def emphasis_style(): + pal = QApplication.instance().palette() + return 'color: {}; font-weight: bold'.format(pal.color(pal.Link).name()) + + class Results(QWidget): - EMPH = "color:magenta; font-weight:bold" MARGIN = 4 item_selected = pyqtSignal() @@ -355,7 +359,7 @@ class Results(QWidget): self.update() def make_text(self, text, positions): - text = QStaticText(make_highlighted_text(self.EMPH, text, positions)) + text = QStaticText(make_highlighted_text(emphasis_style(), text, positions)) text.setTextOption(self.text_option) text.setTextFormat(Qt.RichText) return text @@ -423,8 +427,8 @@ class QuickOpen(Dialog): def default_help_text(self): example = '

{0}i{1}mages/{0}c{1}hapter1/{0}s{1}cene{0}3{1}.jpg
'.format( - '' % Results.EMPH, '') - chars = '
ics3
' % Results.EMPH + '' % emphasis_style(), '') + chars = '
ics3
' % emphasis_style() return _('''

Quickly choose a file by typing in just a few characters from the file name into the field above. For example, if want to choose the file: @@ -439,6 +443,8 @@ class QuickOpen(Dialog): self.text = t = QLineEdit(self) t.textEdited.connect(self.update_matches) + t.setClearButtonEnabled(True) + t.setPlaceholderText(_('Search')) l.addWidget(t, alignment=Qt.AlignTop) self.help_label = hl = QLabel(self.help_text) @@ -509,7 +515,7 @@ class NamesDelegate(QStyledItemDelegate): to.setWrapMode(to.NoWrap) to.setAlignment(Qt.AlignLeft | Qt.AlignVCenter) positions = sorted(set(positions) - {-1}, reverse=True) - text = '%s' % make_highlighted_text(Results.EMPH, text, positions) + text = '%s' % make_highlighted_text(emphasis_style(), text, positions) doc = QTextDocument() c = 'rgb(%d, %d, %d)'%c.getRgb()[:3] doc.setDefaultStyleSheet(' body { color: %s }'%c)