forked from openlp/openlp
printform/dialog: code standards
This commit is contained in:
parent
b0f7e34271
commit
1031651db0
|
@ -50,107 +50,107 @@ class Ui_PrintServiceDialog(object):
|
|||
"""
|
||||
The UI of the print service dialog
|
||||
"""
|
||||
def setupUi(self, printServiceDialog):
|
||||
def setupUi(self, print_service_dialog):
|
||||
"""
|
||||
Set up the UI
|
||||
"""
|
||||
printServiceDialog.setObjectName(u'printServiceDialog')
|
||||
printServiceDialog.resize(664, 594)
|
||||
self.mainLayout = QtGui.QVBoxLayout(printServiceDialog)
|
||||
self.mainLayout.setSpacing(0)
|
||||
self.mainLayout.setMargin(0)
|
||||
self.mainLayout.setObjectName(u'mainLayout')
|
||||
self.toolbar = QtGui.QToolBar(printServiceDialog)
|
||||
print_service_dialog.setObjectName(u'print_service_dialog')
|
||||
print_service_dialog.resize(664, 594)
|
||||
self.main_layout = QtGui.QVBoxLayout(print_service_dialog)
|
||||
self.main_layout.setSpacing(0)
|
||||
self.main_layout.setMargin(0)
|
||||
self.main_layout.setObjectName(u'main_layout')
|
||||
self.toolbar = QtGui.QToolBar(print_service_dialog)
|
||||
self.toolbar.setIconSize(QtCore.QSize(22, 22))
|
||||
self.toolbar.setToolButtonStyle(QtCore.Qt.ToolButtonTextBesideIcon)
|
||||
self.printButton = self.toolbar.addAction(build_icon(u':/general/general_print.png'),
|
||||
self.print_button = self.toolbar.addAction(build_icon(u':/general/general_print.png'),
|
||||
translate('OpenLP.PrintServiceForm', 'Print'))
|
||||
self.optionsButton = QtGui.QToolButton(self.toolbar)
|
||||
self.optionsButton.setToolButtonStyle(QtCore.Qt.ToolButtonTextBesideIcon)
|
||||
self.optionsButton.setIcon(build_icon(u':/system/system_configure.png'))
|
||||
self.optionsButton.setCheckable(True)
|
||||
self.toolbar.addWidget(self.optionsButton)
|
||||
self.options_button = QtGui.QToolButton(self.toolbar)
|
||||
self.options_button.setToolButtonStyle(QtCore.Qt.ToolButtonTextBesideIcon)
|
||||
self.options_button.setIcon(build_icon(u':/system/system_configure.png'))
|
||||
self.options_button.setCheckable(True)
|
||||
self.toolbar.addWidget(self.options_button)
|
||||
self.toolbar.addSeparator()
|
||||
self.plainCopy = self.toolbar.addAction(build_icon(u':/system/system_edit_copy.png'),
|
||||
self.plain_copy = self.toolbar.addAction(build_icon(u':/system/system_edit_copy.png'),
|
||||
translate('OpenLP.PrintServiceForm', 'Copy'))
|
||||
self.htmlCopy = self.toolbar.addAction(build_icon(u':/system/system_edit_copy.png'),
|
||||
self.html_copy = self.toolbar.addAction(build_icon(u':/system/system_edit_copy.png'),
|
||||
translate('OpenLP.PrintServiceForm', 'Copy as HTML'))
|
||||
self.toolbar.addSeparator()
|
||||
self.zoomInButton = QtGui.QToolButton(self.toolbar)
|
||||
self.zoomInButton.setIcon(build_icon(u':/general/general_zoom_in.png'))
|
||||
self.zoomInButton.setObjectName(u'zoomInButton')
|
||||
self.zoomInButton.setIconSize(QtCore.QSize(22, 22))
|
||||
self.toolbar.addWidget(self.zoomInButton)
|
||||
self.zoomOutButton = QtGui.QToolButton(self.toolbar)
|
||||
self.zoomOutButton.setIcon(build_icon(u':/general/general_zoom_out.png'))
|
||||
self.zoomOutButton.setObjectName(u'zoomOutButton')
|
||||
self.zoomOutButton.setIconSize(QtCore.QSize(22, 22))
|
||||
self.toolbar.addWidget(self.zoomOutButton)
|
||||
self.zoomOriginalButton = QtGui.QToolButton(self.toolbar)
|
||||
self.zoomOriginalButton.setIcon(build_icon(u':/general/general_zoom_original.png'))
|
||||
self.zoomOriginalButton.setObjectName(u'zoomOriginalButton')
|
||||
self.zoomOriginalButton.setIconSize(QtCore.QSize(22, 22))
|
||||
self.toolbar.addWidget(self.zoomOriginalButton)
|
||||
self.zoomComboBox = QtGui.QComboBox(printServiceDialog)
|
||||
self.zoomComboBox.setObjectName(u'zoomComboBox')
|
||||
self.toolbar.addWidget(self.zoomComboBox)
|
||||
self.mainLayout.addWidget(self.toolbar)
|
||||
self.previewWidget = QtGui.QPrintPreviewWidget(printServiceDialog)
|
||||
self.mainLayout.addWidget(self.previewWidget)
|
||||
self.optionsWidget = QtGui.QWidget(printServiceDialog)
|
||||
self.optionsWidget.hide()
|
||||
self.optionsWidget.resize(400, 300)
|
||||
self.optionsWidget.setAutoFillBackground(True)
|
||||
self.optionsLayout = QtGui.QVBoxLayout(self.optionsWidget)
|
||||
self.optionsLayout.setContentsMargins(8, 8, 8, 8)
|
||||
self.title_label = QtGui.QLabel(self.optionsWidget)
|
||||
self.zoom_in_button = QtGui.QToolButton(self.toolbar)
|
||||
self.zoom_in_button.setIcon(build_icon(u':/general/general_zoom_in.png'))
|
||||
self.zoom_in_button.setObjectName(u'zoom_in_button')
|
||||
self.zoom_in_button.setIconSize(QtCore.QSize(22, 22))
|
||||
self.toolbar.addWidget(self.zoom_in_button)
|
||||
self.zoom_out_button = QtGui.QToolButton(self.toolbar)
|
||||
self.zoom_out_button.setIcon(build_icon(u':/general/general_zoom_out.png'))
|
||||
self.zoom_out_button.setObjectName(u'zoom_out_button')
|
||||
self.zoom_out_button.setIconSize(QtCore.QSize(22, 22))
|
||||
self.toolbar.addWidget(self.zoom_out_button)
|
||||
self.zoom_original_button = QtGui.QToolButton(self.toolbar)
|
||||
self.zoom_original_button.setIcon(build_icon(u':/general/general_zoom_original.png'))
|
||||
self.zoom_original_button.setObjectName(u'zoom_original_button')
|
||||
self.zoom_original_button.setIconSize(QtCore.QSize(22, 22))
|
||||
self.toolbar.addWidget(self.zoom_original_button)
|
||||
self.zoom_combo_box = QtGui.QComboBox(print_service_dialog)
|
||||
self.zoom_combo_box.setObjectName(u'zoom_combo_box')
|
||||
self.toolbar.addWidget(self.zoom_combo_box)
|
||||
self.main_layout.addWidget(self.toolbar)
|
||||
self.preview_widget = QtGui.QPrintPreviewWidget(print_service_dialog)
|
||||
self.main_layout.addWidget(self.preview_widget)
|
||||
self.options_widget = QtGui.QWidget(print_service_dialog)
|
||||
self.options_widget.hide()
|
||||
self.options_widget.resize(400, 300)
|
||||
self.options_widget.setAutoFillBackground(True)
|
||||
self.options_layout = QtGui.QVBoxLayout(self.options_widget)
|
||||
self.options_layout.setContentsMargins(8, 8, 8, 8)
|
||||
self.title_label = QtGui.QLabel(self.options_widget)
|
||||
self.title_label.setObjectName(u'title_label')
|
||||
self.optionsLayout.addWidget(self.title_label)
|
||||
self.titleLineEdit = QtGui.QLineEdit(self.optionsWidget)
|
||||
self.titleLineEdit.setObjectName(u'titleLineEdit')
|
||||
self.optionsLayout.addWidget(self.titleLineEdit)
|
||||
self.footerLabel = QtGui.QLabel(self.optionsWidget)
|
||||
self.footerLabel.setObjectName(u'footerLabel')
|
||||
self.optionsLayout.addWidget(self.footerLabel)
|
||||
self.footerTextEdit = SpellTextEdit(self.optionsWidget, False)
|
||||
self.footerTextEdit.setObjectName(u'footerTextEdit')
|
||||
self.optionsLayout.addWidget(self.footerTextEdit)
|
||||
self.optionsGroupBox = QtGui.QGroupBox()
|
||||
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()
|
||||
self.groupLayout.addWidget(self.metaDataCheckBox)
|
||||
self.groupLayout.addStretch(1)
|
||||
self.optionsGroupBox.setLayout(self.groupLayout)
|
||||
self.optionsLayout.addWidget(self.optionsGroupBox)
|
||||
self.options_layout.addWidget(self.title_label)
|
||||
self.title_line_edit = QtGui.QLineEdit(self.options_widget)
|
||||
self.title_line_edit.setObjectName(u'title_line_edit')
|
||||
self.options_layout.addWidget(self.title_line_edit)
|
||||
self.footer_label = QtGui.QLabel(self.options_widget)
|
||||
self.footer_label.setObjectName(u'footer_label')
|
||||
self.options_layout.addWidget(self.footer_label)
|
||||
self.footer_text_edit = SpellTextEdit(self.options_widget, False)
|
||||
self.footer_text_edit.setObjectName(u'footer_text_edit')
|
||||
self.options_layout.addWidget(self.footer_text_edit)
|
||||
self.options_group_box = QtGui.QGroupBox()
|
||||
self.group_layout = QtGui.QVBoxLayout()
|
||||
self.slide_text_check_box = QtGui.QCheckBox()
|
||||
self.group_layout.addWidget(self.slide_text_check_box)
|
||||
self.page_break_after_text = QtGui.QCheckBox()
|
||||
self.group_layout.addWidget(self.page_break_after_text)
|
||||
self.notes_check_box = QtGui.QCheckBox()
|
||||
self.group_layout.addWidget(self.notes_check_box)
|
||||
self.meta_data_check_box = QtGui.QCheckBox()
|
||||
self.group_layout.addWidget(self.meta_data_check_box)
|
||||
self.group_layout.addStretch(1)
|
||||
self.options_group_box.setLayout(self.group_layout)
|
||||
self.options_layout.addWidget(self.options_group_box)
|
||||
|
||||
self.retranslateUi(printServiceDialog)
|
||||
QtCore.QObject.connect(self.optionsButton, QtCore.SIGNAL(u'toggled(bool)'), self.toggleOptions)
|
||||
self.retranslateUi(print_service_dialog)
|
||||
self.options_button.toggled.connect(self.toggle_options)
|
||||
|
||||
def retranslateUi(self, printServiceDialog):
|
||||
def retranslateUi(self, print_service_dialog):
|
||||
"""
|
||||
Translate the UI on the fly
|
||||
"""
|
||||
printServiceDialog.setWindowTitle(UiStrings().PrintService)
|
||||
self.zoomOutButton.setToolTip(translate('OpenLP.PrintServiceForm', 'Zoom Out'))
|
||||
self.zoomOriginalButton.setToolTip(translate('OpenLP.PrintServiceForm', 'Zoom Original'))
|
||||
self.zoomInButton.setToolTip(translate('OpenLP.PrintServiceForm', 'Zoom In'))
|
||||
self.optionsButton.setText(translate('OpenLP.PrintServiceForm', 'Options'))
|
||||
print_service_dialog.setWindowTitle(UiStrings().PrintService)
|
||||
self.zoom_out_button.setToolTip(translate('OpenLP.PrintServiceForm', 'Zoom Out'))
|
||||
self.zoom_original_button.setToolTip(translate('OpenLP.PrintServiceForm', 'Zoom Original'))
|
||||
self.zoom_in_button.setToolTip(translate('OpenLP.PrintServiceForm', 'Zoom In'))
|
||||
self.options_button.setText(translate('OpenLP.PrintServiceForm', 'Options'))
|
||||
self.title_label.setText(translate('OpenLP.PrintServiceForm', 'Title:'))
|
||||
self.footerLabel.setText(translate('OpenLP.PrintServiceForm', 'Custom Footer Text:'))
|
||||
self.optionsGroupBox.setTitle(translate('OpenLP.PrintServiceForm', 'Other Options'))
|
||||
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', 'Include play length of media items'))
|
||||
self.titleLineEdit.setText(translate('OpenLP.PrintServiceForm', 'Service Sheet'))
|
||||
self.footer_label.setText(translate('OpenLP.PrintServiceForm', 'Custom Footer Text:'))
|
||||
self.options_group_box.setTitle(translate('OpenLP.PrintServiceForm', 'Other Options'))
|
||||
self.slide_text_check_box.setText(translate('OpenLP.PrintServiceForm', 'Include slide text if available'))
|
||||
self.page_break_after_text.setText(translate('OpenLP.PrintServiceForm', 'Add page break before each text item'))
|
||||
self.notes_check_box.setText(translate('OpenLP.PrintServiceForm', 'Include service item notes'))
|
||||
self.meta_data_check_box.setText(translate('OpenLP.PrintServiceForm', 'Include play length of media items'))
|
||||
self.title_line_edit.setText(translate('OpenLP.PrintServiceForm', 'Service Sheet'))
|
||||
# Do not change the order.
|
||||
self.zoomComboBox.addItems([
|
||||
self.zoom_combo_box.addItems([
|
||||
translate('OpenLP.PrintServiceDialog', 'Fit Page'),
|
||||
translate('OpenLP.PrintServiceDialog', 'Fit Width'),
|
||||
u'100%',
|
||||
|
|
|
@ -120,124 +120,123 @@ class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog):
|
|||
"""
|
||||
QtGui.QDialog.__init__(self, self.main_window)
|
||||
self.printer = QtGui.QPrinter()
|
||||
self.printDialog = QtGui.QPrintDialog(self.printer, self)
|
||||
self.print_dialog = QtGui.QPrintDialog(self.printer, self)
|
||||
self.document = QtGui.QTextDocument()
|
||||
self.zoom = 0
|
||||
self.setupUi(self)
|
||||
# Load the settings for the dialog.
|
||||
settings = Settings()
|
||||
settings.beginGroup(u'advanced')
|
||||
self.slideTextCheckBox.setChecked(settings.value(u'print slide text'))
|
||||
self.pageBreakAfterText.setChecked(settings.value(u'add page break'))
|
||||
if not self.slideTextCheckBox.isChecked():
|
||||
self.pageBreakAfterText.setDisabled(True)
|
||||
self.metaDataCheckBox.setChecked(settings.value(u'print file meta data'))
|
||||
self.notesCheckBox.setChecked(settings.value(u'print notes'))
|
||||
self.zoomComboBox.setCurrentIndex(settings.value(u'display size'))
|
||||
self.slide_text_check_box.setChecked(settings.value(u'print slide text'))
|
||||
self.page_break_after_text.setChecked(settings.value(u'add page break'))
|
||||
if not self.slide_text_check_box.isChecked():
|
||||
self.page_break_after_text.setDisabled(True)
|
||||
self.meta_data_check_box.setChecked(settings.value(u'print file meta data'))
|
||||
self.notes_check_box.setChecked(settings.value(u'print notes'))
|
||||
self.zoom_combo_box.setCurrentIndex(settings.value(u'display size'))
|
||||
settings.endGroup()
|
||||
# Signals
|
||||
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)
|
||||
self.updatePreviewText()
|
||||
self.print_button.triggered.connect(self.print_service_order)
|
||||
self.zoom_out_button.clicked.connect(self.zoom_out)
|
||||
self.zoom_in_button.clicked.connect(self.zoom_in)
|
||||
self.zoom_original_button.clicked.connect(self.zoom_original)
|
||||
self.preview_widget.paintRequested.connect(self.paint_requested)
|
||||
self.zoom_combo_box.currentIndexChanged.connect(self.display_size_changed)
|
||||
self.plain_copy.triggered.connect(self.copy_text)
|
||||
self.html_copy.triggered.connect(self.copy_html_text)
|
||||
self.slide_text_check_box.stateChanged.connect(self.on_slide_text_check_box_changed)
|
||||
self.update_preview_text()
|
||||
|
||||
def toggleOptions(self, checked):
|
||||
def toggle_options(self, checked):
|
||||
"""
|
||||
Toggle various options
|
||||
"""
|
||||
self.optionsWidget.setVisible(checked)
|
||||
self.options_widget.setVisible(checked)
|
||||
if checked:
|
||||
left = self.optionsButton.pos().x()
|
||||
left = self.options_button.pos().x()
|
||||
top = self.toolbar.height()
|
||||
self.optionsWidget.move(left, top)
|
||||
self.titleLineEdit.setFocus()
|
||||
self.options_widget.move(left, top)
|
||||
self.title_line_edit.setFocus()
|
||||
else:
|
||||
self.saveOptions()
|
||||
self.updatePreviewText()
|
||||
self.save_options()
|
||||
self.update_preview_text()
|
||||
|
||||
def updatePreviewText(self):
|
||||
def update_preview_text(self):
|
||||
"""
|
||||
Creates the html text and updates the html of *self.document*.
|
||||
"""
|
||||
html_data = self._addElement(u'html')
|
||||
self._addElement(u'head', parent=html_data)
|
||||
self._addElement(u'title', self.titleLineEdit.text(), html_data.head)
|
||||
html_data = self._add_element(u'html')
|
||||
self._add_element(u'head', parent=html_data)
|
||||
self._add_element(u'title', self.title_line_edit.text(), html_data.head)
|
||||
css_path = os.path.join(AppLocation.get_data_path(), u'service_print.css')
|
||||
custom_css = get_text_file_string(css_path)
|
||||
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)
|
||||
self._addElement(u'h1', cgi.escape(self.titleLineEdit.text()), html_data.body, classId=u'serviceTitle')
|
||||
self._add_element(u'style', custom_css, html_data.head, attribute=(u'type', u'text/css'))
|
||||
self._add_element(u'body', parent=html_data)
|
||||
self._add_element(u'h1', cgi.escape(self.title_line_edit.text()), html_data.body, classId=u'serviceTitle')
|
||||
for index, item in enumerate(self.service_manager.service_items):
|
||||
self._addPreviewItem(html_data.body, item[u'service_item'], index)
|
||||
self._add_preview_item(html_data.body, item[u'service_item'], index)
|
||||
# Add the custom service notes:
|
||||
if self.footerTextEdit.toPlainText():
|
||||
div = self._addElement(u'div', parent=html_data.body, classId=u'customNotes')
|
||||
self._addElement(
|
||||
if self.footer_text_edit.toPlainText():
|
||||
div = self._add_element(u'div', parent=html_data.body, classId=u'customNotes')
|
||||
self._add_element(
|
||||
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')
|
||||
self._add_element(u'span', cgi.escape(self.footer_text_edit.toPlainText()), div, classId=u'customNotesText')
|
||||
self.document.setHtml(html.tostring(html_data))
|
||||
self.previewWidget.updatePreview()
|
||||
self.preview_widget.updatePreview()
|
||||
|
||||
def _addPreviewItem(self, body, item, index):
|
||||
def _add_preview_item(self, body, item, index):
|
||||
"""
|
||||
Add a preview item
|
||||
"""
|
||||
div = self._addElement(u'div', classId=u'item', parent=body)
|
||||
div = self._add_element(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')
|
||||
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)
|
||||
if self.slideTextCheckBox.isChecked():
|
||||
item_title = self._add_element(u'h2', parent=div, classId=u'itemTitle')
|
||||
self._add_element(u'img', parent=item_title, attribute=(u'src', item.icon))
|
||||
self._add_element(u'span', u' ' + cgi.escape(item.get_display_title()), item_title)
|
||||
if self.slide_text_check_box.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']:
|
||||
text_div = self._addElement(u'div', parent=div, classId=u'itemText')
|
||||
text_div = self._add_element(u'div', parent=div, classId=u'itemText')
|
||||
else:
|
||||
self._addElement(u'br', parent=text_div)
|
||||
self._addElement(u'span', slide[u'html'], text_div)
|
||||
self._add_element(u'br', parent=text_div)
|
||||
self._add_element(u'span', slide[u'html'], text_div)
|
||||
verse_def = slide[u'verseTag']
|
||||
# Break the page before the div element.
|
||||
if index != 0 and self.pageBreakAfterText.isChecked():
|
||||
if index != 0 and self.page_break_after_text.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')
|
||||
ol = self._add_element(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)
|
||||
self._add_element(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:
|
||||
foot_text = cgi.escape(foot_text.replace(u'<br>', u'\n'))
|
||||
self._addElement(u'div', foot_text.replace(u'\n', u'<br>'), parent=div, classId=u'itemFooter')
|
||||
self._add_element(u'div', foot_text.replace(u'\n', u'<br>'), parent=div, classId=u'itemFooter')
|
||||
# Add service items' notes.
|
||||
if self.notesCheckBox.isChecked():
|
||||
if self.notes_check_box.isChecked():
|
||||
if item.notes:
|
||||
p = self._addElement(u'div', classId=u'itemNotes', parent=div)
|
||||
self._addElement(u'span', translate('OpenLP.ServiceManager', 'Notes: '), p, classId=u'itemNotesTitle')
|
||||
self._addElement(u'span', cgi.escape(item.notes).replace(u'\n', u'<br>'), p, classId=u'itemNotesText')
|
||||
p = self._add_element(u'div', classId=u'itemNotes', parent=div)
|
||||
self._add_element(u'span', translate('OpenLP.ServiceManager', 'Notes: '), p, classId=u'itemNotesTitle')
|
||||
self._add_element(u'span', cgi.escape(item.notes).replace(u'\n', u'<br>'), p, classId=u'itemNotesText')
|
||||
# Add play length of media files.
|
||||
if item.is_media() and self.metaDataCheckBox.isChecked():
|
||||
if item.is_media() and self.meta_data_check_box.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)
|
||||
self._addElement(
|
||||
title = self._add_element(u'div', classId=u'media', parent=div)
|
||||
self._add_element(
|
||||
u'span', translate('OpenLP.ServiceManager', 'Playing time: '), title, classId=u'mediaTitle')
|
||||
self._addElement(u'span', unicode(datetime.timedelta(seconds=tme)), title, classId=u'mediaText')
|
||||
self._add_element(u'span', unicode(datetime.timedelta(seconds=tme)), title, classId=u'mediaText')
|
||||
|
||||
def _addElement(self, tag, text=None, parent=None, classId=None, attribute=None):
|
||||
def _add_element(self, tag, text=None, parent=None, classId=None, attribute=None):
|
||||
"""
|
||||
Creates a html element. If ``text`` is given, the element's text will
|
||||
set and if a ``parent`` is given, the element is appended.
|
||||
|
@ -269,7 +268,7 @@ class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog):
|
|||
element.set(attribute[0], attribute[1])
|
||||
return element
|
||||
|
||||
def paintRequested(self, printer):
|
||||
def paint_requested(self, printer):
|
||||
"""
|
||||
Paint the preview of the *self.document*.
|
||||
|
||||
|
@ -278,32 +277,32 @@ class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog):
|
|||
"""
|
||||
self.document.print_(printer)
|
||||
|
||||
def displaySizeChanged(self, display):
|
||||
def display_size_changed(self, display):
|
||||
"""
|
||||
The Zoom Combo box has changed so set up the size.
|
||||
"""
|
||||
if display == ZoomSize.Page:
|
||||
self.previewWidget.fitInView()
|
||||
self.preview_widget.fitInView()
|
||||
elif display == ZoomSize.Width:
|
||||
self.previewWidget.fitToWidth()
|
||||
self.preview_widget.fitToWidth()
|
||||
elif display == ZoomSize.OneHundred:
|
||||
self.previewWidget.fitToWidth()
|
||||
self.previewWidget.zoomIn(1)
|
||||
self.preview_widget.fitToWidth()
|
||||
self.preview_widget.zoomIn(1)
|
||||
elif display == ZoomSize.SeventyFive:
|
||||
self.previewWidget.fitToWidth()
|
||||
self.previewWidget.zoomIn(0.75)
|
||||
self.preview_widget.fitToWidth()
|
||||
self.preview_widget.zoomIn(0.75)
|
||||
elif display == ZoomSize.Fifty:
|
||||
self.previewWidget.fitToWidth()
|
||||
self.previewWidget.zoomIn(0.5)
|
||||
self.preview_widget.fitToWidth()
|
||||
self.preview_widget.zoomIn(0.5)
|
||||
elif display == ZoomSize.TwentyFive:
|
||||
self.previewWidget.fitToWidth()
|
||||
self.previewWidget.zoomIn(0.25)
|
||||
self.preview_widget.fitToWidth()
|
||||
self.preview_widget.zoomIn(0.25)
|
||||
settings = Settings()
|
||||
settings.beginGroup(u'advanced')
|
||||
settings.setValue(u'display size', display)
|
||||
settings.endGroup()
|
||||
|
||||
def copyText(self):
|
||||
def copy_text(self):
|
||||
"""
|
||||
Copies the display text to the clipboard as plain text
|
||||
"""
|
||||
|
@ -327,45 +326,45 @@ class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog):
|
|||
# and put it all on the clipboard
|
||||
self.main_window.clipboard.setText(clipboard_text)
|
||||
|
||||
def copyHtmlText(self):
|
||||
def copy_html_text(self):
|
||||
"""
|
||||
Copies the display text to the clipboard as Html
|
||||
"""
|
||||
self.update_song_usage()
|
||||
self.main_window.clipboard.setText(self.document.toHtml())
|
||||
|
||||
def printServiceOrder(self):
|
||||
def print_service_order(self):
|
||||
"""
|
||||
Called, when the *printButton* is clicked. Opens the *printDialog*.
|
||||
Called, when the *print_button* is clicked. Opens the *print_dialog*.
|
||||
"""
|
||||
if not self.printDialog.exec_():
|
||||
if not self.print_dialog.exec_():
|
||||
return
|
||||
self.update_song_usage()
|
||||
# Print the document.
|
||||
self.document.print_(self.printer)
|
||||
|
||||
def zoomIn(self):
|
||||
def zoom_in(self):
|
||||
"""
|
||||
Called when *zoomInButton* is clicked.
|
||||
Called when *zoom_in_button* is clicked.
|
||||
"""
|
||||
self.previewWidget.zoomIn()
|
||||
self.preview_widget.zoomIn()
|
||||
self.zoom -= 0.1
|
||||
|
||||
def zoomOut(self):
|
||||
def zoom_out(self):
|
||||
"""
|
||||
Called when *zoomOutButton* is clicked.
|
||||
Called when *zoom_out_button* is clicked.
|
||||
"""
|
||||
self.previewWidget.zoomOut()
|
||||
self.preview_widget.zoomOut()
|
||||
self.zoom += 0.1
|
||||
|
||||
def zoomOriginal(self):
|
||||
def zoom_original(self):
|
||||
"""
|
||||
Called when *zoomOutButton* is clicked.
|
||||
Called when *zoom_out_button* is clicked.
|
||||
"""
|
||||
self.previewWidget.zoomIn(1 + self.zoom)
|
||||
self.preview_widget.zoomIn(1 + self.zoom)
|
||||
self.zoom = 0
|
||||
|
||||
def updateTextFormat(self, value):
|
||||
def update_text_format(self, value):
|
||||
"""
|
||||
Called when html copy check box is selected.
|
||||
"""
|
||||
|
@ -374,24 +373,24 @@ class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog):
|
|||
else:
|
||||
self.copyTextButton.setText(UiStrings().CopyToText)
|
||||
|
||||
def onSlideTextCheckBoxChanged(self, state):
|
||||
def on_slide_text_check_box_changed(self, state):
|
||||
"""
|
||||
Disable or enable the ``pageBreakAfterText`` checkbox as it should only
|
||||
be enabled, when the ``slideTextCheckBox`` is enabled.
|
||||
Disable or enable the ``page_break_after_text`` checkbox as it should only
|
||||
be enabled, when the ``slide_text_check_box`` is enabled.
|
||||
"""
|
||||
self.pageBreakAfterText.setDisabled(state == QtCore.Qt.Unchecked)
|
||||
self.page_break_after_text.setDisabled(state == QtCore.Qt.Unchecked)
|
||||
|
||||
def saveOptions(self):
|
||||
def save_options(self):
|
||||
"""
|
||||
Save the settings and close the dialog.
|
||||
"""
|
||||
# Save the settings for this dialog.
|
||||
settings = Settings()
|
||||
settings.beginGroup(u'advanced')
|
||||
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())
|
||||
settings.setValue(u'print notes', self.notesCheckBox.isChecked())
|
||||
settings.setValue(u'print slide text', self.slide_text_check_box.isChecked())
|
||||
settings.setValue(u'add page break', self.page_break_after_text.isChecked())
|
||||
settings.setValue(u'print file meta data', self.meta_data_check_box.isChecked())
|
||||
settings.setValue(u'print notes', self.notes_check_box.isChecked())
|
||||
settings.endGroup()
|
||||
|
||||
def update_song_usage(self):
|
||||
|
@ -399,7 +398,7 @@ class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog):
|
|||
Update the song usage
|
||||
"""
|
||||
# Only continue when we include the song's text.
|
||||
if not self.slideTextCheckBox.isChecked():
|
||||
if not self.slide_text_check_box.isChecked():
|
||||
return
|
||||
for item in self.service_manager.service_items:
|
||||
# Trigger Audit requests
|
||||
|
|
|
@ -317,7 +317,7 @@ class ActionList(object):
|
|||
actions.append(action)
|
||||
ActionList.shortcut_map[shortcuts[1]] = actions
|
||||
else:
|
||||
log.warn(u'Shortcut %s is removed from %s because another action already uses this shortcut.' %
|
||||
log.warn(u'Shortcut "%s" is removed from "%s" because another action already uses this shortcut.' %
|
||||
(shortcuts[1], action.objectName()))
|
||||
shortcuts.remove(shortcuts[1])
|
||||
# Check the primary shortcut.
|
||||
|
@ -328,7 +328,7 @@ class ActionList(object):
|
|||
actions.append(action)
|
||||
ActionList.shortcut_map[shortcuts[0]] = actions
|
||||
else:
|
||||
log.warn(u'Shortcut %s is removed from %s because another action already uses this shortcut.' %
|
||||
log.warn(u'Shortcut "%s" is removed from "%s" because another action already uses this shortcut.' %
|
||||
(shortcuts[0], action.objectName()))
|
||||
action.setShortcuts([QtGui.QKeySequence(shortcut) for shortcut in shortcuts])
|
||||
|
||||
|
|
Loading…
Reference in New Issue