forked from openlp/openlp
clean ups
This commit is contained in:
parent
9da23266c6
commit
bc3173966a
@ -36,6 +36,16 @@ from PyQt4 import QtCore, QtGui, Qt
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class ImageSource(object):
|
||||
"""
|
||||
This enumeration class represents different image sources. An image sources
|
||||
states where an image is used.
|
||||
"""
|
||||
ImagePlugin = 1
|
||||
Theme = 2
|
||||
|
||||
|
||||
class MediaType(object):
|
||||
"""
|
||||
An enumeration class for types of media.
|
||||
@ -265,7 +275,6 @@ def resize_image(image_path, width, height, background=u'#000000'):
|
||||
if image_ratio == resize_ratio:
|
||||
# We neither need to centre the image nor add "bars" to the image.
|
||||
return preview
|
||||
#FIXME: change variables to real_width and real_height
|
||||
realw = preview.width()
|
||||
realh = preview.height()
|
||||
# and move it to the centre of the preview space
|
||||
|
@ -96,15 +96,6 @@ class Priority(object):
|
||||
Urgent = 0
|
||||
|
||||
|
||||
class ImageSource(object):
|
||||
"""
|
||||
This enumeration class represents different image sources. An image sources
|
||||
states where an image is used.
|
||||
"""
|
||||
ImagePlugin = 1
|
||||
Theme = 2
|
||||
|
||||
|
||||
class Image(object):
|
||||
"""
|
||||
This class represents an image. To mark an image as *dirty* call the
|
||||
@ -131,10 +122,10 @@ class Image(object):
|
||||
self.path = path
|
||||
self.image = None
|
||||
self.image_bytes = None
|
||||
self.priority = Priority.Normal
|
||||
self.source = source
|
||||
self.background = background
|
||||
self.timestamp = os.stat(path).st_mtime
|
||||
self.priority = Priority.Normal
|
||||
self.secondary_priority = Image.secondary_priority
|
||||
Image.secondary_priority += 1
|
||||
|
||||
@ -196,7 +187,6 @@ class ImageManager(QtCore.QObject):
|
||||
self.imageThread = ImageThread(self)
|
||||
self._conversionQueue = PriorityQueue()
|
||||
self.stopManager = False
|
||||
self.imageSource = ImageSource()
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'config_updated'), self.processUpdates)
|
||||
|
||||
|
@ -32,7 +32,7 @@ from PyQt4 import QtGui, QtCore, QtWebKit
|
||||
|
||||
from openlp.core.lib import ServiceItem, expand_tags, \
|
||||
build_lyrics_format_css, build_lyrics_outline_css, Receiver, \
|
||||
ItemCapabilities, FormattingTags
|
||||
ItemCapabilities, FormattingTags, ImageSource
|
||||
from openlp.core.lib.theme import ThemeLevel
|
||||
from openlp.core.ui import MainDisplay, ScreenList
|
||||
|
||||
@ -138,7 +138,7 @@ class Renderer(object):
|
||||
# if No file do not update cache
|
||||
if theme_data.background_filename:
|
||||
self.image_manager.addImage(theme_data.background_filename,
|
||||
self.image_manager.imageSource.Theme,
|
||||
ImageSource.Theme,
|
||||
QtGui.QColor(theme_data.background_border_color))
|
||||
|
||||
def pre_render(self, override_theme_data=None):
|
||||
@ -243,7 +243,7 @@ class Renderer(object):
|
||||
# if No file do not update cache
|
||||
if theme_data.background_filename:
|
||||
self.image_manager.addImage(theme_data.background_filename,
|
||||
self.image_manager.imageSource.Theme,
|
||||
ImageSource.Theme,
|
||||
QtGui.QColor(theme_data.background_border_color))
|
||||
theme_data, main, footer = self.pre_render(theme_data)
|
||||
serviceItem.themedata = theme_data
|
||||
|
@ -36,7 +36,8 @@ import logging
|
||||
import os
|
||||
import uuid
|
||||
|
||||
from openlp.core.lib import build_icon, clean_tags, expand_tags, translate
|
||||
from openlp.core.lib import build_icon, clean_tags, expand_tags, translate, \
|
||||
ImageSource
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
@ -217,9 +218,8 @@ class ServiceItem(object):
|
||||
self.image_border = background
|
||||
self.service_item_type = ServiceItemType.Image
|
||||
self._raw_frames.append({u'title': title, u'path': path})
|
||||
self.renderer.image_manager.addImage(path,
|
||||
self.renderer.image_manager.imageSource.ImagePlugin,
|
||||
self.image_border)
|
||||
self.renderer.image_manager.addImage(
|
||||
path, ImageSource.ImagePlugin, self.image_border)
|
||||
self._new_item()
|
||||
|
||||
def add_from_text(self, raw_slide, verse_tag=None):
|
||||
|
@ -37,7 +37,7 @@ from PyQt4 import QtCore, QtGui, QtWebKit, QtOpenGL
|
||||
from PyQt4.phonon import Phonon
|
||||
|
||||
from openlp.core.lib import Receiver, build_html, ServiceItem, image_to_byte, \
|
||||
translate, PluginManager, expand_tags
|
||||
translate, PluginManager, expand_tags, ImageSource
|
||||
from openlp.core.lib.theme import BackgroundType
|
||||
from openlp.core.lib.settings import Settings
|
||||
|
||||
@ -278,7 +278,7 @@ class MainDisplay(Display):
|
||||
"""
|
||||
API for replacement backgrounds so Images are added directly to cache.
|
||||
"""
|
||||
self.imageManager.addImage(path, self.imageManager.imageSource.ImagePlugin, background)
|
||||
self.imageManager.addImage(path, ImageSource.ImagePlugin, background)
|
||||
if not hasattr(self, u'serviceItem'):
|
||||
return False
|
||||
self.override[u'image'] = path
|
||||
@ -300,7 +300,7 @@ class MainDisplay(Display):
|
||||
re-added to the image manager.
|
||||
"""
|
||||
log.debug(u'image to display')
|
||||
image = self.imageManager.getImageBytes(path, self.imageManager.imageSource.ImagePlugin)
|
||||
image = self.imageManager.getImageBytes(path, ImageSource.ImagePlugin)
|
||||
self.controller.mediaController.video_reset(self.controller)
|
||||
self.displayImage(image)
|
||||
|
||||
@ -379,20 +379,23 @@ class MainDisplay(Display):
|
||||
Receiver.send_message(u'video_background_replaced')
|
||||
self.override = {}
|
||||
# We have a different theme.
|
||||
elif self.override[u'theme'] != serviceItem.themedata.background_filename:
|
||||
elif self.override[u'theme'] != \
|
||||
serviceItem.themedata.background_filename:
|
||||
Receiver.send_message(u'live_theme_changed')
|
||||
self.override = {}
|
||||
else:
|
||||
# replace the background
|
||||
background = self.imageManager. \
|
||||
getImageBytes(self.override[u'image'], self.imageManager.imageSource.ImagePlugin)
|
||||
background = self.imageManager.getImageBytes(
|
||||
self.override[u'image'], ImageSource.ImagePlugin)
|
||||
self.setTransparency(self.serviceItem.themedata.background_type ==
|
||||
BackgroundType.to_string(BackgroundType.Transparent))
|
||||
if self.serviceItem.themedata.background_filename:
|
||||
self.serviceItem.bg_image_bytes = self.imageManager. \
|
||||
getImageBytes(self.serviceItem.themedata.background_filename, self.imageManager.imageSource.Theme)
|
||||
self.serviceItem.bg_image_bytes = self.imageManager.getImageBytes(
|
||||
self.serviceItem.themedata.background_filename,
|
||||
ImageSource.Theme)
|
||||
if image_path:
|
||||
image_bytes = self.imageManager.getImageBytes(image_path, self.imageManager.imageSource.ImagePlugin)
|
||||
image_bytes = self.imageManager.getImageBytes(
|
||||
image_path, ImageSource.ImagePlugin)
|
||||
else:
|
||||
image_bytes = None
|
||||
html = build_html(self.serviceItem, self.screen, self.isLive,
|
||||
|
@ -34,7 +34,7 @@ from collections import deque
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import OpenLPToolbar, Receiver, ItemCapabilities, \
|
||||
translate, build_icon, build_html, PluginManager, ServiceItem
|
||||
translate, build_icon, build_html, PluginManager, ServiceItem, ImageSource
|
||||
from openlp.core.lib.ui import UiStrings, create_action
|
||||
from openlp.core.lib.settings import Settings
|
||||
from openlp.core.lib import SlideLimits, ServiceItemAction
|
||||
@ -862,9 +862,9 @@ class SlideController(Controller):
|
||||
if framenumber == slideno:
|
||||
self.serviceItem.bg_image_bytes = \
|
||||
self.imageManager.getImageBytes(frame[u'path'],
|
||||
self.imageManager.imageSource.ImagePlugin)
|
||||
ImageSource.ImagePlugin)
|
||||
image = self.imageManager.getImage(frame[u'path'],
|
||||
self.imageManager.imageSource.ImagePlugin)
|
||||
ImageSource.ImagePlugin)
|
||||
label.setPixmap(QtGui.QPixmap.fromImage(image))
|
||||
self.previewListWidget.setCellWidget(framenumber, 0, label)
|
||||
slideHeight = width * (1 / self.ratio)
|
||||
|
@ -38,7 +38,7 @@ from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import OpenLPToolbar, get_text_file_string, build_icon, \
|
||||
Receiver, SettingsManager, translate, check_item_selected, \
|
||||
check_directory_exists, create_thumb, validate_thumb
|
||||
check_directory_exists, create_thumb, validate_thumb, ImageSource
|
||||
from openlp.core.lib.theme import ThemeXML, BackgroundType, VerticalType, \
|
||||
BackgroundGradientType
|
||||
from openlp.core.lib.settings import Settings
|
||||
@ -671,7 +671,7 @@ class ThemeManager(QtGui.QWidget):
|
||||
BackgroundType.to_string(BackgroundType.Image):
|
||||
self.mainwindow.imageManager.updateImageBorder(
|
||||
theme.background_filename,
|
||||
self.mainwindow.imageManager.imageSource.Theme, QtGui.QColor(theme.background_border_color))
|
||||
ImageSource.Theme, QtGui.QColor(theme.background_border_color))
|
||||
self.mainwindow.imageManager.processUpdates()
|
||||
self.loadThemes()
|
||||
|
||||
|
@ -31,7 +31,7 @@ from PyQt4 import QtCore, QtGui
|
||||
import logging
|
||||
|
||||
from openlp.core.lib import Plugin, StringContent, build_icon, translate, \
|
||||
Receiver
|
||||
Receiver, ImageSource
|
||||
from openlp.core.lib.settings import Settings
|
||||
from openlp.plugins.images.lib import ImageMediaItem, ImageTab
|
||||
|
||||
@ -99,4 +99,4 @@ class ImagePlugin(Plugin):
|
||||
background = QtGui.QColor(Settings().value(self.settingsSection
|
||||
+ u'/background color', QtCore.QVariant(u'#000000')))
|
||||
self.liveController.imageManager.updateImagesBorder(
|
||||
self.liveController.imageManager.imageSource.ImagePlugin, background)
|
||||
ImageSource.ImagePlugin, background)
|
||||
|
Loading…
Reference in New Issue
Block a user