forked from openlp/openlp
Renderer - speed up adding to slide controller
This commit is contained in:
parent
261351e27b
commit
555b9b92a5
@ -205,7 +205,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.
|
||||||
|
|
||||||
@ -213,8 +213,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, QtCore.Qt.SmoothTransformation)
|
preview = preview.scaled(w, h, QtCore.Qt.KeepAspectRatio, QtCore.Qt.SmoothTransformation)
|
||||||
realw = preview.width();
|
realw = preview.width();
|
||||||
realh = preview.height()
|
realh = preview.height()
|
||||||
|
@ -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