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( ButtonIcon.addPixmap(
QtGui.QPixmap(icon), QtGui.QIcon.Normal, QtGui.QIcon.Off) QtGui.QPixmap(icon), QtGui.QIcon.Normal, QtGui.QIcon.Off)
else: else:
if len(icon) > 2:
ButtonIcon.addPixmap(QtGui.QPixmap.fromImage(QtGui.QImage(icon)), ButtonIcon.addPixmap(QtGui.QPixmap.fromImage(QtGui.QImage(icon)),
QtGui.QIcon.Normal, QtGui.QIcon.Off) 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)
elif isinstance(icon, QtGui.QImage): elif isinstance(icon, QtGui.QImage):
ButtonIcon = QtGui.QIcon() ButtonIcon = QtGui.QIcon()
ButtonIcon.addPixmap( ButtonIcon.addPixmap(

View File

@ -266,7 +266,10 @@ class Renderer(object):
bbox = self._render_lines_unaligned(footer_lines, True, bbox = self._render_lines_unaligned(footer_lines, True,
(self._rect_footer.left(), self._rect_footer.top()), True) (self._rect_footer.left(), self._rect_footer.top()), True)
log.debug(u'generate_frame_from_lines - Finish') log.debug(u'generate_frame_from_lines - Finish')
if self._theme.display_slideTransition:
return {u'main':self._frame, u'trans':self._frameOp} return {u'main':self._frame, u'trans':self._frameOp}
else:
return {u'main':self._frame, u'trans':None}
def _generate_background_frame(self): def _generate_background_frame(self):
""" """
@ -574,6 +577,7 @@ class Renderer(object):
if draw: if draw:
painter.drawText(x, y + metrics.ascent(), line) painter.drawText(x, y + metrics.ascent(), line)
painter.end() painter.end()
if self._theme.display_slideTransition:
# Print 2nd image with 50% weight # Print 2nd image with 50% weight
painter = QtGui.QPainter() painter = QtGui.QPainter()
painter.begin(self._frameOp) painter.begin(self._frameOp)

View File

@ -276,6 +276,10 @@ class ServiceItem(object):
def is_image(self): def is_image(self):
return self.service_item_type == ServiceItemType.Image 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): def is_text(self):
return self.service_item_type == ServiceItemType.Text return self.service_item_type == ServiceItemType.Text

View File

@ -70,6 +70,7 @@ blankthemexml=\
<horizontalAlign>0</horizontalAlign> <horizontalAlign>0</horizontalAlign>
<verticalAlign>0</verticalAlign> <verticalAlign>0</verticalAlign>
<wrapStyle>0</wrapStyle> <wrapStyle>0</wrapStyle>
<slideTransition>False</slideTransition>
</display> </display>
</theme> </theme>
''' '''
@ -237,7 +238,7 @@ class ThemeXML(object):
background.appendChild(element) background.appendChild(element)
def add_display(self, shadow, shadow_color, outline, outline_color, def add_display(self, shadow, shadow_color, outline, outline_color,
horizontal, vertical, wrap): horizontal, vertical, wrap, transition):
""" """
Add a Display options. Add a Display options.
@ -261,6 +262,10 @@ class ThemeXML(object):
``wrap`` ``wrap``
Wrap style. Wrap style.
``transition``
Whether the slide transition is active.
""" """
background = self.theme_xml.createElement(u'display') background = self.theme_xml.createElement(u'display')
self.theme.appendChild(background) self.theme.appendChild(background)
@ -291,6 +296,12 @@ class ThemeXML(object):
value = self.theme_xml.createTextNode(wrap) value = self.theme_xml.createTextNode(wrap)
element.appendChild(value) element.appendChild(value)
background.appendChild(element) 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): def child_element(self, element, tag, value):
""" """
@ -362,7 +373,7 @@ class ThemeXML(object):
if master == u'font_' and e[0] == u'type': if master == u'font_' and e[0] == u'type':
master += e[1] + u'_' master += e[1] + u'_'
elif master == u'display_' and (element.tag == u'shadow' \ 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) et = str_to_bool(element.text)
setattr(self, master + element.tag, et) setattr(self, master + element.tag, et)
setattr(self, master + element.tag + u'_'+ e[0], e[1]) setattr(self, master + element.tag + u'_'+ e[0], e[1])
@ -375,6 +386,7 @@ class ThemeXML(object):
else: else:
if element.tag: if element.tag:
field = master + element.tag field = master + element.tag
element.text = element.text.strip().lstrip()
if element.text == u'True' or element.text == u'False': if element.text == u'True' or element.text == u'False':
setattr(self, field, str_to_bool(element.text)) setattr(self, field, str_to_bool(element.text))
else: else:

View File

@ -487,6 +487,17 @@ class Ui_AmendThemeDialog(object):
self.VerticalComboBox.addItem(QtCore.QString()) self.VerticalComboBox.addItem(QtCore.QString())
self.gridLayout_4.addWidget(self.VerticalComboBox, 1, 1, 1, 1) self.gridLayout_4.addWidget(self.VerticalComboBox, 1, 1, 1, 1)
self.OptionsRightLayout.addWidget(self.AlignmentGroupBox) 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) spacerItem6 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
self.OptionsRightLayout.addItem(spacerItem6) self.OptionsRightLayout.addItem(spacerItem6)
self.OtherOptionsLayout.addWidget(self.OptionsRightWidget) self.OtherOptionsLayout.addWidget(self.OptionsRightWidget)
@ -643,6 +654,8 @@ class Ui_AmendThemeDialog(object):
self.VerticalComboBox.setItemText(0, self.trUtf8('Top')) self.VerticalComboBox.setItemText(0, self.trUtf8('Top'))
self.VerticalComboBox.setItemText(1, self.trUtf8('Middle')) self.VerticalComboBox.setItemText(1, self.trUtf8('Middle'))
self.VerticalComboBox.setItemText(2, self.trUtf8('Bottom')) 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.setTabText(
self.ThemeTabWidget.indexOf(self.OtherOptionsTab), self.ThemeTabWidget.indexOf(self.OtherOptionsTab),
self.trUtf8('Other Options')) self.trUtf8('Other Options'))

View File

@ -123,6 +123,8 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
QtCore.SIGNAL(u'stateChanged(int)'), self.onOutlineCheckBoxChanged) QtCore.SIGNAL(u'stateChanged(int)'), self.onOutlineCheckBoxChanged)
QtCore.QObject.connect(self.ShadowCheckBox, QtCore.QObject.connect(self.ShadowCheckBox,
QtCore.SIGNAL(u'stateChanged(int)'), self.onShadowCheckBoxChanged) QtCore.SIGNAL(u'stateChanged(int)'), self.onShadowCheckBoxChanged)
QtCore.QObject.connect(self.SlideTransitionCheckedBox,
QtCore.SIGNAL(u'stateChanged(int)'), self.onSlideTransitionCheckedBoxChanged)
def accept(self): def accept(self):
new_theme = ThemeXML() new_theme = ThemeXML()
@ -176,7 +178,8 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
unicode(self.theme.display_outline_color), unicode(self.theme.display_outline_color),
unicode(self.theme.display_horizontalAlign), unicode(self.theme.display_horizontalAlign),
unicode(self.theme.display_verticalAlign), 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() theme = new_theme.extract_xml()
pretty_theme = new_theme.extract_formatted_xml() pretty_theme = new_theme.extract_formatted_xml()
if self.thememanager.saveTheme(theme_name, theme, pretty_theme, if self.thememanager.saveTheme(theme_name, theme, pretty_theme,
@ -446,6 +449,14 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
self.stateChanging(self.theme) self.stateChanging(self.theme)
self.previewTheme() 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): def onShadowColorPushButtonClicked(self):
self.theme.display_shadow_color = QtGui.QColorDialog.getColor( self.theme.display_shadow_color = QtGui.QColorDialog.getColor(
QtGui.QColor(self.theme.display_shadow_color), self).name() QtGui.QColor(self.theme.display_shadow_color), self).name()
@ -562,6 +573,11 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
self.ShadowCheckBox.setChecked(False) self.ShadowCheckBox.setChecked(False)
self.ShadowColorPushButton.setEnabled(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.HorizontalComboBox.setCurrentIndex(
self.theme.display_horizontalAlign) self.theme.display_horizontalAlign)
self.VerticalComboBox.setCurrentIndex(self.theme.display_verticalAlign) 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 * An osd which is a pickle of the service items
* All image, presentation and video files needed to run the service. * All image, presentation and video files needed to run the service.
""" """
log.debug(u'onSaveService')
if not quick or self.isNew: if not quick or self.isNew:
filename = QtGui.QFileDialog.getSaveFileName(self, filename = QtGui.QFileDialog.getSaveFileName(self,
u'Save Service', self.config.get_last_dir()) u'Save Service', self.config.get_last_dir())
@ -430,13 +431,12 @@ class ServiceManager(QtGui.QWidget):
try: try:
zip = zipfile.ZipFile(unicode(filename), 'w') zip = zipfile.ZipFile(unicode(filename), 'w')
for item in self.serviceItems: for item in self.serviceItems:
service.append( service.append({u'serviceitem':item[u'service_item'].get_service_repr()})
{u'serviceitem':item[u'service_item'].get_service_repr()}) if item[u'service_item'].uses_file():
if item[u'service_item'].service_item_type == ServiceItemType.Image or \
item[u'service_item'].service_item_type == ServiceItemType.Command:
for frame in item[u'service_item'].get_frames: for frame in item[u'service_item'].get_frames:
path_from = unicode(os.path.join( 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) zip.write(path_from)
file = open(servicefile, u'wb') file = open(servicefile, u'wb')
cPickle.dump(service, file) cPickle.dump(service, file)

View File

@ -389,7 +389,7 @@ class ThemeManager(QtGui.QWidget):
newtheme.add_display(unicode(shadow), unicode(theme.ShadowColor.name()), newtheme.add_display(unicode(shadow), unicode(theme.ShadowColor.name()),
unicode(outline), unicode(theme.OutlineColor.name()), unicode(outline), unicode(theme.OutlineColor.name()),
unicode(theme.HorizontalAlign), unicode(theme.VerticalAlign), unicode(theme.HorizontalAlign), unicode(theme.VerticalAlign),
unicode(theme.WrapStyle)) unicode(theme.WrapStyle), 0)
return newtheme.extract_xml() return newtheme.extract_xml()
def saveTheme(self, name, theme_xml, theme_pretty_xml, image_from, 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_shadow_color
theme.display_verticalAlign = int(theme.display_verticalAlign.strip()) theme.display_verticalAlign = int(theme.display_verticalAlign.strip())
theme.display_wrapStyle = theme.display_wrapStyle.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_color = theme.font_footer_color.strip()
theme.font_footer_height = int(theme.font_footer_height.strip()) theme.font_footer_height = int(theme.font_footer_height.strip())
theme.font_footer_indentation = \ theme.font_footer_indentation = \

View File

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

View File

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