diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -44,7 +44,6 @@ Plasma Declarative NetworkManagerQt - KDELibs4Support ) find_package(KF5ModemManagerQt ${KF5_MIN_VERSION}) diff --git a/libs/editor/CMakeLists.txt b/libs/editor/CMakeLists.txt --- a/libs/editor/CMakeLists.txt +++ b/libs/editor/CMakeLists.txt @@ -99,7 +99,6 @@ KF5::Notifications KF5::Wallet KF5::Solid - KF5::KDELibs4Support # KLocale ) if (WITH_MODEMMANAGER_SUPPORT) diff --git a/libs/editor/mobileproviders.cpp b/libs/editor/mobileproviders.cpp --- a/libs/editor/mobileproviders.cpp +++ b/libs/editor/mobileproviders.cpp @@ -23,8 +23,7 @@ #include #include - -#include +#include const QString MobileProviders::ProvidersFile = "/usr/share/mobile-broadband-provider-info/serviceproviders.xml"; @@ -34,10 +33,21 @@ MobileProviders::MobileProviders() { - const QStringList allCountries = KLocale::global()->allCountriesList(); - Q_FOREACH (const QString & cc, allCountries) { - // qCDebug(PLASMA_NM) << "Inserting" << cc.toUpper() << KLocale::global()->countryCodeToName(cc); - mCountries.insert(cc.toUpper(), KLocale::global()->countryCodeToName(cc)); + for (int c = 1; c <= QLocale::LastCountry; c++) { + const auto country = static_cast(c); + QLocale locale(QLocale::AnyLanguage, country); + if (locale.country() == country) { + const QString localeName = locale.name(); + const auto idx = localeName.indexOf(QLatin1Char('_')); + if (idx != -1) { + const QString countryCode = localeName.mid(idx + 1); + QString countryName = locale.nativeCountryName(); + if (countryName.isEmpty()) { + countryName = QLocale::countryToString(country); + } + mCountries.insert(countryCode, countryName); + } + } } mError = Success; @@ -85,7 +95,12 @@ QString MobileProviders::countryFromLocale() const { - return KLocale::global()->country().toUpper(); + const QString localeName = QLocale().name(); + const auto idx = localeName.indexOf(QLatin1Char('_')); + if (idx != -1) { + return localeName.mid(idx + 1); + } + return QString(); } QStringList MobileProviders::getProvidersList(QString country, NetworkManager::ConnectionSettings::ConnectionType type) @@ -303,10 +318,9 @@ QString MobileProviders::getNameByLocale(const QMap & localizedNames) const { QString name; - const QStringList locales = KLocale::global()->languageList(); + const QStringList locales = QLocale().uiLanguages(); Q_FOREACH (const QString & locale, locales) { - QString language, country, modifier, charset; - KLocale::splitLocale(locale, language, country, modifier, charset); + QString language = locale.split(QLatin1Char('-')).at(0); if (localizedNames.contains(language)) { return localizedNames[language];