diff --git a/src/ui/screens/import_screen.py b/src/ui/screens/import_screen.py index fb559d7..eb0cbf3 100644 --- a/src/ui/screens/import_screen.py +++ b/src/ui/screens/import_screen.py @@ -32,22 +32,23 @@ class PhotoCard(QFrame): layout.setContentsMargins(4, 4, 4, 4) layout.setSpacing(4) - # Conteneur miniature (pour superposer la pastille) - thumb_container = QWidget() - thumb_container.setFixedSize(200, 140) - thumb_container.setCursor(Qt.CursorShape.PointingHandCursor) - thumb_container.mousePressEvent = lambda e: self._edit() + # Miniature cliquable + self.thumb_btn = QPushButton() + self.thumb_btn.setFixedSize(200, 140) + self.thumb_btn.setCursor(Qt.CursorShape.PointingHandCursor) + self.thumb_btn.setStyleSheet(""" + QPushButton { + background: #f8f8f8; + border: none; + border-radius: 6px; + } + QPushButton:pressed { background: #eee; } + """) + self.thumb_btn.clicked.connect(self._edit) - thumb_layout = QVBoxLayout(thumb_container) - thumb_layout.setContentsMargins(0, 0, 0, 0) - thumb_layout.setSpacing(0) - - self.thumb_label = QLabel() - self.thumb_label.setAlignment(Qt.AlignmentFlag.AlignCenter) - self.thumb_label.setFixedSize(200, 140) self._pixmap_original = QPixmap(self.path) self._update_thumbnail() - thumb_layout.addWidget(self.thumb_label) + layout.addWidget(self.thumb_btn) # Pastille orange (ratio ≠ 3:2) self.ratio_dot = QLabel() @@ -59,11 +60,10 @@ class PhotoCard(QFrame): } """) self.ratio_dot.hide() - self.ratio_dot.setParent(thumb_container) + self.ratio_dot.setParent(self.thumb_btn) self.ratio_dot.move(182, 4) self._check_ratio() - layout.addWidget(thumb_container) # Barre du bas : − quantité + (centré) bar = QHBoxLayout() @@ -153,30 +153,31 @@ class PhotoCard(QFrame): self.qty_label.setStyleSheet("color: #333;") def _update_thumbnail(self): - """Redimensionne la miniature pour remplir le label fixe.""" + """Redimensionne la miniature et la centre sur le bouton.""" if self._pixmap_original.isNull(): return - w = self.thumb_label.width() - h = self.thumb_label.height() + w = self.thumb_btn.width() + h = self.thumb_btn.height() if w > 10 and h > 10: scaled = self._pixmap_original.scaled( - w, h, + w - 4, h - 4, Qt.AspectRatioMode.KeepAspectRatio, Qt.TransformationMode.SmoothTransformation ) - self.thumb_label.setPixmap(scaled) + self.thumb_btn.setIcon(QIcon(scaled)) + self.thumb_btn.setIconSize(QSize(w - 4, h - 4)) def apply_responsive(self, window_height): """Adapte les tailles au responsive.""" thumb_h = max(100, int(window_height * 0.16)) thumb_w = max(140, int(thumb_h * 1.45)) - self.thumb_label.setFixedSize(thumb_w, thumb_h) - self.thumb_label.parent().setFixedSize(thumb_w, thumb_h) + self.thumb_btn.setFixedSize(thumb_w, thumb_h) self._update_thumbnail() # Pastille orange dot_size = max(10, int(window_height * 0.018)) self.ratio_dot.setFixedSize(dot_size, dot_size) + self.ratio_dot.setParent(self.thumb_btn) self.ratio_dot.move(thumb_w - dot_size - 4, 4) self.ratio_dot.setStyleSheet(f""" QLabel {{ @@ -184,6 +185,7 @@ class PhotoCard(QFrame): border-radius: {dot_size // 2}px; }} """) + self.ratio_dot.raise_() btn_size = max(28, int(window_height * 0.04)) font_size = max(12, int(window_height * 0.02))