forked from openlp/openlp
Theme updates
This commit is contained in:
parent
6421e18bba
commit
ede8ae6f09
@ -81,6 +81,16 @@ HTMLSRC = u"""
|
||||
</html>
|
||||
"""
|
||||
def build_html(item, screen, alert):
|
||||
"""
|
||||
Build the full web paged structure for display
|
||||
|
||||
`item`
|
||||
Service Item to be displayed
|
||||
`screen`
|
||||
Current display information
|
||||
`alert`
|
||||
Alert display display information
|
||||
"""
|
||||
width = screen[u'size'].width()
|
||||
height = screen[u'size'].height()
|
||||
html = HTMLSRC % (build_video(width, height),
|
||||
@ -91,10 +101,17 @@ def build_html(item, screen, alert):
|
||||
build_image(width, height),
|
||||
build_blank(width, height),
|
||||
build_image_src(item.bg_frame))
|
||||
print html
|
||||
return html
|
||||
|
||||
def build_video(width, height):
|
||||
"""
|
||||
Build the video display div
|
||||
|
||||
`width`
|
||||
Screen width
|
||||
`height`
|
||||
Screen height
|
||||
"""
|
||||
video = """
|
||||
#video {
|
||||
position: absolute;
|
||||
@ -108,6 +125,14 @@ def build_video(width, height):
|
||||
return video % (width, height)
|
||||
|
||||
def build_blank(width, height):
|
||||
"""
|
||||
Build the blank display div
|
||||
|
||||
`width`
|
||||
Screen width
|
||||
`height`
|
||||
Screen height
|
||||
"""
|
||||
blank = """
|
||||
#blank {
|
||||
position: absolute;
|
||||
@ -121,6 +146,14 @@ def build_blank(width, height):
|
||||
return blank % (width, height)
|
||||
|
||||
def build_image(width, height):
|
||||
"""
|
||||
Build the image display div
|
||||
|
||||
`width`
|
||||
Screen width
|
||||
`height`
|
||||
Screen height
|
||||
"""
|
||||
image = """
|
||||
#image {
|
||||
position: absolute;
|
||||
@ -141,6 +174,12 @@ def build_image_src(image):
|
||||
return image_src % image_to_byte(image)
|
||||
|
||||
def build_lyrics(item):
|
||||
"""
|
||||
Build the video display div
|
||||
|
||||
`item`
|
||||
Service Item containing theme and location information
|
||||
"""
|
||||
lyrics = """
|
||||
#lyrics {position: absolute; %s z-index:3; %s; %s %s }
|
||||
table {border=0;margin=0padding=0;}
|
||||
|
@ -185,8 +185,7 @@ class RenderManager(object):
|
||||
footer.append(u'Amazing Grace (John Newton)' )
|
||||
footer.append(u'Public Domain')
|
||||
footer.append(u'CCLI 123456')
|
||||
formatted = self.renderer.format_slide(verse, False)
|
||||
#Only Render the first slide page returned
|
||||
# build a service item to generate preview
|
||||
serviceItem = ServiceItem()
|
||||
serviceItem.add_from_text(u'', verse, u'')
|
||||
serviceItem.render_manager = self
|
||||
@ -194,8 +193,7 @@ class RenderManager(object):
|
||||
serviceItem.raw_footer = footer
|
||||
self.display.buildHtml(serviceItem)
|
||||
frame, raw_html = serviceItem.get_rendered_frame(0)
|
||||
frame = self.display.text(raw_html)
|
||||
return frame
|
||||
return self.display.text(raw_html)
|
||||
|
||||
def format_slide(self, words):
|
||||
"""
|
||||
@ -208,22 +206,19 @@ class RenderManager(object):
|
||||
self.build_text_rectangle(self.themedata)
|
||||
return self.renderer.format_slide(words, False)
|
||||
|
||||
def generate_slide(self, main_text, footer_text):
|
||||
"""
|
||||
Generate the actual slide image.
|
||||
|
||||
``main_text``
|
||||
The text for the main area of the slide.
|
||||
|
||||
``footer_text``
|
||||
The text for the slide footer.
|
||||
"""
|
||||
log.debug(u'generate slide')
|
||||
self.build_text_rectangle(self.themedata)
|
||||
self.renderer.set_frame_dest(self.width, self.height)
|
||||
image = self.previewDisplay.preview(self.renderer.bg_frame,
|
||||
main_text[0], self.themedata)
|
||||
return image
|
||||
# def generate_slide(self, main_text):
|
||||
# """
|
||||
# Generate the actual slide image.
|
||||
#
|
||||
# ``main_text``
|
||||
# The text for the main area of the slide.
|
||||
# """
|
||||
# log.debug(u'generate slide')
|
||||
# self.build_text_rectangle(self.themedata)
|
||||
# self.renderer.set_frame_dest(self.width, self.height)
|
||||
# image = self.previewDisplay.preview(self.renderer.bg_frame,
|
||||
# main_text[0], self.themedata)
|
||||
# return image
|
||||
|
||||
def calculate_default(self, screen):
|
||||
"""
|
||||
|
@ -94,6 +94,8 @@ class ServiceItem(object):
|
||||
#self.cache = {}
|
||||
self.icon = None
|
||||
self.themedata = None
|
||||
self.main = None
|
||||
self.footer = None
|
||||
|
||||
def add_capability(self, capability):
|
||||
"""
|
||||
@ -178,11 +180,7 @@ class ServiceItem(object):
|
||||
has generated by the render method above.
|
||||
"""
|
||||
log.debug(u'render individual')
|
||||
# if self.theme is None:
|
||||
# bg_image = self.render_manager.set_override_theme(None)
|
||||
# else:
|
||||
# bg_image = self.render_manager.set_override_theme(self.theme)
|
||||
raw_html = self._display_frames[row][u'text'].split(u'\n')
|
||||
return self._display_frames[row][u'text'].split(u'\n')[0]
|
||||
# if self.cache.get(row):
|
||||
# frame = self.cache[row]
|
||||
# else:
|
||||
@ -191,9 +189,9 @@ class ServiceItem(object):
|
||||
# self.raw_footer)
|
||||
# else:
|
||||
# frame = self.render_manager.generate_slide(raw_html, u'')
|
||||
frame = None
|
||||
#self.cache[row] = frame
|
||||
return frame, raw_html[0]
|
||||
# frame = None
|
||||
# #self.cache[row] = frame
|
||||
# return raw_html[0]
|
||||
|
||||
def add_from_image(self, path, title, image):
|
||||
"""
|
||||
@ -380,7 +378,7 @@ class ServiceItem(object):
|
||||
renders it if required.
|
||||
"""
|
||||
if self.service_item_type == ServiceItemType.Text:
|
||||
return self.render_individual(row)
|
||||
return None, self.render_individual(row)
|
||||
else:
|
||||
return self._raw_frames[row][u'image'], u''
|
||||
|
||||
|
@ -169,6 +169,7 @@ class MainDisplay(DisplayWidget):
|
||||
`slide`
|
||||
The slide text to be displayed
|
||||
"""
|
||||
log.debug(u'text')
|
||||
print slide
|
||||
self.frame.findFirstElement('div#lyrics').setInnerXml(slide)
|
||||
return self.preview()
|
||||
@ -180,6 +181,7 @@ class MainDisplay(DisplayWidget):
|
||||
`slide`
|
||||
The slide text to be displayed
|
||||
"""
|
||||
log.debug(u'alert')
|
||||
self.frame.findFirstElement('div#alert').setInnerXml(self.alerttext)
|
||||
|
||||
def image(self, image):
|
||||
@ -190,6 +192,7 @@ class MainDisplay(DisplayWidget):
|
||||
`Image`
|
||||
The Image to be displayed can be QImage or QPixmap
|
||||
"""
|
||||
log.debug(u'image')
|
||||
image = resize_image(image, self.screen[u'size'].width(),
|
||||
self.screen[u'size'].height())
|
||||
self.frame.evaluateJavaScript(
|
||||
@ -200,10 +203,12 @@ class MainDisplay(DisplayWidget):
|
||||
'src', unicode('data:image/png;base64,%s' % image_to_byte(image)))
|
||||
|
||||
def reset(self):
|
||||
log.debug(u'reset')
|
||||
self.frame.findFirstElement('img').setAttribute(
|
||||
'src', unicode('data:image/png;base64,%s' % image_to_byte(self.serviceItem.bg_frame)))
|
||||
|
||||
def video(self, videoPath, noSound=False):
|
||||
log.debug(u'video')
|
||||
self.frame.findFirstElement('video').setAttribute('src', videoPath)
|
||||
self.frame.evaluateJavaScript(
|
||||
"document.getElementById('video').style.visibility = 'visible'")
|
||||
@ -214,9 +219,13 @@ class MainDisplay(DisplayWidget):
|
||||
self.frame.evaluateJavaScript("document.getElementById('video').mute()")
|
||||
|
||||
def loaded(self):
|
||||
"""
|
||||
Called by webView event to show display is fully loaded
|
||||
"""
|
||||
self.loaded = True
|
||||
|
||||
def preview(self):
|
||||
log.debug(u'preview')
|
||||
# Wait for the webview to update before geting the preview.
|
||||
# Important otherwise first preview will miss the background !
|
||||
while not self.loaded:
|
||||
@ -238,6 +247,7 @@ class MainDisplay(DisplayWidget):
|
||||
Store the serviceItem and build the new HTML from it. Add the
|
||||
HTML to the display
|
||||
"""
|
||||
log.debug(u'buildHtml')
|
||||
self.loaded = False
|
||||
self.serviceItem = serviceItem
|
||||
html = build_html(self.serviceItem, self.screen, None)
|
||||
|
@ -661,8 +661,7 @@ class ThemeManager(QtGui.QWidget):
|
||||
Call the RenderManager to build a Sample Image
|
||||
"""
|
||||
log.debug(u'generateImage %s ', themedata)
|
||||
frame = self.parent.RenderManager.generate_preview(themedata)
|
||||
return frame
|
||||
return self.parent.RenderManager.generate_preview(themedata)
|
||||
|
||||
def getPreviewImage(self, theme):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user