[users] Hide hostname box when set to None

If the hostname will not be written, hide the input box.
While here, improve some naming in the designer file.
This commit is contained in:
Adriaan de Groot 2022-04-11 10:42:00 +02:00
parent 99bf5497ca
commit b653b13002
2 changed files with 32 additions and 19 deletions

View File

@ -105,18 +105,31 @@ UsersPage::UsersPage( Config* config, QWidget* parent )
connect( ui->textBoxFullName, &QLineEdit::textEdited, config, &Config::setFullName );
connect( config, &Config::fullNameChanged, this, &UsersPage::onFullNameTextEdited );
ui->textBoxHostName->setText( config->hostName() );
connect( ui->textBoxHostName, &QLineEdit::textEdited, config, &Config::setHostName );
connect( config,
&Config::hostNameChanged,
[ this ]( const QString& name )
{
if ( !ui->textBoxHostName->hasFocus() )
// If the hostname is going to be written out, then show the field
if ( ( m_config->hostNameActions() & HostNameAction::EtcHostname )
|| ( m_config->hostNameActions() & HostNameAction::SystemdHostname ) )
{
ui->textBoxHostname->setText( config->hostName() );
connect( ui->textBoxHostname, &QLineEdit::textEdited, config, &Config::setHostName );
connect( config,
&Config::hostNameChanged,
[ this ]( const QString& name )
{
ui->textBoxHostName->setText( name );
}
} );
connect( config, &Config::hostNameStatusChanged, this, &UsersPage::reportHostNameStatus );
if ( !ui->textBoxHostname->hasFocus() )
{
ui->textBoxHostname->setText( name );
}
} );
connect( config, &Config::hostNameStatusChanged, this, &UsersPage::reportHostNameStatus );
}
else
{
// Need to hide the hostname parts individually because there's no widget-group
ui->hostnameLabel->hide();
ui->labelHostname->hide();
ui->textBoxHostname->hide();
ui->labelHostnameError->hide();
}
ui->textBoxLoginName->setText( config->loginName() );
connect( ui->textBoxLoginName, &QLineEdit::textEdited, config, &Config::setLoginName );

View File

@ -42,7 +42,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<layout class="QHBoxLayout" name="fullNameLayout">
<item>
<widget class="QLineEdit" name="textBoxFullName">
<property name="minimumSize">
@ -129,7 +129,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<layout class="QHBoxLayout" name="usernameLayout">
<item>
<widget class="QLineEdit" name="textBoxLoginName">
<property name="sizePolicy">
@ -218,7 +218,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
</spacer>
</item>
<item>
<widget class="QLabel" name="hostname_label_2">
<widget class="QLabel" name="hostnameLabel">
<property name="text">
<string>What is the name of this computer?</string>
</property>
@ -228,9 +228,9 @@ SPDX-License-Identifier: GPL-3.0-or-later
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<layout class="QHBoxLayout" name="hostnameLayout">
<item>
<widget class="QLineEdit" name="textBoxHostName">
<widget class="QLineEdit" name="textBoxHostname">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
@ -304,7 +304,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
</layout>
</item>
<item>
<spacer name="verticalSpacer_3">
<spacer name="hostnameVSpace">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
@ -330,7 +330,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<layout class="QHBoxLayout" name="userPasswordLayout">
<item>
<widget class="QLineEdit" name="textBoxUserPassword">
<property name="sizePolicy">
@ -500,7 +500,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<layout class="QHBoxLayout" name="rootPasswordLayout">
<item>
<widget class="QLineEdit" name="textBoxRootPassword">
<property name="sizePolicy">