From 92595e33bfdcf94506f42f307e97127108ae53d7 Mon Sep 17 00:00:00 2001 From: David Faure Date: Wed, 3 Jul 2024 15:45:37 +0200 Subject: [PATCH] Port away from deprecated API in Qt 6.6: QColor::setNamedColor The replacement, QColor::fromString() exists since Qt 6.4. --- QXlsx/CMakeLists.txt | 2 +- QXlsx/QXlsx.pri | 2 +- QXlsx/QXlsx.pro | 2 +- QXlsx/source/xlsxcolor.cpp | 8 ++++++++ 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/QXlsx/CMakeLists.txt b/QXlsx/CMakeLists.txt index e1a6cc5e..6362711e 100644 --- a/QXlsx/CMakeLists.txt +++ b/QXlsx/CMakeLists.txt @@ -147,7 +147,7 @@ target_compile_definitions(QXlsx PRIVATE QT_USE_QSTRINGBUILDER QT_NO_SIGNALS_SLOTS_KEYWORDS QT_USE_FAST_OPERATOR_PLUS - QT_DISABLE_DEPRECATED_BEFORE=0x060200 + QT_DISABLE_DEPRECATED_BEFORE=0x060600 ) if (NOT WIN32) diff --git a/QXlsx/QXlsx.pri b/QXlsx/QXlsx.pri index 8e2ea599..233c98c2 100644 --- a/QXlsx/QXlsx.pri +++ b/QXlsx/QXlsx.pri @@ -20,7 +20,7 @@ DEFINES += QT_DEPRECATED_WARNINGS # You can also make your code fail to compile if you use deprecated APIs. # In order to do so, uncomment the following line. # You can also select to disable deprecated APIs only up to a certain version of Qt. -#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 +DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060600 # disables all the APIs deprecated before Qt 6.6.0 isEmpty(QXLSX_PARENTPATH) { message( 'QXLSX_PARENTPATH is empty. use default value.' ) diff --git a/QXlsx/QXlsx.pro b/QXlsx/QXlsx.pro index c4946b80..4cd2d173 100644 --- a/QXlsx/QXlsx.pro +++ b/QXlsx/QXlsx.pro @@ -22,7 +22,7 @@ DEFINES += QT_DEPRECATED_WARNINGS # You can also make your code fail to compile if you use deprecated APIs. # In order to do so, uncomment the following line. # You can also select to disable deprecated APIs only up to a certain version of Qt. -#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 +DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060600 # disables all the APIs deprecated before Qt 6.6.0 QXLSX_PARENTPATH=$$PWD/ QXLSX_HEADERPATH=$$PWD/header/ diff --git a/QXlsx/source/xlsxcolor.cpp b/QXlsx/source/xlsxcolor.cpp index 1fee05d4..5fd87cdf 100644 --- a/QXlsx/source/xlsxcolor.cpp +++ b/QXlsx/source/xlsxcolor.cpp @@ -116,6 +116,13 @@ XlsxColor::operator QVariant() const QColor XlsxColor::fromARGBString(const QString &c) { +#if QT_VERSION >= QT_VERSION_CHECK(6, 4, 0) + if (c.startsWith(u'#')) { + return QColor::fromString(c); + } else { + return QColor::fromString(QLatin1Char('#') + c); + } +#else QColor color; if (c.startsWith(u'#')) { color.setNamedColor(c); @@ -123,6 +130,7 @@ QColor XlsxColor::fromARGBString(const QString &c) color.setNamedColor(QLatin1Char('#') + c); } return color; +#endif } QString XlsxColor::toARGBString(const QColor &c)