From 5a6a9a0d45d95ebef47019a6632effeead0cd67b Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 20 Jul 2020 22:21:29 +0200 Subject: [PATCH] [locale] Move job-creation to Config - since Config knows what settings there are, it should create the jobs to run later -- not the Page. - this doesn't work yet, because the Config does **not** know what the selected timezone is yet. --- src/modules/locale/Config.cpp | 17 +++++++++++++++++ src/modules/locale/Config.h | 2 ++ src/modules/locale/LocalePage.cpp | 17 +---------------- src/modules/locale/LocalePage.h | 2 -- src/modules/locale/LocaleViewStep.cpp | 2 +- 5 files changed, 21 insertions(+), 19 deletions(-) diff --git a/src/modules/locale/Config.cpp b/src/modules/locale/Config.cpp index 39ae8732b..2e0eb8173 100644 --- a/src/modules/locale/Config.cpp +++ b/src/modules/locale/Config.cpp @@ -20,6 +20,8 @@ #include "Config.h" +#include "SetTimezoneJob.h" + #include "utils/Logger.h" #include "utils/Variant.h" @@ -172,3 +174,18 @@ Config::setConfigurationMap( const QVariantMap& configurationMap ) } m_localeGenLines = loadLocales( localeGenPath ); } + +Calamares::JobList +Config::createJobs() +{ + Calamares::JobList list; + const CalamaresUtils::Locale::TZZone* location = nullptr; // TODO: m_tzWidget->currentLocation(); + + if ( location ) + { + Calamares::Job* j = new SetTimezoneJob( location->region(), location->zone() ); + list.append( Calamares::job_ptr( j ) ); + } + + return list; +} diff --git a/src/modules/locale/Config.h b/src/modules/locale/Config.h index 4f8c9bc64..8e1f29cf7 100644 --- a/src/modules/locale/Config.h +++ b/src/modules/locale/Config.h @@ -21,6 +21,7 @@ #ifndef LOCALE_CONFIG_H #define LOCALE_CONFIG_H +#include "Job.h" #include "locale/TimeZone.h" #include @@ -40,6 +41,7 @@ public: ~Config(); void setConfigurationMap( const QVariantMap& ); + Calamares::JobList createJobs(); public Q_SLOTS: const QStringList& supportedLocales() const { return m_localeGenLines; } diff --git a/src/modules/locale/LocalePage.cpp b/src/modules/locale/LocalePage.cpp index 2a4212fca..b3fa8e8e9 100644 --- a/src/modules/locale/LocalePage.cpp +++ b/src/modules/locale/LocalePage.cpp @@ -114,9 +114,7 @@ LocalePage::LocalePage( Config* config, QWidget* parent ) } -LocalePage::~LocalePage() -{ -} +LocalePage::~LocalePage() {} void @@ -185,19 +183,6 @@ LocalePage::prettyStatus() const } -Calamares::JobList -LocalePage::createJobs() -{ - QList< Calamares::job_ptr > list; - const CalamaresUtils::Locale::TZZone* location = m_tzWidget->currentLocation(); - - Calamares::Job* j = new SetTimezoneJob( location->region(), location->zone() ); - list.append( Calamares::job_ptr( j ) ); - - return list; -} - - QMap< QString, QString > LocalePage::localesMap() { diff --git a/src/modules/locale/LocalePage.h b/src/modules/locale/LocalePage.h index 6c7fed1d6..c8312309e 100644 --- a/src/modules/locale/LocalePage.h +++ b/src/modules/locale/LocalePage.h @@ -47,8 +47,6 @@ public: QString prettyStatus() const; - Calamares::JobList createJobs(); - QMap< QString, QString > localesMap(); void onActivate(); diff --git a/src/modules/locale/LocaleViewStep.cpp b/src/modules/locale/LocaleViewStep.cpp index d71523da1..81162d843 100644 --- a/src/modules/locale/LocaleViewStep.cpp +++ b/src/modules/locale/LocaleViewStep.cpp @@ -166,7 +166,7 @@ LocaleViewStep::onLeave() { if ( m_actualWidget ) { - m_jobs = m_actualWidget->createJobs(); + m_jobs = m_config->createJobs(); m_prettyStatus = m_actualWidget->prettyStatus(); auto map = m_actualWidget->localesMap();