Fix up theme xml handling to new schema

This commit is contained in:
Tim Bentley 2010-10-05 20:52:28 +01:00
parent fc092ed919
commit 4e8a7f47eb
7 changed files with 355 additions and 201 deletions

View File

@ -87,16 +87,16 @@ body {
var transition = %s;
function show_video(state, path, volume, loop){
// Note, the preferred method for looping would be to use the
// Note, the preferred method for looping would be to use the
// video tag loop attribute.
// But QtWebKit doesn't support this. Neither does it support the
// onended event, hence the setInterval()
// In addition, setting the currentTime attribute to zero to restart
// the video raises an INDEX_SIZE_ERROR: DOM Exception 1
// To complicate it further, sometimes vid.currentTime stops
// To complicate it further, sometimes vid.currentTime stops
// slightly short of vid.duration and vid.ended is intermittent!
//
// Note, currently the background may go black between loops. Not
// Note, currently the background may go black between loops. Not
// desirable. Need to investigate using two <video>'s, and hiding/
// preloading one, and toggle between the two when looping.
@ -112,7 +112,7 @@ body {
vid2.volume = volume;
}
switch(state){
case 'init':
case 'init':
vid.src = path;
vid2.src = path;
if(loop == null) loop = false;
@ -129,8 +129,8 @@ body {
vid.style.visibility = 'visible';
if(vid.looping){
video_timer = setInterval(
function() {
show_video('poll');
function() {
show_video('poll');
}, 200);
}
break;
@ -447,17 +447,17 @@ def build_lyrics_css(item, webkitvers):
lyricsmain += build_lyrics_outline_css(theme)
else:
outline = build_lyrics_outline_css(theme)
if theme.display_shadow:
if theme.display_outline and webkitvers < 534.3:
if theme.font_main_shadow:
if theme.font_main_outline and webkitvers < 534.3:
shadow = u'padding-left: %spx; padding-top: %spx;' % \
(int(theme.display_shadow_size) +
(int(theme.display_outline_size) * 2),
theme.display_shadow_size)
(int(theme.font_main_shadow_size) +
(int(theme.font_main_outline_size) * 2),
theme.font_main_shadow_size)
shadow += build_lyrics_outline_css(theme, True)
else:
lyricsmain += u' text-shadow: %s %spx %spx;' % \
(theme.display_shadow_color, theme.display_shadow_size,
theme.display_shadow_size)
(theme.font_mainy_shadow_color, theme.font_main_shadow_size,
theme.font_main_shadow_size)
lyrics_css = style % (lyricstable, lyrics, lyricsmain, outline, shadow)
return lyrics_css
@ -472,14 +472,14 @@ def build_lyrics_outline_css(theme, is_shadow=False):
`is_shadow`
If true, use the shadow colors instead
"""
if theme.display_outline:
size = float(theme.display_outline_size) / 16
if theme.font_main_outline:
size = float(theme.font_main_outline_size) / 16
if is_shadow:
fill_color = theme.display_shadow_color
outline_color = theme.display_shadow_color
fill_color = theme.font_main_shadow_color
outline_color = theme.font_main_shadow_color
else:
fill_color = theme.font_main_color
outline_color = theme.display_outline_color
outline_color = theme.font_main_outline_color
return u' -webkit-text-stroke: %sem %s; ' \
u'-webkit-text-fill-color: %s; ' % (size, outline_color, fill_color)
else:
@ -512,8 +512,8 @@ def build_lyrics_format_css(theme, width, height):
valign = u'middle'
else:
valign = u'top'
if theme.display_outline:
left_margin = int(theme.display_outline_size) * 2
if theme.font_main_outline:
left_margin = int(theme.font_main_outline_size) * 2
else:
left_margin = 0
lyrics = u'white-space:pre-wrap; word-wrap: break-word; ' \
@ -523,12 +523,12 @@ def build_lyrics_format_css(theme, width, height):
(align, valign, theme.font_main_name, theme.font_main_proportion,
theme.font_main_color, 100 + int(theme.font_main_line_adjustment),
left_margin, width, height)
if theme.display_outline:
if theme.font_main_outline:
if webkit_version() < 534.3:
lyrics += u' letter-spacing: 1px;'
if theme.font_main_italics:
lyrics += u' font-style:italic; '
if theme.font_main_weight == u'Bold':
if theme.font_main_bold:
lyrics += u' font-weight:bold; '
return lyrics
@ -548,7 +548,7 @@ def build_lyrics_html(item, webkitvers):
# display:table/display:table-cell are required for each lyric block.
lyrics = u''
theme = item.themedata
if webkitvers < 534.4 and theme and theme.display_outline:
if webkitvers < 534.4 and theme and theme.font_main_outline:
lyrics += u'<div class="lyricstable">' \
u'<div id="lyricsshadow" style="opacity:1" ' \
u'class="lyricscell lyricsshadow"></div></div>'

View File

@ -90,9 +90,9 @@ class Renderer(object):
self._rect_footer = rect_footer
self.page_width = self._rect.width()
self.page_height = self._rect.height()
if self._theme.display_shadow:
self.page_width -= int(self._theme.display_shadow_size)
self.page_height -= int(self._theme.display_shadow_size)
if self._theme.font_main_shadow:
self.page_width -= int(self._theme.font_main_shadow_size)
self.page_height -= int(self._theme.font_main_shadow_size)
self.web = QtWebKit.QWebView()
self.web.setVisible(False)
self.web.resize(self.page_width, self.page_height)

View File

@ -31,6 +31,7 @@ import re
from xml.dom.minidom import Document
from xml.etree.ElementTree import ElementTree, XML
from lxml import etree, objectify
from openlp.core.lib import str_to_bool
@ -54,26 +55,27 @@ BLANK_THEME_XML = \
<name>Arial</name>
<color>#000000</color>
<proportion>30</proportion>
<weight>Normal</weight>
<bold>False</bold>
<italics>False</italics>
<line_adjustment>0</line_adjustment>
<shadow color="#ffffff" size="5">True</shadow>
<outline color="#ffffff" size="2">False</outline>
<location override="False" x="10" y="10" width="1004" height="690"/>
</font>
<font type="footer">
<name>Arial</name>
<color>#000000</color>
<proportion>12</proportion>
<weight>Normal</weight>
<bold>False</bold>
<italics>False</italics>
<shadow color="#000000" size="5">True</shadow>
<outline color="#000000" size="2">False</outline>
<line_adjustment>0</line_adjustment>
<location override="False" x="10" y="690" width="1004" height="78"/>
</font>
<display>
<shadow color="#000000" size="5">True</shadow>
<outline color="#000000" size="2">False</outline>
<horizontalAlign>0</horizontalAlign>
<verticalAlign>0</verticalAlign>
<wrapStyle>0</wrapStyle>
<slideTransition>False</slideTransition>
</display>
</theme>
@ -87,7 +89,7 @@ class ThemeLevel(object):
Service = 2
Song = 3
boolean_list = [u'italics', u'override', u'outline', u'shadow', \
boolean_list = [u'bold', u'italics', u'override', u'outline', u'shadow', \
u'slide_transition']
integer_list =[u'proportion', u'line_adjustment', u'x', u'height', u'y', \
@ -186,12 +188,13 @@ class ThemeXML(object):
background.setAttribute(u'mode', u'opaque')
background.setAttribute(u'type', u'image')
self.theme.appendChild(background)
#Create Filename element
# Create Filename element
self.child_element(background, u'filename', filename)
def add_font(self, name, color, proportion, override, fonttype=u'main',
weight=u'Normal', italics=u'False', line_adjustment=0,
xpos=0, ypos=0, width=0, height=0):
bold=u'False', italics=u'False', line_adjustment=0,
xpos=0, ypos=0, width=0, height=0 , outline=u'False', outline_color=u'#ffffff',
outline_pixel=2, shadow=u'False', shadow_color=u'#ffffff', shadow_pixel=5):
"""
Add a Font.
@ -227,25 +230,44 @@ class ThemeXML(object):
``height``
The height of the text block.
``outline``
Whether or not to show an outline.
``outline_color``
The colour of the outline.
``outline_size``
How big the Shadow is
``shadow``
Whether or not to show a shadow.
``shadow_color``
The colour of the shadow.
``shadow_size``
How big the Shadow is
"""
background = self.theme_xml.createElement(u'font')
background.setAttribute(u'type', fonttype)
self.theme.appendChild(background)
#Create Font name element
# Create Font name element
self.child_element(background, u'name', name)
#Create Font color element
# Create Font color element
self.child_element(background, u'color', color)
#Create Proportion name element
# Create Proportion name element
self.child_element(background, u'proportion', proportion)
#Create weight name element
self.child_element(background, u'weight', weight)
#Create italics name element
# Create weight name element
self.child_element(background, u'bold', bold)
# Create italics name element
self.child_element(background, u'italics', italics)
#Create indentation name element
# Create indentation name element
self.child_element(
background, u'line_adjustment', unicode(line_adjustment))
#Create Location element
# Create Location element
element = self.theme_xml.createElement(u'location')
element.setAttribute(u'override', override)
if override == u'True':
@ -254,72 +276,50 @@ class ThemeXML(object):
element.setAttribute(u'width', width)
element.setAttribute(u'height', height)
background.appendChild(element)
# Shadow
element = self.theme_xml.createElement(u'shadow')
element.setAttribute(u'shadowColor', unicode(shadow_color))
element.setAttribute(u'shadowSize', unicode(shadow_pixel))
value = self.theme_xml.createTextNode(unicode(shadow))
element.appendChild(value)
background.appendChild(element)
# Outline
element = self.theme_xml.createElement(u'outline')
element.setAttribute(u'outlineColor', unicode(outline_color))
element.setAttribute(u'outlineSize', unicode(outline_pixel))
value = self.theme_xml.createTextNode(unicode(outline))
element.appendChild(value)
background.appendChild(element)
def add_display(self, shadow, shadow_color, outline, outline_color,
horizontal, vertical, wrap, transition, shadow_pixel=5,
outline_pixel=2):
def add_display(self, horizontal, vertical, transition):
"""
Add a Display options.
``shadow``
Whether or not to show a shadow.
``shadow_color``
The colour of the shadow.
``outline``
Whether or not to show an outline.
``outline_color``
The colour of the outline.
``horizontal``
The horizontal alignment of the text.
``vertical``
The vertical alignment of the text.
``wrap``
Wrap style.
``transition``
Whether the slide transition is active.
"""
background = self.theme_xml.createElement(u'display')
self.theme.appendChild(background)
# Shadow
element = self.theme_xml.createElement(u'shadow')
element.setAttribute(u'color', shadow_color)
element.setAttribute(u'size', unicode(shadow_pixel))
value = self.theme_xml.createTextNode(shadow)
element.appendChild(value)
background.appendChild(element)
# Outline
element = self.theme_xml.createElement(u'outline')
element.setAttribute(u'color', outline_color)
element.setAttribute(u'size', unicode(outline_pixel))
value = self.theme_xml.createTextNode(outline)
element.appendChild(value)
background.appendChild(element)
# Horizontal alignment
element = self.theme_xml.createElement(u'horizontalAlign')
value = self.theme_xml.createTextNode(horizontal)
value = self.theme_xml.createTextNode(unicode(horizontal))
element.appendChild(value)
background.appendChild(element)
# Vertical alignment
element = self.theme_xml.createElement(u'verticalAlign')
value = self.theme_xml.createTextNode(vertical)
element.appendChild(value)
background.appendChild(element)
# Wrap style
element = self.theme_xml.createElement(u'wrapStyle')
value = self.theme_xml.createTextNode(wrap)
value = self.theme_xml.createTextNode(unicode(vertical))
element.appendChild(value)
background.appendChild(element)
# Slide Transition
element = self.theme_xml.createElement(u'slideTransition')
value = self.theme_xml.createTextNode(transition)
value = self.theme_xml.createTextNode(unicode(transition))
element.appendChild(value)
background.appendChild(element)
@ -359,7 +359,7 @@ class ThemeXML(object):
The XML string to parse.
"""
self.parse_xml(BLANK_THEME_XML)
self.parse_xml(xml)
self.parse_xml(unicode(xml))
def parse_xml(self, xml):
"""
@ -368,47 +368,69 @@ class ThemeXML(object):
``xml``
The XML string to parse.
"""
theme_xml = ElementTree(element=XML(xml.encode(u'ascii',
u'xmlcharrefreplace')))
# remove encoding string
if xml[:5] == u'<?xml':
xml = xml[38:]
try:
theme_xml = objectify.fromstring(xml)
except etree.XMLSyntaxError:
log.exception(u'Invalid xml %s', xml)
# print objectify.dump(theme_xml)
xml_iter = theme_xml.getiterator()
master = u''
for element in xml_iter:
if not isinstance(element.text, unicode):
element.text = unicode(str(element.text), u'utf-8')
if element.getchildren():
master = element.tag + u'_'
else:
# background transparent tags have no children so special case
if element.tag == u'background':
for e in element.attrib.iteritems():
self._create_attr(element.tag , e[0], e[1])
if element.attrib:
for e in element.attrib.iteritems():
if master == u'font_' and e[0] == u'type':
master += e[1] + u'_'
elif master == u'display_' and (element.tag == u'shadow' \
or element.tag == u'outline' ):
self._create_attr(master, element.tag, element.text)
self._create_attr(master, element.tag + u'_'+ e[0], e[1])
parent = element.getparent()
master = u''
if parent is not None:
if element.getparent().tag == u'font':
master = element.getparent().tag + u'_' + element.getparent().attrib[u'type']
if element.getparent().tag == u'display':
master = element.getparent().tag
if element.getparent().tag == u'background':
master = element.getparent().tag
if element.getparent().attrib:
for attr in element.getparent().attrib:
self._create_attr(master, attr, element.getparent().attrib[attr])
if master:
# the next few lines fix up errors in the XML to the current standard.
# move the fields from display to font_main
if master == u'display' and (element.tag == u'shadow' or element.tag == u'outline'):
master = u'font_main'
# fix bold font
if element.tag == u'weight':
if element.text.strip().lstrip() == u'Normal':
self._create_attr(master, u'bold', False)
else:
field = master + e[0]
self._create_attr(master, e[0], e[1])
self._create_attr(master, u'bold', True)
else:
# normal service happens here!
self._create_attr(master, element.tag, element.text)
if element.attrib:
# correction for the shadow and outline tags
if element.tag == u'shadow' or element.tag == u'outline':
master = master + '_' + element.tag
for attr in element.attrib:
self._create_attr(master, attr, element.attrib[attr])
else:
self._create_attr(master, element.tag, element.text)
else:
if element.tag:
element.text = element.text.strip().lstrip()
self._create_attr(master , element.tag, element.text)
if element.tag == u'name':
self._create_attr(u'theme', element.tag, element.text)
def _create_attr(self, master , element, value):
"""
Create the attributes with the correct data types and name format
"""
field = self._de_hump(element)
if field in boolean_list:
setattr(self, master + field, str_to_bool(value))
elif field in integer_list:
setattr(self, master + field, int(value))
tag = master + u'_' + field
if element in boolean_list:
setattr(self, tag, str_to_bool(value))
elif element in integer_list:
setattr(self, tag, int(value))
else:
setattr(self, master + field, unicode(value))
# make string value unicode
if not isinstance(value, unicode):
value = unicode(str(value), u'utf-8')
setattr(self, tag, unicode(value).strip().lstrip())
def __str__(self):
"""
@ -453,7 +475,13 @@ class ThemeXML(object):
unicode(self.font_main_x),
unicode(self.font_main_y),
unicode(self.font_main_width),
unicode(self.font_main_height))
unicode(self.font_main_height),
self.font_main_outline,
self.font_main_outline_color,
self.font_main_outline_size,
self.font_main_shadow,
self.font_main_shadow_color,
self.font_main_shadow_size)
self.add_font(unicode(self.font_footer_name),
unicode(self.font_footer_color),
unicode(self.font_footer_proportion),
@ -464,15 +492,13 @@ class ThemeXML(object):
unicode(self.font_footer_x),
unicode(self.font_footer_y),
unicode(self.font_footer_width),
unicode(self.font_footer_height))
self.add_display(unicode(self.display_shadow),
unicode(self.display_shadow_color),
unicode(self.display_outline),
unicode(self.display_outline_color),
unicode(self.display_horizontal_align),
unicode(self.display_vertical_align),
unicode(self.display_wrap_style),
unicode(self.display_slide_transition),
unicode(self.display_shadow_size),
unicode(self.display_outline_size))
unicode(self.font_footer_height),
self.font_footer_outline,
self.font_footer_outline_color,
self.font_footer_outline_size,
self.font_footer_shadow,
self.font_footer_shadow_color,
self.font_footer_shadow_size)
self.add_display(self.display_horizontal_align,
self.display_vertical_align,
self.display_slide_transition)

View File

@ -762,8 +762,8 @@ class ThemeManager(QtGui.QWidget):
u'30', u'False')
newtheme.add_font(unicode(QtGui.QFont().family()), u'#FFFFFF',
u'12', u'False', u'footer')
newtheme.add_display(u'False', u'#FFFFFF', u'False',
unicode(u'#FFFFFF'), u'0', u'0', u'0', u'False')
newtheme.add_display(u'0', u'0', u'0')
print newtheme.extract_xml()
return newtheme.extract_xml()
def createThemeFromXml(self, theme_xml, path):

View File

@ -2,7 +2,7 @@
# Form implementation generated from reading ui file 'themewizard.ui'
#
# Created: Sat Oct 2 08:13:48 2010
# Created: Sun Oct 3 17:44:50 2010
# by: PyQt4 UI code generator 4.7.4
#
# WARNING! All changes made in this file will be lost!
@ -20,10 +20,10 @@ class Ui_ThemeWizard(object):
self.welcomePage.setTitle("")
self.welcomePage.setSubTitle("")
self.welcomePage.setObjectName("welcomePage")
self.WelcomeLayout = QtGui.QHBoxLayout(self.welcomePage)
self.WelcomeLayout.setSpacing(8)
self.WelcomeLayout.setMargin(0)
self.WelcomeLayout.setObjectName("WelcomeLayout")
self.welcomeLayout = QtGui.QHBoxLayout(self.welcomePage)
self.welcomeLayout.setSpacing(8)
self.welcomeLayout.setMargin(0)
self.welcomeLayout.setObjectName("welcomeLayout")
self.importBibleImage = QtGui.QLabel(self.welcomePage)
self.importBibleImage.setMinimumSize(QtCore.QSize(163, 0))
self.importBibleImage.setMaximumSize(QtCore.QSize(163, 16777215))
@ -32,7 +32,7 @@ class Ui_ThemeWizard(object):
self.importBibleImage.setPixmap(QtGui.QPixmap(":/wizards/wizard_importbible.bmp"))
self.importBibleImage.setIndent(0)
self.importBibleImage.setObjectName("importBibleImage")
self.WelcomeLayout.addWidget(self.importBibleImage)
self.welcomeLayout.addWidget(self.importBibleImage)
self.welcomePageLayout = QtGui.QVBoxLayout()
self.welcomePageLayout.setSpacing(8)
self.welcomePageLayout.setObjectName("welcomePageLayout")
@ -48,7 +48,7 @@ class Ui_ThemeWizard(object):
self.welcomePageLayout.addWidget(self.informationLabel)
spacerItem1 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
self.welcomePageLayout.addItem(spacerItem1)
self.WelcomeLayout.addLayout(self.welcomePageLayout)
self.welcomeLayout.addLayout(self.welcomePageLayout)
ThemeWizard.addPage(self.welcomePage)
self.backgroundPage = QtGui.QWizardPage()
self.backgroundPage.setObjectName("backgroundPage")
@ -110,27 +110,27 @@ class Ui_ThemeWizard(object):
ThemeWizard.addPage(self.backgroundPage)
self.mainAreaPage = QtGui.QWizardPage()
self.mainAreaPage.setObjectName("mainAreaPage")
self.mainAreaLayout = QtGui.QFormLayout(self.mainAreaPage)
self.mainAreaLayout.setFieldGrowthPolicy(QtGui.QFormLayout.ExpandingFieldsGrow)
self.mainAreaLayout.setContentsMargins(50, 20, 20, 20)
self.mainAreaLayout.setSpacing(8)
self.mainAreaLayout.setObjectName("mainAreaLayout")
self.formLayout = QtGui.QFormLayout(self.mainAreaPage)
self.formLayout.setFormAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignTop)
self.formLayout.setContentsMargins(-1, 20, 20, 20)
self.formLayout.setSpacing(8)
self.formLayout.setObjectName("formLayout")
self.mainFontLabel = QtGui.QLabel(self.mainAreaPage)
self.mainFontLabel.setObjectName("mainFontLabel")
self.mainAreaLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.mainFontLabel)
self.formLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.mainFontLabel)
self.mainFontComboBox = QtGui.QFontComboBox(self.mainAreaPage)
self.mainFontComboBox.setObjectName("mainFontComboBox")
self.mainAreaLayout.setWidget(0, QtGui.QFormLayout.FieldRole, self.mainFontComboBox)
self.formLayout.setWidget(0, QtGui.QFormLayout.FieldRole, self.mainFontComboBox)
self.mainColorLabel = QtGui.QLabel(self.mainAreaPage)
self.mainColorLabel.setObjectName("mainColorLabel")
self.mainAreaLayout.setWidget(1, QtGui.QFormLayout.LabelRole, self.mainColorLabel)
self.formLayout.setWidget(1, QtGui.QFormLayout.LabelRole, self.mainColorLabel)
self.mainColorPushButton = QtGui.QPushButton(self.mainAreaPage)
self.mainColorPushButton.setText("")
self.mainColorPushButton.setObjectName("mainColorPushButton")
self.mainAreaLayout.setWidget(1, QtGui.QFormLayout.FieldRole, self.mainColorPushButton)
self.formLayout.setWidget(1, QtGui.QFormLayout.FieldRole, self.mainColorPushButton)
self.mainSizeLabel = QtGui.QLabel(self.mainAreaPage)
self.mainSizeLabel.setObjectName("mainSizeLabel")
self.mainAreaLayout.setWidget(2, QtGui.QFormLayout.LabelRole, self.mainSizeLabel)
self.formLayout.setWidget(2, QtGui.QFormLayout.LabelRole, self.mainSizeLabel)
self.mainSizeLayout = QtGui.QHBoxLayout()
self.mainSizeLayout.setSpacing(8)
self.mainSizeLayout.setMargin(0)
@ -149,23 +149,49 @@ class Ui_ThemeWizard(object):
self.mainLineCountLabel = QtGui.QLabel(self.mainAreaPage)
self.mainLineCountLabel.setObjectName("mainLineCountLabel")
self.mainSizeLayout.addWidget(self.mainLineCountLabel)
self.mainAreaLayout.setLayout(2, QtGui.QFormLayout.FieldRole, self.mainSizeLayout)
self.formLayout.setLayout(2, QtGui.QFormLayout.FieldRole, self.mainSizeLayout)
self.lineSpacingLabel = QtGui.QLabel(self.mainAreaPage)
self.lineSpacingLabel.setObjectName("lineSpacingLabel")
self.formLayout.setWidget(3, QtGui.QFormLayout.LabelRole, self.lineSpacingLabel)
self.lineSpacingSpinBox = QtGui.QSpinBox(self.mainAreaPage)
self.lineSpacingSpinBox.setMinimum(-50)
self.lineSpacingSpinBox.setMaximum(50)
self.lineSpacingSpinBox.setObjectName("lineSpacingSpinBox")
self.formLayout.setWidget(3, QtGui.QFormLayout.FieldRole, self.lineSpacingSpinBox)
self.mainOutlineCheckBox = QtGui.QCheckBox(self.mainAreaPage)
self.mainOutlineCheckBox.setObjectName("mainOutlineCheckBox")
self.mainAreaLayout.setWidget(3, QtGui.QFormLayout.LabelRole, self.mainOutlineCheckBox)
self.formLayout.setWidget(4, QtGui.QFormLayout.LabelRole, self.mainOutlineCheckBox)
self.outlineLayout = QtGui.QHBoxLayout()
self.outlineLayout.setObjectName("outlineLayout")
self.mainOutlineColorPushButton = QtGui.QPushButton(self.mainAreaPage)
self.mainOutlineColorPushButton.setEnabled(False)
self.mainOutlineColorPushButton.setText("")
self.mainOutlineColorPushButton.setObjectName("mainOutlineColorPushButton")
self.mainAreaLayout.setWidget(3, QtGui.QFormLayout.FieldRole, self.mainOutlineColorPushButton)
self.outlineLayout.addWidget(self.mainOutlineColorPushButton)
self.outlineSizeLabel = QtGui.QLabel(self.mainAreaPage)
self.outlineSizeLabel.setObjectName("outlineSizeLabel")
self.outlineLayout.addWidget(self.outlineSizeLabel)
self.outlineSizeSpinBox = QtGui.QSpinBox(self.mainAreaPage)
self.outlineSizeSpinBox.setObjectName("outlineSizeSpinBox")
self.outlineLayout.addWidget(self.outlineSizeSpinBox)
self.formLayout.setLayout(4, QtGui.QFormLayout.FieldRole, self.outlineLayout)
self.mainShadowCheckBox = QtGui.QCheckBox(self.mainAreaPage)
self.mainShadowCheckBox.setObjectName("mainShadowCheckBox")
self.mainAreaLayout.setWidget(4, QtGui.QFormLayout.LabelRole, self.mainShadowCheckBox)
self.formLayout.setWidget(5, QtGui.QFormLayout.LabelRole, self.mainShadowCheckBox)
self.shadowLayout = QtGui.QHBoxLayout()
self.shadowLayout.setObjectName("shadowLayout")
self.mainShadowColorPushButton = QtGui.QPushButton(self.mainAreaPage)
self.mainShadowColorPushButton.setEnabled(False)
self.mainShadowColorPushButton.setText("")
self.mainShadowColorPushButton.setObjectName("mainShadowColorPushButton")
self.mainAreaLayout.setWidget(4, QtGui.QFormLayout.FieldRole, self.mainShadowColorPushButton)
self.shadowLayout.addWidget(self.mainShadowColorPushButton)
self.shadowSizeLabel = QtGui.QLabel(self.mainAreaPage)
self.shadowSizeLabel.setObjectName("shadowSizeLabel")
self.shadowLayout.addWidget(self.shadowSizeLabel)
self.shadowSizeSpinBox = QtGui.QSpinBox(self.mainAreaPage)
self.shadowSizeSpinBox.setObjectName("shadowSizeSpinBox")
self.shadowLayout.addWidget(self.shadowSizeSpinBox)
self.formLayout.setLayout(5, QtGui.QFormLayout.FieldRole, self.shadowLayout)
ThemeWizard.addPage(self.mainAreaPage)
self.footerAreaPage = QtGui.QWizardPage()
self.footerAreaPage.setObjectName("footerAreaPage")
@ -428,9 +454,15 @@ class Ui_ThemeWizard(object):
self.mainColorLabel.setText(QtGui.QApplication.translate("ThemeWizard", "Color:", None, QtGui.QApplication.UnicodeUTF8))
self.mainSizeLabel.setText(QtGui.QApplication.translate("ThemeWizard", "Size:", None, QtGui.QApplication.UnicodeUTF8))
self.mainSizeSpinBox.setSuffix(QtGui.QApplication.translate("ThemeWizard", "pt", None, QtGui.QApplication.UnicodeUTF8))
self.mainLineCountLabel.setText(QtGui.QApplication.translate("ThemeWizard", "(%d lines per silde)", None, QtGui.QApplication.UnicodeUTF8))
self.mainLineCountLabel.setText(QtGui.QApplication.translate("ThemeWizard", "(%d lines per slide)", None, QtGui.QApplication.UnicodeUTF8))
self.lineSpacingLabel.setText(QtGui.QApplication.translate("ThemeWizard", "Line Spacing:", None, QtGui.QApplication.UnicodeUTF8))
self.lineSpacingSpinBox.setSuffix(QtGui.QApplication.translate("ThemeWizard", "pt", None, QtGui.QApplication.UnicodeUTF8))
self.mainOutlineCheckBox.setText(QtGui.QApplication.translate("ThemeWizard", "&Outline:", None, QtGui.QApplication.UnicodeUTF8))
self.outlineSizeLabel.setText(QtGui.QApplication.translate("ThemeWizard", "Size:", None, QtGui.QApplication.UnicodeUTF8))
self.outlineSizeSpinBox.setSuffix(QtGui.QApplication.translate("ThemeWizard", "pt", None, QtGui.QApplication.UnicodeUTF8))
self.mainShadowCheckBox.setText(QtGui.QApplication.translate("ThemeWizard", "&Shadow:", None, QtGui.QApplication.UnicodeUTF8))
self.shadowSizeLabel.setText(QtGui.QApplication.translate("ThemeWizard", "Size:", None, QtGui.QApplication.UnicodeUTF8))
self.shadowSizeSpinBox.setSuffix(QtGui.QApplication.translate("ThemeWizard", "pt", None, QtGui.QApplication.UnicodeUTF8))
self.footerAreaPage.setTitle(QtGui.QApplication.translate("ThemeWizard", "Footer Area Font Details", None, QtGui.QApplication.UnicodeUTF8))
self.footerAreaPage.setSubTitle(QtGui.QApplication.translate("ThemeWizard", "Define the font and display characteristics for the Footer text", None, QtGui.QApplication.UnicodeUTF8))
self.footerFontLabel.setText(QtGui.QApplication.translate("ThemeWizard", "Font:", None, QtGui.QApplication.UnicodeUTF8))

View File

@ -33,6 +33,52 @@ from themewizard import Ui_ThemeWizard
log = logging.getLogger(__name__)
class BackgroundType(object):
Solid = 0
Gradient = 1
Image = 3
@staticmethod
def to_string(type):
if type == BackgroundType.Solid:
return u'solid'
elif type == BackgroundType.Gradient:
return u'gradient'
elif type == BackgroundType.Image:
return u'image'
@staticmethod
def from_string(type_string):
if type_string == u'solid':
return BackgroundType.Solid
elif type_string == u'gradient':
return BackgroundType.Gradient
elif type_string == u'image':
return BackgroundType.Image
class BackgroundGradientType(object):
Horizontal = 0
Vertical = 1
Circular = 3
@staticmethod
def to_string(type):
if type == BackgroundType.Solid:
return u'horizontal'
elif type == BackgroundType.Gradient:
return u'vertical'
elif type == BackgroundType.Image:
return u'circular'
@staticmethod
def from_string(type_string):
if type_string == u'horizontal':
return BackgroundType.Solid
elif type_string == u'vertical':
return BackgroundType.Gradient
elif type_string == u'circular':
return BackgroundType.Image
class ThemeWizardForm(QtGui.QWizard, Ui_ThemeWizard):
"""
This is the Bible Import Wizard, which allows easy importing of Bibles
@ -54,8 +100,6 @@ class ThemeWizardForm(QtGui.QWizard, Ui_ThemeWizard):
The Bible plugin.
"""
# Do not translate as internal
self.backgrounds = [u'solid', u'gradient', u'image']
self.gradients = [u'horizontal', u'vertical', u'circular']
QtGui.QWizard.__init__(self, parent)
self.setupUi(self)
self.registerFields()
@ -75,7 +119,7 @@ class ThemeWizardForm(QtGui.QWizard, Ui_ThemeWizard):
self.onColor2PushButtonClicked)
QtCore.QObject.connect(self.imageBrowseButton,
QtCore.SIGNAL(u'pressed()'),
self.onimageBrowseButtonClicked)
self.onImageBrowseButtonClicked)
def exec_(self):
"""
@ -92,10 +136,10 @@ class ThemeWizardForm(QtGui.QWizard, Ui_ThemeWizard):
# Background Screen
if self.currentId() == 0:
print self.field(u'background_type').toString()
self.paintBackgroundScreen()
self.setBackgroundTabValues()
return True
def paintBackgroundScreen(self):
def setBackgroundTabValues(self):
if self.theme.background_type == u'solid':
self.setField(u'background_type', QtCore.QVariant(0))
self.color1PushButton.setVisible(True)
@ -153,7 +197,7 @@ class ThemeWizardForm(QtGui.QWizard, Ui_ThemeWizard):
def setDefaults(self):
self.restart()
self.paintBackgroundScreen()
self.setBackgroundTabValues()
def registerFields(self):
self.welcomePage.registerField(
@ -169,27 +213,27 @@ class ThemeWizardForm(QtGui.QWizard, Ui_ThemeWizard):
def onBackgroundComboBox(self, index):
self.theme.background_type = self.backgrounds[index]
self.paintBackgroundScreen()
self.setBackgroundTabValues()
def onGradientComboBox(self, index):
self.theme.background_direction = self.gradients[index]
self.paintBackgroundScreen()
self.setBackgroundTabValues()
def onColor1PushButtonClicked(self):
if self.theme.background_type == u'solid':
self.theme.background_color = \
self._colorButtonPushed(self.theme.background_color)
self._colorButton(self.theme.background_color)
else:
self.theme.background_start_color = \
self._colorButtonPushed(self.theme.background_start_color)
self.paintBackgroundScreen()
self._colorButton(self.theme.background_start_color)
self.setBackgroundTabValues()
def onColor2PushButtonClicked(self):
self.theme.background_end_color = \
self._colorButtonPushed(self.theme.background_end_color)
self.paintBackgroundScreen()
self._colorButton(self.theme.background_end_color)
self.setBackgroundTabValues()
def onimageBrowseButtonClicked(self):
def onImageBrowseButtonClicked(self):
images_filter = get_images_filter()
images_filter = '%s;;%s (*.*) (*)' % (images_filter,
translate('OpenLP.AmendThemeForm', 'All Files'))
@ -198,13 +242,11 @@ class ThemeWizardForm(QtGui.QWizard, Ui_ThemeWizard):
images_filter)
if filename:
self.theme.background_filename = filename
self.paintBackgroundScreen()
self.setBackgroundTabValues()
def _colorButtonPushed(self, field):
def _colorButton(self, field):
new_color = QtGui.QColorDialog.getColor(
QtGui.QColor(field), self)
if new_color.isValid():
field = new_color.name()
return field

View File

@ -29,7 +29,7 @@
<property name="subTitle">
<string/>
</property>
<layout class="QHBoxLayout" name="WelcomeLayout">
<layout class="QHBoxLayout" name="welcomeLayout">
<property name="spacing">
<number>8</number>
</property>
@ -57,7 +57,7 @@
<string/>
</property>
<property name="pixmap">
<pixmap resource="Projects/OpenLP/trunk/resources/images/openlp-2.qrc">:/wizards/wizard_importbible.bmp</pixmap>
<pixmap resource="../images/openlp-2.qrc">:/wizards/wizard_importbible.bmp</pixmap>
</property>
<property name="indent">
<number>0</number>
@ -224,7 +224,7 @@ p, li { white-space: pre-wrap; }
<string/>
</property>
<property name="icon">
<iconset resource="Projects/OpenLP/trunk/resources/images/openlp-2.qrc">
<iconset resource="../images/openlp-2.qrc">
<normaloff>:/general/general_open.png</normaloff>:/general/general_open.png</iconset>
</property>
</widget>
@ -266,9 +266,9 @@ p, li { white-space: pre-wrap; }
<property name="subTitle">
<string>Define the font and display characteristics for the Display text</string>
</property>
<layout class="QFormLayout" name="mainAreaLayout">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::ExpandingFieldsGrow</enum>
<layout class="QFormLayout" name="formLayout">
<property name="formAlignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="horizontalSpacing">
<number>8</number>
@ -276,9 +276,6 @@ p, li { white-space: pre-wrap; }
<property name="verticalSpacing">
<number>8</number>
</property>
<property name="leftMargin">
<number>50</number>
</property>
<property name="topMargin">
<number>20</number>
</property>
@ -355,45 +352,101 @@ p, li { white-space: pre-wrap; }
<item>
<widget class="QLabel" name="mainLineCountLabel">
<property name="text">
<string>(%d lines per silde)</string>
<string>(%d lines per slide)</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="3" column="0">
<widget class="QLabel" name="lineSpacingLabel">
<property name="text">
<string>Line Spacing:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QSpinBox" name="lineSpacingSpinBox">
<property name="suffix">
<string>pt</string>
</property>
<property name="minimum">
<number>-50</number>
</property>
<property name="maximum">
<number>50</number>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QCheckBox" name="mainOutlineCheckBox">
<property name="text">
<string>&amp;Outline:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QPushButton" name="mainOutlineColorPushButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string/>
</property>
</widget>
<item row="4" column="1">
<layout class="QHBoxLayout" name="outlineLayout">
<item>
<widget class="QPushButton" name="mainOutlineColorPushButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="outlineSizeLabel">
<property name="text">
<string>Size:</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="outlineSizeSpinBox">
<property name="suffix">
<string>pt</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="4" column="0">
<item row="5" column="0">
<widget class="QCheckBox" name="mainShadowCheckBox">
<property name="text">
<string>&amp;Shadow:</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QPushButton" name="mainShadowColorPushButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string/>
</property>
</widget>
<item row="5" column="1">
<layout class="QHBoxLayout" name="shadowLayout">
<item>
<widget class="QPushButton" name="mainShadowColorPushButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="shadowSizeLabel">
<property name="text">
<string>Size:</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="shadowSizeSpinBox">
<property name="suffix">
<string>pt</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
@ -972,7 +1025,8 @@ p, li { white-space: pre-wrap; }
</widget>
</widget>
<resources>
<include location="Projects/OpenLP/trunk/resources/images/openlp-2.qrc"/>
<include location="../images/openlp-2.qrc"/>
<include location="../images/openlp-2.qrc"/>
<include location="Projects/OpenLP/trunk/resources/images/openlp-2.qrc"/>
</resources>
<connections/>