forked from qt-creator/qt-creator
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:
@@ -1,54 +1,5 @@
|
|||||||
add_qtc_plugin(QmlProfiler
|
if(WITH_TESTS)
|
||||||
CONDITION TARGET Tracing
|
set(TEST_SOURCES
|
||||||
DEPENDS QmlDebug QmlJS Tracing Qt5::QuickWidgets
|
|
||||||
PLUGIN_DEPENDS Core Debugger ProjectExplorer QtSupport TextEditor
|
|
||||||
SOURCES
|
|
||||||
debugmessagesmodel.cpp debugmessagesmodel.h
|
|
||||||
flamegraphmodel.cpp flamegraphmodel.h
|
|
||||||
flamegraphview.cpp flamegraphview.h
|
|
||||||
inputeventsmodel.cpp inputeventsmodel.h
|
|
||||||
memoryusagemodel.cpp memoryusagemodel.h
|
|
||||||
pixmapcachemodel.cpp pixmapcachemodel.h
|
|
||||||
qml/qmlprofiler.qrc
|
|
||||||
qmlevent.cpp qmlevent.h
|
|
||||||
qmleventlocation.cpp qmleventlocation.h
|
|
||||||
qmleventtype.cpp qmleventtype.h
|
|
||||||
qmlnote.cpp qmlnote.h
|
|
||||||
qmlprofiler_global.h
|
|
||||||
qmlprofileractions.cpp qmlprofileractions.h
|
|
||||||
qmlprofileranimationsmodel.cpp qmlprofileranimationsmodel.h
|
|
||||||
qmlprofilerattachdialog.cpp qmlprofilerattachdialog.h
|
|
||||||
qmlprofilerbindingloopsrenderpass.cpp qmlprofilerbindingloopsrenderpass.h
|
|
||||||
qmlprofilerclientmanager.cpp qmlprofilerclientmanager.h
|
|
||||||
qmlprofilerconstants.h
|
|
||||||
qmlprofilerdetailsrewriter.cpp qmlprofilerdetailsrewriter.h
|
|
||||||
qmlprofilereventsview.h
|
|
||||||
qmlprofilereventtypes.h
|
|
||||||
qmlprofilermodelmanager.cpp qmlprofilermodelmanager.h
|
|
||||||
qmlprofilernotesmodel.cpp qmlprofilernotesmodel.h
|
|
||||||
qmlprofilerplugin.cpp qmlprofilerplugin.h
|
|
||||||
qmlprofilerrangemodel.cpp qmlprofilerrangemodel.h
|
|
||||||
qmlprofilerrunconfigurationaspect.cpp qmlprofilerrunconfigurationaspect.h
|
|
||||||
qmlprofilerruncontrol.cpp qmlprofilerruncontrol.h
|
|
||||||
qmlprofilersettings.cpp qmlprofilersettings.h
|
|
||||||
qmlprofilerstatemanager.cpp qmlprofilerstatemanager.h
|
|
||||||
qmlprofilerstatewidget.cpp qmlprofilerstatewidget.h
|
|
||||||
qmlprofilerstatisticsmodel.cpp qmlprofilerstatisticsmodel.h
|
|
||||||
qmlprofilerstatisticsview.cpp qmlprofilerstatisticsview.h
|
|
||||||
qmlprofilertextmark.cpp qmlprofilertextmark.h
|
|
||||||
qmlprofilertimelinemodel.cpp qmlprofilertimelinemodel.h
|
|
||||||
qmlprofilertool.cpp qmlprofilertool.h
|
|
||||||
qmlprofilertraceclient.cpp qmlprofilertraceclient.h
|
|
||||||
qmlprofilertracefile.cpp qmlprofilertracefile.h
|
|
||||||
qmlprofilertraceview.cpp qmlprofilertraceview.h
|
|
||||||
qmlprofilerviewmanager.cpp qmlprofilerviewmanager.h
|
|
||||||
qmltypedevent.cpp qmltypedevent.h
|
|
||||||
scenegraphtimelinemodel.cpp scenegraphtimelinemodel.h
|
|
||||||
)
|
|
||||||
|
|
||||||
extend_qtc_plugin(QmlProfiler
|
|
||||||
CONDITION WITH_TESTS
|
|
||||||
SOURCES
|
|
||||||
tests/debugmessagesmodel_test.cpp tests/debugmessagesmodel_test.h
|
tests/debugmessagesmodel_test.cpp tests/debugmessagesmodel_test.h
|
||||||
tests/fakedebugserver.cpp tests/fakedebugserver.h
|
tests/fakedebugserver.cpp tests/fakedebugserver.h
|
||||||
tests/flamegraphmodel_test.cpp tests/flamegraphmodel_test.h
|
tests/flamegraphmodel_test.cpp tests/flamegraphmodel_test.h
|
||||||
@@ -70,4 +21,91 @@ extend_qtc_plugin(QmlProfiler
|
|||||||
tests/qmlprofilertraceclient_test.cpp tests/qmlprofilertraceclient_test.h
|
tests/qmlprofilertraceclient_test.cpp tests/qmlprofilertraceclient_test.h
|
||||||
tests/qmlprofilertraceview_test.cpp tests/qmlprofilertraceview_test.h
|
tests/qmlprofilertraceview_test.cpp tests/qmlprofilertraceview_test.h
|
||||||
tests/tests.qrc
|
tests/tests.qrc
|
||||||
|
)
|
||||||
|
else()
|
||||||
|
set(TEST_SOURCES "")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(QMLPROFILER_CPP_SOURCES
|
||||||
|
debugmessagesmodel.cpp debugmessagesmodel.h
|
||||||
|
flamegraphmodel.cpp flamegraphmodel.h
|
||||||
|
flamegraphview.cpp flamegraphview.h
|
||||||
|
inputeventsmodel.cpp inputeventsmodel.h
|
||||||
|
memoryusagemodel.cpp memoryusagemodel.h
|
||||||
|
pixmapcachemodel.cpp pixmapcachemodel.h
|
||||||
|
qmlevent.cpp qmlevent.h
|
||||||
|
qmleventlocation.cpp qmleventlocation.h
|
||||||
|
qmleventtype.cpp qmleventtype.h
|
||||||
|
qmlnote.cpp qmlnote.h
|
||||||
|
qmlprofiler_global.h
|
||||||
|
qmlprofileractions.cpp qmlprofileractions.h
|
||||||
|
qmlprofileranimationsmodel.cpp qmlprofileranimationsmodel.h
|
||||||
|
qmlprofilerattachdialog.cpp qmlprofilerattachdialog.h
|
||||||
|
qmlprofilerbindingloopsrenderpass.cpp qmlprofilerbindingloopsrenderpass.h
|
||||||
|
qmlprofilerclientmanager.cpp qmlprofilerclientmanager.h
|
||||||
|
qmlprofilerconstants.h
|
||||||
|
qmlprofilerdetailsrewriter.cpp qmlprofilerdetailsrewriter.h
|
||||||
|
qmlprofilereventsview.h
|
||||||
|
qmlprofilereventtypes.h
|
||||||
|
qmlprofilermodelmanager.cpp qmlprofilermodelmanager.h
|
||||||
|
qmlprofilernotesmodel.cpp qmlprofilernotesmodel.h
|
||||||
|
qmlprofilerplugin.cpp qmlprofilerplugin.h
|
||||||
|
qmlprofilerrangemodel.cpp qmlprofilerrangemodel.h
|
||||||
|
qmlprofilerrunconfigurationaspect.cpp qmlprofilerrunconfigurationaspect.h
|
||||||
|
qmlprofilerruncontrol.cpp qmlprofilerruncontrol.h
|
||||||
|
qmlprofilersettings.cpp qmlprofilersettings.h
|
||||||
|
qmlprofilerstatemanager.cpp qmlprofilerstatemanager.h
|
||||||
|
qmlprofilerstatewidget.cpp qmlprofilerstatewidget.h
|
||||||
|
qmlprofilerstatisticsmodel.cpp qmlprofilerstatisticsmodel.h
|
||||||
|
qmlprofilerstatisticsview.cpp qmlprofilerstatisticsview.h
|
||||||
|
qmlprofilertextmark.cpp qmlprofilertextmark.h
|
||||||
|
qmlprofilertimelinemodel.cpp qmlprofilertimelinemodel.h
|
||||||
|
qmlprofilertool.cpp qmlprofilertool.h
|
||||||
|
qmlprofilertraceclient.cpp qmlprofilertraceclient.h
|
||||||
|
qmlprofilertracefile.cpp qmlprofilertracefile.h
|
||||||
|
qmlprofilertraceview.cpp qmlprofilertraceview.h
|
||||||
|
qmlprofilerviewmanager.cpp qmlprofilerviewmanager.h
|
||||||
|
qmltypedevent.cpp qmltypedevent.h
|
||||||
|
scenegraphtimelinemodel.cpp scenegraphtimelinemodel.h
|
||||||
)
|
)
|
||||||
|
|
||||||
|
add_qtc_plugin(QmlProfiler
|
||||||
|
DEPENDS QmlDebug QmlJS Tracing Qt5::QuickWidgets
|
||||||
|
PLUGIN_DEPENDS Core Debugger ProjectExplorer QtSupport TextEditor
|
||||||
|
SOURCES
|
||||||
|
${TEST_SOURCES}
|
||||||
|
)
|
||||||
|
|
||||||
|
if(${Qt5_VERSION} VERSION_LESS "6.2.0")
|
||||||
|
extend_qtc_plugin(QmlProfiler
|
||||||
|
SOURCES
|
||||||
|
${QMLPROFILER_CPP_SOURCES}
|
||||||
|
qml/qmlprofiler.qrc
|
||||||
|
)
|
||||||
|
else() # < Qt 6.2
|
||||||
|
set(QMLPROFILER_QML_FILES
|
||||||
|
qml/QmlProfilerFlameGraphView.qml
|
||||||
|
)
|
||||||
|
|
||||||
|
set(QMLPROFILER_QML_RESOURCES
|
||||||
|
qml/bindingloops.frag
|
||||||
|
qml/bindingloops.vert
|
||||||
|
)
|
||||||
|
|
||||||
|
foreach(file IN LISTS QMLPROFILER_QML_FILES QMLPROFILER_QML_RESOURCES)
|
||||||
|
get_filename_component(fileName "${file}" NAME)
|
||||||
|
set_source_files_properties("${file}" PROPERTIES QT_RESOURCE_ALIAS "${fileName}")
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
qt_add_qml_module(QmlProfiler
|
||||||
|
URI "QtCreator.QmlProfiler"
|
||||||
|
VERSION "1.0"
|
||||||
|
NO_CREATE_PLUGIN_TARGET
|
||||||
|
QML_FILES
|
||||||
|
${QMLPROFILER_QML_FILES}
|
||||||
|
RESOURCES
|
||||||
|
${QMLPROFILER_QML_RESOURCES}
|
||||||
|
SOURCES
|
||||||
|
${QMLPROFILER_CPP_SOURCES}
|
||||||
|
)
|
||||||
|
endif() # < Qt 6.2
|
||||||
|
|||||||
@@ -55,6 +55,10 @@ struct FlameGraphData {
|
|||||||
class FlameGraphModel : public QAbstractItemModel
|
class FlameGraphModel : public QAbstractItemModel
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 2, 0)
|
||||||
|
QML_NAMED_ELEMENT(QmlProfilerFlameGraphModel)
|
||||||
|
QML_UNCREATABLE("use the context property")
|
||||||
|
#endif // Qt >= 6.2
|
||||||
public:
|
public:
|
||||||
enum Role {
|
enum Role {
|
||||||
TypeIdRole = Qt::UserRole + 1, // Sort by data, not by displayed string
|
TypeIdRole = Qt::UserRole + 1, // Sort by data, not by displayed string
|
||||||
|
|||||||
@@ -48,15 +48,16 @@ FlameGraphView::FlameGraphView(QmlProfilerModelManager *manager, QWidget *parent
|
|||||||
|
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 2, 0)
|
#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"));
|
||||||
|
#endif // Qt < 6.2
|
||||||
|
|
||||||
Timeline::TimelineTheme::setupTheme(m_content->engine());
|
Timeline::TimelineTheme::setupTheme(m_content->engine());
|
||||||
|
|
||||||
m_content->rootContext()->setContextProperty(QStringLiteral("flameGraphModel"), m_model);
|
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->setClearColor(Utils::creatorTheme()->color(Utils::Theme::Timeline_BackgroundColor1));
|
||||||
|
|
||||||
m_content->setResizeMode(QQuickWidget::SizeRootObjectToView);
|
m_content->setResizeMode(QQuickWidget::SizeRootObjectToView);
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
import QtCreator.QmlProfiler 1.0
|
import QtCreator.QmlProfiler 1.0
|
||||||
import "../QtCreator/Tracing/" // TODO: Turn into module import when possible
|
import "../Tracing" // TODO: Turn into module import when possible
|
||||||
|
|
||||||
FlameGraphView {
|
FlameGraphView {
|
||||||
id: root
|
id: root
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<RCC>
|
<RCC>
|
||||||
<qresource prefix="/qmlprofiler">
|
<qresource prefix="/QtCreator/QmlProfiler">
|
||||||
<file>bindingloops.vert</file>
|
<file>bindingloops.vert</file>
|
||||||
<file>bindingloops.frag</file>
|
<file>bindingloops.frag</file>
|
||||||
<file>QmlProfilerFlameGraphView.qml</file>
|
<file>QmlProfilerFlameGraphView.qml</file>
|
||||||
|
|||||||
@@ -317,11 +317,13 @@ BindingLoopMaterialShader::BindingLoopMaterialShader()
|
|||||||
: QSGMaterialShader()
|
: QSGMaterialShader()
|
||||||
{
|
{
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||||
setShaderSourceFile(QOpenGLShader::Vertex, QStringLiteral(":/qmlprofiler/bindingloops.vert"));
|
setShaderSourceFile(QOpenGLShader::Vertex,
|
||||||
setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/qmlprofiler/bindingloops.frag"));
|
QStringLiteral(":/QtCreator/QmlProfiler/bindingloops.vert"));
|
||||||
|
setShaderSourceFile(QOpenGLShader::Fragment,
|
||||||
|
QStringLiteral(":/QtCreator/QmlProfiler/bindingloops.frag"));
|
||||||
#else // < Qt 6
|
#else // < Qt 6
|
||||||
setShaderFileName(VertexStage, ":/qmlprofiler/bindingloops.vert");
|
setShaderFileName(VertexStage, ":/QtCreator/QmlProfiler/bindingloops.vert");
|
||||||
setShaderFileName(FragmentStage, ":/qmlprofiler/bindingloops.frag");
|
setShaderFileName(FragmentStage, ":/QtCreator/QmlProfiler/bindingloops.frag");
|
||||||
#endif // < Qt 6
|
#endif // < Qt 6
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user