1 | // Copyright (C) 2016 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 |
3 | |
4 | #include "qmlprofilerclient.h" |
5 | #include "qmlprofilerdata.h" |
6 | |
7 | #include <private/qqmlprofilerclient_p_p.h> |
8 | |
9 | #include <QtCore/QStack> |
10 | #include <QtCore/QStringList> |
11 | |
12 | #include <limits> |
13 | |
14 | class QmlProfilerClientPrivate : public QQmlProfilerClientPrivate |
15 | { |
16 | Q_DECLARE_PUBLIC(QmlProfilerClient) |
17 | public: |
18 | QmlProfilerClientPrivate(QQmlDebugConnection *connection, QmlProfilerData *data); |
19 | |
20 | QmlProfilerData *data; |
21 | bool enabled; |
22 | }; |
23 | |
24 | QmlProfilerClientPrivate::QmlProfilerClientPrivate(QQmlDebugConnection *connection, |
25 | QmlProfilerData *data) : |
26 | QQmlProfilerClientPrivate(connection, data), data(data), enabled(false) |
27 | { |
28 | } |
29 | |
30 | QmlProfilerClient::QmlProfilerClient(QQmlDebugConnection *connection, QmlProfilerData *data) : |
31 | QQmlProfilerClient(*(new QmlProfilerClientPrivate(connection, data))) |
32 | { |
33 | Q_D(QmlProfilerClient); |
34 | setRequestedFeatures(std::numeric_limits<quint64>::max()); |
35 | connect(sender: this, signal: &QQmlDebugClient::stateChanged, |
36 | context: this, slot: &QmlProfilerClient::onStateChanged); |
37 | connect(sender: this, signal: &QQmlProfilerClient::traceStarted, |
38 | context: d->data, slot: &QmlProfilerData::setTraceStartTime); |
39 | connect(sender: this, signal: &QQmlProfilerClient::traceFinished, |
40 | context: d->data, slot: &QmlProfilerData::setTraceEndTime); |
41 | connect(sender: this, signal: &QQmlProfilerClient::complete, |
42 | context: d->data, slot: &QmlProfilerData::complete); |
43 | } |
44 | |
45 | void QmlProfilerClient::onStateChanged(State state) |
46 | { |
47 | Q_D(QmlProfilerClient); |
48 | if ((d->enabled && state != Enabled) || (!d->enabled && state == Enabled)) { |
49 | d->enabled = (state == Enabled); |
50 | emit enabledChanged(enabled: d->enabled); |
51 | } |
52 | } |
53 | |
54 | #include "moc_qmlprofilerclient.cpp" |
55 | |