widgets.statusbar.prompter: Use None for self.question instead of _busy.

This commit is contained in:
Florian Bruhin 2014-08-02 17:58:33 +02:00
parent ee1bdacf25
commit 5d5f3c7f87

View File

@ -68,7 +68,6 @@ class Prompter:
self.question = None
self._loops = []
self._queue = deque()
self._busy = False
self._prompt = prompt
def __repr__(self):
@ -86,7 +85,7 @@ class Prompter:
def _get_ctx(self):
"""Get a PromptContext based on the current state."""
if not self._busy:
if self.question is None:
return None
ctx = PromptContext(question=self.question,
text=self._prompt.txt.text(),
@ -106,7 +105,7 @@ class Prompter:
logger.debug("Restoring context {}".format(ctx))
if ctx is None:
self._prompt.hide_prompt.emit()
self._busy = False
self.question = None
return False
self.question = ctx.question
self._prompt.txt.setText(ctx.text)
@ -154,7 +153,6 @@ class Prompter:
raise ValueError("Invalid prompt mode!")
self._prompt.lineedit.setFocus()
self._prompt.show_prompt.emit()
self._busy = True
return mode
@pyqtSlot(KeyMode)
@ -165,9 +163,9 @@ class Prompter:
self._prompt.lineedit.clear()
self._prompt.lineedit.setEchoMode(QLineEdit.Normal)
self._prompt.hide_prompt.emit()
self._busy = False
if self.question.answer is None and not self.question.is_aborted:
self.question.cancel()
self.question = None
@cmdutils.register(instance='mainwindow.status.prompt.prompter', hide=True,
modes=[KeyMode.prompt])
@ -247,7 +245,7 @@ class Prompter:
logger.debug("Asking question {}, blocking {}, loops {}, queue "
"{}".format(question, blocking, self._loops, self._queue))
if self._busy and not blocking:
if self.question is not None and not blocking:
# We got an async question, but we're already busy with one, so we
# just queue it up for later.
logger.debug("Adding {} to queue.".format(question))