forked from openlp/openlp
Fix XML schema for naming
Fix ThemeManager and Renderer to cover changes Move code for Boolean Config issues Various code style fixes
This commit is contained in:
parent
6b4a5ff5d9
commit
a662404122
@ -52,9 +52,9 @@ class OpenLP(QtGui.QApplication):
|
||||
self.processEvents()
|
||||
screens = []
|
||||
# Decide how many screens we have and their size
|
||||
for i in range (0 , self.desktop().numScreens()):
|
||||
screens.insert(i, (i+1, self.desktop().availableGeometry(i+1)))
|
||||
log.info(u'Screen %d found with resolution %s', i+1, self.desktop().availableGeometry(i+1))
|
||||
for screen in xrange (0 , self.desktop().numScreens()):
|
||||
screens.insert(screen, (screen+1, self.desktop().availableGeometry(screen+1)))
|
||||
log.info(u'Screen %d found with resolution %s', screen+1, self.desktop().availableGeometry(screen+1))
|
||||
# start the main app window
|
||||
self.main_window = MainWindow(screens)
|
||||
self.main_window.show()
|
||||
|
@ -15,3 +15,10 @@ 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
|
||||
"""
|
||||
__all__ = ['convertStringToBoolean']
|
||||
|
||||
def convertStringToBoolean(stringvalue):
|
||||
if stringvalue.lower() == 'true':
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
@ -3,7 +3,7 @@
|
||||
"""
|
||||
OpenLP - Open Source Lyrics Projection
|
||||
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
|
||||
the terms of the GNU General Public License as published by the Free Software
|
||||
@ -23,11 +23,11 @@ from render import Renderer
|
||||
from settingsmanager import SettingsManager
|
||||
from pluginmanager import PluginManager
|
||||
|
||||
__all__ = ['Renderer', 'SettingsManager', 'PluginManager', 'translate', 'fileToXML']
|
||||
__all__ = ['Renderer', 'SettingsManager', 'PluginManager', 'translate',
|
||||
'fileToXML' ]
|
||||
|
||||
def translate(context, text):
|
||||
return QtGui.QApplication.translate(context, text, None, QtGui.QApplication.UnicodeUTF8)
|
||||
|
||||
def fileToXML(xmlfile):
|
||||
return open(xmlfile).read()
|
||||
|
||||
|
@ -19,7 +19,6 @@ Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
"""
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
from openlp.core.resources import *
|
||||
from openlp.core.lib import PluginConfig
|
||||
|
||||
class SettingsTab(QtGui.QWidget):
|
||||
@ -39,7 +38,7 @@ class SettingsTab(QtGui.QWidget):
|
||||
else:
|
||||
self.config = PluginConfig(str(title))
|
||||
self.load()
|
||||
|
||||
|
||||
def setTitle(self, title):
|
||||
self.tabTitle = title
|
||||
|
||||
@ -51,15 +50,9 @@ class SettingsTab(QtGui.QWidget):
|
||||
|
||||
def retranslateUi(self):
|
||||
pass
|
||||
|
||||
|
||||
def load(self):
|
||||
pass
|
||||
|
||||
|
||||
def save(self):
|
||||
pass
|
||||
|
||||
def convertStringToBoolean(self, stringvalue):
|
||||
if stringvalue.lower() == 'true':
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
@ -21,9 +21,50 @@ from xml.etree.ElementTree import ElementTree, XML, dump
|
||||
|
||||
For XML Schema see wiki.openlp.org
|
||||
"""
|
||||
|
||||
from openlp import convertStringToBoolean
|
||||
from xml.dom.minidom import Document
|
||||
from xml.etree.ElementTree import ElementTree, XML, dump
|
||||
|
||||
blankthemexml=\
|
||||
'''<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<theme version="1.0">
|
||||
<name>BlankStyle</name>
|
||||
<background mode="transparent"/>
|
||||
<background type="solid" mode="opaque">
|
||||
<color>#000000</color>
|
||||
</background>
|
||||
<background type="gradient" mode="opaque">
|
||||
<startColor>#000000</startColor>
|
||||
<endColor>#000000</endColor>
|
||||
<direction>vertical</direction>
|
||||
</background>
|
||||
<background type="image" mode="opaque">
|
||||
<filename>fred.bmp</filename>
|
||||
</background>
|
||||
<font type="main">
|
||||
<name>Arial</name>
|
||||
<color>#000000</color>
|
||||
<proportion>30</proportion>
|
||||
<location overide="False">
|
||||
</location>
|
||||
</font>
|
||||
<font type="footer">
|
||||
<name>Arial</name>
|
||||
<color>#000000</color>
|
||||
<proportion>12</proportion>
|
||||
<location overide="True" x="10" y="10" width="100" height="150"/>
|
||||
</font>
|
||||
<display>
|
||||
<shadow color="#000000">True</shadow>
|
||||
<outline color="#000000">False</outline>
|
||||
<horizontalAlign>0</horizontalAlign>
|
||||
<verticalAlign>0</verticalAlign>
|
||||
<wrapStyle>0</wrapStyle>
|
||||
</display>
|
||||
</theme>
|
||||
'''
|
||||
|
||||
class ThemeXML():
|
||||
def __init__(self):
|
||||
# Create the minidom document
|
||||
@ -31,11 +72,11 @@ class ThemeXML():
|
||||
|
||||
def new_document(self, name):
|
||||
# Create the <song> base element
|
||||
self.theme = self.theme_xml.createElement(u'Theme')
|
||||
self.theme = self.theme_xml.createElement(u'theme')
|
||||
self.theme_xml.appendChild(self.theme)
|
||||
self.theme.setAttribute(u'version', u'1.0')
|
||||
|
||||
self.name = self.theme_xml.createElement(u'Name')
|
||||
self.name = self.theme_xml.createElement(u'name')
|
||||
ctn = self.theme_xml.createTextNode(name)
|
||||
self.name.appendChild(ctn)
|
||||
self.theme.appendChild(self.name)
|
||||
@ -52,30 +93,23 @@ class ThemeXML():
|
||||
background.setAttribute(u'type', u'solid')
|
||||
self.theme.appendChild(background)
|
||||
|
||||
color = self.theme_xml.createElement(u'color1')
|
||||
color = self.theme_xml.createElement(u'color')
|
||||
bkc = self.theme_xml.createTextNode(bkcolor)
|
||||
color.appendChild(bkc)
|
||||
background.appendChild(color)
|
||||
|
||||
color = self.theme_xml.createElement(u'color2')
|
||||
background.appendChild(color)
|
||||
|
||||
color = self.theme_xml.createElement(u'direction')
|
||||
background.appendChild(color)
|
||||
|
||||
|
||||
def add_background_gradient(self, startcolor, endcolor, direction):
|
||||
background = self.theme_xml.createElement(u'background')
|
||||
background.setAttribute(u'mode', u'opaque')
|
||||
background.setAttribute(u'type', u'gradient')
|
||||
self.theme.appendChild(background)
|
||||
|
||||
color = self.theme_xml.createElement(u'color1')
|
||||
color = self.theme_xml.createElement(u'startcolor')
|
||||
bkc = self.theme_xml.createTextNode(startcolor)
|
||||
color.appendChild(bkc)
|
||||
background.appendChild(color)
|
||||
|
||||
color = self.theme_xml.createElement(u'color2')
|
||||
color = self.theme_xml.createElement(u'endcolor')
|
||||
bkc = self.theme_xml.createTextNode(endcolor)
|
||||
color.appendChild(bkc)
|
||||
background.appendChild(color)
|
||||
@ -96,33 +130,34 @@ class ThemeXML():
|
||||
color.appendChild(bkc)
|
||||
background.appendChild(color)
|
||||
|
||||
def add_font(self, fontname, fontcolor, fontproportion, override, fonttype=u'main', xpos=0, ypos=0 ,width=0, height=0):
|
||||
def add_font(self, name, color, proportion, override, fonttype=u'main', xpos=0, ypos=0 ,width=0, height=0):
|
||||
background = self.theme_xml.createElement(u'font')
|
||||
background.setAttribute(u'type',fonttype)
|
||||
self.theme.appendChild(background)
|
||||
|
||||
name = self.theme_xml.createElement(u'name')
|
||||
fn = self.theme_xml.createTextNode(fontname)
|
||||
name.appendChild(fn)
|
||||
background.appendChild(name)
|
||||
element = self.theme_xml.createElement(u'name')
|
||||
fn = self.theme_xml.createTextNode(name)
|
||||
element.appendChild(fn)
|
||||
background.appendChild(element)
|
||||
|
||||
name = self.theme_xml.createElement(u'color')
|
||||
fn = self.theme_xml.createTextNode(fontcolor)
|
||||
name.appendChild(fn)
|
||||
background.appendChild(name)
|
||||
element = self.theme_xml.createElement(u'color')
|
||||
fn = self.theme_xml.createTextNode(color)
|
||||
element.appendChild(fn)
|
||||
background.appendChild(element)
|
||||
|
||||
name = self.theme_xml.createElement(u'proportion')
|
||||
fn = self.theme_xml.createTextNode(fontproportion)
|
||||
name.appendChild(fn)
|
||||
background.appendChild(name)
|
||||
element = self.theme_xml.createElement(u'proportion')
|
||||
fn = self.theme_xml.createTextNode(proportion)
|
||||
element.appendChild(fn)
|
||||
background.appendChild(element)
|
||||
|
||||
name = self.theme_xml.createElement(u'location')
|
||||
name.setAttribute(u'override',override)
|
||||
name.setAttribute(u'x',str(xpos))
|
||||
name.setAttribute(u'y',str(ypos))
|
||||
name.setAttribute(u'width',str(width))
|
||||
name.setAttribute(u'height',str(height))
|
||||
background.appendChild(name)
|
||||
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))
|
||||
background.appendChild(element)
|
||||
|
||||
def add_display(self, shadow, shadowColor, outline, outlineColor, horizontal, vertical, wrap):
|
||||
background = self.theme_xml.createElement(u'display')
|
||||
@ -170,6 +205,13 @@ class ThemeXML():
|
||||
return self.theme_xml.toxml()
|
||||
|
||||
def parse(self, xml):
|
||||
self.baseParseXml()
|
||||
self.parse_xml(xml)
|
||||
|
||||
def baseParseXml(self):
|
||||
self.parse_xml(blankthemexml)
|
||||
|
||||
def parse_xml(self, xml):
|
||||
theme_xml = ElementTree(element=XML(xml))
|
||||
iter=theme_xml.getiterator()
|
||||
master = u''
|
||||
@ -185,13 +227,14 @@ class ThemeXML():
|
||||
master += e[1] + u'_'
|
||||
elif master == u'display_' and (element.tag == u'shadow' or element.tag == u'outline'):
|
||||
#print "b", master, element.tag, element.text, e[0], e[1]
|
||||
setattr(self, master + element.tag , element.text)
|
||||
et = convertStringToBoolean(element.text)
|
||||
setattr(self, master + element.tag , et)
|
||||
setattr(self, master + element.tag +u'_'+ e[0], e[1])
|
||||
else:
|
||||
field = master + e[0]
|
||||
setattr(self, field, e[1])
|
||||
else:
|
||||
#print "c", element.tag
|
||||
#print "c", element.tag, element.text
|
||||
if element.tag is not None :
|
||||
field = master + element.tag
|
||||
setattr(self, field, element.text)
|
||||
|
@ -18,12 +18,12 @@ 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 copy import copy
|
||||
#from interpolate import interpolate
|
||||
|
||||
class Renderer:
|
||||
|
||||
@ -40,7 +40,7 @@ class Renderer:
|
||||
tell it to render a particular screenfull with render_screen(n)
|
||||
|
||||
"""
|
||||
def __init__(self):
|
||||
def __init__(self, path=None):
|
||||
self._rect=None
|
||||
self._debug=0
|
||||
self.words=None
|
||||
@ -50,6 +50,7 @@ class Renderer:
|
||||
self._theme=None
|
||||
self._bg_image_filename=None
|
||||
self._paint=None
|
||||
self._path = path
|
||||
|
||||
def set_debug(self, debug):
|
||||
self._debug=debug
|
||||
@ -61,7 +62,9 @@ class Renderer:
|
||||
|
||||
def set_bg_image(self, filename):
|
||||
log.debug(u'set bg image %s', filename)
|
||||
self._bg_image_filename=filename
|
||||
|
||||
self._bg_image_filename=os.path.join(self._path, self._theme.theme_name, filename)
|
||||
print self._bg_image_filename
|
||||
if self._paint is not None:
|
||||
self.scale_bg_image()
|
||||
|
||||
@ -71,6 +74,7 @@ class Renderer:
|
||||
# rescale and offset
|
||||
imw=i.width()
|
||||
imh=i.height()
|
||||
print imw, imh
|
||||
dcw=self._paint.width()+1
|
||||
dch=self._paint.height()
|
||||
imratio=imw/float(imh)
|
||||
@ -128,7 +132,7 @@ class Renderer:
|
||||
p=QtGui.QPainter()
|
||||
p.begin(self._paint)
|
||||
if self._theme.background_type == u'solid':
|
||||
p.fillRect(self._paint.rect(), QtGui.QColor(self._theme.background_color1))
|
||||
p.fillRect(self._paint.rect(), QtGui.QColor(self._theme.background_color))
|
||||
elif self._theme.background_type == u'gradient' : # gradient
|
||||
gradient = None
|
||||
if self._theme.background_direction == u'vertical':
|
||||
@ -142,8 +146,8 @@ class Renderer:
|
||||
h = int(self._paint.height())/2
|
||||
gradient = QtGui.QRadialGradient(w, h, w) # Circular
|
||||
|
||||
gradient.setColorAt(0, QtGui.QColor(self._theme.background_color1))
|
||||
gradient.setColorAt(1, QtGui.QColor(self._theme.background_color2))
|
||||
gradient.setColorAt(0, QtGui.QColor(self._theme.background_startColor))
|
||||
gradient.setColorAt(1, QtGui.QColor(self._theme.background_endColor))
|
||||
|
||||
p.setBrush(QtGui.QBrush(gradient))
|
||||
rectPath = QtGui.QPainterPath()
|
||||
@ -161,9 +165,9 @@ class Renderer:
|
||||
elif self._theme.background_type== u'image': # image
|
||||
r=self._paint.rect()
|
||||
log.debug(u'Image size details %d %d %d %d ', r.x(), r.y(), r.width(),r.height())
|
||||
log.debug(u' Background Parameter %d ', self._theme.background_borderColor)
|
||||
if self._theme.Bbackground_borderColor is not None:
|
||||
p.fillRect(self._paint.rect(), self._theme.background_borderColor)
|
||||
#log.debug(u' Background Parameter %d ', self._theme.background_color1)
|
||||
#if self._theme.background_color1 is not None:
|
||||
# p.fillRect(self._paint.rect(), self._theme.background_borderColor)
|
||||
p.drawPixmap(self.background_offsetx,self.background_offsety, self.img)
|
||||
p.end()
|
||||
log.debug(u'render background done')
|
||||
@ -192,7 +196,7 @@ class Renderer:
|
||||
endline=startline+ratio
|
||||
while (endline<=numlines):
|
||||
by=0
|
||||
for (x,y) in bboxes[startline:endline]:
|
||||
for (x, y) in bboxes[startline:endline]:
|
||||
by+=y
|
||||
if by > bottom:
|
||||
good=0
|
||||
@ -220,7 +224,7 @@ class Renderer:
|
||||
endline=startline+1
|
||||
while (endline<=numlines):
|
||||
by=0
|
||||
for (x,y) in bboxes[startline:endline]:
|
||||
for (x, y) in bboxes[startline:endline]:
|
||||
by+=y
|
||||
if by > bottom:
|
||||
retval.append(lines[startline:endline-1])
|
||||
@ -237,7 +241,7 @@ class Renderer:
|
||||
y = rect.top()
|
||||
elif int(self._theme.display_verticalAlign) == 1: # bottom align
|
||||
y=rect.bottom()-bbox.height()
|
||||
elif int(t.display_verticalAlign) == 2: # centre align
|
||||
elif int(self._theme.display_verticalAlign) == 2: # centre align
|
||||
y=rect.top()+(rect.height()-bbox.height())/2
|
||||
else:
|
||||
assert(0, u'Invalid value for theme.VerticalAlign:%s' % self._theme.display_verticalAlign)
|
||||
@ -254,11 +258,11 @@ class Renderer:
|
||||
# put stuff on background so need to reset before doing the job properly.
|
||||
self._render_background()
|
||||
x, y = self._correctAlignment(self._rect, bbox)
|
||||
bbox=self._render_lines_unaligned(lines, False, (x,y))
|
||||
bbox=self._render_lines_unaligned(lines, False, (x, y))
|
||||
|
||||
if lines1 is not None:
|
||||
x, y = self._correctAlignment(self._rect_footer, bbox1)
|
||||
bbox=self._render_lines_unaligned(lines1, True, (x,y) )
|
||||
bbox=self._render_lines_unaligned(lines1, True, (x, y) )
|
||||
|
||||
log.debug(u'render lines DONE')
|
||||
|
||||
@ -273,7 +277,7 @@ class Renderer:
|
||||
|
||||
Returns the bounding box of the text as QRect"""
|
||||
log.debug(u'render unaligned %s', lines)
|
||||
x,y=tlcorner
|
||||
x, y=tlcorner
|
||||
brx=x
|
||||
bry=y
|
||||
for line in lines:
|
||||
@ -284,7 +288,7 @@ class Renderer:
|
||||
(thisx, bry) = self._render_single_line(line, footer, (x,bry))
|
||||
if (thisx > brx):
|
||||
brx=thisx
|
||||
retval=QtCore.QRect(x,y,brx-x, bry-y)
|
||||
retval=QtCore.QRect(x, y,brx-x, bry-y)
|
||||
if self._debug:
|
||||
p=QtGui.QPainter()
|
||||
p.begin(self._paint)
|
||||
@ -303,10 +307,10 @@ class Renderer:
|
||||
If the line is too wide for the context, it wraps, but
|
||||
right-aligns the surplus words in the manner of song lyrics
|
||||
|
||||
Returns the bottom-right corner (of what was rendered) as a tuple(x,y).
|
||||
Returns the bottom-right corner (of what was rendered) as a tuple(x, y).
|
||||
"""
|
||||
#log.debug(u'Render single line %s @ %s '%( line, tlcorner))
|
||||
x,y=tlcorner
|
||||
x, y=tlcorner
|
||||
# We draw the text to see how big it is and then iterate to make it fit
|
||||
# when we line wrap we do in in the "lyrics" style, so the second line is
|
||||
# right aligned with a "hanging indent"
|
||||
@ -334,12 +338,13 @@ class Renderer:
|
||||
rightextent=None
|
||||
t=self._theme
|
||||
align=t.display_horizontalAlign
|
||||
|
||||
wrapstyle=t.display_wrapStyle
|
||||
|
||||
for linenum in range(len(lines)):
|
||||
line=lines[linenum]
|
||||
#find out how wide line is
|
||||
w,h=self._get_extent_and_render(line, footer, tlcorner=(x,y), draw=False)
|
||||
w,h=self._get_extent_and_render(line, footer, tlcorner=(x, y), draw=False)
|
||||
|
||||
if t.display_shadow:
|
||||
w+=self._shadow_offset
|
||||
@ -367,8 +372,8 @@ class Renderer:
|
||||
draw=True, color = t.display_shadow_color)
|
||||
if t.display_outline:
|
||||
self._get_extent_and_render(line, footer,(x+self._outline_offset,y), draw=True, color = t.display_outline_color)
|
||||
self._get_extent_and_render(line, footer,(x,y+self._outline_offset), draw=True, color = t.display_outline_color)
|
||||
self._get_extent_and_render(line, footer,(x,y-self._outline_offset), draw=True, color = t.display_outline_color)
|
||||
self._get_extent_and_render(line, footer,(x, y+self._outline_offset), draw=True, color = t.display_outline_color)
|
||||
self._get_extent_and_render(line, footer,(x, y-self._outline_offset), draw=True, color = t.display_outline_color)
|
||||
self._get_extent_and_render(line, footer,(x-self._outline_offset,y), draw=True, color = t.display_outline_color)
|
||||
if self._outline_offset > 1:
|
||||
self._get_extent_and_render(line, footer,(x+self._outline_offset,y+self._outline_offset), draw=True, color = t.display_outline_color)
|
||||
@ -376,7 +381,7 @@ class Renderer:
|
||||
self._get_extent_and_render(line, footer,(x+self._outline_offset,y-self._outline_offset), draw=True, color = t.display_outline_color)
|
||||
self._get_extent_and_render(line, footer,(x-self._outline_offset,y-self._outline_offset), draw=True, color = t.display_outline_color)
|
||||
|
||||
self._get_extent_and_render(line, footer,tlcorner=(x,y), draw=True)
|
||||
self._get_extent_and_render(line, footer,tlcorner=(x, y), draw=True)
|
||||
# log.debug(u'Line %2d: Render '%s' at (%d, %d) wh=(%d,%d)' % ( linenum, line, x, y,w,h)
|
||||
y += h
|
||||
if linenum == 0:
|
||||
@ -386,7 +391,7 @@ class Renderer:
|
||||
p=QtGui.QPainter()
|
||||
p.begin(self._paint)
|
||||
p.setPen(QtGui.QPen(QtGui.QColor(0,255,0)))
|
||||
p.drawRect(startx,starty,rightextent-startx,y-starty)
|
||||
p.drawRect(startx,starty,rightextent-startx, y-starty)
|
||||
p.end()
|
||||
|
||||
brcorner=(rightextent,y)
|
||||
@ -429,12 +434,12 @@ class Renderer:
|
||||
p.setPen(QtGui.QColor(self._theme.font_main_color))
|
||||
else:
|
||||
p.setPen(QtGui.QColor(color))
|
||||
x,y=tlcorner
|
||||
x, y=tlcorner
|
||||
metrics=QtGui.QFontMetrics(font)
|
||||
# xxx some fudges to make it exactly like wx! Take 'em out later
|
||||
w=metrics.width(line)
|
||||
h=metrics.height()-2
|
||||
if draw:
|
||||
p.drawText(x,y+metrics.height()-metrics.descent()-1, line)
|
||||
p.drawText(x, y+metrics.height()-metrics.descent()-1, line)
|
||||
p.end()
|
||||
return (w, h)
|
||||
|
@ -97,29 +97,44 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
|
||||
def onBackgroundTypeComboBoxSelected(self):
|
||||
if self.BackgroundTypeComboBox.currentIndex() == 0: # Solid
|
||||
self.theme.background_type = u'solid'
|
||||
if self.theme.background_direction == None: # never defined
|
||||
self.theme.background_direction = u'horizontal'
|
||||
if self.theme.background_startColor is None :
|
||||
self.theme.background_startColor = u'#000000'
|
||||
if self.theme.background_endColor is None :
|
||||
self.theme.background_endColor = u'#000000'
|
||||
elif self.BackgroundTypeComboBox.currentIndex() == 1: # Gradient
|
||||
self.theme.background_type = u'gradient'
|
||||
if self.theme.background_direction == None: # never defined
|
||||
self.theme.background_direction = u'horizontal'
|
||||
self.theme.background_color2 = u'#000000'
|
||||
if self.theme.background_startColor is None :
|
||||
self.theme.background_startColor = u'#000000'
|
||||
if self.theme.background_endColor is None :
|
||||
self.theme.background_endColor = u'#000000'
|
||||
else:
|
||||
self.theme.background_type = u'image'
|
||||
self.stateChanging(self.theme)
|
||||
self.generateImage(self.theme)
|
||||
|
||||
def onColor1PushButtonClicked(self):
|
||||
self.theme.background_color1 = QtGui.QColorDialog.getColor(
|
||||
QColor(self.theme.background_color1), self).name()
|
||||
self.Color1PushButton.setStyleSheet(
|
||||
'background-color: %s' % str(self.theme.background_color1))
|
||||
if self.theme.background_type == u'solid':
|
||||
self.theme.background_color = QtGui.QColorDialog.getColor(
|
||||
QColor(self.theme.background_color), self).name()
|
||||
self.Color1PushButton.setStyleSheet(
|
||||
'background-color: %s' % str(self.theme.background_color))
|
||||
else:
|
||||
self.theme.background_startColor = QtGui.QColorDialog.getColor(
|
||||
QColor(self.theme.background_startColor), self).name()
|
||||
self.Color1PushButton.setStyleSheet(
|
||||
'background-color: %s' % str(self.theme.background_startColor))
|
||||
|
||||
self.generateImage(self.theme)
|
||||
|
||||
def onColor2PushButtonClicked(self):
|
||||
self.theme.background_color2 = QtGui.QColorDialog.getColor(
|
||||
QColor(self.theme.background_color2), self).name()
|
||||
self.theme.background_endColor = QtGui.QColorDialog.getColor(
|
||||
QColor(self.theme.background_endColor), self).name()
|
||||
self.Color2PushButton.setStyleSheet(
|
||||
'background-color: %s' % str(self.theme.background_color2))
|
||||
'background-color: %s' % str(self.theme.background_endColor))
|
||||
|
||||
self.generateImage(self.theme)
|
||||
|
||||
@ -165,7 +180,7 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
|
||||
def stateChanging(self, theme):
|
||||
if theme.background_type == u'solid':
|
||||
self.Color1PushButton.setStyleSheet(
|
||||
'background-color: %s' % str(theme.background_color1))
|
||||
'background-color: %s' % str(theme.background_color))
|
||||
self.Color1Label.setText(translate(u'ThemeManager', u'Background Font:'))
|
||||
self.Color1Label.setVisible(True)
|
||||
self.Color1PushButton.setVisible(True)
|
||||
@ -173,9 +188,9 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
|
||||
self.Color2PushButton.setVisible(False)
|
||||
elif theme.background_type == u'gradient':
|
||||
self.Color1PushButton.setStyleSheet(
|
||||
'background-color: %s' % str(theme.background_color1))
|
||||
'background-color: %s' % str(theme.background_startColor))
|
||||
self.Color2PushButton.setStyleSheet(
|
||||
'background-color: %s' % str(theme.background_color2))
|
||||
'background-color: %s' % str(theme.background_endColor))
|
||||
self.Color1Label.setText(translate(u'ThemeManager', u'First Color:'))
|
||||
self.Color2Label.setText(translate(u'ThemeManager', u'Second Color:'))
|
||||
self.Color1Label.setVisible(True)
|
||||
@ -197,7 +212,7 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
|
||||
frame=TstFrame(size)
|
||||
frame=frame
|
||||
paintdest=frame.GetPixmap()
|
||||
r=Renderer()
|
||||
r=Renderer(self.path)
|
||||
r.set_paint_dest(paintdest)
|
||||
|
||||
r.set_theme(theme) # set default theme
|
||||
|
@ -236,6 +236,8 @@ class ThemeManager(QWidget):
|
||||
def unzipTheme(self, filename, dir):
|
||||
log.debug(u'Unzipping theme %s', filename)
|
||||
zip = zipfile.ZipFile(str(filename))
|
||||
filexml = None
|
||||
themename = None
|
||||
for file in zip.namelist():
|
||||
if file.endswith('/'):
|
||||
theme_dir = os.path.join(dir, file)
|
||||
@ -243,21 +245,25 @@ class ThemeManager(QWidget):
|
||||
os.mkdir(os.path.join(dir, file))
|
||||
else:
|
||||
fullpath = os.path.join(dir, file)
|
||||
names = file.split(u'/')
|
||||
if themename is None:
|
||||
names = file.split(u'/')
|
||||
themename = names[0]
|
||||
xml_data = zip.read(file)
|
||||
if os.path.splitext (file) [1].lower () in [u'.xml']:
|
||||
if self.checkVersion1(xml_data):
|
||||
filexml = self.migrateVersion122(filename, fullpath, xml_data)
|
||||
outfile = open(fullpath, 'w')
|
||||
outfile.write(filexml)
|
||||
outfile.close()
|
||||
self.generateImage(dir,names[0], filexml)
|
||||
else:
|
||||
file_xml = xml_data
|
||||
outfile = open(fullpath, 'w')
|
||||
outfile.write(filexml)
|
||||
outfile.close()
|
||||
if os.path.splitext (file) [1].lower () in [u'.bmp']:
|
||||
print os.path.splitext (file)
|
||||
else:
|
||||
if os.path.splitext (file) [1].lower () in [u'.bmp']:
|
||||
if fullpath is not os.path.join(dir, file):
|
||||
outfile = open(fullpath, 'w')
|
||||
outfile.write(zip.read(file))
|
||||
outfile.close()
|
||||
outfile = open(fullpath, 'w')
|
||||
outfile.write(zip.read(file))
|
||||
outfile.close()
|
||||
self.generateImage(dir,themename, filexml)
|
||||
|
||||
def checkVersion1(self, xmlfile):
|
||||
log.debug(u'checkVersion1 ')
|
||||
@ -297,7 +303,7 @@ class ThemeManager(QWidget):
|
||||
return newtheme.extract_xml()
|
||||
|
||||
def generateImage(self, dir, name, theme_xml):
|
||||
log.debug(u'generateImage %s %s ', dir, theme_xml)
|
||||
log.debug(u'generateImage %s %s %s', dir, name, theme_xml)
|
||||
theme = ThemeXML()
|
||||
theme.parse(theme_xml)
|
||||
#print theme
|
||||
@ -305,11 +311,10 @@ class ThemeManager(QWidget):
|
||||
frame=TstFrame(size)
|
||||
frame=frame
|
||||
paintdest=frame.GetPixmap()
|
||||
r=Renderer()
|
||||
r=Renderer(dir)
|
||||
r.set_paint_dest(paintdest)
|
||||
|
||||
r.set_theme(theme) # set default theme
|
||||
r._render_background()
|
||||
r.set_text_rectangle(QtCore.QRect(0,0, size.width()-1, size.height()-1), QtCore.QRect(10,560, size.width()-1, size.height()-1))
|
||||
|
||||
lines=[]
|
||||
|
@ -21,8 +21,8 @@ Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core import translate
|
||||
from openlp import convertStringToBoolean
|
||||
from openlp.core.lib import SettingsTab
|
||||
from openlp.core.resources import *
|
||||
|
||||
class BiblesTab(SettingsTab):
|
||||
"""
|
||||
@ -182,11 +182,11 @@ class BiblesTab(SettingsTab):
|
||||
self.bible_search = True
|
||||
|
||||
def load(self):
|
||||
self.paragraph_style = self.convertStringToBoolean(self.config.get_config('paragraph style', u'True'))
|
||||
self.show_new_chapters = self.convertStringToBoolean(self.config.get_config('display new chapter', u"False"))
|
||||
self.paragraph_style = convertStringToBoolean(self.config.get_config('paragraph style', u'True'))
|
||||
self.show_new_chapters = convertStringToBoolean(self.config.get_config('display new chapter', u"False"))
|
||||
self.display_style = int(self.config.get_config('display brackets', '0'))
|
||||
self.bible_theme = int(self.config.get_config('bible theme', '0'))
|
||||
self.bible_search = self.convertStringToBoolean(self.config.get_config('search as type', u'True'))
|
||||
self.bible_search = convertStringToBoolean(self.config.get_config('search as type', u'True'))
|
||||
if self.paragraph_style:
|
||||
self.ParagraphRadioButton.setChecked(True)
|
||||
else:
|
||||
|
@ -21,8 +21,8 @@ Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core import translate
|
||||
from openlp import convertStringToBoolean
|
||||
from openlp.core.lib import SettingsTab
|
||||
from openlp.core.resources import *
|
||||
|
||||
class VideoTab(SettingsTab):
|
||||
"""
|
||||
@ -49,12 +49,12 @@ class VideoTab(SettingsTab):
|
||||
self.UseVMRLabel = QtGui.QLabel(self.VideoModeGroupBox)
|
||||
self.UseVMRLabel.setObjectName("UseVMRLabel")
|
||||
self.VideoModeLayout.addWidget(self.UseVMRLabel)
|
||||
|
||||
|
||||
self.VideoLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.VideoModeGroupBox)
|
||||
# Signals and slots
|
||||
# Signals and slots
|
||||
QtCore.QObject.connect(self.UseVMRCheckBox,
|
||||
QtCore.SIGNAL("stateChanged(int)"), self.onVMRCheckBoxChanged)
|
||||
|
||||
QtCore.SIGNAL("stateChanged(int)"), self.onVMRCheckBoxChanged)
|
||||
|
||||
def retranslateUi(self):
|
||||
self.VideoModeGroupBox.setTitle(translate("SettingsForm", "Video Mode"))
|
||||
self.UseVMRCheckBox.setText(translate("SettingsForm", "Use Video Mode Rendering"))
|
||||
@ -69,11 +69,11 @@ class VideoTab(SettingsTab):
|
||||
self.use_vmr_mode = False
|
||||
if use_vmr_mode == 2: # we have a set value convert to True/False
|
||||
self.use_vmr_mode = True
|
||||
|
||||
|
||||
def load(self):
|
||||
self.use_vmr_mode = self.convertStringToBoolean(self.config.get_config(u'use mode layout', u'False'))
|
||||
self.use_vmr_mode = convertStringToBoolean(self.config.get_config(u'use mode layout', u'False'))
|
||||
if self.use_vmr_mode :
|
||||
self.UseVMRCheckBox.setChecked(True)
|
||||
|
||||
|
||||
def save(self):
|
||||
self.config.set_config(u'use mode layout', str(self.use_vmr_mode))
|
||||
self.config.set_config(u'use mode layout', str(self.use_vmr_mode))
|
||||
|
Loading…
Reference in New Issue
Block a user