aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/perfprofiler
diff options
context:
space:
mode:
authorAlessandro Portale <alessandro.portale@qt.io>2021-06-24 23:17:09 +0200
committerAlessandro Portale <alessandro.portale@qt.io>2021-06-28 15:06:50 +0000
commitbb8aa12cbc29e0c3f78d793e7666987691182f77 (patch)
treef6a661d5cca18456f0e5da615d2edc8ea0178552 /src/plugins/perfprofiler
parent9624d2cd6924d9053140e1c60e0137b3bb76c414 (diff)
PerfProfiler: Add qml, register types via qt_add_qml_module
Use the CMake-based qml API to create the "QtCreator.PerfProfiler" module. This uses qt_add_qml_module, which was introduced with Qt 6.2. For Qt 6.1 and below, everything compiles and runs like before this change. Change-Id: I7e3a9e544e52592b5daf0117ce415583ab97dafe Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'src/plugins/perfprofiler')
-rw-r--r--src/plugins/perfprofiler/CMakeLists.txt98
-rw-r--r--src/plugins/perfprofiler/PerfProfilerFlameGraphView.qml2
-rw-r--r--src/plugins/perfprofiler/perfprofiler.qrc4
-rw-r--r--src/plugins/perfprofiler/perfprofilerflamegraphmodel.h5
-rw-r--r--src/plugins/perfprofiler/perfprofilerflamegraphview.cpp4
5 files changed, 74 insertions, 39 deletions
diff --git a/src/plugins/perfprofiler/CMakeLists.txt b/src/plugins/perfprofiler/CMakeLists.txt
index b7644fb3fc3..3c0ce3e434a 100644
--- a/src/plugins/perfprofiler/CMakeLists.txt
+++ b/src/plugins/perfprofiler/CMakeLists.txt
@@ -1,41 +1,69 @@
+if(WITH_TESTS)
+ set(TEST_SOURCES
+ tests/perfprofilertracefile_test.cpp tests/perfprofilertracefile_test.h
+ tests/perfresourcecounter_test.cpp tests/perfresourcecounter_test.h
+ tests/tests.qrc
+ )
+else()
+ set(TEST_SOURCES "")
+endif()
+
+set(PERFPROFILER_CPP_SOURCES
+ perfconfigeventsmodel.cpp perfconfigeventsmodel.h
+ perfconfigwidget.cpp perfconfigwidget.h
+ perfdatareader.cpp perfdatareader.h
+ perfevent.h
+ perfeventtype.h
+ perfloaddialog.cpp perfloaddialog.h perfloaddialog.ui
+ perfoptionspage.cpp perfoptionspage.h
+ perfprofiler.qrc
+ perfprofilerconstants.h
+ perfprofilerflamegraphmodel.cpp perfprofilerflamegraphmodel.h
+ perfprofilerflamegraphview.cpp perfprofilerflamegraphview.h
+ perfprofilerplugin.cpp perfprofilerplugin.h
+ perfprofilerruncontrol.cpp perfprofilerruncontrol.h
+ perfprofilerstatisticsmodel.cpp perfprofilerstatisticsmodel.h
+ perfprofilerstatisticsview.cpp perfprofilerstatisticsview.h
+ perfprofilertool.cpp perfprofilertool.h
+ perfprofilertracefile.cpp perfprofilertracefile.h
+ perfprofilertracemanager.cpp perfprofilertracemanager.h
+ perfprofilertraceview.cpp perfprofilertraceview.h
+ perfprofiler_global.h
+ perfresourcecounter.cpp perfresourcecounter.h
+ perfrunconfigurationaspect.cpp perfrunconfigurationaspect.h
+ perfsettings.cpp perfsettings.h
+ perftimelinemodel.cpp perftimelinemodel.h
+ perftimelinemodelmanager.cpp perftimelinemodelmanager.h
+ perftimelineresourcesrenderpass.cpp perftimelineresourcesrenderpass.h
+ perftracepointdialog.cpp perftracepointdialog.h perftracepointdialog.ui
+)
+
add_qtc_plugin(PerfProfiler
- CONDITION TARGET Tracing
DEPENDS Tracing Qt5::QuickWidgets
PLUGIN_DEPENDS Core Debugger ProjectExplorer QtSupport
SOURCES
- perfconfigeventsmodel.cpp perfconfigeventsmodel.h
- perfconfigwidget.cpp perfconfigwidget.h
- perfdatareader.cpp perfdatareader.h
- perfevent.h
- perfeventtype.h
- perfloaddialog.cpp perfloaddialog.h perfloaddialog.ui
- perfoptionspage.cpp perfoptionspage.h
- perfprofiler.qrc
- perfprofilerconstants.h
- perfprofilerflamegraphmodel.cpp perfprofilerflamegraphmodel.h
- perfprofilerflamegraphview.cpp perfprofilerflamegraphview.h
- perfprofilerplugin.cpp perfprofilerplugin.h
- perfprofilerruncontrol.cpp perfprofilerruncontrol.h
- perfprofilerstatisticsmodel.cpp perfprofilerstatisticsmodel.h
- perfprofilerstatisticsview.cpp perfprofilerstatisticsview.h
- perfprofilertool.cpp perfprofilertool.h
- perfprofilertracefile.cpp perfprofilertracefile.h
- perfprofilertracemanager.cpp perfprofilertracemanager.h
- perfprofilertraceview.cpp perfprofilertraceview.h
- perfprofiler_global.h
- perfresourcecounter.cpp perfresourcecounter.h
- perfrunconfigurationaspect.cpp perfrunconfigurationaspect.h
- perfsettings.cpp perfsettings.h
- perftimelinemodel.cpp perftimelinemodel.h
- perftimelinemodelmanager.cpp perftimelinemodelmanager.h
- perftimelineresourcesrenderpass.cpp perftimelineresourcesrenderpass.h
- perftracepointdialog.cpp perftracepointdialog.h perftracepointdialog.ui
+ ${TEST_SOURCES}
)
-extend_qtc_plugin(PerfProfiler
- CONDITION WITH_TESTS
- SOURCES
- tests/perfprofilertracefile_test.cpp tests/perfprofilertracefile_test.h
- tests/perfresourcecounter_test.cpp tests/perfresourcecounter_test.h
- tests/tests.qrc
-)
+if(${Qt5_VERSION} VERSION_LESS "6.2.0")
+ extend_qtc_plugin(PerfProfiler
+ SOURCES
+ ${PERFPROFILER_CPP_SOURCES}
+ perfprofiler.qrc
+ )
+else() # < Qt 6.2
+ qt_add_resources(PerfProfiler perfprofiler
+ PREFIX "/perfprofiler"
+ tracepoints.sh
+ )
+
+ qt_add_qml_module(PerfProfiler
+ URI "QtCreator.PerfProfiler"
+ VERSION "1.0"
+ NO_CREATE_PLUGIN_TARGET
+ QML_FILES
+ PerfProfilerFlameGraphView.qml
+ SOURCES
+ ${PERFPROFILER_CPP_SOURCES}
+ )
+endif() # < Qt 6.2
diff --git a/src/plugins/perfprofiler/PerfProfilerFlameGraphView.qml b/src/plugins/perfprofiler/PerfProfilerFlameGraphView.qml
index 90bd3b21384..4a3a5ae43b1 100644
--- a/src/plugins/perfprofiler/PerfProfilerFlameGraphView.qml
+++ b/src/plugins/perfprofiler/PerfProfilerFlameGraphView.qml
@@ -24,7 +24,7 @@
****************************************************************************/
import QtCreator.PerfProfiler 1.0
-import "../QtCreator/Tracing/" // TODO: Turn into module import when possible
+import "../Tracing" // TODO: Turn into module import when possible
FlameGraphView {
id: root
diff --git a/src/plugins/perfprofiler/perfprofiler.qrc b/src/plugins/perfprofiler/perfprofiler.qrc
index 05be0370fe1..803828dbb2d 100644
--- a/src/plugins/perfprofiler/perfprofiler.qrc
+++ b/src/plugins/perfprofiler/perfprofiler.qrc
@@ -1,6 +1,8 @@
<RCC>
<qresource prefix="/perfprofiler">
- <file>PerfProfilerFlameGraphView.qml</file>
<file>tracepoints.sh</file>
</qresource>
+ <qresource prefix="/QtCreator/PerfProfiler">
+ <file>PerfProfilerFlameGraphView.qml</file>
+ </qresource>
</RCC>
diff --git a/src/plugins/perfprofiler/perfprofilerflamegraphmodel.h b/src/plugins/perfprofiler/perfprofilerflamegraphmodel.h
index e794f79be79..ec5595ea252 100644
--- a/src/plugins/perfprofiler/perfprofilerflamegraphmodel.h
+++ b/src/plugins/perfprofiler/perfprofilerflamegraphmodel.h
@@ -30,6 +30,7 @@
#include <QAbstractItemModel>
#include <QScopedPointer>
+#include <QtQml/qqml.h>
namespace PerfProfiler {
namespace Internal {
@@ -38,6 +39,10 @@ class PerfProfilerFlameGraphData;
class PerfProfilerFlameGraphModel : public QAbstractItemModel
{
Q_OBJECT
+#if QT_VERSION >= QT_VERSION_CHECK(6, 2, 0)
+ QML_ELEMENT
+ QML_UNCREATABLE("use the context property")
+#endif // Qt >= 6.2
Q_DISABLE_COPY(PerfProfilerFlameGraphModel);
public:
PerfProfilerFlameGraphModel(PerfProfilerFlameGraphModel &&) = delete;
diff --git a/src/plugins/perfprofiler/perfprofilerflamegraphview.cpp b/src/plugins/perfprofiler/perfprofilerflamegraphview.cpp
index c6f00f1ef4b..d7082bd8b0a 100644
--- a/src/plugins/perfprofiler/perfprofilerflamegraphview.cpp
+++ b/src/plugins/perfprofiler/perfprofilerflamegraphview.cpp
@@ -47,15 +47,15 @@ PerfProfilerFlameGraphView::PerfProfilerFlameGraphView(QWidget *parent, PerfProf
#if QT_VERSION < QT_VERSION_CHECK(6, 2, 0)
qmlRegisterType<FlameGraph::FlameGraph>("QtCreator.Tracing", 1, 0, "FlameGraph");
-#endif // Qt < 6.2
qmlRegisterUncreatableType<PerfProfilerFlameGraphModel>(
"QtCreator.PerfProfiler", 1, 0, "PerfProfilerFlameGraphModel",
QLatin1String("use the context property"));
+#endif // Qt < 6.2
Timeline::TimelineTheme::setupTheme(engine());
rootContext()->setContextProperty(QStringLiteral("flameGraphModel"), m_model);
- setSource(QUrl(QStringLiteral("qrc:/perfprofiler/PerfProfilerFlameGraphView.qml")));
+ setSource(QUrl(QStringLiteral("qrc:/QtCreator/PerfProfiler/PerfProfilerFlameGraphView.qml")));
setClearColor(Utils::creatorTheme()->color(Utils::Theme::Timeline_BackgroundColor1));
setResizeMode(QQuickWidget::SizeRootObjectToView);