Fix Rendering to allow dynamic placement of Main and Footers

Fix bugs in CustomPlugin
This commit is contained in:
Tim Bentley 2009-04-30 22:02:28 +01:00
parent e9279b4b12
commit 4fc7b974fa
8 changed files with 84 additions and 65 deletions

View File

@ -51,23 +51,36 @@ class RenderManager:
self.theme = self.default_theme
log.debug("theme is now %s", self.theme)
self.theme = self.theme_manager.getThemeData(self.theme)
self.renderer.set_theme(self.theme)
self.themedata = self.theme_manager.getThemeData(self.theme)
self.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))
self.renderer.set_theme(self.themedata)
if self.theme.font_main_override == False:
pass
if self.theme.font_footer_override == False:
pass
self.build_text_rectangle(self.themedata)
def build_text_rectangle(self, theme):
main_rect = None
footer_rect = None
if theme.font_main_override == False:
main_rect = QtCore.QRect(10,0, self.width-1, self.height-1)
else:
main_rect = QtCore.QRect(int(theme.font_main_x) , int(theme.font_main_y),
int(theme.font_main_width)-1, int(theme.font_main_height)-1)
if theme.font_footer_override == False:
footer_rect = QtCore.QRect(10,self.footer_start, self.width-1, self.height-self.footer_start)
else:
footer_rect = QtCore.QRect(int(theme.font_footer_x),int(theme.font_footer_y),
int(theme.font_footer_width)-1, int(theme.font_footer_height)-1)
self.renderer.set_text_rectangle(main_rect,footer_rect)
def generate_preview(self, themedata):
self.calculate_default(QtCore.QSize(800,600))
self.renderer.set_theme(themedata)
self.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))
self.build_text_rectangle(themedata)
frame = QtGui.QPixmap(self.width, self.height)
self.renderer.set_paint_dest(frame)
@ -87,8 +100,8 @@ class RenderManager:
def format_slide(self, words, footer):
self.calculate_default(QtCore.QSize(800,600))
self.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))
#self.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))
return self.renderer.format_slide(words, footer)
@ -96,12 +109,6 @@ class RenderManager:
if preview == True:
self.calculate_default(QtCore.QSize(800,600))
self.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))
#frame = QtGui.QPixmap(self.width, self.height)
#self.renderer.set_paint_dest(frame)
#print main_text
answer=self.renderer.render_lines(main_text, footer_text)
return self.frame

View File

@ -81,6 +81,7 @@ class SongXMLParser():
iter=self.song_xml.getiterator()
verse_list = []
for element in iter:
#print element.tag, element.attrib, element.text
if element.tag == u'verse':
verse_list.append([element.attrib, element.text])
return verse_list

View File

@ -151,11 +151,12 @@ class ThemeXML():
element = self.theme_xml.createElement(u'location')
element.setAttribute(u'override',override)
if override == True:
element.setAttribute(u'x',str(xpos))
element.setAttribute(u'y',str(ypos))
element.setAttribute(u'width',str(width))
element.setAttribute(u'height',str(height))
if override == u'True':
element.setAttribute(u'x',xpos)
element.setAttribute(u'y',ypos)
element.setAttribute(u'width',width)
element.setAttribute(u'height',height)
background.appendChild(element)
def add_display(self, shadow, shadowColor, outline, outlineColor, horizontal, vertical, wrap):

View File

@ -111,12 +111,21 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
#else:
#newtheme.add_background_image(str(self.theme.))
new_theme.add_font(str(self.theme.font_main_name), str(self.theme.font_main_color), str(self.theme.font_main_proportion), u'False')
new_theme.add_font(str(self.theme.font_footer_name), str(self.theme.font_footer_color), str(self.theme.font_footer_proportion), u'False', u'footer')
new_theme.add_display(str(self.theme.display_shadow), str(self.theme.display_shadow_color), str(self.theme.display_outline), str(self.theme.display_outline_color),
str(self.theme.display_horizontalAlign), str(self.theme.display_verticalAlign), str(self.theme.display_wrapStyle))
new_theme.add_font(str(self.theme.font_main_name), str(self.theme.font_main_color),
str(self.theme.font_main_proportion), str(self.theme.font_main_override),u'main',
str(self.theme.font_main_x), str(self.theme.font_main_y), str(self.theme.font_main_width),
str(self.theme.font_main_height))
new_theme.add_font(str(self.theme.font_footer_name), str(self.theme.font_footer_color),
str(self.theme.font_footer_proportion), str(self.theme.font_footer_override),u'footer',
str(self.theme.font_footer_x), str(self.theme.font_footer_y), str(self.theme.font_footer_width),
str(self.theme.font_footer_height) )
new_theme.add_display(str(self.theme.display_shadow), str(self.theme.display_shadow_color),
str(self.theme.display_outline), str(self.theme.display_outline_color),
str(self.theme.display_horizontalAlign), str(self.theme.display_verticalAlign),
str(self.theme.display_wrapStyle))
theme = new_theme.extract_xml()
self.thememanager.saveTheme(theme_name, theme)
return QtGui.QDialog.accept(self)
@ -208,27 +217,24 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
self.theme.font_footer_proportion = value
self.previewTheme(self.theme)
def onFontFooterDefaultCheckBoxChanged(self):
self.stateChanging(self.theme)
self.previewTheme(self.theme)
def onFontFooterDefaultCheckBoxChanged(self, value):
if value == 2: # checked
self.theme.font_footer_override = False
else:
self.theme.font_footer_override = True
if int(self.theme.font_footer_x) == 0 and int(self.theme.font_footer_y) == 0 and \
int(self.theme.font_footer_width) == 0 and int(self.theme.font_footer_height) == 0:
self.theme.font_footer_x = u'10'
self.theme.font_footer_y = u'730'
self.theme.font_footer_width = u'1024'
self.theme.font_footer_height = u'38'
self.FontFooterXSpinBox.setValue(int(self.theme.font_footer_x))
self.FontFooterYSpinBox.setValue(int(self.theme.font_footer_y))
self.FontFooterWidthSpinBox.setValue(int(self.theme.font_footer_width))
self.FontFooterHeightSpinBox.setValue(int(self.theme.font_footer_height))
if int(self.theme.font_footer_x) == 0 and int(self.theme.font_footer_y) == 0 and \
int(self.theme.font_footer_width) == 0 and int(self.theme.font_footer_height) == 0:
self.theme.font_footer_x = u'10'
self.theme.font_footer_y = u'730'
self.theme.font_footer_width = u'1024'
self.theme.font_footer_height = u'38'
self.FontFooterXSpinBox.setValue(int(self.theme.font_footer_x))
self.FontFooterYSpinBox.setValue(int(self.theme.font_footer_y))
self.FontFooterWidthSpinBox.setValue(int(self.theme.font_footer_width))
self.FontFooterHeightSpinBox.setValue(int(self.theme.font_footer_height))
self.stateChanging(self.theme)
self.previewTheme(self.theme)
@ -367,7 +373,6 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
return newtheme.extract_xml()
def paintUi(self, theme):
print theme # leave as helpful for initial development
self.stateChanging(theme)
self.ThemeNameEdit.setText(self.theme.theme_name)
if self.theme.background_mode == u'opaque':

View File

@ -143,7 +143,7 @@ class ServiceManager(QWidget):
QtCore.SIGNAL("activated(int)"), self.onThemeComboBoxSelected)
def onThemeComboBoxSelected(self, currentIndex):
self.renderManager.default_theme =self.ThemeComboBox.currentText()
self.renderManager.default_theme = self.ThemeComboBox.currentText()
def addServiceItem(self, item):
"""Adds service item"""

View File

@ -33,31 +33,35 @@ class SlideController(QtGui.QWidget):
self.PaneLayout.setSpacing(50)
self.PaneLayout.setMargin(0)
# self.Controller = QtGui.QGraphicsView(self.Splitter)
#self.VerseListView = QtGui.QListWidget(customEditDialog)
#self.VerseListView.setObjectName("VerseListView")
#self.horizontalLayout_4.addWidget(self.VerseListView)
self.Controller = QtGui.QScrollArea(self.Splitter)
self.Controller.setWidgetResizable(True)
self.ControllerContents = QtGui.QWidget(self.Controller)
self.ControllerContents.setGeometry(QtCore.QRect(0, 0, 228, 536))
self.Controller.setGeometry(QtCore.QRect(0, 0, 828, 536))
self.Controller.setWidget(self.ControllerContents)
#self.Screen = QtGui.QGraphicsView(self.Splitter)
#self.Screen.setMaximumSize(QtCore.QSize(16777215, 250))
self.ThemePreview = QtGui.QLabel(self.Splitter)
self.SlidePreview = QtGui.QLabel(self.Splitter)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.ThemePreview.sizePolicy().hasHeightForWidth())
self.ThemePreview.setSizePolicy(sizePolicy)
self.ThemePreview.setMinimumSize(QtCore.QSize(250, 190))
self.ThemePreview.setFrameShape(QtGui.QFrame.WinPanel)
self.ThemePreview.setFrameShadow(QtGui.QFrame.Sunken)
self.ThemePreview.setLineWidth(1)
self.ThemePreview.setScaledContents(True)
self.ThemePreview.setObjectName("ThemePreview")
sizePolicy.setHeightForWidth(self.SlidePreview.sizePolicy().hasHeightForWidth())
self.SlidePreview.setSizePolicy(sizePolicy)
self.SlidePreview.setMinimumSize(QtCore.QSize(250, 190))
self.SlidePreview.setFrameShape(QtGui.QFrame.WinPanel)
self.SlidePreview.setFrameShadow(QtGui.QFrame.Sunken)
self.SlidePreview.setLineWidth(1)
self.SlidePreview.setScaledContents(True)
self.SlidePreview.setObjectName("SlidePreview")
def previewFrame(self, frame):
self.ThemePreview.setPixmap(frame)
self.SlidePreview.setPixmap(frame)
imageLabel = QtGui.QLabel()
imageLabel.setPixmap(frame)
self.Controller.setWidget(imageLabel)

View File

@ -80,7 +80,7 @@ class EditCustomForm(QtGui.QDialog, Ui_customEditDialog):
if id != 0:
self.customSlide = self.custommanager.get_custom(id)
self.TitleEdit.setText(self.customSlide.title)
self.CreditEdit.setText(self.customSlide.title)
self.CreditEdit.setText(self.customSlide.credits)
songXML=SongXMLParser(self.customSlide.text)
verseList = songXML.get_verses()

View File

@ -194,10 +194,9 @@ class CustomMediaItem(MediaManagerItem):
id = self.CustomListData.getId(index)
customSlide = self.parent.custommanager.get_custom(id)
title = customSlide.title
credit = customSlide.title
credit = customSlide.credits
theme = customSlide.theme_name
print theme
if theme == u'' or theme == None:
if len(theme) == 0 or theme == None:
self.parent.render_manager.set_override_theme(None)
else:
self.parent.render_manager.set_override_theme(theme)
@ -206,11 +205,13 @@ class CustomMediaItem(MediaManagerItem):
verseList = songXML.get_verses()
for verse in verseList:
slide = self.parent.render_manager.format_slide(verse[1], False)
print verse
print slide
footer_lines.append(title + u' '+ credit)
frame=self.parent.render_manager.generate_slide(slide, footer_lines)
self.parent.preview_controller.previewFrame(frame)
if slide is not None:
frame=self.parent.render_manager.generate_slide(slide, footer_lines, False)
self.parent.preview_controller.previewFrame(frame)
def onCustomLiveClick(self):
pass