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 import build_icon, translate, SpellTextEdit
from openlp.core.lib.ui import UiStrings 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): def setupUi(self, printServiceDialog):
printServiceDialog.setObjectName(u'printServiceDialog') printServiceDialog.setObjectName(u'printServiceDialog')
printServiceDialog.resize(664, 594) printServiceDialog.resize(664, 594)
@ -40,23 +56,24 @@ class Ui_PrintServiceOrderDialog(object):
self.toolbar = QtGui.QToolBar(printServiceDialog) self.toolbar = QtGui.QToolBar(printServiceDialog)
self.toolbar.setIconSize(QtCore.QSize(22, 22)) self.toolbar.setIconSize(QtCore.QSize(22, 22))
self.toolbar.setToolButtonStyle(QtCore.Qt.ToolButtonTextBesideIcon) self.toolbar.setToolButtonStyle(QtCore.Qt.ToolButtonTextBesideIcon)
self.toolbar.addAction( self.printButton = self.toolbar.addAction(
QtGui.QIcon(build_icon(u':/general/general_print.png')), 'Print') QtGui.QIcon(build_icon(u':/general/general_print.png')), 'Print')
self.optionsButton = QtGui.QToolButton(self.toolbar) self.optionsButton = QtGui.QToolButton(self.toolbar)
self.optionsButton.setText(u'Options') self.optionsButton.setText(u'Options')
self.optionsButton.setToolButtonStyle(QtCore.Qt.ToolButtonTextBesideIcon) self.optionsButton.setToolButtonStyle(
QtCore.Qt.ToolButtonTextBesideIcon)
self.optionsButton.setIcon(QtGui.QIcon( self.optionsButton.setIcon(QtGui.QIcon(
build_icon(u':/system/system_configure.png'))) build_icon(u':/system/system_configure.png')))
self.optionsButton.setCheckable(True) self.optionsButton.setCheckable(True)
self.toolbar.addWidget(self.optionsButton) self.toolbar.addWidget(self.optionsButton)
self.toolbar.addAction( self.closeButton = self.toolbar.addAction(
QtGui.QIcon(build_icon(u':/system/system_close.png')), QtGui.QIcon(build_icon(u':/system/system_close.png')),
'Close') 'Close')
self.toolbar.addSeparator() self.toolbar.addSeparator()
self.toolbar.addAction( self.plainCopy = self.toolbar.addAction(
QtGui.QIcon(build_icon(u':/system/system_edit_copy.png')), QtGui.QIcon(build_icon(u':/system/system_edit_copy.png')),
'Copy') 'Copy')
self.toolbar.addAction( self.htmlCopy = self.toolbar.addAction(
QtGui.QIcon(build_icon(u':/system/system_edit_copy.png')), QtGui.QIcon(build_icon(u':/system/system_edit_copy.png')),
'Copy as HTML') 'Copy as HTML')
self.toolbar.addSeparator() self.toolbar.addSeparator()
@ -83,22 +100,10 @@ class Ui_PrintServiceOrderDialog(object):
self.toolbar.addWidget(self.zoomOriginalButton) self.toolbar.addWidget(self.zoomOriginalButton)
self.zoomComboBox = QtGui.QComboBox(printServiceDialog) self.zoomComboBox = QtGui.QComboBox(printServiceDialog)
self.zoomComboBox.setObjectName((u'zoomComboBox')) 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.toolbar.addWidget(self.zoomComboBox)
self.mainLayout.addWidget(self.toolbar) self.mainLayout.addWidget(self.toolbar)
self.scrollArea = QtGui.QScrollArea(printServiceDialog) self.previewWidget = QtGui.QPrintPreviewWidget(printServiceDialog)
self.scrollArea.setWidgetResizable(True) self.mainLayout.addWidget(self.previewWidget)
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.optionsWidget = QtGui.QWidget(printServiceDialog) self.optionsWidget = QtGui.QWidget(printServiceDialog)
self.optionsWidget.hide() self.optionsWidget.hide()
self.optionsWidget.resize(400, 300) self.optionsWidget.resize(400, 300)
@ -123,7 +128,7 @@ class Ui_PrintServiceOrderDialog(object):
self.groupLayout = QtGui.QVBoxLayout() self.groupLayout = QtGui.QVBoxLayout()
self.slideTextCheckBox = QtGui.QCheckBox() self.slideTextCheckBox = QtGui.QCheckBox()
self.groupLayout.addWidget(self.slideTextCheckBox) self.groupLayout.addWidget(self.slideTextCheckBox)
self.notesCheckBox = QtGui.QCheckBox('Include service item notes') self.notesCheckBox = QtGui.QCheckBox()
self.groupLayout.addWidget(self.notesCheckBox) self.groupLayout.addWidget(self.notesCheckBox)
self.metaDataCheckBox = QtGui.QCheckBox() self.metaDataCheckBox = QtGui.QCheckBox()
self.groupLayout.addWidget(self.metaDataCheckBox) self.groupLayout.addWidget(self.metaDataCheckBox)
@ -136,21 +141,22 @@ class Ui_PrintServiceOrderDialog(object):
QtCore.QObject.connect(self.optionsButton, QtCore.QObject.connect(self.optionsButton,
QtCore.SIGNAL(u'toggled(bool)'), self.toggleOptions) QtCore.SIGNAL(u'toggled(bool)'), self.toggleOptions)
self.retranslateUi(printServiceDialog)
QtCore.QMetaObject.connectSlotsByName(printServiceDialog)
def retranslateUi(self, printServiceDialog): def retranslateUi(self, printServiceDialog):
printServiceDialog.setWindowTitle( printServiceDialog.setWindowTitle(
translate('OpenLP.PrintServiceOrderForm', 'Print Service Order')) translate('OpenLP.PrintServiceForm', 'Print Service Order'))
# self.previewLabel.setText( self.slideTextCheckBox.setText(translate('OpenLP.PrintServiceForm',
# translate('OpenLP.PrintServiceOrderForm', '<b>Preview:</b>')) 'Include slide text if available'))
self.slideTextCheckBox.setText(translate( self.notesCheckBox.setText(translate('OpenLP.PrintServiceForm',
'OpenLP.PrintServiceOrderForm', 'Include slide text if available')) 'Include service item notes'))
self.notesCheckBox.setText(translate( self.metaDataCheckBox.setText(translate('OpenLP.PrintServiceForm',
'OpenLP.PrintServiceOrderForm', 'Include service item notes'))
self.metaDataCheckBox.setText(
translate('OpenLP.PrintServiceOrderForm',
'Include play length of media items')) '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( # self.serviceTitleLabel.setText(translate(
# 'OpenLP.PrintServiceOrderForm', 'Title:')) # 'OpenLP.PrintServiceOrderForm', 'Title:'))
# self.serviceTitleLineEdit.setText(translate('OpenLP.ServiceManager', # 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 import translate
from openlp.core.lib.ui import UiStrings 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): def __init__(self, parent, serviceManager):
""" """
@ -55,14 +55,20 @@ class PrintServiceOrderForm(QtGui.QDialog, Ui_PrintServiceOrderDialog):
u'print notes', QtCore.QVariant(False)).toBool()) u'print notes', QtCore.QVariant(False)).toBool())
settings.endGroup() settings.endGroup()
# Signals # Signals
# QtCore.QObject.connect(self.printButton, QtCore.QObject.connect(self.printButton,
# QtCore.SIGNAL(u'clicked()'), self.printServiceOrder) QtCore.SIGNAL(u'triggered()'), self.printServiceOrder)
# QtCore.QObject.connect(self.zoomOutButton, QtCore.QObject.connect(self.closeButton,
# QtCore.SIGNAL(u'clicked()'), self.zoomOut) QtCore.SIGNAL(u'triggered()'), self.accept)
# QtCore.QObject.connect(self.zoomInButton, QtCore.QObject.connect(self.zoomOutButton,
# QtCore.SIGNAL(u'clicked()'), self.zoomIn) QtCore.SIGNAL(u'clicked()'), self.zoomOut)
# QtCore.QObject.connect(self.previewWidget, QtCore.QObject.connect(self.zoomInButton,
# QtCore.SIGNAL(u'paintRequested(QPrinter *)'), self.paintRequested) 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.QObject.connect(self.serviceTitleLineEdit,
# QtCore.SIGNAL(u'textChanged(const QString)'), # QtCore.SIGNAL(u'textChanged(const QString)'),
# self.updatePreviewText) # self.updatePreviewText)
@ -72,7 +78,7 @@ class PrintServiceOrderForm(QtGui.QDialog, Ui_PrintServiceOrderDialog):
# QtCore.SIGNAL(u'stateChanged(int)'), self.updatePreviewText) # QtCore.SIGNAL(u'stateChanged(int)'), self.updatePreviewText)
# QtCore.QObject.connect(self.metaDataCheckBox, # QtCore.QObject.connect(self.metaDataCheckBox,
# QtCore.SIGNAL(u'stateChanged(int)'), self.updatePreviewText) # QtCore.SIGNAL(u'stateChanged(int)'), self.updatePreviewText)
# QtCore.QObject.connect(self.customNoteEdit, # QtCore.QObject.connect(self.footerTextEdit,
# QtCore.SIGNAL(u'textChanged()'), self.updatePreviewText) # QtCore.SIGNAL(u'textChanged()'), self.updatePreviewText)
# QtCore.QObject.connect(self.cancelButton, # QtCore.QObject.connect(self.cancelButton,
# QtCore.SIGNAL(u'clicked()'), self.reject) # QtCore.SIGNAL(u'clicked()'), self.reject)
@ -80,7 +86,7 @@ class PrintServiceOrderForm(QtGui.QDialog, Ui_PrintServiceOrderDialog):
# QtCore.SIGNAL(u'clicked()'), self.copyText) # QtCore.SIGNAL(u'clicked()'), self.copyText)
# QtCore.QObject.connect(self.copyHtmlButton, # QtCore.QObject.connect(self.copyHtmlButton,
# QtCore.SIGNAL(u'clicked()'), self.copyHtmlText) # QtCore.SIGNAL(u'clicked()'), self.copyHtmlText)
# self.updatePreviewText() self.updatePreviewText()
def toggleOptions(self, checked): def toggleOptions(self, checked):
self.optionsWidget.setVisible(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*. Creates the html text and updates the html of *self.document*.
""" """
text = u'' text = u''
if self.serviceTitleLineEdit.text(): if self.titleLineEdit.text():
text += u'<h2>%s</h2>' % unicode(self.serviceTitleLineEdit.text()) text += u'<h2>%s</h2>' % unicode(self.titleLineEdit.text())
for item in self.serviceManager.serviceItems: for item in self.serviceManager.serviceItems:
item = item[u'service_item'] item = item[u'service_item']
# Add the title of the 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( text += u'<p><b>%s</b> %s</p>' % (translate(
'OpenLP.ServiceManager', u'Playing time:'), 'OpenLP.ServiceManager', u'Playing time:'),
unicode(datetime.timedelta(seconds=item.media_length))) unicode(datetime.timedelta(seconds=item.media_length)))
if self.customNoteEdit.toPlainText(): if self.footerTextEdit.toPlainText():
text += u'<h4>%s</h4>%s' % (translate('OpenLP.ServiceManager', 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.document.setHtml(text)
self.previewWidget.updatePreview() self.previewWidget.updatePreview()
@ -155,20 +161,39 @@ class PrintServiceOrderForm(QtGui.QDialog, Ui_PrintServiceOrderDialog):
""" """
self.document.print_(printer) 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): def copyText(self):
""" """
Copies the display text to the clipboard as plain text Copies the display text to the clipboard as plain text
""" """
self.parent.clipboard.setText(self.document.toPlainText()) self.parent.clipboard.setText(self.document.toPlainText())
def copyHtmlText(self): def copyHtmlText(self):
""" """
Copies the display text to the clipboard as Html Copies the display text to the clipboard as Html
""" """
self.parent.clipboard.setText(self.document.toHtml()) self.parent.clipboard.setText(self.document.toHtml())
def printServiceOrder(self): def printServiceOrder(self):
""" """
Called, when the *printButton* is clicked. Opens the *printDialog*. Called, when the *printButton* is clicked. Opens the *printDialog*.
@ -190,6 +215,12 @@ class PrintServiceOrderForm(QtGui.QDialog, Ui_PrintServiceOrderDialog):
""" """
self.previewWidget.zoomOut() self.previewWidget.zoomOut()
def zoomOriginal(self):
"""
Called when *zoomOutButton* is clicked.
"""
self.previewWidget.fitInView()
def updateTextFormat(self, value): def updateTextFormat(self, value):
""" """
Called when html copy check box is selected. Called when html copy check box is selected.
@ -213,8 +244,3 @@ class PrintServiceOrderForm(QtGui.QDialog, Ui_PrintServiceOrderDialog):
settings.setValue(u'print notes', settings.setValue(u'print notes',
QtCore.QVariant(self.notesCheckBox.isChecked())) QtCore.QVariant(self.notesCheckBox.isChecked()))
settings.endGroup() 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 ThemeLevel
from openlp.core.lib.ui import UiStrings, critical_error_message_box from openlp.core.lib.ui import UiStrings, critical_error_message_box
from openlp.core.ui import ServiceNoteForm, ServiceItemEditForm, StartTimeForm 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, \ from openlp.core.utils import AppLocation, delete_file, file_is_unicode, \
split_filename split_filename
@ -1208,5 +1208,5 @@ class ServiceManager(QtGui.QWidget):
""" """
Print a Service Order Sheet. Print a Service Order Sheet.
""" """
settingDialog = PrintServiceOrderForm(self.mainwindow, self) settingDialog = PrintServiceForm(self.mainwindow, self)
settingDialog.exec_() settingDialog.exec_()