Revert "Global prompt container"
This reverts commit c23beee6502776dd19c0955b311e8dfb9f1c77ae.
This commit is contained in:
parent
1d6166b474
commit
fdd1147620
@ -372,6 +372,9 @@ def _init_modules(args, crash_handler):
|
||||
crash_handler: The CrashHandler instance.
|
||||
"""
|
||||
# pylint: disable=too-many-statements
|
||||
log.init.debug("Initializing prompts...")
|
||||
prompt.init()
|
||||
|
||||
log.init.debug("Initializing save manager...")
|
||||
save_manager = savemanager.SaveManager(qApp)
|
||||
objreg.register('save-manager', save_manager)
|
||||
@ -388,9 +391,6 @@ def _init_modules(args, crash_handler):
|
||||
config.init(qApp)
|
||||
save_manager.init_autosave()
|
||||
|
||||
log.init.debug("Initializing prompts...")
|
||||
prompt.init()
|
||||
|
||||
log.init.debug("Initializing web history...")
|
||||
history.init(qApp)
|
||||
|
||||
|
@ -183,9 +183,13 @@ class MainWindow(QWidget):
|
||||
self._messageview = messageview.MessageView(parent=self)
|
||||
self._add_overlay(self._messageview, self._messageview.update_geometry)
|
||||
|
||||
self._add_overlay(prompt.prompt_container,
|
||||
prompt.prompt_container.update_geometry,
|
||||
self._prompt_container = prompt.PromptContainer(self.win_id, self)
|
||||
self._add_overlay(self._prompt_container,
|
||||
self._prompt_container.update_geometry,
|
||||
centered=True, padding=10)
|
||||
objreg.register('prompt-container', self._prompt_container,
|
||||
scope='window', window=self.win_id)
|
||||
self._prompt_container.hide()
|
||||
|
||||
log.init.debug("Initializing modes...")
|
||||
modeman.init(self.win_id, self)
|
||||
|
@ -292,6 +292,7 @@ class PromptContainer(QWidget):
|
||||
|
||||
Attributes:
|
||||
_layout: The layout used to show prompts in.
|
||||
_win_id: The window ID this object is associated with.
|
||||
|
||||
Signals:
|
||||
update_geometry: Emitted when the geometry should be updated.
|
||||
@ -317,10 +318,11 @@ class PromptContainer(QWidget):
|
||||
"""
|
||||
update_geometry = pyqtSignal()
|
||||
|
||||
def __init__(self, parent=None):
|
||||
def __init__(self, win_id, parent=None):
|
||||
super().__init__(parent)
|
||||
self._layout = QVBoxLayout(self)
|
||||
self._layout.setContentsMargins(10, 10, 10, 10)
|
||||
self._win_id = win_id
|
||||
|
||||
self.setObjectName('PromptContainer')
|
||||
self.setAttribute(Qt.WA_StyledBackground, True)
|
||||
@ -330,7 +332,7 @@ class PromptContainer(QWidget):
|
||||
prompt_queue.show_prompt.connect(self._on_show_prompt)
|
||||
|
||||
def __repr__(self):
|
||||
return utils.get_repr(self)
|
||||
return utils.get_repr(self, win_id=self._win_id)
|
||||
|
||||
@pyqtSlot(object)
|
||||
def _on_show_prompt(self, prompt):
|
||||
@ -349,11 +351,10 @@ class PromptContainer(QWidget):
|
||||
self.hide()
|
||||
return
|
||||
|
||||
# FIXME no win-id
|
||||
# prompt.question.aborted.connect(
|
||||
# lambda: modeman.maybe_leave(self._win_id, prompt.KEY_MODE,
|
||||
# 'aborted'))
|
||||
# modeman.enter(self._win_id, prompt.KEY_MODE, 'question asked')
|
||||
prompt.question.aborted.connect(
|
||||
lambda: modeman.maybe_leave(self._win_id, prompt.KEY_MODE,
|
||||
'aborted'))
|
||||
modeman.enter(self._win_id, prompt.KEY_MODE, 'question asked')
|
||||
|
||||
self.setSizePolicy(prompt.sizePolicy())
|
||||
self._layout.addWidget(prompt)
|
||||
@ -365,8 +366,7 @@ class PromptContainer(QWidget):
|
||||
@pyqtSlot(usertypes.KeyMode)
|
||||
def _on_prompt_done(self, key_mode):
|
||||
"""Leave the prompt mode in this window if a question was answered."""
|
||||
# FIXME no win-id
|
||||
#modeman.maybe_leave(self._win_id, key_mode, ':prompt-accept')
|
||||
modeman.maybe_leave(self._win_id, key_mode, ':prompt-accept')
|
||||
|
||||
|
||||
class LineEdit(QLineEdit):
|
||||
@ -752,9 +752,8 @@ class AlertPrompt(_BasePrompt):
|
||||
|
||||
|
||||
def init():
|
||||
global prompt_queue, prompt_container
|
||||
global prompt_queue
|
||||
prompt_queue = PromptQueue()
|
||||
prompt_container = PromptContainer()
|
||||
objreg.register('prompt-queue', prompt_queue) # for commands
|
||||
message.global_bridge.ask_question.connect(
|
||||
prompt_queue.ask_question, Qt.DirectConnection)
|
||||
|
Loading…
Reference in New Issue
Block a user