forked from qt-creator/qt-creator
ProjectExplorer: Use a ISettingsAspect::setConfigWidgetCreator() setter
Closer to the usual pattern elsewhere. Change-Id: Ieaed483bc7f61b63e5bde87a721f43c3e3d737aa Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -34,13 +34,14 @@
|
||||
namespace PerfProfiler {
|
||||
|
||||
PerfSettings::PerfSettings(ProjectExplorer::Target *target)
|
||||
: ISettingsAspect([this, target] {
|
||||
{
|
||||
setConfigWidgetCreator([this, target] {
|
||||
auto widget = new Internal::PerfConfigWidget(this);
|
||||
widget->setTracePointsButtonVisible(target != nullptr);
|
||||
widget->setTarget(target);
|
||||
return widget;
|
||||
})
|
||||
{
|
||||
});
|
||||
|
||||
readGlobalSettings();
|
||||
}
|
||||
|
||||
|
||||
@@ -70,9 +70,7 @@ const char BUILD_KEY[] = "ProjectExplorer.RunConfiguration.BuildKey";
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
||||
ISettingsAspect::ISettingsAspect(const ConfigWidgetCreator &creator)
|
||||
: m_configWidgetCreator(creator)
|
||||
{}
|
||||
ISettingsAspect::ISettingsAspect() = default;
|
||||
|
||||
QWidget *ISettingsAspect::createConfigWidget() const
|
||||
{
|
||||
@@ -80,6 +78,12 @@ QWidget *ISettingsAspect::createConfigWidget() const
|
||||
return m_configWidgetCreator();
|
||||
}
|
||||
|
||||
void ISettingsAspect::setConfigWidgetCreator(const ConfigWidgetCreator &configWidgetCreator)
|
||||
{
|
||||
m_configWidgetCreator = configWidgetCreator;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IRunConfigurationAspect
|
||||
|
||||
@@ -61,14 +61,15 @@ class PROJECTEXPLORER_EXPORT ISettingsAspect : public QObject
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
/// Create a configuration widget for this settings aspect.
|
||||
using ConfigWidgetCreator = std::function<QWidget *()>;
|
||||
ISettingsAspect();
|
||||
|
||||
explicit ISettingsAspect(const ConfigWidgetCreator &configWidgetCreator);
|
||||
/// Create a configuration widget for this settings aspect.
|
||||
QWidget *createConfigWidget() const;
|
||||
|
||||
protected:
|
||||
///
|
||||
using ConfigWidgetCreator = std::function<QWidget *()>;
|
||||
void setConfigWidgetCreator(const ConfigWidgetCreator &configWidgetCreator);
|
||||
|
||||
friend class GlobalOrProjectAspect;
|
||||
/// Converts current object into map for storage.
|
||||
virtual void toMap(QVariantMap &map) const = 0;
|
||||
|
||||
@@ -35,8 +35,9 @@ namespace QmlProfiler {
|
||||
namespace Internal {
|
||||
|
||||
QmlProfilerSettings::QmlProfilerSettings()
|
||||
: ProjectExplorer::ISettingsAspect([this] { return new QmlProfilerConfigWidget(this); })
|
||||
{
|
||||
setConfigWidgetCreator([this] { return new QmlProfilerConfigWidget(this); });
|
||||
|
||||
QVariantMap defaults;
|
||||
defaults.insert(QLatin1String(Constants::FLUSH_INTERVAL), 1000);
|
||||
defaults.insert(QLatin1String(Constants::FLUSH_ENABLED), false);
|
||||
|
||||
@@ -82,9 +82,7 @@ template <typename T> void setIfPresent(const QVariantMap &map, const QString &k
|
||||
*val = map.value(key).template value<T>();
|
||||
}
|
||||
|
||||
ValgrindBaseSettings::ValgrindBaseSettings(const ConfigWidgetCreator &creator)
|
||||
: ISettingsAspect(creator)
|
||||
{}
|
||||
ValgrindBaseSettings::ValgrindBaseSettings() = default;
|
||||
|
||||
void ValgrindBaseSettings::fromMap(const QVariantMap &map)
|
||||
{
|
||||
@@ -304,9 +302,10 @@ void ValgrindBaseSettings::setVisualisationMinimumInclusiveCostRatio(
|
||||
static ValgrindGlobalSettings *theGlobalSettings = nullptr;
|
||||
|
||||
ValgrindGlobalSettings::ValgrindGlobalSettings()
|
||||
: ValgrindBaseSettings([this] { return new ValgrindConfigWidget(this, true); })
|
||||
{
|
||||
theGlobalSettings = this;
|
||||
|
||||
setConfigWidgetCreator([this] { return new ValgrindConfigWidget(this, true); });
|
||||
readSettings();
|
||||
}
|
||||
|
||||
@@ -494,8 +493,9 @@ void ValgrindGlobalSettings::setShortenTemplates(bool on)
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
ValgrindProjectSettings::ValgrindProjectSettings()
|
||||
: ValgrindBaseSettings([this] { return new ValgrindConfigWidget(this, false); })
|
||||
{}
|
||||
{
|
||||
setConfigWidgetCreator([this] { return new ValgrindConfigWidget(this, false); });
|
||||
}
|
||||
|
||||
void ValgrindProjectSettings::fromMap(const QVariantMap &map)
|
||||
{
|
||||
|
||||
@@ -59,7 +59,7 @@ public:
|
||||
LeakCheckOnFinishYes
|
||||
};
|
||||
|
||||
ValgrindBaseSettings(const ConfigWidgetCreator &creator);
|
||||
ValgrindBaseSettings();
|
||||
|
||||
void toMap(QVariantMap &map) const override;
|
||||
void fromMap(const QVariantMap &map) override;
|
||||
|
||||
Reference in New Issue
Block a user