diff options
Diffstat (limited to 'src/gui/painting/qcolor.cpp')
-rw-r--r-- | src/gui/painting/qcolor.cpp | 66 |
1 files changed, 10 insertions, 56 deletions
diff --git a/src/gui/painting/qcolor.cpp b/src/gui/painting/qcolor.cpp index 708bf501e7..2af2e8cb6b 100644 --- a/src/gui/painting/qcolor.cpp +++ b/src/gui/painting/qcolor.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2022 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: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 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 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. -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2022 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qcolor.h" #include "qcolor_p.h" @@ -820,12 +784,10 @@ QColor::QColor(Spec spec) noexcept } } -#if QT_DEPRECATED_SINCE(6, 6) +// ### Qt 7: remove those after deprecating them for the last Qt 6 LTS release /*! \fn QColor::QColor(const QString &name) - \deprecated [6.6] Use fromString() instead. - Constructs a named color in the same way as setNamedColor() using the given \a name. @@ -837,8 +799,6 @@ QColor::QColor(Spec spec) noexcept /*! \fn QColor::QColor(const char *name) - \deprecated [6.6] Use fromString() instead. - Constructs a named color in the same way as setNamedColor() using the given \a name. @@ -849,8 +809,6 @@ QColor::QColor(Spec spec) noexcept /*! \fn QColor::QColor(QLatin1StringView name) - \deprecated [6.6] Use fromString() instead. - Constructs a named color in the same way as setNamedColor() using the given \a name. @@ -858,7 +816,6 @@ QColor::QColor(Spec spec) noexcept \since 5.8 \sa setNamedColor(), name(), isValid() */ -#endif // QT_DEPRECATED_SINCE(6, 6) /*! \fn bool QColor::isValid() const @@ -1297,15 +1254,12 @@ void QColor::getRgbF(float *r, float *g, float *b, float *a) const if (!r || !g || !b) return; - if (cspec == Invalid) - return; - - if (cspec != Rgb && cspec != ExtendedRgb) { + if (cspec != Invalid && cspec != Rgb && cspec != ExtendedRgb) { toRgb().getRgbF(r, g, b, a); return; } - if (cspec == Rgb) { + if (cspec == Rgb || cspec == Invalid) { *r = ct.argb.red / float(USHRT_MAX); *g = ct.argb.green / float(USHRT_MAX); *b = ct.argb.blue / float(USHRT_MAX); @@ -1529,7 +1483,7 @@ void QColor::setAlpha(int alpha) QCOLOR_INT_RANGE_CHECK("QColor::setAlpha", alpha); if (cspec == ExtendedRgb) { constexpr float f = 1.0f / 255; - castF16(ct.argbExtended.alphaF16) = alpha * f; + castF16(ct.argbExtended.alphaF16) = qfloat16(alpha * f); return; } ct.argb.alpha = alpha * 0x101; @@ -1558,7 +1512,7 @@ void QColor::setAlphaF(float alpha) { QCOLOR_REAL_RANGE_CHECK("QColor::setAlphaF", alpha); if (cspec == ExtendedRgb) { - castF16(ct.argbExtended.alphaF16) = alpha; + castF16(ct.argbExtended.alphaF16) = qfloat16(alpha); return; } float tmp = alpha * USHRT_MAX; @@ -1676,7 +1630,7 @@ void QColor::setRedF(float red) if (cspec == Rgb && red >= 0.0f && red <= 1.0f) ct.argb.red = qRound(red * USHRT_MAX); else if (cspec == ExtendedRgb) - castF16(ct.argbExtended.redF16) = red; + castF16(ct.argbExtended.redF16) = qfloat16(red); else setRgbF(red, greenF(), blueF(), alphaF()); } @@ -1708,7 +1662,7 @@ void QColor::setGreenF(float green) if (cspec == Rgb && green >= 0.0f && green <= 1.0f) ct.argb.green = qRound(green * USHRT_MAX); else if (cspec == ExtendedRgb) - castF16(ct.argbExtended.greenF16) = green; + castF16(ct.argbExtended.greenF16) = qfloat16(green); else setRgbF(redF(), green, blueF(), alphaF()); } @@ -1738,7 +1692,7 @@ void QColor::setBlueF(float blue) if (cspec == Rgb && blue >= 0.0f && blue <= 1.0f) ct.argb.blue = qRound(blue * USHRT_MAX); else if (cspec == ExtendedRgb) - castF16(ct.argbExtended.blueF16) = blue; + castF16(ct.argbExtended.blueF16) = qfloat16(blue); else setRgbF(redF(), greenF(), blue, alphaF()); } |