Tracing: Add qml, register types via qt_add_qml_module

Use the CMake-based qml API to create the "QtCreator.Tracing" 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: I4d63f9f724d0628cfaab9d1164c0d575f15d15aa
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
This commit is contained in:
Alessandro Portale
2021-06-09 16:56:48 +02:00
parent 693d54a069
commit a56ce4e450
25 changed files with 200 additions and 74 deletions

View File

@@ -122,12 +122,14 @@ QmlProfilerTraceView::QmlProfilerTraceView(QWidget *parent, QmlProfilerViewManag
groupLayout->setContentsMargins(0, 0, 0, 0);
groupLayout->setSpacing(0);
#if QT_VERSION < QT_VERSION_CHECK(6, 2, 0)
qmlRegisterType<Timeline::TimelineRenderer>("QtCreator.Tracing", 1, 0, "TimelineRenderer");
qmlRegisterType<Timeline::TimelineOverviewRenderer>("QtCreator.Tracing", 1, 0,
"TimelineOverviewRenderer");
qmlRegisterAnonymousType<Timeline::TimelineZoomControl>("QtCreator.Tracing", 1);
qmlRegisterAnonymousType<Timeline::TimelineModel>("QtCreator.Tracing", 1);
qmlRegisterAnonymousType<Timeline::TimelineNotesModel>("QtCreator.Tracing", 1);
#endif // Qt < 6.2
d->m_mainView = new QQuickWidget(this);
d->m_mainView->setResizeMode(QQuickWidget::SizeRootObjectToView);
@@ -171,7 +173,7 @@ QmlProfilerTraceView::QmlProfilerTraceView(QWidget *parent, QmlProfilerViewManag
d->m_modelProxy);
d->m_mainView->rootContext()->setContextProperty(QLatin1String("zoomControl"),
d->m_zoomControl);
d->m_mainView->setSource(QUrl(QLatin1String("qrc:/tracing/MainView.qml")));
d->m_mainView->setSource(QUrl(QLatin1String("qrc:/QtCreator/Tracing/MainView.qml")));
connect(d->m_modelProxy, &Timeline::TimelineModelAggregator::updateCursorPosition,
this, &QmlProfilerTraceView::updateCursorPosition);