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