From bc6253a6279f7fed580eb4b8802ceb811ce82883 Mon Sep 17 00:00:00 2001 From: Ian Knight Date: Thu, 5 May 2016 13:27:04 +0930 Subject: [PATCH] Housekeeping, added check for thumbnails to avoid icon scaling issues --- openlp/core/lib/__init__.py | 6 +++--- openlp/core/lib/serviceitem.py | 3 ++- openlp/core/ui/lib/listpreviewwidget.py | 10 +++++++--- openlp/core/ui/slidecontroller.py | 9 +++++++-- 4 files changed, 19 insertions(+), 9 deletions(-) diff --git a/openlp/core/lib/__init__.py b/openlp/core/lib/__init__.py index 5a1006893..1fee2fe5a 100644 --- a/openlp/core/lib/__init__.py +++ b/openlp/core/lib/__init__.py @@ -56,12 +56,12 @@ 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. + ``CommandPlugins`` + This states that an image is being used by a command plugin. """ ImagePlugin = 1 Theme = 2 - PresentationPlugin = 3 + CommandPlugins = 3 class MediaType(object): diff --git a/openlp/core/lib/serviceitem.py b/openlp/core/lib/serviceitem.py index 32afbfe4f..2cbbb98e9 100644 --- a/openlp/core/lib/serviceitem.py +++ b/openlp/core/lib/serviceitem.py @@ -334,7 +334,8 @@ 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') + if self.is_capable(ItemCapabilities.HasThumbnails): + self.image_manager.add_image(image, ImageSource.CommandPlugins, '#000000') self._new_item() def get_service_repr(self, lite_save): diff --git a/openlp/core/ui/lib/listpreviewwidget.py b/openlp/core/ui/lib/listpreviewwidget.py index e18292129..2383cc35f 100644 --- a/openlp/core/ui/lib/listpreviewwidget.py +++ b/openlp/core/ui/lib/listpreviewwidget.py @@ -27,7 +27,7 @@ It is based on a QTableWidget but represents its contents in list form. from PyQt5 import QtCore, QtGui, QtWidgets from openlp.core.common import RegistryProperties, Settings -from openlp.core.lib import ImageSource, ServiceItem +from openlp.core.lib import ImageSource, ItemCapabilities, ServiceItem class ListPreviewWidget(QtWidgets.QTableWidget, RegistryProperties): @@ -152,10 +152,14 @@ class ListPreviewWidget(QtWidgets.QTableWidget, RegistryProperties): else: label.setScaledContents(True) if self.service_item.is_command(): - image = self.image_manager.get_image(frame['image'], ImageSource.PresentationPlugin) + if self.service_item.is_capable(ItemCapabilities.HasThumbnails): + image = self.image_manager.get_image(frame['image'], ImageSource.CommandPlugins) + pixmap = QtGui.QPixmap.fromImage(image) + else: + pixmap = QtGui.QPixmap(frame['image']) else: image = self.image_manager.get_image(frame['path'], ImageSource.ImagePlugin) - pixmap = QtGui.QPixmap.fromImage(image) + pixmap = QtGui.QPixmap.fromImage(image) pixmap.setDevicePixelRatio(label.devicePixelRatio()) label.setPixmap(pixmap) slide_height = width // self.screen_ratio diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index db4e01210..c06860057 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -1141,8 +1141,13 @@ class SlideController(DisplayController, RegistryProperties): # 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)) + # If not live, use the slide's thumbnail/icon instead + image_path = self.service_item.get_rendered_frame(self.selected_row) + if self.service_item.is_capable(ItemCapabilities.HasThumbnails): + image = self.image_manager.get_image(image_path, ImageSource.CommandPlugins) + self.slide_image = QtGui.QPixmap.fromImage(image) + else: + self.slide_image = QtGui.QPixmap(image_path) self.slide_image.setDevicePixelRatio(self.main_window.devicePixelRatio()) self.slide_preview.setPixmap(self.slide_image) else: