From 4f6c8a7b5d079bb12cff39489bb42cfcbea73ed2 Mon Sep 17 00:00:00 2001 From: Laurent Montel Date: Wed, 29 Dec 2021 11:33:14 +0100 Subject: [PATCH] Port deprecated I18N_NOOP2 --- src/colorscheme/ColorScheme.cpp | 15 +++++++++++++-- src/colorscheme/ColorScheme.h | 9 +++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/colorscheme/ColorScheme.cpp b/src/colorscheme/ColorScheme.cpp index 0dd83b98..4f73167b 100644 --- a/src/colorscheme/ColorScheme.cpp +++ b/src/colorscheme/ColorScheme.cpp @@ -30,7 +30,10 @@ #include #endif - +#if KI18N_VERSION >= QT_VERSION_CHECK(5, 89, 0) +#undef I18N_NOOP2 +#define I18N_NOOP2 kli18nc +#endif namespace { const int FGCOLOR_INDEX = 0; @@ -119,7 +122,12 @@ const char *const ColorScheme::colorNames[TABLE_COLORS] = { "Color6Faint", "Color7Faint", }; + +#if KI18N_VERSION >= QT_VERSION_CHECK(5, 89, 0) +const KLazyLocalizedString ColorScheme::translatedColorNames[TABLE_COLORS] = { +#else const char *const ColorScheme::translatedColorNames[TABLE_COLORS] = { +#endif I18N_NOOP2("@item:intable palette", "Foreground"), I18N_NOOP2("@item:intable palette", "Background"), I18N_NOOP2("@item:intable palette", "Color 1"), @@ -162,8 +170,11 @@ QString ColorScheme::colorNameForIndex(int index) QString ColorScheme::translatedColorNameForIndex(int index) { Q_ASSERT(index >= 0 && index < TABLE_COLORS); - +#if KI18N_VERSION >= QT_VERSION_CHECK(5, 89, 0) + return translatedColorNames[index].toString(); +#else return i18nc("@item:intable palette", translatedColorNames[index]); +#endif } ColorScheme::ColorScheme() diff --git a/src/colorscheme/ColorScheme.h b/src/colorscheme/ColorScheme.h index d130b9bc..377a67b1 100644 --- a/src/colorscheme/ColorScheme.h +++ b/src/colorscheme/ColorScheme.h @@ -19,6 +19,11 @@ // Konsole #include "ColorSchemeWallpaper.h" +#include +#if KI18N_VERSION >= QT_VERSION_CHECK(5, 89, 0) +#include +#endif + class KConfig; class QPixmap; class QPainter; @@ -185,7 +190,11 @@ private: ColorSchemeWallpaper::Ptr _wallpaper; static const char *const colorNames[TABLE_COLORS]; +#if KI18N_VERSION >= QT_VERSION_CHECK(5, 89, 0) + static const KLazyLocalizedString translatedColorNames[TABLE_COLORS]; +#else static const char *const translatedColorNames[TABLE_COLORS]; +#endif }; }