diff options
author | Jesper K. Pedersen <jesper.pedersen@kdab.com> | 2013-05-21 09:00:49 +0000 |
---|---|---|
committer | Jesper K. Pedersen <jesper.pedersen@kdab.com> | 2013-05-23 13:56:26 +0200 |
commit | d788bc73f1aa5b60c6675d3c3a6db0650b435ec2 (patch) | |
tree | 3d11b818780a4ea1fc0b13c2542f84f774011a03 | |
parent | 20604c28517aa4e318393598cf3d86d5ce113b77 (diff) |
added a Yes/No question dialog
Change-Id: I5d27c0e367ebdc311aa259dc95ab50ef991a6413
Reviewed-by: Nicolas Arnaud-Cormos <nicolas@kdab.com>
-rw-r--r-- | utils/dialogs.cpp | 14 | ||||
-rw-r--r-- | utils/dialogs.h | 1 |
2 files changed, 14 insertions, 1 deletions
diff --git a/utils/dialogs.cpp b/utils/dialogs.cpp index af086ea..723c6a9 100644 --- a/utils/dialogs.cpp +++ b/utils/dialogs.cpp @@ -29,7 +29,7 @@ #include "dialogs.h" #include <QInputDialog> - +#include <QMessageBox> namespace Scripting { namespace Internal { @@ -43,5 +43,17 @@ QString Dialogs::getText(const QString &title, const QString& label, const QStri return QInputDialog::getText(0, title, label, QLineEdit::Normal, defaultValue); } +bool Dialogs::yesNoQuestion(const QString &title, const QString &label, const QString& details, const QString& yesLabel, const QString& noLabel) +{ + QMessageBox box; + box.setWindowTitle(title); + box.setText(label); + if ( !details.isEmpty() ) + box.setDetailedText(details); + box.addButton(yesLabel, QMessageBox::AcceptRole); + box.addButton(noLabel, QMessageBox::RejectRole); + return box.exec() == QMessageBox::AcceptRole; +} + } // namespace Internal } // namespace Scripting diff --git a/utils/dialogs.h b/utils/dialogs.h index 845d897..470b878 100644 --- a/utils/dialogs.h +++ b/utils/dialogs.h @@ -46,6 +46,7 @@ public: public slots: QString getText(const QString& title, const QString &label, const QString& defaultValue = QString()); + bool yesNoQuestion(const QString& title, const QString &label, const QString &details = QString(), const QString &yesLabel = tr("Yes"), const QString &noLabel = tr("No")); }; } // namespace Internal |