summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@digia.com>2014-08-21 20:11:55 +0200
committerShawn Rutledge <shawn.rutledge@digia.com>2014-08-24 17:10:42 +0200
commitbb844065944049d836736192505ea28973f39444 (patch)
tree0949dc0ca90346e08543ad96ae49bee9d32db2be
parent737b7bec8513c23d1ea6bbbc88dbe6f357efb2fa (diff)
downloadqtquickcontrols-bb844065944049d836736192505ea28973f39444.tar.gz
Dialog: initialize enabled and clicked buttons
When the dialog becomes visible, no button has been clicked yet: we are waiting for the user to do that. Failure to initialize m_clickedButton made the logic in accept() and reject() unreliable: accept() does not imply OK unless we are sure the user did not click any other button, and the same with reject() implying Cancel. Change-Id: I340c18bd0fca6cc9a7274c1063882de425444326 Reviewed-by: Liang Qi <liang.qi@digia.com>
-rw-r--r--src/dialogs/qquickdialog.cpp9
-rw-r--r--src/dialogs/qquickdialog_p.h1
2 files changed, 10 insertions, 0 deletions
diff --git a/src/dialogs/qquickdialog.cpp b/src/dialogs/qquickdialog.cpp
index 14c996f6..060512d0 100644
--- a/src/dialogs/qquickdialog.cpp
+++ b/src/dialogs/qquickdialog.cpp
@@ -210,6 +210,8 @@ QT_BEGIN_NAMESPACE
*/
QQuickDialog::QQuickDialog(QObject *parent)
: QQuickAbstractDialog(parent)
+ , m_enabledButtons(Ok)
+ , m_clickedButton(NoButton)
{
}
@@ -233,6 +235,13 @@ QJSValue QQuickDialog::__standardButtonsRightModel()
return m_standardButtonsRightModel;
}
+void QQuickDialog::setVisible(bool v)
+{
+ if (v)
+ m_clickedButton == NoButton;
+ QQuickAbstractDialog::setVisible(v);
+}
+
void QQuickDialog::updateStandardButtons()
{
if (m_standardButtonsRightModel.isUndefined()) {
diff --git a/src/dialogs/qquickdialog_p.h b/src/dialogs/qquickdialog_p.h
index 5a04a83e..565859f3 100644
--- a/src/dialogs/qquickdialog_p.h
+++ b/src/dialogs/qquickdialog_p.h
@@ -81,6 +81,7 @@ public:
Q_INVOKABLE QJSValue __standardButtonsRightModel();
QString title() const { return m_title; }
+ virtual void setVisible(bool v);
public Q_SLOTS:
virtual void setTitle(const QString &arg);