from typing import Optional

from PyQt6.QtWidgets import QMessageBox


class CloseBox(QMessageBox):
    """
    Box for asking user if he really wants to close the process.
    """

    def __init__(self, question_text: Optional[str] = None) -> None:
        super().__init__()
        if not question_text:
            question_text = (
                "Opravdu chcete ukoncit proces? Vsechna data budou vymazana!"
            )
        self.question_text = question_text
        self._init_close_box()

    def _init_close_box(self) -> None:
        self.setIcon(QMessageBox.Icon.Warning)
        self.setWindowTitle("Ukonceni procesu")
        self.setText("Ukonceni procesu")
        self.setInformativeText(self.question_text)
        self.addButton("Ano, ukoncit", QMessageBox.ButtonRole.YesRole)
        self.addButton("Ne, zůstat", QMessageBox.ButtonRole.NoRole)
