From 9c30b2e5a902c5e99e15a16522aadfd51714d7b8 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Tue, 23 Oct 2018 17:43:52 +0100 Subject: [PATCH] More plugin state cleanups --- openlp/core/app.py | 3 ++- openlp/core/common/registry.py | 7 +++++++ openlp/core/lib/plugin.py | 3 +++ openlp/core/lib/pluginmanager.py | 15 +++++++++++++++ openlp/core/ui/mainwindow.py | 10 ---------- 5 files changed, 27 insertions(+), 11 deletions(-) diff --git a/openlp/core/app.py b/openlp/core/app.py index b1077f1b0..e929c7924 100644 --- a/openlp/core/app.py +++ b/openlp/core/app.py @@ -118,6 +118,7 @@ class OpenLP(QtWidgets.QApplication): loader() self.main_window = MainWindow() Registry().execute('bootstrap_initialise') + State().flush_preconditions() Registry().execute('bootstrap_post_set_up') State().flush_preconditions() Registry().initialise = False @@ -136,7 +137,7 @@ class OpenLP(QtWidgets.QApplication): if Settings().value('core/update check'): check_for_update(self.main_window) self.main_window.is_display_blank() - self.main_window.app_startup() + Registry().execute('bootstrap_completion') return self.exec() @staticmethod diff --git a/openlp/core/common/registry.py b/openlp/core/common/registry.py index 0dab36bad..89730b87e 100644 --- a/openlp/core/common/registry.py +++ b/openlp/core/common/registry.py @@ -204,6 +204,7 @@ class RegistryBase(object): Registry().register(de_hump(self.__class__.__name__), self) Registry().register_function('bootstrap_initialise', self.bootstrap_initialise) Registry().register_function('bootstrap_post_set_up', self.bootstrap_post_set_up) + Registry().register_function('bootstrap_completion', self.bootstrap_completion) def bootstrap_initialise(self): """ @@ -216,3 +217,9 @@ class RegistryBase(object): Dummy method to be overridden """ pass + + def bootstrap_completion(self): + """ + Dummy method to be overridden + """ + pass diff --git a/openlp/core/lib/plugin.py b/openlp/core/lib/plugin.py index c47ea5ced..bf99efc80 100644 --- a/openlp/core/lib/plugin.py +++ b/openlp/core/lib/plugin.py @@ -323,6 +323,9 @@ class Plugin(RegistryBase, RegistryProperties): """ return self.text_strings[name] + def set_plugin_text_strings(self): + pass + def set_plugin_ui_text_strings(self, tooltips): """ Called to define all translatable texts of the plugin diff --git a/openlp/core/lib/pluginmanager.py b/openlp/core/lib/pluginmanager.py index 0c8664af5..af83547ba 100644 --- a/openlp/core/lib/pluginmanager.py +++ b/openlp/core/lib/pluginmanager.py @@ -55,6 +55,11 @@ class PluginManager(RegistryBase, LogMixin, RegistryProperties): # hook methods have to happen after find_plugins. Find plugins needs # the controllers hence the hooks have moved from setupUI() to here # Find and insert settings tabs + + def bootstrap_post_set_up(self): + """ + Bootstrap all the plugin manager functions + """ self.hook_settings_tabs() # Find and insert media manager items self.hook_media_manager() @@ -67,6 +72,16 @@ class PluginManager(RegistryBase, LogMixin, RegistryProperties): # Call the initialise method to setup plugins. self.initialise_plugins() + def bootstrap_completion(self): + """ + Give all the plugins a chance to perform some tasks at startup + """ + self.application.process_events() + for plugin in self.plugins: + if plugin.is_active(): + plugin.app_startup() + self.application.process_events() + def find_plugins(self): """ Scan a directory for objects inheriting from the ``Plugin`` class. diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 41eee40db..00baf8e56 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -657,16 +657,6 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow, LogMixin, RegistryPropert self.set_view_mode(False, True, False, False, True, True) self.mode_live_item.setChecked(True) - def app_startup(self): - """ - Give all the plugins a chance to perform some tasks at startup - """ - self.application.process_events() - for plugin in self.plugin_manager.plugins: - if plugin.is_active(): - plugin.app_startup() - self.application.process_events() - def first_time(self): """ Import themes if first time