[users] Factor out show/hide of AD controls

While here, expand documentation a little.
This commit is contained in:
Adriaan de Groot 2024-04-14 21:33:39 +02:00
parent f674214741
commit 0ef3842da6
3 changed files with 21 additions and 25 deletions

View File

@ -226,9 +226,9 @@ public:
bool permitWeakPasswords() const { return m_permitWeakPasswords; }
/// Current setting for "require strong password"?
bool requireStrongPasswords() const { return m_requireStrongPasswords; }
/// Is Active Directory enabled?
/// Is Active Directory enabled in the config file?
bool getActiveDirectoryEnabled() const;
/// Is it both enabled and activated?
/// Is it both enabled and activated by user choice (checkbox)?
bool getActiveDirectoryUsed() const;
const QList< GroupDescription >& defaultGroups() const { return m_defaultGroups; }

View File

@ -164,34 +164,13 @@ UsersPage::UsersPage( Config* config, QWidget* parent )
// Active Directory is not checked or enabled by default
ui->useADCheckbox->setVisible( m_config->getActiveDirectoryEnabled() );
ui->domainLabel->setVisible( false );
ui->domainField->setVisible( false );
ui->domainAdminLabel->setVisible( false );
ui->domainAdminField->setVisible( false );
ui->domainPasswordField->setVisible( false );
ui->domainPasswordLabel->setVisible( false );
ui->ipAddressField->setVisible( false );
ui->ipAddressLabel->setVisible( false );
connect( ui->useADCheckbox,
&QCheckBox::toggled,
[ = ]( bool checked )
{
ui->domainLabel->setVisible( checked );
ui->domainField->setVisible( checked );
ui->domainAdminLabel->setVisible( checked );
ui->domainAdminField->setVisible( checked );
ui->domainPasswordField->setVisible( checked );
ui->domainPasswordLabel->setVisible( checked );
ui->ipAddressField->setVisible( checked );
ui->ipAddressLabel->setVisible( checked );
} );
onActiveDirectoryToggled( false );
connect( ui->useADCheckbox, &QCheckBox::toggled, this, &UsersPage::onActiveDirectoryToggled );
connect( ui->domainField, &QLineEdit::textChanged, config, &Config::setActiveDirectoryDomain );
connect( ui->domainAdminField, &QLineEdit::textChanged, config, &Config::setActiveDirectoryAdminUsername );
connect( ui->domainPasswordField, &QLineEdit::textChanged, config, &Config::setActiveDirectoryAdminPassword );
connect( ui->ipAddressField, &QLineEdit::textChanged, config, &Config::setActiveDirectoryIP );
connect( ui->useADCheckbox, &QCheckBox::toggled, config, &Config::setActiveDirectoryUsed );
CALAMARES_RETRANSLATE_SLOT( &UsersPage::retranslate );
@ -314,3 +293,18 @@ UsersPage::onReuseUserPasswordChanged( const int checked )
ui->textBoxRootPassword->setVisible( visible );
ui->textBoxVerifiedRootPassword->setVisible( visible );
}
void
UsersPage::onActiveDirectoryToggled( bool checked )
{
ui->domainLabel->setVisible( checked );
ui->domainField->setVisible( checked );
ui->domainAdminLabel->setVisible( checked );
ui->domainAdminField->setVisible( checked );
ui->domainPasswordField->setVisible( checked );
ui->domainPasswordLabel->setVisible( checked );
ui->ipAddressField->setVisible( checked );
ui->ipAddressLabel->setVisible( checked );
m_config->setActiveDirectoryUsed( checked );
}

View File

@ -44,6 +44,8 @@ protected slots:
void reportUserPasswordStatus( int, const QString& );
void reportRootPasswordStatus( int, const QString& );
void onActiveDirectoryToggled( bool checked );
private:
void retranslate();