diff options
Diffstat (limited to 'src/gui/painting/qcolor.cpp')
-rw-r--r-- | src/gui/painting/qcolor.cpp | 96 |
1 files changed, 89 insertions, 7 deletions
diff --git a/src/gui/painting/qcolor.cpp b/src/gui/painting/qcolor.cpp index d50c42f1ee..3f30c061dc 100644 --- a/src/gui/painting/qcolor.cpp +++ b/src/gui/painting/qcolor.cpp @@ -416,6 +416,18 @@ QColor::QColor(QRgb color) ct.argb.pad = 0; } +/*! + \since 5.6 + + Constructs a color with the value \a rgba64. + + \sa fromRgba64() +*/ + +QColor::QColor(QRgba64 rgba64) +{ + setRgba64(rgba64); +} /*! \internal @@ -469,6 +481,7 @@ QColor::QColor(Spec spec) \sa setNamedColor(), name(), isValid() */ +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) /*! \fn QColor::QColor(const QColor &color) @@ -476,6 +489,7 @@ QColor::QColor(Spec spec) \sa isValid() */ +#endif /*! \fn bool QColor::isValid() const @@ -941,7 +955,7 @@ void QColor::setRgb(int r, int g, int b, int a) For an invalid color, the alpha value of the returned color is unspecified. - \sa setRgba(), rgb() + \sa setRgba(), rgb(), rgba64() */ QRgb QColor::rgba() const @@ -954,7 +968,7 @@ QRgb QColor::rgba() const /*! Sets the RGB value to \a rgba, including its alpha. - \sa rgba(), rgb() + \sa rgba(), rgb(), setRgba64() */ void QColor::setRgba(QRgb rgba) { @@ -967,6 +981,40 @@ void QColor::setRgba(QRgb rgba) } /*! + \since 5.6 + + Returns the RGB64 value of the color, including its alpha. + + For an invalid color, the alpha value of the returned color is unspecified. + + \sa setRgba64(), rgba(), rgb() +*/ + +QRgba64 QColor::rgba64() const +{ + if (cspec != Invalid && cspec != Rgb) + return toRgb().rgba64(); + return qRgba64(ct.argb.red, ct.argb.green, ct.argb.blue, ct.argb.alpha); +} + +/*! + \since 5.6 + + Sets the RGB64 value to \a rgba, including its alpha. + + \sa \setRgba(), rgba64() +*/ +void QColor::setRgba64(QRgba64 rgba) +{ + cspec = Rgb; + ct.argb.alpha = rgba.alpha(); + ct.argb.red = rgba.red(); + ct.argb.green = rgba.green(); + ct.argb.blue = rgba.blue(); + ct.argb.pad = 0; +} + +/*! \fn QRgb QColor::rgb() const Returns the RGB value of the color. The alpha value is opaque. @@ -1850,7 +1898,7 @@ QColor QColor::fromRgb(QRgb rgb) Unlike the fromRgb() function, the alpha-channel specified by the given QRgb value is included. - \sa fromRgb(), isValid() + \sa fromRgb(), fromRgba64(), isValid() */ QColor QColor::fromRgba(QRgb rgba) @@ -1865,7 +1913,7 @@ QColor QColor::fromRgba(QRgb rgba) All the values must be in the range 0-255. - \sa toRgb(), fromRgbF(), isValid() + \sa toRgb(), fromRgba64(), fromRgbF(), isValid() */ QColor QColor::fromRgb(int r, int g, int b, int a) { @@ -1894,7 +1942,7 @@ QColor QColor::fromRgb(int r, int g, int b, int a) All the values must be in the range 0.0-1.0. - \sa fromRgb(), toRgb(), isValid() + \sa fromRgb(), fromRgba64(), toRgb(), isValid() */ QColor QColor::fromRgbF(qreal r, qreal g, qreal b, qreal a) { @@ -1916,6 +1964,38 @@ QColor QColor::fromRgbF(qreal r, qreal g, qreal b, qreal a) return color; } + +/*! + \since 5.6 + + Static convenience function that returns a QColor constructed from the RGBA64 + color values, \a r (red), \a g (green), \a b (blue), and \a a + (alpha-channel, i.e. transparency). + + \sa fromRgb(), fromRgbF(), toRgb(), isValid() +*/ +QColor QColor::fromRgba64(ushort r, ushort g, ushort b, ushort a) +{ + QColor color; + color.setRgba64(qRgba64(r, g, b, a)); + return color; +} + +/*! + \since 5.6 + + Static convenience function that returns a QColor constructed from the + given QRgba64 value \a rgba64. + + \sa fromRgb(), fromRgbF(), toRgb(), isValid() +*/ +QColor QColor::fromRgba64(QRgba64 rgba64) +{ + QColor color; + color.setRgba64(rgba64); + return color; +} + /*! Static convenience function that returns a QColor constructed from the HSV color values, \a h (hue), \a s (saturation), \a v (value), and \a a @@ -1995,7 +2075,7 @@ QColor QColor::fromHsl(int h, int s, int l, int a) || s < 0 || s > 255 || l < 0 || l > 255 || a < 0 || a > 255) { - qWarning("QColor::fromHsv: HSV parameters out of range"); + qWarning("QColor::fromHsl: HSL parameters out of range"); return QColor(); } @@ -2027,7 +2107,7 @@ QColor QColor::fromHslF(qreal h, qreal s, qreal l, qreal a) || (s < qreal(0.0) || s > qreal(1.0)) || (l < qreal(0.0) || l > qreal(1.0)) || (a < qreal(0.0) || a > qreal(1.0))) { - qWarning("QColor::fromHsvF: HSV parameters out of range"); + qWarning("QColor::fromHslF: HSL parameters out of range"); return QColor(); } @@ -2307,6 +2387,7 @@ QColor QColor::dark(int factor) const return hsv.convertTo(cspec); } +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) /*! Assigns a copy of \a color to this color, and returns a reference to it. */ @@ -2316,6 +2397,7 @@ QColor &QColor::operator=(const QColor &color) ct.argb = color.ct.argb; return *this; } +#endif /*! \overload Assigns a copy of \a color and returns a reference to this color. |