From 1bf9f725d19664e7b28857986acefbfdb2b12162 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Tue, 11 Feb 2014 23:08:48 +0100 Subject: [PATCH] Respect the DontUseNativeDialog option for QColorDialog By reimplementing canBeNativeDialog() we ensure it is only shown natively if the circumstances are correct. The change was modelled on how QFileDialog implements the same checks. Change-Id: If58e33d6d0547e95975d7c0453901fa592eb96a0 [ChangeLog][QtWidgets][QColorDialog] Ensured QColorDialog::DontUseNativeDialog is respected when showing the dialog. Reviewed-by: Friedemann Kleint --- src/widgets/dialogs/qcolordialog.cpp | 15 +++++++++++++++ src/widgets/dialogs/qcolordialog_p.h | 2 ++ 2 files changed, 17 insertions(+) diff --git a/src/widgets/dialogs/qcolordialog.cpp b/src/widgets/dialogs/qcolordialog.cpp index 2b7cf8e99f..8866a3e97e 100644 --- a/src/widgets/dialogs/qcolordialog.cpp +++ b/src/widgets/dialogs/qcolordialog.cpp @@ -1790,6 +1790,21 @@ void QColorDialogPrivate::retranslateStrings() cs->retranslateStrings(); } +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) + return false; + + QLatin1String staticName(QColorDialog::staticMetaObject.className()); + QLatin1String dynamicName(q->metaObject()->className()); + return (staticName == dynamicName); +} + static const Qt::WindowFlags DefaultWindowFlags = Qt::Dialog | Qt::WindowTitleHint | Qt::MSWindowsFixedSizeDialogHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint; diff --git a/src/widgets/dialogs/qcolordialog_p.h b/src/widgets/dialogs/qcolordialog_p.h index f58a9200db..72c3b0e3cd 100644 --- a/src/widgets/dialogs/qcolordialog_p.h +++ b/src/widgets/dialogs/qcolordialog_p.h @@ -110,6 +110,8 @@ public: bool handleColorPickingMouseButtonRelease(QMouseEvent *e); bool handleColorPickingKeyPress(QKeyEvent *e); + bool canBeNativeDialog() const; + QWellArray *custom; QWellArray *standard;