summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorThorbjørn Martsum <tmartsum@gmail.com>2013-06-10 07:30:01 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-09-20 22:02:00 +0200
commit3e87d7e81458a8622ae461ed03d881a17aade41c (patch)
tree50cdff0d9afa1c35f761ed571a6993fbec43c626 /tests
parent16c47c3b343e2024cce3acd50f2dfe10ae5c40c7 (diff)
QMessageBox - make it possible to have a checkbox on the dialog
This (partly) solves Task-number: QTBUG-2450 Change-Id: Ie2280c87b96e72acc76e806a83c4e8cc0d4e4ee4 Reviewed-by: J-P Nurmi <jpnurmi@digia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/manual/dialogs/messageboxpanel.cpp18
-rw-r--r--tests/manual/dialogs/messageboxpanel.h3
2 files changed, 21 insertions, 0 deletions
diff --git a/tests/manual/dialogs/messageboxpanel.cpp b/tests/manual/dialogs/messageboxpanel.cpp
index 6fc84e11fd..529a8251e1 100644
--- a/tests/manual/dialogs/messageboxpanel.cpp
+++ b/tests/manual/dialogs/messageboxpanel.cpp
@@ -63,6 +63,8 @@ MessageBoxPanel::MessageBoxPanel(QWidget *parent) : QWidget(parent)
,m_btnShowApply(new QPushButton)
,m_resultLabel(new QLabel)
,m_chkReallocMsgBox(new QCheckBox(QString::fromLatin1("Reallocate Message Box")))
+,m_checkboxText(new QLineEdit)
+,m_checkBoxResult(new QLabel)
,m_msgbox(new QMessageBox)
{
// --- Options ---
@@ -97,6 +99,10 @@ MessageBoxPanel::MessageBoxPanel(QWidget *parent) : QWidget(parent)
m_buttonsMask->setText(QString::fromLatin1("0x00300400"));
optionsLayout->addWidget(m_buttonsMask);
+ // check box check
+ optionsLayout->addWidget(new QLabel(QString::fromLatin1("Checkbox text ("" => no chkbox)")));
+ optionsLayout->addWidget(m_checkboxText);
+
// reallocate
optionsLayout->addWidget(m_chkReallocMsgBox);
optionsLayout->addItem(new QSpacerItem(10, 10, QSizePolicy::Expanding, QSizePolicy::Expanding));
@@ -114,6 +120,7 @@ MessageBoxPanel::MessageBoxPanel(QWidget *parent) : QWidget(parent)
// result label
execLayout->addWidget(m_resultLabel);
+ execLayout->addWidget(m_checkBoxResult);
execLayout->addItem(new QSpacerItem(10, 10, QSizePolicy::Expanding, QSizePolicy::Expanding));
execGroupBox->setLayout(execLayout);
@@ -129,6 +136,7 @@ MessageBoxPanel::MessageBoxPanel(QWidget *parent) : QWidget(parent)
void MessageBoxPanel::setupMessageBox(QMessageBox &box)
{
m_resultLabel->setText(QString());
+ m_checkBoxResult->setText(QString());
box.setText(m_textInMsgBox->text());
box.setInformativeText(m_informativeText->text());
box.setDetailedText(m_detailedtext->text());
@@ -141,6 +149,10 @@ void MessageBoxPanel::setupMessageBox(QMessageBox &box)
if (box.standardButtons() == (QMessageBox::StandardButtons) 0)
box.setStandardButtons(QMessageBox::Ok); // just to have something.
+ box.setCheckBox(0);
+ if (m_checkboxText->text().length() > 0)
+ box.setCheckBox(new QCheckBox(m_checkboxText->text()));
+
box.setIcon((QMessageBox::Icon) m_iconComboBox->currentIndex());
}
@@ -164,6 +176,12 @@ void MessageBoxPanel::doExec()
QString sres;
sres.setNum(res, 16);
m_resultLabel->setText(QString::fromLatin1("Return value (hex): %1").arg(sres));
+ if (m_msgbox->checkBox()) {
+ if (m_msgbox->checkBox()->isChecked())
+ m_checkBoxResult->setText(QString::fromLatin1("Checkbox was checked"));
+ else
+ m_checkBoxResult->setText(QString::fromLatin1("Checkbox was not checked"));
+ }
}
void MessageBoxPanel::doShowApply()
diff --git a/tests/manual/dialogs/messageboxpanel.h b/tests/manual/dialogs/messageboxpanel.h
index 9f7e35210c..138007c244 100644
--- a/tests/manual/dialogs/messageboxpanel.h
+++ b/tests/manual/dialogs/messageboxpanel.h
@@ -43,6 +43,7 @@
#define MESSAGEBOXPANEL_H
#include <QWidget>
+#include <QCheckBox>
QT_BEGIN_NAMESPACE
class QComboBox;
@@ -77,6 +78,8 @@ private:
QValidator *m_validator;
QLabel *m_resultLabel;
QCheckBox *m_chkReallocMsgBox;
+ QLineEdit *m_checkboxText;
+ QLabel *m_checkBoxResult;
QMessageBox *m_msgbox;
void setupMessageBox(QMessageBox &box);
};