From 89350cbff49fe1e2d27ac09db427677fe3cc26aa Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Thu, 22 May 2014 16:41:58 +0200 Subject: [PATCH] Emit answered signal from statusbar prompt. This is so we can leave the mode (and hide the command widget) before emitting the answered signal (and possibly ask something again). --- qutebrowser/utils/usertypes.py | 13 +------------ qutebrowser/widgets/statusbar/_prompt.py | 5 +++++ 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/qutebrowser/utils/usertypes.py b/qutebrowser/utils/usertypes.py index 6b948126d..105304075 100644 --- a/qutebrowser/utils/usertypes.py +++ b/qutebrowser/utils/usertypes.py @@ -279,15 +279,4 @@ class Question(QObject): self.default = None self.text = None self.user = None - self._answer = None - - @property - def answer(self): - """Getter for answer so we can define a setter.""" - return self._answer - - @answer.setter - def answer(self, val): - """Setter for answer to emit the answered signal after setting.""" - self._answer = val - self.answered.emit() + self.answer = None diff --git a/qutebrowser/widgets/statusbar/_prompt.py b/qutebrowser/widgets/statusbar/_prompt.py index 633f571e7..1bf46d814 100644 --- a/qutebrowser/widgets/statusbar/_prompt.py +++ b/qutebrowser/widgets/statusbar/_prompt.py @@ -100,14 +100,17 @@ class Prompt(QWidget): self.question.answer = (self.question.user, password) modeman.leave('prompt', 'prompt accept') self.hide_prompt.emit() + self.question.answered.emit() elif self.question.mode == PromptMode.text: # User just entered text. self.question.answer = self._input.text() modeman.leave('prompt', 'prompt accept') + self.question.answered.emit() elif self.question.mode == PromptMode.yesno: # User wants to accept the default of a yes/no question. self.question.answer = self.question.default modeman.leave('yesno', 'yesno accept') + self.question.answered.emit() else: raise ValueError("Invalid question mode!") @@ -120,6 +123,7 @@ class Prompt(QWidget): return self.question.answer = True modeman.leave('yesno', 'yesno accept') + self.question.answered.emit() @cmdutils.register(instance='mainwindow.status.prompt', hide=True, modes=['yesno']) @@ -130,6 +134,7 @@ class Prompt(QWidget): return self.question.answer = False modeman.leave('yesno', 'prompt accept') + self.question.answered.emit() def display(self): """Display the question in self.question in the widget.