From 544b4648e115ccda84344bf2aec0dde18d661973 Mon Sep 17 00:00:00 2001 From: Charles Haley <> Date: Thu, 17 Jun 2010 11:08:31 +0100 Subject: [PATCH] Fix bug #5856 --- src/calibre/gui2/search_box.py | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/calibre/gui2/search_box.py b/src/calibre/gui2/search_box.py index f34c52d221..848c3f2238 100644 --- a/src/calibre/gui2/search_box.py +++ b/src/calibre/gui2/search_box.py @@ -90,14 +90,18 @@ class SearchBox2(QComboBox): self.help_text = help_text self.colorize = colorize self.clear_to_help() - self.connect(self, SIGNAL('editTextChanged(QString)'), self.text_edited_slot) def normalize_state(self): - self.setEditText('') - self.line_edit.setStyleSheet( - 'QLineEdit { color: black; background-color: %s; }' % - self.normal_background) - self.help_state = False + if self.help_state: + self.setEditText('') + self.line_edit.setStyleSheet( + 'QLineEdit { color: black; background-color: %s; }' % + self.normal_background) + self.help_state = False + else: + self.line_edit.setStyleSheet( + 'QLineEdit { color: black; background-color: %s; }' % + self.normal_background) def clear_to_help(self): if self.help_state: @@ -131,17 +135,15 @@ class SearchBox2(QComboBox): self.line_edit.setStyleSheet('QLineEdit { color: black; background-color: %s; }' % col) def key_pressed(self, event): - if self.help_state: - self.normalize_state() + self.normalize_state() if not self.as_you_type: if event.key() in (Qt.Key_Return, Qt.Key_Enter): self.do_search() + else: + self.timer = self.startTimer(self.__class__.INTERVAL) def mouse_released(self, event): - if self.help_state: - self.normalize_state() - - def text_edited_slot(self, text): + self.normalize_state() if self.as_you_type: self.timer = self.startTimer(self.__class__.INTERVAL)