forked from qt-creator/qt-creator
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:
@@ -1,36 +1,105 @@
|
|||||||
|
find_package(QT NAMES Qt5 Qt6)
|
||||||
|
|
||||||
if (WITH_TESTS)
|
if (WITH_TESTS)
|
||||||
set(TEST_SOURCES
|
set(TEST_SOURCES
|
||||||
runscenegraphtest.cpp runscenegraphtest.h
|
runscenegraphtest.cpp runscenegraphtest.h
|
||||||
)
|
)
|
||||||
endif()
|
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
|
add_qtc_library(Tracing
|
||||||
FEATURE_INFO
|
FEATURE_INFO
|
||||||
DEPENDS Utils Qt5::Qml Qt5::Quick
|
DEPENDS Utils Qt5::Qml Qt5::Quick
|
||||||
PUBLIC_DEPENDS Qt5::Widgets
|
PUBLIC_DEPENDS Qt5::Widgets
|
||||||
SOURCES ${TEST_SOURCES}
|
SOURCES
|
||||||
flamegraph.cpp flamegraph.h
|
${TEST_SOURCES}
|
||||||
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
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
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
|
||||||
|
@@ -28,8 +28,9 @@
|
|||||||
#include "tracing_global.h"
|
#include "tracing_global.h"
|
||||||
#include "flamegraphattached.h"
|
#include "flamegraphattached.h"
|
||||||
|
|
||||||
#include <QQuickItem>
|
|
||||||
#include <QAbstractItemModel>
|
#include <QAbstractItemModel>
|
||||||
|
#include <QQuickItem>
|
||||||
|
#include <QtQml/qqml.h>
|
||||||
|
|
||||||
namespace FlameGraph {
|
namespace FlameGraph {
|
||||||
|
|
||||||
@@ -48,6 +49,9 @@ class TRACING_EXPORT FlameGraph : public QQuickItem
|
|||||||
Q_PROPERTY(bool zoomed READ isZoomed NOTIFY rootChanged)
|
Q_PROPERTY(bool zoomed READ isZoomed NOTIFY rootChanged)
|
||||||
Q_PROPERTY(int selectedTypeId READ selectedTypeId WRITE setSelectedTypeId
|
Q_PROPERTY(int selectedTypeId READ selectedTypeId WRITE setSelectedTypeId
|
||||||
NOTIFY selectedTypeIdChanged)
|
NOTIFY selectedTypeIdChanged)
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 2, 0)
|
||||||
|
QML_ELEMENT
|
||||||
|
#endif // Qt >= 6.2
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FlameGraph(QQuickItem *parent = nullptr);
|
FlameGraph(QQuickItem *parent = nullptr);
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
<RCC>
|
<RCC>
|
||||||
<qresource prefix="/tracing">
|
<qresource prefix="/QtCreator/Tracing">
|
||||||
<file>ButtonsBar.qml</file>
|
<file>ButtonsBar.qml</file>
|
||||||
<file>CategoryLabel.qml</file>
|
<file>CategoryLabel.qml</file>
|
||||||
<file>Detail.qml</file>
|
<file>Detail.qml</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()
|
void TimeFormatter::setupTimeFormatter()
|
||||||
{
|
{
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(6, 2, 0)
|
||||||
static const int typeIndex = qmlRegisterSingletonType<TimeFormatter>(
|
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)
|
Q_UNUSED(typeIndex)
|
||||||
|
#endif // Qt < 6.2
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -27,6 +27,7 @@
|
|||||||
#include "tracing_global.h"
|
#include "tracing_global.h"
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
#include <QtQml/qqml.h>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
namespace Timeline {
|
namespace Timeline {
|
||||||
@@ -35,6 +36,11 @@ QString TRACING_EXPORT formatTime(qint64 timestamp,
|
|||||||
|
|
||||||
class TRACING_EXPORT TimeFormatter : public QObject {
|
class TRACING_EXPORT TimeFormatter : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 2, 0)
|
||||||
|
QML_ELEMENT
|
||||||
|
QML_SINGLETON
|
||||||
|
#endif // Qt >= 6.2
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Q_INVOKABLE QString format(qint64 timestamp, qint64 reference)
|
Q_INVOKABLE QString format(qint64 timestamp, qint64 reference)
|
||||||
{
|
{
|
||||||
|
@@ -461,11 +461,13 @@ TimelineItemsMaterialShader::TimelineItemsMaterialShader()
|
|||||||
: QSGMaterialShader()
|
: QSGMaterialShader()
|
||||||
{
|
{
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||||
setShaderSourceFile(QOpenGLShader::Vertex, QStringLiteral(":/tracing/timelineitems.vert"));
|
setShaderSourceFile(QOpenGLShader::Vertex,
|
||||||
setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/tracing/timelineitems.frag"));
|
QStringLiteral(":/QtCreator/Tracing/timelineitems.vert"));
|
||||||
|
setShaderSourceFile(QOpenGLShader::Fragment,
|
||||||
|
QStringLiteral(":/QtCreator/Tracing/timelineitems.frag"));
|
||||||
#else // < Qt 6
|
#else // < Qt 6
|
||||||
setShaderFileName(VertexStage, ":/tracing/timelineitems.vert");
|
setShaderFileName(VertexStage, ":/QtCreator/Tracing/timelineitems.vert");
|
||||||
setShaderFileName(FragmentStage, ":/tracing/timelineitems.frag");
|
setShaderFileName(FragmentStage, ":/QtCreator/Tracing/timelineitems.frag");
|
||||||
#endif // < Qt 6
|
#endif // < Qt 6
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -29,6 +29,7 @@
|
|||||||
#include "timelinerenderpass.h"
|
#include "timelinerenderpass.h"
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
#include <QColor>
|
#include <QColor>
|
||||||
|
#include <QtQml/qqml.h>
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
@@ -53,6 +54,9 @@ class TRACING_EXPORT TimelineModel : public QObject
|
|||||||
Q_PROPERTY(QVariantList labels READ labels NOTIFY labelsChanged)
|
Q_PROPERTY(QVariantList labels READ labels NOTIFY labelsChanged)
|
||||||
Q_PROPERTY(int count READ count NOTIFY contentChanged)
|
Q_PROPERTY(int count READ count NOTIFY contentChanged)
|
||||||
Q_PROPERTY(int defaultRowHeight READ defaultRowHeight CONSTANT)
|
Q_PROPERTY(int defaultRowHeight READ defaultRowHeight CONSTANT)
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 2, 0)
|
||||||
|
QML_ANONYMOUS
|
||||||
|
#endif // Qt >= 6.2
|
||||||
|
|
||||||
public:
|
public:
|
||||||
class TimelineModelPrivate;
|
class TimelineModelPrivate;
|
||||||
|
@@ -27,6 +27,7 @@
|
|||||||
|
|
||||||
#include "tracing_global.h"
|
#include "tracing_global.h"
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
#include <QtQml/qqml.h>
|
||||||
|
|
||||||
namespace Timeline {
|
namespace Timeline {
|
||||||
|
|
||||||
@@ -35,6 +36,10 @@ class TRACING_EXPORT TimelineNotesModel : public QObject
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(int count READ count NOTIFY changed)
|
Q_PROPERTY(int count READ count NOTIFY changed)
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 2, 0)
|
||||||
|
QML_ANONYMOUS
|
||||||
|
#endif // Qt >= 6.2
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TimelineNotesModel(QObject *parent = nullptr);
|
TimelineNotesModel(QObject *parent = nullptr);
|
||||||
~TimelineNotesModel() override;
|
~TimelineNotesModel() override;
|
||||||
|
@@ -247,11 +247,11 @@ NotesMaterialShader::NotesMaterialShader()
|
|||||||
: QSGMaterialShader()
|
: QSGMaterialShader()
|
||||||
{
|
{
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||||
setShaderSourceFile(QOpenGLShader::Vertex, QStringLiteral(":/tracing/notes.vert"));
|
setShaderSourceFile(QOpenGLShader::Vertex, QStringLiteral(":/QtCreator/Tracing/notes.vert"));
|
||||||
setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/tracing/notes.frag"));
|
setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/QtCreator/Tracing/notes.frag"));
|
||||||
#else // < Qt 6
|
#else // < Qt 6
|
||||||
setShaderFileName(VertexStage, ":/tracing/notes.vert");
|
setShaderFileName(VertexStage, ":/QtCreator/Tracing/notes.vert");
|
||||||
setShaderFileName(FragmentStage, ":/tracing/notes.frag");
|
setShaderFileName(FragmentStage, ":/QtCreator/Tracing/notes.frag");
|
||||||
#endif // < Qt 6
|
#endif // < Qt 6
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -31,6 +31,11 @@ namespace Timeline {
|
|||||||
|
|
||||||
class TRACING_EXPORT TimelineOverviewRenderer : public TimelineAbstractRenderer
|
class TRACING_EXPORT TimelineOverviewRenderer : public TimelineAbstractRenderer
|
||||||
{
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 2, 0)
|
||||||
|
QML_ELEMENT
|
||||||
|
#endif // Qt >= 6.2
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TimelineOverviewRenderer(QQuickItem *parent = nullptr);
|
TimelineOverviewRenderer(QQuickItem *parent = nullptr);
|
||||||
|
|
||||||
|
@@ -31,13 +31,16 @@
|
|||||||
#include "timelineabstractrenderer.h"
|
#include "timelineabstractrenderer.h"
|
||||||
|
|
||||||
#include <QSGTransformNode>
|
#include <QSGTransformNode>
|
||||||
#include <QQuickItem>
|
#include <QtQml/qqml.h>
|
||||||
|
|
||||||
namespace Timeline {
|
namespace Timeline {
|
||||||
|
|
||||||
class TRACING_EXPORT TimelineRenderer : public TimelineAbstractRenderer
|
class TRACING_EXPORT TimelineRenderer : public TimelineAbstractRenderer
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 2, 0)
|
||||||
|
QML_ELEMENT
|
||||||
|
#endif // Qt >= 6.2
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit TimelineRenderer(QQuickItem *parent = nullptr);
|
explicit TimelineRenderer(QQuickItem *parent = nullptr);
|
||||||
|
@@ -67,23 +67,23 @@ public:
|
|||||||
else if (iconName == QLatin1String("zoom"))
|
else if (iconName == QLatin1String("zoom"))
|
||||||
icon = Utils::Icons::ZOOM_TOOLBAR;
|
icon = Utils::Icons::ZOOM_TOOLBAR;
|
||||||
else if (iconName == QLatin1String("rangeselection"))
|
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}});
|
Utils::Theme::IconsBaseColor}});
|
||||||
else if (iconName == QLatin1String("rangeselected"))
|
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}});
|
Utils::Theme::IconsBaseColor}});
|
||||||
else if (iconName == QLatin1String("selectionmode"))
|
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}});
|
Utils::Theme::IconsBaseColor}});
|
||||||
else if (iconName == QLatin1String("edit"))
|
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}});
|
Utils::Theme::IconsBaseColor}});
|
||||||
else if (iconName == QLatin1String("lock_open"))
|
else if (iconName == QLatin1String("lock_open"))
|
||||||
icon = Utils::Icons::UNLOCKED_TOOLBAR;
|
icon = Utils::Icons::UNLOCKED_TOOLBAR;
|
||||||
else if (iconName == QLatin1String("lock_closed"))
|
else if (iconName == QLatin1String("lock_closed"))
|
||||||
icon = Utils::Icons::LOCKED_TOOLBAR;
|
icon = Utils::Icons::LOCKED_TOOLBAR;
|
||||||
else if (iconName == QLatin1String("range_handle"))
|
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}});
|
Utils::Theme::IconsBaseColor}});
|
||||||
else if (iconName == QLatin1String("note"))
|
else if (iconName == QLatin1String("note"))
|
||||||
icon = Utils::Icons::INFO_TOOLBAR;
|
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)
|
void TimelineTheme::setupTheme(QQmlEngine *engine)
|
||||||
{
|
{
|
||||||
static const int typeIndex = qmlRegisterSingletonType<Utils::Theme>("QtCreator.Tracing", 1, 0,
|
#if QT_VERSION < QT_VERSION_CHECK(6, 2, 0)
|
||||||
"Theme", singletonProvider);
|
static const int typeIndex = qmlRegisterSingletonType<Utils::Theme>(
|
||||||
|
"QtCreator.Tracing", 1, 0, "Theme",
|
||||||
|
[](QQmlEngine *, QJSEngine *){ return Utils::proxyTheme(); });
|
||||||
Q_UNUSED(typeIndex)
|
Q_UNUSED(typeIndex)
|
||||||
|
#endif // Qt < 6.2
|
||||||
engine->addImageProvider(QLatin1String("icons"), new TimelineImageIconProvider);
|
engine->addImageProvider(QLatin1String("icons"), new TimelineImageIconProvider);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -27,12 +27,24 @@
|
|||||||
|
|
||||||
#include "tracing_global.h"
|
#include "tracing_global.h"
|
||||||
|
|
||||||
QT_FORWARD_DECLARE_CLASS(QQmlEngine)
|
#include <utils/theme/theme.h>
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QtQml/qqml.h>
|
||||||
|
|
||||||
namespace Timeline {
|
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:
|
public:
|
||||||
|
explicit TimelineTheme(QObject *parent = nullptr);
|
||||||
|
|
||||||
static void setupTheme(QQmlEngine* engine);
|
static void setupTheme(QQmlEngine* engine);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -26,6 +26,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "tracing_global.h"
|
#include "tracing_global.h"
|
||||||
|
#include <QtQml/qqml.h>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
namespace Timeline {
|
namespace Timeline {
|
||||||
@@ -55,6 +56,10 @@ class TRACING_EXPORT TimelineZoomControl : public QObject {
|
|||||||
Q_PROPERTY(qint64 maximumZoomFactor READ maximumZoomFactor CONSTANT)
|
Q_PROPERTY(qint64 maximumZoomFactor READ maximumZoomFactor CONSTANT)
|
||||||
Q_PROPERTY(qint64 minimumRangeLength READ minimumRangeLength CONSTANT)
|
Q_PROPERTY(qint64 minimumRangeLength READ minimumRangeLength CONSTANT)
|
||||||
|
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 2, 0)
|
||||||
|
QML_ANONYMOUS
|
||||||
|
#endif // Qt >= 6.2
|
||||||
|
|
||||||
public:
|
public:
|
||||||
qint64 maximumZoomFactor() const { return 1 << 10; }
|
qint64 maximumZoomFactor() const { return 1 << 10; }
|
||||||
qint64 minimumRangeLength() const { return 500; }
|
qint64 minimumRangeLength() const { return 500; }
|
||||||
|
@@ -44,12 +44,14 @@ CtfVisualizerTraceView::CtfVisualizerTraceView(QWidget *parent, CtfVisualizerToo
|
|||||||
{
|
{
|
||||||
setObjectName(QLatin1String("CtfVisualizerTraceView"));
|
setObjectName(QLatin1String("CtfVisualizerTraceView"));
|
||||||
|
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(6, 2, 0)
|
||||||
qmlRegisterType<Timeline::TimelineRenderer>("QtCreator.Tracing", 1, 0, "TimelineRenderer");
|
qmlRegisterType<Timeline::TimelineRenderer>("QtCreator.Tracing", 1, 0, "TimelineRenderer");
|
||||||
qmlRegisterType<Timeline::TimelineOverviewRenderer>("QtCreator.Tracing", 1, 0,
|
qmlRegisterType<Timeline::TimelineOverviewRenderer>("QtCreator.Tracing", 1, 0,
|
||||||
"TimelineOverviewRenderer");
|
"TimelineOverviewRenderer");
|
||||||
qmlRegisterAnonymousType<Timeline::TimelineZoomControl>("QtCreator.Tracing", 1);
|
qmlRegisterAnonymousType<Timeline::TimelineZoomControl>("QtCreator.Tracing", 1);
|
||||||
qmlRegisterAnonymousType<Timeline::TimelineModel>("QtCreator.Tracing", 1);
|
qmlRegisterAnonymousType<Timeline::TimelineModel>("QtCreator.Tracing", 1);
|
||||||
qmlRegisterAnonymousType<Timeline::TimelineNotesModel>("QtCreator.Tracing", 1);
|
qmlRegisterAnonymousType<Timeline::TimelineNotesModel>("QtCreator.Tracing", 1);
|
||||||
|
#endif // Qt < 6.2
|
||||||
|
|
||||||
setResizeMode(QQuickWidget::SizeRootObjectToView);
|
setResizeMode(QQuickWidget::SizeRootObjectToView);
|
||||||
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||||
@@ -64,7 +66,7 @@ CtfVisualizerTraceView::CtfVisualizerTraceView(QWidget *parent, CtfVisualizerToo
|
|||||||
tool->modelAggregator());
|
tool->modelAggregator());
|
||||||
rootContext()->setContextProperty(QLatin1String("zoomControl"),
|
rootContext()->setContextProperty(QLatin1String("zoomControl"),
|
||||||
tool->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.
|
// Avoid ugly warnings when reading from null properties in QML.
|
||||||
connect(tool->modelAggregator(), &QObject::destroyed, this, [this]{ setSource(QUrl()); });
|
connect(tool->modelAggregator(), &QObject::destroyed, this, [this]{ setSource(QUrl()); });
|
||||||
|
@@ -24,7 +24,7 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
import QtCreator.PerfProfiler 1.0
|
import QtCreator.PerfProfiler 1.0
|
||||||
import "../tracing/"
|
import "../QtCreator/Tracing/" // TODO: Turn into module import when possible
|
||||||
|
|
||||||
FlameGraphView {
|
FlameGraphView {
|
||||||
id: root
|
id: root
|
||||||
|
@@ -45,7 +45,9 @@ PerfProfilerFlameGraphView::PerfProfilerFlameGraphView(QWidget *parent, PerfProf
|
|||||||
PerfProfilerTraceManager *manager = tool->traceManager();
|
PerfProfilerTraceManager *manager = tool->traceManager();
|
||||||
m_model = new PerfProfilerFlameGraphModel(manager);
|
m_model = new PerfProfilerFlameGraphModel(manager);
|
||||||
|
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(6, 2, 0)
|
||||||
qmlRegisterType<FlameGraph::FlameGraph>("QtCreator.Tracing", 1, 0, "FlameGraph");
|
qmlRegisterType<FlameGraph::FlameGraph>("QtCreator.Tracing", 1, 0, "FlameGraph");
|
||||||
|
#endif // Qt < 6.2
|
||||||
qmlRegisterUncreatableType<PerfProfilerFlameGraphModel>(
|
qmlRegisterUncreatableType<PerfProfilerFlameGraphModel>(
|
||||||
"QtCreator.PerfProfiler", 1, 0, "PerfProfilerFlameGraphModel",
|
"QtCreator.PerfProfiler", 1, 0, "PerfProfilerFlameGraphModel",
|
||||||
QLatin1String("use the context property"));
|
QLatin1String("use the context property"));
|
||||||
|
@@ -42,12 +42,14 @@ PerfProfilerTraceView::PerfProfilerTraceView(QWidget *parent, PerfProfilerTool *
|
|||||||
{
|
{
|
||||||
setObjectName(QLatin1String("PerfProfilerTraceView"));
|
setObjectName(QLatin1String("PerfProfilerTraceView"));
|
||||||
|
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(6, 2, 0)
|
||||||
qmlRegisterType<Timeline::TimelineRenderer>("QtCreator.Tracing", 1, 0, "TimelineRenderer");
|
qmlRegisterType<Timeline::TimelineRenderer>("QtCreator.Tracing", 1, 0, "TimelineRenderer");
|
||||||
qmlRegisterType<Timeline::TimelineOverviewRenderer>("QtCreator.Tracing", 1, 0,
|
qmlRegisterType<Timeline::TimelineOverviewRenderer>("QtCreator.Tracing", 1, 0,
|
||||||
"TimelineOverviewRenderer");
|
"TimelineOverviewRenderer");
|
||||||
qmlRegisterAnonymousType<Timeline::TimelineZoomControl>("QtCreator.Tracing", 1);
|
qmlRegisterAnonymousType<Timeline::TimelineZoomControl>("QtCreator.Tracing", 1);
|
||||||
qmlRegisterAnonymousType<Timeline::TimelineModel>("QtCreator.Tracing", 1);
|
qmlRegisterAnonymousType<Timeline::TimelineModel>("QtCreator.Tracing", 1);
|
||||||
qmlRegisterAnonymousType<Timeline::TimelineNotesModel>("QtCreator.Tracing", 1);
|
qmlRegisterAnonymousType<Timeline::TimelineNotesModel>("QtCreator.Tracing", 1);
|
||||||
|
#endif // Qt < 6.2
|
||||||
|
|
||||||
setResizeMode(QQuickWidget::SizeRootObjectToView);
|
setResizeMode(QQuickWidget::SizeRootObjectToView);
|
||||||
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||||
@@ -62,7 +64,7 @@ PerfProfilerTraceView::PerfProfilerTraceView(QWidget *parent, PerfProfilerTool *
|
|||||||
tool->modelManager());
|
tool->modelManager());
|
||||||
rootContext()->setContextProperty(QLatin1String("zoomControl"),
|
rootContext()->setContextProperty(QLatin1String("zoomControl"),
|
||||||
tool->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.
|
// Avoid ugly warnings when reading from null properties in QML.
|
||||||
connect(tool->modelManager(), &QObject::destroyed, this, [this]{ setSource(QUrl()); });
|
connect(tool->modelManager(), &QObject::destroyed, this, [this]{ setSource(QUrl()); });
|
||||||
|
@@ -46,7 +46,9 @@ FlameGraphView::FlameGraphView(QmlProfilerModelManager *manager, QWidget *parent
|
|||||||
setObjectName("QmlProfiler.FlameGraph.Dock");
|
setObjectName("QmlProfiler.FlameGraph.Dock");
|
||||||
setWindowTitle(tr("Flame Graph"));
|
setWindowTitle(tr("Flame Graph"));
|
||||||
|
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(6, 2, 0)
|
||||||
qmlRegisterType<FlameGraph::FlameGraph>("QtCreator.Tracing", 1, 0, "FlameGraph");
|
qmlRegisterType<FlameGraph::FlameGraph>("QtCreator.Tracing", 1, 0, "FlameGraph");
|
||||||
|
#endif // Qt < 6.2
|
||||||
qmlRegisterUncreatableType<FlameGraphModel>("QtCreator.QmlProfiler", 1, 0,
|
qmlRegisterUncreatableType<FlameGraphModel>("QtCreator.QmlProfiler", 1, 0,
|
||||||
"QmlProfilerFlameGraphModel",
|
"QmlProfilerFlameGraphModel",
|
||||||
QLatin1String("use the context property"));
|
QLatin1String("use the context property"));
|
||||||
|
@@ -24,7 +24,7 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
import QtCreator.QmlProfiler 1.0
|
import QtCreator.QmlProfiler 1.0
|
||||||
import "../tracing/"
|
import "../QtCreator/Tracing/" // TODO: Turn into module import when possible
|
||||||
|
|
||||||
FlameGraphView {
|
FlameGraphView {
|
||||||
id: root
|
id: root
|
||||||
|
@@ -122,12 +122,14 @@ QmlProfilerTraceView::QmlProfilerTraceView(QWidget *parent, QmlProfilerViewManag
|
|||||||
groupLayout->setContentsMargins(0, 0, 0, 0);
|
groupLayout->setContentsMargins(0, 0, 0, 0);
|
||||||
groupLayout->setSpacing(0);
|
groupLayout->setSpacing(0);
|
||||||
|
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(6, 2, 0)
|
||||||
qmlRegisterType<Timeline::TimelineRenderer>("QtCreator.Tracing", 1, 0, "TimelineRenderer");
|
qmlRegisterType<Timeline::TimelineRenderer>("QtCreator.Tracing", 1, 0, "TimelineRenderer");
|
||||||
qmlRegisterType<Timeline::TimelineOverviewRenderer>("QtCreator.Tracing", 1, 0,
|
qmlRegisterType<Timeline::TimelineOverviewRenderer>("QtCreator.Tracing", 1, 0,
|
||||||
"TimelineOverviewRenderer");
|
"TimelineOverviewRenderer");
|
||||||
qmlRegisterAnonymousType<Timeline::TimelineZoomControl>("QtCreator.Tracing", 1);
|
qmlRegisterAnonymousType<Timeline::TimelineZoomControl>("QtCreator.Tracing", 1);
|
||||||
qmlRegisterAnonymousType<Timeline::TimelineModel>("QtCreator.Tracing", 1);
|
qmlRegisterAnonymousType<Timeline::TimelineModel>("QtCreator.Tracing", 1);
|
||||||
qmlRegisterAnonymousType<Timeline::TimelineNotesModel>("QtCreator.Tracing", 1);
|
qmlRegisterAnonymousType<Timeline::TimelineNotesModel>("QtCreator.Tracing", 1);
|
||||||
|
#endif // Qt < 6.2
|
||||||
|
|
||||||
d->m_mainView = new QQuickWidget(this);
|
d->m_mainView = new QQuickWidget(this);
|
||||||
d->m_mainView->setResizeMode(QQuickWidget::SizeRootObjectToView);
|
d->m_mainView->setResizeMode(QQuickWidget::SizeRootObjectToView);
|
||||||
@@ -171,7 +173,7 @@ QmlProfilerTraceView::QmlProfilerTraceView(QWidget *parent, QmlProfilerViewManag
|
|||||||
d->m_modelProxy);
|
d->m_modelProxy);
|
||||||
d->m_mainView->rootContext()->setContextProperty(QLatin1String("zoomControl"),
|
d->m_mainView->rootContext()->setContextProperty(QLatin1String("zoomControl"),
|
||||||
d->m_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,
|
connect(d->m_modelProxy, &Timeline::TimelineModelAggregator::updateCursorPosition,
|
||||||
this, &QmlProfilerTraceView::updateCursorPosition);
|
this, &QmlProfilerTraceView::updateCursorPosition);
|
||||||
|
@@ -1030,16 +1030,16 @@ void IconLister::addProfilerTimelineIcons()
|
|||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
const QString prefix = "Profiler";
|
const QString prefix = "Profiler";
|
||||||
const QList<IconInfo> icons = {
|
const QList<IconInfo> icons = {
|
||||||
{Icon({{":/tracing/ico_rangeselection.png", Theme::IconsBaseColor}}).icon(), "rangeselection", prefix,
|
{Icon({{":/QtCreator/Tracing/ico_rangeselection.png", Theme::IconsBaseColor}}).icon(),
|
||||||
""},
|
"rangeselection", prefix, ""},
|
||||||
{Icon({{":/tracing/ico_rangeselected.png", Theme::IconsBaseColor}}).icon(), "rangeselected", prefix,
|
{Icon({{":/QtCreator/Tracing/ico_rangeselected.png", Theme::IconsBaseColor}}).icon(),
|
||||||
""},
|
"rangeselected", prefix, ""},
|
||||||
{Icon({{":/tracing/ico_selectionmode.png", Theme::IconsBaseColor}}).icon(), "selectionmode", prefix,
|
{Icon({{":/QtCreator/Tracing/ico_selectionmode.png", Theme::IconsBaseColor}}).icon(),
|
||||||
""},
|
"selectionmode", prefix, ""},
|
||||||
{Icon({{":/tracing/ico_edit.png", Theme::IconsBaseColor}}).icon(), "edit", prefix,
|
{Icon({{":/QtCreator/Tracing/ico_edit.png", Theme::IconsBaseColor}}).icon(),
|
||||||
""},
|
"edit", prefix, ""},
|
||||||
{Icon({{":/tracing/range_handle.png", Theme::IconsBaseColor}}).icon(), "range_handle", prefix,
|
{Icon({{":/QtCreator/Tracing/range_handle.png", Theme::IconsBaseColor}}).icon(),
|
||||||
""},
|
"range_handle", prefix, ""},
|
||||||
};
|
};
|
||||||
m_icons.append(icons);
|
m_icons.append(icons);
|
||||||
}
|
}
|
||||||
|
@@ -24,7 +24,7 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
import QtCreator.TstTracingFlameGraphView 1.0
|
import QtCreator.TstTracingFlameGraphView 1.0
|
||||||
import "../tracing/"
|
import "../QtCreator/Tracing/" // TODO: Turn into module import when possible
|
||||||
|
|
||||||
FlameGraphView {
|
FlameGraphView {
|
||||||
id: root
|
id: root
|
||||||
|
@@ -129,7 +129,9 @@ private:
|
|||||||
void tst_FlameGraphView::initTestCase()
|
void tst_FlameGraphView::initTestCase()
|
||||||
{
|
{
|
||||||
model.fill();
|
model.fill();
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(6, 2, 0)
|
||||||
qmlRegisterType<FlameGraph::FlameGraph>("QtCreator.Tracing", 1, 0, "FlameGraph");
|
qmlRegisterType<FlameGraph::FlameGraph>("QtCreator.Tracing", 1, 0, "FlameGraph");
|
||||||
|
#endif // Qt < 6.2
|
||||||
qmlRegisterUncreatableType<TestFlameGraphModel>(
|
qmlRegisterUncreatableType<TestFlameGraphModel>(
|
||||||
"QtCreator.TstTracingFlameGraphView", 1, 0, "TestFlameGraphModel",
|
"QtCreator.TstTracingFlameGraphView", 1, 0, "TestFlameGraphModel",
|
||||||
QLatin1String("use the context property"));
|
QLatin1String("use the context property"));
|
||||||
|
@@ -125,12 +125,14 @@ public:
|
|||||||
{
|
{
|
||||||
setResizeMode(QQuickView::SizeRootObjectToView);
|
setResizeMode(QQuickView::SizeRootObjectToView);
|
||||||
|
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(6, 2, 0)
|
||||||
qmlRegisterType<TimelineRenderer>("QtCreator.Tracing", 1, 0, "TimelineRenderer");
|
qmlRegisterType<TimelineRenderer>("QtCreator.Tracing", 1, 0, "TimelineRenderer");
|
||||||
qmlRegisterType<TimelineOverviewRenderer>(
|
qmlRegisterType<TimelineOverviewRenderer>(
|
||||||
"QtCreator.Tracing", 1, 0, "TimelineOverviewRenderer");
|
"QtCreator.Tracing", 1, 0, "TimelineOverviewRenderer");
|
||||||
qmlRegisterAnonymousType<TimelineZoomControl>("QtCreator.Tracing", 1);
|
qmlRegisterAnonymousType<TimelineZoomControl>("QtCreator.Tracing", 1);
|
||||||
qmlRegisterAnonymousType<TimelineModel>("QtCreator.Tracing", 1);
|
qmlRegisterAnonymousType<TimelineModel>("QtCreator.Tracing", 1);
|
||||||
qmlRegisterAnonymousType<TimelineNotesModel>("QtCreator.Tracing", 1);
|
qmlRegisterAnonymousType<TimelineNotesModel>("QtCreator.Tracing", 1);
|
||||||
|
#endif // Qt < 6.2
|
||||||
|
|
||||||
TimelineTheme::setupTheme(engine());
|
TimelineTheme::setupTheme(engine());
|
||||||
TimeFormatter::setupTimeFormatter();
|
TimeFormatter::setupTimeFormatter();
|
||||||
@@ -145,7 +147,7 @@ public:
|
|||||||
m_zoomControl = new TimelineZoomControl(this);
|
m_zoomControl = new TimelineZoomControl(this);
|
||||||
m_zoomControl->setTrace(0, oneMs * 1000); // Total timeline length
|
m_zoomControl->setTrace(0, oneMs * 1000); // Total timeline length
|
||||||
rootContext()->setContextProperty("zoomControl", m_zoomControl);
|
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.
|
// Zoom onto first timeline third. Needs to be done after loading setSource.
|
||||||
m_zoomControl->setRange(0, oneMs * 1000 / 3.0);
|
m_zoomControl->setRange(0, oneMs * 1000 / 3.0);
|
||||||
|
Reference in New Issue
Block a user