From 2a448c057deef69aaa272dda53bc800097bb23e3 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 10 May 2019 07:53:44 -0400 Subject: [PATCH] [welcome] Provide API for updating the country - Changing country will pre-select the language most likely for that country (it doesn't, yet, since we don't have the data). --- src/modules/welcome/WelcomeViewStep.cpp | 21 ++++++++++++++++++--- src/modules/welcome/WelcomeViewStep.h | 7 +++++++ 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/modules/welcome/WelcomeViewStep.cpp b/src/modules/welcome/WelcomeViewStep.cpp index 91745967e..0442a2d6c 100644 --- a/src/modules/welcome/WelcomeViewStep.cpp +++ b/src/modules/welcome/WelcomeViewStep.cpp @@ -126,9 +126,11 @@ WelcomeViewStep::setConfigurationMap( const QVariantMap& configurationMap ) CalamaresUtils::getString( geoip, "url" ), CalamaresUtils::getString( geoip, "selector" ) ); auto* future = new FWString(); - connect( future, &FWString::finished, [f=future, h=handler]() + connect( future, &FWString::finished, [view=this, f=future, h=handler]() { - cDebug() << "GeoIP result for welcome=" << f->future().result(); + QString countryResult = f->future().result(); + cDebug() << "GeoIP result for welcome=" << countryResult; + view->setCountry( countryResult ); f->deleteLater(); delete h; } ); @@ -136,7 +138,20 @@ WelcomeViewStep::setConfigurationMap( const QVariantMap& configurationMap ) } } -Calamares::RequirementsList WelcomeViewStep::checkRequirements() +Calamares::RequirementsList +WelcomeViewStep::checkRequirements() { return m_requirementsChecker->checkRequirements(); } + +void +WelcomeViewStep::setCountry( const QString& countryCode ) +{ + if ( countryCode.length() != 2 ) + { + cDebug() << "Unusable country code" << countryCode; + return; + } + + cDebug() << "TODO: update country" << countryCode; +} diff --git a/src/modules/welcome/WelcomeViewStep.h b/src/modules/welcome/WelcomeViewStep.h index 937cad246..7deed2167 100644 --- a/src/modules/welcome/WelcomeViewStep.h +++ b/src/modules/welcome/WelcomeViewStep.h @@ -54,6 +54,13 @@ public: void setConfigurationMap( const QVariantMap& configurationMap ) override; + /** @brief Sets the country that Calamares is running in. + * + * This (ideally) sets up language and locale settings that are right for + * the given 2-letter country code. + */ + void setCountry( const QString& ); + Calamares::RequirementsList checkRequirements() override; private: