forked from qt-creator/qt-creator
QmlDesigner: Use proxy dialog for 3D edit view
To integrate the 3D edit view in the qml2puppet process, we create a dialog in the Qt Creator process. This dialog acts as a proxy that manages the actual window. For this I introduced a new command that allows showing, hiding, resizing and moving of the 3D edit view. The 3D edit view always follows the proxy dialog. During moving and resizing we hide the window to avoid artefacts. At this point in time the proxy widget is a dialog, but it could also be a dockwidget or any other QWidget in the future. Task-number: QDS-1179 Change-Id: I67ccab49eb2de9ba23098a67b2f9577f6c7fd3ac Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 "change3dviewcommand.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
Change3DViewCommand::Change3DViewCommand() = default;
|
||||
|
||||
Change3DViewCommand::Change3DViewCommand(const QVector<InformationContainer> &informationVector)
|
||||
: m_informationVector(informationVector)
|
||||
{
|
||||
}
|
||||
|
||||
QVector<InformationContainer> Change3DViewCommand::informationVector() const
|
||||
{
|
||||
return m_informationVector;
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const Change3DViewCommand &command)
|
||||
{
|
||||
out << command.informationVector();
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &in, Change3DViewCommand &command)
|
||||
{
|
||||
in >> command.m_informationVector;
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
QDebug operator <<(QDebug debug, const Change3DViewCommand &command)
|
||||
{
|
||||
return debug.nospace() << "Change3DViewCommand(auxiliaryChanges: " << command.m_informationVector << ")";
|
||||
}
|
||||
|
||||
} // namespace QmlDesigner
|
||||
@@ -0,0 +1,57 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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>
|
||||
#include <QVector>
|
||||
|
||||
#include "informationcontainer.h"
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
class Change3DViewCommand
|
||||
{
|
||||
friend QDataStream &operator>>(QDataStream &in, Change3DViewCommand &command);
|
||||
friend QDebug operator <<(QDebug debug, const Change3DViewCommand &command);
|
||||
|
||||
public:
|
||||
Change3DViewCommand();
|
||||
explicit Change3DViewCommand(const QVector<InformationContainer> &auxiliaryChangeVector);
|
||||
|
||||
QVector<InformationContainer> informationVector() const;
|
||||
|
||||
private:
|
||||
QVector<InformationContainer> m_informationVector;
|
||||
};
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const Change3DViewCommand &command);
|
||||
QDataStream &operator>>(QDataStream &in, Change3DViewCommand &command);
|
||||
|
||||
QDebug operator <<(QDebug debug, const Change3DViewCommand &command);
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
||||
Q_DECLARE_METATYPE(QmlDesigner::Change3DViewCommand)
|
||||
@@ -28,6 +28,7 @@ HEADERS += $$PWD/removesharedmemorycommand.h
|
||||
HEADERS += $$PWD/puppetalivecommand.h
|
||||
HEADERS += $$PWD/changeselectioncommand.h
|
||||
HEADERS += $$PWD/drop3dlibraryitemcommand.h
|
||||
HEADERS += $$PWD/change3dviewcommand.h
|
||||
|
||||
SOURCES += $$PWD/synchronizecommand.cpp
|
||||
SOURCES += $$PWD/debugoutputcommand.cpp
|
||||
@@ -57,3 +58,4 @@ SOURCES += $$PWD/removesharedmemorycommand.cpp
|
||||
SOURCES += $$PWD/puppetalivecommand.cpp
|
||||
SOURCES += $$PWD/changeselectioncommand.cpp
|
||||
SOURCES += $$PWD/drop3dlibraryitemcommand.cpp
|
||||
SOURCES += $$PWD/change3dviewcommand.cpp
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
#include "instancecontainer.h"
|
||||
#include "createinstancescommand.h"
|
||||
#include "createscenecommand.h"
|
||||
#include "change3dviewcommand.h"
|
||||
#include "changevaluescommand.h"
|
||||
#include "changebindingscommand.h"
|
||||
#include "changeauxiliarycommand.h"
|
||||
@@ -360,6 +361,11 @@ void NodeInstanceClientProxy::createScene(const CreateSceneCommand &command)
|
||||
nodeInstanceServer()->createScene(command);
|
||||
}
|
||||
|
||||
void NodeInstanceClientProxy::change3DView(const Change3DViewCommand &command)
|
||||
{
|
||||
nodeInstanceServer()->change3DView(command);
|
||||
}
|
||||
|
||||
void NodeInstanceClientProxy::clearScene(const ClearSceneCommand &command)
|
||||
{
|
||||
nodeInstanceServer()->clearScene(command);
|
||||
@@ -447,6 +453,7 @@ 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 changeFileUrlCommandType = QMetaType::type("ChangeFileUrlCommand");
|
||||
static const int createSceneCommandType = QMetaType::type("CreateSceneCommand");
|
||||
static const int clearSceneCommandType = QMetaType::type("ClearSceneCommand");
|
||||
@@ -470,6 +477,8 @@ void NodeInstanceClientProxy::dispatchCommand(const QVariant &command)
|
||||
|
||||
if (commandType == createInstancesCommandType)
|
||||
createInstances(command.value<CreateInstancesCommand>());
|
||||
else if (commandType == change3DViewCommandType)
|
||||
change3DView(command.value<Change3DViewCommand>());
|
||||
else if (commandType == changeFileUrlCommandType)
|
||||
changeFileUrl(command.value<ChangeFileUrlCommand>());
|
||||
else if (commandType == createSceneCommandType)
|
||||
|
||||
@@ -45,6 +45,7 @@ class CreateSceneCommand;
|
||||
class CreateInstancesCommand;
|
||||
class ClearSceneCommand;
|
||||
class ReparentInstancesCommand;
|
||||
class Change3DViewCommand;
|
||||
class ChangeFileUrlCommand;
|
||||
class ChangeValuesCommand;
|
||||
class ChangeAuxiliaryCommand;
|
||||
@@ -95,6 +96,7 @@ protected:
|
||||
void changeFileUrl(const ChangeFileUrlCommand &command);
|
||||
void createScene(const CreateSceneCommand &command);
|
||||
void clearScene(const ClearSceneCommand &command);
|
||||
void change3DView(const Change3DViewCommand &command);
|
||||
void removeInstances(const RemoveInstancesCommand &command);
|
||||
void removeProperties(const RemovePropertiesCommand &command);
|
||||
void changePropertyBindings(const ChangeBindingsCommand &command);
|
||||
|
||||
@@ -52,7 +52,11 @@ enum InformationName
|
||||
HasBindingForProperty,
|
||||
ContentTransform,
|
||||
ContentItemTransform,
|
||||
ContentItemBoundingRect
|
||||
ContentItemBoundingRect,
|
||||
MoveView,
|
||||
ShowView,
|
||||
ResizeView,
|
||||
HideView
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include "instancecontainer.h"
|
||||
#include "createinstancescommand.h"
|
||||
#include "createscenecommand.h"
|
||||
#include "change3dviewcommand.h"
|
||||
#include "changevaluescommand.h"
|
||||
#include "changebindingscommand.h"
|
||||
#include "changeauxiliarycommand.h"
|
||||
@@ -90,6 +91,9 @@ void NodeInstanceServerInterface::registerCommands()
|
||||
qRegisterMetaType<CreateSceneCommand>("CreateSceneCommand");
|
||||
qRegisterMetaTypeStreamOperators<CreateSceneCommand>("CreateSceneCommand");
|
||||
|
||||
qRegisterMetaType<Change3DViewCommand>("Change3DViewCommand");
|
||||
qRegisterMetaTypeStreamOperators<Change3DViewCommand>("Change3DViewCommand");
|
||||
|
||||
qRegisterMetaType<ChangeBindingsCommand>("ChangeBindingsCommand");
|
||||
qRegisterMetaTypeStreamOperators<ChangeBindingsCommand>("ChangeBindingsCommand");
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ class PropertyAbstractContainer;
|
||||
class PropertyBindingContainer;
|
||||
class PropertyValueContainer;
|
||||
|
||||
class Change3DViewCommand;
|
||||
class ChangeFileUrlCommand;
|
||||
class ChangeValuesCommand;
|
||||
class ChangeBindingsCommand;
|
||||
@@ -66,6 +67,7 @@ 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 removeInstances(const RemoveInstancesCommand &command) = 0;
|
||||
virtual void removeProperties(const RemovePropertiesCommand &command) = 0;
|
||||
virtual void changePropertyBindings(const ChangeBindingsCommand &command) = 0;
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
import QtQuick 2.12
|
||||
import QtQuick.Window 2.0
|
||||
import QtQuick.Window 2.12
|
||||
import QtQuick3D 1.0
|
||||
import QtQuick.Controls 2.0
|
||||
import QtGraphicalEffects 1.0
|
||||
@@ -33,9 +33,14 @@ Window {
|
||||
id: viewWindow
|
||||
width: 1024
|
||||
height: 768
|
||||
visible: true
|
||||
visible: false
|
||||
title: "3D"
|
||||
flags: Qt.WindowStaysOnTopHint | Qt.Window | Qt.WindowTitleHint | Qt.WindowCloseButtonHint
|
||||
flags: Qt.Widget | Qt.SplashScreen
|
||||
|
||||
onActiveChanged: {
|
||||
if (viewWindow.active)
|
||||
cameraControl.forceActiveFocus()
|
||||
}
|
||||
|
||||
property alias scene: editView.importScene
|
||||
property alias showEditLight: btnEditViewLight.toggled
|
||||
|
||||
@@ -332,6 +332,10 @@ void NodeInstanceServer::clearScene(const ClearSceneCommand &/*command*/)
|
||||
m_fileUrl.clear();
|
||||
}
|
||||
|
||||
void NodeInstanceServer::change3DView(const Change3DViewCommand &/*command*/)
|
||||
{
|
||||
}
|
||||
|
||||
void NodeInstanceServer::changeSelection(const ChangeSelectionCommand & /*command*/)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -101,6 +101,7 @@ 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 removeInstances(const RemoveInstancesCommand &command) override;
|
||||
void removeProperties(const RemovePropertiesCommand &command) override;
|
||||
void reparentInstances(const ReparentInstancesCommand &command) override;
|
||||
|
||||
+84
@@ -40,6 +40,7 @@
|
||||
#include "changefileurlcommand.h"
|
||||
#include "clearscenecommand.h"
|
||||
#include "reparentinstancescommand.h"
|
||||
#include "change3dviewcommand.h"
|
||||
#include "changevaluescommand.h"
|
||||
#include "changebindingscommand.h"
|
||||
#include "changeidscommand.h"
|
||||
@@ -129,6 +130,8 @@ 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);
|
||||
|
||||
@@ -219,6 +222,65 @@ 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)
|
||||
{
|
||||
@@ -253,6 +315,14 @@ void Qt5InformationNodeInstanceServer::updateViewPortRect()
|
||||
viewPortProperty.write(viewPortrect);
|
||||
}
|
||||
|
||||
void Qt5InformationNodeInstanceServer::handleActiveChanged()
|
||||
{
|
||||
if (m_blockViewActivate)
|
||||
return;
|
||||
|
||||
activateEditView();
|
||||
}
|
||||
|
||||
Qt5InformationNodeInstanceServer::Qt5InformationNodeInstanceServer(NodeInstanceClientInterface *nodeInstanceClient) :
|
||||
Qt5NodeInstanceServer(nodeInstanceClient)
|
||||
{
|
||||
@@ -641,4 +711,18 @@ void Qt5InformationNodeInstanceServer::changePropertyValues(const ChangeValuesCo
|
||||
startRenderTimer();
|
||||
}
|
||||
|
||||
void Qt5InformationNodeInstanceServer::change3DView(const Change3DViewCommand &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());
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
||||
@@ -42,6 +42,7 @@ public:
|
||||
|
||||
void reparentInstances(const ReparentInstancesCommand &command) override;
|
||||
void clearScene(const ClearSceneCommand &command) override;
|
||||
void change3DView(const Change3DViewCommand &command) override;
|
||||
void createScene(const CreateSceneCommand &command) override;
|
||||
void completeComponent(const CompleteComponentCommand &command) override;
|
||||
void token(const TokenCommand &command) override;
|
||||
@@ -54,6 +55,7 @@ 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;
|
||||
@@ -80,6 +82,12 @@ 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;
|
||||
@@ -88,6 +96,8 @@ private:
|
||||
QVariant m_changedNode;
|
||||
PropertyName m_changedProperty;
|
||||
ServerNodeInstance m_viewPortInstance;
|
||||
|
||||
bool m_blockViewActivate = false;
|
||||
};
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
||||
@@ -140,6 +140,7 @@ extend_qtc_plugin(QmlDesigner
|
||||
valueschangedcommand.cpp valueschangedcommand.h
|
||||
changeselectioncommand.cpp changeselectioncommand.h
|
||||
drop3dlibraryitemcommand.cpp drop3dlibraryitemcommand.h
|
||||
change3dviewcommand.cpp change3dviewcommand.h
|
||||
)
|
||||
|
||||
extend_qtc_plugin(QmlDesigner
|
||||
@@ -234,6 +235,7 @@ extend_qtc_plugin(QmlDesigner
|
||||
snappinglinecreator.cpp snappinglinecreator.h
|
||||
toolbox.cpp toolbox.h
|
||||
option3daction.cpp option3daction.h
|
||||
editview3dproxydialog.cpp editview3dproxydialog.h
|
||||
)
|
||||
|
||||
extend_qtc_plugin(QmlDesigner
|
||||
|
||||
@@ -0,0 +1,168 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 "editview3dproxydialog.h"
|
||||
#include "formeditorview.h"
|
||||
|
||||
#include <nodeinstanceview.h>
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
|
||||
#include <utils/hostosinfo.h>
|
||||
|
||||
#include <QApplication>
|
||||
#include <QMouseEvent>
|
||||
#include <QStyle>
|
||||
#include <QWindow>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
const int borderOffset = 8;
|
||||
|
||||
static int titleBarHeight() {
|
||||
return QApplication::style()->pixelMetric(QStyle::PM_TitleBarHeight);
|
||||
}
|
||||
|
||||
EditView3DProxyDialog::EditView3DProxyDialog(FormEditorView *view) :
|
||||
QDialog(Core::ICore::dialogParent())
|
||||
,m_formEditorView(view)
|
||||
{
|
||||
setFocusPolicy(Qt::ClickFocus);
|
||||
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||
|
||||
if (Utils::HostOsInfo::isMacHost()) {
|
||||
setWindowFlag(Qt::Tool);
|
||||
setAttribute(Qt::WA_MacAlwaysShowToolWindow);
|
||||
}
|
||||
|
||||
resize(1024, 768);
|
||||
}
|
||||
|
||||
void EditView3DProxyDialog::invalidate()
|
||||
{
|
||||
if (nodeInstanceView() && isVisible())
|
||||
nodeInstanceView()->show3DView(adjustedRect());
|
||||
}
|
||||
|
||||
void EditView3DProxyDialog::moveEvent(QMoveEvent *event)
|
||||
{
|
||||
if (nodeInstanceView())
|
||||
nodeInstanceView()->move3DView(pos() + QPoint(borderOffset, titleBarHeight() + 2 * borderOffset));
|
||||
|
||||
QDialog::moveEvent(event);
|
||||
}
|
||||
|
||||
void EditView3DProxyDialog::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
if (m_formEditorView) {
|
||||
m_formEditorView->toggle3DViewEnabled(false);
|
||||
m_formEditorView->setupOption3DAction();
|
||||
}
|
||||
|
||||
nodeInstanceView()->hide3DView();
|
||||
|
||||
QDialog::closeEvent(event);
|
||||
}
|
||||
|
||||
void EditView3DProxyDialog::hideEvent(QHideEvent *event)
|
||||
{
|
||||
if (m_formEditorView) {
|
||||
m_formEditorView->toggle3DViewEnabled(false);
|
||||
m_formEditorView->setupOption3DAction();
|
||||
}
|
||||
|
||||
nodeInstanceView()->hide3DView();
|
||||
|
||||
QDialog::hideEvent(event);
|
||||
}
|
||||
|
||||
void EditView3DProxyDialog::focusOutEvent(QFocusEvent *event)
|
||||
{
|
||||
if (isVisible())
|
||||
showView();
|
||||
|
||||
QDialog::focusOutEvent(event);
|
||||
}
|
||||
|
||||
void EditView3DProxyDialog::focusInEvent(QFocusEvent *event)
|
||||
{
|
||||
showView();
|
||||
|
||||
QDialog::focusInEvent(event);
|
||||
}
|
||||
|
||||
void EditView3DProxyDialog::resizeEvent(QResizeEvent *event)
|
||||
{
|
||||
if (nodeInstanceView())
|
||||
nodeInstanceView()->show3DView(adjustedRect());
|
||||
|
||||
QDialog::resizeEvent(event);
|
||||
}
|
||||
|
||||
bool EditView3DProxyDialog::event(QEvent *event)
|
||||
{
|
||||
if (event->type() == QEvent::WindowActivate) {
|
||||
showView();
|
||||
} else if (event->type() == QEvent::NonClientAreaMouseButtonPress) {
|
||||
auto mouseMoveEvent = static_cast<QMouseEvent *>(event);
|
||||
if (mouseMoveEvent->buttons() & Qt::LeftButton)
|
||||
hideView();
|
||||
} else if (event->type() == QEvent::NonClientAreaMouseButtonRelease) {
|
||||
auto mouseMoveEvent = static_cast<QMouseEvent *>(event);
|
||||
if (mouseMoveEvent->buttons() & Qt::LeftButton)
|
||||
showView();
|
||||
}
|
||||
|
||||
return QDialog::event(event);
|
||||
}
|
||||
|
||||
QRect EditView3DProxyDialog::adjustedRect() const
|
||||
{
|
||||
return QRect(pos(), size()).adjusted(borderOffset,
|
||||
titleBarHeight() + 2 * borderOffset,
|
||||
-borderOffset, titleBarHeight());
|
||||
}
|
||||
|
||||
NodeInstanceView *EditView3DProxyDialog::nodeInstanceView() const
|
||||
{
|
||||
if (m_formEditorView)
|
||||
return m_formEditorView->nodeInstanceView();
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void EditView3DProxyDialog::showView()
|
||||
{
|
||||
if (nodeInstanceView())
|
||||
nodeInstanceView()->show3DView(adjustedRect());
|
||||
}
|
||||
|
||||
void EditView3DProxyDialog::hideView()
|
||||
{
|
||||
if (nodeInstanceView())
|
||||
nodeInstanceView()->hide3DView();
|
||||
}
|
||||
|
||||
} //QmlDesigner
|
||||
@@ -0,0 +1,67 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 "abstractcustomtool.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QDialog>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
class FormEditorView;
|
||||
class NodeInstanceView;
|
||||
|
||||
class EditView3DProxyDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit EditView3DProxyDialog(FormEditorView *view);
|
||||
|
||||
void invalidate();
|
||||
|
||||
protected:
|
||||
void moveEvent(QMoveEvent *event) override;
|
||||
void closeEvent(QCloseEvent *event) override;
|
||||
void hideEvent(QHideEvent *event) override;
|
||||
void focusOutEvent(QFocusEvent *event) override;
|
||||
void focusInEvent(QFocusEvent *event) override;
|
||||
void resizeEvent(QResizeEvent *event) override;
|
||||
bool event(QEvent *event) override;
|
||||
|
||||
private:
|
||||
QRect adjustedRect() const;
|
||||
NodeInstanceView *nodeInstanceView() const;
|
||||
void showView();
|
||||
void hideView();
|
||||
|
||||
QPointer<FormEditorView> m_formEditorView;
|
||||
|
||||
};
|
||||
|
||||
} //QmlDesigner
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
VPATH += $$PWD
|
||||
SOURCES += formeditoritem.cpp \
|
||||
editview3dproxydialog.cpp \
|
||||
formeditorview.cpp \
|
||||
formeditorscene.cpp \
|
||||
formeditorwidget.cpp \
|
||||
@@ -40,6 +41,7 @@ SOURCES += formeditoritem.cpp \
|
||||
option3daction.cpp
|
||||
|
||||
HEADERS += formeditorscene.h \
|
||||
editview3dproxydialog.h \
|
||||
formeditorwidget.h \
|
||||
formeditoritem.h \
|
||||
formeditorview.h \
|
||||
|
||||
@@ -474,6 +474,8 @@ void FormEditorView::instancesCompleted(const QVector<ModelNode> &completedNodeL
|
||||
itemNodeList.append(item);
|
||||
}
|
||||
}
|
||||
if (node.isRootNode())
|
||||
formEditorWidget()->invalidate3DEditor();
|
||||
}
|
||||
currentTool()->instancesCompleted(itemNodeList);
|
||||
}
|
||||
@@ -594,6 +596,8 @@ void FormEditorView::toggle3DViewEnabled(bool enabled)
|
||||
rootModelNode().removeAuxiliaryData("3d-view");
|
||||
else
|
||||
rootModelNode().setAuxiliaryData("3d-view", false);
|
||||
|
||||
formEditorWidget()->set3dEditorVisibility(enabled);
|
||||
}
|
||||
|
||||
QmlItemNode findRecursiveQmlItemNode(const QmlObjectNode &firstQmlObjectNode)
|
||||
|
||||
@@ -119,6 +119,7 @@ public:
|
||||
void exportAsImage();
|
||||
|
||||
void toggle3DViewEnabled(bool enabled);
|
||||
void setupOption3DAction();
|
||||
|
||||
protected:
|
||||
void reset();
|
||||
@@ -131,7 +132,6 @@ private: //functions
|
||||
void hideNodeFromScene(const QmlItemNode &qmlItemNode);
|
||||
void createFormEditorWidget();
|
||||
void temporaryBlockView();
|
||||
void setupOption3DAction();
|
||||
|
||||
private: //variables
|
||||
QPointer<FormEditorWidget> m_formEditorWidget;
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "designeractionmanager.h"
|
||||
#include "editview3dproxydialog.h"
|
||||
#include "formeditorwidget.h"
|
||||
#include "formeditorscene.h"
|
||||
#include "qmldesignerplugin.h"
|
||||
@@ -173,6 +174,8 @@ FormEditorWidget::FormEditorWidget(FormEditorView *view) :
|
||||
|
||||
fillLayout->addWidget(m_graphicsView.data());
|
||||
m_graphicsView.data()->setStyleSheet(Theme::replaceCssColors(QString::fromUtf8(Utils::FileReader::fetchQrc(QLatin1String(":/qmldesigner/scrollbar.css")))));
|
||||
|
||||
m_editView3DProxyDialog = new EditView3DProxyDialog(view);
|
||||
}
|
||||
|
||||
void FormEditorWidget::changeTransformTool(bool checked)
|
||||
@@ -394,6 +397,17 @@ FormEditorGraphicsView *FormEditorWidget::graphicsView() const
|
||||
return m_graphicsView;
|
||||
}
|
||||
|
||||
void FormEditorWidget::set3dEditorVisibility(bool b)
|
||||
{
|
||||
m_editView3DProxyDialog->setVisible(b);
|
||||
}
|
||||
|
||||
void FormEditorWidget::invalidate3DEditor()
|
||||
{
|
||||
if (m_editView3DProxyDialog)
|
||||
m_editView3DProxyDialog->invalidate();
|
||||
}
|
||||
|
||||
DocumentWarningWidget *FormEditorWidget::errorWidget()
|
||||
{
|
||||
if (m_documentErrorWidget.isNull()) {
|
||||
|
||||
@@ -37,6 +37,7 @@ QT_END_NAMESPACE
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
class EditView3DProxyDialog;
|
||||
class ZoomAction;
|
||||
class LineEditAction;
|
||||
class BackgroundAction;
|
||||
@@ -47,7 +48,6 @@ class FormEditorGraphicsView;
|
||||
class ToolBox;
|
||||
class QmlItemNode;
|
||||
|
||||
|
||||
class FormEditorWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -87,6 +87,9 @@ public:
|
||||
|
||||
FormEditorGraphicsView *graphicsView() const;
|
||||
|
||||
void set3dEditorVisibility(bool b);
|
||||
void invalidate3DEditor();
|
||||
|
||||
protected:
|
||||
void wheelEvent(QWheelEvent *event) override;
|
||||
QActionGroup *toolActionGroup() const;
|
||||
@@ -117,6 +120,7 @@ private:
|
||||
QPointer<Option3DAction> m_option3DAction;
|
||||
QPointer<QAction> m_resetAction;
|
||||
QPointer<DocumentWarningWidget> m_documentErrorWidget;
|
||||
QPointer<EditView3DProxyDialog> m_editView3DProxyDialog;
|
||||
};
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
||||
@@ -59,6 +59,7 @@ class CreateSceneCommand;
|
||||
class CreateInstancesCommand;
|
||||
class ClearSceneCommand;
|
||||
class ReparentInstancesCommand;
|
||||
class Change3DViewCommand;
|
||||
class ChangeFileUrlCommand;
|
||||
class ChangeValuesCommand;
|
||||
class ChangeBindingsCommand;
|
||||
@@ -142,10 +143,15 @@ public:
|
||||
void selectedNodesChanged(const QList<ModelNode> &selectedNodeList,
|
||||
const QList<ModelNode> &lastSelectedNodeList) override;
|
||||
|
||||
void show3DView(const QRect &rect);
|
||||
void move3DView(const QPoint &position);
|
||||
void hide3DView();
|
||||
|
||||
protected:
|
||||
void timerEvent(QTimerEvent *event) override;
|
||||
|
||||
private: // functions
|
||||
enum ViewAction { Show, Move, Hide };
|
||||
void activateState(const NodeInstance &instance);
|
||||
void activateBaseState();
|
||||
|
||||
@@ -170,6 +176,7 @@ private: // functions
|
||||
|
||||
|
||||
CreateSceneCommand createCreateSceneCommand();
|
||||
Change3DViewCommand createChange3DViewCommand(ViewAction action, const QPoint &pos = {}, const QSize &size = {}) const;
|
||||
ClearSceneCommand createClearSceneCommand() const;
|
||||
CreateInstancesCommand createCreateInstancesCommand(const QList<NodeInstance> &instanceList) const;
|
||||
CompleteComponentCommand createComponentCompleteCommand(const QList<NodeInstance> &instanceList) const;
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
|
||||
#include <createinstancescommand.h>
|
||||
#include <createscenecommand.h>
|
||||
#include <change3dviewcommand.h>
|
||||
#include <changevaluescommand.h>
|
||||
#include <changebindingscommand.h>
|
||||
#include <changeauxiliarycommand.h>
|
||||
@@ -651,6 +652,11 @@ void NodeInstanceServerProxy::clearScene(const ClearSceneCommand &command)
|
||||
writeCommand(QVariant::fromValue(command));
|
||||
}
|
||||
|
||||
void NodeInstanceServerProxy::change3DView(const Change3DViewCommand &command)
|
||||
{
|
||||
writeCommand(QVariant::fromValue(command));
|
||||
}
|
||||
|
||||
void NodeInstanceServerProxy::removeInstances(const RemoveInstancesCommand &command)
|
||||
{
|
||||
writeCommand(QVariant::fromValue(command));
|
||||
|
||||
@@ -69,6 +69,7 @@ public:
|
||||
void createInstances(const CreateInstancesCommand &command) override;
|
||||
void changeFileUrl(const ChangeFileUrlCommand &command) override;
|
||||
void createScene(const CreateSceneCommand &command) override;
|
||||
void change3DView(const Change3DViewCommand &command) override;
|
||||
void clearScene(const ClearSceneCommand &command) override;
|
||||
void removeInstances(const RemoveInstancesCommand &command) override;
|
||||
void changeSelection(const ChangeSelectionCommand &command) override;
|
||||
|
||||
@@ -48,6 +48,7 @@
|
||||
#include "clearscenecommand.h"
|
||||
#include "changefileurlcommand.h"
|
||||
#include "reparentinstancescommand.h"
|
||||
#include "change3dviewcommand.h"
|
||||
#include "changevaluescommand.h"
|
||||
#include "changeauxiliarycommand.h"
|
||||
#include "changebindingscommand.h"
|
||||
@@ -978,6 +979,20 @@ ClearSceneCommand NodeInstanceView::createClearSceneCommand() const
|
||||
return {};
|
||||
}
|
||||
|
||||
Change3DViewCommand NodeInstanceView::createChange3DViewCommand(ViewAction action, const QPoint &pos, const QSize &size) const
|
||||
{
|
||||
InformationName informationName = InformationName::ShowView;
|
||||
|
||||
if (action == ViewAction::Move)
|
||||
informationName = InformationName::MoveView;
|
||||
else if (action == ViewAction::Hide)
|
||||
informationName = InformationName::HideView;
|
||||
|
||||
const qint32 instanceId = 0;
|
||||
|
||||
return Change3DViewCommand({ InformationContainer(instanceId, informationName, pos, size) });
|
||||
}
|
||||
|
||||
CompleteComponentCommand NodeInstanceView::createComponentCompleteCommand(const QList<NodeInstance> &instanceList) const
|
||||
{
|
||||
QVector<qint32> containerList;
|
||||
@@ -1458,6 +1473,23 @@ void NodeInstanceView::selectedNodesChanged(const QList<ModelNode> &selectedNode
|
||||
nodeInstanceServer()->changeSelection(createChangeSelectionCommand(selectedNodeList));
|
||||
}
|
||||
|
||||
void NodeInstanceView::move3DView(const QPoint &position)
|
||||
{
|
||||
nodeInstanceServer()->change3DView(createChange3DViewCommand(ViewAction::Move, position));
|
||||
}
|
||||
|
||||
void NodeInstanceView::hide3DView()
|
||||
{
|
||||
nodeInstanceServer()->change3DView(createChange3DViewCommand(ViewAction::Hide));
|
||||
}
|
||||
|
||||
void NodeInstanceView::show3DView(const QRect &rect)
|
||||
{
|
||||
nodeInstanceServer()->change3DView(createChange3DViewCommand(ViewAction::Show,
|
||||
rect.topLeft(),
|
||||
rect.size()));
|
||||
}
|
||||
|
||||
void NodeInstanceView::timerEvent(QTimerEvent *event)
|
||||
{
|
||||
if (m_restartProcessTimerId == event->timerId())
|
||||
|
||||
@@ -171,6 +171,8 @@ Project {
|
||||
"commands/changeselectioncommand.h",
|
||||
"commands/drop3dlibraryitemcommand.cpp",
|
||||
"commands/drop3dlibraryitemcommand.h",
|
||||
"commands/change3dviewcommand.cpp",
|
||||
"commands/change3dviewcommand.h",
|
||||
"container/addimportcontainer.cpp",
|
||||
"container/addimportcontainer.h",
|
||||
"container/idcontainer.cpp",
|
||||
|
||||
@@ -46,6 +46,7 @@ extend_qtc_executable(qml2puppet
|
||||
tokencommand.cpp tokencommand.h
|
||||
changeselectioncommand.cpp changeselectioncommand.h
|
||||
drop3dlibraryitemcommand.cpp drop3dlibraryitemcommand.h
|
||||
change3dviewcommand.cpp change3dviewcommand.h
|
||||
valueschangedcommand.cpp
|
||||
)
|
||||
|
||||
|
||||
@@ -97,6 +97,8 @@ QtcTool {
|
||||
"commands/changeselectioncommand.h",
|
||||
"commands/drop3dlibraryitemcommand.cpp",
|
||||
"commands/drop3dlibraryitemcommand.h",
|
||||
"commands/change3dviewcommand.cpp",
|
||||
"commands/change3dviewcommand.h",
|
||||
"container/addimportcontainer.cpp",
|
||||
"container/addimportcontainer.h",
|
||||
"container/idcontainer.cpp",
|
||||
|
||||
Reference in New Issue
Block a user