From 8580b3ba1f43de17df7b8249b1b7972905728b0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Lam?= Date: Thu, 5 Oct 2017 18:20:18 +0200 Subject: [PATCH] Qt: Add ignore button for panic alerts Allows easily disabling panic alerts during a session if needed. --- Source/Core/DolphinQt2/Main.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Source/Core/DolphinQt2/Main.cpp b/Source/Core/DolphinQt2/Main.cpp index 7d4e497b97..567732cf2d 100644 --- a/Source/Core/DolphinQt2/Main.cpp +++ b/Source/Core/DolphinQt2/Main.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include "Common/MsgHandler.h" @@ -30,7 +31,11 @@ static bool QtMsgAlertHandler(const char* caption, const char* text, bool yes_no QMessageBox message_box(QApplication::activeWindow()); message_box.setWindowTitle(QString::fromUtf8(caption)); message_box.setText(QString::fromUtf8(text)); + message_box.setStandardButtons(yes_no ? QMessageBox::Yes | QMessageBox::No : QMessageBox::Ok); + if (style == MsgType::Warning) + message_box.addButton(QMessageBox::Ignore)->setText(QObject::tr("Ignore for this session")); + message_box.setIcon([&] { switch (style) { @@ -47,7 +52,14 @@ static bool QtMsgAlertHandler(const char* caption, const char* text, bool yes_no return QMessageBox::NoIcon; }()); - return message_box.exec() == QMessageBox::Yes; + const int button = message_box.exec(); + if (button == QMessageBox::Yes) + return true; + + if (button == QMessageBox::Ignore) + SetEnableAlert(false); + + return false; }); }