Change xml handling to work with Normal/Bold and True

This commit is contained in:
Tim Bentley 2009-08-03 20:49:21 +01:00
parent 13f016cf5f
commit 5ccf0581de
3 changed files with 44 additions and 37 deletions

View File

@ -556,17 +556,21 @@ class Renderer(object):
"""
Set the fonts from the current theme settings.
"""
footer_weight = 50
if self._theme.font_footer_weight == u'Bold':
footer_weight = 75
self.footerFont = QtGui.QFont(self._theme.font_footer_name,
int(self._theme.font_footer_proportion), # size
int(self._theme.font_footer_weight), # weight
0)# italic
self.footerFont.setItalic(int(self._theme.font_footer_italics))
int(footer_weight), # weight
self._theme.font_footer_italics)# italic
self.footerFont.setPixelSize(int(self._theme.font_footer_proportion))
main_weight = 50
if self._theme.font_main_weight == u'Bold':
main_weight = 75
self.mainFont = QtGui.QFont(self._theme.font_main_name,
int(self._theme.font_main_proportion), # size
int(self._theme.font_main_weight), # weight
0)# italic
self.mainFont.setItalic(int(self._theme.font_main_italics))
int(main_weight), # weight
self._theme.font_main_italics)# italic
self.mainFont.setPixelSize(int(self._theme.font_main_proportion))
def _get_extent_and_render(self, line, footer, tlcorner=(0, 0), draw=False, color=None):

View File

@ -46,16 +46,16 @@ blankthemexml=\
<name>Arial</name>
<color>#000000</color>
<proportion>30</proportion>
<weight>50</weight>
<italics>0</italics>
<weight>Normal</weight>
<italics>False</italics>
<location override="False" x="0" y="0" width="0" height="0"/>
</font>
<font type="footer">
<name>Arial</name>
<color>#000000</color>
<proportion>12</proportion>
<weight>50</weight>
<italics>0</italics>
<weight>Normal</weight>
<italics>False</italics>
<location override="False" x="0" y="0" width="0" height="0"/>
</font>
<display>
@ -161,7 +161,7 @@ class ThemeXML(object):
#Create Filename element
self.child_element(background, u'filename', filename)
def add_font(self, name, color, proportion, override, fonttype=u'main', weight=u'50', italics=u'0',
def add_font(self, name, color, proportion, override, fonttype=u'main', weight=u'Bold', italics=False,
xpos=0, ypos=0, width=0, height=0):
"""
Add a Font.
@ -341,13 +341,16 @@ class ThemeXML(object):
setattr(self, master + element.tag + u'_'+ e[0], e[1])
else:
field = master + e[0]
e1 = e[1]
if e[1] == u'True' or e[1] == u'False':
e1 = str_to_bool(e[1])
setattr(self, field, e1)
setattr(self, field, str_to_bool(e[1]))
else:
setattr(self, field, e[1])
else:
if element.tag is not None:
field = master + element.tag
if element.text == u'True' or element.text == u'False':
setattr(self, field, str_to_bool(element.text))
else:
setattr(self, field, element.text)
def __str__(self):

View File

@ -166,17 +166,17 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
def onFontMainWeightComboBoxSelected(self, value):
if value ==0:
self.theme.font_main_weight = 50
self.theme.font_main_italics = 0
self.theme.font_main_weight = u'Normal'
self.theme.font_main_italics = False
elif value == 1:
self.theme.font_main_weight = 75
self.theme.font_main_italics = 0
self.theme.font_main_weight = u'Bold'
self.theme.font_main_italics = False
elif value == 2:
self.theme.font_main_weight = 50
self.theme.font_main_italics = 1
self.theme.font_main_weight = u'Normal'
self.theme.font_main_italics = True
else:
self.theme.font_main_weight = 75
self.theme.font_main_italics = 1
self.theme.font_main_weight = u'Bold'
self.theme.font_main_italics = True
self.previewTheme(self.theme)
def onFontMainColorPushButtonClicked(self):
@ -239,17 +239,17 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
def onFontFooterWeightComboBoxSelected(self, value):
if value == 0:
self.theme.font_footer_weight = 50
self.theme.font_footer_italics = 0
self.theme.font_footer_weight = u'Normal'
self.theme.font_footer_italics = False
elif value == 1:
self.theme.font_footer_weight = 75
self.theme.font_footer_italics = 0
self.theme.font_footer_weight = u'Bold'
self.theme.font_footer_italics = False
elif value == 2:
self.theme.font_footer_weight = 50
self.theme.font_footer_italics = 1
self.theme.font_footer_weight = u'Normal'
self.theme.font_footer_italics = True
else:
self.theme.font_footer_weight = 75
self.theme.font_footer_italics = 1
self.theme.font_footer_weight = u'Bold'
self.theme.font_footer_italics = True
self.previewTheme(self.theme)
def onFontFooterColorPushButtonClicked(self):
@ -445,11 +445,11 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
self.GradientComboBox.setCurrentIndex(2)
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:
if not self.theme.font_main_italics and self.theme.font_main_weight == u'Normal':
self.FontMainWeightComboBox.setCurrentIndex(0)
elif int(self.theme.font_main_italics) == 0 and int(self.theme.font_main_weight) == 75:
elif not self.theme.font_main_italics and self.theme.font_main_weight == u'Bold':
self.FontMainWeightComboBox.setCurrentIndex(1)
elif int(self.theme.font_main_italics) == 1 and int(self.theme.font_main_weight) == 50:
elif self.theme.font_main_italics and self.theme.font_main_weight == u'Normal':
self.FontMainWeightComboBox.setCurrentIndex(2)
else:
self.FontMainWeightComboBox.setCurrentIndex(3)
@ -459,11 +459,11 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
self.FontMainWidthSpinBox.setValue(int(self.theme.font_main_width))
self.FontMainHeightSpinBox.setValue(int(self.theme.font_main_height))
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:
if not self.theme.font_footer_italics and self.theme.font_footer_weight == u'Normal':
self.FontFooterWeightComboBox.setCurrentIndex(0)
elif int(self.theme.font_footer_italics) == 0 and int(self.theme.font_footer_weight) == 75:
elif not self.theme.font_footer_italics and self.theme.font_footer_weight == u'Bold':
self.FontFooterWeightComboBox.setCurrentIndex(1)
elif int(self.theme.font_footer_italics) == 1 and int(self.theme.font_footer_weight) == 50:
elif self.theme.font_footer_italics and self.theme.font_footer_weight == u'Normal':
self.FontFooterWeightComboBox.setCurrentIndex(2)
else:
self.FontFooterWeightComboBox.setCurrentIndex(3)