| 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 GLOBALINSPECTOR_H |
| 5 | #define GLOBALINSPECTOR_H |
| 6 | |
| 7 | #include "qquickwindowinspector.h" |
| 8 | |
| 9 | #include <QtCore/QObject> |
| 10 | #include <QtCore/QPointer> |
| 11 | #include <QtCore/QHash> |
| 12 | #include <QtQuick/QQuickItem> |
| 13 | |
| 14 | QT_BEGIN_NAMESPACE |
| 15 | |
| 16 | namespace QmlJSDebugger { |
| 17 | |
| 18 | class SelectionHighlight; |
| 19 | |
| 20 | class GlobalInspector : public QObject |
| 21 | { |
| 22 | Q_OBJECT |
| 23 | public: |
| 24 | GlobalInspector(QObject *parent = nullptr) : QObject(parent), m_eventId(0) {} |
| 25 | ~GlobalInspector(); |
| 26 | |
| 27 | void setSelectedItems(const QList<QQuickItem *> &items); |
| 28 | void showSelectedItemName(QQuickItem *item, const QPointF &point); |
| 29 | |
| 30 | void addWindow(QQuickWindow *window); |
| 31 | void setParentWindow(QQuickWindow *window, QWindow *parentWindow); |
| 32 | void setQmlEngine(QQuickWindow *window, QQmlEngine *engine); |
| 33 | void removeWindow(QQuickWindow *window); |
| 34 | void processMessage(const QByteArray &message); |
| 35 | |
| 36 | Q_SIGNALS: |
| 37 | void messageToClient(const QString &name, const QByteArray &data); |
| 38 | |
| 39 | private: |
| 40 | void sendResult(int requestId, bool success); |
| 41 | void sendCurrentObjects(const QList<QObject *> &objects); |
| 42 | void removeFromSelectedItems(QObject *object); |
| 43 | QString titleForItem(QQuickItem *item) const; |
| 44 | QString idStringForObject(QObject *obj) const; |
| 45 | bool createQmlObject(int requestId, const QString &qml, QObject *parent, |
| 46 | const QStringList &importList, const QString &filename); |
| 47 | bool destroyQmlObject(QObject *object, int requestId, int debugId); |
| 48 | bool syncSelectedItems(const QList<QQuickItem *> &items); |
| 49 | |
| 50 | QList<QQuickItem *> m_selectedItems; |
| 51 | QHash<QQuickItem *, SelectionHighlight *> m_highlightItems; |
| 52 | QList<QQuickWindowInspector *> m_windowInspectors; |
| 53 | int m_eventId; |
| 54 | }; |
| 55 | |
| 56 | } // QmlJSDebugger |
| 57 | |
| 58 | QT_END_NAMESPACE |
| 59 | |
| 60 | #endif // GLOBALINSPECTOR_H |
| 61 | |