From e45d650697ed997484d565f6b992b0c2a15f49fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=81=8D=E5=85=AE=E6=83=9A=E5=85=AE?= <101191390+HIllya51@users.noreply.github.com> Date: Wed, 10 Apr 2024 22:34:34 +0800 Subject: [PATCH] Update dialog_savedgame.py --- .../LunaTranslator/gui/dialog_savedgame.py | 24 +++++++++---------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/LunaTranslator/LunaTranslator/gui/dialog_savedgame.py b/LunaTranslator/LunaTranslator/gui/dialog_savedgame.py index 022dd244..4f388f91 100644 --- a/LunaTranslator/LunaTranslator/gui/dialog_savedgame.py +++ b/LunaTranslator/LunaTranslator/gui/dialog_savedgame.py @@ -183,6 +183,16 @@ class IMGWidget(QLabel): self.pix = pixmap + pixmap = QPixmap(self.size()) + pixmap.fill(Qt.transparent) + painter = QPainter(pixmap) + painter.setRenderHint(QPainter.SmoothPixmapTransform) + painter.setRenderHint(QPainter.Antialiasing) + painter.drawPixmap(self.getrect(), self.pix) + painter.end() + + self.setPixmap(pixmap) + self.setFixedSize(pixmap.size()) def getrect(self): size = self.adaptsize(self.pix.size()) rect = QRect() @@ -191,22 +201,10 @@ class IMGWidget(QLabel): rect.setSize(size) return rect - def paintEvent(self, a0) -> None: - if self.pix: - try: - painter = QPainter(self) - painter.setRenderHint(QPainter.Antialiasing, True) - painter.setRenderHint(QPainter.HighQualityAntialiasing, True) - painter.setRenderHint(QPainter.LosslessImageRendering, True) - painter.drawPixmap(self.getrect(), self.pix) - except: - print_exc() - return super().paintEvent(a0) - def __init__(self, w, h, pixmap) -> None: super().__init__() self.setFixedSize(QSize(w, h)) - self.pix = None + self.setScaledContents(True) self.setimg(pixmap)