From cc4acf4edd43cd464f55c1952e7a94afa666cc8e Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sat, 16 Oct 2010 08:21:24 +0100 Subject: [PATCH] Position Tab updates --- openlp/core/lib/theme.py | 21 +++--- openlp/core/ui/thememanager.py | 2 +- openlp/core/ui/themewizardform.py | 104 +++++++++++++++++++++++------- 3 files changed, 93 insertions(+), 34 deletions(-) diff --git a/openlp/core/lib/theme.py b/openlp/core/lib/theme.py index d46d4907b..46c82968c 100644 --- a/openlp/core/lib/theme.py +++ b/openlp/core/lib/theme.py @@ -42,16 +42,16 @@ BLANK_THEME_XML = \ ''' BlankStyle - - #000000 + + - + #000000 #000000 vertical - - + + #000000 Arial @@ -70,9 +70,9 @@ BLANK_THEME_XML = \ 12 False False + 0 True False - 0 @@ -383,7 +383,7 @@ class ThemeXML(object): # print objectify.dump(theme_xml) xml_iter = theme_xml.getiterator() for element in xml_iter: - #print "base",element.getparent(), element.tag, element.text, element.attrib + #print "base", element.getparent(), element.tag, element.text, element.attrib parent = element.getparent() master = u'' if parent is not None: @@ -403,6 +403,8 @@ class ThemeXML(object): self._create_attr(master, attr, \ element.getparent().attrib[attr]) if master: + #print "A", element.tag + self._create_attr(master, element.tag, element.text) if element.attrib: for attr in element.attrib: base_element = attr @@ -412,11 +414,10 @@ class ThemeXML(object): base_element = element.tag + u'_' + attr self._create_attr(master, base_element, element.attrib[attr]) - else: - self._create_attr(master, element.tag, element.text) else: + #print "C", element.tag if element.tag == u'name': - self._create_attr(u'theme', element.tag, element.text) + self._create_attr(u'theme', element.tag, element.text) def _translate_tags(self, master, element, value): """ diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index 592ec4520..c31de0009 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -215,7 +215,7 @@ class ThemeManager(QtGui.QWidget): Loads a new theme with the default settings and then launches the theme editing form for the user to make their customisations. """ - theme = self.createThemeFromXml(self.baseTheme(), self.path) + theme = ThemeXML() #self.createThemeFromXml(self.baseTheme(), self.path) #self.amendThemeForm.loadTheme(theme) self.saveThemeName = u'' self.themeWizardForm.theme = theme diff --git a/openlp/core/ui/themewizardform.py b/openlp/core/ui/themewizardform.py index ecdf604cf..50bc82a53 100644 --- a/openlp/core/ui/themewizardform.py +++ b/openlp/core/ui/themewizardform.py @@ -157,28 +157,44 @@ class ThemeWizardForm(QtGui.QWizard, Ui_ThemeWizard): self.onFooterDefaultPositionCheckBox) def onOutlineCheckCheckBoxChanged(self, state): + """ + Change statd as Outline check box changed + """ self.outlineColorPushButton.setEnabled(state) self.outlineSizeSpinBox.setEnabled(state) def onShadowCheckCheckBoxChanged(self, state): + """ + Change state as Shadow check box changed + """ self.shadowColorPushButton.setEnabled(state) self.shadowSizeSpinBox.setEnabled(state) - def onMainDefaultPositionCheckBox(self, state): - print "main", state - print self.field(u'mainDefaultPosition') - self.theme.font_main_override = self.field(u'mainDefaultPosition') - print self.theme.font_main_override, type(self.theme.font_main_override) - self.mainXSpinBox.setEnabled(not state) - self.mainYSpinBox.setEnabled(not state) - self.mainHeightSpinBox.setEnabled(not state) - self.mainWidthSpinBox.setEnabled(not state) + def onMainDefaultPositionCheckBox(self, value): + """ + Change state as Main Area Position check box changed + """ + if value == QtCore.Qt.Checked: + self.theme.font_main_override = False + else: + self.theme.font_main_override = True + self.mainXSpinBox.setEnabled(self.theme.font_main_override) + self.mainYSpinBox.setEnabled(self.theme.font_main_override) + self.mainHeightSpinBox.setEnabled(self.theme.font_main_override) + self.mainWidthSpinBox.setEnabled(self.theme.font_main_override) - def onFooterDefaultPositionCheckBox(self, state): - self.footerXSpinBox.setEnabled(not state) - self.footerYSpinBox.setEnabled(not state) - self.footerHeightSpinBox.setEnabled(not state) - self.footerWidthSpinBox.setEnabled(not state) + def onFooterDefaultPositionCheckBox(self, value): + """ + Change state as Footer Area Position check box changed + """ + if value == QtCore.Qt.Checked: + self.theme.font_footer_override = False + else: + self.theme.font_footer_override = True + self.footerXSpinBox.setEnabled(self.theme.font_footer_override) + self.footerYSpinBox.setEnabled(self.theme.font_footer_override) + self.footerHeightSpinBox.setEnabled(self.theme.font_footer_override) + self.footerWidthSpinBox.setEnabled(self.theme.font_footer_override) def exec_(self): """ @@ -189,7 +205,7 @@ class ThemeWizardForm(QtGui.QWizard, Ui_ThemeWizard): def validateCurrentPage(self): """ - Validate the current page before moving on to the next page. + Handle Tab specific code when moving between Tabs. """ print "CURRENT id", self.currentId() # Preview Screen @@ -200,6 +216,9 @@ class ThemeWizardForm(QtGui.QWizard, Ui_ThemeWizard): return True def setBackgroundTabValues(self): + """ + Handle the display and State of the background display tab. + """ if self.theme.background_type == \ BackgroundType.to_string(BackgroundType.Solid): self.setField(u'background_type', QtCore.QVariant(0)) @@ -265,7 +284,10 @@ class ThemeWizardForm(QtGui.QWizard, Ui_ThemeWizard): else: self.setField(u'gradient', QtCore.QVariant(4)) - def setMainAreaTabValues(self):# + def setMainAreaTabValues(self): + """ + Handle the display and State of the Main Area tab. + """ self.mainFontComboBox.setCurrentFont( QtGui.QFont(self.theme.font_main_name)) self.mainColorPushButton.setStyleSheet(u'background-color: %s' % @@ -292,6 +314,9 @@ class ThemeWizardForm(QtGui.QWizard, Ui_ThemeWizard): QtCore.QVariant(self.theme.font_main_italics)) def setFooterAreaTabValues(self): + """ + Handle the display and State of the Footer Area tab. + """ self.footerFontComboBox.setCurrentFont( QtGui.QFont(self.theme.font_main_name)) self.footerColorPushButton.setStyleSheet(u'background-color: %s' % @@ -300,8 +325,11 @@ class ThemeWizardForm(QtGui.QWizard, Ui_ThemeWizard): QtCore.QVariant(self.theme.font_footer_size)) def setPositionTabValues(self): - self.setField(u'mainDefaultPosition', \ - QtCore.QVariant(self.theme.font_main_override)) + print self.theme.font_main_override + if self.theme.font_main_override: + self.setField(u'mainDefaultPosition', QtCore.QVariant(False)) + else: + self.setField(u'mainDefaultPosition', QtCore.QVariant(True)) self.setField(u'mainPositionX', \ QtCore.QVariant(self.theme.font_main_x)) self.setField(u'mainPositionY', \ @@ -310,8 +338,10 @@ class ThemeWizardForm(QtGui.QWizard, Ui_ThemeWizard): QtCore.QVariant(self.theme.font_main_height)) self.setField(u'mainPositionWidth', \ QtCore.QVariant(self.theme.font_main_width)) - self.setField(u'mainDefaultPosition', \ - QtCore.QVariant(self.theme.font_main_override)) + if self.theme.font_footer_override: + self.setField(u'footerDefaultPosition', QtCore.QVariant(False)) + else: + self.setField(u'footerDefaultPosition', QtCore.QVariant(True)) self.setField(u'footerPositionX', \ QtCore.QVariant(self.theme.font_footer_x)) self.setField(u'footerPositionY', \ @@ -325,6 +355,9 @@ class ThemeWizardForm(QtGui.QWizard, Ui_ThemeWizard): pass def setDefaults(self): + """ + Set up display at start of theme edit. + """ self.restart() self.setBackgroundTabValues() self.setMainAreaTabValues() @@ -334,10 +367,11 @@ class ThemeWizardForm(QtGui.QWizard, Ui_ThemeWizard): # Set up field states self.onOutlineCheckCheckBoxChanged(self.theme.font_main_outline) self.onShadowCheckCheckBoxChanged(self.theme.font_main_shadow) - self.onMainDefaultPositionCheckBox(self.theme.font_main_override) - self.onFooterDefaultPositionCheckBox(self.theme.font_footer_override) def registerFields(self): + """ + Map field names to screen names, + """ self.backgroundPage.registerField( u'background_type', self.backgroundTypeComboBox) self.backgroundPage.registerField( @@ -396,10 +430,16 @@ class ThemeWizardForm(QtGui.QWizard, Ui_ThemeWizard): u'footerPositionHeight', self.footerHeightSpinBox) def onBackgroundComboBox(self, index): + """ + Background style Combo box has changed. + """ self.theme.background_type = BackgroundType.to_string(index) self.setBackgroundTabValues() def onGradientComboBox(self, index): + """ + Background gradient Combo box has changed. + """ self.theme.background_direction = \ BackgroundGradientType.to_string(index) self.setBackgroundTabValues() @@ -454,6 +494,10 @@ class ThemeWizardForm(QtGui.QWizard, Ui_ThemeWizard): self.setFooterAreaTabValues() def updateTheme(self): + """ + Update the theme object from the UI for fields not already updated + when the are changed. + """ # main page self.theme.font_main_name = \ self.mainFontComboBox.currentFont().family() @@ -472,9 +516,23 @@ class ThemeWizardForm(QtGui.QWizard, Ui_ThemeWizard): self.footerFontComboBox.currentFont().family() self.theme.font_footer_size = \ self.field(u'footerSizeSpinBox').toInt()[0] + # position page + self.theme.font_main_x = self.field(u'mainPositionX').toInt()[0] + self.theme.font_main_y = self.field(u'mainPositionY').toInt()[0] + self.theme.font_main_height = \ + self.field(u'mainPositionHeight').toInt()[0] + self.theme.font_main_width = self.field(u'mainPositionWidth').toInt()[0] + self.theme.font_footer_x = self.field(u'footerPositionX').toInt()[0] + self.theme.font_footer_y = self.field(u'footerPositionY').toInt()[0] + self.theme.font_footer_height = \ + self.field(u'footerPositionHeight').toInt()[0] + self.theme.font_footer_width = \ + self.field(u'footerPositionWidth').toInt()[0] def _colorButton(self, field): - print field + """ + Handle Color buttons + """ new_color = QtGui.QColorDialog.getColor( QtGui.QColor(field), self) if new_color.isValid():