diff options
author | Marco Bubke <marco.bubke@qt.io> | 2020-09-03 13:48:13 +0200 |
---|---|---|
committer | Thomas Hartmann <thomas.hartmann@qt.io> | 2020-09-11 08:57:42 +0000 |
commit | 0f9010d381d9defb7597f28186b9e10d3dd3eae1 (patch) | |
tree | 437e2d0e8774736804bb3fe37f1bc2995ffd1622 /share | |
parent | a535196c418a7054c2fb1524ff1df9afb0961166 (diff) |
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>
Diffstat (limited to 'share')
17 files changed, 481 insertions, 24 deletions
diff --git a/share/qtcreator/qml/qmlpuppet/commands/commands.pri b/share/qtcreator/qml/qmlpuppet/commands/commands.pri index f343cbbd47a..680abb2744f 100644 --- a/share/qtcreator/qml/qmlpuppet/commands/commands.pri +++ b/share/qtcreator/qml/qmlpuppet/commands/commands.pri @@ -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 \ diff --git a/share/qtcreator/qml/qmlpuppet/commands/scenecreatedcommand.h b/share/qtcreator/qml/qmlpuppet/commands/scenecreatedcommand.h new file mode 100644 index 00000000000..c854821b839 --- /dev/null +++ b/share/qtcreator/qml/qmlpuppet/commands/scenecreatedcommand.h @@ -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) diff --git a/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.cpp b/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.cpp index 1f23d39d7d0..67f9efe9876 100644 --- a/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.cpp +++ b/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.cpp @@ -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() { } diff --git a/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.h b/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.h index c034435be8c..11658c5dd58 100644 --- a/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.h +++ b/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.h @@ -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; diff --git a/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceclientinterface.h b/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceclientinterface.h index d60e0d7ff0c..e3b9121c82a 100644 --- a/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceclientinterface.h +++ b/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceclientinterface.h @@ -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() {} diff --git a/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceserverinterface.cpp b/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceserverinterface.cpp index e3a05376e27..638308af110 100644 --- a/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceserverinterface.cpp +++ b/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceserverinterface.cpp @@ -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"); } } diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/capturenodeinstanceserverdispatcher.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/capturenodeinstanceserverdispatcher.cpp new file mode 100644 index 00000000000..e03dcd3d34b --- /dev/null +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/capturenodeinstanceserverdispatcher.cpp @@ -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 diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/capturenodeinstanceserverdispatcher.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/capturenodeinstanceserverdispatcher.h new file mode 100644 index 00000000000..8544ea1a1c6 --- /dev/null +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/capturenodeinstanceserverdispatcher.h @@ -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 diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/instances.pri b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/instances.pri index b57e3aab8f4..85de00c5ff2 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/instances.pri +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/instances.pri @@ -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 \ diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstanceserver.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstanceserver.cpp index 368f99a0331..c53e5378623 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstanceserver.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstanceserver.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_timer = startTimer(m_timerModeInterval); - m_slowRenderTimer = true; + m_timerMode = TimerMode::SlowTimer; } void NodeInstanceServer::stopRenderTimer() @@ -1449,4 +1451,9 @@ void NodeInstanceServer::handleExtraRender() } } +void NodeInstanceServer::disableTimer() +{ + m_timerMode = TimerMode::DisableTimer; +} + } // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstanceserver.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstanceserver.h index 140e216049c..0c5810b3ec6 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstanceserver.h +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstanceserver.h @@ -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; diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstanceserverdispatcher.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstanceserverdispatcher.cpp new file mode 100644 index 00000000000..a06a156e15e --- /dev/null +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstanceserverdispatcher.cpp @@ -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 diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstanceserverdispatcher.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstanceserverdispatcher.h new file mode 100644 index 00000000000..c09c629573a --- /dev/null +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstanceserverdispatcher.h @@ -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 diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5capturenodeinstanceserver.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5capturepreviewnodeinstanceserver.cpp index f1e2a3a4758..46461581f83 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5capturenodeinstanceserver.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5capturepreviewnodeinstanceserver.cpp @@ -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; diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5capturenodeinstanceserver.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5capturepreviewnodeinstanceserver.h index cd0208e5633..8118728973d 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5capturenodeinstanceserver.h +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5capturepreviewnodeinstanceserver.h @@ -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) {} diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5nodeinstanceclientproxy.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5nodeinstanceclientproxy.cpp index 1cdfc910742..defbf5614a3 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5nodeinstanceclientproxy.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5nodeinstanceclientproxy.cpp @@ -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(); } } diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/servernodeinstance.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/servernodeinstance.h index ea27429c66f..975d0e8c378 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/servernodeinstance.h +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/servernodeinstance.h @@ -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); |