diff options
author | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2019-06-12 01:37:05 +0200 |
---|---|---|
committer | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2019-06-12 19:55:17 +0200 |
commit | de82d239f814cf2a717bea0defeee3732384e271 (patch) | |
tree | 2da5d584adf618b6401ba733e873cb06b1a95d1e /src/gui/painting/qcolor.cpp | |
parent | 166753d8e00e11d2fa92d3bfbe5667ad4b8f7b9d (diff) |
Make QColor a literal type
Extracted from the SVG names patch.
It basically just requires adding a constexpr constructor to the
inner union, then sprinkling constexpr on the existing ones.
Do minor refactorings as drive-by.
Change-Id: I60e7a1c9068def3507cb07440450e51673269f84
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src/gui/painting/qcolor.cpp')
-rw-r--r-- | src/gui/painting/qcolor.cpp | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/src/gui/painting/qcolor.cpp b/src/gui/painting/qcolor.cpp index 174350d884..6cbc30e79a 100644 --- a/src/gui/painting/qcolor.cpp +++ b/src/gui/painting/qcolor.cpp @@ -1349,7 +1349,7 @@ void QColor::setRgbF(qreal r, qreal g, qreal b, qreal a) */ void QColor::setRgb(int r, int g, int b, int a) { - if ((uint)r > 255 || (uint)g > 255 || (uint)b > 255 || (uint)a > 255) { + if (!isRgbaValid(r, g, b, a)) { qWarning("QColor::setRgb: RGB parameters out of range"); invalidate(); return; @@ -2398,10 +2398,7 @@ QColor QColor::fromRgba(QRgb rgba) noexcept */ QColor QColor::fromRgb(int r, int g, int b, int a) { - if (r < 0 || r > 255 - || g < 0 || g > 255 - || b < 0 || b > 255 - || a < 0 || a > 255) { + if (!isRgbaValid(r, g, b, a)) { qWarning("QColor::fromRgb: RGB parameters out of range"); return QColor(); } |