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 | // Hash< object to be destroyed, QPair<destroy eventId, object debugId> > |
51 | QList<QQuickItem *> m_selectedItems; |
52 | QHash<QQuickItem *, SelectionHighlight *> m_highlightItems; |
53 | QList<QQuickWindowInspector *> m_windowInspectors; |
54 | int m_eventId; |
55 | }; |
56 | |
57 | } // QmlJSDebugger |
58 | |
59 | QT_END_NAMESPACE |
60 | |
61 | #endif // GLOBALINSPECTOR_H |
62 | |