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).
This commit is contained in:
Florian Bruhin 2014-05-22 16:41:58 +02:00
parent f3fd247282
commit 89350cbff4
2 changed files with 6 additions and 12 deletions

View File

@ -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

View File

@ -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.