Add / Edit a .lib or .inc library link.
| 6 | |
| 7 | |
| 8 | class LibraryLinkDialog(QDialog): |
| 9 | """Add / Edit a .lib or .inc library link.""" |
| 10 | |
| 11 | def __init__(self, directive: str = "lib", simulator: str = "SLiCAP", |
| 12 | file_path: str = "", corner: str = "", parent=None): |
| 13 | super().__init__(parent, Qt.Window) |
| 14 | self.setWindowTitle("Add / Edit Library Link") |
| 15 | self.setMinimumWidth(480) |
| 16 | |
| 17 | layout = QVBoxLayout(self) |
| 18 | form = QFormLayout() |
| 19 | |
| 20 | self._directive_combo = QComboBox() |
| 21 | self._directive_combo.addItems([".lib", ".inc"]) |
| 22 | self._directive_combo.setCurrentText(f".{directive}") |
| 23 | form.addRow("Directive:", self._directive_combo) |
| 24 | |
| 25 | self._sim_combo = QComboBox() |
| 26 | self._sim_combo.addItems(["SLiCAP", "SPICE"]) |
| 27 | self._sim_combo.setCurrentText(simulator) |
| 28 | form.addRow("Simulator:", self._sim_combo) |
| 29 | |
| 30 | file_row = QHBoxLayout() |
| 31 | self._file_edit = QLineEdit(file_path) |
| 32 | self._file_edit.setPlaceholderText("Library file path…") |
| 33 | browse_btn = QPushButton("Browse…") |
| 34 | browse_btn.clicked.connect(self._browse) |
| 35 | file_row.addWidget(self._file_edit, 1) |
| 36 | file_row.addWidget(browse_btn) |
| 37 | form.addRow("File:", file_row) |
| 38 | |
| 39 | self._corner_label = QLabel("Corner:") |
| 40 | self._corner_edit = QLineEdit(corner) |
| 41 | self._corner_edit.setPlaceholderText("optional, e.g. TT") |
| 42 | form.addRow(self._corner_label, self._corner_edit) |
| 43 | |
| 44 | layout.addLayout(form) |
| 45 | |
| 46 | buttons = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) |
| 47 | buttons.accepted.connect(self.accept) |
| 48 | buttons.rejected.connect(self.reject) |
| 49 | layout.addWidget(buttons) |
| 50 | |
| 51 | self._directive_combo.currentTextChanged.connect(self._update_corner_visibility) |
| 52 | self._sim_combo.currentTextChanged.connect(self._update_corner_visibility) |
| 53 | self._update_corner_visibility() |
| 54 | |
| 55 | def _update_corner_visibility(self) -> None: |
| 56 | show = (self._directive_combo.currentText() == ".lib" |
| 57 | and self._sim_combo.currentText() == "SPICE") |
| 58 | self._corner_label.setVisible(show) |
| 59 | self._corner_edit.setVisible(show) |
| 60 | |
| 61 | def _browse(self) -> None: |
| 62 | from . import project |
| 63 | path, _ = QFileDialog.getOpenFileName( |
| 64 | self, "Select Library File", |
| 65 | self._file_edit.text() or str(project.subdir("lib")), |
no outgoing calls
no test coverage detected