gui.dialogs.clean_dialog
1from pathlib import Path 2 3from PySide6.QtWidgets import ( 4 QDialog, QVBoxLayout, QHBoxLayout, QLabel, 5 QCheckBox, QPushButton, QDialogButtonBox, 6 QGroupBox, 7) 8from gui.utils.dropdown_button import DropdownButton 9 10 11class CleanDialog(QDialog): 12 def __init__(self, courses: list[Path], current_course: Path | None = None, parent=None): 13 super().__init__(parent) 14 self.setWindowTitle('Limpiar output') 15 self.setMinimumWidth(340) 16 self._courses = courses 17 self._checks: dict[Path, QCheckBox] = {} 18 self._build_ui(current_course) 19 20 def _build_ui(self, current_course: Path | None) -> None: 21 layout = QVBoxLayout(self) 22 layout.setSpacing(10) 23 24 # Cursos 25 grp = QGroupBox('Cursos a limpiar') 26 grp_lay = QVBoxLayout(grp) 27 for course in self._courses: 28 cb = QCheckBox(course.name) 29 cb.setChecked(current_course is None or course == current_course) 30 grp_lay.addWidget(cb) 31 self._checks[course] = cb 32 layout.addWidget(grp) 33 34 # Tipo 35 hlay = QHBoxLayout() 36 hlay.addWidget(QLabel('Tipo de ficheros:')) 37 self._tipo_combo = DropdownButton() 38 self._tipo_combo.addItems(['ambos (odp + pdf)', 'solo odp', 'solo pdf']) 39 hlay.addWidget(self._tipo_combo) 40 layout.addLayout(hlay) 41 42 btns = QDialogButtonBox( 43 QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel 44 ) 45 btns.accepted.connect(self.accept) 46 btns.rejected.connect(self.reject) 47 layout.addWidget(btns) 48 49 def selected_courses(self) -> list[Path]: 50 return [p for p, cb in self._checks.items() if cb.isChecked()] 51 52 def selected_tipo(self) -> str | None: 53 idx = self._tipo_combo.currentIndex() 54 return [None, 'odp', 'pdf'][idx]
class
CleanDialog(PySide6.QtWidgets.QDialog):
12class CleanDialog(QDialog): 13 def __init__(self, courses: list[Path], current_course: Path | None = None, parent=None): 14 super().__init__(parent) 15 self.setWindowTitle('Limpiar output') 16 self.setMinimumWidth(340) 17 self._courses = courses 18 self._checks: dict[Path, QCheckBox] = {} 19 self._build_ui(current_course) 20 21 def _build_ui(self, current_course: Path | None) -> None: 22 layout = QVBoxLayout(self) 23 layout.setSpacing(10) 24 25 # Cursos 26 grp = QGroupBox('Cursos a limpiar') 27 grp_lay = QVBoxLayout(grp) 28 for course in self._courses: 29 cb = QCheckBox(course.name) 30 cb.setChecked(current_course is None or course == current_course) 31 grp_lay.addWidget(cb) 32 self._checks[course] = cb 33 layout.addWidget(grp) 34 35 # Tipo 36 hlay = QHBoxLayout() 37 hlay.addWidget(QLabel('Tipo de ficheros:')) 38 self._tipo_combo = DropdownButton() 39 self._tipo_combo.addItems(['ambos (odp + pdf)', 'solo odp', 'solo pdf']) 40 hlay.addWidget(self._tipo_combo) 41 layout.addLayout(hlay) 42 43 btns = QDialogButtonBox( 44 QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel 45 ) 46 btns.accepted.connect(self.accept) 47 btns.rejected.connect(self.reject) 48 layout.addWidget(btns) 49 50 def selected_courses(self) -> list[Path]: 51 return [p for p, cb in self._checks.items() if cb.isChecked()] 52 53 def selected_tipo(self) -> str | None: 54 idx = self._tipo_combo.currentIndex() 55 return [None, 'odp', 'pdf'][idx]
QDialog(self, /, parent: PySide6.QtWidgets.QWidget | None = None, f: PySide6.QtCore.Qt.WindowType = Default(Qt.WindowFlags), *, sizeGripEnabled: bool | None = None, modal: bool | None = None) -> None