ProjectExplorer: Make sure the working dir is properly expanded

... in the path chooser.

Fixes: QTCREATORBUG-26274
Change-Id: I4aa920888b9bef2820ed883e1f34a5c670a545d6
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Christian Kandeler
2021-09-21 17:52:38 +02:00
parent 3922b1a917
commit e1e962503a
3 changed files with 11 additions and 0 deletions

View File

@@ -233,6 +233,8 @@ bool RunConfiguration::isEnabled() const
QWidget *RunConfiguration::createConfigurationWidget()
{
if (const auto wdAspect = aspect<WorkingDirectoryAspect>())
wdAspect->setMacroExpanderProvider([this] { return &m_expander; });
Layouting::Form builder;
for (BaseAspect *aspect : qAsConst(m_aspects)) {
if (aspect->isVisible())

View File

@@ -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
*/

View File

@@ -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<Utils::PathChooser> m_chooser;
QPointer<QToolButton> m_resetButton;
Utils::MacroExpanderProvider m_expanderProvider;
};
class PROJECTEXPLORER_EXPORT ArgumentsAspect : public Utils::BaseAspect