Sort out Initialistion order and Plugin Status code

This commit is contained in:
Tim Bentley 2009-10-03 14:08:18 +01:00
parent 9ec94494e8
commit c4f8fc86cd
11 changed files with 40 additions and 29 deletions

View File

@ -118,7 +118,7 @@ class MediaManagerItem(QtGui.QWidget):
self.requiredIcons()
self.setupUi()
self.retranslateUi()
self.initialise()
#self.initialise()
def requiredIcons(self):
"""
@ -131,7 +131,6 @@ class MediaManagerItem(QtGui.QWidget):
self.hasFileIcon = False
self.hasDeleteIcon = True
def retranslateUi(self):
"""
This method is called automatically to provide OpenLP with the

View File

@ -161,6 +161,14 @@ class Plugin(object):
self.status = new_status
self.config.set_config(u'%s_status' % self.name, self.status)
def is_active(self):
"""
Indicates if the plugin is active
Returns True or False.
"""
return int(self.status ) == int(PluginStatus.Active)
def get_media_manager_item(self):
"""
Construct a MediaManagerItem object with all the buttons and things
@ -228,6 +236,7 @@ class Plugin(object):
"""
Called by the plugin Manager to initialise anything it needs.
"""
log.info(u'base class called')
pass
def finalise(self):

View File

@ -135,14 +135,14 @@ class PluginManager(object):
"""
for plugin in self.plugins:
if plugin.status is not PluginStatus.Disabled:
media_manager_item = plugin.get_media_manager_item()
if media_manager_item is not None:
plugin.media_item = plugin.get_media_manager_item()
if plugin.media_item is not None:
log.debug(u'Inserting media manager item from %s' % \
plugin.name)
mediatoolbox.addItem(media_manager_item, plugin.icon,
media_manager_item.title)
mediatoolbox.addItem(plugin.media_item, plugin.icon,
plugin.media_item.title)
if plugin.status == PluginStatus.Inactive:
media_manager_item.hide()
plugin.media_item.hide()
def hook_settings_tabs(self, settingsform=None):
"""
@ -160,7 +160,7 @@ class PluginManager(object):
log.debug(u'Inserting settings tab item from %s' % plugin.name)
settingsform.addTab(settings_tab)
else:
log.debug(u'No settings in %s' % plugin.name)
log.debug(u'No tab settings in %s' % plugin.name)
def hook_import_menu(self, import_menu):
"""
@ -173,8 +173,6 @@ class PluginManager(object):
for plugin in self.plugins:
if plugin.status is not PluginStatus.Disabled:
plugin.add_import_menu_item(import_menu)
if plugin.status == PluginStatus.Inactive:
import_menu.hide()
def hook_export_menu(self, export_menu):
"""
@ -187,8 +185,6 @@ class PluginManager(object):
for plugin in self.plugins:
if plugin.status is not PluginStatus.Disabled:
plugin.add_export_menu_item(export_menu)
if plugin.status == PluginStatus.Inactive:
export_menu.hide()
def hook_tools_menu(self, tools_menu):
"""
@ -201,23 +197,25 @@ class PluginManager(object):
for plugin in self.plugins:
if plugin.status is not PluginStatus.Disabled:
plugin.add_tools_menu_item(tools_menu)
if plugin.status == PluginStatus.Inactive:
tools_menu.hide()
def initialise_plugins(self):
"""
Loop through all the plugins and give them an opportunity to
initialise themselves.
"""
log.info(u'initialising plugins')
for plugin in self.plugins:
if plugin.status == PluginStatus.Active:
if plugin.is_active():
plugin.initialise()
if plugin.media_item is not None:
plugin.media_item.initialise()
def finalise_plugins(self):
"""
Loop through all the plugins and give them an opportunity to
clean themselves up
"""
log.info(u'finalising plugins')
for plugin in self.plugins:
if plugin.status == PluginStatus.Active:
if plugin.is_active():
plugin.finalise()

View File

@ -58,6 +58,7 @@ class AuditPlugin(Plugin):
The actual **Tools** menu item, so that your actions can
use it as their parent.
"""
log.info(u'add tools menu')
self.toolsMenu = tools_menu
self.AuditMenu = QtGui.QMenu(tools_menu)
self.AuditMenu.setObjectName(u'AuditMenu')
@ -119,7 +120,7 @@ class AuditPlugin(Plugin):
self.AuditMenu.menuAction().setVisible(False)
def initialise(self):
log.info(u'Plugin Initialising')
log.info(u'audit Initialising')
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'audit_live'), self.onReceiveAudit)
QtCore.QObject.connect(Receiver.get_receiver(),

View File

@ -49,8 +49,7 @@ class BiblePlugin(Plugin):
def get_media_manager_item(self):
# Create the BibleManagerItem object
self.media_item = BibleMediaItem(self, self.icon, u'Bible Verses')
return self.media_item
return BibleMediaItem(self, self.icon, u'Bible Verses')
def add_import_menu_item(self, import_menu):
self.ImportBibleItem = QtGui.QAction(import_menu)

View File

@ -54,8 +54,7 @@ class CustomPlugin(Plugin):
def get_media_manager_item(self):
# Create the CustomManagerItem object
self.media_item = CustomMediaItem(self, self.icon, u'Custom Slides')
return self.media_item
return CustomMediaItem(self, self.icon, u'Custom Slides')
def about(self):
return u'<b>Custom Plugin</b> <br>This plugin allows slides to be displayed on the screen in the same way songs are. The difference between this plugin and songs is this plugin provides greater freedom.<br><br>This is a core plugin and cannot be made inactive</b>'

View File

@ -39,14 +39,22 @@ class ImagePlugin(Plugin):
# Create the plugin icon
self.icon = buildIcon(u':/media/media_image.png')
def can_be_disabled(self):
return True
def initialise(self):
log.info(u'Plugin Initialising')
def finalise(self):
log.info(u'Plugin Finalise')
def get_settings_tab(self):
self.ImageTab = ImageTab()
return self.ImageTab
def get_media_manager_item(self):
# Create the MediaManagerItem object
self.media_item = ImageMediaItem(self, self.icon, u'Images')
return self.media_item
return ImageMediaItem(self, self.icon, u'Images')
def about(self):
return u'<b>Image Plugin</b><br>Allows images of all types to be displayed. If a number of images are selected together and presented on the live controller it is possible to turn them into a timed loop.<br> From the plugin if the <i>Override background</i> is chosen and an image is selected any somgs which are rendered will use the selected image from the background instead of the one provied by the theme.<br>'

View File

@ -65,6 +65,7 @@ class ImageMediaItem(MediaManagerItem):
self.hasEditIcon = False
def initialise(self):
log.debug(u'initialise')
self.ListView.setSelectionMode(
QtGui.QAbstractItemView.ExtendedSelection)
self.ListView.setIconSize(QtCore.QSize(88,50))

View File

@ -42,8 +42,7 @@ class MediaPlugin(Plugin):
def get_media_manager_item(self):
# Create the MediaManagerItem object
self.media_item = MediaMediaItem(self, self.icon, u'Media')
return self.media_item
return MediaMediaItem(self, self.icon, u'Media')
def about(self):
return u'<b>Media Plugin</b> <br> One day this may provide access to video and audio clips'

View File

@ -57,9 +57,8 @@ class PresentationPlugin(Plugin):
"""
Create the Media Manager List
"""
self.media_item = PresentationMediaItem(
return PresentationMediaItem(
self, self.icon, u'Presentations', self.controllers)
return self.media_item
def registerControllers(self, controller):
self.controllers[controller.name] = controller

View File

@ -64,8 +64,7 @@ class SongsPlugin(Plugin):
Create the MediaManagerItem object, which is displaed in the
Media Manager.
"""
self.media_item = SongMediaItem(self, self.icon, 'Songs')
return self.media_item
return SongMediaItem(self, self.icon, 'Songs')
def add_import_menu_item(self, import_menu):
"""