QmlProject: Clean up environment selection

On desktop you get "system environment" as default now and "clean
environment" as option. "kit environment" doesn't make any sense as that
is meant for build configurations.

On remote Devices you only get "clean environment" because we cannot
query the generic remote device for its default environment. However,
as the environment was rather random before and it worked, a clean
environment will probably not break it.

Change-Id: Iab0ed804a21cf77db9e3413926ff710c91561db0
Task-number: QTCREATORBUG-19887
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
Ulf Hermann
2018-02-21 17:01:45 +01:00
parent 6e419d642a
commit 5179dbbe68
2 changed files with 21 additions and 13 deletions

View File

@@ -27,6 +27,7 @@
#include "qmlproject.h" #include "qmlproject.h"
#include <projectexplorer/kitinformation.h>
#include <projectexplorer/target.h> #include <projectexplorer/target.h>
#include <projectexplorer/kit.h> #include <projectexplorer/kit.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
@@ -39,28 +40,35 @@ namespace QmlProjectManager {
QList<int> QmlProjectEnvironmentAspect::possibleBaseEnvironments() const QList<int> QmlProjectEnvironmentAspect::possibleBaseEnvironments() const
{ {
return QList<int>() << static_cast<int>(KitEnvironmentBase) QList<int> ret;
<< static_cast<int>(SystemEnvironmentBase); if (ProjectExplorer::DeviceTypeKitInformation::deviceTypeId(runConfiguration()->target()->kit())
== ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE) {
ret << SystemEnvironmentBase;
}
ret << CleanEnvironmentBase;
return ret;
} }
QString QmlProjectEnvironmentAspect::baseEnvironmentDisplayName(int base) const QString QmlProjectEnvironmentAspect::baseEnvironmentDisplayName(int base) const
{ {
if (base == static_cast<int>(SystemEnvironmentBase)) switch (base) {
case SystemEnvironmentBase:
return tr("System Environment"); return tr("System Environment");
if (base == static_cast<int>(KitEnvironmentBase)) case CleanEnvironmentBase:
return tr("Kit Environment"); return tr("Clean Environment");
default:
QTC_CHECK(false);
return QString(); return QString();
}
} }
Utils::Environment QmlProjectEnvironmentAspect::baseEnvironment() const Utils::Environment QmlProjectEnvironmentAspect::baseEnvironment() const
{ {
int base = baseEnvironmentBase(); Utils::Environment env = baseEnvironmentBase() == SystemEnvironmentBase
Utils::Environment env = Utils::Environment::systemEnvironment(); ? Utils::Environment::systemEnvironment()
if (base == static_cast<int>(KitEnvironmentBase)) : Utils::Environment();
runConfiguration()->target()->kit()->addToEnvironment(env);
QmlProject *project = qobject_cast<QmlProject *>(runConfiguration()->target()->project()); if (QmlProject *project = qobject_cast<QmlProject *>(runConfiguration()->target()->project()))
if (project)
env.modify(project->environment()); env.modify(project->environment());
return env; return env;

View File

@@ -43,7 +43,7 @@ public:
private: private:
enum BaseEnvironmentBase { enum BaseEnvironmentBase {
SystemEnvironmentBase = 0, SystemEnvironmentBase = 0,
KitEnvironmentBase CleanEnvironmentBase,
}; };
}; };