diff options
author | Mahmoud Badri <mahmoud.badri@qt.io> | 2019-12-11 21:29:10 +0200 |
---|---|---|
committer | Mahmoud Badri <mahmoud.badri@qt.io> | 2019-12-13 12:40:43 +0000 |
commit | f97de35dd4af80fa5f3d4229ac4aa8519d9e1d38 (patch) | |
tree | ebc8244942f8014726a7166464f3cc8153d6de21 /share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.cpp | |
parent | c2bfdff70b4d539e719d7eb78a59ed4214b683f4 (diff) |
Improve edit view 3D "on top" logicqds/v1.4.0-rc1
- Proxy dialog removed
- When the QDS window is minimized/maximized, the edit view 3D follows.
The opposite is not true (edit view 3D can be minimized separately).
- Edit view 3D is always on top of QDS window. Only exception is when
a popup is shown (so that the user can handle the popup).
- External apps go normally on top of the edit view 3D.
Known (non critical) issues:
- Activating the edit view 3D doesn't raise() the QDS window, so if an
external app is on top of the edit view 3D then the view is clicked,
the external app will be in between the view and the QDS window.
- Closing the edit view 3D from the x button doesnt work (causes a
restart). This is not in the scope of this commit.
Task-number: QDS-1179
Change-Id: I1dd72590037be295b94735de96772307ba14c59c
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
Diffstat (limited to 'share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.cpp')
-rw-r--r-- | share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.cpp | 117 |
1 files changed, 34 insertions, 83 deletions
diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.cpp index dcaf9a73451..e65b1b4b2da 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 } } |