Fix completion

This commit is contained in:
Florian Bruhin 2014-05-22 08:40:36 +02:00
parent ecc838d02c
commit e7d9a3dc88
3 changed files with 9 additions and 5 deletions

View File

@ -424,7 +424,7 @@ class QuteBrowser(QApplication):
cmd.clear_completion_selection.connect( cmd.clear_completion_selection.connect(
completion.on_clear_completion_selection) completion.on_clear_completion_selection)
cmd.hide_completion.connect(completion.hide) cmd.hide_completion.connect(completion.hide)
cmd.textEdited.connect(completion.on_cmd_text_changed) cmd.update_completion.connect(completion.on_update_completion)
completion.change_completed_part.connect(cmd.on_change_completed_part) completion.change_completed_part.connect(cmd.on_change_completed_part)
def _recover_pages(self): def _recover_pages(self):

View File

@ -265,7 +265,7 @@ class CompletionView(QTreeView):
def set_model(self, model): def set_model(self, model):
"""Switch completion to a new model. """Switch completion to a new model.
Called from cmd_text_changed(). Called from on_update_completion().
Args: Args:
model: The model to use. model: The model to use.
@ -285,7 +285,7 @@ class CompletionView(QTreeView):
self._init_command_completion() self._init_command_completion()
@pyqtSlot(str) @pyqtSlot(str)
def on_cmd_text_changed(self, text): def on_update_completion(self, text):
"""Check if completions are available and activate them. """Check if completions are available and activate them.
Slot for the textChanged signal of the statusbar command widget. Slot for the textChanged signal of the statusbar command widget.

View File

@ -50,6 +50,8 @@ class Command(MinimalLineEdit):
clear_completion_selection: Emitted before the completion widget is clear_completion_selection: Emitted before the completion widget is
hidden. hidden.
hide_completion: Emitted when the completion widget should be hidden. hide_completion: Emitted when the completion widget should be hidden.
update_completion: Emitted when the completion should be shown/updated.
arg: The new text which was set.
show_cmd: Emitted when command input should be shown. show_cmd: Emitted when command input should be shown.
hide_cmd: Emitted when command input can be hidden. hide_cmd: Emitted when command input can be hidden.
""" """
@ -59,6 +61,7 @@ class Command(MinimalLineEdit):
got_search_rev = pyqtSignal(str) got_search_rev = pyqtSignal(str)
clear_completion_selection = pyqtSignal() clear_completion_selection = pyqtSignal()
hide_completion = pyqtSignal() hide_completion = pyqtSignal()
update_completion = pyqtSignal(str)
show_cmd = pyqtSignal() show_cmd = pyqtSignal()
hide_cmd = pyqtSignal() hide_cmd = pyqtSignal()
@ -72,6 +75,7 @@ class Command(MinimalLineEdit):
self._validator = _CommandValidator(self) self._validator = _CommandValidator(self)
self.setValidator(self._validator) self.setValidator(self._validator)
self.textEdited.connect(self.history.stop) self.textEdited.connect(self.history.stop)
self.textEdited.connect(self.update_completion)
self.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Ignored) self.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Ignored)
@pyqtSlot(str) @pyqtSlot(str)
@ -82,13 +86,13 @@ class Command(MinimalLineEdit):
text: The text to set (string). text: The text to set (string).
Emit: Emit:
textEdited: Emitted if the text changed. update_completion: Emitted if the text changed.
""" """
old_text = self.text() old_text = self.text()
self.setText(text) self.setText(text)
if old_text != text: if old_text != text:
# We want the completion to pop out here. # We want the completion to pop out here.
self.textEdited.emit(text) self.update_completion.emit(text)
self.setFocus() self.setFocus()
self.show_cmd.emit() self.show_cmd.emit()