Commit e974f073 authored by hjk's avatar hjk

ProjectExplorer: Introduce priorities for RunControlFactories

This can be used by downstream plugins to overrule existing
RunControlFactories.

Change-Id: I23c8e3983827dfa1b5f780664d2e539e908944aa
Reviewed-by: Eike Ziller's avatarEike Ziller <eike.ziller@qt.io>
Reviewed-by: Tobias Hunger's avatarTobias Hunger <tobias.hunger@qt.io>
parent a72b38b8
......@@ -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)
......
......@@ -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
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment