diff options
| author | Mat M <mathew1800@gmail.com> | 2019-03-04 17:40:27 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-03-04 17:40:27 -0500 |
| commit | 147f7ca3213aef22dfe45bfab86e2d221aa248bf (patch) | |
| tree | b32f19c11585ea4e1b205eb2e959e695636e5a19 /Source/Core/DolphinQt/QtUtils/ModalMessageBox.cpp | |
| parent | a59010fa29ab10ca031bea87fc5df165e70e2dff (diff) | |
| parent | 70da86f1c3c933ce28d122f95f34ff6c24f89d80 (diff) | |
Merge pull request #7849 from spycrab/qt_modal_again
Qt: Make every messagebox modal
Diffstat (limited to 'Source/Core/DolphinQt/QtUtils/ModalMessageBox.cpp')
| -rw-r--r-- | Source/Core/DolphinQt/QtUtils/ModalMessageBox.cpp | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/Source/Core/DolphinQt/QtUtils/ModalMessageBox.cpp b/Source/Core/DolphinQt/QtUtils/ModalMessageBox.cpp new file mode 100644 index 0000000000..25d10de729 --- /dev/null +++ b/Source/Core/DolphinQt/QtUtils/ModalMessageBox.cpp @@ -0,0 +1,54 @@ +// Copyright 2019 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#include "DolphinQt/QtUtils/ModalMessageBox.h" + +#include <QApplication> + +ModalMessageBox::ModalMessageBox(QWidget* parent) : QMessageBox(parent) +{ + setWindowModality(Qt::WindowModal); + + // No parent is still preferable to showing a hidden parent here. + if (parent != nullptr && !parent->isVisible()) + setParent(nullptr); +} + +static inline int ExecMessageBox(ModalMessageBox::Icon icon, QWidget* parent, const QString& title, + const QString& text, ModalMessageBox::StandardButtons buttons, + ModalMessageBox::StandardButton default_button) +{ + ModalMessageBox msg(parent); + msg.setIcon(icon); + msg.setWindowTitle(title); + msg.setText(text); + msg.setStandardButtons(buttons); + msg.setDefaultButton(default_button); + + return msg.exec(); +} + +int ModalMessageBox::critical(QWidget* parent, const QString& title, const QString& text, + StandardButtons buttons, StandardButton default_button) +{ + return ExecMessageBox(QMessageBox::Critical, parent, title, text, buttons, default_button); +} + +int ModalMessageBox::information(QWidget* parent, const QString& title, const QString& text, + StandardButtons buttons, StandardButton default_button) +{ + return ExecMessageBox(QMessageBox::Information, parent, title, text, buttons, default_button); +} + +int ModalMessageBox::question(QWidget* parent, const QString& title, const QString& text, + StandardButtons buttons, StandardButton default_button) +{ + return ExecMessageBox(QMessageBox::Critical, parent, title, text, buttons, default_button); +} + +int ModalMessageBox::warning(QWidget* parent, const QString& title, const QString& text, + StandardButtons buttons, StandardButton default_button) +{ + return ExecMessageBox(QMessageBox::Warning, parent, title, text, buttons, default_button); +} |
