forked from qt-creator/qt-creator
Docker: Use FileListAspect for mounts
Change-Id: I6392c8bb8ebdfb0984f56ebda23567ef8b42bb6a Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -173,6 +173,8 @@ DockerDeviceSettings::DockerDeviceSettings()
|
|||||||
mounts.setSettingsKey(DockerDeviceMappedPaths);
|
mounts.setSettingsKey(DockerDeviceMappedPaths);
|
||||||
mounts.setLabelText(Tr::tr("Paths to mount:"));
|
mounts.setLabelText(Tr::tr("Paths to mount:"));
|
||||||
mounts.setDefaultValue({Core::DocumentManager::projectsDirectory().toString()});
|
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.setSettingsKey(DockerDeviceClangDExecutable);
|
||||||
clangdExecutable.setLabelText(Tr::tr("Clangd Executable:"));
|
clangdExecutable.setLabelText(Tr::tr("Clangd Executable:"));
|
||||||
@@ -460,11 +462,10 @@ Tasks DockerDevicePrivate::validateMounts() const
|
|||||||
{
|
{
|
||||||
Tasks result;
|
Tasks result;
|
||||||
|
|
||||||
for (const QString &mount : deviceSettings->mounts()) {
|
for (const FilePath &mount : deviceSettings->mounts()) {
|
||||||
const FilePath path = FilePath::fromUserInput(mount);
|
if (!mount.isDir()) {
|
||||||
if (!path.isDir()) {
|
|
||||||
const QString message = Tr::tr("Path \"%1\" is not a directory or does not exist.")
|
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, {}));
|
result.append(Task(Task::Error, message, {}, -1, {}));
|
||||||
}
|
}
|
||||||
@@ -705,8 +706,8 @@ QStringList DockerDevicePrivate::createMountArgs() const
|
|||||||
{
|
{
|
||||||
QStringList cmds;
|
QStringList cmds;
|
||||||
QList<TemporaryMountInfo> mounts = m_temporaryMounts;
|
QList<TemporaryMountInfo> mounts = m_temporaryMounts;
|
||||||
for (const QString &m : deviceSettings->mounts())
|
for (const FilePath &m : deviceSettings->mounts())
|
||||||
mounts.append({FilePath::fromUserInput(m), FilePath::fromUserInput(m)});
|
mounts.append({m, m});
|
||||||
|
|
||||||
for (const TemporaryMountInfo &mi : mounts) {
|
for (const TemporaryMountInfo &mi : mounts) {
|
||||||
if (isValidMountInfo(mi))
|
if (isValidMountInfo(mi))
|
||||||
@@ -1189,8 +1190,8 @@ bool DockerDevicePrivate::addTemporaryMount(const FilePath &path, const FilePath
|
|||||||
if (alreadyAdded)
|
if (alreadyAdded)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const bool alreadyManuallyAdded = anyOf(deviceSettings->mounts(), [path](const QString &mount) {
|
const bool alreadyManuallyAdded = anyOf(deviceSettings->mounts(), [path](const FilePath &mount) {
|
||||||
return mount == path.path();
|
return mount == path;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (alreadyManuallyAdded)
|
if (alreadyManuallyAdded)
|
||||||
@@ -1225,8 +1226,8 @@ void DockerDevicePrivate::shutdown()
|
|||||||
void DockerDevicePrivate::changeMounts(QStringList newMounts)
|
void DockerDevicePrivate::changeMounts(QStringList newMounts)
|
||||||
{
|
{
|
||||||
newMounts.removeDuplicates();
|
newMounts.removeDuplicates();
|
||||||
if (deviceSettings->mounts() != newMounts) {
|
if (deviceSettings->mounts.value() != newMounts) {
|
||||||
deviceSettings->mounts() = newMounts;
|
deviceSettings->mounts.value() = newMounts;
|
||||||
stopCurrentContainer(); // Force re-start with new mounts.
|
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()) {
|
for (const FilePath &mount : deviceSettings->mounts()) {
|
||||||
const FilePath mountPoint = FilePath::fromString(mount);
|
const FilePath mountPoint = mount;
|
||||||
if (devicePath.isChildOf(mountPoint)) {
|
if (devicePath.isChildOf(mountPoint)) {
|
||||||
const FilePath relativePath = devicePath.relativeChildPath(mountPoint);
|
const FilePath relativePath = devicePath.relativeChildPath(mountPoint);
|
||||||
return mountPoint.pathAppended(relativePath.path());
|
return mountPoint.pathAppended(relativePath.path());
|
||||||
@@ -1257,12 +1258,11 @@ bool DockerDevicePrivate::ensureReachable(const FilePath &other)
|
|||||||
if (other.isSameDevice(q->rootPath()))
|
if (other.isSameDevice(q->rootPath()))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
for (const QString &mount : deviceSettings->mounts()) {
|
for (const FilePath &mount : deviceSettings->mounts()) {
|
||||||
const FilePath fMount = FilePath::fromString(mount);
|
if (other.isChildOf(mount))
|
||||||
if (other.isChildOf(fMount))
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (fMount == other)
|
if (mount == other)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -26,7 +26,7 @@ public:
|
|||||||
Utils::StringAspect repo{this};
|
Utils::StringAspect repo{this};
|
||||||
Utils::StringAspect tag{this};
|
Utils::StringAspect tag{this};
|
||||||
Utils::BoolAspect useLocalUidGid{this};
|
Utils::BoolAspect useLocalUidGid{this};
|
||||||
Utils::StringListAspect mounts{this};
|
Utils::FilePathListAspect mounts{this};
|
||||||
Utils::BoolAspect keepEntryPoint{this};
|
Utils::BoolAspect keepEntryPoint{this};
|
||||||
Utils::BoolAspect enableLldbFlags{this};
|
Utils::BoolAspect enableLldbFlags{this};
|
||||||
Utils::FilePathAspect clangdExecutable{this};
|
Utils::FilePathAspect clangdExecutable{this};
|
||||||
|
@@ -57,28 +57,13 @@ DockerDeviceWidget::DockerDeviceWidget(const IDevice::Ptr &device)
|
|||||||
auto pathListLabel = new InfoLabel(Tr::tr("Paths to mount:"));
|
auto pathListLabel = new InfoLabel(Tr::tr("Paths to mount:"));
|
||||||
pathListLabel->setAdditionalToolTip(Tr::tr("Source directory list should not be empty."));
|
pathListLabel->setAdditionalToolTip(Tr::tr("Source directory list should not be empty."));
|
||||||
|
|
||||||
m_pathsListEdit = new PathListEditor;
|
auto markupMounts = [deviceSettings, pathListLabel] {
|
||||||
m_pathsListEdit->setPlaceholderText(Tr::tr("Host directories to mount into the container"));
|
const bool isEmpty = deviceSettings->mounts.volatileValue().isEmpty();
|
||||||
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();
|
|
||||||
pathListLabel->setType(isEmpty ? InfoLabel::Warning : InfoLabel::None);
|
pathListLabel->setType(isEmpty ? InfoLabel::Warning : InfoLabel::None);
|
||||||
};
|
};
|
||||||
markupMounts();
|
markupMounts();
|
||||||
|
|
||||||
connect(m_pathsListEdit,
|
connect(&deviceSettings->mounts, &FilePathListAspect::volatileValueChanged, this, markupMounts);
|
||||||
&PathListEditor::changed,
|
|
||||||
this,
|
|
||||||
[this, dockerDevice, markupMounts, deviceSettings] {
|
|
||||||
deviceSettings->mounts.setVolatileValue(m_pathsListEdit->pathList());
|
|
||||||
// dockerDevice->setData(m_data);
|
|
||||||
markupMounts();
|
|
||||||
});
|
|
||||||
|
|
||||||
auto logView = new QTextBrowser;
|
auto logView = new QTextBrowser;
|
||||||
connect(&m_kitItemDetector, &KitDetector::logOutput,
|
connect(&m_kitItemDetector, &KitDetector::logOutput,
|
||||||
@@ -183,7 +168,7 @@ DockerDeviceWidget::DockerDeviceWidget(const IDevice::Ptr &device)
|
|||||||
deviceSettings->clangdExecutable, br,
|
deviceSettings->clangdExecutable, br,
|
||||||
Column {
|
Column {
|
||||||
pathListLabel,
|
pathListLabel,
|
||||||
m_pathsListEdit,
|
deviceSettings->mounts,
|
||||||
}, br,
|
}, br,
|
||||||
If { dockerDevice->isAutoDetected(), {}, {detectionControls} },
|
If { dockerDevice->isAutoDetected(), {}, {detectionControls} },
|
||||||
noMargin,
|
noMargin,
|
||||||
|
@@ -31,7 +31,6 @@ public:
|
|||||||
void updateDaemonStateTexts();
|
void updateDaemonStateTexts();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Utils::PathListEditor *m_pathsListEdit;
|
|
||||||
QLabel *m_daemonState;
|
QLabel *m_daemonState;
|
||||||
QToolButton *m_daemonReset;
|
QToolButton *m_daemonReset;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user