from __future__ import annotations

from PySide6.QtWidgets import QMessageBox, QWidget


def ask_yes_no(parent: QWidget | None, title: str, text: str, *, default_yes: bool = False) -> bool:
    msg = QMessageBox(parent)
    msg.setIcon(QMessageBox.Question)
    msg.setWindowTitle(title)
    msg.setText(text)
    btn_yes = msg.addButton("Так", QMessageBox.YesRole)
    btn_no = msg.addButton("Ні", QMessageBox.NoRole)
    msg.setDefaultButton(btn_yes if default_yes else btn_no)
    msg.exec()
    return msg.clickedButton() is btn_yes
