From bcd917d3600ffaa840c0137494df9c433f863f85 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Fri, 26 Oct 2018 20:30:39 +0100 Subject: [PATCH] finish plugin migartion and clean up main window --- openlp/core/lib/pluginmanager.py | 8 +++----- openlp/core/loader.py | 11 ++++++++++- openlp/core/ui/mainwindow.py | 10 ---------- openlp/core/ui/pluginform.py | 5 +++-- 4 files changed, 16 insertions(+), 18 deletions(-) diff --git a/openlp/core/lib/pluginmanager.py b/openlp/core/lib/pluginmanager.py index 3203e4f8c..95b470b07 100644 --- a/openlp/core/lib/pluginmanager.py +++ b/openlp/core/lib/pluginmanager.py @@ -90,20 +90,18 @@ class PluginManager(RegistryBase, LogMixin, RegistryProperties): glob_pattern = os.path.join('plugins', '*', '[!.]*plugin.py') extension_loader(glob_pattern) plugin_classes = Plugin.__subclasses__() - plugin_objects = [] for p in plugin_classes: try: - plugin = p() + p() self.log_debug('Loaded plugin {plugin}'.format(plugin=str(p))) - plugin_objects.append(plugin) except TypeError: self.log_exception('Failed to load plugin {plugin}'.format(plugin=str(p))) - def hook_media_manager(self): + @staticmethod + def hook_media_manager(): """ Create the plugins' media manager items. """ - aa = State().list_plugins() for plugin in State().list_plugins(): if plugin.status is not PluginStatus.Disabled: plugin.create_media_manager_item() diff --git a/openlp/core/loader.py b/openlp/core/loader.py index 80c002172..db0493641 100644 --- a/openlp/core/loader.py +++ b/openlp/core/loader.py @@ -20,12 +20,15 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### """ -The :mod:`~openlp.core.commmon.loader` module provides a bootstrap for the common modules +The :mod:`~openlp.core.loader` module provides a bootstrap for the singleton classes """ from openlp.core.state import State from openlp.core.ui.media import MediaController from openlp.core.lib.pluginmanager import PluginManager +from openlp.core.display.renderer import Renderer +from openlp.core.lib.imagemanager import ImageManager +from openlp.core.ui.slidecontroller import LiveController, PreviewController def loader(): @@ -37,3 +40,9 @@ def loader(): State().load_settings() MediaController() PluginManager() + # Set up the path with plugins + ImageManager() + Renderer() + # Create slide controllers + PreviewController() + LiveController() diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 00baf8e56..cbf33f17e 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -41,11 +41,8 @@ from openlp.core.common.mixins import LogMixin, RegistryProperties from openlp.core.common.path import Path, copyfile, create_paths from openlp.core.common.registry import Registry from openlp.core.common.settings import Settings -from openlp.core.display.renderer import Renderer from openlp.core.display.screens import ScreenList -from openlp.core.lib.imagemanager import ImageManager from openlp.core.lib.plugin import PluginStatus -from openlp.core.lib.pluginmanager import PluginManager from openlp.core.lib.ui import create_action from openlp.core.projectors.manager import ProjectorManager from openlp.core.ui.shortcutlistform import ShortcutListForm @@ -54,7 +51,6 @@ from openlp.core.ui.thememanager import ThemeManager from openlp.core.ui.servicemanager import ServiceManager from openlp.core.ui.aboutform import AboutForm from openlp.core.ui.pluginform import PluginForm -from openlp.core.ui.slidecontroller import LiveController, PreviewController from openlp.core.ui.settingsform import SettingsForm from openlp.core.ui.firsttimeform import FirstTimeForm from openlp.core.ui.printserviceform import PrintServiceForm @@ -89,9 +85,6 @@ class Ui_MainWindow(object): self.control_splitter.setOrientation(QtCore.Qt.Horizontal) self.control_splitter.setObjectName('control_splitter') self.main_content_layout.addWidget(self.control_splitter) - # Create slide controllers - PreviewController(self) - LiveController(self) preview_visible = Settings().value('user interface/preview panel') live_visible = Settings().value('user interface/live panel') panel_locked = Settings().value('user interface/lock panel') @@ -505,9 +498,6 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow, LogMixin, RegistryPropert SettingsForm(self) self.formatting_tag_form = FormattingTagForm(self) self.shortcut_form = ShortcutListForm(self) - # Set up the path with plugins - ImageManager() - Renderer() # Set up the interface self.setupUi(self) # Define the media Dock Manager diff --git a/openlp/core/ui/pluginform.py b/openlp/core/ui/pluginform.py index 386d3e5b0..cbaf60527 100644 --- a/openlp/core/ui/pluginform.py +++ b/openlp/core/ui/pluginform.py @@ -26,6 +26,7 @@ import logging from PyQt5 import QtCore, QtWidgets +from openlp.core.state import State from openlp.core.common.i18n import translate from openlp.core.common.mixins import RegistryProperties from openlp.core.lib.plugin import PluginStatus @@ -62,7 +63,7 @@ class PluginForm(QtWidgets.QDialog, Ui_PluginViewDialog, RegistryProperties): self._clear_details() self.programatic_change = True plugin_list_width = 0 - for plugin in self.plugin_manager.plugins: + for plugin in State().list_plugins(): item = QtWidgets.QListWidgetItem(self.plugin_list_widget) # We do this just to make 100% sure the status is an integer as # sometimes when it's loaded from the config, it isn't cast to int. @@ -116,7 +117,7 @@ class PluginForm(QtWidgets.QDialog, Ui_PluginViewDialog, RegistryProperties): return plugin_name_singular = self.plugin_list_widget.currentItem().text().split('(')[0][:-1] self.active_plugin = None - for plugin in self.plugin_manager.plugins: + for plugin in State().list_plugins(): if plugin.name_strings['singular'] == plugin_name_singular: self.active_plugin = plugin break