From 1c9a4093a5402b4e7a8ebe1aea819d98af833e40 Mon Sep 17 00:00:00 2001 From: Christoph Schleifenbaum Date: Tue, 10 Apr 2012 17:17:41 +0200 Subject: Respect the DontUseNativeDialog flag. QFontDialog and QColorDialog were ignoring the DontUseNativeDialog. This lead to a native (Cocoa) dialog created all the time. Fix the testcase for QFontDialog. It needs the DontUseNativeDialog flag set. Task-number: QTBUG-24321 Change-Id: I159c1ad057bac38226f1e01a56b15f142650bfd8 Reviewed-by: Bradley T. Hughes --- src/widgets/dialogs/qcolordialog.cpp | 5 ++--- src/widgets/dialogs/qfontdialog.cpp | 21 ++++++++++----------- src/widgets/dialogs/qfontdialog_p.h | 2 +- 3 files changed, 13 insertions(+), 15 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/dialogs/qcolordialog.cpp b/src/widgets/dialogs/qcolordialog.cpp index 606b9b00f7..d7a8f5dc21 100644 --- a/src/widgets/dialogs/qcolordialog.cpp +++ b/src/widgets/dialogs/qcolordialog.cpp @@ -1247,7 +1247,7 @@ inline bool QColorDialogPrivate::isAlphaVisible() const { return cs->isAlphaVisi QColor QColorDialogPrivate::currentQColor() const { - if (nativeDialogInUse) + if (!options->testOption(QColorDialogOptions::DontUseNativeDialog) && nativeDialogInUse) return platformColorDialogHelper()->currentColor_sys(); return cs->currentQColor(); } @@ -1706,8 +1706,7 @@ void QColorDialog::setCurrentColor(const QColor &color) d->selectColor(color); d->setCurrentAlpha(color.alpha()); - // ### fixme: Call helper - if (d->nativeDialogInUse) + if (!testOption(QColorDialog::DontUseNativeDialog) && d->nativeDialogInUse) d->platformColorDialogHelper()->setCurrentColor_sys(color); } diff --git a/src/widgets/dialogs/qfontdialog.cpp b/src/widgets/dialogs/qfontdialog.cpp index 7e71cd7cd4..b267f67422 100644 --- a/src/widgets/dialogs/qfontdialog.cpp +++ b/src/widgets/dialogs/qfontdialog.cpp @@ -171,11 +171,6 @@ void QFontDialogPrivate::init() { Q_Q(QFontDialog); -#ifdef Q_WS_MAC - nativeDialogInUse = false; - delegate = 0; -#endif - q->setSizeGripEnabled(true); q->setWindowTitle(QFontDialog::tr("Select Font")); @@ -805,8 +800,10 @@ void QFontDialog::setCurrentFont(const QFont &font) d->strikeout->setChecked(font.strikeOut()); d->underline->setChecked(font.underline()); d->updateFamilies(); - if (QPlatformFontDialogHelper *helper = d->platformFontDialogHelper()) - helper->setCurrentFont_sys(font); + if (d->canBeNativeDialog()) { + if (QPlatformFontDialogHelper *helper = d->platformFontDialogHelper()) + helper->setCurrentFont_sys(font); + } #ifdef Q_WS_MAC if (d->delegate) @@ -824,8 +821,10 @@ void QFontDialog::setCurrentFont(const QFont &font) QFont QFontDialog::currentFont() const { Q_D(const QFontDialog); - if (const QPlatformFontDialogHelper *helper = d->platformFontDialogHelper()) - return helper->currentFont_sys(); + if (d->canBeNativeDialog()) { + if (const QPlatformFontDialogHelper *helper = d->platformFontDialogHelper()) + return helper->currentFont_sys(); + } return d->sampleEdit->font(); } @@ -1013,9 +1012,9 @@ void QFontDialog::done(int result) d->memberToDisconnectOnClose.clear(); } -bool QFontDialogPrivate::canBeNativeDialog() +bool QFontDialogPrivate::canBeNativeDialog() const { - Q_Q(QFontDialog); + Q_Q(const QFontDialog); if (nativeDialogInUse) return true; if (q->testAttribute(Qt::WA_DontShowOnScreen)) diff --git a/src/widgets/dialogs/qfontdialog_p.h b/src/widgets/dialogs/qfontdialog_p.h index 9bf00d2657..75a9045d2b 100644 --- a/src/widgets/dialogs/qfontdialog_p.h +++ b/src/widgets/dialogs/qfontdialog_p.h @@ -143,7 +143,7 @@ public: QPointer receiverToDisconnectOnClose; QByteArray memberToDisconnectOnClose; - bool canBeNativeDialog(); + bool canBeNativeDialog() const; void _q_runNativeAppModalPanel(); #ifdef Q_WS_MAC static void setFont(void *delegate, const QFont &font); -- cgit v1.2.3