From 3ff480eaa9566bba95e6beaa4e9a43d843694574 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 7 Jan 2019 17:29:54 +0100 Subject: [PATCH] [locale] Refactor to make updating global locale setting easier. --- src/modules/locale/LocalePage.cpp | 13 +++++++++++-- src/modules/locale/LocalePage.h | 6 ++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/modules/locale/LocalePage.cpp b/src/modules/locale/LocalePage.cpp index f9e2aa515..d5bd8147a 100644 --- a/src/modules/locale/LocalePage.cpp +++ b/src/modules/locale/LocalePage.cpp @@ -481,6 +481,16 @@ LocalePage::prettyLCLocale( const QString& lcLocale ) const .arg( QLocale::countryToString( locale.country() ) ); } + +void +LocalePage::updateGlobalLocale() +{ + auto *gs = Calamares::JobQueue::instance()->globalStorage(); + const QString bcp47 = m_selectedLocaleConfiguration.toBcp47(); + gs->insert( "locale", bcp47 ); +} + + void LocalePage::updateGlobalStorage() { @@ -493,8 +503,7 @@ LocalePage::updateGlobalStorage() gs->insert( "locationRegion", location.region ); gs->insert( "locationZone", location.zone ); - const QString bcp47 = m_selectedLocaleConfiguration.toBcp47(); - gs->insert( "locale", bcp47 ); + updateGlobalLocale(); // If we're in chroot mode (normal install mode), then we immediately set the // timezone on the live system. When debugging timezones, don't bother. diff --git a/src/modules/locale/LocalePage.h b/src/modules/locale/LocalePage.h index c4ca20503..4b93c690e 100644 --- a/src/modules/locale/LocalePage.h +++ b/src/modules/locale/LocalePage.h @@ -57,6 +57,12 @@ private: // the settings for language and numbers. std::pair< QString, QString > prettyLocaleStatus( const LocaleConfiguration& ) const; + /** @brief Update the GS *locale* key with the selected system language. + * + * This uses whatever is set in m_selectedLocaleConfiguration as the language, + * and writes it to GS *locale* key (as a string, in BCP47 format). + */ + void updateGlobalLocale(); void updateGlobalStorage(); void updateLocaleLabels();