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.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;
|
||||
}
|
||||
|
||||
|
@@ -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};
|
||||
|
@@ -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,
|
||||
|
@@ -31,7 +31,6 @@ public:
|
||||
void updateDaemonStateTexts();
|
||||
|
||||
private:
|
||||
Utils::PathListEditor *m_pathsListEdit;
|
||||
QLabel *m_daemonState;
|
||||
QToolButton *m_daemonReset;
|
||||
|
||||
|
Reference in New Issue
Block a user