diff --git a/openlp/core/lib/theme.py b/openlp/core/lib/theme.py index 0990f6906..e00169870 100644 --- a/openlp/core/lib/theme.py +++ b/openlp/core/lib/theme.py @@ -338,16 +338,14 @@ class ThemeXML(object): def dump_xml(self): """ - Dump the XML to file. + Dump the XML to file used for debugging """ - # Debugging aid to see what we have return self.theme_xml.toprettyxml(indent=u' ') def extract_xml(self): """ - Pull out the XML string. + Print out the XML string. """ - # Print our newly created XML return self.theme_xml.toxml(u'utf-8').decode(u'utf-8') def extract_formatted_xml(self): @@ -407,6 +405,9 @@ class ThemeXML(object): self._create_attr(field, element.text) def _create_attr(self, 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, field, str_to_bool(value)) @@ -426,7 +427,9 @@ class ThemeXML(object): return u'\n'.join(theme_strings) def _de_hump(self, name): - + """ + Change Camel Case string to python string + """ s1 = re.sub(u'(.)([A-Z][a-z]+)', r'\1_\2', name) return re.sub(u'([a-z0-9])([A-Z])', r'\1_\2', s1).lower() diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index e76516b57..692bfe041 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -462,11 +462,7 @@ class ThemeManager(QtGui.QWidget): log.exception(u'Theme XML is not UTF-8 ' u'encoded.') break - if self.checkVersion1(xml_data): - # upgrade theme xml - filexml = self.migrateVersion122(xml_data) - else: - filexml = xml_data + filexml = self.checkVersionAndConvert(xml_data) outfile = open(fullpath, u'w') outfile.write(filexml.encode(u'utf-8')) else: @@ -492,20 +488,21 @@ class ThemeManager(QtGui.QWidget): if outfile: outfile.close() - def checkVersion1(self, xmlfile): + def checkVersionAndConvert(self, xml_data): """ Check if a theme is from OpenLP version 1 - ``xmlfile`` + ``xml_data`` Theme XML to check the version of """ log.debug(u'checkVersion1 ') - theme = xmlfile.encode(u'ascii', u'xmlcharrefreplace') + theme = xml_data.encode(u'ascii', u'xmlcharrefreplace') tree = ElementTree(element=XML(theme)).getroot() + # look for old version 1 tags if tree.find(u'BackgroundType') is None: - return False + return xml_data else: - return True + return self.migrateVersion122(xml_data) def migrateVersion122(self, xml_data): """ diff --git a/resources/forms/themewizard.ui b/resources/forms/themewizard.ui index 54f9e43aa..a87052322 100644 --- a/resources/forms/themewizard.ui +++ b/resources/forms/themewizard.ui @@ -1,95 +1,893 @@ - - ThemeWizard - - - Qt::ApplicationModal - - + + + Wizard + + 0 0 - 576 - 397 + 559 + 487 - + Theme Wizard - + true - + QWizard::ModernStyle - - QWizard::DisabledBackButtonOnLastPage|QWizard::IndependentPages|QWizard::NoBackButtonOnStartPage|QWizard::NoCancelButton + + QWizard::HaveCustomButton1|QWizard::NoBackButtonOnStartPage - - - Welcome - - + + - - - - 20 - 100 - 341 - 31 - + + + + + + 8 - - Welcome to the Theme Wizard. This wizard will guide you through the process of creating a new theme. + + 0 - - true - - + + + + + 163 + 0 + + + + + 163 + 16777215 + + + + 0 + + + + + + :/wizards/wizard_importbible.bmp + + + 0 + + + + + + + 8 + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:14pt; font-weight:600;">Welcome to the Theme Wizard</span></p></body></html> + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 40 + + + + + + + + This wizard will help you to maintain Themes . Click the next button below to start the process.. + + + true + + + 10 + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + - - - Theme Name + + + Select Import Source - - Choose a name for your theme + + Select the import format, and where to import from. - - - - 100 - 130 - 91 - 17 - + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - Theme Name: - - - - - - 200 - 127 - 261 - 22 - - - + + + + + + Background: + + + + + + + + Opaque + + + + + Transparent + + + + + + + + + + + + Background Type: + + + + + + + + Solid Color + + + + + Gradient + + + + + Image + + + + + + + + + + + + <Color1> + + + + + + + + + + + + + + + + + + <Color2> + + + + + + + + + + + + + + + + + + Gradient : + + + + + + + + Horizontal + + + + + Vertical + + + + + Circular + + + + + + + + + + + + Image: + + + + + + + + + + ... + + + + + + - - - Select Background + + + Main Area Font Details - - Select a background type and configure your background + + Define the font and display charaistics for the Display text + + + + + Font: + + + + + + + + + + Font Color: + + + + + + + + + + + + + + Size: + + + + + + + + 0 + 0 + + + + + 70 + 0 + + + + pt + + + 999 + + + 16 + + + + + + + Wrap Indentation + + + + + + + + + + TextLabel + + + + + + + Show Outline: + + + + + + + + + + + + + + Outline Color: + + + + + + + + + + + + + + Show Shadow: + + + + + + + + + + + + + + Shadow Color: + + + + + + + + + + + + + + + Footer Area Font Details + + + Define the font and display charaistics for the Footer text + + + + + + Font: + + + + + + + + + + Font Color: + + + + + + + + + + + + + + Size: + + + + + + + + 0 + 0 + + + + + 70 + 0 + + + + pt + + + 999 + + + 10 + + + + + + + Show Outline: + + + + + + + + + + + + + + Shadow Color: + + + + + + + + + + + + + + Show Shadow: + + + + + + + + + + + + + + Outline Color: + + + + + + + + + + + + + + + Text Display Layout + + + Allows you to change and move the Main and Footer areas. + + + + + + + + + false + + + + + + + + + Main Area + + + + + + + Footer Area + + + + + + + X Position: + + + + + + + + 0 + 0 + + + + + 78 + 0 + + + + px + + + 9999 + + + 0 + + + + + + + X Position: + + + + + + + + 0 + 0 + + + + + 78 + 0 + + + + px + + + 9999 + + + 0 + + + + + + + Y Position: + + + + + + + + 0 + 0 + + + + + 78 + 0 + + + + px + + + 9999 + + + + + + + Y Position: + + + + + + + + 0 + 0 + + + + + 78 + 0 + + + + px + + + 9999 + + + 0 + + + + + + + Width: + + + + + + + + 0 + 0 + + + + + 78 + 0 + + + + px + + + 9999 + + + + + + + Width: + + + + + + + + 78 + 0 + + + + px + + + 9999 + + + + + + + Height: + + + + + + + + 0 + 0 + + + + + 78 + 0 + + + + px + + + 9999 + + + + + + + Height: + + + + + + + + 78 + 0 + + + + px + + + 9999 + + + + + + + + + Use Default Location: + + + + + + + + Save and Preview + + + View the theme and save it replacing the current one or change the name to create a new theme + + + + + + + + Theme Name: + + + + + + + + + + + + + + Preview + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + + 300 + 225 + + + + QFrame::WinPanel + + + QFrame::Sunken + + + 1 + + + + + + true + + + + + + - +