diff options
Diffstat (limited to 'share')
14 files changed, 283 insertions, 144 deletions
diff --git a/share/qtcreator/qml/qmlpuppet/commands/commands.pri b/share/qtcreator/qml/qmlpuppet/commands/commands.pri index ffd1ce6dea..7985b25975 100644 --- a/share/qtcreator/qml/qmlpuppet/commands/commands.pri +++ b/share/qtcreator/qml/qmlpuppet/commands/commands.pri @@ -28,7 +28,8 @@ HEADERS += $$PWD/removesharedmemorycommand.h HEADERS += $$PWD/puppetalivecommand.h HEADERS += $$PWD/changeselectioncommand.h HEADERS += $$PWD/drop3dlibraryitemcommand.h -HEADERS += $$PWD/change3dviewcommand.h +HEADERS += $$PWD/update3dviewstatecommand.h +HEADERS += $$PWD/enable3dviewcommand.h SOURCES += $$PWD/synchronizecommand.cpp SOURCES += $$PWD/debugoutputcommand.cpp @@ -58,4 +59,5 @@ SOURCES += $$PWD/removesharedmemorycommand.cpp SOURCES += $$PWD/puppetalivecommand.cpp SOURCES += $$PWD/changeselectioncommand.cpp SOURCES += $$PWD/drop3dlibraryitemcommand.cpp -SOURCES += $$PWD/change3dviewcommand.cpp +SOURCES += $$PWD/update3dviewstatecommand.cpp +SOURCES += $$PWD/enable3dviewcommand.cpp diff --git a/share/qtcreator/qml/qmlpuppet/commands/change3dviewcommand.cpp b/share/qtcreator/qml/qmlpuppet/commands/enable3dviewcommand.cpp index ad4832d86b..7fd3b3f350 100644 --- a/share/qtcreator/qml/qmlpuppet/commands/change3dviewcommand.cpp +++ b/share/qtcreator/qml/qmlpuppet/commands/enable3dviewcommand.cpp @@ -23,41 +23,43 @@ ** ****************************************************************************/ -#include "change3dviewcommand.h" +#include "enable3dviewcommand.h" #include <QDebug> +#include <QDataStream> namespace QmlDesigner { -Change3DViewCommand::Change3DViewCommand() = default; - -Change3DViewCommand::Change3DViewCommand(const QVector<InformationContainer> &informationVector) - : m_informationVector(informationVector) +// open / close edit view 3D command +Enable3DViewCommand::Enable3DViewCommand(bool enable) + : m_enable(enable) { } -QVector<InformationContainer> Change3DViewCommand::informationVector() const +bool Enable3DViewCommand::isEnable() const { - return m_informationVector; + return m_enable; } -QDataStream &operator<<(QDataStream &out, const Change3DViewCommand &command) +QDataStream &operator<<(QDataStream &out, const Enable3DViewCommand &command) { - out << command.informationVector(); + out << qint32(command.isEnable()); return out; } -QDataStream &operator>>(QDataStream &in, Change3DViewCommand &command) +QDataStream &operator>>(QDataStream &in, Enable3DViewCommand &command) { - in >> command.m_informationVector; + qint32 enable; + in >> enable; + command.m_enable = enable; return in; } -QDebug operator <<(QDebug debug, const Change3DViewCommand &command) +QDebug operator<<(QDebug debug, const Enable3DViewCommand &command) { - return debug.nospace() << "Change3DViewCommand(auxiliaryChanges: " << command.m_informationVector << ")"; + return debug.nospace() << "Enable3DViewCommand(enable: " << command.m_enable << ")"; } } // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/commands/change3dviewcommand.h b/share/qtcreator/qml/qmlpuppet/commands/enable3dviewcommand.h index 6b1b062da0..cd9529fbb5 100644 --- a/share/qtcreator/qml/qmlpuppet/commands/change3dviewcommand.h +++ b/share/qtcreator/qml/qmlpuppet/commands/enable3dviewcommand.h @@ -26,32 +26,29 @@ #pragma once #include <QMetaType> -#include <QVector> - -#include "informationcontainer.h" namespace QmlDesigner { -class Change3DViewCommand +class Enable3DViewCommand { - friend QDataStream &operator>>(QDataStream &in, Change3DViewCommand &command); - friend QDebug operator <<(QDebug debug, const Change3DViewCommand &command); + friend QDataStream &operator>>(QDataStream &in, Enable3DViewCommand &command); + friend QDebug operator<<(QDebug debug, const Enable3DViewCommand &command); public: - Change3DViewCommand(); - explicit Change3DViewCommand(const QVector<InformationContainer> &auxiliaryChangeVector); + explicit Enable3DViewCommand(bool enable); + Enable3DViewCommand() = default; - QVector<InformationContainer> informationVector() const; + bool isEnable() const; private: - QVector<InformationContainer> m_informationVector; + bool m_enable = true; }; -QDataStream &operator<<(QDataStream &out, const Change3DViewCommand &command); -QDataStream &operator>>(QDataStream &in, Change3DViewCommand &command); +QDataStream &operator<<(QDataStream &out, const Enable3DViewCommand &command); +QDataStream &operator>>(QDataStream &in, Enable3DViewCommand &command); -QDebug operator <<(QDebug debug, const Change3DViewCommand &command); +QDebug operator<<(QDebug debug, const Enable3DViewCommand &command); } // namespace QmlDesigner -Q_DECLARE_METATYPE(QmlDesigner::Change3DViewCommand) +Q_DECLARE_METATYPE(QmlDesigner::Enable3DViewCommand) diff --git a/share/qtcreator/qml/qmlpuppet/commands/update3dviewstatecommand.cpp b/share/qtcreator/qml/qmlpuppet/commands/update3dviewstatecommand.cpp new file mode 100644 index 0000000000..b387cf09f3 --- /dev/null +++ b/share/qtcreator/qml/qmlpuppet/commands/update3dviewstatecommand.cpp @@ -0,0 +1,106 @@ +/**************************************************************************** +** +** Copyright (C) 2019 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 "update3dviewstatecommand.h" + +#include <QDebug> +#include <QDataStream> + +namespace QmlDesigner { + +Update3dViewStateCommand::Update3dViewStateCommand(Qt::WindowStates previousStates, + Qt::WindowStates currentStates) + : m_previousStates(previousStates) + , m_currentStates(currentStates) + , m_type(Update3dViewStateCommand::StateChange) +{ +} + +Update3dViewStateCommand::Update3dViewStateCommand(bool active, bool hasPopup) + : m_active(active) + , m_hasPopup(hasPopup) + , m_type(Update3dViewStateCommand::ActiveChange) +{ +} + +Qt::WindowStates Update3dViewStateCommand::previousStates() const +{ + return m_previousStates; +} + +Qt::WindowStates Update3dViewStateCommand::currentStates() const +{ + return m_currentStates; +} + +bool Update3dViewStateCommand::isActive() const +{ + return m_active; +} + +bool Update3dViewStateCommand::hasPopup() const +{ + return m_hasPopup; +} + +Update3dViewStateCommand::Type Update3dViewStateCommand::type() const +{ + return m_type; +} + +QDataStream &operator<<(QDataStream &out, const Update3dViewStateCommand &command) +{ + out << command.previousStates(); + out << command.currentStates(); + out << qint32(command.isActive()); + out << qint32(command.hasPopup()); + out << qint32(command.type()); + + return out; +} + +QDataStream &operator>>(QDataStream &in, Update3dViewStateCommand &command) +{ + in >> command.m_previousStates; + in >> command.m_currentStates; + qint32 active; + qint32 hasPopup; + qint32 type; + in >> active; + in >> hasPopup; + in >> type; + command.m_active = active; + command.m_hasPopup = hasPopup; + command.m_type = Update3dViewStateCommand::Type(type); + + return in; +} + +QDebug operator<<(QDebug debug, const Update3dViewStateCommand &command) +{ + return debug.nospace() << "Update3dViewStateCommand(type: " << command.m_type << ")"; +} + +} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/commands/update3dviewstatecommand.h b/share/qtcreator/qml/qmlpuppet/commands/update3dviewstatecommand.h new file mode 100644 index 0000000000..de8511255d --- /dev/null +++ b/share/qtcreator/qml/qmlpuppet/commands/update3dviewstatecommand.h @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2019 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 Update3dViewStateCommand +{ + friend QDataStream &operator>>(QDataStream &in, Update3dViewStateCommand &command); + friend QDebug operator<<(QDebug debug, const Update3dViewStateCommand &command); + +public: + enum Type { StateChange, ActiveChange, Empty }; + + explicit Update3dViewStateCommand(Qt::WindowStates previousStates, Qt::WindowStates currentStates); + explicit Update3dViewStateCommand(bool active, bool hasPopup); + Update3dViewStateCommand() = default; + + Qt::WindowStates previousStates() const; + Qt::WindowStates currentStates() const; + + bool isActive() const; + bool hasPopup() const; + + Type type() const; + +private: + Qt::WindowStates m_previousStates = Qt::WindowNoState; + Qt::WindowStates m_currentStates = Qt::WindowNoState; + + bool m_active = false; + bool m_hasPopup = false; + + Type m_type = Empty; +}; + +QDataStream &operator<<(QDataStream &out, const Update3dViewStateCommand &command); +QDataStream &operator>>(QDataStream &in, Update3dViewStateCommand &command); + +QDebug operator<<(QDebug debug, const Update3dViewStateCommand &command); + +} // namespace QmlDesigner + +Q_DECLARE_METATYPE(QmlDesigner::Update3dViewStateCommand) diff --git a/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.cpp b/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.cpp index 93520c2f7d..d12cfe327f 100644 --- a/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.cpp +++ b/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.cpp @@ -41,7 +41,8 @@ #include "instancecontainer.h" #include "createinstancescommand.h" #include "createscenecommand.h" -#include "change3dviewcommand.h" +#include "update3dviewstatecommand.h" +#include "enable3dviewcommand.h" #include "changevaluescommand.h" #include "changebindingscommand.h" #include "changeauxiliarycommand.h" @@ -361,9 +362,14 @@ void NodeInstanceClientProxy::createScene(const CreateSceneCommand &command) nodeInstanceServer()->createScene(command); } -void NodeInstanceClientProxy::change3DView(const Change3DViewCommand &command) +void NodeInstanceClientProxy::update3DViewState(const Update3dViewStateCommand &command) { - nodeInstanceServer()->change3DView(command); + nodeInstanceServer()->update3DViewState(command); +} + +void NodeInstanceClientProxy::enable3DView(const Enable3DViewCommand &command) +{ + nodeInstanceServer()->enable3DView(command); } void NodeInstanceClientProxy::clearScene(const ClearSceneCommand &command) @@ -453,7 +459,8 @@ void NodeInstanceClientProxy::changeSelection(const ChangeSelectionCommand &comm void NodeInstanceClientProxy::dispatchCommand(const QVariant &command) { static const int createInstancesCommandType = QMetaType::type("CreateInstancesCommand"); - static const int change3DViewCommandType = QMetaType::type("Change3DViewCommand"); + static const int update3dViewStateCommand = QMetaType::type("Update3dViewStateCommand"); + static const int enable3DViewCommandType = QMetaType::type("Enable3DViewCommand"); static const int changeFileUrlCommandType = QMetaType::type("ChangeFileUrlCommand"); static const int createSceneCommandType = QMetaType::type("CreateSceneCommand"); static const int clearSceneCommandType = QMetaType::type("ClearSceneCommand"); @@ -477,8 +484,10 @@ void NodeInstanceClientProxy::dispatchCommand(const QVariant &command) if (commandType == createInstancesCommandType) createInstances(command.value<CreateInstancesCommand>()); - else if (commandType == change3DViewCommandType) - change3DView(command.value<Change3DViewCommand>()); + else if (commandType == update3dViewStateCommand) + update3DViewState(command.value<Update3dViewStateCommand>()); + else if (commandType == enable3DViewCommandType) + enable3DView(command.value<Enable3DViewCommand>()); else if (commandType == changeFileUrlCommandType) changeFileUrl(command.value<ChangeFileUrlCommand>()); else if (commandType == createSceneCommandType) diff --git a/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.h b/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.h index e9044b63ef..5a742947d2 100644 --- a/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.h +++ b/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.h @@ -45,7 +45,8 @@ class CreateSceneCommand; class CreateInstancesCommand; class ClearSceneCommand; class ReparentInstancesCommand; -class Change3DViewCommand; +class Update3dViewStateCommand; +class Enable3DViewCommand; class ChangeFileUrlCommand; class ChangeValuesCommand; class ChangeAuxiliaryCommand; @@ -96,7 +97,8 @@ protected: void changeFileUrl(const ChangeFileUrlCommand &command); void createScene(const CreateSceneCommand &command); void clearScene(const ClearSceneCommand &command); - void change3DView(const Change3DViewCommand &command); + void update3DViewState(const Update3dViewStateCommand &command); + void enable3DView(const Enable3DViewCommand &command); void removeInstances(const RemoveInstancesCommand &command); void removeProperties(const RemovePropertiesCommand &command); void changePropertyBindings(const ChangeBindingsCommand &command); diff --git a/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceserverinterface.cpp b/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceserverinterface.cpp index 83c8c67ef7..bbd73e63ca 100644 --- a/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceserverinterface.cpp +++ b/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceserverinterface.cpp @@ -32,7 +32,8 @@ #include "instancecontainer.h" #include "createinstancescommand.h" #include "createscenecommand.h" -#include "change3dviewcommand.h" +#include "update3dviewstatecommand.h" +#include "enable3dviewcommand.h" #include "changevaluescommand.h" #include "changebindingscommand.h" #include "changeauxiliarycommand.h" @@ -91,8 +92,11 @@ void NodeInstanceServerInterface::registerCommands() qRegisterMetaType<CreateSceneCommand>("CreateSceneCommand"); qRegisterMetaTypeStreamOperators<CreateSceneCommand>("CreateSceneCommand"); - qRegisterMetaType<Change3DViewCommand>("Change3DViewCommand"); - qRegisterMetaTypeStreamOperators<Change3DViewCommand>("Change3DViewCommand"); + qRegisterMetaType<Update3dViewStateCommand>("Update3dViewStateCommand"); + qRegisterMetaTypeStreamOperators<Update3dViewStateCommand>("Update3dViewStateCommand"); + + qRegisterMetaType<Enable3DViewCommand>("Enable3DViewCommand"); + qRegisterMetaTypeStreamOperators<Enable3DViewCommand>("Enable3DViewCommand"); qRegisterMetaType<ChangeBindingsCommand>("ChangeBindingsCommand"); qRegisterMetaTypeStreamOperators<ChangeBindingsCommand>("ChangeBindingsCommand"); diff --git a/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceserverinterface.h b/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceserverinterface.h index 3dc651ef2f..e60d99b1e1 100644 --- a/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceserverinterface.h +++ b/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceserverinterface.h @@ -33,7 +33,8 @@ class PropertyAbstractContainer; class PropertyBindingContainer; class PropertyValueContainer; -class Change3DViewCommand; +class Update3dViewStateCommand; +class Enable3DViewCommand; class ChangeFileUrlCommand; class ChangeValuesCommand; class ChangeBindingsCommand; @@ -67,7 +68,8 @@ public: virtual void changeFileUrl(const ChangeFileUrlCommand &command) = 0; virtual void createScene(const CreateSceneCommand &command) = 0; virtual void clearScene(const ClearSceneCommand &command) = 0; - virtual void change3DView(const Change3DViewCommand &command) = 0; + virtual void update3DViewState(const Update3dViewStateCommand &command) = 0; + virtual void enable3DView(const Enable3DViewCommand &command) = 0; virtual void removeInstances(const RemoveInstancesCommand &command) = 0; virtual void removeProperties(const RemovePropertiesCommand &command) = 0; virtual void changePropertyBindings(const ChangeBindingsCommand &command) = 0; diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/EditView3D.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/EditView3D.qml index 9cdb74fc12..1e471d73f1 100644 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/EditView3D.qml +++ b/share/qtcreator/qml/qmlpuppet/mockfiles/EditView3D.qml @@ -34,14 +34,10 @@ Window { id: viewWindow width: 1024 height: 768 - visible: false - title: "3D" - flags: Qt.Widget | Qt.SplashScreen - - onActiveChanged: { - if (viewWindow.active) - cameraControl.forceActiveFocus() - } + visible: true + title: "3D Edit View" + // need all those flags otherwise the title bar disappears after setting WindowStaysOnTopHint flag later + flags: Qt.Window | Qt.WindowTitleHint | Qt.WindowSystemMenuHint | Qt.WindowMinMaxButtonsHint | Qt.WindowCloseButtonHint property alias scene: editView.importScene property alias showEditLight: btnEditViewLight.toggled diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstanceserver.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstanceserver.cpp index d19c0faea4..5f277bf6bb 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstanceserver.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstanceserver.cpp @@ -332,7 +332,11 @@ void NodeInstanceServer::clearScene(const ClearSceneCommand &/*command*/) m_fileUrl.clear(); } -void NodeInstanceServer::change3DView(const Change3DViewCommand &/*command*/) +void NodeInstanceServer::update3DViewState(const Update3dViewStateCommand &/*command*/) +{ +} + +void NodeInstanceServer::enable3DView(const Enable3DViewCommand &/*command*/) { } diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstanceserver.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstanceserver.h index ba74636733..861b674af9 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstanceserver.h +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstanceserver.h @@ -101,7 +101,8 @@ public: void changeIds(const ChangeIdsCommand &command) override; void createScene(const CreateSceneCommand &command) override; void clearScene(const ClearSceneCommand &command) override; - void change3DView(const Change3DViewCommand &command) override; + void update3DViewState(const Update3dViewStateCommand &command) override; + void enable3DView(const Enable3DViewCommand &command) override; void removeInstances(const RemoveInstancesCommand &command) override; void removeProperties(const RemovePropertiesCommand &command) override; void reparentInstances(const ReparentInstancesCommand &command) override; diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.cpp index dcaf9a7345..e65b1b4b2d 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.cpp @@ -40,7 +40,8 @@ #include "changefileurlcommand.h" #include "clearscenecommand.h" #include "reparentinstancescommand.h" -#include "change3dviewcommand.h" +#include "update3dviewstatecommand.h" +#include "enable3dviewcommand.h" #include "changevaluescommand.h" #include "changebindingscommand.h" #include "changeidscommand.h" @@ -59,7 +60,7 @@ #include "tokencommand.h" #include "removesharedmemorycommand.h" #include "objectnodeinstance.h" -#include <drop3dlibraryitemcommand.h> +#include "drop3dlibraryitemcommand.h" #include "dummycontextobject.h" #include "../editor3d/generalhelper.h" @@ -119,7 +120,7 @@ QObject *Qt5InformationNodeInstanceServer::createEditView3D(QQmlEngine *engine) QWindow *window = qobject_cast<QWindow *>(component.create()); if (!window) { - qWarning() << "Could not create edit view" << component.errors(); + qWarning() << "Could not create edit view 3D: " << component.errors(); return nullptr; } @@ -130,8 +131,6 @@ QObject *Qt5InformationNodeInstanceServer::createEditView3D(QQmlEngine *engine) this, SLOT(handleObjectPropertyCommit(QVariant, QVariant))); QObject::connect(window, SIGNAL(changeObjectProperty(QVariant, QVariant)), this, SLOT(handleObjectPropertyChange(QVariant, QVariant))); - QObject::connect(window, SIGNAL(activeChanged()), - this, SLOT(handleActiveChanged())); QObject::connect(&m_propertyChangeTimer, &QTimer::timeout, this, &Qt5InformationNodeInstanceServer::handleObjectPropertyChangeTimeout); QObject::connect(&m_selectionChangeTimer, &QTimer::timeout, @@ -150,7 +149,7 @@ QObject *Qt5InformationNodeInstanceServer::createEditView3D(QQmlEngine *engine) return window; } -// The selection has changed in the 3D edit view. Empty list indicates selection is cleared. +// The selection has changed in the edit view 3D. Empty list indicates selection is cleared. void Qt5InformationNodeInstanceServer::handleSelectionChanged(const QVariant &objs) { QList<ServerNodeInstance> instanceList; @@ -231,65 +230,6 @@ void Qt5InformationNodeInstanceServer::modifyVariantValue( } } -void Qt5InformationNodeInstanceServer::showEditView(const QPoint &pos, const QSize &size) -{ - m_blockViewActivate = false; - auto window = qobject_cast<QWindow *>(m_editView3D); - if (window) { - activateEditView(); - window->setPosition(pos); - window->resize(size); - } -} - -void Qt5InformationNodeInstanceServer::hideEditView() -{ - m_blockViewActivate = true; - auto window = qobject_cast<QWindow *>(m_editView3D); - if (window) - window->hide(); -} - -void Qt5InformationNodeInstanceServer::activateEditView() -{ - auto window = qobject_cast<QWindow *>(m_editView3D); - if (window) { - Qt::WindowFlags flags = window->flags(); - -#ifdef Q_OS_MACOS - window->setFlags(Qt::Popup); - window->show(); - window->setFlags(flags); -#else - window->raise(); - window->setFlags(flags | Qt::WindowStaysOnTopHint); - window->show(); - - window->requestActivate(); - window->raise(); - window->setFlags(flags); -#endif - } -} - -void Qt5InformationNodeInstanceServer::moveEditView(const QPoint &pos) -{ - auto window = qobject_cast<QWindow*>(m_editView3D); - if (window) { - activateEditView(); - window->setPosition(pos); - } -} - -void Qt5InformationNodeInstanceServer::resizeEditView(const QSize &size) -{ - auto window = qobject_cast<QWindow *>(m_editView3D); - if (window) { - activateEditView(); - window->resize(size); - } -} - void Qt5InformationNodeInstanceServer::handleObjectPropertyCommit(const QVariant &object, const QVariant &propName) { @@ -324,14 +264,6 @@ void Qt5InformationNodeInstanceServer::updateViewPortRect() viewPortProperty.write(viewPortrect); } -void Qt5InformationNodeInstanceServer::handleActiveChanged() -{ - if (m_blockViewActivate) - return; - - activateEditView(); -} - Qt5InformationNodeInstanceServer::Qt5InformationNodeInstanceServer(NodeInstanceClientInterface *nodeInstanceClient) : Qt5NodeInstanceServer(nodeInstanceClient) { @@ -759,17 +691,36 @@ void Qt5InformationNodeInstanceServer::changePropertyValues(const ChangeValuesCo startRenderTimer(); } -void Qt5InformationNodeInstanceServer::change3DView(const Change3DViewCommand &command) +// update 3D view window state when the main app window state change +void Qt5InformationNodeInstanceServer::update3DViewState(const Update3dViewStateCommand &command) +{ + auto window = qobject_cast<QWindow *>(m_editView3D); + if (window) { + if (command.type() == Update3dViewStateCommand::StateChange) { + if (command.previousStates() & Qt::WindowMinimized) // main window expanded from minimize state + window->show(); + else if (command.currentStates() & Qt::WindowMinimized) // main window minimized + window->hide(); + } else if (command.type() == Update3dViewStateCommand::ActiveChange) { + window->setFlag(Qt::WindowStaysOnTopHint, command.isActive()); + + // main window has a popup open, lower the edit view 3D so that the pop up is visible + if (command.hasPopup()) + window->lower(); + } + } +} + +void Qt5InformationNodeInstanceServer::enable3DView(const Enable3DViewCommand &command) { - for (const InformationContainer &container : command.informationVector()) { - if (container.name() == InformationName::ShowView) - showEditView(container.information().toPoint(), container.secondInformation().toSize()); - else if (container.name() == InformationName::HideView) - hideEditView(); - else if (container.name() == InformationName::MoveView) - moveEditView(container.information().toPoint()); - else if (container.name() == InformationName::ResizeView) - resizeEditView(container.secondInformation().toSize()); + // TODO: this method is not currently in use as the 3D view is currently enabled by resetting the puppet. + // It should however be implemented here. + + auto window = qobject_cast<QWindow *>(m_editView3D); + if (window && !command.isEnable()) { + // TODO: remove the 3D view + } else if (!window && command.isEnable()) { + // TODO: create the 3D view } } diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.h index 0ac073655b..079b811c05 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.h +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.h @@ -38,12 +38,14 @@ namespace QmlDesigner { class Qt5InformationNodeInstanceServer : public Qt5NodeInstanceServer { Q_OBJECT + public: explicit Qt5InformationNodeInstanceServer(NodeInstanceClientInterface *nodeInstanceClient); void reparentInstances(const ReparentInstancesCommand &command) override; void clearScene(const ClearSceneCommand &command) override; - void change3DView(const Change3DViewCommand &command) override; + void update3DViewState(const Update3dViewStateCommand &command) override; + void enable3DView(const Enable3DViewCommand &command) override; void createScene(const CreateSceneCommand &command) override; void completeComponent(const CompleteComponentCommand &command) override; void token(const TokenCommand &command) override; @@ -56,7 +58,6 @@ private slots: void handleObjectPropertyCommit(const QVariant &object, const QVariant &propName); void handleObjectPropertyChange(const QVariant &object, const QVariant &propName); void updateViewPortRect(); - void handleActiveChanged(); protected: void collectItemChangesAndSendChangeCommands() override; @@ -84,12 +85,6 @@ private: const PropertyName &propertyName, ValuesModifiedCommand::TransactionOption option); - void showEditView(const QPoint &pos, const QSize &size); - void hideEditView(); - void activateEditView(); - void moveEditView(const QPoint &pos); - void resizeEditView(const QSize &size); - QObject *m_editView3D = nullptr; QSet<ServerNodeInstance> m_parentChangedSet; QList<ServerNodeInstance> m_completedComponentList; @@ -99,7 +94,6 @@ private: QVariant m_changedNode; PropertyName m_changedProperty; ServerNodeInstance m_viewPortInstance; - bool m_blockViewActivate = false; QObject *m_rootNode = nullptr; ChangeSelectionCommand m_pendingSelectionChangeCommand; }; |