Register prompt per window

This commit is contained in:
Florian Bruhin 2014-09-28 22:44:12 +02:00
parent cc0e164dcf
commit 2dea47b162
2 changed files with 6 additions and 6 deletions

View File

@ -55,7 +55,7 @@ class Prompt(QWidget):
def __init__(self, win_id, parent=None): def __init__(self, win_id, parent=None):
super().__init__(parent) super().__init__(parent)
objreg.register('prompt', self) objreg.register('prompt', self, scope='window', window=win_id)
self._hbox = QHBoxLayout(self) self._hbox = QHBoxLayout(self)
self._hbox.setContentsMargins(0, 0, 0, 0) self._hbox.setContentsMargins(0, 0, 0, 0)
self._hbox.setSpacing(5) self._hbox.setSpacing(5)

View File

@ -89,7 +89,7 @@ class Prompter:
"""Get a PromptContext based on the current state.""" """Get a PromptContext based on the current state."""
if not self._busy: if not self._busy:
return None return None
prompt = objreg.get('prompt') prompt = objreg.get('prompt', scope='window', window=self._win_id)
ctx = PromptContext(question=self._question, ctx = PromptContext(question=self._question,
text=prompt.txt.text(), text=prompt.txt.text(),
input_text=prompt.lineedit.text(), input_text=prompt.lineedit.text(),
@ -106,7 +106,7 @@ class Prompter:
Return: True if a context was restored, False otherwise. Return: True if a context was restored, False otherwise.
""" """
log.statusbar.debug("Restoring context {}".format(ctx)) log.statusbar.debug("Restoring context {}".format(ctx))
prompt = objreg.get('prompt') prompt = objreg.get('prompt', scope='window', window=self._win_id)
if ctx is None: if ctx is None:
prompt.hide_prompt.emit() prompt.hide_prompt.emit()
self._busy = False self._busy = False
@ -127,7 +127,7 @@ class Prompter:
Raise: Raise:
ValueError if the set PromptMode is invalid. ValueError if the set PromptMode is invalid.
""" """
prompt = objreg.get('prompt') prompt = objreg.get('prompt', scope='window', window=self._win_id)
if self._question.mode == usertypes.PromptMode.yesno: if self._question.mode == usertypes.PromptMode.yesno:
if self._question.default is None: if self._question.default is None:
suffix = "" suffix = ""
@ -181,7 +181,7 @@ class Prompter:
@pyqtSlot(usertypes.KeyMode) @pyqtSlot(usertypes.KeyMode)
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."""
prompt = objreg.get('prompt') prompt = objreg.get('prompt', scope='window', window=self._win_id)
if mode in (usertypes.KeyMode.prompt, usertypes.KeyMode.yesno): if mode in (usertypes.KeyMode.prompt, usertypes.KeyMode.yesno):
prompt.txt.setText('') prompt.txt.setText('')
prompt.lineedit.clear() prompt.lineedit.clear()
@ -202,7 +202,7 @@ class Prompter:
This executes the next action depending on the question mode, e.g. asks This executes the next action depending on the question mode, e.g. asks
for the password or leaves the mode. for the password or leaves the mode.
""" """
prompt = objreg.get('prompt') prompt = objreg.get('prompt', scope='window', window=self._win_id)
if (self._question.mode == usertypes.PromptMode.user_pwd and if (self._question.mode == usertypes.PromptMode.user_pwd and
self._question.user is None): self._question.user is None):
# User just entered an username # User just entered an username