forked from openlp/openlp
Performance Improvements and code fixes
bzr-revno: 519
This commit is contained in:
commit
87ac4b5aa6
@ -218,7 +218,7 @@ class Renderer(object):
|
|||||||
if len(page) == page_length:
|
if len(page) == page_length:
|
||||||
split_pages.append(page)
|
split_pages.append(page)
|
||||||
page = []
|
page = []
|
||||||
if len(page) > 0:
|
if len(page) > 0 and page != u' ':
|
||||||
split_pages.append(page)
|
split_pages.append(page)
|
||||||
return split_pages
|
return split_pages
|
||||||
|
|
||||||
@ -440,7 +440,7 @@ class Renderer(object):
|
|||||||
rightextent = x + w
|
rightextent = x + w
|
||||||
# shift right from last line's rh edge
|
# shift right from last line's rh edge
|
||||||
if self._theme.display_wrapStyle == 1 and linenum != 0:
|
if self._theme.display_wrapStyle == 1 and linenum != 0:
|
||||||
rightextent = self._first_line_right_extent +
|
rightextent = self._first_line_right_extent + \
|
||||||
self._right_margin
|
self._right_margin
|
||||||
if rightextent > maxx:
|
if rightextent > maxx:
|
||||||
rightextent = maxx
|
rightextent = maxx
|
||||||
|
@ -209,7 +209,7 @@ class RenderManager(object):
|
|||||||
self.renderer.set_frame_dest(self.width, self.height)
|
self.renderer.set_frame_dest(self.width, self.height)
|
||||||
return self.renderer.generate_frame_from_lines(main_text, footer_text)
|
return self.renderer.generate_frame_from_lines(main_text, footer_text)
|
||||||
|
|
||||||
def resize_image(self, image):
|
def resize_image(self, image, width = 0, height = 0):
|
||||||
"""
|
"""
|
||||||
Resize an image to fit on the current screen.
|
Resize an image to fit on the current screen.
|
||||||
|
|
||||||
@ -217,8 +217,12 @@ class RenderManager(object):
|
|||||||
The image to resize.
|
The image to resize.
|
||||||
"""
|
"""
|
||||||
preview = QtGui.QImage(image)
|
preview = QtGui.QImage(image)
|
||||||
w = self.width
|
if width == 0:
|
||||||
h = self.height
|
w = self.width
|
||||||
|
h = self.height
|
||||||
|
else:
|
||||||
|
w = width
|
||||||
|
h = height
|
||||||
preview = preview.scaled(w, h, QtCore.Qt.KeepAspectRatio,
|
preview = preview.scaled(w, h, QtCore.Qt.KeepAspectRatio,
|
||||||
QtCore.Qt.SmoothTransformation)
|
QtCore.Qt.SmoothTransformation)
|
||||||
realw = preview.width();
|
realw = preview.width();
|
||||||
|
@ -100,7 +100,7 @@ class ServiceItem(object):
|
|||||||
self.frames = self.service_frames
|
self.frames = self.service_frames
|
||||||
elif self.service_item_type == ServiceType.Image:
|
elif self.service_item_type == ServiceType.Image:
|
||||||
for slide in self.service_frames:
|
for slide in self.service_frames:
|
||||||
slide[u'image'] =
|
slide[u'image'] = \
|
||||||
self.RenderManager.resize_image(slide[u'image'])
|
self.RenderManager.resize_image(slide[u'image'])
|
||||||
self.frames = self.service_frames
|
self.frames = self.service_frames
|
||||||
else:
|
else:
|
||||||
|
@ -21,7 +21,7 @@ import logging
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
from openlp.core.lib import OpenLPToolbar, translate, buildIcon, Receiver, ServiceType
|
from openlp.core.lib import OpenLPToolbar, translate, buildIcon, Receiver, ServiceType, RenderManager
|
||||||
|
|
||||||
class SlideList(QtGui.QTableWidget):
|
class SlideList(QtGui.QTableWidget):
|
||||||
"""
|
"""
|
||||||
@ -250,20 +250,21 @@ class SlideController(QtGui.QWidget):
|
|||||||
"""
|
"""
|
||||||
log.debug(u'displayServiceManagerItems Start')
|
log.debug(u'displayServiceManagerItems Start')
|
||||||
self.serviceitem = serviceitem
|
self.serviceitem = serviceitem
|
||||||
slide_pixmap = QtGui.QPixmap.fromImage(self.serviceitem.frames[0][u'image'])
|
slide_image = self.serviceitem.frames[0][u'image']
|
||||||
|
size = slide_image.size()
|
||||||
slide_width = 300
|
slide_width = 300
|
||||||
slide_height = slide_width * slide_pixmap.height() / slide_pixmap.width()
|
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, slide_width)
|
||||||
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)
|
||||||
pixmap = QtGui.QPixmap.fromImage(frame[u'image'])
|
pixmap = self.parent.RenderManager.resize_image(frame[u'image'], slide_width, slide_height)
|
||||||
item = QtGui.QTableWidgetItem()
|
item = QtGui.QTableWidgetItem()
|
||||||
label = QtGui.QLabel()
|
label = QtGui.QLabel()
|
||||||
label.setMargin(8)
|
label.setMargin(8)
|
||||||
label.setScaledContents(True)
|
label.setScaledContents(True)
|
||||||
label.setPixmap(pixmap)
|
label.setPixmap(QtGui.QPixmap.fromImage(pixmap))
|
||||||
self.PreviewListWidget.setCellWidget(framenumber, 0, label)
|
self.PreviewListWidget.setCellWidget(framenumber, 0, label)
|
||||||
self.PreviewListWidget.setItem(framenumber, 0, item)
|
self.PreviewListWidget.setItem(framenumber, 0, item)
|
||||||
self.PreviewListWidget.setRowHeight(framenumber, slide_height)
|
self.PreviewListWidget.setRowHeight(framenumber, slide_height)
|
||||||
|
Loading…
Reference in New Issue
Block a user