2010-07-08 14:00:33 +02:00
|
|
|
#include "qdeclarativedesigndebugserver.h"
|
|
|
|
|
|
|
|
#include <QDebug>
|
|
|
|
|
|
|
|
QDeclarativeDesignDebugServer::QDeclarativeDesignDebugServer(QObject *parent)
|
|
|
|
: QDeclarativeDebugService(QLatin1String("QDeclarativeDesignMode"), parent)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void QDeclarativeDesignDebugServer::messageReceived(const QByteArray &message)
|
|
|
|
{
|
|
|
|
QDataStream ds(message);
|
|
|
|
|
|
|
|
QByteArray type;
|
|
|
|
ds >> type;
|
|
|
|
|
|
|
|
if (type == "SET_CURRENT_OBJECTS") {
|
|
|
|
int itemCount = 0;
|
|
|
|
ds >> itemCount;
|
|
|
|
|
|
|
|
QList<QObject*> selectedObjects;
|
|
|
|
for(int i = 0; i < itemCount; ++i) {
|
|
|
|
int debugId = -1;
|
|
|
|
ds >> debugId;
|
|
|
|
QObject *obj = objectForId(debugId);
|
|
|
|
|
|
|
|
if (obj)
|
|
|
|
selectedObjects << obj;
|
|
|
|
}
|
|
|
|
|
|
|
|
emit currentObjectsChanged(selectedObjects);
|
|
|
|
|
|
|
|
} else if (type == "RELOAD") {
|
|
|
|
emit reloadRequested();
|
|
|
|
} else if (type == "SET_ANIMATION_SPEED") {
|
|
|
|
qreal speed;
|
|
|
|
ds >> speed;
|
|
|
|
emit animationSpeedChangeRequested(speed);
|
|
|
|
} else if (type == "CHANGE_TOOL") {
|
|
|
|
QByteArray toolName;
|
|
|
|
ds >> toolName;
|
|
|
|
if (toolName == "COLOR_PICKER") {
|
2010-07-12 12:02:35 +02:00
|
|
|
emit colorPickerToolRequested();
|
2010-07-08 14:00:33 +02:00
|
|
|
} else if (toolName == "SELECT") {
|
2010-07-12 12:02:35 +02:00
|
|
|
emit selectToolRequested();
|
2010-07-08 14:00:33 +02:00
|
|
|
} else if (toolName == "SELECT_MARQUEE") {
|
2010-07-12 12:02:35 +02:00
|
|
|
emit selectMarqueeToolRequested();
|
2010-07-08 14:00:33 +02:00
|
|
|
} else if (toolName == "ZOOM") {
|
2010-07-12 12:02:35 +02:00
|
|
|
emit zoomToolRequested();
|
2010-07-08 14:00:33 +02:00
|
|
|
}
|
2010-07-12 12:02:35 +02:00
|
|
|
} else if (type == "SET_DESIGN_MODE") {
|
|
|
|
bool inDesignMode;
|
|
|
|
ds >> inDesignMode;
|
|
|
|
emit designModeBehaviorChanged(inDesignMode);
|
2010-07-08 14:00:33 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-07-12 12:02:35 +02:00
|
|
|
void QDeclarativeDesignDebugServer::setDesignModeBehavior(bool inDesignMode)
|
|
|
|
{
|
|
|
|
QByteArray message;
|
|
|
|
QDataStream ds(&message, QIODevice::WriteOnly);
|
|
|
|
|
|
|
|
ds << QByteArray("SET_DESIGN_MODE")
|
|
|
|
<< inDesignMode;
|
|
|
|
|
|
|
|
sendMessage(message);
|
|
|
|
}
|
2010-07-08 14:00:33 +02:00
|
|
|
|
|
|
|
void QDeclarativeDesignDebugServer::setCurrentObjects(QList<QObject*> objects)
|
|
|
|
{
|
|
|
|
QByteArray message;
|
|
|
|
QDataStream ds(&message, QIODevice::WriteOnly);
|
|
|
|
|
|
|
|
ds << QByteArray("CURRENT_OBJECTS_CHANGED")
|
|
|
|
<< objects.length();
|
|
|
|
|
|
|
|
foreach(QObject *object, objects) {
|
|
|
|
int id = idForObject(object);
|
|
|
|
ds << id;
|
|
|
|
}
|
|
|
|
|
|
|
|
sendMessage(message);
|
|
|
|
}
|
|
|
|
|
|
|
|
void QDeclarativeDesignDebugServer::setCurrentTool(QmlViewer::Constants::DesignTool toolId)
|
|
|
|
{
|
|
|
|
QByteArray message;
|
|
|
|
QDataStream ds(&message, QIODevice::WriteOnly);
|
|
|
|
|
|
|
|
ds << QByteArray("TOOL_CHANGED")
|
|
|
|
<< toolId;
|
|
|
|
|
|
|
|
sendMessage(message);
|
|
|
|
}
|
|
|
|
|
|
|
|
void QDeclarativeDesignDebugServer::setAnimationSpeed(qreal slowdownFactor)
|
|
|
|
{
|
|
|
|
|
|
|
|
QByteArray message;
|
|
|
|
QDataStream ds(&message, QIODevice::WriteOnly);
|
|
|
|
|
|
|
|
ds << QByteArray("ANIMATION_SPEED_CHANGED")
|
|
|
|
<< slowdownFactor;
|
|
|
|
|
|
|
|
sendMessage(message);
|
|
|
|
}
|