forked from qt-creator/qt-creator
enable adding custom config widgets from a run control factory
To achieve this there are two methods in IRunControlFactory you need to implement: 1) createRunConfigurationAspect returns a IRunConfigurationAspect which stores the settings specific to your plugin. 2) createConfigurationWidget returns a RunConfigWidget that will be shown in the project settings Merge-request: 258 Reviewed-by: hjk <qtc-committer@nokia.com>
This commit is contained in:
@@ -160,6 +160,7 @@ RunConfiguration::RunConfiguration(Target *target, const QString &id) :
|
||||
m_qmlDebugServerPort(Constants::QML_DEFAULT_DEBUG_SERVER_PORT)
|
||||
{
|
||||
Q_ASSERT(target);
|
||||
addExtraAspects();
|
||||
}
|
||||
|
||||
RunConfiguration::RunConfiguration(Target *target, RunConfiguration *source) :
|
||||
@@ -168,10 +169,20 @@ RunConfiguration::RunConfiguration(Target *target, RunConfiguration *source) :
|
||||
m_useQmlDebugger(source->useQmlDebugger())
|
||||
{
|
||||
Q_ASSERT(target);
|
||||
addExtraAspects();
|
||||
}
|
||||
|
||||
RunConfiguration::~RunConfiguration()
|
||||
{
|
||||
qDeleteAll(m_aspects);
|
||||
}
|
||||
|
||||
void RunConfiguration::addExtraAspects()
|
||||
{
|
||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||
foreach (IRunControlFactory *factory, pm->getObjects<IRunControlFactory>())
|
||||
if (IRunConfigurationAspect *aspect = factory->createRunConfigurationAspect())
|
||||
m_aspects.append(aspect);
|
||||
}
|
||||
|
||||
bool RunConfiguration::isEnabled(BuildConfiguration *bc) const
|
||||
@@ -239,6 +250,9 @@ QVariantMap RunConfiguration::toMap() const
|
||||
map.insert(QLatin1String(USE_CPP_DEBUGGER_KEY), m_useCppDebugger);
|
||||
map.insert(QLatin1String(USE_QML_DEBUGGER_KEY), m_useQmlDebugger);
|
||||
map.insert(QLatin1String(QML_DEBUG_SERVER_PORT_KEY), m_qmlDebugServerPort);
|
||||
foreach (IRunConfigurationAspect *aspect, m_aspects)
|
||||
map.unite(aspect->toMap());
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
@@ -259,9 +273,18 @@ bool RunConfiguration::fromMap(const QVariantMap &map)
|
||||
m_useQmlDebugger = map.value(QLatin1String(USE_QML_DEBUGGER_KEY), false).toBool();
|
||||
m_qmlDebugServerPort = map.value(QLatin1String(QML_DEBUG_SERVER_PORT_KEY), Constants::QML_DEFAULT_DEBUG_SERVER_PORT).toUInt();
|
||||
|
||||
foreach (IRunConfigurationAspect *aspect, m_aspects)
|
||||
if (!aspect->fromMap(map))
|
||||
return false;
|
||||
|
||||
return ProjectConfiguration::fromMap(map);
|
||||
}
|
||||
|
||||
QList<IRunConfigurationAspect *> RunConfiguration::extraAspects() const
|
||||
{
|
||||
return m_aspects;
|
||||
}
|
||||
|
||||
ProjectExplorer::OutputFormatter *RunConfiguration::createOutputFormatter() const
|
||||
{
|
||||
return new OutputFormatter();
|
||||
@@ -303,6 +326,11 @@ IRunControlFactory::~IRunControlFactory()
|
||||
{
|
||||
}
|
||||
|
||||
IRunConfigurationAspect *IRunControlFactory::createRunConfigurationAspect()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
RunControl::RunControl(RunConfiguration *runConfiguration, QString mode)
|
||||
: m_runMode(mode), m_runConfiguration(runConfiguration), m_outputFormatter(0)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user