← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~googol/openlp/plugin-api into lp:openlp

 

Andreas Preikschat has proposed merging lp:~googol/openlp/plugin-api into lp:openlp.

Requested reviews:
  OpenLP Core (openlp-core)

For more details, see:
https://code.launchpad.net/~googol/openlp/plugin-api/+merge/184211

Hello,

- moved things to Plugin class
-- 
https://code.launchpad.net/~googol/openlp/plugin-api/+merge/184211
Your team OpenLP Core is requested to review the proposed merge of lp:~googol/openlp/plugin-api into lp:openlp.
=== modified file 'openlp/core/lib/plugin.py'
--- openlp/core/lib/plugin.py	2013-08-31 18:17:38 +0000
+++ openlp/core/lib/plugin.py	2013-09-05 22:46:29 +0000
@@ -34,7 +34,7 @@
 
 from PyQt4 import QtCore
 
-from openlp.core.lib import Settings, Registry, UiStrings
+from openlp.core.lib import Settings, Registry, UiStrings, build_icon
 from openlp.core.utils import get_application_version
 
 log = logging.getLogger(__name__)
@@ -120,7 +120,8 @@
     """
     log.info('loaded')
 
-    def __init__(self, name, default_settings, media_item_class=None, settings_tab_class=None, version=None):
+    def __init__(self, name, default_settings, weight, icon_path, 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*
@@ -136,6 +137,12 @@
         ``default_settings``
             A dict containing the plugin's settings. The value to each key is the default value to be used.
 
+        ``weight``
+            The plugin's importance/weight. Lower ones are more important.
+
+        ``icon_path``
+            The path to the icon for this plugin.
+
         ``media_item_class``
             The class name of the plugin's media item.
 
@@ -156,12 +163,13 @@
         else:
             self.version = get_application_version()['version']
         self.settings_section = self.name
-        self.icon = None
+        self.icon_path = icon_path
+        self.icon = build_icon(self.icon_path)
         self.media_item_class = media_item_class
         self.settings_tab_class = settings_tab_class
         self.settings_tab = None
         self.media_item = None
-        self.weight = 0
+        self.weight = weight
         self.status = PluginStatus.Inactive
         # Add the default status to the default settings.
         default_settings[name + '/status'] = PluginStatus.Inactive

=== modified file 'openlp/plugins/alerts/alertsplugin.py'
--- openlp/plugins/alerts/alertsplugin.py	2013-08-31 18:17:38 +0000
+++ openlp/plugins/alerts/alertsplugin.py	2013-09-05 22:46:29 +0000
@@ -31,7 +31,7 @@
 
 from PyQt4 import QtGui
 
-from openlp.core.lib import Plugin, Settings, StringContent, build_icon, translate
+from openlp.core.lib import Plugin, Settings, StringContent, translate
 from openlp.core.lib.db import Manager
 from openlp.core.lib.ui import create_action, UiStrings
 from openlp.core.lib.theme import VerticalType
@@ -129,10 +129,8 @@
     log.info('Alerts Plugin loaded')
 
     def __init__(self):
-        super(AlertsPlugin, self).__init__('alerts', __default_settings__, settings_tab_class=AlertsTab)
-        self.weight = -3
-        self.icon_path = ':/plugins/plugin_alerts.png'
-        self.icon = build_icon(self.icon_path)
+        super(AlertsPlugin, self).__init__(
+            'alerts', __default_settings__, -3, ':/plugins/plugin_alerts.png', settings_tab_class=AlertsTab)
         self.alerts_manager = AlertsManager(self)
         self.manager = Manager('alerts', init_schema)
         self.alert_form = AlertForm(self)

=== modified file 'openlp/plugins/bibles/bibleplugin.py'
--- openlp/plugins/bibles/bibleplugin.py	2013-08-31 18:17:38 +0000
+++ openlp/plugins/bibles/bibleplugin.py	2013-09-05 22:46:29 +0000
@@ -31,7 +31,7 @@
 
 from PyQt4 import QtGui
 
-from openlp.core.lib import Plugin, StringContent, build_icon, translate
+from openlp.core.lib import Plugin, StringContent, translate
 from openlp.core.lib.ui import UiStrings, create_action
 from openlp.core.utils.actions import ActionList
 from openlp.plugins.bibles.lib import BibleManager, BiblesTab, BibleMediaItem, LayoutStyle, DisplayStyle, \
@@ -69,10 +69,8 @@
     log.info('Bible Plugin loaded')
 
     def __init__(self):
-        super(BiblePlugin, self).__init__('bibles', __default_settings__, BibleMediaItem, BiblesTab)
-        self.weight = -9
-        self.icon_path = ':/plugins/plugin_bibles.png'
-        self.icon = build_icon(self.icon_path)
+        super(BiblePlugin, self).__init__(
+            'bibles', __default_settings__, -9, ':/plugins/plugin_bibles.png', BibleMediaItem, BiblesTab)
         self.manager = None
 
     def initialise(self):

=== modified file 'openlp/plugins/custom/customplugin.py'
--- openlp/plugins/custom/customplugin.py	2013-08-31 18:17:38 +0000
+++ openlp/plugins/custom/customplugin.py	2013-09-05 22:46:29 +0000
@@ -33,7 +33,7 @@
 
 import logging
 
-from openlp.core.lib import Plugin, StringContent, build_icon, translate
+from openlp.core.lib import Plugin, StringContent, translate
 from openlp.core.lib.db import Manager
 from openlp.plugins.custom.lib import CustomMediaItem, CustomTab
 from openlp.plugins.custom.lib.db import CustomSlide, init_schema
@@ -61,11 +61,9 @@
     log.info('Custom Plugin loaded')
 
     def __init__(self):
-        super(CustomPlugin, self).__init__('custom', __default_settings__, CustomMediaItem, CustomTab)
-        self.weight = -5
+        super(CustomPlugin, self).__init__(
+            'custom', __default_settings__, -5, ':/plugins/plugin_custom.png', CustomMediaItem, CustomTab)
         self.manager = Manager('custom', init_schema)
-        self.icon_path = ':/plugins/plugin_custom.png'
-        self.icon = build_icon(self.icon_path)
 
     def about(self):
         about_text = translate('CustomPlugin', '<strong>Custom Slide Plugin </strong><br />The custom slide plugin '

=== modified file 'openlp/plugins/images/imageplugin.py'
--- openlp/plugins/images/imageplugin.py	2013-08-31 18:17:38 +0000
+++ openlp/plugins/images/imageplugin.py	2013-09-05 22:46:29 +0000
@@ -31,7 +31,7 @@
 
 import logging
 
-from openlp.core.lib import Plugin, StringContent, Registry, ImageSource, Settings, build_icon, translate
+from openlp.core.lib import Plugin, StringContent, Registry, ImageSource, Settings, translate
 from openlp.core.lib.db import Manager
 from openlp.plugins.images.lib import ImageMediaItem, ImageTab
 from openlp.plugins.images.lib.db import init_schema, ImageFilenames
@@ -48,11 +48,8 @@
     log.info('Image Plugin loaded')
 
     def __init__(self):
-        super(ImagePlugin, self).__init__('images', __default_settings__, ImageMediaItem, ImageTab)
+        super(ImagePlugin, self).__init__('images', __default_settings__, -7, ':/plugins/plugin_images.png', ImageMediaItem, ImageTab)
         self.manager = Manager('images', init_schema)
-        self.weight = -7
-        self.icon_path = ':/plugins/plugin_images.png'
-        self.icon = build_icon(self.icon_path)
 
     def about(self):
         about_text = translate('ImagePlugin', '<strong>Image Plugin</strong>'

=== modified file 'openlp/plugins/media/mediaplugin.py'
--- openlp/plugins/media/mediaplugin.py	2013-08-31 18:17:38 +0000
+++ openlp/plugins/media/mediaplugin.py	2013-09-05 22:46:29 +0000
@@ -49,10 +49,8 @@
     log.info('%s MediaPlugin loaded', __name__)
 
     def __init__(self):
-        super(MediaPlugin, self).__init__('media', __default_settings__, MediaMediaItem)
-        self.weight = -6
-        self.icon_path = ':/plugins/plugin_media.png'
-        self.icon = build_icon(self.icon_path)
+        super(MediaPlugin, self).__init__(
+            'media', __default_settings__, -6, ':/plugins/plugin_media.png', MediaMediaItem)
         # passed with drag and drop messages
         self.dnd_id = 'Media'
 

=== modified file 'openlp/plugins/presentations/presentationplugin.py'
--- openlp/plugins/presentations/presentationplugin.py	2013-08-31 18:17:38 +0000
+++ openlp/plugins/presentations/presentationplugin.py	2013-09-05 22:46:29 +0000
@@ -57,18 +57,14 @@
     This plugin allowed a Presentation to be opened, controlled and displayed on the output display. The plugin controls
     third party applications such as OpenOffice.org Impress, Microsoft PowerPoint and the PowerPoint viewer.
     """
-    log = logging.getLogger('PresentationPlugin')
+    log.info('Presentation Plugin loaded')
 
     def __init__(self):
         """
         PluginPresentation constructor.
         """
-        log.debug('Initialised')
+        Plugin.__init__(self, 'presentations', __default_settings__, -8, ':/plugins/plugin_presentations.png')
         self.controllers = {}
-        Plugin.__init__(self, 'presentations', __default_settings__, __default_settings__)
-        self.weight = -8
-        self.icon_path = ':/plugins/plugin_presentations.png'
-        self.icon = build_icon(self.icon_path)
 
     def create_settings_tab(self, parent):
         """

=== modified file 'openlp/plugins/remotes/remoteplugin.py'
--- openlp/plugins/remotes/remoteplugin.py	2013-08-31 18:17:38 +0000
+++ openlp/plugins/remotes/remoteplugin.py	2013-09-05 22:46:29 +0000
@@ -55,10 +55,8 @@
         """
         remotes constructor
         """
-        super(RemotesPlugin, self).__init__('remotes', __default_settings__, settings_tab_class=RemoteTab)
-        self.icon_path = ':/plugins/plugin_remote.png'
-        self.icon = build_icon(self.icon_path)
-        self.weight = -1
+        super(RemotesPlugin, self).__init__(
+            'remotes', __default_settings__, -1, ':/plugins/plugin_remote.png', settings_tab_class=RemoteTab)
         self.server = None
 
     def initialise(self):

=== modified file 'openlp/plugins/songs/songsplugin.py'
--- openlp/plugins/songs/songsplugin.py	2013-08-31 18:17:38 +0000
+++ openlp/plugins/songs/songsplugin.py	2013-09-05 22:46:29 +0000
@@ -38,7 +38,7 @@
 
 from PyQt4 import QtCore, QtGui
 
-from openlp.core.lib import Plugin, StringContent, UiStrings, build_icon, translate
+from openlp.core.lib import Plugin, StringContent, UiStrings, translate
 from openlp.core.lib.db import Manager
 from openlp.core.lib.ui import create_action
 from openlp.core.utils.actions import ActionList
@@ -80,11 +80,9 @@
         """
         Create and set up the Songs plugin.
         """
-        super(SongsPlugin, self).__init__('songs', __default_settings__, SongMediaItem, SongsTab)
+        super(SongsPlugin, self).__init__(
+            'songs', __default_settings__, -10, ':/plugins/plugin_songs.png', SongMediaItem, SongsTab)
         self.manager = Manager('songs', init_schema, upgrade_mod=upgrade)
-        self.weight = -10
-        self.icon_path = ':/plugins/plugin_songs.png'
-        self.icon = build_icon(self.icon_path)
 
     def check_pre_conditions(self):
         """

=== modified file 'openlp/plugins/songusage/songusageplugin.py'
--- openlp/plugins/songusage/songusageplugin.py	2013-08-31 18:17:38 +0000
+++ openlp/plugins/songusage/songusageplugin.py	2013-09-05 22:46:29 +0000
@@ -60,10 +60,8 @@
     log.info('SongUsage Plugin loaded')
 
     def __init__(self):
-        super(SongUsagePlugin, self).__init__('songusage', __default_settings__)
+        super(SongUsagePlugin, self).__init__('songusage', __default_settings__, -4, ':/plugins/plugin_songusage.png')
         self.manager = Manager('songusage', init_schema, upgrade_mod=upgrade)
-        self.weight = -4
-        self.icon = build_icon(':/plugins/plugin_songusage.png')
         self.active_icon = build_icon(':/songusage/song_usage_active.png')
         self.inactive_icon = build_icon(':/songusage/song_usage_inactive.png')
         self.song_usage_active = False