From a56ce4e45055ea6dcb47ad826c5d28c62384387a Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Wed, 9 Jun 2021 16:56:48 +0200 Subject: [PATCH] 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 --- src/libs/tracing/CMakeLists.txt | 119 ++++++++++++++---- src/libs/tracing/flamegraph.h | 6 +- src/libs/tracing/qml/tracing.qrc | 2 +- src/libs/tracing/timelineformattime.cpp | 12 +- src/libs/tracing/timelineformattime.h | 6 + src/libs/tracing/timelineitemsrenderpass.cpp | 10 +- src/libs/tracing/timelinemodel.h | 4 + src/libs/tracing/timelinenotesmodel.h | 5 + src/libs/tracing/timelinenotesrenderpass.cpp | 8 +- src/libs/tracing/timelineoverviewrenderer.h | 5 + src/libs/tracing/timelinerenderer.h | 5 +- src/libs/tracing/timelinetheme.cpp | 23 ++-- src/libs/tracing/timelinetheme.h | 16 ++- src/libs/tracing/timelinezoomcontrol.h | 5 + .../ctfvisualizer/ctfvisualizertraceview.cpp | 4 +- .../PerfProfilerFlameGraphView.qml | 2 +- .../perfprofilerflamegraphview.cpp | 2 + .../perfprofiler/perfprofilertraceview.cpp | 4 +- src/plugins/qmlprofiler/flamegraphview.cpp | 2 + .../qml/QmlProfilerFlameGraphView.qml | 2 +- .../qmlprofiler/qmlprofilertraceview.cpp | 4 +- src/tools/iconlister/iconlister.cpp | 20 +-- .../flamegraphview/TestFlameGraphView.qml | 2 +- .../flamegraphview/tst_flamegraphview.cpp | 2 + .../tracing/tst_manual_widgets_tracing.cpp | 4 +- 25 files changed, 200 insertions(+), 74 deletions(-) diff --git a/src/libs/tracing/CMakeLists.txt b/src/libs/tracing/CMakeLists.txt index 6db0fdc0dbd..762fc71c278 100644 --- a/src/libs/tracing/CMakeLists.txt +++ b/src/libs/tracing/CMakeLists.txt @@ -1,36 +1,105 @@ +find_package(QT NAMES Qt5 Qt6) + if (WITH_TESTS) set(TEST_SOURCES runscenegraphtest.cpp runscenegraphtest.h ) endif() +set(TRACING_CPP_SOURCES + flamegraph.cpp flamegraph.h + flamegraphattached.h + safecastable.h + timelineabstractrenderer.cpp timelineabstractrenderer.h timelineabstractrenderer_p.h + timelineformattime.cpp timelineformattime.h + timelineitemsrenderpass.cpp timelineitemsrenderpass.h + timelinemodel.cpp timelinemodel.h timelinemodel_p.h + timelinemodelaggregator.cpp timelinemodelaggregator.h + timelinenotesmodel.cpp timelinenotesmodel.h timelinenotesmodel_p.h + timelinenotesrenderpass.cpp timelinenotesrenderpass.h + timelineoverviewrenderer.cpp timelineoverviewrenderer.h timelineoverviewrenderer_p.h + timelinerenderer.cpp timelinerenderer.h timelinerenderer_p.h + timelinerenderpass.cpp timelinerenderpass.h + timelinerenderstate.cpp timelinerenderstate.h timelinerenderstate_p.h + timelineselectionrenderpass.cpp timelineselectionrenderpass.h + timelinetheme.cpp timelinetheme.h + timelinetracefile.cpp timelinetracefile.h + timelinetracemanager.cpp timelinetracemanager.h + timelinezoomcontrol.cpp timelinezoomcontrol.h + traceevent.h + traceeventtype.h + tracestashfile.h + tracing_global.h +) + add_qtc_library(Tracing FEATURE_INFO DEPENDS Utils Qt5::Qml Qt5::Quick PUBLIC_DEPENDS Qt5::Widgets - SOURCES ${TEST_SOURCES} - flamegraph.cpp flamegraph.h - flamegraphattached.h - safecastable.h - qml/tracing.qrc - timelineabstractrenderer.cpp timelineabstractrenderer.h timelineabstractrenderer_p.h - timelineformattime.cpp timelineformattime.h - timelineitemsrenderpass.cpp timelineitemsrenderpass.h - timelinemodel.cpp timelinemodel.h timelinemodel_p.h - timelinemodelaggregator.cpp timelinemodelaggregator.h - timelinenotesmodel.cpp timelinenotesmodel.h timelinenotesmodel_p.h - timelinenotesrenderpass.cpp timelinenotesrenderpass.h - timelineoverviewrenderer.cpp timelineoverviewrenderer.h timelineoverviewrenderer_p.h - timelinerenderer.cpp timelinerenderer.h timelinerenderer_p.h - timelinerenderpass.cpp timelinerenderpass.h - timelinerenderstate.cpp timelinerenderstate.h timelinerenderstate_p.h - timelineselectionrenderpass.cpp timelineselectionrenderpass.h - timelinetheme.cpp timelinetheme.h - timelinetracefile.cpp timelinetracefile.h - timelinetracemanager.cpp timelinetracemanager.h - timelinezoomcontrol.cpp timelinezoomcontrol.h - traceevent.h - traceeventtype.h - tracestashfile.h - tracing_global.h + SOURCES + ${TEST_SOURCES} ) + +if(${QT_VERSION} VERSION_LESS "6.2.0") + extend_qtc_library(Tracing + SOURCES + ${TRACING_CPP_SOURCES} + qml/tracing.qrc + ) +else() # < Qt 6.2 + set(TRACING_QML_FILES + qml/ButtonsBar.qml + qml/CategoryLabel.qml + qml/Detail.qml + qml/FlameGraphDelegate.qml + qml/FlameGraphView.qml + qml/ImageToolButton.qml + qml/MainView.qml + qml/Overview.qml + qml/RangeDetails.qml + qml/RangeMover.qml + qml/RowLabel.qml + qml/SelectionRange.qml + qml/SelectionRangeDetails.qml + qml/TimeDisplay.qml + qml/TimelineContent.qml + qml/TimelineLabels.qml + qml/TimelineRulers.qml + qml/TimelineText.qml + qml/TimeMarks.qml + ) + + set(TRACING_QML_RESOURCES + qml/ico_edit.png + qml/ico_edit@2x.png + qml/ico_rangeselected.png + qml/ico_rangeselected@2x.png + qml/ico_rangeselection.png + qml/ico_rangeselection@2x.png + qml/ico_selectionmode.png + qml/ico_selectionmode@2x.png + qml/notes.frag + qml/notes.vert + qml/range_handle.png + qml/range_handle@2.png + qml/timelineitems.frag + qml/timelineitems.vert + ) + + foreach(file IN LISTS TRACING_QML_FILES TRACING_QML_RESOURCES) + get_filename_component(fileName "${file}" NAME) + set_source_files_properties("${file}" PROPERTIES QT_RESOURCE_ALIAS "${fileName}") + endforeach() + + qt_add_qml_module(Tracing + URI "QtCreator.Tracing" + VERSION "1.0" + NO_CREATE_PLUGIN_TARGET + QML_FILES + ${TRACING_QML_FILES} + RESOURCES + ${TRACING_QML_RESOURCES} + SOURCES + ${TRACING_CPP_SOURCES} + ) +endif() # < Qt 6.2 diff --git a/src/libs/tracing/flamegraph.h b/src/libs/tracing/flamegraph.h index d29b79315b7..9bffa5f251f 100644 --- a/src/libs/tracing/flamegraph.h +++ b/src/libs/tracing/flamegraph.h @@ -28,8 +28,9 @@ #include "tracing_global.h" #include "flamegraphattached.h" -#include #include +#include +#include namespace FlameGraph { @@ -48,6 +49,9 @@ class TRACING_EXPORT FlameGraph : public QQuickItem Q_PROPERTY(bool zoomed READ isZoomed NOTIFY rootChanged) Q_PROPERTY(int selectedTypeId READ selectedTypeId WRITE setSelectedTypeId NOTIFY selectedTypeIdChanged) +#if QT_VERSION >= QT_VERSION_CHECK(6, 2, 0) + QML_ELEMENT +#endif // Qt >= 6.2 public: FlameGraph(QQuickItem *parent = nullptr); diff --git a/src/libs/tracing/qml/tracing.qrc b/src/libs/tracing/qml/tracing.qrc index 4c4ec100f85..45d36b933e8 100644 --- a/src/libs/tracing/qml/tracing.qrc +++ b/src/libs/tracing/qml/tracing.qrc @@ -1,5 +1,5 @@ - + ButtonsBar.qml CategoryLabel.qml Detail.qml diff --git a/src/libs/tracing/timelineformattime.cpp b/src/libs/tracing/timelineformattime.cpp index 1bda33a0761..a01d0e0bc8b 100644 --- a/src/libs/tracing/timelineformattime.cpp +++ b/src/libs/tracing/timelineformattime.cpp @@ -86,18 +86,14 @@ QString formatTime(qint64 timestamp, qint64 reference) } } -static QObject *createFormatter(QQmlEngine *engine, QJSEngine *scriptEngine) -{ - Q_UNUSED(engine) - Q_UNUSED(scriptEngine) - return new TimeFormatter; -} - void TimeFormatter::setupTimeFormatter() { +#if QT_VERSION < QT_VERSION_CHECK(6, 2, 0) static const int typeIndex = qmlRegisterSingletonType( - "QtCreator.Tracing", 1, 0, "TimeFormatter", createFormatter); + "QtCreator.Tracing", 1, 0, "TimeFormatter", + [](QQmlEngine *, QJSEngine *){ return new TimeFormatter; }); Q_UNUSED(typeIndex) +#endif // Qt < 6.2 } } diff --git a/src/libs/tracing/timelineformattime.h b/src/libs/tracing/timelineformattime.h index 0ed8a5a3f40..60f1e38d5b5 100644 --- a/src/libs/tracing/timelineformattime.h +++ b/src/libs/tracing/timelineformattime.h @@ -27,6 +27,7 @@ #include "tracing_global.h" #include #include +#include #include namespace Timeline { @@ -35,6 +36,11 @@ QString TRACING_EXPORT formatTime(qint64 timestamp, class TRACING_EXPORT TimeFormatter : public QObject { Q_OBJECT +#if QT_VERSION >= QT_VERSION_CHECK(6, 2, 0) + QML_ELEMENT + QML_SINGLETON +#endif // Qt >= 6.2 + public: Q_INVOKABLE QString format(qint64 timestamp, qint64 reference) { diff --git a/src/libs/tracing/timelineitemsrenderpass.cpp b/src/libs/tracing/timelineitemsrenderpass.cpp index cc0fb7dc679..9911382240a 100644 --- a/src/libs/tracing/timelineitemsrenderpass.cpp +++ b/src/libs/tracing/timelineitemsrenderpass.cpp @@ -461,11 +461,13 @@ TimelineItemsMaterialShader::TimelineItemsMaterialShader() : QSGMaterialShader() { #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - setShaderSourceFile(QOpenGLShader::Vertex, QStringLiteral(":/tracing/timelineitems.vert")); - setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/tracing/timelineitems.frag")); + setShaderSourceFile(QOpenGLShader::Vertex, + QStringLiteral(":/QtCreator/Tracing/timelineitems.vert")); + setShaderSourceFile(QOpenGLShader::Fragment, + QStringLiteral(":/QtCreator/Tracing/timelineitems.frag")); #else // < Qt 6 - setShaderFileName(VertexStage, ":/tracing/timelineitems.vert"); - setShaderFileName(FragmentStage, ":/tracing/timelineitems.frag"); + setShaderFileName(VertexStage, ":/QtCreator/Tracing/timelineitems.vert"); + setShaderFileName(FragmentStage, ":/QtCreator/Tracing/timelineitems.frag"); #endif // < Qt 6 } diff --git a/src/libs/tracing/timelinemodel.h b/src/libs/tracing/timelinemodel.h index 53b8835017d..e9543c16966 100644 --- a/src/libs/tracing/timelinemodel.h +++ b/src/libs/tracing/timelinemodel.h @@ -29,6 +29,7 @@ #include "timelinerenderpass.h" #include #include +#include #include @@ -53,6 +54,9 @@ class TRACING_EXPORT TimelineModel : public QObject Q_PROPERTY(QVariantList labels READ labels NOTIFY labelsChanged) Q_PROPERTY(int count READ count NOTIFY contentChanged) Q_PROPERTY(int defaultRowHeight READ defaultRowHeight CONSTANT) +#if QT_VERSION >= QT_VERSION_CHECK(6, 2, 0) + QML_ANONYMOUS +#endif // Qt >= 6.2 public: class TimelineModelPrivate; diff --git a/src/libs/tracing/timelinenotesmodel.h b/src/libs/tracing/timelinenotesmodel.h index 8db19e233d3..07ddde822c6 100644 --- a/src/libs/tracing/timelinenotesmodel.h +++ b/src/libs/tracing/timelinenotesmodel.h @@ -27,6 +27,7 @@ #include "tracing_global.h" #include +#include namespace Timeline { @@ -35,6 +36,10 @@ class TRACING_EXPORT TimelineNotesModel : public QObject { Q_OBJECT Q_PROPERTY(int count READ count NOTIFY changed) +#if QT_VERSION >= QT_VERSION_CHECK(6, 2, 0) + QML_ANONYMOUS +#endif // Qt >= 6.2 + public: TimelineNotesModel(QObject *parent = nullptr); ~TimelineNotesModel() override; diff --git a/src/libs/tracing/timelinenotesrenderpass.cpp b/src/libs/tracing/timelinenotesrenderpass.cpp index b397832d7bd..90a10ca4602 100644 --- a/src/libs/tracing/timelinenotesrenderpass.cpp +++ b/src/libs/tracing/timelinenotesrenderpass.cpp @@ -247,11 +247,11 @@ NotesMaterialShader::NotesMaterialShader() : QSGMaterialShader() { #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - setShaderSourceFile(QOpenGLShader::Vertex, QStringLiteral(":/tracing/notes.vert")); - setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/tracing/notes.frag")); + setShaderSourceFile(QOpenGLShader::Vertex, QStringLiteral(":/QtCreator/Tracing/notes.vert")); + setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/QtCreator/Tracing/notes.frag")); #else // < Qt 6 - setShaderFileName(VertexStage, ":/tracing/notes.vert"); - setShaderFileName(FragmentStage, ":/tracing/notes.frag"); + setShaderFileName(VertexStage, ":/QtCreator/Tracing/notes.vert"); + setShaderFileName(FragmentStage, ":/QtCreator/Tracing/notes.frag"); #endif // < Qt 6 } diff --git a/src/libs/tracing/timelineoverviewrenderer.h b/src/libs/tracing/timelineoverviewrenderer.h index a59f95c61b8..119b691e1b5 100644 --- a/src/libs/tracing/timelineoverviewrenderer.h +++ b/src/libs/tracing/timelineoverviewrenderer.h @@ -31,6 +31,11 @@ namespace Timeline { class TRACING_EXPORT TimelineOverviewRenderer : public TimelineAbstractRenderer { + Q_OBJECT +#if QT_VERSION >= QT_VERSION_CHECK(6, 2, 0) + QML_ELEMENT +#endif // Qt >= 6.2 + public: TimelineOverviewRenderer(QQuickItem *parent = nullptr); diff --git a/src/libs/tracing/timelinerenderer.h b/src/libs/tracing/timelinerenderer.h index 16a766d695b..bf64d1cd2e5 100644 --- a/src/libs/tracing/timelinerenderer.h +++ b/src/libs/tracing/timelinerenderer.h @@ -31,13 +31,16 @@ #include "timelineabstractrenderer.h" #include -#include +#include namespace Timeline { class TRACING_EXPORT TimelineRenderer : public TimelineAbstractRenderer { Q_OBJECT +#if QT_VERSION >= QT_VERSION_CHECK(6, 2, 0) + QML_ELEMENT +#endif // Qt >= 6.2 public: explicit TimelineRenderer(QQuickItem *parent = nullptr); diff --git a/src/libs/tracing/timelinetheme.cpp b/src/libs/tracing/timelinetheme.cpp index d274d3cec95..f9c3bc12c3c 100644 --- a/src/libs/tracing/timelinetheme.cpp +++ b/src/libs/tracing/timelinetheme.cpp @@ -67,23 +67,23 @@ public: else if (iconName == QLatin1String("zoom")) icon = Utils::Icons::ZOOM_TOOLBAR; else if (iconName == QLatin1String("rangeselection")) - icon = Utils::Icon({{QLatin1String(":/tracing/ico_rangeselection.png"), + icon = Utils::Icon({{QLatin1String(":/QtCreator/Tracing/ico_rangeselection.png"), Utils::Theme::IconsBaseColor}}); else if (iconName == QLatin1String("rangeselected")) - icon = Utils::Icon({{QLatin1String(":/tracing/ico_rangeselected.png"), + icon = Utils::Icon({{QLatin1String(":/QtCreator/Tracing/ico_rangeselected.png"), Utils::Theme::IconsBaseColor}}); else if (iconName == QLatin1String("selectionmode")) - icon = Utils::Icon({{QLatin1String(":/tracing/ico_selectionmode.png"), + icon = Utils::Icon({{QLatin1String(":/QtCreator/Tracing/ico_selectionmode.png"), Utils::Theme::IconsBaseColor}}); else if (iconName == QLatin1String("edit")) - icon = Utils::Icon({{QLatin1String(":/tracing/ico_edit.png"), + icon = Utils::Icon({{QLatin1String(":/QtCreator/Tracing/ico_edit.png"), Utils::Theme::IconsBaseColor}}); else if (iconName == QLatin1String("lock_open")) icon = Utils::Icons::UNLOCKED_TOOLBAR; else if (iconName == QLatin1String("lock_closed")) icon = Utils::Icons::LOCKED_TOOLBAR; else if (iconName == QLatin1String("range_handle")) - icon = Utils::Icon({{QLatin1String(":/tracing/range_handle.png"), + icon = Utils::Icon({{QLatin1String(":/QtCreator/Tracing/range_handle.png"), Utils::Theme::IconsBaseColor}}); else if (iconName == QLatin1String("note")) icon = Utils::Icons::INFO_TOOLBAR; @@ -103,18 +103,19 @@ public: } }; -static QObject *singletonProvider(QQmlEngine *engine, QJSEngine *scriptEngine) +TimelineTheme::TimelineTheme(QObject *parent) + : Utils::Theme(Utils::creatorTheme(), parent) { - Q_UNUSED(engine) - Q_UNUSED(scriptEngine) - return Utils::proxyTheme(); } void TimelineTheme::setupTheme(QQmlEngine *engine) { - static const int typeIndex = qmlRegisterSingletonType("QtCreator.Tracing", 1, 0, - "Theme", singletonProvider); +#if QT_VERSION < QT_VERSION_CHECK(6, 2, 0) + static const int typeIndex = qmlRegisterSingletonType( + "QtCreator.Tracing", 1, 0, "Theme", + [](QQmlEngine *, QJSEngine *){ return Utils::proxyTheme(); }); Q_UNUSED(typeIndex) +#endif // Qt < 6.2 engine->addImageProvider(QLatin1String("icons"), new TimelineImageIconProvider); } diff --git a/src/libs/tracing/timelinetheme.h b/src/libs/tracing/timelinetheme.h index 059bfabad70..54155419976 100644 --- a/src/libs/tracing/timelinetheme.h +++ b/src/libs/tracing/timelinetheme.h @@ -27,12 +27,24 @@ #include "tracing_global.h" -QT_FORWARD_DECLARE_CLASS(QQmlEngine) +#include + +#include +#include namespace Timeline { -class TRACING_EXPORT TimelineTheme { +class TRACING_EXPORT TimelineTheme : public Utils::Theme +{ + Q_OBJECT +#if QT_VERSION >= QT_VERSION_CHECK(6, 2, 0) + QML_NAMED_ELEMENT(Theme) + QML_SINGLETON +#endif // Qt >= 6.2 + public: + explicit TimelineTheme(QObject *parent = nullptr); + static void setupTheme(QQmlEngine* engine); }; diff --git a/src/libs/tracing/timelinezoomcontrol.h b/src/libs/tracing/timelinezoomcontrol.h index 3b3a0b3d51e..2aab624b7af 100644 --- a/src/libs/tracing/timelinezoomcontrol.h +++ b/src/libs/tracing/timelinezoomcontrol.h @@ -26,6 +26,7 @@ #pragma once #include "tracing_global.h" +#include #include namespace Timeline { @@ -55,6 +56,10 @@ class TRACING_EXPORT TimelineZoomControl : public QObject { Q_PROPERTY(qint64 maximumZoomFactor READ maximumZoomFactor CONSTANT) Q_PROPERTY(qint64 minimumRangeLength READ minimumRangeLength CONSTANT) +#if QT_VERSION >= QT_VERSION_CHECK(6, 2, 0) + QML_ANONYMOUS +#endif // Qt >= 6.2 + public: qint64 maximumZoomFactor() const { return 1 << 10; } qint64 minimumRangeLength() const { return 500; } diff --git a/src/plugins/ctfvisualizer/ctfvisualizertraceview.cpp b/src/plugins/ctfvisualizer/ctfvisualizertraceview.cpp index 4d61c1d66fe..f108999e595 100644 --- a/src/plugins/ctfvisualizer/ctfvisualizertraceview.cpp +++ b/src/plugins/ctfvisualizer/ctfvisualizertraceview.cpp @@ -44,12 +44,14 @@ CtfVisualizerTraceView::CtfVisualizerTraceView(QWidget *parent, CtfVisualizerToo { setObjectName(QLatin1String("CtfVisualizerTraceView")); +#if QT_VERSION < QT_VERSION_CHECK(6, 2, 0) qmlRegisterType("QtCreator.Tracing", 1, 0, "TimelineRenderer"); qmlRegisterType("QtCreator.Tracing", 1, 0, "TimelineOverviewRenderer"); qmlRegisterAnonymousType("QtCreator.Tracing", 1); qmlRegisterAnonymousType("QtCreator.Tracing", 1); qmlRegisterAnonymousType("QtCreator.Tracing", 1); +#endif // Qt < 6.2 setResizeMode(QQuickWidget::SizeRootObjectToView); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); @@ -64,7 +66,7 @@ CtfVisualizerTraceView::CtfVisualizerTraceView(QWidget *parent, CtfVisualizerToo tool->modelAggregator()); rootContext()->setContextProperty(QLatin1String("zoomControl"), tool->zoomControl()); - setSource(QUrl(QLatin1String("qrc:/tracing/MainView.qml"))); + setSource(QUrl(QLatin1String("qrc:/QtCreator/Tracing/MainView.qml"))); // Avoid ugly warnings when reading from null properties in QML. connect(tool->modelAggregator(), &QObject::destroyed, this, [this]{ setSource(QUrl()); }); diff --git a/src/plugins/perfprofiler/PerfProfilerFlameGraphView.qml b/src/plugins/perfprofiler/PerfProfilerFlameGraphView.qml index b508547407c..90bd3b21384 100644 --- a/src/plugins/perfprofiler/PerfProfilerFlameGraphView.qml +++ b/src/plugins/perfprofiler/PerfProfilerFlameGraphView.qml @@ -24,7 +24,7 @@ ****************************************************************************/ import QtCreator.PerfProfiler 1.0 -import "../tracing/" +import "../QtCreator/Tracing/" // TODO: Turn into module import when possible FlameGraphView { id: root diff --git a/src/plugins/perfprofiler/perfprofilerflamegraphview.cpp b/src/plugins/perfprofiler/perfprofilerflamegraphview.cpp index 03d220fa997..c6f00f1ef4b 100644 --- a/src/plugins/perfprofiler/perfprofilerflamegraphview.cpp +++ b/src/plugins/perfprofiler/perfprofilerflamegraphview.cpp @@ -45,7 +45,9 @@ PerfProfilerFlameGraphView::PerfProfilerFlameGraphView(QWidget *parent, PerfProf PerfProfilerTraceManager *manager = tool->traceManager(); m_model = new PerfProfilerFlameGraphModel(manager); +#if QT_VERSION < QT_VERSION_CHECK(6, 2, 0) qmlRegisterType("QtCreator.Tracing", 1, 0, "FlameGraph"); +#endif // Qt < 6.2 qmlRegisterUncreatableType( "QtCreator.PerfProfiler", 1, 0, "PerfProfilerFlameGraphModel", QLatin1String("use the context property")); diff --git a/src/plugins/perfprofiler/perfprofilertraceview.cpp b/src/plugins/perfprofiler/perfprofilertraceview.cpp index 6a84cc55d75..bc2df091520 100644 --- a/src/plugins/perfprofiler/perfprofilertraceview.cpp +++ b/src/plugins/perfprofiler/perfprofilertraceview.cpp @@ -42,12 +42,14 @@ PerfProfilerTraceView::PerfProfilerTraceView(QWidget *parent, PerfProfilerTool * { setObjectName(QLatin1String("PerfProfilerTraceView")); +#if QT_VERSION < QT_VERSION_CHECK(6, 2, 0) qmlRegisterType("QtCreator.Tracing", 1, 0, "TimelineRenderer"); qmlRegisterType("QtCreator.Tracing", 1, 0, "TimelineOverviewRenderer"); qmlRegisterAnonymousType("QtCreator.Tracing", 1); qmlRegisterAnonymousType("QtCreator.Tracing", 1); qmlRegisterAnonymousType("QtCreator.Tracing", 1); +#endif // Qt < 6.2 setResizeMode(QQuickWidget::SizeRootObjectToView); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); @@ -62,7 +64,7 @@ PerfProfilerTraceView::PerfProfilerTraceView(QWidget *parent, PerfProfilerTool * tool->modelManager()); rootContext()->setContextProperty(QLatin1String("zoomControl"), tool->zoomControl()); - setSource(QUrl(QLatin1String("qrc:/tracing/MainView.qml"))); + setSource(QUrl(QLatin1String("qrc:/QtCreator/Tracing/MainView.qml"))); // Avoid ugly warnings when reading from null properties in QML. connect(tool->modelManager(), &QObject::destroyed, this, [this]{ setSource(QUrl()); }); diff --git a/src/plugins/qmlprofiler/flamegraphview.cpp b/src/plugins/qmlprofiler/flamegraphview.cpp index 995d028504b..4008da48a50 100644 --- a/src/plugins/qmlprofiler/flamegraphview.cpp +++ b/src/plugins/qmlprofiler/flamegraphview.cpp @@ -46,7 +46,9 @@ FlameGraphView::FlameGraphView(QmlProfilerModelManager *manager, QWidget *parent setObjectName("QmlProfiler.FlameGraph.Dock"); setWindowTitle(tr("Flame Graph")); +#if QT_VERSION < QT_VERSION_CHECK(6, 2, 0) qmlRegisterType("QtCreator.Tracing", 1, 0, "FlameGraph"); +#endif // Qt < 6.2 qmlRegisterUncreatableType("QtCreator.QmlProfiler", 1, 0, "QmlProfilerFlameGraphModel", QLatin1String("use the context property")); diff --git a/src/plugins/qmlprofiler/qml/QmlProfilerFlameGraphView.qml b/src/plugins/qmlprofiler/qml/QmlProfilerFlameGraphView.qml index 5f60e563e32..bf7f54b2728 100644 --- a/src/plugins/qmlprofiler/qml/QmlProfilerFlameGraphView.qml +++ b/src/plugins/qmlprofiler/qml/QmlProfilerFlameGraphView.qml @@ -24,7 +24,7 @@ ****************************************************************************/ import QtCreator.QmlProfiler 1.0 -import "../tracing/" +import "../QtCreator/Tracing/" // TODO: Turn into module import when possible FlameGraphView { id: root diff --git a/src/plugins/qmlprofiler/qmlprofilertraceview.cpp b/src/plugins/qmlprofiler/qmlprofilertraceview.cpp index ce3e7135a5a..3ceae1d712b 100644 --- a/src/plugins/qmlprofiler/qmlprofilertraceview.cpp +++ b/src/plugins/qmlprofiler/qmlprofilertraceview.cpp @@ -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("QtCreator.Tracing", 1, 0, "TimelineRenderer"); qmlRegisterType("QtCreator.Tracing", 1, 0, "TimelineOverviewRenderer"); qmlRegisterAnonymousType("QtCreator.Tracing", 1); qmlRegisterAnonymousType("QtCreator.Tracing", 1); qmlRegisterAnonymousType("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); diff --git a/src/tools/iconlister/iconlister.cpp b/src/tools/iconlister/iconlister.cpp index d3d084e8ca5..17ebbc0306b 100644 --- a/src/tools/iconlister/iconlister.cpp +++ b/src/tools/iconlister/iconlister.cpp @@ -1030,16 +1030,16 @@ void IconLister::addProfilerTimelineIcons() using namespace Utils; const QString prefix = "Profiler"; const QList icons = { - {Icon({{":/tracing/ico_rangeselection.png", Theme::IconsBaseColor}}).icon(), "rangeselection", prefix, - ""}, - {Icon({{":/tracing/ico_rangeselected.png", Theme::IconsBaseColor}}).icon(), "rangeselected", prefix, - ""}, - {Icon({{":/tracing/ico_selectionmode.png", Theme::IconsBaseColor}}).icon(), "selectionmode", prefix, - ""}, - {Icon({{":/tracing/ico_edit.png", Theme::IconsBaseColor}}).icon(), "edit", prefix, - ""}, - {Icon({{":/tracing/range_handle.png", Theme::IconsBaseColor}}).icon(), "range_handle", prefix, - ""}, + {Icon({{":/QtCreator/Tracing/ico_rangeselection.png", Theme::IconsBaseColor}}).icon(), + "rangeselection", prefix, ""}, + {Icon({{":/QtCreator/Tracing/ico_rangeselected.png", Theme::IconsBaseColor}}).icon(), + "rangeselected", prefix, ""}, + {Icon({{":/QtCreator/Tracing/ico_selectionmode.png", Theme::IconsBaseColor}}).icon(), + "selectionmode", prefix, ""}, + {Icon({{":/QtCreator/Tracing/ico_edit.png", Theme::IconsBaseColor}}).icon(), + "edit", prefix, ""}, + {Icon({{":/QtCreator/Tracing/range_handle.png", Theme::IconsBaseColor}}).icon(), + "range_handle", prefix, ""}, }; m_icons.append(icons); } diff --git a/tests/auto/tracing/flamegraphview/TestFlameGraphView.qml b/tests/auto/tracing/flamegraphview/TestFlameGraphView.qml index a449b9c6550..5b8d0cfc206 100644 --- a/tests/auto/tracing/flamegraphview/TestFlameGraphView.qml +++ b/tests/auto/tracing/flamegraphview/TestFlameGraphView.qml @@ -24,7 +24,7 @@ ****************************************************************************/ import QtCreator.TstTracingFlameGraphView 1.0 -import "../tracing/" +import "../QtCreator/Tracing/" // TODO: Turn into module import when possible FlameGraphView { id: root diff --git a/tests/auto/tracing/flamegraphview/tst_flamegraphview.cpp b/tests/auto/tracing/flamegraphview/tst_flamegraphview.cpp index c155f971995..e342dade151 100644 --- a/tests/auto/tracing/flamegraphview/tst_flamegraphview.cpp +++ b/tests/auto/tracing/flamegraphview/tst_flamegraphview.cpp @@ -129,7 +129,9 @@ private: void tst_FlameGraphView::initTestCase() { model.fill(); +#if QT_VERSION < QT_VERSION_CHECK(6, 2, 0) qmlRegisterType("QtCreator.Tracing", 1, 0, "FlameGraph"); +#endif // Qt < 6.2 qmlRegisterUncreatableType( "QtCreator.TstTracingFlameGraphView", 1, 0, "TestFlameGraphModel", QLatin1String("use the context property")); diff --git a/tests/manual/widgets/tracing/tst_manual_widgets_tracing.cpp b/tests/manual/widgets/tracing/tst_manual_widgets_tracing.cpp index e47bfc1be06..d027536e9e7 100644 --- a/tests/manual/widgets/tracing/tst_manual_widgets_tracing.cpp +++ b/tests/manual/widgets/tracing/tst_manual_widgets_tracing.cpp @@ -125,12 +125,14 @@ public: { setResizeMode(QQuickView::SizeRootObjectToView); +#if QT_VERSION < QT_VERSION_CHECK(6, 2, 0) qmlRegisterType("QtCreator.Tracing", 1, 0, "TimelineRenderer"); qmlRegisterType( "QtCreator.Tracing", 1, 0, "TimelineOverviewRenderer"); qmlRegisterAnonymousType("QtCreator.Tracing", 1); qmlRegisterAnonymousType("QtCreator.Tracing", 1); qmlRegisterAnonymousType("QtCreator.Tracing", 1); +#endif // Qt < 6.2 TimelineTheme::setupTheme(engine()); TimeFormatter::setupTimeFormatter(); @@ -145,7 +147,7 @@ public: m_zoomControl = new TimelineZoomControl(this); m_zoomControl->setTrace(0, oneMs * 1000); // Total timeline length rootContext()->setContextProperty("zoomControl", m_zoomControl); - setSource(QUrl(QLatin1String("qrc:/tracing/MainView.qml"))); + setSource(QUrl(QLatin1String("qrc:/QtCreator/Tracing/MainView.qml"))); // Zoom onto first timeline third. Needs to be done after loading setSource. m_zoomControl->setRange(0, oneMs * 1000 / 3.0);