2009-03-07 09:20:26 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
|
|
|
|
2009-09-08 19:58:05 +00:00
|
|
|
###############################################################################
|
|
|
|
# OpenLP - Open Source Lyrics Projection #
|
|
|
|
# --------------------------------------------------------------------------- #
|
2009-12-31 12:52:01 +00:00
|
|
|
# Copyright (c) 2008-2010 Raoul Snyman #
|
|
|
|
# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael #
|
2010-07-24 22:10:47 +00:00
|
|
|
# Gorven, Scott Guerrieri, Meinert Jordan, Andreas Preikschat, Christian #
|
|
|
|
# Richter, Philip Ridout, Maikel Stuivenberg, Martin Thompson, Jon Tibble, #
|
|
|
|
# Carsten Tinggaard, Frode Woldsund #
|
2009-09-08 19:58:05 +00:00
|
|
|
# --------------------------------------------------------------------------- #
|
|
|
|
# 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 MERCHANTABILITY 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 #
|
|
|
|
###############################################################################
|
2009-03-07 09:20:26 +00:00
|
|
|
|
|
|
|
import logging
|
|
|
|
|
|
|
|
from forms import EditCustomForm
|
2010-06-18 01:26:01 +00:00
|
|
|
|
2010-06-08 15:38:09 +00:00
|
|
|
from openlp.core.lib import Plugin, build_icon, PluginStatus, translate
|
2010-06-15 02:08:22 +00:00
|
|
|
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
|
2009-03-07 09:20:26 +00:00
|
|
|
|
2010-02-27 15:31:23 +00:00
|
|
|
log = logging.getLogger(__name__)
|
2009-04-07 19:03:36 +00:00
|
|
|
|
2009-03-12 19:52:37 +00:00
|
|
|
class CustomPlugin(Plugin):
|
2009-09-11 04:54:22 +00:00
|
|
|
"""
|
|
|
|
This plugin enables the user to create, edit and display
|
|
|
|
custom slide shows. Custom shows are divided into slides.
|
|
|
|
Each show is able to have it's own theme.
|
|
|
|
Custom shows are designed to replace the use of songs where
|
|
|
|
the songs plugin has become restrictive. Examples could be
|
|
|
|
Welcome slides, Bible Reading information, Orders of service.
|
|
|
|
"""
|
2009-03-15 19:31:33 +00:00
|
|
|
log.info(u'Custom Plugin loaded')
|
2009-04-07 19:03:36 +00:00
|
|
|
|
2009-03-22 07:13:34 +00:00
|
|
|
def __init__(self, plugin_helpers):
|
2010-06-23 17:37:01 +00:00
|
|
|
Plugin.__init__(self, u'Custom', u'1.9.2', plugin_helpers)
|
2009-03-07 09:20:26 +00:00
|
|
|
self.weight = -5
|
2010-06-15 02:08:22 +00:00
|
|
|
self.custommanager = Manager(u'custom', init_schema)
|
2009-03-25 20:30:48 +00:00
|
|
|
self.edit_custom_form = EditCustomForm(self.custommanager)
|
2010-07-10 01:01:14 +00:00
|
|
|
self.icon_path = u':/plugins/plugin_custom.png'
|
|
|
|
self.icon = build_icon(self.icon_path)
|
2010-02-06 10:33:33 +00:00
|
|
|
self.status = PluginStatus.Active
|
2009-03-07 09:20:26 +00:00
|
|
|
|
2010-07-05 16:00:48 +00:00
|
|
|
def getSettingsTab(self):
|
2009-12-13 08:57:58 +00:00
|
|
|
return CustomTab(self.name)
|
|
|
|
|
2010-07-05 16:00:48 +00:00
|
|
|
def getMediaManagerItem(self):
|
2009-03-15 19:31:33 +00:00
|
|
|
# Create the CustomManagerItem object
|
2009-10-30 17:44:16 +00:00
|
|
|
return CustomMediaItem(self, self.icon, self.name)
|
2009-10-01 16:56:42 +00:00
|
|
|
|
|
|
|
def about(self):
|
2010-07-23 18:03:19 +00:00
|
|
|
about_text = translate('CustomPlugin', '<strong>Custom Plugin</strong>'
|
|
|
|
'<br />The custom plugin provides the ability to set up custom '
|
|
|
|
'text slides that can be displayed on the screen the same way '
|
|
|
|
'songs are. This plugin provides greater freedom over the songs '
|
|
|
|
'plugin.')
|
2010-02-03 17:23:33 +00:00
|
|
|
return about_text
|
2010-03-04 19:03:09 +00:00
|
|
|
|
2010-07-12 21:11:00 +00:00
|
|
|
def usesTheme(self, theme):
|
|
|
|
"""
|
|
|
|
Called to find out if the custom plugin is currently using a theme.
|
|
|
|
|
|
|
|
Returns True if the theme is being used, otherwise returns False.
|
|
|
|
"""
|
2010-07-18 23:37:24 +00:00
|
|
|
if self.custommanager.get_all_objects(CustomSlide,
|
2010-06-30 22:05:51 +00:00
|
|
|
CustomSlide.theme_name == theme):
|
2010-03-04 19:03:09 +00:00
|
|
|
return True
|
2010-07-12 21:11:00 +00:00
|
|
|
return False
|
|
|
|
|
|
|
|
def renameTheme(self, oldTheme, newTheme):
|
|
|
|
"""
|
|
|
|
Renames a theme the custom plugin is using making the plugin use the
|
|
|
|
new name.
|
|
|
|
|
|
|
|
``oldTheme``
|
|
|
|
The name of the theme the plugin should stop using.
|
|
|
|
|
|
|
|
``newTheme``
|
|
|
|
The new name the plugin should now use.
|
|
|
|
"""
|
2010-07-18 23:37:24 +00:00
|
|
|
customsUsingTheme = self.custommanager.get_all_objects(CustomSlide,
|
|
|
|
CustomSlide.theme_name == oldTheme)
|
2010-07-12 21:11:00 +00:00
|
|
|
for custom in customsUsingTheme:
|
|
|
|
custom.theme_name = newTheme
|
2010-07-24 22:10:47 +00:00
|
|
|
self.custommanager.save_object(custom)
|