forked from qt-creator/qt-creator
PerfProfiler: Move towards the canonical plugin setup pattern
Change-Id: I5d2f468c35c154664550175aefd21307b8107bba Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -33,7 +33,7 @@
|
||||
namespace PerfProfiler {
|
||||
namespace Internal {
|
||||
|
||||
PerfOptionsPage::PerfOptionsPage(QObject *parent) : Core::IOptionsPage(parent)
|
||||
PerfOptionsPage::PerfOptionsPage()
|
||||
{
|
||||
setId(Constants::PerfSettingsId);
|
||||
setDisplayName(QCoreApplication::translate("PerfProfiler::PerfOptionsPage", "CPU Usage"));
|
||||
|
@@ -36,7 +36,7 @@ class PerfOptionsPage : public Core::IOptionsPage
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
PerfOptionsPage(QObject *parent = nullptr);
|
||||
PerfOptionsPage();
|
||||
|
||||
QWidget *widget();
|
||||
void apply();
|
||||
|
@@ -52,32 +52,44 @@
|
||||
#include <QAction>
|
||||
#include <QDebug>
|
||||
#include <QMenu>
|
||||
#include <QtPlugin>
|
||||
|
||||
using namespace ProjectExplorer;
|
||||
|
||||
namespace PerfProfiler {
|
||||
namespace Internal {
|
||||
|
||||
Q_GLOBAL_STATIC(PerfSettings, perfGlobalSettings)
|
||||
|
||||
class PerfProfilerPluginPrivate
|
||||
{
|
||||
public:
|
||||
PerfProfilerPluginPrivate()
|
||||
{
|
||||
RunConfiguration::registerAspect<PerfRunConfigurationAspect>();
|
||||
|
||||
RunControl::registerWorkerCreator(ProjectExplorer::Constants::PERFPROFILER_RUN_MODE,
|
||||
[](RunControl *runControl){ return new PerfProfilerRunner(runControl); });
|
||||
|
||||
auto constraint = [](RunConfiguration *) { return true; };
|
||||
RunControl::registerWorker<PerfProfilerRunner>
|
||||
(ProjectExplorer::Constants::PERFPROFILER_RUN_MODE, constraint);
|
||||
}
|
||||
|
||||
PerfOptionsPage optionsPage;
|
||||
PerfProfilerTool profilerTool;
|
||||
};
|
||||
|
||||
PerfProfilerPlugin::~PerfProfilerPlugin()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
bool PerfProfilerPlugin::initialize(const QStringList &arguments, QString *errorString)
|
||||
{
|
||||
Q_UNUSED(arguments)
|
||||
Q_UNUSED(errorString)
|
||||
|
||||
(void) new Internal::PerfOptionsPage(this);
|
||||
|
||||
RunConfiguration::registerAspect<PerfRunConfigurationAspect>();
|
||||
|
||||
(void) new Internal::PerfProfilerTool(this);
|
||||
|
||||
RunControl::registerWorkerCreator(ProjectExplorer::Constants::PERFPROFILER_RUN_MODE,
|
||||
[](RunControl *runControl){ return new Internal::PerfProfilerRunner(runControl); });
|
||||
|
||||
auto constraint = [](RunConfiguration *) { return true; };
|
||||
RunControl::registerWorker<Internal::PerfProfilerRunner>
|
||||
(ProjectExplorer::Constants::PERFPROFILER_RUN_MODE, constraint);
|
||||
|
||||
d = new PerfProfilerPluginPrivate;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -85,19 +97,20 @@ void PerfProfilerPlugin::extensionsInitialized()
|
||||
{
|
||||
}
|
||||
|
||||
PerfProfiler::PerfSettings *PerfProfilerPlugin::globalSettings()
|
||||
PerfSettings *PerfProfilerPlugin::globalSettings()
|
||||
{
|
||||
return perfGlobalSettings();
|
||||
}
|
||||
|
||||
QList<QObject *> PerfProfiler::PerfProfilerPlugin::createTestObjects() const
|
||||
QList<QObject *> PerfProfilerPlugin::createTestObjects() const
|
||||
{
|
||||
QList<QObject *> tests;
|
||||
#if WITH_TESTS
|
||||
tests << new Internal::PerfProfilerTraceFileTest;
|
||||
tests << new Internal::PerfResourceCounterTest;
|
||||
tests << new PerfProfilerTraceFileTest;
|
||||
tests << new PerfResourceCounterTest;
|
||||
#endif // WITH_TESTS
|
||||
return tests;
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace PerfProfiler
|
||||
|
@@ -30,6 +30,7 @@
|
||||
#include <extensionsystem/iplugin.h>
|
||||
|
||||
namespace PerfProfiler {
|
||||
namespace Internal {
|
||||
|
||||
class PerfProfilerPlugin : public ExtensionSystem::IPlugin
|
||||
{
|
||||
@@ -37,11 +38,16 @@ class PerfProfilerPlugin : public ExtensionSystem::IPlugin
|
||||
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "PerfProfiler.json")
|
||||
|
||||
public:
|
||||
~PerfProfilerPlugin();
|
||||
|
||||
bool initialize(const QStringList &arguments, QString *errorString) final;
|
||||
void extensionsInitialized() final;
|
||||
QList<QObject *> createTestObjects() const final;
|
||||
|
||||
static PerfSettings *globalSettings();
|
||||
|
||||
class PerfProfilerPluginPrivate *d = nullptr;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace PerfProfiler
|
||||
|
@@ -69,8 +69,7 @@ namespace Internal {
|
||||
|
||||
static PerfProfilerTool *s_instance;
|
||||
|
||||
PerfProfilerTool::PerfProfilerTool(QObject *parent) :
|
||||
QObject(parent)
|
||||
PerfProfilerTool::PerfProfilerTool()
|
||||
{
|
||||
s_instance = this;
|
||||
m_traceManager = new PerfProfilerTraceManager(this);
|
||||
|
@@ -48,7 +48,7 @@ class PerfProfilerTool : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
PerfProfilerTool(QObject *parent = nullptr);
|
||||
PerfProfilerTool();
|
||||
static PerfProfilerTool *instance();
|
||||
|
||||
PerfProfilerTraceManager *traceManager() const;
|
||||
|
@@ -35,7 +35,7 @@ namespace PerfProfiler {
|
||||
PerfRunConfigurationAspect::PerfRunConfigurationAspect(ProjectExplorer::Target *target)
|
||||
{
|
||||
setProjectSettings(new PerfSettings(target));
|
||||
setGlobalSettings(PerfProfilerPlugin::globalSettings());
|
||||
setGlobalSettings(Internal::PerfProfilerPlugin::globalSettings());
|
||||
setId(Constants::PerfSettingsId);
|
||||
setDisplayName(QCoreApplication::translate("PerfProfiler::PerfRunConfigurationAspect",
|
||||
"Performance Analyzer Settings"));
|
||||
|
Reference in New Issue
Block a user