From 0047b8d1c105f969293f2fe8e7cd64ea7da1d4df Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Fri, 4 Feb 2011 13:57:48 +0100 Subject: [PATCH] --- openlp/core/ui/advancedtab.py | 39 ++++++++++++------ openlp/core/ui/servicemanager.py | 68 +++++++++++++++++++------------- 2 files changed, 67 insertions(+), 40 deletions(-) diff --git a/openlp/core/ui/advancedtab.py b/openlp/core/ui/advancedtab.py index f68131894..630cbc18c 100644 --- a/openlp/core/ui/advancedtab.py +++ b/openlp/core/ui/advancedtab.py @@ -84,11 +84,15 @@ class AdvancedTab(SettingsTab): self.serviceOrderGroupBox.setObjectName(u'serviceOrderGroupBox') self.serviceOrderLayout = QtGui.QVBoxLayout(self.serviceOrderGroupBox) self.serviceOrderLayout.setObjectName(u'serviceOrderLayout') - self.detailedServicePrintCheckBox = QtGui.QCheckBox( - self.serviceOrderGroupBox) - self.detailedServicePrintCheckBox.setObjectName( - u'detailedServicePrintCheckBox') - self.serviceOrderLayout.addWidget(self.detailedServicePrintCheckBox) + self.printSlideTextCheckBox = QtGui.QCheckBox(self.serviceOrderGroupBox) + self.printSlideTextCheckBox.setObjectName(u'printSlideTextCheckBox') + self.serviceOrderLayout.addWidget(self.printSlideTextCheckBox) + self.printMetaDataCheckBox = QtGui.QCheckBox(self.serviceOrderGroupBox) + self.printMetaDataCheckBox.setObjectName(u'printMetaDataCheckBox') + self.serviceOrderLayout.addWidget(self.printMetaDataCheckBox) + self.printNotesCheckBox = QtGui.QCheckBox(self.serviceOrderGroupBox) + self.printNotesCheckBox.setObjectName(u'printNotesCheckBox') + self.serviceOrderLayout.addWidget(self.printNotesCheckBox) self.leftLayout.addWidget(self.serviceOrderGroupBox) # self.sharedDirGroupBox = QtGui.QGroupBox(self.leftColumn) # self.sharedDirGroupBox.setObjectName(u'sharedDirGroupBox') @@ -141,9 +145,12 @@ class AdvancedTab(SettingsTab): 'Hide the mouse cursor when moved over the display window')) self.serviceOrderGroupBox.setTitle(translate('OpenLP.AdvancedTab', 'Service Order Print')) - self.detailedServicePrintCheckBox.setText( - translate('OpenLP.AdvancedTab', - 'Print slide texts and service item notes as well')) + self.printSlideTextCheckBox.setText( + translate('OpenLP.AdvancedTab', 'Include text slides if available')) + self.printMetaDataCheckBox.setText(translate( + 'OpenLP.AdvancedTab', 'Include playing time of media files')) + self.printNotesCheckBox.setText( + translate('OpenLP.AdvancedTab', 'Include service item notes')) # self.sharedDirGroupBox.setTitle( # translate('AdvancedTab', 'Central Data Store')) # self.sharedCheckBox.setText( @@ -179,8 +186,12 @@ class AdvancedTab(SettingsTab): QtCore.QVariant(True)).toBool()) self.hideMouseCheckBox.setChecked( settings.value(u'hide mouse', QtCore.QVariant(False)).toBool()) - self.detailedServicePrintCheckBox.setChecked(settings.value( - u'detailed service print', QtCore.QVariant(False)).toBool()) + self.printSlideTextCheckBox.setChecked(settings.value( + u'print slide text', QtCore.QVariant(False)).toBool()) + self.printMetaDataCheckBox.setChecked(settings.value( + u'print file meta data', QtCore.QVariant(False)).toBool()) + self.printNotesCheckBox.setChecked(settings.value( + u'print notes', QtCore.QVariant(False)).toBool()) settings.endGroup() def save(self): @@ -201,8 +212,12 @@ class AdvancedTab(SettingsTab): QtCore.QVariant(self.enableAutoCloseCheckBox.isChecked())) settings.setValue(u'hide mouse', QtCore.QVariant(self.hideMouseCheckBox.isChecked())) - settings.setValue(u'detailed service print', - QtCore.QVariant(self.detailedServicePrintCheckBox.isChecked())) + settings.setValue(u'print slide text', + QtCore.QVariant(self.printSlideTextCheckBox.isChecked())) + settings.setValue(u'print file meta data', + QtCore.QVariant(self.printMetaDataCheckBox.isChecked())) + settings.setValue(u'print notes', + QtCore.QVariant(self.printNotesCheckBox.isChecked())) settings.endGroup() # def onSharedCheckBoxChanged(self, checked): diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 4d36f4aec..3f38afe58 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -24,9 +24,11 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### -import os -import logging import cPickle +import datetime +import logging +import mutagen +import os import zipfile log = logging.getLogger(__name__) @@ -1188,11 +1190,6 @@ class ServiceManager(QtGui.QWidget): """ Print a Service Order Sheet. """ - if not self.serviceItems: - critical_error_message_box( - message=translate('OpenLP.ServiceManager', - 'There is no service item in this service.')) - return printDialog = QtGui.QPrintDialog() if not printDialog.exec_(): return @@ -1200,29 +1197,44 @@ class ServiceManager(QtGui.QWidget): 'Service Order Sheet') for item in self.serviceItems: item = item[u'service_item'] - # add the title + # Add the title of the service item. text += u'

%s

' % (item.icon, item.get_display_title()) - if not QtCore.QSettings().value(u'advanced' + - u'/detailed service print', QtCore.QVariant(True)).toBool(): - continue - if item.is_text(): - # Add the text of the service item. - for slide in item.get_frames(): - text += u'

' + slide[u'text'] + u'

' - elif item.is_image(): - # Add the image names of the service item. - text += u'
    ' - for slide in range(len(item.get_frames())): - text += u'
  1. %s

  2. ' % item.get_frame_title(slide) - text += u'
' - if item.foot_text: - # add footer - text += u'

%s

' % item.foot_text - if item.notes: - # add notes - text += u'

%s %s

' % (translate( - 'OpenLP.ServiceManager', 'Notes:'), item.notes) + # Add slide text of the service item. + if QtCore.QSettings().value(u'advanced' + + u'/print slide text', QtCore.QVariant(False)).toBool(): + if item.is_text(): + # Add the text of the service item. + for slide in item.get_frames(): + text += u'

' + slide[u'text'] + u'

' + elif item.is_image(): + # Add the image names of the service item. + text += u'
    ' + for slide in range(len(item.get_frames())): + text += u'
  1. %s

  2. ' % item.get_frame_title(slide) + text += u'
' + if item.foot_text: + # add footer + text += u'

%s

' % item.foot_text + # Add service items' notes. + if QtCore.QSettings().value(u'advanced' + + u'/print notes', QtCore.QVariant(False)).toBool(): + if item.notes: + text += u'

%s %s

' % (translate( + 'OpenLP.ServiceManager', 'Notes:'), item.notes) + # Add play length of media files. + if item.is_media() and QtCore.QSettings().value(u'advanced' + + u'/print file meta data', QtCore.QVariant(False)).toBool(): + path = os.path.join(item.get_frames()[0][u'path'], + item.get_frames()[0][u'title']) + if not os.path.isfile(path): + continue + file = mutagen.File(path) + if file is not None: + length = int(file.info.length) + text += u'

%s %s

' % (translate( + 'OpenLP.ServiceManager', u'Playing time:'), + unicode(datetime.timedelta(seconds=length))) serviceDocument = QtGui.QTextDocument() serviceDocument.setHtml(text) serviceDocument.print_(printDialog.printer())