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

@@ -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

View File

@@ -28,8 +28,9 @@
#include "tracing_global.h"
#include "flamegraphattached.h"
#include <QQuickItem>
#include <QAbstractItemModel>
#include <QQuickItem>
#include <QtQml/qqml.h>
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);

View File

@@ -1,5 +1,5 @@
<RCC>
<qresource prefix="/tracing">
<qresource prefix="/QtCreator/Tracing">
<file>ButtonsBar.qml</file>
<file>CategoryLabel.qml</file>
<file>Detail.qml</file>

View File

@@ -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<TimeFormatter>(
"QtCreator.Tracing", 1, 0, "TimeFormatter", createFormatter);
"QtCreator.Tracing", 1, 0, "TimeFormatter",
[](QQmlEngine *, QJSEngine *){ return new TimeFormatter; });
Q_UNUSED(typeIndex)
#endif // Qt < 6.2
}
}

View File

@@ -27,6 +27,7 @@
#include "tracing_global.h"
#include <QString>
#include <QObject>
#include <QtQml/qqml.h>
#include <limits>
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)
{

View File

@@ -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
}

View File

@@ -29,6 +29,7 @@
#include "timelinerenderpass.h"
#include <QVariant>
#include <QColor>
#include <QtQml/qqml.h>
#include <memory>
@@ -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;

View File

@@ -27,6 +27,7 @@
#include "tracing_global.h"
#include <QObject>
#include <QtQml/qqml.h>
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;

View File

@@ -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
}

View File

@@ -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);

View File

@@ -31,13 +31,16 @@
#include "timelineabstractrenderer.h"
#include <QSGTransformNode>
#include <QQuickItem>
#include <QtQml/qqml.h>
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);

View File

@@ -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<Utils::Theme>("QtCreator.Tracing", 1, 0,
"Theme", singletonProvider);
#if QT_VERSION < QT_VERSION_CHECK(6, 2, 0)
static const int typeIndex = qmlRegisterSingletonType<Utils::Theme>(
"QtCreator.Tracing", 1, 0, "Theme",
[](QQmlEngine *, QJSEngine *){ return Utils::proxyTheme(); });
Q_UNUSED(typeIndex)
#endif // Qt < 6.2
engine->addImageProvider(QLatin1String("icons"), new TimelineImageIconProvider);
}

View File

@@ -27,12 +27,24 @@
#include "tracing_global.h"
QT_FORWARD_DECLARE_CLASS(QQmlEngine)
#include <utils/theme/theme.h>
#include <QObject>
#include <QtQml/qqml.h>
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);
};

View File

@@ -26,6 +26,7 @@
#pragma once
#include "tracing_global.h"
#include <QtQml/qqml.h>
#include <QTimer>
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; }

View File

@@ -44,12 +44,14 @@ CtfVisualizerTraceView::CtfVisualizerTraceView(QWidget *parent, CtfVisualizerToo
{
setObjectName(QLatin1String("CtfVisualizerTraceView"));
#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
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()); });

View File

@@ -24,7 +24,7 @@
****************************************************************************/
import QtCreator.PerfProfiler 1.0
import "../tracing/"
import "../QtCreator/Tracing/" // TODO: Turn into module import when possible
FlameGraphView {
id: root

View File

@@ -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<FlameGraph::FlameGraph>("QtCreator.Tracing", 1, 0, "FlameGraph");
#endif // Qt < 6.2
qmlRegisterUncreatableType<PerfProfilerFlameGraphModel>(
"QtCreator.PerfProfiler", 1, 0, "PerfProfilerFlameGraphModel",
QLatin1String("use the context property"));

View File

@@ -42,12 +42,14 @@ PerfProfilerTraceView::PerfProfilerTraceView(QWidget *parent, PerfProfilerTool *
{
setObjectName(QLatin1String("PerfProfilerTraceView"));
#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
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()); });

View File

@@ -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<FlameGraph::FlameGraph>("QtCreator.Tracing", 1, 0, "FlameGraph");
#endif // Qt < 6.2
qmlRegisterUncreatableType<FlameGraphModel>("QtCreator.QmlProfiler", 1, 0,
"QmlProfilerFlameGraphModel",
QLatin1String("use the context property"));

View File

@@ -24,7 +24,7 @@
****************************************************************************/
import QtCreator.QmlProfiler 1.0
import "../tracing/"
import "../QtCreator/Tracing/" // TODO: Turn into module import when possible
FlameGraphView {
id: root

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);

View File

@@ -1030,16 +1030,16 @@ void IconLister::addProfilerTimelineIcons()
using namespace Utils;
const QString prefix = "Profiler";
const QList<IconInfo> 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);
}

View File

@@ -24,7 +24,7 @@
****************************************************************************/
import QtCreator.TstTracingFlameGraphView 1.0
import "../tracing/"
import "../QtCreator/Tracing/" // TODO: Turn into module import when possible
FlameGraphView {
id: root

View File

@@ -129,7 +129,9 @@ private:
void tst_FlameGraphView::initTestCase()
{
model.fill();
#if QT_VERSION < QT_VERSION_CHECK(6, 2, 0)
qmlRegisterType<FlameGraph::FlameGraph>("QtCreator.Tracing", 1, 0, "FlameGraph");
#endif // Qt < 6.2
qmlRegisterUncreatableType<TestFlameGraphModel>(
"QtCreator.TstTracingFlameGraphView", 1, 0, "TestFlameGraphModel",
QLatin1String("use the context property"));

View File

@@ -125,12 +125,14 @@ public:
{
setResizeMode(QQuickView::SizeRootObjectToView);
#if QT_VERSION < QT_VERSION_CHECK(6, 2, 0)
qmlRegisterType<TimelineRenderer>("QtCreator.Tracing", 1, 0, "TimelineRenderer");
qmlRegisterType<TimelineOverviewRenderer>(
"QtCreator.Tracing", 1, 0, "TimelineOverviewRenderer");
qmlRegisterAnonymousType<TimelineZoomControl>("QtCreator.Tracing", 1);
qmlRegisterAnonymousType<TimelineModel>("QtCreator.Tracing", 1);
qmlRegisterAnonymousType<TimelineNotesModel>("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);