forked from openlp/openlp
doc clean up, removed method with a one liner, fixed media item recreation bug
This commit is contained in:
parent
38a2a3dee2
commit
12547fad2a
@ -91,8 +91,9 @@ class Plugin(QtCore.QObject):
|
|||||||
``checkPreConditions()``
|
``checkPreConditions()``
|
||||||
Provides the Plugin with a handle to check if it can be loaded.
|
Provides the Plugin with a handle to check if it can be loaded.
|
||||||
|
|
||||||
``getMediaManagerItem()``
|
``createMediaManagerItem()``
|
||||||
Returns an instance of MediaManagerItem to be used in the Media Manager.
|
Creates a new instance of MediaManagerItem to be used in the Media
|
||||||
|
Manager.
|
||||||
|
|
||||||
``addImportMenuItem(import_menu)``
|
``addImportMenuItem(import_menu)``
|
||||||
Add an item to the Import menu.
|
Add an item to the Import menu.
|
||||||
@ -100,8 +101,8 @@ class Plugin(QtCore.QObject):
|
|||||||
``addExportMenuItem(export_menu)``
|
``addExportMenuItem(export_menu)``
|
||||||
Add an item to the Export menu.
|
Add an item to the Export menu.
|
||||||
|
|
||||||
``getSettingsTab()``
|
``createSettingsTab()``
|
||||||
Returns an instance of SettingsTabItem to be used in the Settings
|
Creates a new instance of SettingsTabItem to be used in the Settings
|
||||||
dialog.
|
dialog.
|
||||||
|
|
||||||
``addToMenu(menubar)``
|
``addToMenu(menubar)``
|
||||||
@ -178,7 +179,7 @@ class Plugin(QtCore.QObject):
|
|||||||
Provides the Plugin with a handle to check if it can be loaded.
|
Provides the Plugin with a handle to check if it can be loaded.
|
||||||
Failing Preconditions does not stop a settings Tab being created
|
Failing Preconditions does not stop a settings Tab being created
|
||||||
|
|
||||||
Returns True or False.
|
Returns ``True`` or ``False``.
|
||||||
"""
|
"""
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@ -210,10 +211,10 @@ class Plugin(QtCore.QObject):
|
|||||||
"""
|
"""
|
||||||
return self.status == PluginStatus.Active
|
return self.status == PluginStatus.Active
|
||||||
|
|
||||||
def getMediaManagerItem(self):
|
def createMediaManagerItem(self):
|
||||||
"""
|
"""
|
||||||
Construct a MediaManagerItem object with all the buttons and things
|
Construct a MediaManagerItem object with all the buttons and things
|
||||||
you need, and return it for integration into openlp.org.
|
you need, and return it for integration into OpenLP.
|
||||||
"""
|
"""
|
||||||
if self.media_item_class:
|
if self.media_item_class:
|
||||||
return self.media_item_class(self.mediadock.media_dock, self,
|
return self.media_item_class(self.mediadock.media_dock, self,
|
||||||
@ -247,10 +248,10 @@ class Plugin(QtCore.QObject):
|
|||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def getSettingsTab(self, parent):
|
def createSettingsTab(self, parent):
|
||||||
"""
|
"""
|
||||||
Create a tab for the settings window to display the configurable
|
Create a tab for the settings window to display the configurable options
|
||||||
options for this plugin to the user.
|
for this plugin to the user.
|
||||||
"""
|
"""
|
||||||
if self.settings_tab_class:
|
if self.settings_tab_class:
|
||||||
return self.settings_tab_class(parent, self.name,
|
return self.settings_tab_class(parent, self.name,
|
||||||
|
@ -113,7 +113,7 @@ class PluginManager(object):
|
|||||||
plugin_objects.append(plugin)
|
plugin_objects.append(plugin)
|
||||||
except TypeError:
|
except TypeError:
|
||||||
log.exception(u'Failed to load plugin %s', unicode(p))
|
log.exception(u'Failed to load plugin %s', unicode(p))
|
||||||
plugins_list = sorted(plugin_objects, self.order_by_weight)
|
plugins_list = sorted(plugin_objects, key=lambda plugin: plugin.weight)
|
||||||
for plugin in plugins_list:
|
for plugin in plugins_list:
|
||||||
if plugin.checkPreConditions():
|
if plugin.checkPreConditions():
|
||||||
log.debug(u'Plugin %s active', unicode(plugin.name))
|
log.debug(u'Plugin %s active', unicode(plugin.name))
|
||||||
@ -122,29 +122,13 @@ class PluginManager(object):
|
|||||||
plugin.status = PluginStatus.Disabled
|
plugin.status = PluginStatus.Disabled
|
||||||
self.plugins.append(plugin)
|
self.plugins.append(plugin)
|
||||||
|
|
||||||
def order_by_weight(self, x, y):
|
def hook_media_manager(self):
|
||||||
"""
|
"""
|
||||||
Sort two plugins and order them by their weight.
|
Create the plugins' media manager items.
|
||||||
|
|
||||||
``x``
|
|
||||||
The first plugin.
|
|
||||||
|
|
||||||
``y``
|
|
||||||
The second plugin.
|
|
||||||
"""
|
|
||||||
return cmp(x.weight, y.weight)
|
|
||||||
|
|
||||||
def hook_media_manager(self, mediadock):
|
|
||||||
"""
|
|
||||||
Loop through all the plugins. If a plugin has a valid media manager
|
|
||||||
item, add it to the media manager.
|
|
||||||
|
|
||||||
``mediatoolbox``
|
|
||||||
The Media Manager itself.
|
|
||||||
"""
|
"""
|
||||||
for plugin in self.plugins:
|
for plugin in self.plugins:
|
||||||
if plugin.status is not PluginStatus.Disabled:
|
if plugin.status is not PluginStatus.Disabled:
|
||||||
plugin.mediaItem = plugin.getMediaManagerItem()
|
plugin.mediaItem = plugin.createMediaManagerItem()
|
||||||
|
|
||||||
def hook_settings_tabs(self, settings_form=None):
|
def hook_settings_tabs(self, settings_form=None):
|
||||||
"""
|
"""
|
||||||
@ -152,14 +136,12 @@ class PluginManager(object):
|
|||||||
item, add it to the settings tab.
|
item, add it to the settings tab.
|
||||||
Tabs are set for all plugins not just Active ones
|
Tabs are set for all plugins not just Active ones
|
||||||
|
|
||||||
``settingsform``
|
``settings_form``
|
||||||
Defaults to *None*. The settings form to add tabs to.
|
Defaults to *None*. The settings form to add tabs to.
|
||||||
"""
|
"""
|
||||||
for plugin in self.plugins:
|
for plugin in self.plugins:
|
||||||
if plugin.status is not PluginStatus.Disabled:
|
if plugin.status is not PluginStatus.Disabled:
|
||||||
plugin.settings_tab = plugin.getSettingsTab(settings_form)
|
plugin.settings_tab = plugin.createSettingsTab(settings_form)
|
||||||
else:
|
|
||||||
plugin.settings_tab = None
|
|
||||||
settings_form.plugins = self.plugins
|
settings_form.plugins = self.plugins
|
||||||
|
|
||||||
def hook_import_menu(self, import_menu):
|
def hook_import_menu(self, import_menu):
|
||||||
|
@ -655,7 +655,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
|||||||
self.pluginManager.hook_settings_tabs(self.settingsForm)
|
self.pluginManager.hook_settings_tabs(self.settingsForm)
|
||||||
# Find and insert media manager items
|
# Find and insert media manager items
|
||||||
log.info(u'hook media')
|
log.info(u'hook media')
|
||||||
self.pluginManager.hook_media_manager(self.mediaDockManager)
|
self.pluginManager.hook_media_manager()
|
||||||
# Call the hook method to pull in import menus.
|
# Call the hook method to pull in import menus.
|
||||||
log.info(u'hook menus')
|
log.info(u'hook menus')
|
||||||
self.pluginManager.hook_import_menu(self.fileImportMenu)
|
self.pluginManager.hook_import_menu(self.fileImportMenu)
|
||||||
|
@ -52,7 +52,7 @@ class MediaPlugin(Plugin):
|
|||||||
for ext in self.video_extensions_list:
|
for ext in self.video_extensions_list:
|
||||||
self.serviceManager.supportedSuffixes(ext[2:])
|
self.serviceManager.supportedSuffixes(ext[2:])
|
||||||
|
|
||||||
def getSettingsTab(self, parent):
|
def createSettingsTab(self, parent):
|
||||||
"""
|
"""
|
||||||
Create the settings Tab
|
Create the settings Tab
|
||||||
"""
|
"""
|
||||||
|
@ -57,7 +57,7 @@ class PresentationPlugin(Plugin):
|
|||||||
self.icon_path = u':/plugins/plugin_presentations.png'
|
self.icon_path = u':/plugins/plugin_presentations.png'
|
||||||
self.icon = build_icon(self.icon_path)
|
self.icon = build_icon(self.icon_path)
|
||||||
|
|
||||||
def getSettingsTab(self, parent):
|
def createSettingsTab(self, parent):
|
||||||
"""
|
"""
|
||||||
Create the settings Tab
|
Create the settings Tab
|
||||||
"""
|
"""
|
||||||
@ -94,7 +94,7 @@ class PresentationPlugin(Plugin):
|
|||||||
controller.kill()
|
controller.kill()
|
||||||
Plugin.finalise(self)
|
Plugin.finalise(self)
|
||||||
|
|
||||||
def getMediaManagerItem(self):
|
def createMediaManagerItem(self):
|
||||||
"""
|
"""
|
||||||
Create the Media Manager List
|
Create the Media Manager List
|
||||||
"""
|
"""
|
||||||
|
@ -181,7 +181,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
|||||||
plugin.status == PluginStatus.Active:
|
plugin.status == PluginStatus.Active:
|
||||||
self.audioAddFromMediaButton.setVisible(True)
|
self.audioAddFromMediaButton.setVisible(True)
|
||||||
self.mediaForm.populateFiles(
|
self.mediaForm.populateFiles(
|
||||||
plugin.getMediaManagerItem().getList(MediaType.Audio))
|
plugin.mediaItem.getList(MediaType.Audio))
|
||||||
break
|
break
|
||||||
|
|
||||||
def newSong(self):
|
def newSong(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user