Coverage for pyPhotoAlbum/dialogs/print_settings_dialog.py: 14%
51 statements
« prev ^ index » next coverage.py v7.14.1, created at 2026-06-20 12:55 +0000
« prev ^ index » next coverage.py v7.14.1, created at 2026-06-20 12:55 +0000
1"""
2Print Settings Dialog for pyPhotoAlbum
4Project-level bleed and safe-area configuration applied uniformly to all pages.
5"""
7from typing import Any, Dict
8from PyQt6.QtWidgets import (
9 QDialog,
10 QVBoxLayout,
11 QHBoxLayout,
12 QLabel,
13 QDoubleSpinBox,
14 QPushButton,
15 QGroupBox,
16)
17from pyPhotoAlbum.project import Project
20class PrintSettingsDialog(QDialog):
21 """Dialog for configuring project-wide print settings (bleed and safe area)."""
23 def __init__(self, parent, project: Project):
24 super().__init__(parent)
25 self.project = project
26 self._setup_ui()
28 def _setup_ui(self):
29 self.setWindowTitle("Print Settings")
30 self.setMinimumWidth(340)
32 layout = QVBoxLayout()
34 group = QGroupBox("Bleed && Safe Area (applied to all pages)")
35 group_layout = QVBoxLayout()
37 # Bleed
38 bleed_layout = QHBoxLayout()
39 bleed_layout.addWidget(QLabel("Bleed Margin:"))
40 self.bleed_spinbox = QDoubleSpinBox()
41 self.bleed_spinbox.setRange(0.0, 20.0)
42 self.bleed_spinbox.setSingleStep(0.5)
43 self.bleed_spinbox.setDecimals(1)
44 self.bleed_spinbox.setSuffix(" mm")
45 self.bleed_spinbox.setValue(self.project.page_bleed_mm)
46 self.bleed_spinbox.setToolTip(
47 "Extra white space added around each page in the exported PDF.\n"
48 "The printer cuts here — 3 mm is standard."
49 )
50 bleed_layout.addWidget(self.bleed_spinbox)
51 group_layout.addLayout(bleed_layout)
53 # Safe area
54 safe_layout = QHBoxLayout()
55 safe_layout.addWidget(QLabel("Safe Area:"))
56 self.safe_spinbox = QDoubleSpinBox()
57 self.safe_spinbox.setRange(0.0, 50.0)
58 self.safe_spinbox.setSingleStep(0.5)
59 self.safe_spinbox.setDecimals(1)
60 self.safe_spinbox.setSuffix(" mm")
61 self.safe_spinbox.setValue(self.project.page_safe_area_mm)
62 self.safe_spinbox.setToolTip(
63 "Keep text and important content inside this distance from the cut/trim line.\n"
64 "Shown as a red guide in the editor."
65 )
66 safe_layout.addWidget(self.safe_spinbox)
67 group_layout.addLayout(safe_layout)
69 group.setLayout(group_layout)
70 layout.addWidget(group)
72 # Buttons
73 btn_layout = QHBoxLayout()
74 cancel_btn = QPushButton("Cancel")
75 cancel_btn.clicked.connect(self.reject)
76 ok_btn = QPushButton("OK")
77 ok_btn.clicked.connect(self.accept)
78 ok_btn.setDefault(True)
79 btn_layout.addStretch()
80 btn_layout.addWidget(cancel_btn)
81 btn_layout.addWidget(ok_btn)
82 layout.addLayout(btn_layout)
84 self.setLayout(layout)
86 def get_values(self) -> Dict[str, Any]:
87 return {
88 "page_bleed_mm": self.bleed_spinbox.value(),
89 "page_safe_area_mm": self.safe_spinbox.value(),
90 }