Merge from lp:~trb143/openlp/cleanup

bzr-revno: 685
This commit is contained in:
Tim Bentley 2009-12-09 23:17:41 +02:00 committed by Raoul Snyman
commit 01cce5b4cd
10 changed files with 81 additions and 51 deletions

View File

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

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

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

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])
@ -375,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:

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,14 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
self.stateChanging(self.theme)
self.previewTheme()
def onSlideTransitionCheckedBoxChanged(self, value):
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 +573,11 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
self.ShadowCheckBox.setChecked(False)
self.ShadowColorPushButton.setEnabled(False)
if self.theme.display_slideTransition:
self.SlideTransitionCheckedBox.setCheckState(QtCore.Qt.Checked)
else:
self.SlideTransitionCheckedBox.setCheckState(QtCore.Qt.Unchecked)
self.HorizontalComboBox.setCurrentIndex(
self.theme.display_horizontalAlign)
self.VerticalComboBox.setCurrentIndex(self.theme.display_verticalAlign)

View File

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

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

View File

@ -125,7 +125,4 @@
<file>theme_export.png</file>
<file>theme_import.png</file>
</qresource>
<qresource prefix="pages" >
<file>slide.png</file>
</qresource>
</RCC>

View File

@ -1 +1 @@
1.9.0-684
1.9.0-685