summaryrefslogtreecommitdiffstats
path: root/src/gui/painting/qcolor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/painting/qcolor.cpp')
-rw-r--r--src/gui/painting/qcolor.cpp153
1 files changed, 79 insertions, 74 deletions
diff --git a/src/gui/painting/qcolor.cpp b/src/gui/painting/qcolor.cpp
index 3f30c061dc..20dd8d7f82 100644
--- a/src/gui/painting/qcolor.cpp
+++ b/src/gui/painting/qcolor.cpp
@@ -1,31 +1,37 @@
/****************************************************************************
**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:LGPL21$
+** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
@@ -331,7 +337,7 @@ QT_BEGIN_NAMESPACE
\sa isValid(), {QColor#Predefined Colors}{Predefined Colors}
*/
-QColor::QColor(Qt::GlobalColor color)
+QColor::QColor(Qt::GlobalColor color) Q_DECL_NOTHROW
{
#define QRGB(r, g, b) \
QRgb(((0xffu << 24) | ((r & 0xff) << 16) | ((g & 0xff) << 8) | (b & 0xff)))
@@ -406,7 +412,7 @@ QColor::QColor(Qt::GlobalColor color)
\sa fromRgb(), isValid()
*/
-QColor::QColor(QRgb color)
+QColor::QColor(QRgb color) Q_DECL_NOTHROW
{
cspec = Rgb;
ct.argb.alpha = 0xffff;
@@ -424,7 +430,7 @@ QColor::QColor(QRgb color)
\sa fromRgba64()
*/
-QColor::QColor(QRgba64 rgba64)
+QColor::QColor(QRgba64 rgba64) Q_DECL_NOTHROW
{
setRgba64(rgba64);
}
@@ -438,7 +444,7 @@ QColor::QColor(QRgba64 rgba64)
becomes a valid color by accident.
*/
-QColor::QColor(Spec spec)
+QColor::QColor(Spec spec) Q_DECL_NOTHROW
{
switch (spec) {
case Invalid:
@@ -958,7 +964,7 @@ void QColor::setRgb(int r, int g, int b, int a)
\sa setRgba(), rgb(), rgba64()
*/
-QRgb QColor::rgba() const
+QRgb QColor::rgba() const Q_DECL_NOTHROW
{
if (cspec != Invalid && cspec != Rgb)
return toRgb().rgba();
@@ -970,7 +976,7 @@ QRgb QColor::rgba() const
\sa rgba(), rgb(), setRgba64()
*/
-void QColor::setRgba(QRgb rgba)
+void QColor::setRgba(QRgb rgba) Q_DECL_NOTHROW
{
cspec = Rgb;
ct.argb.alpha = qAlpha(rgba) * 0x101;
@@ -990,7 +996,7 @@ void QColor::setRgba(QRgb rgba)
\sa setRgba64(), rgba(), rgb()
*/
-QRgba64 QColor::rgba64() const
+QRgba64 QColor::rgba64() const Q_DECL_NOTHROW
{
if (cspec != Invalid && cspec != Rgb)
return toRgb().rgba64();
@@ -1004,7 +1010,7 @@ QRgba64 QColor::rgba64() const
\sa \setRgba(), rgba64()
*/
-void QColor::setRgba64(QRgba64 rgba)
+void QColor::setRgba64(QRgba64 rgba) Q_DECL_NOTHROW
{
cspec = Rgb;
ct.argb.alpha = rgba.alpha();
@@ -1021,7 +1027,7 @@ void QColor::setRgba64(QRgba64 rgba)
\sa getRgb(), rgba()
*/
-QRgb QColor::rgb() const
+QRgb QColor::rgb() const Q_DECL_NOTHROW
{
if (cspec != Invalid && cspec != Rgb)
return toRgb().rgb();
@@ -1033,7 +1039,7 @@ QRgb QColor::rgb() const
Sets the RGB value to \a rgb. The alpha value is set to opaque.
*/
-void QColor::setRgb(QRgb rgb)
+void QColor::setRgb(QRgb rgb) Q_DECL_NOTHROW
{
cspec = Rgb;
ct.argb.alpha = 0xffff;
@@ -1048,7 +1054,7 @@ void QColor::setRgb(QRgb rgb)
\sa setAlpha(), alphaF(), {QColor#Alpha-Blended Drawing}{Alpha-Blended Drawing}
*/
-int QColor::alpha() const
+int QColor::alpha() const Q_DECL_NOTHROW
{ return ct.argb.alpha >> 8; }
@@ -1070,7 +1076,7 @@ void QColor::setAlpha(int alpha)
\sa setAlphaF(), alpha(), {QColor#Alpha-Blended Drawing}{Alpha-Blended Drawing}
*/
-qreal QColor::alphaF() const
+qreal QColor::alphaF() const Q_DECL_NOTHROW
{ return ct.argb.alpha / qreal(USHRT_MAX); }
/*!
@@ -1093,7 +1099,7 @@ void QColor::setAlphaF(qreal alpha)
\sa setRed(), redF(), getRgb()
*/
-int QColor::red() const
+int QColor::red() const Q_DECL_NOTHROW
{
if (cspec != Invalid && cspec != Rgb)
return toRgb().red();
@@ -1120,7 +1126,7 @@ void QColor::setRed(int red)
\sa setGreen(), greenF(), getRgb()
*/
-int QColor::green() const
+int QColor::green() const Q_DECL_NOTHROW
{
if (cspec != Invalid && cspec != Rgb)
return toRgb().green();
@@ -1148,7 +1154,7 @@ void QColor::setGreen(int green)
\sa setBlue(), blueF(), getRgb()
*/
-int QColor::blue() const
+int QColor::blue() const Q_DECL_NOTHROW
{
if (cspec != Invalid && cspec != Rgb)
return toRgb().blue();
@@ -1176,7 +1182,7 @@ void QColor::setBlue(int blue)
\sa setRedF(), red(), getRgbF()
*/
-qreal QColor::redF() const
+qreal QColor::redF() const Q_DECL_NOTHROW
{
if (cspec != Invalid && cspec != Rgb)
return toRgb().redF();
@@ -1204,7 +1210,7 @@ void QColor::setRedF(qreal red)
\sa setGreenF(), green(), getRgbF()
*/
-qreal QColor::greenF() const
+qreal QColor::greenF() const Q_DECL_NOTHROW
{
if (cspec != Invalid && cspec != Rgb)
return toRgb().greenF();
@@ -1232,7 +1238,7 @@ void QColor::setGreenF(qreal green)
\sa setBlueF(), blue(), getRgbF()
*/
-qreal QColor::blueF() const
+qreal QColor::blueF() const Q_DECL_NOTHROW
{
if (cspec != Invalid && cspec != Rgb)
return toRgb().blueF();
@@ -1262,7 +1268,7 @@ void QColor::setBlueF(qreal blue)
\sa hsvHue(), hueF(), getHsv(), {QColor#The HSV Color Model}{The HSV Color Model}
*/
-int QColor::hue() const
+int QColor::hue() const Q_DECL_NOTHROW
{
return hsvHue();
}
@@ -1272,7 +1278,7 @@ int QColor::hue() const
\sa hueF(), getHsv(), {QColor#The HSV Color Model}{The HSV Color Model}
*/
-int QColor::hsvHue() const
+int QColor::hsvHue() const Q_DECL_NOTHROW
{
if (cspec != Invalid && cspec != Hsv)
return toHsv().hue();
@@ -1288,7 +1294,7 @@ int QColor::hsvHue() const
Model}
*/
-int QColor::saturation() const
+int QColor::saturation() const Q_DECL_NOTHROW
{
return hsvSaturation();
}
@@ -1298,7 +1304,7 @@ int QColor::saturation() const
\sa saturationF(), getHsv(), {QColor#The HSV Color Model}{The HSV Color Model}
*/
-int QColor::hsvSaturation() const
+int QColor::hsvSaturation() const Q_DECL_NOTHROW
{
if (cspec != Invalid && cspec != Hsv)
return toHsv().saturation();
@@ -1310,7 +1316,7 @@ int QColor::hsvSaturation() const
\sa valueF(), getHsv(), {QColor#The HSV Color Model}{The HSV Color Model}
*/
-int QColor::value() const
+int QColor::value() const Q_DECL_NOTHROW
{
if (cspec != Invalid && cspec != Hsv)
return toHsv().value();
@@ -1324,7 +1330,7 @@ int QColor::value() const
\sa hsvHueF(), hue(), getHsvF(), {QColor#The HSV Color Model}{The HSV Color Model}
*/
-qreal QColor::hueF() const
+qreal QColor::hueF() const Q_DECL_NOTHROW
{
return hsvHueF();
}
@@ -1335,7 +1341,7 @@ qreal QColor::hueF() const
\sa hue(), getHsvF(), {QColor#The HSV Color Model}{The HSV Color
Model}
*/
-qreal QColor::hsvHueF() const
+qreal QColor::hsvHueF() const Q_DECL_NOTHROW
{
if (cspec != Invalid && cspec != Hsv)
return toHsv().hueF();
@@ -1350,7 +1356,7 @@ qreal QColor::hsvHueF() const
\sa hsvSaturationF(), saturation(), getHsvF(), {QColor#The HSV Color Model}{The HSV Color
Model}
*/
-qreal QColor::saturationF() const
+qreal QColor::saturationF() const Q_DECL_NOTHROW
{
return hsvSaturationF();
}
@@ -1360,7 +1366,7 @@ qreal QColor::saturationF() const
\sa saturation(), getHsvF(), {QColor#The HSV Color Model}{The HSV Color Model}
*/
-qreal QColor::hsvSaturationF() const
+qreal QColor::hsvSaturationF() const Q_DECL_NOTHROW
{
if (cspec != Invalid && cspec != Hsv)
return toHsv().saturationF();
@@ -1372,7 +1378,7 @@ qreal QColor::hsvSaturationF() const
\sa value(), getHsvF(), {QColor#The HSV Color Model}{The HSV Color Model}
*/
-qreal QColor::valueF() const
+qreal QColor::valueF() const Q_DECL_NOTHROW
{
if (cspec != Invalid && cspec != Hsv)
return toHsv().valueF();
@@ -1386,7 +1392,7 @@ qreal QColor::valueF() const
\sa getHslF(), getHsl()
*/
-int QColor::hslHue() const
+int QColor::hslHue() const Q_DECL_NOTHROW
{
if (cspec != Invalid && cspec != Hsl)
return toHsl().hslHue();
@@ -1400,7 +1406,7 @@ int QColor::hslHue() const
\sa saturationF(), getHsv(), {QColor#The HSV Color Model}{The HSV Color Model}
*/
-int QColor::hslSaturation() const
+int QColor::hslSaturation() const Q_DECL_NOTHROW
{
if (cspec != Invalid && cspec != Hsl)
return toHsl().hslSaturation();
@@ -1414,7 +1420,7 @@ int QColor::hslSaturation() const
\sa lightnessF(), getHsl()
*/
-int QColor::lightness() const
+int QColor::lightness() const Q_DECL_NOTHROW
{
if (cspec != Invalid && cspec != Hsl)
return toHsl().lightness();
@@ -1428,7 +1434,7 @@ int QColor::lightness() const
\sa hue(), getHslF()
*/
-qreal QColor::hslHueF() const
+qreal QColor::hslHueF() const Q_DECL_NOTHROW
{
if (cspec != Invalid && cspec != Hsl)
return toHsl().hslHueF();
@@ -1442,7 +1448,7 @@ qreal QColor::hslHueF() const
\sa saturationF(), getHslF()
*/
-qreal QColor::hslSaturationF() const
+qreal QColor::hslSaturationF() const Q_DECL_NOTHROW
{
if (cspec != Invalid && cspec != Hsl)
return toHsl().hslSaturationF();
@@ -1456,7 +1462,7 @@ qreal QColor::hslSaturationF() const
\sa value(), getHslF()
*/
-qreal QColor::lightnessF() const
+qreal QColor::lightnessF() const Q_DECL_NOTHROW
{
if (cspec != Invalid && cspec != Hsl)
return toHsl().lightnessF();
@@ -1468,7 +1474,7 @@ qreal QColor::lightnessF() const
\sa cyanF(), getCmyk(), {QColor#The CMYK Color Model}{The CMYK Color Model}
*/
-int QColor::cyan() const
+int QColor::cyan() const Q_DECL_NOTHROW
{
if (cspec != Invalid && cspec != Cmyk)
return toCmyk().cyan();
@@ -1480,7 +1486,7 @@ int QColor::cyan() const
\sa magentaF(), getCmyk(), {QColor#The CMYK Color Model}{The CMYK Color Model}
*/
-int QColor::magenta() const
+int QColor::magenta() const Q_DECL_NOTHROW
{
if (cspec != Invalid && cspec != Cmyk)
return toCmyk().magenta();
@@ -1492,7 +1498,7 @@ int QColor::magenta() const
\sa yellowF(), getCmyk(), {QColor#The CMYK Color Model}{The CMYK Color Model}
*/
-int QColor::yellow() const
+int QColor::yellow() const Q_DECL_NOTHROW
{
if (cspec != Invalid && cspec != Cmyk)
return toCmyk().yellow();
@@ -1505,7 +1511,7 @@ int QColor::yellow() const
\sa blackF(), getCmyk(), {QColor#The CMYK Color Model}{The CMYK Color Model}
*/
-int QColor::black() const
+int QColor::black() const Q_DECL_NOTHROW
{
if (cspec != Invalid && cspec != Cmyk)
return toCmyk().black();
@@ -1517,7 +1523,7 @@ int QColor::black() const
\sa cyan(), getCmykF(), {QColor#The CMYK Color Model}{The CMYK Color Model}
*/
-qreal QColor::cyanF() const
+qreal QColor::cyanF() const Q_DECL_NOTHROW
{
if (cspec != Invalid && cspec != Cmyk)
return toCmyk().cyanF();
@@ -1529,7 +1535,7 @@ qreal QColor::cyanF() const
\sa magenta(), getCmykF(), {QColor#The CMYK Color Model}{The CMYK Color Model}
*/
-qreal QColor::magentaF() const
+qreal QColor::magentaF() const Q_DECL_NOTHROW
{
if (cspec != Invalid && cspec != Cmyk)
return toCmyk().magentaF();
@@ -1541,7 +1547,7 @@ qreal QColor::magentaF() const
\sa yellow(), getCmykF(), {QColor#The CMYK Color Model}{The CMYK Color Model}
*/
-qreal QColor::yellowF() const
+qreal QColor::yellowF() const Q_DECL_NOTHROW
{
if (cspec != Invalid && cspec != Cmyk)
return toCmyk().yellowF();
@@ -1553,7 +1559,7 @@ qreal QColor::yellowF() const
\sa black(), getCmykF(), {QColor#The CMYK Color Model}{The CMYK Color Model}
*/
-qreal QColor::blackF() const
+qreal QColor::blackF() const Q_DECL_NOTHROW
{
if (cspec != Invalid && cspec != Cmyk)
return toCmyk().blackF();
@@ -1565,7 +1571,7 @@ qreal QColor::blackF() const
\sa fromRgb(), convertTo(), isValid()
*/
-QColor QColor::toRgb() const
+QColor QColor::toRgb() const Q_DECL_NOTHROW
{
if (!isValid() || cspec == Rgb)
return *this;
@@ -1711,7 +1717,7 @@ QColor QColor::toRgb() const
\sa fromHsv(), convertTo(), isValid(), {QColor#The HSV Color Model}{The HSV Color Model}
*/
-QColor QColor::toHsv() const
+QColor QColor::toHsv() const Q_DECL_NOTHROW
{
if (!isValid() || cspec == Hsv)
return *this;
@@ -1762,7 +1768,7 @@ QColor QColor::toHsv() const
\sa fromHsl(), convertTo(), isValid()
*/
-QColor QColor::toHsl() const
+QColor QColor::toHsl() const Q_DECL_NOTHROW
{
if (!isValid() || cspec == Hsl)
return *this;
@@ -1818,7 +1824,7 @@ QColor QColor::toHsl() const
\sa fromCmyk(), convertTo(), isValid(), {QColor#The CMYK Color Model}{The CMYK Color Model}
*/
-QColor QColor::toCmyk() const
+QColor QColor::toCmyk() const Q_DECL_NOTHROW
{
if (!isValid() || cspec == Cmyk)
return *this;
@@ -1854,7 +1860,7 @@ QColor QColor::toCmyk() const
return color;
}
-QColor QColor::convertTo(QColor::Spec colorSpec) const
+QColor QColor::convertTo(QColor::Spec colorSpec) const Q_DECL_NOTHROW
{
if (colorSpec == cspec)
return *this;
@@ -1885,7 +1891,7 @@ QColor QColor::convertTo(QColor::Spec colorSpec) const
\sa fromRgba(), fromRgbF(), toRgb(), isValid()
*/
-QColor QColor::fromRgb(QRgb rgb)
+QColor QColor::fromRgb(QRgb rgb) Q_DECL_NOTHROW
{
return fromRgb(qRed(rgb), qGreen(rgb), qBlue(rgb));
}
@@ -1901,7 +1907,7 @@ QColor QColor::fromRgb(QRgb rgb)
\sa fromRgb(), fromRgba64(), isValid()
*/
-QColor QColor::fromRgba(QRgb rgba)
+QColor QColor::fromRgba(QRgb rgba) Q_DECL_NOTHROW
{
return fromRgb(qRed(rgba), qGreen(rgba), qBlue(rgba), qAlpha(rgba));
}
@@ -1974,7 +1980,7 @@ QColor QColor::fromRgbF(qreal r, qreal g, qreal b, qreal a)
\sa fromRgb(), fromRgbF(), toRgb(), isValid()
*/
-QColor QColor::fromRgba64(ushort r, ushort g, ushort b, ushort a)
+QColor QColor::fromRgba64(ushort r, ushort g, ushort b, ushort a) Q_DECL_NOTHROW
{
QColor color;
color.setRgba64(qRgba64(r, g, b, a));
@@ -1989,7 +1995,7 @@ QColor QColor::fromRgba64(ushort r, ushort g, ushort b, ushort a)
\sa fromRgb(), fromRgbF(), toRgb(), isValid()
*/
-QColor QColor::fromRgba64(QRgba64 rgba64)
+QColor QColor::fromRgba64(QRgba64 rgba64) Q_DECL_NOTHROW
{
QColor color;
color.setRgba64(rgba64);
@@ -2323,7 +2329,7 @@ QColor QColor::fromCmykF(qreal c, qreal m, qreal y, qreal k, qreal a)
Use lighter(\a factor) instead.
*/
-QColor QColor::light(int factor) const
+QColor QColor::light(int factor) const Q_DECL_NOTHROW
{
if (factor <= 0) // invalid lightness factor
return *this;
@@ -2373,7 +2379,7 @@ QColor QColor::light(int factor) const
Use darker(\a factor) instead.
*/
-QColor QColor::dark(int factor) const
+QColor QColor::dark(int factor) const Q_DECL_NOTHROW
{
if (factor <= 0) // invalid darkness factor
return *this;
@@ -2391,7 +2397,7 @@ QColor QColor::dark(int factor) const
/*!
Assigns a copy of \a color to this color, and returns a reference to it.
*/
-QColor &QColor::operator=(const QColor &color)
+QColor &QColor::operator=(const QColor &color) Q_DECL_NOTHROW
{
cspec = color.cspec;
ct.argb = color.ct.argb;
@@ -2402,7 +2408,7 @@ QColor &QColor::operator=(const QColor &color)
/*! \overload
Assigns a copy of \a color and returns a reference to this color.
*/
-QColor &QColor::operator=(Qt::GlobalColor color)
+QColor &QColor::operator=(Qt::GlobalColor color) Q_DECL_NOTHROW
{
return operator=(QColor(color));
}
@@ -2411,12 +2417,11 @@ QColor &QColor::operator=(Qt::GlobalColor color)
Returns \c true if this color has the same RGB and alpha values as \a color;
otherwise returns \c false.
*/
-bool QColor::operator==(const QColor &color) const
+bool QColor::operator==(const QColor &color) const Q_DECL_NOTHROW
{
if (cspec == Hsl && cspec == color.cspec) {
return (ct.argb.alpha == color.ct.argb.alpha
- && ((((ct.ahsl.hue % 36000) == (color.ct.ahsl.hue % 36000)))
- || (ct.ahsl.hue == color.ct.ahsl.hue))
+ && ct.ahsl.hue % 36000 == color.ct.ahsl.hue % 36000
&& (qAbs(ct.ahsl.saturation - color.ct.ahsl.saturation) < 50
|| ct.ahsl.lightness == 0
|| color.ct.ahsl.lightness == 0
@@ -2439,7 +2444,7 @@ bool QColor::operator==(const QColor &color) const
Returns \c true if this color has a different RGB and alpha values from
\a color; otherwise returns \c false.
*/
-bool QColor::operator!=(const QColor &color) const
+bool QColor::operator!=(const QColor &color) const Q_DECL_NOTHROW
{ return !operator==(color); }
@@ -2456,7 +2461,7 @@ QColor::operator QVariant() const
Marks the color as invalid and sets all components to zero (alpha is set
to fully opaque for compatibility with Qt 3).
*/
-void QColor::invalidate()
+void QColor::invalidate() Q_DECL_NOTHROW
{
cspec = Invalid;
ct.argb.alpha = USHRT_MAX;