ProjectExplorer: Re-work setup runworker factories

This combines two of the previous three paths to create run workers,
and refers to RunConfigurations by id, not by type where possible
to decrease coupling between the classes.

Only allow "type of run configuration" and "type of device"
as the only possible kind of restriction and require a uniform
RunWorker constructor signature.

Adapt user code to fit that pattern.

Change-Id: I5a6d49c9a144785fd0235d7586f244b56f67b366
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2019-08-07 18:05:15 +02:00
parent a88970db34
commit f9c221eb54
33 changed files with 289 additions and 308 deletions

View File

@@ -88,23 +88,13 @@ public:
}
};
class QmlPreviewRunWorkerFactory : public RunWorkerFactory
class AndroidQmlPreviewWorker : public AndroidQmlToolingSupport
{
public:
QmlPreviewRunWorkerFactory()
{
addSupportedRunMode(QML_PREVIEW_RUN_MODE);
setProducer([](RunControl *runControl) -> RunWorker * {
const Runnable runnable = runControl->runConfiguration()->runnable();
return new AndroidQmlToolingSupport(runControl, runnable.executable.toString());
});
addConstraint([](RunConfiguration *runConfig) {
return runConfig->isEnabled()
&& runConfig->id().name().startsWith("QmlProjectManager.QmlRunConfiguration")
&& DeviceTypeKitAspect::deviceTypeId(runConfig->target()->kit())
== Android::Constants::ANDROID_DEVICE_TYPE;
});
}
AndroidQmlPreviewWorker(RunControl *runControl)
: AndroidQmlToolingSupport(runControl,
runControl->runConfiguration()->runnable().executable.toString())
{}
};
class AndroidPluginPrivate : public QObject
@@ -151,14 +141,32 @@ public:
AndroidManifestEditorFactory manifestEditorFactory;
AndroidRunConfigurationFactory runConfigFactory;
SimpleRunWorkerFactory<AndroidRunSupport, AndroidRunConfiguration> runWorkerFactory;
SimpleRunWorkerFactory<AndroidDebugSupport, AndroidRunConfiguration>
debugWorkerFactory{DEBUG_RUN_MODE};
SimpleRunWorkerFactory<AndroidQmlToolingSupport, AndroidRunConfiguration>
profilerWorkerFactory{QML_PROFILER_RUN_MODE};
SimpleRunWorkerFactory<AndroidQmlToolingSupport, AndroidRunConfiguration>
qmlPreviewWorkerFactory{QML_PREVIEW_RUN_MODE};
QmlPreviewRunWorkerFactory qmlPreviewWorkerFactory2;
RunWorkerFactory runWorkerFactory{
RunWorkerFactory::make<AndroidRunSupport>(),
{NORMAL_RUN_MODE},
{runConfigFactory.id()}
};
RunWorkerFactory debugWorkerFactory{
RunWorkerFactory::make<AndroidDebugSupport>(),
{DEBUG_RUN_MODE},
{runConfigFactory.id()}
};
RunWorkerFactory profilerWorkerFactory{
RunWorkerFactory::make<AndroidQmlToolingSupport>(),
{QML_PROFILER_RUN_MODE},
{runConfigFactory.id()}
};
RunWorkerFactory qmlPreviewWorkerFactory{
RunWorkerFactory::make<AndroidQmlToolingSupport>(),
{QML_PREVIEW_RUN_MODE},
{runConfigFactory.id()}
};
RunWorkerFactory qmlPreviewWorkerFactory2{
RunWorkerFactory::make<AndroidQmlPreviewWorker>(),
{QML_PREVIEW_RUN_MODE},
{"QmlProjectManager.QmlRunConfiguration"},
{Android::Constants::ANDROID_DEVICE_TYPE}
};
AndroidBuildApkStepFactory buildApkStepFactory;
AndroidGdbServerKitAspect gdbServerKitAspect;