From 9a643eadfc2d918ae8c9bf14c514e1832ff86411 Mon Sep 17 00:00:00 2001 From: Jules Date: Sat, 21 Mar 2026 23:12:17 +0100 Subject: [PATCH] =?UTF-8?q?Fix=20galerie=20:=20miniatures=20remplissent=20?= =?UTF-8?q?les=20cartes,=20taille=20max=20limit=C3=A9e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Miniature s'adapte à la taille de la carte via resizeEvent - MaxWidth/MaxHeight sur les cartes pour éviter les cadres blancs énormes - Fonctionne avec 3 ou 50 photos Co-Authored-By: Claude Opus 4.6 (1M context) --- src/ui/screens/import_screen.py | 49 ++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/src/ui/screens/import_screen.py b/src/ui/screens/import_screen.py index e3c426c..45c2094 100644 --- a/src/ui/screens/import_screen.py +++ b/src/ui/screens/import_screen.py @@ -28,23 +28,19 @@ class PhotoCard(QFrame): border-radius: 10px; } """) + self.setMaximumWidth(350) + self.setMaximumHeight(300) + layout = QVBoxLayout(self) - layout.setContentsMargins(5, 5, 5, 5) + layout.setContentsMargins(4, 4, 4, 4) layout.setSpacing(4) - # Miniature + # Miniature — s'étire pour remplir la carte self.thumb_label = QLabel() self.thumb_label.setAlignment(Qt.AlignmentFlag.AlignCenter) - self.thumb_label.setMinimumSize(150, 120) - pixmap = QPixmap(self.path) - if not pixmap.isNull(): - scaled = pixmap.scaled( - 200, 150, - Qt.AspectRatioMode.KeepAspectRatio, - Qt.TransformationMode.SmoothTransformation - ) - self.thumb_label.setPixmap(scaled) - layout.addWidget(self.thumb_label) + self.thumb_label.setScaledContents(False) + self._pixmap_original = QPixmap(self.path) + layout.addWidget(self.thumb_label, 1) # Barre du bas : crayon + quantité bar = QHBoxLayout() @@ -132,22 +128,31 @@ class PhotoCard(QFrame): """) self.qty_label.setStyleSheet("color: #333;") - def apply_responsive(self, window_height): - """Adapte les tailles au responsive.""" - thumb_h = max(80, int(window_height * 0.15)) - thumb_w = max(100, int(thumb_h * 1.4)) - self.thumb_label.setMinimumSize(thumb_w, thumb_h) + def resizeEvent(self, event): + super().resizeEvent(event) + self._update_thumbnail() - # Re-scale la miniature - pixmap = QPixmap(self.path) - if not pixmap.isNull(): - scaled = pixmap.scaled( - thumb_w, thumb_h, + def _update_thumbnail(self): + """Redimensionne la miniature pour remplir l'espace disponible.""" + if self._pixmap_original.isNull(): + return + w = self.thumb_label.width() + h = self.thumb_label.height() + if w > 10 and h > 10: + scaled = self._pixmap_original.scaled( + w, h, Qt.AspectRatioMode.KeepAspectRatio, Qt.TransformationMode.SmoothTransformation ) self.thumb_label.setPixmap(scaled) + def apply_responsive(self, window_height): + """Adapte les tailles au responsive.""" + max_h = max(150, int(window_height * 0.28)) + max_w = max(200, int(max_h * 1.3)) + self.setMaximumHeight(max_h) + self.setMaximumWidth(max_w) + btn_size = max(28, int(window_height * 0.04)) font_size = max(12, int(window_height * 0.02))