GwR patch mapping ESC to clear search box

This commit is contained in:
GRiker 2011-01-23 06:46:39 -07:00
parent d7b1b084a4
commit 6eef57563c

View File

@ -76,7 +76,10 @@ class SearchBox2(QComboBox): # {{{
c.setCompletionMode(c.PopupCompletion) c.setCompletionMode(c.PopupCompletion)
c.highlighted[QString].connect(self.completer_used) c.highlighted[QString].connect(self.completer_used)
c.activated[QString].connect(self.history_selected) 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.line_edit.key_pressed.connect(self.key_pressed, type=Qt.DirectConnection)
self.activated.connect(self.history_selected) self.activated.connect(self.history_selected)
self.setEditable(True) self.setEditable(True)
@ -91,6 +94,9 @@ class SearchBox2(QComboBox): # {{{
self._in_a_search = False self._in_a_search = False
self.tool_tip_text = self.toolTip() self.tool_tip_text = self.toolTip()
def esc(self, *args):
self.clear()
def initialize(self, opt_name, colorize=False, help_text=_('Search')): def initialize(self, opt_name, colorize=False, help_text=_('Search')):
self.as_you_type = config['search_as_you_type'] self.as_you_type = config['search_as_you_type']
self.opt_name = opt_name self.opt_name = opt_name