Rename visible to _busy and make it private.

This commit is contained in:
Florian Bruhin 2014-07-02 06:42:23 +02:00
parent 3f85f63546
commit 5c84616ff4
2 changed files with 6 additions and 6 deletions

View File

@ -262,7 +262,6 @@ class StatusBar(QWidget):
"""Show prompt widget instead of temporary text.""" """Show prompt widget instead of temporary text."""
self.error = False self.error = False
self.prompt_active = True self.prompt_active = True
self.prompt.visible = True
if self._text_pop_timer.isActive(): if self._text_pop_timer.isActive():
self._timer_was_active = True self._timer_was_active = True
self._text_pop_timer.stop() self._text_pop_timer.stop()
@ -271,7 +270,6 @@ class StatusBar(QWidget):
def _hide_prompt_widget(self): def _hide_prompt_widget(self):
"""Show temporary text instead of prompt widget.""" """Show temporary text instead of prompt widget."""
self.prompt_active = False self.prompt_active = False
self.prompt.visible = False
logger.debug("Hiding prompt widget, queue: {}".format( logger.debug("Hiding prompt widget, queue: {}".format(
self._text_queue)) self._text_queue))
if self._timer_was_active: if self._timer_was_active:

View File

@ -74,7 +74,7 @@ class Prompt(QWidget):
self._input = MinimalLineEdit() self._input = MinimalLineEdit()
self._hbox.addWidget(self._input) self._hbox.addWidget(self._input)
self.visible = False self._busy = False
def __repr__(self): def __repr__(self):
return '<{}>'.format(self.__class__.__name__) return '<{}>'.format(self.__class__.__name__)
@ -91,8 +91,7 @@ class Prompt(QWidget):
def _get_ctx(self): def _get_ctx(self):
"""Get a PromptContext based on the current state.""" """Get a PromptContext based on the current state."""
if not self.visible: if not self._busy:
# FIXME do we really use visible here?
return None return None
ctx = PromptContext(question=self.question, text=self._txt.text(), ctx = PromptContext(question=self.question, text=self._txt.text(),
input_text=self._input.text(), input_text=self._input.text(),
@ -111,6 +110,7 @@ class Prompt(QWidget):
logger.debug("Restoring context {}".format(ctx)) logger.debug("Restoring context {}".format(ctx))
if ctx is None: if ctx is None:
self.hide_prompt.emit() self.hide_prompt.emit()
self._busy = False
return False return False
self.question = ctx.question self.question = ctx.question
self._txt.setText(ctx.text) self._txt.setText(ctx.text)
@ -155,6 +155,7 @@ class Prompt(QWidget):
raise ValueError("Invalid prompt mode!") raise ValueError("Invalid prompt mode!")
self._input.setFocus() self._input.setFocus()
self.show_prompt.emit() self.show_prompt.emit()
self._busy = True
return mode return mode
def on_mode_left(self, mode): def on_mode_left(self, mode):
@ -164,6 +165,7 @@ class Prompt(QWidget):
self._input.clear() self._input.clear()
self._input.setEchoMode(QLineEdit.Normal) self._input.setEchoMode(QLineEdit.Normal)
self.hide_prompt.emit() self.hide_prompt.emit()
self._busy = False
if self.question.answer is None and not self.question.is_aborted: if self.question.answer is None and not self.question.is_aborted:
self.question.cancel() self.question.cancel()
@ -246,7 +248,7 @@ class Prompt(QWidget):
logger.debug("Asking question {}, blocking {}, loops {}, queue " logger.debug("Asking question {}, blocking {}, loops {}, queue "
"{}".format(question, blocking, self._loops, self._queue)) "{}".format(question, blocking, self._loops, self._queue))
if self.visible and not blocking: if self._busy and not blocking:
# We got an async question, but we're already busy with one, so we # We got an async question, but we're already busy with one, so we
# just queue it up for later. # just queue it up for later.
logger.debug("Adding to queue") logger.debug("Adding to queue")