[users] Move autologin setting to Config

main
Adriaan de Groot 5 years ago
parent 6c930af5cb
commit 45b71c24e7

@ -312,6 +312,16 @@ Config::setFullName( const QString& name )
}
}
void
Config::setAutoLogin( bool b )
{
if ( b != m_doAutoLogin )
{
m_doAutoLogin = b;
emit autoLoginChanged( b );
}
}
void
Config::setConfigurationMap( const QVariantMap& configurationMap )
{
@ -325,4 +335,6 @@ Config::setConfigurationMap( const QVariantMap& configurationMap )
setAutologinGroup( CalamaresUtils::getString( configurationMap, "autologinGroup" ) );
setSudoersGroup( CalamaresUtils::getString( configurationMap, "sudoersGroup" ) );
m_doAutoLogin = CalamaresUtils::getBool( configurationMap, "doAutologin", false );
}

@ -33,6 +33,8 @@ class Config : public QObject
Q_PROPERTY( QString autologinGroup READ autologinGroup WRITE setAutologinGroup NOTIFY autologinGroupChanged )
Q_PROPERTY( QString sudoersGroup READ sudoersGroup WRITE setSudoersGroup NOTIFY sudoersGroupChanged )
Q_PROPERTY( bool doAutoLogin READ doAutoLogin WRITE setAutoLogin NOTIFY autoLoginChanged )
Q_PROPERTY( QString fullName READ fullName WRITE setFullName NOTIFY fullNameChanged )
Q_PROPERTY( QString loginName READ loginName WRITE setLoginName NOTIFY loginNameChanged )
Q_PROPERTY( QString loginNameStatus READ loginNameStatus NOTIFY loginNameStatusChanged )
@ -70,6 +72,9 @@ public:
/// Status message about hostname -- empty for "ok"
QString hostNameStatus() const;
/// Should the user be automatically logged-in?
bool doAutoLogin() const { return m_doAutoLogin; }
static const QStringList& forbiddenLoginNames();
static const QStringList& forbiddenHostNames();
@ -97,6 +102,9 @@ public Q_SLOTS:
/// Sets the host name (flags it as "custom")
void setHostName( const QString& host );
/// Sets the autologin flag
void setAutoLogin( bool b );
signals:
void userShellChanged( const QString& );
void autologinGroupChanged( const QString& );
@ -106,6 +114,7 @@ signals:
void loginNameStatusChanged( const QString& );
void hostNameChanged( const QString& );
void hostNameStatusChanged( const QString& );
void autoLoginChanged( bool );
private:
QString m_userShell;
@ -114,6 +123,8 @@ private:
QString m_fullName;
QString m_loginName;
QString m_hostName;
bool m_doAutoLogin = false;
bool m_customLoginName = false;
bool m_customHostName = false;
};

@ -149,6 +149,11 @@ UsersPage::UsersPage( Config* config, QWidget* parent )
connect( config, &Config::loginNameChanged, ui->textBoxLoginName, &QLineEdit::setText );
connect( config, &Config::loginNameStatusChanged, this, &UsersPage::reportLoginNameStatus );
connect( ui->checkBoxDoAutoLogin, &QCheckBox::stateChanged, this, [this]( int checked ) {
m_config->setAutoLogin( checked != Qt::Unchecked );
} );
connect( config, &Config::autoLoginChanged, ui->checkBoxDoAutoLogin, &QCheckBox::setChecked );
setWriteRootPassword( true );
ui->checkBoxReusePassword->setChecked( true );
ui->checkBoxValidatePassword->setChecked( true );
@ -239,7 +244,7 @@ UsersPage::createJobs( const QStringList& defaultGroupsList )
Calamares::Job* j;
j = new CreateUserJob( m_config->loginName(),
m_config->fullName().isEmpty() ? m_config->loginName() : m_config->fullName(),
ui->checkBoxAutoLogin->isChecked(),
m_config->doAutoLogin(),
defaultGroupsList );
list.append( Calamares::job_ptr( j ) );
@ -248,7 +253,7 @@ UsersPage::createJobs( const QStringList& defaultGroupsList )
gs->insert( "reuseRootPassword", ui->checkBoxReusePassword->isChecked() );
}
gs->insert( "hostname", m_config->hostName() );
if ( ui->checkBoxAutoLogin->isChecked() )
if ( m_config->doAutoLogin() )
{
gs->insert( "autologinUser", m_config->loginName() );
}
@ -378,13 +383,6 @@ UsersPage::setValidatePasswordDefault( bool checked )
emit checkReady( isReady() );
}
void
UsersPage::setAutologinDefault( bool checked )
{
ui->checkBoxAutoLogin->setChecked( checked );
emit checkReady( isReady() );
}
void
UsersPage::setReusePasswordDefault( bool checked )
{

@ -54,7 +54,6 @@ public:
void setWriteRootPassword( bool show );
void setPasswordCheckboxVisible( bool visible );
void setValidatePasswordDefault( bool checked );
void setAutologinDefault( bool checked );
void setReusePasswordDefault( bool checked );
/** @brief Process entries in the passwordRequirements config entry

@ -180,7 +180,6 @@ UsersViewStep::setConfigurationMap( const QVariantMap& configurationMap )
Calamares::JobQueue::instance()->globalStorage()->insert( "setRootPassword", setRootPassword );
m_widget->setWriteRootPassword( setRootPassword );
m_widget->setAutologinDefault( getBool( configurationMap, "doAutologin", false ) );
m_widget->setReusePasswordDefault( getBool( configurationMap, "doReusePassword", false ) );
if ( configurationMap.contains( "passwordRequirements" )

@ -456,7 +456,7 @@
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBoxAutoLogin">
<widget class="QCheckBox" name="checkBoxDoAutoLogin">
<property name="text">
<string>Log in automatically without asking for the password.</string>
</property>

Loading…
Cancel
Save