aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKonstantin Ritt <ritt.ks@gmail.com>2016-12-30 20:03:31 +0300
committerJani Heikkinen <jani.heikkinen@qt.io>2017-01-05 10:46:38 +0000
commitfc083796ad8b02bf9d995ee22b6d60090e1e284d (patch)
treef1afdfa0e9369cb5f5a2e0bf3aee8486df98c32f /src
parenta13dce3d471c77474ce4b0f6bae115a015139229 (diff)
Implement QQuickDialogButtonBox::standardButton(StandardButton)
Change-Id: I25935a069127a48c00dae951bc77665be6a429e1 Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/quicktemplates2/qquickdialogbuttonbox.cpp12
1 files changed, 11 insertions, 1 deletions
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<QQuickAbstractButton *>(d->itemAt(i));
+ if (Q_LIKELY(btn)) {
+ QQuickDialogButtonBoxAttached *attached = qobject_cast<QQuickDialogButtonBoxAttached *>(qmlAttachedPropertiesObject<QQuickDialogButtonBox>(btn, false));
+ if (attached && QQuickDialogButtonBoxAttachedPrivate::get(attached)->standardButton == button)
+ return btn;
+ }
+ }
return nullptr;
}