Fix galerie : cartes à taille fixe, plus de cadre blanc extensible
Miniature en taille fixe (responsive selon la fenêtre mais pas extensible). Même rendu avec 3 ou 50 photos. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -28,19 +28,17 @@ class PhotoCard(QFrame):
|
|||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
}
|
}
|
||||||
""")
|
""")
|
||||||
self.setMaximumWidth(350)
|
|
||||||
self.setMaximumHeight(300)
|
|
||||||
|
|
||||||
layout = QVBoxLayout(self)
|
layout = QVBoxLayout(self)
|
||||||
layout.setContentsMargins(4, 4, 4, 4)
|
layout.setContentsMargins(4, 4, 4, 4)
|
||||||
layout.setSpacing(4)
|
layout.setSpacing(4)
|
||||||
|
|
||||||
# Miniature — s'étire pour remplir la carte
|
# Miniature — taille fixe
|
||||||
self.thumb_label = QLabel()
|
self.thumb_label = QLabel()
|
||||||
self.thumb_label.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
self.thumb_label.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
||||||
self.thumb_label.setScaledContents(False)
|
self.thumb_label.setFixedSize(200, 140)
|
||||||
self._pixmap_original = QPixmap(self.path)
|
self._pixmap_original = QPixmap(self.path)
|
||||||
layout.addWidget(self.thumb_label, 1)
|
self._update_thumbnail()
|
||||||
|
layout.addWidget(self.thumb_label)
|
||||||
|
|
||||||
# Barre du bas : crayon + quantité
|
# Barre du bas : crayon + quantité
|
||||||
bar = QHBoxLayout()
|
bar = QHBoxLayout()
|
||||||
@@ -128,12 +126,8 @@ class PhotoCard(QFrame):
|
|||||||
""")
|
""")
|
||||||
self.qty_label.setStyleSheet("color: #333;")
|
self.qty_label.setStyleSheet("color: #333;")
|
||||||
|
|
||||||
def resizeEvent(self, event):
|
|
||||||
super().resizeEvent(event)
|
|
||||||
self._update_thumbnail()
|
|
||||||
|
|
||||||
def _update_thumbnail(self):
|
def _update_thumbnail(self):
|
||||||
"""Redimensionne la miniature pour remplir l'espace disponible."""
|
"""Redimensionne la miniature pour remplir le label fixe."""
|
||||||
if self._pixmap_original.isNull():
|
if self._pixmap_original.isNull():
|
||||||
return
|
return
|
||||||
w = self.thumb_label.width()
|
w = self.thumb_label.width()
|
||||||
@@ -148,10 +142,10 @@ class PhotoCard(QFrame):
|
|||||||
|
|
||||||
def apply_responsive(self, window_height):
|
def apply_responsive(self, window_height):
|
||||||
"""Adapte les tailles au responsive."""
|
"""Adapte les tailles au responsive."""
|
||||||
max_h = max(150, int(window_height * 0.28))
|
thumb_h = max(100, int(window_height * 0.16))
|
||||||
max_w = max(200, int(max_h * 1.3))
|
thumb_w = max(140, int(thumb_h * 1.45))
|
||||||
self.setMaximumHeight(max_h)
|
self.thumb_label.setFixedSize(thumb_w, thumb_h)
|
||||||
self.setMaximumWidth(max_w)
|
self._update_thumbnail()
|
||||||
|
|
||||||
btn_size = max(28, int(window_height * 0.04))
|
btn_size = max(28, int(window_height * 0.04))
|
||||||
font_size = max(12, int(window_height * 0.02))
|
font_size = max(12, int(window_height * 0.02))
|
||||||
|
|||||||
Reference in New Issue
Block a user