forked from qt-creator/qt-creator
Utils: Introduce a FilePath::absolutePath() function
... and start using it. Change-Id: I44c74005a4deee72d0332106a4ce3582e0b66191 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -800,6 +800,13 @@ FilePath FilePath::parentDir() const
|
||||
return FilePath::fromString(parent);
|
||||
}
|
||||
|
||||
FilePath FilePath::absolutePath() const
|
||||
{
|
||||
FilePath result = *this;
|
||||
result.m_data = QFileInfo(m_data).absolutePath();
|
||||
return result;
|
||||
}
|
||||
|
||||
/// Constructs a FilePath from \a filename
|
||||
/// \a filename is not checked for validity.
|
||||
FilePath FilePath::fromString(const QString &filename)
|
||||
|
||||
@@ -86,6 +86,7 @@ public:
|
||||
bool isWritablePath() const;
|
||||
|
||||
FilePath parentDir() const;
|
||||
FilePath absolutePath() const;
|
||||
|
||||
bool operator==(const FilePath &other) const;
|
||||
bool operator!=(const FilePath &other) const;
|
||||
|
||||
@@ -119,11 +119,9 @@ void DesktopRunConfiguration::updateTargetInformation()
|
||||
aspect<ExecutableAspect>()->setExecutable(executable);
|
||||
|
||||
if (!executable.isEmpty()) {
|
||||
QString defaultWorkingDir = QFileInfo(executable.toString()).absolutePath();
|
||||
if (!defaultWorkingDir.isEmpty()) {
|
||||
auto wdAspect = aspect<WorkingDirectoryAspect>();
|
||||
wdAspect->setDefaultWorkingDirectory(FilePath::fromString(defaultWorkingDir));
|
||||
}
|
||||
const FilePath defaultWorkingDir = executable.absolutePath();
|
||||
if (!defaultWorkingDir.isEmpty())
|
||||
aspect<WorkingDirectoryAspect>()->setDefaultWorkingDirectory(defaultWorkingDir);
|
||||
}
|
||||
|
||||
emit enabledChanged();
|
||||
|
||||
Reference in New Issue
Block a user