diff --git a/src/calibre/gui2/search_box.py b/src/calibre/gui2/search_box.py index e4073a01c9..99d435c913 100644 --- a/src/calibre/gui2/search_box.py +++ b/src/calibre/gui2/search_box.py @@ -76,7 +76,10 @@ class SearchBox2(QComboBox): # {{{ c.setCompletionMode(c.PopupCompletion) c.highlighted[QString].connect(self.completer_used) c.activated[QString].connect(self.history_selected) - + self.esc_action = QAction(self) + self.addAction(self.esc_action) + self.esc_action.setShortcut(QKeySequence(Qt.Key_Escape)) + self.esc_action.triggered.connect(self.esc) self.line_edit.key_pressed.connect(self.key_pressed, type=Qt.DirectConnection) self.activated.connect(self.history_selected) self.setEditable(True) @@ -91,6 +94,9 @@ class SearchBox2(QComboBox): # {{{ self._in_a_search = False self.tool_tip_text = self.toolTip() + def esc(self, *args): + self.clear() + def initialize(self, opt_name, colorize=False, help_text=_('Search')): self.as_you_type = config['search_as_you_type'] self.opt_name = opt_name