ProjectExplorer: Change authenticationType to BoolAspect

Using a BoolAspect allows us to set it as an enabler on the PrivateKeyFile
aspect.

Change-Id: Ief61526d65d3c2c2bdfe8e2773404ccb701dc525
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Marcus Tillmanns
2025-04-23 11:44:53 +02:00
parent d284974274
commit 9b840c4fce
4 changed files with 17 additions and 24 deletions

View File

@@ -717,8 +717,7 @@ SshParameters IDevice::sshParameters() const
void IDevice::setDefaultSshParameters(const SshParameters &sshParameters)
{
QTC_ASSERT(QThread::currentThread() == qApp->thread(),
return); // This is not thread-safe.
QTC_ASSERT(QThread::currentThread() == qApp->thread(), return);
sshParametersAspectContainer().host.setDefaultValue(sshParameters.host());
sshParametersAspectContainer().port.setDefaultValue(sshParameters.port());
@@ -726,8 +725,8 @@ void IDevice::setDefaultSshParameters(const SshParameters &sshParameters)
sshParametersAspectContainer().privateKeyFile.setDefaultPathValue(
sshParameters.privateKeyFile());
sshParametersAspectContainer().timeout.setDefaultValue(sshParameters.timeout());
sshParametersAspectContainer().authenticationType.setDefaultValue(
sshParameters.authenticationType());
sshParametersAspectContainer().useKeyFile.setDefaultValue(
sshParameters.authenticationType() == SshParameters::AuthenticationTypeSpecificKey);
sshParametersAspectContainer().hostKeyCheckingMode.setDefaultValue(
sshParameters.hostKeyCheckingMode());
@@ -939,7 +938,7 @@ void DeviceRef::setSshParameters(const SshParameters &params)
{
const IDevice::Ptr device = m_mutableDevice.lock();
QTC_ASSERT(device, return);
device->setDefaultSshParameters(params);
device->sshParametersAspectContainer().setSshParameters(params);
}
SshParametersAspectContainer &IDevice::sshParametersAspectContainer() const

View File

@@ -226,7 +226,7 @@ void SshParametersAspectContainer::setSshParameters(const SshParameters &params)
userName.setVolatileValue(params.userName());
privateKeyFile.setVolatileValue(params.privateKeyFile().toUserOutput());
timeout.setVolatileValue(params.timeout());
authenticationType.setVolatileValue(params.authenticationType());
useKeyFile.setVolatileValue(params.authenticationType() == SshParameters::AuthenticationTypeSpecificKey);
hostKeyCheckingMode.setVolatileValue(params.hostKeyCheckingMode());
privateKeyFile.setEnabled(
@@ -246,21 +246,21 @@ SshParameters SshParametersAspectContainer::sshParameters() const
params.setUserName(userName.expandedValue());
params.setPrivateKeyFile(privateKeyFile.expandedValue());
params.setTimeout(timeout.value());
params.setAuthenticationType(authenticationType.value());
params.setAuthenticationType(
useKeyFile() ? SshParameters::AuthenticationTypeSpecificKey
: SshParameters::AuthenticationTypeAll);
params.setHostKeyCheckingMode(hostKeyCheckingMode.value());
return params;
}
SshParametersAspectContainer::SshParametersAspectContainer()
{
authenticationType.setDefaultValue(SshParameters::AuthenticationTypeAll);
authenticationType.setDisplayStyle(SelectionAspect::DisplayStyle::RadioButtons);
authenticationType
.addOption(Tr::tr("Default"), Tr::tr("Use all available authentication methods"));
authenticationType
.addOption(Tr::tr("Specific &key"), Tr::tr("Use only the specified private key"));
authenticationType.setToolTip(Tr::tr("Select the authentication method to use"));
authenticationType.setLabelText(Tr::tr("Authentication type:"));
useKeyFile.setDefaultValue(SshParameters::AuthenticationTypeAll);
useKeyFile.setToolTip(
Tr::tr("Enable to specify a private key file to use for authentication, "
"otherwise the default mechanism is used for authentication "
"(password, .sshconfig and the default private key)"));
useKeyFile.setLabelText(Tr::tr("Use specific key:"));
hostKeyCheckingMode.setToolTip(Tr::tr("The device's SSH host key checking mode"));
hostKeyCheckingMode.setLabelText(Tr::tr("Host key check:"));
@@ -290,13 +290,7 @@ SshParametersAspectContainer::SshParametersAspectContainer()
privateKeyFile.setToolTip(Tr::tr("The device's private key file"));
privateKeyFile.setLabelText(Tr::tr("Private key file:"));
privateKeyFile.setHistoryCompleter("KeyFile");
privateKeyFile.setEnabled(
authenticationType.volatileValue() == SshParameters::AuthenticationTypeSpecificKey);
connect(&authenticationType, &SelectionAspect::volatileValueChanged, this, [this]() {
privateKeyFile.setEnabled(
authenticationType.volatileValue() == SshParameters::AuthenticationTypeSpecificKey);
});
privateKeyFile.setEnabler(&useKeyFile);
timeout.setDefaultValue(10);
timeout.setLabelText(Tr::tr("Timeout:"));

View File

@@ -82,9 +82,9 @@ public:
void setSshParameters(const SshParameters &params);
public:
Utils::BoolAspect useKeyFile{this};
Utils::FilePathAspect privateKeyFile{this};
Utils::IntegerAspect timeout{this};
Utils::TypedSelectionAspect<SshParameters::AuthenticationType> authenticationType{this};
Utils::TypedSelectionAspect<SshHostKeyCheckingMode> hostKeyCheckingMode{this};
Utils::StringAspect host{this};

View File

@@ -61,10 +61,10 @@ GenericLinuxDeviceConfigurationWidget::GenericLinuxDeviceConfigurationWidget(
Form {
Tr::tr("Machine type:"), machineType, st, br,
device->sshParametersAspectContainer().authenticationType.labelText(), device->sshParametersAspectContainer().authenticationType, st, br,
device->sshParametersAspectContainer().host, device->sshParametersAspectContainer().port, device->sshParametersAspectContainer().hostKeyCheckingMode, st, br,
device->freePortsAspect, portWarningLabel, device->sshParametersAspectContainer().timeout, st, br,
device->sshParametersAspectContainer().userName, st, br,
device->sshParametersAspectContainer().useKeyFile, st, br,
device->sshParametersAspectContainer().privateKeyFile, createKeyButton, br,
device->debugServerPathAspect, br,
device->qmlRunCommandAspect, br,