From 01c55405fa55add25a469bdaee8c562ab3ab8941 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Fri, 26 Feb 2021 14:20:47 +0100 Subject: Add QColorSpace::description A way to read the description of the profile from ICC, or set one yourself. Change-Id: I68622e30ee209cac99c41f3df934712c3548c0de Reviewed-by: Friedemann Kleint Reviewed-by: Eirik Aavitsland --- .../gui/painting/qcolorspace/tst_qcolorspace.cpp | 23 +++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/auto/gui/painting/qcolorspace/tst_qcolorspace.cpp b/tests/auto/gui/painting/qcolorspace/tst_qcolorspace.cpp index bc26552311..ce21dbe9b7 100644 --- a/tests/auto/gui/painting/qcolorspace/tst_qcolorspace.cpp +++ b/tests/auto/gui/painting/qcolorspace/tst_qcolorspace.cpp @@ -80,6 +80,8 @@ private slots: void changePrimaries(); void transferFunctionTable(); + + void description(); }; tst_QColorSpace::tst_QColorSpace() @@ -225,7 +227,7 @@ void tst_QColorSpace::fromIccProfile() QCOMPARE(fileColorSpace, namedColorSpace); QCOMPARE(fileColorSpace.transferFunction(), transferFunction); - QCOMPARE(QColorSpacePrivate::get(fileColorSpace)->description, description); + QCOMPARE(fileColorSpace.description(), description); } void tst_QColorSpace::imageConversion_data() @@ -616,5 +618,24 @@ void tst_QColorSpace::transferFunctionTable() QCOMPARE(customSRgb, QColorSpace::SRgbLinear); } +void tst_QColorSpace::description() +{ + QColorSpace srgb(QColorSpace::SRgb); + QCOMPARE(srgb.description(), QLatin1String("sRGB")); + + srgb.setTransferFunction(QColorSpace::TransferFunction::ProPhotoRgb); + QCOMPARE(srgb.description(), QString()); // No longer sRGB + srgb.setTransferFunction(QColorSpace::TransferFunction::Linear); + QCOMPARE(srgb.description(), QLatin1String("Linear sRGB")); // Auto-detect + + srgb.setTransferFunction(QColorSpace::TransferFunction::ProPhotoRgb); + srgb.setDescription(QStringLiteral("My custom sRGB")); + QCOMPARE(srgb.description(), QLatin1String("My custom sRGB")); + srgb.setTransferFunction(QColorSpace::TransferFunction::Linear); + QCOMPARE(srgb.description(), QLatin1String("My custom sRGB")); // User given name not reset + srgb.setDescription(QString()); + QCOMPARE(srgb.description(), QLatin1String("Linear sRGB")); // Set to empty returns default behavior +} + QTEST_MAIN(tst_QColorSpace) #include "tst_qcolorspace.moc" -- cgit v1.2.3