From 18a3092aa1941546c1464446767d5b9857ff6c05 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Sat, 2 Jul 2022 23:18:38 +0200 Subject: [PATCH] [libcalamares] Use namespace Calamares The distinction CalamaresUtils and Calamares is old-fashioned, since we can use nested namespaces (and already do) for a lot of things; make libcalamares/locale/ a bit more consistent by using namespace Calamares::Locale for everything. --- src/libcalamares/locale/Lookup.cpp | 4 ++-- src/libcalamares/locale/Lookup.h | 4 ++-- src/libcalamares/locale/Tests.cpp | 4 ++-- src/libcalamares/locale/Translation.cpp | 4 ++-- src/libcalamares/locale/Translation.h | 4 ++-- src/libcalamares/locale/TranslationsModel.cpp | 4 ++-- src/libcalamares/locale/TranslationsModel.h | 4 ++-- src/libcalamares/utils/Retranslator.cpp | 8 ++++---- src/libcalamares/utils/Retranslator.h | 6 +++--- src/modules/locale/Config.cpp | 2 +- src/modules/welcome/Config.cpp | 14 +++++++------- src/modules/welcome/Config.h | 6 +++--- src/modules/welcome/WelcomePage.cpp | 2 +- src/modules/welcome/WelcomePage.h | 2 +- 14 files changed, 34 insertions(+), 34 deletions(-) diff --git a/src/libcalamares/locale/Lookup.cpp b/src/libcalamares/locale/Lookup.cpp index 3dba50898..60c36fdf6 100644 --- a/src/libcalamares/locale/Lookup.cpp +++ b/src/libcalamares/locale/Lookup.cpp @@ -12,7 +12,7 @@ #include "CountryData_p.cpp" -namespace CalamaresUtils +namespace Calamares { namespace Locale { @@ -95,4 +95,4 @@ languageForCountry( QLocale::Country country ) } } // namespace Locale -} // namespace CalamaresUtils +} // namespace Calamares diff --git a/src/libcalamares/locale/Lookup.h b/src/libcalamares/locale/Lookup.h index 4095fd097..d026f9343 100644 --- a/src/libcalamares/locale/Lookup.h +++ b/src/libcalamares/locale/Lookup.h @@ -16,7 +16,7 @@ #include #include -namespace CalamaresUtils +namespace Calamares { namespace Locale { @@ -42,6 +42,6 @@ DLLEXPORT QPair< QLocale::Country, QLocale::Language > countryData( const QStrin /// @brief Get a likely locale for a 2-letter country code DLLEXPORT QLocale countryLocale( const QString& code ); } // namespace Locale -} // namespace CalamaresUtils +} // namespace Calamares #endif diff --git a/src/libcalamares/locale/Tests.cpp b/src/libcalamares/locale/Tests.cpp index fa8ea3342..d32d8fafb 100644 --- a/src/libcalamares/locale/Tests.cpp +++ b/src/libcalamares/locale/Tests.cpp @@ -72,7 +72,7 @@ LocaleTests::initTestCase() void LocaleTests::testLanguageModelCount() { - const auto* m = CalamaresUtils::Locale::availableTranslations(); + const auto* m = Calamares::Locale::availableTranslations(); QVERIFY( m ); QVERIFY( m->rowCount( QModelIndex() ) > 1 ); @@ -91,7 +91,7 @@ LocaleTests::testLanguageModelCount() void LocaleTests::testLanguageScripts() { - const auto* m = CalamaresUtils::Locale::availableTranslations(); + const auto* m = Calamares::Locale::availableTranslations(); QVERIFY( m ); diff --git a/src/libcalamares/locale/Translation.cpp b/src/libcalamares/locale/Translation.cpp index 279949d3f..9d2beafb8 100644 --- a/src/libcalamares/locale/Translation.cpp +++ b/src/libcalamares/locale/Translation.cpp @@ -128,7 +128,7 @@ specialCaseSystemLanguage() return ( it != std::cend( special_cases ) ) ? QString::fromLatin1( it->id ) : QString(); } -namespace CalamaresUtils +namespace Calamares { namespace Locale { @@ -187,4 +187,4 @@ Translation::getLocale( const Id& localeId ) } } // namespace Locale -} // namespace CalamaresUtils +} // namespace Calamares diff --git a/src/libcalamares/locale/Translation.h b/src/libcalamares/locale/Translation.h index 912a509ac..e7f066475 100644 --- a/src/libcalamares/locale/Translation.h +++ b/src/libcalamares/locale/Translation.h @@ -18,7 +18,7 @@ #include #include -namespace CalamaresUtils +namespace Calamares { namespace Locale { @@ -124,6 +124,6 @@ operator==( const Translation::Id& lhs, const Translation::Id& rhs ) } } // namespace Locale -} // namespace CalamaresUtils +} // namespace Calamares #endif diff --git a/src/libcalamares/locale/TranslationsModel.cpp b/src/libcalamares/locale/TranslationsModel.cpp index e8cc5130e..304246053 100644 --- a/src/libcalamares/locale/TranslationsModel.cpp +++ b/src/libcalamares/locale/TranslationsModel.cpp @@ -15,7 +15,7 @@ #include "CalamaresTranslations.h" // For the list of translations -namespace CalamaresUtils +namespace Calamares { namespace Locale { @@ -144,4 +144,4 @@ availableTranslations() } } // namespace Locale -} // namespace CalamaresUtils +} // namespace Calamares diff --git a/src/libcalamares/locale/TranslationsModel.h b/src/libcalamares/locale/TranslationsModel.h index f95b756a8..6982f871f 100644 --- a/src/libcalamares/locale/TranslationsModel.h +++ b/src/libcalamares/locale/TranslationsModel.h @@ -19,7 +19,7 @@ #include -namespace CalamaresUtils +namespace Calamares { namespace Locale { @@ -85,5 +85,5 @@ private: */ DLLEXPORT TranslationsModel* availableTranslations(); } // namespace Locale -} // namespace CalamaresUtils +} // namespace Calamares #endif diff --git a/src/libcalamares/utils/Retranslator.cpp b/src/libcalamares/utils/Retranslator.cpp index f3ae93836..5af975002 100644 --- a/src/libcalamares/utils/Retranslator.cpp +++ b/src/libcalamares/utils/Retranslator.cpp @@ -178,7 +178,7 @@ static QTranslator* s_tztranslator = nullptr; static QString s_translatorLocaleName; void -installTranslator( const CalamaresUtils::Locale::Translation::Id& locale, const QString& brandingTranslationsPrefix ) +installTranslator( const Calamares::Locale::Translation::Id& locale, const QString& brandingTranslationsPrefix ) { s_translatorLocaleName = locale.name; @@ -190,17 +190,17 @@ installTranslator( const CalamaresUtils::Locale::Translation::Id& locale, const void installTranslator() { - installTranslator( CalamaresUtils::Locale::Translation().id(), QString() ); + installTranslator( Calamares::Locale::Translation().id(), QString() ); } -CalamaresUtils::Locale::Translation::Id +Calamares::Locale::Translation::Id translatorLocaleName() { return { s_translatorLocaleName }; } bool -loadTranslator( const CalamaresUtils::Locale::Translation::Id& locale, const QString& prefix, QTranslator* translator ) +loadTranslator( const Calamares::Locale::Translation::Id& locale, const QString& prefix, QTranslator* translator ) { return ::tryLoad( translator, prefix, locale.name ); } diff --git a/src/libcalamares/utils/Retranslator.h b/src/libcalamares/utils/Retranslator.h index 94eba8b1c..33106d4c8 100644 --- a/src/libcalamares/utils/Retranslator.h +++ b/src/libcalamares/utils/Retranslator.h @@ -29,7 +29,7 @@ namespace CalamaresUtils * @param locale the new locale (names as defined by Calamares). * @param brandingTranslationsPrefix the branding path prefix, from Calamares::Branding. */ -DLLEXPORT void installTranslator( const CalamaresUtils::Locale::Translation::Id& locale, +DLLEXPORT void installTranslator( const Calamares::Locale::Translation::Id& locale, const QString& brandingTranslationsPrefix ); /** @brief Initializes the translations with the current system settings @@ -42,7 +42,7 @@ DLLEXPORT void installTranslator(); * QLocale passed in, because Calamares will munge some names and * may remap translations. */ -DLLEXPORT CalamaresUtils::Locale::Translation::Id translatorLocaleName(); +DLLEXPORT Calamares::Locale::Translation::Id translatorLocaleName(); /** @brief Loads translations into the given @p translator * @@ -58,7 +58,7 @@ DLLEXPORT CalamaresUtils::Locale::Translation::Id translatorLocaleName(); * @returns @c true on success */ DLLEXPORT bool -loadTranslator( const CalamaresUtils::Locale::Translation::Id& locale, const QString& prefix, QTranslator* translator ); +loadTranslator( const Calamares::Locale::Translation::Id& locale, const QString& prefix, QTranslator* translator ); /** @brief Set @p allow to true to load translations from current dir. * diff --git a/src/modules/locale/Config.cpp b/src/modules/locale/Config.cpp index 2357019a7..8167aaec2 100644 --- a/src/modules/locale/Config.cpp +++ b/src/modules/locale/Config.cpp @@ -399,7 +399,7 @@ Config::currentTimezoneName() const static inline QString localeLabel( const QString& s ) { - using CalamaresUtils::Locale::Translation; + using Calamares::Locale::Translation; Translation lang( { s }, Translation::LabelFormat::AlwaysWithCountry ); return lang.label(); diff --git a/src/modules/welcome/Config.cpp b/src/modules/welcome/Config.cpp index 0e692637b..ca907d384 100644 --- a/src/modules/welcome/Config.cpp +++ b/src/modules/welcome/Config.cpp @@ -26,7 +26,7 @@ Config::Config( QObject* parent ) : QObject( parent ) - , m_languages( CalamaresUtils::Locale::availableTranslations() ) + , m_languages( Calamares::Locale::availableTranslations() ) , m_filtermodel( std::make_unique< QSortFilterProxyModel >() ) , m_requirementsChecker( std::make_unique< GeneralRequirements >( this ) ) { @@ -84,7 +84,7 @@ Config::retranslate() emit warningMessageChanged( m_warningMessage ); } -CalamaresUtils::Locale::TranslationsModel* +Calamares::Locale::TranslationsModel* Config::languagesModel() const { return m_languages; @@ -120,7 +120,7 @@ void Config::initLanguages() { // Find the best initial translation - CalamaresUtils::Locale::Translation defaultTranslation; + Calamares::Locale::Translation defaultTranslation; cDebug() << "Trying to match locale" << defaultTranslation.id(); int matchedLocaleIndex = m_languages->find( defaultTranslation.id() ); @@ -172,7 +172,7 @@ void Config::setCountryCode( const QString& countryCode ) { m_countryCode = countryCode; - setLocaleIndex( CalamaresUtils::Locale::availableTranslations()->find( m_countryCode ) ); + setLocaleIndex( Calamares::Locale::availableTranslations()->find( m_countryCode ) ); emit countryCodeChanged( m_countryCode ); } @@ -186,7 +186,7 @@ Config::setLanguageIcon( const QString& languageIcon ) void Config::setLocaleIndex( int index ) { - if ( index == m_localeIndex || index > CalamaresUtils::Locale::availableTranslations()->rowCount( QModelIndex() ) + if ( index == m_localeIndex || index > Calamares::Locale::availableTranslations()->rowCount( QModelIndex() ) || index < 0 ) { return; @@ -347,7 +347,7 @@ setCountry( Config* config, const QString& countryCode, CalamaresUtils::GeoIP::H return; } - auto c_l = CalamaresUtils::Locale::countryData( countryCode ); + auto c_l = Calamares::Locale::countryData( countryCode ); if ( c_l.first == QLocale::Country::AnyCountry ) { cDebug() << "Unusable country code" << countryCode; @@ -356,7 +356,7 @@ setCountry( Config* config, const QString& countryCode, CalamaresUtils::GeoIP::H } else { - int r = CalamaresUtils::Locale::availableTranslations()->find( countryCode ); + int r = Calamares::Locale::availableTranslations()->find( countryCode ); if ( r < 0 ) { cDebug() << "Unusable country code" << countryCode << "(no suitable translation)"; diff --git a/src/modules/welcome/Config.h b/src/modules/welcome/Config.h index 49d9a1b11..276f0cc33 100644 --- a/src/modules/welcome/Config.h +++ b/src/modules/welcome/Config.h @@ -28,7 +28,7 @@ class Config : public QObject * This is a list-model, with names and descriptions for the translations * available to Calamares. */ - Q_PROPERTY( CalamaresUtils::Locale::TranslationsModel* languagesModel READ languagesModel CONSTANT FINAL ) + Q_PROPERTY( Calamares::Locale::TranslationsModel* languagesModel READ languagesModel CONSTANT FINAL ) /** @brief The requirements (from modules) and their checked-status * * The model grows rows over time as each module is checked and its @@ -95,7 +95,7 @@ public: QString warningMessage() const; public slots: - CalamaresUtils::Locale::TranslationsModel* languagesModel() const; + Calamares::Locale::TranslationsModel* languagesModel() const; void retranslate(); ///@brief The **global** requirements model, from ModuleManager @@ -122,7 +122,7 @@ signals: private: void initLanguages(); - CalamaresUtils::Locale::TranslationsModel* m_languages = nullptr; + Calamares::Locale::TranslationsModel* m_languages = nullptr; std::unique_ptr< QSortFilterProxyModel > m_filtermodel; std::unique_ptr< GeneralRequirements > m_requirementsChecker; diff --git a/src/modules/welcome/WelcomePage.cpp b/src/modules/welcome/WelcomePage.cpp index 597317069..96675261b 100644 --- a/src/modules/welcome/WelcomePage.cpp +++ b/src/modules/welcome/WelcomePage.cpp @@ -222,5 +222,5 @@ LocaleTwoColumnDelegate::paint( QPainter* painter, const QStyleOptionViewItem& o Qt::AlignRight | Qt::AlignVCenter, option.palette, false, - index.data( CalamaresUtils::Locale::TranslationsModel::EnglishLabelRole ).toString() ); + index.data( Calamares::Locale::TranslationsModel::EnglishLabelRole ).toString() ); } diff --git a/src/modules/welcome/WelcomePage.h b/src/modules/welcome/WelcomePage.h index 71aebd468..163d13eb1 100644 --- a/src/modules/welcome/WelcomePage.h +++ b/src/modules/welcome/WelcomePage.h @@ -63,7 +63,7 @@ private: Ui::WelcomePage* ui; CheckerContainer* m_checkingWidget; - CalamaresUtils::Locale::TranslationsModel* m_languages; + Calamares::Locale::TranslationsModel* m_languages; Config* m_conf; };