openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #00517
[Merge] lp:~trb143/openlp/audit into lp:openlp
Tim Bentley has proposed merging lp:~trb143/openlp/audit into lp:openlp.
Requested reviews:
OpenLP Core (openlp-core)
--
https://code.launchpad.net/~trb143/openlp/audit/+merge/13085
Your team OpenLP Core is subscribed to branch lp:openlp.
=== modified file 'openlp/core/lib/plugin.py'
--- openlp/core/lib/plugin.py 2009-10-03 19:02:40 +0000
+++ openlp/core/lib/plugin.py 2009-10-08 17:35:19 +0000
@@ -119,9 +119,6 @@
self.icon = None
self.config = PluginConfig(self.name)
self.weight = 0
- self.media_id = -1
- self.settings_id = -1
- self.media_active = False
self.status = PluginStatus.Inactive
# Set up logging
self.log = logging.getLogger(self.name)
@@ -130,7 +127,7 @@
self.render_manager = plugin_helpers[u'render']
self.service_manager = plugin_helpers[u'service']
self.settings = plugin_helpers[u'settings']
- self.mediatoolbox = plugin_helpers[u'toolbox']
+ self.mediadock = plugin_helpers[u'toolbox']
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'%s_add_service_item'% self.name), self.process_add_service_event)
@@ -155,8 +152,8 @@
"""
Sets the status of the plugin
"""
- self.status = self.config.get_config(\
- u'%s_status' % self.name, PluginStatus.Inactive)
+ self.status = int(self.config.get_config(\
+ u'%s_status' % self.name, PluginStatus.Inactive))
def toggle_status(self, new_status):
"""
@@ -171,7 +168,7 @@
Returns True or False.
"""
- return int(self.status ) == int(PluginStatus.Active)
+ return self.status == PluginStatus.Active
def get_media_manager_item(self):
"""
@@ -253,21 +250,12 @@
"""
Called by the plugin to remove toolbar
"""
- if self.media_id is not -1:
- self.mediatoolbox.removeItem(self.media_id)
- if self.settings_id is not -1:
- self.settings.removeTab(self.settings_id)
- self.media_active = False
+ self.mediadock.removeDock(self.name)
+ self.settings.removeTab(self.name)
def insert_toolbox_item(self):
"""
Called by plugin to replace toolbar
"""
- if not self.media_active:
- if self.media_id is not -1:
- self.mediatoolbox.insertItem(
- self.media_id, self.media_item, self.icon, self.media_item.title)
- if self.settings_id is not -1:
- self.settings.insertTab(
- self.settings_id, self.settings_tab)
- self.media_active = True
+ self.mediadock.insertDock(self.name)
+ self.settings.insertTab(self.name)
=== modified file 'openlp/core/lib/pluginmanager.py'
--- openlp/core/lib/pluginmanager.py 2009-10-03 19:02:40 +0000
+++ openlp/core/lib/pluginmanager.py 2009-10-08 17:35:19 +0000
@@ -125,7 +125,7 @@
"""
return cmp(x.weight, y.weight)
- def hook_media_manager(self, mediatoolbox):
+ 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.
@@ -139,9 +139,8 @@
if plugin.media_item is not None:
log.debug(u'Inserting media manager item from %s' % \
plugin.name)
- plugin.media_id = mediatoolbox.addItem(
- plugin.media_item, plugin.icon, plugin.media_item.title)
- plugin.media_active = True
+ mediadock.addDock(plugin.name,
+ plugin.media_item, plugin.icon)
def hook_settings_tabs(self, settingsform=None):
"""
@@ -157,7 +156,7 @@
plugin.settings_tab = plugin.get_settings_tab()
if plugin.settings_tab is not None:
log.debug(u'Inserting settings tab item from %s' % plugin.name)
- plugin.settings_id = settingsform.addTab(plugin.settings_tab)
+ settingsform.addTab(plugin.name, plugin.settings_tab)
else:
log.debug(u'No tab settings in %s' % plugin.name)
@@ -202,11 +201,12 @@
Loop through all the plugins and give them an opportunity to
initialise themselves.
"""
- log.info(u'initialising plugins')
for plugin in self.plugins:
+ log.info(u'initialising plugins %s in a %s state'
+ % (plugin.name, plugin.is_active()))
if plugin.is_active():
plugin.initialise()
- if plugin.media_item is not None and not plugin.is_active():
+ if not plugin.is_active():
plugin.remove_toolbox_item()
def finalise_plugins(self):
=== modified file 'openlp/core/ui/__init__.py'
--- openlp/core/ui/__init__.py 2009-09-25 00:43:42 +0000
+++ openlp/core/ui/__init__.py 2009-10-08 17:35:19 +0000
@@ -34,10 +34,11 @@
from alertform import AlertForm
from plugindialoglistform import PluginForm
from settingsform import SettingsForm
+from mediadockmanager import MediaDockManager
from servicemanager import ServiceManager
from thememanager import ThemeManager
from mainwindow import MainWindow
__all__ = ['SplashScreen', 'AboutForm', 'SettingsForm', 'MainWindow',
'MainDisplay', 'SlideController', 'ServiceManager', 'ThemeManager',
- 'AmendThemeForm']
+ 'AmendThemeForm', 'MediaDockManager']
=== modified file 'openlp/core/ui/mainwindow.py'
--- openlp/core/ui/mainwindow.py 2009-10-03 18:39:44 +0000
+++ openlp/core/ui/mainwindow.py 2009-10-08 17:35:19 +0000
@@ -29,9 +29,10 @@
from openlp.core.ui import AboutForm, SettingsForm, AlertForm, \
ServiceManager, ThemeManager, MainDisplay, SlideController, \
- PluginForm
+ PluginForm, MediaDockManager
from openlp.core.lib import translate, RenderManager, PluginConfig, \
- OpenLPDockWidget, SettingsManager, PluginManager, Receiver, buildIcon
+ OpenLPDockWidget, SettingsManager, PluginManager, Receiver, \
+ buildIcon
class Ui_MainWindow(object):
@@ -489,6 +490,8 @@
#ThemeManager needs to call RenderManager
self.RenderManager = RenderManager(self.ThemeManagerContents,
self.screenList, self.getMonitorNumber())
+ #Define the media Dock Manager
+ self.mediaDockManager = MediaDockManager(self.MediaToolBox)
log.info(u'Load Plugins')
#make the controllers available to the plugins
self.plugin_helpers[u'preview'] = self.PreviewController
@@ -496,7 +499,7 @@
self.plugin_helpers[u'render'] = self.RenderManager
self.plugin_helpers[u'service'] = self.ServiceManagerContents
self.plugin_helpers[u'settings'] = self.settingsForm
- self.plugin_helpers[u'toolbox'] = self.MediaToolBox
+ self.plugin_helpers[u'toolbox'] = self.mediaDockManager
self.plugin_manager.find_plugins(pluginpath, self.plugin_helpers)
# hook methods have to happen after find_plugins. Find plugins needs
# the controllers hence the hooks have moved from setupUI() to here
@@ -505,7 +508,7 @@
self.plugin_manager.hook_settings_tabs(self.settingsForm)
# Find and insert media manager items
log.info(u'hook media')
- self.plugin_manager.hook_media_manager(self.MediaToolBox)
+ self.plugin_manager.hook_media_manager(self.mediaDockManager)
# Call the hook method to pull in import menus.
log.info(u'hook menus')
self.plugin_manager.hook_import_menu(self.FileImportMenu)
=== added file 'openlp/core/ui/mediadockmanager.py'
--- openlp/core/ui/mediadockmanager.py 1970-01-01 00:00:00 +0000
+++ openlp/core/ui/mediadockmanager.py 2009-10-08 17:35:19 +0000
@@ -0,0 +1,51 @@
+# -*- coding: utf-8 -*-
+# vim: autoindent shiftwidth=4 expanddock textwidth=80 dockstop=4 softdockstop=4
+
+###############################################################################
+# OpenLP - Open Source Lyrics Projection #
+# --------------------------------------------------------------------------- #
+# Copyright (c) 2008-2009 Raoul Snyman #
+# Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley, Carsten #
+# Tinggaard, Jon Tibble, Jonathan Corwin, Maikel Stuivenberg, Scott Guerrieri #
+# --------------------------------------------------------------------------- #
+# This program is free software; you can redistribute it and/or modify it #
+# under the terms of the GNU General Public License as published by the Free #
+# Software Foundation; version 2 of the License. #
+# #
+# This program is distributed in the hope that it will be useful, but WITHOUT #
+# ANY WARRANTY; without even the implied warranty of MERCHANdockILITY or #
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
+# more details. #
+# #
+# You should have received a copy of the GNU General Public License along #
+# with this program; if not, write to the Free Software Foundation, Inc., 59 #
+# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
+###############################################################################
+
+import logging
+
+log = logging.getLogger(u'MediaDockManager')
+
+class MediaDockManager(object):
+
+ def __init__(self, mediaDock):
+ self.mediaDock = mediaDock
+
+ def addDock(self, name, media_item, icon):
+ log.info(u'Adding %s dock' % name)
+ id = self.mediaDock.addItem(
+ media_item, icon, media_item.title)
+
+ def insertDock(self, name):
+ log.debug(u'Inserting %s dock' % name)
+ for tab_index in range(0, self.mediaDock.count()):
+ #print self.mediaDock.widget(tab_index).ConfigSection, name
+ if self.mediaDock.widget(tab_index).ConfigSection == name.lower():
+ self.mediaDock.setItemEnabled(tab_index, True)
+
+ def removeDock(self, name):
+ log.debug(u'remove %s dock' % name)
+ for tab_index in range(0, self.mediaDock.count()):
+ #print "rd", self.mediaDock.widget(tab_index).ConfigSection, name
+ if self.mediaDock.widget(tab_index).ConfigSection == name.lower():
+ self.mediaDock.setItemEnabled(tab_index, False)
=== modified file 'openlp/core/ui/settingsform.py'
--- openlp/core/ui/settingsform.py 2009-10-03 19:02:40 +0000
+++ openlp/core/ui/settingsform.py 2009-10-08 17:35:19 +0000
@@ -38,26 +38,39 @@
self.setupUi(self)
# General tab
self.GeneralTab = GeneralTab(screen_list)
- self.addTab(self.GeneralTab)
+ self.addTab(u'General', self.GeneralTab)
# Themes tab
self.ThemesTab = ThemesTab(mainWindow)
- self.addTab(self.ThemesTab)
+ self.addTab(u'Themes', self.ThemesTab)
# Alert tab
self.AlertsTab = AlertsTab()
- self.addTab(self.AlertsTab)
+ self.addTab(u'Alerts', self.AlertsTab)
- def addTab(self, tab):
+ def addTab(self, name, tab):
log.info(u'Adding %s tab' % tab.title())
- return self.SettingsTabWidget.addTab(tab, tab.title())
-
- def insertTab(self, id, tab):
- log.debug(u'Inserting %s tab' % tab.title())
- self.SettingsTabWidget.insertTab(id, tab, tab.title())
-
- def removeTab(self, id):
- log.debug(u'remove %s no tab' % unicode(id))
- self.SettingsTabWidget.removeTab(id)
-
+ id = self.SettingsTabWidget.addTab(tab, tab.title())
+
+ def insertTab(self, name):
+ log.debug(u'Inserting %s tab' % name)
+ for tab_index in range(0, self.SettingsTabWidget.count()):
+ #print self.SettingsTabWidget.widget(tab_index).title()
+ if self.SettingsTabWidget.widget(tab_index).title() == name:
+ #print "Insert match"
+ #print self.SettingsTabWidget.widget(tab_index).isVisible()
+ self.SettingsTabWidget.setTabEnabled(tab_index, True)
+ #print self.SettingsTabWidget.widget(tab_index).isVisible()
+
+
+ def removeTab(self, name):
+ log.debug(u'remove %s tab' % name)
+ #print ">>>>>>>>>>> remove settings"
+ for tab_index in range(0, self.SettingsTabWidget.count()):
+ #print "rt", self.SettingsTabWidget.widget(tab_index).title(), name
+ if self.SettingsTabWidget.widget(tab_index).title() == name:
+ #print "remove match"
+ #print self.SettingsTabWidget.widget(tab_index).isVisible()
+ self.SettingsTabWidget.setTabEnabled(tab_index, False)
+ #print self.SettingsTabWidget.widget(tab_index).isVisible()
def accept(self):
for tab_index in range(0, self.SettingsTabWidget.count()):
=== modified file 'openlp/plugins/bibles/bibleplugin.py'
--- openlp/plugins/bibles/bibleplugin.py 2009-10-03 19:02:40 +0000
+++ openlp/plugins/bibles/bibleplugin.py 2009-10-08 17:35:19 +0000
@@ -41,7 +41,26 @@
# Create the plugin icon
self.icon = buildIcon(u':/media/media_bible.png')
#Register the bible Manager
- self.biblemanager = BibleManager(self.config)
+ self.biblemanager = None
+
+ def can_be_disabled(self):
+ return True
+
+ def initialise(self):
+ log.info(u'bibles Initialising')
+ if self.biblemanager is None:
+ self.biblemanager = BibleManager(self.config)
+ Plugin.initialise(self)
+ self.insert_toolbox_item()
+ self.ImportBibleItem.setVisible(True)
+ self.ExportBibleItem.setVisible(True)
+
+ def finalise(self):
+ log.info(u'Plugin Finalise')
+ Plugin.finalise(self)
+ self.remove_toolbox_item()
+ self.ImportBibleItem.setVisible(False)
+ self.ExportBibleItem.setVisible(False)
def get_settings_tab(self):
return BiblesTab()
@@ -58,15 +77,18 @@
# Signals and slots
QtCore.QObject.connect(self.ImportBibleItem,
QtCore.SIGNAL(u'triggered()'), self.onBibleNewClick)
+ self.ImportBibleItem.setVisible(False)
def add_export_menu_item(self, export_menu):
self.ExportBibleItem = QtGui.QAction(export_menu)
self.ExportBibleItem.setObjectName(u'ExportBibleItem')
export_menu.addAction(self.ExportBibleItem)
self.ExportBibleItem.setText(translate(u'BiblePlugin', u'&Bible'))
+ self.ExportBibleItem.setVisible(False)
def onBibleNewClick(self):
- self.media_item.onBibleNewClick()
+ if self.media_item is not None:
+ self.media_item.onNewClick()
def about(self):
return u'<b>Bible Plugin</b> <br>This plugin allows bible verse from different sources to be displayed on the screen during the service.<br><br>This is a core plugin and cannot be made inactive</b>'
=== modified file 'openlp/plugins/bibles/lib/mediaitem.py'
--- openlp/plugins/bibles/lib/mediaitem.py 2009-09-29 17:05:34 +0000
+++ openlp/plugins/bibles/lib/mediaitem.py 2009-10-08 17:35:19 +0000
@@ -226,9 +226,10 @@
translate(u'BibleMediaItem', u'Keep'))
def initialise(self):
- log.debug(u'initialise')
+ log.debug(u'bible manager initialise')
self.loadBibles()
self.parent.biblemanager.set_media_manager(self)
+ log.debug(u'bible manager initialise complete')
def setQuickMessage(self, text):
self.QuickMessage.setText(translate(u'BibleMediaItem', unicode(text)))
=== modified file 'openlp/plugins/images/lib/imagetab.py'
--- openlp/plugins/images/lib/imagetab.py 2009-09-25 00:43:42 +0000
+++ openlp/plugins/images/lib/imagetab.py 2009-10-08 17:35:19 +0000
@@ -31,7 +31,7 @@
ImageTab is the Image settings tab in the settings dialog.
"""
def __init__(self):
- SettingsTab.__init__(self, translate(u'ImageTab', u'Image'), u'Image')
+ SettingsTab.__init__(self, translate(u'ImageTab', u'Images'), u'Image')
def setupUi(self):
self.setObjectName(u'ImageTab')
=== modified file 'openlp/plugins/media/lib/mediaitem.py'
--- openlp/plugins/media/lib/mediaitem.py 2009-09-26 09:11:39 +0000
+++ openlp/plugins/media/lib/mediaitem.py 2009-10-08 17:35:19 +0000
@@ -46,9 +46,10 @@
self.TranslationContext = u'MediaPlugin'
self.IconPath = u'images/image'
self.PluginTextShort = u'Media'
- self.ConfigSection = u'images'
+ self.ConfigSection = u'media'
self.OnNewPrompt = u'Select Media(s)'
- self.OnNewFileMasks = u'Videos (*.avi *.mpeg *.mpg *.mp4);;Audio (*.ogg *.mp3 *.wma);;All files (*)'
+ self.OnNewFileMasks = \
+ u'Videos (*.avi *.mpeg *.mpg *.mp4);;Audio (*.ogg *.mp3 *.wma);;All files (*)'
# this next is a class, not an instance of a class - it will
# be instanced by the base MediaManagerItem
self.ListViewWithDnD_class = MediaListView
=== modified file 'openlp/plugins/media/mediaplugin.py'
--- openlp/plugins/media/mediaplugin.py 2009-10-03 19:02:40 +0000
+++ openlp/plugins/media/mediaplugin.py 2009-10-08 17:35:19 +0000
@@ -22,10 +22,15 @@
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
###############################################################################
+import logging
+
from openlp.core.lib import Plugin, buildIcon
from openlp.plugins.media.lib import MediaTab, MediaMediaItem
class MediaPlugin(Plugin):
+ global log
+ log = logging.getLogger(u'MediaPlugin')
+ log.info(u'Media Plugin loaded')
def __init__(self, plugin_helpers):
# Call the parent constructor
@@ -39,6 +44,18 @@
def get_settings_tab(self):
return MediaTab()
+ def can_be_disabled(self):
+ return True
+
+ def initialise(self):
+ log.info(u'Plugin Initialising')
+ Plugin.initialise(self)
+ self.insert_toolbox_item()
+
+ def finalise(self):
+ log.info(u'Plugin Finalise')
+ self.remove_toolbox_item()
+
def get_media_manager_item(self):
# Create the MediaManagerItem object
return MediaMediaItem(self, self.icon, u'Media')
=== modified file 'openlp/plugins/presentations/presentationplugin.py'
--- openlp/plugins/presentations/presentationplugin.py 2009-10-03 19:02:40 +0000
+++ openlp/plugins/presentations/presentationplugin.py 2009-10-08 17:35:19 +0000
@@ -51,6 +51,19 @@
Create the settings Tab
"""
return PresentationTab(self.controllers)
+#
+# def can_be_disabled(self):
+# return True
+#
+# def initialise(self):
+# log.info(u'Presentations Initialising')
+# Plugin.initialise(self)
+# self.insert_toolbox_item()
+#
+# def finalise(self):
+# log.info(u'Plugin Finalise')
+# Plugin.finalise(self)
+# self.remove_toolbox_item()
def get_media_manager_item(self):
"""
=== modified file 'openlp/plugins/remotes/remoteplugin.py'
--- openlp/plugins/remotes/remoteplugin.py 2009-10-03 07:25:41 +0000
+++ openlp/plugins/remotes/remoteplugin.py 2009-10-08 17:35:19 +0000
@@ -41,6 +41,8 @@
def initialise(self):
log.debug(u'initialise')
+ Plugin.initialise(self)
+ self.insert_toolbox_item()
self.server = QtNetwork.QUdpSocket()
self.server.bind(int(self.config.get_config(u'remote port', 4316)))
QtCore.QObject.connect(self.server,
@@ -48,6 +50,7 @@
def finalise(self):
log.debug(u'finalise')
+ self.remove_toolbox_item()
if self.server is not None:
self.server.close()
=== modified file 'openlp/plugins/songs/lib/mediaitem.py'
--- openlp/plugins/songs/lib/mediaitem.py 2009-09-29 02:54:32 +0000
+++ openlp/plugins/songs/lib/mediaitem.py 2009-10-08 17:35:19 +0000
@@ -46,7 +46,7 @@
def __init__(self, parent, icon, title):
self.TranslationContext = u'SongPlugin'
self.PluginTextShort = u'Song'
- self.ConfigSection = u'song'
+ self.ConfigSection = u'songs'
self.IconPath = u'songs/song'
self.ListViewWithDnD_class = SongListView
self.ServiceItemIconName = u':/media/song_image.png'
=== modified file 'openlp/plugins/songs/songsplugin.py'
--- openlp/plugins/songs/songsplugin.py 2009-10-03 18:39:44 +0000
+++ openlp/plugins/songs/songsplugin.py 2009-10-08 17:35:19 +0000
@@ -51,7 +51,7 @@
# Call the parent constructor
Plugin.__init__(self, u'Songs', u'1.9.0', plugin_helpers)
self.weight = -10
- self.songmanager = SongManager(self.config)
+ self.songmanager = None
self.openlp_import_form = OpenLPImportForm()
self.opensong_import_form = OpenSongImportForm()
self.openlp_export_form = OpenLPExportForm()
@@ -59,6 +59,26 @@
# Create the plugin icon
self.icon = buildIcon(u':/media/media_song.png')
+ def can_be_disabled(self):
+ return True
+
+ def initialise(self):
+ log.info(u'Songs Initialising')
+ if self.songmanager is None:
+ self.songmanager = SongManager(self.config)
+ Plugin.initialise(self)
+ self.insert_toolbox_item()
+ self.ImportSongMenu.menuAction().setVisible(True)
+ self.ExportSongMenu.menuAction().setVisible(True)
+ self.media_item.displayResultsSong(self.songmanager.get_songs())
+
+ def finalise(self):
+ log.info(u'Plugin Finalise')
+ Plugin.finalise(self)
+ self.remove_toolbox_item()
+ self.ImportSongMenu.menuAction().setVisible(False)
+ self.ExportSongMenu.menuAction().setVisible(False)
+
def get_media_manager_item(self):
"""
Create the MediaManagerItem object, which is displaed in the
@@ -109,6 +129,7 @@
QtCore.SIGNAL(u'triggered()'), self.onImportOpenlp1ItemClick)
QtCore.QObject.connect(self.ImportOpenSongItem,
QtCore.SIGNAL(u'triggered()'), self.onImportOpenSongItemClick)
+ self.ImportSongMenu.menuAction().setVisible(False)
def add_export_menu_item(self, export_menu):
"""
@@ -143,10 +164,7 @@
QtCore.SIGNAL(u'triggered()'), self.onExportOpenlp1ItemClicked)
QtCore.QObject.connect(self.ExportOpenSongItem,
QtCore.SIGNAL(u'triggered()'), self.onExportOpenSongItemClicked)
-
- def initialise(self):
- Plugin.initialise(self)
- self.media_item.displayResultsSong(self.songmanager.get_songs())
+ self.ExportSongMenu.menuAction().setVisible(False)
def onImportOpenlp1ItemClick(self):
self.openlp_import_form.show()
Follow ups