QmlProfiler: Merge qmlprofileractions into qmlprofilertool

Change-Id: I9e43964de230ccb9549c976953d734eb355f667a
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2023-09-01 13:21:57 +02:00
parent f2a93943f5
commit c2a69683cf
6 changed files with 68 additions and 135 deletions

View File

@@ -38,8 +38,7 @@ set(QMLPROFILER_CPP_SOURCES
qmleventtype.cpp qmleventtype.h
qmlnote.cpp qmlnote.h
qmlprofiler_global.h
qmlprofilertr.h
qmlprofileractions.cpp qmlprofileractions.h
qmlprofilertr.h
qmlprofileranimationsmodel.cpp qmlprofileranimationsmodel.h
qmlprofilerattachdialog.cpp qmlprofilerattachdialog.h
qmlprofilerbindingloopsrenderpass.cpp qmlprofilerbindingloopsrenderpass.h

View File

@@ -30,7 +30,6 @@ QtcPlugin {
"qmleventtype.cpp", "qmleventtype.h",
"qmlnote.cpp", "qmlnote.h",
"qmlprofiler_global.h", "qmlprofilertr.h",
"qmlprofileractions.h", "qmlprofileractions.cpp",
"qmlprofileranimationsmodel.h", "qmlprofileranimationsmodel.cpp",
"qmlprofilerattachdialog.cpp", "qmlprofilerattachdialog.h",
"qmlprofilerbindingloopsrenderpass.cpp","qmlprofilerbindingloopsrenderpass.h",

View File

@@ -1,92 +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 "qmlprofileractions.h"
#include "qmlprofilerconstants.h"
#include "qmlprofilermodelmanager.h"
#include "qmlprofilerstatemanager.h"
#include "qmlprofilertool.h"
#include "qmlprofilertr.h"
#include <debugger/analyzer/analyzerconstants.h>
#include <coreplugin/actionmanager/actionmanager.h>
#include <coreplugin/actionmanager/command.h>
#include <QMenu>
namespace QmlProfiler {
namespace Internal {
using namespace Core;
using namespace Debugger::Constants;
QmlProfilerActions::QmlProfilerActions(QObject *parent) : QObject(parent)
{}
void QmlProfilerActions::attachToTool(QmlProfilerTool *tool)
{
const QString description = Tr::tr("The QML Profiler can be used to find performance "
"bottlenecks in applications using QML.");
m_runAction = std::make_unique<QAction>(Tr::tr("QML Profiler"));
m_runAction->setToolTip(description);
QObject::connect(m_runAction.get(), &QAction::triggered,
tool, &QmlProfilerTool::profileStartupProject);
QAction *toolStartAction = tool->startAction();
QObject::connect(toolStartAction, &QAction::changed, this, [this, toolStartAction] {
m_runAction->setEnabled(toolStartAction->isEnabled());
});
m_attachAction = std::make_unique<QAction>(Tr::tr("QML Profiler (Attach to Waiting Application)"));
m_attachAction->setToolTip(description);
QObject::connect(m_attachAction.get(), &QAction::triggered,
tool, &QmlProfilerTool::attachToWaitingApplication);
m_loadQmlTrace = std::make_unique<QAction>(Tr::tr("Load QML Trace"));
connect(m_loadQmlTrace.get(), &QAction::triggered,
tool, &QmlProfilerTool::showLoadDialog, Qt::QueuedConnection);
m_saveQmlTrace = std::make_unique<QAction>(Tr::tr("Save QML Trace"));
connect(m_saveQmlTrace.get(), &QAction::triggered,
tool, &QmlProfilerTool::showSaveDialog, Qt::QueuedConnection);
QmlProfilerStateManager *stateManager = tool->stateManager();
connect(stateManager, &QmlProfilerStateManager::serverRecordingChanged,
this, [this](bool recording) {
m_loadQmlTrace->setEnabled(!recording);
});
m_loadQmlTrace->setEnabled(!stateManager->serverRecording());
QmlProfilerModelManager *modelManager = tool->modelManager();
connect(modelManager, &QmlProfilerModelManager::traceChanged,
this, [this, modelManager] {
m_saveQmlTrace->setEnabled(!modelManager->isEmpty());
});
m_saveQmlTrace->setEnabled(!modelManager->isEmpty());
}
void QmlProfilerActions::registerActions()
{
m_options.reset(ActionManager::createMenu("Analyzer.Menu.QMLOptions"));
m_options->menu()->setTitle(Tr::tr("QML Profiler Options"));
m_options->menu()->setEnabled(true);
ActionContainer *menu = ActionManager::actionContainer(M_DEBUG_ANALYZER);
menu->addAction(ActionManager::registerAction(m_runAction.get(),
"QmlProfiler.Internal"),
Debugger::Constants::G_ANALYZER_TOOLS);
menu->addAction(ActionManager::registerAction(m_attachAction.get(),
"QmlProfiler.AttachToWaitingApplication"),
Debugger::Constants::G_ANALYZER_REMOTE_TOOLS);
menu->addMenu(m_options.get(), G_ANALYZER_OPTIONS);
m_options->addAction(ActionManager::registerAction(m_loadQmlTrace.get(),
Constants::QmlProfilerLoadActionId));
m_options->addAction(ActionManager::registerAction(m_saveQmlTrace.get(),
Constants::QmlProfilerSaveActionId));
}
} // namespace Internal
} // namespace QmlProfiler

View File

@@ -1,35 +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/actionmanager/actioncontainer.h>
#include <QObject>
#include <QAction>
#include <memory>
namespace QmlProfiler {
namespace Internal {
class QmlProfilerTool;
class QmlProfilerActions : public QObject
{
Q_OBJECT
public:
explicit QmlProfilerActions(QObject *parent = nullptr);
void attachToTool(QmlProfilerTool *tool);
void registerActions();
private:
std::unique_ptr<Core::ActionContainer> m_options;
std::unique_ptr<QAction> m_loadQmlTrace;
std::unique_ptr<QAction> m_saveQmlTrace;
std::unique_ptr<QAction> m_runAction;
std::unique_ptr<QAction> m_attachAction;
};
} // namespace Internal
} // namespace QmlProfiler

View File

@@ -6,7 +6,6 @@
#include "qmlprofilerruncontrol.h"
#include "qmlprofilersettings.h"
#include "qmlprofilertool.h"
#include "qmlprofileractions.h"
#ifdef WITH_TESTS
@@ -57,7 +56,6 @@ class QmlProfilerPluginPrivate
{
public:
QmlProfilerTool m_profilerTool;
QmlProfilerActions m_actions;
// The full local profiler.
LocalQmlProfilerRunWorkerFactory localQmlProfilerRunWorkerFactory;
@@ -99,8 +97,6 @@ bool QmlProfilerPlugin::initialize(const QStringList &arguments, QString *errorS
void QmlProfilerPlugin::extensionsInitialized()
{
d = new QmlProfilerPluginPrivate;
d->m_actions.attachToTool(&d->m_profilerTool);
d->m_actions.registerActions();
RunConfiguration::registerAspect<QmlProfilerRunConfigurationAspect>();
}

View File

@@ -1,6 +1,8 @@
// 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 "qmlprofilertool.h"
#include "qmlprofilerattachdialog.h"
#include "qmlprofilerclientmanager.h"
#include "qmlprofilerconstants.h"
@@ -11,11 +13,11 @@
#include "qmlprofilersettings.h"
#include "qmlprofilerstatemanager.h"
#include "qmlprofilertextmark.h"
#include "qmlprofilertool.h"
#include "qmlprofilertr.h"
#include "qmlprofilerviewmanager.h"
#include <coreplugin/actionmanager/command.h>
#include <coreplugin/actionmanager/actioncontainer.h>
#include <coreplugin/actionmanager/actionmanager.h>
#include <coreplugin/coreconstants.h>
#include <coreplugin/editormanager/editormanager.h>
@@ -27,6 +29,7 @@
#include <coreplugin/modemanager.h>
#include <coreplugin/progressmanager/progressmanager.h>
#include <debugger/analyzer/analyzerconstants.h>
#include <debugger/analyzer/analyzermanager.h>
#include <debugger/debuggericons.h>
#include <debugger/debuggermainwindow.h>
@@ -105,6 +108,12 @@ public:
QElapsedTimer m_recordingElapsedTime;
bool m_toolBusy = false;
std::unique_ptr<Core::ActionContainer> m_options;
std::unique_ptr<QAction> m_loadQmlTrace;
std::unique_ptr<QAction> m_saveQmlTrace;
std::unique_ptr<QAction> m_runAction;
std::unique_ptr<QAction> m_attachAction;
};
QmlProfilerTool::QmlProfilerTool()
@@ -255,6 +264,63 @@ QmlProfilerTool::QmlProfilerTool()
connect(d->m_profilerState, &QmlProfilerStateManager::clientRecordingChanged,
d->m_recordButton, updateRecordButton);
updateRecordButton();
const QString description = Tr::tr("The QML Profiler can be used to find performance "
"bottlenecks in applications using QML.");
d->m_runAction = std::make_unique<QAction>(Tr::tr("QML Profiler"));
d->m_runAction->setToolTip(description);
QObject::connect(d->m_runAction.get(), &QAction::triggered,
this, &QmlProfilerTool::profileStartupProject);
QAction *toolStartAction = startAction();
QObject::connect(toolStartAction, &QAction::changed, this, [this, toolStartAction] {
d->m_runAction->setEnabled(toolStartAction->isEnabled());
});
d->m_attachAction = std::make_unique<QAction>(Tr::tr("QML Profiler (Attach to Waiting Application)"));
d->m_attachAction->setToolTip(description);
QObject::connect(d->m_attachAction.get(), &QAction::triggered,
this, &QmlProfilerTool::attachToWaitingApplication);
d->m_loadQmlTrace = std::make_unique<QAction>(Tr::tr("Load QML Trace"));
connect(d->m_loadQmlTrace.get(), &QAction::triggered,
this, &QmlProfilerTool::showLoadDialog, Qt::QueuedConnection);
d->m_saveQmlTrace = std::make_unique<QAction>(Tr::tr("Save QML Trace"));
connect(d->m_saveQmlTrace.get(), &QAction::triggered,
this, &QmlProfilerTool::showSaveDialog, Qt::QueuedConnection);
connect(d->m_profilerState, &QmlProfilerStateManager::serverRecordingChanged,
this, [this](bool recording) {
d->m_loadQmlTrace->setEnabled(!recording);
});
d->m_loadQmlTrace->setEnabled(!d->m_profilerState->serverRecording());
connect(d->m_profilerModelManager, &QmlProfilerModelManager::traceChanged,
this, [this] {
d->m_saveQmlTrace->setEnabled(!d->m_profilerModelManager->isEmpty());
});
d->m_saveQmlTrace->setEnabled(!d->m_profilerModelManager->isEmpty());
d->m_options.reset(ActionManager::createMenu("Analyzer.Menu.QMLOptions"));
d->m_options->menu()->setTitle(Tr::tr("QML Profiler Options"));
d->m_options->menu()->setEnabled(true);
ActionContainer *menu = ActionManager::actionContainer(M_DEBUG_ANALYZER);
menu->addAction(ActionManager::registerAction(d->m_runAction.get(),
"QmlProfiler.Internal"),
Debugger::Constants::G_ANALYZER_TOOLS);
menu->addAction(ActionManager::registerAction(d->m_attachAction.get(),
"QmlProfiler.AttachToWaitingApplication"),
Debugger::Constants::G_ANALYZER_REMOTE_TOOLS);
menu->addMenu(d->m_options.get(), G_ANALYZER_OPTIONS);
d->m_options->addAction(ActionManager::registerAction(d->m_loadQmlTrace.get(),
Constants::QmlProfilerLoadActionId));
d->m_options->addAction(ActionManager::registerAction(d->m_saveQmlTrace.get(),
Constants::QmlProfilerSaveActionId));
}
QmlProfilerTool::~QmlProfilerTool()