2011-02-04 18:00:59 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
2012-12-29 13:35:16 +00:00
|
|
|
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
|
2011-02-04 18:00:59 +00:00
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
# OpenLP - Open Source Lyrics Projection #
|
|
|
|
# --------------------------------------------------------------------------- #
|
2012-12-29 20:56:56 +00:00
|
|
|
# Copyright (c) 2008-2013 Raoul Snyman #
|
|
|
|
# Portions copyright (c) 2008-2013 Tim Bentley, Gerald Britton, Jonathan #
|
2012-06-22 14:14:53 +00:00
|
|
|
# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, #
|
2012-11-11 21:16:14 +00:00
|
|
|
# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. #
|
2012-10-21 13:16:22 +00:00
|
|
|
# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, #
|
|
|
|
# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, #
|
|
|
|
# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, #
|
2012-12-01 07:57:54 +00:00
|
|
|
# Frode Woldsund, Martin Zibricky, Patrick Zimmermann #
|
2011-02-04 18:00:59 +00:00
|
|
|
# --------------------------------------------------------------------------- #
|
|
|
|
# This program is free software; you can redistribute it and/or modify it #
|
|
|
|
# under the terms of the GNU General Public License as published by the Free #
|
|
|
|
# Software Foundation; version 2 of the License. #
|
|
|
|
# #
|
|
|
|
# This program is distributed in the hope that it will be useful, but WITHOUT #
|
|
|
|
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
|
|
|
|
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
|
|
|
|
# more details. #
|
|
|
|
# #
|
|
|
|
# You should have received a copy of the GNU General Public License along #
|
|
|
|
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
|
|
|
|
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
|
|
|
###############################################################################
|
2011-08-14 13:05:39 +00:00
|
|
|
import cgi
|
2011-02-04 18:00:59 +00:00
|
|
|
import datetime
|
2011-04-07 19:10:19 +00:00
|
|
|
import os
|
2011-02-04 18:00:59 +00:00
|
|
|
|
|
|
|
from PyQt4 import QtCore, QtGui
|
2011-04-06 19:14:02 +00:00
|
|
|
from lxml import html
|
2011-02-04 18:00:59 +00:00
|
|
|
|
2012-05-17 15:13:09 +00:00
|
|
|
from openlp.core.lib import translate, get_text_file_string, Receiver, Settings
|
2011-02-15 18:51:37 +00:00
|
|
|
from openlp.core.lib.ui import UiStrings
|
2011-02-19 17:33:24 +00:00
|
|
|
from openlp.core.ui.printservicedialog import Ui_PrintServiceDialog, ZoomSize
|
2011-04-07 19:10:19 +00:00
|
|
|
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 {
|
2011-05-30 05:03:46 +00:00
|
|
|
font-weight: 600;
|
|
|
|
font-size: x-large;
|
|
|
|
color: black;
|
2011-04-07 19:10:19 +00:00
|
|
|
}
|
|
|
|
|
2011-04-25 10:13:13 +00:00
|
|
|
.item {
|
2011-05-30 05:03:46 +00:00
|
|
|
color: black;
|
2011-04-25 10:13:13 +00:00
|
|
|
}
|
|
|
|
|
2011-04-07 19:10:19 +00:00
|
|
|
.itemTitle {
|
2011-05-30 05:03:46 +00:00
|
|
|
font-weight: 600;
|
|
|
|
font-size: large;
|
2011-04-07 19:10:19 +00:00
|
|
|
}
|
|
|
|
|
2011-05-29 06:26:14 +00:00
|
|
|
.itemText {
|
2011-05-30 05:03:46 +00:00
|
|
|
margin-top: 10px;
|
2011-05-29 06:26:14 +00:00
|
|
|
}
|
2011-04-07 19:10:19 +00:00
|
|
|
|
|
|
|
.itemFooter {
|
2011-05-30 05:03:46 +00:00
|
|
|
font-size: 8px;
|
2011-04-07 19:10:19 +00:00
|
|
|
}
|
|
|
|
|
2011-04-25 10:13:13 +00:00
|
|
|
.itemNotes {}
|
2011-04-24 19:50:28 +00:00
|
|
|
|
2011-04-07 19:10:19 +00:00
|
|
|
.itemNotesTitle {
|
2011-05-30 05:03:46 +00:00
|
|
|
font-weight: bold;
|
|
|
|
font-size: 12px;
|
2011-04-07 19:10:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.itemNotesText {
|
2011-05-30 05:03:46 +00:00
|
|
|
font-size: 11px;
|
2011-04-24 19:50:28 +00:00
|
|
|
}
|
|
|
|
|
2011-04-25 10:13:13 +00:00
|
|
|
.media {}
|
|
|
|
|
2011-04-24 19:50:28 +00:00
|
|
|
.mediaTitle {
|
2011-05-30 05:03:46 +00:00
|
|
|
font-weight: bold;
|
|
|
|
font-size: 11px;
|
2011-04-25 10:13:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.mediaText {}
|
|
|
|
|
|
|
|
.imageList {}
|
|
|
|
|
|
|
|
.customNotes {
|
2011-05-30 05:03:46 +00:00
|
|
|
margin-top: 10px;
|
2011-04-07 19:10:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.customNotesTitle {
|
2011-05-30 05:03:46 +00:00
|
|
|
font-weight: bold;
|
|
|
|
font-size: 11px;
|
2011-04-07 19:10:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.customNotesText {
|
2011-05-30 05:03:46 +00:00
|
|
|
font-size: 11px;
|
2011-04-07 19:10:19 +00:00
|
|
|
}
|
2011-04-24 19:50:28 +00:00
|
|
|
|
|
|
|
.newPage {
|
2011-05-30 05:03:46 +00:00
|
|
|
page-break-before: always;
|
2011-04-24 19:50:28 +00:00
|
|
|
}
|
2011-04-07 19:10:19 +00:00
|
|
|
"""
|
2011-02-04 18:00:59 +00:00
|
|
|
|
2011-02-19 17:33:24 +00:00
|
|
|
class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog):
|
2011-02-15 18:51:37 +00:00
|
|
|
|
2011-03-19 10:08:05 +00:00
|
|
|
def __init__(self, mainWindow, serviceManager):
|
2011-02-04 18:00:59 +00:00
|
|
|
"""
|
|
|
|
Constructor
|
|
|
|
"""
|
2011-03-19 10:08:05 +00:00
|
|
|
QtGui.QDialog.__init__(self, mainWindow)
|
|
|
|
self.mainWindow = mainWindow
|
2011-02-06 13:57:57 +00:00
|
|
|
self.serviceManager = serviceManager
|
2011-02-05 19:48:21 +00:00
|
|
|
self.printer = QtGui.QPrinter()
|
|
|
|
self.printDialog = QtGui.QPrintDialog(self.printer, self)
|
|
|
|
self.document = QtGui.QTextDocument()
|
2011-02-19 20:23:23 +00:00
|
|
|
self.zoom = 0
|
2011-02-06 13:57:57 +00:00
|
|
|
self.setupUi(self)
|
2011-02-06 14:00:39 +00:00
|
|
|
# Load the settings for the dialog.
|
2012-05-17 15:13:09 +00:00
|
|
|
settings = Settings()
|
2011-02-04 20:10:32 +00:00
|
|
|
settings.beginGroup(u'advanced')
|
2012-12-29 13:35:16 +00:00
|
|
|
self.slideTextCheckBox.setChecked(settings.value(u'print slide text', False))
|
|
|
|
self.pageBreakAfterText.setChecked(settings.value(u'add page break', False))
|
2011-04-06 19:14:02 +00:00
|
|
|
if not self.slideTextCheckBox.isChecked():
|
|
|
|
self.pageBreakAfterText.setDisabled(True)
|
2012-12-29 13:35:16 +00:00
|
|
|
self.metaDataCheckBox.setChecked(settings.value(u'print file meta data', False))
|
2012-05-17 15:13:09 +00:00
|
|
|
self.notesCheckBox.setChecked(settings.value(u'print notes', False))
|
|
|
|
self.zoomComboBox.setCurrentIndex(settings.value(u'display size', 0))
|
2011-02-04 20:10:32 +00:00
|
|
|
settings.endGroup()
|
2011-02-06 07:16:42 +00:00
|
|
|
# Signals
|
2012-12-29 13:35:16 +00:00
|
|
|
QtCore.QObject.connect(self.printButton, QtCore.SIGNAL(u'triggered()'), self.printServiceOrder)
|
|
|
|
QtCore.QObject.connect(self.zoomOutButton, QtCore.SIGNAL(u'clicked()'), self.zoomOut)
|
|
|
|
QtCore.QObject.connect(self.zoomInButton, QtCore.SIGNAL(u'clicked()'), self.zoomIn)
|
|
|
|
QtCore.QObject.connect(self.zoomOriginalButton, QtCore.SIGNAL(u'clicked()'), self.zoomOriginal)
|
|
|
|
QtCore.QObject.connect(self.previewWidget, QtCore.SIGNAL(u'paintRequested(QPrinter *)'), self.paintRequested)
|
|
|
|
QtCore.QObject.connect(self.zoomComboBox, QtCore.SIGNAL(u'currentIndexChanged(int)'), self.displaySizeChanged)
|
|
|
|
QtCore.QObject.connect(self.plainCopy, 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)
|
2011-02-19 17:33:24 +00:00
|
|
|
self.updatePreviewText()
|
2011-02-19 08:36:24 +00:00
|
|
|
|
|
|
|
def toggleOptions(self, checked):
|
|
|
|
self.optionsWidget.setVisible(checked)
|
|
|
|
if checked:
|
|
|
|
left = self.optionsButton.pos().x()
|
|
|
|
top = self.toolbar.height()
|
|
|
|
self.optionsWidget.move(left, top)
|
|
|
|
self.titleLineEdit.setFocus()
|
|
|
|
else:
|
|
|
|
self.saveOptions()
|
2011-02-19 20:23:23 +00:00
|
|
|
self.updatePreviewText()
|
2011-02-04 18:00:59 +00:00
|
|
|
|
2011-02-06 07:16:42 +00:00
|
|
|
def updatePreviewText(self):
|
2011-02-04 18:00:59 +00:00
|
|
|
"""
|
2011-02-06 13:57:57 +00:00
|
|
|
Creates the html text and updates the html of *self.document*.
|
2011-02-04 18:00:59 +00:00
|
|
|
"""
|
2011-04-24 19:50:28 +00:00
|
|
|
html_data = self._addElement(u'html')
|
|
|
|
self._addElement(u'head', parent=html_data)
|
2012-05-17 18:57:01 +00:00
|
|
|
self._addElement(u'title', self.titleLineEdit.text(), html_data.head)
|
2012-12-29 13:35:16 +00:00
|
|
|
css_path = os.path.join(AppLocation.get_data_path(), u'service_print.css')
|
2011-04-13 09:19:16 +00:00
|
|
|
custom_css = get_text_file_string(css_path)
|
2011-04-24 19:50:28 +00:00
|
|
|
if not custom_css:
|
|
|
|
custom_css = DEFAULT_CSS
|
|
|
|
self._addElement(u'style', custom_css, html_data.head,
|
|
|
|
attribute=(u'type', u'text/css'))
|
|
|
|
self._addElement(u'body', parent=html_data)
|
2012-05-17 18:57:01 +00:00
|
|
|
self._addElement(u'h1', cgi.escape(self.titleLineEdit.text()),
|
2011-04-24 19:50:28 +00:00
|
|
|
html_data.body, classId=u'serviceTitle')
|
2011-04-06 19:14:02 +00:00
|
|
|
for index, item in enumerate(self.serviceManager.serviceItems):
|
2011-04-24 19:50:28 +00:00
|
|
|
self._addPreviewItem(html_data.body, item[u'service_item'], index)
|
2011-04-06 19:14:02 +00:00
|
|
|
# Add the custom service notes:
|
2011-04-13 09:19:16 +00:00
|
|
|
if self.footerTextEdit.toPlainText():
|
2012-12-29 13:35:16 +00:00
|
|
|
div = self._addElement(u'div', parent=html_data.body, classId=u'customNotes')
|
|
|
|
self._addElement(u'span', translate('OpenLP.ServiceManager', 'Custom Service Notes: '), div,
|
|
|
|
classId=u'customNotesTitle')
|
|
|
|
self._addElement(u'span', cgi.escape(self.footerTextEdit.toPlainText()), div, classId=u'customNotesText')
|
2011-04-06 19:14:02 +00:00
|
|
|
self.document.setHtml(html.tostring(html_data))
|
2011-02-06 07:16:42 +00:00
|
|
|
self.previewWidget.updatePreview()
|
|
|
|
|
2011-04-24 19:50:28 +00:00
|
|
|
def _addPreviewItem(self, body, item, index):
|
|
|
|
div = self._addElement(u'div', classId=u'item', parent=body)
|
|
|
|
# Add the title of the service item.
|
|
|
|
item_title = self._addElement(u'h2', parent=div, classId=u'itemTitle')
|
2012-12-29 13:35:16 +00:00
|
|
|
self._addElement(u'img', parent=item_title, attribute=(u'src', item.icon))
|
|
|
|
self._addElement(u'span', u' ' + cgi.escape(item.get_display_title()), item_title)
|
2011-04-24 19:50:28 +00:00
|
|
|
if self.slideTextCheckBox.isChecked():
|
|
|
|
# Add the text of the service item.
|
|
|
|
if item.is_text():
|
|
|
|
verse_def = None
|
|
|
|
for slide in item.get_frames():
|
|
|
|
if not verse_def or verse_def != slide[u'verseTag']:
|
2012-12-29 13:35:16 +00:00
|
|
|
text_div = self._addElement(u'div', parent=div, classId=u'itemText')
|
2011-04-24 19:50:28 +00:00
|
|
|
else:
|
2011-05-29 06:26:14 +00:00
|
|
|
self._addElement(u'br', parent=text_div)
|
|
|
|
self._addElement(u'span', slide[u'html'], text_div)
|
2011-04-24 19:50:28 +00:00
|
|
|
verse_def = slide[u'verseTag']
|
|
|
|
# Break the page before the div element.
|
|
|
|
if index != 0 and self.pageBreakAfterText.isChecked():
|
|
|
|
div.set(u'class', u'item newPage')
|
|
|
|
# Add the image names of the service item.
|
|
|
|
elif item.is_image():
|
|
|
|
ol = self._addElement(u'ol', parent=div, classId=u'imageList')
|
|
|
|
for slide in range(len(item.get_frames())):
|
|
|
|
self._addElement(u'li', item.get_frame_title(slide), ol)
|
|
|
|
# add footer
|
|
|
|
foot_text = item.foot_text
|
|
|
|
foot_text = foot_text.partition(u'<br>')[2]
|
|
|
|
if foot_text:
|
2011-08-14 13:05:39 +00:00
|
|
|
foot_text = cgi.escape(foot_text.replace(u'<br>', u'\n'))
|
2012-12-29 13:35:16 +00:00
|
|
|
self._addElement(u'div', foot_text.replace(u'\n', u'<br>'), parent=div, classId=u'itemFooter')
|
2011-04-24 19:50:28 +00:00
|
|
|
# Add service items' notes.
|
|
|
|
if self.notesCheckBox.isChecked():
|
|
|
|
if item.notes:
|
|
|
|
p = self._addElement(u'div', classId=u'itemNotes', parent=div)
|
2012-12-29 13:35:16 +00:00
|
|
|
self._addElement(u'span', translate('OpenLP.ServiceManager', 'Notes: '), p,
|
2011-04-24 19:50:28 +00:00
|
|
|
classId=u'itemNotesTitle')
|
2012-12-29 13:35:16 +00:00
|
|
|
self._addElement(u'span', cgi.escape(item.notes).replace(u'\n', u'<br>'), p, classId=u'itemNotesText')
|
2011-04-24 19:50:28 +00:00
|
|
|
# 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
|
|
|
|
title = self._addElement(u'div', classId=u'media', parent=div)
|
2012-12-29 13:35:16 +00:00
|
|
|
self._addElement(u'span', translate('OpenLP.ServiceManager', 'Playing time: '), title,
|
|
|
|
classId=u'mediaTitle')
|
2011-04-24 19:50:28 +00:00
|
|
|
self._addElement(u'span', unicode(datetime.timedelta(seconds=tme)),
|
2011-04-25 10:13:13 +00:00
|
|
|
title, classId=u'mediaText')
|
2011-04-24 19:50:28 +00:00
|
|
|
|
|
|
|
def _addElement(self, tag, text=None, parent=None, classId=None,
|
2011-04-25 10:13:13 +00:00
|
|
|
attribute=None):
|
2011-04-13 09:19:16 +00:00
|
|
|
"""
|
|
|
|
Creates a html element. If ``text`` is given, the element's text will
|
|
|
|
set and if a ``parent`` is given, the element is appended.
|
2011-04-13 09:42:18 +00:00
|
|
|
|
|
|
|
``tag``
|
|
|
|
The html tag, e. g. ``u'span'``. Defaults to ``None``.
|
|
|
|
|
|
|
|
``text``
|
|
|
|
The text for the tag. Defaults to ``None``.
|
|
|
|
|
|
|
|
``parent``
|
|
|
|
The parent element. Defaults to ``None``.
|
|
|
|
|
2011-04-24 19:50:28 +00:00
|
|
|
``classId``
|
|
|
|
Value for the class attribute
|
2011-04-13 09:42:18 +00:00
|
|
|
|
2011-04-24 19:50:28 +00:00
|
|
|
``attribute``
|
|
|
|
Tuple name/value pair to add as an optional attribute
|
2011-04-13 09:19:16 +00:00
|
|
|
"""
|
|
|
|
if text is not None:
|
2011-04-24 19:50:28 +00:00
|
|
|
element = html.fragment_fromstring(unicode(text), create_parent=tag)
|
|
|
|
else:
|
|
|
|
element = html.Element(tag)
|
2011-04-13 09:19:16 +00:00
|
|
|
if parent is not None:
|
|
|
|
parent.append(element)
|
2011-04-24 19:50:28 +00:00
|
|
|
if classId is not None:
|
|
|
|
element.set(u'class', classId)
|
2011-04-13 09:42:18 +00:00
|
|
|
if attribute is not None:
|
2011-04-24 19:50:28 +00:00
|
|
|
element.set(attribute[0], attribute[1])
|
2011-04-13 09:19:16 +00:00
|
|
|
return element
|
|
|
|
|
2011-02-06 07:16:42 +00:00
|
|
|
def paintRequested(self, printer):
|
|
|
|
"""
|
2011-02-06 13:57:57 +00:00
|
|
|
Paint the preview of the *self.document*.
|
2011-02-07 17:27:38 +00:00
|
|
|
|
|
|
|
``printer``
|
|
|
|
A *QPrinter* object.
|
2011-02-06 07:16:42 +00:00
|
|
|
"""
|
2011-02-06 14:09:43 +00:00
|
|
|
self.document.print_(printer)
|
2011-02-06 07:16:42 +00:00
|
|
|
|
2011-02-19 17:33:24 +00:00
|
|
|
def displaySizeChanged(self, display):
|
|
|
|
"""
|
|
|
|
The Zoom Combo box has changed so set up the size.
|
|
|
|
"""
|
|
|
|
if display == ZoomSize.Page:
|
|
|
|
self.previewWidget.fitInView()
|
|
|
|
elif display == ZoomSize.Width:
|
|
|
|
self.previewWidget.fitToWidth()
|
|
|
|
elif display == ZoomSize.OneHundred:
|
|
|
|
self.previewWidget.fitToWidth()
|
2011-02-19 20:23:23 +00:00
|
|
|
self.previewWidget.zoomIn(1)
|
2011-02-19 17:33:24 +00:00
|
|
|
elif display == ZoomSize.SeventyFive:
|
|
|
|
self.previewWidget.fitToWidth()
|
2011-02-19 20:23:23 +00:00
|
|
|
self.previewWidget.zoomIn(0.75)
|
2011-02-19 17:33:24 +00:00
|
|
|
elif display == ZoomSize.Fifty:
|
|
|
|
self.previewWidget.fitToWidth()
|
2011-02-19 20:23:23 +00:00
|
|
|
self.previewWidget.zoomIn(0.5)
|
2011-02-19 17:33:24 +00:00
|
|
|
elif display == ZoomSize.TwentyFive:
|
|
|
|
self.previewWidget.fitToWidth()
|
2011-02-19 20:23:23 +00:00
|
|
|
self.previewWidget.zoomIn(0.25)
|
2012-05-17 15:13:09 +00:00
|
|
|
settings = Settings()
|
2011-02-19 17:33:24 +00:00
|
|
|
settings.beginGroup(u'advanced')
|
2012-05-17 15:13:09 +00:00
|
|
|
settings.setValue(u'display size', display)
|
2011-02-19 17:33:24 +00:00
|
|
|
settings.endGroup()
|
|
|
|
|
2011-02-15 18:51:37 +00:00
|
|
|
def copyText(self):
|
2011-02-18 17:38:39 +00:00
|
|
|
"""
|
|
|
|
Copies the display text to the clipboard as plain text
|
|
|
|
"""
|
2011-08-22 17:32:18 +00:00
|
|
|
self.update_song_usage()
|
2012-06-30 16:11:49 +00:00
|
|
|
cursor = QtGui.QTextCursor(self.document)
|
2012-06-30 18:51:53 +00:00
|
|
|
cursor.select(QtGui.QTextCursor.Document)
|
2012-06-30 17:25:49 +00:00
|
|
|
clipboard_text = cursor.selectedText()
|
2012-06-30 16:11:49 +00:00
|
|
|
# We now have the unprocessed unicode service text in the cursor
|
2012-06-30 16:15:42 +00:00
|
|
|
# So we replace u2028 with \n and u2029 with \n\n and a few others
|
2012-06-30 16:11:49 +00:00
|
|
|
clipboard_text = clipboard_text.replace(u'\u2028', u'\n')
|
|
|
|
clipboard_text = clipboard_text.replace(u'\u2029', u'\n\n')
|
|
|
|
clipboard_text = clipboard_text.replace(u'\u2018', u'\'')
|
|
|
|
clipboard_text = clipboard_text.replace(u'\u2019', u'\'')
|
|
|
|
clipboard_text = clipboard_text.replace(u'\u201c', u'"')
|
|
|
|
clipboard_text = clipboard_text.replace(u'\u201d', u'"')
|
|
|
|
clipboard_text = clipboard_text.replace(u'\u2026', u'...')
|
|
|
|
clipboard_text = clipboard_text.replace(u'\u2013', u'-')
|
|
|
|
clipboard_text = clipboard_text.replace(u'\u2014', u'-')
|
|
|
|
# remove the icon from the text
|
|
|
|
clipboard_text = clipboard_text.replace(u'\ufffc\xa0', u'')
|
|
|
|
# and put it all on the clipboard
|
2012-06-30 17:16:44 +00:00
|
|
|
self.mainWindow.clipboard.setText(clipboard_text)
|
2011-02-18 17:38:39 +00:00
|
|
|
|
|
|
|
def copyHtmlText(self):
|
|
|
|
"""
|
|
|
|
Copies the display text to the clipboard as Html
|
|
|
|
"""
|
2011-08-22 17:32:18 +00:00
|
|
|
self.update_song_usage()
|
2011-03-28 20:18:55 +00:00
|
|
|
self.mainWindow.clipboard.setText(self.document.toHtml())
|
2011-02-18 17:38:39 +00:00
|
|
|
|
2011-02-06 07:16:42 +00:00
|
|
|
def printServiceOrder(self):
|
2011-02-06 13:57:57 +00:00
|
|
|
"""
|
|
|
|
Called, when the *printButton* is clicked. Opens the *printDialog*.
|
|
|
|
"""
|
2011-02-06 07:16:42 +00:00
|
|
|
if not self.printDialog.exec_():
|
|
|
|
return
|
2011-08-26 10:21:47 +00:00
|
|
|
self.update_song_usage()
|
2011-02-06 13:57:57 +00:00
|
|
|
# Print the document.
|
2011-02-06 07:16:42 +00:00
|
|
|
self.document.print_(self.printer)
|
2011-02-06 13:57:57 +00:00
|
|
|
|
|
|
|
def zoomIn(self):
|
|
|
|
"""
|
|
|
|
Called when *zoomInButton* is clicked.
|
|
|
|
"""
|
|
|
|
self.previewWidget.zoomIn()
|
2011-02-19 20:23:23 +00:00
|
|
|
self.zoom -= 0.1
|
2011-02-06 14:09:43 +00:00
|
|
|
|
2011-02-06 13:57:57 +00:00
|
|
|
def zoomOut(self):
|
|
|
|
"""
|
|
|
|
Called when *zoomOutButton* is clicked.
|
|
|
|
"""
|
|
|
|
self.previewWidget.zoomOut()
|
2011-02-19 20:23:23 +00:00
|
|
|
self.zoom += 0.1
|
2011-02-06 13:57:57 +00:00
|
|
|
|
2011-02-19 17:33:24 +00:00
|
|
|
def zoomOriginal(self):
|
|
|
|
"""
|
|
|
|
Called when *zoomOutButton* is clicked.
|
|
|
|
"""
|
2011-02-19 20:23:23 +00:00
|
|
|
self.previewWidget.zoomIn(1 + self.zoom)
|
|
|
|
self.zoom = 0
|
2011-02-19 17:33:24 +00:00
|
|
|
|
2011-02-15 18:51:37 +00:00
|
|
|
def updateTextFormat(self, value):
|
|
|
|
"""
|
|
|
|
Called when html copy check box is selected.
|
|
|
|
"""
|
|
|
|
if value == QtCore.Qt.Checked:
|
2011-04-15 21:43:59 +00:00
|
|
|
self.copyTextButton.setText(UiStrings().CopyToHtml)
|
2011-02-15 18:51:37 +00:00
|
|
|
else:
|
2011-04-15 21:43:59 +00:00
|
|
|
self.copyTextButton.setText(UiStrings().CopyToText)
|
2011-02-15 18:51:37 +00:00
|
|
|
|
2011-04-06 19:14:02 +00:00
|
|
|
def onSlideTextCheckBoxChanged(self, state):
|
|
|
|
"""
|
2011-04-07 08:45:49 +00:00
|
|
|
Disable or enable the ``pageBreakAfterText`` checkbox as it should only
|
|
|
|
be enabled, when the ``slideTextCheckBox`` is enabled.
|
2011-04-06 19:14:02 +00:00
|
|
|
"""
|
|
|
|
self.pageBreakAfterText.setDisabled(state == QtCore.Qt.Unchecked)
|
|
|
|
|
2011-02-19 08:36:24 +00:00
|
|
|
def saveOptions(self):
|
2011-02-06 13:57:57 +00:00
|
|
|
"""
|
|
|
|
Save the settings and close the dialog.
|
|
|
|
"""
|
2011-02-04 20:10:32 +00:00
|
|
|
# Save the settings for this dialog.
|
2012-05-17 15:13:09 +00:00
|
|
|
settings = Settings()
|
2011-02-04 20:10:32 +00:00
|
|
|
settings.beginGroup(u'advanced')
|
2012-12-29 13:35:16 +00:00
|
|
|
settings.setValue(u'print slide text', self.slideTextCheckBox.isChecked())
|
|
|
|
settings.setValue(u'add page break', self.pageBreakAfterText.isChecked())
|
|
|
|
settings.setValue(u'print file meta data', self.metaDataCheckBox.isChecked())
|
2012-05-17 15:13:09 +00:00
|
|
|
settings.setValue(u'print notes', self.notesCheckBox.isChecked())
|
2011-04-24 19:54:48 +00:00
|
|
|
settings.endGroup()
|
2011-08-22 17:32:18 +00:00
|
|
|
|
|
|
|
def update_song_usage(self):
|
2011-12-03 18:01:36 +00:00
|
|
|
# Only continue when we include the song's text.
|
|
|
|
if not self.slideTextCheckBox.isChecked():
|
|
|
|
return
|
2012-03-12 22:12:16 +00:00
|
|
|
for item in self.serviceManager.serviceItems:
|
2011-08-22 17:32:18 +00:00
|
|
|
# Trigger Audit requests
|
2012-12-29 13:35:16 +00:00
|
|
|
Receiver.send_message(u'print_service_started', [item[u'service_item']])
|