From b640c7a852b7803e658449d45d940c24080a4dbe Mon Sep 17 00:00:00 2001 From: "dries.k" Date: Fri, 2 Sep 2022 17:21:27 +0200 Subject: [PATCH] only scale if the image is too large --- gotify_tray/gui/widgets/ImagePopup.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/gotify_tray/gui/widgets/ImagePopup.py b/gotify_tray/gui/widgets/ImagePopup.py index f84d487..8850c6d 100644 --- a/gotify_tray/gui/widgets/ImagePopup.py +++ b/gotify_tray/gui/widgets/ImagePopup.py @@ -26,12 +26,16 @@ class ImagePopup(QtWidgets.QLabel): self.popup_timer = QtCore.QTimer() self.popup_timer.timeout.connect(self.check_mouse) - pixmap = QtGui.QPixmap(filename).scaled( - settings.value("ImagePopup/w", type=int), - settings.value("ImagePopup/h", type=int), - aspectRatioMode=QtCore.Qt.AspectRatioMode.KeepAspectRatio, - transformMode=QtCore.Qt.TransformationMode.SmoothTransformation, - ) + pixmap = QtGui.QPixmap(filename) + W = settings.value("ImagePopup/w", type=int) + H = settings.value("ImagePopup/h", type=int) + if pixmap.height() > H or pixmap.width() > W: + pixmap = pixmap.scaled( + W, + H, + aspectRatioMode=QtCore.Qt.AspectRatioMode.KeepAspectRatio, + transformMode=QtCore.Qt.TransformationMode.SmoothTransformation, + ) self.setPixmap(pixmap) self.move(pos - QtCore.QPoint(15, 15))