[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( ui->textBoxFullName, &QLineEdit::textEdited, config, &Config::setFullName );
connect( config, &Config::fullNameChanged, this, &UsersPage::onFullNameTextEdited ); connect( config, &Config::fullNameChanged, this, &UsersPage::onFullNameTextEdited );
ui->textBoxHostName->setText( config->hostName() ); // If the hostname is going to be written out, then show the field
connect( ui->textBoxHostName, &QLineEdit::textEdited, config, &Config::setHostName ); 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, connect( config,
&Config::hostNameChanged, &Config::hostNameChanged,
[ this ]( const QString& name ) [ this ]( const QString& name )
{ {
if ( !ui->textBoxHostName->hasFocus() ) if ( !ui->textBoxHostname->hasFocus() )
{ {
ui->textBoxHostName->setText( name ); ui->textBoxHostname->setText( name );
} }
} ); } );
connect( config, &Config::hostNameStatusChanged, this, &UsersPage::reportHostNameStatus ); 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() ); ui->textBoxLoginName->setText( config->loginName() );
connect( ui->textBoxLoginName, &QLineEdit::textEdited, config, &Config::setLoginName ); connect( ui->textBoxLoginName, &QLineEdit::textEdited, config, &Config::setLoginName );

View File

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