forked from qt-creator/qt-creator
ProjectExplorer: Dissolve ISettingsAspect
Covered by AspectContainer nowadays. Change-Id: Id7eadaf089059031e6bd4c4b3e742e4ed0a1dc96 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -27,7 +27,7 @@ AnalyzerRunConfigWidget::AnalyzerRunConfigWidget(ProjectExplorer::GlobalOrProjec
|
|||||||
auto restoreButton = new QPushButton(Tr::tr("Restore Global"));
|
auto restoreButton = new QPushButton(Tr::tr("Restore Global"));
|
||||||
|
|
||||||
auto innerPane = new QWidget;
|
auto innerPane = new QWidget;
|
||||||
auto configWidget = aspect->projectSettings()->createConfigWidget();
|
auto configWidget = aspect->projectSettings()->layouter()().emerge();
|
||||||
|
|
||||||
auto details = new DetailsWidget;
|
auto details = new DetailsWidget;
|
||||||
details->setWidget(innerPane);
|
details->setWidget(innerPane);
|
||||||
|
@@ -27,13 +27,6 @@ PerfSettings &globalSettings()
|
|||||||
|
|
||||||
PerfSettings::PerfSettings(ProjectExplorer::Target *target)
|
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.setSettingsKey("Analyzer.Perf.Frequency");
|
||||||
period.setRange(250, 2147483647);
|
period.setRange(250, 2147483647);
|
||||||
period.setDefaultValue(250);
|
period.setDefaultValue(250);
|
||||||
@@ -71,11 +64,12 @@ PerfSettings::PerfSettings(ProjectExplorer::Target *target)
|
|||||||
stackSize.setEnabled(callgraphMode.volatileValue() == 0);
|
stackSize.setEnabled(callgraphMode.volatileValue() == 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
setLayouter([this] {
|
setLayouter([this, target] {
|
||||||
using namespace Layouting;
|
using namespace Layouting;
|
||||||
return Column {
|
auto widget = new Internal::PerfConfigWidget(this);
|
||||||
createConfigWidget()
|
widget->setTracePointsButtonVisible(target != nullptr);
|
||||||
};
|
widget->setTarget(target);
|
||||||
|
return Column { widget };
|
||||||
});
|
});
|
||||||
|
|
||||||
readSettings();
|
readSettings();
|
||||||
|
@@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
namespace PerfProfiler {
|
namespace PerfProfiler {
|
||||||
|
|
||||||
class PERFPROFILER_EXPORT PerfSettings final : public ProjectExplorer::ISettingsAspect
|
class PERFPROFILER_EXPORT PerfSettings final : public Utils::AspectContainer
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
@@ -47,25 +47,6 @@ namespace ProjectExplorer {
|
|||||||
const char BUILD_KEY[] = "ProjectExplorer.RunConfiguration.BuildKey";
|
const char BUILD_KEY[] = "ProjectExplorer.RunConfiguration.BuildKey";
|
||||||
const char CUSTOMIZED_KEY[] = "ProjectExplorer.RunConfiguration.Customized";
|
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;
|
delete m_projectSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GlobalOrProjectAspect::setProjectSettings(ISettingsAspect *settings)
|
void GlobalOrProjectAspect::setProjectSettings(AspectContainer *settings)
|
||||||
{
|
{
|
||||||
m_projectSettings = settings;
|
m_projectSettings = settings;
|
||||||
m_projectSettings->setAutoApply(true);
|
m_projectSettings->setAutoApply(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GlobalOrProjectAspect::setGlobalSettings(ISettingsAspect *settings)
|
void GlobalOrProjectAspect::setGlobalSettings(AspectContainer *settings)
|
||||||
{
|
{
|
||||||
m_globalSettings = settings;
|
m_globalSettings = settings;
|
||||||
m_projectSettings->setAutoApply(false);
|
m_projectSettings->setAutoApply(false);
|
||||||
@@ -100,7 +81,7 @@ void GlobalOrProjectAspect::setUsingGlobalSettings(bool value)
|
|||||||
m_useGlobalSettings = value;
|
m_useGlobalSettings = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
ISettingsAspect *GlobalOrProjectAspect::currentSettings() const
|
AspectContainer *GlobalOrProjectAspect::currentSettings() const
|
||||||
{
|
{
|
||||||
return m_useGlobalSettings ? m_globalSettings : m_projectSettings;
|
return m_useGlobalSettings ? m_globalSettings : m_projectSettings;
|
||||||
}
|
}
|
||||||
|
@@ -11,8 +11,6 @@
|
|||||||
#include <utils/environment.h>
|
#include <utils/environment.h>
|
||||||
#include <utils/macroexpander.h>
|
#include <utils/macroexpander.h>
|
||||||
|
|
||||||
#include <QWidget>
|
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
@@ -29,32 +27,6 @@ class RunConfiguration;
|
|||||||
class RunConfigurationCreationInfo;
|
class RunConfigurationCreationInfo;
|
||||||
class Target;
|
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
|
* An interface to facilitate switching between hunks of
|
||||||
* global and per-project configuration data.
|
* global and per-project configuration data.
|
||||||
@@ -69,19 +41,19 @@ public:
|
|||||||
GlobalOrProjectAspect();
|
GlobalOrProjectAspect();
|
||||||
~GlobalOrProjectAspect() override;
|
~GlobalOrProjectAspect() override;
|
||||||
|
|
||||||
void setProjectSettings(ISettingsAspect *settings);
|
void setProjectSettings(Utils::AspectContainer *settings);
|
||||||
void setGlobalSettings(ISettingsAspect *settings);
|
void setGlobalSettings(Utils::AspectContainer *settings);
|
||||||
|
|
||||||
bool isUsingGlobalSettings() const { return m_useGlobalSettings; }
|
bool isUsingGlobalSettings() const { return m_useGlobalSettings; }
|
||||||
void setUsingGlobalSettings(bool value);
|
void setUsingGlobalSettings(bool value);
|
||||||
void resetProjectToGlobalSettings();
|
void resetProjectToGlobalSettings();
|
||||||
|
|
||||||
ISettingsAspect *projectSettings() const { return m_projectSettings; }
|
Utils::AspectContainer *projectSettings() const { return m_projectSettings; }
|
||||||
ISettingsAspect *currentSettings() const;
|
Utils::AspectContainer *currentSettings() const;
|
||||||
|
|
||||||
struct Data : Utils::BaseAspect::Data
|
struct Data : Utils::BaseAspect::Data
|
||||||
{
|
{
|
||||||
ISettingsAspect *currentSettings = nullptr;
|
Utils::AspectContainer *currentSettings = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@@ -92,8 +64,8 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_useGlobalSettings = false;
|
bool m_useGlobalSettings = false;
|
||||||
ISettingsAspect *m_projectSettings = nullptr; // Owned if present.
|
Utils::AspectContainer *m_projectSettings = nullptr; // Owned if present.
|
||||||
ISettingsAspect *m_globalSettings = nullptr; // Not owned.
|
Utils::AspectContainer *m_globalSettings = nullptr; // Not owned.
|
||||||
};
|
};
|
||||||
|
|
||||||
// Documentation inside.
|
// Documentation inside.
|
||||||
@@ -133,7 +105,7 @@ public:
|
|||||||
|
|
||||||
ProjectExplorer::ProjectNode *productNode() const;
|
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)))
|
if (auto a = qobject_cast<GlobalOrProjectAspect *>(aspect(id)))
|
||||||
return qobject_cast<T *>(a->currentSettings());
|
return qobject_cast<T *>(a->currentSettings());
|
||||||
@@ -264,5 +236,3 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
} // namespace ProjectExplorer
|
} // namespace ProjectExplorer
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(ProjectExplorer::ISettingsAspect *);
|
|
||||||
|
@@ -62,8 +62,6 @@ QmlProfilerSettings::QmlProfilerSettings()
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
setConfigWidgetCreator([this] { return layouter()().emerge(); });
|
|
||||||
|
|
||||||
readSettings();
|
readSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -3,11 +3,11 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <projectexplorer/runconfiguration.h>
|
#include <utils/aspects.h>
|
||||||
|
|
||||||
namespace QmlProfiler::Internal {
|
namespace QmlProfiler::Internal {
|
||||||
|
|
||||||
class QmlProfilerSettings : public ProjectExplorer::ISettingsAspect
|
class QmlProfilerSettings : public Utils::AspectContainer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QmlProfilerSettings();
|
QmlProfilerSettings();
|
||||||
|
@@ -176,14 +176,6 @@ void SuppressionAspect::bufferToGui()
|
|||||||
d->m_model.appendRow(new QStandardItem(file.toUserOutput()));
|
d->m_model.appendRow(new QStandardItem(file.toUserOutput()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// ValgrindConfigWidget
|
|
||||||
|
|
||||||
|
|
||||||
QWidget *createSettingsWidget(ValgrindBaseSettings *settings)
|
|
||||||
{
|
|
||||||
return settings->layouter()().emerge();
|
|
||||||
}
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// ValgrindBaseSettings
|
// ValgrindBaseSettings
|
||||||
@@ -414,8 +406,6 @@ ValgrindGlobalSettings::ValgrindGlobalSettings()
|
|||||||
shortenTemplates.setLabelText("<>"); // FIXME: Create a real icon
|
shortenTemplates.setLabelText("<>"); // FIXME: Create a real icon
|
||||||
shortenTemplates.setToolTip(Tr::tr("Remove template parameter lists when displaying function names."));
|
shortenTemplates.setToolTip(Tr::tr("Remove template parameter lists when displaying function names."));
|
||||||
|
|
||||||
setConfigWidgetCreator([this] { return createSettingsWidget(this); });
|
|
||||||
|
|
||||||
setSettingsGroup("Analyzer");
|
setSettingsGroup("Analyzer");
|
||||||
readSettings();
|
readSettings();
|
||||||
setAutoApply(false);
|
setAutoApply(false);
|
||||||
@@ -434,8 +424,6 @@ ValgrindGlobalSettings::ValgrindGlobalSettings()
|
|||||||
ValgrindProjectSettings::ValgrindProjectSettings()
|
ValgrindProjectSettings::ValgrindProjectSettings()
|
||||||
: ValgrindBaseSettings(false)
|
: ValgrindBaseSettings(false)
|
||||||
{
|
{
|
||||||
setConfigWidgetCreator([this] { return createSettingsWidget(this); });
|
|
||||||
|
|
||||||
connect(this, &AspectContainer::fromMapFinished, [this] {
|
connect(this, &AspectContainer::fromMapFinished, [this] {
|
||||||
// FIXME: Update project page e.g. on "Restore Global", aspects
|
// FIXME: Update project page e.g. on "Restore Global", aspects
|
||||||
// there are 'autoapply', and Aspect::cancel() is normally part of
|
// there are 'autoapply', and Aspect::cancel() is normally part of
|
||||||
|
@@ -38,7 +38,7 @@ private:
|
|||||||
/**
|
/**
|
||||||
* Valgrind settings shared for global and per-project.
|
* Valgrind settings shared for global and per-project.
|
||||||
*/
|
*/
|
||||||
class ValgrindBaseSettings : public ProjectExplorer::ISettingsAspect
|
class ValgrindBaseSettings : public Utils::AspectContainer
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user