diff --git a/openlp/core/lib/__init__.py b/openlp/core/lib/__init__.py index 824ec62db..7d3087079 100644 --- a/openlp/core/lib/__init__.py +++ b/openlp/core/lib/__init__.py @@ -27,6 +27,8 @@ def file_to_xml(xmlfile): return open(xmlfile).read() def str_to_bool(stringvalue): + if stringvalue is True or stringvalue is False: + return stringvalue return stringvalue.strip().lower() in (u'true', u'yes', u'y') def buildIcon(icon): diff --git a/openlp/core/ui/amendthemeform.py b/openlp/core/ui/amendthemeform.py index b9a709bf2..a25aff950 100644 --- a/openlp/core/ui/amendthemeform.py +++ b/openlp/core/ui/amendthemeform.py @@ -21,7 +21,8 @@ import logging import os, os.path from PyQt4 import QtCore, QtGui -from openlp.core.lib import ThemeXML, Renderer, file_to_xml, translate +from openlp.core.lib import ThemeXML, Renderer, file_to_xml, str_to_bool, \ + translate from amendthemedialog import Ui_AmendThemeDialog @@ -180,11 +181,55 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): xml = file_to_xml(xml_file) self.theme.parse(xml) self.theme.extend_image_filename(self.path) + self.cleanTheme(self.theme) self.allowPreview = False self.paintUi(self.theme) self.allowPreview = True self.previewTheme(self.theme) + def cleanTheme(self, theme): + self.theme.background_color = theme.background_color.strip() + self.theme.background_direction = theme.background_direction.strip() + self.theme.background_endColor = theme.background_endColor.strip() + if theme.background_filename: + self.theme.background_filename = theme.background_filename.strip() + #self.theme.background_mode + self.theme.background_startColor = theme.background_startColor.strip() + #self.theme.background_type + self.theme.display_display = theme.display_display.strip() + self.theme.display_horizontalAlign = \ + theme.display_horizontalAlign.strip() + self.theme.display_outline = str_to_bool(theme.display_outline) + #self.theme.display_outline_color + self.theme.display_shadow = str_to_bool(theme.display_shadow) + #self.theme.display_shadow_color + self.theme.display_verticalAlign = \ + theme.display_verticalAlign.strip() + self.theme.display_wrapStyle = theme.display_wrapStyle.strip() + self.theme.font_footer_color = theme.font_footer_color.strip() + self.theme.font_footer_height = theme.font_footer_height.strip() + self.theme.font_footer_italics = str_to_bool(theme.font_footer_italics) + self.theme.font_footer_name = theme.font_footer_name.strip() + #self.theme.font_footer_override + self.theme.font_footer_proportion = \ + theme.font_footer_proportion.strip() + self.theme.font_footer_weight = theme.font_footer_weight.strip() + self.theme.font_footer_width = theme.font_footer_width.strip() + self.theme.font_footer_x = theme.font_footer_x.strip() + self.theme.font_footer_y = theme.font_footer_y.strip() + self.theme.font_main_color = theme.font_main_color.strip() + self.theme.font_main_height = theme.font_main_height.strip() + self.theme.font_main_italics = str_to_bool(theme.font_main_italics) + self.theme.font_main_name = theme.font_main_name.strip() + #self.theme.font_main_override + self.theme.font_main_proportion = theme.font_main_proportion.strip() + self.theme.font_main_weight = theme.font_main_weight.strip() + self.theme.font_main_x = theme.font_main_x.strip() + self.theme.font_main_y = theme.font_main_y.strip() + #self.theme.theme_mode + self.theme.theme_name = theme.theme_name.strip() + #self.theme.theme_version + def onImageToolButtonClicked(self): filename = QtGui.QFileDialog.getOpenFileName(self, 'Open file') if filename != "":