forked from openlp/openlp
Clean theme handling
bzr-revno: 658
This commit is contained in:
commit
aa8b7c3fe5
@ -42,7 +42,7 @@ ts_message = u""" <message>
|
|||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
"""
|
"""
|
||||||
find_trUtf8 = re.compile(r"trUtf8\(u'([\w]+)'\)", re.UNICODE)
|
find_trUtf8 = re.compile(r"trUtf8\(u'([\.:;\\&\w]+)'\)", re.UNICODE)
|
||||||
strings = {}
|
strings = {}
|
||||||
|
|
||||||
def parse_file(filename):
|
def parse_file(filename):
|
||||||
@ -83,7 +83,7 @@ def write_file(filename):
|
|||||||
file.close()
|
file.close()
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
start_dir = u'/home/raoul/Projects/openlp/i18n'
|
start_dir = u'.'
|
||||||
for root, dirs, files in os.walk(start_dir):
|
for root, dirs, files in os.walk(start_dir):
|
||||||
for file in files:
|
for file in files:
|
||||||
if file.endswith(u'.py'):
|
if file.endswith(u'.py'):
|
||||||
|
@ -28,7 +28,7 @@ import os.path
|
|||||||
|
|
||||||
from PyQt4 import QtCore, QtGui
|
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
|
from amendthemedialog import Ui_AmendThemeDialog
|
||||||
|
|
||||||
log = logging.getLogger(u'AmendThemeForm')
|
log = logging.getLogger(u'AmendThemeForm')
|
||||||
@ -184,14 +184,7 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
|
|||||||
|
|
||||||
def loadTheme(self, theme):
|
def loadTheme(self, theme):
|
||||||
log.debug(u'LoadTheme %s', theme)
|
log.debug(u'LoadTheme %s', theme)
|
||||||
if theme is None:
|
self.theme = self.thememanager.getThemeData(theme)
|
||||||
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)
|
|
||||||
# Stop the initial screen setup generating 1 preview per field!
|
# Stop the initial screen setup generating 1 preview per field!
|
||||||
self.allowPreview = False
|
self.allowPreview = False
|
||||||
self.paintUi(self.theme)
|
self.paintUi(self.theme)
|
||||||
|
@ -269,18 +269,14 @@ class ThemeManager(QtGui.QWidget):
|
|||||||
return self.themelist
|
return self.themelist
|
||||||
|
|
||||||
def getThemeData(self, themename):
|
def getThemeData(self, themename):
|
||||||
|
assert(themename)
|
||||||
log.debug(u'getthemedata for theme %s', themename)
|
log.debug(u'getthemedata for theme %s', themename)
|
||||||
xml_file = os.path.join(self.path, unicode(themename),
|
xml_file = os.path.join(self.path, unicode(themename),
|
||||||
unicode(themename) + u'.xml')
|
unicode(themename) + u'.xml')
|
||||||
try:
|
xml = file_to_xml(xml_file)
|
||||||
xml = file_to_xml(xml_file)
|
if not xml:
|
||||||
except:
|
|
||||||
xml = self.baseTheme()
|
xml = self.baseTheme()
|
||||||
theme = ThemeXML()
|
return createThemeFromXml(xml, self.path)
|
||||||
theme.parse(xml)
|
|
||||||
self.cleanTheme(theme)
|
|
||||||
theme.extend_image_filename(self.path)
|
|
||||||
return theme
|
|
||||||
|
|
||||||
def checkThemesExists(self, dir):
|
def checkThemesExists(self, dir):
|
||||||
log.debug(u'check themes')
|
log.debug(u'check themes')
|
||||||
@ -428,10 +424,7 @@ class ThemeManager(QtGui.QWidget):
|
|||||||
|
|
||||||
def generateAndSaveImage(self, dir, name, theme_xml):
|
def generateAndSaveImage(self, dir, name, theme_xml):
|
||||||
log.debug(u'generateAndSaveImage %s %s %s', dir, name, theme_xml)
|
log.debug(u'generateAndSaveImage %s %s %s', dir, name, theme_xml)
|
||||||
theme = ThemeXML()
|
theme = self.createThemeFromXml(theme_xml, dir)
|
||||||
theme.parse(theme_xml)
|
|
||||||
self.cleanTheme(theme)
|
|
||||||
theme.extend_image_filename(dir)
|
|
||||||
frame = self.generateImage(theme)
|
frame = self.generateImage(theme)
|
||||||
samplepathname = os.path.join(self.path, name + u'.png')
|
samplepathname = os.path.join(self.path, name + u'.png')
|
||||||
if os.path.exists(samplepathname):
|
if os.path.exists(samplepathname):
|
||||||
@ -465,6 +458,13 @@ class ThemeManager(QtGui.QWidget):
|
|||||||
unicode(u'#FFFFFF'), unicode(0), unicode(0), unicode(0))
|
unicode(u'#FFFFFF'), unicode(0), unicode(0), unicode(0))
|
||||||
return newtheme.extract_xml()
|
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):
|
def cleanTheme(self, theme):
|
||||||
theme.background_color = theme.background_color.strip()
|
theme.background_color = theme.background_color.strip()
|
||||||
theme.background_direction = theme.background_direction.strip()
|
theme.background_direction = theme.background_direction.strip()
|
||||||
|
@ -1 +1 @@
|
|||||||
1.9.0-656
|
1.9.0-658
|
||||||
|
Loading…
Reference in New Issue
Block a user