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