From d8f7d9c6995bd5a6da9458a4bbf06325d502fa3c Mon Sep 17 00:00:00 2001 From: Maxime GRANDCOLAS Date: Mon, 21 Jun 2021 11:40:28 +0200 Subject: [PATCH] Fix bug when redrawing the qr code multiple times --- parsec/core/gui/custom_widgets.py | 2 +- parsec/core/gui/qrcode_widget.py | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/parsec/core/gui/custom_widgets.py b/parsec/core/gui/custom_widgets.py index 0f492ea8754..3f3ba91a7b7 100644 --- a/parsec/core/gui/custom_widgets.py +++ b/parsec/core/gui/custom_widgets.py @@ -293,7 +293,7 @@ def leaveEvent(self, event): self._draw_overlay() def setPixmap(self, pix): - self._pix = pix + self._pix = pix.copy() self._draw_overlay() def _draw_overlay(self): diff --git a/parsec/core/gui/qrcode_widget.py b/parsec/core/gui/qrcode_widget.py index 97dae550e8c..0a521aa92db 100644 --- a/parsec/core/gui/qrcode_widget.py +++ b/parsec/core/gui/qrcode_widget.py @@ -1,4 +1,4 @@ -# Parsec Cloud (https://parsec.cloud) Copyright (c) AGPLv3 2019 Scille SAS +# Parsec Cloud (https://parsec.cloud) Copyright (c) AGPLv3 2016-2021 Scille SAS from PyQt5.QtCore import QRectF from PyQt5.QtWidgets import QWidget, QVBoxLayout @@ -27,13 +27,14 @@ def generate_qr_code(text): img = QImage(":/logos/images/logos/parsec2.png") if img: img = img.convertToFormat(QImage.Format_ARGB32) - PARSEC_LOGO = QImage(img.width() + 30, img.height() + 20, QImage.Format_ARGB32) - PARSEC_LOGO.fill(QColor(0xF4, 0xF4, 0xF4)) + logo = QImage(img.width() + 30, img.height() + 20, QImage.Format_ARGB32) + logo.fill(QColor(0xF4, 0xF4, 0xF4)) painter = QPainter() - painter.begin(PARSEC_LOGO) + painter.begin(logo) painter.setCompositionMode(QPainter.CompositionMode_SourceOver) painter.drawImage(15, 10, img) painter.end() + PARSEC_LOGO = logo qr = qrcode.QRCode( version=None, error_correction=qrcode.constants.ERROR_CORRECT_H, border=4, box_size=10 @@ -46,13 +47,14 @@ def generate_qr_code(text): qrcode.image.svg.SvgPathImage.QR_PATH_STYLE = ( "fill:#5193FF;fill-opacity:1;fill-rule:nonzero;stroke:none" ) - img = qr.make_image(image_factory=qrcode.image.svg.SvgPathImage) + qr_img = qr.make_image(image_factory=qrcode.image.svg.SvgPathImage) stream = io.BytesIO() - img.save(stream) + qr_img.save(stream) renderer = QSvgRenderer() renderer.load(stream.getvalue()) final_img = QImage(600, 600, QImage.Format_ARGB32) + final_img.fill(QColor(0xF4, 0xF4, 0xF4)) painter = QPainter() painter.begin(final_img)