forked from qt-creator/qt-creator
QmlDesigner: Add capturing for qml puppet streams
Change-Id: I094e01b85cfe1ddafb0590f56d9d5b810a390cb4 Reviewed-by: Thomas Hartmann <Thomas.Hartmann@digia.com>
This commit is contained in:
@@ -20,4 +20,7 @@ will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.</license>
|
|||||||
<description>Visual Designer for QML files.</description>
|
<description>Visual Designer for QML files.</description>
|
||||||
<url>http://www.qt-project.org</url>
|
<url>http://www.qt-project.org</url>
|
||||||
$$dependencyList
|
$$dependencyList
|
||||||
|
<argumentList>
|
||||||
|
<argument name=\"-capture-puppet-stream\" parameter=\"capture file\">Captures the Qml Puppet stream</argument>
|
||||||
|
</argumentList>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|||||||
@@ -38,6 +38,7 @@
|
|||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
|
#include <QMessageBox>
|
||||||
|
|
||||||
#include "createinstancescommand.h"
|
#include "createinstancescommand.h"
|
||||||
#include "createscenecommand.h"
|
#include "createscenecommand.h"
|
||||||
@@ -240,6 +241,13 @@ NodeInstanceServerProxy::NodeInstanceServerProxy(NodeInstanceView *nodeInstanceV
|
|||||||
} else {
|
} else {
|
||||||
QMessageBox::warning(0, tr("Cannot Find QML Puppet Executable"), missingQmlPuppetErrorMessage(applicationPath));
|
QMessageBox::warning(0, tr("Cannot Find QML Puppet Executable"), missingQmlPuppetErrorMessage(applicationPath));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int indexOfCapturePuppetStream = QCoreApplication::arguments().indexOf("-capture-puppet-stream");
|
||||||
|
if (indexOfCapturePuppetStream > 0) {
|
||||||
|
m_captureFileForTest.setFileName(QCoreApplication::arguments().at(indexOfCapturePuppetStream + 1));
|
||||||
|
bool isOpen = m_captureFileForTest.open(QIODevice::WriteOnly);
|
||||||
|
qDebug() << "file is open: " << isOpen;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NodeInstanceServerProxy::~NodeInstanceServerProxy()
|
NodeInstanceServerProxy::~NodeInstanceServerProxy()
|
||||||
@@ -333,9 +341,9 @@ QString NodeInstanceServerProxy::missingQmlPuppetErrorMessage(const QString &app
|
|||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void writeCommandToSocket(const QVariant &command, QLocalSocket *socket, unsigned int commandCounter)
|
static void writeCommandToIODecive(const QVariant &command, QIODevice *ioDevice, unsigned int commandCounter)
|
||||||
{
|
{
|
||||||
if (socket) {
|
if (ioDevice) {
|
||||||
QByteArray block;
|
QByteArray block;
|
||||||
QDataStream out(&block, QIODevice::WriteOnly);
|
QDataStream out(&block, QIODevice::WriteOnly);
|
||||||
out.setVersion(QDataStream::Qt_4_8);
|
out.setVersion(QDataStream::Qt_4_8);
|
||||||
@@ -345,22 +353,29 @@ static void writeCommandToSocket(const QVariant &command, QLocalSocket *socket,
|
|||||||
out.device()->seek(0);
|
out.device()->seek(0);
|
||||||
out << quint32(block.size() - sizeof(quint32));
|
out << quint32(block.size() - sizeof(quint32));
|
||||||
|
|
||||||
socket->write(block);
|
ioDevice->write(block);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void NodeInstanceServerProxy::writeCommand(const QVariant &command)
|
void NodeInstanceServerProxy::writeCommand(const QVariant &command)
|
||||||
{
|
{
|
||||||
writeCommandToSocket(command, m_firstSocket.data(), m_writeCommandCounter);
|
writeCommandToIODecive(command, m_firstSocket.data(), m_writeCommandCounter);
|
||||||
writeCommandToSocket(command, m_secondSocket.data(), m_writeCommandCounter);
|
writeCommandToIODecive(command, m_secondSocket.data(), m_writeCommandCounter);
|
||||||
writeCommandToSocket(command, m_thirdSocket.data(), m_writeCommandCounter);
|
writeCommandToIODecive(command, m_thirdSocket.data(), m_writeCommandCounter);
|
||||||
|
|
||||||
|
if (m_captureFileForTest.isWritable()) {
|
||||||
|
qDebug() << "Write strean to file: " << m_captureFileForTest.fileName();
|
||||||
|
writeCommandToIODecive(command, &m_captureFileForTest, m_writeCommandCounter);
|
||||||
|
qDebug() << "\twrite file: " << m_captureFileForTest.pos();
|
||||||
|
}
|
||||||
|
|
||||||
m_writeCommandCounter++;
|
m_writeCommandCounter++;
|
||||||
if (m_runModus == TestModus) {
|
if (m_runModus == TestModus) {
|
||||||
static int synchronizeId = 0;
|
static int synchronizeId = 0;
|
||||||
synchronizeId++;
|
synchronizeId++;
|
||||||
SynchronizeCommand synchronizeCommand(synchronizeId);
|
SynchronizeCommand synchronizeCommand(synchronizeId);
|
||||||
|
|
||||||
writeCommandToSocket(QVariant::fromValue(synchronizeCommand), m_firstSocket.data(), m_writeCommandCounter);
|
writeCommandToIODecive(QVariant::fromValue(synchronizeCommand), m_firstSocket.data(), m_writeCommandCounter);
|
||||||
m_writeCommandCounter++;
|
m_writeCommandCounter++;
|
||||||
|
|
||||||
while (m_firstSocket->waitForReadyRead(100)) {
|
while (m_firstSocket->waitForReadyRead(100)) {
|
||||||
@@ -375,6 +390,14 @@ void NodeInstanceServerProxy::processFinished(int /*exitCode*/, QProcess::ExitSt
|
|||||||
{
|
{
|
||||||
qDebug() << "Process finished:" << sender();
|
qDebug() << "Process finished:" << sender();
|
||||||
|
|
||||||
|
if (m_captureFileForTest.isOpen()) {
|
||||||
|
m_captureFileForTest.close();
|
||||||
|
m_captureFileForTest.remove();
|
||||||
|
QMessageBox::warning(0, tr("Qml Puppet crashes"), tr("Your are recording a Puppet stream and the puppet crashes. "
|
||||||
|
"It is recommended to reopen the Qml Designer and start again."));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
writeCommand(QVariant::fromValue(EndPuppetCommand()));
|
writeCommand(QVariant::fromValue(EndPuppetCommand()));
|
||||||
|
|
||||||
if (m_firstSocket)
|
if (m_firstSocket)
|
||||||
|
|||||||
@@ -34,6 +34,7 @@
|
|||||||
|
|
||||||
#include <QWeakPointer>
|
#include <QWeakPointer>
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
|
#include <QFile>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QLocalServer;
|
class QLocalServer;
|
||||||
@@ -75,6 +76,8 @@ protected:
|
|||||||
void dispatchCommand(const QVariant &command);
|
void dispatchCommand(const QVariant &command);
|
||||||
NodeInstanceClientInterface *nodeInstanceClient() const;
|
NodeInstanceClientInterface *nodeInstanceClient() const;
|
||||||
QString missingQmlPuppetErrorMessage(const QString &applicationPath) const;
|
QString missingQmlPuppetErrorMessage(const QString &applicationPath) const;
|
||||||
|
QString qmlPuppetApplicationName() const;
|
||||||
|
QString macOSBundlePath(const QString &path) const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void processCrashed();
|
void processCrashed();
|
||||||
@@ -86,9 +89,7 @@ private slots:
|
|||||||
void readThirdDataStream();
|
void readThirdDataStream();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString qmlPuppetApplicationName() const;
|
QFile m_captureFileForTest;
|
||||||
QString macOSBundlePath(const QString &path) const;
|
|
||||||
|
|
||||||
QWeakPointer<QLocalServer> m_localServer;
|
QWeakPointer<QLocalServer> m_localServer;
|
||||||
QWeakPointer<QLocalSocket> m_firstSocket;
|
QWeakPointer<QLocalSocket> m_firstSocket;
|
||||||
QWeakPointer<QLocalSocket> m_secondSocket;
|
QWeakPointer<QLocalSocket> m_secondSocket;
|
||||||
|
|||||||
@@ -41,6 +41,7 @@
|
|||||||
#include <coreplugin/designmode.h>
|
#include <coreplugin/designmode.h>
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
#include <coreplugin/modemanager.h>
|
#include <coreplugin/modemanager.h>
|
||||||
|
#include <extensionsystem/pluginspec.h>
|
||||||
|
|
||||||
#include <projectexplorer/projectexplorerconstants.h>
|
#include <projectexplorer/projectexplorerconstants.h>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user