PathChooser: Provide static way to expand a directory...

...to be able to fetch working directory even for
non-active targets.

Change-Id: I563e9b56e8a8393b998811e0fb364078d4c37d03
Reviewed-by: hjk <hjk@theqtcompany.com>
This commit is contained in:
Christian Stenger
2016-01-07 13:46:54 +01:00
parent 9cd8e7f252
commit 069f8c234c
3 changed files with 28 additions and 2 deletions

View File

@@ -330,6 +330,20 @@ FileName PathChooser::fileName() const
return FileName::fromString(path());
}
// FIXME: try to remove again
QString PathChooser::expandedDirectory(const QString &input, const Environment &env,
const QString &baseDir)
{
if (input.isEmpty())
return input;
const QString path = QDir::cleanPath(env.expandVariables(input));
if (path.isEmpty())
return path;
if (!baseDir.isEmpty() && QFileInfo(path).isRelative())
return QFileInfo(baseDir + QLatin1Char('/') + path).absoluteFilePath();
return path;
}
void PathChooser::setPath(const QString &path)
{
d->m_lineEdit->setText(QDir::toNativeSeparators(path));