Docker: Fix default device name

Change-Id: I1d7e8dd62a11cf897ebb22389f21370c8a3811cf
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
Marcus Tillmanns
2023-09-15 09:17:04 +02:00
parent 0b85fc5aa0
commit 5109b0ce0e
2 changed files with 15 additions and 5 deletions

View File

@@ -139,10 +139,21 @@ public:
DockerDevicePrivate *m_dev = nullptr;
};
void DockerDeviceSettings::fromMap(const Store &map)
{
DeviceSettings::fromMap(map);
// This is the only place where we can correctly set the default name.
// Only here do we know the image id and the repo reliably, no matter
// where or how we were created.
if (displayName.value() == displayName.defaultValue()) {
displayName.setDefaultValue(
Tr::tr("Docker Image \"%1\" (%2)").arg(repoAndTag()).arg(imageId.value()));
}
}
DockerDeviceSettings::DockerDeviceSettings()
{
displayName.setDefaultValue(Tr::tr("Docker Image"));
imageId.setSettingsKey(DockerDeviceDataImageIdKey);
imageId.setLabelText(Tr::tr("Image ID:"));
imageId.setReadOnly(true);
@@ -505,9 +516,6 @@ DockerDevice::DockerDevice(std::unique_ptr<DockerDeviceSettings> deviceSettings)
setupId(IDevice::ManuallyAdded);
setType(Constants::DOCKER_DEVICE_TYPE);
setMachineType(IDevice::Hardware);
d->deviceSettings->displayName.setDefaultValue(Tr::tr("Docker Image \"%1\" (%2)")
.arg(d->deviceSettings->repoAndTag())
.arg(d->deviceSettings->imageId()));
setAllowEmptyCommand(true);
setOpenTerminal([this](const Environment &env, const FilePath &workingDir) {

View File

@@ -19,6 +19,8 @@ class DockerDeviceSettings : public ProjectExplorer::DeviceSettings
public:
DockerDeviceSettings();
void fromMap(const Utils::Store &map) override;
QString repoAndTag() const;
QString repoAndTagEncoded() const;