forked from qt-creator/qt-creator
Use function objects for IRunConfigurationAspect::createConfigurationWidget
Change-Id: Ief70ed8fc2731ad21b00c74407ff4b659d705caf Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
@@ -215,6 +215,7 @@ DebuggerRunConfigurationAspect::DebuggerRunConfigurationAspect(
|
||||
{
|
||||
setId("DebuggerAspect");
|
||||
setDisplayName(tr("Debugger settings"));
|
||||
setRunConfigWidgetCreator([this] { return new Internal::DebuggerRunConfigWidget(this); });
|
||||
}
|
||||
|
||||
void DebuggerRunConfigurationAspect::setUseQmlDebugger(bool value)
|
||||
@@ -335,9 +336,4 @@ DebuggerRunConfigurationAspect *DebuggerRunConfigurationAspect::create
|
||||
return new DebuggerRunConfigurationAspect(runConfiguration);
|
||||
}
|
||||
|
||||
RunConfigWidget *DebuggerRunConfigurationAspect::createConfigurationWidget()
|
||||
{
|
||||
return new Internal::DebuggerRunConfigWidget(this);
|
||||
}
|
||||
|
||||
} // namespace Debugger
|
||||
|
@@ -61,8 +61,6 @@ public:
|
||||
void fromMap(const QVariantMap &map);
|
||||
void toMap(QVariantMap &map) const;
|
||||
|
||||
ProjectExplorer::RunConfigWidget *createConfigurationWidget();
|
||||
|
||||
bool useCppDebugger() const;
|
||||
void setUseCppDebugger(bool value);
|
||||
bool useQmlDebugger() const;
|
||||
|
@@ -44,11 +44,7 @@ EnvironmentAspect::EnvironmentAspect(RunConfiguration *runConfig) :
|
||||
{
|
||||
setDisplayName(tr("Run Environment"));
|
||||
setId("EnvironmentAspect");
|
||||
}
|
||||
|
||||
RunConfigWidget *EnvironmentAspect::createConfigurationWidget()
|
||||
{
|
||||
return new EnvironmentAspectWidget(this);
|
||||
setRunConfigWidgetCreator([this] { return new EnvironmentAspectWidget(this); });
|
||||
}
|
||||
|
||||
int EnvironmentAspect::baseEnvironmentBase() const
|
||||
|
@@ -41,9 +41,6 @@ class PROJECTEXPLORER_EXPORT EnvironmentAspect : public IRunConfigurationAspect
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
// IRunConfigurationAspect:
|
||||
RunConfigWidget *createConfigurationWidget() override;
|
||||
|
||||
virtual QList<int> possibleBaseEnvironments() const = 0;
|
||||
virtual QString baseEnvironmentDisplayName(int base) const = 0;
|
||||
|
||||
|
@@ -124,9 +124,9 @@ IRunConfigurationAspect::~IRunConfigurationAspect()
|
||||
transferred to the caller.
|
||||
*/
|
||||
|
||||
RunConfigWidget *IRunConfigurationAspect::createConfigurationWidget()
|
||||
RunConfigWidget *IRunConfigurationAspect::createConfigurationWidget() const
|
||||
{
|
||||
return nullptr;
|
||||
return m_runConfigWidgetCreator ? m_runConfigWidgetCreator() : nullptr;
|
||||
}
|
||||
|
||||
void IRunConfigurationAspect::setProjectSettings(ISettingsAspect *settings)
|
||||
@@ -161,6 +161,11 @@ void IRunConfigurationAspect::toMap(QVariantMap &map) const
|
||||
map.insert(m_id.toString() + QLatin1String(".UseGlobalSettings"), m_useGlobalSettings);
|
||||
}
|
||||
|
||||
void IRunConfigurationAspect::setRunConfigWidgetCreator(const RunConfigWidgetCreator &runConfigWidgetCreator)
|
||||
{
|
||||
m_runConfigWidgetCreator = runConfigWidgetCreator;
|
||||
}
|
||||
|
||||
IRunConfigurationAspect *IRunConfigurationAspect::clone(RunConfiguration *runConfig) const
|
||||
{
|
||||
IRunConfigurationAspect *other = create(runConfig);
|
||||
|
@@ -36,12 +36,9 @@
|
||||
#include <QPointer>
|
||||
#include <QWidget>
|
||||
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QFormLayout;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace Utils { class OutputFormatter; }
|
||||
|
||||
namespace ProjectExplorer {
|
||||
@@ -121,7 +118,10 @@ public:
|
||||
|
||||
virtual IRunConfigurationAspect *create(RunConfiguration *runConfig) const = 0;
|
||||
virtual IRunConfigurationAspect *clone(RunConfiguration *runConfig) const;
|
||||
virtual RunConfigWidget *createConfigurationWidget();
|
||||
|
||||
using RunConfigWidgetCreator = std::function<RunConfigWidget *()>;
|
||||
void setRunConfigWidgetCreator(const RunConfigWidgetCreator &runConfigWidgetCreator);
|
||||
RunConfigWidget *createConfigurationWidget() const;
|
||||
|
||||
void setId(Core::Id id) { m_id = id; }
|
||||
void setDisplayName(const QString &displayName) { m_displayName = displayName; }
|
||||
@@ -151,6 +151,7 @@ private:
|
||||
RunConfiguration *m_runConfiguration = nullptr;
|
||||
ISettingsAspect *m_projectSettings = nullptr; // Owned if present.
|
||||
ISettingsAspect *m_globalSettings = nullptr; // Not owned.
|
||||
RunConfigWidgetCreator m_runConfigWidgetCreator;
|
||||
};
|
||||
|
||||
class PROJECTEXPLORER_EXPORT ClonableConcept
|
||||
|
@@ -43,6 +43,7 @@ QmlProfilerRunConfigurationAspect::QmlProfilerRunConfigurationAspect(
|
||||
setDisplayName(QCoreApplication::translate("QmlProfilerRunConfiguration", "QML Profiler Settings"));
|
||||
setUsingGlobalSettings(true);
|
||||
resetProjectToGlobalSettings();
|
||||
setRunConfigWidgetCreator([this] { return new Debugger::AnalyzerRunConfigWidget(this); });
|
||||
}
|
||||
|
||||
ProjectExplorer::IRunConfigurationAspect *QmlProfilerRunConfigurationAspect::create(
|
||||
@@ -51,10 +52,5 @@ ProjectExplorer::IRunConfigurationAspect *QmlProfilerRunConfigurationAspect::cre
|
||||
return new QmlProfilerRunConfigurationAspect(runConfig);
|
||||
}
|
||||
|
||||
ProjectExplorer::RunConfigWidget *QmlProfilerRunConfigurationAspect::createConfigurationWidget()
|
||||
{
|
||||
return new Debugger::AnalyzerRunConfigWidget(this);
|
||||
}
|
||||
|
||||
} // Internal
|
||||
} // QmlProfiler
|
||||
|
@@ -37,8 +37,6 @@ public:
|
||||
|
||||
ProjectExplorer::IRunConfigurationAspect *create(
|
||||
ProjectExplorer::RunConfiguration *runConfig) const;
|
||||
|
||||
ProjectExplorer::RunConfigWidget *createConfigurationWidget();
|
||||
};
|
||||
|
||||
} // Internal
|
||||
|
@@ -71,17 +71,13 @@ public:
|
||||
setDisplayName(QCoreApplication::translate("Valgrind::Internal::ValgrindRunConfigurationAspect", "Valgrind Settings"));
|
||||
setUsingGlobalSettings(true);
|
||||
resetProjectToGlobalSettings();
|
||||
setRunConfigWidgetCreator([this] { return new AnalyzerRunConfigWidget(this); });
|
||||
}
|
||||
|
||||
ValgrindRunConfigurationAspect *create(RunConfiguration *parent) const override
|
||||
{
|
||||
return new ValgrindRunConfigurationAspect(parent);
|
||||
}
|
||||
|
||||
RunConfigWidget *createConfigurationWidget() override
|
||||
{
|
||||
return new AnalyzerRunConfigWidget(this);
|
||||
}
|
||||
};
|
||||
|
||||
IRunConfigurationAspect *ValgrindRunControlFactory::createRunConfigurationAspect(RunConfiguration *rc)
|
||||
|
Reference in New Issue
Block a user