mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-05 01:20:42 +00:00
utils: Add new messageBox helper that includes checkBox
This commit is contained in:
committed by
Baldur Karlsson
parent
0ae03ad1ae
commit
58b0d29bf4
@@ -442,6 +442,29 @@ QMessageBox::StandardButton RDDialog::messageBox(QMessageBox::Icon icon, QWidget
|
||||
return ret;
|
||||
}
|
||||
|
||||
QMessageBox::StandardButton RDDialog::messageBoxChecked(QMessageBox::Icon icon, QWidget *parent,
|
||||
const QString &title, const QString &text,
|
||||
QCheckBox *checkBox, bool &checked,
|
||||
QMessageBox::StandardButtons buttons,
|
||||
QMessageBox::StandardButton defaultButton)
|
||||
{
|
||||
bool isChecked = checked;
|
||||
QMessageBox::StandardButton ret = defaultButton;
|
||||
|
||||
// if we're already on the right thread, this boils down to a function call
|
||||
GUIInvoke::blockcall([&]() {
|
||||
QMessageBox mb(icon, title, text, buttons, parent);
|
||||
mb.setDefaultButton(defaultButton);
|
||||
mb.setCheckBox(checkBox);
|
||||
show(&mb);
|
||||
isChecked = mb.checkBox()->isChecked();
|
||||
ret = mb.standardButton(mb.clickedButton());
|
||||
});
|
||||
|
||||
checked = isChecked;
|
||||
return ret;
|
||||
}
|
||||
|
||||
QString RDDialog::getExistingDirectory(QWidget *parent, const QString &caption, const QString &dir,
|
||||
QFileDialog::Options options)
|
||||
{
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QCoreApplication>
|
||||
#include <QDebug>
|
||||
#include <QFileDialog>
|
||||
@@ -818,6 +819,10 @@ struct RDDialog
|
||||
QMessageBox::Icon, QWidget *parent, const QString &title, const QString &text,
|
||||
QMessageBox::StandardButtons buttons = QMessageBox::Ok,
|
||||
QMessageBox::StandardButton defaultButton = QMessageBox::NoButton);
|
||||
static QMessageBox::StandardButton messageBoxChecked(
|
||||
QMessageBox::Icon, QWidget *parent, const QString &title, const QString &text,
|
||||
QCheckBox *checkBox, bool &checked, QMessageBox::StandardButtons buttons = QMessageBox::Ok,
|
||||
QMessageBox::StandardButton defaultButton = QMessageBox::NoButton);
|
||||
|
||||
static QMessageBox::StandardButton information(
|
||||
QWidget *parent, const QString &title, const QString &text,
|
||||
@@ -836,6 +841,16 @@ struct RDDialog
|
||||
return messageBox(QMessageBox::Question, parent, title, text, buttons, defaultButton);
|
||||
}
|
||||
|
||||
static QMessageBox::StandardButton questionChecked(
|
||||
QWidget *parent, const QString &title, const QString &text, QCheckBox *checkBox, bool &checked,
|
||||
QMessageBox::StandardButtons buttons = QMessageBox::StandardButtons(QMessageBox::Yes |
|
||||
QMessageBox::No),
|
||||
QMessageBox::StandardButton defaultButton = QMessageBox::NoButton)
|
||||
{
|
||||
return messageBoxChecked(QMessageBox::Question, parent, title, text, checkBox, checked, buttons,
|
||||
defaultButton);
|
||||
}
|
||||
|
||||
static QMessageBox::StandardButton warning(
|
||||
QWidget *parent, const QString &title, const QString &text,
|
||||
QMessageBox::StandardButtons buttons = QMessageBox::Ok,
|
||||
|
||||
Reference in New Issue
Block a user