[users] Move job creation from widget to viewstep
- This is a half-step: the ViewStep shouldn't do job creation either, eventually it needs to be the Config object, but this is better than asking the widget (UI) to create some jobs. - When updating login- or host-name, or the autologin setting, set it in GS as well. This is a minor improvement over doing it only when leaving the page. - Since the Config object isn't complete, there are leftovers in the widget, which has a fillGlobalStorage() for the not-jobs-related bits previously in createJobs().
This commit is contained in:
parent
6a03bcb25e
commit
cc2e3f79ff
@ -87,6 +87,16 @@ Config::setLoginName( const QString& login )
|
|||||||
{
|
{
|
||||||
if ( login != m_loginName )
|
if ( login != m_loginName )
|
||||||
{
|
{
|
||||||
|
Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage();
|
||||||
|
if ( login.isEmpty() )
|
||||||
|
{
|
||||||
|
gs->remove( "username" );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gs->insert( "username", login );
|
||||||
|
}
|
||||||
|
|
||||||
m_customLoginName = !login.isEmpty();
|
m_customLoginName = !login.isEmpty();
|
||||||
m_loginName = login;
|
m_loginName = login;
|
||||||
emit loginNameChanged( login );
|
emit loginNameChanged( login );
|
||||||
@ -143,6 +153,16 @@ Config::setHostName( const QString& host )
|
|||||||
{
|
{
|
||||||
if ( host != m_hostName )
|
if ( host != m_hostName )
|
||||||
{
|
{
|
||||||
|
Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage();
|
||||||
|
if ( host.isEmpty() )
|
||||||
|
{
|
||||||
|
gs->remove( "hostname" );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gs->insert( "hostname", host );
|
||||||
|
}
|
||||||
|
|
||||||
m_customHostName = !host.isEmpty();
|
m_customHostName = !host.isEmpty();
|
||||||
m_hostName = host;
|
m_hostName = host;
|
||||||
emit hostNameChanged( host );
|
emit hostNameChanged( host );
|
||||||
@ -317,6 +337,15 @@ Config::setAutoLogin( bool b )
|
|||||||
{
|
{
|
||||||
if ( b != m_doAutoLogin )
|
if ( b != m_doAutoLogin )
|
||||||
{
|
{
|
||||||
|
Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage();
|
||||||
|
if ( b )
|
||||||
|
{
|
||||||
|
gs->insert( "autologinUser", loginName() );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gs->remove( "autologinUser" );
|
||||||
|
}
|
||||||
m_doAutoLogin = b;
|
m_doAutoLogin = b;
|
||||||
emit autoLoginChanged( b );
|
emit autoLoginChanged( b );
|
||||||
}
|
}
|
||||||
|
@ -24,12 +24,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "UsersPage.h"
|
#include "UsersPage.h"
|
||||||
#include "ui_page_usersetup.h"
|
|
||||||
|
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
#include "CreateUserJob.h"
|
#include "ui_page_usersetup.h"
|
||||||
#include "SetHostNameJob.h"
|
|
||||||
#include "SetPasswordJob.h"
|
|
||||||
|
|
||||||
#include "GlobalStorage.h"
|
#include "GlobalStorage.h"
|
||||||
#include "JobQueue.h"
|
#include "JobQueue.h"
|
||||||
@ -189,7 +186,7 @@ UsersPage::retranslate()
|
|||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
UsersPage::isReady()
|
UsersPage::isReady() const
|
||||||
{
|
{
|
||||||
bool readyFields = m_readyFullName && m_readyHostname && m_readyPassword && m_readyUsername;
|
bool readyFields = m_readyFullName && m_readyHostname && m_readyPassword && m_readyUsername;
|
||||||
// If we're going to write a root password, we need a valid one (or reuse the user's password)
|
// If we're going to write a root password, we need a valid one (or reuse the user's password)
|
||||||
@ -224,38 +221,21 @@ UsersPage::getUserPassword() const
|
|||||||
return QPair< QString, QString >( m_config->loginName(), ui->textBoxUserPassword->text() );
|
return QPair< QString, QString >( m_config->loginName(), ui->textBoxUserPassword->text() );
|
||||||
}
|
}
|
||||||
|
|
||||||
QList< Calamares::job_ptr >
|
void
|
||||||
UsersPage::createJobs( const QStringList& defaultGroupsList )
|
UsersPage::fillGlobalStorage() const
|
||||||
{
|
{
|
||||||
QList< Calamares::job_ptr > list;
|
|
||||||
if ( !isReady() )
|
if ( !isReady() )
|
||||||
{
|
{
|
||||||
return list;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage();
|
Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage();
|
||||||
|
|
||||||
Calamares::Job* j;
|
|
||||||
j = new CreateUserJob( m_config->loginName(),
|
|
||||||
m_config->fullName().isEmpty() ? m_config->loginName() : m_config->fullName(),
|
|
||||||
m_config->doAutoLogin(),
|
|
||||||
defaultGroupsList );
|
|
||||||
list.append( Calamares::job_ptr( j ) );
|
|
||||||
|
|
||||||
if ( m_config->writeRootPassword() )
|
if ( m_config->writeRootPassword() )
|
||||||
{
|
{
|
||||||
gs->insert( "reuseRootPassword", ui->checkBoxReusePassword->isChecked() );
|
gs->insert( "reuseRootPassword", ui->checkBoxReusePassword->isChecked() );
|
||||||
}
|
}
|
||||||
gs->insert( "hostname", m_config->hostName() );
|
|
||||||
if ( m_config->doAutoLogin() )
|
|
||||||
{
|
|
||||||
gs->insert( "autologinUser", m_config->loginName() );
|
|
||||||
}
|
|
||||||
|
|
||||||
gs->insert( "username", m_config->loginName() );
|
|
||||||
gs->insert( "password", CalamaresUtils::obscure( ui->textBoxUserPassword->text() ) );
|
gs->insert( "password", CalamaresUtils::obscure( ui->textBoxUserPassword->text() ) );
|
||||||
|
|
||||||
return list;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -25,7 +25,6 @@
|
|||||||
#define USERSPAGE_H
|
#define USERSPAGE_H
|
||||||
|
|
||||||
#include "CheckPWQuality.h"
|
#include "CheckPWQuality.h"
|
||||||
#include "Job.h"
|
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
@ -45,9 +44,9 @@ public:
|
|||||||
explicit UsersPage( Config* config, QWidget* parent = nullptr );
|
explicit UsersPage( Config* config, QWidget* parent = nullptr );
|
||||||
virtual ~UsersPage();
|
virtual ~UsersPage();
|
||||||
|
|
||||||
bool isReady();
|
bool isReady() const;
|
||||||
|
|
||||||
Calamares::JobList createJobs( const QStringList& defaultGroupsList );
|
void fillGlobalStorage() const;
|
||||||
|
|
||||||
void onActivate();
|
void onActivate();
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#include "UsersViewStep.h"
|
#include "UsersViewStep.h"
|
||||||
|
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
|
#include "CreateUserJob.h"
|
||||||
#include "SetHostNameJob.h"
|
#include "SetHostNameJob.h"
|
||||||
#include "SetPasswordJob.h"
|
#include "SetPasswordJob.h"
|
||||||
#include "UsersPage.h"
|
#include "UsersPage.h"
|
||||||
@ -138,13 +139,16 @@ void
|
|||||||
UsersViewStep::onLeave()
|
UsersViewStep::onLeave()
|
||||||
{
|
{
|
||||||
m_jobs.clear();
|
m_jobs.clear();
|
||||||
if ( !m_widget )
|
if ( !m_widget || !m_widget->isReady() )
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_jobs.append( m_widget->createJobs( m_defaultGroups ) );
|
|
||||||
|
|
||||||
Calamares::Job* j;
|
Calamares::Job* j;
|
||||||
|
j = new CreateUserJob( m_config->loginName(),
|
||||||
|
m_config->fullName().isEmpty() ? m_config->loginName() : m_config->fullName(),
|
||||||
|
m_config->doAutoLogin(),
|
||||||
|
m_defaultGroups );
|
||||||
|
|
||||||
auto userPW = m_widget->getUserPassword();
|
auto userPW = m_widget->getUserPassword();
|
||||||
j = new SetPasswordJob( userPW.first, userPW.second );
|
j = new SetPasswordJob( userPW.first, userPW.second );
|
||||||
@ -155,6 +159,8 @@ UsersViewStep::onLeave()
|
|||||||
|
|
||||||
j = new SetHostNameJob( m_config->hostName(), m_actions );
|
j = new SetHostNameJob( m_config->hostName(), m_actions );
|
||||||
m_jobs.append( Calamares::job_ptr( j ) );
|
m_jobs.append( Calamares::job_ptr( j ) );
|
||||||
|
|
||||||
|
m_widget->fillGlobalStorage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user