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:
Jules
2026-03-21 13:50:55 +01:00
parent 500309ed53
commit e7a27018e5
6 changed files with 427 additions and 5 deletions

View 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,
}

View File

@@ -0,0 +1,117 @@
"""Dialogue Ajouter du texte sur une page."""
from PyQt6.QtWidgets import (QDialog, QVBoxLayout, QHBoxLayout, QLabel,
QGroupBox, QComboBox, QSpinBox, QLineEdit,
QDialogButtonBox, QDoubleSpinBox, QTextEdit,
QColorDialog, QPushButton)
from PyQt6.QtGui import QColor
from PyQt6.QtCore import Qt
from reportlab.lib.units import mm
class AddTextDialog(QDialog):
def __init__(self, total_pages=1, current_page=0, parent=None):
super().__init__(parent)
self.setWindowTitle("Ajouter du texte")
self.setMinimumWidth(450)
self._total_pages = total_pages
self._current_page = current_page
self._color = QColor(0, 0, 0)
self._setup_ui()
def _setup_ui(self):
layout = QVBoxLayout(self)
# Texte
grp_text = QGroupBox("Texte")
tl = QVBoxLayout(grp_text)
self.edit_text = QTextEdit()
self.edit_text.setPlaceholderText("Saisissez le texte a ajouter...")
self.edit_text.setMaximumHeight(80)
tl.addWidget(self.edit_text)
layout.addWidget(grp_text)
# Police
grp_font = QGroupBox("Police")
fl = QHBoxLayout(grp_font)
self.combo_font = QComboBox()
self.combo_font.addItems(["Helvetica", "Helvetica-Bold", "Times-Roman",
"Times-Bold", "Courier", "Courier-Bold"])
fl.addWidget(self.combo_font)
fl.addWidget(QLabel("Taille :"))
self.spin_size = QSpinBox()
self.spin_size.setRange(4, 200)
self.spin_size.setValue(12)
fl.addWidget(self.spin_size)
self.btn_color = QPushButton("Couleur")
self.btn_color.setStyleSheet("background: black; color: white; padding: 4px 12px;")
self.btn_color.clicked.connect(self._choose_color)
fl.addWidget(self.btn_color)
layout.addWidget(grp_font)
# Position
grp_pos = QGroupBox("Position (mm depuis le bas-gauche)")
pl = QHBoxLayout(grp_pos)
pl.addWidget(QLabel("X :"))
self.spin_x = QDoubleSpinBox()
self.spin_x.setRange(0, 2000)
self.spin_x.setValue(20)
self.spin_x.setSuffix(" mm")
pl.addWidget(self.spin_x)
pl.addWidget(QLabel("Y :"))
self.spin_y = QDoubleSpinBox()
self.spin_y.setRange(0, 2000)
self.spin_y.setValue(20)
self.spin_y.setSuffix(" mm")
pl.addWidget(self.spin_y)
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_color(self):
color = QColorDialog.getColor(self._color, self)
if color.isValid():
self._color = color
self.btn_color.setStyleSheet(
f"background: {color.name()}; color: {'white' if color.lightness() < 128 else 'black'}; padding: 4px 12px;"
)
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 {
"text": self.edit_text.toPlainText(),
"font_name": self.combo_font.currentText(),
"font_size": self.spin_size.value(),
"color": (self._color.redF(), self._color.greenF(), self._color.blueF()),
"x": self.spin_x.value() * mm,
"y": self.spin_y.value() * mm,
"apply_to": apply_to,
"current_page": self._current_page,
}