diff options
author | hjk <[email protected]> | 2017-06-26 12:57:33 +0200 |
---|---|---|
committer | hjk <[email protected]> | 2017-06-28 15:39:49 +0000 |
commit | e974f0733e5d42ede7e30e1d98d3fe3d0500e8a1 (patch) | |
tree | 1cfc4ec8d388250507e2cb7578df11fb8da35a53 | |
parent | a72b38b8c9f26c375ee0e6e348d4c3a32af16c25 (diff) |
ProjectExplorer: Introduce priorities for RunControlFactoriesv4.3.1
This can be used by downstream plugins to overrule existing
RunControlFactories.
Change-Id: I23c8e3983827dfa1b5f780664d2e539e908944aa
Reviewed-by: Eike Ziller <[email protected]>
Reviewed-by: Tobias Hunger <[email protected]>
-rw-r--r-- | src/plugins/projectexplorer/projectexplorer.cpp | 10 | ||||
-rw-r--r-- | src/plugins/projectexplorer/runconfiguration.cpp | 13 | ||||
-rw-r--r-- | src/plugins/projectexplorer/runconfiguration.h | 4 |
3 files changed, 26 insertions, 1 deletions
diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index 61c3bf50a70..e6c25c84b61 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -1980,10 +1980,18 @@ void ProjectExplorerPluginPrivate::buildStateChanged(Project * pro) // NBS TODO implement more than one runner static IRunControlFactory *findRunControlFactory(RunConfiguration *config, Core::Id mode) { - return ExtensionSystem::PluginManager::getObject<IRunControlFactory>( + auto factories = ExtensionSystem::PluginManager::getObjects<IRunControlFactory>( [&config, &mode](IRunControlFactory *factory) { return factory->canRun(config, mode); }); + + if (factories.isEmpty()) + return nullptr; + auto it = std::max_element(factories.begin(), factories.end(), + [](IRunControlFactory *a, IRunControlFactory *b) { + return a->priority() < b->priority(); + }); + return *it; } void ProjectExplorerPluginPrivate::executeRunConfiguration(RunConfiguration *runConfiguration, Core::Id runMode) diff --git a/src/plugins/projectexplorer/runconfiguration.cpp b/src/plugins/projectexplorer/runconfiguration.cpp index da5c7b398b9..e06bbda79d6 100644 --- a/src/plugins/projectexplorer/runconfiguration.cpp +++ b/src/plugins/projectexplorer/runconfiguration.cpp @@ -501,6 +501,19 @@ IRunConfigurationAspect *IRunControlFactory::createRunConfigurationAspect(RunCon than it needs to be. */ + +const char PRIORITY_KEY[] = "RunControlFactoryPriority"; + +int ProjectExplorer::IRunControlFactory::priority() const +{ + return property(PRIORITY_KEY).toInt(); // 0 by default. +} + +void IRunControlFactory::setPriority(int priority) +{ + setProperty(PRIORITY_KEY, priority); +} + namespace Internal { class RunControlPrivate diff --git a/src/plugins/projectexplorer/runconfiguration.h b/src/plugins/projectexplorer/runconfiguration.h index 3efb2dae5b2..9a330afb9f2 100644 --- a/src/plugins/projectexplorer/runconfiguration.h +++ b/src/plugins/projectexplorer/runconfiguration.h @@ -335,6 +335,10 @@ public: virtual RunControl *create(RunConfiguration *runConfiguration, Core::Id mode, QString *errorMessage) = 0; virtual IRunConfigurationAspect *createRunConfigurationAspect(RunConfiguration *rc); + + int priority() const; +protected: + void setPriority(int priority); // Higher values will be preferred. }; class PROJECTEXPLORER_EXPORT RunConfigWidget : public QWidget |