diff options
author | Tim Jenssen <tim.jenssen@qt.io> | 2020-08-13 08:34:24 +0200 |
---|---|---|
committer | Tim Jenssen <tim.jenssen@qt.io> | 2020-08-13 06:39:40 +0000 |
commit | 4fe5b923cddc9110094a883b5b7dd3051d8c8d90 (patch) | |
tree | 34e3984ab983882423bc563542a041b99b35f065 /share | |
parent | 24ca17f714ec133acc2bf0fd93c051ef730d69dc (diff) | |
parent | dc870f538dd3e11464a3ece179edf024161e14ba (diff) |
Merge remote-tracking branch 'origin/qds-1.59' into 4.13
Change-Id: Ic720f3adab305c5ef8cd10e713ccabf510eff0c0
Diffstat (limited to 'share')
16 files changed, 495 insertions, 164 deletions
diff --git a/share/qtcreator/qml/qmlpuppet/commands/captureddatacommand.h b/share/qtcreator/qml/qmlpuppet/commands/captureddatacommand.h new file mode 100644 index 0000000000..c7950e278b --- /dev/null +++ b/share/qtcreator/qml/qmlpuppet/commands/captureddatacommand.h @@ -0,0 +1,107 @@ +/**************************************************************************** +** +** 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> + +#include "imagecontainer.h" + +namespace QmlDesigner { + +class CapturedDataCommand +{ +public: + struct NodeData + { + friend QDataStream &operator<<(QDataStream &out, const NodeData &data) + { + out << data.nodeId; + out << data.contentRect; + out << data.sceneTransform; + out << data.text; + + return out; + } + + friend QDataStream &operator>>(QDataStream &in, NodeData &data) + { + in >> data.nodeId; + in >> data.contentRect; + in >> data.sceneTransform; + in >> data.text; + + return in; + } + + qint32 nodeId = -1; + QRectF contentRect; + QTransform sceneTransform; + QString text; + }; + + struct StateData + { + friend QDataStream &operator<<(QDataStream &out, const StateData &data) + { + out << data.image; + out << data.nodeData; + + return out; + } + + friend QDataStream &operator>>(QDataStream &in, StateData &data) + { + in >> data.image; + in >> data.nodeData; + + return in; + } + + ImageContainer image; + QVector<NodeData> nodeData; + }; + + friend QDataStream &operator<<(QDataStream &out, const CapturedDataCommand &command) + { + out << command.stateData; + + return out; + } + + friend QDataStream &operator>>(QDataStream &in, CapturedDataCommand &command) + { + in >> command.stateData; + + return in; + } + +public: + QVector<StateData> stateData; +}; + +} // namespace QmlDesigner + +Q_DECLARE_METATYPE(QmlDesigner::CapturedDataCommand) diff --git a/share/qtcreator/qml/qmlpuppet/commands/commands.pri b/share/qtcreator/qml/qmlpuppet/commands/commands.pri index 03a44ae750..f343cbbd47 100644 --- a/share/qtcreator/qml/qmlpuppet/commands/commands.pri +++ b/share/qtcreator/qml/qmlpuppet/commands/commands.pri @@ -1,69 +1,70 @@ -INCLUDEPATH += $$PWD/ +INCLUDEPATH += $$PWD -HEADERS += $$PWD/synchronizecommand.h -HEADERS += $$PWD/changepreviewimagesizecommand.h -HEADERS += $$PWD/changelanguagecommand.h -HEADERS += $$PWD//debugoutputcommand.h -HEADERS += $$PWD/endpuppetcommand.h -HEADERS += $$PWD/tokencommand.h -HEADERS += $$PWD/componentcompletedcommand.h -HEADERS += $$PWD/completecomponentcommand.h -HEADERS += $$PWD/statepreviewimagechangedcommand.h -HEADERS += $$PWD/childrenchangedcommand.h -HEADERS += $$PWD/changebindingscommand.h -HEADERS += $$PWD/changefileurlcommand.h -HEADERS += $$PWD/changeidscommand.h -HEADERS += $$PWD/changenodesourcecommand.h -HEADERS += $$PWD/changestatecommand.h -HEADERS += $$PWD/changevaluescommand.h -HEADERS += $$PWD/createscenecommand.h -HEADERS += $$PWD/clearscenecommand.h -HEADERS += $$PWD/createinstancescommand.h -HEADERS += $$PWD/informationchangedcommand.h -HEADERS += $$PWD/pixmapchangedcommand.h -HEADERS += $$PWD/removeinstancescommand.h -HEADERS += $$PWD/removepropertiescommand.h -HEADERS += $$PWD/reparentinstancescommand.h -HEADERS += $$PWD/valueschangedcommand.h -HEADERS += $$PWD/changeauxiliarycommand.h -HEADERS += $$PWD/removesharedmemorycommand.h -HEADERS += $$PWD/puppetalivecommand.h -HEADERS += $$PWD/changeselectioncommand.h -HEADERS += $$PWD/update3dviewstatecommand.h -HEADERS += $$PWD/puppettocreatorcommand.h -HEADERS += $$PWD/inputeventcommand.h -HEADERS += $$PWD/view3dactioncommand.h +HEADERS += $$PWD/synchronizecommand.h \ \ + $$PWD/captureddatacommand.h \ + $$PWD/changepreviewimagesizecommand.h \ + $$PWD/changelanguagecommand.h \ + $$PWD//debugoutputcommand.h \ + $$PWD/endpuppetcommand.h \ + $$PWD/tokencommand.h \ + $$PWD/componentcompletedcommand.h \ + $$PWD/completecomponentcommand.h \ + $$PWD/statepreviewimagechangedcommand.h \ + $$PWD/childrenchangedcommand.h \ + $$PWD/changebindingscommand.h \ + $$PWD/changefileurlcommand.h \ + $$PWD/changeidscommand.h \ + $$PWD/changenodesourcecommand.h \ + $$PWD/changestatecommand.h \ + $$PWD/changevaluescommand.h \ + $$PWD/createscenecommand.h \ + $$PWD/clearscenecommand.h \ + $$PWD/createinstancescommand.h \ + $$PWD/informationchangedcommand.h \ + $$PWD/pixmapchangedcommand.h \ + $$PWD/removeinstancescommand.h \ + $$PWD/removepropertiescommand.h \ + $$PWD/reparentinstancescommand.h \ + $$PWD/valueschangedcommand.h \ + $$PWD/changeauxiliarycommand.h \ + $$PWD/removesharedmemorycommand.h \ + $$PWD/puppetalivecommand.h \ + $$PWD/changeselectioncommand.h \ + $$PWD/update3dviewstatecommand.h \ + $$PWD/puppettocreatorcommand.h \ + $$PWD/inputeventcommand.h \ + $$PWD/view3dactioncommand.h -SOURCES += $$PWD/synchronizecommand.cpp -SOURCES += $$PWD/changepreviewimagesizecommand.cpp -SOURCES += $$PWD/changelanguagecommand.cpp -SOURCES += $$PWD/debugoutputcommand.cpp -SOURCES += $$PWD/endpuppetcommand.cpp -SOURCES += $$PWD/tokencommand.cpp -SOURCES += $$PWD/componentcompletedcommand.cpp -SOURCES += $$PWD/completecomponentcommand.cpp -SOURCES += $$PWD/statepreviewimagechangedcommand.cpp -SOURCES += $$PWD/childrenchangedcommand.cpp -SOURCES += $$PWD/changebindingscommand.cpp -SOURCES += $$PWD/changefileurlcommand.cpp -SOURCES += $$PWD/changeidscommand.cpp -SOURCES += $$PWD/changenodesourcecommand.cpp -SOURCES += $$PWD/changestatecommand.cpp -SOURCES += $$PWD/changevaluescommand.cpp -SOURCES += $$PWD/informationchangedcommand.cpp -SOURCES += $$PWD/removeinstancescommand.cpp -SOURCES += $$PWD/removepropertiescommand.cpp -SOURCES += $$PWD/reparentinstancescommand.cpp -SOURCES += $$PWD/valueschangedcommand.cpp -SOURCES += $$PWD/clearscenecommand.cpp -SOURCES += $$PWD/createinstancescommand.cpp -SOURCES += $$PWD/createscenecommand.cpp -SOURCES += $$PWD/pixmapchangedcommand.cpp -SOURCES += $$PWD/changeauxiliarycommand.cpp -SOURCES += $$PWD/removesharedmemorycommand.cpp -SOURCES += $$PWD/puppetalivecommand.cpp -SOURCES += $$PWD/changeselectioncommand.cpp -SOURCES += $$PWD/update3dviewstatecommand.cpp -SOURCES += $$PWD/puppettocreatorcommand.cpp -SOURCES += $$PWD/inputeventcommand.cpp -SOURCES += $$PWD/view3dactioncommand.cpp +SOURCES += $$PWD/synchronizecommand.cpp \ + $$PWD/changepreviewimagesizecommand.cpp \ + $$PWD/changelanguagecommand.cpp \ + $$PWD/debugoutputcommand.cpp \ + $$PWD/endpuppetcommand.cpp \ + $$PWD/tokencommand.cpp \ + $$PWD/componentcompletedcommand.cpp \ + $$PWD/completecomponentcommand.cpp \ + $$PWD/statepreviewimagechangedcommand.cpp \ + $$PWD/childrenchangedcommand.cpp \ + $$PWD/changebindingscommand.cpp \ + $$PWD/changefileurlcommand.cpp \ + $$PWD/changeidscommand.cpp \ + $$PWD/changenodesourcecommand.cpp \ + $$PWD/changestatecommand.cpp \ + $$PWD/changevaluescommand.cpp \ + $$PWD/informationchangedcommand.cpp \ + $$PWD/removeinstancescommand.cpp \ + $$PWD/removepropertiescommand.cpp \ + $$PWD/reparentinstancescommand.cpp \ + $$PWD/valueschangedcommand.cpp \ + $$PWD/clearscenecommand.cpp \ + $$PWD/createinstancescommand.cpp \ + $$PWD/createscenecommand.cpp \ + $$PWD/pixmapchangedcommand.cpp \ + $$PWD/changeauxiliarycommand.cpp \ + $$PWD/removesharedmemorycommand.cpp \ + $$PWD/puppetalivecommand.cpp \ + $$PWD/changeselectioncommand.cpp \ + $$PWD/update3dviewstatecommand.cpp \ + $$PWD/puppettocreatorcommand.cpp \ + $$PWD/inputeventcommand.cpp \ + $$PWD/view3dactioncommand.cpp diff --git a/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.cpp b/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.cpp index 8a338df93d..24dad65090 100644 --- a/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.cpp +++ b/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.cpp @@ -35,6 +35,7 @@ #include "nodeinstanceserverinterface.h" +#include "captureddatacommand.h" #include "changeauxiliarycommand.h" #include "changebindingscommand.h" #include "changefileurlcommand.h" @@ -84,12 +85,11 @@ constexpr void (QLocalSocket::*LocalSocketErrorFunction)(QLocalSocket::LocalSock #endif NodeInstanceClientProxy::NodeInstanceClientProxy(QObject *parent) - : QObject(parent), - m_inputIoDevice(nullptr), - m_outputIoDevice(nullptr), - m_nodeInstanceServer(nullptr), - m_writeCommandCounter(0), - m_synchronizeId(-1) + : QObject(parent) + , m_inputIoDevice(nullptr) + , m_outputIoDevice(nullptr) + , m_writeCommandCounter(0) + , m_synchronizeId(-1) { connect(&m_puppetAliveTimer, &QTimer::timeout, this, &NodeInstanceClientProxy::sendPuppetAliveCommand); m_puppetAliveTimer.setInterval(2000); @@ -174,7 +174,8 @@ bool compareCommands(const QVariant &command, const QVariant &controlCommand) else if (command.userType() == debugOutputCommandType) return command.value<DebugOutputCommand>() == controlCommand.value<DebugOutputCommand>(); else if (command.userType() == changeSelectionCommandType) - return command.value<ChangeSelectionCommand>() == controlCommand.value<ChangeSelectionCommand>(); + return command.value<ChangeSelectionCommand>() + == controlCommand.value<ChangeSelectionCommand>(); } return false; @@ -267,6 +268,11 @@ void NodeInstanceClientProxy::handlePuppetToCreatorCommand(const PuppetToCreator writeCommand(QVariant::fromValue(command)); } +void NodeInstanceClientProxy::capturedData(const CapturedDataCommand &command) +{ + writeCommand(QVariant::fromValue(command)); +} + void NodeInstanceClientProxy::flush() { } @@ -365,12 +371,13 @@ void NodeInstanceClientProxy::sendPuppetAliveCommand() NodeInstanceServerInterface *NodeInstanceClientProxy::nodeInstanceServer() const { - return m_nodeInstanceServer; + return m_nodeInstanceServer.get(); } -void NodeInstanceClientProxy::setNodeInstanceServer(NodeInstanceServerInterface *nodeInstanceServer) +void NodeInstanceClientProxy::setNodeInstanceServer( + std::unique_ptr<NodeInstanceServerInterface> nodeInstanceServer) { - m_nodeInstanceServer = nodeInstanceServer; + m_nodeInstanceServer = std::move(nodeInstanceServer); } void NodeInstanceClientProxy::createInstances(const CreateInstancesCommand &command) diff --git a/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.h b/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.h index e6f4b58df4..fd681b6990 100644 --- a/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.h +++ b/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.h @@ -69,7 +69,7 @@ class NodeInstanceClientProxy : public QObject, public NodeInstanceClientInterfa Q_OBJECT public: - NodeInstanceClientProxy(QObject *parent = nullptr); + NodeInstanceClientProxy(QObject *parent); void informationChanged(const InformationChangedCommand &command) override; void valuesChanged(const ValuesChangedCommand &command) override; @@ -83,6 +83,7 @@ public: void puppetAlive(const PuppetAliveCommand &command); void selectionChanged(const ChangeSelectionCommand &command) override; void handlePuppetToCreatorCommand(const PuppetToCreatorCommand &command) override; + void capturedData(const CapturedDataCommand &capturedData) override; void flush() override; void synchronizeWithClientProcess() override; @@ -94,7 +95,7 @@ protected: void writeCommand(const QVariant &command); void dispatchCommand(const QVariant &command); NodeInstanceServerInterface *nodeInstanceServer() const; - void setNodeInstanceServer(NodeInstanceServerInterface *nodeInstanceServer); + void setNodeInstanceServer(std::unique_ptr<NodeInstanceServerInterface> nodeInstanceServer); void createInstances(const CreateInstancesCommand &command); void changeFileUrl(const ChangeFileUrlCommand &command); @@ -130,7 +131,7 @@ private: QTimer m_puppetAliveTimer; QIODevice *m_inputIoDevice; QIODevice *m_outputIoDevice; - NodeInstanceServerInterface *m_nodeInstanceServer; + std::unique_ptr<NodeInstanceServerInterface> m_nodeInstanceServer; quint32 m_writeCommandCounter; int m_synchronizeId; }; diff --git a/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceclientinterface.h b/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceclientinterface.h index 9498cfb1f7..d60e0d7ff0 100644 --- a/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceclientinterface.h +++ b/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceclientinterface.h @@ -42,6 +42,7 @@ class DebugOutputCommand; class PuppetAliveCommand; class ChangeSelectionCommand; class PuppetToCreatorCommand; +class CapturedDataCommand; class NodeInstanceClientInterface { @@ -57,6 +58,7 @@ public: virtual void debugOutput(const DebugOutputCommand &command) = 0; virtual void selectionChanged(const ChangeSelectionCommand &command) = 0; virtual void handlePuppetToCreatorCommand(const PuppetToCreatorCommand &command) = 0; + virtual void capturedData(const CapturedDataCommand &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 62669d3158..e3a05376e2 100644 --- a/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceserverinterface.cpp +++ b/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceserverinterface.cpp @@ -27,16 +27,17 @@ #include <qmetatype.h> #include "addimportcontainer.h" +#include "captureddatacommand.h" #include "changeauxiliarycommand.h" #include "changebindingscommand.h" #include "changefileurlcommand.h" #include "changeidscommand.h" #include "changelanguagecommand.h" #include "changenodesourcecommand.h" +#include "changepreviewimagesizecommand.h" #include "changeselectioncommand.h" #include "changestatecommand.h" #include "changevaluescommand.h" -#include "changepreviewimagesizecommand.h" #include "childrenchangedcommand.h" #include "clearscenecommand.h" #include "completecomponentcommand.h" @@ -219,6 +220,9 @@ void NodeInstanceServerInterface::registerCommands() qRegisterMetaType<ChangePreviewImageSizeCommand>("ChangePreviewImageSizeCommand"); qRegisterMetaTypeStreamOperators<ChangePreviewImageSizeCommand>("ChangePreviewImageSizeCommand"); + + qRegisterMetaType<CapturedDataCommand>("CapturedDataCommand"); + qRegisterMetaTypeStreamOperators<CapturedDataCommand>("CapturedDataCommand"); } } diff --git a/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceserverinterface.h b/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceserverinterface.h index 10c2d1fdbb..39eb2618d6 100644 --- a/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceserverinterface.h +++ b/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceserverinterface.h @@ -60,11 +60,6 @@ class NodeInstanceServerInterface : public QObject { Q_OBJECT public: - enum RunModus { - NormalModus, - TestModus // No preview images and synchronized - }; - explicit NodeInstanceServerInterface(QObject *parent = nullptr); virtual void createInstances(const CreateInstancesCommand &command) = 0; diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/instances.pri b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/instances.pri index 7072196437..b57e3aab8f 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/instances.pri +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/instances.pri @@ -5,54 +5,56 @@ versionAtLeast(QT_VERSION, 5.15.0):qtHaveModule(quick3d) { DEFINES *= QUICK3D_MODULE } -HEADERS += $$PWD/qt5nodeinstanceserver.h -HEADERS += $$PWD/qt5testnodeinstanceserver.h -HEADERS += $$PWD/qt5informationnodeinstanceserver.h -HEADERS += $$PWD/qt5rendernodeinstanceserver.h -HEADERS += $$PWD/qt5previewnodeinstanceserver.h -HEADERS += $$PWD/qt5nodeinstanceclientproxy.h -HEADERS += $$PWD/quickitemnodeinstance.h -HEADERS += $$PWD/behaviornodeinstance.h -HEADERS += $$PWD/dummycontextobject.h -HEADERS += $$PWD/childrenchangeeventfilter.h -HEADERS += $$PWD/componentnodeinstance.h -HEADERS += $$PWD/dummynodeinstance.h -HEADERS += $$PWD/nodeinstanceserver.h -HEADERS += $$PWD/nodeinstancesignalspy.h -HEADERS += $$PWD/objectnodeinstance.h -HEADERS += $$PWD/qmlpropertychangesnodeinstance.h -HEADERS += $$PWD/qmlstatenodeinstance.h -HEADERS += $$PWD/qmltransitionnodeinstance.h -HEADERS += $$PWD/servernodeinstance.h -HEADERS += $$PWD/anchorchangesnodeinstance.h -HEADERS += $$PWD/positionernodeinstance.h -HEADERS += $$PWD/layoutnodeinstance.h -HEADERS += $$PWD/qt3dpresentationnodeinstance.h -HEADERS += $$PWD/quick3dnodeinstance.h -HEADERS += $$PWD/quick3dtexturenodeinstance.h +HEADERS += $$PWD/qt5nodeinstanceserver.h \ + $$PWD/qt5capturenodeinstanceserver.h \ + $$PWD/qt5testnodeinstanceserver.h \ + $$PWD/qt5informationnodeinstanceserver.h \ + $$PWD/qt5rendernodeinstanceserver.h \ + $$PWD/qt5previewnodeinstanceserver.h \ + $$PWD/qt5nodeinstanceclientproxy.h \ + $$PWD/quickitemnodeinstance.h \ + $$PWD/behaviornodeinstance.h \ + $$PWD/dummycontextobject.h \ + $$PWD/childrenchangeeventfilter.h \ + $$PWD/componentnodeinstance.h \ + $$PWD/dummynodeinstance.h \ + $$PWD/nodeinstanceserver.h \ + $$PWD/nodeinstancesignalspy.h \ + $$PWD/objectnodeinstance.h \ + $$PWD/qmlpropertychangesnodeinstance.h \ + $$PWD/qmlstatenodeinstance.h \ + $$PWD/qmltransitionnodeinstance.h \ + $$PWD/servernodeinstance.h \ + $$PWD/anchorchangesnodeinstance.h \ + $$PWD/positionernodeinstance.h \ + $$PWD/layoutnodeinstance.h \ + $$PWD/qt3dpresentationnodeinstance.h \ + $$PWD/quick3dnodeinstance.h \ + $$PWD/quick3dtexturenodeinstance.h -SOURCES += $$PWD/qt5nodeinstanceserver.cpp -SOURCES += $$PWD/qt5testnodeinstanceserver.cpp -SOURCES += $$PWD/qt5informationnodeinstanceserver.cpp -SOURCES += $$PWD/qt5rendernodeinstanceserver.cpp -SOURCES += $$PWD/qt5previewnodeinstanceserver.cpp -SOURCES += $$PWD/qt5nodeinstanceclientproxy.cpp -SOURCES += $$PWD/quickitemnodeinstance.cpp -SOURCES += $$PWD/behaviornodeinstance.cpp -SOURCES += $$PWD/dummycontextobject.cpp -SOURCES += $$PWD/childrenchangeeventfilter.cpp -SOURCES += $$PWD/componentnodeinstance.cpp -SOURCES += $$PWD/dummynodeinstance.cpp -SOURCES += $$PWD/nodeinstanceserver.cpp -SOURCES += $$PWD/nodeinstancesignalspy.cpp -SOURCES += $$PWD/objectnodeinstance.cpp -SOURCES += $$PWD/qmlpropertychangesnodeinstance.cpp -SOURCES += $$PWD/qmlstatenodeinstance.cpp -SOURCES += $$PWD/qmltransitionnodeinstance.cpp -SOURCES += $$PWD/servernodeinstance.cpp -SOURCES += $$PWD/anchorchangesnodeinstance.cpp -SOURCES += $$PWD/positionernodeinstance.cpp -SOURCES += $$PWD/layoutnodeinstance.cpp -SOURCES += $$PWD/qt3dpresentationnodeinstance.cpp -SOURCES += $$PWD/quick3dnodeinstance.cpp -SOURCES += $$PWD/quick3dtexturenodeinstance.cpp +SOURCES += $$PWD/qt5nodeinstanceserver.cpp \ + $$PWD/qt5capturenodeinstanceserver.cpp \ + $$PWD/qt5testnodeinstanceserver.cpp \ + $$PWD/qt5informationnodeinstanceserver.cpp \ + $$PWD/qt5rendernodeinstanceserver.cpp \ + $$PWD/qt5previewnodeinstanceserver.cpp \ + $$PWD/qt5nodeinstanceclientproxy.cpp \ + $$PWD/quickitemnodeinstance.cpp \ + $$PWD/behaviornodeinstance.cpp \ + $$PWD/dummycontextobject.cpp \ + $$PWD/childrenchangeeventfilter.cpp \ + $$PWD/componentnodeinstance.cpp \ + $$PWD/dummynodeinstance.cpp \ + $$PWD/nodeinstanceserver.cpp \ + $$PWD/nodeinstancesignalspy.cpp \ + $$PWD/objectnodeinstance.cpp \ + $$PWD/qmlpropertychangesnodeinstance.cpp \ + $$PWD/qmlstatenodeinstance.cpp \ + $$PWD/qmltransitionnodeinstance.cpp \ + $$PWD/servernodeinstance.cpp \ + $$PWD/anchorchangesnodeinstance.cpp \ + $$PWD/positionernodeinstance.cpp \ + $$PWD/layoutnodeinstance.cpp \ + $$PWD/qt3dpresentationnodeinstance.cpp \ + $$PWD/quick3dnodeinstance.cpp \ + $$PWD/quick3dtexturenodeinstance.cpp diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstanceserver.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstanceserver.cpp index 1b48a9ae14..ce5cf29953 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstanceserver.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstanceserver.cpp @@ -179,6 +179,8 @@ NodeInstanceServer::NodeInstanceServer(NodeInstanceClientInterface *nodeInstance m_childrenChangeEventFilter(new Internal::ChildrenChangeEventFilter(this)), m_nodeInstanceClient(nodeInstanceClient) { + m_idInstances.reserve(1000); + qmlRegisterType<DummyContextObject>("QmlDesigner", 1, 0, "DummyContextObject"); connect(m_childrenChangeEventFilter.data(), &Internal::ChildrenChangeEventFilter::childrenChanged, this, &NodeInstanceServer::emitParentChanged); @@ -226,8 +228,8 @@ ServerNodeInstance NodeInstanceServer::instanceForId(qint32 id) const if (id < 0) return ServerNodeInstance(); - Q_ASSERT(m_idInstanceHash.contains(id)); - return m_idInstanceHash.value(id); + Q_ASSERT(m_idInstances.size() > id); + return m_idInstances[id]; } bool NodeInstanceServer::hasInstanceForId(qint32 id) const @@ -235,7 +237,7 @@ bool NodeInstanceServer::hasInstanceForId(qint32 id) const if (id < 0) return false; - return m_idInstanceHash.contains(id) && m_idInstanceHash.value(id).isValid(); + return m_idInstances.size() > id && m_idInstances[id].isValid(); } ServerNodeInstance NodeInstanceServer::instanceForObject(QObject *object) const @@ -790,7 +792,7 @@ void NodeInstanceServer::removeAllInstanceRelationships() instance.makeInvalid(); } - m_idInstanceHash.clear(); + m_idInstances.clear(); m_objectInstanceHash.clear(); } @@ -1243,10 +1245,11 @@ void NodeInstanceServer::notifyPropertyChange(qint32 instanceid, const PropertyN void NodeInstanceServer::insertInstanceRelationship(const ServerNodeInstance &instance) { Q_ASSERT(instance.isValid()); - Q_ASSERT(!m_idInstanceHash.contains(instance.instanceId())); Q_ASSERT(!m_objectInstanceHash.contains(instance.internalObject())); m_objectInstanceHash.insert(instance.internalObject(), instance); - m_idInstanceHash.insert(instance.instanceId(), instance); + if (instance.instanceId() >= m_idInstances.size()) + m_idInstances.resize(instance.instanceId() + 1); + m_idInstances[instance.instanceId()] = instance; } void NodeInstanceServer::removeInstanceRelationsip(qint32 instanceId) @@ -1255,7 +1258,7 @@ void NodeInstanceServer::removeInstanceRelationsip(qint32 instanceId) ServerNodeInstance instance = instanceForId(instanceId); if (instance.isValid()) instance.setId(QString()); - m_idInstanceHash.remove(instanceId); + m_idInstances[instanceId] = ServerNodeInstance{}; m_objectInstanceHash.remove(instance.internalObject()); instance.makeInvalid(); } @@ -1383,8 +1386,8 @@ void NodeInstanceServer::removeInstanceRelationsipForDeletedObject(QObject *obje ServerNodeInstance instance = instanceForObject(object); m_objectInstanceHash.remove(object); - if (m_idInstanceHash.contains(instance.instanceId())) - m_idInstanceHash.remove(instance.instanceId()); + if (instance.instanceId() >= 0 && m_idInstances.size() > instance.instanceId()) + m_idInstances[instance.instanceId()] = ServerNodeInstance{}; } } diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstanceserver.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstanceserver.h index b0dc39a2a2..140e216049 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstanceserver.h +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstanceserver.h @@ -160,6 +160,8 @@ public: ServerNodeInstance instanceForObject(QObject *object) const; bool hasInstanceForObject(QObject *object) const; + const QVector<ServerNodeInstance> &nodeInstances() const { return m_idInstances; } + virtual QQmlEngine *engine() const = 0; QQmlContext *context() const; @@ -277,7 +279,7 @@ private: void setupOnlyWorkingImports(const QStringList &workingImportStatementList); ServerNodeInstance m_rootNodeInstance; ServerNodeInstance m_activeStateInstance; - QHash<qint32, ServerNodeInstance> m_idInstanceHash; + QVector<ServerNodeInstance> m_idInstances; QHash<QObject*, ServerNodeInstance> m_objectInstanceHash; QMultiHash<QString, ObjectPropertyPair> m_fileSystemWatcherHash; QList<QPair<QString, QPointer<QObject> > > m_dummyObjectList; diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5capturenodeinstanceserver.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5capturenodeinstanceserver.cpp new file mode 100644 index 0000000000..aea75a76c7 --- /dev/null +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5capturenodeinstanceserver.cpp @@ -0,0 +1,105 @@ +/**************************************************************************** +** +** 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 "qt5capturenodeinstanceserver.h" +#include "servernodeinstance.h" + +#include <captureddatacommand.h> +#include <createscenecommand.h> +#include <nodeinstanceclientinterface.h> + +#include <QImage> +#include <QQuickView> + +namespace QmlDesigner { + +namespace { + +QImage renderPreviewImage(ServerNodeInstance rootNodeInstance) +{ + rootNodeInstance.updateDirtyNodeRecursive(); + + QSize previewImageSize = rootNodeInstance.boundingRect().size().toSize(); + + QImage previewImage = rootNodeInstance.renderPreviewImage(previewImageSize); + + return previewImage; +} + +CapturedDataCommand::StateData collectStateData(ServerNodeInstance rootNodeInstance, + const QVector<ServerNodeInstance> &nodeInstances, + qint32 stateInstanceId) +{ + CapturedDataCommand::StateData stateData; + stateData.image = ImageContainer(stateInstanceId, + QmlDesigner::renderPreviewImage(rootNodeInstance), + stateInstanceId); + + for (const ServerNodeInstance &instance : nodeInstances) { + auto textProperty = instance.property("text"); + if (!textProperty.isNull() && instance.holdsGraphical()) { + CapturedDataCommand::NodeData nodeData; + nodeData.nodeId = instance.instanceId(); + nodeData.contentRect = instance.contentItemBoundingRect(); + nodeData.sceneTransform = instance.sceneTransform(); + nodeData.text = textProperty.toString(); + stateData.nodeData.push_back(std::move(nodeData)); + } + } + + return stateData; +} +} // namespace + +void Qt5CaptureNodeInstanceServer::collectItemChangesAndSendChangeCommands() +{ + static bool inFunction = false; + + if (!rootNodeInstance().holdsGraphical()) + return; + + if (!inFunction) { + inFunction = true; + + DesignerSupport::polishItems(quickView()); + + QVector<CapturedDataCommand::StateData> stateDatas; + stateDatas.push_back(collectStateData(rootNodeInstance(), nodeInstances(), 0)); + + for (ServerNodeInstance stateInstance : rootNodeInstance().stateInstances()) { + stateInstance.activateState(); + stateDatas.push_back( + collectStateData(rootNodeInstance(), nodeInstances(), stateInstance.instanceId())); + stateInstance.deactivateState(); + } + + nodeInstanceClient()->capturedData(CapturedDataCommand{stateDatas}); + + slowDownRenderTimer(); + inFunction = false; + } +} + +} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5capturenodeinstanceserver.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5capturenodeinstanceserver.h new file mode 100644 index 0000000000..cd0208e563 --- /dev/null +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5capturenodeinstanceserver.h @@ -0,0 +1,45 @@ +/**************************************************************************** +** +** 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 <qt5previewnodeinstanceserver.h> + +namespace QmlDesigner { + +class Qt5CaptureNodeInstanceServer : public Qt5PreviewNodeInstanceServer +{ +public: + explicit Qt5CaptureNodeInstanceServer(NodeInstanceClientInterface *nodeInstanceClient) + : Qt5PreviewNodeInstanceServer(nodeInstanceClient) + {} + +protected: + void collectItemChangesAndSendChangeCommands() override; + +private: +}; + +} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5nodeinstanceclientproxy.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5nodeinstanceclientproxy.cpp index 449e4ff188..1cdfc91074 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5nodeinstanceclientproxy.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5nodeinstanceclientproxy.cpp @@ -27,6 +27,7 @@ #include <QCoreApplication> +#include "qt5capturenodeinstanceserver.h" #include "qt5informationnodeinstanceserver.h" #include "qt5previewnodeinstanceserver.h" #include "qt5rendernodeinstanceserver.h" @@ -37,7 +38,7 @@ #if defined(Q_OS_UNIX) #include <unistd.h> #elif defined(Q_OS_WIN) -#include <windows.h> +#include <Windows.h> #endif namespace QmlDesigner { @@ -57,18 +58,21 @@ Qt5NodeInstanceClientProxy::Qt5NodeInstanceClientProxy(QObject *parent) : DesignerSupport::activateDesignerWindowManager(); if (QCoreApplication::arguments().at(1) == QLatin1String("--readcapturedstream")) { qputenv("DESIGNER_DONT_USE_SHARED_MEMORY", "1"); - setNodeInstanceServer(new Qt5TestNodeInstanceServer(this)); + setNodeInstanceServer(std::make_unique<Qt5TestNodeInstanceServer>(this)); initializeCapturedStream(QCoreApplication::arguments().at(2)); readDataStream(); QCoreApplication::exit(); } else if (QCoreApplication::arguments().at(2) == QLatin1String("previewmode")) { - setNodeInstanceServer(new Qt5PreviewNodeInstanceServer(this)); + setNodeInstanceServer(std::make_unique<Qt5PreviewNodeInstanceServer>(this)); initializeSocket(); } else if (QCoreApplication::arguments().at(2) == QLatin1String("editormode")) { - setNodeInstanceServer(new Qt5InformationNodeInstanceServer(this)); + setNodeInstanceServer(std::make_unique<Qt5InformationNodeInstanceServer>(this)); initializeSocket(); } else if (QCoreApplication::arguments().at(2) == QLatin1String("rendermode")) { - setNodeInstanceServer(new Qt5RenderNodeInstanceServer(this)); + setNodeInstanceServer(std::make_unique<Qt5RenderNodeInstanceServer>(this)); + initializeSocket(); + } else if (QCoreApplication::arguments().at(2) == QLatin1String("capturemode")) { + setNodeInstanceServer(std::make_unique<Qt5CaptureNodeInstanceServer>(this)); initializeSocket(); } } diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5previewnodeinstanceserver.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5previewnodeinstanceserver.cpp index 852ef16bad..810c8f0dcf 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5previewnodeinstanceserver.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5previewnodeinstanceserver.cpp @@ -84,7 +84,8 @@ void Qt5PreviewNodeInstanceServer::collectItemChangesAndSendChangeCommands() instance.deactivateState(); } - nodeInstanceClient()->statePreviewImagesChanged(StatePreviewImageChangedCommand(imageContainerVector)); + nodeInstanceClient()->statePreviewImagesChanged( + StatePreviewImageChangedCommand(imageContainerVector)); slowDownRenderTimer(); handleExtraRender(); @@ -105,7 +106,7 @@ QImage Qt5PreviewNodeInstanceServer::renderPreviewImage() QSize previewImageSize = boundingRect.size().toSize(); - if (!m_previewSize.isNull()) + if (m_previewSize.isValid() && !m_previewSize.isNull()) previewImageSize.scale(m_previewSize, Qt::KeepAspectRatio); QImage previewImage = rootNodeInstance().renderPreviewImage(previewImageSize); @@ -124,9 +125,6 @@ void Qt5PreviewNodeInstanceServer::changePreviewImageSize( { m_previewSize = command.size; - if (!command.size.isValid()) - m_previewSize = {160, 160}; - collectItemChangesAndSendChangeCommands(); } diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/servernodeinstance.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/servernodeinstance.h index 10943a676a..ea27429c66 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/servernodeinstance.h +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/servernodeinstance.h @@ -72,6 +72,7 @@ class ServerNodeInstance friend class Qt5InformationNodeInstanceServer; friend class Qt5NodeInstanceServer; friend class Qt5PreviewNodeInstanceServer; + friend class Qt5CaptureNodeInstanceServer; friend class Qt5TestNodeInstanceServer; friend class QHash<qint32, ServerNodeInstance>; friend uint qHash(const ServerNodeInstance &instance); @@ -171,6 +172,8 @@ public: static bool isSubclassOf(QObject *object, const QByteArray &superTypeName); void setModifiedFlag(bool b); + void updateDirtyNodeRecursive(); + bool holdsGraphical() const; private: // functions ServerNodeInstance(const QSharedPointer<Internal::ObjectNodeInstance> &abstractInstance); @@ -197,7 +200,6 @@ private: // functions void setDeleteHeldInstance(bool deleteInstance); void reparent(const ServerNodeInstance &oldParentInstance, const PropertyName &oldParentProperty, const ServerNodeInstance &newParentInstance, const PropertyName &newParentProperty); - void setId(const QString &id); static QSharedPointer<Internal::ObjectNodeInstance> createInstance(QObject *objectToBeWrapped); @@ -206,10 +208,6 @@ private: // functions void setNodeSource(const QString &source); - bool holdsGraphical() const; - - void updateDirtyNodeRecursive(); - QObject *internalObject() const; // should be not used outside of the nodeinstances!!!! private: // variables diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/StandardTextSection.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/StandardTextSection.qml index 6c5e6fde86..6132cfd261 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/StandardTextSection.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/StandardTextSection.qml @@ -26,6 +26,8 @@ import QtQuick 2.1 import HelperWidgets 2.0 import QtQuick.Layouts 1.0 +import StudioControls 1.0 as StudioControls +import StudioTheme 1.0 as StudioTheme Section { anchors.left: parent.left @@ -46,9 +48,29 @@ Section { Label { text: qsTr("Text") } - LineEdit { - backendValue: backendValues.text - Layout.fillWidth: true + + RowLayout { + LineEdit { + backendValue: backendValues.text + Layout.fillWidth: true + } + + StudioControls.AbstractButton { + id: richTextEditorButton + buttonIcon: StudioTheme.Constants.textAlignTop + onClicked: { + richTextDialogLoader.show() + } + } + + RichTextEditor{ + onRejected: { + hideWidget() + } + onAccepted: { + hideWidget() + } + } } Label { @@ -219,4 +241,39 @@ Section { Layout.fillWidth: true } } + + Loader { + id: richTextDialogLoader + + visible: false + active: visible + + function show() { + richTextDialogLoader.visible = true + } + + sourceComponent: Item { + id: richTextEditorParent + + Component.onCompleted: { + richTextEditor.showWidget() + richTextEditor.richText = backendValues.text.value + } + + RichTextEditor { + id: richTextEditor + + onRejected: { + hideWidget() + richTextDialogLoader.visible = false + } + onAccepted: { + backendValues.text.value = richTextEditor.richText + backendValues.textFormat.setEnumeration("Text", "RichText") + hideWidget() + richTextDialogLoader.visible = false + } + } + } + } } |