fix up service print

This commit is contained in:
Tim Bentley 2018-04-17 21:50:27 +01:00
parent f5645f91d3
commit 1dfd7403bd
5 changed files with 32 additions and 28 deletions

View File

@ -22,13 +22,14 @@
"""
The :mod:`~openlp.core.api.tab` module contains the settings tab for the API
"""
from PyQt5 import QtCore, QtGui, QtNetwork, QtWidgets
from PyQt5 import QtCore, QtGui, QtWidgets
from openlp.core.common import get_local_ip4
from openlp.core.common.i18n import UiStrings, translate
from openlp.core.common.registry import Registry
from openlp.core.common.settings import Settings
from openlp.core.lib import SettingsTab
from openlp.core.ui.icons import UiIcons
ZERO_URL = '0.0.0.0'
@ -38,7 +39,7 @@ class ApiTab(SettingsTab):
RemoteTab is the Remotes settings tab in the settings dialog.
"""
def __init__(self, parent):
self.icon_path = ':/plugins/plugin_remote.png'
self.icon_path = UiIcons().remote
advanced_translated = translate('OpenLP.AdvancedTab', 'Advanced')
super(ApiTab, self).__init__(parent, 'api', advanced_translated)

View File

@ -50,7 +50,7 @@ class AdvancedTab(SettingsTab):
Initialise the settings tab
"""
self.data_exists = False
self.icon_path = ':/system/system_settings.png'
self.icon_path = UiIcons().settings
self.autoscroll_map = [None, {'dist': -1, 'pos': 0}, {'dist': -1, 'pos': 1}, {'dist': -1, 'pos': 2},
{'dist': 0, 'pos': 0}, {'dist': 0, 'pos': 1}, {'dist': 0, 'pos': 2},
{'dist': 0, 'pos': 3}, {'dist': 1, 'pos': 0}, {'dist': 1, 'pos': 1},

View File

@ -73,7 +73,7 @@ class Ui_ExceptionDialog(object):
self.exception_text_edit.setObjectName('exception_text_edit')
self.exception_layout.addWidget(self.exception_text_edit)
self.send_report_button = create_button(exception_dialog, 'send_report_button',
icon=':/general/general_email.png',
icon=UiIcons().email,
click=self.on_send_report_button_clicked)
self.save_report_button = create_button(exception_dialog, 'save_report_button',
icon=UiIcons().save,
@ -92,7 +92,7 @@ class Ui_ExceptionDialog(object):
"""
Translate the widgets on the fly.
"""
# Note that bugs mail is not clicable, but it adds the blue color and underlining and makes the test copyable.
# Note that bugs mail is not clickable, but it adds the blue color and underlining and makes the test copyable.
exception_dialog.setWindowTitle(translate('OpenLP.ExceptionDialog', 'Error Occurred'))
# Explanation text,   adds a small space before: If possible, write in English.
self.description_explanation.setText(

View File

@ -71,16 +71,18 @@ class UiIcons(object):
'desktop': 'fa.desktop',
'delete': 'fa.trash',
'edit': 'fa.edit',
'email': 'fa.envelope',
'exit': 'fa.sign-out',
'download': 'fa.cloud-download',
'info': 'fa.info',
'live': 'fa.camera',
'live': 'fa.desktop',
'manual': 'fa.graduation-cap',
'minus': 'fa.minus',
'music': 'fa.music',
'new': 'fa.file',
'new_group': 'fa.folder',
'notes': 'fa.sticky-note',
'open': 'fa.map',
'open': 'fa.folder-open',
'pause': 'fa.pause',
'play': 'fa.play',
'plus': 'fa.plus',

View File

@ -33,7 +33,7 @@ from openlp.core.common.i18n import UiStrings, translate
from openlp.core.common.mixins import RegistryProperties
from openlp.core.common.registry import Registry
from openlp.core.common.settings import Settings
from openlp.core.lib import get_text_file_string
from openlp.core.lib import get_text_file_string, image_to_byte
from openlp.core.ui.printservicedialog import Ui_PrintServiceDialog, ZoomSize
DEFAULT_CSS = """/*
@ -184,7 +184,7 @@ class PrintServiceForm(QtWidgets.QDialog, Ui_PrintServiceDialog, RegistryPropert
custom_css = DEFAULT_CSS
self._add_element('style', custom_css, html_data.head, attribute=('type', 'text/css'))
self._add_element('body', parent=html_data)
self._add_element('h1', html.escape(self.title_line_edit.text()), html_data.body, classId='serviceTitle')
self._add_element('h1', html.escape(self.title_line_edit.text()), html_data.body, class_id='serviceTitle')
for index, item in enumerate(self.service_manager.service_items):
self._add_preview_item(html_data.body, item['service_item'], index)
if not self.show_chords_check_box.isChecked():
@ -195,10 +195,10 @@ class PrintServiceForm(QtWidgets.QDialog, Ui_PrintServiceDialog, RegistryPropert
spacing_span.drop_tree()
# Add the custom service notes:
if self.footer_text_edit.toPlainText():
div = self._add_element('div', parent=html_data.body, classId='customNotes')
div = self._add_element('div', parent=html_data.body, class_id='customNotes')
self._add_element(
'span', translate('OpenLP.ServiceManager', 'Custom Service Notes: '), div, classId='customNotesTitle')
self._add_element('span', html.escape(self.footer_text_edit.toPlainText()), div, classId='customNotesText')
'span', translate('OpenLP.ServiceManager', 'Custom Service Notes: '), div, class_id='customNotesTitle')
self._add_element('span', html.escape(self.footer_text_edit.toPlainText()), div, class_id='customNotesText')
self.document.setHtml(lxml.html.tostring(html_data).decode())
self.preview_widget.updatePreview()
@ -206,10 +206,11 @@ class PrintServiceForm(QtWidgets.QDialog, Ui_PrintServiceDialog, RegistryPropert
"""
Add a preview item
"""
div = self._add_element('div', classId='item', parent=body)
div = self._add_element('div', class_id='item', parent=body)
# Add the title of the service item.
item_title = self._add_element('h2', parent=div, classId='itemTitle')
self._add_element('img', parent=item_title, attribute=('src', item.icon))
item_title = self._add_element('h2', parent=div, class_id='itemTitle')
img = image_to_byte(item.iconic_representation.pixmap(20, 20).toImage())
self._add_element('img', parent=item_title, attribute=('src', 'data:image/png;base64, ' + img))
self._add_element('span', ' ' + html.escape(item.get_display_title()), item_title)
if self.slide_text_check_box.isChecked():
# Add the text of the service item.
@ -218,7 +219,7 @@ class PrintServiceForm(QtWidgets.QDialog, Ui_PrintServiceDialog, RegistryPropert
verse_html = None
for slide in item.get_frames():
if not verse_def or verse_def != slide['verseTag'] or verse_html == slide['printing_html']:
text_div = self._add_element('div', parent=div, classId='itemText')
text_div = self._add_element('div', parent=div, class_id='itemText')
elif 'chordspacing' not in slide['printing_html']:
self._add_element('br', parent=text_div)
self._add_element('span', slide['printing_html'], text_div)
@ -229,7 +230,7 @@ class PrintServiceForm(QtWidgets.QDialog, Ui_PrintServiceDialog, RegistryPropert
div.set('class', 'item newPage')
# Add the image names of the service item.
elif item.is_image():
ol = self._add_element('ol', parent=div, classId='imageList')
ol = self._add_element('ol', parent=div, class_id='imageList')
for slide in range(len(item.get_frames())):
self._add_element('li', item.get_frame_title(slide), ol)
# add footer
@ -237,24 +238,24 @@ class PrintServiceForm(QtWidgets.QDialog, Ui_PrintServiceDialog, RegistryPropert
foot_text = foot_text.partition('<br>')[2]
if foot_text:
foot_text = html.escape(foot_text.replace('<br>', '\n'))
self._add_element('div', foot_text.replace('\n', '<br>'), parent=div, classId='itemFooter')
self._add_element('div', foot_text.replace('\n', '<br>'), parent=div, class_id='itemFooter')
# Add service items' notes.
if self.notes_check_box.isChecked():
if item.notes:
p = self._add_element('div', classId='itemNotes', parent=div)
self._add_element('span', translate('OpenLP.ServiceManager', 'Notes: '), p, classId='itemNotesTitle')
self._add_element('span', html.escape(item.notes).replace('\n', '<br>'), p, classId='itemNotesText')
p = self._add_element('div', class_id='itemNotes', parent=div)
self._add_element('span', translate('OpenLP.ServiceManager', 'Notes: '), p, class_id='itemNotesTitle')
self._add_element('span', html.escape(item.notes).replace('\n', '<br>'), p, class_id='itemNotesText')
# Add play length of media files.
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._add_element('div', classId='media', parent=div)
title = self._add_element('div', class_id='media', parent=div)
self._add_element(
'span', translate('OpenLP.ServiceManager', 'Playing time: '), title, classId='mediaTitle')
self._add_element('span', str(datetime.timedelta(seconds=tme)), title, classId='mediaText')
'span', translate('OpenLP.ServiceManager', 'Playing time: '), title, class_id='mediaTitle')
self._add_element('span', str(datetime.timedelta(seconds=tme)), title, class_id='mediaText')
def _add_element(self, tag, text=None, parent=None, classId=None, attribute=None):
def _add_element(self, tag, text=None, parent=None, class_id=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.
@ -262,7 +263,7 @@ class PrintServiceForm(QtWidgets.QDialog, Ui_PrintServiceDialog, RegistryPropert
:param tag: The html tag, e. g. ``'span'``. Defaults to ``None``.
:param text: The text for the tag. Defaults to ``None``.
:param parent: The parent element. Defaults to ``None``.
:param classId: Value for the class attribute
:param class_id: Value for the class attribute
:param attribute: Tuple name/value pair to add as an optional attribute
"""
if text is not None:
@ -271,8 +272,8 @@ class PrintServiceForm(QtWidgets.QDialog, Ui_PrintServiceDialog, RegistryPropert
element = lxml.html.Element(tag)
if parent is not None:
parent.append(element)
if classId is not None:
element.set('class', classId)
if class_id is not None:
element.set('class', class_id)
if attribute is not None:
element.set(attribute[0], attribute[1])
return element