diff --git a/src/plugins/qt4projectmanager/baseqtversion.cpp b/src/plugins/qt4projectmanager/baseqtversion.cpp index e2e83df9626fb948590e737986c8008db3341a96..5666faaaa529a4a49d791b12c5cb891a5c24cf76 100644 --- a/src/plugins/qt4projectmanager/baseqtversion.cpp +++ b/src/plugins/qt4projectmanager/baseqtversion.cpp @@ -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) diff --git a/src/plugins/qt4projectmanager/baseqtversion.h b/src/plugins/qt4projectmanager/baseqtversion.h index 60c9f9a49ec42dba6b4225c073ecdf730537f24f..12773a0cdbe8f2c8408514cfa078f8922648a439 100644 --- a/src/plugins/qt4projectmanager/baseqtversion.h +++ b/src/plugins/qt4projectmanager/baseqtversion.h @@ -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()); diff --git a/src/plugins/qt4projectmanager/qtversionmanager.cpp b/src/plugins/qt4projectmanager/qtversionmanager.cpp index 669ad7381e963ac0f43df58128ec3f84850d9d9c..bc14aadfdf61aef204388992cbea7ccc7ae2375b 100644 --- a/src/plugins/qt4projectmanager/qtversionmanager.cpp +++ b/src/plugins/qt4projectmanager/qtversionmanager.cpp @@ -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); }