forked from qt-creator/qt-creator
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/43 Reviewed-by: Daniel Teske <daniel.teske@nokia.com>
This commit is contained in:
committed by
Daniel Teske
parent
4773cdf7c0
commit
a923cee383
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user