2010-09-10 19:21:14 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
2013-01-01 16:33:41 +00:00
|
|
|
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
|
2010-09-10 19:21:14 +00:00
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
# OpenLP - Open Source Lyrics Projection #
|
|
|
|
# --------------------------------------------------------------------------- #
|
2013-12-24 08:56:50 +00:00
|
|
|
# Copyright (c) 2008-2014 Raoul Snyman #
|
|
|
|
# Portions copyright (c) 2008-2014 Tim Bentley, Gerald Britton, Jonathan #
|
2012-06-22 14:14:53 +00:00
|
|
|
# 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, #
|
2012-12-01 07:57:54 +00:00
|
|
|
# Frode Woldsund, Martin Zibricky, Patrick Zimmermann #
|
2010-09-10 19:21:14 +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 #
|
|
|
|
###############################################################################
|
|
|
|
|
2013-02-16 09:24:06 +00:00
|
|
|
from PyQt4 import QtGui
|
2011-08-20 13:21:25 +00:00
|
|
|
|
2010-09-10 19:21:14 +00:00
|
|
|
import logging
|
|
|
|
|
2013-12-13 17:44:05 +00:00
|
|
|
from openlp.core.common import Registry, Settings, translate
|
|
|
|
from openlp.core.lib import Plugin, StringContent, ImageSource, build_icon
|
2013-01-25 11:52:32 +00:00
|
|
|
from openlp.core.lib.db import Manager
|
2011-08-20 11:45:06 +00:00
|
|
|
from openlp.plugins.images.lib import ImageMediaItem, ImageTab
|
2013-10-13 20:36:42 +00:00
|
|
|
from openlp.plugins.images.lib.db import init_schema
|
2010-09-10 19:21:14 +00:00
|
|
|
|
|
|
|
log = logging.getLogger(__name__)
|
2013-01-10 20:50:01 +00:00
|
|
|
|
2013-01-10 20:41:16 +00:00
|
|
|
__default_settings__ = {
|
2013-08-31 18:17:38 +00:00
|
|
|
'images/db type': 'sqlite',
|
|
|
|
'images/background color': '#000000',
|
2013-01-30 10:57:06 +00:00
|
|
|
}
|
2010-09-10 19:21:14 +00:00
|
|
|
|
2013-01-10 20:50:01 +00:00
|
|
|
|
2010-09-10 19:21:14 +00:00
|
|
|
class ImagePlugin(Plugin):
|
2013-08-31 18:17:38 +00:00
|
|
|
log.info('Image Plugin loaded')
|
2010-09-10 19:21:14 +00:00
|
|
|
|
2013-01-23 21:05:25 +00:00
|
|
|
def __init__(self):
|
2013-08-31 18:17:38 +00:00
|
|
|
super(ImagePlugin, self).__init__('images', __default_settings__, ImageMediaItem, ImageTab)
|
|
|
|
self.manager = Manager('images', init_schema)
|
2010-09-10 19:21:14 +00:00
|
|
|
self.weight = -7
|
2013-08-31 18:17:38 +00:00
|
|
|
self.icon_path = ':/plugins/plugin_images.png'
|
2013-03-19 19:43:22 +00:00
|
|
|
self.icon = build_icon(self.icon_path)
|
2010-09-10 19:21:14 +00:00
|
|
|
|
|
|
|
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 '
|
2010-09-16 21:10:36 +00:00
|
|
|
'background, which renders text-based items like songs with the '
|
2010-09-10 19:21:14 +00:00
|
|
|
'selected image as a background instead of the background '
|
|
|
|
'provided by the theme.')
|
|
|
|
return about_text
|
2010-09-12 21:03:16 +00:00
|
|
|
|
2013-03-03 19:35:11 +00:00
|
|
|
def app_startup(self):
|
|
|
|
"""
|
2013-04-19 19:03:16 +00:00
|
|
|
Perform tasks on application startup.
|
2013-03-03 19:35:11 +00:00
|
|
|
"""
|
|
|
|
Plugin.app_startup(self)
|
2013-04-19 19:03:16 +00:00
|
|
|
# Convert old settings-based image list to the database.
|
2013-03-03 19:35:11 +00:00
|
|
|
files_from_config = Settings().get_files_from_config(self)
|
2013-03-18 22:04:09 +00:00
|
|
|
if files_from_config:
|
2013-08-31 18:17:38 +00:00
|
|
|
log.debug('Importing images list from old config: %s' % files_from_config)
|
2013-03-19 19:43:22 +00:00
|
|
|
self.media_item.save_new_images_list(files_from_config)
|
2013-03-04 13:37:19 +00:00
|
|
|
|
|
|
|
def upgrade_settings(self, settings):
|
|
|
|
"""
|
|
|
|
Upgrade the settings of this plugin.
|
2013-03-14 11:32:58 +00:00
|
|
|
|
|
|
|
``settings``
|
|
|
|
The Settings object containing the old settings.
|
2013-03-04 13:37:19 +00:00
|
|
|
"""
|
|
|
|
files_from_config = settings.get_files_from_config(self)
|
2013-03-18 22:04:09 +00:00
|
|
|
if files_from_config:
|
2013-08-31 18:17:38 +00:00
|
|
|
log.debug('Importing images list from old config: %s' % files_from_config)
|
2013-03-19 19:43:22 +00:00
|
|
|
self.media_item.save_new_images_list(files_from_config)
|
2013-03-03 19:35:11 +00:00
|
|
|
|
2013-02-19 21:23:56 +00:00
|
|
|
def set_plugin_text_strings(self):
|
2010-09-10 19:21:14 +00:00
|
|
|
"""
|
2013-04-19 19:03:16 +00:00
|
|
|
Called to define all translatable texts of the plugin.
|
2010-09-10 19:21:14 +00:00
|
|
|
"""
|
2010-09-15 17:55:27 +00:00
|
|
|
## Name PluginList ##
|
2013-03-19 19:43:22 +00:00
|
|
|
self.text_strings[StringContent.Name] = {
|
2013-08-31 18:17:38 +00:00
|
|
|
'singular': translate('ImagePlugin', 'Image', 'name singular'),
|
|
|
|
'plural': translate('ImagePlugin', 'Images', 'name plural')
|
2010-09-10 19:21:14 +00:00
|
|
|
}
|
2010-09-15 17:55:27 +00:00
|
|
|
## Name for MediaDockManager, SettingsManager ##
|
2013-08-31 18:17:38 +00:00
|
|
|
self.text_strings[StringContent.VisibleName] = {'title': translate('ImagePlugin', 'Images', 'container title')}
|
2010-09-10 19:21:14 +00:00
|
|
|
# Middle Header Bar
|
2011-02-14 17:25:51 +00:00
|
|
|
tooltips = {
|
2013-08-31 18:17:38 +00:00
|
|
|
'load': translate('ImagePlugin', 'Load a new image.'),
|
|
|
|
'import': '',
|
|
|
|
'new': translate('ImagePlugin', 'Add a new image.'),
|
|
|
|
'edit': translate('ImagePlugin', 'Edit the selected image.'),
|
|
|
|
'delete': translate('ImagePlugin', 'Delete the selected image.'),
|
|
|
|
'preview': translate('ImagePlugin', 'Preview the selected image.'),
|
|
|
|
'live': translate('ImagePlugin', 'Send the selected image live.'),
|
|
|
|
'service': translate('ImagePlugin', 'Add the selected image to the service.')
|
2011-02-14 17:25:51 +00:00
|
|
|
}
|
2013-03-19 19:43:22 +00:00
|
|
|
self.set_plugin_ui_text_strings(tooltips)
|
2011-08-20 13:21:25 +00:00
|
|
|
|
2013-03-17 09:21:18 +00:00
|
|
|
def config_update(self):
|
2011-08-20 15:02:57 +00:00
|
|
|
"""
|
2013-04-19 19:03:16 +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.
|
2011-08-20 15:02:57 +00:00
|
|
|
"""
|
2013-08-31 18:17:38 +00:00
|
|
|
log.info('Images config_update')
|
|
|
|
background = QtGui.QColor(Settings().value(self.settings_section + '/background color'))
|
2013-02-12 07:49:01 +00:00
|
|
|
self.image_manager.update_images_border(ImageSource.ImagePlugin, background)
|
|
|
|
|
|
|
|
def _get_image_manager(self):
|
|
|
|
"""
|
|
|
|
Adds the image manager to the class dynamically
|
|
|
|
"""
|
2013-08-31 18:17:38 +00:00
|
|
|
if not hasattr(self, '_image_manager'):
|
|
|
|
self._image_manager = Registry().get('image_manager')
|
2013-02-12 07:49:01 +00:00
|
|
|
return self._image_manager
|
|
|
|
|
|
|
|
image_manager = property(_get_image_manager)
|