From 582dd56ed20db0bef79a1b3ab572ade75f3a28ed Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sun, 4 Oct 2009 16:00:52 +0100 Subject: [PATCH 1/6] Fix int issue --- openlp/core/lib/plugin.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/openlp/core/lib/plugin.py b/openlp/core/lib/plugin.py index 0e82aa8b5..c2d0e92f9 100644 --- a/openlp/core/lib/plugin.py +++ b/openlp/core/lib/plugin.py @@ -155,8 +155,8 @@ class Plugin(object): """ 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 +171,7 @@ class Plugin(object): Returns True or False. """ - return int(self.status ) == int(PluginStatus.Active) + return self.status == PluginStatus.Active def get_media_manager_item(self): """ From cfc82e740703a0f0215f35c0963907ac454a17e1 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Wed, 7 Oct 2009 06:09:35 +0100 Subject: [PATCH 2/6] Cleanup hinding code and move to disable for now --- openlp/core/lib/plugin.py | 22 ++++----------- openlp/core/lib/pluginmanager.py | 14 +++++----- openlp/core/ui/__init__.py | 3 ++- openlp/core/ui/mainwindow.py | 11 +++++--- openlp/core/ui/settingsform.py | 37 ++++++++++++++++++-------- openlp/plugins/images/lib/imagetab.py | 2 +- openlp/plugins/remotes/remoteplugin.py | 3 +++ 7 files changed, 51 insertions(+), 41 deletions(-) diff --git a/openlp/core/lib/plugin.py b/openlp/core/lib/plugin.py index c2d0e92f9..dba0f5ace 100644 --- a/openlp/core/lib/plugin.py +++ b/openlp/core/lib/plugin.py @@ -119,9 +119,6 @@ class Plugin(object): 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 @@ class Plugin(object): 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) @@ -253,21 +250,12 @@ class Plugin(object): """ 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) diff --git a/openlp/core/lib/pluginmanager.py b/openlp/core/lib/pluginmanager.py index 905d34a09..c99bbc934 100644 --- a/openlp/core/lib/pluginmanager.py +++ b/openlp/core/lib/pluginmanager.py @@ -125,7 +125,7 @@ class PluginManager(object): """ 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 @@ class PluginManager(object): 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 @@ class PluginManager(object): 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 @@ class PluginManager(object): 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): diff --git a/openlp/core/ui/__init__.py b/openlp/core/ui/__init__.py index 7ffb77463..909fc5f3f 100644 --- a/openlp/core/ui/__init__.py +++ b/openlp/core/ui/__init__.py @@ -34,10 +34,11 @@ from about import AboutForm 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'] diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index d06a78a53..af30313cf 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -29,9 +29,10 @@ from PyQt4 import QtCore, QtGui 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 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): #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 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): 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 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): 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) diff --git a/openlp/core/ui/settingsform.py b/openlp/core/ui/settingsform.py index 2daaaaab7..02b87736c 100644 --- a/openlp/core/ui/settingsform.py +++ b/openlp/core/ui/settingsform.py @@ -35,29 +35,44 @@ class SettingsForm(QtGui.QDialog, Ui_SettingsDialog): def __init__(self, screen_list, mainWindow, parent=None): QtGui.QDialog.__init__(self, None) + self.tabs = {} 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()) + id = self.SettingsTabWidget.addTab(tab, tab.title()) + self.tabs[name] = ({u'data': tab, u'id': id, u'active':True}) - def insertTab(self, id, tab): - log.debug(u'Inserting %s tab' % tab.title()) - self.SettingsTabWidget.insertTab(id, 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.widget(tab_index).setEnabled(True) + #print self.SettingsTabWidget.widget(tab_index).isVisible() - def removeTab(self, id): - log.debug(u'remove %s no tab' % unicode(id)) - self.SettingsTabWidget.removeTab(id) + def removeTab(self, name): + log.debug(u'remove %s tab' % name) + #print ">>>>>>>>>>> remove settings" + for tab_index in range(0, self.SettingsTabWidget.count()): + #print 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.widget(tab_index).setEnabled(False) + #print self.SettingsTabWidget.widget(tab_index).isVisible() def accept(self): for tab_index in range(0, self.SettingsTabWidget.count()): diff --git a/openlp/plugins/images/lib/imagetab.py b/openlp/plugins/images/lib/imagetab.py index ccf6d7571..5c00d826d 100644 --- a/openlp/plugins/images/lib/imagetab.py +++ b/openlp/plugins/images/lib/imagetab.py @@ -31,7 +31,7 @@ class ImageTab(SettingsTab): 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') diff --git a/openlp/plugins/remotes/remoteplugin.py b/openlp/plugins/remotes/remoteplugin.py index 6c56036a0..8b1e3f1b9 100644 --- a/openlp/plugins/remotes/remoteplugin.py +++ b/openlp/plugins/remotes/remoteplugin.py @@ -41,6 +41,8 @@ class RemotesPlugin(Plugin): 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 @@ class RemotesPlugin(Plugin): def finalise(self): log.debug(u'finalise') + self.remove_toolbox_item() if self.server is not None: self.server.close() From 34062ab7b971b111e387d727ae888aa8d8fa43a5 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Wed, 7 Oct 2009 06:10:06 +0100 Subject: [PATCH 3/6] New file --- openlp/core/ui/mediadockmanager.py | 54 ++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 openlp/core/ui/mediadockmanager.py diff --git a/openlp/core/ui/mediadockmanager.py b/openlp/core/ui/mediadockmanager.py new file mode 100644 index 000000000..10c9fe18b --- /dev/null +++ b/openlp/core/ui/mediadockmanager.py @@ -0,0 +1,54 @@ +# -*- 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 + self.docks = {} + + def addDock(self, name, media_item, icon): + log.info(u'Adding %s dock' % name) + id = self.mediaDock.addItem( + media_item, icon, media_item.title) + self.docks[name] = (\ + {u'data':media_item, u'icon':icon, u'id': id, u'active':True}) + + 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.widget(tab_index).setEnabled(True) + + def removeDock(self, name): + log.debug(u'remove %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.widget(tab_index).setEnabled(False) From 85a0c245ea4fb6d72cf1240f094e0f9b32ae046f Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Wed, 7 Oct 2009 17:16:21 +0100 Subject: [PATCH 4/6] Clean up disenablement --- openlp/core/ui/mediadockmanager.py | 4 ++-- openlp/core/ui/settingsform.py | 4 ++-- openlp/plugins/media/lib/mediaitem.py | 5 +++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/openlp/core/ui/mediadockmanager.py b/openlp/core/ui/mediadockmanager.py index 10c9fe18b..dc123b424 100644 --- a/openlp/core/ui/mediadockmanager.py +++ b/openlp/core/ui/mediadockmanager.py @@ -44,11 +44,11 @@ class MediaDockManager(object): 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.widget(tab_index).setEnabled(True) + 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 self.mediaDock.widget(tab_index).ConfigSection, name if self.mediaDock.widget(tab_index).ConfigSection == name.lower(): - self.mediaDock.widget(tab_index).setEnabled(False) + self.mediaDock.setItemEnabled(tab_index, False) diff --git a/openlp/core/ui/settingsform.py b/openlp/core/ui/settingsform.py index 02b87736c..30c52c59a 100644 --- a/openlp/core/ui/settingsform.py +++ b/openlp/core/ui/settingsform.py @@ -59,7 +59,7 @@ class SettingsForm(QtGui.QDialog, Ui_SettingsDialog): if self.SettingsTabWidget.widget(tab_index).title() == name: #print "Insert match" #print self.SettingsTabWidget.widget(tab_index).isVisible() - self.SettingsTabWidget.widget(tab_index).setEnabled(True) + self.SettingsTabWidget.setTabEnabled(tab_index, True) #print self.SettingsTabWidget.widget(tab_index).isVisible() @@ -71,7 +71,7 @@ class SettingsForm(QtGui.QDialog, Ui_SettingsDialog): if self.SettingsTabWidget.widget(tab_index).title() == name: #print "remove match" #print self.SettingsTabWidget.widget(tab_index).isVisible() - self.SettingsTabWidget.widget(tab_index).setEnabled(False) + self.SettingsTabWidget.setTabEnabled(tab_index, False) #print self.SettingsTabWidget.widget(tab_index).isVisible() def accept(self): diff --git a/openlp/plugins/media/lib/mediaitem.py b/openlp/plugins/media/lib/mediaitem.py index 157a84070..d9d725966 100644 --- a/openlp/plugins/media/lib/mediaitem.py +++ b/openlp/plugins/media/lib/mediaitem.py @@ -46,9 +46,10 @@ class MediaMediaItem(MediaManagerItem): 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 From 5d32ce5e66b3750cc24fab852ec72677c4850e68 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Thu, 8 Oct 2009 06:02:39 +0100 Subject: [PATCH 5/6] More cleanups, Bibles and media done --- openlp/core/ui/mediadockmanager.py | 5 +---- openlp/core/ui/settingsform.py | 4 +--- openlp/plugins/bibles/bibleplugin.py | 26 ++++++++++++++++++++++++-- openlp/plugins/bibles/lib/mediaitem.py | 3 ++- openlp/plugins/media/mediaplugin.py | 17 +++++++++++++++++ 5 files changed, 45 insertions(+), 10 deletions(-) diff --git a/openlp/core/ui/mediadockmanager.py b/openlp/core/ui/mediadockmanager.py index dc123b424..9462cd423 100644 --- a/openlp/core/ui/mediadockmanager.py +++ b/openlp/core/ui/mediadockmanager.py @@ -30,14 +30,11 @@ class MediaDockManager(object): def __init__(self, mediaDock): self.mediaDock = mediaDock - self.docks = {} def addDock(self, name, media_item, icon): log.info(u'Adding %s dock' % name) id = self.mediaDock.addItem( media_item, icon, media_item.title) - self.docks[name] = (\ - {u'data':media_item, u'icon':icon, u'id': id, u'active':True}) def insertDock(self, name): log.debug(u'Inserting %s dock' % name) @@ -49,6 +46,6 @@ class MediaDockManager(object): def removeDock(self, name): log.debug(u'remove %s dock' % name) for tab_index in range(0, self.mediaDock.count()): - #print self.mediaDock.widget(tab_index).ConfigSection, name + #print "rd", self.mediaDock.widget(tab_index).ConfigSection, name if self.mediaDock.widget(tab_index).ConfigSection == name.lower(): self.mediaDock.setItemEnabled(tab_index, False) diff --git a/openlp/core/ui/settingsform.py b/openlp/core/ui/settingsform.py index 30c52c59a..9d3c5e3f7 100644 --- a/openlp/core/ui/settingsform.py +++ b/openlp/core/ui/settingsform.py @@ -35,7 +35,6 @@ class SettingsForm(QtGui.QDialog, Ui_SettingsDialog): def __init__(self, screen_list, mainWindow, parent=None): QtGui.QDialog.__init__(self, None) - self.tabs = {} self.setupUi(self) # General tab self.GeneralTab = GeneralTab(screen_list) @@ -50,7 +49,6 @@ class SettingsForm(QtGui.QDialog, Ui_SettingsDialog): def addTab(self, name, tab): log.info(u'Adding %s tab' % tab.title()) id = self.SettingsTabWidget.addTab(tab, tab.title()) - self.tabs[name] = ({u'data': tab, u'id': id, u'active':True}) def insertTab(self, name): log.debug(u'Inserting %s tab' % name) @@ -67,7 +65,7 @@ class SettingsForm(QtGui.QDialog, Ui_SettingsDialog): log.debug(u'remove %s tab' % name) #print ">>>>>>>>>>> remove settings" for tab_index in range(0, self.SettingsTabWidget.count()): - #print self.SettingsTabWidget.widget(tab_index).title(), name + #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() diff --git a/openlp/plugins/bibles/bibleplugin.py b/openlp/plugins/bibles/bibleplugin.py index ca02fd11f..6b79bd083 100644 --- a/openlp/plugins/bibles/bibleplugin.py +++ b/openlp/plugins/bibles/bibleplugin.py @@ -41,7 +41,26 @@ class BiblePlugin(Plugin): # 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 @@ class BiblePlugin(Plugin): # 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'Bible Plugin
This plugin allows bible verse from different sources to be displayed on the screen during the service.

This is a core plugin and cannot be made inactive' diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 10944e4a7..c4370ca2f 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -226,9 +226,10 @@ class BibleMediaItem(MediaManagerItem): 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))) diff --git a/openlp/plugins/media/mediaplugin.py b/openlp/plugins/media/mediaplugin.py index 79b005a9a..ae757cc36 100644 --- a/openlp/plugins/media/mediaplugin.py +++ b/openlp/plugins/media/mediaplugin.py @@ -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 @@ class MediaPlugin(Plugin): 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') From afff83113f18b813aaebdd6eaaf572cffb55eefd Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Thu, 8 Oct 2009 18:28:59 +0100 Subject: [PATCH 6/6] Songs now play hide and seek --- openlp/plugins/songs/lib/mediaitem.py | 2 +- openlp/plugins/songs/songsplugin.py | 28 ++++++++++++++++++++++----- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index 84ba9fce0..f8e0f67fa 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -46,7 +46,7 @@ class SongMediaItem(MediaManagerItem): 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' diff --git a/openlp/plugins/songs/songsplugin.py b/openlp/plugins/songs/songsplugin.py index 89ed9da75..9c9e4f1ad 100644 --- a/openlp/plugins/songs/songsplugin.py +++ b/openlp/plugins/songs/songsplugin.py @@ -51,7 +51,7 @@ class SongsPlugin(Plugin): # 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 @@ class SongsPlugin(Plugin): # 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 @@ class SongsPlugin(Plugin): 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 @@ class SongsPlugin(Plugin): 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()