Expand QTC variables from PathChooser

This would allow to use QTC variables in settings using this widget
such as Extra Debugging Helpers.

Change-Id: I8ac6de46f359f58a501f09774d992a19b48d7d5f
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Alexis Jeandet
2018-09-06 09:03:55 +02:00
committed by hjk
parent bdc1ea1d74
commit 08508522fe
2 changed files with 21 additions and 2 deletions

View File

@@ -28,6 +28,7 @@
#include "environment.h"
#include "optional.h"
#include "qtcassert.h"
#include "macroexpander.h"
#include "synchronousprocess.h"
#include "hostosinfo.h"
@@ -174,12 +175,14 @@ public:
Environment m_environment;
BinaryVersionToolTipEventFilter *m_binaryVersionToolTipEventFilter = nullptr;
QList<QAbstractButton *> m_buttons;
MacroExpander *m_macroExpander;
};
PathChooserPrivate::PathChooserPrivate() :
m_hLayout(new QHBoxLayout),
m_lineEdit(new FancyLineEdit),
m_acceptingKind(PathChooser::ExistingDirectory)
m_acceptingKind(PathChooser::ExistingDirectory),
m_macroExpander(globalMacroExpander())
{
}
@@ -187,7 +190,12 @@ QString PathChooserPrivate::expandedPath(const QString &input) const
{
if (input.isEmpty())
return input;
const QString path = FileName::fromUserInput(m_environment.expandVariables(input)).toString();
QString expandedInput = m_environment.expandVariables(input);
if (m_macroExpander)
expandedInput = m_macroExpander->expand(expandedInput);
const QString path = FileName::fromUserInput(expandedInput).toString();
if (path.isEmpty())
return path;
@@ -692,6 +700,11 @@ void PathChooser::setHistoryCompleter(const QString &historyKey, bool restoreLas
d->m_lineEdit->setHistoryCompleter(historyKey, restoreLastItemFromHistory);
}
void PathChooser::setMacroExpander(MacroExpander *macroExpander)
{
d->m_macroExpander = macroExpander;
}
QStringList PathChooser::commandVersionArguments() const
{
return d->m_binaryVersionToolTipEventFilter ?