aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarcus Tillmanns <[email protected]>2023-09-12 09:43:49 +0200
committerMarcus Tillmanns <[email protected]>2023-09-12 08:51:39 +0000
commit0c157b4ba6afadb4a8d6eff362cc39a4c46ef095 (patch)
tree12d7fda06dbb20a2b1b5dbd926f4f78f133e4924 /src
parentf6205d6cc7a0f35eca25d645c68eea7f95612822 (diff)
Docker: Use FileListAspect for mounts
Diffstat (limited to 'src')
-rw-r--r--src/plugins/docker/dockerdevice.cpp32
-rw-r--r--src/plugins/docker/dockerdevice.h2
-rw-r--r--src/plugins/docker/dockerdevicewidget.cpp23
-rw-r--r--src/plugins/docker/dockerdevicewidget.h1
4 files changed, 21 insertions, 37 deletions
diff --git a/src/plugins/docker/dockerdevice.cpp b/src/plugins/docker/dockerdevice.cpp
index 5976bd1a113..bcef8da84bc 100644
--- a/src/plugins/docker/dockerdevice.cpp
+++ b/src/plugins/docker/dockerdevice.cpp
@@ -173,6 +173,8 @@ DockerDeviceSettings::DockerDeviceSettings()
mounts.setSettingsKey(DockerDeviceMappedPaths);
mounts.setLabelText(Tr::tr("Paths to mount:"));
mounts.setDefaultValue({Core::DocumentManager::projectsDirectory().toString()});
+ mounts.setToolTip(Tr::tr("Maps paths in this list one-to-one to the docker container."));
+ mounts.setPlaceHolderText(Tr::tr("Host directories to mount into the container"));
clangdExecutable.setSettingsKey(DockerDeviceClangDExecutable);
clangdExecutable.setLabelText(Tr::tr("Clangd Executable:"));
@@ -460,11 +462,10 @@ Tasks DockerDevicePrivate::validateMounts() const
{
Tasks result;
- for (const QString &mount : deviceSettings->mounts()) {
- const FilePath path = FilePath::fromUserInput(mount);
- if (!path.isDir()) {
+ for (const FilePath &mount : deviceSettings->mounts()) {
+ if (!mount.isDir()) {
const QString message = Tr::tr("Path \"%1\" is not a directory or does not exist.")
- .arg(mount);
+ .arg(mount.toUserOutput());
result.append(Task(Task::Error, message, {}, -1, {}));
}
@@ -705,8 +706,8 @@ QStringList DockerDevicePrivate::createMountArgs() const
{
QStringList cmds;
QList<TemporaryMountInfo> mounts = m_temporaryMounts;
- for (const QString &m : deviceSettings->mounts())
- mounts.append({FilePath::fromUserInput(m), FilePath::fromUserInput(m)});
+ for (const FilePath &m : deviceSettings->mounts())
+ mounts.append({m, m});
for (const TemporaryMountInfo &mi : mounts) {
if (isValidMountInfo(mi))
@@ -1189,8 +1190,8 @@ bool DockerDevicePrivate::addTemporaryMount(const FilePath &path, const FilePath
if (alreadyAdded)
return false;
- const bool alreadyManuallyAdded = anyOf(deviceSettings->mounts(), [path](const QString &mount) {
- return mount == path.path();
+ const bool alreadyManuallyAdded = anyOf(deviceSettings->mounts(), [path](const FilePath &mount) {
+ return mount == path;
});
if (alreadyManuallyAdded)
@@ -1225,8 +1226,8 @@ void DockerDevicePrivate::shutdown()
void DockerDevicePrivate::changeMounts(QStringList newMounts)
{
newMounts.removeDuplicates();
- if (deviceSettings->mounts() != newMounts) {
- deviceSettings->mounts() = newMounts;
+ if (deviceSettings->mounts.value() != newMounts) {
+ deviceSettings->mounts.value() = newMounts;
stopCurrentContainer(); // Force re-start with new mounts.
}
}
@@ -1241,8 +1242,8 @@ expected_str<FilePath> DockerDevicePrivate::localSource(const FilePath &other) c
}
}
- for (const QString &mount : deviceSettings->mounts()) {
- const FilePath mountPoint = FilePath::fromString(mount);
+ for (const FilePath &mount : deviceSettings->mounts()) {
+ const FilePath mountPoint = mount;
if (devicePath.isChildOf(mountPoint)) {
const FilePath relativePath = devicePath.relativeChildPath(mountPoint);
return mountPoint.pathAppended(relativePath.path());
@@ -1257,12 +1258,11 @@ bool DockerDevicePrivate::ensureReachable(const FilePath &other)
if (other.isSameDevice(q->rootPath()))
return true;
- for (const QString &mount : deviceSettings->mounts()) {
- const FilePath fMount = FilePath::fromString(mount);
- if (other.isChildOf(fMount))
+ for (const FilePath &mount : deviceSettings->mounts()) {
+ if (other.isChildOf(mount))
return true;
- if (fMount == other)
+ if (mount == other)
return true;
}
diff --git a/src/plugins/docker/dockerdevice.h b/src/plugins/docker/dockerdevice.h
index 821438edb8a..d44a676bfd5 100644
--- a/src/plugins/docker/dockerdevice.h
+++ b/src/plugins/docker/dockerdevice.h
@@ -26,7 +26,7 @@ public:
Utils::StringAspect repo{this};
Utils::StringAspect tag{this};
Utils::BoolAspect useLocalUidGid{this};
- Utils::StringListAspect mounts{this};
+ Utils::FilePathListAspect mounts{this};
Utils::BoolAspect keepEntryPoint{this};
Utils::BoolAspect enableLldbFlags{this};
Utils::FilePathAspect clangdExecutable{this};
diff --git a/src/plugins/docker/dockerdevicewidget.cpp b/src/plugins/docker/dockerdevicewidget.cpp
index 0ec608d4538..7450297c158 100644
--- a/src/plugins/docker/dockerdevicewidget.cpp
+++ b/src/plugins/docker/dockerdevicewidget.cpp
@@ -57,28 +57,13 @@ DockerDeviceWidget::DockerDeviceWidget(const IDevice::Ptr &device)
auto pathListLabel = new InfoLabel(Tr::tr("Paths to mount:"));
pathListLabel->setAdditionalToolTip(Tr::tr("Source directory list should not be empty."));
- m_pathsListEdit = new PathListEditor;
- m_pathsListEdit->setPlaceholderText(Tr::tr("Host directories to mount into the container"));
- m_pathsListEdit->setToolTip(Tr::tr("Maps paths in this list one-to-one to the "
- "docker container."));
- m_pathsListEdit->setPathList(deviceSettings->mounts());
- m_pathsListEdit->setMaximumHeight(100);
- m_pathsListEdit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
-
- auto markupMounts = [this, pathListLabel] {
- const bool isEmpty = m_pathsListEdit->pathList().isEmpty();
+ auto markupMounts = [deviceSettings, pathListLabel] {
+ const bool isEmpty = deviceSettings->mounts.volatileValue().isEmpty();
pathListLabel->setType(isEmpty ? InfoLabel::Warning : InfoLabel::None);
};
markupMounts();
- connect(m_pathsListEdit,
- &PathListEditor::changed,
- this,
- [this, dockerDevice, markupMounts, deviceSettings] {
- deviceSettings->mounts.setVolatileValue(m_pathsListEdit->pathList());
- // dockerDevice->setData(m_data);
- markupMounts();
- });
+ connect(&deviceSettings->mounts, &FilePathListAspect::volatileValueChanged, this, markupMounts);
auto logView = new QTextBrowser;
connect(&m_kitItemDetector, &KitDetector::logOutput,
@@ -183,7 +168,7 @@ DockerDeviceWidget::DockerDeviceWidget(const IDevice::Ptr &device)
deviceSettings->clangdExecutable, br,
Column {
pathListLabel,
- m_pathsListEdit,
+ deviceSettings->mounts,
}, br,
If { dockerDevice->isAutoDetected(), {}, {detectionControls} },
noMargin,
diff --git a/src/plugins/docker/dockerdevicewidget.h b/src/plugins/docker/dockerdevicewidget.h
index 7a15239c513..edc76062c40 100644
--- a/src/plugins/docker/dockerdevicewidget.h
+++ b/src/plugins/docker/dockerdevicewidget.h
@@ -31,7 +31,6 @@ public:
void updateDaemonStateTexts();
private:
- Utils::PathListEditor *m_pathsListEdit;
QLabel *m_daemonState;
QToolButton *m_daemonReset;