forked from openlp/openlp
Corrected aspect ratio on slide previews
This commit is contained in:
parent
f6cb085b0d
commit
f0d7cf7f36
@ -55,9 +55,13 @@ class ImageSource(object):
|
||||
|
||||
``Theme``
|
||||
This says, that the image is used by a theme.
|
||||
|
||||
``PresentationPlugin``
|
||||
This states that an image is being used by the presentation plugin.
|
||||
"""
|
||||
ImagePlugin = 1
|
||||
Theme = 2
|
||||
PresentationPlugin = 3
|
||||
|
||||
|
||||
class MediaType(object):
|
||||
@ -174,10 +178,24 @@ def create_thumb(image_path, thumb_path, return_icon=True, size=None):
|
||||
ext = os.path.splitext(thumb_path)[1].lower()
|
||||
reader = QtGui.QImageReader(image_path)
|
||||
if size is None:
|
||||
# No size given; use default height of 88
|
||||
ratio = reader.size().width() / reader.size().height()
|
||||
reader.setScaledSize(QtCore.QSize(int(ratio * 88), 88))
|
||||
else:
|
||||
elif size.isValid():
|
||||
# Complete size given
|
||||
reader.setScaledSize(size)
|
||||
else:
|
||||
# Invalid size given
|
||||
ratio = reader.size().width() / reader.size().height()
|
||||
if size.width() >= 0:
|
||||
# Valid width; scale height
|
||||
reader.setScaledSize(QtCore.QSize(size.width(), int(size.width() / ratio)))
|
||||
elif size.height() >= 0:
|
||||
# Valid height; scale width
|
||||
reader.setScaledSize(QtCore.QSize(int(ratio * size.height()), size.height()))
|
||||
else:
|
||||
# Invalid; use default height of 88
|
||||
reader.setScaledSize(QtCore.QSize(int(ratio * 88), 88))
|
||||
thumb = reader.read()
|
||||
thumb.save(thumb_path, ext[1:])
|
||||
if not return_icon:
|
||||
|
@ -334,6 +334,7 @@ class ServiceItem(RegistryProperties):
|
||||
file_location_hash, ntpath.basename(image))
|
||||
self._raw_frames.append({'title': file_name, 'image': image, 'path': path,
|
||||
'display_title': display_title, 'notes': notes})
|
||||
self.image_manager.add_image(image, ImageSource.PresentationPlugin, '#000000')
|
||||
self._new_item()
|
||||
|
||||
def get_service_repr(self, lite_save):
|
||||
|
@ -152,14 +152,15 @@ class ListPreviewWidget(QtWidgets.QTableWidget, RegistryProperties):
|
||||
else:
|
||||
label.setScaledContents(True)
|
||||
if self.service_item.is_command():
|
||||
pixmap = QtGui.QPixmap(frame['image'])
|
||||
pixmap.setDevicePixelRatio(label.devicePixelRatio())
|
||||
label.setPixmap(pixmap)
|
||||
#pixmap = QtGui.QPixmap(frame['image'])
|
||||
#pixmap.setDevicePixelRatio(label.devicePixelRatio())
|
||||
#label.setPixmap(pixmap)
|
||||
image = self.image_manager.get_image(frame['image'], ImageSource.PresentationPlugin)
|
||||
else:
|
||||
image = self.image_manager.get_image(frame['path'], ImageSource.ImagePlugin)
|
||||
pixmap = QtGui.QPixmap.fromImage(image)
|
||||
pixmap.setDevicePixelRatio(label.devicePixelRatio())
|
||||
label.setPixmap(pixmap)
|
||||
pixmap = QtGui.QPixmap.fromImage(image)
|
||||
pixmap.setDevicePixelRatio(label.devicePixelRatio())
|
||||
label.setPixmap(pixmap)
|
||||
slide_height = width // self.screen_ratio
|
||||
# Setup and validate row height cap if in use.
|
||||
max_img_row_height = Settings().value('advanced/slide max height')
|
||||
|
@ -1132,9 +1132,16 @@ class SlideController(DisplayController, RegistryProperties):
|
||||
"""
|
||||
self.log_debug('update_preview %s ' % self.screens.current['primary'])
|
||||
if self.service_item and self.service_item.is_capable(ItemCapabilities.ProvidesOwnDisplay):
|
||||
# Grab now, but try again in a couple of seconds if slide change is slow
|
||||
QtCore.QTimer.singleShot(500, self.grab_maindisplay)
|
||||
QtCore.QTimer.singleShot(2500, self.grab_maindisplay)
|
||||
if self.is_live:
|
||||
# If live, grab screen-cap of main display now
|
||||
QtCore.QTimer.singleShot(500, self.grab_maindisplay)
|
||||
# but take another in a couple of seconds in case slide change is slow
|
||||
QtCore.QTimer.singleShot(2500, self.grab_maindisplay)
|
||||
else:
|
||||
# If not live, use the slide's thumbnail instead
|
||||
self.slide_image = QtGui.QPixmap.fromImage(self.image_manager.get_image(self.service_item.get_rendered_frame(self.selected_row), ImageSource.PresentationPlugin)) #QtGui.QPixmap(self.service_item.get_rendered_frame(self.selected_row))
|
||||
self.slide_image.setDevicePixelRatio(self.main_window.devicePixelRatio())
|
||||
self.slide_preview.setPixmap(self.slide_image)
|
||||
else:
|
||||
self.slide_image = self.display.preview()
|
||||
self.slide_image.setDevicePixelRatio(self.main_window.devicePixelRatio())
|
||||
|
@ -242,13 +242,13 @@ class PresentationDocument(object):
|
||||
|
||||
def convert_thumbnail(self, file, idx):
|
||||
"""
|
||||
Convert the slide image the application made to a standard 320x240 .png image.
|
||||
Convert the slide image the application made to a scaled 360px height .png image.
|
||||
"""
|
||||
if self.check_thumbnails():
|
||||
return
|
||||
if os.path.isfile(file):
|
||||
thumb_path = self.get_thumbnail_path(idx, False)
|
||||
create_thumb(file, thumb_path, False, QtCore.QSize(320, 240))
|
||||
create_thumb(file, thumb_path, False, QtCore.QSize(-1, 360))
|
||||
|
||||
def get_thumbnail_path(self, slide_no, check_exists):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user