From e1e962503ad2faed0abddb8062161754f9de3b87 Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Tue, 21 Sep 2021 17:52:38 +0200 Subject: [PATCH] ProjectExplorer: Make sure the working dir is properly expanded ... in the path chooser. Fixes: QTCREATORBUG-26274 Change-Id: I4aa920888b9bef2820ed883e1f34a5c670a545d6 Reviewed-by: hjk --- src/plugins/projectexplorer/runconfiguration.cpp | 2 ++ src/plugins/projectexplorer/runconfigurationaspects.cpp | 7 +++++++ src/plugins/projectexplorer/runconfigurationaspects.h | 2 ++ 3 files changed, 11 insertions(+) diff --git a/src/plugins/projectexplorer/runconfiguration.cpp b/src/plugins/projectexplorer/runconfiguration.cpp index 6677a418529..4bb59cab1b0 100644 --- a/src/plugins/projectexplorer/runconfiguration.cpp +++ b/src/plugins/projectexplorer/runconfiguration.cpp @@ -233,6 +233,8 @@ bool RunConfiguration::isEnabled() const QWidget *RunConfiguration::createConfigurationWidget() { + if (const auto wdAspect = aspect()) + wdAspect->setMacroExpanderProvider([this] { return &m_expander; }); Layouting::Form builder; for (BaseAspect *aspect : qAsConst(m_aspects)) { if (aspect->isVisible()) diff --git a/src/plugins/projectexplorer/runconfigurationaspects.cpp b/src/plugins/projectexplorer/runconfigurationaspects.cpp index ef10cbc618e..4f02850f15b 100644 --- a/src/plugins/projectexplorer/runconfigurationaspects.cpp +++ b/src/plugins/projectexplorer/runconfigurationaspects.cpp @@ -176,6 +176,8 @@ void WorkingDirectoryAspect::addToLayout(LayoutBuilder &builder) { QTC_CHECK(!m_chooser); m_chooser = new PathChooser; + if (m_expanderProvider) + m_chooser->setMacroExpander(m_expanderProvider()); m_chooser->setHistoryCompleter(settingsKey()); m_chooser->setExpectedKind(Utils::PathChooser::Directory); m_chooser->setPromptDialogTitle(tr("Select Working Directory")); @@ -291,6 +293,11 @@ void WorkingDirectoryAspect::setDefaultWorkingDirectory(const FilePath &defaultW } } +void WorkingDirectoryAspect::setMacroExpanderProvider(const MacroExpanderProvider &expanderProvider) +{ + m_expanderProvider = expanderProvider; +} + /*! \internal */ diff --git a/src/plugins/projectexplorer/runconfigurationaspects.h b/src/plugins/projectexplorer/runconfigurationaspects.h index 00b44ceabf9..e417f4ca28c 100644 --- a/src/plugins/projectexplorer/runconfigurationaspects.h +++ b/src/plugins/projectexplorer/runconfigurationaspects.h @@ -82,6 +82,7 @@ public: Utils::FilePath defaultWorkingDirectory() const; Utils::FilePath unexpandedWorkingDirectory() const; void setDefaultWorkingDirectory(const Utils::FilePath &defaultWorkingDirectory); + void setMacroExpanderProvider(const Utils::MacroExpanderProvider &expanderProvider); Utils::PathChooser *pathChooser() const; private: @@ -95,6 +96,7 @@ private: Utils::FilePath m_defaultWorkingDirectory; QPointer m_chooser; QPointer m_resetButton; + Utils::MacroExpanderProvider m_expanderProvider; }; class PROJECTEXPLORER_EXPORT ArgumentsAspect : public Utils::BaseAspect