PerfProfiler: Convert to current settings scheme

Change-Id: I33e667a1cd9515f17af1bf9b2af6171b083c79de
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2023-07-20 09:36:41 +02:00
parent 45aa708e89
commit 678e8d3137
10 changed files with 42 additions and 69 deletions

View File

@@ -15,7 +15,6 @@ set(PERFPROFILER_CPP_SOURCES
perfevent.h
perfeventtype.h
perfloaddialog.cpp perfloaddialog.h
perfoptionspage.cpp perfoptionspage.h
perfprofiler.qrc
perfprofilerconstants.h
perfprofilerflamegraphmodel.cpp perfprofilerflamegraphmodel.h

View File

@@ -1,26 +0,0 @@
// Copyright (C) 2018 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "perfconfigwidget.h"
#include "perfoptionspage.h"
#include "perfprofilerconstants.h"
#include "perfprofilertr.h"
#include <debugger/analyzer/analyzericons.h>
#include <debugger/debuggertr.h>
namespace PerfProfiler {
namespace Internal {
PerfOptionsPage::PerfOptionsPage(PerfSettings *settings)
{
setId(Constants::PerfSettingsId);
setDisplayName(Tr::tr("CPU Usage"));
setCategory("T.Analyzer");
setDisplayCategory(::Debugger::Tr::tr("Analyzer"));
setCategoryIconPath(Analyzer::Icons::SETTINGSCATEGORY_ANALYZER);
setWidgetCreator([settings] { return new PerfConfigWidget(settings); });
}
} // namespace Internal
} // namespace PerfProfiler

View File

@@ -1,21 +0,0 @@
// Copyright (C) 2018 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 PerfProfiler {
class PerfSettings;
namespace Internal {
class PerfOptionsPage final : public Core::IOptionsPage
{
public:
explicit PerfOptionsPage(PerfSettings *settings);
};
} // namespace Internal
} // namespace PerfProfiler

View File

@@ -26,8 +26,6 @@ QtcPlugin {
"perfeventtype.h",
"perfloaddialog.cpp",
"perfloaddialog.h",
"perfoptionspage.cpp",
"perfoptionspage.h",
"perfprofiler_global.h", "perfprofilertr.h",
"perfprofilerconstants.h",
"perfprofilerplugin.cpp",

View File

@@ -1,8 +1,8 @@
// Copyright (C) 2018 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "perfoptionspage.h"
#include "perfprofilerplugin.h"
#include "perfprofilerruncontrol.h"
#include "perfprofilertool.h"
#include "perfrunconfigurationaspect.h"
@@ -17,8 +17,6 @@ using namespace ProjectExplorer;
namespace PerfProfiler::Internal {
Q_GLOBAL_STATIC(PerfSettings, perfGlobalSettings)
class PerfProfilerPluginPrivate
{
public:
@@ -28,7 +26,6 @@ public:
}
PerfProfilerRunWorkerFactory profilerWorkerFactory;
PerfOptionsPage optionsPage{perfGlobalSettings()};
PerfProfilerTool profilerTool;
};
@@ -47,9 +44,4 @@ void PerfProfilerPlugin::initialize()
#endif // WITH_TESTS
}
PerfSettings *PerfProfilerPlugin::globalSettings()
{
return perfGlobalSettings();
}
} // PerfProfiler::Internal

View File

@@ -3,8 +3,6 @@
#pragma once
#include "perfsettings.h"
#include <extensionsystem/iplugin.h>
namespace PerfProfiler::Internal {
@@ -19,8 +17,6 @@ public:
void initialize() final;
static PerfSettings *globalSettings();
class PerfProfilerPluginPrivate *d = nullptr;
};

View File

@@ -237,7 +237,7 @@ void PerfProfilerTool::createViews()
}
PerfConfigWidget *widget = new PerfConfigWidget(
settings ? settings : PerfProfilerPlugin::globalSettings(),
settings ? settings : &globalSettings(),
Core::ICore::dialogParent());
widget->setTracePointsButtonVisible(true);
widget->setTarget(target);

View File

@@ -14,7 +14,7 @@ namespace PerfProfiler {
PerfRunConfigurationAspect::PerfRunConfigurationAspect(ProjectExplorer::Target *target)
{
setProjectSettings(new PerfSettings(target));
setGlobalSettings(Internal::PerfProfilerPlugin::globalSettings());
setGlobalSettings(&PerfProfiler::globalSettings());
setId(Constants::PerfSettingsId);
setDisplayName(Tr::tr("Performance Analyzer Settings"));
setUsingGlobalSettings(true);

View File

@@ -6,16 +6,25 @@
#include "perfprofilertr.h"
#include "perfsettings.h"
#include <coreplugin/dialogs/ioptionspage.h>
#include <coreplugin/icore.h>
#include <QSettings>
#include <debugger/analyzer/analyzericons.h>
#include <debugger/debuggertr.h>
#include <utils/layoutbuilder.h>
#include <utils/process.h>
using namespace Utils;
namespace PerfProfiler {
PerfSettings &globalSettings()
{
static PerfSettings theSettings(nullptr);
return theSettings;
}
PerfSettings::PerfSettings(ProjectExplorer::Target *target)
{
setConfigWidgetCreator([this, target] {
@@ -62,6 +71,14 @@ PerfSettings::PerfSettings(ProjectExplorer::Target *target)
stackSize.setEnabled(callgraphMode.volatileValue() == 0);
});
setLayouter([this] {
using namespace Layouting;
return Column {
createConfigWidget()
};
});
readSettings();
readGlobalSettings();
}
@@ -125,4 +142,22 @@ void PerfSettings::resetToDefault()
fromMap(map);
}
// PerfSettingsPage
class PerfSettingsPage final : public Core::IOptionsPage
{
public:
PerfSettingsPage()
{
setId(Constants::PerfSettingsId);
setDisplayName(Tr::tr("CPU Usage"));
setCategory("T.Analyzer");
setDisplayCategory(::Debugger::Tr::tr("Analyzer"));
setCategoryIconPath(Analyzer::Icons::SETTINGSCATEGORY_ANALYZER);
setSettingsProvider([] { return &globalSettings(); });
}
};
const PerfSettingsPage settingsPage;
} // namespace PerfProfiler

View File

@@ -7,8 +7,6 @@
#include <projectexplorer/runconfiguration.h>
#include <QObject>
namespace PerfProfiler {
class PERFPROFILER_EXPORT PerfSettings final : public ProjectExplorer::ISettingsAspect
@@ -34,4 +32,6 @@ public:
Utils::StringAspect extraArguments{this};
};
PerfSettings &globalSettings();
} // namespace PerfProfiler