| 1 | // SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. |
| 2 | // |
| 3 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 4 | |
| 5 | #include "messagebox.h" |
| 6 | |
| 7 | #include <QMessageBox> |
| 8 | #include <QApplication> |
| 9 | #include <QWidget> |
| 10 | |
| 11 | namespace Internal { |
| 12 | |
| 13 | namespace { |
| 14 | |
| 15 | QWidget *message(QMessageBox::Icon icon, const QString &title, const QString &desciption) |
| 16 | { |
| 17 | QMessageBox *messageBox = new QMessageBox(icon, |
| 18 | title, |
| 19 | desciption, |
| 20 | QMessageBox::Ok/*, |
| 21 | dialogParent()*/); |
| 22 | |
| 23 | messageBox->setAttribute(Qt::WA_DeleteOnClose); |
| 24 | messageBox->setModal(true); |
| 25 | messageBox->show(); |
| 26 | return messageBox; |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | QWidget *warning(const QString &title, const QString &desciption) |
| 31 | { |
| 32 | return message(QMessageBox::Warning, title, desciption); |
| 33 | } |
| 34 | |
| 35 | QWidget *information(const QString &title, const QString &desciption) |
| 36 | { |
| 37 | return message(QMessageBox::Information, title, desciption); |
| 38 | } |
| 39 | |
| 40 | QWidget *critical(const QString &title, const QString &desciption) |
| 41 | { |
| 42 | return message(QMessageBox::Critical, title, desciption); |
| 43 | } |
| 44 | } |
| 45 | |