16 #include <QApplication>
17 #include <QMessageBox>
18 #include <QPushButton>
22 void information(QWidget* parent,
const QString& title,
const QString& text,
23 const QString& detailedText)
25 QScopedPointer<QMessageBox> messageBox(
new QMessageBox(parent));
27 messageBox->setWindowModality(Qt::WindowModal);
28 messageBox->setWindowTitle(QString(
"%1 - %2").arg(QApplication::applicationName()).arg(title));
29 messageBox->setText(text);
30 if (!detailedText.isEmpty())
31 messageBox->setInformativeText(detailedText);
32 messageBox->setIcon(QMessageBox::Information);
33 messageBox->addButton(QMessageBox::Ok);
37 void warning(QWidget* parent,
const QString& title,
const QString& text,
38 const QString& detailedText)
40 QScopedPointer<QMessageBox> messageBox(
new QMessageBox(parent));
42 messageBox->setWindowModality(Qt::WindowModal);
43 messageBox->setWindowTitle(QString(
"%1 - %2").arg(QApplication::applicationName()).arg(title));
44 messageBox->setText(text);
45 if (!detailedText.isEmpty())
46 messageBox->setInformativeText(detailedText);
47 messageBox->setIcon(QMessageBox::Warning);
48 messageBox->addButton(QMessageBox::Ok);
52 bool question(QWidget* parent,
const QString& title,
const QString& text,
53 const QString& detailedText,
const QString& yesText,
const QString& noText)
55 QScopedPointer<QMessageBox> messageBox(
new QMessageBox(parent));
57 messageBox->setWindowModality(Qt::WindowModal);
58 messageBox->setWindowTitle(QString(
"%1 - %2").arg(QApplication::applicationName()).arg(title));
59 messageBox->setText(text);
60 if (!detailedText.isEmpty())
61 messageBox->setInformativeText(detailedText);
62 messageBox->setIcon(QMessageBox::Question);
63 QAbstractButton* yesButton = messageBox->addButton(yesText, QMessageBox::AcceptRole);
64 messageBox->addButton(noText, QMessageBox::RejectRole);
65 messageBox->setDefaultButton(qobject_cast<QPushButton*>(yesButton));
67 return messageBox->clickedButton() == yesButton;
70 bool okToDelete(QWidget* parent,
const QString& title,
const QString& text,
71 const QString& detailedText)
73 QScopedPointer<QMessageBox> messageBox(
new QMessageBox(parent));
75 messageBox->setWindowModality(Qt::WindowModal);
76 messageBox->setIcon(QMessageBox::Question);
77 messageBox->setWindowTitle(QString(
"%1 - %2").arg(QApplication::applicationName()).arg(title));
78 messageBox->setText(text);
79 if (!detailedText.isEmpty())
80 messageBox->setInformativeText(detailedText);
81 QAbstractButton* deleteButton = messageBox->addButton(
"&Delete", QMessageBox::AcceptRole);
82 messageBox->addButton(
"Do &Not Delete", QMessageBox::RejectRole);
83 messageBox->setDefaultButton(qobject_cast<QPushButton*>(deleteButton));
85 return messageBox->clickedButton() == deleteButton;
Defines class GUIHelpers functions.
void information(QWidget *parent, const QString &title, const QString &text, const QString &detailedText)
bool okToDelete(QWidget *parent, const QString &title, const QString &text, const QString &detailedText)
void warning(QWidget *parent, const QString &title, const QString &text, const QString &detailedText)
bool question(QWidget *parent, const QString &title, const QString &text, const QString &detailedText, const QString &yesText, const QString &noText)