diff options
author | con <qtc-committer@nokia.com> | 2010-07-13 16:42:36 +0200 |
---|---|---|
committer | con <qtc-committer@nokia.com> | 2010-07-14 14:45:18 +0200 |
commit | 352b491c87aba787fa1e87d04ea79c282f5b843d (patch) | |
tree | e7615b78d733b940488173a46261645c920e5a62 /src/libs/utils/stringutils.cpp | |
parent | 29af23cdb16341e5e1d517520b0a03b91f5048b3 (diff) | |
download | qt-creator-352b491c87aba787fa1e87d04ea79c282f5b843d.tar.gz |
On Linux/Mac, show home path as ~ in recent projects.
Reviewed-by: Daniel Molkentin
Diffstat (limited to 'src/libs/utils/stringutils.cpp')
-rw-r--r-- | src/libs/utils/stringutils.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/libs/utils/stringutils.cpp b/src/libs/utils/stringutils.cpp index cf1b4b36cf..10a2d41839 100644 --- a/src/libs/utils/stringutils.cpp +++ b/src/libs/utils/stringutils.cpp @@ -31,6 +31,8 @@ #include <QtCore/QString> #include <QtCore/QStringList> +#include <QtCore/QFileInfo> +#include <QtCore/QDir> #include <limits.h> @@ -100,4 +102,21 @@ QTCREATOR_UTILS_EXPORT QString commonPath(const QStringList &files) return common; } +QTCREATOR_UTILS_EXPORT QString withTildeHomePath(const QString &path) +{ +#ifdef Q_OS_WIN + QString outPath = path; +#else + static const QString homePath = QDir::homePath(); + + QFileInfo fi(QDir::cleanPath(path)); + QString outPath = fi.absoluteFilePath(); + if (outPath.startsWith(homePath)) + outPath = QLatin1Char('~') + outPath.mid(homePath.size()); + else + outPath = path; +#endif + return outPath; +} + } // namespace Utils |