More Print Work

This commit is contained in:
Tim Bentley 2011-02-19 17:33:24 +00:00
parent 31b217571c
commit b5e369ba4d
3 changed files with 90 additions and 58 deletions

View File

@ -29,7 +29,23 @@ from PyQt4 import QtCore, QtGui
from openlp.core.lib import build_icon, translate, SpellTextEdit
from openlp.core.lib.ui import UiStrings
class Ui_PrintServiceOrderDialog(object):
class ZoomSize():
"""
Type enumeration for Combo Box sizes
"""
Page = 0
Width = 1
OneHundred = 2
SeventyFive = 3
Fifty = 4
TwentyFive = 5
Sizes = [
translate('OpenLP.PrintServiceDialog', 'Fit Page'),
translate('OpenLP.PrintServiceDialog', 'Fit Width'),
u'100%', u'75%', u'50%', u'25%']
class Ui_PrintServiceDialog(object):
def setupUi(self, printServiceDialog):
printServiceDialog.setObjectName(u'printServiceDialog')
printServiceDialog.resize(664, 594)
@ -40,23 +56,24 @@ class Ui_PrintServiceOrderDialog(object):
self.toolbar = QtGui.QToolBar(printServiceDialog)
self.toolbar.setIconSize(QtCore.QSize(22, 22))
self.toolbar.setToolButtonStyle(QtCore.Qt.ToolButtonTextBesideIcon)
self.toolbar.addAction(
self.printButton = self.toolbar.addAction(
QtGui.QIcon(build_icon(u':/general/general_print.png')), 'Print')
self.optionsButton = QtGui.QToolButton(self.toolbar)
self.optionsButton.setText(u'Options')
self.optionsButton.setToolButtonStyle(QtCore.Qt.ToolButtonTextBesideIcon)
self.optionsButton.setToolButtonStyle(
QtCore.Qt.ToolButtonTextBesideIcon)
self.optionsButton.setIcon(QtGui.QIcon(
build_icon(u':/system/system_configure.png')))
self.optionsButton.setCheckable(True)
self.toolbar.addWidget(self.optionsButton)
self.toolbar.addAction(
self.closeButton = self.toolbar.addAction(
QtGui.QIcon(build_icon(u':/system/system_close.png')),
'Close')
self.toolbar.addSeparator()
self.toolbar.addAction(
self.plainCopy = self.toolbar.addAction(
QtGui.QIcon(build_icon(u':/system/system_edit_copy.png')),
'Copy')
self.toolbar.addAction(
self.htmlCopy = self.toolbar.addAction(
QtGui.QIcon(build_icon(u':/system/system_edit_copy.png')),
'Copy as HTML')
self.toolbar.addSeparator()
@ -83,22 +100,10 @@ class Ui_PrintServiceOrderDialog(object):
self.toolbar.addWidget(self.zoomOriginalButton)
self.zoomComboBox = QtGui.QComboBox(printServiceDialog)
self.zoomComboBox.setObjectName((u'zoomComboBox'))
self.zoomComboBox.addItem(u'Fit Page')
self.zoomComboBox.addItem(u'Fit Width')
self.zoomComboBox.addItem(u'100%')
self.zoomComboBox.addItem(u'75%')
self.zoomComboBox.addItem(u'50%')
self.zoomComboBox.addItem(u'25%')
self.toolbar.addWidget(self.zoomComboBox)
self.mainLayout.addWidget(self.toolbar)
self.scrollArea = QtGui.QScrollArea(printServiceDialog)
self.scrollArea.setWidgetResizable(True)
self.scrollArea.setObjectName(u'scrollArea')
self.scrollAreaWidgetContents = QtGui.QWidget()
self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, 0, 227, 473))
self.scrollAreaWidgetContents.setObjectName(u'scrollAreaWidgetContents')
self.scrollArea.setWidget(self.scrollAreaWidgetContents)
self.mainLayout.addWidget(self.scrollArea)
self.previewWidget = QtGui.QPrintPreviewWidget(printServiceDialog)
self.mainLayout.addWidget(self.previewWidget)
self.optionsWidget = QtGui.QWidget(printServiceDialog)
self.optionsWidget.hide()
self.optionsWidget.resize(400, 300)
@ -123,7 +128,7 @@ class Ui_PrintServiceOrderDialog(object):
self.groupLayout = QtGui.QVBoxLayout()
self.slideTextCheckBox = QtGui.QCheckBox()
self.groupLayout.addWidget(self.slideTextCheckBox)
self.notesCheckBox = QtGui.QCheckBox('Include service item notes')
self.notesCheckBox = QtGui.QCheckBox()
self.groupLayout.addWidget(self.notesCheckBox)
self.metaDataCheckBox = QtGui.QCheckBox()
self.groupLayout.addWidget(self.metaDataCheckBox)
@ -136,21 +141,22 @@ class Ui_PrintServiceOrderDialog(object):
QtCore.QObject.connect(self.optionsButton,
QtCore.SIGNAL(u'toggled(bool)'), self.toggleOptions)
self.retranslateUi(printServiceDialog)
QtCore.QMetaObject.connectSlotsByName(printServiceDialog)
def retranslateUi(self, printServiceDialog):
printServiceDialog.setWindowTitle(
translate('OpenLP.PrintServiceOrderForm', 'Print Service Order'))
# self.previewLabel.setText(
# translate('OpenLP.PrintServiceOrderForm', '<b>Preview:</b>'))
self.slideTextCheckBox.setText(translate(
'OpenLP.PrintServiceOrderForm', 'Include slide text if available'))
self.notesCheckBox.setText(translate(
'OpenLP.PrintServiceOrderForm', 'Include service item notes'))
self.metaDataCheckBox.setText(
translate('OpenLP.PrintServiceOrderForm',
translate('OpenLP.PrintServiceForm', 'Print Service Order'))
self.slideTextCheckBox.setText(translate('OpenLP.PrintServiceForm',
'Include slide text if available'))
self.notesCheckBox.setText(translate('OpenLP.PrintServiceForm',
'Include service item notes'))
self.metaDataCheckBox.setText(translate('OpenLP.PrintServiceForm',
'Include play length of media items'))
self.zoomComboBox.addItem(ZoomSize.Sizes[ZoomSize.Page])
self.zoomComboBox.addItem(ZoomSize.Sizes[ZoomSize.Width])
self.zoomComboBox.addItem(ZoomSize.Sizes[ZoomSize.OneHundred])
self.zoomComboBox.addItem(ZoomSize.Sizes[ZoomSize.SeventyFive])
self.zoomComboBox.addItem(ZoomSize.Sizes[ZoomSize.Fifty])
self.zoomComboBox.addItem(ZoomSize.Sizes[ZoomSize.TwentyFive])
# self.serviceTitleLabel.setText(translate(
# 'OpenLP.PrintServiceOrderForm', 'Title:'))
# self.serviceTitleLineEdit.setText(translate('OpenLP.ServiceManager',

View File

@ -29,9 +29,9 @@ from PyQt4 import QtCore, QtGui
from openlp.core.lib import translate
from openlp.core.lib.ui import UiStrings
from openlp.core.ui.printserviceorderdialog import Ui_PrintServiceOrderDialog
from openlp.core.ui.printservicedialog import Ui_PrintServiceDialog, ZoomSize
class PrintServiceOrderForm(QtGui.QDialog, Ui_PrintServiceOrderDialog):
class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog):
def __init__(self, parent, serviceManager):
"""
@ -55,14 +55,20 @@ class PrintServiceOrderForm(QtGui.QDialog, Ui_PrintServiceOrderDialog):
u'print notes', QtCore.QVariant(False)).toBool())
settings.endGroup()
# Signals
# QtCore.QObject.connect(self.printButton,
# QtCore.SIGNAL(u'clicked()'), 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.previewWidget,
# QtCore.SIGNAL(u'paintRequested(QPrinter *)'), self.paintRequested)
QtCore.QObject.connect(self.printButton,
QtCore.SIGNAL(u'triggered()'), self.printServiceOrder)
QtCore.QObject.connect(self.closeButton,
QtCore.SIGNAL(u'triggered()'), self.accept)
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.serviceTitleLineEdit,
# QtCore.SIGNAL(u'textChanged(const QString)'),
# self.updatePreviewText)
@ -72,7 +78,7 @@ class PrintServiceOrderForm(QtGui.QDialog, Ui_PrintServiceOrderDialog):
# QtCore.SIGNAL(u'stateChanged(int)'), self.updatePreviewText)
# QtCore.QObject.connect(self.metaDataCheckBox,
# QtCore.SIGNAL(u'stateChanged(int)'), self.updatePreviewText)
# QtCore.QObject.connect(self.customNoteEdit,
# QtCore.QObject.connect(self.footerTextEdit,
# QtCore.SIGNAL(u'textChanged()'), self.updatePreviewText)
# QtCore.QObject.connect(self.cancelButton,
# QtCore.SIGNAL(u'clicked()'), self.reject)
@ -80,7 +86,7 @@ class PrintServiceOrderForm(QtGui.QDialog, Ui_PrintServiceOrderDialog):
# QtCore.SIGNAL(u'clicked()'), self.copyText)
# QtCore.QObject.connect(self.copyHtmlButton,
# QtCore.SIGNAL(u'clicked()'), self.copyHtmlText)
# self.updatePreviewText()
self.updatePreviewText()
def toggleOptions(self, checked):
self.optionsWidget.setVisible(checked)
@ -97,8 +103,8 @@ class PrintServiceOrderForm(QtGui.QDialog, Ui_PrintServiceOrderDialog):
Creates the html text and updates the html of *self.document*.
"""
text = u''
if self.serviceTitleLineEdit.text():
text += u'<h2>%s</h2>' % unicode(self.serviceTitleLineEdit.text())
if self.titleLineEdit.text():
text += u'<h2>%s</h2>' % unicode(self.titleLineEdit.text())
for item in self.serviceManager.serviceItems:
item = item[u'service_item']
# Add the title of the service item.
@ -140,9 +146,9 @@ class PrintServiceOrderForm(QtGui.QDialog, Ui_PrintServiceOrderDialog):
text += u'<p><b>%s</b> %s</p>' % (translate(
'OpenLP.ServiceManager', u'Playing time:'),
unicode(datetime.timedelta(seconds=item.media_length)))
if self.customNoteEdit.toPlainText():
if self.footerTextEdit.toPlainText():
text += u'<h4>%s</h4>%s' % (translate('OpenLP.ServiceManager',
u'Custom Service Notes:'), self.customNoteEdit.toPlainText())
u'Custom Service Notes:'), self.footerTextEdit.toPlainText())
self.document.setHtml(text)
self.previewWidget.updatePreview()
@ -155,20 +161,39 @@ class PrintServiceOrderForm(QtGui.QDialog, Ui_PrintServiceOrderDialog):
"""
self.document.print_(printer)
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()
elif display == ZoomSize.SeventyFive:
self.previewWidget.fitToWidth()
elif display == ZoomSize.Fifty:
self.previewWidget.fitToWidth()
elif display == ZoomSize.TwentyFive:
self.previewWidget.fitToWidth()
settings = QtCore.QSettings()
settings.beginGroup(u'advanced')
settings.setValue(u'display size',QtCore.QVariant(display))
settings.endGroup()
def copyText(self):
"""
Copies the display text to the clipboard as plain text
"""
self.parent.clipboard.setText(self.document.toPlainText())
def copyHtmlText(self):
"""
Copies the display text to the clipboard as Html
"""
self.parent.clipboard.setText(self.document.toHtml())
def printServiceOrder(self):
"""
Called, when the *printButton* is clicked. Opens the *printDialog*.
@ -190,6 +215,12 @@ class PrintServiceOrderForm(QtGui.QDialog, Ui_PrintServiceOrderDialog):
"""
self.previewWidget.zoomOut()
def zoomOriginal(self):
"""
Called when *zoomOutButton* is clicked.
"""
self.previewWidget.fitInView()
def updateTextFormat(self, value):
"""
Called when html copy check box is selected.
@ -213,8 +244,3 @@ class PrintServiceOrderForm(QtGui.QDialog, Ui_PrintServiceOrderDialog):
settings.setValue(u'print notes',
QtCore.QVariant(self.notesCheckBox.isChecked()))
settings.endGroup()
def close(self):
# Close the dialog.
return QtGui.QDialog.accept(self)

View File

@ -37,7 +37,7 @@ from openlp.core.lib import OpenLPToolbar, ServiceItem, context_menu_action, \
ThemeLevel
from openlp.core.lib.ui import UiStrings, critical_error_message_box
from openlp.core.ui import ServiceNoteForm, ServiceItemEditForm, StartTimeForm
from openlp.core.ui.printserviceorderform import PrintServiceOrderForm
from openlp.core.ui.printserviceform import PrintServiceForm
from openlp.core.utils import AppLocation, delete_file, file_is_unicode, \
split_filename
@ -1208,5 +1208,5 @@ class ServiceManager(QtGui.QWidget):
"""
Print a Service Order Sheet.
"""
settingDialog = PrintServiceOrderForm(self.mainwindow, self)
settingDialog = PrintServiceForm(self.mainwindow, self)
settingDialog.exec_()