QmlDebugger: Log activity of Observer in debugger log

This commit is contained in:
Kai Koehne
2010-12-16 17:26:25 +01:00
parent d6bc3a2822
commit 948ca6f2ac
5 changed files with 114 additions and 56 deletions

View File

@@ -285,6 +285,11 @@ void QmlAdapter::logServiceStatusChange(const QString &service, QDeclarativeDebu
} }
} }
void QmlAdapter::logServiceActivity(const QString &service, const QString &logMessage)
{
showConnectionStatusMessage(QString("%1 %2").arg(service, logMessage));
}
void QmlAdapter::flushSendBuffer() void QmlAdapter::flushSendBuffer()
{ {
QTC_ASSERT(d->m_qmlClient->status() == QDeclarativeDebugClient::Enabled, return); QTC_ASSERT(d->m_qmlClient->status() == QDeclarativeDebugClient::Enabled, return);

View File

@@ -73,7 +73,9 @@ public:
void setMaxConnectionAttempts(int maxAttempts); void setMaxConnectionAttempts(int maxAttempts);
void setConnectionAttemptInterval(int interval); void setConnectionAttemptInterval(int interval);
void logServiceStatusChange(const QString &service, QDeclarativeDebugClient::Status newStatus); public slots:
void logServiceStatusChange(const QString &service, QDeclarativeDebugClient::Status newStatus);
void logServiceActivity(const QString &service, const QString &logMessage);
signals: signals:
void connected(); void connected();

View File

@@ -94,6 +94,8 @@ void ClientProxy::connectToServer()
SIGNAL(selectedColorChanged(QColor))); SIGNAL(selectedColorChanged(QColor)));
connect(m_observerClient, SIGNAL(contextPathUpdated(QStringList)), connect(m_observerClient, SIGNAL(contextPathUpdated(QStringList)),
SIGNAL(contextPathUpdated(QStringList))); SIGNAL(contextPathUpdated(QStringList)));
connect(m_observerClient, SIGNAL(logActivity(QString,QString)),
m_adapter, SLOT(logServiceActivity(QString,QString)));
updateConnected(); updateConnected();
} }
@@ -133,6 +135,8 @@ void ClientProxy::disconnectFromServer()
this, SIGNAL(selectedColorChanged(QColor))); this, SIGNAL(selectedColorChanged(QColor)));
disconnect(m_observerClient, SIGNAL(contextPathUpdated(QStringList)), disconnect(m_observerClient, SIGNAL(contextPathUpdated(QStringList)),
this, SIGNAL(contextPathUpdated(QStringList))); this, SIGNAL(contextPathUpdated(QStringList)));
disconnect(m_observerClient, SIGNAL(logActivity(QString,QString)),
m_adapter, SLOT(logServiceActivity(QString,QString)));
delete m_observerClient; delete m_observerClient;
m_observerClient = 0; m_observerClient = 0;

View File

@@ -45,10 +45,6 @@
#include <QColor> #include <QColor>
enum {
debug = true
};
namespace QmlJSInspector { namespace QmlJSInspector {
namespace Internal { namespace Internal {
@@ -75,6 +71,9 @@ void QmlJSObserverClient::messageReceived(const QByteArray &message)
int objectCount; int objectCount;
ds >> objectCount; ds >> objectCount;
log(LogReceive, QString("%1 %2 [list of debug ids]").arg(QString(type),
QString::number(objectCount)));
m_currentDebugIds.clear(); m_currentDebugIds.clear();
for(int i = 0; i < objectCount; ++i) { for(int i = 0; i < objectCount; ++i) {
@@ -90,6 +89,8 @@ void QmlJSObserverClient::messageReceived(const QByteArray &message)
int toolId; int toolId;
ds >> toolId; ds >> toolId;
log(LogReceive, QString("%1 %2").arg(QString(type), QString::number(toolId)));
if (toolId == Constants::ColorPickerMode) { if (toolId == Constants::ColorPickerMode) {
emit colorPickerActivated(); emit colorPickerActivated();
} else if (toolId == Constants::ZoomMode) { } else if (toolId == Constants::ZoomMode) {
@@ -102,24 +103,42 @@ void QmlJSObserverClient::messageReceived(const QByteArray &message)
} else if (type == "ANIMATION_SPEED_CHANGED") { } else if (type == "ANIMATION_SPEED_CHANGED") {
qreal slowdownFactor; qreal slowdownFactor;
ds >> slowdownFactor; ds >> slowdownFactor;
log(LogReceive, QString("%1 %2").arg(QString(type), QString::number(slowdownFactor)));
emit animationSpeedChanged(slowdownFactor); emit animationSpeedChanged(slowdownFactor);
} else if (type == "SET_DESIGN_MODE") { } else if (type == "SET_DESIGN_MODE") {
bool inDesignMode; bool inDesignMode;
ds >> inDesignMode; ds >> inDesignMode;
log(LogReceive, QString("%1 %2").arg(QString(type), inDesignMode ? "true" : "false"));
emit designModeBehaviorChanged(inDesignMode); emit designModeBehaviorChanged(inDesignMode);
} else if (type == "SHOW_APP_ON_TOP") { } else if (type == "SHOW_APP_ON_TOP") {
bool showAppOnTop; bool showAppOnTop;
ds >> showAppOnTop; ds >> showAppOnTop;
log(LogReceive, QString("%1 %2").arg(QString(type), showAppOnTop ? "true" : "false"));
emit showAppOnTopChanged(showAppOnTop); emit showAppOnTopChanged(showAppOnTop);
} else if (type == "RELOADED") { } else if (type == "RELOADED") {
log(LogReceive, type);
emit reloaded(); emit reloaded();
} else if (type == "COLOR_CHANGED") { } else if (type == "COLOR_CHANGED") {
QColor col; QColor col;
ds >> col; ds >> col;
log(LogReceive, QString("%1 %2").arg(QString(type), col.name()));
emit selectedColorChanged(col); emit selectedColorChanged(col);
} else if (type == "CONTEXT_PATH_UPDATED") { } else if (type == "CONTEXT_PATH_UPDATED") {
QStringList contextPath; QStringList contextPath;
ds >> contextPath; ds >> contextPath;
log(LogReceive, QString("%1 %2").arg(QString(type), contextPath.join(", ")));
emit contextPathUpdated(contextPath); emit contextPathUpdated(contextPath);
} }
} }
@@ -141,15 +160,16 @@ void QmlJSObserverClient::setCurrentObjects(const QList<int> &debugIds) {
QByteArray message; QByteArray message;
QDataStream ds(&message, QIODevice::WriteOnly); QDataStream ds(&message, QIODevice::WriteOnly);
ds << QByteArray("SET_CURRENT_OBJECTS") QByteArray cmd = "SET_CURRENT_OBJECTS";
ds << cmd
<< debugIds.length(); << debugIds.length();
foreach (int id, debugIds) { foreach (int id, debugIds) {
ds << id; ds << id;
} }
if (debug) log(LogSend, QString("%1 %2 [list of ids]").arg(QString(cmd),
qDebug() << "QmlJSObserverClient: Sending" <<"SET_CURRENT_OBJECTS" << debugIds.length() << "[list of ids]"; QString::number(debugIds.length())));
sendMessage(message); sendMessage(message);
} }
@@ -175,7 +195,8 @@ void QmlJSObserverClient::setObjectIdList(const QList<QDeclarativeDebugObjectRef
recurseObjectIdList(ref, debugIds, objectIds); recurseObjectIdList(ref, debugIds, objectIds);
} }
ds << QByteArray("OBJECT_ID_LIST") QByteArray cmd = "OBJECT_ID_LIST";
ds << cmd
<< debugIds.length(); << debugIds.length();
Q_ASSERT(debugIds.length() == objectIds.length()); Q_ASSERT(debugIds.length() == objectIds.length());
@@ -184,8 +205,8 @@ void QmlJSObserverClient::setObjectIdList(const QList<QDeclarativeDebugObjectRef
ds << debugIds[i] << objectIds[i]; ds << debugIds[i] << objectIds[i];
} }
if (debug) log(LogSend, QString("%1 %2 [list of debug / object ids]").arg(QString(cmd),
qDebug() << "QmlJSObserverClient: Sending" <<"OBJECT_ID_LIST" << debugIds.length() << "[list of debug / object ids]"; QString::number(debugIds.length())));
sendMessage(message); sendMessage(message);
} }
@@ -198,11 +219,11 @@ void QmlJSObserverClient::setContextPathIndex(int contextPathIndex)
QByteArray message; QByteArray message;
QDataStream ds(&message, QIODevice::WriteOnly); QDataStream ds(&message, QIODevice::WriteOnly);
ds << QByteArray("SET_CONTEXT_PATH_IDX") QByteArray cmd = "SET_CONTEXT_PATH_IDX";
ds << cmd
<< contextPathIndex; << contextPathIndex;
if (debug) log(LogSend, QString("%1 %2").arg(QString(cmd), contextPathIndex));
qDebug() << "QmlJSObserverClient: Sending" <<"SET_CONTEXT_PATH_IDX" << contextPathIndex;
sendMessage(message); sendMessage(message);
} }
@@ -215,10 +236,10 @@ void QmlJSObserverClient::clearComponentCache()
QByteArray message; QByteArray message;
QDataStream ds(&message, QIODevice::WriteOnly); QDataStream ds(&message, QIODevice::WriteOnly);
ds << QByteArray("CLEAR_COMPONENT_CACHE"); QByteArray cmd = "CLEAR_COMPONENT_CACHE";
ds << cmd;
if (debug) log(LogSend, cmd);
qDebug() << "QmlJSObserverClient: Sending" <<"CLEAR_COMPONENT_CACHE";
sendMessage(message); sendMessage(message);
} }
@@ -231,10 +252,10 @@ void QmlJSObserverClient::reloadViewer()
QByteArray message; QByteArray message;
QDataStream ds(&message, QIODevice::WriteOnly); QDataStream ds(&message, QIODevice::WriteOnly);
ds << QByteArray("RELOAD"); QByteArray cmd = "RELOAD";
ds << cmd;
if (debug) log(LogSend, cmd);
qDebug() << "QmlJSObserverClient: Sending" <<"RELOAD";
sendMessage(message); sendMessage(message);
} }
@@ -247,11 +268,11 @@ void QmlJSObserverClient::setDesignModeBehavior(bool inDesignMode)
QByteArray message; QByteArray message;
QDataStream ds(&message, QIODevice::WriteOnly); QDataStream ds(&message, QIODevice::WriteOnly);
ds << QByteArray("SET_DESIGN_MODE") QByteArray cmd = "SET_DESIGN_MODE";
ds << cmd
<< inDesignMode; << inDesignMode;
if (debug) log(LogSend, QString("%1 %2").arg(QString(cmd), inDesignMode ? "true" : "false"));
qDebug() << "QmlJSObserverClient: Sending" <<"SET_DESIGN_MODE" << inDesignMode;
sendMessage(message); sendMessage(message);
} }
@@ -264,11 +285,12 @@ void QmlJSObserverClient::setAnimationSpeed(qreal slowdownFactor)
QByteArray message; QByteArray message;
QDataStream ds(&message, QIODevice::WriteOnly); QDataStream ds(&message, QIODevice::WriteOnly);
ds << QByteArray("SET_ANIMATION_SPEED") QByteArray cmd = "SET_ANIMATION_SPEED";
ds << cmd
<< slowdownFactor; << slowdownFactor;
if (debug)
qDebug() << "QmlJSObserverClient: Sending" <<"SET_ANIMATION_SPEED" << slowdownFactor; log(LogSend, QString("%1 %2").arg(QString(cmd), QString::number(slowdownFactor)));
sendMessage(message); sendMessage(message);
} }
@@ -281,11 +303,12 @@ void QmlJSObserverClient::changeToColorPickerTool()
QByteArray message; QByteArray message;
QDataStream ds(&message, QIODevice::WriteOnly); QDataStream ds(&message, QIODevice::WriteOnly);
ds << QByteArray("CHANGE_TOOL") QByteArray cmd = "CHANGE_TOOL";
<< QByteArray("COLOR_PICKER"); QByteArray tool = "COLOR_PICKER";
ds << cmd
<< tool;
if (debug) log(LogSend, QString("%1 %2").arg(QString(cmd), QString(tool)));
qDebug() << "QmlJSObserverClient: Sending" <<"CHANGE_TOOL" << "COLOR_PICKER";
sendMessage(message); sendMessage(message);
} }
@@ -298,11 +321,12 @@ void QmlJSObserverClient::changeToSelectTool()
QByteArray message; QByteArray message;
QDataStream ds(&message, QIODevice::WriteOnly); QDataStream ds(&message, QIODevice::WriteOnly);
ds << QByteArray("CHANGE_TOOL") QByteArray cmd = "CHANGE_TOOL";
<< QByteArray("SELECT"); QByteArray tool = "SELECT";
ds << cmd
<< tool;
if (debug) log(LogSend, QString("%1 %2").arg(QString(cmd), QString(tool)));
qDebug() << "QmlJSObserverClient: Sending" <<"CHANGE_TOOL" << "SELECT";
sendMessage(message); sendMessage(message);
} }
@@ -315,11 +339,12 @@ void QmlJSObserverClient::changeToSelectMarqueeTool()
QByteArray message; QByteArray message;
QDataStream ds(&message, QIODevice::WriteOnly); QDataStream ds(&message, QIODevice::WriteOnly);
ds << QByteArray("CHANGE_TOOL") QByteArray cmd = "CHANGE_TOOL";
<< QByteArray("SELECT_MARQUEE"); QByteArray tool = "SELECT_MARQUEE";
ds << cmd
<< tool;
if (debug) log(LogSend, QString("%1 %2").arg(QString(cmd), QString(tool)));
qDebug() << "QmlJSObserverClient: Sending" <<"CHANGE_TOOL" << "SELECT_MARQUEE";
sendMessage(message); sendMessage(message);
} }
@@ -332,11 +357,12 @@ void QmlJSObserverClient::changeToZoomTool()
QByteArray message; QByteArray message;
QDataStream ds(&message, QIODevice::WriteOnly); QDataStream ds(&message, QIODevice::WriteOnly);
ds << QByteArray("CHANGE_TOOL") QByteArray cmd = "CHANGE_TOOL";
<< QByteArray("ZOOM"); QByteArray tool = "ZOOM";
ds << cmd
<< tool;
if (debug) log(LogSend, QString("%1 %2").arg(QString(cmd), QString(tool)));
qDebug() << "QmlJSObserverClient: Sending" <<"CHANGE_TOOL" << "ZOOM";
sendMessage(message); sendMessage(message);
} }
@@ -349,11 +375,10 @@ void QmlJSObserverClient::showAppOnTop(bool showOnTop)
QByteArray message; QByteArray message;
QDataStream ds(&message, QIODevice::WriteOnly); QDataStream ds(&message, QIODevice::WriteOnly);
ds << QByteArray("SHOW_APP_ON_TOP") QByteArray cmd = "SHOW_APP_ON_TOP";
<< showOnTop; ds << showOnTop;
if (debug) log(LogSend, QString("%1 %2").arg(QString(cmd), showOnTop ? "true" : "false");
qDebug() << "QmlJSObserverClient: Sending" <<"SHOWONTOP" << showOnTop;
sendMessage(message); sendMessage(message);
} }
@@ -367,14 +392,15 @@ void QmlJSObserverClient::createQmlObject(const QString &qmlText, int parentDebu
QByteArray message; QByteArray message;
QDataStream ds(&message, QIODevice::WriteOnly); QDataStream ds(&message, QIODevice::WriteOnly);
ds << QByteArray("CREATE_OBJECT") QByteArray cmd = "CREATE_OBJECT";
ds << cmd
<< qmlText << qmlText
<< parentDebugId << parentDebugId
<< imports << imports
<< filename; << filename;
if (debug) log(LogSend, QString("%1 %2 %3 [%4] %5").arg(QString(cmd), qmlText, QString::number(parentDebugId),
qDebug() << "QmlJSObserverClient: Sending" << "CREATE_OBJECT" << qmlText << parentDebugId << imports << filename; imports.join(","), filename));
sendMessage(message); sendMessage(message);
} }
@@ -386,10 +412,10 @@ void QmlJSObserverClient::destroyQmlObject(int debugId)
QByteArray message; QByteArray message;
QDataStream ds(&message, QIODevice::WriteOnly); QDataStream ds(&message, QIODevice::WriteOnly);
ds << QByteArray("DESTROY_OBJECT") << debugId; QByteArray cmd = "DESTROY_OBJECT";
ds << cmd << debugId;
if (debug) log(LogSend, QString("%1 %2").arg(QString(cmd), debugId));
qDebug() << "QmlJSObserverClient: Sending" << "DESTROY_OBJECT" << debugId;
sendMessage(message); sendMessage(message);
} }
@@ -401,12 +427,13 @@ void QmlJSObserverClient::reparentQmlObject(int debugId, int newParent)
QByteArray message; QByteArray message;
QDataStream ds(&message, QIODevice::WriteOnly); QDataStream ds(&message, QIODevice::WriteOnly);
ds << QByteArray("MOVE_OBJECT") QByteArray cmd = "MOVE_OBJECT";
ds << cmd
<< debugId << debugId
<< newParent; << newParent;
if (debug) log(LogSend, QString("%1 %2 %3").arg(QString(cmd), QString::number(debugId),
qDebug() << "QmlJSObserverClient: Sending" << "MOVE_OBJECT" << debugId << newParent; QString::number(newParent)));
sendMessage(message); sendMessage(message);
} }
@@ -428,6 +455,17 @@ void QmlJSObserverClient::applyChangesFromQmlFile()
// TODO // TODO
} }
void QmlJSObserverClient::log(LogDirection direction, const QString &message)
{
QString msg;
if (direction == LogSend) {
msg += " sending ";
} else {
msg += " receiving ";
}
msg += message;
emit logActivity(name(), msg);
}
} // namespace Internal } // namespace Internal
} // namespace QmlJSInspector } // namespace QmlJSInspector

View File

@@ -92,14 +92,23 @@ signals:
void animationSpeedChanged(qreal slowdownFactor); void animationSpeedChanged(qreal slowdownFactor);
void designModeBehaviorChanged(bool inDesignMode); void designModeBehaviorChanged(bool inDesignMode);
void showAppOnTopChanged(bool showAppOnTop); void showAppOnTopChanged(bool showAppOnTop);
void reloaded(); // the server has reloaded the document void reloaded(); // the server has reloadetd he document
void contextPathUpdated(const QStringList &path); void contextPathUpdated(const QStringList &path);
void logActivity(QString client, QString message);
protected: protected:
virtual void statusChanged(Status); virtual void statusChanged(Status);
virtual void messageReceived(const QByteArray &); virtual void messageReceived(const QByteArray &);
private: private:
enum LogDirection {
LogSend,
LogReceive
};
void log(LogDirection direction, const QString &str);
QList<int> m_currentDebugIds; QList<int> m_currentDebugIds;
QDeclarativeDebugConnection *m_connection; QDeclarativeDebugConnection *m_connection;
}; };