diff options
author | Marc Mutz <marc.mutz@qt.io> | 2022-02-15 11:58:08 +0100 |
---|---|---|
committer | Marc Mutz <marc.mutz@qt.io> | 2022-03-15 10:36:09 +0000 |
commit | ce83a03cfda1b1d98234e8d82f8c41eda285384e (patch) | |
tree | 89b1eb2f55cac8248a3e7f05b32fe3c186e6f653 /src | |
parent | ee0908228f0e06f426c3c95d4e7fb733d9433705 (diff) |
QColor: deprecate isValidColor, setNamedColor, string-ish ctors
[ChangeLog][QtGui][QColor] The constructors from string-ish type, as
well as the setNamedColor() and isValidColor() functions, have been
deprecated effective Qt 6.6 in favor of fromString() and
isValidColorName(), resp.
Fixes: QTBUG-101389
Change-Id: I002646bd48c1e4340dc6842fd136fc9f35bb9b61
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/painting/qcolor.cpp | 22 | ||||
-rw-r--r-- | src/gui/painting/qcolor.h | 18 |
2 files changed, 31 insertions, 9 deletions
diff --git a/src/gui/painting/qcolor.cpp b/src/gui/painting/qcolor.cpp index 94eac47ffb..48bfdd79b9 100644 --- a/src/gui/painting/qcolor.cpp +++ b/src/gui/painting/qcolor.cpp @@ -820,10 +820,11 @@ QColor::QColor(Spec spec) noexcept } } +#if QT_DEPRECATED_SINCE(6, 6) /*! \fn QColor::QColor(const QString &name) - \obsolete + \deprecated [6.6] Use fromString() instead. Constructs a named color in the same way as setNamedColor() using the given \a name. @@ -836,7 +837,7 @@ QColor::QColor(Spec spec) noexcept /*! \fn QColor::QColor(const char *name) - \obsolete + \deprecated [6.6] Use fromString() instead. Constructs a named color in the same way as setNamedColor() using the given \a name. @@ -848,7 +849,7 @@ QColor::QColor(Spec spec) noexcept /*! \fn QColor::QColor(QLatin1String name) - \obsolete + \deprecated [6.6] Use fromString() instead. Constructs a named color in the same way as setNamedColor() using the given \a name. @@ -857,6 +858,7 @@ QColor::QColor(Spec spec) noexcept \since 5.8 \sa setNamedColor(), name(), isValid() */ +#endif // QT_DEPRECATED_SINCE(6, 6) /*! \fn bool QColor::isValid() const @@ -884,8 +886,9 @@ QString QColor::name(NameFormat format) const return QString(); } +#if QT_DEPRECATED_SINCE(6, 6) /*! - \obsolete + \deprecated [6.6] Use fromString() instead. Sets the RGB value of this QColor to \a name, which may be in one of these formats: @@ -918,7 +921,7 @@ void QColor::setNamedColor(const QString &name) /*! \overload \since 5.10 - \obsolete + \deprecated [6.6] Use fromString() instead. */ void QColor::setNamedColor(QStringView name) @@ -929,7 +932,7 @@ void QColor::setNamedColor(QStringView name) /*! \overload \since 5.8 - \obsolete + \deprecated [6.6] Use fromString() instead. */ void QColor::setNamedColor(QLatin1String name) @@ -940,7 +943,7 @@ void QColor::setNamedColor(QLatin1String name) /*! \since 4.7 - \obsolete + \deprecated [6.6] Use isValidColorName() instead. Returns \c true if the \a name is a valid color name and can be used to construct a valid QColor object, otherwise returns @@ -958,7 +961,7 @@ bool QColor::isValidColor(const QString &name) /*! \overload \since 5.10 - \obsolete + \deprecated [6.6] Use isValidColorName() instead. */ bool QColor::isValidColor(QStringView name) noexcept { @@ -968,12 +971,13 @@ bool QColor::isValidColor(QStringView name) noexcept /*! \overload \since 5.8 - \obsolete + \deprecated [6.6] Use isValidColorName() instead. */ bool QColor::isValidColor(QLatin1String name) noexcept { return isValidColorName(name); } +#endif // QT_DEPRECATED_SINCE(6, 6) /*! \since 6.4 diff --git a/src/gui/painting/qcolor.h b/src/gui/painting/qcolor.h index 5bb4da87cf..26e7623e9f 100644 --- a/src/gui/painting/qcolor.h +++ b/src/gui/painting/qcolor.h @@ -83,10 +83,16 @@ public: 0) {} QColor(QRgb rgb) noexcept; QColor(QRgba64 rgba64) noexcept; +#if QT_DEPRECATED_SINCE(6, 6) + QT_DEPRECATED_VERSION_X_6_6("Use QColor::fromString() instead.") inline QColor(const QString& name); + QT_DEPRECATED_VERSION_X_6_6("Use QColor::fromString() instead.") explicit inline QColor(QStringView name); + QT_DEPRECATED_VERSION_X_6_6("Use QColor::fromString() instead.") inline QColor(const char *aname); + QT_DEPRECATED_VERSION_X_6_6("Use QColor::fromString() instead.") inline QColor(QLatin1String name); +#endif QColor(Spec spec) noexcept; static QColor fromString(QAnyStringView name) noexcept; @@ -97,9 +103,14 @@ public: QString name(NameFormat format = HexRgb) const; +#if QT_DEPRECATED_SINCE(6, 6) + QT_DEPRECATED_VERSION_X_6_6("Use fromString() instead.") void setNamedColor(const QString& name); + QT_DEPRECATED_VERSION_X_6_6("Use fromString() instead.") void setNamedColor(QStringView name); + QT_DEPRECATED_VERSION_X_6_6("Use fromString() instead.") void setNamedColor(QLatin1String name); +#endif static QStringList colorNames(); @@ -223,9 +234,14 @@ public: operator QVariant() const; +#if QT_DEPRECATED_SINCE(6, 6) + QT_DEPRECATED_VERSION_X_6_6("Use isValidColorName() instead.") static bool isValidColor(const QString &name); + QT_DEPRECATED_VERSION_X_6_6("Use isValidColorName() instead.") static bool isValidColor(QStringView) noexcept; + QT_DEPRECATED_VERSION_X_6_6("Use isValidColorName() instead.") static bool isValidColor(QLatin1String) noexcept; +#endif static bool isValidColorName(QAnyStringView) noexcept; private: @@ -296,6 +312,7 @@ public: // can't give friendship to a namespace, so it needs to be public }; Q_DECLARE_TYPEINFO(QColor, Q_RELOCATABLE_TYPE); +#if QT_DEPRECATED_SINCE(6, 6) inline QColor::QColor(QLatin1String aname) : QColor(fromString(aname)) {} @@ -307,6 +324,7 @@ inline QColor::QColor(const QString& aname) inline QColor::QColor(const char *aname) : QColor(fromString(aname)) {} +#endif inline bool QColor::isValid() const noexcept { return cspec != Invalid; } |