Start fixing foo
This commit is contained in:
parent
0d037c74d4
commit
4cdf4fc45f
@ -262,6 +262,7 @@ 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()
|
||||||
@ -270,6 +271,7 @@ 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:
|
||||||
|
@ -36,7 +36,7 @@ class Prompt(QWidget):
|
|||||||
|
|
||||||
Attributes:
|
Attributes:
|
||||||
question: A Question object with the question to be asked to the user.
|
question: A Question object with the question to be asked to the user.
|
||||||
loops: A list of local EventLoops to spin into in exec_.
|
loops: A list of local EventLoops to spin into in _spin.
|
||||||
_hbox: The QHBoxLayout used to display the text and prompt.
|
_hbox: The QHBoxLayout used to display the text and prompt.
|
||||||
_txt: The TextBase instance (QLabel) used to display the prompt text.
|
_txt: The TextBase instance (QLabel) used to display the prompt text.
|
||||||
_input: The MinimalLineEdit instance (QLineEdit) used for the input.
|
_input: The MinimalLineEdit instance (QLineEdit) used for the input.
|
||||||
@ -65,15 +65,22 @@ class Prompt(QWidget):
|
|||||||
self._input = MinimalLineEdit()
|
self._input = MinimalLineEdit()
|
||||||
self._hbox.addWidget(self._input)
|
self._hbox.addWidget(self._input)
|
||||||
|
|
||||||
|
self._old_input = self._input.text()
|
||||||
|
self._old_echo_mode = self._input.echoMode()
|
||||||
|
self._old_text = self._txt.text()
|
||||||
|
self._old_visible = None
|
||||||
|
self.visible = False
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return '<{}>'.format(self.__class__.__name__)
|
return '<{}>'.format(self.__class__.__name__)
|
||||||
|
|
||||||
def on_mode_left(self, mode):
|
def on_mode_left(self, mode):
|
||||||
"""Clear and reset input when the mode was left."""
|
"""Clear and reset input when the mode was left."""
|
||||||
if mode in ('prompt', 'yesno'):
|
if mode in ('prompt', 'yesno'):
|
||||||
self._txt.setText('')
|
self._txt.setText(self._old_text)
|
||||||
self._input.clear()
|
self._input.setText(self._old_input)
|
||||||
self._input.setEchoMode(QLineEdit.Normal)
|
self._input.setEchoMode(self._old_echo_mode)
|
||||||
|
if not self._old_visible:
|
||||||
self.hide_prompt.emit()
|
self.hide_prompt.emit()
|
||||||
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()
|
||||||
@ -146,7 +153,7 @@ class Prompt(QWidget):
|
|||||||
|
|
||||||
Args:
|
Args:
|
||||||
question: The Question object to ask.
|
question: The Question object to ask.
|
||||||
blocking: If True, exec_ is called and the result is returned.
|
blocking: If True, _spin is called and the result is returned.
|
||||||
|
|
||||||
Return:
|
Return:
|
||||||
The answer of the user when blocking=True.
|
The answer of the user when blocking=True.
|
||||||
@ -155,6 +162,10 @@ class Prompt(QWidget):
|
|||||||
Raise:
|
Raise:
|
||||||
ValueError if the set PromptMode is invalid.
|
ValueError if the set PromptMode is invalid.
|
||||||
"""
|
"""
|
||||||
|
self._old_input = self._input.text()
|
||||||
|
self._old_echo_mode = self._input.echoMode()
|
||||||
|
self._old_text = self._txt.text()
|
||||||
|
self._old_visible = self.visible
|
||||||
self.question = question
|
self.question = question
|
||||||
if question.mode == PromptMode.yesno:
|
if question.mode == PromptMode.yesno:
|
||||||
if question.default is None:
|
if question.default is None:
|
||||||
@ -189,15 +200,7 @@ class Prompt(QWidget):
|
|||||||
question.aborted.connect(lambda: modeman.maybe_leave(mode, 'aborted'))
|
question.aborted.connect(lambda: modeman.maybe_leave(mode, 'aborted'))
|
||||||
modeman.enter(mode, 'question asked')
|
modeman.enter(mode, 'question asked')
|
||||||
if blocking:
|
if blocking:
|
||||||
return self.exec_()
|
loop = EventLoop()
|
||||||
|
|
||||||
def exec_(self):
|
|
||||||
"""Local eventloop to spin in for a blocking question.
|
|
||||||
|
|
||||||
Return:
|
|
||||||
The answer to the question. No, it's not always 42.
|
|
||||||
"""
|
|
||||||
loop = EventLoop(self)
|
|
||||||
self.loops.append(loop)
|
self.loops.append(loop)
|
||||||
loop.destroyed.connect(lambda: self.loops.remove(loop))
|
loop.destroyed.connect(lambda: self.loops.remove(loop))
|
||||||
self.question.answered.connect(loop.quit)
|
self.question.answered.connect(loop.quit)
|
||||||
|
Loading…
Reference in New Issue
Block a user