Commit a923cee3 authored by Friedemann Kleint's avatar Friedemann Kleint Committed by Daniel Teske

Qt version: Add base name of Qt folder to generated display name.

With some smartness to skip over bin, qtbase and display
usr as 'System'. Introduce BaseQtVersion::defaultDisplayName().

Change-Id: I5249bbd7102f40441e7a873d861c525e4194d74f
Reviewed-on: http://codereview.qt.nokia.com/43Reviewed-by: default avatarDaniel Teske <daniel.teske@nokia.com>
parent 4773cdf7
......@@ -50,6 +50,7 @@
#include <utils/synchronousprocess.h>
#include <QtCore/QDir>
#include <QtCore/QFileInfo>
#include <QtCore/QCoreApplication>
#include <QtCore/QProcess>
......@@ -183,7 +184,7 @@ BaseQtVersion::BaseQtVersion(const QString &qmakeCommand, bool isAutodetected, c
m_qmakeIsExecutable(false)
{
ctor(qmakeCommand);
setDisplayName(qtVersionString());
setDisplayName(defaultDisplayName(qtVersionString(), qmakeCommand, false));
}
BaseQtVersion::BaseQtVersion()
......@@ -222,10 +223,37 @@ void BaseQtVersion::ctor(const QString& qmakePath)
m_sourcePath.clear();
}
BaseQtVersion::~BaseQtVersion()
{
}
QString BaseQtVersion::defaultDisplayName(const QString &versionString, const QString &qmakePath,
bool fromPath)
{
QString location;
if (qmakePath.isEmpty()) {
location = QCoreApplication::translate("QtVersion", "<unknown>");
} else {
// Deduce a description from '/foo/qt-folder/[qtbase]/bin/qmake' -> '/foo/qt-folder'.
// '/usr' indicates System Qt 4.X on Linux.
QDir dir = QFileInfo(qmakePath).absoluteDir();
do {
const QString dirName = dir.dirName();
if (dirName == QLatin1String("usr")) { // System-installed Qt.
location = QCoreApplication::translate("QtVersion", "System");
break;
}
if (dirName.compare(QLatin1String("bin"), Qt::CaseInsensitive)
&& dirName.compare(QLatin1String("qtbase"), Qt::CaseInsensitive)) {
location = dirName;
break;
}
} while (dir.cdUp());
}
return fromPath ?
QCoreApplication::translate("QtVersion", "Qt %1 in PATH (%2)").arg(versionString, location) :
QCoreApplication::translate("QtVersion", "Qt %1 (%2)").arg(versionString, location);
}
void BaseQtVersion::setId(int id)
......
......@@ -189,6 +189,10 @@ public:
virtual QtConfigWidget *createConfigurationWidget() const;
static QString defaultDisplayName(const QString &versionString,
const QString &qmakePath,
bool fromPath = false);
protected:
BaseQtVersion();
BaseQtVersion(const QString &path, bool isAutodetected = false, const QString &autodetectionSource = QString());
......
......@@ -374,7 +374,7 @@ void QtVersionManager::findSystemQt()
return;
BaseQtVersion *version = QtVersionFactory::createQtVersionFromQMakePath(systemQMakePath);
version->setDisplayName(tr("Qt in PATH (%1)").arg(version->qtVersionString()));
version->setDisplayName(BaseQtVersion::defaultDisplayName(version->qtVersionString(), systemQMakePath, true));
m_versions.insert(version->uniqueId(), version);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment