diff --git a/lisp/application.py b/lisp/application.py index be5c9c9e8..a8fd1a4c0 100644 --- a/lisp/application.py +++ b/lisp/application.py @@ -49,6 +49,7 @@ class Application(metaclass=Singleton): def __init__(self, app_conf): self.session_created = Signal() + self.session_initialised = Signal() self.session_before_finalize = Signal() self.__conf = app_conf @@ -142,6 +143,7 @@ def __new_session_dialog(self): self.__load_from_file(dialog.sessionPath) else: self.__new_session(dialog.selected()) + self.session_initialised.emit(self.__session) else: if self.__session is None: # If the user close the dialog, and no layout exists @@ -215,6 +217,8 @@ def __load_from_file(self, session_file): for plugin_name, plugin_config in session_dict['session']['plugins'].items(): self.__session.set_plugin_session_config(plugin_name, plugin_config) + self.session_initialised.emit(self.__session) + # Load cues for cues_dict in session_dict.get("cues", {}): cue_type = cues_dict.pop("_type_", "Undefined") diff --git a/lisp/core/plugin.py b/lisp/core/plugin.py index dfdbd11ac..f21bbba0e 100644 --- a/lisp/core/plugin.py +++ b/lisp/core/plugin.py @@ -37,7 +37,8 @@ def __init__(self, app): """:type app: lisp.application.Application""" self.__app = app - app.session_created.connect(self._on_session_init) + app.session_created.connect(self._on_session_created) + app.session_initialised.connect(self._on_session_initialised) @property def app(self): @@ -47,6 +48,28 @@ def app(self): def finalize(self): """Called when the application is getting closed.""" - def _on_session_init(self): - """Called each time a session is initialised (eg. when a session is created or opened).""" + def _on_session_created(self): + """Called immediately after a session is created. + + In the case of a file load, this gets called before the session + properties and cues are restored. + """ self.SessionConfig = PluginSessionConfig(self) + self.SessionConfig.changed.connect(self._on_session_config_altered) + self.SessionConfig.updated.connect(self._on_session_config_altered) + + def _on_session_initialised(self, _): + """Called once a session is fully initialised. + + For new sessions, there is not much difference between this and `app.session_created` + + For loaded sessions, this is called *after* the various showfile properties have + been set, but *before* the cues are restored. + """ + pass + + def _on_session_config_altered(self, _): + """Called whenever the session config is changed or updated in any way.""" + pass + +