[users] Refactor setting GS
- both changing the autologin and changing the user (login) name affect global storage, and both may need to change the autologin username; split it into a free function. - the fullname change was bypassing the login in changing the login name, **but** then it needs a back-workaround to keep the "custom" setting off (when custom is off, auto-fill username and hostname is active). - after loading the config, fill GS already. - when finalizing GS, get the autologin settings again.
This commit is contained in:
parent
d7dc48d201
commit
ec0b68084f
@ -30,6 +30,30 @@ static const QRegExp HOSTNAME_RX( "^[a-zA-Z0-9][-a-zA-Z0-9_]*$" );
|
|||||||
static constexpr const int HOSTNAME_MIN_LENGTH = 2;
|
static constexpr const int HOSTNAME_MIN_LENGTH = 2;
|
||||||
static constexpr const int HOSTNAME_MAX_LENGTH = 63;
|
static constexpr const int HOSTNAME_MAX_LENGTH = 63;
|
||||||
|
|
||||||
|
static void
|
||||||
|
updateGSAutoLogin( bool doAutoLogin, const QString& login )
|
||||||
|
{
|
||||||
|
Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage();
|
||||||
|
|
||||||
|
if ( doAutoLogin && !login.isEmpty() )
|
||||||
|
{
|
||||||
|
gs->insert( "autologinUser", login );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gs->remove( "autologinUser" );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( login.isEmpty() )
|
||||||
|
{
|
||||||
|
gs->remove( "username" );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gs->insert( "username", login );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const NamedEnumTable< HostNameAction >&
|
const NamedEnumTable< HostNameAction >&
|
||||||
hostNameActionNames()
|
hostNameActionNames()
|
||||||
{
|
{
|
||||||
@ -110,15 +134,7 @@ Config::setLoginName( const QString& login )
|
|||||||
{
|
{
|
||||||
if ( login != m_loginName )
|
if ( login != m_loginName )
|
||||||
{
|
{
|
||||||
Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage();
|
updateGSAutoLogin( doAutoLogin(), login );
|
||||||
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;
|
||||||
@ -330,9 +346,9 @@ Config::setFullName( const QString& name )
|
|||||||
QString login = makeLoginNameSuggestion( cleanParts );
|
QString login = makeLoginNameSuggestion( cleanParts );
|
||||||
if ( !login.isEmpty() && login != m_loginName )
|
if ( !login.isEmpty() && login != m_loginName )
|
||||||
{
|
{
|
||||||
m_loginName = login;
|
setLoginName( login );
|
||||||
emit loginNameChanged( login );
|
// It's **still** not custom, though setLoginName() sets that
|
||||||
emit loginNameStatusChanged( loginNameStatus() );
|
m_customLoginName = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( !m_customHostName )
|
if ( !m_customHostName )
|
||||||
@ -340,9 +356,9 @@ Config::setFullName( const QString& name )
|
|||||||
QString hostname = makeHostnameSuggestion( cleanParts );
|
QString hostname = makeHostnameSuggestion( cleanParts );
|
||||||
if ( !hostname.isEmpty() && hostname != m_hostName )
|
if ( !hostname.isEmpty() && hostname != m_hostName )
|
||||||
{
|
{
|
||||||
m_hostName = hostname;
|
setHostName( hostname );
|
||||||
emit hostNameChanged( hostname );
|
// Still not custom
|
||||||
emit hostNameStatusChanged( hostNameStatus() );
|
m_customHostName = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -353,15 +369,7 @@ Config::setAutoLogin( bool b )
|
|||||||
{
|
{
|
||||||
if ( b != m_doAutoLogin )
|
if ( b != m_doAutoLogin )
|
||||||
{
|
{
|
||||||
Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage();
|
updateGSAutoLogin( b, loginName() );
|
||||||
if ( b )
|
|
||||||
{
|
|
||||||
gs->insert( "autologinUser", loginName() );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
gs->remove( "autologinUser" );
|
|
||||||
}
|
|
||||||
m_doAutoLogin = b;
|
m_doAutoLogin = b;
|
||||||
emit autoLoginChanged( b );
|
emit autoLoginChanged( b );
|
||||||
}
|
}
|
||||||
@ -700,14 +708,16 @@ Config::setConfigurationMap( const QVariantMap& configurationMap )
|
|||||||
}
|
}
|
||||||
std::sort( m_passwordChecks.begin(), m_passwordChecks.end() );
|
std::sort( m_passwordChecks.begin(), m_passwordChecks.end() );
|
||||||
|
|
||||||
|
updateGSAutoLogin( doAutoLogin(), loginName() );
|
||||||
checkReady();
|
checkReady();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Config::finalizeGlobalStorage() const
|
Config::finalizeGlobalStorage() const
|
||||||
{
|
{
|
||||||
Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage();
|
updateGSAutoLogin( doAutoLogin(), loginName() );
|
||||||
|
|
||||||
|
Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage();
|
||||||
if ( writeRootPassword() )
|
if ( writeRootPassword() )
|
||||||
{
|
{
|
||||||
gs->insert( "reuseRootPassword", reuseUserPasswordForRoot() );
|
gs->insert( "reuseRootPassword", reuseUserPasswordForRoot() );
|
||||||
|
Loading…
Reference in New Issue
Block a user