Skip to content
Permalink
Browse files

UI: Allow to specify modality of ready ModalMessageBoxes

  • Loading branch information
CookiePLMonster committed Nov 10, 2019
1 parent b712cc1 commit af92a88aa083c4cecf3486bb3b8108b8059b1904
Showing with 27 additions and 14 deletions.
  1. +19 −10 Source/Core/DolphinQt/QtUtils/ModalMessageBox.cpp
  2. +8 −4 Source/Core/DolphinQt/QtUtils/ModalMessageBox.h
@@ -19,9 +19,10 @@ ModalMessageBox::ModalMessageBox(QWidget* parent, Qt::WindowModality modality)

static inline int ExecMessageBox(ModalMessageBox::Icon icon, QWidget* parent, const QString& title,
const QString& text, ModalMessageBox::StandardButtons buttons,
ModalMessageBox::StandardButton default_button)
ModalMessageBox::StandardButton default_button,
Qt::WindowModality modality)
{
ModalMessageBox msg(parent);
ModalMessageBox msg(parent, modality);
msg.setIcon(icon);
msg.setWindowTitle(title);
msg.setText(text);
@@ -32,25 +33,33 @@ static inline int ExecMessageBox(ModalMessageBox::Icon icon, QWidget* parent, co
}

int ModalMessageBox::critical(QWidget* parent, const QString& title, const QString& text,
StandardButtons buttons, StandardButton default_button)
StandardButtons buttons, StandardButton default_button,
Qt::WindowModality modality)
{
return ExecMessageBox(QMessageBox::Critical, parent, title, text, buttons, default_button);
return ExecMessageBox(QMessageBox::Critical, parent, title, text, buttons, default_button,
modality);
}

int ModalMessageBox::information(QWidget* parent, const QString& title, const QString& text,
StandardButtons buttons, StandardButton default_button)
StandardButtons buttons, StandardButton default_button,
Qt::WindowModality modality)
{
return ExecMessageBox(QMessageBox::Information, parent, title, text, buttons, default_button);
return ExecMessageBox(QMessageBox::Information, parent, title, text, buttons, default_button,
modality);
}

int ModalMessageBox::question(QWidget* parent, const QString& title, const QString& text,
StandardButtons buttons, StandardButton default_button)
StandardButtons buttons, StandardButton default_button,
Qt::WindowModality modality)
{
return ExecMessageBox(QMessageBox::Warning, parent, title, text, buttons, default_button);
return ExecMessageBox(QMessageBox::Warning, parent, title, text, buttons, default_button,
modality);
}

int ModalMessageBox::warning(QWidget* parent, const QString& title, const QString& text,
StandardButtons buttons, StandardButton default_button)
StandardButtons buttons, StandardButton default_button,
Qt::WindowModality modality)
{
return ExecMessageBox(QMessageBox::Warning, parent, title, text, buttons, default_button);
return ExecMessageBox(QMessageBox::Warning, parent, title, text, buttons, default_button,
modality);
}
@@ -13,11 +13,15 @@ class ModalMessageBox : public QMessageBox
explicit ModalMessageBox(QWidget* parent, Qt::WindowModality modality = Qt::WindowModal);

static int critical(QWidget* parent, const QString& title, const QString& text,
StandardButtons buttons = Ok, StandardButton default_button = NoButton);
StandardButtons buttons = Ok, StandardButton default_button = NoButton,
Qt::WindowModality modality = Qt::WindowModal);
static int information(QWidget* parent, const QString& title, const QString& text,
StandardButtons buttons = Ok, StandardButton default_button = NoButton);
StandardButtons buttons = Ok, StandardButton default_button = NoButton,
Qt::WindowModality modality = Qt::WindowModal);
static int question(QWidget* parent, const QString& title, const QString& text,
StandardButtons buttons = Yes | No, StandardButton default_button = NoButton);
StandardButtons buttons = Yes | No, StandardButton default_button = NoButton,
Qt::WindowModality modality = Qt::WindowModal);
static int warning(QWidget* parent, const QString& title, const QString& text,
StandardButtons buttons = Ok, StandardButton default_button = NoButton);
StandardButtons buttons = Ok, StandardButton default_button = NoButton,
Qt::WindowModality modality = Qt::WindowModal);
};

0 comments on commit af92a88

Please sign in to comment.
You can’t perform that action at this time.