openlp/openlp/plugins/images/imageplugin.py

102 lines
5.3 KiB
Python
Raw Normal View History

# -*- coding: utf-8 -*-
2013-01-01 16:33:41 +00:00
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
# --------------------------------------------------------------------------- #
2012-12-29 20:56:56 +00:00
# Copyright (c) 2008-2013 Raoul Snyman #
# Portions copyright (c) 2008-2013 Tim Bentley, Gerald Britton, Jonathan #
# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, #
2012-11-11 21:16:14 +00:00
# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. #
2012-10-21 13:16:22 +00:00
# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, #
# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, #
# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, #
# Frode Woldsund, Martin Zibricky, Patrick Zimmermann #
# --------------------------------------------------------------------------- #
# 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 #
###############################################################################
2011-08-20 13:21:25 +00:00
from PyQt4 import QtCore, QtGui
import logging
from openlp.core.lib import Plugin, StringContent, build_icon, translate, Receiver, ImageSource, Settings
2011-08-20 11:45:06 +00:00
from openlp.plugins.images.lib import ImageMediaItem, ImageTab
log = logging.getLogger(__name__)
2013-01-10 20:50:01 +00:00
2013-01-10 20:41:16 +00:00
__default_settings__ = {
u'images/background color': u'#000000',
2013-01-18 19:24:06 +00:00
u'images/images files': []
2013-01-10 20:09:27 +00:00
}
2013-01-10 20:50:01 +00:00
class ImagePlugin(Plugin):
log.info(u'Image Plugin loaded')
2013-01-23 21:05:25 +00:00
def __init__(self):
Plugin.__init__(self, u'images', __default_settings__, ImageMediaItem, ImageTab)
self.weight = -7
self.iconPath = u':/plugins/plugin_images.png'
self.icon = build_icon(self.iconPath)
2013-01-01 16:33:41 +00:00
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'image_updated'), self.image_updated)
def about(self):
about_text = translate('ImagePlugin', '<strong>Image Plugin</strong>'
'<br />The image plugin provides displaying of images.<br />One '
'of the distinguishing features of this plugin is the ability to '
'group a number of images together in the service manager, making '
'the displaying of multiple images easier. This plugin can also '
'make use of OpenLP\'s "timed looping" feature to create a slide '
'show that runs automatically. In addition to this, images from '
'the plugin can be used to override the current theme\'s '
'background, which renders text-based items like songs with the '
'selected image as a background instead of the background '
'provided by the theme.')
return about_text
2010-09-12 21:03:16 +00:00
2010-09-27 18:15:55 +00:00
def setPluginTextStrings(self):
"""
Called to define all translatable texts of the plugin
"""
2010-09-15 17:55:27 +00:00
## Name PluginList ##
self.textStrings[StringContent.Name] = {
u'singular': translate('ImagePlugin', 'Image', 'name singular'),
u'plural': translate('ImagePlugin', 'Images', 'name plural')
}
2010-09-15 17:55:27 +00:00
## Name for MediaDockManager, SettingsManager ##
2013-01-01 16:33:41 +00:00
self.textStrings[StringContent.VisibleName] = {u'title': translate('ImagePlugin', 'Images', 'container title')
2010-09-15 17:55:27 +00:00
}
# Middle Header Bar
2011-02-14 17:25:51 +00:00
tooltips = {
2011-06-11 21:43:08 +00:00
u'load': translate('ImagePlugin', 'Load a new image.'),
2011-02-14 19:08:18 +00:00
u'import': u'',
2011-06-11 21:43:08 +00:00
u'new': translate('ImagePlugin', 'Add a new image.'),
u'edit': translate('ImagePlugin', 'Edit the selected image.'),
u'delete': translate('ImagePlugin', 'Delete the selected image.'),
u'preview': translate('ImagePlugin', 'Preview the selected image.'),
u'live': translate('ImagePlugin', 'Send the selected image live.'),
2013-01-01 16:33:41 +00:00
u'service': translate('ImagePlugin', 'Add the selected image to the service.')
2011-02-14 17:25:51 +00:00
}
self.setPluginUiTextStrings(tooltips)
2011-08-20 13:21:25 +00:00
def image_updated(self):
2011-08-20 15:02:57 +00:00
"""
Triggered by saving and changing the image border. Sets the images in
image manager to require updates. Actual update is triggered by the
last part of saving the config.
"""
background = QtGui.QColor(Settings().value(self.settingsSection + u'/background color'))
2013-01-01 16:33:41 +00:00
self.liveController.imageManager.updateImagesBorder(ImageSource.ImagePlugin, background)