Cocoa: fix setting color with alpha channel value for color dialog

Make sure that if ShowAlphaChannel option is set then also setShowsAlpha
needs to be set for the panel before setting the current color, otherwise
alpha channel value is omitted.

Task-number: QTBUG-24320

Change-Id: Ifb3822711af8ffd0cf6cb4c8aab2b0020d296663
Reviewed-by: Morten Johan Sørvig <morten.sorvig@nokia.com>
This commit is contained in:
Teemu Katajisto 2012-03-22 13:27:21 +02:00 committed by Qt by Nokia
parent 91c44fd31e
commit 89b5244310
2 changed files with 5 additions and 3 deletions

View File

@ -404,6 +404,11 @@ void QCocoaColorDialogHelper::setCurrentColor_sys(const QColor &color)
if (!mDelegate)
createNSColorPanelDelegate();
QT_MANGLE_NAMESPACE(QNSColorPanelDelegate) *delegate = static_cast<QT_MANGLE_NAMESPACE(QNSColorPanelDelegate) *>(mDelegate);
// make sure that if ShowAlphaChannel option is set then also setShowsAlpha
// needs to be set, otherwise alpha value is omitted
[delegate->mColorPanel setShowsAlpha:options()->testOption(QColorDialogOptions::ShowAlphaChannel)];
NSColor *nsColor;
const QColor::Spec spec = color.spec();
if (spec == QColor::Cmyk) {

View File

@ -156,9 +156,6 @@ void tst_QColorDialog::task247349_alpha()
dialog.setOption(QColorDialog::ShowAlphaChannel, true);
int alpha = 0x17;
dialog.setCurrentColor(QColor(0x01, 0x02, 0x03, alpha));
#ifdef Q_OS_MAC
QEXPECT_FAIL("", "Fails on Mac OS X, see QTBUG-24320", Abort);
#endif
QCOMPARE(alpha, dialog.currentColor().alpha());
QCOMPARE(alpha, qAlpha(dialog.currentColor().rgba()));
}