diff options
author | Eike Ziller <eike.ziller@qt.io> | 2020-09-14 10:12:14 +0200 |
---|---|---|
committer | Eike Ziller <eike.ziller@qt.io> | 2020-09-14 10:12:14 +0200 |
commit | 20f51bc642fb94f31bfe672a0cef1e69f5b0c9e7 (patch) | |
tree | 5ecaee969c9da31e95a083aa9469e395aebaab49 /share/qtcreator/qml/qmlpuppet | |
parent | 58d288b5234c18f98e39213810ac277c2571ccd7 (diff) | |
parent | 73ac5a3d877c69b4b549606f10cb7ddcbdb4cf7c (diff) |
Merge remote-tracking branch 'origin/4.13' into master
Conflicts:
src/plugins/languageclient/languageclientcompletionassist.cpp
Change-Id: If12e1c532e5623ef063681309a918e7b51117b1c
Diffstat (limited to 'share/qtcreator/qml/qmlpuppet')
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 f343cbbd47..680abb2744 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 0000000000..c854821b83 --- /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 0138fcc9d8..0c0f4fec78 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 c034435be8..11658c5dd5 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 d60e0d7ff0..e3b9121c82 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 e3a05376e2..638308af11 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 0000000000..e03dcd3d34 --- /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 0000000000..8544ea1a1c --- /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 b57e3aab8f..85de00c5ff 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 570f21a81f..6bbaebe086 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstanceserver.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstanceserver.cpp @@ -260,7 +260,7 @@ void NodeInstanceServer::setRenderTimerInterval(int timerInterval) void NodeInstanceServer::setSlowRenderTimerInterval(int timerInterval) { - m_slowRenderTimerInterval = timerInterval; + m_timerModeInterval = timerInterval; } void NodeInstanceServer::setTimerId(int timerId) @@ -280,29 +280,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() @@ -1448,4 +1450,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 140e216049..0c5810b3ec 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 0000000000..a06a156e15 --- /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 0000000000..c09c629573 --- /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 f1e2a3a475..46461581f8 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 cd0208e563..8118728973 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 1cdfc91074..defbf5614a 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 ea27429c66..975d0e8c37 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); |