Clean theme handling

bzr-revno: 658
This commit is contained in:
Jon Tibble 2009-11-06 15:38:30 +00:00
commit aa8b7c3fe5
4 changed files with 17 additions and 24 deletions

View File

@ -42,7 +42,7 @@ ts_message = u""" <message>
<translation type="unfinished"></translation>
</message>
"""
find_trUtf8 = re.compile(r"trUtf8\(u'([\w]+)'\)", re.UNICODE)
find_trUtf8 = re.compile(r"trUtf8\(u'([\.:;\\&\w]+)'\)", re.UNICODE)
strings = {}
def parse_file(filename):
@ -83,7 +83,7 @@ def write_file(filename):
file.close()
def main():
start_dir = u'/home/raoul/Projects/openlp/i18n'
start_dir = u'.'
for root, dirs, files in os.walk(start_dir):
for file in files:
if file.endswith(u'.py'):

View File

@ -28,7 +28,7 @@ import os.path
from PyQt4 import QtCore, QtGui
from openlp.core.lib import ThemeXML, file_to_xml
from openlp.core.lib import ThemeXML
from amendthemedialog import Ui_AmendThemeDialog
log = logging.getLogger(u'AmendThemeForm')
@ -184,14 +184,7 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
def loadTheme(self, theme):
log.debug(u'LoadTheme %s', theme)
if theme is None:
self.theme.parse(self.thememanager.baseTheme())
else:
xml_file = os.path.join(self.path, theme, theme + u'.xml')
xml = file_to_xml(xml_file)
self.theme.parse(xml)
self.theme.extend_image_filename(self.path)
self.thememanager.cleanTheme(self.theme)
self.theme = self.thememanager.getThemeData(theme)
# Stop the initial screen setup generating 1 preview per field!
self.allowPreview = False
self.paintUi(self.theme)

View File

@ -269,18 +269,14 @@ class ThemeManager(QtGui.QWidget):
return self.themelist
def getThemeData(self, themename):
assert(themename)
log.debug(u'getthemedata for theme %s', themename)
xml_file = os.path.join(self.path, unicode(themename),
unicode(themename) + u'.xml')
try:
xml = file_to_xml(xml_file)
except:
xml = file_to_xml(xml_file)
if not xml:
xml = self.baseTheme()
theme = ThemeXML()
theme.parse(xml)
self.cleanTheme(theme)
theme.extend_image_filename(self.path)
return theme
return createThemeFromXml(xml, self.path)
def checkThemesExists(self, dir):
log.debug(u'check themes')
@ -428,10 +424,7 @@ class ThemeManager(QtGui.QWidget):
def generateAndSaveImage(self, dir, name, theme_xml):
log.debug(u'generateAndSaveImage %s %s %s', dir, name, theme_xml)
theme = ThemeXML()
theme.parse(theme_xml)
self.cleanTheme(theme)
theme.extend_image_filename(dir)
theme = self.createThemeFromXml(theme_xml, dir)
frame = self.generateImage(theme)
samplepathname = os.path.join(self.path, name + u'.png')
if os.path.exists(samplepathname):
@ -465,6 +458,13 @@ class ThemeManager(QtGui.QWidget):
unicode(u'#FFFFFF'), unicode(0), unicode(0), unicode(0))
return newtheme.extract_xml()
def createThemeFromXml(self, theme_xml, path):
theme = ThemeXML()
theme.parse(theme_xml)
self.cleanTheme(theme)
theme.extend_image_filename(path)
return theme
def cleanTheme(self, theme):
theme.background_color = theme.background_color.strip()
theme.background_direction = theme.background_direction.strip()

View File

@ -1 +1 @@
1.9.0-656
1.9.0-658