forked from qt-creator/qt-creator
ProjectExplorer: Remove direct runconfig dependency from ISettingsAspect
Change-Id: I5d8a6a31f6bf97c34163b64b8d37f9ea070717ba Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
This commit is contained in:
@@ -41,7 +41,6 @@ namespace Debugger {
|
|||||||
AnalyzerRunConfigWidget::AnalyzerRunConfigWidget(ProjectExplorer::IRunConfigurationAspect *aspect)
|
AnalyzerRunConfigWidget::AnalyzerRunConfigWidget(ProjectExplorer::IRunConfigurationAspect *aspect)
|
||||||
{
|
{
|
||||||
m_aspect = aspect;
|
m_aspect = aspect;
|
||||||
m_config = aspect->projectSettings();
|
|
||||||
|
|
||||||
auto globalSetting = new QWidget;
|
auto globalSetting = new QWidget;
|
||||||
auto globalSettingLayout = new QHBoxLayout(globalSetting);
|
auto globalSettingLayout = new QHBoxLayout(globalSetting);
|
||||||
@@ -63,7 +62,7 @@ AnalyzerRunConfigWidget::AnalyzerRunConfigWidget(ProjectExplorer::IRunConfigurat
|
|||||||
globalSettingLayout->addStretch(2);
|
globalSettingLayout->addStretch(2);
|
||||||
|
|
||||||
QWidget *innerPane = new QWidget;
|
QWidget *innerPane = new QWidget;
|
||||||
m_configWidget = m_config->createConfigWidget(innerPane);
|
m_configWidget = aspect->projectSettings()->createConfigWidget();
|
||||||
|
|
||||||
auto layout = new QVBoxLayout(innerPane);
|
auto layout = new QVBoxLayout(innerPane);
|
||||||
layout->setContentsMargins(0, 0, 0, 0);
|
layout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
|||||||
@@ -54,7 +54,6 @@ private:
|
|||||||
|
|
||||||
QWidget *m_configWidget;
|
QWidget *m_configWidget;
|
||||||
ProjectExplorer::IRunConfigurationAspect *m_aspect;
|
ProjectExplorer::IRunConfigurationAspect *m_aspect;
|
||||||
ProjectExplorer::ISettingsAspect *m_config;
|
|
||||||
QComboBox *m_settingsCombo;
|
QComboBox *m_settingsCombo;
|
||||||
QPushButton *m_restoreButton;
|
QPushButton *m_restoreButton;
|
||||||
Utils::DetailsWidget *m_details;
|
Utils::DetailsWidget *m_details;
|
||||||
|
|||||||
@@ -77,14 +77,14 @@ namespace ProjectExplorer {
|
|||||||
//
|
//
|
||||||
///////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
ISettingsAspect::ISettingsAspect(RunConfiguration *runConfiguration) :
|
ISettingsAspect::ISettingsAspect(const ConfigWidgetCreator &creator)
|
||||||
m_runConfiguration(runConfiguration)
|
: m_configWidgetCreator(creator)
|
||||||
{
|
{}
|
||||||
}
|
|
||||||
|
|
||||||
RunConfiguration *ISettingsAspect::runConfiguration() const
|
QWidget *ISettingsAspect::createConfigWidget() const
|
||||||
{
|
{
|
||||||
return m_runConfiguration;
|
QTC_ASSERT(m_configWidgetCreator, return nullptr);
|
||||||
|
return m_configWidgetCreator();
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////
|
||||||
|
|||||||
@@ -79,12 +79,11 @@ class PROJECTEXPLORER_EXPORT ISettingsAspect : public QObject
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ISettingsAspect(RunConfiguration *runConfiguration);
|
|
||||||
|
|
||||||
/// Create a configuration widget for this settings aspect.
|
/// Create a configuration widget for this settings aspect.
|
||||||
virtual QWidget *createConfigWidget(QWidget *parent) = 0;
|
using ConfigWidgetCreator = std::function<QWidget *()>;
|
||||||
|
|
||||||
RunConfiguration *runConfiguration() const;
|
explicit ISettingsAspect(const ConfigWidgetCreator &configWidgetCreator);
|
||||||
|
QWidget *createConfigWidget() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
///
|
///
|
||||||
@@ -94,8 +93,7 @@ protected:
|
|||||||
/// Read object state from @p map.
|
/// Read object state from @p map.
|
||||||
virtual void fromMap(const QVariantMap &map) = 0;
|
virtual void fromMap(const QVariantMap &map) = 0;
|
||||||
|
|
||||||
private:
|
ConfigWidgetCreator m_configWidgetCreator;
|
||||||
RunConfiguration *m_runConfiguration;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ QmlProfilerRunConfigurationAspect::QmlProfilerRunConfigurationAspect(
|
|||||||
ProjectExplorer::RunConfiguration *parent) :
|
ProjectExplorer::RunConfiguration *parent) :
|
||||||
ProjectExplorer::IRunConfigurationAspect(parent)
|
ProjectExplorer::IRunConfigurationAspect(parent)
|
||||||
{
|
{
|
||||||
setProjectSettings(new QmlProfilerSettings(parent));
|
setProjectSettings(new QmlProfilerSettings);
|
||||||
setGlobalSettings(QmlProfilerPlugin::globalSettings());
|
setGlobalSettings(QmlProfilerPlugin::globalSettings());
|
||||||
setId(Constants::SETTINGS);
|
setId(Constants::SETTINGS);
|
||||||
setDisplayName(QCoreApplication::translate("QmlProfilerRunConfiguration", "QML Profiler Settings"));
|
setDisplayName(QCoreApplication::translate("QmlProfilerRunConfiguration", "QML Profiler Settings"));
|
||||||
|
|||||||
@@ -34,8 +34,8 @@
|
|||||||
namespace QmlProfiler {
|
namespace QmlProfiler {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
QmlProfilerSettings::QmlProfilerSettings(ProjectExplorer::RunConfiguration *runConfiguration) :
|
QmlProfilerSettings::QmlProfilerSettings()
|
||||||
ProjectExplorer::ISettingsAspect(runConfiguration)
|
: ProjectExplorer::ISettingsAspect([this] { return new QmlProfilerConfigWidget(this); })
|
||||||
{
|
{
|
||||||
QVariantMap defaults;
|
QVariantMap defaults;
|
||||||
defaults.insert(QLatin1String(Constants::FLUSH_INTERVAL), 1000);
|
defaults.insert(QLatin1String(Constants::FLUSH_INTERVAL), 1000);
|
||||||
@@ -54,11 +54,6 @@ QmlProfilerSettings::QmlProfilerSettings(ProjectExplorer::RunConfiguration *runC
|
|||||||
fromMap(map);
|
fromMap(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget *QmlProfilerSettings::createConfigWidget(QWidget *parent)
|
|
||||||
{
|
|
||||||
return new Internal::QmlProfilerConfigWidget(this, parent);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool QmlProfilerSettings::flushEnabled() const
|
bool QmlProfilerSettings::flushEnabled() const
|
||||||
{
|
{
|
||||||
return m_flushEnabled;
|
return m_flushEnabled;
|
||||||
|
|||||||
@@ -34,8 +34,7 @@ class QmlProfilerSettings : public ProjectExplorer::ISettingsAspect
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
QmlProfilerSettings(ProjectExplorer::RunConfiguration *runConfiguration = nullptr);
|
QmlProfilerSettings();
|
||||||
QWidget *createConfigWidget(QWidget *parent) override;
|
|
||||||
|
|
||||||
bool flushEnabled() const;
|
bool flushEnabled() const;
|
||||||
void setFlushEnabled(bool flushEnabled);
|
void setFlushEnabled(bool flushEnabled);
|
||||||
|
|||||||
@@ -44,10 +44,8 @@
|
|||||||
namespace Valgrind {
|
namespace Valgrind {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
ValgrindConfigWidget::ValgrindConfigWidget(ValgrindBaseSettings *settings,
|
ValgrindConfigWidget::ValgrindConfigWidget(ValgrindBaseSettings *settings, bool global)
|
||||||
QWidget *parent, bool global)
|
: m_settings(settings),
|
||||||
: QWidget(parent),
|
|
||||||
m_settings(settings),
|
|
||||||
m_ui(new Ui::ValgrindConfigWidget)
|
m_ui(new Ui::ValgrindConfigWidget)
|
||||||
{
|
{
|
||||||
m_ui->setupUi(this);
|
m_ui->setupUi(this);
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ class ValgrindConfigWidget : public QWidget
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ValgrindConfigWidget(ValgrindBaseSettings *settings, QWidget *parent, bool global);
|
ValgrindConfigWidget(ValgrindBaseSettings *settings, bool global);
|
||||||
virtual ~ValgrindConfigWidget();
|
virtual ~ValgrindConfigWidget();
|
||||||
|
|
||||||
void setSuppressions(const QStringList &files);
|
void setSuppressions(const QStringList &files);
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ public:
|
|||||||
QWidget *widget()
|
QWidget *widget()
|
||||||
{
|
{
|
||||||
if (!m_widget)
|
if (!m_widget)
|
||||||
m_widget = new ValgrindConfigWidget(theGlobalSettings, 0, true);
|
m_widget = new ValgrindConfigWidget(theGlobalSettings, true);
|
||||||
return m_widget;
|
return m_widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,7 +95,7 @@ public:
|
|||||||
ValgrindRunConfigurationAspect(RunConfiguration *parent)
|
ValgrindRunConfigurationAspect(RunConfiguration *parent)
|
||||||
: IRunConfigurationAspect(parent)
|
: IRunConfigurationAspect(parent)
|
||||||
{
|
{
|
||||||
setProjectSettings(new ValgrindProjectSettings(parent));
|
setProjectSettings(new ValgrindProjectSettings);
|
||||||
setGlobalSettings(ValgrindPlugin::globalSettings());
|
setGlobalSettings(ValgrindPlugin::globalSettings());
|
||||||
setId(ANALYZER_VALGRIND_SETTINGS);
|
setId(ANALYZER_VALGRIND_SETTINGS);
|
||||||
setDisplayName(QCoreApplication::translate("Valgrind::Internal::ValgrindRunConfigurationAspect",
|
setDisplayName(QCoreApplication::translate("Valgrind::Internal::ValgrindRunConfigurationAspect",
|
||||||
|
|||||||
@@ -81,6 +81,10 @@ 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)
|
||||||
|
: ISettingsAspect(creator)
|
||||||
|
{}
|
||||||
|
|
||||||
void ValgrindBaseSettings::fromMap(const QVariantMap &map)
|
void ValgrindBaseSettings::fromMap(const QVariantMap &map)
|
||||||
{
|
{
|
||||||
// General
|
// General
|
||||||
@@ -113,10 +117,6 @@ void ValgrindBaseSettings::fromMap(const QVariantMap &map)
|
|||||||
emit changed();
|
emit changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
ValgrindBaseSettings::ValgrindBaseSettings(ProjectExplorer::RunConfiguration *runConfiguration) :
|
|
||||||
ProjectExplorer::ISettingsAspect(runConfiguration)
|
|
||||||
{}
|
|
||||||
|
|
||||||
void ValgrindBaseSettings::toMap(QVariantMap &map) const
|
void ValgrindBaseSettings::toMap(QVariantMap &map) const
|
||||||
{
|
{
|
||||||
// General
|
// General
|
||||||
@@ -289,15 +289,11 @@ void ValgrindBaseSettings::setVisualisationMinimumInclusiveCostRatio(
|
|||||||
//////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
ValgrindGlobalSettings::ValgrindGlobalSettings()
|
ValgrindGlobalSettings::ValgrindGlobalSettings()
|
||||||
|
: ValgrindBaseSettings([this] { return new ValgrindConfigWidget(this, true); })
|
||||||
{
|
{
|
||||||
readSettings();
|
readSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget *ValgrindGlobalSettings::createConfigWidget(QWidget *parent)
|
|
||||||
{
|
|
||||||
return new ValgrindConfigWidget(this, parent, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ValgrindGlobalSettings::fromMap(const QVariantMap &map)
|
void ValgrindGlobalSettings::fromMap(const QVariantMap &map)
|
||||||
{
|
{
|
||||||
ValgrindBaseSettings::fromMap(map);
|
ValgrindBaseSettings::fromMap(map);
|
||||||
@@ -475,16 +471,10 @@ void ValgrindGlobalSettings::setShortenTemplates(bool on)
|
|||||||
//
|
//
|
||||||
//////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
ValgrindProjectSettings::ValgrindProjectSettings(
|
ValgrindProjectSettings::ValgrindProjectSettings()
|
||||||
ProjectExplorer::RunConfiguration *runConfiguration) :
|
: ValgrindBaseSettings([this] { return new ValgrindConfigWidget(this, false); })
|
||||||
ValgrindBaseSettings(runConfiguration)
|
|
||||||
{}
|
{}
|
||||||
|
|
||||||
QWidget *ValgrindProjectSettings::createConfigWidget(QWidget *parent)
|
|
||||||
{
|
|
||||||
return new ValgrindConfigWidget(this, parent, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ValgrindProjectSettings::fromMap(const QVariantMap &map)
|
void ValgrindProjectSettings::fromMap(const QVariantMap &map)
|
||||||
{
|
{
|
||||||
ValgrindBaseSettings::fromMap(map);
|
ValgrindBaseSettings::fromMap(map);
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ public:
|
|||||||
LeakCheckOnFinishYes
|
LeakCheckOnFinishYes
|
||||||
};
|
};
|
||||||
|
|
||||||
ValgrindBaseSettings(ProjectExplorer::RunConfiguration *runConfiguration = nullptr);
|
ValgrindBaseSettings(const ConfigWidgetCreator &creator);
|
||||||
|
|
||||||
void toMap(QVariantMap &map) const override;
|
void toMap(QVariantMap &map) const override;
|
||||||
void fromMap(const QVariantMap &map) override;
|
void fromMap(const QVariantMap &map) override;
|
||||||
@@ -183,7 +183,6 @@ class ValgrindGlobalSettings : public ValgrindBaseSettings
|
|||||||
public:
|
public:
|
||||||
ValgrindGlobalSettings();
|
ValgrindGlobalSettings();
|
||||||
|
|
||||||
QWidget *createConfigWidget(QWidget *parent) override;
|
|
||||||
void toMap(QVariantMap &map) const override;
|
void toMap(QVariantMap &map) const override;
|
||||||
void fromMap(const QVariantMap &map) override;
|
void fromMap(const QVariantMap &map) override;
|
||||||
|
|
||||||
@@ -239,9 +238,8 @@ class ValgrindProjectSettings : public ValgrindBaseSettings
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ValgrindProjectSettings(ProjectExplorer::RunConfiguration *runConfiguration);
|
ValgrindProjectSettings();
|
||||||
|
|
||||||
QWidget *createConfigWidget(QWidget *parent) override;
|
|
||||||
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