Files
copydev-imposing-tool/app/dialogs/page_numbers_dialog.py
Jules 202834a794 V3.6.0 — Demonter pages, masquage visuel, regles, bleeds, corrections
- Demonter les pages : couper en 2 sans reordonner (sous Delivretiser)
- Masquage visuel : selection au curseur sur l'apercu + plage de pages
- Regles horizontale/verticale en mm (menu Affichage)
- Fonds perdus : filigrane rouge pour visualiser les bleeds
- Reperes de coupe : marques a l'exterieur (page agrandie), 2 traits/coin
- Numerotation : couleur configurable via selecteur
- Decalage : Trim & Shift renomme en francais, creep -> chasse
- Recadrages multiples cumulatifs (plages differentes)
- Fix spinbox format personnalise (fleches aleatoires)
- Fix combo livret : option Automatique preservee

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-29 22:12:54 +02:00

146 lines
5.2 KiB
Python

"""Dialogue Numerotation de pages."""
from PyQt6.QtWidgets import (QDialog, QVBoxLayout, QHBoxLayout, QLabel,
QGroupBox, QComboBox, QSpinBox, QLineEdit,
QDialogButtonBox, QDoubleSpinBox, QPushButton,
QColorDialog)
from PyQt6.QtGui import QColor
from reportlab.lib.units import mm
class PageNumbersDialog(QDialog):
def __init__(self, parent=None):
super().__init__(parent)
self.setWindowTitle("Numerotation de pages")
self.setMinimumWidth(400)
self._color = QColor(0, 0, 0)
self._setup_ui()
def _setup_ui(self):
layout = QVBoxLayout(self)
# Position
grp_pos = QGroupBox("Position")
pl = QHBoxLayout(grp_pos)
pl.addWidget(QLabel("Emplacement :"))
self.combo_pos = QComboBox()
positions = [
"haut-gauche", "haut-centre", "haut-droite",
"milieu-gauche", "milieu-centre", "milieu-droite",
"bas-gauche", "bas-centre", "bas-droite"
]
self.combo_pos.addItems(positions)
self.combo_pos.setCurrentText("bas-centre")
pl.addWidget(self.combo_pos)
layout.addWidget(grp_pos)
# Police
grp_font = QGroupBox("Police")
fl = QHBoxLayout(grp_font)
fl.addWidget(QLabel("Police :"))
self.combo_font = QComboBox()
self.combo_font.addItems(["Helvetica", "Times-Roman", "Courier"])
fl.addWidget(self.combo_font)
fl.addWidget(QLabel("Taille :"))
self.spin_size = QSpinBox()
self.spin_size.setRange(4, 72)
self.spin_size.setValue(10)
fl.addWidget(self.spin_size)
layout.addWidget(grp_font)
# Couleur
color_layout = QHBoxLayout()
color_layout.addWidget(QLabel("Couleur :"))
self.btn_color = QPushButton()
self.btn_color.setFixedSize(60, 28)
self._update_color_button()
self.btn_color.clicked.connect(self._pick_color)
color_layout.addWidget(self.btn_color)
color_layout.addStretch()
layout.addLayout(color_layout)
# Texte
grp_text = QGroupBox("Texte")
tl = QHBoxLayout(grp_text)
tl.addWidget(QLabel("Prefixe :"))
self.edit_prefix = QLineEdit()
self.edit_prefix.setPlaceholderText("ex: Page ")
tl.addWidget(self.edit_prefix)
tl.addWidget(QLabel("Suffixe :"))
self.edit_suffix = QLineEdit()
self.edit_suffix.setPlaceholderText("ex: / 24")
tl.addWidget(self.edit_suffix)
layout.addWidget(grp_text)
# Numero de depart
start_layout = QHBoxLayout()
start_layout.addWidget(QLabel("Commencer a :"))
self.spin_start = QSpinBox()
self.spin_start.setRange(0, 9999)
self.spin_start.setValue(1)
start_layout.addWidget(self.spin_start)
start_layout.addStretch()
layout.addLayout(start_layout)
# Marges
margin_layout = QHBoxLayout()
margin_layout.addWidget(QLabel("Marge X :"))
self.spin_mx = QDoubleSpinBox()
self.spin_mx.setRange(0, 100)
self.spin_mx.setValue(10)
self.spin_mx.setSuffix(" mm")
margin_layout.addWidget(self.spin_mx)
margin_layout.addWidget(QLabel("Marge Y :"))
self.spin_my = QDoubleSpinBox()
self.spin_my.setRange(0, 100)
self.spin_my.setValue(10)
self.spin_my.setSuffix(" mm")
margin_layout.addWidget(self.spin_my)
layout.addLayout(margin_layout)
# Appliquer a
grp_apply = QGroupBox("Appliquer a")
al = QHBoxLayout(grp_apply)
self.combo_apply = QComboBox()
self.combo_apply.addItems(["Toutes les pages", "Pages paires", "Pages impaires"])
al.addWidget(self.combo_apply)
layout.addWidget(grp_apply)
# Boutons
buttons = QDialogButtonBox(
QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel
)
buttons.accepted.connect(self.accept)
buttons.rejected.connect(self.reject)
layout.addWidget(buttons)
def _pick_color(self):
color = QColorDialog.getColor(self._color, self, "Couleur de la numerotation")
if color.isValid():
self._color = color
self._update_color_button()
def _update_color_button(self):
self.btn_color.setStyleSheet(
f"background-color: {self._color.name()}; border: 1px solid #999; border-radius: 4px;"
)
def get_settings(self):
apply_map = {
"Toutes les pages": "all",
"Pages paires": "even",
"Pages impaires": "odd"
}
return {
"position": self.combo_pos.currentText(),
"font_name": self.combo_font.currentText(),
"font_size": self.spin_size.value(),
"color": (self._color.redF(), self._color.greenF(), self._color.blueF()),
"prefix": self.edit_prefix.text(),
"suffix": self.edit_suffix.text(),
"start_number": self.spin_start.value(),
"margin_x": self.spin_mx.value() * mm,
"margin_y": self.spin_my.value() * mm,
"apply_to": apply_map[self.combo_apply.currentText()],
}