From 836f7c2ab7c4ba715e341f740097c448c4f905b6 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sun, 6 Dec 2009 19:21:58 +0000 Subject: [PATCH 1/5] Remove unneeded image --- resources/images/openlp-2.qrc | 3 --- 1 file changed, 3 deletions(-) diff --git a/resources/images/openlp-2.qrc b/resources/images/openlp-2.qrc index 244a70d29..8fa38c42b 100644 --- a/resources/images/openlp-2.qrc +++ b/resources/images/openlp-2.qrc @@ -125,7 +125,4 @@ theme_export.png theme_import.png - - slide.png - From 26dd28d0831d56e27f26f9351807c773181b9d11 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sun, 6 Dec 2009 19:22:41 +0000 Subject: [PATCH 2/5] Remove unneeded code --- openlp/core/lib/__init__.py | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/openlp/core/lib/__init__.py b/openlp/core/lib/__init__.py index cbde91b17..9356bc284 100644 --- a/openlp/core/lib/__init__.py +++ b/openlp/core/lib/__init__.py @@ -105,25 +105,8 @@ def build_icon(icon): ButtonIcon.addPixmap( QtGui.QPixmap(icon), QtGui.QIcon.Normal, QtGui.QIcon.Off) else: - if len(icon) > 2: - ButtonIcon.addPixmap(QtGui.QPixmap.fromImage(QtGui.QImage(icon)), - QtGui.QIcon.Normal, QtGui.QIcon.Off) - else: - #lets build a Icon from text - pmap = QtGui.QPixmap(u':/pages/slide.png') - painter = QtGui.QPainter(pmap) - painter.setPen(QtGui.QColor(QtGui.QColor.black)) - font = QtGui.QFont() - font.setFamily(u'Arial') - font.setBold(True) - font.setPointSize(12) - painter.setFont(font) - metrics = QtGui.QFontMetrics(font) - painter.drawText(5, 3 + metrics.ascent(), icon) - painter.end() - ButtonIcon.addPixmap( - pmap, QtGui.QIcon.Normal, QtGui.QIcon.Off) - + ButtonIcon.addPixmap(QtGui.QPixmap.fromImage(QtGui.QImage(icon)), + QtGui.QIcon.Normal, QtGui.QIcon.Off) elif isinstance(icon, QtGui.QImage): ButtonIcon = QtGui.QIcon() ButtonIcon.addPixmap( From 4158ae458eba83ac3a8867a700f312c3c1396ca3 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Tue, 8 Dec 2009 17:04:27 +0000 Subject: [PATCH 3/5] Clean up ServiceItem usage in ServiceManager --- openlp/core/lib/serviceitem.py | 4 ++++ openlp/core/ui/servicemanager.py | 10 +++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/openlp/core/lib/serviceitem.py b/openlp/core/lib/serviceitem.py index 8f30499f5..f8fe7d539 100644 --- a/openlp/core/lib/serviceitem.py +++ b/openlp/core/lib/serviceitem.py @@ -276,6 +276,10 @@ class ServiceItem(object): def is_image(self): return self.service_item_type == ServiceItemType.Image + def uses_file(self): + return self.service_item_type == ServiceItemType.Image or \ + self.service_item_type == ServiceItemType.Command + def is_text(self): return self.service_item_type == ServiceItemType.Text diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 96e82dead..c7dcc33b0 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -411,6 +411,7 @@ class ServiceManager(QtGui.QWidget): * An osd which is a pickle of the service items * All image, presentation and video files needed to run the service. """ + log.debug(u'onSaveService') if not quick or self.isNew: filename = QtGui.QFileDialog.getSaveFileName(self, u'Save Service', self.config.get_last_dir()) @@ -430,13 +431,12 @@ class ServiceManager(QtGui.QWidget): try: zip = zipfile.ZipFile(unicode(filename), 'w') for item in self.serviceItems: - service.append( - {u'serviceitem':item[u'service_item'].get_service_repr()}) - if item[u'service_item'].service_item_type == ServiceItemType.Image or \ - item[u'service_item'].service_item_type == ServiceItemType.Command: + service.append({u'serviceitem':item[u'service_item'].get_service_repr()}) + if item[u'service_item'].uses_file(): for frame in item[u'service_item'].get_frames: path_from = unicode(os.path.join( - item[u'service_item'].service_item_path, frame.get_frame_title())) + item[u'service_item'].service_item_path, + frame.get_frame_title())) zip.write(path_from) file = open(servicefile, u'wb') cPickle.dump(service, file) From 9893a887ab4d18836378188c3d2fb7d30999ec2e Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Tue, 8 Dec 2009 17:52:45 +0000 Subject: [PATCH 4/5] Add slideTransition Flag to theme to allow for transitions to be turned off at theme level --- openlp/core/lib/renderer.py | 36 +++++++++++++++++------------- openlp/core/lib/themexmlhandler.py | 21 ++++++++++++----- openlp/core/ui/amendthemedialog.py | 13 +++++++++++ openlp/core/ui/amendthemeform.py | 25 ++++++++++++++++++++- openlp/core/ui/thememanager.py | 3 ++- 5 files changed, 75 insertions(+), 23 deletions(-) diff --git a/openlp/core/lib/renderer.py b/openlp/core/lib/renderer.py index 6bb064d07..3d6198419 100644 --- a/openlp/core/lib/renderer.py +++ b/openlp/core/lib/renderer.py @@ -266,7 +266,10 @@ class Renderer(object): bbox = self._render_lines_unaligned(footer_lines, True, (self._rect_footer.left(), self._rect_footer.top()), True) log.debug(u'generate_frame_from_lines - Finish') - return {u'main':self._frame, u'trans':self._frameOp} + if self._theme.display_slideTransition: + return {u'main':self._frame, u'trans':self._frameOp} + else: + return {u'main':self._frame, u'trans':None} def _generate_background_frame(self): """ @@ -574,22 +577,23 @@ class Renderer(object): if draw: painter.drawText(x, y + metrics.ascent(), line) painter.end() - # Print 2nd image with 50% weight - painter = QtGui.QPainter() - painter.begin(self._frameOp) - painter.setRenderHint(QtGui.QPainter.Antialiasing); - painter.setOpacity(0.7) - painter.setFont(font) - if color is None: - if footer: - painter.setPen(QtGui.QColor(self._theme.font_footer_color)) + if self._theme.display_slideTransition: + # Print 2nd image with 50% weight + painter = QtGui.QPainter() + painter.begin(self._frameOp) + painter.setRenderHint(QtGui.QPainter.Antialiasing); + painter.setOpacity(0.7) + painter.setFont(font) + if color is None: + if footer: + painter.setPen(QtGui.QColor(self._theme.font_footer_color)) + else: + painter.setPen(QtGui.QColor(self._theme.font_main_color)) else: - painter.setPen(QtGui.QColor(self._theme.font_main_color)) - else: - painter.setPen(QtGui.QColor(color)) - if draw: - painter.drawText(x, y + metrics.ascent(), line) - painter.end() + painter.setPen(QtGui.QColor(color)) + if draw: + painter.drawText(x, y + metrics.ascent(), line) + painter.end() return (w, h) def snoop_Image(self, image, image2=None): diff --git a/openlp/core/lib/themexmlhandler.py b/openlp/core/lib/themexmlhandler.py index b2429c952..dc5ae432b 100644 --- a/openlp/core/lib/themexmlhandler.py +++ b/openlp/core/lib/themexmlhandler.py @@ -67,9 +67,10 @@ blankthemexml=\ True False - 0 - 0 - 0 + 0 + 0 + 0 + False ''' @@ -237,7 +238,7 @@ class ThemeXML(object): background.appendChild(element) def add_display(self, shadow, shadow_color, outline, outline_color, - horizontal, vertical, wrap): + horizontal, vertical, wrap, transition): """ Add a Display options. @@ -261,6 +262,10 @@ class ThemeXML(object): ``wrap`` Wrap style. + + ``transition`` + Whether the slide transition is active. + """ background = self.theme_xml.createElement(u'display') self.theme.appendChild(background) @@ -291,6 +296,12 @@ class ThemeXML(object): value = self.theme_xml.createTextNode(wrap) element.appendChild(value) background.appendChild(element) + # Slide Transition + element = self.theme_xml.createElement(u'slideTransition') + value = self.theme_xml.createTextNode(transition) + element.appendChild(value) + background.appendChild(element) + def child_element(self, element, tag, value): """ @@ -362,7 +373,7 @@ class ThemeXML(object): 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'): + 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]) diff --git a/openlp/core/ui/amendthemedialog.py b/openlp/core/ui/amendthemedialog.py index d2670720a..ad5fbe65f 100644 --- a/openlp/core/ui/amendthemedialog.py +++ b/openlp/core/ui/amendthemedialog.py @@ -487,6 +487,17 @@ class Ui_AmendThemeDialog(object): self.VerticalComboBox.addItem(QtCore.QString()) self.gridLayout_4.addWidget(self.VerticalComboBox, 1, 1, 1, 1) self.OptionsRightLayout.addWidget(self.AlignmentGroupBox) + self.TransitionGroupBox = QtGui.QGroupBox(self.OptionsRightWidget) + self.TransitionGroupBox.setObjectName(u'TransitionGroupBox') + self.gridLayout_5 = QtGui.QGridLayout(self.TransitionGroupBox) + self.gridLayout_5.setObjectName(u'gridLayout_5') + self.SlideTransitionCheckedBoxLabel = QtGui.QLabel(self.TransitionGroupBox) + self.SlideTransitionCheckedBoxLabel.setObjectName(u'SlideTransitionCheckedBoxLabel') + self.gridLayout_5.addWidget(self.SlideTransitionCheckedBoxLabel, 0, 0, 1, 1) + self.SlideTransitionCheckedBox = QtGui.QCheckBox(self.AlignmentGroupBox) + self.SlideTransitionCheckedBox.setTristate(False) + self.gridLayout_5.addWidget(self.SlideTransitionCheckedBox, 0, 1, 1, 1) + self.OptionsRightLayout.addWidget(self.TransitionGroupBox) spacerItem6 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) self.OptionsRightLayout.addItem(spacerItem6) self.OtherOptionsLayout.addWidget(self.OptionsRightWidget) @@ -643,6 +654,8 @@ class Ui_AmendThemeDialog(object): self.VerticalComboBox.setItemText(0, self.trUtf8('Top')) self.VerticalComboBox.setItemText(1, self.trUtf8('Middle')) self.VerticalComboBox.setItemText(2, self.trUtf8('Bottom')) + self.TransitionGroupBox.setTitle(self.trUtf8('Slide Transition')) + self.SlideTransitionCheckedBoxLabel.setText(self.trUtf8('Transition Active:')) self.ThemeTabWidget.setTabText( self.ThemeTabWidget.indexOf(self.OtherOptionsTab), self.trUtf8('Other Options')) diff --git a/openlp/core/ui/amendthemeform.py b/openlp/core/ui/amendthemeform.py index 0769db07a..fd660d6d2 100644 --- a/openlp/core/ui/amendthemeform.py +++ b/openlp/core/ui/amendthemeform.py @@ -123,6 +123,8 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): QtCore.SIGNAL(u'stateChanged(int)'), self.onOutlineCheckBoxChanged) QtCore.QObject.connect(self.ShadowCheckBox, QtCore.SIGNAL(u'stateChanged(int)'), self.onShadowCheckBoxChanged) + QtCore.QObject.connect(self.SlideTransitionCheckedBox, + QtCore.SIGNAL(u'stateChanged(int)'), self.onSlideTransitionCheckedBoxChanged) def accept(self): new_theme = ThemeXML() @@ -176,7 +178,8 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): 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_wrapStyle), + unicode(self.theme.display_slideTransition)) theme = new_theme.extract_xml() pretty_theme = new_theme.extract_formatted_xml() if self.thememanager.saveTheme(theme_name, theme, pretty_theme, @@ -446,6 +449,15 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): self.stateChanging(self.theme) self.previewTheme() + def onSlideTransitionCheckedBoxChanged(self, value): + print "changed" + if value == 2: # checked + self.theme.display_slideTransition= True + else: + self.theme.display_slideTransition = False + self.stateChanging(self.theme) + self.previewTheme() + def onShadowColorPushButtonClicked(self): self.theme.display_shadow_color = QtGui.QColorDialog.getColor( QtGui.QColor(self.theme.display_shadow_color), self).name() @@ -562,6 +574,12 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): self.ShadowCheckBox.setChecked(False) self.ShadowColorPushButton.setEnabled(False) + print self.theme.display_slideTransition + if self.theme.display_slideTransition: + self.SlideTransitionCheckedBox.setChecked(True) + else: + self.SlideTransitionCheckedBox.setChecked(False) + self.HorizontalComboBox.setCurrentIndex( self.theme.display_horizontalAlign) self.VerticalComboBox.setCurrentIndex(self.theme.display_verticalAlign) @@ -654,6 +672,11 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): else: self.ShadowColorPushButton.setEnabled(False) + if self.theme.display_slideTransition: + self.SlideTransitionCheckedBox.setChecked(True) + else: + self.SlideTransitionCheckedBox.setChecked(False) + def previewTheme(self): if self.allowPreview: #calculate main number of rows diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index 12af6d10f..c3277637b 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -389,7 +389,7 @@ class ThemeManager(QtGui.QWidget): newtheme.add_display(unicode(shadow), unicode(theme.ShadowColor.name()), unicode(outline), unicode(theme.OutlineColor.name()), unicode(theme.HorizontalAlign), unicode(theme.VerticalAlign), - unicode(theme.WrapStyle)) + unicode(theme.WrapStyle), 0) return newtheme.extract_xml() def saveTheme(self, name, theme_xml, theme_pretty_xml, image_from, @@ -502,6 +502,7 @@ class ThemeManager(QtGui.QWidget): #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_indentation = \ From 3cc63840f4eddd3058fa719348d7204a0d383c0a Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Wed, 9 Dec 2009 17:09:45 +0000 Subject: [PATCH 5/5] Fix up theme string issues to False is matched Remove any Print statements --- openlp/core/lib/themexmlhandler.py | 1 + openlp/core/ui/amendthemeform.py | 13 +++---------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/openlp/core/lib/themexmlhandler.py b/openlp/core/lib/themexmlhandler.py index dc5ae432b..42743d1bd 100644 --- a/openlp/core/lib/themexmlhandler.py +++ b/openlp/core/lib/themexmlhandler.py @@ -386,6 +386,7 @@ class ThemeXML(object): 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: diff --git a/openlp/core/ui/amendthemeform.py b/openlp/core/ui/amendthemeform.py index fd660d6d2..da56ce3c4 100644 --- a/openlp/core/ui/amendthemeform.py +++ b/openlp/core/ui/amendthemeform.py @@ -450,9 +450,8 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): self.previewTheme() def onSlideTransitionCheckedBoxChanged(self, value): - print "changed" if value == 2: # checked - self.theme.display_slideTransition= True + self.theme.display_slideTransition = True else: self.theme.display_slideTransition = False self.stateChanging(self.theme) @@ -574,11 +573,10 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): self.ShadowCheckBox.setChecked(False) self.ShadowColorPushButton.setEnabled(False) - print self.theme.display_slideTransition if self.theme.display_slideTransition: - self.SlideTransitionCheckedBox.setChecked(True) + self.SlideTransitionCheckedBox.setCheckState(QtCore.Qt.Checked) else: - self.SlideTransitionCheckedBox.setChecked(False) + self.SlideTransitionCheckedBox.setCheckState(QtCore.Qt.Unchecked) self.HorizontalComboBox.setCurrentIndex( self.theme.display_horizontalAlign) @@ -672,11 +670,6 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): else: self.ShadowColorPushButton.setEnabled(False) - if self.theme.display_slideTransition: - self.SlideTransitionCheckedBox.setChecked(True) - else: - self.SlideTransitionCheckedBox.setChecked(False) - def previewTheme(self): if self.allowPreview: #calculate main number of rows