forked from openlp/openlp
Renderer Fixes
bzr-revno: 559
This commit is contained in:
commit
97131a3dbc
@ -153,18 +153,15 @@ class Renderer(object):
|
|||||||
The footer of the slide.
|
The footer of the slide.
|
||||||
"""
|
"""
|
||||||
log.debug(u'format_slide - Start')
|
log.debug(u'format_slide - Start')
|
||||||
# print words
|
|
||||||
verses = []
|
verses = []
|
||||||
words = words.replace(u'\r\n', u'\n')
|
words = words.replace(u'\r\n', u'\n')
|
||||||
verses_text = words.split(u'\n')
|
verses_text = words.split(u'\n')
|
||||||
#print verses_text
|
|
||||||
text = []
|
text = []
|
||||||
for verse in verses_text:
|
for verse in verses_text:
|
||||||
lines = verse.split(u'\n')
|
lines = verse.split(u'\n')
|
||||||
for line in lines:
|
for line in lines:
|
||||||
text.append(line)
|
text.append(line)
|
||||||
split_text = self.pre_render_text(text)
|
split_text = self.pre_render_text(text)
|
||||||
# print split_text
|
|
||||||
log.debug(u'format_slide - End')
|
log.debug(u'format_slide - End')
|
||||||
return split_text
|
return split_text
|
||||||
|
|
||||||
@ -173,33 +170,27 @@ class Renderer(object):
|
|||||||
#take the width work out approx how many characters and add 50%
|
#take the width work out approx how many characters and add 50%
|
||||||
line_width = self._rect.width() - self._right_margin
|
line_width = self._rect.width() - self._right_margin
|
||||||
#number of lines on a page - adjust for rounding up.
|
#number of lines on a page - adjust for rounding up.
|
||||||
# print "Metrics ", line_width
|
|
||||||
page_length = int(self._rect.height() / metrics.height() - 2 ) - 1
|
page_length = int(self._rect.height() / metrics.height() - 2 ) - 1
|
||||||
ave_line_width = line_width / metrics.averageCharWidth()
|
ave_line_width = line_width / metrics.averageCharWidth()
|
||||||
ave_line_width = int(ave_line_width + (ave_line_width * 1))
|
ave_line_width = int(ave_line_width + (ave_line_width * 1))
|
||||||
# print "B", ave_line_width
|
|
||||||
split_pages = []
|
split_pages = []
|
||||||
page = []
|
page = []
|
||||||
split_lines = []
|
split_lines = []
|
||||||
count = 0
|
count = 0
|
||||||
for line in text:
|
for line in text:
|
||||||
#print "C", line, len(line)
|
|
||||||
#Must be a blank line so keep it.
|
#Must be a blank line so keep it.
|
||||||
if len(line) == 0:
|
if len(line) == 0:
|
||||||
line = u' '
|
line = u' '
|
||||||
while len(line) > 0:
|
while len(line) > 0:
|
||||||
# print "C1", line, len(line)
|
|
||||||
if len(line) > ave_line_width:
|
if len(line) > ave_line_width:
|
||||||
pos = line.find(u' ', ave_line_width)
|
pos = line.find(u' ', ave_line_width)
|
||||||
split_text = line[:pos]
|
split_text = line[:pos]
|
||||||
else:
|
else:
|
||||||
pos = len(line)
|
pos = len(line)
|
||||||
split_text = line
|
split_text = line
|
||||||
# print "E", metrics.width(split_text, -1), line_width
|
|
||||||
while metrics.width(split_text, -1) > line_width:
|
while metrics.width(split_text, -1) > line_width:
|
||||||
#Find the next space to the left
|
#Find the next space to the left
|
||||||
pos = line[:pos].rfind(u' ')
|
pos = line[:pos].rfind(u' ')
|
||||||
# print "F", pos, line[:pos]
|
|
||||||
#no more spaces found
|
#no more spaces found
|
||||||
if pos == 0:
|
if pos == 0:
|
||||||
split_text = line
|
split_text = line
|
||||||
@ -208,16 +199,9 @@ class Renderer(object):
|
|||||||
pos = len(split_text)
|
pos = len(split_text)
|
||||||
else:
|
else:
|
||||||
split_text = line[:pos]
|
split_text = line[:pos]
|
||||||
# print "F1", split_text, line, pos
|
|
||||||
split_lines.append(split_text)
|
split_lines.append(split_text)
|
||||||
line = line[pos:]
|
line = line[pos:]
|
||||||
#Text fits in a line now
|
#Text fits in a line now
|
||||||
# if len(line) <= line_width:
|
|
||||||
# split_lines.append(line)
|
|
||||||
# line = u''
|
|
||||||
# print "G", split_lines
|
|
||||||
# print "H", line
|
|
||||||
#print "I", split_lines, page_length
|
|
||||||
for line in split_lines:
|
for line in split_lines:
|
||||||
page.append(line)
|
page.append(line)
|
||||||
if len(page) == page_length:
|
if len(page) == page_length:
|
||||||
@ -252,7 +236,6 @@ class Renderer(object):
|
|||||||
Defaults to *None*. The footer to render.
|
Defaults to *None*. The footer to render.
|
||||||
"""
|
"""
|
||||||
log.debug(u'generate_frame_from_lines - Start')
|
log.debug(u'generate_frame_from_lines - Start')
|
||||||
#print "Render Lines ", lines
|
|
||||||
bbox = self._render_lines_unaligned(lines, False)
|
bbox = self._render_lines_unaligned(lines, False)
|
||||||
if footer_lines is not None:
|
if footer_lines is not None:
|
||||||
bbox1 = self._render_lines_unaligned(footer_lines, True)
|
bbox1 = self._render_lines_unaligned(footer_lines, True)
|
||||||
@ -321,8 +304,6 @@ class Renderer(object):
|
|||||||
if self.bg_image is not None:
|
if self.bg_image is not None:
|
||||||
painter.drawImage(0, 0, self.bg_image)
|
painter.drawImage(0, 0, self.bg_image)
|
||||||
painter.end()
|
painter.end()
|
||||||
# self.bg_frame_small = self.bg_frame.scaled(QtCore.QSize(280, 210),
|
|
||||||
# QtCore.Qt.KeepAspectRatio, QtCore.Qt.SmoothTransformation)
|
|
||||||
log.debug(u'render background End')
|
log.debug(u'render background End')
|
||||||
|
|
||||||
def _correctAlignment(self, rect, bbox):
|
def _correctAlignment(self, rect, bbox):
|
||||||
|
@ -194,9 +194,7 @@ class RenderManager(object):
|
|||||||
The words to go on the slides.
|
The words to go on the slides.
|
||||||
"""
|
"""
|
||||||
log.debug(u'format slide')
|
log.debug(u'format slide')
|
||||||
#self.calculate_default(self.screen_list[self.current_display][u'size'])
|
|
||||||
self.build_text_rectangle(self.themedata)
|
self.build_text_rectangle(self.themedata)
|
||||||
#self.renderer.set_frame_dest(self.width, self.height)
|
|
||||||
return self.renderer.format_slide(words, False)
|
return self.renderer.format_slide(words, False)
|
||||||
|
|
||||||
def generate_slide(self, main_text, footer_text):
|
def generate_slide(self, main_text, footer_text):
|
||||||
@ -254,6 +252,7 @@ class RenderManager(object):
|
|||||||
else:
|
else:
|
||||||
self.width = screen.width()
|
self.width = screen.width()
|
||||||
self.height = screen.height()
|
self.height = screen.height()
|
||||||
log.debug(u'calculate default %d, %d', self.width, self.height)
|
self.screen_ratio = float(self.height) / float(self.width)
|
||||||
|
log.debug(u'calculate default %d, %d, %f', self.width, self.height, self.screen_ratio )
|
||||||
# 90% is start of footer
|
# 90% is start of footer
|
||||||
self.footer_start = int(self.height * 0.90)
|
self.footer_start = int(self.height * 0.90)
|
||||||
|
@ -93,15 +93,10 @@ class ServiceItem(object):
|
|||||||
self.RenderManager.set_override_theme(None)
|
self.RenderManager.set_override_theme(None)
|
||||||
else:
|
else:
|
||||||
self.RenderManager.set_override_theme(self.theme)
|
self.RenderManager.set_override_theme(self.theme)
|
||||||
firstTime = True
|
|
||||||
for slide in self.service_frames:
|
for slide in self.service_frames:
|
||||||
formated = self.RenderManager.format_slide(slide[u'raw_slide'])
|
formated = self.RenderManager.format_slide(slide[u'raw_slide'])
|
||||||
for format in formated:
|
for format in formated:
|
||||||
frame = None
|
frame = None
|
||||||
if firstTime:
|
|
||||||
frame = self.RenderManager.generate_slide(format,
|
|
||||||
self.raw_footer)
|
|
||||||
firstTime = False
|
|
||||||
lines = u''
|
lines = u''
|
||||||
for line in format:
|
for line in format:
|
||||||
lines += line + u'\n'
|
lines += line + u'\n'
|
||||||
|
@ -157,13 +157,6 @@ class SlideController(QtGui.QWidget):
|
|||||||
self.DelaySpinBox.setSuffix(translate(u'SlideController', u's'))
|
self.DelaySpinBox.setSuffix(translate(u'SlideController', u's'))
|
||||||
|
|
||||||
self.ControllerLayout.addWidget(self.Toolbar)
|
self.ControllerLayout.addWidget(self.Toolbar)
|
||||||
#sizeToolbarPolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed,
|
|
||||||
# QtGui.QSizePolicy.Fixed)
|
|
||||||
#sizeToolbarPolicy.setHorizontalStretch(0)
|
|
||||||
#sizeToolbarPolicy.setVerticalStretch(0)
|
|
||||||
#sizeToolbarPolicy.setHeightForWidth(
|
|
||||||
# self.Toolbar.sizePolicy().hasHeightForWidth())
|
|
||||||
#self.Toolbar.setSizePolicy(sizeToolbarPolicy)
|
|
||||||
# Screen preview area
|
# Screen preview area
|
||||||
self.PreviewFrame = QtGui.QFrame(self.Splitter)
|
self.PreviewFrame = QtGui.QFrame(self.Splitter)
|
||||||
self.PreviewFrame.setGeometry(QtCore.QRect(0, 0, 300, 225))
|
self.PreviewFrame.setGeometry(QtCore.QRect(0, 0, 300, 225))
|
||||||
@ -284,29 +277,26 @@ class SlideController(QtGui.QWidget):
|
|||||||
log.debug(u'displayServiceManagerItems Start')
|
log.debug(u'displayServiceManagerItems Start')
|
||||||
before = time.time()
|
before = time.time()
|
||||||
self.serviceitem = serviceitem
|
self.serviceitem = serviceitem
|
||||||
slide_image = self.serviceitem.frames[0][u'image']
|
|
||||||
size = slide_image.size()
|
|
||||||
slide_width = self.settingsmanager.slidecontroller_image
|
|
||||||
slide_height = slide_width * size.height() / size.width()
|
|
||||||
self.PreviewListWidget.clear()
|
self.PreviewListWidget.clear()
|
||||||
self.PreviewListWidget.setRowCount(0)
|
self.PreviewListWidget.setRowCount(0)
|
||||||
self.PreviewListWidget.setColumnWidth(0, slide_width)
|
self.PreviewListWidget.setColumnWidth(0, self.settingsmanager.slidecontroller_image)
|
||||||
for framenumber, frame in enumerate(self.serviceitem.frames):
|
for framenumber, frame in enumerate(self.serviceitem.frames):
|
||||||
self.PreviewListWidget.setRowCount(self.PreviewListWidget.rowCount() + 1)
|
self.PreviewListWidget.setRowCount(self.PreviewListWidget.rowCount() + 1)
|
||||||
item = QtGui.QTableWidgetItem()
|
item = QtGui.QTableWidgetItem()
|
||||||
label = QtGui.QLabel()
|
label = QtGui.QLabel()
|
||||||
label.setMargin(8)
|
label.setMargin(8)
|
||||||
|
#It is a Image
|
||||||
if frame[u'text'] == None:
|
if frame[u'text'] == None:
|
||||||
pixmap = self.parent.RenderManager.resize_image(frame[u'image'], slide_width, slide_height)
|
pixmap = self.parent.RenderManager.resize_image(frame[u'image'])
|
||||||
label.setScaledContents(True)
|
label.setScaledContents(True)
|
||||||
label.setPixmap(QtGui.QPixmap.fromImage(pixmap))
|
label.setPixmap(QtGui.QPixmap.fromImage(pixmap))
|
||||||
else:
|
else:
|
||||||
label.setText(frame[u'text'])
|
label.setText(frame[u'text'])
|
||||||
self.PreviewListWidget.setCellWidget(framenumber, 0, label)
|
self.PreviewListWidget.setCellWidget(framenumber, 0, label)
|
||||||
self.PreviewListWidget.setItem(framenumber, 0, item)
|
self.PreviewListWidget.setItem(framenumber, 0, item)
|
||||||
|
slide_height = self.settingsmanager.slidecontroller_image * self.parent.RenderManager.screen_ratio
|
||||||
self.PreviewListWidget.setRowHeight(framenumber, slide_height)
|
self.PreviewListWidget.setRowHeight(framenumber, slide_height)
|
||||||
slide_width = self.PreviewListWidget.viewport().size().width()
|
self.PreviewListWidget.setColumnWidth(0, self.PreviewListWidget.viewport().size().width())
|
||||||
self.PreviewListWidget.setColumnWidth(0, slide_width)
|
|
||||||
if slideno > self.PreviewListWidget.rowCount():
|
if slideno > self.PreviewListWidget.rowCount():
|
||||||
self.PreviewListWidget.selectRow(self.PreviewListWidget.rowCount())
|
self.PreviewListWidget.selectRow(self.PreviewListWidget.rowCount())
|
||||||
else:
|
else:
|
||||||
@ -314,6 +304,7 @@ class SlideController(QtGui.QWidget):
|
|||||||
self.onSlideSelected()
|
self.onSlideSelected()
|
||||||
self.PreviewListWidget.setFocus()
|
self.PreviewListWidget.setFocus()
|
||||||
log.info(u'Display Rendering took %4s' % (time.time() - before))
|
log.info(u'Display Rendering took %4s' % (time.time() - before))
|
||||||
|
if self.serviceitem.audit != u'':
|
||||||
Receiver().send_message(u'audit_live', self.serviceitem.audit)
|
Receiver().send_message(u'audit_live', self.serviceitem.audit)
|
||||||
log.debug(u'displayServiceManagerItems End')
|
log.debug(u'displayServiceManagerItems End')
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user