Warning ratio sur galerie + cadre recadrage auto dans l'éditeur
Galerie : - Petit badge orange ⚠ en haut à droite des photos pas au ratio 3:2 - Discret, tooltip "Photo à recadrer" - Tolérance 5% autour du ratio 1.5 Éditeur : - Si la photo n'est pas au ratio 3:2, le cadre de recadrage s'affiche automatiquement en suggestion à l'ouverture - L'utilisateur peut le déplacer/redimensionner ou le valider Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -125,6 +125,13 @@ class EditorScreen(QWidget):
|
||||
self.scene.setSceneRect(QRectF(pixmap.rect()))
|
||||
self.view.fitInView(self.pixmap_item, Qt.AspectRatioMode.KeepAspectRatio)
|
||||
|
||||
# Auto-afficher le cadre de recadrage si ratio ≠ 3:2
|
||||
w, h = pixmap.width(), pixmap.height()
|
||||
if w > 0 and h > 0:
|
||||
ratio = max(w, h) / min(w, h)
|
||||
if abs(ratio - 1.5) > 0.075:
|
||||
self._show_ratio_crop()
|
||||
|
||||
def resizeEvent(self, event):
|
||||
super().resizeEvent(event)
|
||||
if self.pixmap_item:
|
||||
@@ -149,6 +156,37 @@ class EditorScreen(QWidget):
|
||||
image.save(path, "PNG")
|
||||
return path
|
||||
|
||||
# --- Cadre ratio suggéré ---
|
||||
def _show_ratio_crop(self):
|
||||
"""Affiche un cadre de recadrage au ratio 3:2 en suggestion."""
|
||||
if not self.pixmap_item:
|
||||
return
|
||||
self.is_cropping = True
|
||||
self.view.setDragMode(QGraphicsView.DragMode.NoDrag)
|
||||
pr = self.pixmap_item.boundingRect()
|
||||
img_w, img_h = pr.width(), pr.height()
|
||||
|
||||
ratio = 1.5
|
||||
# Adapter au sens de l'image
|
||||
if img_w < img_h:
|
||||
ratio = 1.0 / ratio
|
||||
|
||||
# Plus grande zone possible
|
||||
if img_w / img_h > ratio:
|
||||
crop_h = img_h * 0.95
|
||||
crop_w = crop_h * ratio
|
||||
else:
|
||||
crop_w = img_w * 0.95
|
||||
crop_h = crop_w / ratio
|
||||
|
||||
x = (img_w - crop_w) / 2
|
||||
y = (img_h - crop_h) / 2
|
||||
|
||||
crop_rect = QRectF(x, y, crop_w, crop_h)
|
||||
self.crop_overlay = CropOverlay(crop_rect)
|
||||
self.crop_overlay.set_bounds(pr)
|
||||
self.scene.addItem(self.crop_overlay)
|
||||
|
||||
# --- Navigation ---
|
||||
def _go_back(self):
|
||||
self._cancel_crop()
|
||||
|
||||
Reference in New Issue
Block a user