diff --git a/src/plugins/projectexplorer/qtversionmanager.cpp b/src/plugins/projectexplorer/qtversionmanager.cpp index dae9faddca4998bba644eb65274db5f11b3e0f71..3b160bd9564f259711d3021f387d30c9adc420e8 100644 --- a/src/plugins/projectexplorer/qtversionmanager.cpp +++ b/src/plugins/projectexplorer/qtversionmanager.cpp @@ -230,9 +230,19 @@ void QtVersionManager::addNewVersionsFromInstaller() void QtVersionManager::updateSystemVersion() { bool haveSystemVersion = false; + QString systemQMakePath = findSystemQt(Environment::systemEnvironment()); + QString systemQtPath; + if (systemQMakePath.isNull()) { + systemQtPath = tr("<not found>"); + } else { + QDir dir(QFileInfo(systemQMakePath).absoluteDir()); + dir.cdUp(); + systemQtPath = dir.absolutePath(); + } + foreach (QtVersion *version, m_versions) { if (version->isSystemVersion()) { - version->setPath(findSystemQt()); + version->setPath(systemQtPath); version->setName(tr("Auto-detected Qt")); haveSystemVersion = true; } @@ -240,7 +250,7 @@ void QtVersionManager::updateSystemVersion() if (haveSystemVersion) return; QtVersion *version = new QtVersion(tr("Auto-detected Qt"), - findSystemQt(), + systemQtPath, getUniqueId(), true); m_versions.prepend(version); @@ -278,23 +288,20 @@ QString QtVersionManager::qtVersionForQMake(const QString &qmakePath) return QString(); } -QString QtVersionManager::findSystemQt() const +QString QtVersionManager::findSystemQt(const Environment &env) { - Environment env = Environment::systemEnvironment(); QStringList paths = env.path(); foreach (const QString &path, paths) { foreach (const QString &possibleCommand, possibleQMakeCommands()) { QFileInfo qmake(path + "/" + possibleCommand); if (qmake.exists()) { if (!qtVersionForQMake(qmake.absoluteFilePath()).isNull()) { - QDir dir(qmake.absoluteDir()); - dir.cdUp(); - return dir.absolutePath(); + return qmake.absoluteFilePath(); } } } } - return tr("<not found>"); + return QString::null; } QtVersion *QtVersionManager::currentQtVersion() const diff --git a/src/plugins/projectexplorer/qtversionmanager.h b/src/plugins/projectexplorer/qtversionmanager.h index 381cbec35622f1d58ca02307a72b4f4a9d75ddf3..3523a4477979d03545de8e4a0677fe711b845f5b 100644 --- a/src/plugins/projectexplorer/qtversionmanager.h +++ b/src/plugins/projectexplorer/qtversionmanager.h @@ -40,6 +40,7 @@ namespace ProjectExplorer { namespace Internal { class QtOptionsPageWidget; +class QtOptionsPage; } class PROJECTEXPLORER_EXPORT QtVersion @@ -77,6 +78,7 @@ public: void addToEnvironment(ProjectExplorer::Environment &env); bool hasDebuggingHelper() const; + QString dumperLibrary() const; // Builds a debugging library // returns the output of the commands QString buildDebuggingHelperLibrary(); @@ -91,7 +93,6 @@ public: }; QmakeBuildConfig defaultBuildConfig() const; - QString dumperLibrary() const; private: static int getUniqueId(); // Also used by QtOptionsPageWidget @@ -128,7 +129,7 @@ class PROJECTEXPLORER_EXPORT QtVersionManager : public QObject Q_OBJECT // for getUniqueId(); friend class QtVersion; - friend class QtOptionsPage; + friend class Internal::QtOptionsPage; public: static QtVersionManager *instance(); QtVersionManager(); @@ -150,6 +151,10 @@ public: static QString qtVersionForQMake(const QString &qmakePath); static QtVersion::QmakeBuildConfig scanMakefileForQmakeConfig(const QString &directory, QtVersion::QmakeBuildConfig defaultBuildConfig); static QString findQtVersionFromMakefile(const QString &directory); + + // returns the full path to the first qmake, qmake-qt4, qmake4 that has + // at least version 2.0.0 and thus is a qt4 qmake + static QString findSystemQt(const Environment &env); signals: void defaultQtVersionChanged(); void qtVersionsChanged(); @@ -162,7 +167,7 @@ private: void addNewVersionsFromInstaller(); void updateSystemVersion(); void updateDocumentation(); - QString findSystemQt() const; + static int indexOfVersionInList(const QtVersion * const version, const QList<QtVersion *> &list); void updateUniqueIdToIndexMap();