diff --git a/openlp/core/lib/theme.py b/openlp/core/lib/theme.py index aa24d0193..44ea9fd43 100644 --- a/openlp/core/lib/theme.py +++ b/openlp/core/lib/theme.py @@ -28,6 +28,7 @@ Provide the theme XML and handling functions for OpenLP v2 themes. """ import os import re +import logging from xml.dom.minidom import Document from xml.etree.ElementTree import ElementTree, XML @@ -35,6 +36,8 @@ from lxml import etree, objectify from openlp.core.lib import str_to_bool +log = logging.getLogger(__name__) + BLANK_THEME_XML = \ ''' @@ -369,12 +372,14 @@ class ThemeXML(object): The XML string to parse. """ # remove encoding string - if xml[:5] == u'') + if line: + xml = xml[line + 2:] try: theme_xml = objectify.fromstring(xml) except etree.XMLSyntaxError: log.exception(u'Invalid xml %s', xml) + return # print objectify.dump(theme_xml) xml_iter = theme_xml.getiterator() for element in xml_iter: diff --git a/openlp/core/ui/themewizard.py b/openlp/core/ui/themewizard.py index 5d9561b26..18c6c6bd2 100644 --- a/openlp/core/ui/themewizard.py +++ b/openlp/core/ui/themewizard.py @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file 'themewizard.ui' # -# Created: Sun Oct 3 17:44:50 2010 +# Created: Sat Oct 9 08:32:36 2010 # by: PyQt4 UI code generator 4.7.4 # # WARNING! All changes made in this file will be lost! @@ -106,6 +106,8 @@ class Ui_ThemeWizard(object): self.gradientComboBox.addItem("") self.gradientComboBox.addItem("") self.gradientComboBox.addItem("") + self.gradientComboBox.addItem("") + self.gradientComboBox.addItem("") self.backgroundLayout.setWidget(4, QtGui.QFormLayout.FieldRole, self.gradientComboBox) ThemeWizard.addPage(self.backgroundPage) self.mainAreaPage = QtGui.QWizardPage() @@ -158,16 +160,16 @@ class Ui_ThemeWizard(object): self.lineSpacingSpinBox.setMaximum(50) self.lineSpacingSpinBox.setObjectName("lineSpacingSpinBox") self.formLayout.setWidget(3, QtGui.QFormLayout.FieldRole, self.lineSpacingSpinBox) - self.mainOutlineCheckBox = QtGui.QCheckBox(self.mainAreaPage) - self.mainOutlineCheckBox.setObjectName("mainOutlineCheckBox") - self.formLayout.setWidget(4, QtGui.QFormLayout.LabelRole, self.mainOutlineCheckBox) + self.outlineCheckBox = QtGui.QCheckBox(self.mainAreaPage) + self.outlineCheckBox.setObjectName("outlineCheckBox") + self.formLayout.setWidget(4, QtGui.QFormLayout.LabelRole, self.outlineCheckBox) self.outlineLayout = QtGui.QHBoxLayout() self.outlineLayout.setObjectName("outlineLayout") - self.mainOutlineColorPushButton = QtGui.QPushButton(self.mainAreaPage) - self.mainOutlineColorPushButton.setEnabled(False) - self.mainOutlineColorPushButton.setText("") - self.mainOutlineColorPushButton.setObjectName("mainOutlineColorPushButton") - self.outlineLayout.addWidget(self.mainOutlineColorPushButton) + self.outlineColorPushButton = QtGui.QPushButton(self.mainAreaPage) + self.outlineColorPushButton.setEnabled(True) + self.outlineColorPushButton.setText("") + self.outlineColorPushButton.setObjectName("outlineColorPushButton") + self.outlineLayout.addWidget(self.outlineColorPushButton) self.outlineSizeLabel = QtGui.QLabel(self.mainAreaPage) self.outlineSizeLabel.setObjectName("outlineSizeLabel") self.outlineLayout.addWidget(self.outlineSizeLabel) @@ -175,16 +177,16 @@ class Ui_ThemeWizard(object): self.outlineSizeSpinBox.setObjectName("outlineSizeSpinBox") self.outlineLayout.addWidget(self.outlineSizeSpinBox) self.formLayout.setLayout(4, QtGui.QFormLayout.FieldRole, self.outlineLayout) - self.mainShadowCheckBox = QtGui.QCheckBox(self.mainAreaPage) - self.mainShadowCheckBox.setObjectName("mainShadowCheckBox") - self.formLayout.setWidget(5, QtGui.QFormLayout.LabelRole, self.mainShadowCheckBox) + self.shadowCheckBox = QtGui.QCheckBox(self.mainAreaPage) + self.shadowCheckBox.setObjectName("shadowCheckBox") + self.formLayout.setWidget(5, QtGui.QFormLayout.LabelRole, self.shadowCheckBox) self.shadowLayout = QtGui.QHBoxLayout() self.shadowLayout.setObjectName("shadowLayout") - self.mainShadowColorPushButton = QtGui.QPushButton(self.mainAreaPage) - self.mainShadowColorPushButton.setEnabled(False) - self.mainShadowColorPushButton.setText("") - self.mainShadowColorPushButton.setObjectName("mainShadowColorPushButton") - self.shadowLayout.addWidget(self.mainShadowColorPushButton) + self.shadowColorPushButton = QtGui.QPushButton(self.mainAreaPage) + self.shadowColorPushButton.setEnabled(True) + self.shadowColorPushButton.setText("") + self.shadowColorPushButton.setObjectName("shadowColorPushButton") + self.shadowLayout.addWidget(self.shadowColorPushButton) self.shadowSizeLabel = QtGui.QLabel(self.mainAreaPage) self.shadowSizeLabel.setObjectName("shadowSizeLabel") self.shadowLayout.addWidget(self.shadowSizeLabel) @@ -227,23 +229,10 @@ class Ui_ThemeWizard(object): self.footerSizeSpinBox.setProperty("value", 10) self.footerSizeSpinBox.setObjectName("footerSizeSpinBox") self.footerLayout.setWidget(2, QtGui.QFormLayout.FieldRole, self.footerSizeSpinBox) - self.footerOutlineCheckBox = QtGui.QCheckBox(self.footerAreaPage) - self.footerOutlineCheckBox.setObjectName("footerOutlineCheckBox") - self.footerLayout.setWidget(3, QtGui.QFormLayout.LabelRole, self.footerOutlineCheckBox) - self.footerOutlineColorPushButton = QtGui.QPushButton(self.footerAreaPage) - self.footerOutlineColorPushButton.setEnabled(False) - self.footerOutlineColorPushButton.setText("") - self.footerOutlineColorPushButton.setObjectName("footerOutlineColorPushButton") - self.footerLayout.setWidget(3, QtGui.QFormLayout.FieldRole, self.footerOutlineColorPushButton) - self.footerShadowCheckBox = QtGui.QCheckBox(self.footerAreaPage) - self.footerShadowCheckBox.setObjectName("footerShadowCheckBox") - self.footerLayout.setWidget(4, QtGui.QFormLayout.LabelRole, self.footerShadowCheckBox) - self.footerShadowColorPushButton = QtGui.QPushButton(self.footerAreaPage) - self.footerShadowColorPushButton.setEnabled(False) - self.footerShadowColorPushButton.setText("") - self.footerShadowColorPushButton.setObjectName("footerShadowColorPushButton") - self.footerLayout.setWidget(4, QtGui.QFormLayout.FieldRole, self.footerShadowColorPushButton) ThemeWizard.addPage(self.footerAreaPage) + self.alignmentPage = QtGui.QWizardPage() + self.alignmentPage.setObjectName("alignmentPage") + ThemeWizard.addPage(self.alignmentPage) self.areaPositionPage = QtGui.QWizardPage() self.areaPositionPage.setObjectName("areaPositionPage") self.gridLayout_2 = QtGui.QGridLayout(self.areaPositionPage) @@ -448,6 +437,8 @@ class Ui_ThemeWizard(object): self.gradientComboBox.setItemText(0, QtGui.QApplication.translate("ThemeWizard", "Horizontal", None, QtGui.QApplication.UnicodeUTF8)) self.gradientComboBox.setItemText(1, QtGui.QApplication.translate("ThemeWizard", "Vertical", None, QtGui.QApplication.UnicodeUTF8)) self.gradientComboBox.setItemText(2, QtGui.QApplication.translate("ThemeWizard", "Circular", None, QtGui.QApplication.UnicodeUTF8)) + self.gradientComboBox.setItemText(3, QtGui.QApplication.translate("ThemeWizard", "Top Left - Bottom Right", None, QtGui.QApplication.UnicodeUTF8)) + self.gradientComboBox.setItemText(4, QtGui.QApplication.translate("ThemeWizard", "Bottom Left - Top Right", None, QtGui.QApplication.UnicodeUTF8)) self.mainAreaPage.setTitle(QtGui.QApplication.translate("ThemeWizard", "Main Area Font Details", None, QtGui.QApplication.UnicodeUTF8)) self.mainAreaPage.setSubTitle(QtGui.QApplication.translate("ThemeWizard", "Define the font and display characteristics for the Display text", None, QtGui.QApplication.UnicodeUTF8)) self.mainFontLabel.setText(QtGui.QApplication.translate("ThemeWizard", "Font:", None, QtGui.QApplication.UnicodeUTF8)) @@ -457,10 +448,10 @@ class Ui_ThemeWizard(object): self.mainLineCountLabel.setText(QtGui.QApplication.translate("ThemeWizard", "(%d lines per slide)", None, QtGui.QApplication.UnicodeUTF8)) self.lineSpacingLabel.setText(QtGui.QApplication.translate("ThemeWizard", "Line Spacing:", None, QtGui.QApplication.UnicodeUTF8)) self.lineSpacingSpinBox.setSuffix(QtGui.QApplication.translate("ThemeWizard", "pt", None, QtGui.QApplication.UnicodeUTF8)) - self.mainOutlineCheckBox.setText(QtGui.QApplication.translate("ThemeWizard", "&Outline:", None, QtGui.QApplication.UnicodeUTF8)) + self.outlineCheckBox.setText(QtGui.QApplication.translate("ThemeWizard", "&Outline:", None, QtGui.QApplication.UnicodeUTF8)) self.outlineSizeLabel.setText(QtGui.QApplication.translate("ThemeWizard", "Size:", None, QtGui.QApplication.UnicodeUTF8)) self.outlineSizeSpinBox.setSuffix(QtGui.QApplication.translate("ThemeWizard", "pt", None, QtGui.QApplication.UnicodeUTF8)) - self.mainShadowCheckBox.setText(QtGui.QApplication.translate("ThemeWizard", "&Shadow:", None, QtGui.QApplication.UnicodeUTF8)) + self.shadowCheckBox.setText(QtGui.QApplication.translate("ThemeWizard", "&Shadow:", None, QtGui.QApplication.UnicodeUTF8)) self.shadowSizeLabel.setText(QtGui.QApplication.translate("ThemeWizard", "Size:", None, QtGui.QApplication.UnicodeUTF8)) self.shadowSizeSpinBox.setSuffix(QtGui.QApplication.translate("ThemeWizard", "pt", None, QtGui.QApplication.UnicodeUTF8)) self.footerAreaPage.setTitle(QtGui.QApplication.translate("ThemeWizard", "Footer Area Font Details", None, QtGui.QApplication.UnicodeUTF8)) @@ -469,8 +460,8 @@ class Ui_ThemeWizard(object): self.footerColorLabel.setText(QtGui.QApplication.translate("ThemeWizard", "Color:", None, QtGui.QApplication.UnicodeUTF8)) self.footerSizeLabel.setText(QtGui.QApplication.translate("ThemeWizard", "Size:", None, QtGui.QApplication.UnicodeUTF8)) self.footerSizeSpinBox.setSuffix(QtGui.QApplication.translate("ThemeWizard", "pt", None, QtGui.QApplication.UnicodeUTF8)) - self.footerOutlineCheckBox.setText(QtGui.QApplication.translate("ThemeWizard", "&Outline:", None, QtGui.QApplication.UnicodeUTF8)) - self.footerShadowCheckBox.setText(QtGui.QApplication.translate("ThemeWizard", "&Shadow:", None, QtGui.QApplication.UnicodeUTF8)) + self.alignmentPage.setTitle(QtGui.QApplication.translate("ThemeWizard", "Text Formatting Details", None, QtGui.QApplication.UnicodeUTF8)) + self.alignmentPage.setSubTitle(QtGui.QApplication.translate("ThemeWizard", "Allows additional display formatting information to be defined", None, QtGui.QApplication.UnicodeUTF8)) self.areaPositionPage.setTitle(QtGui.QApplication.translate("ThemeWizard", "Output Area Locations", None, QtGui.QApplication.UnicodeUTF8)) self.areaPositionPage.setSubTitle(QtGui.QApplication.translate("ThemeWizard", "Allows you to change and move the Main and Footer areas.", None, QtGui.QApplication.UnicodeUTF8)) self.mainPositionGroupBox.setTitle(QtGui.QApplication.translate("ThemeWizard", "&Main Area", None, QtGui.QApplication.UnicodeUTF8)) @@ -497,3 +488,4 @@ class Ui_ThemeWizard(object): self.previewPage.setSubTitle(QtGui.QApplication.translate("ThemeWizard", "View the theme and save it replacing the current one or change the name to create a new theme", None, QtGui.QApplication.UnicodeUTF8)) self.themeNameLabel.setText(QtGui.QApplication.translate("ThemeWizard", "Theme name:", None, QtGui.QApplication.UnicodeUTF8)) self.previewLabel.setText(QtGui.QApplication.translate("ThemeWizard", "Preview", None, QtGui.QApplication.UnicodeUTF8)) + diff --git a/openlp/core/ui/themewizardform.py b/openlp/core/ui/themewizardform.py index 1b4054ad3..43f00dfbf 100644 --- a/openlp/core/ui/themewizardform.py +++ b/openlp/core/ui/themewizardform.py @@ -130,6 +130,15 @@ class ThemeWizardForm(QtGui.QWizard, Ui_ThemeWizard): QtCore.QObject.connect(self.imageBrowseButton, QtCore.SIGNAL(u'pressed()'), self.onImageBrowseButtonClicked) + QtCore.QObject.connect(self.mainColorPushButton, + QtCore.SIGNAL(u'pressed()'), + self.onMainColourPushButtonClicked) + QtCore.QObject.connect(self.outlineColorPushButton, + QtCore.SIGNAL(u'pressed()'), + self.onOutlineColourPushButtonClicked) + QtCore.QObject.connect(self.shadowColorPushButton, + QtCore.SIGNAL(u'pressed()'), + self.onShadowColourPushButtonClicked) def exec_(self): """ @@ -215,21 +224,68 @@ class ThemeWizardForm(QtGui.QWizard, Ui_ThemeWizard): else: self.setField(u'gradient', QtCore.QVariant(4)) + def setMainAreaTabValues(self): + #self.setField(u'mainFontComboBox', QtCore.QVariant(self.theme.font_main_name)) + self.mainColorPushButton.setStyleSheet(u'background-color: %s' % + self.theme.font_main_color) + self.setField(u'mainSizeSpinBox', QtCore.QVariant(self.theme.font_main_proportion)) + self.setField(u'lineSpacingSpinBox', QtCore.QVariant(self.theme.font_main_line_adjustment)) + self.setField(u'outlineCheckBox', QtCore.QVariant(self.theme.font_main_outline)) + self.outlineColorPushButton.setStyleSheet(u'background-color: %s' % + self.theme.font_main_outline_color) + self.setField(u'outlineSizeSpinBox', QtCore.QVariant(self.theme.font_main_outline_size)) + self.setField(u'shadowCheckBox', QtCore.QVariant(self.theme.font_main_shadow)) + self.shadowColorPushButton.setStyleSheet(u'background-color: %s' % + self.theme.font_main_shadow_color) + self.setField(u'shadowSizeSpinBox', QtCore.QVariant(self.theme.font_main_shadow_size)) + pass + + def setFooterAreaTabValues(self): + pass + def setAlignmentTabValues(self): + pass + def setPositionTabValues(self): + pass + def setDefaults(self): self.restart() self.setBackgroundTabValues() + self.setMainAreaTabValues() + self.setFooterAreaTabValues() + self.setAlignmentTabValues() + self.setPositionTabValues() def registerFields(self): - self.welcomePage.registerField( + self.backgroundPage.registerField( u'background_type', self.backgroundTypeComboBox) - self.welcomePage.registerField( + self.backgroundPage.registerField( u'color_1', self.color1PushButton) - self.welcomePage.registerField( + self.backgroundPage.registerField( u'color_2', self.color2PushButton) - self.welcomePage.registerField( + self.backgroundPage.registerField( u'background_image', self.imageLineEdit) - self.welcomePage.registerField( + self.backgroundPage.registerField( u'gradient', self.gradientComboBox) + self.mainAreaPage.registerField( + u'mainFontComboBox', self.mainFontComboBox) + self.mainAreaPage.registerField( + u'mainColorPushButton', self.mainColorPushButton) + self.mainAreaPage.registerField( + u'mainSizeSpinBox', self.mainSizeSpinBox) + self.mainAreaPage.registerField( + u'lineSpacingSpinBox', self.lineSpacingSpinBox) + self.mainAreaPage.registerField( + u'outlineCheckBox', self.outlineCheckBox) + self.mainAreaPage.registerField( + u'outlineColorPushButton', self.outlineColorPushButton) + self.mainAreaPage.registerField( + u'outlineSizeSpinBox', self.outlineSizeSpinBox) + self.mainAreaPage.registerField( + u'shadowCheckBox', self.shadowCheckBox) + self.mainAreaPage.registerField( + u'shadowColorPushButton', self.shadowColorPushButton) + self.mainAreaPage.registerField( + u'shadowSizeSpinBox', self.shadowSizeSpinBox) def onBackgroundComboBox(self, index): self.theme.background_type = BackgroundType.to_string(index) @@ -266,7 +322,27 @@ class ThemeWizardForm(QtGui.QWizard, Ui_ThemeWizard): self.theme.background_filename = filename self.setBackgroundTabValues() + def onMainFontComboBox(self, index): + #self.theme.background_type = BackgroundType.to_string(index) + self.setBackgroundTabValues() + + def onMainColourPushButtonClicked(self): + self.theme.font_main_color = \ + self._colorButton(self.theme.font_main_color) + self.setBackgroundTabValues() + + def onOutlineColourPushButtonClicked(self): + self.theme.font_main_outline_color = \ + self._colorButton(self.theme.font_main_outline_color) + self.setBackgroundTabValues() + + def onShadowColourPushButtonClicked(self): + self.theme.font_main_shadow_color = \ + self._colorButton(self.theme.font_main_shadow_color) + self.setBackgroundTabValues() + def _colorButton(self, field): + print field new_color = QtGui.QColorDialog.getColor( QtGui.QColor(field), self) if new_color.isValid(): diff --git a/resources/forms/themewizard.ui b/resources/forms/themewizard.ui index fea8f6af4..ef1aae935 100644 --- a/resources/forms/themewizard.ui +++ b/resources/forms/themewizard.ui @@ -255,6 +255,16 @@ p, li { white-space: pre-wrap; } Circular + + + Top Left - Bottom Right + + + + + Bottom Left - Top Right + + @@ -379,7 +389,7 @@ p, li { white-space: pre-wrap; } - + &Outline: @@ -388,9 +398,9 @@ p, li { white-space: pre-wrap; } - + - false + true @@ -414,7 +424,7 @@ p, li { white-space: pre-wrap; } - + &Shadow: @@ -423,9 +433,9 @@ p, li { white-space: pre-wrap; } - + - false + true @@ -535,42 +545,16 @@ p, li { white-space: pre-wrap; } - - - - &Outline: - - - - - - - false - - - - - - - - - - &Shadow: - - - - - - - false - - - - - - + + + Text Formatting Details + + + Allows additional display formatting information to be defined + + Output Area Locations