Debian Codegraph @

Source/Core/DolphinQt/QtUtils/ModalMessageBox.cpp

raw symbols SCIP
1 // Copyright 2019 Dolphin Emulator Project
2 // SPDX-License-Identifier: GPL-2.0-or-later
3
4 #include "DolphinQt/QtUtils/ModalMessageBox.h"
5
6 #include <QApplication>
7
8 ModalMessageBox::ModalMessageBox(QWidget* parent, Qt::WindowModality modality)
9 : QMessageBox(parent != nullptr ? parent->window() : nullptr)
10 {
11 setWindowModality(modality);
12 setWindowFlags(Qt::Sheet | Qt::WindowTitleHint | Qt::CustomizeWindowHint);
13
14 // No parent is still preferable to showing a hidden parent here.
15 if (parent != nullptr && !parent->window()->isVisible())
16 setParent(nullptr);
17 }
18
19 static inline int ExecMessageBox(ModalMessageBox::Icon icon, QWidget* parent, const QString& title,
20 const QString& text, ModalMessageBox::StandardButtons buttons,
21 ModalMessageBox::StandardButton default_button,
22 Qt::WindowModality modality, const QString& detailed_text)
23 {
24 ModalMessageBox msg(parent, modality);
25 msg.setIcon(icon);
26 msg.setWindowTitle(title);
27 msg.setText(text);
28 msg.setStandardButtons(buttons);
29 msg.setDefaultButton(default_button);
30 msg.setDetailedText(detailed_text);
31
32 return msg.exec();
33 }
34
35 int ModalMessageBox::critical(QWidget* parent, const QString& title, const QString& text,
36 StandardButtons buttons, StandardButton default_button,
37 Qt::WindowModality modality, const QString& detailedText)
38 {
39 return ExecMessageBox(QMessageBox::Critical, parent, title, text, buttons, default_button,
40 modality, detailedText);
41 }
42
43 int ModalMessageBox::information(QWidget* parent, const QString& title, const QString& text,
44 StandardButtons buttons, StandardButton default_button,
45 Qt::WindowModality modality, const QString& detailedText)
46 {
47 return ExecMessageBox(QMessageBox::Information, parent, title, text, buttons, default_button,
48 modality, detailedText);
49 }
50
51 int ModalMessageBox::question(QWidget* parent, const QString& title, const QString& text,
52 StandardButtons buttons, StandardButton default_button,
53 Qt::WindowModality modality, const QString& detailedText)
54 {
55 return ExecMessageBox(QMessageBox::Warning, parent, title, text, buttons, default_button,
56 modality, detailedText);
57 }
58
59 int ModalMessageBox::warning(QWidget* parent, const QString& title, const QString& text,
60 StandardButtons buttons, StandardButton default_button,
61 Qt::WindowModality modality, const QString& detailedText)
62 {
63 return ExecMessageBox(QMessageBox::Warning, parent, title, text, buttons, default_button,
64 modality, detailedText);
65 }