Edit book: Fix saved search dialog causing high CPU usage

This commit is contained in:
Kovid Goyal 2014-04-28 16:34:24 +05:30
parent 47b6df13d0
commit 77a58c8511

View File

@ -84,6 +84,11 @@ class WhereBox(QComboBox):
<dd>Search only within the marked text in the currently opened file. You can mark text using the Search menu.</dd>
</dl>'''))
self.emphasize = emphasize
self.ofont = QFont(self.font())
if emphasize:
f = self.emph_font = QFont(self.ofont)
f.setBold(True), f.setItalic(True)
self.setFont(f)
@dynamic_property
def where(self):
@ -94,16 +99,16 @@ class WhereBox(QComboBox):
self.setCurrentIndex({v:k for k, v in wm.iteritems()}[val])
return property(fget=fget, fset=fset)
def paintEvent(self, ev):
def showPopup(self):
# 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)
self.setFont(self.ofont)
QComboBox.showPopup(self)
def hidePopup(self):
if self.emphasize:
self.setFont(ofont)
self.setFont(self.emph_font)
QComboBox.hidePopup(self)
class DirectionBox(QComboBox):