This commit is contained in:
Tim Bentley 2011-09-27 18:48:35 +01:00
commit 8e8e76e708
4 changed files with 29 additions and 33 deletions

View File

@ -34,8 +34,8 @@ from openlp.core.lib.theme import BackgroundType, BackgroundGradientType, \
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
# FIXME: Add html5 doctype. However, do not break theme gradients.
HTMLSRC = u""" HTMLSRC = u"""
<!DOCTYPE html>
<html> <html>
<head> <head>
<title>OpenLP Display</title> <title>OpenLP Display</title>
@ -404,7 +404,7 @@ def build_background_css(item, width, height):
background = \ background = \
u'background: ' \ u'background: ' \
u'-webkit-gradient(linear, left top, left bottom, ' \ u'-webkit-gradient(linear, left top, left bottom, ' \
'from(%s), to(%s))' % (theme.background_start_color, 'from(%s), to(%s)) fixed' % (theme.background_start_color,
theme.background_end_color) theme.background_end_color)
elif theme.background_direction == \ elif theme.background_direction == \
BackgroundGradientType.to_string( \ BackgroundGradientType.to_string( \
@ -412,7 +412,7 @@ def build_background_css(item, width, height):
background = \ background = \
u'background: ' \ u'background: ' \
u'-webkit-gradient(linear, left top, right bottom, ' \ u'-webkit-gradient(linear, left top, right bottom, ' \
'from(%s), to(%s))' % (theme.background_start_color, 'from(%s), to(%s)) fixed' % (theme.background_start_color,
theme.background_end_color) theme.background_end_color)
elif theme.background_direction == \ elif theme.background_direction == \
BackgroundGradientType.to_string \ BackgroundGradientType.to_string \
@ -420,20 +420,21 @@ def build_background_css(item, width, height):
background = \ background = \
u'background: ' \ u'background: ' \
u'-webkit-gradient(linear, left bottom, right top, ' \ u'-webkit-gradient(linear, left bottom, right top, ' \
'from(%s), to(%s))' % (theme.background_start_color, 'from(%s), to(%s)) fixed' % (theme.background_start_color,
theme.background_end_color) theme.background_end_color)
elif theme.background_direction == \ elif theme.background_direction == \
BackgroundGradientType.to_string \ BackgroundGradientType.to_string \
(BackgroundGradientType.Vertical): (BackgroundGradientType.Vertical):
background = \ background = \
u'background: -webkit-gradient(linear, left top, ' \ u'background: -webkit-gradient(linear, left top, ' \
u'right top, from(%s), to(%s))' % \ u'right top, from(%s), to(%s)) fixed' % \
(theme.background_start_color, theme.background_end_color) (theme.background_start_color, theme.background_end_color)
else: else:
background = \ background = \
u'background: -webkit-gradient(radial, %s 50%%, 100, %s ' \ u'background: -webkit-gradient(radial, %s 50%%, 100, %s ' \
u'50%%, %s, from(%s), to(%s))' % (width, width, width, u'50%%, %s, from(%s), to(%s)) fixed' % (width, width,
theme.background_start_color, theme.background_end_color) width, theme.background_start_color,
theme.background_end_color)
return background return background
def build_lyrics_css(item, webkitvers): def build_lyrics_css(item, webkitvers):

View File

@ -44,6 +44,7 @@ VERSE = u'The Lord said to {r}Noah{/r}: \n' \
'Get those children out of the muddy, muddy \n' \ 'Get those children out of the muddy, muddy \n' \
'{r}C{/r}{b}h{/b}{bl}i{/bl}{y}l{/y}{g}d{/g}{pk}' \ '{r}C{/r}{b}h{/b}{bl}i{/bl}{y}l{/y}{g}d{/g}{pk}' \
'r{/pk}{o}e{/o}{pp}n{/pp} of the Lord\n' 'r{/pk}{o}e{/o}{pp}n{/pp} of the Lord\n'
VERSE_FOR_LINE_COUNT = u'\n'.join(map(unicode, xrange(50)))
FOOTER = [u'Arky Arky (Unknown)', u'Public Domain', u'CCLI 123456'] FOOTER = [u'Arky Arky (Unknown)', u'Public Domain', u'CCLI 123456']
class Renderer(object): class Renderer(object):
@ -190,7 +191,7 @@ class Renderer(object):
serviceItem.theme = theme_data serviceItem.theme = theme_data
if self.force_page: if self.force_page:
# make big page for theme edit dialog to get line count # make big page for theme edit dialog to get line count
serviceItem.add_from_text(u'', VERSE + VERSE + VERSE) serviceItem.add_from_text(u'', VERSE_FOR_LINE_COUNT)
else: else:
self.imageManager.del_image(theme_data.theme_name) self.imageManager.del_image(theme_data.theme_name)
serviceItem.add_from_text(u'', VERSE) serviceItem.add_from_text(u'', VERSE)
@ -224,14 +225,10 @@ class Renderer(object):
# Bibles # Bibles
if item.is_capable(ItemCapabilities.CanWordSplit): if item.is_capable(ItemCapabilities.CanWordSplit):
pages = self._paginate_slide_words(text.split(u'\n'), line_end) pages = self._paginate_slide_words(text.split(u'\n'), line_end)
else: # Songs and Custom
# Clean up line endings. elif item.is_capable(ItemCapabilities.CanSoftBreak):
lines = self._lines_split(text) pages = []
pages = self._paginate_slide(lines, line_end) if u'[---]' in text:
# Songs and Custom
if item.is_capable(ItemCapabilities.CanSoftBreak) and \
len(pages) > 1 and u'[---]' in text:
pages = []
while True: while True:
slides = text.split(u'\n[---]\n', 2) slides = text.split(u'\n[---]\n', 2)
# If there are (at least) two occurrences of [---] we use # If there are (at least) two occurrences of [---] we use
@ -272,6 +269,11 @@ class Renderer(object):
lines = text.strip(u'\n').split(u'\n') lines = text.strip(u'\n').split(u'\n')
pages.extend(self._paginate_slide(lines, line_end)) pages.extend(self._paginate_slide(lines, line_end))
break break
else:
# Clean up line endings.
pages = self._paginate_slide(text.split(u'\n'), line_end)
else:
pages = self._paginate_slide(text.split(u'\n'), line_end)
new_pages = [] new_pages = []
for page in pages: for page in pages:
while page.endswith(u'<br>'): while page.endswith(u'<br>'):
@ -585,12 +587,3 @@ class Renderer(object):
# this parse we are to be wordy # this parse we are to be wordy
line = line.replace(u'\n', u' ') line = line.replace(u'\n', u' ')
return line.split(u' ') return line.split(u' ')
def _lines_split(self, text):
"""
Split the slide up by physical line
"""
# this parse we do not want to use this so remove it
text = text.replace(u'\n[---]', u'')
text = text.replace(u'[---]', u'')
return text.split(u'\n')

View File

@ -660,14 +660,17 @@ class ServiceManager(QtGui.QWidget):
for item in items: for item in items:
self.mainwindow.incrementProgressBar() self.mainwindow.incrementProgressBar()
serviceItem = ServiceItem() serviceItem = ServiceItem()
serviceItem.from_service = True
serviceItem.renderer = self.mainwindow.renderer serviceItem.renderer = self.mainwindow.renderer
serviceItem.set_from_service(item, self.servicePath) serviceItem.set_from_service(item, self.servicePath)
self.validateItem(serviceItem) self.validateItem(serviceItem)
self.addServiceItem(serviceItem, repaint=False) self.loadItem_uuid = 0
if serviceItem.is_capable(ItemCapabilities.OnLoadUpdate): if serviceItem.is_capable(ItemCapabilities.OnLoadUpdate):
Receiver.send_message(u'%s_service_load' % Receiver.send_message(u'%s_service_load' %
serviceItem.name.lower(), serviceItem) serviceItem.name.lower(), serviceItem)
# if the item has been processed
if serviceItem._uuid == self.loadItem_uuid:
serviceItem.edit_id = int(self.loadItem_editId)
self.addServiceItem(serviceItem, repaint=False)
delete_file(p_file) delete_file(p_file)
self.setFileName(fileName) self.setFileName(fileName)
self.mainwindow.addRecentFile(fileName) self.mainwindow.addRecentFile(fileName)
@ -1122,12 +1125,10 @@ class ServiceManager(QtGui.QWidget):
def serviceItemUpdate(self, message): def serviceItemUpdate(self, message):
""" """
Triggered from plugins to update service items. Triggered from plugins to update service items.
Save the values as they will be used as part of the service load
""" """
editId, uuid = message.split(u':') editId, self.loadItem_uuid = message.split(u':')
for item in self.serviceItems: self.loadItem_editId = int(editId)
if item[u'service_item']._uuid == uuid:
item[u'service_item'].edit_id = int(editId)
self.setModified()
def replaceServiceItem(self, newItem): def replaceServiceItem(self, newItem):
""" """

View File

@ -510,7 +510,8 @@ class SongMediaItem(MediaManagerItem):
# Add the audio file to the service item. # Add the audio file to the service item.
if len(song.media_files) > 0: if len(song.media_files) > 0:
service_item.add_capability(ItemCapabilities.HasBackgroundAudio) service_item.add_capability(ItemCapabilities.HasBackgroundAudio)
service_item.background_audio = [m.file_name for m in song.media_files] service_item.background_audio = \
[m.file_name for m in song.media_files]
return True return True
def serviceLoad(self, item): def serviceLoad(self, item):