ProjectExplorer: Dissolve ISettingsAspect

Covered by AspectContainer nowadays.

Change-Id: Id7eadaf089059031e6bd4c4b3e742e4ed0a1dc96
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2023-07-21 16:39:05 +02:00
parent 2260c12f6c
commit 9a53869d51
9 changed files with 21 additions and 90 deletions

View File

@@ -27,7 +27,7 @@ AnalyzerRunConfigWidget::AnalyzerRunConfigWidget(ProjectExplorer::GlobalOrProjec
auto restoreButton = new QPushButton(Tr::tr("Restore Global"));
auto innerPane = new QWidget;
auto configWidget = aspect->projectSettings()->createConfigWidget();
auto configWidget = aspect->projectSettings()->layouter()().emerge();
auto details = new DetailsWidget;
details->setWidget(innerPane);

View File

@@ -27,13 +27,6 @@ PerfSettings &globalSettings()
PerfSettings::PerfSettings(ProjectExplorer::Target *target)
{
setConfigWidgetCreator([this, target] {
auto widget = new Internal::PerfConfigWidget(this);
widget->setTracePointsButtonVisible(target != nullptr);
widget->setTarget(target);
return widget;
});
period.setSettingsKey("Analyzer.Perf.Frequency");
period.setRange(250, 2147483647);
period.setDefaultValue(250);
@@ -71,11 +64,12 @@ PerfSettings::PerfSettings(ProjectExplorer::Target *target)
stackSize.setEnabled(callgraphMode.volatileValue() == 0);
});
setLayouter([this] {
setLayouter([this, target] {
using namespace Layouting;
return Column {
createConfigWidget()
};
auto widget = new Internal::PerfConfigWidget(this);
widget->setTracePointsButtonVisible(target != nullptr);
widget->setTarget(target);
return Column { widget };
});
readSettings();

View File

@@ -9,7 +9,7 @@
namespace PerfProfiler {
class PERFPROFILER_EXPORT PerfSettings final : public ProjectExplorer::ISettingsAspect
class PERFPROFILER_EXPORT PerfSettings final : public Utils::AspectContainer
{
Q_OBJECT

View File

@@ -47,25 +47,6 @@ namespace ProjectExplorer {
const char BUILD_KEY[] = "ProjectExplorer.RunConfiguration.BuildKey";
const char CUSTOMIZED_KEY[] = "ProjectExplorer.RunConfiguration.Customized";
///////////////////////////////////////////////////////////////////////
//
// ISettingsAspect
//
///////////////////////////////////////////////////////////////////////
ISettingsAspect::ISettingsAspect() = default;
QWidget *ISettingsAspect::createConfigWidget() const
{
QTC_ASSERT(m_configWidgetCreator, return nullptr);
return m_configWidgetCreator();
}
void ISettingsAspect::setConfigWidgetCreator(const ConfigWidgetCreator &configWidgetCreator)
{
m_configWidgetCreator = configWidgetCreator;
}
///////////////////////////////////////////////////////////////////////
//
@@ -83,13 +64,13 @@ GlobalOrProjectAspect::~GlobalOrProjectAspect()
delete m_projectSettings;
}
void GlobalOrProjectAspect::setProjectSettings(ISettingsAspect *settings)
void GlobalOrProjectAspect::setProjectSettings(AspectContainer *settings)
{
m_projectSettings = settings;
m_projectSettings->setAutoApply(true);
}
void GlobalOrProjectAspect::setGlobalSettings(ISettingsAspect *settings)
void GlobalOrProjectAspect::setGlobalSettings(AspectContainer *settings)
{
m_globalSettings = settings;
m_projectSettings->setAutoApply(false);
@@ -100,7 +81,7 @@ void GlobalOrProjectAspect::setUsingGlobalSettings(bool value)
m_useGlobalSettings = value;
}
ISettingsAspect *GlobalOrProjectAspect::currentSettings() const
AspectContainer *GlobalOrProjectAspect::currentSettings() const
{
return m_useGlobalSettings ? m_globalSettings : m_projectSettings;
}

View File

@@ -11,8 +11,6 @@
#include <utils/environment.h>
#include <utils/macroexpander.h>
#include <QWidget>
#include <functional>
#include <memory>
@@ -29,32 +27,6 @@ class RunConfiguration;
class RunConfigurationCreationInfo;
class Target;
/**
* An interface for a hunk of global or per-project
* configuration data.
*
*/
class PROJECTEXPLORER_EXPORT ISettingsAspect : public Utils::AspectContainer
{
Q_OBJECT
public:
ISettingsAspect();
/// 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;
ConfigWidgetCreator m_configWidgetCreator;
};
/**
* An interface to facilitate switching between hunks of
* global and per-project configuration data.
@@ -69,19 +41,19 @@ public:
GlobalOrProjectAspect();
~GlobalOrProjectAspect() override;
void setProjectSettings(ISettingsAspect *settings);
void setGlobalSettings(ISettingsAspect *settings);
void setProjectSettings(Utils::AspectContainer *settings);
void setGlobalSettings(Utils::AspectContainer *settings);
bool isUsingGlobalSettings() const { return m_useGlobalSettings; }
void setUsingGlobalSettings(bool value);
void resetProjectToGlobalSettings();
ISettingsAspect *projectSettings() const { return m_projectSettings; }
ISettingsAspect *currentSettings() const;
Utils::AspectContainer *projectSettings() const { return m_projectSettings; }
Utils::AspectContainer *currentSettings() const;
struct Data : Utils::BaseAspect::Data
{
ISettingsAspect *currentSettings = nullptr;
Utils::AspectContainer *currentSettings = nullptr;
};
protected:
@@ -92,8 +64,8 @@ protected:
private:
bool m_useGlobalSettings = false;
ISettingsAspect *m_projectSettings = nullptr; // Owned if present.
ISettingsAspect *m_globalSettings = nullptr; // Not owned.
Utils::AspectContainer *m_projectSettings = nullptr; // Owned if present.
Utils::AspectContainer *m_globalSettings = nullptr; // Not owned.
};
// Documentation inside.
@@ -133,7 +105,7 @@ public:
ProjectExplorer::ProjectNode *productNode() const;
template <class T = ISettingsAspect> T *currentSettings(Utils::Id id) const
template <class T = Utils::AspectContainer> T *currentSettings(Utils::Id id) const
{
if (auto a = qobject_cast<GlobalOrProjectAspect *>(aspect(id)))
return qobject_cast<T *>(a->currentSettings());
@@ -264,5 +236,3 @@ private:
};
} // namespace ProjectExplorer
Q_DECLARE_METATYPE(ProjectExplorer::ISettingsAspect *);

View File

@@ -62,8 +62,6 @@ QmlProfilerSettings::QmlProfilerSettings()
};
});
setConfigWidgetCreator([this] { return layouter()().emerge(); });
readSettings();
}

View File

@@ -3,11 +3,11 @@
#pragma once
#include <projectexplorer/runconfiguration.h>
#include <utils/aspects.h>
namespace QmlProfiler::Internal {
class QmlProfilerSettings : public ProjectExplorer::ISettingsAspect
class QmlProfilerSettings : public Utils::AspectContainer
{
public:
QmlProfilerSettings();

View File

@@ -176,14 +176,6 @@ void SuppressionAspect::bufferToGui()
d->m_model.appendRow(new QStandardItem(file.toUserOutput()));
}
// ValgrindConfigWidget
QWidget *createSettingsWidget(ValgrindBaseSettings *settings)
{
return settings->layouter()().emerge();
}
//////////////////////////////////////////////////////////////////
//
// ValgrindBaseSettings
@@ -414,8 +406,6 @@ ValgrindGlobalSettings::ValgrindGlobalSettings()
shortenTemplates.setLabelText("<>"); // FIXME: Create a real icon
shortenTemplates.setToolTip(Tr::tr("Remove template parameter lists when displaying function names."));
setConfigWidgetCreator([this] { return createSettingsWidget(this); });
setSettingsGroup("Analyzer");
readSettings();
setAutoApply(false);
@@ -434,8 +424,6 @@ ValgrindGlobalSettings::ValgrindGlobalSettings()
ValgrindProjectSettings::ValgrindProjectSettings()
: ValgrindBaseSettings(false)
{
setConfigWidgetCreator([this] { return createSettingsWidget(this); });
connect(this, &AspectContainer::fromMapFinished, [this] {
// FIXME: Update project page e.g. on "Restore Global", aspects
// there are 'autoapply', and Aspect::cancel() is normally part of

View File

@@ -38,7 +38,7 @@ private:
/**
* Valgrind settings shared for global and per-project.
*/
class ValgrindBaseSettings : public ProjectExplorer::ISettingsAspect
class ValgrindBaseSettings : public Utils::AspectContainer
{
Q_OBJECT