forked from qt-creator/qt-creator
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:
@@ -717,8 +717,7 @@ SshParameters IDevice::sshParameters() const
|
|||||||
|
|
||||||
void IDevice::setDefaultSshParameters(const SshParameters &sshParameters)
|
void IDevice::setDefaultSshParameters(const SshParameters &sshParameters)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(QThread::currentThread() == qApp->thread(),
|
QTC_ASSERT(QThread::currentThread() == qApp->thread(), return);
|
||||||
return); // This is not thread-safe.
|
|
||||||
|
|
||||||
sshParametersAspectContainer().host.setDefaultValue(sshParameters.host());
|
sshParametersAspectContainer().host.setDefaultValue(sshParameters.host());
|
||||||
sshParametersAspectContainer().port.setDefaultValue(sshParameters.port());
|
sshParametersAspectContainer().port.setDefaultValue(sshParameters.port());
|
||||||
@@ -726,8 +725,8 @@ void IDevice::setDefaultSshParameters(const SshParameters &sshParameters)
|
|||||||
sshParametersAspectContainer().privateKeyFile.setDefaultPathValue(
|
sshParametersAspectContainer().privateKeyFile.setDefaultPathValue(
|
||||||
sshParameters.privateKeyFile());
|
sshParameters.privateKeyFile());
|
||||||
sshParametersAspectContainer().timeout.setDefaultValue(sshParameters.timeout());
|
sshParametersAspectContainer().timeout.setDefaultValue(sshParameters.timeout());
|
||||||
sshParametersAspectContainer().authenticationType.setDefaultValue(
|
sshParametersAspectContainer().useKeyFile.setDefaultValue(
|
||||||
sshParameters.authenticationType());
|
sshParameters.authenticationType() == SshParameters::AuthenticationTypeSpecificKey);
|
||||||
sshParametersAspectContainer().hostKeyCheckingMode.setDefaultValue(
|
sshParametersAspectContainer().hostKeyCheckingMode.setDefaultValue(
|
||||||
sshParameters.hostKeyCheckingMode());
|
sshParameters.hostKeyCheckingMode());
|
||||||
|
|
||||||
@@ -939,7 +938,7 @@ void DeviceRef::setSshParameters(const SshParameters ¶ms)
|
|||||||
{
|
{
|
||||||
const IDevice::Ptr device = m_mutableDevice.lock();
|
const IDevice::Ptr device = m_mutableDevice.lock();
|
||||||
QTC_ASSERT(device, return);
|
QTC_ASSERT(device, return);
|
||||||
device->setDefaultSshParameters(params);
|
device->sshParametersAspectContainer().setSshParameters(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
SshParametersAspectContainer &IDevice::sshParametersAspectContainer() const
|
SshParametersAspectContainer &IDevice::sshParametersAspectContainer() const
|
||||||
|
@@ -226,7 +226,7 @@ void SshParametersAspectContainer::setSshParameters(const SshParameters ¶ms)
|
|||||||
userName.setVolatileValue(params.userName());
|
userName.setVolatileValue(params.userName());
|
||||||
privateKeyFile.setVolatileValue(params.privateKeyFile().toUserOutput());
|
privateKeyFile.setVolatileValue(params.privateKeyFile().toUserOutput());
|
||||||
timeout.setVolatileValue(params.timeout());
|
timeout.setVolatileValue(params.timeout());
|
||||||
authenticationType.setVolatileValue(params.authenticationType());
|
useKeyFile.setVolatileValue(params.authenticationType() == SshParameters::AuthenticationTypeSpecificKey);
|
||||||
hostKeyCheckingMode.setVolatileValue(params.hostKeyCheckingMode());
|
hostKeyCheckingMode.setVolatileValue(params.hostKeyCheckingMode());
|
||||||
|
|
||||||
privateKeyFile.setEnabled(
|
privateKeyFile.setEnabled(
|
||||||
@@ -246,21 +246,21 @@ SshParameters SshParametersAspectContainer::sshParameters() const
|
|||||||
params.setUserName(userName.expandedValue());
|
params.setUserName(userName.expandedValue());
|
||||||
params.setPrivateKeyFile(privateKeyFile.expandedValue());
|
params.setPrivateKeyFile(privateKeyFile.expandedValue());
|
||||||
params.setTimeout(timeout.value());
|
params.setTimeout(timeout.value());
|
||||||
params.setAuthenticationType(authenticationType.value());
|
params.setAuthenticationType(
|
||||||
|
useKeyFile() ? SshParameters::AuthenticationTypeSpecificKey
|
||||||
|
: SshParameters::AuthenticationTypeAll);
|
||||||
params.setHostKeyCheckingMode(hostKeyCheckingMode.value());
|
params.setHostKeyCheckingMode(hostKeyCheckingMode.value());
|
||||||
return params;
|
return params;
|
||||||
}
|
}
|
||||||
|
|
||||||
SshParametersAspectContainer::SshParametersAspectContainer()
|
SshParametersAspectContainer::SshParametersAspectContainer()
|
||||||
{
|
{
|
||||||
authenticationType.setDefaultValue(SshParameters::AuthenticationTypeAll);
|
useKeyFile.setDefaultValue(SshParameters::AuthenticationTypeAll);
|
||||||
authenticationType.setDisplayStyle(SelectionAspect::DisplayStyle::RadioButtons);
|
useKeyFile.setToolTip(
|
||||||
authenticationType
|
Tr::tr("Enable to specify a private key file to use for authentication, "
|
||||||
.addOption(Tr::tr("Default"), Tr::tr("Use all available authentication methods"));
|
"otherwise the default mechanism is used for authentication "
|
||||||
authenticationType
|
"(password, .sshconfig and the default private key)"));
|
||||||
.addOption(Tr::tr("Specific &key"), Tr::tr("Use only the specified private key"));
|
useKeyFile.setLabelText(Tr::tr("Use specific key:"));
|
||||||
authenticationType.setToolTip(Tr::tr("Select the authentication method to use"));
|
|
||||||
authenticationType.setLabelText(Tr::tr("Authentication type:"));
|
|
||||||
|
|
||||||
hostKeyCheckingMode.setToolTip(Tr::tr("The device's SSH host key checking mode"));
|
hostKeyCheckingMode.setToolTip(Tr::tr("The device's SSH host key checking mode"));
|
||||||
hostKeyCheckingMode.setLabelText(Tr::tr("Host key check:"));
|
hostKeyCheckingMode.setLabelText(Tr::tr("Host key check:"));
|
||||||
@@ -290,13 +290,7 @@ SshParametersAspectContainer::SshParametersAspectContainer()
|
|||||||
privateKeyFile.setToolTip(Tr::tr("The device's private key file"));
|
privateKeyFile.setToolTip(Tr::tr("The device's private key file"));
|
||||||
privateKeyFile.setLabelText(Tr::tr("Private key file:"));
|
privateKeyFile.setLabelText(Tr::tr("Private key file:"));
|
||||||
privateKeyFile.setHistoryCompleter("KeyFile");
|
privateKeyFile.setHistoryCompleter("KeyFile");
|
||||||
privateKeyFile.setEnabled(
|
privateKeyFile.setEnabler(&useKeyFile);
|
||||||
authenticationType.volatileValue() == SshParameters::AuthenticationTypeSpecificKey);
|
|
||||||
|
|
||||||
connect(&authenticationType, &SelectionAspect::volatileValueChanged, this, [this]() {
|
|
||||||
privateKeyFile.setEnabled(
|
|
||||||
authenticationType.volatileValue() == SshParameters::AuthenticationTypeSpecificKey);
|
|
||||||
});
|
|
||||||
|
|
||||||
timeout.setDefaultValue(10);
|
timeout.setDefaultValue(10);
|
||||||
timeout.setLabelText(Tr::tr("Timeout:"));
|
timeout.setLabelText(Tr::tr("Timeout:"));
|
||||||
|
@@ -82,9 +82,9 @@ public:
|
|||||||
void setSshParameters(const SshParameters ¶ms);
|
void setSshParameters(const SshParameters ¶ms);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
Utils::BoolAspect useKeyFile{this};
|
||||||
Utils::FilePathAspect privateKeyFile{this};
|
Utils::FilePathAspect privateKeyFile{this};
|
||||||
Utils::IntegerAspect timeout{this};
|
Utils::IntegerAspect timeout{this};
|
||||||
Utils::TypedSelectionAspect<SshParameters::AuthenticationType> authenticationType{this};
|
|
||||||
Utils::TypedSelectionAspect<SshHostKeyCheckingMode> hostKeyCheckingMode{this};
|
Utils::TypedSelectionAspect<SshHostKeyCheckingMode> hostKeyCheckingMode{this};
|
||||||
|
|
||||||
Utils::StringAspect host{this};
|
Utils::StringAspect host{this};
|
||||||
|
@@ -61,10 +61,10 @@ GenericLinuxDeviceConfigurationWidget::GenericLinuxDeviceConfigurationWidget(
|
|||||||
|
|
||||||
Form {
|
Form {
|
||||||
Tr::tr("Machine type:"), machineType, st, br,
|
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->sshParametersAspectContainer().host, device->sshParametersAspectContainer().port, device->sshParametersAspectContainer().hostKeyCheckingMode, st, br,
|
||||||
device->freePortsAspect, portWarningLabel, device->sshParametersAspectContainer().timeout, st, br,
|
device->freePortsAspect, portWarningLabel, device->sshParametersAspectContainer().timeout, st, br,
|
||||||
device->sshParametersAspectContainer().userName, st, br,
|
device->sshParametersAspectContainer().userName, st, br,
|
||||||
|
device->sshParametersAspectContainer().useKeyFile, st, br,
|
||||||
device->sshParametersAspectContainer().privateKeyFile, createKeyButton, br,
|
device->sshParametersAspectContainer().privateKeyFile, createKeyButton, br,
|
||||||
device->debugServerPathAspect, br,
|
device->debugServerPathAspect, br,
|
||||||
device->qmlRunCommandAspect, br,
|
device->qmlRunCommandAspect, br,
|
||||||
|
Reference in New Issue
Block a user