From fc083796ad8b02bf9d995ee22b6d60090e1e284d Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Fri, 30 Dec 2016 20:03:31 +0300 Subject: Implement QQuickDialogButtonBox::standardButton(StandardButton) Change-Id: I25935a069127a48c00dae951bc77665be6a429e1 Reviewed-by: J-P Nurmi --- src/quicktemplates2/qquickdialogbuttonbox.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/quicktemplates2/qquickdialogbuttonbox.cpp b/src/quicktemplates2/qquickdialogbuttonbox.cpp index 10603d58..1e7a5fd7 100644 --- a/src/quicktemplates2/qquickdialogbuttonbox.cpp +++ b/src/quicktemplates2/qquickdialogbuttonbox.cpp @@ -500,7 +500,17 @@ void QQuickDialogButtonBox::setStandardButtons(QPlatformDialogHelper::StandardBu */ QQuickAbstractButton *QQuickDialogButtonBox::standardButton(QPlatformDialogHelper::StandardButton button) const { - Q_UNUSED(button); + Q_D(const QQuickDialogButtonBox); + if (Q_UNLIKELY(!(d->standardButtons & button))) + return nullptr; + for (int i = 0, n = count(); i < n; ++i) { + QQuickAbstractButton *btn = qobject_cast(d->itemAt(i)); + if (Q_LIKELY(btn)) { + QQuickDialogButtonBoxAttached *attached = qobject_cast(qmlAttachedPropertiesObject(btn, false)); + if (attached && QQuickDialogButtonBoxAttachedPrivate::get(attached)->standardButton == button) + return btn; + } + } return nullptr; } -- cgit v1.2.3