From 75da1bece4f5da57275e87a3ce276efe3fdd2c83 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Thu, 23 Jul 2020 23:25:52 +0200 Subject: [PATCH] [locale] Add properties for language and LC codes - we already had the human-readable status strings, but also want the actual code (particularly for being able to **update** the code from QML) --- src/modules/locale/Config.cpp | 2 ++ src/modules/locale/Config.h | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/src/modules/locale/Config.cpp b/src/modules/locale/Config.cpp index 42b6d616f..21f4d90a7 100644 --- a/src/modules/locale/Config.cpp +++ b/src/modules/locale/Config.cpp @@ -288,6 +288,7 @@ Config::setLanguageExplicitly( const QString& language ) m_selectedLocaleConfiguration.explicit_lang = true; emit currentLanguageStatusChanged( currentLanguageStatus() ); + emit currentLanguageCodeChanged( currentLanguageCode() ); } void @@ -306,6 +307,7 @@ Config::setLCLocaleExplicitly( const QString& locale ) m_selectedLocaleConfiguration.explicit_lc = true; emit currentLCStatusChanged( currentLCStatus() ); + emit currentLCCodeChanged( currentLCCode() ); } QString diff --git a/src/modules/locale/Config.h b/src/modules/locale/Config.h index 3d048bc28..484c1032e 100644 --- a/src/modules/locale/Config.h +++ b/src/modules/locale/Config.h @@ -43,9 +43,13 @@ class Config : public QObject Q_PROPERTY( const CalamaresUtils::Locale::TZZone* currentLocation READ currentLocation WRITE setCurrentLocation NOTIFY currentLocationChanged ) + // Status are complete, human-readable, messages Q_PROPERTY( QString currentLocationStatus READ currentLocationStatus NOTIFY currentLanguageStatusChanged ) Q_PROPERTY( QString currentLanguageStatus READ currentLanguageStatus NOTIFY currentLanguageStatusChanged ) Q_PROPERTY( QString currentLCStatus READ currentLCStatus NOTIFY currentLCStatusChanged ) + // Code are internal identifiers, like "en_US.UTF-8" + Q_PROPERTY( QString currentLanguageCode READ currentLanguageCode WRITE setLanguageExplicitly NOTIFY currentLanguageCodeChanged ) + Q_PROPERTY( QString currentLCCode READ currentLCCode WRITE setLCLocaleExplicitly NOTIFY currentLCCodeChanged ) public: Config( QObject* parent = nullptr ); @@ -103,11 +107,16 @@ public Q_SLOTS: */ void setCurrentLocation( const CalamaresUtils::Locale::TZZone* location ); + QString currentLanguageCode() const { return localeConfiguration().language(); } + QString currentLCCode() const { return localeConfiguration().lc_numeric; } + signals: void currentLocationChanged( const CalamaresUtils::Locale::TZZone* location ) const; void currentLocationStatusChanged( const QString& ) const; void currentLanguageStatusChanged( const QString& ) const; void currentLCStatusChanged( const QString& ) const; + void currentLanguageCodeChanged( const QString& ) const; + void currentLCCodeChanged( const QString& ) const; private: /// A list of supported locale identifiers (e.g. "en_US.UTF-8")