forked from openlp/openlp
Fix renderer name
Introduce rendermanager
This commit is contained in:
parent
a1368e1f76
commit
d85a0ba293
@ -32,8 +32,9 @@ from toolbar import OpenLPToolbar
|
|||||||
from songxmlhandler import SongXMLBuilder
|
from songxmlhandler import SongXMLBuilder
|
||||||
from songxmlhandler import SongXMLParser
|
from songxmlhandler import SongXMLParser
|
||||||
from themexmlhandler import ThemeXML
|
from themexmlhandler import ThemeXML
|
||||||
from openlp.core.lib.render import Renderer
|
from renderer import Renderer
|
||||||
|
from rendermanager import RenderManager
|
||||||
|
|
||||||
__all__ = ['Renderer','PluginConfig', 'Plugin', 'SettingsTab', 'MediaManagerItem', 'Event', 'EventType'
|
__all__ = ['Renderer','PluginConfig', 'Plugin', 'SettingsTab', 'MediaManagerItem', 'Event', 'EventType'
|
||||||
'XmlRootClass', 'ServiceItem', 'Receiver', 'OpenLPToolbar', 'SongXMLBuilder',
|
'XmlRootClass', 'ServiceItem', 'Receiver', 'OpenLPToolbar', 'SongXMLBuilder',
|
||||||
'SongXMLParser', 'EventManager', 'ThemeXML']
|
'SongXMLParser', 'EventManager', 'ThemeXML', 'RenderManager']
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
"""
|
"""
|
||||||
OpenLP - Open Source Lyrics Projection
|
OpenLP - Open Source Lyrics Projection
|
||||||
Copyright (c) 2008 Raoul Snyman
|
Copyright (c) 2008 Raoul Snyman
|
||||||
Portions copyright (c) 2008 Martin Thompson, Tim Bentley
|
Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify it under
|
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
|
the terms of the GNU General Public License as published by the Free Software
|
81
openlp/core/lib/rendermanager.py
Normal file
81
openlp/core/lib/rendermanager.py
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
||||||
|
"""
|
||||||
|
OpenLP - Open Source Lyrics Projection
|
||||||
|
Copyright (c) 2008 Raoul Snyman
|
||||||
|
Portions copyright (c) 2008 - 2009Martin Thompson, Tim Bentley
|
||||||
|
|
||||||
|
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
|
||||||
|
"""
|
||||||
|
import logging
|
||||||
|
import os, os.path
|
||||||
|
import sys
|
||||||
|
from PyQt4 import QtGui, QtCore, Qt
|
||||||
|
from renderer import Renderer
|
||||||
|
|
||||||
|
class RenderManager:
|
||||||
|
"""
|
||||||
|
Class to pull all Renderer interactions into one place.
|
||||||
|
The plugins will call helper methods to do the rendering but
|
||||||
|
this class will provide display defense code.
|
||||||
|
"""
|
||||||
|
global log
|
||||||
|
log=logging.getLogger(u'RenderManager')
|
||||||
|
log.info(u'RenderManager Loaded')
|
||||||
|
|
||||||
|
def __init__(self, screen_list):
|
||||||
|
log.debug(u'Initilisation started')
|
||||||
|
self.screen_list = screen_list
|
||||||
|
self.displays = len(screen_list)
|
||||||
|
self.current_display = 1
|
||||||
|
self.renderer = Renderer()
|
||||||
|
self.calculate_default(self.screen_list[self.current_display-1][1])
|
||||||
|
|
||||||
|
def set_theme(self, theme):
|
||||||
|
self.theme = theme
|
||||||
|
if theme.font_main_override == False:
|
||||||
|
pass
|
||||||
|
if theme.font_footer_override == False:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def generate_preview(self):
|
||||||
|
self.calculate_default(QtCore.QSize(800,600))
|
||||||
|
|
||||||
|
frame = QtGui.QPixmap(self.width, self.height)
|
||||||
|
renderer=Renderer(None)
|
||||||
|
renderer.set_paint_dest(frame)
|
||||||
|
|
||||||
|
renderer.set_theme(self.theme)
|
||||||
|
renderer.set_text_rectangle(QtCore.QRect(10,0, self.width-1, self.height-1),
|
||||||
|
QtCore.QRect(10,self.footer_start, self.width-1, self.height-self.footer_start))
|
||||||
|
|
||||||
|
lines=[]
|
||||||
|
lines.append(u'Amazing Grace!')
|
||||||
|
lines.append(u'How sweet the sound')
|
||||||
|
lines.append(u'To save a wretch like me;')
|
||||||
|
lines.append(u'I once was lost but now am found,')
|
||||||
|
lines.append(u'Was blind, but now I see.')
|
||||||
|
lines1=[]
|
||||||
|
lines1.append(u'Amazing Grace (John Newton)' )
|
||||||
|
lines1.append(u'CCLI xxx (c)Openlp.org')
|
||||||
|
answer=renderer.render_lines(lines, lines1)
|
||||||
|
return frame
|
||||||
|
|
||||||
|
def generate_bible(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def calculate_default(self, screen):
|
||||||
|
self.width = screen.width()
|
||||||
|
self.height = screen.height()
|
||||||
|
self.footer_start = int(self.height*0.95) # 95% is start of footer
|
@ -123,6 +123,14 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
|
|||||||
self.theme.font_main_name = self.FontMainComboBox.currentFont().family()
|
self.theme.font_main_name = self.FontMainComboBox.currentFont().family()
|
||||||
self.previewTheme(self.theme)
|
self.previewTheme(self.theme)
|
||||||
|
|
||||||
|
def onFontMainColorPushButtonClicked(self):
|
||||||
|
self.theme.font_main_color = QtGui.QColorDialog.getColor(
|
||||||
|
QColor(self.theme.font_main_color), self).name()
|
||||||
|
|
||||||
|
self.FontMainColorPushButton.setStyleSheet(
|
||||||
|
'background-color: %s' % str(self.theme.font_main_color))
|
||||||
|
self.previewTheme(self.theme)
|
||||||
|
|
||||||
def onFontMainSizeSpinBoxChanged(self, value):
|
def onFontMainSizeSpinBoxChanged(self, value):
|
||||||
self.theme.font_main_proportion = value
|
self.theme.font_main_proportion = value
|
||||||
self.previewTheme(self.theme)
|
self.previewTheme(self.theme)
|
||||||
@ -159,6 +167,14 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
|
|||||||
self.theme.font_footer_name = self.FontFooterComboBox.currentFont().family()
|
self.theme.font_footer_name = self.FontFooterComboBox.currentFont().family()
|
||||||
self.previewTheme(self.theme)
|
self.previewTheme(self.theme)
|
||||||
|
|
||||||
|
def onFontFooterColorPushButtonClicked(self):
|
||||||
|
self.theme.font_footer_color = QtGui.QColorDialog.getColor(
|
||||||
|
QColor(self.theme.font_footer_color), self).name()
|
||||||
|
|
||||||
|
self.FontFooterColorPushButton.setStyleSheet(
|
||||||
|
'background-color: %s' % str(self.theme.font_footer_color))
|
||||||
|
self.previewTheme(self.theme)
|
||||||
|
|
||||||
def onFontFooterSizeSpinBoxChanged(self, value):
|
def onFontFooterSizeSpinBoxChanged(self, value):
|
||||||
self.theme.font_footer_proportion = value
|
self.theme.font_footer_proportion = value
|
||||||
self.previewTheme(self.theme)
|
self.previewTheme(self.theme)
|
||||||
@ -251,23 +267,6 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
|
|||||||
'background-color: %s' % str(self.theme.background_endColor))
|
'background-color: %s' % str(self.theme.background_endColor))
|
||||||
|
|
||||||
self.previewTheme(self.theme)
|
self.previewTheme(self.theme)
|
||||||
|
|
||||||
def onFontMainColorPushButtonClicked(self):
|
|
||||||
self.theme.font_main_color = QtGui.QColorDialog.getColor(
|
|
||||||
QColor(self.theme.font_main_color), self).name()
|
|
||||||
|
|
||||||
self.FontMainColorPushButton.setStyleSheet(
|
|
||||||
'background-color: %s' % str(self.theme.font_main_color))
|
|
||||||
self.previewTheme(self.theme)
|
|
||||||
|
|
||||||
def onFontFooterColorPushButtonClicked(self):
|
|
||||||
self.theme.font_footer_color = QtGui.QColorDialog.getColor(
|
|
||||||
QColor(self.theme.font_footer_color), self).name()
|
|
||||||
|
|
||||||
self.FontFooterColorPushButton.setStyleSheet(
|
|
||||||
'background-color: %s' % str(self.theme.font_footer_color))
|
|
||||||
self.previewTheme(self.theme)
|
|
||||||
|
|
||||||
#
|
#
|
||||||
#Other Tab
|
#Other Tab
|
||||||
#
|
#
|
||||||
@ -310,8 +309,6 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
|
|||||||
self.theme.display_verticalAlign = currentIndex
|
self.theme.display_verticalAlign = currentIndex
|
||||||
self.stateChanging(self.theme)
|
self.stateChanging(self.theme)
|
||||||
self.previewTheme(self.theme)
|
self.previewTheme(self.theme)
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
#Local Methods
|
#Local Methods
|
||||||
#
|
#
|
||||||
|
@ -28,7 +28,7 @@ from openlp.core.resources import *
|
|||||||
|
|
||||||
from openlp.core.ui import AboutForm, SettingsForm, AlertForm, \
|
from openlp.core.ui import AboutForm, SettingsForm, AlertForm, \
|
||||||
SlideController, ServiceManager, ThemeManager
|
SlideController, ServiceManager, ThemeManager
|
||||||
from openlp.core.lib import Plugin, MediaManagerItem, SettingsTab, EventManager
|
from openlp.core.lib import Plugin, MediaManagerItem, SettingsTab, EventManager, RenderManager
|
||||||
|
|
||||||
from openlp.core import PluginManager
|
from openlp.core import PluginManager
|
||||||
|
|
||||||
@ -44,6 +44,7 @@ class MainWindow(object):
|
|||||||
self.alert_form = AlertForm()
|
self.alert_form = AlertForm()
|
||||||
self.about_form = AboutForm()
|
self.about_form = AboutForm()
|
||||||
self.settings_form = SettingsForm(self.screen_list)
|
self.settings_form = SettingsForm(self.screen_list)
|
||||||
|
self.RenderManager = RenderManager(self.screen_list)
|
||||||
|
|
||||||
pluginpath = os.path.split(os.path.abspath(__file__))[0]
|
pluginpath = os.path.split(os.path.abspath(__file__))[0]
|
||||||
pluginpath = os.path.abspath(os.path.join(pluginpath, '..', '..','plugins'))
|
pluginpath = os.path.abspath(os.path.join(pluginpath, '..', '..','plugins'))
|
||||||
@ -57,6 +58,7 @@ class MainWindow(object):
|
|||||||
self.plugin_helpers[u'live'] = self.LiveController
|
self.plugin_helpers[u'live'] = self.LiveController
|
||||||
self.plugin_helpers[u'event'] = self.EventManager
|
self.plugin_helpers[u'event'] = self.EventManager
|
||||||
self.plugin_helpers[u'theme'] = self.ThemeManagerContents # Theme manger
|
self.plugin_helpers[u'theme'] = self.ThemeManagerContents # Theme manger
|
||||||
|
self.plugin_helpers[u'render'] = self.RenderManager
|
||||||
|
|
||||||
self.plugin_manager.find_plugins(pluginpath, self.plugin_helpers, self.EventManager)
|
self.plugin_manager.find_plugins(pluginpath, self.plugin_helpers, self.EventManager)
|
||||||
# hook methods have to happen after find_plugins. Find plugins needs the controllers
|
# hook methods have to happen after find_plugins. Find plugins needs the controllers
|
||||||
@ -84,6 +86,7 @@ class MainWindow(object):
|
|||||||
# Once all components are initialised load the Themes
|
# Once all components are initialised load the Themes
|
||||||
log.info(u'Load Themes')
|
log.info(u'Load Themes')
|
||||||
self.ThemeManagerContents.setEventManager(self.EventManager)
|
self.ThemeManagerContents.setEventManager(self.EventManager)
|
||||||
|
self.ThemeManagerContents.setRenderManager(self.RenderManager)
|
||||||
self.ThemeManagerContents.loadThemes()
|
self.ThemeManagerContents.loadThemes()
|
||||||
|
|
||||||
def setupUi(self):
|
def setupUi(self):
|
||||||
|
@ -187,6 +187,9 @@ class ThemeManager(QWidget):
|
|||||||
def setEventManager(self, eventManager):
|
def setEventManager(self, eventManager):
|
||||||
self.eventManager = eventManager
|
self.eventManager = eventManager
|
||||||
|
|
||||||
|
def setRenderManager(self, renderManager):
|
||||||
|
self.renderManager = renderManager
|
||||||
|
|
||||||
def onAddTheme(self):
|
def onAddTheme(self):
|
||||||
self.amendThemeForm.loadTheme(None)
|
self.amendThemeForm.loadTheme(None)
|
||||||
self.amendThemeForm.exec_()
|
self.amendThemeForm.exec_()
|
||||||
@ -335,24 +338,7 @@ class ThemeManager(QWidget):
|
|||||||
|
|
||||||
def generateImage(self, theme):
|
def generateImage(self, theme):
|
||||||
log.debug(u'generateImage %s ', theme)
|
log.debug(u'generateImage %s ', theme)
|
||||||
size=QtCore.QSize(800,600)
|
self.renderManager.set_theme(theme)
|
||||||
frame = QtGui.QPixmap(size.width(), size.height())
|
frame = self.renderManager.generate_preview()
|
||||||
renderer=Renderer(self.path)
|
|
||||||
renderer.set_paint_dest(frame)
|
|
||||||
|
|
||||||
renderer.set_theme(theme) # set default theme
|
|
||||||
#renderer._render_background()
|
|
||||||
renderer.set_text_rectangle(QtCore.QRect(0,0, size.width()-1, size.height()-1), QtCore.QRect(10,560, size.width()-1, size.height()-1))
|
|
||||||
|
|
||||||
lines=[]
|
|
||||||
lines.append(u'Amazing Grace!')
|
|
||||||
lines.append(u'How sweet the sound')
|
|
||||||
lines.append(u'To save a wretch like me;')
|
|
||||||
lines.append(u'I once was lost but now am found,')
|
|
||||||
lines.append(u'Was blind, but now I see.')
|
|
||||||
lines1=[]
|
|
||||||
lines1.append(u'Amazing Grace (John Newton)' )
|
|
||||||
lines1.append(u'CCLI xxx (c)Openlp.org')
|
|
||||||
answer=renderer.render_lines(lines, lines1)
|
|
||||||
return frame
|
return frame
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user