mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-06-23 15:30:45 -04:00
Fix #1864152 [[Enhancement] Look of the Choose Virtual library](https://bugs.launchpad.net/calibre/+bug/1864152)
This commit is contained in:
parent
6e8a80341b
commit
f77c3bf3a6
@ -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 = '<pre>{0}S{1}ome {0}B{1}ook {0}C{1}ollection</pre>'.format(
|
||||
'<span style="%s">' % Results.EMPH, '</span>')
|
||||
chars = '<pre style="%s">sbc</pre>' % Results.EMPH
|
||||
'<span style="%s">' % emphasis_style(), '</span>')
|
||||
chars = '<pre style="%s">sbc</pre>' % emphasis_style()
|
||||
help_text = _('''<p>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}
|
||||
|
@ -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 = '<pre>{0}i{1}mages/{0}c{1}hapter1/{0}s{1}cene{0}3{1}.jpg</pre>'.format(
|
||||
'<span style="%s">' % Results.EMPH, '</span>')
|
||||
chars = '<pre style="%s">ics3</pre>' % Results.EMPH
|
||||
'<span style="%s">' % emphasis_style(), '</span>')
|
||||
chars = '<pre style="%s">ics3</pre>' % emphasis_style()
|
||||
|
||||
return _('''<p>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 = '<body>%s</body>' % make_highlighted_text(Results.EMPH, text, positions)
|
||||
text = '<body>%s</body>' % make_highlighted_text(emphasis_style(), text, positions)
|
||||
doc = QTextDocument()
|
||||
c = 'rgb(%d, %d, %d)'%c.getRgb()[:3]
|
||||
doc.setDefaultStyleSheet(' body { color: %s }'%c)
|
||||
|
Loading…
x
Reference in New Issue
Block a user