finish plugin migartion and clean up main window

This commit is contained in:
Tim Bentley 2018-10-26 20:30:39 +01:00
parent 20dc4f81ed
commit bcd917d360
4 changed files with 16 additions and 18 deletions

View File

@ -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()

View File

@ -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()

View File

@ -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

View File

@ -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