diff --git a/openlp/core/ui/printservicedialog.py b/openlp/core/ui/printservicedialog.py index 97f4b4060..9593e9ec4 100644 --- a/openlp/core/ui/printservicedialog.py +++ b/openlp/core/ui/printservicedialog.py @@ -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', + 'Add page break before each text item.')) self.notesCheckBox.setText(translate('OpenLP.PrintServiceForm', 'Include service item notes')) self.metaDataCheckBox.setText(translate('OpenLP.PrintServiceForm', diff --git a/openlp/core/ui/printserviceform.py b/openlp/core/ui/printserviceform.py index 4e0f018a4..407b8e2b4 100644 --- a/openlp/core/ui/printserviceform.py +++ b/openlp/core/ui/printserviceform.py @@ -24,12 +24,65 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### import datetime +import os from PyQt4 import QtCore, QtGui +from lxml import html from openlp.core.lib import translate from openlp.core.lib.ui import UiStrings from openlp.core.ui.printservicedialog import Ui_PrintServiceDialog, ZoomSize +from openlp.core.utils import AppLocation + +DEFAULT_CSS = """/* +Edit this file to customize the service order print. Note, that not all CSS +properties are supported. See: +http://doc.trolltech.com/4.7/richtext-html-subset.html#css-properties +*/ + +.serviceTitle { + font-weight:600; + font-size:x-large; + color:black; +} + +.itemTitle { + font-weight:600; + font-size:large; + color:black; +} + +.itemText { + color:black; +} + +.itemFooter { + font-size:8px; + color:black; +} + +.itemNotesTitle { + font-weight:bold; + font-size:12px; + color:black; +} + +.itemNotesText { + font-size:11px; + color:black; +} + +.customNotesTitle { + font-weight:bold; + font-size:11px; + color:black; +} + +.customNotesText { + font-size:11px; + color:black; +} +""" class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog): @@ -50,6 +103,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 +133,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 +153,105 @@ 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'
' + slide[u'html'] - verse = slide[u'verseTag'] - elif verse != slide[u'verseTag']: - text += u'<\p>
' + slide[u'html']
- verse = slide[u'verseTag']
+ if not verse_def or verse_def != slide[u'verseTag']:
+ p = html.Element(u'p')
+ p.set(u'class', u'itemText')
+ div.append(p)
else:
- text += u'
' + slide[u'html']
- text += u'
%s
%s
' % item.foot_text + p = html.fromstring(item.foot_text) + p.set(u'class', u'itemFooter') + div.append(p) # Add service items' notes. if self.notesCheckBox.isChecked(): if item.notes: - text += u'%s
%s' % (translate( - 'OpenLP.ServiceManager', 'Notes:'), + p = html.Element(u'p') + title = html.Element(u'span') + title.set(u'class', u'itemNotesTitle') + title.text = unicode( + translate('OpenLP.ServiceManager', 'Notes:')) + p.append(title) + text = html.fromstring(u' %s' % item.notes.replace(u'\n', u'%s %s
' % (translate( - 'OpenLP.ServiceManager', u'Playing time:'), - unicode(datetime.timedelta(seconds=tme))) - if self.footerTextEdit.toPlainText(): - text += u'%s
' % + translate('OpenLP.ServiceManager', 'Playing time:')) + p.append(html.fromstring(u'%s' % + unicode(datetime.timedelta(seconds=tme)))) + div.append(p) + html_data.body.append(div) + # Add the custom service notes: + if self.footerTextEdit.toPlainText(): + title = html.Element(u'span') + title.set(u'class', u'customNotesTitle') + title.text = unicode( + translate('OpenLP.ServiceManager', u'Custom Service Notes:')) + div.append(title) + text = html.Element(u'span') + text.set(u'class', u'customNotesText') + text.text = u' %s' % self.footerTextEdit.toPlainText() + div.append(text) + self.document.setHtml(html.tostring(html_data)) self.previewWidget.updatePreview() def paintRequested(self, printer): @@ -232,6 +340,13 @@ class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog): else: self.copyTextButton.setText(UiStrings.CopyToText) + def onSlideTextCheckBoxChanged(self, state): + """ + Disable or enable the ``pageBreakAfterText`` checkbox as it should only + be enabled, when the ``slideTextCheckBox`` is enabled. + """ + self.pageBreakAfterText.setDisabled(state == QtCore.Qt.Unchecked) + def saveOptions(self): """ Save the settings and close the dialog. @@ -241,6 +356,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',