openlp/openlp/plugins/images/imageplugin.py

102 lines
5.1 KiB
Python
Raw Normal View History

# -*- coding: utf-8 -*-
2019-04-13 13:00:22 +00:00
##########################################################################
# OpenLP - Open Source Lyrics Projection #
# ---------------------------------------------------------------------- #
# Copyright (c) 2008-2020 OpenLP Developers #
2019-04-13 13:00:22 +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, either version 3 of the License, or #
# (at your option) any later version. #
# #
# 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, see <https://www.gnu.org/licenses/>. #
##########################################################################
import logging
2017-12-28 08:08:12 +00:00
from PyQt5 import QtGui
2018-10-20 14:41:32 +00:00
from openlp.core.state import State
2018-04-10 19:26:56 +00:00
from openlp.core.common.i18n import translate
2018-08-26 07:28:43 +00:00
from openlp.core.lib import ImageSource, build_icon
from openlp.core.lib.db import Manager
2018-10-02 04:39:42 +00:00
from openlp.core.lib.plugin import Plugin, StringContent
from openlp.core.ui.icons import UiIcons
from openlp.plugins.images.remote import register_views
from openlp.plugins.images.lib import upgrade
from openlp.plugins.images.lib.mediaitem import ImageMediaItem
from openlp.plugins.images.lib.imagetab import ImageTab
2013-10-13 20:36:42 +00:00
from openlp.plugins.images.lib.db import init_schema
2018-10-02 04:39:42 +00:00
log = logging.getLogger(__name__)
2013-01-10 20:50:01 +00:00
class ImagePlugin(Plugin):
2013-08-31 18:17:38 +00:00
log.info('Image Plugin loaded')
2013-01-23 21:05:25 +00:00
def __init__(self):
super(ImagePlugin, self).__init__('images', ImageMediaItem, ImageTab)
self.manager = Manager('images', init_schema, upgrade_mod=upgrade)
self.weight = -7
2018-04-07 19:41:00 +00:00
self.icon_path = UiIcons().picture
2013-03-19 19:43:22 +00:00
self.icon = build_icon(self.icon_path)
register_views()
2018-10-26 18:30:59 +00:00
State().add_service('image', self.weight, is_plugin=True)
State().update_pre_conditions('image', self.check_pre_conditions())
2016-01-04 00:18:01 +00:00
@staticmethod
def about():
about_text = translate('ImagePlugin', '<strong>Image Plugin</strong>'
2014-03-08 20:39:36 +00:00
'<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
2013-02-19 21:23:56 +00:00
def set_plugin_text_strings(self):
"""
2013-04-19 19:03:16 +00:00
Called to define all translatable texts of the plugin.
"""
2014-04-12 20:19:22 +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')
}
2014-04-12 20:19:22 +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')}
# Middle Header Bar
2011-02-14 17:25:51 +00:00
tooltips = {
'load': translate('ImagePlugin', 'Add new image(s).'),
2013-08-31 18:17:38 +00:00
'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(self.settings.value(self.settings_section + '/background color'))
2013-02-12 07:49:01 +00:00
self.image_manager.update_images_border(ImageSource.ImagePlugin, background)