summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2020-05-26 12:14:02 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2020-05-28 21:15:55 +0200
commitd80a98d52548b1081ba3f980252fe9aee89bc1f8 (patch)
treea4bc4d969da7dd159a6b3bb6972cd0170406b176 /src
parent0ea99a68f9e7659d0b77a6dc7cd514980dc3e748 (diff)
Fix ExtendedRgb and Rgb encoding comparisons
ExtendedRgb should be treated as Rgb as it can be an automatic upgrade. Pick-to: 5.15 Change-Id: I2942a1067ed5cacb2f60f303f467887cb44c36dd Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/gui/painting/qcolor.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/gui/painting/qcolor.cpp b/src/gui/painting/qcolor.cpp
index 72471c60d4..f8a455e28b 100644
--- a/src/gui/painting/qcolor.cpp
+++ b/src/gui/painting/qcolor.cpp
@@ -2883,6 +2883,8 @@ QColor &QColor::operator=(Qt::GlobalColor color) noexcept
Returns \c true if this color has the same color specification and component values as \a color;
otherwise returns \c false.
+ ExtendedRgb and Rgb specifications are considered matching in this context.
+
\sa spec()
*/
bool QColor::operator==(const QColor &color) const noexcept
@@ -2896,6 +2898,12 @@ bool QColor::operator==(const QColor &color) const noexcept
|| ct.ahsl.lightness == USHRT_MAX
|| color.ct.ahsl.lightness == USHRT_MAX)
&& (qAbs(ct.ahsl.lightness - color.ct.ahsl.lightness)) < 50);
+ } else if ((cspec == ExtendedRgb || color.cspec == ExtendedRgb) &&
+ (cspec == color.cspec || cspec == Rgb || color.cspec == Rgb)) {
+ return qFuzzyCompare(alphaF(), color.alphaF())
+ && qFuzzyCompare(redF(), color.redF())
+ && qFuzzyCompare(greenF(), color.greenF())
+ && qFuzzyCompare(blueF(), color.blueF());
} else {
return (cspec == color.cspec
&& ct.argb.alpha == color.ct.argb.alpha
@@ -2912,6 +2920,8 @@ bool QColor::operator==(const QColor &color) const noexcept
Returns \c true if this color has different color specification or component values from
\a color; otherwise returns \c false.
+ ExtendedRgb and Rgb specifications are considered matching in this context.
+
\sa spec()
*/
bool QColor::operator!=(const QColor &color) const noexcept