QmlProfiler: Add qml, register types via qt_add_qml_module

Use the CMake-based qml API to create the "QtCreator.QmlProfiler"
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: If381059bbf2a0a2b92c7f62e6da3142036ac6bbc
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
This commit is contained in:
Alessandro Portale
2021-06-24 23:15:42 +02:00
parent 3ebe5dbb99
commit 9624d2cd69
6 changed files with 104 additions and 59 deletions

View File

@@ -48,15 +48,16 @@ FlameGraphView::FlameGraphView(QmlProfilerModelManager *manager, QWidget *parent
#if QT_VERSION < QT_VERSION_CHECK(6, 2, 0)
qmlRegisterType<FlameGraph::FlameGraph>("QtCreator.Tracing", 1, 0, "FlameGraph");
#endif // Qt < 6.2
qmlRegisterUncreatableType<FlameGraphModel>("QtCreator.QmlProfiler", 1, 0,
"QmlProfilerFlameGraphModel",
QLatin1String("use the context property"));
#endif // Qt < 6.2
Timeline::TimelineTheme::setupTheme(m_content->engine());
m_content->rootContext()->setContextProperty(QStringLiteral("flameGraphModel"), m_model);
m_content->setSource(QUrl(QStringLiteral("qrc:/qmlprofiler/QmlProfilerFlameGraphView.qml")));
m_content->setSource(
QUrl(QStringLiteral("qrc:/QtCreator/QmlProfiler/QmlProfilerFlameGraphView.qml")));
m_content->setClearColor(Utils::creatorTheme()->color(Utils::Theme::Timeline_BackgroundColor1));
m_content->setResizeMode(QQuickWidget::SizeRootObjectToView);