forked from qt-creator/qt-creator
QmlDesigner: Introduce multiple node instance server
For capturing data we need a atomic mechanism. So in one process multiple node instance server can be started and then a command is send back that a scene is created. It can be used to ensure that captured data of views is up to date. Task-number: QDS-2630 Change-Id: Iea8d0b036b6384c9c1b0f91af401f2b1f1978c12 Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
committed by
Thomas Hartmann
parent
a535196c41
commit
0f9010d381
@@ -6,6 +6,7 @@ HEADERS += $$PWD/synchronizecommand.h \ \
|
||||
$$PWD/changelanguagecommand.h \
|
||||
$$PWD//debugoutputcommand.h \
|
||||
$$PWD/endpuppetcommand.h \
|
||||
$$PWD/scenecreatedcommand.h \
|
||||
$$PWD/tokencommand.h \
|
||||
$$PWD/componentcompletedcommand.h \
|
||||
$$PWD/completecomponentcommand.h \
|
||||
|
||||
42
share/qtcreator/qml/qmlpuppet/commands/scenecreatedcommand.h
Normal file
42
share/qtcreator/qml/qmlpuppet/commands/scenecreatedcommand.h
Normal file
@@ -0,0 +1,42 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2020 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QMetaType>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
class SceneCreatedCommand
|
||||
{
|
||||
public:
|
||||
friend QDataStream &operator<<(QDataStream &out, const SceneCreatedCommand &) { return out; }
|
||||
|
||||
friend QDataStream &operator>>(QDataStream &in, SceneCreatedCommand &) { return in; }
|
||||
};
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
||||
Q_DECLARE_METATYPE(QmlDesigner::SceneCreatedCommand)
|
||||
@@ -68,6 +68,7 @@
|
||||
#include "removepropertiescommand.h"
|
||||
#include "removesharedmemorycommand.h"
|
||||
#include "reparentinstancescommand.h"
|
||||
#include "scenecreatedcommand.h"
|
||||
#include "statepreviewimagechangedcommand.h"
|
||||
#include "synchronizecommand.h"
|
||||
#include "tokencommand.h"
|
||||
@@ -275,6 +276,11 @@ void NodeInstanceClientProxy::capturedData(const CapturedDataCommand &command)
|
||||
writeCommand(QVariant::fromValue(command));
|
||||
}
|
||||
|
||||
void NodeInstanceClientProxy::sceneCreated(const SceneCreatedCommand &command)
|
||||
{
|
||||
writeCommand(QVariant::fromValue(command));
|
||||
}
|
||||
|
||||
void NodeInstanceClientProxy::flush()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -87,6 +87,7 @@ public:
|
||||
void selectionChanged(const ChangeSelectionCommand &command) override;
|
||||
void handlePuppetToCreatorCommand(const PuppetToCreatorCommand &command) override;
|
||||
void capturedData(const CapturedDataCommand &capturedData) override;
|
||||
void sceneCreated(const SceneCreatedCommand &command) override;
|
||||
|
||||
void flush() override;
|
||||
void synchronizeWithClientProcess() override;
|
||||
|
||||
@@ -43,6 +43,7 @@ class PuppetAliveCommand;
|
||||
class ChangeSelectionCommand;
|
||||
class PuppetToCreatorCommand;
|
||||
class CapturedDataCommand;
|
||||
class SceneCreatedCommand;
|
||||
|
||||
class NodeInstanceClientInterface
|
||||
{
|
||||
@@ -59,6 +60,7 @@ public:
|
||||
virtual void selectionChanged(const ChangeSelectionCommand &command) = 0;
|
||||
virtual void handlePuppetToCreatorCommand(const PuppetToCreatorCommand &command) = 0;
|
||||
virtual void capturedData(const CapturedDataCommand &command) = 0;
|
||||
virtual void sceneCreated(const SceneCreatedCommand &command) = 0;
|
||||
|
||||
virtual void flush() {}
|
||||
virtual void synchronizeWithClientProcess() {}
|
||||
|
||||
@@ -60,6 +60,7 @@
|
||||
#include "removepropertiescommand.h"
|
||||
#include "removesharedmemorycommand.h"
|
||||
#include "reparentinstancescommand.h"
|
||||
#include "scenecreatedcommand.h"
|
||||
#include "statepreviewimagechangedcommand.h"
|
||||
#include "synchronizecommand.h"
|
||||
#include "tokencommand.h"
|
||||
@@ -223,6 +224,9 @@ void NodeInstanceServerInterface::registerCommands()
|
||||
|
||||
qRegisterMetaType<CapturedDataCommand>("CapturedDataCommand");
|
||||
qRegisterMetaTypeStreamOperators<CapturedDataCommand>("CapturedDataCommand");
|
||||
|
||||
qRegisterMetaType<SceneCreatedCommand>("SceneCreatedCommand");
|
||||
qRegisterMetaTypeStreamOperators<SceneCreatedCommand>("SceneCreatedCommand");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2020 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "capturenodeinstanceserverdispatcher.h"
|
||||
|
||||
#include "nodeinstanceclientinterface.h"
|
||||
#include "qt5capturepreviewnodeinstanceserver.h"
|
||||
#include "qt5informationnodeinstanceserver.h"
|
||||
#include "qt5rendernodeinstanceserver.h"
|
||||
#include "scenecreatedcommand.h"
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
void CaptureNodeInstanceServerDispatcher::createScene(const CreateSceneCommand &command)
|
||||
{
|
||||
NodeInstanceServerDispatcher::createScene(command);
|
||||
|
||||
QTimer::singleShot(100,
|
||||
this,
|
||||
&CaptureNodeInstanceServerDispatcher::collectItemChangesAndSendChangeCommands);
|
||||
}
|
||||
|
||||
void CaptureNodeInstanceServerDispatcher::collectItemChangesAndSendChangeCommands()
|
||||
{
|
||||
for (std::unique_ptr<NodeInstanceServer> &server : m_servers)
|
||||
server->collectItemChangesAndSendChangeCommands();
|
||||
|
||||
m_nodeInstanceClient->sceneCreated({});
|
||||
}
|
||||
|
||||
} // namespace QmlDesigner
|
||||
@@ -0,0 +1,50 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2020 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "nodeinstanceserverdispatcher.h"
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
class CaptureNodeInstanceServerDispatcher : public NodeInstanceServerDispatcher
|
||||
{
|
||||
public:
|
||||
CaptureNodeInstanceServerDispatcher(const QStringList &serverNames,
|
||||
NodeInstanceClientInterface *nodeInstanceClient)
|
||||
: NodeInstanceServerDispatcher{serverNames, nodeInstanceClient}
|
||||
, m_nodeInstanceClient{nodeInstanceClient}
|
||||
{}
|
||||
|
||||
void createScene(const CreateSceneCommand &command);
|
||||
|
||||
private:
|
||||
void collectItemChangesAndSendChangeCommands();
|
||||
|
||||
private:
|
||||
NodeInstanceClientInterface *m_nodeInstanceClient;
|
||||
};
|
||||
|
||||
} // namespace QmlDesigner
|
||||
@@ -6,7 +6,10 @@ versionAtLeast(QT_VERSION, 5.15.0):qtHaveModule(quick3d) {
|
||||
}
|
||||
|
||||
HEADERS += $$PWD/qt5nodeinstanceserver.h \
|
||||
$$PWD/qt5capturenodeinstanceserver.h \
|
||||
$$PWD/capturenodeinstanceserverdispatcher.h \
|
||||
$$PWD/capturescenecreatedcommand.h \
|
||||
$$PWD/nodeinstanceserverdispatcher.h \
|
||||
$$PWD/qt5capturepreviewnodeinstanceserver.h \
|
||||
$$PWD/qt5testnodeinstanceserver.h \
|
||||
$$PWD/qt5informationnodeinstanceserver.h \
|
||||
$$PWD/qt5rendernodeinstanceserver.h \
|
||||
@@ -33,7 +36,9 @@ HEADERS += $$PWD/qt5nodeinstanceserver.h \
|
||||
$$PWD/quick3dtexturenodeinstance.h
|
||||
|
||||
SOURCES += $$PWD/qt5nodeinstanceserver.cpp \
|
||||
$$PWD/qt5capturenodeinstanceserver.cpp \
|
||||
$$PWD/capturenodeinstanceserverdispatcher.cpp \
|
||||
$$PWD/nodeinstanceserverdispatcher.cpp \
|
||||
$$PWD/qt5capturepreviewnodeinstanceserver.cpp \
|
||||
$$PWD/qt5testnodeinstanceserver.cpp \
|
||||
$$PWD/qt5informationnodeinstanceserver.cpp \
|
||||
$$PWD/qt5rendernodeinstanceserver.cpp \
|
||||
|
||||
@@ -261,7 +261,7 @@ void NodeInstanceServer::setRenderTimerInterval(int timerInterval)
|
||||
|
||||
void NodeInstanceServer::setSlowRenderTimerInterval(int timerInterval)
|
||||
{
|
||||
m_slowRenderTimerInterval = timerInterval;
|
||||
m_timerModeInterval = timerInterval;
|
||||
}
|
||||
|
||||
void NodeInstanceServer::setTimerId(int timerId)
|
||||
@@ -281,29 +281,31 @@ int NodeInstanceServer::renderTimerInterval() const
|
||||
|
||||
void NodeInstanceServer::startRenderTimer()
|
||||
{
|
||||
if (m_slowRenderTimer)
|
||||
if (m_timerMode == TimerMode::SlowTimer)
|
||||
stopRenderTimer();
|
||||
|
||||
if (m_timerMode == TimerMode::DisableTimer)
|
||||
return;
|
||||
|
||||
if (m_timer == 0)
|
||||
m_timer = startTimer(m_renderTimerInterval);
|
||||
|
||||
m_slowRenderTimer = false;
|
||||
m_timerMode = TimerMode::NormalTimer;
|
||||
}
|
||||
|
||||
void NodeInstanceServer::slowDownRenderTimer()
|
||||
{
|
||||
if (!m_slowRenderTimer)
|
||||
stopRenderTimer();
|
||||
|
||||
if (m_timer != 0) {
|
||||
killTimer(m_timer);
|
||||
m_timer = 0;
|
||||
}
|
||||
|
||||
if (m_timer == 0)
|
||||
m_timer = startTimer(m_slowRenderTimerInterval);
|
||||
if (m_timerMode == TimerMode::DisableTimer)
|
||||
return;
|
||||
|
||||
m_slowRenderTimer = true;
|
||||
m_timer = startTimer(m_timerModeInterval);
|
||||
|
||||
m_timerMode = TimerMode::SlowTimer;
|
||||
}
|
||||
|
||||
void NodeInstanceServer::stopRenderTimer()
|
||||
@@ -1449,4 +1451,9 @@ void NodeInstanceServer::handleExtraRender()
|
||||
}
|
||||
}
|
||||
|
||||
void NodeInstanceServer::disableTimer()
|
||||
{
|
||||
m_timerMode = TimerMode::DisableTimer;
|
||||
}
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
||||
@@ -114,6 +114,8 @@ namespace Internal {
|
||||
class ChildrenChangeEventFilter;
|
||||
}
|
||||
|
||||
enum class TimerMode { DisableTimer, NormalTimer, SlowTimer };
|
||||
|
||||
class NodeInstanceServer : public NodeInstanceServerInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -128,7 +130,6 @@ public:
|
||||
QVariant propertyValue;
|
||||
};
|
||||
|
||||
|
||||
explicit NodeInstanceServer(NodeInstanceClientInterface *nodeInstanceClient);
|
||||
|
||||
void createInstances(const CreateInstancesCommand &command) override;
|
||||
@@ -171,7 +172,9 @@ public:
|
||||
QFileSystemWatcher *dummydataFileSystemWatcher();
|
||||
Internal::ChildrenChangeEventFilter *childrenChangeEventFilter() const;
|
||||
void addFilePropertyToFileSystemWatcher(QObject *object, const PropertyName &propertyName, const QString &path);
|
||||
void removeFilePropertyFromFileSystemWatcher(QObject *object, const PropertyName &propertyName, const QString &path);
|
||||
void removeFilePropertyFromFileSystemWatcher(QObject *object,
|
||||
const PropertyName &propertyName,
|
||||
const QString &path);
|
||||
|
||||
QUrl fileUrl() const;
|
||||
|
||||
@@ -190,7 +193,9 @@ public:
|
||||
virtual QQuickView *quickView() const = 0;
|
||||
|
||||
void sendDebugOutput(DebugOutputCommand::Type type, const QString &message, qint32 instanceId = 0);
|
||||
void sendDebugOutput(DebugOutputCommand::Type type, const QString &message, const QVector<qint32> &instanceIds);
|
||||
void sendDebugOutput(DebugOutputCommand::Type type,
|
||||
const QString &message,
|
||||
const QVector<qint32> &instanceIds);
|
||||
|
||||
void removeInstanceRelationsipForDeletedObject(QObject *object);
|
||||
|
||||
@@ -198,6 +203,10 @@ public:
|
||||
void decrementNeedsExtraRender();
|
||||
void handleExtraRender();
|
||||
|
||||
void disableTimer();
|
||||
|
||||
virtual void collectItemChangesAndSendChangeCommands() = 0;
|
||||
|
||||
public slots:
|
||||
void refreshLocalFileProperty(const QString &path);
|
||||
void refreshDummyData(const QString &path);
|
||||
@@ -221,7 +230,6 @@ protected:
|
||||
|
||||
void timerEvent(QTimerEvent *) override;
|
||||
|
||||
virtual void collectItemChangesAndSendChangeCommands() = 0;
|
||||
|
||||
ValuesChangedCommand createValuesChangedCommand(const QList<ServerNodeInstance> &instanceList) const;
|
||||
ValuesChangedCommand createValuesChangedCommand(const QVector<InstancePropertyPair> &propertyList) const;
|
||||
@@ -290,8 +298,8 @@ private:
|
||||
NodeInstanceClientInterface *m_nodeInstanceClient;
|
||||
int m_timer = 0;
|
||||
int m_renderTimerInterval = 16;
|
||||
bool m_slowRenderTimer = false;
|
||||
int m_slowRenderTimerInterval = 200;
|
||||
TimerMode m_timerMode = TimerMode::NormalTimer;
|
||||
int m_timerModeInterval = 200;
|
||||
QVector<InstancePropertyPair> m_changedPropertyList;
|
||||
QByteArray m_importCode;
|
||||
QPointer<QObject> m_dummyContextObject;
|
||||
|
||||
@@ -0,0 +1,202 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2020 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "nodeinstanceserverdispatcher.h"
|
||||
|
||||
#include "qt5capturepreviewnodeinstanceserver.h"
|
||||
#include "qt5informationnodeinstanceserver.h"
|
||||
#include "qt5rendernodeinstanceserver.h"
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
NodeInstanceServerDispatcher::NodeInstanceServerDispatcher(const QStringList &serverNames,
|
||||
NodeInstanceClientInterface *nodeInstanceClient)
|
||||
{
|
||||
for (const QString &serverName : serverNames)
|
||||
addServer(serverName, nodeInstanceClient);
|
||||
}
|
||||
|
||||
void NodeInstanceServerDispatcher::createInstances(const CreateInstancesCommand &command)
|
||||
{
|
||||
for (std::unique_ptr<NodeInstanceServer> &server : m_servers)
|
||||
server->createInstances(command);
|
||||
}
|
||||
|
||||
void NodeInstanceServerDispatcher::changeFileUrl(const ChangeFileUrlCommand &command)
|
||||
{
|
||||
for (std::unique_ptr<NodeInstanceServer> &server : m_servers)
|
||||
server->changeFileUrl(command);
|
||||
}
|
||||
|
||||
void NodeInstanceServerDispatcher::createScene(const CreateSceneCommand &command)
|
||||
{
|
||||
for (std::unique_ptr<NodeInstanceServer> &server : m_servers)
|
||||
server->createScene(command);
|
||||
}
|
||||
|
||||
void NodeInstanceServerDispatcher::clearScene(const ClearSceneCommand &command)
|
||||
{
|
||||
for (std::unique_ptr<NodeInstanceServer> &server : m_servers)
|
||||
server->clearScene(command);
|
||||
}
|
||||
|
||||
void NodeInstanceServerDispatcher::update3DViewState(const Update3dViewStateCommand &command)
|
||||
{
|
||||
for (std::unique_ptr<NodeInstanceServer> &server : m_servers)
|
||||
server->update3DViewState(command);
|
||||
}
|
||||
|
||||
void NodeInstanceServerDispatcher::removeInstances(const RemoveInstancesCommand &command)
|
||||
{
|
||||
for (std::unique_ptr<NodeInstanceServer> &server : m_servers)
|
||||
server->removeInstances(command);
|
||||
}
|
||||
|
||||
void NodeInstanceServerDispatcher::removeProperties(const RemovePropertiesCommand &command)
|
||||
{
|
||||
for (std::unique_ptr<NodeInstanceServer> &server : m_servers)
|
||||
server->removeProperties(command);
|
||||
}
|
||||
|
||||
void NodeInstanceServerDispatcher::changePropertyBindings(const ChangeBindingsCommand &command)
|
||||
{
|
||||
for (std::unique_ptr<NodeInstanceServer> &server : m_servers)
|
||||
server->changePropertyBindings(command);
|
||||
}
|
||||
|
||||
void NodeInstanceServerDispatcher::changePropertyValues(const ChangeValuesCommand &command)
|
||||
{
|
||||
for (std::unique_ptr<NodeInstanceServer> &server : m_servers)
|
||||
server->changePropertyValues(command);
|
||||
}
|
||||
|
||||
void NodeInstanceServerDispatcher::changeAuxiliaryValues(const ChangeAuxiliaryCommand &command)
|
||||
{
|
||||
for (std::unique_ptr<NodeInstanceServer> &server : m_servers)
|
||||
server->changeAuxiliaryValues(command);
|
||||
}
|
||||
|
||||
void NodeInstanceServerDispatcher::reparentInstances(const ReparentInstancesCommand &command)
|
||||
{
|
||||
for (std::unique_ptr<NodeInstanceServer> &server : m_servers)
|
||||
server->reparentInstances(command);
|
||||
}
|
||||
|
||||
void NodeInstanceServerDispatcher::changeIds(const ChangeIdsCommand &command)
|
||||
{
|
||||
for (std::unique_ptr<NodeInstanceServer> &server : m_servers)
|
||||
server->changeIds(command);
|
||||
}
|
||||
|
||||
void NodeInstanceServerDispatcher::changeState(const ChangeStateCommand &command)
|
||||
{
|
||||
for (std::unique_ptr<NodeInstanceServer> &server : m_servers)
|
||||
server->changeState(command);
|
||||
}
|
||||
|
||||
void NodeInstanceServerDispatcher::completeComponent(const CompleteComponentCommand &command)
|
||||
{
|
||||
for (std::unique_ptr<NodeInstanceServer> &server : m_servers)
|
||||
server->completeComponent(command);
|
||||
}
|
||||
|
||||
void NodeInstanceServerDispatcher::changeNodeSource(const ChangeNodeSourceCommand &command)
|
||||
{
|
||||
for (std::unique_ptr<NodeInstanceServer> &server : m_servers)
|
||||
server->changeNodeSource(command);
|
||||
}
|
||||
|
||||
void NodeInstanceServerDispatcher::token(const TokenCommand &command)
|
||||
{
|
||||
for (std::unique_ptr<NodeInstanceServer> &server : m_servers)
|
||||
server->token(command);
|
||||
}
|
||||
|
||||
void NodeInstanceServerDispatcher::removeSharedMemory(const RemoveSharedMemoryCommand &command)
|
||||
{
|
||||
for (std::unique_ptr<NodeInstanceServer> &server : m_servers)
|
||||
server->removeSharedMemory(command);
|
||||
}
|
||||
|
||||
void NodeInstanceServerDispatcher::changeSelection(const ChangeSelectionCommand &command)
|
||||
{
|
||||
for (std::unique_ptr<NodeInstanceServer> &server : m_servers)
|
||||
server->changeSelection(command);
|
||||
}
|
||||
|
||||
void NodeInstanceServerDispatcher::inputEvent(const InputEventCommand &command)
|
||||
{
|
||||
for (std::unique_ptr<NodeInstanceServer> &server : m_servers)
|
||||
server->inputEvent(command);
|
||||
}
|
||||
|
||||
void NodeInstanceServerDispatcher::view3DAction(const View3DActionCommand &command)
|
||||
{
|
||||
for (std::unique_ptr<NodeInstanceServer> &server : m_servers)
|
||||
server->view3DAction(command);
|
||||
}
|
||||
|
||||
void NodeInstanceServerDispatcher::changeLanguage(const ChangeLanguageCommand &command)
|
||||
{
|
||||
for (std::unique_ptr<NodeInstanceServer> &server : m_servers)
|
||||
server->changeLanguage(command);
|
||||
}
|
||||
|
||||
void NodeInstanceServerDispatcher::changePreviewImageSize(const ChangePreviewImageSizeCommand &command)
|
||||
{
|
||||
for (std::unique_ptr<NodeInstanceServer> &server : m_servers)
|
||||
server->changePreviewImageSize(command);
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
std::unique_ptr<NodeInstanceServer> createNodeInstanceServer(
|
||||
const QString &serverName, NodeInstanceClientInterface *nodeInstanceClient)
|
||||
{
|
||||
if (serverName == "capturemode")
|
||||
return std::make_unique<Qt5CapturePreviewNodeInstanceServer>(nodeInstanceClient);
|
||||
else if (serverName == "rendermode")
|
||||
return std::make_unique<Qt5RenderNodeInstanceServer>(nodeInstanceClient);
|
||||
else if (serverName == "editormode")
|
||||
return std::make_unique<Qt5InformationNodeInstanceServer>(nodeInstanceClient);
|
||||
else if (serverName == "previewmode")
|
||||
return std::make_unique<Qt5PreviewNodeInstanceServer>(nodeInstanceClient);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void NodeInstanceServerDispatcher::addServer(const QString &serverName,
|
||||
NodeInstanceClientInterface *nodeInstanceClient)
|
||||
{
|
||||
auto server = createNodeInstanceServer(serverName, nodeInstanceClient);
|
||||
|
||||
server->disableTimer();
|
||||
|
||||
m_servers.push_back(std::move(server));
|
||||
}
|
||||
|
||||
} // namespace QmlDesigner
|
||||
@@ -0,0 +1,71 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2020 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <nodeinstanceserver.h>
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
class NodeInstanceServerDispatcher : public NodeInstanceServerInterface
|
||||
{
|
||||
public:
|
||||
NodeInstanceServerDispatcher(const QStringList &serverNames,
|
||||
NodeInstanceClientInterface *nodeInstanceClient);
|
||||
|
||||
void createInstances(const CreateInstancesCommand &command);
|
||||
void changeFileUrl(const ChangeFileUrlCommand &command);
|
||||
void createScene(const CreateSceneCommand &command);
|
||||
void clearScene(const ClearSceneCommand &command);
|
||||
void update3DViewState(const Update3dViewStateCommand &command);
|
||||
void removeInstances(const RemoveInstancesCommand &command);
|
||||
void removeProperties(const RemovePropertiesCommand &command);
|
||||
void changePropertyBindings(const ChangeBindingsCommand &command);
|
||||
void changePropertyValues(const ChangeValuesCommand &command);
|
||||
void changeAuxiliaryValues(const ChangeAuxiliaryCommand &command);
|
||||
void reparentInstances(const ReparentInstancesCommand &command);
|
||||
void changeIds(const ChangeIdsCommand &command);
|
||||
void changeState(const ChangeStateCommand &command);
|
||||
void completeComponent(const CompleteComponentCommand &command);
|
||||
void changeNodeSource(const ChangeNodeSourceCommand &command);
|
||||
void token(const TokenCommand &command);
|
||||
void removeSharedMemory(const RemoveSharedMemoryCommand &command);
|
||||
void changeSelection(const ChangeSelectionCommand &command);
|
||||
void inputEvent(const InputEventCommand &command);
|
||||
void view3DAction(const View3DActionCommand &command);
|
||||
void changeLanguage(const ChangeLanguageCommand &command);
|
||||
void changePreviewImageSize(const ChangePreviewImageSizeCommand &command);
|
||||
|
||||
private:
|
||||
void addServer(const QString &serverName, NodeInstanceClientInterface *nodeInstanceClient);
|
||||
|
||||
protected:
|
||||
std::vector<std::unique_ptr<NodeInstanceServer>> m_servers;
|
||||
};
|
||||
|
||||
} // namespace QmlDesigner
|
||||
@@ -23,7 +23,7 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qt5capturenodeinstanceserver.h"
|
||||
#include "qt5capturepreviewnodeinstanceserver.h"
|
||||
#include "servernodeinstance.h"
|
||||
|
||||
#include <captureddatacommand.h>
|
||||
@@ -75,7 +75,7 @@ CapturedDataCommand::StateData collectStateData(ServerNodeInstance rootNodeInsta
|
||||
}
|
||||
} // namespace
|
||||
|
||||
void Qt5CaptureNodeInstanceServer::collectItemChangesAndSendChangeCommands()
|
||||
void Qt5CapturePreviewNodeInstanceServer::collectItemChangesAndSendChangeCommands()
|
||||
{
|
||||
static bool inFunction = false;
|
||||
|
||||
@@ -29,10 +29,10 @@
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
class Qt5CaptureNodeInstanceServer : public Qt5PreviewNodeInstanceServer
|
||||
class Qt5CapturePreviewNodeInstanceServer : public Qt5PreviewNodeInstanceServer
|
||||
{
|
||||
public:
|
||||
explicit Qt5CaptureNodeInstanceServer(NodeInstanceClientInterface *nodeInstanceClient)
|
||||
explicit Qt5CapturePreviewNodeInstanceServer(NodeInstanceClientInterface *nodeInstanceClient)
|
||||
: Qt5PreviewNodeInstanceServer(nodeInstanceClient)
|
||||
{}
|
||||
|
||||
@@ -27,7 +27,8 @@
|
||||
|
||||
#include <QCoreApplication>
|
||||
|
||||
#include "qt5capturenodeinstanceserver.h"
|
||||
#include "capturenodeinstanceserverdispatcher.h"
|
||||
#include "qt5capturepreviewnodeinstanceserver.h"
|
||||
#include "qt5informationnodeinstanceserver.h"
|
||||
#include "qt5previewnodeinstanceserver.h"
|
||||
#include "qt5rendernodeinstanceserver.h"
|
||||
@@ -62,6 +63,10 @@ Qt5NodeInstanceClientProxy::Qt5NodeInstanceClientProxy(QObject *parent) :
|
||||
initializeCapturedStream(QCoreApplication::arguments().at(2));
|
||||
readDataStream();
|
||||
QCoreApplication::exit();
|
||||
} else if (QCoreApplication::arguments().at(2).contains(',')) {
|
||||
const QStringList serverNames = QCoreApplication::arguments().at(2).split(',');
|
||||
setNodeInstanceServer(std::make_unique<CaptureNodeInstanceServerDispatcher>(serverNames, this));
|
||||
initializeSocket();
|
||||
} else if (QCoreApplication::arguments().at(2) == QLatin1String("previewmode")) {
|
||||
setNodeInstanceServer(std::make_unique<Qt5PreviewNodeInstanceServer>(this));
|
||||
initializeSocket();
|
||||
@@ -72,7 +77,7 @@ Qt5NodeInstanceClientProxy::Qt5NodeInstanceClientProxy(QObject *parent) :
|
||||
setNodeInstanceServer(std::make_unique<Qt5RenderNodeInstanceServer>(this));
|
||||
initializeSocket();
|
||||
} else if (QCoreApplication::arguments().at(2) == QLatin1String("capturemode")) {
|
||||
setNodeInstanceServer(std::make_unique<Qt5CaptureNodeInstanceServer>(this));
|
||||
setNodeInstanceServer(std::make_unique<Qt5CapturePreviewNodeInstanceServer>(this));
|
||||
initializeSocket();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ class ServerNodeInstance
|
||||
friend class Qt5InformationNodeInstanceServer;
|
||||
friend class Qt5NodeInstanceServer;
|
||||
friend class Qt5PreviewNodeInstanceServer;
|
||||
friend class Qt5CaptureNodeInstanceServer;
|
||||
friend class Qt5CapturePreviewNodeInstanceServer;
|
||||
friend class Qt5TestNodeInstanceServer;
|
||||
friend class QHash<qint32, ServerNodeInstance>;
|
||||
friend uint qHash(const ServerNodeInstance &instance);
|
||||
|
||||
@@ -50,11 +50,12 @@
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <memory>
|
||||
#include <QDebug>
|
||||
#include <QPair>
|
||||
#include <QPicture>
|
||||
#include <QString>
|
||||
#include <QTimer>
|
||||
#include <memory>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
@@ -770,6 +771,11 @@ void FormEditorView::exportAsImage()
|
||||
m_formEditorWidget->exportAsImage(m_scene->rootFormEditorItem()->boundingRect());
|
||||
}
|
||||
|
||||
QPicture FormEditorView::renderToPicture() const
|
||||
{
|
||||
return m_formEditorWidget->renderToPicture();
|
||||
}
|
||||
|
||||
QmlItemNode findRecursiveQmlItemNode(const QmlObjectNode &firstQmlObjectNode)
|
||||
{
|
||||
QmlObjectNode qmlObjectNode = firstQmlObjectNode;
|
||||
|
||||
@@ -128,6 +128,7 @@ public:
|
||||
void setGotoErrorCallback(std::function<void(int, int)> gotoErrorCallback);
|
||||
|
||||
void exportAsImage();
|
||||
QPicture renderToPicture() const;
|
||||
|
||||
protected:
|
||||
void reset();
|
||||
|
||||
@@ -53,6 +53,7 @@
|
||||
#include <QActionGroup>
|
||||
#include <QFileDialog>
|
||||
#include <QPainter>
|
||||
#include <QPicture>
|
||||
#include <QVBoxLayout>
|
||||
#include <QWheelEvent>
|
||||
|
||||
@@ -487,6 +488,19 @@ void FormEditorWidget::exportAsImage(const QRectF &boundingRect)
|
||||
}
|
||||
}
|
||||
|
||||
QPicture FormEditorWidget::renderToPicture() const
|
||||
{
|
||||
QPicture picture;
|
||||
QPainter painter{&picture};
|
||||
|
||||
const QTransform viewportTransform = m_graphicsView->viewportTransform();
|
||||
const QRectF boundingRect = rootItemRect();
|
||||
|
||||
m_graphicsView->render(&painter, boundingRect, viewportTransform.mapRect(boundingRect.toRect()));
|
||||
|
||||
return picture;
|
||||
}
|
||||
|
||||
FormEditorGraphicsView *FormEditorWidget::graphicsView() const
|
||||
{
|
||||
return m_graphicsView;
|
||||
@@ -504,7 +518,4 @@ DocumentWarningWidget *FormEditorWidget::errorWidget()
|
||||
return m_documentErrorWidget;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
||||
@@ -83,6 +83,7 @@ public:
|
||||
void showWarningMessageBox(const QList<DocumentMessage> &warnings);
|
||||
|
||||
void exportAsImage(const QRectF &boundingRect);
|
||||
QPicture renderToPicture() const;
|
||||
|
||||
FormEditorGraphicsView *graphicsView() const;
|
||||
|
||||
|
||||
@@ -99,6 +99,7 @@ public:
|
||||
void nodeSourceChanged(const ModelNode &modelNode, const QString &newNodeSource) override;
|
||||
void capturedData(const CapturedDataCommand &capturedData) override;
|
||||
void currentStateChanged(const ModelNode &node) override;
|
||||
void sceneCreated(const SceneCreatedCommand &command) override;
|
||||
|
||||
QList<NodeInstance> instances() const;
|
||||
NodeInstance instanceForModelNode(const ModelNode &node) const ;
|
||||
|
||||
@@ -64,6 +64,7 @@
|
||||
#include "removepropertiescommand.h"
|
||||
#include "removesharedmemorycommand.h"
|
||||
#include "reparentinstancescommand.h"
|
||||
#include "scenecreatedcommand.h"
|
||||
#include "statepreviewimagechangedcommand.h"
|
||||
#include "tokencommand.h"
|
||||
#include "update3dviewstatecommand.h"
|
||||
@@ -585,10 +586,10 @@ void NodeInstanceView::currentStateChanged(const ModelNode &node)
|
||||
nodeInstanceView()->activateBaseState();
|
||||
}
|
||||
|
||||
void NodeInstanceView::sceneCreated(const SceneCreatedCommand &) {}
|
||||
|
||||
//\}
|
||||
|
||||
|
||||
void NodeInstanceView::removeAllInstanceNodeRelationships()
|
||||
{
|
||||
m_nodeInstanceHash.clear();
|
||||
|
||||
@@ -135,6 +135,7 @@ Project {
|
||||
"commands/changevaluescommand.cpp",
|
||||
"commands/changevaluescommand.h",
|
||||
"commands/captureddatacommand.h",
|
||||
"commands/scenecreatedcommand.h",
|
||||
"commands/childrenchangedcommand.cpp",
|
||||
"commands/childrenchangedcommand.h",
|
||||
"commands/clearscenecommand.cpp",
|
||||
|
||||
@@ -53,6 +53,7 @@ extend_qtc_executable(qml2puppet
|
||||
view3dactioncommand.cpp view3dactioncommand.h
|
||||
valueschangedcommand.cpp
|
||||
captureddatacommand.h
|
||||
scenecreatedcommand.h
|
||||
)
|
||||
|
||||
extend_qtc_executable(qml2puppet
|
||||
@@ -156,7 +157,9 @@ extend_qtc_executable(qml2puppet
|
||||
quick3dtexturenodeinstance.cpp quick3dtexturenodeinstance.h
|
||||
quickitemnodeinstance.cpp quickitemnodeinstance.h
|
||||
servernodeinstance.cpp servernodeinstance.h
|
||||
qt5capturenodeinstanceserver.cpp qt5capturenodeinstanceserver.h
|
||||
qt5capturepreviewnodeinstanceserver.cpp qt5capturepreviewnodeinstanceserver.h
|
||||
nodeinstanceserverdispatcher.cpp nodeinstanceserverdispatcher.h
|
||||
capturenodeinstanceserverdispatcher.cpp capturenodeinstanceserverdispatcher.h
|
||||
)
|
||||
|
||||
extend_qtc_executable(qml2puppet
|
||||
|
||||
@@ -117,6 +117,7 @@ QtcTool {
|
||||
"commands/view3dactioncommand.cpp",
|
||||
"commands/view3dactioncommand.h",
|
||||
"commands/captureddatacommand.h",
|
||||
"commands/scenecreatedcommand.h",
|
||||
"container/addimportcontainer.cpp",
|
||||
"container/addimportcontainer.h",
|
||||
"container/idcontainer.cpp",
|
||||
@@ -219,8 +220,12 @@ QtcTool {
|
||||
"instances/qt5testnodeinstanceserver.h",
|
||||
"instances/servernodeinstance.cpp",
|
||||
"instances/servernodeinstance.h",
|
||||
"instances/qt5capturenodeinstanceserver.cpp",
|
||||
"instances/qt5capturenodeinstanceserver.h",
|
||||
"instances/qt5capturepreviewnodeinstanceserver.cpp",
|
||||
"instances/qt5capturepreviewnodeinstanceserver.h",
|
||||
"instances/nodeinstanceserverdispatcher.cpp",
|
||||
"instances/nodeinstanceserverdispatcher.h",
|
||||
"instances/capturenodeinstanceserverdispatcher.cpp",
|
||||
"instances/capturenodeinstanceserverdispatcher.h",
|
||||
"editor3d/generalhelper.cpp",
|
||||
"editor3d/mousearea3d.cpp",
|
||||
"editor3d/camerageometry.cpp",
|
||||
|
||||
Reference in New Issue
Block a user