V2.3.0 — Ajout texte/image + barre outils verticale
- Ajout de texte libre sur les pages (Annotations > Ajouter du texte) - Texte multi-ligne, police, taille, couleur au choix - Position X/Y en mm, appliquer a page courante/toutes/paires/impaires - Ajout d'image sur les pages (Annotations > Ajouter une image) - PNG/JPG/BMP/GIF/TIFF, position, taille, ratio auto - Memes options d'application - Barre d'outils verticale a droite avec toutes les fonctions : - IMPOSITION : Livret, N-Up, Repetition, Manuel, Joindre - PAGES : Recadrer, Pg blanche, Fusionner - ANNOTATIONS : Texte, Image, Numeros, Masquer - REPERES : Coupe +/-, Bleed +/- - Toolbar horizontale : Ouvrir, Enregistrer, Imprimer, Zoom Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
120
app/dialogs/add_image_dialog.py
Normal file
120
app/dialogs/add_image_dialog.py
Normal file
@@ -0,0 +1,120 @@
|
||||
"""Dialogue Ajouter une image sur une page."""
|
||||
|
||||
from PyQt6.QtWidgets import (QDialog, QVBoxLayout, QHBoxLayout, QLabel,
|
||||
QGroupBox, QComboBox, QDoubleSpinBox,
|
||||
QDialogButtonBox, QPushButton, QFileDialog)
|
||||
from reportlab.lib.units import mm
|
||||
|
||||
|
||||
class AddImageDialog(QDialog):
|
||||
def __init__(self, total_pages=1, current_page=0, parent=None):
|
||||
super().__init__(parent)
|
||||
self.setWindowTitle("Ajouter une image")
|
||||
self.setMinimumWidth(400)
|
||||
self._total_pages = total_pages
|
||||
self._current_page = current_page
|
||||
self._image_path = None
|
||||
self._setup_ui()
|
||||
|
||||
def _setup_ui(self):
|
||||
layout = QVBoxLayout(self)
|
||||
|
||||
# Image
|
||||
grp_img = QGroupBox("Image")
|
||||
il = QHBoxLayout(grp_img)
|
||||
self.btn_choose = QPushButton("Choisir une image...")
|
||||
self.btn_choose.clicked.connect(self._choose_image)
|
||||
il.addWidget(self.btn_choose)
|
||||
self.lbl_file = QLabel("Aucun fichier")
|
||||
self.lbl_file.setStyleSheet("color: #888;")
|
||||
il.addWidget(self.lbl_file)
|
||||
layout.addWidget(grp_img)
|
||||
|
||||
# Position et taille
|
||||
grp_pos = QGroupBox("Position et taille (mm)")
|
||||
pl = QVBoxLayout(grp_pos)
|
||||
|
||||
row1 = QHBoxLayout()
|
||||
row1.addWidget(QLabel("X :"))
|
||||
self.spin_x = QDoubleSpinBox()
|
||||
self.spin_x.setRange(0, 2000)
|
||||
self.spin_x.setValue(20)
|
||||
self.spin_x.setSuffix(" mm")
|
||||
row1.addWidget(self.spin_x)
|
||||
row1.addWidget(QLabel("Y :"))
|
||||
self.spin_y = QDoubleSpinBox()
|
||||
self.spin_y.setRange(0, 2000)
|
||||
self.spin_y.setValue(20)
|
||||
self.spin_y.setSuffix(" mm")
|
||||
row1.addWidget(self.spin_y)
|
||||
pl.addLayout(row1)
|
||||
|
||||
row2 = QHBoxLayout()
|
||||
row2.addWidget(QLabel("Largeur :"))
|
||||
self.spin_w = QDoubleSpinBox()
|
||||
self.spin_w.setRange(1, 2000)
|
||||
self.spin_w.setValue(50)
|
||||
self.spin_w.setSuffix(" mm")
|
||||
row2.addWidget(self.spin_w)
|
||||
row2.addWidget(QLabel("Hauteur :"))
|
||||
self.spin_h = QDoubleSpinBox()
|
||||
self.spin_h.setRange(0, 2000)
|
||||
self.spin_h.setValue(0)
|
||||
self.spin_h.setSuffix(" mm")
|
||||
self.spin_h.setSpecialValueText("Auto")
|
||||
row2.addWidget(self.spin_h)
|
||||
pl.addLayout(row2)
|
||||
|
||||
pl.addWidget(QLabel("Hauteur 0 = proportionnelle a la largeur"))
|
||||
layout.addWidget(grp_pos)
|
||||
|
||||
# Appliquer a
|
||||
grp_apply = QGroupBox("Appliquer a")
|
||||
al = QHBoxLayout(grp_apply)
|
||||
self.combo_apply = QComboBox()
|
||||
self.combo_apply.addItems([
|
||||
f"Page courante ({self._current_page + 1})",
|
||||
"Toutes les pages",
|
||||
"Pages paires",
|
||||
"Pages impaires"
|
||||
])
|
||||
al.addWidget(self.combo_apply)
|
||||
layout.addWidget(grp_apply)
|
||||
|
||||
buttons = QDialogButtonBox(
|
||||
QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel
|
||||
)
|
||||
buttons.accepted.connect(self.accept)
|
||||
buttons.rejected.connect(self.reject)
|
||||
layout.addWidget(buttons)
|
||||
|
||||
def _choose_image(self):
|
||||
path, _ = QFileDialog.getOpenFileName(
|
||||
self, "Choisir une image", "",
|
||||
"Images (*.png *.jpg *.jpeg *.bmp *.gif *.tiff)"
|
||||
)
|
||||
if path:
|
||||
self._image_path = path
|
||||
self.lbl_file.setText(path.split("/")[-1].split("\\")[-1])
|
||||
self.lbl_file.setStyleSheet("color: #0066cc;")
|
||||
|
||||
def get_settings(self):
|
||||
apply_text = self.combo_apply.currentText()
|
||||
if "courante" in apply_text:
|
||||
apply_to = "current"
|
||||
elif "paires" in apply_text.lower():
|
||||
apply_to = "even"
|
||||
elif "impaires" in apply_text.lower():
|
||||
apply_to = "odd"
|
||||
else:
|
||||
apply_to = "all"
|
||||
|
||||
return {
|
||||
"image_path": self._image_path,
|
||||
"x": self.spin_x.value() * mm,
|
||||
"y": self.spin_y.value() * mm,
|
||||
"width": self.spin_w.value() * mm,
|
||||
"height": self.spin_h.value() * mm if self.spin_h.value() > 0 else None,
|
||||
"apply_to": apply_to,
|
||||
"current_page": self._current_page,
|
||||
}
|
||||
Reference in New Issue
Block a user