From 5ccf0581deae690ed6cf4671e60c87d80c669bd4 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Mon, 3 Aug 2009 20:49:21 +0100 Subject: [PATCH] Change xml handling to work with Normal/Bold and True --- openlp/core/lib/renderer.py | 16 +++++++---- openlp/core/lib/themexmlhandler.py | 21 ++++++++------ openlp/core/ui/amendthemeform.py | 44 +++++++++++++++--------------- 3 files changed, 44 insertions(+), 37 deletions(-) diff --git a/openlp/core/lib/renderer.py b/openlp/core/lib/renderer.py index d6ef78434..61558de8b 100644 --- a/openlp/core/lib/renderer.py +++ b/openlp/core/lib/renderer.py @@ -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): diff --git a/openlp/core/lib/themexmlhandler.py b/openlp/core/lib/themexmlhandler.py index e8a33aade..c5ba6ff99 100644 --- a/openlp/core/lib/themexmlhandler.py +++ b/openlp/core/lib/themexmlhandler.py @@ -46,16 +46,16 @@ blankthemexml=\ Arial #000000 30 - 50 - 0 + Normal + False Arial #000000 12 - 50 - 0 + Normal + False @@ -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,14 +341,17 @@ 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 - setattr(self, field, element.text) + 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): """ diff --git a/openlp/core/ui/amendthemeform.py b/openlp/core/ui/amendthemeform.py index fd966f54e..f22c9212a 100644 --- a/openlp/core/ui/amendthemeform.py +++ b/openlp/core/ui/amendthemeform.py @@ -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)