From 56ad625f7843bb66bef2a0ef9b5c97d354fbdb25 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 15 Feb 2016 14:27:56 +0100 Subject: [PATCH] Add attribute Qt::AA_DontUseNativeDialogs. The attribute can be set to suppress native dialogs for example for testing purposes. Task-number: QTBUG-51074 Change-Id: I35611e07e00b7a060f22b49d6ab6f3b8627f8aca Reviewed-by: Shawn Rutledge Reviewed-by: J-P Nurmi --- src/corelib/global/qnamespace.h | 1 + src/corelib/global/qnamespace.qdoc | 4 ++++ src/widgets/dialogs/qcolordialog.cpp | 7 ++++--- src/widgets/dialogs/qfiledialog.cpp | 7 ++++--- src/widgets/dialogs/qfontdialog.cpp | 7 ++++--- 5 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h index 25973a3ae4..b6d8e6fdc8 100644 --- a/src/corelib/global/qnamespace.h +++ b/src/corelib/global/qnamespace.h @@ -506,6 +506,7 @@ public: AA_EnableHighDpiScaling = 20, AA_DisableHighDpiScaling = 21, AA_UseStyleSheetPropagationInWidgetStyles = 22, // ### Qt 6: remove me + AA_DontUseNativeDialogs = 23, // Add new attributes before this line AA_AttributeCount diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc index 1efcce393d..b17a1ab48b 100644 --- a/src/corelib/global/qnamespace.qdoc +++ b/src/corelib/global/qnamespace.qdoc @@ -230,6 +230,10 @@ \l{The Style Sheet Syntax#Inheritance}{The Style Sheet Syntax - Inheritance} for more details. This value has been added in Qt 5.7. + \value AA_DontUseNativeDialogs All dialogs created while this attribute is + set to true won't use the native dialogs provided by the platform. + This value has been added in Qt 5.7. + The following values are obsolete: \value AA_ImmediateWidgetCreation This attribute is no longer fully diff --git a/src/widgets/dialogs/qcolordialog.cpp b/src/widgets/dialogs/qcolordialog.cpp index 47f2e76faf..9f86bea0ca 100644 --- a/src/widgets/dialogs/qcolordialog.cpp +++ b/src/widgets/dialogs/qcolordialog.cpp @@ -1909,10 +1909,11 @@ bool QColorDialogPrivate::canBeNativeDialog() const Q_Q(const QColorDialog); if (nativeDialogInUse) return true; - if (q->testAttribute(Qt::WA_DontShowOnScreen)) - return false; - if (q->options() & QColorDialog::DontUseNativeDialog) + if (QCoreApplication::testAttribute(Qt::AA_DontUseNativeDialogs) + || q->testAttribute(Qt::WA_DontShowOnScreen) + || (q->options() & QColorDialog::DontUseNativeDialog)) { return false; + } QLatin1String staticName(QColorDialog::staticMetaObject.className()); QLatin1String dynamicName(q->metaObject()->className()); diff --git a/src/widgets/dialogs/qfiledialog.cpp b/src/widgets/dialogs/qfiledialog.cpp index 288922d740..ca2b0c0889 100644 --- a/src/widgets/dialogs/qfiledialog.cpp +++ b/src/widgets/dialogs/qfiledialog.cpp @@ -704,10 +704,11 @@ bool QFileDialogPrivate::canBeNativeDialog() const Q_Q(const QFileDialog); if (nativeDialogInUse) return true; - if (q->testAttribute(Qt::WA_DontShowOnScreen)) - return false; - if (q->options() & QFileDialog::DontUseNativeDialog) + if (QCoreApplication::testAttribute(Qt::AA_DontUseNativeDialogs) + || q->testAttribute(Qt::WA_DontShowOnScreen) + || (q->options() & QFileDialog::DontUseNativeDialog)) { return false; + } QLatin1String staticName(QFileDialog::staticMetaObject.className()); QLatin1String dynamicName(q->metaObject()->className()); diff --git a/src/widgets/dialogs/qfontdialog.cpp b/src/widgets/dialogs/qfontdialog.cpp index 7dbcf15b73..a0525f6fbd 100644 --- a/src/widgets/dialogs/qfontdialog.cpp +++ b/src/widgets/dialogs/qfontdialog.cpp @@ -1043,10 +1043,11 @@ bool QFontDialogPrivate::canBeNativeDialog() const Q_Q(const QFontDialog); if (nativeDialogInUse) return true; - if (q->testAttribute(Qt::WA_DontShowOnScreen)) - return false; - if (options->options() & QFontDialog::DontUseNativeDialog) + if (QCoreApplication::testAttribute(Qt::AA_DontUseNativeDialogs) + || q->testAttribute(Qt::WA_DontShowOnScreen) + || (options->options() & QFontDialog::DontUseNativeDialog)) { return false; + } QLatin1String staticName(QFontDialog::staticMetaObject.className()); QLatin1String dynamicName(q->metaObject()->className());