On Linux/Mac, show home path as ~ in recent projects.

Reviewed-by: Daniel Molkentin
This commit is contained in:
con
2010-07-13 16:42:36 +02:00
parent 29af23cdb1
commit 352b491c87
8 changed files with 127 additions and 5 deletions

View File

@@ -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