forked from qt-creator/qt-creator
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:
@@ -28,6 +28,7 @@
|
|||||||
#include "environment.h"
|
#include "environment.h"
|
||||||
#include "optional.h"
|
#include "optional.h"
|
||||||
#include "qtcassert.h"
|
#include "qtcassert.h"
|
||||||
|
#include "macroexpander.h"
|
||||||
|
|
||||||
#include "synchronousprocess.h"
|
#include "synchronousprocess.h"
|
||||||
#include "hostosinfo.h"
|
#include "hostosinfo.h"
|
||||||
@@ -174,12 +175,14 @@ public:
|
|||||||
Environment m_environment;
|
Environment m_environment;
|
||||||
BinaryVersionToolTipEventFilter *m_binaryVersionToolTipEventFilter = nullptr;
|
BinaryVersionToolTipEventFilter *m_binaryVersionToolTipEventFilter = nullptr;
|
||||||
QList<QAbstractButton *> m_buttons;
|
QList<QAbstractButton *> m_buttons;
|
||||||
|
MacroExpander *m_macroExpander;
|
||||||
};
|
};
|
||||||
|
|
||||||
PathChooserPrivate::PathChooserPrivate() :
|
PathChooserPrivate::PathChooserPrivate() :
|
||||||
m_hLayout(new QHBoxLayout),
|
m_hLayout(new QHBoxLayout),
|
||||||
m_lineEdit(new FancyLineEdit),
|
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())
|
if (input.isEmpty())
|
||||||
return input;
|
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())
|
if (path.isEmpty())
|
||||||
return path;
|
return path;
|
||||||
|
|
||||||
@@ -692,6 +700,11 @@ void PathChooser::setHistoryCompleter(const QString &historyKey, bool restoreLas
|
|||||||
d->m_lineEdit->setHistoryCompleter(historyKey, restoreLastItemFromHistory);
|
d->m_lineEdit->setHistoryCompleter(historyKey, restoreLastItemFromHistory);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PathChooser::setMacroExpander(MacroExpander *macroExpander)
|
||||||
|
{
|
||||||
|
d->m_macroExpander = macroExpander;
|
||||||
|
}
|
||||||
|
|
||||||
QStringList PathChooser::commandVersionArguments() const
|
QStringList PathChooser::commandVersionArguments() const
|
||||||
{
|
{
|
||||||
return d->m_binaryVersionToolTipEventFilter ?
|
return d->m_binaryVersionToolTipEventFilter ?
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ QT_END_NAMESPACE
|
|||||||
namespace Utils {
|
namespace Utils {
|
||||||
|
|
||||||
class FancyLineEdit;
|
class FancyLineEdit;
|
||||||
|
class MacroExpander;
|
||||||
class Environment;
|
class Environment;
|
||||||
class PathChooserPrivate;
|
class PathChooserPrivate;
|
||||||
|
|
||||||
@@ -135,6 +136,11 @@ public:
|
|||||||
// Enable a history completer with a history of entries.
|
// Enable a history completer with a history of entries.
|
||||||
void setHistoryCompleter(const QString &historyKey, bool restoreLastItemFromHistory = false);
|
void setHistoryCompleter(const QString &historyKey, bool restoreLastItemFromHistory = false);
|
||||||
|
|
||||||
|
// Sets a macro expander that is used when producing path and fileName.
|
||||||
|
// By default, the global expander is used.
|
||||||
|
// nullptr can be passed to disable macro expansion.
|
||||||
|
void setMacroExpander(MacroExpander *macroExpander);
|
||||||
|
|
||||||
bool isReadOnly() const;
|
bool isReadOnly() const;
|
||||||
void setReadOnly(bool b);
|
void setReadOnly(bool b);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user