Cocoa color dialog cannot be modal, but should show anyway

Silently failing doesn't seem the right way to handle this.
Updated docs for DontUseNativeDialog option: it's not just for
the Mac anymore.  Ensure that the Qt dialog and Mac panel
will never be shown at the same time.

Change-Id: Ia9e80754df6c7622d9039c8dd050ac4de771a030
Task-number: QTBUG-29161
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@digia.com>
This commit is contained in:
Shawn Rutledge 2013-06-14 12:39:02 +02:00 committed by The Qt Project
parent cf98d1e607
commit e083aede62
2 changed files with 8 additions and 8 deletions

View File

@ -368,10 +368,8 @@ void QCocoaColorDialogHelper::exec()
bool QCocoaColorDialogHelper::show(Qt::WindowFlags, Qt::WindowModality windowModality, QWindow *parent) bool QCocoaColorDialogHelper::show(Qt::WindowFlags, Qt::WindowModality windowModality, QWindow *parent)
{ {
if (windowModality == Qt::WindowModal) { if (windowModality == Qt::WindowModal)
// Cocoa's shared color panel cannot be shown as a sheet windowModality = Qt::ApplicationModal;
return false;
}
return showCocoaColorPanel(windowModality, parent); return showCocoaColorPanel(windowModality, parent);
} }
@ -434,9 +432,9 @@ bool QCocoaColorDialogHelper::showCocoaColorPanel(Qt::WindowModality windowModal
createNSColorPanelDelegate(); createNSColorPanelDelegate();
QT_MANGLE_NAMESPACE(QNSColorPanelDelegate) *delegate = static_cast<QT_MANGLE_NAMESPACE(QNSColorPanelDelegate) *>(mDelegate); QT_MANGLE_NAMESPACE(QNSColorPanelDelegate) *delegate = static_cast<QT_MANGLE_NAMESPACE(QNSColorPanelDelegate) *>(mDelegate);
[delegate->mColorPanel setShowsAlpha:options()->testOption(QColorDialogOptions::ShowAlphaChannel)]; [delegate->mColorPanel setShowsAlpha:options()->testOption(QColorDialogOptions::ShowAlphaChannel)];
if (windowModality == Qt::NonModal) if (windowModality != Qt::WindowModal)
[delegate showModelessPanel]; [delegate showModelessPanel];
// no need to show a Qt::ApplicationModal dialog here, since it will be done in _q_platformRunNativeAppModalPanel() // no need to show a Qt::WindowModal dialog here, because it's necessary to call exec() in that case
return true; return true;
} }

View File

@ -1776,6 +1776,8 @@ void QColorDialog::setOptions(ColorDialogOptions options)
d->options->setOptions(QColorDialogOptions::ColorDialogOptions(int(options))); d->options->setOptions(QColorDialogOptions::ColorDialogOptions(int(options)));
d->buttons->setVisible(!(options & NoButtons)); d->buttons->setVisible(!(options & NoButtons));
d->showAlpha(options & ShowAlphaChannel); d->showAlpha(options & ShowAlphaChannel);
if (options & DontUseNativeDialog)
d->nativeDialogInUse = false;
} }
QColorDialog::ColorDialogOptions QColorDialog::options() const QColorDialog::ColorDialogOptions QColorDialog::options() const
@ -1794,8 +1796,8 @@ QColorDialog::ColorDialogOptions QColorDialog::options() const
\value ShowAlphaChannel Allow the user to select the alpha component of a color. \value ShowAlphaChannel Allow the user to select the alpha component of a color.
\value NoButtons Don't display \uicontrol{OK} and \uicontrol{Cancel} buttons. (Useful for "live dialogs".) \value NoButtons Don't display \uicontrol{OK} and \uicontrol{Cancel} buttons. (Useful for "live dialogs".)
\value DontUseNativeDialog Use Qt's standard color dialog on the Mac instead of Apple's \value DontUseNativeDialog Use Qt's standard color dialog instead of the operating system
native color panel. native color dialog.
\sa options, setOption(), testOption(), windowModality() \sa options, setOption(), testOption(), windowModality()
*/ */