forked from openlp/openlp
clean ups
This commit is contained in:
parent
c939a81cfe
commit
d207cf2243
@ -116,7 +116,7 @@ class OpenLP(QtGui.QApplication):
|
|||||||
self.processEvents()
|
self.processEvents()
|
||||||
# start the main app window
|
# start the main app window
|
||||||
self.mainWindow = MainWindow(screens, self.clipboard(),
|
self.mainWindow = MainWindow(screens, self.clipboard(),
|
||||||
self.arguments())
|
self.arguments())
|
||||||
self.mainWindow.show()
|
self.mainWindow.show()
|
||||||
if show_splash:
|
if show_splash:
|
||||||
# now kill the splashscreen
|
# now kill the splashscreen
|
||||||
|
@ -452,7 +452,7 @@ def build_lyrics_css(item, webkitvers):
|
|||||||
.lyricsshadow {
|
.lyricsshadow {
|
||||||
%s
|
%s
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
theme = item.themedata
|
theme = item.themedata
|
||||||
lyricstable = u''
|
lyricstable = u''
|
||||||
lyrics = u''
|
lyrics = u''
|
||||||
@ -460,8 +460,7 @@ def build_lyrics_css(item, webkitvers):
|
|||||||
outline = u''
|
outline = u''
|
||||||
shadow = u''
|
shadow = u''
|
||||||
if theme and item.main:
|
if theme and item.main:
|
||||||
lyricstable = u'left: %spx; top: %spx;' % \
|
lyricstable = u'left: %spx; top: %spx;' % (item.main.x(), item.main.y())
|
||||||
(item.main.x(), item.main.y())
|
|
||||||
lyrics = build_lyrics_format_css(theme, item.main.width(),
|
lyrics = build_lyrics_format_css(theme, item.main.width(),
|
||||||
item.main.height())
|
item.main.height())
|
||||||
# For performance reasons we want to show as few DIV's as possible,
|
# For performance reasons we want to show as few DIV's as possible,
|
||||||
|
@ -29,7 +29,7 @@ import os
|
|||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
from lxml import html
|
from lxml import html
|
||||||
|
|
||||||
from openlp.core.lib import translate
|
from openlp.core.lib import translate, get_text_file_string
|
||||||
from openlp.core.lib.ui import UiStrings
|
from openlp.core.lib.ui import UiStrings
|
||||||
from openlp.core.ui.printservicedialog import Ui_PrintServiceDialog, ZoomSize
|
from openlp.core.ui.printservicedialog import Ui_PrintServiceDialog, ZoomSize
|
||||||
from openlp.core.utils import AppLocation
|
from openlp.core.utils import AppLocation
|
||||||
@ -155,8 +155,6 @@ class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog):
|
|||||||
"""
|
"""
|
||||||
html_data = html.fromstring(
|
html_data = html.fromstring(
|
||||||
u'<title>%s</title>' % unicode(self.titleLineEdit.text()))
|
u'<title>%s</title>' % unicode(self.titleLineEdit.text()))
|
||||||
style = html.Element(u'style')
|
|
||||||
style.set(u'type', u'text/css')
|
|
||||||
css_path = os.path.join(
|
css_path = os.path.join(
|
||||||
AppLocation.get_data_path(), u'servicePrint.css')
|
AppLocation.get_data_path(), u'servicePrint.css')
|
||||||
if not os.path.isfile(css_path):
|
if not os.path.isfile(css_path):
|
||||||
@ -164,96 +162,97 @@ class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog):
|
|||||||
css_file = open(css_path, u'w')
|
css_file = open(css_path, u'w')
|
||||||
css_file.write(DEFAULT_CSS)
|
css_file.write(DEFAULT_CSS)
|
||||||
css_file.close()
|
css_file.close()
|
||||||
css_file = open(css_path, u'r')
|
custom_css = get_text_file_string(css_path)
|
||||||
style.text = u' '.join(css_file.readlines())
|
style = self._addChildToParent(u'style', custom_css, html_data.head)
|
||||||
css_file.close()
|
style.set(u'type', u'text/css')
|
||||||
html_data.head.append(style)
|
self._addChildToParent(u'body', parent=html_data)
|
||||||
html_data.append(html.Element(u'body'))
|
service_title = self._addChildToParent(
|
||||||
service_title = html.Element(u'span')
|
u'span', unicode(self.titleLineEdit.text()), html_data.body)
|
||||||
service_title.set(u'class', u'serviceTitle')
|
service_title.set(u'class', u'serviceTitle')
|
||||||
service_title.text = unicode(self.titleLineEdit.text())
|
|
||||||
html_data.body.append(service_title)
|
|
||||||
for index, item in enumerate(self.serviceManager.serviceItems):
|
for index, item in enumerate(self.serviceManager.serviceItems):
|
||||||
item = item[u'service_item']
|
item = item[u'service_item']
|
||||||
div = html.Element(u'div')
|
div = self._addChildToParent(u'div', parent=html_data.body)
|
||||||
# Add the title of the service item.
|
# Add the title of the service item.
|
||||||
item_title = html.Element(u'h2')
|
item_title = self._addChildToParent(u'h2', parent=div)
|
||||||
item_title.set(u'class', u'itemTitle')
|
item_title.set(u'class', u'itemTitle')
|
||||||
icon = html.Element(u'img')
|
icon = self._addChildToParent(u'img', parent=item_title)
|
||||||
icon.set(u'src', item.icon)
|
icon.set(u'src', item.icon)
|
||||||
item_title.append(icon)
|
self._fromstring(
|
||||||
item_title.append(html.fromstring(
|
u'<span> %s</span>' % item.get_display_title(), item_title)
|
||||||
u'<span> %s</span>' % item.get_display_title()))
|
|
||||||
div.append(item_title)
|
|
||||||
if self.slideTextCheckBox.isChecked():
|
if self.slideTextCheckBox.isChecked():
|
||||||
# Add the text of the service item.
|
# Add the text of the service item.
|
||||||
if item.is_text():
|
if item.is_text():
|
||||||
verse_def = None
|
verse_def = None
|
||||||
for slide in item.get_frames():
|
for slide in item.get_frames():
|
||||||
if not verse_def or verse_def != slide[u'verseTag']:
|
if not verse_def or verse_def != slide[u'verseTag']:
|
||||||
p = html.Element(u'p')
|
p = self._addChildToParent(u'p', parent=div)
|
||||||
p.set(u'class', u'itemText')
|
p.set(u'class', u'itemText')
|
||||||
div.append(p)
|
|
||||||
else:
|
else:
|
||||||
p.append(html.Element(u'br'))
|
self._addChildToParent(u'br', parent=p)
|
||||||
p.append(html.fromstring(
|
self._fromstring(u'<span>%s</span>' % slide[u'html'], p)
|
||||||
u'<span>%s</span>' % slide[u'html']))
|
|
||||||
verse_def = slide[u'verseTag']
|
verse_def = slide[u'verseTag']
|
||||||
# Break the page before the div element.
|
# Break the page before the div element.
|
||||||
if index != 0 and self.pageBreakAfterText.isChecked():
|
if index != 0 and self.pageBreakAfterText.isChecked():
|
||||||
div.set(u'style', u'page-break-before:always')
|
div.set(u'style', u'page-break-before:always')
|
||||||
# Add the image names of the service item.
|
# Add the image names of the service item.
|
||||||
elif item.is_image():
|
elif item.is_image():
|
||||||
ol = html.Element(u'ol')
|
ol = self._addChildToParent(u'ol', parent=div)
|
||||||
for slide in range(len(item.get_frames())):
|
for slide in range(len(item.get_frames())):
|
||||||
li = html.Element(u'li')
|
self._addChildToParent(u'li', item.get_frame_title(slide), ol)
|
||||||
li.text = item.get_frame_title(slide)
|
|
||||||
ol.append(li)
|
|
||||||
div.append(ol)
|
|
||||||
# add footer
|
# add footer
|
||||||
if item.foot_text:
|
if item.foot_text:
|
||||||
p = html.fromstring(item.foot_text)
|
p = self._fromstring(item.foot_text, div)
|
||||||
p.set(u'class', u'itemFooter')
|
p.set(u'class', u'itemFooter')
|
||||||
div.append(p)
|
|
||||||
# Add service items' notes.
|
# Add service items' notes.
|
||||||
if self.notesCheckBox.isChecked():
|
if self.notesCheckBox.isChecked():
|
||||||
if item.notes:
|
if item.notes:
|
||||||
p = html.Element(u'p')
|
p = self._addChildToParent(u'p', parent=div)
|
||||||
title = html.Element(u'span')
|
title = self._addChildToParent(u'span', unicode(
|
||||||
|
translate('OpenLP.ServiceManager', 'Notes:')), p)
|
||||||
title.set(u'class', u'itemNotesTitle')
|
title.set(u'class', u'itemNotesTitle')
|
||||||
title.text = unicode(
|
text = self._fromstring(u'<span> %s</span>' %
|
||||||
translate('OpenLP.ServiceManager', 'Notes:'))
|
item.notes.replace(u'\n', u'<br />'), p)
|
||||||
p.append(title)
|
|
||||||
text = html.fromstring(u'<span> %s</span>' %
|
|
||||||
item.notes.replace(u'\n', u'<br />'))
|
|
||||||
text.set(u'class', u'itemNotesText')
|
text.set(u'class', u'itemNotesText')
|
||||||
p.append(text)
|
|
||||||
div.append(p)
|
|
||||||
# Add play length of media files.
|
# Add play length of media files.
|
||||||
if item.is_media() and self.metaDataCheckBox.isChecked():
|
if item.is_media() and self.metaDataCheckBox.isChecked():
|
||||||
tme = item.media_length
|
tme = item.media_length
|
||||||
if item.end_time > 0:
|
if item.end_time > 0:
|
||||||
tme = item.end_time - item.start_time
|
tme = item.end_time - item.start_time
|
||||||
p = html.fromstring(u'<p><strong>%s</strong> </p>' %
|
title = self._fromstring(u'<p><strong>%s</strong> </p>' %
|
||||||
translate('OpenLP.ServiceManager', 'Playing time:'))
|
translate('OpenLP.ServiceManager', 'Playing time:'), div)
|
||||||
p.append(html.fromstring(u'<span>%s</span>' %
|
self._fromstring(u'<span>%s</span>' %
|
||||||
unicode(datetime.timedelta(seconds=tme))))
|
unicode(datetime.timedelta(seconds=tme)), title)
|
||||||
div.append(p)
|
|
||||||
html_data.body.append(div)
|
|
||||||
# Add the custom service notes:
|
# Add the custom service notes:
|
||||||
if self.footerTextEdit.toPlainText():
|
if self.footerTextEdit.toPlainText():
|
||||||
title = html.Element(u'span')
|
footer_title = self._addChildToParent(u'span', translate(
|
||||||
title.set(u'class', u'customNotesTitle')
|
'OpenLP.ServiceManager', u'Custom Service Notes:'), div)
|
||||||
title.text = unicode(
|
footer_title.set(u'class', u'customNotesTitle')
|
||||||
translate('OpenLP.ServiceManager', u'Custom Service Notes:'))
|
footer_text = self._addChildToParent(u'span',
|
||||||
div.append(title)
|
u' %s' % self.footerTextEdit.toPlainText(), div)
|
||||||
text = html.Element(u'span')
|
footer_text.set(u'class', u'customNotesText')
|
||||||
text.set(u'class', u'customNotesText')
|
|
||||||
text.text = u' %s' % self.footerTextEdit.toPlainText()
|
|
||||||
div.append(text)
|
|
||||||
self.document.setHtml(html.tostring(html_data))
|
self.document.setHtml(html.tostring(html_data))
|
||||||
self.previewWidget.updatePreview()
|
self.previewWidget.updatePreview()
|
||||||
|
|
||||||
|
def _addChildToParent(self, tag, text=None, parent=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.
|
||||||
|
"""
|
||||||
|
element = html.Element(tag)
|
||||||
|
if text is not None:
|
||||||
|
element.text = text
|
||||||
|
if parent is not None:
|
||||||
|
parent.append(element)
|
||||||
|
return element
|
||||||
|
|
||||||
|
def _fromstring(self, string, parent):
|
||||||
|
"""
|
||||||
|
This is used to create a child html element from a string.
|
||||||
|
"""
|
||||||
|
element = html.fromstring(string)
|
||||||
|
parent.append(element)
|
||||||
|
return element
|
||||||
|
|
||||||
def paintRequested(self, printer):
|
def paintRequested(self, printer):
|
||||||
"""
|
"""
|
||||||
Paint the preview of the *self.document*.
|
Paint the preview of the *self.document*.
|
||||||
|
Loading…
Reference in New Issue
Block a user