Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qqmlinspectorservice.cpp
Go to the documentation of this file.
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#include <private/qqmldebugserviceinterfaces_p.h>
5#include <private/qqmldebugservicefactory_p.h>
6
7#include "globalinspector.h"
9
10#include <QtGui/QWindow>
11
13
15{
17public:
18 QQmlInspectorServiceImpl(QObject *parent = nullptr);
19
20 void addWindow(QQuickWindow *window) override;
21 void setParentWindow(QQuickWindow *window, QWindow *parent) override;
22 void removeWindow(QQuickWindow *window) override;
23
26
27protected:
28 void messageReceived(const QByteArray &) override;
29
30private:
32
33 QmlJSDebugger::GlobalInspector *checkInspector();
34 QmlJSDebugger::GlobalInspector *m_globalInspector;
35 QHash<QQuickWindow *, QWindow *> m_waitingWindows;
36
37 void messageFromClient(const QByteArray &message);
38};
39
41 QQmlInspectorService(1, parent), m_globalInspector(nullptr)
42{
44 this, &QQmlInspectorServiceImpl::messageFromClient, Qt::QueuedConnection);
45}
46
47QmlJSDebugger::GlobalInspector *QQmlInspectorServiceImpl::checkInspector()
48{
49 if (state() == Enabled) {
50 if (!m_globalInspector) {
51 m_globalInspector = new QmlJSDebugger::GlobalInspector(this);
55 i != m_waitingWindows.constEnd(); ++i) {
56 m_globalInspector->addWindow(i.key());
57 if (i.value() != 0)
58 m_globalInspector->setParentWindow(i.key(), i.value());
59 }
60 m_waitingWindows.clear();
61 }
62 } else if (m_globalInspector) {
63 delete m_globalInspector;
64 m_globalInspector = nullptr;
65 }
66 return m_globalInspector;
67}
68
70{
71 if (QmlJSDebugger::GlobalInspector *inspector = checkInspector())
72 inspector->addWindow(window);
73 else
74 m_waitingWindows.insert(window, 0);
75}
76
78{
79 if (QmlJSDebugger::GlobalInspector *inspector = checkInspector())
80 inspector->removeWindow(window);
81 else
82 m_waitingWindows.remove(window);
83}
84
86{
87 if (QmlJSDebugger::GlobalInspector *inspector = checkInspector())
88 inspector->setParentWindow(window, parent);
89 else
90 m_waitingWindows[window] = parent;
91}
92
94{
95 // Move the message to the right thread via queued signal
97}
98
99void QQmlInspectorServiceImpl::messageFromClient(const QByteArray &message)
100{
101 if (QmlJSDebugger::GlobalInspector *inspector = checkInspector())
102 inspector->processMessage(message);
103}
104
106{
108 Q_PLUGIN_METADATA(IID QQmlDebugServiceFactory_iid FILE "qqmlinspectorservice.json")
109public:
110 QQmlDebugService *create(const QString &key) override;
111};
112
114{
115 return key == QQmlInspectorServiceImpl::s_key ? new QQmlInspectorServiceImpl(this) : nullptr;
116}
117
119
120#include "qqmlinspectorservice.moc"
\inmodule QtCore
Definition qbytearray.h:57
\inmodule QtCore
Definition qhash.h:1145
bool remove(const Key &key)
Removes the item that has the key from the hash.
Definition qhash.h:958
const_iterator constEnd() const noexcept
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the imaginary item after the ...
Definition qhash.h:1219
const_iterator constBegin() const noexcept
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the first item in the hash.
Definition qhash.h:1215
void clear() noexcept(std::is_nothrow_destructible< Node >::value)
Removes all items from the hash and frees up all memory used by it.
Definition qhash.h:951
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
Definition qhash.h:1303
\inmodule QtCore
Definition qobject.h:103
QObject * parent() const
Returns a pointer to the parent object.
Definition qobject.h:346
void messageToClient(const QString &name, const QByteArray &message)
QQmlDebugService * create(const QString &key) override
void setParentWindow(QQuickWindow *window, QWindow *parent) override
void messageReceived(const QByteArray &) override
void removeWindow(QQuickWindow *window) override
void scheduleMessage(const QByteArray &message)
void addWindow(QQuickWindow *window) override
QQmlInspectorServiceImpl(QObject *parent=nullptr)
\qmltype Window \instantiates QQuickWindow \inqmlmodule QtQuick
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
\inmodule QtGui
Definition qwindow.h:63
void setParentWindow(QQuickWindow *window, QWindow *parentWindow)
void messageToClient(const QString &name, const QByteArray &data)
void addWindow(QQuickWindow *window)
else opt state
[0]
Combined button and popup list for selecting options.
@ QueuedConnection
GLuint64 key
GLuint GLsizei const GLchar * message
#define QQmlDebugServiceFactory_iid
#define Q_OBJECT
#define Q_PLUGIN_METADATA(x)
#define signals
#define emit
connect(quitButton, &QPushButton::clicked, &app, &QCoreApplication::quit, Qt::QueuedConnection)
QObject::connect nullptr
aWidget window() -> setWindowTitle("New Window Title")
[2]
view create()