remove plugin helpers

This commit is contained in:
Tim Bentley 2013-01-23 21:05:25 +00:00
parent 25eb8ae8e8
commit be6977a1a3
16 changed files with 32 additions and 53 deletions

View File

@ -39,8 +39,7 @@ import Queue
from PyQt4 import QtCore
from openlp.core.lib import resize_image, image_to_byte, Receiver, Registry
from openlp.core.ui import ScreenList
from openlp.core.lib import resize_image, image_to_byte, Receiver, Registry, ScreenList
log = logging.getLogger(__name__)

View File

@ -470,7 +470,7 @@ class MediaManagerItem(QtGui.QWidget):
serviceItem = self.buildServiceItem()
if serviceItem:
serviceItem.from_plugin = True
self.plugin.previewController.addServiceItem(serviceItem)
self.preview_controller.addServiceItem(serviceItem)
if keepFocus:
self.listView.setFocus()
@ -496,7 +496,7 @@ class MediaManagerItem(QtGui.QWidget):
serviceItem.from_plugin = True
if remote:
serviceItem.will_auto_start = True
self.plugin.liveController.addServiceItem(serviceItem)
self.live_controller.addServiceItem(serviceItem)
def createItemFromId(self, item_id):
item = QtGui.QListWidgetItem()
@ -511,7 +511,7 @@ class MediaManagerItem(QtGui.QWidget):
QtGui.QMessageBox.information(self, UiStrings().NISp,
translate('OpenLP.MediaManagerItem', 'You must select one or more items to add.'))
else:
# Is it posssible to process multiple list items to generate
# Is it possible to process multiple list items to generate
# multiple service items?
if self.singleServiceItem or self.remoteTriggered:
log.debug(u'%s Add requested', self.plugin.name)
@ -525,7 +525,7 @@ class MediaManagerItem(QtGui.QWidget):
serviceItem = self.buildServiceItem(item, True, remote=remote, context=ServiceItemContext.Service)
if serviceItem:
serviceItem.from_plugin = False
self.plugin.serviceManager.addServiceItem(serviceItem, replace=replace)
self.service_manager.addServiceItem(serviceItem, replace=replace)
def onAddEditClick(self):
"""
@ -542,7 +542,7 @@ class MediaManagerItem(QtGui.QWidget):
translate('OpenLP.MediaManagerItem', 'You must select an existing service item to add to.'))
elif self.plugin.name == serviceItem.name:
self.generateSlideData(serviceItem)
self.plugin.serviceManager.addServiceItem(serviceItem, replace=True)
self.service_manager.addServiceItem(serviceItem, replace=True)
else:
# Turn off the remote edit update message indicator
QtGui.QMessageBox.information(self, translate('OpenLP.MediaManagerItem', 'Invalid Service Item'),

View File

@ -118,8 +118,7 @@ class Plugin(QtCore.QObject):
"""
log.info(u'loaded')
def __init__(self, name, default_settings, plugin_helpers=None, media_item_class=None,
settings_tab_class=None, version=None):
def __init__(self, name, default_settings, media_item_class=None, settings_tab_class=None, version=None):
"""
This is the constructor for the plugin object. This provides an easy
way for descendent plugins to populate common data. This method *must*
@ -135,9 +134,6 @@ class Plugin(QtCore.QObject):
``default_settings``
A dict containing the plugin's settings. The value to each key is the default value to be used.
``plugin_helpers``
Defaults to *None*. A list of helper objects.
``media_item_class``
The class name of the plugin's media item.
@ -165,8 +161,6 @@ class Plugin(QtCore.QObject):
self.mediaItem = None
self.weight = 0
self.status = PluginStatus.Inactive
self.previewController = plugin_helpers[u'preview']
self.liveController = plugin_helpers[u'live']
# Add the default status to the default settings.
default_settings[name + u'/status'] = PluginStatus.Inactive
default_settings[name + u'/last directory'] = u''

View File

@ -62,7 +62,7 @@ class PluginManager(object):
self.plugins = []
log.info(u'Plugin manager Initialised')
def find_plugins(self, plugin_dir, plugin_helpers):
def find_plugins(self, plugin_dir):
"""
Scan the directory ``plugin_dir`` for objects inheriting from the
``Plugin`` class.
@ -70,9 +70,6 @@ class PluginManager(object):
``plugin_dir``
The directory to scan.
``plugin_helpers``
A list of helper objects to pass to the plugins.
"""
log.info(u'Finding plugins')
startdepth = len(os.path.abspath(plugin_dir).split(os.sep))
@ -110,7 +107,7 @@ class PluginManager(object):
plugin_objects = []
for p in plugin_classes:
try:
plugin = p(plugin_helpers)
plugin = p()
log.debug(u'Loaded plugin %s', unicode(p))
plugin_objects.append(plugin)
except TypeError:

View File

@ -301,7 +301,7 @@ class MainDisplay(Display):
"""
log.debug(u'image to display')
image = self.image_manager.getImageBytes(path, ImageSource.ImagePlugin)
self.controller.mediaController.media_reset(self.controller)
self.controller.media_controller.media_reset(self.controller)
self.displayImage(image)
def displayImage(self, image):

View File

@ -482,7 +482,6 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
# Set up the path with plugins
plugin_path = AppLocation.get_directory(AppLocation.PluginsDir)
self.pluginManager = PluginManager(plugin_path)
self.pluginHelpers = {}
self.imageManager = ImageManager()
# Set up the interface
self.setupUi(self)
@ -547,17 +546,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
# Define the media Dock Manager
self.mediaDockManager = MediaDockManager(self.mediaToolBox)
log.info(u'Load Plugins')
# make the controllers available to the plugins
self.pluginHelpers[u'preview'] = self.previewController
self.pluginHelpers[u'live'] = self.liveController
self.pluginHelpers[u'renderer'] = self.renderer
self.pluginHelpers[u'service'] = self.serviceManagerContents
self.pluginHelpers[u'settings form'] = self.settingsForm
self.pluginHelpers[u'toolbox'] = self.mediaDockManager
self.pluginHelpers[u'pluginmanager'] = self.pluginManager
self.pluginHelpers[u'formparent'] = self
self.pluginHelpers[u'mediacontroller'] = self.mediaController
self.pluginManager.find_plugins(plugin_path, self.pluginHelpers)
self.pluginManager.find_plugins(plugin_path)
# 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

View File

@ -35,9 +35,9 @@ from collections import deque
from PyQt4 import QtCore, QtGui
from openlp.core.lib import OpenLPToolbar, Receiver, ItemCapabilities, translate, build_icon, build_html, \
ServiceItem, ImageSource, SlideLimits, ServiceItemAction, Settings, Registry, UiStrings
from openlp.core.ui import HideMode, MainDisplay, Display, ScreenList, DisplayControllerType
from openlp.core.lib.ui import UiStrings, create_action
ServiceItem, ImageSource, SlideLimits, ServiceItemAction, Settings, Registry, UiStrings, ScreenList
from openlp.core.ui import HideMode, MainDisplay, Display, DisplayControllerType
from openlp.core.lib.ui import create_action
from openlp.core.utils.actions import ActionList, CategoryOrder
log = logging.getLogger(__name__)

View File

@ -128,8 +128,8 @@ __default_settings__ = {
class AlertsPlugin(Plugin):
log.info(u'Alerts Plugin loaded')
def __init__(self, plugin_helpers):
Plugin.__init__(self, u'alerts', __default_settings__, plugin_helpers, settings_tab_class=AlertsTab)
def __init__(self):
Plugin.__init__(self, u'alerts', __default_settings__, settings_tab_class=AlertsTab)
self.weight = -3
self.iconPath = u':/plugins/plugin_alerts.png'
self.icon = build_icon(self.iconPath)

View File

@ -68,8 +68,8 @@ __default_settings__ = {
class BiblePlugin(Plugin):
log.info(u'Bible Plugin loaded')
def __init__(self, plugin_helpers):
Plugin.__init__(self, u'bibles', __default_settings__, plugin_helpers, BibleMediaItem, BiblesTab)
def __init__(self):
Plugin.__init__(self, u'bibles', __default_settings__, BibleMediaItem, BiblesTab)
self.weight = -9
self.iconPath = u':/plugins/plugin_bibles.png'
self.icon = build_icon(self.iconPath)

View File

@ -60,8 +60,8 @@ class CustomPlugin(Plugin):
"""
log.info(u'Custom Plugin loaded')
def __init__(self, plugin_helpers):
Plugin.__init__(self, u'custom', __default_settings__, plugin_helpers, CustomMediaItem, CustomTab)
def __init__(self):
Plugin.__init__(self, u'custom', __default_settings__, CustomMediaItem, CustomTab)
self.weight = -5
self.manager = Manager(u'custom', init_schema)
self.iconPath = u':/plugins/plugin_custom.png'

View File

@ -45,8 +45,8 @@ __default_settings__ = {
class ImagePlugin(Plugin):
log.info(u'Image Plugin loaded')
def __init__(self, plugin_helpers):
Plugin.__init__(self, u'images', __default_settings__, plugin_helpers, ImageMediaItem, ImageTab)
def __init__(self):
Plugin.__init__(self, u'images', __default_settings__, ImageMediaItem, ImageTab)
self.weight = -7
self.iconPath = u':/plugins/plugin_images.png'
self.icon = build_icon(self.iconPath)

View File

@ -46,8 +46,8 @@ __default_settings__ = {
class MediaPlugin(Plugin):
log.info(u'%s MediaPlugin loaded', __name__)
def __init__(self, plugin_helpers):
Plugin.__init__(self, u'media', __default_settings__, plugin_helpers, MediaMediaItem)
def __init__(self):
Plugin.__init__(self, u'media', __default_settings__, MediaMediaItem)
self.weight = -6
self.iconPath = u':/plugins/plugin_media.png'
self.icon = build_icon(self.iconPath)

View File

@ -59,13 +59,13 @@ class PresentationPlugin(Plugin):
"""
log = logging.getLogger(u'PresentationPlugin')
def __init__(self, plugin_helpers):
def __init__(self):
"""
PluginPresentation constructor.
"""
log.debug(u'Initialised')
self.controllers = {}
Plugin.__init__(self, u'presentations', __default_settings__, plugin_helpers, __default_settings__)
Plugin.__init__(self, u'presentations', __default_settings__, __default_settings__)
self.weight = -8
self.iconPath = u':/plugins/plugin_presentations.png'
self.icon = build_icon(self.iconPath)

View File

@ -44,11 +44,11 @@ __default_settings__ = {
class RemotesPlugin(Plugin):
log.info(u'Remote Plugin loaded')
def __init__(self, plugin_helpers):
def __init__(self):
"""
remotes constructor
"""
Plugin.__init__(self, u'remotes', __default_settings__, plugin_helpers, settings_tab_class=RemoteTab)
Plugin.__init__(self, u'remotes', __default_settings__, settings_tab_class=RemoteTab)
self.iconPath = u':/plugins/plugin_remote.png'
self.icon = build_icon(self.iconPath)
self.weight = -1

View File

@ -73,11 +73,11 @@ class SongsPlugin(Plugin):
"""
log.info(u'Song Plugin loaded')
def __init__(self, plugin_helpers):
def __init__(self):
"""
Create and set up the Songs plugin.
"""
Plugin.__init__(self, u'songs', __default_settings__, plugin_helpers, SongMediaItem, SongsTab)
Plugin.__init__(self, u'songs', __default_settings__, SongMediaItem, SongsTab)
self.manager = Manager(u'songs', init_schema, upgrade_mod=upgrade)
self.weight = -10
self.iconPath = u':/plugins/plugin_songs.png'

View File

@ -60,8 +60,8 @@ __default_settings__ = {
class SongUsagePlugin(Plugin):
log.info(u'SongUsage Plugin loaded')
def __init__(self, plugin_helpers):
Plugin.__init__(self, u'songusage', __default_settings__, plugin_helpers)
def __init__(self):
Plugin.__init__(self, u'songusage', __default_settings__)
self.manager = Manager(u'songusage', init_schema, upgrade_mod=upgrade)
self.weight = -4
self.icon = build_icon(u':/plugins/plugin_songusage.png')