| 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 | |
| 29 | QT_BEGIN_NAMESPACE |
| 30 | |
| 31 | class QWindow; |
| 32 | class QQuickWindow; |
| 33 | |
| 34 | |
| 35 | #if !QT_CONFIG(qml_debug) |
| 36 | |
| 37 | class TranslationBindingInformation; |
| 38 | |
| 39 | class QV4DebugService |
| 40 | { |
| 41 | public: |
| 42 | void signalEmitted(const QString &) {} |
| 43 | }; |
| 44 | |
| 45 | class QQmlProfilerService |
| 46 | { |
| 47 | public: |
| 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 | |
| 57 | class QQmlEngineDebugService |
| 58 | { |
| 59 | public: |
| 60 | void objectCreated(QJSEngine *, QObject *) {} |
| 61 | static void setStatesDelegateFactory(QQmlDebugStatesDelegate *(*)()) {} |
| 62 | }; |
| 63 | |
| 64 | class QQmlInspectorService { |
| 65 | public: |
| 66 | void addWindow(QQuickWindow *) {} |
| 67 | void setParentWindow(QQuickWindow *, QWindow *) {} |
| 68 | void removeWindow(QQuickWindow *) {} |
| 69 | }; |
| 70 | |
| 71 | class QDebugMessageService {}; |
| 72 | class QQmlEngineControlService {}; |
| 73 | class QQmlNativeDebugService {}; |
| 74 | class QQmlDebugTranslationService { |
| 75 | public: |
| 76 | virtual void foundTranslationBinding(const TranslationBindingInformation &) {} |
| 77 | }; |
| 78 | |
| 79 | #else |
| 80 | |
| 81 | class Q_QML_EXPORT QV4DebugService : public QQmlDebugService |
| 82 | { |
| 83 | Q_OBJECT |
| 84 | public: |
| 85 | ~QV4DebugService() override; |
| 86 | |
| 87 | static const QString s_key; |
| 88 | |
| 89 | virtual void signalEmitted(const QString &signal) = 0; |
| 90 | |
| 91 | protected: |
| 92 | friend class QQmlDebugConnector; |
| 93 | |
| 94 | explicit QV4DebugService(float version, QObject *parent = nullptr) : |
| 95 | QQmlDebugService(s_key, version, parent) {} |
| 96 | }; |
| 97 | |
| 98 | class QQmlAbstractProfilerAdapter; |
| 99 | class Q_QML_EXPORT QQmlProfilerService : public QQmlDebugService |
| 100 | { |
| 101 | Q_OBJECT |
| 102 | public: |
| 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 | |
| 116 | protected: |
| 117 | friend class QQmlDebugConnector; |
| 118 | |
| 119 | explicit QQmlProfilerService(float version, QObject *parent = nullptr) : |
| 120 | QQmlDebugService(s_key, version, parent) {} |
| 121 | }; |
| 122 | |
| 123 | class Q_QML_EXPORT QQmlEngineDebugService : public QQmlDebugService |
| 124 | { |
| 125 | Q_OBJECT |
| 126 | public: |
| 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 | |
| 135 | protected: |
| 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) |
| 145 | struct 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 | |
| 163 | class Q_QML_EXPORT QQmlDebugTranslationService : public QQmlDebugService |
| 164 | { |
| 165 | Q_OBJECT |
| 166 | public: |
| 167 | ~QQmlDebugTranslationService() override; |
| 168 | |
| 169 | static const QString s_key; |
| 170 | |
| 171 | virtual void foundTranslationBinding(const TranslationBindingInformation &translationBindingInformation) = 0; |
| 172 | protected: |
| 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 | |
| 181 | class Q_QML_EXPORT QQmlInspectorService : public QQmlDebugService |
| 182 | { |
| 183 | Q_OBJECT |
| 184 | public: |
| 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 | |
| 193 | protected: |
| 194 | friend class QQmlDebugConnector; |
| 195 | |
| 196 | explicit QQmlInspectorService(float version, QObject *parent = nullptr) : |
| 197 | QQmlDebugService(s_key, version, parent) {} |
| 198 | }; |
| 199 | |
| 200 | class Q_QML_EXPORT QDebugMessageService : public QQmlDebugService |
| 201 | { |
| 202 | Q_OBJECT |
| 203 | public: |
| 204 | ~QDebugMessageService() override; |
| 205 | |
| 206 | static const QString s_key; |
| 207 | |
| 208 | virtual void synchronizeTime(const QElapsedTimer &otherTimer) = 0; |
| 209 | |
| 210 | protected: |
| 211 | friend class QQmlDebugConnector; |
| 212 | |
| 213 | explicit QDebugMessageService(float version, QObject *parent = nullptr) : |
| 214 | QQmlDebugService(s_key, version, parent) {} |
| 215 | }; |
| 216 | |
| 217 | class Q_QML_EXPORT QQmlEngineControlService : public QQmlDebugService |
| 218 | { |
| 219 | Q_OBJECT |
| 220 | public: |
| 221 | ~QQmlEngineControlService() override; |
| 222 | |
| 223 | static const QString s_key; |
| 224 | |
| 225 | protected: |
| 226 | friend class QQmlDebugConnector; |
| 227 | |
| 228 | QQmlEngineControlService(float version, QObject *parent = nullptr) : |
| 229 | QQmlDebugService(s_key, version, parent) {} |
| 230 | |
| 231 | }; |
| 232 | |
| 233 | class Q_QML_EXPORT QQmlNativeDebugService : public QQmlDebugService |
| 234 | { |
| 235 | Q_OBJECT |
| 236 | public: |
| 237 | ~QQmlNativeDebugService() override; |
| 238 | |
| 239 | static const QString s_key; |
| 240 | |
| 241 | protected: |
| 242 | friend class QQmlDebugConnector; |
| 243 | |
| 244 | explicit QQmlNativeDebugService(float version, QObject *parent = nullptr) |
| 245 | : QQmlDebugService(s_key, version, parent) {} |
| 246 | }; |
| 247 | |
| 248 | #endif |
| 249 | |
| 250 | QT_END_NAMESPACE |
| 251 | |
| 252 | #endif // QQMLDEBUGSERVICEINTERFACES_P_H |
| 253 | |
| 254 | |