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 {
|
namespace PerfProfiler {
|
||||||
|
|
||||||
PerfSettings::PerfSettings(ProjectExplorer::Target *target)
|
PerfSettings::PerfSettings(ProjectExplorer::Target *target)
|
||||||
: ISettingsAspect([this, target] {
|
{
|
||||||
|
setConfigWidgetCreator([this, target] {
|
||||||
auto widget = new Internal::PerfConfigWidget(this);
|
auto widget = new Internal::PerfConfigWidget(this);
|
||||||
widget->setTracePointsButtonVisible(target != nullptr);
|
widget->setTracePointsButtonVisible(target != nullptr);
|
||||||
widget->setTarget(target);
|
widget->setTarget(target);
|
||||||
return widget;
|
return widget;
|
||||||
})
|
});
|
||||||
{
|
|
||||||
readGlobalSettings();
|
readGlobalSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -70,9 +70,7 @@ const char BUILD_KEY[] = "ProjectExplorer.RunConfiguration.BuildKey";
|
|||||||
//
|
//
|
||||||
///////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
ISettingsAspect::ISettingsAspect(const ConfigWidgetCreator &creator)
|
ISettingsAspect::ISettingsAspect() = default;
|
||||||
: m_configWidgetCreator(creator)
|
|
||||||
{}
|
|
||||||
|
|
||||||
QWidget *ISettingsAspect::createConfigWidget() const
|
QWidget *ISettingsAspect::createConfigWidget() const
|
||||||
{
|
{
|
||||||
@@ -80,6 +78,12 @@ QWidget *ISettingsAspect::createConfigWidget() const
|
|||||||
return m_configWidgetCreator();
|
return m_configWidgetCreator();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ISettingsAspect::setConfigWidgetCreator(const ConfigWidgetCreator &configWidgetCreator)
|
||||||
|
{
|
||||||
|
m_configWidgetCreator = configWidgetCreator;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// IRunConfigurationAspect
|
// IRunConfigurationAspect
|
||||||
|
|||||||
@@ -61,14 +61,15 @@ class PROJECTEXPLORER_EXPORT ISettingsAspect : public QObject
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/// Create a configuration widget for this settings aspect.
|
ISettingsAspect();
|
||||||
using ConfigWidgetCreator = std::function<QWidget *()>;
|
|
||||||
|
|
||||||
explicit ISettingsAspect(const ConfigWidgetCreator &configWidgetCreator);
|
/// Create a configuration widget for this settings aspect.
|
||||||
QWidget *createConfigWidget() const;
|
QWidget *createConfigWidget() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
///
|
using ConfigWidgetCreator = std::function<QWidget *()>;
|
||||||
|
void setConfigWidgetCreator(const ConfigWidgetCreator &configWidgetCreator);
|
||||||
|
|
||||||
friend class GlobalOrProjectAspect;
|
friend class GlobalOrProjectAspect;
|
||||||
/// Converts current object into map for storage.
|
/// Converts current object into map for storage.
|
||||||
virtual void toMap(QVariantMap &map) const = 0;
|
virtual void toMap(QVariantMap &map) const = 0;
|
||||||
|
|||||||
@@ -35,8 +35,9 @@ namespace QmlProfiler {
|
|||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
QmlProfilerSettings::QmlProfilerSettings()
|
QmlProfilerSettings::QmlProfilerSettings()
|
||||||
: ProjectExplorer::ISettingsAspect([this] { return new QmlProfilerConfigWidget(this); })
|
|
||||||
{
|
{
|
||||||
|
setConfigWidgetCreator([this] { return new QmlProfilerConfigWidget(this); });
|
||||||
|
|
||||||
QVariantMap defaults;
|
QVariantMap defaults;
|
||||||
defaults.insert(QLatin1String(Constants::FLUSH_INTERVAL), 1000);
|
defaults.insert(QLatin1String(Constants::FLUSH_INTERVAL), 1000);
|
||||||
defaults.insert(QLatin1String(Constants::FLUSH_ENABLED), false);
|
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>();
|
*val = map.value(key).template value<T>();
|
||||||
}
|
}
|
||||||
|
|
||||||
ValgrindBaseSettings::ValgrindBaseSettings(const ConfigWidgetCreator &creator)
|
ValgrindBaseSettings::ValgrindBaseSettings() = default;
|
||||||
: ISettingsAspect(creator)
|
|
||||||
{}
|
|
||||||
|
|
||||||
void ValgrindBaseSettings::fromMap(const QVariantMap &map)
|
void ValgrindBaseSettings::fromMap(const QVariantMap &map)
|
||||||
{
|
{
|
||||||
@@ -304,9 +302,10 @@ void ValgrindBaseSettings::setVisualisationMinimumInclusiveCostRatio(
|
|||||||
static ValgrindGlobalSettings *theGlobalSettings = nullptr;
|
static ValgrindGlobalSettings *theGlobalSettings = nullptr;
|
||||||
|
|
||||||
ValgrindGlobalSettings::ValgrindGlobalSettings()
|
ValgrindGlobalSettings::ValgrindGlobalSettings()
|
||||||
: ValgrindBaseSettings([this] { return new ValgrindConfigWidget(this, true); })
|
|
||||||
{
|
{
|
||||||
theGlobalSettings = this;
|
theGlobalSettings = this;
|
||||||
|
|
||||||
|
setConfigWidgetCreator([this] { return new ValgrindConfigWidget(this, true); });
|
||||||
readSettings();
|
readSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -494,8 +493,9 @@ void ValgrindGlobalSettings::setShortenTemplates(bool on)
|
|||||||
//////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
ValgrindProjectSettings::ValgrindProjectSettings()
|
ValgrindProjectSettings::ValgrindProjectSettings()
|
||||||
: ValgrindBaseSettings([this] { return new ValgrindConfigWidget(this, false); })
|
{
|
||||||
{}
|
setConfigWidgetCreator([this] { return new ValgrindConfigWidget(this, false); });
|
||||||
|
}
|
||||||
|
|
||||||
void ValgrindProjectSettings::fromMap(const QVariantMap &map)
|
void ValgrindProjectSettings::fromMap(const QVariantMap &map)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ public:
|
|||||||
LeakCheckOnFinishYes
|
LeakCheckOnFinishYes
|
||||||
};
|
};
|
||||||
|
|
||||||
ValgrindBaseSettings(const ConfigWidgetCreator &creator);
|
ValgrindBaseSettings();
|
||||||
|
|
||||||
void toMap(QVariantMap &map) const override;
|
void toMap(QVariantMap &map) const override;
|
||||||
void fromMap(const QVariantMap &map) override;
|
void fromMap(const QVariantMap &map) override;
|
||||||
|
|||||||
Reference in New Issue
Block a user