diff options
author | hjk <hjk@qt.io> | 2019-08-07 18:05:15 +0200 |
---|---|---|
committer | hjk <hjk@qt.io> | 2019-08-09 12:34:42 +0000 |
commit | f9c221eb54ca3174c57f736b7afd5914147ab2a2 (patch) | |
tree | 1d58370c31fd3c342ddd133f659ee01adb017b22 /src/plugins/android | |
parent | a88970db34357adaaedd7514490d94702744a7ec (diff) | |
download | qt-creator-f9c221eb54ca3174c57f736b7afd5914147ab2a2.tar.gz |
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>
Diffstat (limited to 'src/plugins/android')
-rw-r--r-- | src/plugins/android/androidplugin.cpp | 54 |
1 files changed, 31 insertions, 23 deletions
diff --git a/src/plugins/android/androidplugin.cpp b/src/plugins/android/androidplugin.cpp index 61c4b62252..759e0d5993 100644 --- a/src/plugins/android/androidplugin.cpp +++ b/src/plugins/android/androidplugin.cpp @@ -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; |