diff --git a/openlp/core/app.py b/openlp/core/app.py index e929c7924..45bafb0c6 100644 --- a/openlp/core/app.py +++ b/openlp/core/app.py @@ -120,7 +120,6 @@ class OpenLP(QtWidgets.QApplication): Registry().execute('bootstrap_initialise') State().flush_preconditions() Registry().execute('bootstrap_post_set_up') - State().flush_preconditions() Registry().initialise = False self.main_window.show() if can_show_splash: diff --git a/openlp/core/lib/pluginmanager.py b/openlp/core/lib/pluginmanager.py index af83547ba..ccf843fc0 100644 --- a/openlp/core/lib/pluginmanager.py +++ b/openlp/core/lib/pluginmanager.py @@ -24,6 +24,7 @@ Provide plugin management """ import os +from openlp.core.state import State from openlp.core.common import extension_loader from openlp.core.common.applocation import AppLocation from openlp.core.common.mixins import LogMixin, RegistryProperties @@ -97,20 +98,12 @@ class PluginManager(RegistryBase, LogMixin, RegistryProperties): plugin_objects.append(plugin) except TypeError: self.log_exception('Failed to load plugin {plugin}'.format(plugin=str(p))) - plugins_list = sorted(plugin_objects, key=lambda plugin: plugin.weight) - for plugin in plugins_list: - if plugin.check_pre_conditions(): - self.log_debug('Plugin {plugin} active'.format(plugin=str(plugin.name))) - plugin.set_status() - else: - plugin.status = PluginStatus.Disabled - self.plugins.append(plugin) def hook_media_manager(self): """ Create the plugins' media manager items. """ - for plugin in self.plugins: + for plugin in State().list_plugins(): if plugin.status is not PluginStatus.Disabled: plugin.create_media_manager_item() diff --git a/openlp/core/state.py b/openlp/core/state.py index ca3caac38..0cba136ac 100644 --- a/openlp/core/state.py +++ b/openlp/core/state.py @@ -42,6 +42,7 @@ class StateModule(LogMixin): super(StateModule, self).__init__() self.name = None self.order = 0 + self.isPlugin = None self.status = PluginStatus.Inactive self.pass_preconditions = True self.requires = None @@ -66,11 +67,12 @@ class State(LogMixin): def save_settings(self): pass - def add_service(self, name, order, status=PluginStatus.Active, requires=None): + def add_service(self, name, order, isPlugin=False, status=PluginStatus.Active, requires=None): """ Add a module to the array and lod dependancies. There will only be one item per module :param name: Module name :param order: Order fo display + :param isPlugin: Am I a plugin :param status: The active status :param requires: Module name this requires :return: @@ -79,6 +81,7 @@ class State(LogMixin): state = StateModule() state.name = name state.order = order + state.plugin = isPlugin state.status = status state.requires = requires state.required_by = [] @@ -106,6 +109,7 @@ class State(LogMixin): for mods in self.modules: for req in self.modules[mods].required_by: self.modules[req].pass_preconditions = self.modules[mods].pass_preconditions + # plugins_list = sorted(plugin_objects, key=lambda plugin: plugin.weight) def is_module_active(self, name): return self.modules[name].status == PluginStatus.Active @@ -122,3 +126,10 @@ class State(LogMixin): else: mod = self.modules[name].requires return self.modules[mod].pass_preconditions + + def list_plugins(self): + plugins = [] + for mod in self.modules: + if mod.isPlugin: + plugins.append(mod.name) + return plugins diff --git a/openlp/plugins/alerts/alertsplugin.py b/openlp/plugins/alerts/alertsplugin.py index 9f8ee0085..c79025f02 100644 --- a/openlp/plugins/alerts/alertsplugin.py +++ b/openlp/plugins/alerts/alertsplugin.py @@ -147,7 +147,7 @@ class AlertsPlugin(Plugin): self.alert_form = AlertForm(self) register_endpoint(alerts_endpoint) register_endpoint(api_alerts_endpoint) - State().add_service(self.name, self.weight) + State().add_service(self.name, self.weight, isPlugin=True) State().update_pre_conditions(self.name, self.check_pre_conditions()) def add_tools_menu_item(self, tools_menu): diff --git a/openlp/plugins/bibles/bibleplugin.py b/openlp/plugins/bibles/bibleplugin.py index 303e537aa..5ca0f45c8 100644 --- a/openlp/plugins/bibles/bibleplugin.py +++ b/openlp/plugins/bibles/bibleplugin.py @@ -81,7 +81,7 @@ class BiblePlugin(Plugin): self.manager = BibleManager(self) register_endpoint(bibles_endpoint) register_endpoint(api_bibles_endpoint) - State().add_service(self.name, self.weight) + State().add_service(self.name, self.weight, isPlugin=True) State().update_pre_conditions(self.name, self.check_pre_conditions()) def initialise(self): diff --git a/openlp/plugins/custom/customplugin.py b/openlp/plugins/custom/customplugin.py index 299286cb4..21727736d 100644 --- a/openlp/plugins/custom/customplugin.py +++ b/openlp/plugins/custom/customplugin.py @@ -69,7 +69,7 @@ class CustomPlugin(Plugin): self.icon = build_icon(self.icon_path) register_endpoint(custom_endpoint) register_endpoint(api_custom_endpoint) - State().add_service(self.name, self.weight) + State().add_service(self.name, self.weight, isPlugin=True) State().update_pre_conditions(self.name, self.check_pre_conditions()) @staticmethod diff --git a/openlp/plugins/images/imageplugin.py b/openlp/plugins/images/imageplugin.py index adac1fb8e..d890d889c 100644 --- a/openlp/plugins/images/imageplugin.py +++ b/openlp/plugins/images/imageplugin.py @@ -60,7 +60,7 @@ class ImagePlugin(Plugin): self.icon = build_icon(self.icon_path) register_endpoint(images_endpoint) register_endpoint(api_images_endpoint) - State().add_service(self.name, self.weight) + State().add_service(self.name, self.weight, isPlugin=True) State().update_pre_conditions(self.name, self.check_pre_conditions()) @staticmethod diff --git a/openlp/plugins/presentations/presentationplugin.py b/openlp/plugins/presentations/presentationplugin.py index 268151262..2f3132939 100644 --- a/openlp/plugins/presentations/presentationplugin.py +++ b/openlp/plugins/presentations/presentationplugin.py @@ -75,7 +75,7 @@ class PresentationPlugin(Plugin): self.icon = build_icon(self.icon_path) register_endpoint(presentations_endpoint) register_endpoint(api_presentations_endpoint) - State().add_service(self.name, self.weight) + State().add_service(self.name, self.weight, isPlugin=True) State().update_pre_conditions(self.name, self.check_pre_conditions()) def create_settings_tab(self, parent): diff --git a/openlp/plugins/songs/songsplugin.py b/openlp/plugins/songs/songsplugin.py index 356b96f02..084cff83a 100644 --- a/openlp/plugins/songs/songsplugin.py +++ b/openlp/plugins/songs/songsplugin.py @@ -100,7 +100,7 @@ class SongsPlugin(Plugin): self.songselect_form = None register_endpoint(songs_endpoint) register_endpoint(api_songs_endpoint) - State().add_service(self.name, self.weight) + State().add_service(self.name, self.weight, isPlugin=True) State().update_pre_conditions(self.name, self.check_pre_conditions()) def check_pre_conditions(self): diff --git a/openlp/plugins/songusage/songusageplugin.py b/openlp/plugins/songusage/songusageplugin.py index 86227db73..204c0534f 100644 --- a/openlp/plugins/songusage/songusageplugin.py +++ b/openlp/plugins/songusage/songusageplugin.py @@ -67,7 +67,7 @@ class SongUsagePlugin(Plugin): self.weight = -4 self.icon = UiIcons().song_usage self.song_usage_active = False - State().add_service(self.name, self.weight) + State().add_service(self.name, self.weight, isPlugin=True) State().update_pre_conditions(self.name, self.check_pre_conditions()) def check_pre_conditions(self):