forked from qt-creator/qt-creator
ProjectExplorer: Split EnvironmentAspect
... at least logically a bit more into hunks responsible for one of the possible choices of base environments. This makes it possible to move code that modifies individual cases closer to the only place that uses it. Change-Id: I1c87bb869e04e44b92ff097b0bf25274f93808be Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -278,27 +278,24 @@ void MainQmlFileAspect::changeCurrentFile(IEditor *editor)
|
||||
QmlProjectRunConfiguration::QmlProjectRunConfiguration(Target *target, Id id)
|
||||
: RunConfiguration(target, id)
|
||||
{
|
||||
enum BaseEnvironmentBase {
|
||||
SystemEnvironmentBase = 0,
|
||||
CleanEnvironmentBase
|
||||
};
|
||||
|
||||
auto envAspect = addAspect<EnvironmentAspect>();
|
||||
const Id deviceTypeId = DeviceTypeKitAspect::deviceTypeId(target->kit());
|
||||
if (deviceTypeId == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE)
|
||||
envAspect->addPreferredBaseEnvironment(SystemEnvironmentBase, tr("System Environment"));
|
||||
envAspect->addSupportedBaseEnvironment(CleanEnvironmentBase, tr("Clean Environment"));
|
||||
envAspect->setBaseEnvironmentGetter([envAspect, target]() -> Utils::Environment {
|
||||
Environment env = envAspect->baseEnvironmentBase() == SystemEnvironmentBase
|
||||
? Environment::systemEnvironment()
|
||||
: Environment();
|
||||
|
||||
auto envModifier = [&](Environment env) {
|
||||
if (auto project = qobject_cast<const QmlProject *>(target->project()))
|
||||
env.modify(project->environment());
|
||||
|
||||
return env;
|
||||
});
|
||||
};
|
||||
|
||||
const Id deviceTypeId = DeviceTypeKitAspect::deviceTypeId(target->kit());
|
||||
if (deviceTypeId == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE) {
|
||||
envAspect->addPreferredBaseEnvironment(tr("System Environment"), [&] {
|
||||
return envModifier(Environment::systemEnvironment());
|
||||
});
|
||||
}
|
||||
|
||||
envAspect->addSupportedBaseEnvironment(tr("Clean Environment"), [&] {
|
||||
return envModifier(Environment());
|
||||
});
|
||||
|
||||
m_qmlViewerAspect = addAspect<BaseStringAspect>();
|
||||
m_qmlViewerAspect->setLabelText(tr("QML Viewer:"));
|
||||
|
||||
Reference in New Issue
Block a user