Add slideTransition Flag to theme to allow for transitions to be turned off at theme level

This commit is contained in:
Tim Bentley 2009-12-08 17:52:45 +00:00
parent 4158ae458e
commit 9893a887ab
5 changed files with 75 additions and 23 deletions

View File

@ -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):

View File

@ -67,9 +67,10 @@ blankthemexml=\
<display>
<shadow color="#000000">True</shadow>
<outline color="#000000">False</outline>
<horizontalAlign>0</horizontalAlign>
<verticalAlign>0</verticalAlign>
<wrapStyle>0</wrapStyle>
<horizontalAlign>0</horizontalAlign>
<verticalAlign>0</verticalAlign>
<wrapStyle>0</wrapStyle>
<slideTransition>False</slideTransition>
</display>
</theme>
'''
@ -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])

View File

@ -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'))

View File

@ -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

View File

@ -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 = \