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:
parent
f3fd247282
commit
89350cbff4
@ -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
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user