2010-07-08 11:34:51 +02:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
2011-01-11 16:28:15 +01:00
|
|
|
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
2010-07-08 11:34:51 +02:00
|
|
|
** All rights reserved.
|
|
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
|
|
|
|
**
|
|
|
|
|
** This file is part of the QtDeclarative module of the Qt Toolkit.
|
|
|
|
|
**
|
|
|
|
|
** $QT_BEGIN_LICENSE:LGPL$
|
|
|
|
|
** No Commercial Usage
|
|
|
|
|
** This file contains pre-release code and may not be distributed.
|
|
|
|
|
** You may use this file in accordance with the terms and conditions
|
|
|
|
|
** contained in the Technology Preview License Agreement accompanying
|
|
|
|
|
** this package.
|
|
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
|
|
|
|
** Alternatively, 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.
|
|
|
|
|
**
|
|
|
|
|
** If you have questions regarding the use of this file, please contact
|
|
|
|
|
** Nokia at qt-info@nokia.com.
|
|
|
|
|
**
|
|
|
|
|
**
|
|
|
|
|
**
|
|
|
|
|
**
|
|
|
|
|
**
|
|
|
|
|
**
|
|
|
|
|
**
|
|
|
|
|
**
|
|
|
|
|
** $QT_END_LICENSE$
|
|
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
2010-09-16 13:16:47 +02:00
|
|
|
#include "qmljsobserverclient.h"
|
2010-07-08 11:34:51 +02:00
|
|
|
#include "qmljsclientproxy.h"
|
|
|
|
|
#include "qmljsinspectorconstants.h"
|
|
|
|
|
|
2011-01-24 12:29:48 +01:00
|
|
|
#include <QtGui/QColor>
|
2010-07-26 12:47:55 +02:00
|
|
|
|
2011-02-24 17:26:36 +01:00
|
|
|
using namespace QmlJSDebugger;
|
|
|
|
|
|
2010-07-08 11:34:51 +02:00
|
|
|
namespace QmlJSInspector {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2010-09-16 13:16:47 +02:00
|
|
|
QmlJSObserverClient::QmlJSObserverClient(QDeclarativeDebugConnection *client,
|
2011-02-24 17:52:35 +01:00
|
|
|
QObject * /*parent*/)
|
2010-09-16 12:29:06 +02:00
|
|
|
: QDeclarativeDebugClient(QLatin1String("QDeclarativeObserverMode"), client) ,
|
2010-07-08 11:34:51 +02:00
|
|
|
m_connection(client)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2010-09-30 14:05:20 +02:00
|
|
|
void QmlJSObserverClient::statusChanged(Status status)
|
|
|
|
|
{
|
|
|
|
|
emit connectedStatusChanged(status);
|
|
|
|
|
}
|
|
|
|
|
|
2010-09-16 13:16:47 +02:00
|
|
|
void QmlJSObserverClient::messageReceived(const QByteArray &message)
|
2010-07-08 11:34:51 +02:00
|
|
|
{
|
|
|
|
|
QDataStream ds(message);
|
|
|
|
|
|
2011-02-24 17:26:36 +01:00
|
|
|
ObserverProtocol::Message type;
|
2010-07-08 11:34:51 +02:00
|
|
|
ds >> type;
|
|
|
|
|
|
2011-02-24 17:26:36 +01:00
|
|
|
switch (type) {
|
|
|
|
|
case ObserverProtocol::CurrentObjectsChanged: {
|
2010-07-08 11:34:51 +02:00
|
|
|
int objectCount;
|
|
|
|
|
ds >> objectCount;
|
2010-10-25 08:05:13 +02:00
|
|
|
|
2011-02-24 17:26:36 +01:00
|
|
|
log(LogReceive, type, QString("%1 [list of debug ids]").arg(objectCount));
|
2010-12-16 17:26:25 +01:00
|
|
|
|
2010-10-25 08:56:25 +02:00
|
|
|
m_currentDebugIds.clear();
|
2010-07-14 14:21:10 +02:00
|
|
|
|
2011-02-24 17:52:35 +01:00
|
|
|
for (int i = 0; i < objectCount; ++i) {
|
2010-07-08 11:34:51 +02:00
|
|
|
int debugId;
|
|
|
|
|
ds >> debugId;
|
2011-02-24 17:52:35 +01:00
|
|
|
if (debugId != -1)
|
2010-10-25 08:56:25 +02:00
|
|
|
m_currentDebugIds << debugId;
|
2010-07-08 11:34:51 +02:00
|
|
|
}
|
2010-07-14 14:21:10 +02:00
|
|
|
|
2010-10-25 08:56:25 +02:00
|
|
|
emit currentObjectsChanged(m_currentDebugIds);
|
2011-02-24 17:26:36 +01:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case ObserverProtocol::ToolChanged: {
|
2010-07-08 11:34:51 +02:00
|
|
|
int toolId;
|
|
|
|
|
ds >> toolId;
|
|
|
|
|
|
2011-02-24 17:26:36 +01:00
|
|
|
log(LogReceive, type, QString::number(toolId));
|
2010-12-16 17:26:25 +01:00
|
|
|
|
2010-07-08 11:34:51 +02:00
|
|
|
if (toolId == Constants::ColorPickerMode) {
|
|
|
|
|
emit colorPickerActivated();
|
|
|
|
|
} else if (toolId == Constants::ZoomMode) {
|
|
|
|
|
emit zoomToolActivated();
|
|
|
|
|
} else if (toolId == Constants::SelectionToolMode) {
|
|
|
|
|
emit selectToolActivated();
|
|
|
|
|
} else if (toolId == Constants::MarqueeSelectionToolMode) {
|
|
|
|
|
emit selectMarqueeToolActivated();
|
|
|
|
|
}
|
2011-02-24 17:26:36 +01:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case ObserverProtocol::AnimationSpeedChanged: {
|
2011-03-18 20:45:23 +01:00
|
|
|
qreal slowDownFactor;
|
|
|
|
|
ds >> slowDownFactor;
|
2010-12-16 17:26:25 +01:00
|
|
|
|
2011-03-18 20:45:23 +01:00
|
|
|
log(LogReceive, type, QString::number(slowDownFactor));
|
2010-12-16 17:26:25 +01:00
|
|
|
|
2011-03-18 20:45:23 +01:00
|
|
|
emit animationSpeedChanged(slowDownFactor);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case ObserverProtocol::ExecutionPausedChanged: {
|
|
|
|
|
bool paused;
|
|
|
|
|
ds >> paused;
|
|
|
|
|
|
|
|
|
|
log(LogReceive, type, paused ? QLatin1String("true") : QLatin1String("false"));
|
|
|
|
|
|
|
|
|
|
emit executionPausedChanged(paused);
|
2011-02-24 17:26:36 +01:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case ObserverProtocol::SetDesignMode: {
|
2010-07-12 12:02:35 +02:00
|
|
|
bool inDesignMode;
|
|
|
|
|
ds >> inDesignMode;
|
2010-12-16 17:26:25 +01:00
|
|
|
|
2011-02-24 17:26:36 +01:00
|
|
|
log(LogReceive, type, QLatin1String(inDesignMode ? "true" : "false"));
|
2010-12-16 17:26:25 +01:00
|
|
|
|
2010-07-12 12:02:35 +02:00
|
|
|
emit designModeBehaviorChanged(inDesignMode);
|
2011-02-24 17:26:36 +01:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case ObserverProtocol::ShowAppOnTop: {
|
2010-11-23 10:07:09 +01:00
|
|
|
bool showAppOnTop;
|
|
|
|
|
ds >> showAppOnTop;
|
2010-12-16 17:26:25 +01:00
|
|
|
|
2011-02-24 17:26:36 +01:00
|
|
|
log(LogReceive, type, QLatin1String(showAppOnTop ? "true" : "false"));
|
2010-12-16 17:26:25 +01:00
|
|
|
|
2010-11-23 10:07:09 +01:00
|
|
|
emit showAppOnTopChanged(showAppOnTop);
|
2011-02-24 17:26:36 +01:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case ObserverProtocol::Reloaded: {
|
2010-12-16 17:26:25 +01:00
|
|
|
log(LogReceive, type);
|
2010-07-20 12:35:36 +02:00
|
|
|
emit reloaded();
|
2011-02-24 17:26:36 +01:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case ObserverProtocol::ColorChanged: {
|
2010-07-26 12:47:55 +02:00
|
|
|
QColor col;
|
|
|
|
|
ds >> col;
|
2010-12-16 17:26:25 +01:00
|
|
|
|
2011-02-24 17:26:36 +01:00
|
|
|
log(LogReceive, type, col.name());
|
2010-12-16 17:26:25 +01:00
|
|
|
|
2010-07-26 12:47:55 +02:00
|
|
|
emit selectedColorChanged(col);
|
2011-02-24 17:26:36 +01:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case ObserverProtocol::ContextPathUpdated: {
|
2010-08-02 17:25:29 +02:00
|
|
|
QStringList contextPath;
|
|
|
|
|
ds >> contextPath;
|
2010-12-16 17:26:25 +01:00
|
|
|
|
2011-02-24 17:26:36 +01:00
|
|
|
log(LogReceive, type, contextPath.join(", "));
|
2010-12-16 17:26:25 +01:00
|
|
|
|
2010-08-02 17:25:29 +02:00
|
|
|
emit contextPathUpdated(contextPath);
|
2011-02-24 17:26:36 +01:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
|
qWarning() << "Warning: Not handling message:" << type;
|
2010-07-08 11:34:51 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-25 08:56:25 +02:00
|
|
|
QList<int> QmlJSObserverClient::currentObjects() const
|
2010-07-14 17:22:22 +02:00
|
|
|
{
|
2010-10-25 08:56:25 +02:00
|
|
|
return m_currentDebugIds;
|
2010-07-14 17:22:22 +02:00
|
|
|
}
|
|
|
|
|
|
2011-02-24 17:52:35 +01:00
|
|
|
void QmlJSObserverClient::setCurrentObjects(const QList<int> &debugIds)
|
|
|
|
|
{
|
2010-07-08 11:34:51 +02:00
|
|
|
if (!m_connection || !m_connection->isConnected())
|
|
|
|
|
return;
|
|
|
|
|
|
2010-10-25 09:38:54 +02:00
|
|
|
if (debugIds == m_currentDebugIds)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
m_currentDebugIds = debugIds;
|
|
|
|
|
|
2010-07-08 11:34:51 +02:00
|
|
|
QByteArray message;
|
|
|
|
|
QDataStream ds(&message, QIODevice::WriteOnly);
|
|
|
|
|
|
2011-02-24 17:26:36 +01:00
|
|
|
ObserverProtocol::Message cmd = ObserverProtocol::SetCurrentObjects;
|
2010-12-16 17:26:25 +01:00
|
|
|
ds << cmd
|
2010-10-25 08:05:13 +02:00
|
|
|
<< debugIds.length();
|
2010-07-08 11:34:51 +02:00
|
|
|
|
2010-10-25 08:05:13 +02:00
|
|
|
foreach (int id, debugIds) {
|
|
|
|
|
ds << id;
|
2010-07-08 11:34:51 +02:00
|
|
|
}
|
|
|
|
|
|
2011-02-24 17:26:36 +01:00
|
|
|
log(LogSend, cmd, QString("%1 [list of ids]").arg(debugIds.length()));
|
2010-10-07 10:56:36 +02:00
|
|
|
|
2010-07-08 11:34:51 +02:00
|
|
|
sendMessage(message);
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-26 15:31:59 +02:00
|
|
|
void recurseObjectIdList(const QDeclarativeDebugObjectReference &ref, QList<int> &debugIds, QList<QString> &objectIds)
|
|
|
|
|
{
|
|
|
|
|
debugIds << ref.debugId();
|
|
|
|
|
objectIds << ref.idString();
|
2011-02-24 17:52:35 +01:00
|
|
|
foreach (const QDeclarativeDebugObjectReference &child, ref.children())
|
2010-07-26 15:31:59 +02:00
|
|
|
recurseObjectIdList(child, debugIds, objectIds);
|
|
|
|
|
}
|
|
|
|
|
|
2010-09-16 13:16:47 +02:00
|
|
|
void QmlJSObserverClient::setObjectIdList(const QList<QDeclarativeDebugObjectReference> &objectRoots)
|
2010-07-26 15:31:59 +02:00
|
|
|
{
|
|
|
|
|
QByteArray message;
|
|
|
|
|
QDataStream ds(&message, QIODevice::WriteOnly);
|
|
|
|
|
|
|
|
|
|
QList<int> debugIds;
|
|
|
|
|
QList<QString> objectIds;
|
|
|
|
|
|
2011-02-24 17:52:35 +01:00
|
|
|
foreach (const QDeclarativeDebugObjectReference &ref, objectRoots)
|
2010-07-26 15:31:59 +02:00
|
|
|
recurseObjectIdList(ref, debugIds, objectIds);
|
|
|
|
|
|
2011-02-24 17:26:36 +01:00
|
|
|
ObserverProtocol::Message cmd = ObserverProtocol::ObjectIdList;
|
2010-12-16 17:26:25 +01:00
|
|
|
ds << cmd
|
2010-07-26 15:31:59 +02:00
|
|
|
<< debugIds.length();
|
|
|
|
|
|
|
|
|
|
Q_ASSERT(debugIds.length() == objectIds.length());
|
|
|
|
|
|
|
|
|
|
for(int i = 0; i < debugIds.length(); ++i) {
|
|
|
|
|
ds << debugIds[i] << objectIds[i];
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-24 17:26:36 +01:00
|
|
|
log(LogSend, cmd, QString("%1 %2 [list of debug / object ids]").arg(debugIds.length()));
|
2010-10-07 10:56:36 +02:00
|
|
|
|
2010-07-26 15:31:59 +02:00
|
|
|
sendMessage(message);
|
|
|
|
|
}
|
|
|
|
|
|
2010-09-16 13:16:47 +02:00
|
|
|
void QmlJSObserverClient::setContextPathIndex(int contextPathIndex)
|
2010-08-03 10:17:09 +02:00
|
|
|
{
|
|
|
|
|
if (!m_connection || !m_connection->isConnected())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
QByteArray message;
|
|
|
|
|
QDataStream ds(&message, QIODevice::WriteOnly);
|
|
|
|
|
|
2011-02-24 17:26:36 +01:00
|
|
|
ObserverProtocol::Message cmd = ObserverProtocol::SetContextPathIdx;
|
2010-12-16 17:26:25 +01:00
|
|
|
ds << cmd
|
2010-08-03 10:17:09 +02:00
|
|
|
<< contextPathIndex;
|
2010-10-07 10:56:36 +02:00
|
|
|
|
2011-02-24 17:26:36 +01:00
|
|
|
log(LogSend, cmd, QString::number(contextPathIndex));
|
2010-10-07 10:56:36 +02:00
|
|
|
|
2010-08-03 10:17:09 +02:00
|
|
|
sendMessage(message);
|
|
|
|
|
}
|
2010-07-26 15:31:59 +02:00
|
|
|
|
2010-09-16 13:16:47 +02:00
|
|
|
void QmlJSObserverClient::clearComponentCache()
|
2010-08-03 14:07:30 +02:00
|
|
|
{
|
|
|
|
|
if (!m_connection || !m_connection->isConnected())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
QByteArray message;
|
|
|
|
|
QDataStream ds(&message, QIODevice::WriteOnly);
|
|
|
|
|
|
2011-02-24 17:26:36 +01:00
|
|
|
ObserverProtocol::Message cmd = ObserverProtocol::ClearComponentCache;
|
2010-12-16 17:26:25 +01:00
|
|
|
ds << cmd;
|
2010-10-07 10:56:36 +02:00
|
|
|
|
2010-12-16 17:26:25 +01:00
|
|
|
log(LogSend, cmd);
|
2010-10-07 10:56:36 +02:00
|
|
|
|
2010-08-03 14:07:30 +02:00
|
|
|
sendMessage(message);
|
|
|
|
|
}
|
|
|
|
|
|
2010-09-16 13:16:47 +02:00
|
|
|
void QmlJSObserverClient::reloadViewer()
|
2010-07-08 11:34:51 +02:00
|
|
|
{
|
|
|
|
|
if (!m_connection || !m_connection->isConnected())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
QByteArray message;
|
|
|
|
|
QDataStream ds(&message, QIODevice::WriteOnly);
|
|
|
|
|
|
2011-02-24 17:26:36 +01:00
|
|
|
ObserverProtocol::Message cmd = ObserverProtocol::Reload;
|
2010-12-16 17:26:25 +01:00
|
|
|
ds << cmd;
|
2010-10-07 10:56:36 +02:00
|
|
|
|
2010-12-16 17:26:25 +01:00
|
|
|
log(LogSend, cmd);
|
2010-10-07 10:56:36 +02:00
|
|
|
|
2010-07-08 11:34:51 +02:00
|
|
|
sendMessage(message);
|
|
|
|
|
}
|
|
|
|
|
|
2010-09-16 13:16:47 +02:00
|
|
|
void QmlJSObserverClient::setDesignModeBehavior(bool inDesignMode)
|
2010-07-12 12:02:35 +02:00
|
|
|
{
|
|
|
|
|
if (!m_connection || !m_connection->isConnected())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
QByteArray message;
|
|
|
|
|
QDataStream ds(&message, QIODevice::WriteOnly);
|
|
|
|
|
|
2011-02-24 17:26:36 +01:00
|
|
|
ObserverProtocol::Message cmd = ObserverProtocol::SetDesignMode;
|
2010-12-16 17:26:25 +01:00
|
|
|
ds << cmd
|
2010-07-12 12:02:35 +02:00
|
|
|
<< inDesignMode;
|
|
|
|
|
|
2011-02-24 17:26:36 +01:00
|
|
|
log(LogSend, cmd, QLatin1String(inDesignMode ? "true" : "false"));
|
2010-10-07 10:56:36 +02:00
|
|
|
|
2010-07-12 12:02:35 +02:00
|
|
|
sendMessage(message);
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-18 20:45:23 +01:00
|
|
|
void QmlJSObserverClient::setAnimationSpeed(qreal slowDownFactor)
|
2010-07-08 11:34:51 +02:00
|
|
|
{
|
|
|
|
|
if (!m_connection || !m_connection->isConnected())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
QByteArray message;
|
|
|
|
|
QDataStream ds(&message, QIODevice::WriteOnly);
|
|
|
|
|
|
2011-02-24 17:26:36 +01:00
|
|
|
ObserverProtocol::Message cmd = ObserverProtocol::SetAnimationSpeed;
|
2010-12-16 17:26:25 +01:00
|
|
|
ds << cmd
|
2011-03-18 20:45:23 +01:00
|
|
|
<< slowDownFactor;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
log(LogSend, cmd, QString::number(slowDownFactor));
|
|
|
|
|
|
|
|
|
|
sendMessage(message);
|
|
|
|
|
}
|
2010-10-07 10:56:36 +02:00
|
|
|
|
2011-03-18 20:45:23 +01:00
|
|
|
void QmlJSObserverClient::setExecutionPaused(bool paused)
|
|
|
|
|
{
|
|
|
|
|
if (!m_connection || !m_connection->isConnected())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
QByteArray message;
|
|
|
|
|
QDataStream ds(&message, QIODevice::WriteOnly);
|
|
|
|
|
|
|
|
|
|
ObserverProtocol::Message cmd = ObserverProtocol::SetExecutionPaused;
|
|
|
|
|
ds << cmd
|
|
|
|
|
<< paused;
|
2010-12-16 17:26:25 +01:00
|
|
|
|
2011-03-18 20:45:23 +01:00
|
|
|
log(LogSend, cmd, paused ? QLatin1String("true") : QLatin1String("false"));
|
2010-10-07 10:56:36 +02:00
|
|
|
|
2010-07-08 11:34:51 +02:00
|
|
|
sendMessage(message);
|
|
|
|
|
}
|
|
|
|
|
|
2010-09-16 13:16:47 +02:00
|
|
|
void QmlJSObserverClient::changeToColorPickerTool()
|
2010-07-08 11:34:51 +02:00
|
|
|
{
|
|
|
|
|
if (!m_connection || !m_connection->isConnected())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
QByteArray message;
|
|
|
|
|
QDataStream ds(&message, QIODevice::WriteOnly);
|
|
|
|
|
|
2011-02-24 17:26:36 +01:00
|
|
|
ObserverProtocol::Message cmd = ObserverProtocol::ChangeTool;
|
|
|
|
|
ObserverProtocol::Tool tool = ObserverProtocol::ColorPickerTool;
|
2010-12-16 17:26:25 +01:00
|
|
|
ds << cmd
|
|
|
|
|
<< tool;
|
2010-10-07 10:56:36 +02:00
|
|
|
|
2011-02-24 17:26:36 +01:00
|
|
|
log(LogSend, cmd, ObserverProtocol::toString(tool));
|
2010-10-07 10:56:36 +02:00
|
|
|
|
2010-07-08 11:34:51 +02:00
|
|
|
sendMessage(message);
|
|
|
|
|
}
|
|
|
|
|
|
2010-09-16 13:16:47 +02:00
|
|
|
void QmlJSObserverClient::changeToSelectTool()
|
2010-07-08 11:34:51 +02:00
|
|
|
{
|
|
|
|
|
if (!m_connection || !m_connection->isConnected())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
QByteArray message;
|
|
|
|
|
QDataStream ds(&message, QIODevice::WriteOnly);
|
|
|
|
|
|
2011-02-24 17:26:36 +01:00
|
|
|
ObserverProtocol::Message cmd = ObserverProtocol::ChangeTool;
|
|
|
|
|
ObserverProtocol::Tool tool = ObserverProtocol::SelectTool;
|
2010-12-16 17:26:25 +01:00
|
|
|
ds << cmd
|
|
|
|
|
<< tool;
|
2010-10-07 10:56:36 +02:00
|
|
|
|
2011-02-24 17:26:36 +01:00
|
|
|
log(LogSend, cmd, ObserverProtocol::toString(tool));
|
2010-10-07 10:56:36 +02:00
|
|
|
|
2010-07-08 11:34:51 +02:00
|
|
|
sendMessage(message);
|
|
|
|
|
}
|
|
|
|
|
|
2010-09-16 13:16:47 +02:00
|
|
|
void QmlJSObserverClient::changeToSelectMarqueeTool()
|
2010-07-08 11:34:51 +02:00
|
|
|
{
|
|
|
|
|
if (!m_connection || !m_connection->isConnected())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
QByteArray message;
|
|
|
|
|
QDataStream ds(&message, QIODevice::WriteOnly);
|
|
|
|
|
|
2011-02-24 17:26:36 +01:00
|
|
|
ObserverProtocol::Message cmd = ObserverProtocol::ChangeTool;
|
|
|
|
|
ObserverProtocol::Tool tool = ObserverProtocol::SelectMarqueeTool;
|
2010-12-16 17:26:25 +01:00
|
|
|
ds << cmd
|
|
|
|
|
<< tool;
|
2010-10-07 10:56:36 +02:00
|
|
|
|
2011-02-24 17:26:36 +01:00
|
|
|
log(LogSend, cmd, ObserverProtocol::toString(tool));
|
2010-10-07 10:56:36 +02:00
|
|
|
|
2010-07-08 11:34:51 +02:00
|
|
|
sendMessage(message);
|
|
|
|
|
}
|
|
|
|
|
|
2010-09-16 13:16:47 +02:00
|
|
|
void QmlJSObserverClient::changeToZoomTool()
|
2010-07-08 11:34:51 +02:00
|
|
|
{
|
|
|
|
|
if (!m_connection || !m_connection->isConnected())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
QByteArray message;
|
|
|
|
|
QDataStream ds(&message, QIODevice::WriteOnly);
|
|
|
|
|
|
2011-02-24 17:26:36 +01:00
|
|
|
ObserverProtocol::Message cmd = ObserverProtocol::ChangeTool;
|
|
|
|
|
ObserverProtocol::Tool tool = ObserverProtocol::ZoomTool;
|
2010-12-16 17:26:25 +01:00
|
|
|
ds << cmd
|
|
|
|
|
<< tool;
|
2010-10-07 10:56:36 +02:00
|
|
|
|
2011-02-24 17:26:36 +01:00
|
|
|
log(LogSend, cmd, ObserverProtocol::toString(tool));
|
2010-10-07 10:56:36 +02:00
|
|
|
|
2010-07-08 11:34:51 +02:00
|
|
|
sendMessage(message);
|
|
|
|
|
}
|
|
|
|
|
|
2010-11-23 10:07:09 +01:00
|
|
|
void QmlJSObserverClient::showAppOnTop(bool showOnTop)
|
|
|
|
|
{
|
|
|
|
|
if (!m_connection || !m_connection->isConnected())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
QByteArray message;
|
|
|
|
|
QDataStream ds(&message, QIODevice::WriteOnly);
|
|
|
|
|
|
2011-02-24 17:26:36 +01:00
|
|
|
ObserverProtocol::Message cmd = ObserverProtocol::ShowAppOnTop;
|
2011-01-24 17:51:24 +01:00
|
|
|
ds << cmd << showOnTop;
|
2010-11-23 10:07:09 +01:00
|
|
|
|
2011-02-24 17:26:36 +01:00
|
|
|
log(LogSend, cmd, QLatin1String(showOnTop ? "true" : "false"));
|
2010-11-23 10:07:09 +01:00
|
|
|
|
|
|
|
|
sendMessage(message);
|
|
|
|
|
}
|
|
|
|
|
|
2010-09-16 13:16:47 +02:00
|
|
|
void QmlJSObserverClient::createQmlObject(const QString &qmlText, int parentDebugId,
|
2010-07-16 09:41:56 +02:00
|
|
|
const QStringList &imports, const QString &filename)
|
|
|
|
|
{
|
|
|
|
|
if (!m_connection || !m_connection->isConnected())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
QByteArray message;
|
|
|
|
|
QDataStream ds(&message, QIODevice::WriteOnly);
|
|
|
|
|
|
2011-02-24 17:26:36 +01:00
|
|
|
ObserverProtocol::Message cmd = ObserverProtocol::CreateObject;
|
2010-12-16 17:26:25 +01:00
|
|
|
ds << cmd
|
2010-07-16 09:41:56 +02:00
|
|
|
<< qmlText
|
2010-07-21 14:26:25 +02:00
|
|
|
<< parentDebugId
|
2010-07-16 09:41:56 +02:00
|
|
|
<< imports
|
|
|
|
|
<< filename;
|
|
|
|
|
|
2011-02-24 17:26:36 +01:00
|
|
|
log(LogSend, cmd, QString("%1 %2 [%3] %4").arg(qmlText, QString::number(parentDebugId),
|
|
|
|
|
imports.join(","), filename));
|
2010-10-07 10:56:36 +02:00
|
|
|
|
2010-07-16 09:41:56 +02:00
|
|
|
sendMessage(message);
|
|
|
|
|
}
|
|
|
|
|
|
2010-09-16 13:16:47 +02:00
|
|
|
void QmlJSObserverClient::destroyQmlObject(int debugId)
|
2010-07-19 10:42:39 +02:00
|
|
|
{
|
|
|
|
|
if (!m_connection || !m_connection->isConnected())
|
|
|
|
|
return;
|
|
|
|
|
QByteArray message;
|
|
|
|
|
QDataStream ds(&message, QIODevice::WriteOnly);
|
|
|
|
|
|
2011-02-24 17:26:36 +01:00
|
|
|
ObserverProtocol::Message cmd = ObserverProtocol::DestroyObject;
|
2010-12-16 17:26:25 +01:00
|
|
|
ds << cmd << debugId;
|
2010-07-19 10:42:39 +02:00
|
|
|
|
2011-02-24 17:26:36 +01:00
|
|
|
log(LogSend, cmd, QString::number(debugId));
|
2010-10-07 10:56:36 +02:00
|
|
|
|
2010-07-19 10:42:39 +02:00
|
|
|
sendMessage(message);
|
|
|
|
|
}
|
|
|
|
|
|
2010-09-16 13:16:47 +02:00
|
|
|
void QmlJSObserverClient::reparentQmlObject(int debugId, int newParent)
|
2010-08-26 17:38:31 +02:00
|
|
|
{
|
|
|
|
|
if (!m_connection || !m_connection->isConnected())
|
|
|
|
|
return;
|
|
|
|
|
QByteArray message;
|
|
|
|
|
QDataStream ds(&message, QIODevice::WriteOnly);
|
|
|
|
|
|
2011-02-24 17:26:36 +01:00
|
|
|
ObserverProtocol::Message cmd = ObserverProtocol::MoveObject;
|
2010-12-16 17:26:25 +01:00
|
|
|
ds << cmd
|
2010-08-26 17:38:31 +02:00
|
|
|
<< debugId
|
|
|
|
|
<< newParent;
|
|
|
|
|
|
2011-02-24 17:26:36 +01:00
|
|
|
log(LogSend, cmd, QString("%1 %2").arg(QString::number(debugId),
|
|
|
|
|
QString::number(newParent)));
|
2010-10-07 10:56:36 +02:00
|
|
|
|
2010-08-26 17:38:31 +02:00
|
|
|
sendMessage(message);
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-19 10:42:39 +02:00
|
|
|
|
2010-09-16 13:16:47 +02:00
|
|
|
void QmlJSObserverClient::applyChangesToQmlFile()
|
2010-07-08 11:34:51 +02:00
|
|
|
{
|
|
|
|
|
if (!m_connection || !m_connection->isConnected())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
// TODO
|
|
|
|
|
}
|
|
|
|
|
|
2010-09-16 13:16:47 +02:00
|
|
|
void QmlJSObserverClient::applyChangesFromQmlFile()
|
2010-07-08 11:34:51 +02:00
|
|
|
{
|
|
|
|
|
if (!m_connection || !m_connection->isConnected())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
// TODO
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-24 17:26:36 +01:00
|
|
|
void QmlJSObserverClient::log(LogDirection direction, ObserverProtocol::Message message,
|
|
|
|
|
const QString &extra)
|
2010-12-16 17:26:25 +01:00
|
|
|
{
|
|
|
|
|
QString msg;
|
2011-02-24 17:26:36 +01:00
|
|
|
if (direction == LogSend)
|
|
|
|
|
msg += QLatin1String(" sending ");
|
|
|
|
|
else
|
|
|
|
|
msg += QLatin1String(" receiving ");
|
|
|
|
|
|
|
|
|
|
msg += ObserverProtocol::toString(message);
|
|
|
|
|
msg += QLatin1Char(' ');
|
|
|
|
|
msg += extra;
|
2010-12-16 17:26:25 +01:00
|
|
|
emit logActivity(name(), msg);
|
|
|
|
|
}
|
2010-07-08 11:34:51 +02:00
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace QmlJSInspector
|