QR bouton : plus gros, plus net, haute résolution

- box_size=20 pour générer en haute résolution
- FastTransformation (pas de lissage = pixels nets)
- QR prend 55% de la hauteur du bouton
- Fond bleu (#2196F3), QR blanc pour contraste

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-21 22:25:08 +01:00
parent 8f48fd2e38
commit 084b4e2b54

View File

@@ -383,17 +383,20 @@ class HomeScreen(QWidget):
# ─── Mini QR sur le bouton ─── # ─── Mini QR sur le bouton ───
def _set_qr_button_icon(self): def _set_qr_button_icon(self):
"""Génère un mini QR code et l'affiche sur le bouton QR Code.""" """Génère un QR code net et l'affiche en gros sur le bouton QR Code."""
try: try:
import qrcode import qrcode
import io import io
self.config = load_config() self.config = load_config()
upload_url = self.config["upload_url"] upload_url = self.config["upload_url"]
qr = qrcode.QRCode(version=1, box_size=4, border=1)
# Haute résolution pour la netteté
qr = qrcode.QRCode(version=1, box_size=20, border=1,
error_correction=qrcode.constants.ERROR_CORRECT_M)
qr.add_data(upload_url) qr.add_data(upload_url)
qr.make(fit=True) qr.make(fit=True)
img = qr.make_image(fill_color="white", back_color="transparent") img = qr.make_image(fill_color="white", back_color="#2196F3")
buffer = io.BytesIO() buffer = io.BytesIO()
img.save(buffer, format="PNG") img.save(buffer, format="PNG")
@@ -403,11 +406,12 @@ class HomeScreen(QWidget):
btn = self.mode_buttons.get("QR Code") btn = self.mode_buttons.get("QR Code")
if btn: if btn:
qr_size = max(40, btn.height() // 3) if btn.height() > 0 else 60 # QR prend 55% de la hauteur du bouton
qr_size = max(60, int(btn.height() * 0.55)) if btn.height() > 0 else 100
pixmap = QPixmap.fromImage(qimage).scaled( pixmap = QPixmap.fromImage(qimage).scaled(
qr_size, qr_size, qr_size, qr_size,
Qt.AspectRatioMode.KeepAspectRatio, Qt.AspectRatioMode.KeepAspectRatio,
Qt.TransformationMode.SmoothTransformation Qt.TransformationMode.FastTransformation # Pas de lissage = QR net
) )
btn.setIcon(QIcon(pixmap)) btn.setIcon(QIcon(pixmap))
from PyQt6.QtCore import QSize from PyQt6.QtCore import QSize