Dialog for setting export border dimensions and visibility.
| 6 | |
| 7 | |
| 8 | class BorderDialog(QDialog): |
| 9 | """Dialog for setting export border dimensions and visibility.""" |
| 10 | |
| 11 | def __init__(self, width: int = 400, height: int = 300, |
| 12 | show_in_export: bool = True, parent=None): |
| 13 | super().__init__(parent, Qt.Window) |
| 14 | self.setWindowTitle("Border") |
| 15 | outer = QVBoxLayout() |
| 16 | outer.setSizeConstraint(QLayout.SetFixedSize) |
| 17 | self.setLayout(outer) |
| 18 | |
| 19 | grid = QGridLayout() |
| 20 | grid.setColumnStretch(1, 1) |
| 21 | |
| 22 | self._w_spin = QSpinBox() |
| 23 | self._w_spin.setRange(10, 10000) |
| 24 | self._w_spin.setValue(width) |
| 25 | self._w_spin.setSuffix(" units") |
| 26 | grid.addWidget(QLabel("Width"), 0, 0) |
| 27 | grid.addWidget(self._w_spin, 0, 1) |
| 28 | |
| 29 | self._h_spin = QSpinBox() |
| 30 | self._h_spin.setRange(10, 10000) |
| 31 | self._h_spin.setValue(height) |
| 32 | self._h_spin.setSuffix(" units") |
| 33 | grid.addWidget(QLabel("Height"), 1, 0) |
| 34 | grid.addWidget(self._h_spin, 1, 1) |
| 35 | |
| 36 | outer.addLayout(grid) |
| 37 | |
| 38 | hint = QLabel("(1 grid square = 5 units, resistor pin-to-pin = 50 units)") |
| 39 | hint.setStyleSheet("color: grey; font-size: 9pt;") |
| 40 | outer.addWidget(hint) |
| 41 | |
| 42 | self._show_cb = QCheckBox("Include border line in export") |
| 43 | self._show_cb.setChecked(show_in_export) |
| 44 | outer.addWidget(self._show_cb) |
| 45 | |
| 46 | buttons = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) |
| 47 | buttons.accepted.connect(self.accept) |
| 48 | buttons.rejected.connect(self.reject) |
| 49 | outer.addWidget(buttons) |
| 50 | |
| 51 | def border_width(self) -> int: |
| 52 | return self._w_spin.value() |
| 53 | |
| 54 | def border_height(self) -> int: |
| 55 | return self._h_spin.value() |
| 56 | |
| 57 | def show_in_export(self) -> bool: |
| 58 | return self._show_cb.isChecked() |
no outgoing calls
no test coverage detected