From 625e3935ed9679157987e185a74aa2d55fe9d9ce Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 7 Apr 2014 09:21:18 +0530 Subject: [PATCH] Edit Book: Saved searches dialog: Make the option to control where to search a little more prominent --- src/calibre/gui2/tweak_book/search.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/calibre/gui2/tweak_book/search.py b/src/calibre/gui2/tweak_book/search.py index df038ef161..7376eeec7c 100644 --- a/src/calibre/gui2/tweak_book/search.py +++ b/src/calibre/gui2/tweak_book/search.py @@ -12,7 +12,7 @@ from collections import OrderedDict from PyQt4.Qt import ( QWidget, QToolBar, Qt, QHBoxLayout, QSize, QIcon, QGridLayout, QLabel, QTimer, - QPushButton, pyqtSignal, QComboBox, QCheckBox, QSizePolicy, QVBoxLayout, + QPushButton, pyqtSignal, QComboBox, QCheckBox, QSizePolicy, QVBoxLayout, QFont, QLineEdit, QToolButton, QListView, QFrame, QApplication, QStyledItemDelegate, QAbstractListModel, QVariant, QFormLayout, QModelIndex, QMenu, QItemSelection) @@ -65,7 +65,7 @@ class HistoryLineEdit(HistoryLineEdit2): class WhereBox(QComboBox): - def __init__(self, parent): + def __init__(self, parent, emphasize=False): QComboBox.__init__(self) self.addItems([_('Current file'), _('All text files'), _('All style files'), _('Selected files'), _('Marked text')]) self.setToolTip('' + _( @@ -83,6 +83,7 @@ class WhereBox(QComboBox):
Marked text
Search only within the marked text in the currently opened file. You can mark text using the Search menu.
''')) + self.emphasize = emphasize @dynamic_property def where(self): @@ -93,6 +94,17 @@ class WhereBox(QComboBox): self.setCurrentIndex({v:k for k, v in wm.iteritems()}[val]) return property(fget=fget, fset=fset) + def paintEvent(self, ev): + # We do it like this so that the popup uses a normal font + if self.emphasize: + ofont = self.font() + f = QFont(ofont) + f.setBold(True), f.setItalic(True) + self.setFont(f) + QComboBox.paintEvent(self, ev) + if self.emphasize: + self.setFont(ofont) + class DirectionBox(QComboBox): def __init__(self, parent): @@ -609,7 +621,7 @@ class SavedSearches(Dialog): d.setFrameStyle(QFrame.HLine) v.addWidget(d) - self.where_box = wb = WhereBox(self) + self.where_box = wb = WhereBox(self, emphasize=True) self.where = SearchWidget.DEFAULT_STATE['where'] v.addWidget(wb) self.direction_box = db = DirectionBox(self)