From f59f8cac6c4329168ecc08e43ce97e59f09be397 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Sun, 13 Apr 2014 22:11:47 +0200 Subject: [PATCH] Clear completion model after an item is selected --- TODO | 1 - qutebrowser/widgets/completion.py | 6 ++++++ qutebrowser/widgets/mainwindow.py | 2 ++ qutebrowser/widgets/statusbar.py | 5 +++++ 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/TODO b/TODO index 3be09917d..b44b1cb3a 100644 --- a/TODO +++ b/TODO @@ -7,7 +7,6 @@ New config TODO Bugs ==== -- Tabbing to a command, then executing it with an error (e.g. :set) keeps the completion position Underlines aren't displayed correctly in completion widget All kind of FIXMEs Weird font rendering diff --git a/qutebrowser/widgets/completion.py b/qutebrowser/widgets/completion.py index efd5b9f43..67f148f57 100644 --- a/qutebrowser/widgets/completion.py +++ b/qutebrowser/widgets/completion.py @@ -275,6 +275,12 @@ class CompletionView(QTreeView): self._ignore_next = True self.change_completed_part.emit(data) + @pyqtSlot() + def on_clear_completion_selection(self): + """Clear the selection model when an item is activated.""" + self.selectionModel().clearSelection() + self.selectionModel().clearCurrentIndex() + class _CompletionItemDelegate(QStyledItemDelegate): diff --git a/qutebrowser/widgets/mainwindow.py b/qutebrowser/widgets/mainwindow.py index 6e08bef9c..8053695c9 100644 --- a/qutebrowser/widgets/mainwindow.py +++ b/qutebrowser/widgets/mainwindow.py @@ -86,6 +86,8 @@ class MainWindow(QWidget): self.tabs.cur_url_changed.connect(self.status.url.set_url) self.tabs.cur_link_hovered.connect(self.status.url.set_hover_url) self.status.cmd.esc_pressed.connect(self.tabs.setFocus) + self.status.cmd.clear_completion_selection.connect( + self.completion.on_clear_completion_selection) self.status.cmd.hide_completion.connect(self.completion.hide) self.status.cmd.textChanged.connect( self.completion.on_cmd_text_changed) diff --git a/qutebrowser/widgets/statusbar.py b/qutebrowser/widgets/statusbar.py index 6fa7a8105..94a979c2c 100644 --- a/qutebrowser/widgets/statusbar.py +++ b/qutebrowser/widgets/statusbar.py @@ -227,6 +227,8 @@ class _Command(QLineEdit): esc_pressed: Emitted when the escape key was pressed. tab_pressed: Emitted when the tab key was pressed. arg: Whether shift has been pressed. + clear_completion_selection: Emitted before the completion widget is + hidden. hide_completion: Emitted when the completion widget should be hidden. show_cmd: Emitted when command input should be shown. hide_cmd: Emitted when command input can be hidden. @@ -239,6 +241,7 @@ class _Command(QLineEdit): got_search_rev = pyqtSignal(str) esc_pressed = pyqtSignal() tab_pressed = pyqtSignal(bool) + clear_completion_selection = pyqtSignal() hide_completion = pyqtSignal() show_cmd = pyqtSignal() hide_cmd = pyqtSignal() @@ -393,6 +396,7 @@ class _Command(QLineEdit): e: The QFocusEvent. Emit: + clear_completion_selection: Always emitted. hide_completion: Always emitted so the completion is hidden. """ if e.reason() in [Qt.MouseFocusReason, Qt.TabFocusReason, @@ -400,6 +404,7 @@ class _Command(QLineEdit): self.setText('') self._histbrowse_stop() self.hide_cmd.emit() + self.clear_completion_selection.emit() self.hide_completion.emit() super().focusOutEvent(e)