From e5d4224fe447e1af538ca8a7fa83e621a7e62883 Mon Sep 17 00:00:00 2001 From: Mahmoud Badri Date: Mon, 16 Dec 2019 22:23:19 +0200 Subject: Prevent the Edit View 3D restart upon closing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also the 2D/3D action updates correctly according to Edit View 3D state. Task-number: QDS-1385 Change-Id: I95d0994e9c56df25a2988eb9d27994268dd1903d Reviewed-by: Henning Gründl Reviewed-by: Tim Jenssen --- .../qtcreator/qml/qmlpuppet/commands/commands.pri | 2 + .../qml/qmlpuppet/commands/view3dclosedcommand.cpp | 47 ++++++++++++++++++++++ .../qml/qmlpuppet/commands/view3dclosedcommand.h | 47 ++++++++++++++++++++++ .../instances/nodeinstanceclientproxy.cpp | 6 +++ .../qmlpuppet/instances/nodeinstanceclientproxy.h | 2 + .../interfaces/nodeinstanceclientinterface.h | 2 + .../interfaces/nodeinstanceserverinterface.cpp | 6 ++- .../instances/qt5informationnodeinstanceserver.cpp | 5 +++ src/plugins/qmldesigner/CMakeLists.txt | 1 + .../components/formeditor/formeditorview.cpp | 3 ++ .../designercore/include/nodeinstanceview.h | 1 + .../instances/nodeinstanceserverproxy.cpp | 4 ++ .../designercore/instances/nodeinstanceview.cpp | 7 ++++ src/plugins/qmldesigner/qmldesignerplugin.qbs | 2 + src/tools/qml2puppet/CMakeLists.txt | 1 + src/tools/qml2puppet/qml2puppet.qbs | 2 + 16 files changed, 137 insertions(+), 1 deletion(-) create mode 100644 share/qtcreator/qml/qmlpuppet/commands/view3dclosedcommand.cpp create mode 100644 share/qtcreator/qml/qmlpuppet/commands/view3dclosedcommand.h diff --git a/share/qtcreator/qml/qmlpuppet/commands/commands.pri b/share/qtcreator/qml/qmlpuppet/commands/commands.pri index 7985b25975..47ec4473ea 100644 --- a/share/qtcreator/qml/qmlpuppet/commands/commands.pri +++ b/share/qtcreator/qml/qmlpuppet/commands/commands.pri @@ -30,6 +30,7 @@ HEADERS += $$PWD/changeselectioncommand.h HEADERS += $$PWD/drop3dlibraryitemcommand.h HEADERS += $$PWD/update3dviewstatecommand.h HEADERS += $$PWD/enable3dviewcommand.h +HEADERS += $$PWD/view3dclosedcommand.h SOURCES += $$PWD/synchronizecommand.cpp SOURCES += $$PWD/debugoutputcommand.cpp @@ -61,3 +62,4 @@ SOURCES += $$PWD/changeselectioncommand.cpp SOURCES += $$PWD/drop3dlibraryitemcommand.cpp SOURCES += $$PWD/update3dviewstatecommand.cpp SOURCES += $$PWD/enable3dviewcommand.cpp +SOURCES += $$PWD/view3dclosedcommand.cpp diff --git a/share/qtcreator/qml/qmlpuppet/commands/view3dclosedcommand.cpp b/share/qtcreator/qml/qmlpuppet/commands/view3dclosedcommand.cpp new file mode 100644 index 0000000000..c7de7a99de --- /dev/null +++ b/share/qtcreator/qml/qmlpuppet/commands/view3dclosedcommand.cpp @@ -0,0 +1,47 @@ +/**************************************************************************** +** +** Copyright (C) 2016 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 "view3dclosedcommand.h" + +namespace QmlDesigner { + +View3DClosedCommand::View3DClosedCommand() = default; + +QDataStream &operator<<(QDataStream &out, const View3DClosedCommand &/*command*/) +{ + return out; +} + +QDataStream &operator>>(QDataStream &in, View3DClosedCommand &/*command*/) +{ + return in; +} + +QDebug operator<<(QDebug debug, const View3DClosedCommand &/*command*/) +{ + return debug.nospace() << "View3DClosedCommand()"; +} + +} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/commands/view3dclosedcommand.h b/share/qtcreator/qml/qmlpuppet/commands/view3dclosedcommand.h new file mode 100644 index 0000000000..132bb3c37b --- /dev/null +++ b/share/qtcreator/qml/qmlpuppet/commands/view3dclosedcommand.h @@ -0,0 +1,47 @@ +/**************************************************************************** +** +** Copyright (C) 2016 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 +#include +#include + +namespace QmlDesigner { + +class View3DClosedCommand +{ +public: + View3DClosedCommand(); +}; + +QDataStream &operator<<(QDataStream &out, const View3DClosedCommand &command); +QDataStream &operator>>(QDataStream &in, View3DClosedCommand &command); + +QDebug operator<<(QDebug debug, const View3DClosedCommand &command); + +} // namespace QmlDesigner + +Q_DECLARE_METATYPE(QmlDesigner::View3DClosedCommand) diff --git a/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.cpp b/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.cpp index d12cfe327f..01d9cd1842 100644 --- a/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.cpp +++ b/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.cpp @@ -71,6 +71,7 @@ #include "puppetalivecommand.h" #include "changeselectioncommand.h" #include "drop3dlibraryitemcommand.h" +#include "view3dclosedcommand.h" namespace QmlDesigner { @@ -261,6 +262,11 @@ void NodeInstanceClientProxy::library3DItemDropped(const Drop3DLibraryItemComman writeCommand(QVariant::fromValue(command)); } +void NodeInstanceClientProxy::view3DClosed(const View3DClosedCommand &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 5a742947d2..7c9724e1ff 100644 --- a/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.h +++ b/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.h @@ -60,6 +60,7 @@ class ChangeNodeSourceCommand; class EndPuppetCommand; class ChangeSelectionCommand; class Drop3DLibraryItemCommand; +class View3DClosedCommand; class NodeInstanceClientProxy : public QObject, public NodeInstanceClientInterface { @@ -80,6 +81,7 @@ public: void puppetAlive(const PuppetAliveCommand &command); void selectionChanged(const ChangeSelectionCommand &command) override; void library3DItemDropped(const Drop3DLibraryItemCommand &command) override; + void view3DClosed(const View3DClosedCommand &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 10688cdd89..b188d7edfd 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 Drop3DLibraryItemCommand; +class View3DClosedCommand; class NodeInstanceClientInterface { @@ -57,6 +58,7 @@ public: virtual void debugOutput(const DebugOutputCommand &command) = 0; virtual void selectionChanged(const ChangeSelectionCommand &command) = 0; virtual void library3DItemDropped(const Drop3DLibraryItemCommand &command) = 0; + virtual void view3DClosed(const View3DClosedCommand &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 bbd73e63ca..f606bfacf2 100644 --- a/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceserverinterface.cpp +++ b/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceserverinterface.cpp @@ -63,12 +63,13 @@ #include "endpuppetcommand.h" #include "debugoutputcommand.h" #include "puppetalivecommand.h" +#include "view3dclosedcommand.h" #include namespace QmlDesigner { -static bool isRegistered=false; +static bool isRegistered = false; NodeInstanceServerInterface::NodeInstanceServerInterface(QObject *parent) : QObject(parent) @@ -205,6 +206,9 @@ void NodeInstanceServerInterface::registerCommands() qRegisterMetaType("PuppetAliveCommand"); qRegisterMetaTypeStreamOperators("PuppetAliveCommand"); + + qRegisterMetaType("View3DClosedCommand"); + qRegisterMetaTypeStreamOperators("View3DClosedCommand"); } } diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.cpp index e65b1b4b2d..db38985d90 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.cpp @@ -61,6 +61,7 @@ #include "removesharedmemorycommand.h" #include "objectnodeinstance.h" #include "drop3dlibraryitemcommand.h" +#include "view3dclosedcommand.h" #include "dummycontextobject.h" #include "../editor3d/generalhelper.h" @@ -97,6 +98,10 @@ bool Qt5InformationNodeInstanceServer::eventFilter(QObject *, QEvent *event) } break; + case QEvent::Close: { + nodeInstanceClient()->view3DClosed(View3DClosedCommand()); + } break; + default: break; } diff --git a/src/plugins/qmldesigner/CMakeLists.txt b/src/plugins/qmldesigner/CMakeLists.txt index 6d3bca379c..0a758c135f 100644 --- a/src/plugins/qmldesigner/CMakeLists.txt +++ b/src/plugins/qmldesigner/CMakeLists.txt @@ -142,6 +142,7 @@ extend_qtc_plugin(QmlDesigner drop3dlibraryitemcommand.cpp drop3dlibraryitemcommand.h update3dviewstatecommand.cpp update3dviewstatecommand.h enable3dviewcommand.cpp enable3dviewcommand.h + view3dclosedcommand.cpp view3dclosedcommand.h ) extend_qtc_plugin(QmlDesigner diff --git a/src/plugins/qmldesigner/components/formeditor/formeditorview.cpp b/src/plugins/qmldesigner/components/formeditor/formeditorview.cpp index ee7b3f18a9..baec381316 100644 --- a/src/plugins/qmldesigner/components/formeditor/formeditorview.cpp +++ b/src/plugins/qmldesigner/components/formeditor/formeditorview.cpp @@ -462,6 +462,9 @@ void FormEditorView::auxiliaryDataChanged(const ModelNode &node, const PropertyN if (isInvisible) newNode.deselectNode(); } + } else if (name == "3d-view") { + bool is3DEnabled = data.isNull() || data.toBool(); + formEditorWidget()->option3DAction()->set3DEnabled(is3DEnabled); } } diff --git a/src/plugins/qmldesigner/designercore/include/nodeinstanceview.h b/src/plugins/qmldesigner/designercore/include/nodeinstanceview.h index f6b705acc3..c55dae2d87 100644 --- a/src/plugins/qmldesigner/designercore/include/nodeinstanceview.h +++ b/src/plugins/qmldesigner/designercore/include/nodeinstanceview.h @@ -138,6 +138,7 @@ public: void selectionChanged(const ChangeSelectionCommand &command) override; void library3DItemDropped(const Drop3DLibraryItemCommand &command) override; + void view3DClosed(const View3DClosedCommand &command) override; void selectedNodesChanged(const QList &selectedNodeList, const QList &lastSelectedNodeList) override; diff --git a/src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.cpp b/src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.cpp index d979e3dd32..07e3216f37 100644 --- a/src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.cpp +++ b/src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.cpp @@ -45,6 +45,7 @@ #include #include #include +#include #include #include @@ -285,6 +286,7 @@ void NodeInstanceServerProxy::dispatchCommand(const QVariant &command, PuppetStr static const int puppetAliveCommandType = QMetaType::type("PuppetAliveCommand"); static const int changeSelectionCommandType = QMetaType::type("ChangeSelectionCommand"); static const int drop3DLibraryItemCommandType = QMetaType::type("Drop3DLibraryItemCommand"); + static const int view3DClosedCommand = QMetaType::type("View3DClosedCommand"); if (m_destructing) return; @@ -312,6 +314,8 @@ void NodeInstanceServerProxy::dispatchCommand(const QVariant &command, PuppetStr nodeInstanceClient()->selectionChanged(command.value()); } else if (command.userType() == drop3DLibraryItemCommandType) { nodeInstanceClient()->library3DItemDropped(command.value()); + } else if (command.userType() == view3DClosedCommand) { + nodeInstanceClient()->view3DClosed(command.value()); } else if (command.userType() == puppetAliveCommandType) { puppetAlive(puppetStreamType); } else if (command.userType() == synchronizeCommandType) { diff --git a/src/plugins/qmldesigner/designercore/instances/nodeinstanceview.cpp b/src/plugins/qmldesigner/designercore/instances/nodeinstanceview.cpp index 9528328754..a550a2e4b2 100644 --- a/src/plugins/qmldesigner/designercore/instances/nodeinstanceview.cpp +++ b/src/plugins/qmldesigner/designercore/instances/nodeinstanceview.cpp @@ -1454,6 +1454,13 @@ void NodeInstanceView::library3DItemDropped(const Drop3DLibraryItemCommand &comm QmlVisualNode::createQmlVisualNode(this, itemLibraryEntry, {}); } +void NodeInstanceView::view3DClosed(const View3DClosedCommand &command) +{ + Q_UNUSED(command) + + rootModelNode().setAuxiliaryData("3d-view", false); +} + void NodeInstanceView::selectedNodesChanged(const QList &selectedNodeList, const QList & /*lastSelectedNodeList*/) { diff --git a/src/plugins/qmldesigner/qmldesignerplugin.qbs b/src/plugins/qmldesigner/qmldesignerplugin.qbs index 1ef8407d8e..67783c7c15 100644 --- a/src/plugins/qmldesigner/qmldesignerplugin.qbs +++ b/src/plugins/qmldesigner/qmldesignerplugin.qbs @@ -175,6 +175,8 @@ Project { "commands/update3dviewstatecommand.h", "commands/enable3dviewcommand.cpp", "commands/enable3dviewcommand.h", + "commands/view3dclosedcommand.cpp", + "commands/view3dclosedcommand.h", "container/addimportcontainer.cpp", "container/addimportcontainer.h", "container/idcontainer.cpp", diff --git a/src/tools/qml2puppet/CMakeLists.txt b/src/tools/qml2puppet/CMakeLists.txt index eb9abeda16..3912645283 100644 --- a/src/tools/qml2puppet/CMakeLists.txt +++ b/src/tools/qml2puppet/CMakeLists.txt @@ -48,6 +48,7 @@ extend_qtc_executable(qml2puppet drop3dlibraryitemcommand.cpp drop3dlibraryitemcommand.h update3dviewstatecommand.cpp update3dviewstatecommand.h enable3dviewcommand.cpp enable3dviewcommand.h + view3dclosedcommand.cpp view3dclosedcommand.h valueschangedcommand.cpp ) diff --git a/src/tools/qml2puppet/qml2puppet.qbs b/src/tools/qml2puppet/qml2puppet.qbs index fb73413038..645250c2d4 100644 --- a/src/tools/qml2puppet/qml2puppet.qbs +++ b/src/tools/qml2puppet/qml2puppet.qbs @@ -101,6 +101,8 @@ QtcTool { "commands/update3dviewstatecommand.h", "commands/enable3dviewcommand.cpp", "commands/enable3dviewcommand.h", + "commands/view3dclosedcommand.cpp", + "commands/view3dclosedcommand.h", "container/addimportcontainer.cpp", "container/addimportcontainer.h", "container/idcontainer.cpp", -- cgit v1.2.1