openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #03661
[Merge] lp:~j-corwin/openlp/render into lp:openlp
Jonathan Corwin has proposed merging lp:~j-corwin/openlp/render into lp:openlp.
Requested reviews:
OpenLP Core (openlp-core)
Related bugs:
#616955 Theme Footer position in regard to its font size
https://bugs.launchpad.net/bugs/616955
#630233 Bars at the top and bottom of the projection screen show desktop
https://bugs.launchpad.net/bugs/630233
#633524 Song footer cannot be left aligned/justified when the lyrics aren't horizontally aligned to the left
https://bugs.launchpad.net/bugs/633524
#633527 Footer text wraps off the screen
https://bugs.launchpad.net/bugs/633527
Address some rendering/speed issues
--
https://code.launchpad.net/~j-corwin/openlp/render/+merge/35964
Your team OpenLP Core is requested to review the proposed merge of lp:~j-corwin/openlp/render into lp:openlp.
=== modified file 'openlp/core/lib/__init__.py'
--- openlp/core/lib/__init__.py 2010-09-14 14:21:44 +0000
+++ openlp/core/lib/__init__.py 2010-09-19 21:15:53 +0000
@@ -220,6 +220,7 @@
``image``
The image to converted.
"""
+ log.debug(u'image_to_byte')
byte_array = QtCore.QByteArray()
# use buffer to store pixmap into byteArray
buffie = QtCore.QBuffer(byte_array)
@@ -249,6 +250,7 @@
The background colour defaults to black.
"""
+ log.debug(u'resize_image')
preview = QtGui.QImage(image)
if not preview.isNull():
# Only resize if different size
=== modified file 'openlp/core/lib/htmlbuilder.py'
--- openlp/core/lib/htmlbuilder.py 2010-09-11 21:40:14 +0000
+++ openlp/core/lib/htmlbuilder.py 2010-09-19 21:15:53 +0000
@@ -27,8 +27,6 @@
import logging
from PyQt4 import QtWebKit
-from openlp.core.lib import image_to_byte
-
log = logging.getLogger(__name__)
HTMLSRC = u"""
@@ -274,7 +272,7 @@
</script>
</head>
<body>
-<img id="image" class="size" src="%s" />
+<img id="image" class="size" %s />
<video id="video" class="size"></video>
%s
<div id="footer" class="footer"></div>
@@ -301,10 +299,10 @@
height = screen[u'size'].height()
theme = item.themedata
webkitvers = webkit_version()
- if item.bg_frame:
- image = u'data:image/png;base64,%s' % image_to_byte(item.bg_frame)
+ if item.bg_image_bytes:
+ image = u'src="data:image/png;base64,%s"' % item.bg_image_bytes
else:
- image = u''
+ image = u'style="display:none;"'
html = HTMLSRC % (build_background_css(item, width, height),
width, height,
build_alert_css(alert, width),
=== modified file 'openlp/core/lib/renderer.py'
--- openlp/core/lib/renderer.py 2010-09-04 16:14:56 +0000
+++ openlp/core/lib/renderer.py 2010-09-19 21:15:53 +0000
@@ -32,7 +32,8 @@
from PyQt4 import QtGui, QtCore, QtWebKit
from openlp.core.lib import resize_image, expand_tags, \
- build_lyrics_format_css, build_lyrics_outline_css
+ build_lyrics_format_css, build_lyrics_outline_css, image_to_byte
+
log = logging.getLogger(__name__)
@@ -54,6 +55,7 @@
self.frame = None
self.bg_frame = None
self.bg_image = None
+ self.bg_image_bytes = None
def set_theme(self, theme):
"""
@@ -66,15 +68,12 @@
self._theme = theme
self.bg_frame = None
self.bg_image = None
+ self.bg_image_bytes = None
self._bg_image_filename = None
self.theme_name = theme.theme_name
if theme.background_type == u'image':
if theme.background_filename:
self._bg_image_filename = unicode(theme.background_filename)
- if self.frame:
- self.bg_image = resize_image(self._bg_image_filename,
- self.frame.width(),
- self.frame.height())
def set_text_rectangle(self, rect_main, rect_footer):
"""
@@ -88,7 +87,23 @@
"""
log.debug(u'set_text_rectangle %s , %s' % (rect_main, rect_footer))
self._rect = rect_main
- self._rect_footer = rect_footer
+ self._rect_footer = rect_footer
+ self.page_width = self._rect.width()
+ self.page_height = self._rect.height()
+ if self._theme.display_shadow:
+ self.page_width -= int(self._theme.display_shadow_size)
+ self.page_height -= int(self._theme.display_shadow_size)
+ self.web = QtWebKit.QWebView()
+ self.web.setVisible(False)
+ self.web.resize(self.page_width, self.page_height)
+ self.web_frame = self.web.page().mainFrame()
+ # Adjust width and height to account for shadow. outline done in css
+ self.page_shell = u'<html><head><style>' \
+ u'*{margin: 0; padding: 0; border: 0;} '\
+ u'#main {position:absolute; top:0px; %s %s}</style><body>' \
+ u'<div id="main">' % \
+ (build_lyrics_format_css(self._theme, self.page_width,
+ self.page_height), build_lyrics_outline_css(self._theme))
def set_frame_dest(self, frame_width, frame_height):
"""
@@ -110,15 +125,18 @@
self.frame.width(), self.frame.height())
if self._theme.background_type == u'image':
self.bg_frame = QtGui.QImage(self.frame.width(),
- self.frame.height(), QtGui.QImage.Format_ARGB32_Premultiplied)
+ self.frame.height(),
+ QtGui.QImage.Format_ARGB32_Premultiplied)
painter = QtGui.QPainter()
painter.begin(self.bg_frame)
painter.fillRect(self.frame.rect(), QtCore.Qt.black)
if self.bg_image:
painter.drawImage(0, 0, self.bg_image)
painter.end()
+ self.bg_image_bytes = image_to_byte(self.bg_frame)
else:
self.bg_frame = None
+ self.bg_image_bytes = None
def format_slide(self, words, line_break):
"""
@@ -139,29 +157,16 @@
lines = verse.split(u'\n')
for line in lines:
text.append(line)
- web = QtWebKit.QWebView()
- web.resize(self._rect.width(), self._rect.height())
- web.setVisible(False)
- frame = web.page().mainFrame()
- # Adjust width and height to account for shadow. outline done in css
- width = self._rect.width() - int(self._theme.display_shadow_size)
- height = self._rect.height() - int(self._theme.display_shadow_size)
- shell = u'<html><head><style>#main {%s %s}</style><body>' \
- u'<div id="main">' % \
- (build_lyrics_format_css(self._theme, width, height),
- build_lyrics_outline_css(self._theme))
formatted = []
html_text = u''
styled_text = u''
- js_height = 'document.getElementById("main").scrollHeight'
for line in text:
styled_line = expand_tags(line) + line_end
styled_text += styled_line
- html = shell + styled_text + u'</div></body></html>'
- web.setHtml(html)
+ html = self.page_shell + styled_text + u'</div></body></html>'
+ self.web.setHtml(html)
# Text too long so go to next page
- text_height = int(frame.evaluateJavaScript(js_height).toString())
- if text_height > height:
+ if self.web_frame.contentsSize().height() > self.page_height:
formatted.append(html_text)
html_text = u''
styled_text = styled_line
=== modified file 'openlp/core/lib/rendermanager.py'
--- openlp/core/lib/rendermanager.py 2010-09-05 16:11:50 +0000
+++ openlp/core/lib/rendermanager.py 2010-09-19 21:15:53 +0000
@@ -223,7 +223,6 @@
The words to go on the slides.
"""
log.debug(u'format slide')
- self.build_text_rectangle(self.themedata)
return self.renderer.format_slide(words, line_break)
def calculate_default(self, screen):
=== modified file 'openlp/core/lib/serviceitem.py'
--- openlp/core/lib/serviceitem.py 2010-09-08 20:38:37 +0000
+++ openlp/core/lib/serviceitem.py 2010-09-19 21:15:53 +0000
@@ -97,7 +97,7 @@
self.themedata = None
self.main = None
self.footer = None
- self.bg_frame = None
+ self.bg_image_bytes = None
def _new_item(self):
"""
@@ -145,7 +145,7 @@
"""
log.debug(u'Render called')
self._display_frames = []
- self.bg_frame = None
+ self.bg_image_bytes = None
line_break = True
if self.is_capable(ItemCapabilities.NoLineBreaks):
line_break = False
@@ -156,7 +156,7 @@
theme = self.theme
self.main, self.footer = \
self.render_manager.set_override_theme(theme, useOverride)
- self.bg_frame = self.render_manager.renderer.bg_frame
+ self.bg_image_bytes = self.render_manager.renderer.bg_image_bytes
self.themedata = self.render_manager.renderer._theme
for slide in self._raw_frames:
before = time.time()
=== modified file 'openlp/core/ui/maindisplay.py'
--- openlp/core/ui/maindisplay.py 2010-09-14 17:29:56 +0000
+++ openlp/core/ui/maindisplay.py 2010-09-19 21:15:53 +0000
@@ -99,6 +99,7 @@
self.alertTab = None
self.hide_mode = None
self.setWindowTitle(u'OpenLP Display')
+ self.setStyleSheet(u'border: 0px; margin: 0px; padding: 0px;')
self.setWindowFlags(QtCore.Qt.FramelessWindowHint |
QtCore.Qt.WindowStaysOnTopHint)
if self.isLive:
@@ -116,12 +117,18 @@
self.screen = self.screens.current
self.setVisible(False)
self.setGeometry(self.screen[u'size'])
- self.scene = QtGui.QGraphicsScene()
- self.setScene(self.scene)
- self.webView = QtWebKit.QGraphicsWebView()
- self.scene.addItem(self.webView)
- self.webView.resize(self.screen[u'size'].width(),
- self.screen[u'size'].height())
+ try:
+ self.webView = QtWebKit.QGraphicsWebView()
+ self.scene = QtGui.QGraphicsScene(self)
+ self.setScene(self.scene)
+ self.scene.addItem(self.webView)
+ self.webView.setGeometry(QtCore.QRectF(0, 0,
+ self.screen[u'size'].width(), self.screen[u'size'].height()))
+ except AttributeError:
+ # QGraphicsWebView a recent addition, so fall back to QWebView
+ self.webView = QtWebKit.QWebView(self)
+ self.webView.setGeometry(0, 0,
+ self.screen[u'size'].width(), self.screen[u'size'].height())
self.page = self.webView.page()
self.frame = self.page.mainFrame()
QtCore.QObject.connect(self.webView,
@@ -306,6 +313,7 @@
# We must have a service item to preview
if not hasattr(self, u'serviceItem'):
return
+ Receiver.send_message(u'openlp_process_events')
if self.isLive:
# Wait for the fade to finish before geting the preview.
# Important otherwise preview will have incorrect text if at all !
@@ -318,6 +326,8 @@
# Important otherwise first preview will miss the background !
while not self.loaded:
Receiver.send_message(u'openlp_process_events')
+ if self.isLive:
+ self.setVisible(True)
preview = QtGui.QImage(self.screen[u'size'].width(),
self.screen[u'size'].height(),
QtGui.QImage.Format_ARGB32_Premultiplied)
@@ -326,8 +336,6 @@
self.frame.render(painter)
painter.end()
# Make display show up if in single screen mode
- if self.isLive:
- self.setVisible(True)
return preview
def buildHtml(self, serviceItem):
@@ -341,7 +349,9 @@
self.serviceItem = serviceItem
html = build_html(self.serviceItem, self.screen, self.parent.alertTab,
self.isLive)
+ log.debug(u'buildHtml - pre setHtml')
self.webView.setHtml(html)
+ log.debug(u'buildHtml - post setHtml')
if serviceItem.foot_text and serviceItem.foot_text:
self.footer(serviceItem.foot_text)
# if was hidden keep it hidden
=== modified file 'openlp/core/ui/slidecontroller.py'
--- openlp/core/ui/slidecontroller.py 2010-09-18 15:24:39 +0000
+++ openlp/core/ui/slidecontroller.py 2010-09-19 21:15:53 +0000
@@ -637,9 +637,9 @@
"""
if not self.serviceItem:
return
- Receiver.send_message(u'%s_first' % self.serviceItem.name.lower(),
- [self.serviceItem, self.isLive])
if self.serviceItem.is_command():
+ Receiver.send_message(u'%s_first' % self.serviceItem.name.lower(),
+ [self.serviceItem, self.isLive])
self.updatePreview()
else:
self.PreviewListWidget.selectRow(0)
@@ -652,9 +652,9 @@
index = int(message[0])
if not self.serviceItem:
return
- Receiver.send_message(u'%s_slide' % self.serviceItem.name.lower(),
- [self.serviceItem, self.isLive, index])
if self.serviceItem.is_command():
+ Receiver.send_message(u'%s_slide' % self.serviceItem.name.lower(),
+ [self.serviceItem, self.isLive, index])
self.updatePreview()
else:
self.PreviewListWidget.selectRow(index)
@@ -769,9 +769,9 @@
row = self.PreviewListWidget.currentRow()
self.selectedRow = 0
if row > -1 and row < self.PreviewListWidget.rowCount():
- Receiver.send_message(u'%s_slide' % self.serviceItem.name.lower(),
- [self.serviceItem, self.isLive, row])
if self.serviceItem.is_command() and self.isLive:
+ Receiver.send_message(u'%s_slide' % self.serviceItem.name.lower(),
+ [self.serviceItem, self.isLive, row])
self.updatePreview()
else:
frame, raw_html = self.serviceItem.get_rendered_frame(row)
Follow ups