summaryrefslogtreecommitdiffstats
path: root/src/widgets/dialogs
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@qt.io>2022-10-26 14:24:13 +0200
committerTor Arne Vestbø <tor.arne.vestbo@qt.io>2022-11-03 16:17:45 +0100
commit971bd702ef50ea959b5c10b2ddd30670839eeda6 (patch)
treeb7d6d6d902722582211c40577bc2ec5154c3af3b /src/widgets/dialogs
parentd59ae19c49853fa97ff5b410717e69e35e27d867 (diff)
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 <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/widgets/dialogs')
-rw-r--r--src/widgets/dialogs/qdialog.cpp3
1 files changed, 3 insertions, 0 deletions
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<QDialogPrivate *>(this);
QDialog *dialog = ncThis->q_func();
const int type = themeDialogType(dialog);