From 971bd702ef50ea959b5c10b2ddd30670839eeda6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 26 Oct 2022 14:24:13 +0200 Subject: [PATCH] Make QDialog respect Qt::AA_DontUseNativeDialogs QDialogs can be backed by native dialog helpers, and the choice of whether to use a particular helper is a runtime decision, made in QDialog::setVisible() via QDialogPrivate::canBeNativeDialog(). As the native dialogs may not always provide every feature of the corresponding Qt dialog, or if the user wants a uniform look and feel for their application (even if that breaks the platform UX), there is a way to opt out, via the Qt::AA_DontUseNativeDialogs attribute. This attribute was checked by subclasses of QDialog/QDialogPrivate, for example QFileDialog or QColorDialog, but not by the base class implementation, which is being used by e.g. QMessageBox. Ideally we'd reduce the amount of code duplication in this area, by having subclasses such as QFileDialog and QColorDialog call the base class implementations, but for now we add a similar check for the attribute to the base class as we have in other leaf classes. [ChangeLog][Widgets] QMessageBox now respects the Qt::AA_DontUseNativeDialogs application attribute to opt out of native message boxes on platforms where this is supported (iOS, Android). Change-Id: I0080441ea8764e9d5fc62d7f2d7b8914a5844c28 Reviewed-by: Volker Hilsheimer --- src/widgets/dialogs/qdialog.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/widgets/dialogs/qdialog.cpp b/src/widgets/dialogs/qdialog.cpp index 4384df0e7f..4a9fa1cf70 100644 --- a/src/widgets/dialogs/qdialog.cpp +++ b/src/widgets/dialogs/qdialog.cpp @@ -98,6 +98,9 @@ QPlatformDialogHelper *QDialogPrivate::platformHelper() const bool QDialogPrivate::canBeNativeDialog() const { + if (QCoreApplication::testAttribute(Qt::AA_DontUseNativeDialogs)) + return false; + QDialogPrivate *ncThis = const_cast(this); QDialog *dialog = ncThis->q_func(); const int type = themeDialogType(dialog);