2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2018 The Qt Company Ltd.
|
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
2018-05-28 16:21:03 +02:00
|
|
|
|
|
|
|
|
#include "qmlprofileractions.h"
|
|
|
|
|
#include "qmlprofilerconstants.h"
|
|
|
|
|
#include "qmlprofilermodelmanager.h"
|
2022-08-30 20:37:31 +02:00
|
|
|
#include "qmlprofilerstatemanager.h"
|
|
|
|
|
#include "qmlprofilertool.h"
|
|
|
|
|
#include "qmlprofilertr.h"
|
2018-05-28 16:21:03 +02:00
|
|
|
|
|
|
|
|
#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)
|
|
|
|
|
{
|
2022-08-30 20:37:31 +02:00
|
|
|
const QString description = Tr::tr("The QML Profiler can be used to find performance "
|
|
|
|
|
"bottlenecks in applications using QML.");
|
2018-05-28 16:21:03 +02:00
|
|
|
|
2022-08-30 20:37:31 +02:00
|
|
|
m_runAction = std::make_unique<QAction>(Tr::tr("QML Profiler"));
|
2018-05-28 16:21:03 +02:00
|
|
|
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());
|
|
|
|
|
});
|
|
|
|
|
|
2022-08-30 20:37:31 +02:00
|
|
|
m_attachAction = std::make_unique<QAction>(Tr::tr("QML Profiler (Attach to Waiting Application)"));
|
2018-05-28 16:21:03 +02:00
|
|
|
m_attachAction->setToolTip(description);
|
|
|
|
|
QObject::connect(m_attachAction.get(), &QAction::triggered,
|
|
|
|
|
tool, &QmlProfilerTool::attachToWaitingApplication);
|
|
|
|
|
|
2022-08-30 20:37:31 +02:00
|
|
|
m_loadQmlTrace = std::make_unique<QAction>(Tr::tr("Load QML Trace"));
|
2018-05-28 16:21:03 +02:00
|
|
|
connect(m_loadQmlTrace.get(), &QAction::triggered,
|
|
|
|
|
tool, &QmlProfilerTool::showLoadDialog, Qt::QueuedConnection);
|
|
|
|
|
|
2022-08-30 20:37:31 +02:00
|
|
|
m_saveQmlTrace = std::make_unique<QAction>(Tr::tr("Save QML Trace"));
|
2018-05-28 16:21:03 +02:00
|
|
|
connect(m_saveQmlTrace.get(), &QAction::triggered,
|
|
|
|
|
tool, &QmlProfilerTool::showSaveDialog, Qt::QueuedConnection);
|
|
|
|
|
|
|
|
|
|
QmlProfilerStateManager *stateManager = tool->stateManager();
|
|
|
|
|
connect(stateManager, &QmlProfilerStateManager::serverRecordingChanged,
|
2020-04-23 16:33:55 +02:00
|
|
|
this, [this](bool recording) {
|
2018-05-28 16:21:03 +02:00
|
|
|
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"));
|
2022-08-30 20:37:31 +02:00
|
|
|
m_options->menu()->setTitle(Tr::tr("QML Profiler Options"));
|
2018-05-28 16:21:03 +02:00
|
|
|
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
|