QmlJSInspector: Add QmlToolsClient for QmlInspector Service

QmlInspector Service replaces the QDeclarativeObserverMode
service in Qt5. This patch adds a new client for the service.

Change-Id: Id79c378cfd88042fdf264cd7416a213a139e618c
Reviewed-by: Kai Koehne <kai.koehne@nokia.com>
This commit is contained in:
Aurindam Jana
2012-04-24 12:23:54 +02:00
parent f4514a2f5c
commit e9df42223c
12 changed files with 879 additions and 290 deletions

View File

@@ -0,0 +1,58 @@
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this file.
** Please review the following information to ensure the GNU Lesser General
** Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** Other Usage
**
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
**
**************************************************************************/
#include "basetoolsclient.h"
namespace QmlJSInspector {
namespace Internal {
BaseToolsClient::BaseToolsClient(QmlDebug::QmlDebugConnection* client, QLatin1String clientName)
: QmlDebugClient(clientName, client)
{
setObjectName(clientName);
}
void BaseToolsClient::statusChanged(Status status)
{
emit connectedStatusChanged(status);
}
void BaseToolsClient::recurseObjectIdList(const QmlDebug::QmlDebugObjectReference &ref,
QList<int> &debugIds, QList<QString> &objectIds)
{
debugIds << ref.debugId();
objectIds << ref.idString();
foreach (const QmlDebug::QmlDebugObjectReference &child, ref.children())
recurseObjectIdList(child, debugIds, objectIds);
}
} // namespace Internal
} // namespace QmlJSInspector

View File

@@ -0,0 +1,104 @@
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this file.
** Please review the following information to ensure the GNU Lesser General
** Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** Other Usage
**
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
**
**************************************************************************/
#ifndef BASETOOLSCLIENT_H
#define BASETOOLSCLIENT_H
#include <qmldebug/qmldebugclient.h>
#include <qmldebug/baseenginedebugclient.h>
namespace QmlJSInspector {
namespace Internal {
class BaseToolsClient : public QmlDebug::QmlDebugClient
{
Q_OBJECT
public:
BaseToolsClient(QmlDebug::QmlDebugConnection* client, QLatin1String clientName);
virtual void setCurrentObjects(const QList<int> &debugIds) = 0;
virtual void reloadViewer() = 0;
virtual void setDesignModeBehavior(bool inDesignMode) = 0;
virtual void setAnimationSpeed(qreal slowDownFactor) = 0;
virtual void setAnimationPaused(bool paused) = 0;
virtual void changeToSelectTool() = 0;
virtual void changeToSelectMarqueeTool() = 0;
virtual void changeToZoomTool() = 0;
virtual void showAppOnTop(bool showOnTop) = 0;
virtual void createQmlObject(const QString &qmlText, int parentDebugId,
const QStringList &imports, const QString &filename,
int order) = 0;
virtual void destroyQmlObject(int debugId) = 0;
virtual void reparentQmlObject(int debugId, int newParent) = 0;
virtual void applyChangesToQmlFile() = 0;
virtual void applyChangesFromQmlFile() = 0;
virtual QList<int> currentObjects() const = 0;
// ### Qt 4.8: remove if we can have access to qdeclarativecontextdata or id's
virtual void setObjectIdList(
const QList<QmlDebug::QmlDebugObjectReference> &objectRoots) = 0;
virtual void clearComponentCache() = 0;
signals:
void connectedStatusChanged(QmlDebug::QmlDebugClient::Status status);
void currentObjectsChanged(const QList<int> &debugIds);
void selectToolActivated();
void selectMarqueeToolActivated();
void zoomToolActivated();
void animationSpeedChanged(qreal slowdownFactor);
void animationPausedChanged(bool paused);
void designModeBehaviorChanged(bool inDesignMode);
void showAppOnTopChanged(bool showAppOnTop);
void reloaded(); // the server has reloadetd he document
void logActivity(QString client, QString message);
protected:
void statusChanged(Status);
void recurseObjectIdList(const QmlDebug::QmlDebugObjectReference &ref,
QList<int> &debugIds, QList<QString> &objectIds);
protected:
enum LogDirection {
LogSend,
LogReceive
};
};
} // namespace Internal
} // namespace QmlJSInspector
#endif // BASETOOLSCLIENT_H

View File

@@ -0,0 +1,442 @@
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this file.
** Please review the following information to ensure the GNU Lesser General
** Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** Other Usage
**
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
**
**************************************************************************/
#include "declarativetoolsclient.h"
#include "qmljsclientproxy.h"
#include "qmljsinspectorconstants.h"
using namespace QmlJSDebugger;
namespace QmlJSInspector {
namespace Internal {
DeclarativeToolsClient::DeclarativeToolsClient(QmlDebugConnection *client)
: BaseToolsClient(client,QLatin1String(Constants::QDECLARATIVE_OBSERVER_MODE)),
m_connection(client)
{
setObjectName(name());
}
void DeclarativeToolsClient::messageReceived(const QByteArray &message)
{
QDataStream ds(message);
InspectorProtocol::Message type;
ds >> type;
switch (type) {
case InspectorProtocol::CurrentObjectsChanged: {
int objectCount;
ds >> objectCount;
log(LogReceive, type, QString("%1 [list of debug ids]").arg(objectCount));
m_currentDebugIds.clear();
for (int i = 0; i < objectCount; ++i) {
int debugId;
ds >> debugId;
if (debugId != -1)
m_currentDebugIds << debugId;
}
emit currentObjectsChanged(m_currentDebugIds);
break;
}
case InspectorProtocol::ToolChanged: {
int toolId;
ds >> toolId;
log(LogReceive, type, QString::number(toolId));
if (toolId == Constants::ZoomMode) {
emit zoomToolActivated();
} else if (toolId == Constants::SelectionToolMode) {
emit selectToolActivated();
} else if (toolId == Constants::MarqueeSelectionToolMode) {
emit selectMarqueeToolActivated();
}
break;
}
case InspectorProtocol::AnimationSpeedChanged: {
qreal slowDownFactor;
ds >> slowDownFactor;
log(LogReceive, type, QString::number(slowDownFactor));
emit animationSpeedChanged(slowDownFactor);
break;
}
case InspectorProtocol::AnimationPausedChanged: {
bool paused;
ds >> paused;
log(LogReceive, type, paused ? QLatin1String("true")
: QLatin1String("false"));
emit animationPausedChanged(paused);
break;
}
case InspectorProtocol::SetDesignMode: {
bool inDesignMode;
ds >> inDesignMode;
log(LogReceive, type, QLatin1String(inDesignMode ? "true" : "false"));
emit designModeBehaviorChanged(inDesignMode);
break;
}
case InspectorProtocol::ShowAppOnTop: {
bool showAppOnTop;
ds >> showAppOnTop;
log(LogReceive, type, QLatin1String(showAppOnTop ? "true" : "false"));
emit showAppOnTopChanged(showAppOnTop);
break;
}
case InspectorProtocol::Reloaded: {
log(LogReceive, type);
emit reloaded();
break;
}
default:
log(LogReceive, type, QLatin1String("Warning: Not handling message"));
}
}
QList<int> DeclarativeToolsClient::currentObjects() const
{
return m_currentDebugIds;
}
void DeclarativeToolsClient::setCurrentObjects(const QList<int> &debugIds)
{
if (!m_connection || !m_connection->isConnected())
return;
if (debugIds == m_currentDebugIds)
return;
m_currentDebugIds = debugIds;
QByteArray message;
QDataStream ds(&message, QIODevice::WriteOnly);
InspectorProtocol::Message cmd = InspectorProtocol::SetCurrentObjects;
ds << cmd
<< debugIds.length();
foreach (int id, debugIds) {
ds << id;
}
log(LogSend, cmd, QString("%1 [list of ids]").arg(debugIds.length()));
sendMessage(message);
}
void DeclarativeToolsClient::setObjectIdList(
const QList<QmlDebug::QmlDebugObjectReference> &objectRoots)
{
QByteArray message;
QDataStream ds(&message, QIODevice::WriteOnly);
QList<int> debugIds;
QList<QString> objectIds;
foreach (const QmlDebug::QmlDebugObjectReference &ref, objectRoots)
recurseObjectIdList(ref, debugIds, objectIds);
InspectorProtocol::Message cmd = InspectorProtocol::ObjectIdList;
ds << cmd
<< debugIds.length();
Q_ASSERT(debugIds.length() == objectIds.length());
for(int i = 0; i < debugIds.length(); ++i) {
ds << debugIds[i] << objectIds[i];
}
log(LogSend, cmd,
QString("%1 %2 [list of debug / object ids]").arg(debugIds.length()));
sendMessage(message);
}
void DeclarativeToolsClient::clearComponentCache()
{
if (!m_connection || !m_connection->isConnected())
return;
QByteArray message;
QDataStream ds(&message, QIODevice::WriteOnly);
InspectorProtocol::Message cmd = InspectorProtocol::ClearComponentCache;
ds << cmd;
log(LogSend, cmd);
sendMessage(message);
}
void DeclarativeToolsClient::reloadViewer()
{
if (!m_connection || !m_connection->isConnected())
return;
QByteArray message;
QDataStream ds(&message, QIODevice::WriteOnly);
InspectorProtocol::Message cmd = InspectorProtocol::Reload;
ds << cmd;
log(LogSend, cmd);
sendMessage(message);
}
void DeclarativeToolsClient::setDesignModeBehavior(bool inDesignMode)
{
if (!m_connection || !m_connection->isConnected())
return;
QByteArray message;
QDataStream ds(&message, QIODevice::WriteOnly);
InspectorProtocol::Message cmd = InspectorProtocol::SetDesignMode;
ds << cmd
<< inDesignMode;
log(LogSend, cmd, QLatin1String(inDesignMode ? "true" : "false"));
sendMessage(message);
}
void DeclarativeToolsClient::setAnimationSpeed(qreal slowDownFactor)
{
if (!m_connection || !m_connection->isConnected())
return;
QByteArray message;
QDataStream ds(&message, QIODevice::WriteOnly);
InspectorProtocol::Message cmd = InspectorProtocol::SetAnimationSpeed;
ds << cmd
<< slowDownFactor;
log(LogSend, cmd, QString::number(slowDownFactor));
sendMessage(message);
}
void DeclarativeToolsClient::setAnimationPaused(bool paused)
{
if (!m_connection || !m_connection->isConnected())
return;
QByteArray message;
QDataStream ds(&message, QIODevice::WriteOnly);
InspectorProtocol::Message cmd = InspectorProtocol::SetAnimationPaused;
ds << cmd
<< paused;
log(LogSend, cmd, paused ? QLatin1String("true") : QLatin1String("false"));
sendMessage(message);
}
void DeclarativeToolsClient::changeToSelectTool()
{
if (!m_connection || !m_connection->isConnected())
return;
QByteArray message;
QDataStream ds(&message, QIODevice::WriteOnly);
InspectorProtocol::Message cmd = InspectorProtocol::ChangeTool;
InspectorProtocol::Tool tool = InspectorProtocol::SelectTool;
ds << cmd
<< tool;
log(LogSend, cmd, InspectorProtocol::toString(tool));
sendMessage(message);
}
void DeclarativeToolsClient::changeToSelectMarqueeTool()
{
if (!m_connection || !m_connection->isConnected())
return;
QByteArray message;
QDataStream ds(&message, QIODevice::WriteOnly);
InspectorProtocol::Message cmd = InspectorProtocol::ChangeTool;
InspectorProtocol::Tool tool = InspectorProtocol::SelectMarqueeTool;
ds << cmd
<< tool;
log(LogSend, cmd, InspectorProtocol::toString(tool));
sendMessage(message);
}
void DeclarativeToolsClient::changeToZoomTool()
{
if (!m_connection || !m_connection->isConnected())
return;
QByteArray message;
QDataStream ds(&message, QIODevice::WriteOnly);
InspectorProtocol::Message cmd = InspectorProtocol::ChangeTool;
InspectorProtocol::Tool tool = InspectorProtocol::ZoomTool;
ds << cmd
<< tool;
log(LogSend, cmd, InspectorProtocol::toString(tool));
sendMessage(message);
}
void DeclarativeToolsClient::showAppOnTop(bool showOnTop)
{
if (!m_connection || !m_connection->isConnected())
return;
QByteArray message;
QDataStream ds(&message, QIODevice::WriteOnly);
InspectorProtocol::Message cmd = InspectorProtocol::ShowAppOnTop;
ds << cmd << showOnTop;
log(LogSend, cmd, QLatin1String(showOnTop ? "true" : "false"));
sendMessage(message);
}
void DeclarativeToolsClient::createQmlObject(const QString &qmlText,
int parentDebugId,
const QStringList &imports,
const QString &filename, int order)
{
if (!m_connection || !m_connection->isConnected())
return;
QByteArray message;
QDataStream ds(&message, QIODevice::WriteOnly);
InspectorProtocol::Message cmd = InspectorProtocol::CreateObject;
ds << cmd
<< qmlText
<< parentDebugId
<< imports
<< filename
<< order;
log(LogSend, cmd, QString("%1 %2 [%3] %4").arg(qmlText,
QString::number(parentDebugId),
imports.join(","), filename));
sendMessage(message);
}
void DeclarativeToolsClient::destroyQmlObject(int debugId)
{
if (!m_connection || !m_connection->isConnected())
return;
QByteArray message;
QDataStream ds(&message, QIODevice::WriteOnly);
InspectorProtocol::Message cmd = InspectorProtocol::DestroyObject;
ds << cmd << debugId;
log(LogSend, cmd, QString::number(debugId));
sendMessage(message);
}
void DeclarativeToolsClient::reparentQmlObject(int debugId, int newParent)
{
if (!m_connection || !m_connection->isConnected())
return;
QByteArray message;
QDataStream ds(&message, QIODevice::WriteOnly);
InspectorProtocol::Message cmd = InspectorProtocol::MoveObject;
ds << cmd
<< debugId
<< newParent;
log(LogSend, cmd, QString("%1 %2").arg(QString::number(debugId),
QString::number(newParent)));
sendMessage(message);
}
void DeclarativeToolsClient::applyChangesToQmlFile()
{
if (!m_connection || !m_connection->isConnected())
return;
// TODO
}
void DeclarativeToolsClient::applyChangesFromQmlFile()
{
if (!m_connection || !m_connection->isConnected())
return;
// TODO
}
void DeclarativeToolsClient::log(LogDirection direction,
InspectorProtocol::Message message,
const QString &extra)
{
QString msg;
if (direction == LogSend)
msg += QLatin1String(" sending ");
else
msg += QLatin1String(" receiving ");
msg += InspectorProtocol::toString(message);
msg += QLatin1Char(' ');
msg += extra;
emit logActivity(name(), msg);
}
} // namespace Internal
} // namespace QmlJSInspector

View File

@@ -0,0 +1,90 @@
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this file.
** Please review the following information to ensure the GNU Lesser General
** Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** Other Usage
**
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
**
**************************************************************************/
#ifndef DECLARATIVETOOLSCLIENT_H
#define DECLARATIVETOOLSCLIENT_H
#include "basetoolsclient.h"
#include <inspectorprotocol.h>
namespace QmlJSInspector {
namespace Internal {
class DeclarativeToolsClient : public BaseToolsClient
{
Q_OBJECT
public:
DeclarativeToolsClient(QmlDebug::QmlDebugConnection *client);
void setCurrentObjects(const QList<int> &debugIds);
void reloadViewer();
void setDesignModeBehavior(bool inDesignMode);
void setAnimationSpeed(qreal slowDownFactor);
void setAnimationPaused(bool paused);
void changeToSelectTool();
void changeToSelectMarqueeTool();
void changeToZoomTool();
void showAppOnTop(bool showOnTop);
void createQmlObject(const QString &qmlText, int parentDebugId,
const QStringList &imports, const QString &filename,
int order);
void destroyQmlObject(int debugId);
void reparentQmlObject(int debugId, int newParent);
void applyChangesToQmlFile();
void applyChangesFromQmlFile();
QList<int> currentObjects() const;
// ### Qt 4.8: remove if we can have access to qdeclarativecontextdata or id's
void setObjectIdList(const QList<QmlDebug::QmlDebugObjectReference> &objectRoots);
void clearComponentCache();
protected:
void messageReceived(const QByteArray &);
private:
void log(LogDirection direction,
QmlJSDebugger::InspectorProtocol::Message message,
const QString &extra = QString());
private:
QList<int> m_currentDebugIds;
QmlDebug::QmlDebugConnection *m_connection;
};
} // namespace Internal
} // namespace QmlJSInspector
#endif // DECLARATIVETOOLSCLIENT_H

View File

@@ -32,6 +32,7 @@
#include "qmljsclientproxy.h" #include "qmljsclientproxy.h"
#include "qmltoolsclient.h" #include "qmltoolsclient.h"
#include "declarativetoolsclient.h"
#include "qmljsinspector.h" #include "qmljsinspector.h"
#include <qmldebug/qmldebugconstants.h> #include <qmldebug/qmldebugconstants.h>
@@ -85,32 +86,20 @@ void ClientProxy::connectToServer()
connect(client2, SIGNAL(newStatus(QmlDebugClient::Status)), connect(client2, SIGNAL(newStatus(QmlDebugClient::Status)),
SLOT(engineClientStatusChanged(QmlDebugClient::Status))); SLOT(engineClientStatusChanged(QmlDebugClient::Status)));
m_inspectorHelperClient = DeclarativeToolsClient *toolsClient1 = new DeclarativeToolsClient(
new QmlToolsClient(m_adapter.data()->connection(), this); m_adapter.data()->connection());
QmlToolsClient *toolsClient2 = new QmlToolsClient(
m_adapter.data()->connection());
connect(m_inspectorHelperClient, connect(toolsClient1, SIGNAL(connectedStatusChanged(QmlDebugClient::Status)),
SIGNAL(connectedStatusChanged(QmlDebugClient::Status)), SLOT(clientStatusChanged(QmlDebugClient::Status)));
this, SLOT(clientStatusChanged(QmlDebugClient::Status))); connect(toolsClient1, SIGNAL(connectedStatusChanged(QmlDebugClient::Status)),
connect(m_inspectorHelperClient, SIGNAL(currentObjectsChanged(QList<int>)), SLOT(toolsClientStatusChanged(QmlDebugClient::Status)));
SLOT(onCurrentObjectsChanged(QList<int>)));
connect(m_inspectorHelperClient, SIGNAL(zoomToolActivated()), connect(toolsClient2, SIGNAL(connectedStatusChanged(QmlDebugClient::Status)),
SIGNAL(zoomToolActivated())); SLOT(clientStatusChanged(QmlDebugClient::Status)));
connect(m_inspectorHelperClient, SIGNAL(selectToolActivated()), connect(toolsClient2, SIGNAL(connectedStatusChanged(QmlDebugClient::Status)),
SIGNAL(selectToolActivated())); SLOT(toolsClientStatusChanged(QmlDebugClient::Status)));
connect(m_inspectorHelperClient, SIGNAL(selectMarqueeToolActivated()),
SIGNAL(selectMarqueeToolActivated()));
connect(m_inspectorHelperClient, SIGNAL(animationSpeedChanged(qreal)),
SIGNAL(animationSpeedChanged(qreal)));
connect(m_inspectorHelperClient, SIGNAL(animationPausedChanged(bool)),
SIGNAL(animationPausedChanged(bool)));
connect(m_inspectorHelperClient, SIGNAL(designModeBehaviorChanged(bool)),
SIGNAL(designModeBehaviorChanged(bool)));
connect(m_inspectorHelperClient, SIGNAL(showAppOnTopChanged(bool)),
SIGNAL(showAppOnTopChanged(bool)));
connect(m_inspectorHelperClient, SIGNAL(reloaded()), this,
SIGNAL(serverReloaded()));
connect(m_inspectorHelperClient, SIGNAL(logActivity(QString,QString)),
m_adapter.data(), SLOT(logServiceActivity(QString,QString)));
updateConnected(); updateConnected();
} }
@@ -131,11 +120,16 @@ void ClientProxy::clientStatusChanged(QmlDebugClient::Status status)
updateConnected(); updateConnected();
} }
QmlDebugClient *ClientProxy::inspectorClient() const QmlDebugClient *ClientProxy::engineDebugClient() const
{ {
return m_engineClient; return m_engineClient;
} }
QmlDebugClient *ClientProxy::toolsClient() const
{
return m_inspectorHelperClient;
}
void ClientProxy::engineClientStatusChanged( void ClientProxy::engineClientStatusChanged(
QmlDebugClient::Status status) QmlDebugClient::Status status)
{ {
@@ -151,6 +145,35 @@ void ClientProxy::engineClientStatusChanged(
} }
} }
void ClientProxy::toolsClientStatusChanged(
QmlDebugClient::Status status)
{
if (status == QmlDebugClient::Enabled) {
m_inspectorHelperClient = qobject_cast<BaseToolsClient*>(sender());
connect(m_inspectorHelperClient, SIGNAL(currentObjectsChanged(QList<int>)),
SLOT(onCurrentObjectsChanged(QList<int>)));
connect(m_inspectorHelperClient, SIGNAL(zoomToolActivated()),
SIGNAL(zoomToolActivated()));
connect(m_inspectorHelperClient, SIGNAL(selectToolActivated()),
SIGNAL(selectToolActivated()));
connect(m_inspectorHelperClient, SIGNAL(selectMarqueeToolActivated()),
SIGNAL(selectMarqueeToolActivated()));
connect(m_inspectorHelperClient, SIGNAL(animationSpeedChanged(qreal)),
SIGNAL(animationSpeedChanged(qreal)));
connect(m_inspectorHelperClient, SIGNAL(animationPausedChanged(bool)),
SIGNAL(animationPausedChanged(bool)));
connect(m_inspectorHelperClient, SIGNAL(designModeBehaviorChanged(bool)),
SIGNAL(designModeBehaviorChanged(bool)));
connect(m_inspectorHelperClient, SIGNAL(showAppOnTopChanged(bool)),
SIGNAL(showAppOnTopChanged(bool)));
connect(m_inspectorHelperClient, SIGNAL(reloaded()), this,
SIGNAL(serverReloaded()));
connect(m_inspectorHelperClient, SIGNAL(logActivity(QString,QString)),
m_adapter.data(), SLOT(logServiceActivity(QString,QString)));
updateConnected();
}
}
void ClientProxy::refreshObjectTree() void ClientProxy::refreshObjectTree()
{ {
if (!m_contextQueryId) { if (!m_contextQueryId) {

View File

@@ -53,7 +53,7 @@ QHash<QPair<QString, int>, QHash<QPair<int, int>, QList<int> > > DebugIdHash;
namespace Internal { namespace Internal {
class InspectorPlugin; class InspectorPlugin;
class QmlToolsClient; class BaseToolsClient;
class ClientProxy : public QObject class ClientProxy : public QObject
@@ -107,7 +107,8 @@ public:
void fetchRootObjects(const QmlDebugContextReference &context, bool clear); void fetchRootObjects(const QmlDebugContextReference &context, bool clear);
void insertObjectInTreeIfNeeded(const QmlDebugObjectReference &object); void insertObjectInTreeIfNeeded(const QmlDebugObjectReference &object);
QmlDebugClient *inspectorClient() const; QmlDebugClient *engineDebugClient() const;
QmlDebugClient *toolsClient() const;
signals: signals:
void objectTreeUpdated(); void objectTreeUpdated();
@@ -158,6 +159,7 @@ private slots:
void connectToServer(); void connectToServer();
void clientStatusChanged(QmlDebugClient::Status status); void clientStatusChanged(QmlDebugClient::Status status);
void engineClientStatusChanged(QmlDebugClient::Status status); void engineClientStatusChanged(QmlDebugClient::Status status);
void toolsClientStatusChanged(QmlDebugClient::Status status);
void onCurrentObjectsChanged(const QList<int> &debugIds, void onCurrentObjectsChanged(const QList<int> &debugIds,
bool requestIfNeeded = true); bool requestIfNeeded = true);
@@ -194,7 +196,7 @@ private:
QWeakPointer<Debugger::QmlAdapter> m_adapter; QWeakPointer<Debugger::QmlAdapter> m_adapter;
BaseEngineDebugClient *m_engineClient; BaseEngineDebugClient *m_engineClient;
QmlToolsClient *m_inspectorHelperClient; BaseToolsClient *m_inspectorHelperClient;
quint32 m_engineQueryId; quint32 m_engineQueryId;
quint32 m_contextQueryId; quint32 m_contextQueryId;

View File

@@ -353,12 +353,18 @@ void InspectorUi::connected(ClientProxy *clientProxy)
connect(m_clientProxy, SIGNAL(result(quint32,QVariant)), connect(m_clientProxy, SIGNAL(result(quint32,QVariant)),
SLOT(onResult(quint32,QVariant))); SLOT(onResult(quint32,QVariant)));
using namespace QmlDebug::Constants; using namespace QmlDebug::Constants;
if (m_clientProxy->inspectorClient()->objectName() == QML_DEBUGGER //first check for the name of the tools client
&& m_clientProxy->inspectorClient()->serviceVersion() if (m_clientProxy->toolsClient()->objectName() == Constants::QML_INSPECTOR) {
>= CURRENT_SUPPORTED_VERSION)
m_toolBar->setZoomToolEnabled(false); m_toolBar->setZoomToolEnabled(false);
else } else if (m_clientProxy->engineDebugClient()->objectName() == QML_DEBUGGER
&& m_clientProxy->engineDebugClient()->serviceVersion()
>= CURRENT_SUPPORTED_VERSION) {
//fall back for the intermediate case
//REMOVE THIS SOON
m_toolBar->setZoomToolEnabled(false);
} else {
m_toolBar->setZoomToolEnabled(true); m_toolBar->setZoomToolEnabled(true);
}
QmlJS::Snapshot snapshot = modelManager()->snapshot(); QmlJS::Snapshot snapshot = modelManager()->snapshot();
for (QHash<QString, QmlJSLiveTextPreview *>::const_iterator it for (QHash<QString, QmlJSLiveTextPreview *>::const_iterator it
= m_textPreviews.constBegin(); = m_textPreviews.constBegin();

View File

@@ -19,10 +19,12 @@ qmljsclientproxy.h \
qmljsinspector.h \ qmljsinspector.h \
qmljsinspectortoolbar.h \ qmljsinspectortoolbar.h \
qmljslivetextpreview.h \ qmljslivetextpreview.h \
qmltoolsclient.h \ basetoolsclient.h \
qmljscontextcrumblepath.h \ qmljscontextcrumblepath.h \
qmljsinspectorsettings.h \ qmljsinspectorsettings.h \
qmljspropertyinspector.h qmljspropertyinspector.h \
declarativetoolsclient.h \
qmltoolsclient.h
SOURCES += \ SOURCES += \
qmljsinspectorplugin.cpp \ qmljsinspectorplugin.cpp \
@@ -30,10 +32,12 @@ qmljsclientproxy.cpp \
qmljsinspector.cpp \ qmljsinspector.cpp \
qmljsinspectortoolbar.cpp \ qmljsinspectortoolbar.cpp \
qmljslivetextpreview.cpp \ qmljslivetextpreview.cpp \
qmltoolsclient.cpp \ basetoolsclient.cpp \
qmljscontextcrumblepath.cpp \ qmljscontextcrumblepath.cpp \
qmljsinspectorsettings.cpp \ qmljsinspectorsettings.cpp \
qmljspropertyinspector.cpp qmljspropertyinspector.cpp \
declarativetoolsclient.cpp \
qmltoolsclient.cpp
include(../../../share/qtcreator/qml/qmljsdebugger/protocol/protocol.pri) include(../../../share/qtcreator/qml/qmljsdebugger/protocol/protocol.pri)

View File

@@ -28,6 +28,8 @@ QtcPlugin {
] ]
files: [ files: [
"basetoolsclient.h",
"declarativetoolsclient.h",
"qmljsinspector_global.h", "qmljsinspector_global.h",
"qmljsinspectorconstants.h", "qmljsinspectorconstants.h",
"qmljsinspectorplugin.h", "qmljsinspectorplugin.h",
@@ -40,6 +42,8 @@ QtcPlugin {
"qmljsinspectorsettings.h", "qmljsinspectorsettings.h",
"qmljspropertyinspector.h", "qmljspropertyinspector.h",
"../../../share/qtcreator/qml/qmljsdebugger/protocol/inspectorprotocol.h", "../../../share/qtcreator/qml/qmljsdebugger/protocol/inspectorprotocol.h",
"basetoolsclient.cpp",
"declarativetoolsclient.cpp",
"qmljsinspectorplugin.cpp", "qmljsinspectorplugin.cpp",
"qmljsclientproxy.cpp", "qmljsclientproxy.cpp",
"qmljsinspector.cpp", "qmljsinspector.cpp",

View File

@@ -51,6 +51,9 @@ const char S_LIVE_PREVIEW_WARNING_KEY[] = "ShowLivePreview";
const char ALWAYS_ADJUST_COLUMNS_WIDTHS[] = "AlwaysAdjustColumnWidths"; const char ALWAYS_ADJUST_COLUMNS_WIDTHS[] = "AlwaysAdjustColumnWidths";
const char QML_INSPECTOR[] = "QmlInspector";
const char QDECLARATIVE_OBSERVER_MODE[] = "QDeclarativeObserverMode";
enum DesignTool { enum DesignTool {
NoTool = 0, NoTool = 0,
SelectionToolMode = 1, SelectionToolMode = 1,

View File

@@ -33,108 +33,75 @@
#include "qmljsclientproxy.h" #include "qmljsclientproxy.h"
#include "qmljsinspectorconstants.h" #include "qmljsinspectorconstants.h"
using namespace QmlJSDebugger; //INSPECTOR SERVICE PROTOCOL
// <HEADER><COMMAND><DATA>
// <HEADER> : <type{request, response, event}><requestId/eventId>[<response_success_bool>]
// <COMMAND> : {"enable", "disable", "select", "setAnimationSpeed",
// "showAppOnTop", "createObject", "destroyObject", "moveObject",
// "clearCache"}
// <DATA> : select: <debugIds_int_list>
// setAnimationSpeed: <speed_real>
// showAppOnTop: <set_bool>
// createObject: <qml_string><parentId_int><imports_string_list><filename_string>
// destroyObject: <debugId_int>
// moveObject: <debugId_int><newParentId_int>
// clearCache: void
const char REQUEST[] = "request";
const char RESPONSE[] = "response";
const char EVENT[] = "event";
const char ENABLE[] = "enable";
const char DISABLE[] = "disable";
const char SELECT[] = "select";
const char RELOAD[] = "reload";
const char SET_ANIMATION_SPEED[] = "setAnimationSpeed";
const char SHOW_APP_ON_TOP[] = "showAppOnTop";
const char CREATE_OBJECT[] = "createObject";
const char DESTROY_OBJECT[] = "destroyObject";
const char MOVE_OBJECT[] = "moveObject";
const char CLEAR_CACHE[] = "clearCache";
namespace QmlJSInspector { namespace QmlJSInspector {
namespace Internal { namespace Internal {
QmlToolsClient::QmlToolsClient(QmlDebugConnection *client, QmlToolsClient::QmlToolsClient(QmlDebugConnection *client)
QObject * /*parent*/) : BaseToolsClient(client, QLatin1String(Constants::QML_INSPECTOR)),
: QmlDebugClient(QLatin1String("QDeclarativeObserverMode"), client), m_connection(client),
m_connection(client) m_requestId(0),
m_slowDownFactor(1)
{ {
setObjectName(name()); setObjectName(name());
} }
void QmlToolsClient::statusChanged(Status status)
{
emit connectedStatusChanged(status);
}
void QmlToolsClient::messageReceived(const QByteArray &message) void QmlToolsClient::messageReceived(const QByteArray &message)
{ {
QDataStream ds(message); QDataStream ds(message);
InspectorProtocol::Message type; QByteArray type;
ds >> type; int requestId;
ds >> type >> requestId;
switch (type) { if (type == QByteArray(RESPONSE)) {
case InspectorProtocol::CurrentObjectsChanged: { bool success = false;
int objectCount; ds >> success;
ds >> objectCount; log(LogReceive, type, QString(QLatin1String("requestId: %1 success: %2"))
.arg(QString::number(requestId)).arg(QString::number(success)));
log(LogReceive, type, QString("%1 [list of debug ids]").arg(objectCount)); } else if (type == QByteArray(EVENT)) {
QByteArray event;
m_currentDebugIds.clear(); ds >> event;
if (event == QByteArray(SELECT)) {
for (int i = 0; i < objectCount; ++i) { m_currentDebugIds.clear();
int debugId; QList<int> debugIds;
ds >> debugId; ds >> debugIds;
if (debugId != -1) log(LogReceive, type + ':' + event,
m_currentDebugIds << debugId; QString("%1 [list of debug ids]").arg(debugIds.count()));
foreach (int debugId, debugIds) {
if (debugId != -1)
m_currentDebugIds << debugId;
}
emit currentObjectsChanged(m_currentDebugIds);
} }
} else {
emit currentObjectsChanged(m_currentDebugIds);
break;
}
case InspectorProtocol::ToolChanged: {
int toolId;
ds >> toolId;
log(LogReceive, type, QString::number(toolId));
if (toolId == Constants::ZoomMode) {
emit zoomToolActivated();
} else if (toolId == Constants::SelectionToolMode) {
emit selectToolActivated();
} else if (toolId == Constants::MarqueeSelectionToolMode) {
emit selectMarqueeToolActivated();
}
break;
}
case InspectorProtocol::AnimationSpeedChanged: {
qreal slowDownFactor;
ds >> slowDownFactor;
log(LogReceive, type, QString::number(slowDownFactor));
emit animationSpeedChanged(slowDownFactor);
break;
}
case InspectorProtocol::AnimationPausedChanged: {
bool paused;
ds >> paused;
log(LogReceive, type, paused ? QLatin1String("true")
: QLatin1String("false"));
emit animationPausedChanged(paused);
break;
}
case InspectorProtocol::SetDesignMode: {
bool inDesignMode;
ds >> inDesignMode;
log(LogReceive, type, QLatin1String(inDesignMode ? "true" : "false"));
emit designModeBehaviorChanged(inDesignMode);
break;
}
case InspectorProtocol::ShowAppOnTop: {
bool showAppOnTop;
ds >> showAppOnTop;
log(LogReceive, type, QLatin1String(showAppOnTop ? "true" : "false"));
emit showAppOnTopChanged(showAppOnTop);
break;
}
case InspectorProtocol::Reloaded: {
log(LogReceive, type);
emit reloaded();
break;
}
default:
log(LogReceive, type, QLatin1String("Warning: Not handling message")); log(LogReceive, type, QLatin1String("Warning: Not handling message"));
} }
} }
@@ -156,55 +123,18 @@ void QmlToolsClient::setCurrentObjects(const QList<int> &debugIds)
QByteArray message; QByteArray message;
QDataStream ds(&message, QIODevice::WriteOnly); QDataStream ds(&message, QIODevice::WriteOnly);
ds << QByteArray(REQUEST) << m_requestId++
<< QByteArray(SELECT) << m_currentDebugIds;
InspectorProtocol::Message cmd = InspectorProtocol::SetCurrentObjects; log(LogSend, SELECT, QString("%1 [list of ids]").arg(debugIds.length()));
ds << cmd
<< debugIds.length();
foreach (int id, debugIds) {
ds << id;
}
log(LogSend, cmd, QString("%1 [list of ids]").arg(debugIds.length()));
sendMessage(message); sendMessage(message);
} }
void recurseObjectIdList(const QmlDebugObjectReference &ref,
QList<int> &debugIds, QList<QString> &objectIds)
{
debugIds << ref.debugId();
objectIds << ref.idString();
foreach (const QmlDebugObjectReference &child, ref.children())
recurseObjectIdList(child, debugIds, objectIds);
}
void QmlToolsClient::setObjectIdList( void QmlToolsClient::setObjectIdList(
const QList<QmlDebugObjectReference> &objectRoots) const QList<QmlDebugObjectReference> &/*objectRoots*/)
{ {
QByteArray message; //NOT IMPLEMENTED
QDataStream ds(&message, QIODevice::WriteOnly);
QList<int> debugIds;
QList<QString> objectIds;
foreach (const QmlDebugObjectReference &ref, objectRoots)
recurseObjectIdList(ref, debugIds, objectIds);
InspectorProtocol::Message cmd = InspectorProtocol::ObjectIdList;
ds << cmd
<< debugIds.length();
Q_ASSERT(debugIds.length() == objectIds.length());
for(int i = 0; i < debugIds.length(); ++i) {
ds << debugIds[i] << objectIds[i];
}
log(LogSend, cmd,
QString("%1 %2 [list of debug / object ids]").arg(debugIds.length()));
sendMessage(message);
} }
void QmlToolsClient::clearComponentCache() void QmlToolsClient::clearComponentCache()
@@ -214,11 +144,10 @@ void QmlToolsClient::clearComponentCache()
QByteArray message; QByteArray message;
QDataStream ds(&message, QIODevice::WriteOnly); QDataStream ds(&message, QIODevice::WriteOnly);
ds << QByteArray(REQUEST) << m_requestId++
<< QByteArray(CLEAR_CACHE);
InspectorProtocol::Message cmd = InspectorProtocol::ClearComponentCache; log(LogSend, CLEAR_CACHE);
ds << cmd;
log(LogSend, cmd);
sendMessage(message); sendMessage(message);
} }
@@ -230,11 +159,10 @@ void QmlToolsClient::reloadViewer()
QByteArray message; QByteArray message;
QDataStream ds(&message, QIODevice::WriteOnly); QDataStream ds(&message, QIODevice::WriteOnly);
ds << QByteArray(REQUEST) << m_requestId++
<< QByteArray(RELOAD);
InspectorProtocol::Message cmd = InspectorProtocol::Reload; log(LogSend, RELOAD);
ds << cmd;
log(LogSend, cmd);
sendMessage(message); sendMessage(message);
} }
@@ -246,12 +174,13 @@ void QmlToolsClient::setDesignModeBehavior(bool inDesignMode)
QByteArray message; QByteArray message;
QDataStream ds(&message, QIODevice::WriteOnly); QDataStream ds(&message, QIODevice::WriteOnly);
ds << QByteArray(REQUEST) << m_requestId++;
if (inDesignMode)
ds << QByteArray(ENABLE);
else
ds << QByteArray(DISABLE);
InspectorProtocol::Message cmd = InspectorProtocol::SetDesignMode; log(LogSend, ENABLE, QLatin1String(inDesignMode ? "true" : "false"));
ds << cmd
<< inDesignMode;
log(LogSend, cmd, QLatin1String(inDesignMode ? "true" : "false"));
sendMessage(message); sendMessage(message);
} }
@@ -263,86 +192,38 @@ void QmlToolsClient::setAnimationSpeed(qreal slowDownFactor)
QByteArray message; QByteArray message;
QDataStream ds(&message, QIODevice::WriteOnly); QDataStream ds(&message, QIODevice::WriteOnly);
ds << QByteArray(REQUEST) << m_requestId++
<< QByteArray(SET_ANIMATION_SPEED) << slowDownFactor;
InspectorProtocol::Message cmd = InspectorProtocol::SetAnimationSpeed; log(LogSend, SET_ANIMATION_SPEED, QString::number(slowDownFactor));
ds << cmd
<< slowDownFactor;
log(LogSend, cmd, QString::number(slowDownFactor));
sendMessage(message); sendMessage(message);
//Cache non-zero values
if (slowDownFactor)
m_slowDownFactor = slowDownFactor;
} }
void QmlToolsClient::setAnimationPaused(bool paused) void QmlToolsClient::setAnimationPaused(bool paused)
{ {
if (!m_connection || !m_connection->isConnected()) if (paused)
return; setAnimationSpeed(0);
else
QByteArray message; setAnimationSpeed(m_slowDownFactor);
QDataStream ds(&message, QIODevice::WriteOnly);
InspectorProtocol::Message cmd = InspectorProtocol::SetAnimationPaused;
ds << cmd
<< paused;
log(LogSend, cmd, paused ? QLatin1String("true") : QLatin1String("false"));
sendMessage(message);
} }
void QmlToolsClient::changeToSelectTool() void QmlToolsClient::changeToSelectTool()
{ {
if (!m_connection || !m_connection->isConnected()) // NOT IMPLEMENTED
return;
QByteArray message;
QDataStream ds(&message, QIODevice::WriteOnly);
InspectorProtocol::Message cmd = InspectorProtocol::ChangeTool;
InspectorProtocol::Tool tool = InspectorProtocol::SelectTool;
ds << cmd
<< tool;
log(LogSend, cmd, InspectorProtocol::toString(tool));
sendMessage(message);
} }
void QmlToolsClient::changeToSelectMarqueeTool() void QmlToolsClient::changeToSelectMarqueeTool()
{ {
if (!m_connection || !m_connection->isConnected()) // NOT IMPLEMENTED
return;
QByteArray message;
QDataStream ds(&message, QIODevice::WriteOnly);
InspectorProtocol::Message cmd = InspectorProtocol::ChangeTool;
InspectorProtocol::Tool tool = InspectorProtocol::SelectMarqueeTool;
ds << cmd
<< tool;
log(LogSend, cmd, InspectorProtocol::toString(tool));
sendMessage(message);
} }
void QmlToolsClient::changeToZoomTool() void QmlToolsClient::changeToZoomTool()
{ {
if (!m_connection || !m_connection->isConnected()) // NOT IMPLEMENTED
return;
QByteArray message;
QDataStream ds(&message, QIODevice::WriteOnly);
InspectorProtocol::Message cmd = InspectorProtocol::ChangeTool;
InspectorProtocol::Tool tool = InspectorProtocol::ZoomTool;
ds << cmd
<< tool;
log(LogSend, cmd, InspectorProtocol::toString(tool));
sendMessage(message);
} }
void QmlToolsClient::showAppOnTop(bool showOnTop) void QmlToolsClient::showAppOnTop(bool showOnTop)
@@ -352,11 +233,10 @@ void QmlToolsClient::showAppOnTop(bool showOnTop)
QByteArray message; QByteArray message;
QDataStream ds(&message, QIODevice::WriteOnly); QDataStream ds(&message, QIODevice::WriteOnly);
ds << QByteArray(REQUEST) << m_requestId++
<< QByteArray(SHOW_APP_ON_TOP) << showOnTop;
InspectorProtocol::Message cmd = InspectorProtocol::ShowAppOnTop; log(LogSend, SHOW_APP_ON_TOP, QLatin1String(showOnTop ? "true" : "false"));
ds << cmd << showOnTop;
log(LogSend, cmd, QLatin1String(showOnTop ? "true" : "false"));
sendMessage(message); sendMessage(message);
} }
@@ -371,16 +251,15 @@ void QmlToolsClient::createQmlObject(const QString &qmlText,
QByteArray message; QByteArray message;
QDataStream ds(&message, QIODevice::WriteOnly); QDataStream ds(&message, QIODevice::WriteOnly);
ds << QByteArray(REQUEST) << m_requestId++
InspectorProtocol::Message cmd = InspectorProtocol::CreateObject; << QByteArray(CREATE_OBJECT)
ds << cmd
<< qmlText << qmlText
<< parentDebugId << parentDebugId
<< imports << imports
<< filename << filename
<< order; << order;
log(LogSend, cmd, QString("%1 %2 [%3] %4").arg(qmlText, log(LogSend, CREATE_OBJECT, QString("%1 %2 [%3] %4").arg(qmlText,
QString::number(parentDebugId), QString::number(parentDebugId),
imports.join(","), filename)); imports.join(","), filename));
@@ -393,11 +272,10 @@ void QmlToolsClient::destroyQmlObject(int debugId)
return; return;
QByteArray message; QByteArray message;
QDataStream ds(&message, QIODevice::WriteOnly); QDataStream ds(&message, QIODevice::WriteOnly);
ds << QByteArray(REQUEST) << m_requestId++
<< QByteArray(DESTROY_OBJECT) << debugId;
InspectorProtocol::Message cmd = InspectorProtocol::DestroyObject; log(LogSend, DESTROY_OBJECT, QString::number(debugId));
ds << cmd << debugId;
log(LogSend, cmd, QString::number(debugId));
sendMessage(message); sendMessage(message);
} }
@@ -408,13 +286,10 @@ void QmlToolsClient::reparentQmlObject(int debugId, int newParent)
return; return;
QByteArray message; QByteArray message;
QDataStream ds(&message, QIODevice::WriteOnly); QDataStream ds(&message, QIODevice::WriteOnly);
ds << QByteArray(REQUEST) << m_requestId++
<< QByteArray(MOVE_OBJECT) << debugId << newParent;
InspectorProtocol::Message cmd = InspectorProtocol::MoveObject; log(LogSend, MOVE_OBJECT, QString("%1 %2").arg(QString::number(debugId),
ds << cmd
<< debugId
<< newParent;
log(LogSend, cmd, QString("%1 %2").arg(QString::number(debugId),
QString::number(newParent))); QString::number(newParent)));
sendMessage(message); sendMessage(message);
@@ -438,7 +313,7 @@ void QmlToolsClient::applyChangesFromQmlFile()
} }
void QmlToolsClient::log(LogDirection direction, void QmlToolsClient::log(LogDirection direction,
InspectorProtocol::Message message, const QByteArray &message,
const QString &extra) const QString &extra)
{ {
QString msg; QString msg;
@@ -447,7 +322,7 @@ void QmlToolsClient::log(LogDirection direction,
else else
msg += QLatin1String(" receiving "); msg += QLatin1String(" receiving ");
msg += InspectorProtocol::toString(message); msg += message;
msg += QLatin1Char(' '); msg += QLatin1Char(' ');
msg += extra; msg += extra;
emit logActivity(name(), msg); emit logActivity(name(), msg);

View File

@@ -32,19 +32,15 @@
#ifndef QMLTOOLSCLIENT_H #ifndef QMLTOOLSCLIENT_H
#define QMLTOOLSCLIENT_H #define QMLTOOLSCLIENT_H
#include <qmldebug/qmldebugclient.h> #include "basetoolsclient.h"
#include <inspectorprotocol.h>
#include <qmldebug/baseenginedebugclient.h>
namespace QmlJSInspector { namespace QmlJSInspector {
namespace Internal { namespace Internal {
class QmlToolsClient : public QmlDebug::QmlDebugClient class QmlToolsClient : public BaseToolsClient
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit QmlToolsClient(QmlDebug::QmlDebugConnection *client, explicit QmlToolsClient(QmlDebug::QmlDebugConnection *client);
QObject *parent = 0);
void setCurrentObjects(const QList<int> &debugIds); void setCurrentObjects(const QList<int> &debugIds);
void reloadViewer(); void reloadViewer();
@@ -72,37 +68,19 @@ public:
void clearComponentCache(); void clearComponentCache();
signals:
void connectedStatusChanged(QmlDebugClient::Status status);
void currentObjectsChanged(const QList<int> &debugIds);
void selectToolActivated();
void selectMarqueeToolActivated();
void zoomToolActivated();
void animationSpeedChanged(qreal slowdownFactor);
void animationPausedChanged(bool paused);
void designModeBehaviorChanged(bool inDesignMode);
void showAppOnTopChanged(bool showAppOnTop);
void reloaded(); // the server has reloadetd he document
void logActivity(QString client, QString message);
protected: protected:
void statusChanged(Status);
void messageReceived(const QByteArray &); void messageReceived(const QByteArray &);
private: private:
enum LogDirection {
LogSend,
LogReceive
};
void log(LogDirection direction, void log(LogDirection direction,
QmlJSDebugger::InspectorProtocol::Message message, const QByteArray &message,
const QString &extra = QString()); const QString &extra = QString());
private:
QList<int> m_currentDebugIds; QList<int> m_currentDebugIds;
QmlDebug::QmlDebugConnection *m_connection; QmlDebug::QmlDebugConnection *m_connection;
int m_requestId;
qreal m_slowDownFactor;
}; };
} // namespace Internal } // namespace Internal