[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
|
||||
Config::setUserName( const QString& name )
|
||||
Config::setFullName( const QString& name )
|
||||
{
|
||||
// TODO: handle "empty" case
|
||||
// TODO: rename to "FullName"
|
||||
if ( name.isEmpty() && !m_fullName.isEmpty() )
|
||||
{
|
||||
if ( !m_customHostName )
|
||||
{
|
||||
setHostName( name );
|
||||
}
|
||||
if ( !m_customLoginName )
|
||||
{
|
||||
setLoginName( name );
|
||||
}
|
||||
m_fullName = name;
|
||||
emit fullNameChanged( name );
|
||||
}
|
||||
|
||||
if ( name != m_fullName )
|
||||
{
|
||||
m_fullName = name;
|
||||
emit userNameChanged( name );
|
||||
emit fullNameChanged( name );
|
||||
|
||||
// Build login and hostname, if needed
|
||||
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 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 hostName READ hostName WRITE setHostName NOTIFY hostNameChanged )
|
||||
@ -57,7 +57,7 @@ public:
|
||||
QString sudoersGroup() const { return m_sudoersGroup; }
|
||||
|
||||
/// 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
|
||||
QString loginName() const { return m_loginName; }
|
||||
|
||||
@ -81,7 +81,7 @@ public Q_SLOTS:
|
||||
void setSudoersGroup( const QString& group );
|
||||
|
||||
/// 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")
|
||||
void setLoginName( const QString& login );
|
||||
|
||||
@ -92,7 +92,7 @@ signals:
|
||||
void userShellChanged( const QString& );
|
||||
void autologinGroupChanged( const QString& );
|
||||
void sudoersGroupChanged( const QString& );
|
||||
void userNameChanged( const QString& );
|
||||
void fullNameChanged( const QString& );
|
||||
void loginNameChanged( const QString& );
|
||||
void hostNameChanged( const QString& );
|
||||
|
||||
|
@ -92,7 +92,6 @@ UsersPage::UsersPage( Config* config, QWidget* parent )
|
||||
ui->setupUi( this );
|
||||
|
||||
// Connect signals and slots
|
||||
connect( ui->textBoxFullName, &QLineEdit::textEdited, this, &UsersPage::onFullNameTextEdited );
|
||||
connect( ui->textBoxUserPassword, &QLineEdit::textChanged, this, &UsersPage::onPasswordTextChanged );
|
||||
connect( ui->textBoxUserVerifiedPassword, &QLineEdit::textChanged, this, &UsersPage::onPasswordTextChanged );
|
||||
connect( ui->textBoxRootPassword, &QLineEdit::textChanged, this, &UsersPage::onRootPasswordTextChanged );
|
||||
@ -121,7 +120,10 @@ UsersPage::UsersPage( Config* config, QWidget* parent )
|
||||
checkReady( isReady() );
|
||||
} );
|
||||
|
||||
connect( ui->textBoxHostName, &QLineEdit::textEdited, config, &Config::setHostName);
|
||||
connect( ui->textBoxFullName, &QLineEdit::textEdited, config, &Config::setFullName );
|
||||
connect( config, &Config::fullNameChanged, this, &UsersPage::onFullNameTextEdited );
|
||||
|
||||
connect( ui->textBoxHostName, &QLineEdit::textEdited, config, &Config::setHostName );
|
||||
connect( config, &Config::hostNameChanged, ui->textBoxHostName, &QLineEdit::setText );
|
||||
connect( config, &Config::hostNameChanged, this, &UsersPage::validateHostnameText );
|
||||
|
||||
@ -150,14 +152,14 @@ UsersPage::retranslate()
|
||||
if ( Calamares::Settings::instance()->isSetupMode() )
|
||||
{
|
||||
ui->textBoxLoginName->setToolTip( tr( "<small>If more than one person will "
|
||||
"use this computer, you can create multiple "
|
||||
"accounts after setup.</small>" ) );
|
||||
"use this computer, you can create multiple "
|
||||
"accounts after setup.</small>" ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->textBoxLoginName->setToolTip( tr( "<small>If more than one person will "
|
||||
"use this computer, you can create multiple "
|
||||
"accounts after installation.</small>" ) );
|
||||
"use this computer, you can create multiple "
|
||||
"accounts after installation.</small>" ) );
|
||||
}
|
||||
// Re-do password checks (with output messages) as well.
|
||||
// .. the password-checking methods get their values from the text boxes,
|
||||
@ -218,8 +220,7 @@ UsersPage::createJobs( const QStringList& defaultGroupsList )
|
||||
|
||||
Calamares::Job* j;
|
||||
j = new CreateUserJob( m_config->loginName(),
|
||||
m_config->userName().isEmpty() ? m_config->loginName()
|
||||
: m_config->userName(),
|
||||
m_config->fullName().isEmpty() ? m_config->loginName() : m_config->fullName(),
|
||||
ui->checkBoxAutoLogin->isChecked(),
|
||||
defaultGroupsList );
|
||||
list.append( Calamares::job_ptr( j ) );
|
||||
@ -265,16 +266,6 @@ UsersPage::onFullNameTextEdited( const QString& textRef )
|
||||
{
|
||||
ui->labelFullNameError->clear();
|
||||
ui->labelFullName->clear();
|
||||
#if 0
|
||||
if ( !m_customUsername )
|
||||
{
|
||||
ui->textBoxUsername->clear();
|
||||
}
|
||||
if ( !m_customHostname )
|
||||
{
|
||||
ui->textBoxHostname->clear();
|
||||
}
|
||||
#endif
|
||||
m_readyFullName = false;
|
||||
}
|
||||
else
|
||||
@ -287,7 +278,6 @@ UsersPage::onFullNameTextEdited( const QString& textRef )
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
UsersPage::validateUsernameText( const QString& textRef )
|
||||
{
|
||||
@ -321,11 +311,9 @@ UsersPage::validateUsernameText( const QString& textRef )
|
||||
tr( "Only lowercase letters, numbers, underscore and hyphen are allowed." ) );
|
||||
m_readyUsername = false;
|
||||
}
|
||||
else if ( 0 == QString::compare("root", text, Qt::CaseSensitive ) )
|
||||
else if ( 0 == QString::compare( "root", text, Qt::CaseSensitive ) )
|
||||
{
|
||||
labelError( ui->labelUsername,
|
||||
ui->labelUsernameError,
|
||||
tr( "'root' is not allowed as user name." ) );
|
||||
labelError( ui->labelUsername, ui->labelUsernameError, tr( "'root' is not allowed as user name." ) );
|
||||
m_readyUsername = false;
|
||||
}
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user