From 36b3446d2cdc9e013f157624626ad16b3757286e Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sat, 11 Sep 2010 07:59:36 +0100 Subject: [PATCH 1/9] Theme Cleanup up --- openlp/core/lib/htmlbuilder.py | 20 ++++++------ openlp/core/lib/theme.py | 45 ++++++++++++++++++------- openlp/core/ui/amendthemeform.py | 50 ++++++++++++++-------------- openlp/core/ui/maindisplay.py | 2 +- openlp/core/ui/thememanager.py | 56 -------------------------------- 5 files changed, 69 insertions(+), 104 deletions(-) diff --git a/openlp/core/lib/htmlbuilder.py b/openlp/core/lib/htmlbuilder.py index 7f4fc5082..f0194da02 100644 --- a/openlp/core/lib/htmlbuilder.py +++ b/openlp/core/lib/htmlbuilder.py @@ -281,7 +281,7 @@ def build_html(item, screen, alert, islive): build_alert_css(alert, width), build_footer_css(item, height), build_lyrics_css(item, webkitvers), - u'true' if theme and theme.display_slideTransition and islive \ + u'true' if theme and theme.display_slide_transition and islive \ else u'false', image, build_lyrics_html(item, webkitvers)) @@ -318,18 +318,18 @@ def build_background_css(item, width, height): background = \ u'background: ' \ u'-webkit-gradient(linear, left top, left bottom, ' \ - 'from(%s), to(%s))' % (theme.background_startColor, - theme.background_endColor) + 'from(%s), to(%s))' % (theme.background_start_color, + theme.background_end_color) elif theme.background_direction == u'vertical': background = \ u'background: -webkit-gradient(linear, left top, ' \ u'right top, from(%s), to(%s))' % \ - (theme.background_startColor, theme.background_endColor) + (theme.background_start_color, theme.background_end_color) else: background = \ u'background: -webkit-gradient(radial, %s 50%%, 100, %s ' \ u'50%%, %s, from(%s), to(%s))' % (width, width, width, - theme.background_startColor, theme.background_endColor) + theme.background_start_color, theme.background_end_color) return background def build_lyrics_css(item, webkitvers): @@ -446,15 +446,15 @@ def build_lyrics_format_css(theme, width, height): Height of the lyrics block """ - if theme.display_horizontalAlign == 2: + if theme.display_horizontal_align == 2: align = u'center' - elif theme.display_horizontalAlign == 1: + elif theme.display_horizontal_align == 1: align = u'right' else: align = u'left' - if theme.display_verticalAlign == 2: + if theme.display_vertical_align == 2: valign = u'bottom' - elif theme.display_verticalAlign == 1: + elif theme.display_vertical_align == 1: valign = u'middle' else: valign = u'top' @@ -518,7 +518,7 @@ def build_footer_css(item, height): font-size: %spt; color: %s; text-align: left; - white-space:nowrap; + white-space:nowrap; """ theme = item.themedata if not theme or not item.footer: diff --git a/openlp/core/lib/theme.py b/openlp/core/lib/theme.py index ee3418dca..0990f6906 100644 --- a/openlp/core/lib/theme.py +++ b/openlp/core/lib/theme.py @@ -27,6 +27,7 @@ Provide the theme XML and handling functions for OpenLP v2 themes. """ import os +import re from xml.dom.minidom import Document from xml.etree.ElementTree import ElementTree, XML @@ -86,6 +87,17 @@ class ThemeLevel(object): Service = 2 Song = 3 +boolean_list = [u'font_main_italics', u'font_main_override', \ +u'font_footer_italics', u'font_footer_override', u'display_outline', \ +u'display_shadow', u'display_slide_transition'] + +integer_list =[u'font_main_proportion', u'font_main_line_adjustment', \ +u'font_main_x', u'font_main_height', u'font_main_y', u'font_main_width', \ +u'font_footer_proportion', u'font_footer_line_adjustment', u'font_footer_x', \ +u'font_footer_height', u'font_footer_y', u'font_footer_width', \ +u'display_shadow_size', u'display_outline_size', u'display_horizontal_align',\ +u'display_vertical_align', u'display_wrap_style' ] + class ThemeXML(object): """ A class to encapsulate the Theme XML. @@ -372,10 +384,10 @@ class ThemeXML(object): if element.getchildren(): master = element.tag + u'_' else: - #background transparent tags have no children so special case + # background transparent tags have no children so special case if element.tag == u'background': for e in element.attrib.iteritems(): - setattr(self, element.tag + u'_' + e[0], e[1]) + self._create_attr(element.tag + u'_' + e[0], e[1]) if element.attrib: for e in element.attrib.iteritems(): if master == u'font_' and e[0] == u'type': @@ -383,22 +395,25 @@ class ThemeXML(object): elif master == u'display_' and (element.tag == u'shadow' \ or element.tag == u'outline' ): et = str_to_bool(element.text) - setattr(self, master + element.tag, et) - setattr(self, master + element.tag + u'_'+ e[0], e[1]) + self._create_attr(master + element.tag, et) + self._create_attr(master + element.tag + u'_'+ e[0], e[1]) else: field = master + e[0] - if e[1] == u'True' or e[1] == u'False': - setattr(self, field, str_to_bool(e[1])) - else: - setattr(self, field, e[1]) + self._create_attr(field, e[1]) else: if element.tag: field = master + element.tag element.text = element.text.strip().lstrip() - if element.text == u'True' or element.text == u'False': - setattr(self, field, str_to_bool(element.text)) - else: - setattr(self, field, element.text) + self._create_attr(field, element.text) + + def _create_attr(self, element, value): + field = self._de_hump(element) + if field in boolean_list: + setattr(self, field, str_to_bool(value)) + elif field in integer_list: + setattr(self, field, int(value)) + else: + setattr(self, field, unicode(value)) def __str__(self): """ @@ -409,3 +424,9 @@ class ThemeXML(object): if key[0:1] != u'_': theme_strings.append(u'%30s: %s' % (key, getattr(self, key))) return u'\n'.join(theme_strings) + + def _de_hump(self, 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() + diff --git a/openlp/core/ui/amendthemeform.py b/openlp/core/ui/amendthemeform.py index e23044a2b..b1352dedb 100644 --- a/openlp/core/ui/amendthemeform.py +++ b/openlp/core/ui/amendthemeform.py @@ -150,8 +150,8 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): unicode(self.theme.background_color)) elif self.theme.background_type == u'gradient': new_theme.add_background_gradient( - unicode(self.theme.background_startColor), - unicode(self.theme.background_endColor), + unicode(self.theme.background_start_color), + unicode(self.theme.background_end_color), self.theme.background_direction) else: filename = \ @@ -185,10 +185,10 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): unicode(self.theme.display_shadow_color), unicode(self.theme.display_outline), unicode(self.theme.display_outline_color), - unicode(self.theme.display_horizontalAlign), - unicode(self.theme.display_verticalAlign), - unicode(self.theme.display_wrapStyle), - unicode(self.theme.display_slideTransition), + unicode(self.theme.display_horizontal_align), + unicode(self.theme.display_vertical_align), + unicode(self.theme.display_wrap_style), + unicode(self.theme.display_slide_transition), unicode(self.theme.display_shadow_size), unicode(self.theme.display_outline_size)) theme = new_theme.extract_xml() @@ -407,10 +407,10 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): self.theme.background_direction = u'vertical' else: self.theme.background_direction = u'circular' - if self.theme.background_startColor is None: - self.theme.background_startColor = u'#000000' - if self.theme.background_endColor is None: - self.theme.background_endColor = u'#ff0000' + if self.theme.background_start_color is None: + self.theme.background_start_color = u'#000000' + if self.theme.background_end_color is None: + self.theme.background_end_color = u'#ff0000' self.imageLineEdit.setText(u'') else: self.theme.background_type = u'image' @@ -427,20 +427,20 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): unicode(self.theme.background_color)) else: new_color = QtGui.QColorDialog.getColor( - QtGui.QColor(self.theme.background_startColor), self) + QtGui.QColor(self.theme.background_start_color), self) if new_color.isValid(): - self.theme.background_startColor = new_color.name() + self.theme.background_start_color = new_color.name() self.color1PushButton.setStyleSheet(u'background-color: %s' % - unicode(self.theme.background_startColor)) + unicode(self.theme.background_start_color)) self.previewTheme() def onColor2PushButtonClicked(self): new_color = QtGui.QColorDialog.getColor( - QtGui.QColor(self.theme.background_endColor), self) + QtGui.QColor(self.theme.background_end_color), self) if new_color.isValid(): - self.theme.background_endColor = new_color.name() + self.theme.background_end_color = new_color.name() self.color2PushButton.setStyleSheet(u'background-color: %s' % - unicode(self.theme.background_endColor)) + unicode(self.theme.background_end_color)) self.previewTheme() # @@ -483,9 +483,9 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): def onSlideTransitionCheckBoxChanged(self, value): if value == 2: # checked - self.theme.display_slideTransition = True + self.theme.display_slide_transition = True else: - self.theme.display_slideTransition = False + self.theme.display_slide_transition = False self.stateChanging(self.theme) self.previewTheme() @@ -499,12 +499,12 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): self.previewTheme() def onHorizontalComboBoxSelected(self, currentIndex): - self.theme.display_horizontalAlign = currentIndex + self.theme.display_horizontal_align = currentIndex self.stateChanging(self.theme) self.previewTheme() def onVerticalComboBoxSelected(self, currentIndex): - self.theme.display_verticalAlign = currentIndex + self.theme.display_vertical_align = currentIndex self.stateChanging(self.theme) self.previewTheme() @@ -598,13 +598,13 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): self.shadowCheckBox.setChecked(False) self.shadowColorPushButton.setEnabled(False) self.shadowSpinBox.setValue(int(self.theme.display_shadow_size)) - if self.theme.display_slideTransition: + if self.theme.display_slide_transition: self.slideTransitionCheckBox.setCheckState(QtCore.Qt.Checked) else: self.slideTransitionCheckBox.setCheckState(QtCore.Qt.Unchecked) self.horizontalComboBox.setCurrentIndex( - self.theme.display_horizontalAlign) - self.verticalComboBox.setCurrentIndex(self.theme.display_verticalAlign) + self.theme.display_horizontal_align) + self.verticalComboBox.setCurrentIndex(self.theme.display_vertical_align) def stateChanging(self, theme): self.backgroundTypeComboBox.setVisible(True) @@ -625,9 +625,9 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): self.gradientComboBox.setVisible(False) elif theme.background_type == u'gradient': self.color1PushButton.setStyleSheet(u'background-color: %s' \ - % unicode(theme.background_startColor)) + % unicode(theme.background_start_color)) self.color2PushButton.setStyleSheet(u'background-color: %s' \ - % unicode(theme.background_endColor)) + % unicode(theme.background_end_color)) self.color1Label.setText( translate('OpenLP.AmendThemeForm', 'First color:')) self.color2Label.setText( diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index 3e0b070b9..6fbd7995c 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -307,7 +307,7 @@ class MainDisplay(DisplayWidget): # Wait for the fade to finish before geting the preview. # Important otherwise preview will have incorrect text if at all ! if self.serviceItem.themedata and \ - self.serviceItem.themedata.display_slideTransition: + self.serviceItem.themedata.display_slide_transition: while self.frame.evaluateJavaScript(u'show_text_complete()') \ .toString() == u'false': Receiver.send_message(u'openlp_process_events') diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index 11130293c..e76516b57 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -699,61 +699,5 @@ class ThemeManager(QtGui.QWidget): """ theme = ThemeXML() theme.parse(theme_xml) - self.cleanTheme(theme) theme.extend_image_filename(path) return theme - - def cleanTheme(self, theme): - """ - Clean a theme loaded from an XML file by removing stray whitespace and - making sure parameters are the correct type for the theme object - attributes - """ - theme.background_color = theme.background_color.strip() - theme.background_direction = theme.background_direction.strip() - theme.background_endColor = theme.background_endColor.strip() - if theme.background_filename: - theme.background_filename = theme.background_filename.strip() - #theme.background_mode - theme.background_startColor = theme.background_startColor.strip() - #theme.background_type - if theme.display_display: - theme.display_display = theme.display_display.strip() - theme.display_horizontalAlign = \ - int(theme.display_horizontalAlign.strip()) - theme.display_outline = str_to_bool(theme.display_outline) - #theme.display_outline_color - theme.display_shadow = str_to_bool(theme.display_shadow) - #theme.display_shadow_color - theme.display_verticalAlign = int(theme.display_verticalAlign.strip()) - theme.display_wrapStyle = theme.display_wrapStyle.strip() - theme.display_slideTransition = theme.display_slideTransition - theme.font_footer_color = theme.font_footer_color.strip() - theme.font_footer_height = int(theme.font_footer_height.strip()) - theme.font_footer_italics = str_to_bool(theme.font_footer_italics) - theme.font_footer_name = theme.font_footer_name.strip() - #theme.font_footer_override - theme.font_footer_proportion = \ - int(theme.font_footer_proportion.strip()) - theme.font_footer_weight = theme.font_footer_weight.strip() - theme.font_footer_width = int(theme.font_footer_width.strip()) - theme.font_footer_x = int(theme.font_footer_x.strip()) - theme.font_footer_y = int(theme.font_footer_y.strip()) - theme.font_main_color = theme.font_main_color.strip() - theme.font_main_height = int(theme.font_main_height.strip()) - theme.font_main_italics = str_to_bool(theme.font_main_italics) - theme.font_main_name = theme.font_main_name.strip() - #theme.font_main_override - theme.font_main_proportion = int(theme.font_main_proportion.strip()) - theme.font_main_weight = theme.font_main_weight.strip() - theme.font_main_width = int(theme.font_main_width.strip()) - theme.font_main_x = int(theme.font_main_x.strip()) - theme.font_main_y = int(theme.font_main_y.strip()) - #theme.theme_mode - theme.theme_name = theme.theme_name.strip() - #theme.theme_version - # Remove the Transparent settings as they are not relevent - if theme.background_mode == u'transparent': - theme.background_mode = u'opaque' - theme.background_type = u'solid' - theme.background_startColor = u'#000000' From beedfb78e6cb29816cdecc7771024cb51b1a0091 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sat, 11 Sep 2010 12:11:19 +0100 Subject: [PATCH 2/9] Change version checking code --- openlp/core/lib/theme.py | 13 +- openlp/core/ui/thememanager.py | 17 +- resources/forms/themewizard.ui | 930 ++++++++++++++++++++++++++++++--- 3 files changed, 879 insertions(+), 81 deletions(-) diff --git a/openlp/core/lib/theme.py b/openlp/core/lib/theme.py index 0990f6906..e00169870 100644 --- a/openlp/core/lib/theme.py +++ b/openlp/core/lib/theme.py @@ -338,16 +338,14 @@ class ThemeXML(object): def dump_xml(self): """ - Dump the XML to file. + Dump the XML to file used for debugging """ - # Debugging aid to see what we have return self.theme_xml.toprettyxml(indent=u' ') def extract_xml(self): """ - Pull out the XML string. + Print out the XML string. """ - # Print our newly created XML return self.theme_xml.toxml(u'utf-8').decode(u'utf-8') def extract_formatted_xml(self): @@ -407,6 +405,9 @@ class ThemeXML(object): self._create_attr(field, element.text) def _create_attr(self, element, value): + """ + Create the attributes with the correct data types and name format + """ field = self._de_hump(element) if field in boolean_list: setattr(self, field, str_to_bool(value)) @@ -426,7 +427,9 @@ class ThemeXML(object): return u'\n'.join(theme_strings) def _de_hump(self, name): - + """ + Change Camel Case string to python string + """ 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() diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index e76516b57..692bfe041 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -462,11 +462,7 @@ class ThemeManager(QtGui.QWidget): log.exception(u'Theme XML is not UTF-8 ' u'encoded.') break - if self.checkVersion1(xml_data): - # upgrade theme xml - filexml = self.migrateVersion122(xml_data) - else: - filexml = xml_data + filexml = self.checkVersionAndConvert(xml_data) outfile = open(fullpath, u'w') outfile.write(filexml.encode(u'utf-8')) else: @@ -492,20 +488,21 @@ class ThemeManager(QtGui.QWidget): if outfile: outfile.close() - def checkVersion1(self, xmlfile): + def checkVersionAndConvert(self, xml_data): """ Check if a theme is from OpenLP version 1 - ``xmlfile`` + ``xml_data`` Theme XML to check the version of """ log.debug(u'checkVersion1 ') - theme = xmlfile.encode(u'ascii', u'xmlcharrefreplace') + theme = xml_data.encode(u'ascii', u'xmlcharrefreplace') tree = ElementTree(element=XML(theme)).getroot() + # look for old version 1 tags if tree.find(u'BackgroundType') is None: - return False + return xml_data else: - return True + return self.migrateVersion122(xml_data) def migrateVersion122(self, xml_data): """ diff --git a/resources/forms/themewizard.ui b/resources/forms/themewizard.ui index 54f9e43aa..a87052322 100644 --- a/resources/forms/themewizard.ui +++ b/resources/forms/themewizard.ui @@ -1,95 +1,893 @@ - - ThemeWizard - - - Qt::ApplicationModal - - + + + Wizard + + 0 0 - 576 - 397 + 559 + 487 - + Theme Wizard - + true - + QWizard::ModernStyle - - QWizard::DisabledBackButtonOnLastPage|QWizard::IndependentPages|QWizard::NoBackButtonOnStartPage|QWizard::NoCancelButton + + QWizard::HaveCustomButton1|QWizard::NoBackButtonOnStartPage - - - Welcome - - + + - - - - 20 - 100 - 341 - 31 - + + + + + + 8 - - Welcome to the Theme Wizard. This wizard will guide you through the process of creating a new theme. + + 0 - - true - - + + + + + 163 + 0 + + + + + 163 + 16777215 + + + + 0 + + + + + + :/wizards/wizard_importbible.bmp + + + 0 + + + + + + + 8 + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:14pt; font-weight:600;">Welcome to the Theme Wizard</span></p></body></html> + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 40 + + + + + + + + This wizard will help you to maintain Themes . Click the next button below to start the process.. + + + true + + + 10 + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + - - - Theme Name + + + Select Import Source - - Choose a name for your theme + + Select the import format, and where to import from. - - - - 100 - 130 - 91 - 17 - + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - Theme Name: - - - - - - 200 - 127 - 261 - 22 - - - + + + + + + Background: + + + + + + + + Opaque + + + + + Transparent + + + + + + + + + + + + Background Type: + + + + + + + + Solid Color + + + + + Gradient + + + + + Image + + + + + + + + + + + + <Color1> + + + + + + + + + + + + + + + + + + <Color2> + + + + + + + + + + + + + + + + + + Gradient : + + + + + + + + Horizontal + + + + + Vertical + + + + + Circular + + + + + + + + + + + + Image: + + + + + + + + + + ... + + + + + + - - - Select Background + + + Main Area Font Details - - Select a background type and configure your background + + Define the font and display charaistics for the Display text + + + + + Font: + + + + + + + + + + Font Color: + + + + + + + + + + + + + + Size: + + + + + + + + 0 + 0 + + + + + 70 + 0 + + + + pt + + + 999 + + + 16 + + + + + + + Wrap Indentation + + + + + + + + + + TextLabel + + + + + + + Show Outline: + + + + + + + + + + + + + + Outline Color: + + + + + + + + + + + + + + Show Shadow: + + + + + + + + + + + + + + Shadow Color: + + + + + + + + + + + + + + + Footer Area Font Details + + + Define the font and display charaistics for the Footer text + + + + + + Font: + + + + + + + + + + Font Color: + + + + + + + + + + + + + + Size: + + + + + + + + 0 + 0 + + + + + 70 + 0 + + + + pt + + + 999 + + + 10 + + + + + + + Show Outline: + + + + + + + + + + + + + + Shadow Color: + + + + + + + + + + + + + + Show Shadow: + + + + + + + + + + + + + + Outline Color: + + + + + + + + + + + + + + + Text Display Layout + + + Allows you to change and move the Main and Footer areas. + + + + + + + + + false + + + + + + + + + Main Area + + + + + + + Footer Area + + + + + + + X Position: + + + + + + + + 0 + 0 + + + + + 78 + 0 + + + + px + + + 9999 + + + 0 + + + + + + + X Position: + + + + + + + + 0 + 0 + + + + + 78 + 0 + + + + px + + + 9999 + + + 0 + + + + + + + Y Position: + + + + + + + + 0 + 0 + + + + + 78 + 0 + + + + px + + + 9999 + + + + + + + Y Position: + + + + + + + + 0 + 0 + + + + + 78 + 0 + + + + px + + + 9999 + + + 0 + + + + + + + Width: + + + + + + + + 0 + 0 + + + + + 78 + 0 + + + + px + + + 9999 + + + + + + + Width: + + + + + + + + 78 + 0 + + + + px + + + 9999 + + + + + + + Height: + + + + + + + + 0 + 0 + + + + + 78 + 0 + + + + px + + + 9999 + + + + + + + Height: + + + + + + + + 78 + 0 + + + + px + + + 9999 + + + + + + + + + Use Default Location: + + + + + + + + Save and Preview + + + View the theme and save it replacing the current one or change the name to create a new theme + + + + + + + + Theme Name: + + + + + + + + + + + + + + Preview + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + + 300 + 225 + + + + QFrame::WinPanel + + + QFrame::Sunken + + + 1 + + + + + + true + + + + + + - + From d3e8da302c0727460f8d75320a44500a755fe31b Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Fri, 24 Sep 2010 12:29:52 +0100 Subject: [PATCH 3/9] More cleanups --- openlp/core/lib/theme.py | 34 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/openlp/core/lib/theme.py b/openlp/core/lib/theme.py index e00169870..33d7676ca 100644 --- a/openlp/core/lib/theme.py +++ b/openlp/core/lib/theme.py @@ -87,16 +87,12 @@ class ThemeLevel(object): Service = 2 Song = 3 -boolean_list = [u'font_main_italics', u'font_main_override', \ -u'font_footer_italics', u'font_footer_override', u'display_outline', \ -u'display_shadow', u'display_slide_transition'] +boolean_list = [u'italics', u'override', u'outline', u'shadow', \ +u'slide_transition'] -integer_list =[u'font_main_proportion', u'font_main_line_adjustment', \ -u'font_main_x', u'font_main_height', u'font_main_y', u'font_main_width', \ -u'font_footer_proportion', u'font_footer_line_adjustment', u'font_footer_x', \ -u'font_footer_height', u'font_footer_y', u'font_footer_width', \ -u'display_shadow_size', u'display_outline_size', u'display_horizontal_align',\ -u'display_vertical_align', u'display_wrap_style' ] +integer_list =[u'proportion', u'line_adjustment', u'x', u'height', u'y', \ +u'width', u'shadow_size', u'outline_size', u'horizontal_align',\ +u'vertical_align', u'wrap_style' ] class ThemeXML(object): """ @@ -385,36 +381,34 @@ class ThemeXML(object): # background transparent tags have no children so special case if element.tag == u'background': for e in element.attrib.iteritems(): - self._create_attr(element.tag + u'_' + e[0], e[1]) + self._create_attr(element.tag , e[0], e[1]) if element.attrib: for e in element.attrib.iteritems(): if master == u'font_' and e[0] == u'type': master += e[1] + u'_' elif master == u'display_' and (element.tag == u'shadow' \ or element.tag == u'outline' ): - et = str_to_bool(element.text) - self._create_attr(master + element.tag, et) - self._create_attr(master + element.tag + u'_'+ e[0], e[1]) + self._create_attr(master, element.tag, element.text) + self._create_attr(master, element.tag + u'_'+ e[0], e[1]) else: field = master + e[0] - self._create_attr(field, e[1]) + self._create_attr(master, e[0], e[1]) else: if element.tag: - field = master + element.tag element.text = element.text.strip().lstrip() - self._create_attr(field, element.text) + self._create_attr(master , element.tag, element.text) - def _create_attr(self, element, value): + def _create_attr(self, master , element, value): """ Create the attributes with the correct data types and name format """ field = self._de_hump(element) if field in boolean_list: - setattr(self, field, str_to_bool(value)) + setattr(self, master + field, str_to_bool(value)) elif field in integer_list: - setattr(self, field, int(value)) + setattr(self, master + field, int(value)) else: - setattr(self, field, unicode(value)) + setattr(self, master + field, unicode(value)) def __str__(self): """ From 8f98ae9d2ecb4ccfbec2ca72488d9b69bf374ccc Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sat, 25 Sep 2010 08:45:21 +0100 Subject: [PATCH 4/9] Add Image cache --- openlp/core/lib/__init__.py | 12 ++++++++++-- openlp/plugins/images/lib/mediaitem.py | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/openlp/core/lib/__init__.py b/openlp/core/lib/__init__.py index ade4bc019..0bf07381b 100644 --- a/openlp/core/lib/__init__.py +++ b/openlp/core/lib/__init__.py @@ -81,6 +81,9 @@ html_expands.append({u'desc':u'Italics', u'start tag':u'{it}', u'start html':u'', u'end tag':u'{/it}', u'end html':u'', u'protected':True}) +# Image cache to stop regualar image resizing +cache = {} + def translate(context, text, comment=None): """ A special shortcut method to wrap around the Qt4 translation functions. @@ -220,7 +223,7 @@ def image_to_byte(image): ``image`` The image to converted. """ - log.debug(u'image_to_byte') + log.debug(u'image_to_byte') byte_array = QtCore.QByteArray() # use buffer to store pixmap into byteArray buffie = QtCore.QBuffer(byte_array) @@ -250,7 +253,7 @@ def resize_image(image, width, height, background=QtCore.Qt.black): The background colour defaults to black. """ - log.debug(u'resize_image') + log.debug(u'resize_image') preview = QtGui.QImage(image) if not preview.isNull(): # Only resize if different size @@ -258,6 +261,9 @@ def resize_image(image, width, height, background=QtCore.Qt.black): return preview preview = preview.scaled(width, height, QtCore.Qt.KeepAspectRatio, QtCore.Qt.SmoothTransformation) + cache_key = u'%s%s%s' % (image, unicode(width), unicode(height)) + if cache_key in cache: + return cache[cache_key] realw = preview.width() realh = preview.height() # and move it to the centre of the preview space @@ -266,6 +272,8 @@ def resize_image(image, width, height, background=QtCore.Qt.black): new_image.fill(background) painter = QtGui.QPainter(new_image) painter.drawImage((width - realw) / 2, (height - realh) / 2, preview) + cache[cache_key] = new_image + print cache return new_image def check_item_selected(list_widget, message): diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index 93271a604..147e2fffc 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -188,7 +188,7 @@ class ImageMediaItem(MediaManagerItem): bitem = self.listView.item(item.row()) filename = unicode(bitem.data(QtCore.Qt.UserRole).toString()) frame = QtGui.QImage(unicode(filename)) - self.parent.liveController.display.image(frame) + self.parent.liveController.display.image(filename) self.resetButton.setVisible(True) def onPreviewClick(self): From 83334a19e9e54861f3a9ef34ce4b2084c0f1508c Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sat, 25 Sep 2010 11:07:40 +0100 Subject: [PATCH 5/9] New Manifest file --- MANIFEST.in | 1 + openlp/core/lib/__init__.py | 14 +++++++------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/MANIFEST.in b/MANIFEST.in index e8a5822e6..efccdf79d 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -3,6 +3,7 @@ recursive-include openlp *.sqlite recursive-include openlp *.csv recursive-include openlp *.html recursive-include openlp *.js +recursive-include openlp *.qm recursive-include documentation * recursive-include resources/forms * recursive-include resources/i18n * diff --git a/openlp/core/lib/__init__.py b/openlp/core/lib/__init__.py index 0bf07381b..e9ca9ecd7 100644 --- a/openlp/core/lib/__init__.py +++ b/openlp/core/lib/__init__.py @@ -81,8 +81,8 @@ html_expands.append({u'desc':u'Italics', u'start tag':u'{it}', u'start html':u'', u'end tag':u'{/it}', u'end html':u'', u'protected':True}) -# Image cache to stop regualar image resizing -cache = {} +# Image image_cache to stop regualar image resizing +image_cache = {} def translate(context, text, comment=None): """ @@ -261,9 +261,9 @@ def resize_image(image, width, height, background=QtCore.Qt.black): return preview preview = preview.scaled(width, height, QtCore.Qt.KeepAspectRatio, QtCore.Qt.SmoothTransformation) - cache_key = u'%s%s%s' % (image, unicode(width), unicode(height)) - if cache_key in cache: - return cache[cache_key] + image_cache_key = u'%s%s%s' % (image, unicode(width), unicode(height)) + if image_cache_key in image_cache: + return image_cache[image_cache_key] realw = preview.width() realh = preview.height() # and move it to the centre of the preview space @@ -272,8 +272,8 @@ def resize_image(image, width, height, background=QtCore.Qt.black): new_image.fill(background) painter = QtGui.QPainter(new_image) painter.drawImage((width - realw) / 2, (height - realh) / 2, preview) - cache[cache_key] = new_image - print cache + image_cache[image_cache_key] = new_image + print image_cache return new_image def check_item_selected(list_widget, message): From cc42dc34d8ac6b8ce709e40007638bee111ceab8 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sun, 26 Sep 2010 08:39:50 +0100 Subject: [PATCH 6/9] Basic Theme copy and rename working --- openlp/core/ui/amendthemeform.py | 5 -- openlp/core/ui/thememanager.py | 83 ++++++++++++++++++++++++----- openlp/plugins/songs/songsplugin.py | 2 +- 3 files changed, 72 insertions(+), 18 deletions(-) diff --git a/openlp/core/ui/amendthemeform.py b/openlp/core/ui/amendthemeform.py index b1352dedb..1e0404f10 100644 --- a/openlp/core/ui/amendthemeform.py +++ b/openlp/core/ui/amendthemeform.py @@ -217,7 +217,6 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): self.imageLineEdit.setText(filename) self.theme.background_filename = filename self.previewTheme() - # # Main Font Tab # @@ -301,7 +300,6 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): if self.theme.font_main_height != self.fontMainHeightSpinBox.value(): self.theme.font_main_height = self.fontMainHeightSpinBox.value() self.previewTheme() - # # Footer Font Tab # @@ -382,7 +380,6 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): self.theme.font_footer_height = \ self.fontFooterHeightSpinBox.value() self.previewTheme() - # # Background Tab # @@ -442,7 +439,6 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): self.color2PushButton.setStyleSheet(u'background-color: %s' % unicode(self.theme.background_end_color)) self.previewTheme() - # # Other Tab # @@ -507,7 +503,6 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): self.theme.display_vertical_align = currentIndex self.stateChanging(self.theme) self.previewTheme() - # # Local Methods # diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index 7f20e661c..461ca009a 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -205,27 +205,86 @@ class ThemeManager(QtGui.QWidget): Renames an existing theme to a new name """ item = self.themeListWidget.currentItem() - oldThemeName = unicode(item.text()) + oldThemeName = unicode(item.data(QtCore.Qt.UserRole).toString()) self.fileRenameForm.FileNameEdit.setText(oldThemeName) + self.saveThemeName = u'' if self.fileRenameForm.exec_(): - newThemeName = self.fileRenameForm.FileNameEdit.text() - print oldThemeName, newThemeName + newThemeName = unicode(self.fileRenameForm.FileNameEdit.text()) + oldThemeData = self.getThemeData(oldThemeName) + self.deleteTheme(oldThemeName) + self.cloneThemeData(oldThemeData, newThemeName) def onCopyTheme(self): """ Copies an existing theme to a new name """ item = self.themeListWidget.currentItem() - oldThemeName = unicode(item.text()) + oldThemeName = unicode(item.data(QtCore.Qt.UserRole).toString()) self.fileRenameForm.FileNameEdit.setText(oldThemeName) + self.saveThemeName = u'' if self.fileRenameForm.exec_(): - newThemeName = self.fileRenameForm.FileNameEdit.text() - print oldThemeName, newThemeName - print self.path - source = os.path.join(self.path, oldThemeName) - for files in os.walk(source): - for name in files[2]: - print name + newThemeName = unicode(self.fileRenameForm.FileNameEdit.text()) + oldThemeData = self.getThemeData(oldThemeName) + self.cloneThemeData(oldThemeData, newThemeName) + self.loadThemes() + + def cloneThemeData(self, oldThemeData, newThemeName): + """ + """ + log.debug(u'cloneThemeData') + new_theme = ThemeXML() + new_theme.new_document(newThemeName) + save_from = None + save_to = None + if oldThemeData.background_type == u'solid': + new_theme.add_background_solid( + unicode(oldThemeData.background_color)) + elif oldThemeData.background_type == u'gradient': + new_theme.add_background_gradient( + unicode(oldThemeData.background_start_color), + unicode(oldThemeData.background_end_color), + oldThemeData.background_direction) + else: + filename = \ + os.path.split(unicode(oldThemeData.background_filename))[1] + new_theme.add_background_image(filename) + save_to = os.path.join(self.path, theme_name, filename) + save_from = oldThemeData.background_filename + new_theme.add_font(unicode(oldThemeData.font_main_name), + unicode(oldThemeData.font_main_color), + unicode(oldThemeData.font_main_proportion), + unicode(oldThemeData.font_main_override), u'main', + unicode(oldThemeData.font_main_weight), + unicode(oldThemeData.font_main_italics), + unicode(oldThemeData.font_main_line_adjustment), + unicode(oldThemeData.font_main_x), + unicode(oldThemeData.font_main_y), + unicode(oldThemeData.font_main_width), + unicode(oldThemeData.font_main_height)) + new_theme.add_font(unicode(oldThemeData.font_footer_name), + unicode(oldThemeData.font_footer_color), + unicode(oldThemeData.font_footer_proportion), + unicode(oldThemeData.font_footer_override), u'footer', + unicode(oldThemeData.font_footer_weight), + unicode(oldThemeData.font_footer_italics), + 0, # line adjustment + unicode(oldThemeData.font_footer_x), + unicode(oldThemeData.font_footer_y), + unicode(oldThemeData.font_footer_width), + unicode(oldThemeData.font_footer_height)) + new_theme.add_display(unicode(oldThemeData.display_shadow), + unicode(oldThemeData.display_shadow_color), + unicode(oldThemeData.display_outline), + unicode(oldThemeData.display_outline_color), + unicode(oldThemeData.display_horizontal_align), + unicode(oldThemeData.display_vertical_align), + unicode(oldThemeData.display_wrap_style), + unicode(oldThemeData.display_slide_transition), + unicode(oldThemeData.display_shadow_size), + unicode(oldThemeData.display_outline_size)) + theme = new_theme.extract_xml() + pretty_theme = new_theme.extract_formatted_xml() + self.saveTheme(newThemeName, theme, pretty_theme, save_from, save_to) def onEditTheme(self): """ @@ -248,7 +307,7 @@ class ThemeManager(QtGui.QWidget): item.data(QtCore.Qt.UserRole).toString()) self.amendThemeForm.exec_() - def onDeleteTheme(self): + def onDeleteTheme(self, onlyDelete=True): """ Delete a theme """ diff --git a/openlp/plugins/songs/songsplugin.py b/openlp/plugins/songs/songsplugin.py index 8180c9a52..27d71cdd7 100644 --- a/openlp/plugins/songs/songsplugin.py +++ b/openlp/plugins/songs/songsplugin.py @@ -140,7 +140,7 @@ class SongsPlugin(Plugin): Song.theme_name == oldTheme) for song in songsUsingTheme: song.theme_name = newTheme - self.custommanager.save_object(song) + self.manager.save_object(song) def importSongs(self, format, **kwargs): class_ = SongFormat.get_class(format) From e33e4cb7ff9d7ea5348b36a2cf5e41b7e1be7da0 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sun, 26 Sep 2010 09:07:47 +0100 Subject: [PATCH 7/9] Replace Context menu with smart context menu --- openlp/core/ui/servicemanager.py | 2 +- openlp/core/ui/thememanager.py | 86 +++++++++++++++++++------------- 2 files changed, 52 insertions(+), 36 deletions(-) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 5abb8d576..319725790 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -236,7 +236,7 @@ class ServiceManager(QtGui.QWidget): self.addToAction = self.dndMenu.addAction( translate('OpenLP.ServiceManager', '&Add to Selected Item')) self.addToAction.setIcon(build_icon(u':/general/general_edit.png')) - #build the context menu + # build the context menu self.menu = QtGui.QMenu() self.editAction = self.menu.addAction( translate('OpenLP.ServiceManager', '&Edit Item')) diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index 461ca009a..f1c0ebd83 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -88,41 +88,32 @@ class ThemeManager(QtGui.QWidget): self.themeListWidget.setAlternatingRowColors(True) self.themeListWidget.setIconSize(QtCore.QSize(88, 50)) self.layout.addWidget(self.themeListWidget) - self.themeListWidget.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu) - self.themeListWidget.addAction( - context_menu_action(self.themeListWidget, - u':/themes/theme_edit.png', - translate('OpenLP.ThemeManager', '&Edit Theme'), - self.onEditTheme)) - self.themeListWidget.addAction( - context_menu_action(self.themeListWidget, - u':/themes/theme_edit.png', - translate('OpenLP.ThemeManager', '&Rename Theme'), - self.onRenameTheme)) - self.themeListWidget.addAction( - context_menu_action(self.themeListWidget, - u':/themes/theme_edit.png', - translate('OpenLP.ThemeManager', '&Copy Theme'), - self.onCopyTheme)) - self.themeListWidget.addAction( - context_menu_separator(self.themeListWidget)) - self.themeListWidget.addAction( - context_menu_action(self.themeListWidget, - u':/general/general_delete.png', - translate('OpenLP.ThemeManager', '&Delete Theme'), - self.onDeleteTheme)) - self.themeListWidget.addAction( - context_menu_action(self.themeListWidget, - u':/general/general_export.png', - translate('OpenLP.ThemeManager', 'Set As &Global Default'), - self.changeGlobalFromScreen)) - self.themeListWidget.addAction( - context_menu_action(self.themeListWidget, - u':/general/general_export.png', - translate('OpenLP.ThemeManager', 'E&xport Theme'), - self.onExportTheme)) - self.themeListWidget.addAction( - context_menu_separator(self.themeListWidget)) + self.themeListWidget.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) + QtCore.QObject.connect(self.themeListWidget, + QtCore.SIGNAL('customContextMenuRequested(QPoint)'), + self.contextMenu) + # build the context menu + self.menu = QtGui.QMenu() + self.editAction = self.menu.addAction( + translate('OpenLP.ThemeManager', '&Edit Theme')) + self.editAction.setIcon(build_icon(u':/themes/theme_edit.png')) + self.copyAction = self.menu.addAction( + translate('OpenLP.ThemeManager', '&Copy Theme')) + self.copyAction.setIcon(build_icon(u':/themes/theme_edit.png')) + self.renameAction = self.menu.addAction( + translate('OpenLP.ThemeManager', '&Rename Theme')) + self.renameAction.setIcon(build_icon(u':/themes/theme_edit.png')) + self.deleteAction = self.menu.addAction( + translate('OpenLP.ThemeManager', '&Delete Theme')) + self.deleteAction.setIcon(build_icon(u':/general/general_delete.png')) + self.sep1 = self.menu.addAction(u'') + self.sep1.setSeparator(True) + self.globalAction = self.menu.addAction( + translate('OpenLP.ThemeManager', 'Set As &Global Default')) + self.globalAction.setIcon(build_icon(u':/general/general_export.png')) + self.exportAction = self.menu.addAction( + translate('OpenLP.ThemeManager', '&Export Theme')) + self.exportAction.setIcon(build_icon(u':/general/general_export.png')) #Signals QtCore.QObject.connect(self.themeListWidget, QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), @@ -143,6 +134,31 @@ class ThemeManager(QtGui.QWidget): self.settingsSection + u'/global theme', QtCore.QVariant(u'')).toString()) + def contextMenu(self, point): + item = self.themeListWidget.itemAt(point) + if item is None: + return + realThemeName = unicode(item.data(QtCore.Qt.UserRole).toString()) + themeName = unicode(item.text()) + self.deleteAction.setVisible(False) + self.renameAction.setVisible(False) + if realThemeName == themeName: + self.deleteAction.setVisible(True) + self.renameAction.setVisible(True) + action = self.menu.exec_(self.themeListWidget.mapToGlobal(point)) + if action == self.editAction: + self.onEditTheme() + if action == self.copyAction: + self.onCopyTheme() + if action == self.renameAction: + self.onRenameTheme() + if action == self.deleteAction: + self.onDeleteTheme() + if action == self.globalAction: + self. self.changeGlobalFromScreen() + if action == self.exportAction: + self. self.onExportTheme() + def changeGlobalFromTab(self, themeName): """ Change the global theme when it is changed through the Themes settings From 2f75087e409e45e77cefa05507a24bc0d8bdeecc Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sun, 26 Sep 2010 09:38:11 +0100 Subject: [PATCH 8/9] Merge request cleanups --- openlp/core/lib/__init__.py | 1 - openlp/core/lib/theme.py | 2 +- openlp/core/ui/filerenamedialog.py | 38 ++++++++++++++++++ openlp/core/ui/filerenameform.py | 42 ++++++++++++++++++++ openlp/core/ui/thememanager.py | 9 +++-- openlp/plugins/images/imageplugin.py | 2 +- openlp/plugins/images/lib/mediaitem.py | 1 - resources/forms/filerenamedialog.ui | 54 ++++++++++++++++++++++++++ 8 files changed, 142 insertions(+), 7 deletions(-) create mode 100644 openlp/core/ui/filerenamedialog.py create mode 100644 openlp/core/ui/filerenameform.py create mode 100644 resources/forms/filerenamedialog.ui diff --git a/openlp/core/lib/__init__.py b/openlp/core/lib/__init__.py index e9ca9ecd7..560450741 100644 --- a/openlp/core/lib/__init__.py +++ b/openlp/core/lib/__init__.py @@ -273,7 +273,6 @@ def resize_image(image, width, height, background=QtCore.Qt.black): painter = QtGui.QPainter(new_image) painter.drawImage((width - realw) / 2, (height - realh) / 2, preview) image_cache[image_cache_key] = new_image - print image_cache return new_image def check_item_selected(list_widget, message): diff --git a/openlp/core/lib/theme.py b/openlp/core/lib/theme.py index 33d7676ca..def6f01cc 100644 --- a/openlp/core/lib/theme.py +++ b/openlp/core/lib/theme.py @@ -91,7 +91,7 @@ boolean_list = [u'italics', u'override', u'outline', u'shadow', \ u'slide_transition'] integer_list =[u'proportion', u'line_adjustment', u'x', u'height', u'y', \ -u'width', u'shadow_size', u'outline_size', u'horizontal_align',\ +u'width', u'shadow_size', u'outline_size', u'horizontal_align', \ u'vertical_align', u'wrap_style' ] class ThemeXML(object): diff --git a/openlp/core/ui/filerenamedialog.py b/openlp/core/ui/filerenamedialog.py new file mode 100644 index 000000000..8632ef37a --- /dev/null +++ b/openlp/core/ui/filerenamedialog.py @@ -0,0 +1,38 @@ +# -*- coding: utf-8 -*- + +# Form implementation generated from reading ui file 'filerenamedialog.ui' +# +# Created: Sat Sep 25 16:20:30 2010 +# by: PyQt4 UI code generator 4.7.3 +# +# WARNING! All changes made in this file will be lost! + +from PyQt4 import QtCore, QtGui + +class Ui_FileRenameDialog(object): + def setupUi(self, FileRenameDialog): + FileRenameDialog.setObjectName("FileRenameDialog") + FileRenameDialog.resize(400, 87) + self.buttonBox = QtGui.QDialogButtonBox(FileRenameDialog) + self.buttonBox.setGeometry(QtCore.QRect(210, 50, 171, 25)) + self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok) + self.buttonBox.setObjectName("buttonBox") + self.widget = QtGui.QWidget(FileRenameDialog) + self.widget.setGeometry(QtCore.QRect(10, 10, 381, 35)) + self.widget.setObjectName("widget") + self.horizontalLayout = QtGui.QHBoxLayout(self.widget) + self.horizontalLayout.setObjectName("horizontalLayout") + self.FileRenameLabel = QtGui.QLabel(self.widget) + self.FileRenameLabel.setObjectName("FileRenameLabel") + self.horizontalLayout.addWidget(self.FileRenameLabel) + self.FileNameEdit = QtGui.QLineEdit(self.widget) + self.FileNameEdit.setObjectName("FileNameEdit") + self.horizontalLayout.addWidget(self.FileNameEdit) + + self.retranslateUi(FileRenameDialog) + QtCore.QMetaObject.connectSlotsByName(FileRenameDialog) + + def retranslateUi(self, FileRenameDialog): + FileRenameDialog.setWindowTitle(QtGui.QApplication.translate("FileRenameDialog", "File Rename", None, QtGui.QApplication.UnicodeUTF8)) + self.FileRenameLabel.setText(QtGui.QApplication.translate("FileRenameDialog", "New File Name:", None, QtGui.QApplication.UnicodeUTF8)) + diff --git a/openlp/core/ui/filerenameform.py b/openlp/core/ui/filerenameform.py new file mode 100644 index 000000000..d1c339811 --- /dev/null +++ b/openlp/core/ui/filerenameform.py @@ -0,0 +1,42 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2010 Raoul Snyman # +# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael # +# Gorven, Scott Guerrieri, Meinert Jordan, Andreas Preikschat, Christian # +# Richter, Philip Ridout, Maikel Stuivenberg, Martin Thompson, Jon Tibble, # +# Carsten Tinggaard, Frode Woldsund # +# --------------------------------------------------------------------------- # +# This program is free software; you can redistribute it and/or modify it # +# under the terms of the GNU General Public License as published by the Free # +# Software Foundation; version 2 of the License. # +# # +# This program is distributed in the hope that it will be useful, but WITHOUT # +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # +# more details. # +# # +# You should have received a copy of the GNU General Public License along # +# with this program; if not, write to the Free Software Foundation, Inc., 59 # +# Temple Place, Suite 330, Boston, MA 02111-1307 USA # +############################################################################### + +from PyQt4 import QtCore, QtGui + +from filerenamedialog import Ui_FileRenameDialog +from openlp.core.lib import translate + +class FileRenameForm(QtGui.QDialog, Ui_FileRenameDialog): + """ + The exception dialog + """ + def __init__(self, parent): + QtGui.QDialog.__init__(self, parent) + self.setupUi(self) + QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(u'accepted()'), + self.accept) + QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(u'rejected()'), + self.reject) diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index f1c0ebd83..2e6fb8602 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -142,9 +142,12 @@ class ThemeManager(QtGui.QWidget): themeName = unicode(item.text()) self.deleteAction.setVisible(False) self.renameAction.setVisible(False) + self.globalAction.setVisible(False) + # If default theme restrict actions if realThemeName == themeName: self.deleteAction.setVisible(True) self.renameAction.setVisible(True) + self.globalAction.setVisible(True) action = self.menu.exec_(self.themeListWidget.mapToGlobal(point)) if action == self.editAction: self.onEditTheme() @@ -155,9 +158,9 @@ class ThemeManager(QtGui.QWidget): if action == self.deleteAction: self.onDeleteTheme() if action == self.globalAction: - self. self.changeGlobalFromScreen() + self.changeGlobalFromScreen() if action == self.exportAction: - self. self.onExportTheme() + self.onExportTheme() def changeGlobalFromTab(self, themeName): """ @@ -323,7 +326,7 @@ class ThemeManager(QtGui.QWidget): item.data(QtCore.Qt.UserRole).toString()) self.amendThemeForm.exec_() - def onDeleteTheme(self, onlyDelete=True): + def onDeleteTheme(self): """ Delete a theme """ diff --git a/openlp/plugins/images/imageplugin.py b/openlp/plugins/images/imageplugin.py index 7f910f395..711000191 100644 --- a/openlp/plugins/images/imageplugin.py +++ b/openlp/plugins/images/imageplugin.py @@ -35,7 +35,7 @@ class ImagePlugin(Plugin): log.info(u'Image Plugin loaded') def __init__(self, plugin_helpers): - Plugin.__init__(self, u'Images', u'1.9.3', plugin_helpers) + Plugin.__init__(self, u'Images', u'1.9.4', plugin_helpers) self.weight = -7 self.icon_path = u':/plugins/plugin_images.png' self.icon = build_icon(self.icon_path) diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index 147e2fffc..4caf5bfc2 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -187,7 +187,6 @@ class ImageMediaItem(MediaManagerItem): for item in items: bitem = self.listView.item(item.row()) filename = unicode(bitem.data(QtCore.Qt.UserRole).toString()) - frame = QtGui.QImage(unicode(filename)) self.parent.liveController.display.image(filename) self.resetButton.setVisible(True) diff --git a/resources/forms/filerenamedialog.ui b/resources/forms/filerenamedialog.ui new file mode 100644 index 000000000..fb2d8780d --- /dev/null +++ b/resources/forms/filerenamedialog.ui @@ -0,0 +1,54 @@ + + + FileRenameDialog + + + + 0 + 0 + 400 + 87 + + + + File Rename + + + + + 210 + 50 + 171 + 25 + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + 10 + 10 + 381 + 27 + + + + + + + New File Name: + + + + + + + + + + + + From 0d5fc3c980203ac7c30e465f17634a9672555b99 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sun, 26 Sep 2010 13:23:50 +0100 Subject: [PATCH 9/9] Style Fixups --- openlp/core/ui/filerenamedialog.py | 37 ++++++++++++++----- openlp/core/ui/thememanager.py | 58 +++++++++++++++--------------- 2 files changed, 58 insertions(+), 37 deletions(-) diff --git a/openlp/core/ui/filerenamedialog.py b/openlp/core/ui/filerenamedialog.py index 8632ef37a..48c9eb13f 100644 --- a/openlp/core/ui/filerenamedialog.py +++ b/openlp/core/ui/filerenamedialog.py @@ -1,14 +1,33 @@ # -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 -# Form implementation generated from reading ui file 'filerenamedialog.ui' -# -# Created: Sat Sep 25 16:20:30 2010 -# by: PyQt4 UI code generator 4.7.3 -# -# WARNING! All changes made in this file will be lost! +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2010 Raoul Snyman # +# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael # +# Gorven, Scott Guerrieri, Meinert Jordan, Andreas Preikschat, Christian # +# Richter, Philip Ridout, Maikel Stuivenberg, Martin Thompson, Jon Tibble, # +# Carsten Tinggaard, Frode Woldsund # +# --------------------------------------------------------------------------- # +# This program is free software; you can redistribute it and/or modify it # +# under the terms of the GNU General Public License as published by the Free # +# Software Foundation; version 2 of the License. # +# # +# This program is distributed in the hope that it will be useful, but WITHOUT # +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # +# more details. # +# # +# You should have received a copy of the GNU General Public License along # +# with this program; if not, write to the Free Software Foundation, Inc., 59 # +# Temple Place, Suite 330, Boston, MA 02111-1307 USA # +############################################################################### from PyQt4 import QtCore, QtGui +from openlp.core.lib import translate + class Ui_FileRenameDialog(object): def setupUi(self, FileRenameDialog): FileRenameDialog.setObjectName("FileRenameDialog") @@ -33,6 +52,8 @@ class Ui_FileRenameDialog(object): QtCore.QMetaObject.connectSlotsByName(FileRenameDialog) def retranslateUi(self, FileRenameDialog): - FileRenameDialog.setWindowTitle(QtGui.QApplication.translate("FileRenameDialog", "File Rename", None, QtGui.QApplication.UnicodeUTF8)) - self.FileRenameLabel.setText(QtGui.QApplication.translate("FileRenameDialog", "New File Name:", None, QtGui.QApplication.UnicodeUTF8)) + FileRenameDialog.setWindowTitle(self.transitionGroupBox.setTitle( + translate('OpenLP.FileRenameForm', 'File Rename'))) + self.FileRenameLabel.setText(translate('OpenLP.FileRenameForm', + 'New File Name:')) diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index 2e6fb8602..ff61b05e8 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -270,37 +270,37 @@ class ThemeManager(QtGui.QWidget): save_to = os.path.join(self.path, theme_name, filename) save_from = oldThemeData.background_filename new_theme.add_font(unicode(oldThemeData.font_main_name), - unicode(oldThemeData.font_main_color), - unicode(oldThemeData.font_main_proportion), - unicode(oldThemeData.font_main_override), u'main', - unicode(oldThemeData.font_main_weight), - unicode(oldThemeData.font_main_italics), - unicode(oldThemeData.font_main_line_adjustment), - unicode(oldThemeData.font_main_x), - unicode(oldThemeData.font_main_y), - unicode(oldThemeData.font_main_width), - unicode(oldThemeData.font_main_height)) + unicode(oldThemeData.font_main_color), + unicode(oldThemeData.font_main_proportion), + unicode(oldThemeData.font_main_override), u'main', + unicode(oldThemeData.font_main_weight), + unicode(oldThemeData.font_main_italics), + unicode(oldThemeData.font_main_line_adjustment), + unicode(oldThemeData.font_main_x), + unicode(oldThemeData.font_main_y), + unicode(oldThemeData.font_main_width), + unicode(oldThemeData.font_main_height)) new_theme.add_font(unicode(oldThemeData.font_footer_name), - unicode(oldThemeData.font_footer_color), - unicode(oldThemeData.font_footer_proportion), - unicode(oldThemeData.font_footer_override), u'footer', - unicode(oldThemeData.font_footer_weight), - unicode(oldThemeData.font_footer_italics), - 0, # line adjustment - unicode(oldThemeData.font_footer_x), - unicode(oldThemeData.font_footer_y), - unicode(oldThemeData.font_footer_width), - unicode(oldThemeData.font_footer_height)) + unicode(oldThemeData.font_footer_color), + unicode(oldThemeData.font_footer_proportion), + unicode(oldThemeData.font_footer_override), u'footer', + unicode(oldThemeData.font_footer_weight), + unicode(oldThemeData.font_footer_italics), + 0, # line adjustment + unicode(oldThemeData.font_footer_x), + unicode(oldThemeData.font_footer_y), + unicode(oldThemeData.font_footer_width), + unicode(oldThemeData.font_footer_height)) new_theme.add_display(unicode(oldThemeData.display_shadow), - unicode(oldThemeData.display_shadow_color), - unicode(oldThemeData.display_outline), - unicode(oldThemeData.display_outline_color), - unicode(oldThemeData.display_horizontal_align), - unicode(oldThemeData.display_vertical_align), - unicode(oldThemeData.display_wrap_style), - unicode(oldThemeData.display_slide_transition), - unicode(oldThemeData.display_shadow_size), - unicode(oldThemeData.display_outline_size)) + unicode(oldThemeData.display_shadow_color), + unicode(oldThemeData.display_outline), + unicode(oldThemeData.display_outline_color), + unicode(oldThemeData.display_horizontal_align), + unicode(oldThemeData.display_vertical_align), + unicode(oldThemeData.display_wrap_style), + unicode(oldThemeData.display_slide_transition), + unicode(oldThemeData.display_shadow_size), + unicode(oldThemeData.display_outline_size)) theme = new_theme.extract_xml() pretty_theme = new_theme.extract_formatted_xml() self.saveTheme(newThemeName, theme, pretty_theme, save_from, save_to)