More theme changes

This commit is contained in:
Tim Bentley 2010-11-05 19:20:41 +00:00
parent e1d2695bc9
commit 73692e9e9f
5 changed files with 306 additions and 250 deletions

View File

@ -190,10 +190,11 @@ class ThemeXML(object):
self.background_filename = os.path.join(path, self.theme_name, self.background_filename = os.path.join(path, self.theme_name,
self.background_filename) self.background_filename)
def new_document(self, name): def _new_document(self, name):
""" """
Create a new theme XML document. Create a new theme XML document.
""" """
self.theme_xml = Document()
self.theme = self.theme_xml.createElement(u'theme') self.theme = self.theme_xml.createElement(u'theme')
self.theme_xml.appendChild(self.theme) self.theme_xml.appendChild(self.theme)
self.theme.setAttribute(u'version', u'2.0') self.theme.setAttribute(u'version', u'2.0')
@ -218,10 +219,9 @@ class ThemeXML(object):
The color of the background. The color of the background.
""" """
background = self.theme_xml.createElement(u'background') background = self.theme_xml.createElement(u'background')
background.setAttribute(u'mode', u'opaque')
background.setAttribute(u'type', u'solid') background.setAttribute(u'type', u'solid')
self.theme.appendChild(background) self.theme.appendChild(background)
self.child_element(background, u'color', bkcolor) self.child_element(background, u'color', unicode(bkcolor))
def add_background_gradient(self, startcolor, endcolor, direction): def add_background_gradient(self, startcolor, endcolor, direction):
""" """
@ -237,15 +237,14 @@ class ThemeXML(object):
The direction of the gradient. The direction of the gradient.
""" """
background = self.theme_xml.createElement(u'background') background = self.theme_xml.createElement(u'background')
background.setAttribute(u'mode', u'opaque')
background.setAttribute(u'type', u'gradient') background.setAttribute(u'type', u'gradient')
self.theme.appendChild(background) self.theme.appendChild(background)
# Create startColor element # Create startColor element
self.child_element(background, u'startColor', startcolor) self.child_element(background, u'startColor', unicode(startcolor))
# Create endColor element # Create endColor element
self.child_element(background, u'endColor', endcolor) self.child_element(background, u'endColor', unicode(endcolor))
# Create direction element # Create direction element
self.child_element(background, u'direction', direction) self.child_element(background, u'direction', unicode(direction))
def add_background_image(self, filename): def add_background_image(self, filename):
""" """
@ -255,7 +254,6 @@ class ThemeXML(object):
The file name of the image. The file name of the image.
""" """
background = self.theme_xml.createElement(u'background') background = self.theme_xml.createElement(u'background')
background.setAttribute(u'mode', u'opaque')
background.setAttribute(u'type', u'image') background.setAttribute(u'type', u'image')
self.theme.appendChild(background) self.theme.appendChild(background)
# Create Filename element # Create Filename element
@ -329,22 +327,22 @@ class ThemeXML(object):
# Create Font color element # Create Font color element
self.child_element(background, u'color', color) self.child_element(background, u'color', color)
# Create Proportion name element # Create Proportion name element
self.child_element(background, u'size', proportion) self.child_element(background, u'size', unicode(proportion))
# Create weight name element # Create weight name element
self.child_element(background, u'bold', bold) self.child_element(background, u'bold', unicode(bold))
# Create italics name element # Create italics name element
self.child_element(background, u'italics', italics) self.child_element(background, u'italics', unicode(italics))
# Create indentation name element # Create indentation name element
self.child_element( self.child_element(
background, u'line_adjustment', unicode(line_adjustment)) background, u'line_adjustment', unicode(line_adjustment))
# Create Location element # Create Location element
element = self.theme_xml.createElement(u'location') element = self.theme_xml.createElement(u'location')
element.setAttribute(u'override', override) element.setAttribute(u'override', unicode(override))
if override == u'True': if override == u'True':
element.setAttribute(u'x', xpos) element.setAttribute(u'x', unicode(xpos))
element.setAttribute(u'y', ypos) element.setAttribute(u'y', unicode(ypos))
element.setAttribute(u'width', width) element.setAttribute(u'width', unicode(width))
element.setAttribute(u'height', height) element.setAttribute(u'height', unicode(height))
background.appendChild(element) background.appendChild(element)
# Shadow # Shadow
element = self.theme_xml.createElement(u'shadow') element = self.theme_xml.createElement(u'shadow')
@ -412,12 +410,14 @@ class ThemeXML(object):
""" """
Print out the XML string. Print out the XML string.
""" """
self._build_xml_from_attrs()
return self.theme_xml.toxml(u'utf-8').decode(u'utf-8') return self.theme_xml.toxml(u'utf-8').decode(u'utf-8')
def extract_formatted_xml(self): def extract_formatted_xml(self):
""" """
Pull out the XML string formatted for human consumption Pull out the XML string formatted for human consumption
""" """
self._build_xml_from_attrs()
return self.theme_xml.toprettyxml(indent=u' ', newl=u'\n', return self.theme_xml.toprettyxml(indent=u' ', newl=u'\n',
encoding=u'utf-8') encoding=u'utf-8')
@ -550,13 +550,16 @@ class ThemeXML(object):
s1 = re.sub(u'(.)([A-Z][a-z]+)', r'\1_\2', name) 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() return re.sub(u'([a-z0-9])([A-Z])', r'\1_\2', s1).lower()
def build_xml_from_attrs(self, ): def _build_xml_from_attrs(self):
""" """
Build the XML from the varables in the object Build the XML from the varables in the object
""" """
if self.background_type == BackgroundType.Solid: self._new_document(self.theme_name)
if self.background_type == \
BackgroundType.to_string(BackgroundType.Solid):
self.add_background_solid(self.background_color) self.add_background_solid(self.background_color)
elif self.background_type == BackgroundType.Gradient: elif self.background_type == \
BackgroundType.to_string(BackgroundType.Gradient):
self.add_background_gradient( self.add_background_gradient(
self.background_start_color, self.background_start_color,
self.background_end_color, self.background_end_color,
@ -567,9 +570,9 @@ class ThemeXML(object):
self.add_background_image(filename) self.add_background_image(filename)
self.add_font(self.font_main_name, self.add_font(self.font_main_name,
self.font_main_color, self.font_main_color,
self.font_main_proportion, self.font_main_size,
self.font_main_override, u'main', self.font_main_override, u'main',
self.font_main_weight, self.font_main_bold,
self.font_main_italics, self.font_main_italics,
self.font_main_line_adjustment, self.font_main_line_adjustment,
self.font_main_x, self.font_main_x,
@ -584,9 +587,9 @@ class ThemeXML(object):
self.font_main_shadow_size) self.font_main_shadow_size)
self.add_font(self.font_footer_name, self.add_font(self.font_footer_name,
self.font_footer_color, self.font_footer_color,
self.font_footer_proportion, self.font_footer_size,
self.font_footer_override, u'footer', self.font_footer_override, u'footer',
self.font_footer_weight, self.font_footer_bold,
self.font_footer_italics, self.font_footer_italics,
0, # line adjustment 0, # line adjustment
self.font_footer_x, self.font_footer_x,

View File

@ -2,7 +2,7 @@
# Form implementation generated from reading ui file 'themedialog.ui' # Form implementation generated from reading ui file 'themedialog.ui'
# #
# Created: Sat Oct 30 12:33:34 2010 # Created: Thu Nov 4 18:12:37 2010
# by: PyQt4 UI code generator 4.7.4 # by: PyQt4 UI code generator 4.7.4
# #
# WARNING! All changes made in this file will be lost! # WARNING! All changes made in this file will be lost!
@ -403,28 +403,26 @@ class Ui_ThemeDialog(object):
ThemeDialog.addPage(self.areaPositionPage) ThemeDialog.addPage(self.areaPositionPage)
self.previewPage = QtGui.QWizardPage() self.previewPage = QtGui.QWizardPage()
self.previewPage.setObjectName("previewPage") self.previewPage.setObjectName("previewPage")
self.previewLayout = QtGui.QGridLayout(self.previewPage)
self.previewLayout.setMargin(20)
self.previewLayout.setSpacing(8)
self.previewLayout.setObjectName("previewLayout")
self.themeNameLabel = QtGui.QLabel(self.previewPage) self.themeNameLabel = QtGui.QLabel(self.previewPage)
self.themeNameLabel.setGeometry(QtCore.QRect(20, 10, 82, 16))
self.themeNameLabel.setTextFormat(QtCore.Qt.PlainText) self.themeNameLabel.setTextFormat(QtCore.Qt.PlainText)
self.themeNameLabel.setObjectName("themeNameLabel") self.themeNameLabel.setObjectName("themeNameLabel")
self.previewLayout.addWidget(self.themeNameLabel, 0, 0, 1, 1)
self.previewLabel = QtGui.QLabel(self.previewPage) self.previewLabel = QtGui.QLabel(self.previewPage)
self.previewLabel.setGeometry(QtCore.QRect(250, 60, 48, 16))
self.previewLabel.setAlignment(QtCore.Qt.AlignCenter) self.previewLabel.setAlignment(QtCore.Qt.AlignCenter)
self.previewLabel.setObjectName("previewLabel") self.previewLabel.setObjectName("previewLabel")
self.previewLayout.addWidget(self.previewLabel, 2, 0, 1, 2)
self.themeNameEdit = QtGui.QLineEdit(self.previewPage) self.themeNameEdit = QtGui.QLineEdit(self.previewPage)
self.themeNameEdit.setGeometry(QtCore.QRect(117, 4, 351, 23))
self.themeNameEdit.setObjectName("themeNameEdit") self.themeNameEdit.setObjectName("themeNameEdit")
self.previewLayout.addWidget(self.themeNameEdit, 0, 1, 1, 1) self.groupBox = QtGui.QGroupBox(self.previewPage)
self.previewBoxLayout = QtGui.QHBoxLayout() self.groupBox.setGeometry(QtCore.QRect(40, 80, 464, 214))
self.previewBoxLayout.setSpacing(0) self.groupBox.setTitle("")
self.previewBoxLayout.setContentsMargins(0, 0, -1, -1) self.groupBox.setObjectName("groupBox")
self.previewBoxLayout.setObjectName("previewBoxLayout") self.horizontalLayout = QtGui.QHBoxLayout(self.groupBox)
spacerItem2 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) self.horizontalLayout.setObjectName("horizontalLayout")
self.previewBoxLayout.addItem(spacerItem2) spacerItem2 = QtGui.QSpacerItem(58, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
self.previewBoxLabel = QtGui.QLabel(self.previewPage) self.horizontalLayout.addItem(spacerItem2)
self.previewBoxLabel = QtGui.QLabel(self.groupBox)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0) sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0) sizePolicy.setVerticalStretch(0)
@ -437,14 +435,14 @@ class Ui_ThemeDialog(object):
self.previewBoxLabel.setText("") self.previewBoxLabel.setText("")
self.previewBoxLabel.setScaledContents(True) self.previewBoxLabel.setScaledContents(True)
self.previewBoxLabel.setObjectName("previewBoxLabel") self.previewBoxLabel.setObjectName("previewBoxLabel")
self.previewBoxLayout.addWidget(self.previewBoxLabel) self.horizontalLayout.addWidget(self.previewBoxLabel)
spacerItem3 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) spacerItem3 = QtGui.QSpacerItem(78, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
self.previewBoxLayout.addItem(spacerItem3) self.horizontalLayout.addItem(spacerItem3)
self.previewLayout.addLayout(self.previewBoxLayout, 3, 0, 1, 2)
ThemeDialog.addPage(self.previewPage) ThemeDialog.addPage(self.previewPage)
self.themeNameLabel.setBuddy(self.themeNameEdit) self.themeNameLabel.setBuddy(self.themeNameEdit)
self.retranslateUi(ThemeDialog) self.retranslateUi(ThemeDialog)
QtCore.QObject.connect(ThemeDialog, QtCore.SIGNAL("accepted()"), ThemeDialog.accept)
QtCore.QMetaObject.connectSlotsByName(ThemeDialog) QtCore.QMetaObject.connectSlotsByName(ThemeDialog)
def retranslateUi(self, ThemeDialog): def retranslateUi(self, ThemeDialog):
@ -530,4 +528,3 @@ class Ui_ThemeDialog(object):
self.previewPage.setSubTitle(QtGui.QApplication.translate("ThemeDialog", "View the theme and save it replacing the current one or change the name to create a new theme", None, QtGui.QApplication.UnicodeUTF8)) self.previewPage.setSubTitle(QtGui.QApplication.translate("ThemeDialog", "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("ThemeDialog", "Theme name:", None, QtGui.QApplication.UnicodeUTF8)) self.themeNameLabel.setText(QtGui.QApplication.translate("ThemeDialog", "Theme name:", None, QtGui.QApplication.UnicodeUTF8))
self.previewLabel.setText(QtGui.QApplication.translate("ThemeDialog", "Preview", None, QtGui.QApplication.UnicodeUTF8)) self.previewLabel.setText(QtGui.QApplication.translate("ThemeDialog", "Preview", None, QtGui.QApplication.UnicodeUTF8))

View File

@ -25,11 +25,12 @@
############################################################################### ###############################################################################
import logging import logging
import os
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
from openlp.core.lib import translate, theme, BackgroundType, BackgroundGradientType from openlp.core.lib import translate, theme, BackgroundType, BackgroundGradientType
from openlp.core.utils import get_images_filter
from themedialog import Ui_ThemeDialog from themedialog import Ui_ThemeDialog
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -101,6 +102,90 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeDialog):
QtCore.SIGNAL(u'stateChanged(int)'), QtCore.SIGNAL(u'stateChanged(int)'),
self.onFooterDefaultPositionCheckBox) self.onFooterDefaultPositionCheckBox)
def setDefaults(self):
"""
Set up display at start of theme edit.
"""
self.restart()
self.setBackgroundTabValues()
self.setMainAreaTabValues()
self.setFooterAreaTabValues()
self.setAlignmentTabValues()
self.setPositionTabValues()
self.setPreviewTabValues()
# Set up field states
self.onOutlineCheckCheckBoxChanged(self.theme.font_main_outline)
self.onShadowCheckCheckBoxChanged(self.theme.font_main_shadow)
def registerFields(self):
"""
Map field names to screen names,
"""
self.backgroundPage.registerField(
u'background_type', self.backgroundTypeComboBox)
self.backgroundPage.registerField(
u'color_1', self.color1PushButton)
self.backgroundPage.registerField(
u'color_2', self.color2PushButton)
self.backgroundPage.registerField(
u'background_image', self.imageLineEdit)
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'boldCheckBox', self.boldCheckBox)
self.mainAreaPage.registerField(
u'italicsCheckBox', self.italicsCheckBox)
self.mainAreaPage.registerField(
u'shadowColorPushButton', self.shadowColorPushButton)
self.mainAreaPage.registerField(
u'shadowSizeSpinBox', self.shadowSizeSpinBox)
self.mainAreaPage.registerField(
u'footerSizeSpinBox', self.footerSizeSpinBox)
self.areaPositionPage.registerField(
u'mainDefaultPosition', self.mainDefaultPositionCheckBox)
self.areaPositionPage.registerField(
u'mainPositionX', self.mainXSpinBox)
self.areaPositionPage.registerField(
u'mainPositionY', self.mainYSpinBox)
self.areaPositionPage.registerField(
u'mainPositionWidth', self.mainWidthSpinBox)
self.areaPositionPage.registerField(
u'mainPositionHeight', self.mainHeightSpinBox)
self.areaPositionPage.registerField(
u'footerDefaultPosition', self.footerDefaultPositionCheckBox)
self.areaPositionPage.registerField(
u'footerPositionX', self.footerXSpinBox)
self.areaPositionPage.registerField(
u'footerPositionY', self.footerYSpinBox)
self.areaPositionPage.registerField(
u'footerPositionWidth', self.footerWidthSpinBox)
self.areaPositionPage.registerField(
u'footerPositionHeight', self.footerHeightSpinBox)
self.backgroundPage.registerField(
u'horizontal', self.horizontalComboBox)
self.backgroundPage.registerField(
u'vertical', self.verticalComboBox)
self.backgroundPage.registerField(
u'slideTransition', self.transitionsCheckBox)
self.backgroundPage.registerField(
u'name', self.themeNameEdit)
def onOutlineCheckCheckBoxChanged(self, state): def onOutlineCheckCheckBoxChanged(self, state):
""" """
Change state as Outline check box changed Change state as Outline check box changed
@ -149,7 +234,6 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeDialog):
return QtGui.QWizard.exec_(self) return QtGui.QWizard.exec_(self)
def initializePage(self, id): def initializePage(self, id):
print id
if id == 0: if id == 0:
self.setBackgroundTabValues() self.setBackgroundTabValues()
elif id == 1: elif id == 1:
@ -164,14 +248,13 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeDialog):
frame = self.thememanager.generateImage(self.theme) frame = self.thememanager.generateImage(self.theme)
self.previewBoxLabel.setPixmap(QtGui.QPixmap.fromImage(frame)) self.previewBoxLabel.setPixmap(QtGui.QPixmap.fromImage(frame))
def validateCurrentPage(self): # def validateCurrentPage(self):
""" # """
Handle Tab specific code when moving between Tabs. # Handle Tab specific code when moving between Tabs.
""" # """
print "CURRENT id", self.currentId() # # Preview Screen
# Preview Screen # self.updateTheme()
self.updateTheme() # return True
return True
def setBackgroundTabValues(self): def setBackgroundTabValues(self):
""" """
@ -326,90 +409,6 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeDialog):
if len(self.theme.theme_name) > 1: if len(self.theme.theme_name) > 1:
self.themeNameEdit.setEnabled(False) self.themeNameEdit.setEnabled(False)
def setDefaults(self):
"""
Set up display at start of theme edit.
"""
self.restart()
self.setBackgroundTabValues()
self.setMainAreaTabValues()
self.setFooterAreaTabValues()
self.setAlignmentTabValues()
self.setPositionTabValues()
self.setPreviewTabValues()
# Set up field states
self.onOutlineCheckCheckBoxChanged(self.theme.font_main_outline)
self.onShadowCheckCheckBoxChanged(self.theme.font_main_shadow)
def registerFields(self):
"""
Map field names to screen names,
"""
self.backgroundPage.registerField(
u'background_type', self.backgroundTypeComboBox)
self.backgroundPage.registerField(
u'color_1', self.color1PushButton)
self.backgroundPage.registerField(
u'color_2', self.color2PushButton)
self.backgroundPage.registerField(
u'background_image', self.imageLineEdit)
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'boldCheckBox', self.boldCheckBox)
self.mainAreaPage.registerField(
u'italicsCheckBox', self.italicsCheckBox)
self.mainAreaPage.registerField(
u'shadowColorPushButton', self.shadowColorPushButton)
self.mainAreaPage.registerField(
u'shadowSizeSpinBox', self.shadowSizeSpinBox)
self.mainAreaPage.registerField(
u'footerSizeSpinBox', self.footerSizeSpinBox)
self.areaPositionPage.registerField(
u'mainDefaultPosition', self.mainDefaultPositionCheckBox)
self.areaPositionPage.registerField(
u'mainPositionX', self.mainXSpinBox)
self.areaPositionPage.registerField(
u'mainPositionY', self.mainYSpinBox)
self.areaPositionPage.registerField(
u'mainPositionWidth', self.mainWidthSpinBox)
self.areaPositionPage.registerField(
u'mainPositionHeight', self.mainHeightSpinBox)
self.areaPositionPage.registerField(
u'footerDefaultPosition', self.footerDefaultPositionCheckBox)
self.areaPositionPage.registerField(
u'footerPositionX', self.footerXSpinBox)
self.areaPositionPage.registerField(
u'footerPositionY', self.footerYSpinBox)
self.areaPositionPage.registerField(
u'footerPositionWidth', self.footerWidthSpinBox)
self.areaPositionPage.registerField(
u'footerPositionHeight', self.footerHeightSpinBox)
self.backgroundPage.registerField(
u'horizontal', self.horizontalComboBox)
self.backgroundPage.registerField(
u'vertical', self.verticalComboBox)
self.backgroundPage.registerField(
u'slideTransition', self.transitionsCheckBox)
self.backgroundPage.registerField(
u'name', self.themeNameEdit)
def onBackgroundComboBox(self, index): def onBackgroundComboBox(self, index):
""" """
Background style Combo box has changed. Background style Combo box has changed.
@ -448,7 +447,7 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeDialog):
translate('OpenLP.ThemeForm', 'Select Image'), u'', translate('OpenLP.ThemeForm', 'Select Image'), u'',
images_filter) images_filter)
if filename: if filename:
self.theme.background_filename = filename self.theme.background_filename = unicode(filename)
self.setBackgroundTabValues() self.setBackgroundTabValues()
def onMainFontComboBox(self): def onMainFontComboBox(self):
@ -486,10 +485,14 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeDialog):
self.field(u'mainSizeSpinBox').toInt()[0] self.field(u'mainSizeSpinBox').toInt()[0]
self.theme.font_main_line_adjustment = \ self.theme.font_main_line_adjustment = \
self.field(u'lineSpacingSpinBox').toInt()[0] self.field(u'lineSpacingSpinBox').toInt()[0]
self.theme.font_main_outline = \ self.theme.font_main_outline_size = \
self.field(u'outlineSizeSpinBox').toInt()[0] self.field(u'outlineSizeSpinBox').toInt()[0]
self.theme.font_main_shadow_size = \ self.theme.font_main_shadow_size = \
self.field(u'shadowSizeSpinBox').toInt()[0] self.field(u'shadowSizeSpinBox').toInt()[0]
self.theme.font_main_bold = \
self.field(u'boldCheckBox').toInt()[0]
self.theme.font_main_italics = \
self.field(u'italicsCheckBox').toInt()[0]
# footer page # footer page
self.theme.font_footer_name = \ self.theme.font_footer_name = \
unicode(self.footerFontComboBox.currentFont().family()) unicode(self.footerFontComboBox.currentFont().family())
@ -518,6 +521,26 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeDialog):
self.theme.theme_name = \ self.theme.theme_name = \
unicode(self.field(u'name').toString()) unicode(self.field(u'name').toString())
def accept(self):
"""
Lets save the them as Finish has been pressed
"""
if not unicode(self.field(u'name').toString()):
return
self.updateTheme()
save_from = None
save_to = None
if self.theme.background_type == \
BackgroundType.to_string(BackgroundType.Image):
filename = \
os.path.split(unicode(self.theme.background_filename))[1]
save_to = os.path.join(self.path, self.theme.theme_name, filename)
save_from = self.theme.background_filename
#theme_xml = self.theme.extract_xml()
#pretty_theme = self.theme.extract_formatted_xml()
if self.thememanager.saveTheme(self.theme, save_from, save_to):
return QtGui.QDialog.accept(self)
def _colorButton(self, field): def _colorButton(self, field):
""" """
Handle Color buttons Handle Color buttons

View File

@ -299,7 +299,8 @@ class ThemeManager(QtGui.QWidget):
# confirm deletion # confirm deletion
answer = QtGui.QMessageBox.question(self, answer = QtGui.QMessageBox.question(self,
translate('OpenLP.ThemeManager', 'Delete Confirmation'), translate('OpenLP.ThemeManager', 'Delete Confirmation'),
translate('OpenLP.ThemeManager', 'Delete theme?'), unicode(translate('OpenLP.ThemeManager', 'Delete %s theme?'))
% theme,
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes |
QtGui.QMessageBox.No), QtGui.QMessageBox.No) QtGui.QMessageBox.No), QtGui.QMessageBox.No)
if answer == QtGui.QMessageBox.No: if answer == QtGui.QMessageBox.No:
@ -628,13 +629,14 @@ class ThemeManager(QtGui.QWidget):
unicode(theme.WrapStyle), unicode(0)) unicode(theme.WrapStyle), unicode(0))
return newtheme.extract_xml() return newtheme.extract_xml()
def saveTheme(self, name, theme_xml, theme_pretty_xml, image_from, def saveTheme(self, theme, image_from, image_to):
image_to):
""" """
Called by thememaintenance Dialog to save the theme Called by thememaintenance Dialog to save the theme
and to trigger the reload of the theme list and to trigger the reload of the theme list
""" """
log.debug(u'saveTheme %s %s', name, theme_xml) name = theme.theme_name
theme_pretty_xml = theme.extract_formatted_xml()
log.debug(u'saveTheme %s %s', name, theme_pretty_xml)
theme_dir = os.path.join(self.path, name) theme_dir = os.path.join(self.path, name)
if not os.path.exists(theme_dir): if not os.path.exists(theme_dir):
os.mkdir(os.path.join(self.path, name)) os.mkdir(os.path.join(self.path, name))
@ -683,7 +685,7 @@ class ThemeManager(QtGui.QWidget):
unicode(image_to).encode(encoding)) unicode(image_to).encode(encoding))
except IOError: except IOError:
log.exception(u'Failed to save theme image') log.exception(u'Failed to save theme image')
self.generateAndSaveImage(self.path, name, theme_xml) self.generateAndSaveImage(self.path, name, theme)
self.loadThemes() self.loadThemes()
# Check if we need to set a new service theme # Check if we need to set a new service theme
if editedServiceTheme: if editedServiceTheme:
@ -713,9 +715,10 @@ class ThemeManager(QtGui.QWidget):
# the theme or to cancel the theme dialog completely. # the theme or to cancel the theme dialog completely.
return False return False
def generateAndSaveImage(self, dir, name, theme_xml): def generateAndSaveImage(self, dir, name, theme):
log.debug(u'generateAndSaveImage %s %s %s', dir, name, theme_xml) log.debug(u'generateAndSaveImage %s %s', dir, name)
theme = self.createThemeFromXml(theme_xml, dir) #theme = self.createThemeFromXml(theme_xml, dir)
theme_xml = theme.extract_xml()
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):

View File

@ -983,15 +983,15 @@ p, li { white-space: pre-wrap; }
<property name="subTitle"> <property name="subTitle">
<string>View the theme and save it replacing the current one or change the name to create a new theme</string> <string>View the theme and save it replacing the current one or change the name to create a new theme</string>
</property> </property>
<layout class="QGridLayout" name="previewLayout">
<property name="margin">
<number>20</number>
</property>
<property name="spacing">
<number>8</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="themeNameLabel"> <widget class="QLabel" name="themeNameLabel">
<property name="geometry">
<rect>
<x>20</x>
<y>10</y>
<width>82</width>
<height>16</height>
</rect>
</property>
<property name="text"> <property name="text">
<string>Theme name:</string> <string>Theme name:</string>
</property> </property>
@ -1002,9 +1002,15 @@ p, li { white-space: pre-wrap; }
<cstring>themeNameEdit</cstring> <cstring>themeNameEdit</cstring>
</property> </property>
</widget> </widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="QLabel" name="previewLabel"> <widget class="QLabel" name="previewLabel">
<property name="geometry">
<rect>
<x>250</x>
<y>60</y>
<width>48</width>
<height>16</height>
</rect>
</property>
<property name="text"> <property name="text">
<string>Preview</string> <string>Preview</string>
</property> </property>
@ -1012,21 +1018,29 @@ p, li { white-space: pre-wrap; }
<set>Qt::AlignCenter</set> <set>Qt::AlignCenter</set>
</property> </property>
</widget> </widget>
</item> <widget class="QLineEdit" name="themeNameEdit">
<item row="0" column="1"> <property name="geometry">
<widget class="QLineEdit" name="themeNameEdit"/> <rect>
</item> <x>117</x>
<item row="3" column="0" colspan="2"> <y>4</y>
<layout class="QHBoxLayout" name="previewBoxLayout"> <width>351</width>
<property name="spacing"> <height>23</height>
<number>0</number> </rect>
</property> </property>
<property name="leftMargin"> </widget>
<number>0</number> <widget class="QGroupBox" name="groupBox">
<property name="geometry">
<rect>
<x>40</x>
<y>80</y>
<width>464</width>
<height>214</height>
</rect>
</property> </property>
<property name="topMargin"> <property name="title">
<number>0</number> <string/>
</property> </property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item> <item>
<spacer name="leftSpacer"> <spacer name="leftSpacer">
<property name="orientation"> <property name="orientation">
@ -1034,7 +1048,7 @@ p, li { white-space: pre-wrap; }
</property> </property>
<property name="sizeHint" stdset="0"> <property name="sizeHint" stdset="0">
<size> <size>
<width>40</width> <width>58</width>
<height>20</height> <height>20</height>
</size> </size>
</property> </property>
@ -1078,15 +1092,14 @@ p, li { white-space: pre-wrap; }
</property> </property>
<property name="sizeHint" stdset="0"> <property name="sizeHint" stdset="0">
<size> <size>
<width>40</width> <width>78</width>
<height>20</height> <height>20</height>
</size> </size>
</property> </property>
</spacer> </spacer>
</item> </item>
</layout> </layout>
</item> </widget>
</layout>
</widget> </widget>
</widget> </widget>
<resources> <resources>
@ -1094,5 +1107,22 @@ p, li { white-space: pre-wrap; }
<include location="../images/openlp-2.qrc"/> <include location="../images/openlp-2.qrc"/>
<include location="Projects/OpenLP/trunk/resources/images/openlp-2.qrc"/> <include location="Projects/OpenLP/trunk/resources/images/openlp-2.qrc"/>
</resources> </resources>
<connections/> <connections>
<connection>
<sender>ThemeDialog</sender>
<signal>accepted()</signal>
<receiver>ThemeDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>455</x>
<y>368</y>
</hint>
<hint type="destinationlabel">
<x>483</x>
<y>401</y>
</hint>
</hints>
</connection>
</connections>
</ui> </ui>