2010-09-10 19:21:14 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
# OpenLP - Open Source Lyrics Projection #
|
|
|
|
# --------------------------------------------------------------------------- #
|
2010-12-26 11:04:47 +00:00
|
|
|
# Copyright (c) 2008-2011 Raoul Snyman #
|
|
|
|
# Portions copyright (c) 2008-2011 Tim Bentley, Jonathan Corwin, Michael #
|
2010-09-10 19:21:14 +00:00
|
|
|
# Gorven, Scott Guerrieri, Meinert Jordan, Andreas Preikschat, Christian #
|
|
|
|
# Richter, Philip Ridout, Maikel Stuivenberg, Martin Thompson, Jon Tibble, #
|
|
|
|
# Carsten Tinggaard, Frode Woldsund #
|
|
|
|
# --------------------------------------------------------------------------- #
|
|
|
|
# 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 #
|
|
|
|
###############################################################################
|
|
|
|
|
|
|
|
import logging
|
|
|
|
|
|
|
|
from forms import EditCustomForm
|
|
|
|
|
2010-09-16 21:10:36 +00:00
|
|
|
from openlp.core.lib import Plugin, StringContent, build_icon, translate
|
2010-09-10 19:21:14 +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
|
|
|
|
|
|
|
|
log = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
class CustomPlugin(Plugin):
|
|
|
|
"""
|
|
|
|
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.
|
2010-09-16 21:10:36 +00:00
|
|
|
Custom shows are designed to replace the use of songs where
|
|
|
|
the songs plugin has become restrictive. Examples could be
|
2010-09-10 19:21:14 +00:00
|
|
|
Welcome slides, Bible Reading information, Orders of service.
|
|
|
|
"""
|
|
|
|
log.info(u'Custom Plugin loaded')
|
|
|
|
|
|
|
|
def __init__(self, plugin_helpers):
|
2010-12-26 11:04:47 +00:00
|
|
|
Plugin.__init__(self, u'Custom', u'1.9.4', plugin_helpers)
|
2010-09-10 19:21:14 +00:00
|
|
|
self.weight = -5
|
2010-10-27 15:30:30 +00:00
|
|
|
self.manager = Manager(u'custom', init_schema)
|
|
|
|
self.edit_custom_form = EditCustomForm(self.manager)
|
2010-09-10 19:21:14 +00:00
|
|
|
self.icon_path = u':/plugins/plugin_custom.png'
|
|
|
|
self.icon = build_icon(self.icon_path)
|
|
|
|
|
|
|
|
def getSettingsTab(self):
|
2010-09-16 21:10:36 +00:00
|
|
|
visible_name = self.getString(StringContent.VisibleName)
|
|
|
|
return CustomTab(self.name, visible_name[u'title'])
|
2010-09-10 19:21:14 +00:00
|
|
|
|
|
|
|
def getMediaManagerItem(self):
|
2010-10-28 14:56:52 +00:00
|
|
|
# Create the ManagerItem object
|
2010-09-15 17:55:27 +00:00
|
|
|
return CustomMediaItem(self, self, self.icon)
|
2010-09-10 19:21:14 +00:00
|
|
|
|
|
|
|
def about(self):
|
|
|
|
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 '
|
2010-09-16 21:10:36 +00:00
|
|
|
'songs are. This plugin provides greater freedom over the songs '
|
2010-09-10 19:21:14 +00:00
|
|
|
'plugin.')
|
|
|
|
return about_text
|
|
|
|
|
|
|
|
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-10-28 14:56:52 +00:00
|
|
|
if self.manager.get_all_objects(CustomSlide,
|
2010-09-10 19:21:14 +00:00
|
|
|
CustomSlide.theme_name == theme):
|
|
|
|
return True
|
|
|
|
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-10-28 14:56:52 +00:00
|
|
|
customsUsingTheme = self.manager.get_all_objects(CustomSlide,
|
2010-09-10 19:21:14 +00:00
|
|
|
CustomSlide.theme_name == oldTheme)
|
|
|
|
for custom in customsUsingTheme:
|
|
|
|
custom.theme_name = newTheme
|
2010-10-28 14:56:52 +00:00
|
|
|
self.manager.save_object(custom)
|
2010-09-16 21:10:36 +00:00
|
|
|
|
2010-09-27 18:15:55 +00:00
|
|
|
def setPluginTextStrings(self):
|
2010-09-10 19:21:14 +00:00
|
|
|
"""
|
|
|
|
Called to define all translatable texts of the plugin
|
|
|
|
"""
|
2010-09-15 17:55:27 +00:00
|
|
|
## Name PluginList ##
|
2010-10-05 16:09:48 +00:00
|
|
|
self.textStrings[StringContent.Name] = {
|
2010-09-10 19:21:14 +00:00
|
|
|
u'singular': translate('CustomsPlugin', 'Custom'),
|
|
|
|
u'plural': translate('CustomsPlugin', 'Customs')
|
|
|
|
}
|
2010-09-15 17:55:27 +00:00
|
|
|
## Name for MediaDockManager, SettingsManager ##
|
2010-10-05 16:09:48 +00:00
|
|
|
self.textStrings[StringContent.VisibleName] = {
|
2010-12-21 19:49:02 +00:00
|
|
|
u'title': translate('CustomsPlugin', 'Custom')
|
2010-09-15 17:55:27 +00:00
|
|
|
}
|
2010-09-10 19:21:14 +00:00
|
|
|
# Middle Header Bar
|
|
|
|
## Import Button ##
|
2010-10-05 16:09:48 +00:00
|
|
|
self.textStrings[StringContent.Import] = {
|
2010-09-10 19:21:14 +00:00
|
|
|
u'title': translate('CustomsPlugin', 'Import'),
|
2010-10-27 15:30:30 +00:00
|
|
|
u'tooltip': translate('CustomsPlugin',
|
2010-09-29 21:06:59 +00:00
|
|
|
'Import a Custom')
|
2010-09-10 19:21:14 +00:00
|
|
|
}
|
|
|
|
## Load Button ##
|
2010-10-05 16:09:48 +00:00
|
|
|
self.textStrings[StringContent.Load] = {
|
2010-09-10 19:21:14 +00:00
|
|
|
u'title': translate('CustomsPlugin', 'Load'),
|
2010-10-27 15:30:30 +00:00
|
|
|
u'tooltip': translate('CustomsPlugin',
|
2010-09-29 21:06:59 +00:00
|
|
|
'Load a new Custom')
|
2010-09-10 19:21:14 +00:00
|
|
|
}
|
|
|
|
## New Button ##
|
2010-10-05 16:09:48 +00:00
|
|
|
self.textStrings[StringContent.New] = {
|
2010-09-10 19:21:14 +00:00
|
|
|
u'title': translate('CustomsPlugin', 'Add'),
|
2010-10-27 15:30:30 +00:00
|
|
|
u'tooltip': translate('CustomsPlugin',
|
2010-09-29 21:06:59 +00:00
|
|
|
'Add a new Custom')
|
2010-09-10 19:21:14 +00:00
|
|
|
}
|
|
|
|
## Edit Button ##
|
2010-10-05 16:09:48 +00:00
|
|
|
self.textStrings[StringContent.Edit] = {
|
2010-09-10 19:21:14 +00:00
|
|
|
u'title': translate('CustomsPlugin', 'Edit'),
|
2010-10-27 15:30:30 +00:00
|
|
|
u'tooltip': translate('CustomsPlugin',
|
2010-09-29 21:06:59 +00:00
|
|
|
'Edit the selected Custom')
|
2010-09-10 19:21:14 +00:00
|
|
|
}
|
|
|
|
## Delete Button ##
|
2010-10-05 16:09:48 +00:00
|
|
|
self.textStrings[StringContent.Delete] = {
|
2010-09-10 19:21:14 +00:00
|
|
|
u'title': translate('CustomsPlugin', 'Delete'),
|
2010-10-27 15:30:30 +00:00
|
|
|
u'tooltip': translate('CustomsPlugin',
|
2010-09-29 21:06:59 +00:00
|
|
|
'Delete the selected Custom')
|
2010-09-10 19:21:14 +00:00
|
|
|
}
|
|
|
|
## Preview ##
|
2010-10-05 16:09:48 +00:00
|
|
|
self.textStrings[StringContent.Preview] = {
|
2010-09-10 19:21:14 +00:00
|
|
|
u'title': translate('CustomsPlugin', 'Preview'),
|
2010-10-27 15:30:30 +00:00
|
|
|
u'tooltip': translate('CustomsPlugin',
|
2010-09-29 21:06:59 +00:00
|
|
|
'Preview the selected Custom')
|
2010-09-10 19:21:14 +00:00
|
|
|
}
|
|
|
|
## Live Button ##
|
2010-10-05 16:09:48 +00:00
|
|
|
self.textStrings[StringContent.Live] = {
|
2010-09-10 19:21:14 +00:00
|
|
|
u'title': translate('CustomsPlugin', 'Live'),
|
2010-10-27 15:30:30 +00:00
|
|
|
u'tooltip': translate('CustomsPlugin',
|
2010-09-29 21:06:59 +00:00
|
|
|
'Send the selected Custom live')
|
2010-09-10 19:21:14 +00:00
|
|
|
}
|
|
|
|
## Add to service Button ##
|
2010-10-05 16:09:48 +00:00
|
|
|
self.textStrings[StringContent.Service] = {
|
2010-09-10 19:21:14 +00:00
|
|
|
u'title': translate('CustomsPlugin', 'Service'),
|
2010-10-27 15:30:30 +00:00
|
|
|
u'tooltip': translate('CustomsPlugin',
|
2010-09-29 21:06:59 +00:00
|
|
|
'Add the selected Custom to the service')
|
2010-10-27 15:30:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
def finalise(self):
|
|
|
|
"""
|
|
|
|
Time to tidy up on exit
|
|
|
|
"""
|
|
|
|
log.info(u'Custom Finalising')
|
|
|
|
self.manager.finalise()
|
2010-12-26 11:04:47 +00:00
|
|
|
Plugin.finalise(self)
|