|
|
@ -27,8 +27,8 @@
|
|
|
|
#include "ui_page_usersetup.h"
|
|
|
|
#include "ui_page_usersetup.h"
|
|
|
|
|
|
|
|
|
|
|
|
#include "CreateUserJob.h"
|
|
|
|
#include "CreateUserJob.h"
|
|
|
|
#include "SetPasswordJob.h"
|
|
|
|
|
|
|
|
#include "SetHostNameJob.h"
|
|
|
|
#include "SetHostNameJob.h"
|
|
|
|
|
|
|
|
#include "SetPasswordJob.h"
|
|
|
|
|
|
|
|
|
|
|
|
#include "GlobalStorage.h"
|
|
|
|
#include "GlobalStorage.h"
|
|
|
|
#include "JobQueue.h"
|
|
|
|
#include "JobQueue.h"
|
|
|
@ -74,30 +74,19 @@ UsersPage::UsersPage( QWidget* parent )
|
|
|
|
ui->setupUi( this );
|
|
|
|
ui->setupUi( this );
|
|
|
|
|
|
|
|
|
|
|
|
// Connect signals and slots
|
|
|
|
// Connect signals and slots
|
|
|
|
connect( ui->textBoxFullName, &QLineEdit::textEdited,
|
|
|
|
connect( ui->textBoxFullName, &QLineEdit::textEdited, this, &UsersPage::onFullNameTextEdited );
|
|
|
|
this, &UsersPage::onFullNameTextEdited );
|
|
|
|
connect( ui->textBoxUsername, &QLineEdit::textEdited, this, &UsersPage::onUsernameTextEdited );
|
|
|
|
connect( ui->textBoxUsername, &QLineEdit::textEdited,
|
|
|
|
connect( ui->textBoxHostname, &QLineEdit::textEdited, this, &UsersPage::onHostnameTextEdited );
|
|
|
|
this, &UsersPage::onUsernameTextEdited );
|
|
|
|
connect( ui->textBoxUserPassword, &QLineEdit::textChanged, this, &UsersPage::onPasswordTextChanged );
|
|
|
|
connect( ui->textBoxHostname, &QLineEdit::textEdited,
|
|
|
|
connect( ui->textBoxUserVerifiedPassword, &QLineEdit::textChanged, this, &UsersPage::onPasswordTextChanged );
|
|
|
|
this, &UsersPage::onHostnameTextEdited );
|
|
|
|
connect( ui->textBoxRootPassword, &QLineEdit::textChanged, this, &UsersPage::onRootPasswordTextChanged );
|
|
|
|
connect( ui->textBoxUserPassword, &QLineEdit::textChanged,
|
|
|
|
connect( ui->textBoxVerifiedRootPassword, &QLineEdit::textChanged, this, &UsersPage::onRootPasswordTextChanged );
|
|
|
|
this, &UsersPage::onPasswordTextChanged );
|
|
|
|
connect( ui->checkBoxValidatePassword, &QCheckBox::stateChanged, this, [this]( int checked ) {
|
|
|
|
connect( ui->textBoxUserVerifiedPassword, &QLineEdit::textChanged,
|
|
|
|
|
|
|
|
this, &UsersPage::onPasswordTextChanged );
|
|
|
|
|
|
|
|
connect( ui->textBoxRootPassword, &QLineEdit::textChanged,
|
|
|
|
|
|
|
|
this, &UsersPage::onRootPasswordTextChanged );
|
|
|
|
|
|
|
|
connect( ui->textBoxVerifiedRootPassword, &QLineEdit::textChanged,
|
|
|
|
|
|
|
|
this, &UsersPage::onRootPasswordTextChanged );
|
|
|
|
|
|
|
|
connect( ui->checkBoxValidatePassword, &QCheckBox::stateChanged,
|
|
|
|
|
|
|
|
this, [this]( int checked )
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
onPasswordTextChanged( ui->textBoxUserPassword->text() );
|
|
|
|
onPasswordTextChanged( ui->textBoxUserPassword->text() );
|
|
|
|
onRootPasswordTextChanged( ui->textBoxRootPassword->text() );
|
|
|
|
onRootPasswordTextChanged( ui->textBoxRootPassword->text() );
|
|
|
|
checkReady( isReady() );
|
|
|
|
checkReady( isReady() );
|
|
|
|
} );
|
|
|
|
} );
|
|
|
|
connect( ui->checkBoxReusePassword, &QCheckBox::stateChanged,
|
|
|
|
connect( ui->checkBoxReusePassword, &QCheckBox::stateChanged, this, [this]( int checked ) {
|
|
|
|
this, [this]( int checked )
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
ui->labelChooseRootPassword->setVisible( !checked );
|
|
|
|
ui->labelChooseRootPassword->setVisible( !checked );
|
|
|
|
ui->labelExtraRootPassword->setVisible( !checked );
|
|
|
|
ui->labelExtraRootPassword->setVisible( !checked );
|
|
|
|
ui->labelRootPassword->setVisible( !checked );
|
|
|
|
ui->labelRootPassword->setVisible( !checked );
|
|
|
@ -117,26 +106,22 @@ UsersPage::UsersPage( QWidget* parent )
|
|
|
|
|
|
|
|
|
|
|
|
// Don't expand the explanations to "stupid wide", but keep them vaguely as-wide-as
|
|
|
|
// Don't expand the explanations to "stupid wide", but keep them vaguely as-wide-as
|
|
|
|
// the things they are explaining.
|
|
|
|
// the things they are explaining.
|
|
|
|
int boxWidth = qMax( qMax( ui->textBoxUsername->width(), ui->textBoxHostname->width() ), ui->textBoxUserPassword->width() );
|
|
|
|
int boxWidth
|
|
|
|
|
|
|
|
= qMax( qMax( ui->textBoxUsername->width(), ui->textBoxHostname->width() ), ui->textBoxUserPassword->width() );
|
|
|
|
ui->username_extra_label_2->setMaximumWidth( 3 * boxWidth );
|
|
|
|
ui->username_extra_label_2->setMaximumWidth( 3 * boxWidth );
|
|
|
|
ui->hostname_extra_label_2->setMaximumWidth( 3 * boxWidth );
|
|
|
|
ui->hostname_extra_label_2->setMaximumWidth( 3 * boxWidth );
|
|
|
|
ui->password_extra_label_3->setMaximumWidth( 3 * boxWidth );
|
|
|
|
ui->password_extra_label_3->setMaximumWidth( 3 * boxWidth );
|
|
|
|
|
|
|
|
|
|
|
|
CALAMARES_RETRANSLATE(
|
|
|
|
CALAMARES_RETRANSLATE(
|
|
|
|
ui->retranslateUi( this );
|
|
|
|
ui->retranslateUi( this ); if ( Calamares::Settings::instance()->isSetupMode() ) {
|
|
|
|
if ( Calamares::Settings::instance()->isSetupMode() )
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
ui->username_extra_label_2->setText( tr( "<small>If more than one person will "
|
|
|
|
ui->username_extra_label_2->setText( tr( "<small>If more than one person will "
|
|
|
|
"use this computer, you can create multiple "
|
|
|
|
"use this computer, you can create multiple "
|
|
|
|
"accounts after setup.</small>" ) );
|
|
|
|
"accounts after setup.</small>" ) );
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
ui->username_extra_label_2->setText( tr( "<small>If more than one person will "
|
|
|
|
ui->username_extra_label_2->setText( tr( "<small>If more than one person will "
|
|
|
|
"use this computer, you can create multiple "
|
|
|
|
"use this computer, you can create multiple "
|
|
|
|
"accounts after installation.</small>" ) );
|
|
|
|
"accounts after installation.</small>" ) );
|
|
|
|
}
|
|
|
|
} )
|
|
|
|
)
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -149,12 +134,11 @@ UsersPage::~UsersPage()
|
|
|
|
bool
|
|
|
|
bool
|
|
|
|
UsersPage::isReady()
|
|
|
|
UsersPage::isReady()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
bool readyFields = m_readyFullName &&
|
|
|
|
bool readyFields = m_readyFullName && m_readyHostname && m_readyPassword && m_readyUsername;
|
|
|
|
m_readyHostname &&
|
|
|
|
|
|
|
|
m_readyPassword &&
|
|
|
|
|
|
|
|
m_readyUsername;
|
|
|
|
|
|
|
|
if ( !m_writeRootPassword || ui->checkBoxReusePassword->isChecked() )
|
|
|
|
if ( !m_writeRootPassword || ui->checkBoxReusePassword->isChecked() )
|
|
|
|
|
|
|
|
{
|
|
|
|
return readyFields;
|
|
|
|
return readyFields;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return readyFields && m_readyRootPassword;
|
|
|
|
return readyFields && m_readyRootPassword;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -165,32 +149,30 @@ UsersPage::createJobs( const QStringList& defaultGroupsList )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
QList< Calamares::job_ptr > list;
|
|
|
|
QList< Calamares::job_ptr > list;
|
|
|
|
if ( !isReady() )
|
|
|
|
if ( !isReady() )
|
|
|
|
|
|
|
|
{
|
|
|
|
return list;
|
|
|
|
return list;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage();
|
|
|
|
Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage();
|
|
|
|
|
|
|
|
|
|
|
|
Calamares::Job* j;
|
|
|
|
Calamares::Job* j;
|
|
|
|
j = new CreateUserJob( ui->textBoxUsername->text(),
|
|
|
|
j = new CreateUserJob( ui->textBoxUsername->text(),
|
|
|
|
ui->textBoxFullName->text().isEmpty() ?
|
|
|
|
ui->textBoxFullName->text().isEmpty() ? ui->textBoxUsername->text()
|
|
|
|
ui->textBoxUsername->text() :
|
|
|
|
: ui->textBoxFullName->text(),
|
|
|
|
ui->textBoxFullName->text(),
|
|
|
|
|
|
|
|
ui->checkBoxAutoLogin->isChecked(),
|
|
|
|
ui->checkBoxAutoLogin->isChecked(),
|
|
|
|
defaultGroupsList );
|
|
|
|
defaultGroupsList );
|
|
|
|
list.append( Calamares::job_ptr( j ) );
|
|
|
|
list.append( Calamares::job_ptr( j ) );
|
|
|
|
|
|
|
|
|
|
|
|
j = new SetPasswordJob( ui->textBoxUsername->text(),
|
|
|
|
j = new SetPasswordJob( ui->textBoxUsername->text(), ui->textBoxUserPassword->text() );
|
|
|
|
ui->textBoxUserPassword->text() );
|
|
|
|
|
|
|
|
list.append( Calamares::job_ptr( j ) );
|
|
|
|
list.append( Calamares::job_ptr( j ) );
|
|
|
|
|
|
|
|
|
|
|
|
if ( m_writeRootPassword )
|
|
|
|
if ( m_writeRootPassword )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
gs->insert( "reuseRootPassword", ui->checkBoxReusePassword->isChecked() );
|
|
|
|
gs->insert( "reuseRootPassword", ui->checkBoxReusePassword->isChecked() );
|
|
|
|
if ( ui->checkBoxReusePassword->isChecked() )
|
|
|
|
if ( ui->checkBoxReusePassword->isChecked() )
|
|
|
|
j = new SetPasswordJob( "root",
|
|
|
|
j = new SetPasswordJob( "root", ui->textBoxUserPassword->text() );
|
|
|
|
ui->textBoxUserPassword->text() );
|
|
|
|
|
|
|
|
else
|
|
|
|
else
|
|
|
|
j = new SetPasswordJob( "root",
|
|
|
|
j = new SetPasswordJob( "root", ui->textBoxRootPassword->text() );
|
|
|
|
ui->textBoxRootPassword->text() );
|
|
|
|
|
|
|
|
list.append( Calamares::job_ptr( j ) );
|
|
|
|
list.append( Calamares::job_ptr( j ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
@ -205,7 +187,9 @@ UsersPage::createJobs( const QStringList& defaultGroupsList )
|
|
|
|
|
|
|
|
|
|
|
|
gs->insert( "hostname", ui->textBoxHostname->text() );
|
|
|
|
gs->insert( "hostname", ui->textBoxHostname->text() );
|
|
|
|
if ( ui->checkBoxAutoLogin->isChecked() )
|
|
|
|
if ( ui->checkBoxAutoLogin->isChecked() )
|
|
|
|
|
|
|
|
{
|
|
|
|
gs->insert( "autologinUser", ui->textBoxUsername->text() );
|
|
|
|
gs->insert( "autologinUser", ui->textBoxUsername->text() );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
gs->insert( "username", ui->textBoxUsername->text() );
|
|
|
|
gs->insert( "username", ui->textBoxUsername->text() );
|
|
|
|
gs->insert( "password", CalamaresUtils::obscure( ui->textBoxUserPassword->text() ) );
|
|
|
|
gs->insert( "password", CalamaresUtils::obscure( ui->textBoxUserPassword->text() ) );
|
|
|
@ -237,16 +221,19 @@ UsersPage::onFullNameTextEdited( const QString& textRef )
|
|
|
|
ui->labelFullNameError->clear();
|
|
|
|
ui->labelFullNameError->clear();
|
|
|
|
ui->labelFullName->clear();
|
|
|
|
ui->labelFullName->clear();
|
|
|
|
if ( !m_customUsername )
|
|
|
|
if ( !m_customUsername )
|
|
|
|
|
|
|
|
{
|
|
|
|
ui->textBoxUsername->clear();
|
|
|
|
ui->textBoxUsername->clear();
|
|
|
|
|
|
|
|
}
|
|
|
|
if ( !m_customHostname )
|
|
|
|
if ( !m_customHostname )
|
|
|
|
|
|
|
|
{
|
|
|
|
ui->textBoxHostname->clear();
|
|
|
|
ui->textBoxHostname->clear();
|
|
|
|
|
|
|
|
}
|
|
|
|
m_readyFullName = false;
|
|
|
|
m_readyFullName = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ui->labelFullName->setPixmap( CalamaresUtils::defaultPixmap( CalamaresUtils::Yes,
|
|
|
|
ui->labelFullName->setPixmap(
|
|
|
|
CalamaresUtils::Original,
|
|
|
|
CalamaresUtils::defaultPixmap( CalamaresUtils::Yes, CalamaresUtils::Original, ui->labelFullName->size() ) );
|
|
|
|
ui->labelFullName->size() ) );
|
|
|
|
|
|
|
|
m_readyFullName = true;
|
|
|
|
m_readyFullName = true;
|
|
|
|
fillSuggestions();
|
|
|
|
fillSuggestions();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -259,8 +246,7 @@ UsersPage::fillSuggestions()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
QString fullName = ui->textBoxFullName->text();
|
|
|
|
QString fullName = ui->textBoxFullName->text();
|
|
|
|
QRegExp rx( "[^a-zA-Z0-9 ]", Qt::CaseInsensitive );
|
|
|
|
QRegExp rx( "[^a-zA-Z0-9 ]", Qt::CaseInsensitive );
|
|
|
|
QString cleanName = CalamaresUtils::removeDiacritics( fullName )
|
|
|
|
QString cleanName = CalamaresUtils::removeDiacritics( fullName ).toLower().replace( rx, " " ).simplified();
|
|
|
|
.toLower().replace( rx, " " ).simplified();
|
|
|
|
|
|
|
|
QStringList cleanParts = cleanName.split( ' ' );
|
|
|
|
QStringList cleanParts = cleanName.split( ' ' );
|
|
|
|
|
|
|
|
|
|
|
|
if ( !m_customUsername )
|
|
|
|
if ( !m_customUsername )
|
|
|
@ -271,8 +257,10 @@ UsersPage::fillSuggestions()
|
|
|
|
for ( int i = 1; i < cleanParts.length(); ++i )
|
|
|
|
for ( int i = 1; i < cleanParts.length(); ++i )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if ( !cleanParts.value( i ).isEmpty() )
|
|
|
|
if ( !cleanParts.value( i ).isEmpty() )
|
|
|
|
|
|
|
|
{
|
|
|
|
usernameSuggestion.append( cleanParts.value( i ).at( 0 ) );
|
|
|
|
usernameSuggestion.append( cleanParts.value( i ).at( 0 ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
if ( USERNAME_RX.indexIn( usernameSuggestion ) != -1 )
|
|
|
|
if ( USERNAME_RX.indexIn( usernameSuggestion ) != -1 )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ui->textBoxUsername->setText( usernameSuggestion );
|
|
|
|
ui->textBoxUsername->setText( usernameSuggestion );
|
|
|
@ -322,13 +310,14 @@ UsersPage::validateUsernameText( const QString& textRef )
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ( text.length() > USERNAME_MAX_LENGTH )
|
|
|
|
else if ( text.length() > USERNAME_MAX_LENGTH )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
labelError( ui->labelUsername, ui->labelUsernameError,
|
|
|
|
labelError( ui->labelUsername, ui->labelUsernameError, tr( "Your username is too long." ) );
|
|
|
|
tr( "Your username is too long." ) );
|
|
|
|
|
|
|
|
m_readyUsername = false;
|
|
|
|
m_readyUsername = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ( val.validate( text, pos ) == QValidator::Invalid )
|
|
|
|
else if ( val.validate( text, pos ) == QValidator::Invalid )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
labelError( ui->labelUsername, ui->labelUsernameError,
|
|
|
|
labelError(
|
|
|
|
|
|
|
|
ui->labelUsername,
|
|
|
|
|
|
|
|
ui->labelUsernameError,
|
|
|
|
tr( "Your username contains invalid characters. Only lowercase letters and numbers are allowed." ) );
|
|
|
|
tr( "Your username contains invalid characters. Only lowercase letters and numbers are allowed." ) );
|
|
|
|
m_readyUsername = false;
|
|
|
|
m_readyUsername = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -366,19 +355,18 @@ UsersPage::validateHostnameText( const QString& textRef )
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ( text.length() < HOSTNAME_MIN_LENGTH )
|
|
|
|
else if ( text.length() < HOSTNAME_MIN_LENGTH )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
labelError( ui->labelHostname, ui->labelHostnameError,
|
|
|
|
labelError( ui->labelHostname, ui->labelHostnameError, tr( "Your hostname is too short." ) );
|
|
|
|
tr( "Your hostname is too short." ) );
|
|
|
|
|
|
|
|
m_readyHostname = false;
|
|
|
|
m_readyHostname = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ( text.length() > HOSTNAME_MAX_LENGTH )
|
|
|
|
else if ( text.length() > HOSTNAME_MAX_LENGTH )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
labelError( ui->labelHostname, ui->labelHostnameError,
|
|
|
|
labelError( ui->labelHostname, ui->labelHostnameError, tr( "Your hostname is too long." ) );
|
|
|
|
tr( "Your hostname is too long." ) );
|
|
|
|
|
|
|
|
m_readyHostname = false;
|
|
|
|
m_readyHostname = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ( val.validate( text, pos ) == QValidator::Invalid )
|
|
|
|
else if ( val.validate( text, pos ) == QValidator::Invalid )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
labelError( ui->labelHostname, ui->labelHostnameError,
|
|
|
|
labelError( ui->labelHostname,
|
|
|
|
|
|
|
|
ui->labelHostnameError,
|
|
|
|
tr( "Your hostname contains invalid characters. Only letters, numbers and dashes are allowed." ) );
|
|
|
|
tr( "Your hostname contains invalid characters. Only letters, numbers and dashes are allowed." ) );
|
|
|
|
m_readyHostname = false;
|
|
|
|
m_readyHostname = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -407,8 +395,7 @@ UsersPage::onPasswordTextChanged( const QString& )
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ( pw1 != pw2 )
|
|
|
|
else if ( pw1 != pw2 )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
labelError( ui->labelUserPassword, ui->labelUserPasswordError,
|
|
|
|
labelError( ui->labelUserPassword, ui->labelUserPasswordError, tr( "Your passwords do not match!" ) );
|
|
|
|
tr( "Your passwords do not match!" ) );
|
|
|
|
|
|
|
|
m_readyPassword = false;
|
|
|
|
m_readyPassword = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
@ -453,8 +440,7 @@ UsersPage::onRootPasswordTextChanged( const QString& )
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ( pw1 != pw2 )
|
|
|
|
else if ( pw1 != pw2 )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
labelError( ui->labelRootPassword, ui->labelRootPasswordError,
|
|
|
|
labelError( ui->labelRootPassword, ui->labelRootPasswordError, tr( "Your passwords do not match!" ) );
|
|
|
|
tr( "Your passwords do not match!" ) );
|
|
|
|
|
|
|
|
m_readyRootPassword = false;
|
|
|
|
m_readyRootPassword = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
@ -529,5 +515,7 @@ UsersPage::addPasswordCheck( const QString& key, const QVariant& value )
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif // CHECK_PWQUALITY
|
|
|
|
#endif // CHECK_PWQUALITY
|
|
|
|
else
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
cWarning() << "Unknown password-check key" << key;
|
|
|
|
cWarning() << "Unknown password-check key" << key;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|