forked from qt-creator/qt-creator
QmlDesigner: Implement Quick3DNodeInstance wrapper
We use Quick3DNodeInstance as a proxy class to wrap QQuick3DNode. The access to private API like QQuick3DNodePrivate::setIsHiddenInEditor() is restriced by such proxy classes. Change-Id: If5191c3b730359000cf983c3af206dcffa07be74 Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io> Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io> Reviewed-by: Pasi Keränen <pasi.keranen@qt.io> Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -1,5 +1,10 @@
|
||||
INCLUDEPATH += $$PWD/
|
||||
|
||||
qtHaveModule(quick3d) {
|
||||
QT *= quick3d-private
|
||||
DEFINES *= QUICK3D_MODULE
|
||||
}
|
||||
|
||||
HEADERS += $$PWD/qt5nodeinstanceserver.h
|
||||
HEADERS += $$PWD/qt5testnodeinstanceserver.h
|
||||
HEADERS += $$PWD/qt5informationnodeinstanceserver.h
|
||||
@@ -23,6 +28,7 @@ HEADERS += $$PWD/anchorchangesnodeinstance.h
|
||||
HEADERS += $$PWD/positionernodeinstance.h
|
||||
HEADERS += $$PWD/layoutnodeinstance.h
|
||||
HEADERS += $$PWD/qt3dpresentationnodeinstance.h
|
||||
HEADERS += $$PWD/quick3dnodeinstance.h
|
||||
|
||||
SOURCES += $$PWD/qt5nodeinstanceserver.cpp
|
||||
SOURCES += $$PWD/qt5testnodeinstanceserver.cpp
|
||||
@@ -47,3 +53,4 @@ SOURCES += $$PWD/anchorchangesnodeinstance.cpp
|
||||
SOURCES += $$PWD/positionernodeinstance.cpp
|
||||
SOURCES += $$PWD/layoutnodeinstance.cpp
|
||||
SOURCES += $$PWD/qt3dpresentationnodeinstance.cpp
|
||||
SOURCES += $$PWD/quick3dnodeinstance.cpp
|
||||
|
@@ -985,12 +985,10 @@ void NodeInstanceServer::setInstanceAuxiliaryData(const PropertyValueContainer &
|
||||
} else if (auxiliaryContainer.name() == "invisible") {
|
||||
if (hasInstanceForId(auxiliaryContainer.instanceId())) {
|
||||
ServerNodeInstance instance = instanceForId(auxiliaryContainer.instanceId());
|
||||
if (instance.isSubclassOf("QQuick3DNode")) {
|
||||
if (!auxiliaryContainer.value().isNull())
|
||||
instance.setPropertyVariant("visible", !auxiliaryContainer.value().toBool());
|
||||
else
|
||||
instance.resetProperty("visible");
|
||||
}
|
||||
if (!auxiliaryContainer.value().isNull())
|
||||
instance.setHideInEditor(auxiliaryContainer.value().toBool());
|
||||
else
|
||||
instance.setHideInEditor(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -392,6 +392,10 @@ PropertyNameList ObjectNodeInstance::ignoredProperties() const
|
||||
return PropertyNameList();
|
||||
}
|
||||
|
||||
void ObjectNodeInstance::setHideInEditor(bool)
|
||||
{
|
||||
}
|
||||
|
||||
QVariant ObjectNodeInstance::convertEnumToValue(const QVariant &value, const PropertyName &name)
|
||||
{
|
||||
Q_ASSERT(value.canConvert<Enumeration>());
|
||||
|
@@ -193,6 +193,8 @@ public:
|
||||
|
||||
virtual PropertyNameList ignoredProperties() const;
|
||||
|
||||
void virtual setHideInEditor(bool b);
|
||||
|
||||
protected:
|
||||
explicit ObjectNodeInstance(QObject *object);
|
||||
void doResetProperty(const PropertyName &propertyName);
|
||||
|
@@ -0,0 +1,83 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 "quick3dnodeinstance.h"
|
||||
#include "qt5nodeinstanceserver.h"
|
||||
|
||||
#include <qmlprivategate.h>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QHash>
|
||||
#include <QQmlExpression>
|
||||
#include <QQmlProperty>
|
||||
|
||||
#include <cmath>
|
||||
|
||||
#ifdef QUICK3D_MODULE
|
||||
#include <private/qquick3dnode_p.h>
|
||||
#include <private/qquick3dnode_p_p.h>
|
||||
#endif
|
||||
|
||||
namespace QmlDesigner {
|
||||
namespace Internal {
|
||||
|
||||
Quick3DNodeInstance::Quick3DNodeInstance(QObject *node)
|
||||
: ObjectNodeInstance(node)
|
||||
{
|
||||
}
|
||||
|
||||
Quick3DNodeInstance::~Quick3DNodeInstance()
|
||||
{
|
||||
}
|
||||
|
||||
Qt5NodeInstanceServer *Quick3DNodeInstance::qt5NodeInstanceServer() const
|
||||
{
|
||||
return qobject_cast<Qt5NodeInstanceServer *>(nodeInstanceServer());
|
||||
}
|
||||
|
||||
QQuick3DNode *Quick3DNodeInstance::quick3DNode() const
|
||||
{
|
||||
return qobject_cast<QQuick3DNode *>(object());
|
||||
}
|
||||
|
||||
Quick3DNodeInstance::Pointer Quick3DNodeInstance::create(QObject *object)
|
||||
{
|
||||
Pointer instance(new Quick3DNodeInstance(object));
|
||||
instance->populateResetHashes();
|
||||
return instance;
|
||||
}
|
||||
|
||||
void Quick3DNodeInstance::setHideInEditor(bool b)
|
||||
{
|
||||
#ifdef QUICK3D_MODULE
|
||||
QQuick3DNodePrivate *privateNode = QQuick3DNodePrivate::get(quick3DNode());
|
||||
if (privateNode)
|
||||
privateNode->setIsHiddenInEditor(b);
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // 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 <QtGlobal>
|
||||
|
||||
#include "objectnodeinstance.h"
|
||||
|
||||
#include <designersupportdelegate.h>
|
||||
|
||||
QT_FORWARD_DECLARE_CLASS(QQuick3DNode)
|
||||
|
||||
namespace QmlDesigner {
|
||||
namespace Internal {
|
||||
|
||||
class Quick3DNodeInstance : public ObjectNodeInstance
|
||||
{
|
||||
public:
|
||||
using Pointer = QSharedPointer<Quick3DNodeInstance>;
|
||||
|
||||
~Quick3DNodeInstance() override;
|
||||
static Pointer create(QObject *objectToBeWrapped);
|
||||
void setHideInEditor(bool b) override;
|
||||
|
||||
protected:
|
||||
explicit Quick3DNodeInstance(QObject *node);
|
||||
|
||||
private:
|
||||
Qt5NodeInstanceServer *qt5NodeInstanceServer() const;
|
||||
QQuick3DNode *quick3DNode() const;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace QmlDesigner
|
@@ -39,6 +39,7 @@
|
||||
#include "qt3dpresentationnodeinstance.h"
|
||||
|
||||
#include "quickitemnodeinstance.h"
|
||||
#include "quick3dnodeinstance.h"
|
||||
|
||||
#include "nodeinstanceserver.h"
|
||||
#include "instancecontainer.h"
|
||||
@@ -170,6 +171,8 @@ Internal::ObjectNodeInstance::Pointer ServerNodeInstance::createInstance(QObject
|
||||
instance = Internal::LayoutNodeInstance::create(objectToBeWrapped);
|
||||
else if (isSubclassOf(objectToBeWrapped, "QQuickItem"))
|
||||
instance = Internal::QuickItemNodeInstance::create(objectToBeWrapped);
|
||||
else if (isSubclassOf(objectToBeWrapped, "QQuick3DNode"))
|
||||
instance = Internal::Quick3DNodeInstance::create(objectToBeWrapped);
|
||||
else if (isSubclassOf(objectToBeWrapped, "QQmlComponent"))
|
||||
instance = Internal::ComponentNodeInstance::create(objectToBeWrapped);
|
||||
else if (objectToBeWrapped->inherits("QQmlAnchorChanges"))
|
||||
@@ -312,6 +315,11 @@ void ServerNodeInstance::setPropertyBinding(const PropertyName &name, const QStr
|
||||
m_nodeInstance->setPropertyBinding(name, expression);
|
||||
}
|
||||
|
||||
void ServerNodeInstance::setHideInEditor(bool b)
|
||||
{
|
||||
m_nodeInstance->setHideInEditor(b);
|
||||
}
|
||||
|
||||
void ServerNodeInstance::resetProperty(const PropertyName &name)
|
||||
{
|
||||
m_nodeInstance->resetProperty(name);
|
||||
|
@@ -172,6 +172,8 @@ private: // functions
|
||||
|
||||
void setPropertyBinding(const PropertyName &name, const QString &expression);
|
||||
|
||||
void setHideInEditor(bool b);
|
||||
|
||||
void resetProperty(const PropertyName &name);
|
||||
void refreshProperty(const PropertyName &name);
|
||||
|
||||
|
@@ -87,6 +87,14 @@ extend_qtc_executable(qml2puppet
|
||||
nodeinstanceclientproxy.cpp nodeinstanceclientproxy.h
|
||||
)
|
||||
|
||||
find_package(Qt5 COMPONENTS Quick3D QUIET)
|
||||
extend_qtc_executable(qml2puppet
|
||||
CONDITION TARGET Qt5::Quick3
|
||||
FEATURE_INFO "Qt Quick 3D"
|
||||
DEPENDS Qt5::Quick3D
|
||||
DEFINES QUICK3D_MODULE
|
||||
)
|
||||
|
||||
extend_qtc_executable(qml2puppet
|
||||
SOURCES_PREFIX "${SRCDIR}/interfaces"
|
||||
SOURCES
|
||||
|
@@ -175,6 +175,8 @@ QtcTool {
|
||||
"instances/qmlpropertychangesnodeinstance.h",
|
||||
"instances/qmlstatenodeinstance.cpp",
|
||||
"instances/qmlstatenodeinstance.h",
|
||||
"instances/quick3dnodeinstance.cpp",
|
||||
"instances/quick3dnodeinstance.h",
|
||||
"instances/qmltransitionnodeinstance.cpp",
|
||||
"instances/qmltransitionnodeinstance.h",
|
||||
"instances/qt3dpresentationnodeinstance.cpp",
|
||||
|
Reference in New Issue
Block a user