From f54411069cc2f587ea2fee9a4d9ae16a8dde648b Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 4 Nov 2011 14:45:42 +0100 Subject: Widgets: Use QPlatformDialogHelper in QColorDialog/QFontDialog. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ib9a2f19679c2d4c8583742a918d61c1a98403843 Reviewed-by: Morten Johan Sørvig --- src/widgets/dialogs/qcolordialog.cpp | 13 +++++++++++-- src/widgets/dialogs/qcolordialog.h | 5 +---- src/widgets/dialogs/qcolordialog_p.h | 2 +- src/widgets/dialogs/qfontdialog.cpp | 24 ++++++++++-------------- src/widgets/dialogs/qfontdialog_p.h | 7 +++---- 5 files changed, 26 insertions(+), 25 deletions(-) (limited to 'src/widgets/dialogs') diff --git a/src/widgets/dialogs/qcolordialog.cpp b/src/widgets/dialogs/qcolordialog.cpp index 027470f779..73302be5e3 100644 --- a/src/widgets/dialogs/qcolordialog.cpp +++ b/src/widgets/dialogs/qcolordialog.cpp @@ -1663,6 +1663,12 @@ void QColorDialogPrivate::_q_addCustom() nextCust = (nextCust+1) % 16; } +void QColorDialogPrivate::_q_platformRunNativeAppModalPanel() +{ + if (nativeDialogInUse) + platformHelper()->_q_platformRunNativeAppModalPanel(); +} + void QColorDialogPrivate::retranslateStrings() { if (!smallDisplay) { @@ -1912,8 +1918,11 @@ void QColorDialog::setVisible(bool visible) } #else - if (!(d->opts & DontUseNativeDialog) && qt_guiPlatformPlugin()->colorDialogSetVisible(this, visible)) { - d->nativeDialogInUse = true; + if (!(d->opts & DontUseNativeDialog)) + if (QPlatformDialogHelper *helper = d->platformHelper()) + d->nativeDialogInUse = helper->setVisible_sys(visible); + + if (d->nativeDialogInUse) { // Set WA_DontShowOnScreen so that QDialog::setVisible(visible) below // updates the state correctly, but skips showing the non-native version: setAttribute(Qt::WA_DontShowOnScreen); diff --git a/src/widgets/dialogs/qcolordialog.h b/src/widgets/dialogs/qcolordialog.h index 86b0b5e96a..fa217c76bf 100644 --- a/src/widgets/dialogs/qcolordialog.h +++ b/src/widgets/dialogs/qcolordialog.h @@ -126,10 +126,7 @@ private: Q_PRIVATE_SLOT(d_func(), void _q_newColorTypedIn(QRgb rgb)) Q_PRIVATE_SLOT(d_func(), void _q_newCustom(int, int)) Q_PRIVATE_SLOT(d_func(), void _q_newStandard(int, int)) -#if defined(Q_WS_MAC) - Q_PRIVATE_SLOT(d_func(), void _q_macRunNativeAppModalPanel()) -#endif - + Q_PRIVATE_SLOT(d_func(), void _q_platformRunNativeAppModalPanel()) friend class QColorShower; }; diff --git a/src/widgets/dialogs/qcolordialog_p.h b/src/widgets/dialogs/qcolordialog_p.h index f1865e66ec..b2413f1418 100644 --- a/src/widgets/dialogs/qcolordialog_p.h +++ b/src/widgets/dialogs/qcolordialog_p.h @@ -89,6 +89,7 @@ public: void retranslateStrings(); void _q_addCustom(); + void _q_platformRunNativeAppModalPanel(); void _q_newHsv(int h, int s, int v); void _q_newColorTypedIn(QRgb rgb); @@ -114,7 +115,6 @@ public: QColorDialog::ColorDialogOptions opts; QPointer receiverToDisconnectOnClose; QByteArray memberToDisconnectOnClose; - bool nativeDialogInUse; #ifdef Q_WS_MAC void openCocoaColorPanel(const QColor &initial, diff --git a/src/widgets/dialogs/qfontdialog.cpp b/src/widgets/dialogs/qfontdialog.cpp index 62338d8a3e..1b8a9137ac 100644 --- a/src/widgets/dialogs/qfontdialog.cpp +++ b/src/widgets/dialogs/qfontdialog.cpp @@ -983,20 +983,18 @@ void QFontDialog::setVisible(bool visible) { if (testAttribute(Qt::WA_WState_ExplicitShowHide) && testAttribute(Qt::WA_WState_Hidden) != visible) return; -#ifdef Q_WS_MAC Q_D(QFontDialog); - if (d->canBeNativeDialog()){ - if (d->setVisible_sys(visible)){ - d->nativeDialogInUse = true; - // Set WA_DontShowOnScreen so that QDialog::setVisible(visible) below - // updates the state correctly, but skips showing the non-native version: - setAttribute(Qt::WA_DontShowOnScreen, true); - } else { - d->nativeDialogInUse = false; - setAttribute(Qt::WA_DontShowOnScreen, false); - } + if (d->canBeNativeDialog()) + if (QPlatformDialogHelper *helper = d->platformHelper()) + d->nativeDialogInUse = helper->setVisible_sys(visible); + if (d->nativeDialogInUse) { + // Set WA_DontShowOnScreen so that QDialog::setVisible(visible) below + // updates the state correctly, but skips showing the non-native version: + setAttribute(Qt::WA_DontShowOnScreen, true); + } else { + d->nativeDialogInUse = false; + setAttribute(Qt::WA_DontShowOnScreen, false); } -#endif // Q_WS_MAC QDialog::setVisible(visible); } @@ -1028,7 +1026,6 @@ void QFontDialog::done(int result) d->memberToDisconnectOnClose.clear(); } -#ifdef Q_WS_MAC bool QFontDialogPrivate::canBeNativeDialog() { Q_Q(QFontDialog); @@ -1043,7 +1040,6 @@ bool QFontDialogPrivate::canBeNativeDialog() QLatin1String dynamicName(q->metaObject()->className()); return (staticName == dynamicName); } -#endif // Q_WS_MAC /*! \fn QFont QFontDialog::getFont(bool *ok, const QFont &initial, QWidget* parent, const char* name) diff --git a/src/widgets/dialogs/qfontdialog_p.h b/src/widgets/dialogs/qfontdialog_p.h index 349e2d3fcb..8b423f92d8 100644 --- a/src/widgets/dialogs/qfontdialog_p.h +++ b/src/widgets/dialogs/qfontdialog_p.h @@ -138,6 +138,8 @@ public: QPointer receiverToDisconnectOnClose; QByteArray memberToDisconnectOnClose; + bool canBeNativeDialog(); + void _q_runNativeAppModalPanel(); #ifdef Q_WS_MAC static void setFont(void *delegate, const QFont &font); @@ -146,12 +148,9 @@ public: void *delegate; void closeCocoaFontPanel(); - bool nativeDialogInUse; - bool canBeNativeDialog(); + bool setVisible_sys(bool visible); void createNSFontPanelDelegate(); - void _q_macRunNativeAppModalPanel(); - void mac_nativeDialogModalHelp(); bool showCocoaFontPanel(); bool hideCocoaFontPanel(); -- cgit v1.2.3