Valgrind: Merge configwidget population to settings aspect container

Change-Id: I021ef0ea9b3ab48c805a8af282a4062ddd701dea
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2023-07-19 10:47:51 +02:00
parent 4d0564a147
commit d2bb1151f5
7 changed files with 82 additions and 129 deletions

View File

@@ -26,7 +26,6 @@ add_qtc_plugin(Valgrind
memchecktool.cpp memchecktool.h
suppressiondialog.cpp suppressiondialog.h
valgrind.qrc
valgrindconfigwidget.cpp valgrindconfigwidget.h
valgrindengine.cpp valgrindengine.h
valgrindplugin.cpp
valgrindrunner.cpp valgrindrunner.h

View File

@@ -30,7 +30,6 @@ QtcPlugin {
"memchecktool.cpp", "memchecktool.h",
"suppressiondialog.cpp", "suppressiondialog.h",
"valgrind.qrc",
"valgrindconfigwidget.cpp", "valgrindconfigwidget.h",
"valgrindengine.cpp", "valgrindengine.h",
"valgrindplugin.cpp",
"valgrindrunner.cpp", "valgrindrunner.h",

View File

@@ -1,111 +0,0 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "valgrindconfigwidget.h"
#include "valgrindsettings.h"
#include "valgrindtr.h"
#include <debugger/analyzer/analyzericons.h>
#include <debugger/debuggertr.h>
#include <coreplugin/icore.h>
#include <utils/algorithm.h>
#include <utils/layoutbuilder.h>
#include <utils/qtcassert.h>
using namespace Utils;
namespace Valgrind::Internal {
class ValgrindConfigWidget : public Core::IOptionsPageWidget
{
public:
explicit ValgrindConfigWidget(ValgrindBaseSettings *settings);
void apply() final
{
globalSettings().apply();
globalSettings().writeSettings();
}
void finish() final
{
globalSettings().finish();
}
};
ValgrindConfigWidget::ValgrindConfigWidget(ValgrindBaseSettings *settings)
{
using namespace Layouting;
ValgrindBaseSettings &s = *settings;
// clang-format off
Grid generic {
s.valgrindExecutable, br,
s.valgrindArguments, br,
s.selfModifyingCodeDetection, br
};
Grid memcheck {
s.memcheckArguments, br,
s.trackOrigins, br,
s.showReachable, br,
s.leakCheckOnFinish, br,
s.numCallers, br,
s.filterExternalIssues, br,
s.suppressions
};
Grid callgrind {
s.callgrindArguments, br,
s.kcachegrindExecutable, br,
s.minimumInclusiveCostRatio, br,
s.visualizationMinimumInclusiveCostRatio, br,
s.enableEventToolTips, br,
Span {
2,
Group {
Column {
s.enableCacheSim,
s.enableBranchSim,
s.collectSystime,
s.collectBusEvents,
}
}
}
};
Column {
Group { title(Tr::tr("Valgrind Generic Settings")), generic },
Group { title(Tr::tr("Memcheck Memory Analysis Options")), memcheck },
Group { title(Tr::tr("Callgrind Profiling Options")), callgrind },
st,
}.attachTo(this);
// clang-format on
}
// ValgrindOptionsPage
class ValgrindOptionsPage final : public Core::IOptionsPage
{
public:
ValgrindOptionsPage()
{
setId(ANALYZER_VALGRIND_SETTINGS);
setDisplayName(Tr::tr("Valgrind"));
setCategory("T.Analyzer");
setDisplayCategory(::Debugger::Tr::tr("Analyzer"));
setCategoryIconPath(Analyzer::Icons::SETTINGSCATEGORY_ANALYZER);
setWidgetCreator([] { return new ValgrindConfigWidget(&globalSettings()); });
}
};
const ValgrindOptionsPage settingsPage;
QWidget *createSettingsWidget(ValgrindBaseSettings *settings)
{
return new ValgrindConfigWidget(settings);
}
} // Valgrind::Internal

View File

@@ -1,12 +0,0 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once
#include <coreplugin/dialogs/ioptionspage.h>
namespace Valgrind::Internal {
QWidget *createSettingsWidget(class ValgrindBaseSettings *settings);
} // Valgrind::Internal

View File

@@ -3,7 +3,6 @@
#include "callgrindtool.h"
#include "memchecktool.h"
#include "valgrindconfigwidget.h"
#include "valgrindsettings.h"
#include "valgrindtr.h"

View File

@@ -4,11 +4,14 @@
#include "valgrindsettings.h"
#include "callgrindcostdelegate.h"
#include "valgrindconfigwidget.h"
#include "valgrindtr.h"
#include <coreplugin/icore.h>
#include <coreplugin/dialogs/ioptionspage.h>
#include <debugger/analyzer/analyzericons.h>
#include <debugger/debuggertr.h>
#include <utils/algorithm.h>
#include <utils/layoutbuilder.h>
#include <utils/qtcassert.h>
@@ -173,6 +176,14 @@ void SuppressionAspect::bufferToGui()
d->m_model.appendRow(new QStandardItem(file.toUserOutput()));
}
// ValgrindConfigWidget
QWidget *createSettingsWidget(ValgrindBaseSettings *settings)
{
return settings->layouter()().emerge();
}
//////////////////////////////////////////////////////////////////
//
// ValgrindBaseSettings
@@ -316,6 +327,54 @@ ValgrindBaseSettings::ValgrindBaseSettings(bool global)
for (int i = 0; i < Valgrind::XmlProtocol::MemcheckErrorKindCount; ++i)
defaultErrorKinds << i;
visibleErrorKinds.setDefaultValue(defaultErrorKinds);
setLayouter([this] {
using namespace Layouting;
// clang-format off
Grid generic {
valgrindExecutable, br,
valgrindArguments, br,
selfModifyingCodeDetection, br
};
Grid memcheck {
memcheckArguments, br,
trackOrigins, br,
showReachable, br,
leakCheckOnFinish, br,
numCallers, br,
filterExternalIssues, br,
suppressions
};
Grid callgrind {
callgrindArguments, br,
kcachegrindExecutable, br,
minimumInclusiveCostRatio, br,
visualizationMinimumInclusiveCostRatio, br,
enableEventToolTips, br,
Span {
2,
Group {
Column {
enableCacheSim,
enableBranchSim,
collectSystime,
collectBusEvents,
}
}
}
};
return Column {
Group { title(Tr::tr("Valgrind Generic Settings")), generic },
Group { title(Tr::tr("Memcheck Memory Analysis Options")), memcheck },
Group { title(Tr::tr("Callgrind Profiling Options")), callgrind },
st,
};
// clang-format on
});
}
@@ -356,8 +415,8 @@ ValgrindGlobalSettings::ValgrindGlobalSettings()
shortenTemplates.setToolTip(Tr::tr("Remove template parameter lists when displaying function names."));
setConfigWidgetCreator([this] { return createSettingsWidget(this); });
readSettings();
readSettings();
setAutoApply(false);
}
@@ -424,4 +483,25 @@ ValgrindProjectSettings::ValgrindProjectSettings()
});
}
//
// ValgrindOptionsPage
//
class ValgrindOptionsPage final : public Core::IOptionsPage
{
public:
ValgrindOptionsPage()
{
setId(ANALYZER_VALGRIND_SETTINGS);
setDisplayName(Tr::tr("Valgrind"));
setCategory("T.Analyzer");
setDisplayCategory(::Debugger::Tr::tr("Analyzer"));
setCategoryIconPath(Analyzer::Icons::SETTINGSCATEGORY_ANALYZER);
setSettingsProvider([] { return &globalSettings(); });
}
};
const ValgrindOptionsPage settingsPage;
} // Valgrind::Internal

View File

@@ -100,7 +100,6 @@ public:
QVariantMap defaultSettings() const;
};
/**
* Global valgrind settings
*/