diff options
author | Ulf Hermann <ulf.hermann@theqtcompany.com> | 2015-11-19 17:14:23 +0100 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@theqtcompany.com> | 2016-01-12 18:00:47 +0000 |
commit | 258638f3726f63b308b6275090b1dad596f4fb56 (patch) | |
tree | cbbcfe5772a90b8e2dd0cfe493be465f9bc2003f /tests/auto/qml/debugger/shared | |
parent | 11bd376d1399faff71ff17af9ee10f61b959901b (diff) |
Rewrite inspector service
The inspector service had bitrotted to a point where there was little
code to be rescued. Apparently it was never really finished and quite
some code didn't make any sense. This change removes some features
that were unused or didn't work correctly:
1. Panning and Zooming with mouse wheel and touch interaction. This
might be useful in some contexts, but the implementation was so broken
that it wasn't worth trying to fix it. The whole idea of doing this on
the layer of QQuickItems is not so great because there is no
distinction between spontaneous changes triggered by the application
and debugging interaction triggered from outside. It might be better to
implement such functionality on a lower level, e.g. in the renderer.
2. Reloading the scene with debug changes. Use one of the other debug
services to change properties. Clearing the component cache is a rather
drastic measure and not necessary here.
In turn, we get support for inspecting multiple windows, and all
subclasses of QQuickWindow are supported now. Also, show-on-top works
now.
Task-number: QTBUG-33376
Change-Id: I65497f49c6b46128a600b0e3a31483eeef40313c
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
Diffstat (limited to 'tests/auto/qml/debugger/shared')
-rw-r--r-- | tests/auto/qml/debugger/shared/debugutil_p.h | 19 | ||||
-rw-r--r-- | tests/auto/qml/debugger/shared/qqmlinspectorclient.cpp | 73 | ||||
-rw-r--r-- | tests/auto/qml/debugger/shared/qqmlinspectorclient.h | 29 |
3 files changed, 94 insertions, 27 deletions
diff --git a/tests/auto/qml/debugger/shared/debugutil_p.h b/tests/auto/qml/debugger/shared/debugutil_p.h index d29bef4362..38e6cb2b12 100644 --- a/tests/auto/qml/debugger/shared/debugutil_p.h +++ b/tests/auto/qml/debugger/shared/debugutil_p.h @@ -130,4 +130,23 @@ private: int m_receivedBindErrors; }; +class QQmlInspectorResultRecipient : public QObject +{ + Q_OBJECT +public: + QQmlInspectorResultRecipient(QObject *parent = 0) : + QObject(parent), lastResponseId(-1), lastResult(false) {} + + int lastResponseId; + bool lastResult; + +public slots: + + void recordResponse(int requestId, bool result) + { + lastResponseId = requestId; + lastResult = result; + } +}; + #endif // DEBUGUTIL_P_H diff --git a/tests/auto/qml/debugger/shared/qqmlinspectorclient.cpp b/tests/auto/qml/debugger/shared/qqmlinspectorclient.cpp index 5fce58c17d..e313f75844 100644 --- a/tests/auto/qml/debugger/shared/qqmlinspectorclient.cpp +++ b/tests/auto/qml/debugger/shared/qqmlinspectorclient.cpp @@ -37,24 +37,78 @@ #include <private/qqmldebugconnection_p.h> #include <QtCore/qdebug.h> -void QQmlInspectorClient::setShowAppOnTop(bool showOnTop) +QQmlInspectorClient::QQmlInspectorClient(QQmlDebugConnection *connection) : + QQmlDebugClient(QLatin1String("QmlInspector"), connection), + m_lastRequestId(-1) +{ +} + +int QQmlInspectorClient::setInspectToolEnabled(bool enabled) { QPacket ds(connection()->currentDataStreamVersion()); - ds << QByteArray("request") << m_requestId++ + ds << QByteArray("request") << ++m_lastRequestId + << QByteArray(enabled ? "enable" : "disable"); + + sendMessage(ds.data()); + return m_lastRequestId; +} + +int QQmlInspectorClient::setShowAppOnTop(bool showOnTop) +{ + QPacket ds(connection()->currentDataStreamVersion()); + ds << QByteArray("request") << ++m_lastRequestId << QByteArray("showAppOnTop") << showOnTop; sendMessage(ds.data()); + return m_lastRequestId; } -void QQmlInspectorClient::reloadQml(const QHash<QString, QByteArray> &changesHash) +int QQmlInspectorClient::setAnimationSpeed(qreal speed) { QPacket ds(connection()->currentDataStreamVersion()); - m_reloadRequestId = m_requestId; + ds << QByteArray("request") << ++m_lastRequestId + << QByteArray("setAnimationSpeed") << speed; - ds << QByteArray("request") << m_requestId++ - << QByteArray("reload") << changesHash; + sendMessage(ds.data()); + return m_lastRequestId; +} +int QQmlInspectorClient::select(const QList<int> &objectIds) +{ + QPacket ds(connection()->currentDataStreamVersion()); + ds << QByteArray("request") << ++m_lastRequestId + << QByteArray("select") << objectIds; + + sendMessage(ds.data()); + return m_lastRequestId; +} + +int QQmlInspectorClient::createObject(const QString &qml, int parentId, const QStringList &imports, + const QString &filename) +{ + QPacket ds(connection()->currentDataStreamVersion()); + ds << QByteArray("request") << ++m_lastRequestId + << QByteArray("createObject") << qml << parentId << imports << filename; + sendMessage(ds.data()); + return m_lastRequestId; +} + +int QQmlInspectorClient::moveObject(int childId, int newParentId) +{ + QPacket ds(connection()->currentDataStreamVersion()); + ds << QByteArray("request") << ++m_lastRequestId + << QByteArray("moveObject") << childId << newParentId; + sendMessage(ds.data()); + return m_lastRequestId; +} + +int QQmlInspectorClient::destroyObject(int objectId) +{ + QPacket ds(connection()->currentDataStreamVersion()); + ds << QByteArray("request") << ++m_lastRequestId + << QByteArray("destroyObject") << objectId; sendMessage(ds.data()); + return m_lastRequestId; } void QQmlInspectorClient::messageReceived(const QByteArray &message) @@ -68,7 +122,8 @@ void QQmlInspectorClient::messageReceived(const QByteArray &message) return; } - m_requestResult = false; - ds >> m_responseId >> m_requestResult; - emit responseReceived(); + int responseId; + bool result; + ds >> responseId >> result; + emit responseReceived(responseId, result); } diff --git a/tests/auto/qml/debugger/shared/qqmlinspectorclient.h b/tests/auto/qml/debugger/shared/qqmlinspectorclient.h index 964dac7701..9306ef3e79 100644 --- a/tests/auto/qml/debugger/shared/qqmlinspectorclient.h +++ b/tests/auto/qml/debugger/shared/qqmlinspectorclient.h @@ -40,32 +40,25 @@ class QQmlInspectorClient : public QQmlDebugClient Q_OBJECT public: - QQmlInspectorClient(QQmlDebugConnection *connection) - : QQmlDebugClient(QLatin1String("QmlInspector"), connection) - , m_showAppOnTop(false) - , m_requestId(0) - , m_requestResult(false) - , m_responseId(-1) - { - } + QQmlInspectorClient(QQmlDebugConnection *connection); - void setShowAppOnTop(bool showOnTop); - void reloadQml(const QHash<QString, QByteArray> &changesHash); + int setInspectToolEnabled(bool enabled); + int setShowAppOnTop(bool showOnTop); + int setAnimationSpeed(qreal speed); + int select(const QList<int> &objectIds); + int createObject(const QString &qml, int parentId, const QStringList &imports, + const QString &filename); + int moveObject(int childId, int newParentId); + int destroyObject(int objectId); signals: - void responseReceived(); + void responseReceived(int requestId, bool result); protected: void messageReceived(const QByteArray &message); private: - bool m_showAppOnTop; - int m_requestId; - -public: - bool m_requestResult; - int m_responseId; - int m_reloadRequestId; + int m_lastRequestId; }; #endif // QQMLINSPECTORCLIENT_H |