forked from openlp/openlp
This commit is contained in:
parent
2806a553c9
commit
3bfe9ec77c
@ -132,6 +132,8 @@ class Ui_PrintServiceDialog(object):
|
||||
self.groupLayout = QtGui.QVBoxLayout()
|
||||
self.slideTextCheckBox = QtGui.QCheckBox()
|
||||
self.groupLayout.addWidget(self.slideTextCheckBox)
|
||||
self.pageBreakAfterText = QtGui.QCheckBox()
|
||||
self.groupLayout.addWidget(self.pageBreakAfterText)
|
||||
self.notesCheckBox = QtGui.QCheckBox()
|
||||
self.groupLayout.addWidget(self.notesCheckBox)
|
||||
self.metaDataCheckBox = QtGui.QCheckBox()
|
||||
@ -149,6 +151,8 @@ class Ui_PrintServiceDialog(object):
|
||||
printServiceDialog.setWindowTitle(UiStrings.PrintServiceOrder)
|
||||
self.slideTextCheckBox.setText(translate('OpenLP.PrintServiceForm',
|
||||
'Include slide text if available'))
|
||||
self.pageBreakAfterText.setText(translate('OpenLP.PrintServiceForm',
|
||||
'break'))
|
||||
self.notesCheckBox.setText(translate('OpenLP.PrintServiceForm',
|
||||
'Include service item notes'))
|
||||
self.metaDataCheckBox.setText(translate('OpenLP.PrintServiceForm',
|
||||
|
@ -26,6 +26,7 @@
|
||||
import datetime
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
from lxml import html
|
||||
|
||||
from openlp.core.lib import translate
|
||||
from openlp.core.lib.ui import UiStrings
|
||||
@ -50,6 +51,10 @@ class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog):
|
||||
settings.beginGroup(u'advanced')
|
||||
self.slideTextCheckBox.setChecked(settings.value(
|
||||
u'print slide text', QtCore.QVariant(False)).toBool())
|
||||
self.pageBreakAfterText.setChecked(settings.value(
|
||||
u'enable page break', QtCore.QVariant(False)).toBool())
|
||||
if not self.slideTextCheckBox.isChecked():
|
||||
self.pageBreakAfterText.setDisabled(True)
|
||||
self.metaDataCheckBox.setChecked(settings.value(
|
||||
u'print file meta data', QtCore.QVariant(False)).toBool())
|
||||
self.notesCheckBox.setChecked(settings.value(
|
||||
@ -76,6 +81,9 @@ class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog):
|
||||
QtCore.SIGNAL(u'triggered()'), self.copyText)
|
||||
QtCore.QObject.connect(self.htmlCopy,
|
||||
QtCore.SIGNAL(u'triggered()'), self.copyHtmlText)
|
||||
QtCore.QObject.connect(self.slideTextCheckBox,
|
||||
QtCore.SIGNAL(u'stateChanged(int)'),
|
||||
self.onSlideTextCheckBoxChanged)
|
||||
self.updatePreviewText()
|
||||
|
||||
def toggleOptions(self, checked):
|
||||
@ -93,57 +101,80 @@ class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog):
|
||||
"""
|
||||
Creates the html text and updates the html of *self.document*.
|
||||
"""
|
||||
text = u''
|
||||
if self.titleLineEdit.text():
|
||||
text += u'<h2>%s</h2>' % unicode(self.titleLineEdit.text())
|
||||
for item in self.serviceManager.serviceItems:
|
||||
html_data = html.fromstring(
|
||||
u'<title>%s</title>' % unicode(self.titleLineEdit.text()))
|
||||
html_data.append(html.Element(u'body'))
|
||||
html_data.body.append(html.fromstring(
|
||||
u'<h2>%s</h2>' % unicode(self.titleLineEdit.text())))
|
||||
for index, item in enumerate(self.serviceManager.serviceItems):
|
||||
item = item[u'service_item']
|
||||
div = html.Element(u'div')
|
||||
# Add the title of the service item.
|
||||
text += u'<h3><img src="%s" /> %s</h3>' % (item.icon,
|
||||
item.get_display_title())
|
||||
# Add slide text of the service item.
|
||||
item_title = html.Element(u'h3')
|
||||
icon = html.Element(u'img')
|
||||
icon.set(u'src', item.icon)
|
||||
item_title.append(icon)
|
||||
item_title.append(
|
||||
html.fromstring(u'<span> %s</span>' % item.get_display_title()))
|
||||
div.append(item_title)
|
||||
if self.slideTextCheckBox.isChecked():
|
||||
# Add the text of the service item.
|
||||
if item.is_text():
|
||||
# Add the text of the service item.
|
||||
verse = None
|
||||
verse_def = None
|
||||
for slide in item.get_frames():
|
||||
if not verse:
|
||||
text += u'<p>' + slide[u'html']
|
||||
verse = slide[u'verseTag']
|
||||
elif verse != slide[u'verseTag']:
|
||||
text += u'<\p><p>' + slide[u'html']
|
||||
verse = slide[u'verseTag']
|
||||
if not verse_def or verse_def != slide[u'verseTag']:
|
||||
p = html.Element(u'p')
|
||||
div.append(p)
|
||||
else:
|
||||
text += u'<br/>' + slide[u'html']
|
||||
text += u'</p>'
|
||||
p.append(html.Element(u'br'))
|
||||
p.append(html.fromstring(
|
||||
u'<span>%s</span>' % slide[u'html']))
|
||||
verse_def = slide[u'verseTag']
|
||||
# Break the page before the div element.
|
||||
if index != 0 and self.pageBreakAfterText.isChecked():
|
||||
div.set(u'style', u'page-break-before:always')
|
||||
# Add the image names of the service item.
|
||||
elif item.is_image():
|
||||
# Add the image names of the service item.
|
||||
text += u'<ol>'
|
||||
ol = html.Element(u'ol')
|
||||
for slide in range(len(item.get_frames())):
|
||||
text += u'<li><p>%s</p></li>' % \
|
||||
item.get_frame_title(slide)
|
||||
text += u'</ol>'
|
||||
li = html.Element(u'li')
|
||||
li.text = item.get_frame_title(slide)
|
||||
ol.append(li)
|
||||
div.append(ol)
|
||||
# add footer
|
||||
if item.foot_text:
|
||||
# add footer
|
||||
text += u'<p>%s</p>' % item.foot_text
|
||||
div.append(html.fromstring(item.foot_text))
|
||||
# Add service items' notes.
|
||||
if self.notesCheckBox.isChecked():
|
||||
if item.notes:
|
||||
text += u'<p><strong>%s</strong></p>%s' % (translate(
|
||||
'OpenLP.ServiceManager', 'Notes:'),
|
||||
item.notes.replace(u'\n', u'<br />'))
|
||||
p = html.Element(u'p')
|
||||
strong = html.Element(u'strong')
|
||||
strong.text = unicode(
|
||||
translate('OpenLP.ServiceManager', 'Notes:'))
|
||||
p.append(strong)
|
||||
p.append(html.fromstring(u'<span>%s</span>' %
|
||||
item.notes.replace(u'\n', u'<br />')))
|
||||
div.append(p)
|
||||
# Add play length of media files.
|
||||
if item.is_media() and self.metaDataCheckBox.isChecked():
|
||||
tme = item.media_length
|
||||
if item.end_time > 0:
|
||||
tme = item.end_time - item.start_time
|
||||
text += u'<p><strong>%s</strong> %s</p>' % (translate(
|
||||
'OpenLP.ServiceManager', u'Playing time:'),
|
||||
unicode(datetime.timedelta(seconds=tme)))
|
||||
if self.footerTextEdit.toPlainText():
|
||||
text += u'<h4>%s</h4>%s' % (translate('OpenLP.ServiceManager',
|
||||
u'Custom Service Notes:'), self.footerTextEdit.toPlainText())
|
||||
self.document.setHtml(text)
|
||||
p = html.fromstring(u'<p><strong>%s</strong> </p>' %
|
||||
translate('OpenLP.ServiceManager', 'Playing time:'))
|
||||
p.append(html.fromstring(u'<span>%s</span>' %
|
||||
unicode(datetime.timedelta(seconds=tme))))
|
||||
div.append(p)
|
||||
html_data.body.append(div)
|
||||
# Add the custom service notes:
|
||||
if self.footerTextEdit.toPlainText():
|
||||
html_data.append(html.fromstring(u'<h4>%</h4>' %
|
||||
translate('OpenLP.ServiceManager', u'Custom Service Notes:')))
|
||||
html_data.append(html.fromstring(
|
||||
u'<span>%s</span>' % self.footerTextEdit.toPlainText()))
|
||||
for div in html_data.body:
|
||||
print len(div), html.tostring(div), u'\n'
|
||||
self.document.setHtml(html.tostring(html_data))
|
||||
self.previewWidget.updatePreview()
|
||||
|
||||
def paintRequested(self, printer):
|
||||
@ -232,6 +263,12 @@ class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog):
|
||||
else:
|
||||
self.copyTextButton.setText(UiStrings.CopyToText)
|
||||
|
||||
def onSlideTextCheckBoxChanged(self, state):
|
||||
"""
|
||||
The ``slideTextCheckBox`` checkbox was either checked or unchecked.
|
||||
"""
|
||||
self.pageBreakAfterText.setDisabled(state == QtCore.Qt.Unchecked)
|
||||
|
||||
def saveOptions(self):
|
||||
"""
|
||||
Save the settings and close the dialog.
|
||||
@ -241,6 +278,8 @@ class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog):
|
||||
settings.beginGroup(u'advanced')
|
||||
settings.setValue(u'print slide text',
|
||||
QtCore.QVariant(self.slideTextCheckBox.isChecked()))
|
||||
settings.setValue(u'enable page break',
|
||||
QtCore.QVariant(self.pageBreakAfterText.isChecked()))
|
||||
settings.setValue(u'print file meta data',
|
||||
QtCore.QVariant(self.metaDataCheckBox.isChecked()))
|
||||
settings.setValue(u'print notes',
|
||||
|
Loading…
Reference in New Issue
Block a user