forked from openlp/openlp
Add attributes to themes
Save data Update data
This commit is contained in:
parent
b93cfa887c
commit
470f1d19df
openlp/core
@ -161,7 +161,7 @@ class ThemeXML(object):
|
|||||||
#Create Filename element
|
#Create Filename element
|
||||||
self.child_element(background, u'filename', filename)
|
self.child_element(background, u'filename', filename)
|
||||||
|
|
||||||
def add_font(self, name, color, proportion, override, fonttype=u'main',
|
def add_font(self, name, color, proportion, override, fonttype=u'main', weight=50, italics=0,
|
||||||
xpos=0, ypos=0, width=0, height=0):
|
xpos=0, ypos=0, width=0, height=0):
|
||||||
"""
|
"""
|
||||||
Add a Font.
|
Add a Font.
|
||||||
@ -181,6 +181,12 @@ class ThemeXML(object):
|
|||||||
``fonttype``
|
``fonttype``
|
||||||
The type of font, ``main`` or ``footer``. Defaults to ``main``.
|
The type of font, ``main`` or ``footer``. Defaults to ``main``.
|
||||||
|
|
||||||
|
``weight``
|
||||||
|
The weight of then font Defaults to 50 Normal
|
||||||
|
|
||||||
|
``italics``
|
||||||
|
Does the font render to italics Defaults to 0 Normal
|
||||||
|
|
||||||
``xpos``
|
``xpos``
|
||||||
The X position of the text block.
|
The X position of the text block.
|
||||||
|
|
||||||
@ -202,8 +208,10 @@ class ThemeXML(object):
|
|||||||
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'proportion', proportion)
|
self.child_element(background, u'proportion', proportion)
|
||||||
#Create Proportion name element
|
#Create weight name element
|
||||||
self.child_element(background, u'proportion', proportion)
|
self.child_element(background, u'weight', weight)
|
||||||
|
#Create italics name element
|
||||||
|
self.child_element(background, u'italics', italics)
|
||||||
#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',override)
|
||||||
|
@ -53,7 +53,6 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
|
|||||||
QtCore.SIGNAL(u'pressed()'), self.onShadowColorPushButtonClicked)
|
QtCore.SIGNAL(u'pressed()'), self.onShadowColorPushButtonClicked)
|
||||||
QtCore.QObject.connect(self.ImageToolButton,
|
QtCore.QObject.connect(self.ImageToolButton,
|
||||||
QtCore.SIGNAL(u'pressed()'), self.onImageToolButtonClicked)
|
QtCore.SIGNAL(u'pressed()'), self.onImageToolButtonClicked)
|
||||||
|
|
||||||
#Combo boxes
|
#Combo boxes
|
||||||
QtCore.QObject.connect(self.BackgroundComboBox,
|
QtCore.QObject.connect(self.BackgroundComboBox,
|
||||||
QtCore.SIGNAL(u'activated(int)'), self.onBackgroundComboBoxSelected)
|
QtCore.SIGNAL(u'activated(int)'), self.onBackgroundComboBoxSelected)
|
||||||
@ -63,13 +62,17 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
|
|||||||
QtCore.SIGNAL(u'activated(int)'), self.onGradientComboBoxSelected)
|
QtCore.SIGNAL(u'activated(int)'), self.onGradientComboBoxSelected)
|
||||||
QtCore.QObject.connect(self.FontMainComboBox,
|
QtCore.QObject.connect(self.FontMainComboBox,
|
||||||
QtCore.SIGNAL(u'activated(int)'), self.onFontMainComboBoxSelected)
|
QtCore.SIGNAL(u'activated(int)'), self.onFontMainComboBoxSelected)
|
||||||
|
QtCore.QObject.connect(self.FontMainWeightComboBox,
|
||||||
|
QtCore.SIGNAL(u'activated(int)'), self.onFontMainWeightComboBoxSelected)
|
||||||
QtCore.QObject.connect(self.FontFooterComboBox,
|
QtCore.QObject.connect(self.FontFooterComboBox,
|
||||||
QtCore.SIGNAL(u'activated(int)'), self.onFontFooterComboBoxSelected)
|
QtCore.SIGNAL(u'activated(int)'), self.onFontFooterComboBoxSelected)
|
||||||
|
QtCore.QObject.connect(self.FontFooterWeightComboBox,
|
||||||
|
QtCore.SIGNAL(u'activated(int)'), self.onFontFooterWeightComboBoxSelected)
|
||||||
QtCore.QObject.connect(self.HorizontalComboBox,
|
QtCore.QObject.connect(self.HorizontalComboBox,
|
||||||
QtCore.SIGNAL(u'activated(int)'), self.onHorizontalComboBoxSelected)
|
QtCore.SIGNAL(u'activated(int)'), self.onHorizontalComboBoxSelected)
|
||||||
QtCore.QObject.connect(self.VerticalComboBox,
|
QtCore.QObject.connect(self.VerticalComboBox,
|
||||||
QtCore.SIGNAL(u'activated(int)'), self.onVerticalComboBoxSelected)
|
QtCore.SIGNAL(u'activated(int)'), self.onVerticalComboBoxSelected)
|
||||||
|
#Spin boxes
|
||||||
QtCore.QObject.connect(self.FontMainSizeSpinBox,
|
QtCore.QObject.connect(self.FontMainSizeSpinBox,
|
||||||
QtCore.SIGNAL(u'editingFinished()'), self.onFontMainSizeSpinBoxChanged)
|
QtCore.SIGNAL(u'editingFinished()'), self.onFontMainSizeSpinBoxChanged)
|
||||||
QtCore.QObject.connect(self.FontFooterSizeSpinBox,
|
QtCore.QObject.connect(self.FontFooterSizeSpinBox,
|
||||||
@ -118,10 +121,12 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
|
|||||||
|
|
||||||
new_theme.add_font(unicode(self.theme.font_main_name), unicode(self.theme.font_main_color),
|
new_theme.add_font(unicode(self.theme.font_main_name), unicode(self.theme.font_main_color),
|
||||||
unicode(self.theme.font_main_proportion), unicode(self.theme.font_main_override), u'main',
|
unicode(self.theme.font_main_proportion), unicode(self.theme.font_main_override), u'main',
|
||||||
|
unicode(self.theme.font_main_weight), unicode(self.theme.font_main_italics),
|
||||||
unicode(self.theme.font_main_x), unicode(self.theme.font_main_y), unicode(self.theme.font_main_width),
|
unicode(self.theme.font_main_x), unicode(self.theme.font_main_y), unicode(self.theme.font_main_width),
|
||||||
unicode(self.theme.font_main_height))
|
unicode(self.theme.font_main_height))
|
||||||
new_theme.add_font(unicode(self.theme.font_footer_name), unicode(self.theme.font_footer_color),
|
new_theme.add_font(unicode(self.theme.font_footer_name), unicode(self.theme.font_footer_color),
|
||||||
unicode(self.theme.font_footer_proportion), unicode(self.theme.font_footer_override), u'footer',
|
unicode(self.theme.font_footer_proportion), unicode(self.theme.font_footer_override), u'footer',
|
||||||
|
unicode(self.theme.font_footer_weight), unicode(self.theme.font_footer_italics),
|
||||||
unicode(self.theme.font_footer_x), unicode(self.theme.font_footer_y), unicode(self.theme.font_footer_width),
|
unicode(self.theme.font_footer_x), unicode(self.theme.font_footer_y), unicode(self.theme.font_footer_width),
|
||||||
unicode(self.theme.font_footer_height) )
|
unicode(self.theme.font_footer_height) )
|
||||||
new_theme.add_display(unicode(self.theme.display_shadow), unicode(self.theme.display_shadow_color),
|
new_theme.add_display(unicode(self.theme.display_shadow), unicode(self.theme.display_shadow_color),
|
||||||
@ -159,6 +164,21 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
|
|||||||
self.theme.font_main_name = self.FontMainComboBox.currentFont().family()
|
self.theme.font_main_name = self.FontMainComboBox.currentFont().family()
|
||||||
self.previewTheme(self.theme)
|
self.previewTheme(self.theme)
|
||||||
|
|
||||||
|
def onFontMainWeightComboBoxSelected(self, value):
|
||||||
|
if value ==0:
|
||||||
|
self.theme.font_main_weight = 50
|
||||||
|
self.theme.font_main_italics = 0
|
||||||
|
elif value == 1:
|
||||||
|
self.theme.font_main_weight = 75
|
||||||
|
self.theme.font_main_italics = 0
|
||||||
|
elif value == 2:
|
||||||
|
self.theme.font_main_weight = 50
|
||||||
|
self.theme.font_main_italics = 1
|
||||||
|
else:
|
||||||
|
self.theme.font_main_weight = 75
|
||||||
|
self.theme.font_main_italics = 1
|
||||||
|
self.previewTheme(self.theme)
|
||||||
|
|
||||||
def onFontMainColorPushButtonClicked(self):
|
def onFontMainColorPushButtonClicked(self):
|
||||||
self.theme.font_main_color = QtGui.QColorDialog.getColor(
|
self.theme.font_main_color = QtGui.QColorDialog.getColor(
|
||||||
QtGui.QColor(self.theme.font_main_color), self).name()
|
QtGui.QColor(self.theme.font_main_color), self).name()
|
||||||
@ -217,6 +237,21 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
|
|||||||
self.theme.font_footer_name = self.FontFooterComboBox.currentFont().family()
|
self.theme.font_footer_name = self.FontFooterComboBox.currentFont().family()
|
||||||
self.previewTheme(self.theme)
|
self.previewTheme(self.theme)
|
||||||
|
|
||||||
|
def onFontFooterWeightComboBoxSelected(self, value):
|
||||||
|
if value == 0:
|
||||||
|
self.theme.font_footer_weight = 50
|
||||||
|
self.theme.font_footer_italics = 0
|
||||||
|
elif value == 1:
|
||||||
|
self.theme.font_footer_weight = 75
|
||||||
|
self.theme.font_footer_italics = 0
|
||||||
|
elif value == 2:
|
||||||
|
self.theme.font_footer_weight = 50
|
||||||
|
self.theme.font_footer_italics = 1
|
||||||
|
else:
|
||||||
|
self.theme.font_footer_weight = 75
|
||||||
|
self.theme.font_footer_italics = 1
|
||||||
|
self.previewTheme(self.theme)
|
||||||
|
|
||||||
def onFontFooterColorPushButtonClicked(self):
|
def onFontFooterColorPushButtonClicked(self):
|
||||||
self.theme.font_footer_color = QtGui.QColorDialog.getColor(
|
self.theme.font_footer_color = QtGui.QColorDialog.getColor(
|
||||||
QtGui.QColor(self.theme.font_footer_color), self).name()
|
QtGui.QColor(self.theme.font_footer_color), self).name()
|
||||||
@ -410,11 +445,28 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
|
|||||||
self.GradientComboBox.setCurrentIndex(2)
|
self.GradientComboBox.setCurrentIndex(2)
|
||||||
|
|
||||||
self.FontMainSizeSpinBox.setValue(int(self.theme.font_main_proportion))
|
self.FontMainSizeSpinBox.setValue(int(self.theme.font_main_proportion))
|
||||||
|
if int(self.theme.font_main_italics) == 0 and int(self.theme.font_main_weight) == 50:
|
||||||
|
self.FontMainWeightComboBox.setCurrentIndex(0)
|
||||||
|
elif int(self.theme.font_main_italics) == 0 and int(self.theme.font_main_weight) == 75:
|
||||||
|
self.FontMainWeightComboBox.setCurrentIndex(1)
|
||||||
|
elif int(self.theme.font_main_italics) == 1 and int(self.theme.font_main_weight) == 50:
|
||||||
|
self.FontMainWeightComboBox.setCurrentIndex(2)
|
||||||
|
else:
|
||||||
|
self.FontMainWeightComboBox.setCurrentIndex(3)
|
||||||
|
|
||||||
self.FontMainXSpinBox.setValue(int(self.theme.font_main_x))
|
self.FontMainXSpinBox.setValue(int(self.theme.font_main_x))
|
||||||
self.FontMainYSpinBox.setValue(int(self.theme.font_main_y))
|
self.FontMainYSpinBox.setValue(int(self.theme.font_main_y))
|
||||||
self.FontMainWidthSpinBox.setValue(int(self.theme.font_main_width))
|
self.FontMainWidthSpinBox.setValue(int(self.theme.font_main_width))
|
||||||
self.FontMainHeightSpinBox.setValue(int(self.theme.font_main_height))
|
self.FontMainHeightSpinBox.setValue(int(self.theme.font_main_height))
|
||||||
self.FontFooterSizeSpinBox.setValue(int(self.theme.font_footer_proportion))
|
self.FontFooterSizeSpinBox.setValue(int(self.theme.font_footer_proportion))
|
||||||
|
if int(self.theme.font_footer_italics) == 0 and int(self.theme.font_footer_weight) == 50:
|
||||||
|
self.FontFooterWeightComboBox.setCurrentIndex(0)
|
||||||
|
elif int(self.theme.font_footer_italics) == 0 and int(self.theme.font_footer_weight) == 75:
|
||||||
|
self.FontFooterWeightComboBox.setCurrentIndex(1)
|
||||||
|
elif int(self.theme.font_footer_italics) == 1 and int(self.theme.font_footer_weight) == 50:
|
||||||
|
self.FontFooterWeightComboBox.setCurrentIndex(2)
|
||||||
|
else:
|
||||||
|
self.FontFooterWeightComboBox.setCurrentIndex(3)
|
||||||
self.FontFooterXSpinBox.setValue(int(self.theme.font_footer_x))
|
self.FontFooterXSpinBox.setValue(int(self.theme.font_footer_x))
|
||||||
self.FontFooterYSpinBox.setValue(int(self.theme.font_footer_y))
|
self.FontFooterYSpinBox.setValue(int(self.theme.font_footer_y))
|
||||||
self.FontFooterWidthSpinBox.setValue(int(self.theme.font_footer_width))
|
self.FontFooterWidthSpinBox.setValue(int(self.theme.font_footer_width))
|
||||||
@ -529,7 +581,6 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
|
|||||||
else:
|
else:
|
||||||
self.ShadowColorPushButton.setEnabled(False)
|
self.ShadowColorPushButton.setEnabled(False)
|
||||||
|
|
||||||
|
|
||||||
def previewTheme(self, theme):
|
def previewTheme(self, theme):
|
||||||
if self.allowPreview:
|
if self.allowPreview:
|
||||||
frame = self.thememanager.generateImage(theme)
|
frame = self.thememanager.generateImage(theme)
|
||||||
|
Loading…
Reference in New Issue
Block a user