aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/projectexplorer/runcontrol.h
diff options
context:
space:
mode:
authorhjk <hjk@qt.io>2019-03-13 12:22:44 +0100
committerhjk <hjk@qt.io>2019-03-19 15:56:17 +0000
commit1bc10248c06bf7248ca9c4e05013b492edc3210a (patch)
tree30e88bbfddb986de5ee36c60779603d03d4535e4 /src/plugins/projectexplorer/runcontrol.h
parent404b284e8f234ca5c27d4a3f4db1af68cb799545 (diff)
ProjectExplorer: Introduce a SimpleRunWorkerFactory template
... and use in as replacement for RunConfiguration::addRunWorkerFactory. It is still convenient to have a simple way to set up run worker factories for the typical "just run for this configuration" case, but it's even better if it follows the nowadays predominant pattern of keeping factories in the plugin's pimpl. Also, it turned out there were two copies of QmlProjectRunconfigurationFactory code, one is enough. Change-Id: I0b28c4ea18d0f52165a49f6133dc8687a3b9c7cf Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'src/plugins/projectexplorer/runcontrol.h')
-rw-r--r--src/plugins/projectexplorer/runcontrol.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/plugins/projectexplorer/runcontrol.h b/src/plugins/projectexplorer/runcontrol.h
index 7afdbc5c66..657c7acd75 100644
--- a/src/plugins/projectexplorer/runcontrol.h
+++ b/src/plugins/projectexplorer/runcontrol.h
@@ -327,4 +327,20 @@ private:
bool m_useTerminal = false;
};
+template <class RunConfig, class RunWorker = SimpleTargetRunner>
+class SimpleRunWorkerFactory : public RunWorkerFactory
+{
+public:
+ SimpleRunWorkerFactory(Core::Id runMode = ProjectExplorer::Constants::NORMAL_RUN_MODE)
+ {
+ addSupportedRunMode(runMode);
+ addConstraint([](RunConfiguration *runConfig) {
+ return qobject_cast<RunConfig *>(runConfig) != nullptr;
+ });
+ setProducer([](RunControl *runControl) {
+ return new RunWorker(runControl);
+ });
+ }
+};
+
} // namespace ProjectExplorer