yubioath-gui: select the contents of the search box when focused

When we hit the find shortcut, select the entire contents of the search
box. This matches the behavior of e.g. Google Chrome's search box.

Signed-off-by: Steven Noonan <steven@uplinklabs.net>
This commit is contained in:
Steven Noonan 2016-09-13 12:29:33 -07:00
parent d3eaf877cd
commit 385ea3480e

View File

@ -98,7 +98,7 @@ class SearchBox(QtGui.QWidget):
self._shortcut_focus = QtGui.QShortcut(
QtGui.QKeySequence.Find,
self._lineedit, self._lineedit.setFocus)
self._lineedit, self._set_focus)
self._shortcut_clear = QtGui.QShortcut(
QtGui.QKeySequence(self.tr("Esc")),
self._lineedit, self._lineedit.clear)
@ -108,6 +108,10 @@ class SearchBox(QtGui.QWidget):
self._timer.setInterval(300)
self._timer.timeout.connect(self._filter_changed)
def _set_focus(self):
self._lineedit.setFocus()
self._lineedit.selectAll()
def _text_changed(self, query):
self._timer.stop()
self._timer.start()