[users] Hook up full name to Config
This commit is contained in:
parent
630a508049
commit
d4a784f521
@ -166,14 +166,26 @@ makeHostnameSuggestion( const QStringList& parts )
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Config::setUserName( const QString& name )
|
Config::setFullName( const QString& name )
|
||||||
{
|
{
|
||||||
// TODO: handle "empty" case
|
if ( name.isEmpty() && !m_fullName.isEmpty() )
|
||||||
// TODO: rename to "FullName"
|
{
|
||||||
|
if ( !m_customHostName )
|
||||||
|
{
|
||||||
|
setHostName( name );
|
||||||
|
}
|
||||||
|
if ( !m_customLoginName )
|
||||||
|
{
|
||||||
|
setLoginName( name );
|
||||||
|
}
|
||||||
|
m_fullName = name;
|
||||||
|
emit fullNameChanged( name );
|
||||||
|
}
|
||||||
|
|
||||||
if ( name != m_fullName )
|
if ( name != m_fullName )
|
||||||
{
|
{
|
||||||
m_fullName = name;
|
m_fullName = name;
|
||||||
emit userNameChanged( name );
|
emit fullNameChanged( name );
|
||||||
|
|
||||||
// Build login and hostname, if needed
|
// Build login and hostname, if needed
|
||||||
QRegExp rx( "[^a-zA-Z0-9 ]", Qt::CaseInsensitive );
|
QRegExp rx( "[^a-zA-Z0-9 ]", Qt::CaseInsensitive );
|
||||||
|
@ -33,7 +33,7 @@ class Config : public QObject
|
|||||||
Q_PROPERTY( QString autologinGroup READ autologinGroup WRITE setAutologinGroup NOTIFY autologinGroupChanged )
|
Q_PROPERTY( QString autologinGroup READ autologinGroup WRITE setAutologinGroup NOTIFY autologinGroupChanged )
|
||||||
Q_PROPERTY( QString sudoersGroup READ sudoersGroup WRITE setSudoersGroup NOTIFY sudoersGroupChanged )
|
Q_PROPERTY( QString sudoersGroup READ sudoersGroup WRITE setSudoersGroup NOTIFY sudoersGroupChanged )
|
||||||
|
|
||||||
Q_PROPERTY( QString userName READ userName WRITE setUserName NOTIFY userNameChanged )
|
Q_PROPERTY( QString fullName READ fullName WRITE setFullName NOTIFY fullNameChanged )
|
||||||
Q_PROPERTY( QString loginName READ loginName WRITE setLoginName NOTIFY loginNameChanged )
|
Q_PROPERTY( QString loginName READ loginName WRITE setLoginName NOTIFY loginNameChanged )
|
||||||
|
|
||||||
Q_PROPERTY( QString hostName READ hostName WRITE setHostName NOTIFY hostNameChanged )
|
Q_PROPERTY( QString hostName READ hostName WRITE setHostName NOTIFY hostNameChanged )
|
||||||
@ -57,7 +57,7 @@ public:
|
|||||||
QString sudoersGroup() const { return m_sudoersGroup; }
|
QString sudoersGroup() const { return m_sudoersGroup; }
|
||||||
|
|
||||||
/// The full (GECOS) name of the user
|
/// The full (GECOS) name of the user
|
||||||
QString userName() const { return m_fullName; }
|
QString fullName() const { return m_fullName; }
|
||||||
/// The login name of the user
|
/// The login name of the user
|
||||||
QString loginName() const { return m_loginName; }
|
QString loginName() const { return m_loginName; }
|
||||||
|
|
||||||
@ -81,7 +81,7 @@ public Q_SLOTS:
|
|||||||
void setSudoersGroup( const QString& group );
|
void setSudoersGroup( const QString& group );
|
||||||
|
|
||||||
/// Sets the full name, may guess a loginName
|
/// Sets the full name, may guess a loginName
|
||||||
void setUserName( const QString& name );
|
void setFullName( const QString& name );
|
||||||
/// Sets the login name (flags it as "custom")
|
/// Sets the login name (flags it as "custom")
|
||||||
void setLoginName( const QString& login );
|
void setLoginName( const QString& login );
|
||||||
|
|
||||||
@ -92,7 +92,7 @@ signals:
|
|||||||
void userShellChanged( const QString& );
|
void userShellChanged( const QString& );
|
||||||
void autologinGroupChanged( const QString& );
|
void autologinGroupChanged( const QString& );
|
||||||
void sudoersGroupChanged( const QString& );
|
void sudoersGroupChanged( const QString& );
|
||||||
void userNameChanged( const QString& );
|
void fullNameChanged( const QString& );
|
||||||
void loginNameChanged( const QString& );
|
void loginNameChanged( const QString& );
|
||||||
void hostNameChanged( const QString& );
|
void hostNameChanged( const QString& );
|
||||||
|
|
||||||
|
@ -92,7 +92,6 @@ UsersPage::UsersPage( Config* config, QWidget* parent )
|
|||||||
ui->setupUi( this );
|
ui->setupUi( this );
|
||||||
|
|
||||||
// Connect signals and slots
|
// Connect signals and slots
|
||||||
connect( ui->textBoxFullName, &QLineEdit::textEdited, this, &UsersPage::onFullNameTextEdited );
|
|
||||||
connect( ui->textBoxUserPassword, &QLineEdit::textChanged, this, &UsersPage::onPasswordTextChanged );
|
connect( ui->textBoxUserPassword, &QLineEdit::textChanged, this, &UsersPage::onPasswordTextChanged );
|
||||||
connect( ui->textBoxUserVerifiedPassword, &QLineEdit::textChanged, this, &UsersPage::onPasswordTextChanged );
|
connect( ui->textBoxUserVerifiedPassword, &QLineEdit::textChanged, this, &UsersPage::onPasswordTextChanged );
|
||||||
connect( ui->textBoxRootPassword, &QLineEdit::textChanged, this, &UsersPage::onRootPasswordTextChanged );
|
connect( ui->textBoxRootPassword, &QLineEdit::textChanged, this, &UsersPage::onRootPasswordTextChanged );
|
||||||
@ -121,6 +120,9 @@ UsersPage::UsersPage( Config* config, QWidget* parent )
|
|||||||
checkReady( isReady() );
|
checkReady( isReady() );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
connect( ui->textBoxFullName, &QLineEdit::textEdited, config, &Config::setFullName );
|
||||||
|
connect( config, &Config::fullNameChanged, this, &UsersPage::onFullNameTextEdited );
|
||||||
|
|
||||||
connect( ui->textBoxHostName, &QLineEdit::textEdited, config, &Config::setHostName );
|
connect( ui->textBoxHostName, &QLineEdit::textEdited, config, &Config::setHostName );
|
||||||
connect( config, &Config::hostNameChanged, ui->textBoxHostName, &QLineEdit::setText );
|
connect( config, &Config::hostNameChanged, ui->textBoxHostName, &QLineEdit::setText );
|
||||||
connect( config, &Config::hostNameChanged, this, &UsersPage::validateHostnameText );
|
connect( config, &Config::hostNameChanged, this, &UsersPage::validateHostnameText );
|
||||||
@ -218,8 +220,7 @@ UsersPage::createJobs( const QStringList& defaultGroupsList )
|
|||||||
|
|
||||||
Calamares::Job* j;
|
Calamares::Job* j;
|
||||||
j = new CreateUserJob( m_config->loginName(),
|
j = new CreateUserJob( m_config->loginName(),
|
||||||
m_config->userName().isEmpty() ? m_config->loginName()
|
m_config->fullName().isEmpty() ? m_config->loginName() : m_config->fullName(),
|
||||||
: m_config->userName(),
|
|
||||||
ui->checkBoxAutoLogin->isChecked(),
|
ui->checkBoxAutoLogin->isChecked(),
|
||||||
defaultGroupsList );
|
defaultGroupsList );
|
||||||
list.append( Calamares::job_ptr( j ) );
|
list.append( Calamares::job_ptr( j ) );
|
||||||
@ -265,16 +266,6 @@ UsersPage::onFullNameTextEdited( const QString& textRef )
|
|||||||
{
|
{
|
||||||
ui->labelFullNameError->clear();
|
ui->labelFullNameError->clear();
|
||||||
ui->labelFullName->clear();
|
ui->labelFullName->clear();
|
||||||
#if 0
|
|
||||||
if ( !m_customUsername )
|
|
||||||
{
|
|
||||||
ui->textBoxUsername->clear();
|
|
||||||
}
|
|
||||||
if ( !m_customHostname )
|
|
||||||
{
|
|
||||||
ui->textBoxHostname->clear();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
m_readyFullName = false;
|
m_readyFullName = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -287,7 +278,6 @@ UsersPage::onFullNameTextEdited( const QString& textRef )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
UsersPage::validateUsernameText( const QString& textRef )
|
UsersPage::validateUsernameText( const QString& textRef )
|
||||||
{
|
{
|
||||||
@ -323,9 +313,7 @@ UsersPage::validateUsernameText( const QString& textRef )
|
|||||||
}
|
}
|
||||||
else if ( 0 == QString::compare( "root", text, Qt::CaseSensitive ) )
|
else if ( 0 == QString::compare( "root", text, Qt::CaseSensitive ) )
|
||||||
{
|
{
|
||||||
labelError( ui->labelUsername,
|
labelError( ui->labelUsername, ui->labelUsernameError, tr( "'root' is not allowed as user name." ) );
|
||||||
ui->labelUsernameError,
|
|
||||||
tr( "'root' is not allowed as user name." ) );
|
|
||||||
m_readyUsername = false;
|
m_readyUsername = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user