From 9106dd9337dfd82511176a900a1f13f31447ce77 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 2 Dec 2024 13:22:39 +0100 Subject: [PATCH] [welcome] Follow deprecations in QLocale --- src/modules/welcome/Config.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/modules/welcome/Config.cpp b/src/modules/welcome/Config.cpp index 2bce564f6..ad5e2d8bc 100644 --- a/src/modules/welcome/Config.cpp +++ b/src/modules/welcome/Config.cpp @@ -116,6 +116,18 @@ Config::languageIcon() const return m_languageIcon; } +static bool +languageAndTerritoryMatch( const QLocale& a, const QLocale& b ) +{ + const bool languageMatch = a.language() == b.language(); +#if QT_VERSION < QT_VERSION_CHECK( 6, 6, 0 ) + const bool placeMatch = a.country() == b.country(); +#else + const bool placeMatch = a.territory() == b.territory(); +#endif + return languageMatch && placeMatch; +} + void Config::initLanguages() { @@ -131,9 +143,8 @@ Config::initLanguages() QLocale defaultLocale = defaultTranslation.locale(); cDebug() << "Trying to match locale" << defaultLocale; - matchedLocaleIndex = m_languages->find( - [ & ]( const QLocale& x ) - { return x.language() == defaultLocale.language() && x.country() == defaultLocale.country(); } ); + matchedLocaleIndex = m_languages->find( [ &defaultLocale ]( const QLocale& x ) + { return languageAndTerritoryMatch( defaultLocale, x ); } ); if ( matchedLocaleIndex < 0 ) {