Fint main tab

This commit is contained in:
Tim Bentley 2010-10-09 11:59:49 +01:00
parent 1e096fc4fe
commit 5009196d45
4 changed files with 141 additions and 84 deletions

View File

@ -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 = \
'''<?xml version="1.0" encoding="utf-8"?>
<theme version="1.0">
@ -369,12 +372,14 @@ class ThemeXML(object):
The XML string to parse.
"""
# remove encoding string
if xml[:5] == u'<?xml':
xml = xml[38:]
line = xml.find(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:

View File

@ -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))

View File

@ -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():

View File

@ -255,6 +255,16 @@ p, li { white-space: pre-wrap; }
<string>Circular</string>
</property>
</item>
<item>
<property name="text">
<string>Top Left - Bottom Right</string>
</property>
</item>
<item>
<property name="text">
<string>Bottom Left - Top Right</string>
</property>
</item>
</widget>
</item>
</layout>
@ -379,7 +389,7 @@ p, li { white-space: pre-wrap; }
</widget>
</item>
<item row="4" column="0">
<widget class="QCheckBox" name="mainOutlineCheckBox">
<widget class="QCheckBox" name="outlineCheckBox">
<property name="text">
<string>&amp;Outline:</string>
</property>
@ -388,9 +398,9 @@ p, li { white-space: pre-wrap; }
<item row="4" column="1">
<layout class="QHBoxLayout" name="outlineLayout">
<item>
<widget class="QPushButton" name="mainOutlineColorPushButton">
<widget class="QPushButton" name="outlineColorPushButton">
<property name="enabled">
<bool>false</bool>
<bool>true</bool>
</property>
<property name="text">
<string/>
@ -414,7 +424,7 @@ p, li { white-space: pre-wrap; }
</layout>
</item>
<item row="5" column="0">
<widget class="QCheckBox" name="mainShadowCheckBox">
<widget class="QCheckBox" name="shadowCheckBox">
<property name="text">
<string>&amp;Shadow:</string>
</property>
@ -423,9 +433,9 @@ p, li { white-space: pre-wrap; }
<item row="5" column="1">
<layout class="QHBoxLayout" name="shadowLayout">
<item>
<widget class="QPushButton" name="mainShadowColorPushButton">
<widget class="QPushButton" name="shadowColorPushButton">
<property name="enabled">
<bool>false</bool>
<bool>true</bool>
</property>
<property name="text">
<string/>
@ -535,42 +545,16 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="footerOutlineCheckBox">
<property name="text">
<string>&amp;Outline:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QPushButton" name="footerOutlineColorPushButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QCheckBox" name="footerShadowCheckBox">
<property name="text">
<string>&amp;Shadow:</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QPushButton" name="footerShadowColorPushButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWizardPage" name="alignmentPage">
<property name="title">
<string>Text Formatting Details</string>
</property>
<property name="subTitle">
<string>Allows additional display formatting information to be defined</string>
</property>
</widget>
<widget class="QWizardPage" name="areaPositionPage">
<property name="title">
<string>Output Area Locations</string>