1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QQMLDEBUGSERVICEINTERFACES_P_H
5#define QQMLDEBUGSERVICEINTERFACES_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtCore/qstring.h>
19#include <private/qtqmlglobal_p.h>
20#if QT_CONFIG(qml_debug)
21#include <private/qqmldebugservice_p.h>
22#endif
23#include <private/qqmldebugstatesdelegate_p.h>
24#include <private/qqmlboundsignal_p.h>
25#include <private/qqmltranslation_p.h>
26
27#include <limits>
28
29QT_BEGIN_NAMESPACE
30
31class QWindow;
32class QQuickWindow;
33
34
35#if !QT_CONFIG(qml_debug)
36
37class TranslationBindingInformation;
38
39class QV4DebugService
40{
41public:
42 void signalEmitted(const QString &) {}
43};
44
45class QQmlProfilerService
46{
47public:
48 void startProfiling(QJSEngine *engine, quint64 features = std::numeric_limits<quint64>::max())
49 {
50 Q_UNUSED(engine);
51 Q_UNUSED(features);
52 }
53
54 void stopProfiling(QJSEngine *) {}
55};
56
57class QQmlEngineDebugService
58{
59public:
60 void objectCreated(QJSEngine *, QObject *) {}
61 static void setStatesDelegateFactory(QQmlDebugStatesDelegate *(*)()) {}
62};
63
64class QQmlInspectorService {
65public:
66 void addWindow(QQuickWindow *) {}
67 void setParentWindow(QQuickWindow *, QWindow *) {}
68 void removeWindow(QQuickWindow *) {}
69};
70
71class QDebugMessageService {};
72class QQmlEngineControlService {};
73class QQmlNativeDebugService {};
74class QQmlDebugTranslationService {
75public:
76 virtual void foundTranslationBinding(const TranslationBindingInformation &) {}
77};
78
79#else
80
81class Q_QML_PRIVATE_EXPORT QV4DebugService : public QQmlDebugService
82{
83 Q_OBJECT
84public:
85 ~QV4DebugService() override;
86
87 static const QString s_key;
88
89 virtual void signalEmitted(const QString &signal) = 0;
90
91protected:
92 friend class QQmlDebugConnector;
93
94 explicit QV4DebugService(float version, QObject *parent = nullptr) :
95 QQmlDebugService(s_key, version, parent) {}
96};
97
98class QQmlAbstractProfilerAdapter;
99class Q_QML_PRIVATE_EXPORT QQmlProfilerService : public QQmlDebugService
100{
101 Q_OBJECT
102public:
103 ~QQmlProfilerService() override;
104
105 static const QString s_key;
106
107 virtual void addGlobalProfiler(QQmlAbstractProfilerAdapter *profiler) = 0;
108 virtual void removeGlobalProfiler(QQmlAbstractProfilerAdapter *profiler) = 0;
109
110 virtual void startProfiling(QJSEngine *engine,
111 quint64 features = std::numeric_limits<quint64>::max()) = 0;
112 virtual void stopProfiling(QJSEngine *engine) = 0;
113
114 virtual void dataReady(QQmlAbstractProfilerAdapter *profiler) = 0;
115
116protected:
117 friend class QQmlDebugConnector;
118
119 explicit QQmlProfilerService(float version, QObject *parent = nullptr) :
120 QQmlDebugService(s_key, version, parent) {}
121};
122
123class Q_QML_PRIVATE_EXPORT QQmlEngineDebugService : public QQmlDebugService
124{
125 Q_OBJECT
126public:
127 ~QQmlEngineDebugService() override;
128
129 static const QString s_key;
130
131 virtual void objectCreated(QJSEngine *engine, QObject *object) = 0;
132 static void setStatesDelegateFactory(QQmlDebugStatesDelegate *(*factory)());
133 static QQmlDebugStatesDelegate *createStatesDelegate();
134
135protected:
136 friend class QQmlDebugConnector;
137
138 explicit QQmlEngineDebugService(float version, QObject *parent = nullptr) :
139 QQmlDebugService(s_key, version, parent) {}
140
141 QQmlBoundSignal *nextSignal(QQmlBoundSignal *prev) { return prev->m_nextSignal; }
142};
143
144#if QT_CONFIG(translation)
145struct TranslationBindingInformation
146{
147 static const TranslationBindingInformation
148 create(const QQmlRefPointer<QV4::ExecutableCompilationUnit> &compilationUnit,
149 const QV4::CompiledData::Binding *binding, QObject *scopeObject,
150 QQmlRefPointer<QQmlContextData> ctxt);
151
152 QQmlRefPointer<QV4::ExecutableCompilationUnit> compilationUnit;
153 QObject *scopeObject;
154 QQmlRefPointer<QQmlContextData> ctxt;
155
156 QString propertyName;
157 QQmlTranslation translation;
158
159 quint32 line;
160 quint32 column;
161};
162
163class Q_QML_PRIVATE_EXPORT QQmlDebugTranslationService : public QQmlDebugService
164{
165 Q_OBJECT
166public:
167 ~QQmlDebugTranslationService() override;
168
169 static const QString s_key;
170
171 virtual void foundTranslationBinding(const TranslationBindingInformation &translationBindingInformation) = 0;
172protected:
173 friend class QQmlDebugConnector;
174
175 explicit QQmlDebugTranslationService(float version, QObject *parent = nullptr) :
176 QQmlDebugService(s_key, version, parent) {}
177
178};
179#endif //QT_CONFIG(translation)
180
181class Q_QML_PRIVATE_EXPORT QQmlInspectorService : public QQmlDebugService
182{
183 Q_OBJECT
184public:
185 ~QQmlInspectorService() override;
186
187 static const QString s_key;
188
189 virtual void addWindow(QQuickWindow *) = 0;
190 virtual void setParentWindow(QQuickWindow *, QWindow *) = 0;
191 virtual void removeWindow(QQuickWindow *) = 0;
192
193protected:
194 friend class QQmlDebugConnector;
195
196 explicit QQmlInspectorService(float version, QObject *parent = nullptr) :
197 QQmlDebugService(s_key, version, parent) {}
198};
199
200class Q_QML_PRIVATE_EXPORT QDebugMessageService : public QQmlDebugService
201{
202 Q_OBJECT
203public:
204 ~QDebugMessageService() override;
205
206 static const QString s_key;
207
208 virtual void synchronizeTime(const QElapsedTimer &otherTimer) = 0;
209
210protected:
211 friend class QQmlDebugConnector;
212
213 explicit QDebugMessageService(float version, QObject *parent = nullptr) :
214 QQmlDebugService(s_key, version, parent) {}
215};
216
217class Q_QML_PRIVATE_EXPORT QQmlEngineControlService : public QQmlDebugService
218{
219 Q_OBJECT
220public:
221 ~QQmlEngineControlService() override;
222
223 static const QString s_key;
224
225protected:
226 friend class QQmlDebugConnector;
227
228 QQmlEngineControlService(float version, QObject *parent = nullptr) :
229 QQmlDebugService(s_key, version, parent) {}
230
231};
232
233class Q_QML_PRIVATE_EXPORT QQmlNativeDebugService : public QQmlDebugService
234{
235 Q_OBJECT
236public:
237 ~QQmlNativeDebugService() override;
238
239 static const QString s_key;
240
241protected:
242 friend class QQmlDebugConnector;
243
244 explicit QQmlNativeDebugService(float version, QObject *parent = nullptr)
245 : QQmlDebugService(s_key, version, parent) {}
246};
247
248#endif
249
250QT_END_NAMESPACE
251
252#endif // QQMLDEBUGSERVICEINTERFACES_P_H
253
254

source code of qtdeclarative/src/qml/debugger/qqmldebugserviceinterfaces_p.h