from PyQt6 import QtWidgets
from .dialog_sources.Ui_apparat_extend import Ui_Dialog
from src import Icon


class ApparatExtendDialog(QtWidgets.QDialog, Ui_Dialog):
    def __init__(
        self,
    ):
        super().__init__()
        self.setupUi(self)
        self.setWindowIcon(Icon("edit").icon)
        self.setWindowTitle("Semesterapparat verlängern")
        self.buttonBox.accepted.connect(self.accept)
        self.buttonBox.rejected.connect(self.reject)

    def get_data(self):
        return {
            "semester": (
                f"SoSe {int(self.sem_year.text()[-2:])}"
                if self.rad_sommer.isChecked()
                else f"WiSe {int(self.sem_year.text()[-2:])}/{int(self.sem_year.text()[-2:]) + 1}"
            ),
            "dauerapp": (
                self.dauerapp.isChecked() if self.dauerapp.isChecked() else False
            ),
        }


if __name__ == "__main__":
    import sys

    app = QtWidgets.QApplication(sys.argv)
    Dialog = QtWidgets.QDialog()
    ui = Ui_Dialog()
    ui.setupUi(Dialog)
    Dialog.show()
    sys.exit(app.exec())
