From 05a653e67022cbdf84383368c8dce3e16e71bdd0 Mon Sep 17 00:00:00 2001 From: Jonathan Springer Date: Sun, 29 Nov 2015 17:48:10 -0500 Subject: [PATCH] Make sure all generated pixmaps are show at the proper pixel ratio --- openlp/core/__init__.py | 1 + openlp/core/ui/listpreviewwidget.py | 8 ++++++-- openlp/core/ui/slidecontroller.py | 2 ++ openlp/core/ui/themeform.py | 1 + openlp/core/ui/themelayoutform.py | 1 + 5 files changed, 11 insertions(+), 2 deletions(-) diff --git a/openlp/core/__init__.py b/openlp/core/__init__.py index f4fa82839..642ad77c5 100644 --- a/openlp/core/__init__.py +++ b/openlp/core/__init__.py @@ -341,6 +341,7 @@ def main(args=None): application = OpenLP(qt_args) application.setOrganizationName('OpenLP') application.setOrganizationDomain('openlp.org') + application.setAttribute(QtCore.Qt.AA_UseHighDpiPixmaps, True) if args and args.portable: application.setApplicationName('OpenLPPortable') Settings.setDefaultFormat(Settings.IniFormat) diff --git a/openlp/core/ui/listpreviewwidget.py b/openlp/core/ui/listpreviewwidget.py index e64f02520..17c333f16 100644 --- a/openlp/core/ui/listpreviewwidget.py +++ b/openlp/core/ui/listpreviewwidget.py @@ -131,10 +131,14 @@ class ListPreviewWidget(QtWidgets.QTableWidget, RegistryProperties): else: label.setScaledContents(True) if self.service_item.is_command(): - label.setPixmap(QtGui.QPixmap(frame['image'])) + pixmap = QtGui.QPixmap(frame['image']) + pixmap.setDevicePixelRatio(label.devicePixelRatio()) + label.setPixmap(pixmap) else: image = self.image_manager.get_image(frame['path'], ImageSource.ImagePlugin) - label.setPixmap(QtGui.QPixmap.fromImage(image)) + pixmap = QtGui.QPixmap.fromImage(image) + pixmap.setDevicePixelRatio(label.devicePixelRatio()) + label.setPixmap(pixmap) self.setCellWidget(frame_number, 0, label) slide_height = width // self.screen_ratio row += 1 diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index d82732fe1..dce623809 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -1129,6 +1129,7 @@ class SlideController(DisplayController, RegistryProperties): QtCore.QTimer.singleShot(2.5, self.grab_maindisplay) else: self.slide_image = self.display.preview() + self.slide_image.setDevicePixelRatio(self.main_window.devicePixelRatio()) self.slide_preview.setPixmap(self.slide_image) self.slide_count += 1 @@ -1139,6 +1140,7 @@ class SlideController(DisplayController, RegistryProperties): win_id = QtWidgets.QApplication.desktop().winId() rect = self.screens.current['size'] win_image = QtGui.QScreen.grabWindow(win_id, rect.x(), rect.y(), rect.width(), rect.height()) + win_image.setDevicePixelRatio(self.slide_preview.devicePixelRatio()) self.slide_preview.setPixmap(win_image) self.slide_image = win_image diff --git a/openlp/core/ui/themeform.py b/openlp/core/ui/themeform.py index 593336dfb..81755e261 100644 --- a/openlp/core/ui/themeform.py +++ b/openlp/core/ui/themeform.py @@ -193,6 +193,7 @@ class ThemeForm(QtWidgets.QWizard, Ui_ThemeWizard, RegistryProperties): if self.page(page_id) == self.preview_page: self.update_theme() frame = self.theme_manager.generate_image(self.theme) + frame.setDevicePixelRatio(self.devicePixelRatio()) self.preview_box_label.setPixmap(frame) self.display_aspect_ratio = float(frame.width()) / frame.height() self.resizeEvent() diff --git a/openlp/core/ui/themelayoutform.py b/openlp/core/ui/themelayoutform.py index 9977665bc..c28987524 100644 --- a/openlp/core/ui/themelayoutform.py +++ b/openlp/core/ui/themelayoutform.py @@ -43,6 +43,7 @@ class ThemeLayoutForm(QtWidgets.QDialog, Ui_ThemeLayoutDialog): Run the Dialog with correct heading. """ pixmap = image.scaledToHeight(400, QtCore.Qt.SmoothTransformation) + pixmap.setDevicePixelRatio(self.theme_display_label.devicePixelRatio()) self.theme_display_label.setPixmap(pixmap) display_aspect_ratio = float(image.width()) / image.height() self.theme_display_label.setFixedSize(400, 400 / display_aspect_ratio)