gui.dialogs.clean_dialog
1# Copyright (C) 2026 David Vaquero <pepesan@gmail.com> 2# 3# This program is free software: you can redistribute it and/or modify 4# it under the terms of the GNU General Public License as published by 5# the Free Software Foundation, either version 3 of the License, or 6# (at your option) any later version. 7# 8# This program is distributed in the hope that it will be useful, 9# but WITHOUT ANY WARRANTY; without even the implied warranty of 10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11# GNU General Public License for more details. 12# 13# You should have received a copy of the GNU General Public License 14# along with this program. If not, see <https://www.gnu.org/licenses/>. 15 16from pathlib import Path 17 18from PySide6.QtWidgets import ( 19 QDialog, QVBoxLayout, QHBoxLayout, QLabel, 20 QCheckBox, QPushButton, QDialogButtonBox, 21 QGroupBox, 22) 23from gui.utils.dropdown_button import DropdownButton 24 25 26class CleanDialog(QDialog): 27 def __init__(self, courses: list[Path], current_course: Path | None = None, parent=None): 28 super().__init__(parent) 29 self.setWindowTitle('Limpiar output') 30 self.setMinimumWidth(340) 31 self._courses = courses 32 self._checks: dict[Path, QCheckBox] = {} 33 self._build_ui(current_course) 34 35 def _build_ui(self, current_course: Path | None) -> None: 36 layout = QVBoxLayout(self) 37 layout.setSpacing(10) 38 39 # Cursos 40 grp = QGroupBox('Cursos a limpiar') 41 grp_lay = QVBoxLayout(grp) 42 for course in self._courses: 43 cb = QCheckBox(course.name) 44 cb.setChecked(current_course is None or course == current_course) 45 grp_lay.addWidget(cb) 46 self._checks[course] = cb 47 layout.addWidget(grp) 48 49 # Tipo 50 hlay = QHBoxLayout() 51 hlay.addWidget(QLabel('Tipo de ficheros:')) 52 self._tipo_combo = DropdownButton() 53 self._tipo_combo.addItems(['ambos (odp + pdf)', 'solo odp', 'solo pdf']) 54 hlay.addWidget(self._tipo_combo) 55 layout.addLayout(hlay) 56 57 btns = QDialogButtonBox( 58 QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel 59 ) 60 btns.accepted.connect(self.accept) 61 btns.rejected.connect(self.reject) 62 layout.addWidget(btns) 63 64 def selected_courses(self) -> list[Path]: 65 return [p for p, cb in self._checks.items() if cb.isChecked()] 66 67 def selected_tipo(self) -> str | None: 68 idx = self._tipo_combo.currentIndex() 69 return [None, 'odp', 'pdf'][idx]
class
CleanDialog(PySide6.QtWidgets.QDialog):
27class CleanDialog(QDialog): 28 def __init__(self, courses: list[Path], current_course: Path | None = None, parent=None): 29 super().__init__(parent) 30 self.setWindowTitle('Limpiar output') 31 self.setMinimumWidth(340) 32 self._courses = courses 33 self._checks: dict[Path, QCheckBox] = {} 34 self._build_ui(current_course) 35 36 def _build_ui(self, current_course: Path | None) -> None: 37 layout = QVBoxLayout(self) 38 layout.setSpacing(10) 39 40 # Cursos 41 grp = QGroupBox('Cursos a limpiar') 42 grp_lay = QVBoxLayout(grp) 43 for course in self._courses: 44 cb = QCheckBox(course.name) 45 cb.setChecked(current_course is None or course == current_course) 46 grp_lay.addWidget(cb) 47 self._checks[course] = cb 48 layout.addWidget(grp) 49 50 # Tipo 51 hlay = QHBoxLayout() 52 hlay.addWidget(QLabel('Tipo de ficheros:')) 53 self._tipo_combo = DropdownButton() 54 self._tipo_combo.addItems(['ambos (odp + pdf)', 'solo odp', 'solo pdf']) 55 hlay.addWidget(self._tipo_combo) 56 layout.addLayout(hlay) 57 58 btns = QDialogButtonBox( 59 QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel 60 ) 61 btns.accepted.connect(self.accept) 62 btns.rejected.connect(self.reject) 63 layout.addWidget(btns) 64 65 def selected_courses(self) -> list[Path]: 66 return [p for p, cb in self._checks.items() if cb.isChecked()] 67 68 def selected_tipo(self) -> str | None: 69 idx = self._tipo_combo.currentIndex() 70 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