From cc51e32b2dcde66b5b265c15761c019483737ba4 Mon Sep 17 00:00:00 2001 From: hjk Date: Mon, 14 Mar 2022 13:17:41 +0100 Subject: [PATCH] Docker: Add a warning when the mount path list is empty The common use case shares project sources between host and docker container, in that case, not sharing anything will not be useful. Change-Id: I44b12089579ead008023caf5134c613fc145b8c7 Reviewed-by: Christian Stenger Reviewed-by: Eike Ziller Reviewed-by: --- src/plugins/docker/dockerdevice.cpp | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/plugins/docker/dockerdevice.cpp b/src/plugins/docker/dockerdevice.cpp index 78456c50888..a89eca89c3c 100644 --- a/src/plugins/docker/dockerdevice.cpp +++ b/src/plugins/docker/dockerdevice.cpp @@ -362,13 +362,26 @@ public: }); #endif + m_pathsListLabel = new InfoLabel(tr("Paths to mount:")); + // FIXME: 8.0: use + //m_pathsListLabel->setToolTip(tr("Source directory list should not be empty")); + m_pathsListEdit = new PathListEditor; + // FIXME: 8.0: use + //m_pathsListEdit->setPlaceholderText(tr("Host directories to mount into the container")); m_pathsListEdit->setToolTip(tr("Maps paths in this list one-to-one to the " "docker container.")); m_pathsListEdit->setPathList(data.mounts); - connect(m_pathsListEdit, &PathListEditor::changed, this, [dockerDevice, this]() { + auto markupMounts = [this] { + const bool isEmpty = m_pathsListEdit->pathList().isEmpty(); + m_pathsListLabel->setType(isEmpty ? InfoLabel::Warning : InfoLabel::None); + }; + markupMounts(); + + connect(m_pathsListEdit, &PathListEditor::changed, this, [dockerDevice, markupMounts, this] { dockerDevice->setMounts(m_pathsListEdit->pathList()); + markupMounts(); }); auto logView = new QTextBrowser; @@ -384,6 +397,8 @@ public: searchDirsComboBox->addItem(tr("Search in Selected Directories")); auto searchDirsLineEdit = new FancyLineEdit; + // FIXME: 8.0: use + //searchDirsLineEdit->setPlaceholderText(tr("Semicolon-separated list of directories")); searchDirsLineEdit->setToolTip( tr("Select the paths in the docker image that should be scanned for kit entries.")); searchDirsLineEdit->setHistoryCompleter("DockerMounts", true); @@ -438,7 +453,7 @@ public: m_usePathMapping, Break(), #endif Column { - new QLabel(tr("Paths to mount:")), + m_pathsListLabel, m_pathsListEdit, }, Break(), Column { @@ -481,7 +496,8 @@ private: #ifdef ALLOW_LOCAL_ACCESS QCheckBox *m_usePathMapping; #endif - Utils::PathListEditor *m_pathsListEdit; + InfoLabel *m_pathsListLabel; + PathListEditor *m_pathsListEdit; KitDetector m_kitItemDetector; };