From c2a69683cf3728f1fd9468dd8e036670b8713162 Mon Sep 17 00:00:00 2001 From: hjk Date: Fri, 1 Sep 2023 13:21:57 +0200 Subject: [PATCH] QmlProfiler: Merge qmlprofileractions into qmlprofilertool Change-Id: I9e43964de230ccb9549c976953d734eb355f667a Reviewed-by: Christian Stenger --- src/plugins/qmlprofiler/CMakeLists.txt | 3 +- src/plugins/qmlprofiler/qmlprofiler.qbs | 1 - .../qmlprofiler/qmlprofileractions.cpp | 92 ------------------- src/plugins/qmlprofiler/qmlprofileractions.h | 35 ------- src/plugins/qmlprofiler/qmlprofilerplugin.cpp | 4 - src/plugins/qmlprofiler/qmlprofilertool.cpp | 68 +++++++++++++- 6 files changed, 68 insertions(+), 135 deletions(-) delete mode 100644 src/plugins/qmlprofiler/qmlprofileractions.cpp delete mode 100644 src/plugins/qmlprofiler/qmlprofileractions.h diff --git a/src/plugins/qmlprofiler/CMakeLists.txt b/src/plugins/qmlprofiler/CMakeLists.txt index ddf4ae63b05..a94dfce931a 100644 --- a/src/plugins/qmlprofiler/CMakeLists.txt +++ b/src/plugins/qmlprofiler/CMakeLists.txt @@ -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 diff --git a/src/plugins/qmlprofiler/qmlprofiler.qbs b/src/plugins/qmlprofiler/qmlprofiler.qbs index 359a9eb1cf2..4ed25d1bca0 100644 --- a/src/plugins/qmlprofiler/qmlprofiler.qbs +++ b/src/plugins/qmlprofiler/qmlprofiler.qbs @@ -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", diff --git a/src/plugins/qmlprofiler/qmlprofileractions.cpp b/src/plugins/qmlprofiler/qmlprofileractions.cpp deleted file mode 100644 index 55f5a4edeca..00000000000 --- a/src/plugins/qmlprofiler/qmlprofileractions.cpp +++ /dev/null @@ -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 - -#include -#include - -#include - -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(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(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(Tr::tr("Load QML Trace")); - connect(m_loadQmlTrace.get(), &QAction::triggered, - tool, &QmlProfilerTool::showLoadDialog, Qt::QueuedConnection); - - m_saveQmlTrace = std::make_unique(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 diff --git a/src/plugins/qmlprofiler/qmlprofileractions.h b/src/plugins/qmlprofiler/qmlprofileractions.h deleted file mode 100644 index 95a884513f1..00000000000 --- a/src/plugins/qmlprofiler/qmlprofileractions.h +++ /dev/null @@ -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 - -#include -#include - -#include - -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 m_options; - std::unique_ptr m_loadQmlTrace; - std::unique_ptr m_saveQmlTrace; - std::unique_ptr m_runAction; - std::unique_ptr m_attachAction; -}; - -} // namespace Internal -} // namespace QmlProfiler diff --git a/src/plugins/qmlprofiler/qmlprofilerplugin.cpp b/src/plugins/qmlprofiler/qmlprofilerplugin.cpp index d1f6ef58996..c60d8f15e6f 100644 --- a/src/plugins/qmlprofiler/qmlprofilerplugin.cpp +++ b/src/plugins/qmlprofiler/qmlprofilerplugin.cpp @@ -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(); } diff --git a/src/plugins/qmlprofiler/qmlprofilertool.cpp b/src/plugins/qmlprofiler/qmlprofilertool.cpp index f6de08d2de2..ecb064c851f 100644 --- a/src/plugins/qmlprofiler/qmlprofilertool.cpp +++ b/src/plugins/qmlprofiler/qmlprofilertool.cpp @@ -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 +#include #include #include #include @@ -27,6 +29,7 @@ #include #include +#include #include #include #include @@ -105,6 +108,12 @@ public: QElapsedTimer m_recordingElapsedTime; bool m_toolBusy = false; + + std::unique_ptr m_options; + std::unique_ptr m_loadQmlTrace; + std::unique_ptr m_saveQmlTrace; + std::unique_ptr m_runAction; + std::unique_ptr 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(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(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(Tr::tr("Load QML Trace")); + connect(d->m_loadQmlTrace.get(), &QAction::triggered, + this, &QmlProfilerTool::showLoadDialog, Qt::QueuedConnection); + + d->m_saveQmlTrace = std::make_unique(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()