[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.
This commit is contained in:
Adriaan de Groot 2020-07-20 22:21:29 +02:00
parent 8c21b59853
commit 5a6a9a0d45
5 changed files with 21 additions and 19 deletions

View File

@ -20,6 +20,8 @@
#include "Config.h" #include "Config.h"
#include "SetTimezoneJob.h"
#include "utils/Logger.h" #include "utils/Logger.h"
#include "utils/Variant.h" #include "utils/Variant.h"
@ -172,3 +174,18 @@ Config::setConfigurationMap( const QVariantMap& configurationMap )
} }
m_localeGenLines = loadLocales( localeGenPath ); 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;
}

View File

@ -21,6 +21,7 @@
#ifndef LOCALE_CONFIG_H #ifndef LOCALE_CONFIG_H
#define LOCALE_CONFIG_H #define LOCALE_CONFIG_H
#include "Job.h"
#include "locale/TimeZone.h" #include "locale/TimeZone.h"
#include <QObject> #include <QObject>
@ -40,6 +41,7 @@ public:
~Config(); ~Config();
void setConfigurationMap( const QVariantMap& ); void setConfigurationMap( const QVariantMap& );
Calamares::JobList createJobs();
public Q_SLOTS: public Q_SLOTS:
const QStringList& supportedLocales() const { return m_localeGenLines; } const QStringList& supportedLocales() const { return m_localeGenLines; }

View File

@ -114,9 +114,7 @@ LocalePage::LocalePage( Config* config, QWidget* parent )
} }
LocalePage::~LocalePage() LocalePage::~LocalePage() {}
{
}
void 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 > QMap< QString, QString >
LocalePage::localesMap() LocalePage::localesMap()
{ {

View File

@ -47,8 +47,6 @@ public:
QString prettyStatus() const; QString prettyStatus() const;
Calamares::JobList createJobs();
QMap< QString, QString > localesMap(); QMap< QString, QString > localesMap();
void onActivate(); void onActivate();

View File

@ -166,7 +166,7 @@ LocaleViewStep::onLeave()
{ {
if ( m_actualWidget ) if ( m_actualWidget )
{ {
m_jobs = m_actualWidget->createJobs(); m_jobs = m_config->createJobs();
m_prettyStatus = m_actualWidget->prettyStatus(); m_prettyStatus = m_actualWidget->prettyStatus();
auto map = m_actualWidget->localesMap(); auto map = m_actualWidget->localesMap();