forked from qt-creator/qt-creator
QmlDesigner: Port 3D edit view to Qt6
Task-number: QDS-2899 Change-Id: Iedbe5e8561e5ab71ef32922e69da43cd3cc57e90 Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -109,7 +109,11 @@ QDataStream &operator<<(QDataStream &out, const ValuesChangedCommand &command)
|
||||
++keyCounter;
|
||||
command.m_keyNumber = keyCounter;
|
||||
QByteArray outDataStreamByteArray;
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
QDataStream temporaryOutDataStream(&outDataStreamByteArray, QIODevice::WriteOnly);
|
||||
#else
|
||||
QDataStream temporaryOutDataStream(&outDataStreamByteArray, QDataStream::WriteOnly);
|
||||
#endif
|
||||
temporaryOutDataStream.setVersion(QDataStream::Qt_4_8);
|
||||
|
||||
temporaryOutDataStream << propertyValueContainer;
|
||||
|
@@ -25,8 +25,6 @@
|
||||
|
||||
import QtQuick 2.12
|
||||
import QtQuick3D 1.15
|
||||
import QtQuick.Controls 2.0
|
||||
import QtGraphicalEffects 1.0
|
||||
import MouseArea3D 1.0
|
||||
|
||||
Item {
|
||||
@@ -100,6 +98,7 @@ Item {
|
||||
if (editView) {
|
||||
// Destroy is async, so make sure we don't get any more updates for the old editView
|
||||
_generalHelper.enableItemUpdate(editView, false);
|
||||
editView.visible = false;
|
||||
editView.destroy();
|
||||
}
|
||||
|
||||
@@ -299,15 +298,23 @@ Item {
|
||||
|
||||
function addLightGizmo(scene, obj)
|
||||
{
|
||||
// Insert into first available gizmo
|
||||
// Insert into first available gizmo if we don't already have gizmo for this object
|
||||
var slotFound = -1;
|
||||
for (var i = 0; i < lightIconGizmos.length; ++i) {
|
||||
if (!lightIconGizmos[i].targetNode) {
|
||||
slotFound = i;
|
||||
} else if (lightIconGizmos[i].targetNode === obj) {
|
||||
lightIconGizmos[i].scene = scene;
|
||||
lightIconGizmos[i].targetNode = obj;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (slotFound !== -1) {
|
||||
lightIconGizmos[slotFound].scene = scene;
|
||||
lightIconGizmos[slotFound].targetNode = obj;
|
||||
return;
|
||||
}
|
||||
|
||||
// No free gizmos available, create a new one
|
||||
var gizmoComponent = Qt.createComponent("LightIconGizmo.qml");
|
||||
if (gizmoComponent.status === Component.Ready) {
|
||||
@@ -324,14 +331,23 @@ Item {
|
||||
|
||||
function addCameraGizmo(scene, obj)
|
||||
{
|
||||
// Insert into first available gizmo
|
||||
// Insert into first available gizmo if we don't already have gizmo for this object
|
||||
var slotFound = -1;
|
||||
for (var i = 0; i < cameraGizmos.length; ++i) {
|
||||
if (!cameraGizmos[i].targetNode) {
|
||||
slotFound = i;
|
||||
} else if (cameraGizmos[i].targetNode === obj) {
|
||||
cameraGizmos[i].scene = scene;
|
||||
cameraGizmos[i].targetNode = obj;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (slotFound !== -1) {
|
||||
cameraGizmos[slotFound].scene = scene;
|
||||
cameraGizmos[slotFound].targetNode = obj;
|
||||
return;
|
||||
}
|
||||
|
||||
// No free gizmos available, create a new one
|
||||
var gizmoComponent = Qt.createComponent("CameraGizmo.qml");
|
||||
var frustumComponent = Qt.createComponent("CameraFrustum.qml");
|
||||
|
@@ -26,7 +26,7 @@
|
||||
import QtQuick 2.0
|
||||
import QtQuick3D 1.15
|
||||
import MouseArea3D 1.0
|
||||
import LightGeometry 1.0
|
||||
import LightUtils 1.0
|
||||
|
||||
Node {
|
||||
id: lightGizmo
|
||||
@@ -35,7 +35,6 @@ Node {
|
||||
property Node targetNode: null
|
||||
property MouseArea3D dragHelper: null
|
||||
property color color: Qt.rgba(1, 1, 0, 1)
|
||||
property real brightnessScale: targetNode ? Math.max(1.0, 1.0 + targetNode.brightness) : 100
|
||||
property real fadeScale: {
|
||||
// Value indicates area where intensity is above certain percent of total brightness.
|
||||
if (lightGizmo.targetNode instanceof SpotLight || lightGizmo.targetNode instanceof PointLight) {
|
||||
@@ -64,6 +63,8 @@ Node {
|
||||
|| pointLightFadeHandle.dragging
|
||||
property point currentMousePos
|
||||
property string currentLabel
|
||||
property int brightnessDecimals: _generalHelper.brightnessScaler() > 10. ? 0 : 2;
|
||||
property real brightnessMultiplier: Math.pow(10, brightnessDecimals);
|
||||
|
||||
signal propertyValueCommit(string propName)
|
||||
signal propertyValueChange(string propName)
|
||||
@@ -226,7 +227,6 @@ Node {
|
||||
onValueCommit: lightGizmo.propertyValueCommit(propName)
|
||||
}
|
||||
}
|
||||
|
||||
Node {
|
||||
id: areaParts
|
||||
visible: lightGizmo.targetNode instanceof AreaLight
|
||||
@@ -305,15 +305,19 @@ Node {
|
||||
active: lightGizmo.visible
|
||||
dragHelper: lightGizmo.dragHelper
|
||||
scale: autoScaler.getScale(Qt.vector3d(5, 5, 5))
|
||||
length: (lightGizmo.brightnessScale / 10) + 3
|
||||
length: targetNode ? Math.max(1.0, 1.0 + targetNode.brightness / _generalHelper.brightnessScaler() * 10.0) + 3 : 10
|
||||
|
||||
property real _startBrightness
|
||||
|
||||
function updateBrightness(relativeDistance, screenPos)
|
||||
{
|
||||
var currentValue = Math.round(Math.max(0, _startBrightness + relativeDistance * 10));
|
||||
var currentValue = Math.max(0, (_startBrightness + relativeDistance * _generalHelper.brightnessScaler() / 10.0));
|
||||
currentValue *= brightnessMultiplier;
|
||||
currentValue = Math.round(currentValue);
|
||||
currentValue /= brightnessMultiplier;
|
||||
|
||||
var l = Qt.locale();
|
||||
lightGizmo.currentLabel = "brightness" + qsTr(": ") + Number(currentValue).toLocaleString(l, 'f', 0);
|
||||
lightGizmo.currentLabel = "brightness" + qsTr(": ") + Number(currentValue).toLocaleString(l, 'f', brightnessDecimals);
|
||||
lightGizmo.currentMousePos = screenPos;
|
||||
targetNode.brightness = currentValue;
|
||||
}
|
||||
|
@@ -25,6 +25,7 @@
|
||||
|
||||
import QtQuick 2.0
|
||||
import QtQuick3D 1.15
|
||||
import LightUtils 1.0
|
||||
|
||||
IconGizmo {
|
||||
id: lightIconGizmo
|
||||
|
@@ -25,7 +25,7 @@
|
||||
|
||||
import QtQuick 2.0
|
||||
import QtQuick3D 1.15
|
||||
import LightGeometry 1.0
|
||||
import LightUtils 1.0
|
||||
|
||||
Model {
|
||||
id: lightModel
|
||||
|
@@ -24,6 +24,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
import QtQuick 2.15
|
||||
import QtQuick3D 1.15
|
||||
|
||||
Item {
|
||||
id: root
|
||||
@@ -32,8 +33,12 @@ Item {
|
||||
|
||||
property alias contentItem: contentItem
|
||||
|
||||
View3D {
|
||||
// Dummy view to hold the context in case View3D items are used in the component
|
||||
// TODO remove when QTBUG-87678 is fixed
|
||||
}
|
||||
|
||||
Item {
|
||||
id: contentItem
|
||||
anchors.fill: parent
|
||||
}
|
||||
}
|
||||
|
@@ -122,6 +122,11 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
View3D {
|
||||
// Dummy view to hold the context
|
||||
// TODO remove when QTBUG-87678 is fixed
|
||||
}
|
||||
|
||||
Item {
|
||||
id: contentItem
|
||||
anchors.fill: parent
|
||||
|
@@ -51,6 +51,19 @@ CameraGeometry::~CameraGeometry()
|
||||
{
|
||||
}
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
QString CameraGeometry::name() const
|
||||
{
|
||||
return objectName();
|
||||
}
|
||||
|
||||
void CameraGeometry::setName(const QString &name)
|
||||
{
|
||||
setObjectName(name);
|
||||
emit nameChanged();
|
||||
}
|
||||
#endif
|
||||
|
||||
QQuick3DCamera *CameraGeometry::camera() const
|
||||
{
|
||||
return m_camera;
|
||||
@@ -173,13 +186,16 @@ void CameraGeometry::fillVertexData(QByteArray &vertexData, QByteArray &indexDat
|
||||
QMatrix4x4 m;
|
||||
QSSGRenderCamera *camera = m_camera->cameraNode();
|
||||
if (camera) {
|
||||
QRectF rect = m_viewPortRect;
|
||||
if (rect.isNull())
|
||||
rect = QRectF(0, 0, 1000, 1000); // Let's have some visualization for null viewports
|
||||
if (qobject_cast<QQuick3DOrthographicCamera *>(m_camera)) {
|
||||
// For some reason ortho cameras show double what projection suggests,
|
||||
// so give them doubled viewport to match visualization to actual camera view
|
||||
camera->calculateGlobalVariables(QRectF(0, 0, m_viewPortRect.width() * 2.0,
|
||||
m_viewPortRect.height() * 2.0));
|
||||
camera->calculateGlobalVariables(QRectF(0, 0, rect.width() * 2.0,
|
||||
rect.height() * 2.0));
|
||||
} else {
|
||||
camera->calculateGlobalVariables(m_viewPortRect);
|
||||
camera->calculateGlobalVariables(rect);
|
||||
}
|
||||
m = camera->projection.inverted();
|
||||
}
|
||||
|
@@ -39,6 +39,17 @@ class CameraGeometry : public QQuick3DGeometry
|
||||
Q_PROPERTY(QQuick3DCamera *camera READ camera WRITE setCamera NOTIFY cameraChanged)
|
||||
Q_PROPERTY(QRectF viewPortRect READ viewPortRect WRITE setViewPortRect NOTIFY viewPortRectChanged)
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
// Name property was removed in Qt 6, so define it here for compatibility.
|
||||
// Name maps to object name.
|
||||
Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
|
||||
public:
|
||||
QString name() const;
|
||||
void setName(const QString &name);
|
||||
signals:
|
||||
void nameChanged();
|
||||
#endif
|
||||
|
||||
public:
|
||||
CameraGeometry();
|
||||
~CameraGeometry() override;
|
||||
@@ -46,12 +57,12 @@ public:
|
||||
QQuick3DCamera *camera() const;
|
||||
QRectF viewPortRect() const;
|
||||
|
||||
public Q_SLOTS:
|
||||
public slots:
|
||||
void setCamera(QQuick3DCamera *camera);
|
||||
void setViewPortRect(const QRectF &rect);
|
||||
void handleCameraPropertyChange();
|
||||
|
||||
Q_SIGNALS:
|
||||
signals:
|
||||
void cameraChanged();
|
||||
void viewPortRectChanged();
|
||||
|
||||
|
@@ -15,3 +15,8 @@ SOURCES += $$PWD/generalhelper.cpp \
|
||||
$$PWD/selectionboxgeometry.cpp \
|
||||
$$PWD/linegeometry.cpp \
|
||||
$$PWD/icongizmoimageprovider.cpp
|
||||
|
||||
versionAtLeast(QT_VERSION, 6.0.0) {
|
||||
HEADERS += $$PWD/qt5compat/qquick3darealight_p.h
|
||||
SOURCES += $$PWD/qt5compat/qquick3darealight.cpp
|
||||
}
|
||||
|
@@ -36,6 +36,7 @@
|
||||
#include <QtQuick3D/private/qquick3dmodel_p.h>
|
||||
#include <QtQuick3D/private/qquick3dviewport_p.h>
|
||||
#include <QtQuick3D/private/qquick3ddefaultmaterial_p.h>
|
||||
#include <QtQuick3D/private/qquick3dscenemanager_p.h>
|
||||
#include <QtQuick3DRuntimeRender/private/qssgrendercontextcore_p.h>
|
||||
#include <QtQuick3DRuntimeRender/private/qssgrenderbuffermanager_p.h>
|
||||
#include <QtQuick3DRuntimeRender/private/qssgrendermodel_p.h>
|
||||
@@ -166,7 +167,12 @@ QVector4D GeneralHelper::focusObjectToCamera(QQuick3DCamera *camera, float defau
|
||||
if (auto renderModel = static_cast<QSSGRenderModel *>(targetPriv->spatialNode)) {
|
||||
QWindow *window = static_cast<QWindow *>(viewPort->window());
|
||||
if (window) {
|
||||
auto context = QSSGRenderContextInterface::getRenderContextInterface(quintptr(window));
|
||||
QSSGRef<QSSGRenderContextInterface> context;
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
context = QSSGRenderContextInterface::getRenderContextInterface(quintptr(window));
|
||||
#else
|
||||
context = targetPriv->sceneManager->rci;
|
||||
#endif
|
||||
if (!context.isNull()) {
|
||||
QSSGBounds3 bounds;
|
||||
auto geometry = qobject_cast<SelectionBoxGeometry *>(modelNode->geometry());
|
||||
@@ -297,6 +303,16 @@ QString GeneralHelper::rootSizeKey() const
|
||||
return _rootSizeKey;
|
||||
}
|
||||
|
||||
double GeneralHelper::brightnessScaler() const
|
||||
{
|
||||
// Light brightness was rescaled in Qt6 from 100 -> 1.
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
return 100.;
|
||||
#else
|
||||
return 1.;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool GeneralHelper::isMacOS() const
|
||||
{
|
||||
#ifdef Q_OS_MACOS
|
||||
|
@@ -31,6 +31,7 @@
|
||||
#include <QtCore/qtimer.h>
|
||||
#include <QtCore/qhash.h>
|
||||
#include <QtCore/qpointer.h>
|
||||
#include <QtCore/qvariant.h>
|
||||
#include <QtGui/qvector3d.h>
|
||||
#include <QtGui/qmatrix4x4.h>
|
||||
|
||||
@@ -82,6 +83,8 @@ public:
|
||||
QString lastSceneIdKey() const;
|
||||
QString rootSizeKey() const;
|
||||
|
||||
Q_INVOKABLE double brightnessScaler() const;
|
||||
|
||||
bool isMacOS() const;
|
||||
|
||||
signals:
|
||||
|
@@ -41,6 +41,19 @@ GridGeometry::~GridGeometry()
|
||||
{
|
||||
}
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
QString GridGeometry::name() const
|
||||
{
|
||||
return objectName();
|
||||
}
|
||||
|
||||
void GridGeometry::setName(const QString &name)
|
||||
{
|
||||
setObjectName(name);
|
||||
emit nameChanged();
|
||||
}
|
||||
#endif
|
||||
|
||||
int GridGeometry::lines() const
|
||||
{
|
||||
return m_lines;
|
||||
|
@@ -41,6 +41,17 @@ class GridGeometry : public QQuick3DGeometry
|
||||
Q_PROPERTY(bool isCenterLine READ isCenterLine WRITE setIsCenterLine NOTIFY isCenterLineChanged)
|
||||
Q_PROPERTY(bool isSubdivision MEMBER m_isSubdivision)
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
// Name property was removed in Qt 6, so define it here for compatibility.
|
||||
// Name maps to object name.
|
||||
Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
|
||||
public:
|
||||
QString name() const;
|
||||
void setName(const QString &name);
|
||||
signals:
|
||||
void nameChanged();
|
||||
#endif
|
||||
|
||||
public:
|
||||
GridGeometry();
|
||||
~GridGeometry() override;
|
||||
@@ -49,12 +60,12 @@ public:
|
||||
float step() const;
|
||||
bool isCenterLine() const;
|
||||
|
||||
public Q_SLOTS:
|
||||
public slots:
|
||||
void setLines(int count);
|
||||
void setStep(float step);
|
||||
void setIsCenterLine(bool enabled);
|
||||
|
||||
Q_SIGNALS:
|
||||
signals:
|
||||
void linesChanged();
|
||||
void stepChanged();
|
||||
void isCenterLineChanged();
|
||||
|
@@ -45,6 +45,19 @@ LightGeometry::~LightGeometry()
|
||||
{
|
||||
}
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
QString LightGeometry::name() const
|
||||
{
|
||||
return objectName();
|
||||
}
|
||||
|
||||
void LightGeometry::setName(const QString &name)
|
||||
{
|
||||
setObjectName(name);
|
||||
emit nameChanged();
|
||||
}
|
||||
#endif
|
||||
|
||||
LightGeometry::LightType LightGeometry::lightType() const
|
||||
{
|
||||
return m_lightType;
|
||||
|
@@ -37,6 +37,17 @@ class LightGeometry : public QQuick3DGeometry
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(LightType lightType READ lightType WRITE setLightType NOTIFY lightTypeChanged)
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
// Name property was removed in Qt 6, so define it here for compatibility.
|
||||
// Name maps to object name.
|
||||
Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
|
||||
public:
|
||||
QString name() const;
|
||||
void setName(const QString &name);
|
||||
signals:
|
||||
void nameChanged();
|
||||
#endif
|
||||
|
||||
public:
|
||||
enum class LightType {
|
||||
Invalid,
|
||||
@@ -52,10 +63,10 @@ public:
|
||||
|
||||
LightType lightType() const;
|
||||
|
||||
public Q_SLOTS:
|
||||
public slots:
|
||||
void setLightType(LightType lightType);
|
||||
|
||||
Q_SIGNALS:
|
||||
signals:
|
||||
void lightTypeChanged();
|
||||
|
||||
protected:
|
||||
|
@@ -41,6 +41,19 @@ LineGeometry::~LineGeometry()
|
||||
{
|
||||
}
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
QString LineGeometry::name() const
|
||||
{
|
||||
return objectName();
|
||||
}
|
||||
|
||||
void LineGeometry::setName(const QString &name)
|
||||
{
|
||||
setObjectName(name);
|
||||
emit nameChanged();
|
||||
}
|
||||
#endif
|
||||
|
||||
QVector3D LineGeometry::startPos() const
|
||||
{
|
||||
return m_startPos;
|
||||
|
@@ -39,6 +39,17 @@ class LineGeometry : public QQuick3DGeometry
|
||||
Q_PROPERTY(QVector3D startPos READ startPos WRITE setStartPos NOTIFY startPosChanged)
|
||||
Q_PROPERTY(QVector3D endPos READ endPos WRITE setEndPos NOTIFY endPosChanged)
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
// Name property was removed in Qt 6, so define it here for compatibility.
|
||||
// Name maps to object name.
|
||||
Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
|
||||
public:
|
||||
QString name() const;
|
||||
void setName(const QString &name);
|
||||
signals:
|
||||
void nameChanged();
|
||||
#endif
|
||||
|
||||
public:
|
||||
LineGeometry();
|
||||
~LineGeometry() override;
|
||||
@@ -46,11 +57,11 @@ public:
|
||||
QVector3D startPos() const;
|
||||
QVector3D endPos() const;
|
||||
|
||||
public Q_SLOTS:
|
||||
public slots:
|
||||
void setStartPos(const QVector3D &pos);
|
||||
void setEndPos(const QVector3D &pos);
|
||||
|
||||
Q_SIGNALS:
|
||||
signals:
|
||||
void startPosChanged();
|
||||
void endPosChanged();
|
||||
|
||||
|
@@ -0,0 +1,59 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2020 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.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef QUICK3D_MODULE
|
||||
|
||||
#include "qquick3darealight_p.h"
|
||||
#include <QtQuick3D/private/qquick3dobject_p.h>
|
||||
|
||||
#include <QtQuick3DRuntimeRender/private/qssgrenderlight_p.h>
|
||||
|
||||
namespace QmlDesigner::Internal {
|
||||
|
||||
float QQuick3DAreaLight::width() const
|
||||
{
|
||||
return m_width;
|
||||
}
|
||||
|
||||
float QQuick3DAreaLight::height() const
|
||||
{
|
||||
return m_height;
|
||||
}
|
||||
|
||||
void QQuick3DAreaLight::setWidth(float width)
|
||||
{
|
||||
m_width = width;
|
||||
emit widthChanged();
|
||||
}
|
||||
|
||||
void QQuick3DAreaLight::setHeight(float height)
|
||||
{
|
||||
m_height = height;
|
||||
emit heightChanged();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
@@ -0,0 +1,66 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2020 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
|
||||
|
||||
#ifdef QUICK3D_MODULE
|
||||
|
||||
// This is a dummy class for Qt 5 compatibility purposes only
|
||||
|
||||
#include <QtQuick3D/private/qquick3dabstractlight_p.h>
|
||||
|
||||
namespace QmlDesigner::Internal {
|
||||
|
||||
class QQuick3DAreaLight : public QQuick3DAbstractLight
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(float width READ width WRITE setWidth NOTIFY widthChanged)
|
||||
Q_PROPERTY(float height READ height WRITE setHeight NOTIFY heightChanged)
|
||||
|
||||
public:
|
||||
QQuick3DAreaLight() : QQuick3DAbstractLight() {}
|
||||
~QQuick3DAreaLight() override {}
|
||||
|
||||
float width() const;
|
||||
float height() const;
|
||||
|
||||
public slots:
|
||||
void setWidth(float width);
|
||||
void setHeight(float height);
|
||||
|
||||
signals:
|
||||
void widthChanged();
|
||||
void heightChanged();
|
||||
|
||||
private:
|
||||
float m_width = 100.0f;
|
||||
float m_height = 100.0f;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
QML_DECLARE_TYPE(QmlDesigner::Internal::QQuick3DAreaLight)
|
||||
|
||||
#endif
|
@@ -32,6 +32,7 @@
|
||||
#include <QtQuick3DRuntimeRender/private/qssgrendercontextcore_p.h>
|
||||
#include <QtQuick3DRuntimeRender/private/qssgrenderbuffermanager_p.h>
|
||||
#include <QtQuick3D/private/qquick3dmodel_p.h>
|
||||
#include <QtQuick3D/private/qquick3dscenemanager_p.h>
|
||||
#include <QtQuick3D/qquick3dobject.h>
|
||||
#include <QtQuick/qquickwindow.h>
|
||||
#include <QtCore/qvector.h>
|
||||
@@ -59,6 +60,19 @@ SelectionBoxGeometry::~SelectionBoxGeometry()
|
||||
m_connections.clear();
|
||||
}
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
QString SelectionBoxGeometry::name() const
|
||||
{
|
||||
return objectName();
|
||||
}
|
||||
|
||||
void SelectionBoxGeometry::setName(const QString &name)
|
||||
{
|
||||
setObjectName(name);
|
||||
emit nameChanged();
|
||||
}
|
||||
#endif
|
||||
|
||||
QQuick3DNode *SelectionBoxGeometry::targetNode() const
|
||||
{
|
||||
return m_targetNode;
|
||||
@@ -291,8 +305,12 @@ void SelectionBoxGeometry::getBounds(
|
||||
if (auto renderModel = static_cast<QSSGRenderModel *>(renderNode)) {
|
||||
QWindow *window = static_cast<QWindow *>(m_view3D->window());
|
||||
if (window) {
|
||||
auto context = QSSGRenderContextInterface::getRenderContextInterface(
|
||||
quintptr(window));
|
||||
QSSGRef<QSSGRenderContextInterface> context;
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
context = QSSGRenderContextInterface::getRenderContextInterface(quintptr(window));
|
||||
#else
|
||||
context = QQuick3DObjectPrivate::get(this)->sceneManager->rci;
|
||||
#endif
|
||||
if (!context.isNull()) {
|
||||
auto bufferManager = context->bufferManager();
|
||||
QSSGBounds3 bounds = renderModel->getModelBounds(bufferManager);
|
||||
|
@@ -43,6 +43,17 @@ class SelectionBoxGeometry : public QQuick3DGeometry
|
||||
Q_PROPERTY(QQuick3DViewport *view3D READ view3D WRITE setView3D NOTIFY view3DChanged)
|
||||
Q_PROPERTY(bool isEmpty READ isEmpty NOTIFY isEmptyChanged)
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
// Name property was removed in Qt 6, so define it here for compatibility.
|
||||
// Name maps to object name.
|
||||
Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
|
||||
public:
|
||||
QString name() const;
|
||||
void setName(const QString &name);
|
||||
signals:
|
||||
void nameChanged();
|
||||
#endif
|
||||
|
||||
public:
|
||||
SelectionBoxGeometry();
|
||||
~SelectionBoxGeometry() override;
|
||||
@@ -54,12 +65,12 @@ public:
|
||||
|
||||
QSSGBounds3 bounds() const;
|
||||
|
||||
public Q_SLOTS:
|
||||
public slots:
|
||||
void setTargetNode(QQuick3DNode *targetNode);
|
||||
void setRootNode(QQuick3DNode *rootNode);
|
||||
void setView3D(QQuick3DViewport *view);
|
||||
|
||||
Q_SIGNALS:
|
||||
signals:
|
||||
void targetNodeChanged();
|
||||
void rootNodeChanged();
|
||||
void view3DChanged();
|
||||
|
@@ -58,75 +58,103 @@ IconRenderer::IconRenderer(int size, const QString &filePath, const QString &sou
|
||||
void IconRenderer::setupRender()
|
||||
{
|
||||
DesignerSupport::activateDesignerMode();
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
DesignerSupport::activateDesignerWindowManager();
|
||||
#endif
|
||||
|
||||
m_quickView = new QQuickView;
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
QSurfaceFormat surfaceFormat = m_quickView->requestedFormat();
|
||||
surfaceFormat.setVersion(4, 1);
|
||||
surfaceFormat.setProfile(QSurfaceFormat::CoreProfile);
|
||||
m_quickView->setFormat(surfaceFormat);
|
||||
|
||||
DesignerSupport::createOpenGLContext(m_quickView);
|
||||
#else
|
||||
m_quickView->setDefaultAlphaBuffer(true);
|
||||
m_quickView->setColor(Qt::transparent);
|
||||
m_ratio = m_quickView->devicePixelRatio();
|
||||
m_quickView->installEventFilter(this);
|
||||
#endif
|
||||
|
||||
QQmlComponent component(m_quickView->engine());
|
||||
component.loadUrl(QUrl::fromLocalFile(m_source));
|
||||
QObject *iconItem = component.create();
|
||||
|
||||
if (iconItem) {
|
||||
QQuickItem *containerItem = nullptr;
|
||||
bool is3D = false;
|
||||
#ifdef QUICK3D_MODULE
|
||||
if (auto scene = qobject_cast<QQuick3DNode *>(iconItem)) {
|
||||
qmlRegisterType<QmlDesigner::Internal::SelectionBoxGeometry>("SelectionBoxGeometry", 1, 0, "SelectionBoxGeometry");
|
||||
QQmlComponent component(m_quickView->engine());
|
||||
component.loadUrl(QUrl("qrc:/qtquickplugin/mockfiles/IconRenderer3D.qml"));
|
||||
containerItem = qobject_cast<QQuickItem *>(component.create());
|
||||
DesignerSupport::setRootItem(m_quickView, containerItem);
|
||||
m_containerItem = qobject_cast<QQuickItem *>(component.create());
|
||||
DesignerSupport::setRootItem(m_quickView, m_containerItem);
|
||||
|
||||
auto helper = new QmlDesigner::Internal::GeneralHelper();
|
||||
m_quickView->engine()->rootContext()->setContextProperty("_generalHelper", helper);
|
||||
|
||||
m_contentItem = QQmlProperty::read(containerItem, "view3D").value<QQuickItem *>();
|
||||
m_contentItem = QQmlProperty::read(m_containerItem, "view3D").value<QQuickItem *>();
|
||||
auto view3D = qobject_cast<QQuick3DViewport *>(m_contentItem);
|
||||
view3D->setImportScene(scene);
|
||||
is3D = true;
|
||||
m_is3D = true;
|
||||
} else
|
||||
#endif
|
||||
if (auto scene = qobject_cast<QQuickItem *>(iconItem)) {
|
||||
m_contentItem = scene;
|
||||
containerItem = new QQuickItem();
|
||||
containerItem->setSize(QSizeF(1024, 1024));
|
||||
DesignerSupport::setRootItem(m_quickView, containerItem);
|
||||
m_contentItem->setParentItem(containerItem);
|
||||
m_containerItem = new QQuickItem();
|
||||
m_containerItem->setSize(QSizeF(1024, 1024));
|
||||
DesignerSupport::setRootItem(m_quickView, m_containerItem);
|
||||
m_contentItem->setParentItem(m_containerItem);
|
||||
}
|
||||
|
||||
if (containerItem && m_contentItem) {
|
||||
m_contentItem->setSize(QSizeF(m_size, m_size));
|
||||
if (m_contentItem->width() > containerItem->width())
|
||||
containerItem->setWidth(m_contentItem->width());
|
||||
if (m_contentItem->height() > containerItem->height())
|
||||
containerItem->setHeight(m_contentItem->height());
|
||||
if (m_containerItem && m_contentItem) {
|
||||
resizeContent(m_size);
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
QTimer::singleShot(0, this, &IconRenderer::createIcon);
|
||||
#else
|
||||
m_quickView->show();
|
||||
m_quickView->lower();
|
||||
|
||||
QTimer::singleShot(0, this, [this, is3D, containerItem]() {
|
||||
// Failsafe to exit eventually if window fails to expose
|
||||
QTimer::singleShot(10000, qGuiApp, &QGuiApplication::quit);
|
||||
#endif
|
||||
} else {
|
||||
QTimer::singleShot(0, qGuiApp, &QGuiApplication::quit);
|
||||
}
|
||||
} else {
|
||||
QTimer::singleShot(0, qGuiApp, &QGuiApplication::quit);
|
||||
}
|
||||
}
|
||||
|
||||
bool IconRenderer::eventFilter(QObject *watched, QEvent *event)
|
||||
{
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
if (watched == m_quickView && event->type() == QEvent::Expose)
|
||||
QTimer::singleShot(0, this, &IconRenderer::createIcon);
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
void IconRenderer::createIcon()
|
||||
{
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
m_designerSupport.refFromEffectItem(m_quickView->rootObject(), false);
|
||||
#endif
|
||||
QQuickDesignerSupportItems::disableNativeTextRendering(m_quickView->rootObject());
|
||||
|
||||
#ifdef QUICK3D_MODULE
|
||||
if (is3D) {
|
||||
if (m_is3D) {
|
||||
// Render once to make sure scene is up to date before we set up the selection box
|
||||
render({});
|
||||
QMetaObject::invokeMethod(containerItem, "setSceneToBox");
|
||||
QMetaObject::invokeMethod(m_containerItem, "setSceneToBox");
|
||||
int tries = 0;
|
||||
while (tries < 10) {
|
||||
++tries;
|
||||
render({});
|
||||
QMetaObject::invokeMethod(containerItem, "fitAndHideBox");
|
||||
QMetaObject::invokeMethod(m_containerItem, "fitAndHideBox");
|
||||
}
|
||||
}
|
||||
#else
|
||||
Q_UNUSED(is3D)
|
||||
Q_UNUSED(containerItem)
|
||||
#endif
|
||||
QFileInfo fi(m_filePath);
|
||||
|
||||
@@ -134,7 +162,7 @@ void IconRenderer::setupRender()
|
||||
render(fi.absoluteFilePath());
|
||||
|
||||
// Render @2x image
|
||||
m_contentItem->setSize(QSizeF(m_size * 2, m_size * 2));
|
||||
resizeContent(m_size * 2);
|
||||
|
||||
QString saveFile;
|
||||
saveFile = fi.absolutePath() + '/' + fi.completeBaseName() + "@2x";
|
||||
@@ -147,13 +175,6 @@ void IconRenderer::setupRender()
|
||||
|
||||
// Allow little time for file operations to finish
|
||||
QTimer::singleShot(1000, qGuiApp, &QGuiApplication::quit);
|
||||
});
|
||||
} else {
|
||||
QTimer::singleShot(0, qGuiApp, &QGuiApplication::quit);
|
||||
}
|
||||
} else {
|
||||
QTimer::singleShot(0, qGuiApp, &QGuiApplication::quit);
|
||||
}
|
||||
}
|
||||
|
||||
void IconRenderer::render(const QString &fileName)
|
||||
@@ -163,14 +184,30 @@ void IconRenderer::render(const QString &fileName)
|
||||
const auto childItems = item->childItems();
|
||||
for (QQuickItem *childItem : childItems)
|
||||
updateNodesRecursive(childItem);
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
DesignerSupport::updateDirtyNode(item);
|
||||
#else
|
||||
if (item->flags() & QQuickItem::ItemHasContents)
|
||||
item->update();
|
||||
#endif
|
||||
};
|
||||
updateNodesRecursive(m_quickView->rootObject());
|
||||
|
||||
QRect rect(QPoint(), m_contentItem->size().toSize());
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
QImage renderImage = m_designerSupport.renderImageForItem(m_quickView->rootObject(),
|
||||
rect, rect.size());
|
||||
#else
|
||||
QImage renderImage = m_quickView->grabWindow();
|
||||
#endif
|
||||
if (!fileName.isEmpty()) {
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
if (m_ratio != 1.) {
|
||||
rect.setWidth(qRound(rect.size().width() * m_ratio));
|
||||
rect.setHeight(qRound(rect.size().height() * m_ratio));
|
||||
}
|
||||
renderImage = renderImage.copy(rect);
|
||||
#endif
|
||||
QFileInfo fi(fileName);
|
||||
if (fi.suffix().isEmpty())
|
||||
renderImage.save(fileName, "PNG");
|
||||
@@ -178,3 +215,17 @@ void IconRenderer::render(const QString &fileName)
|
||||
renderImage.save(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
void IconRenderer::resizeContent(int size)
|
||||
{
|
||||
int theSize = size;
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
if (m_ratio != 1.)
|
||||
theSize = qRound(qreal(size) / m_quickView->devicePixelRatio());
|
||||
#endif
|
||||
m_contentItem->setSize(QSizeF(theSize, theSize));
|
||||
if (m_contentItem->width() > m_containerItem->width())
|
||||
m_containerItem->setWidth(m_contentItem->width());
|
||||
if (m_contentItem->height() > m_containerItem->height())
|
||||
m_containerItem->setHeight(m_contentItem->height());
|
||||
}
|
||||
|
@@ -44,13 +44,21 @@ public:
|
||||
|
||||
void setupRender();
|
||||
|
||||
protected:
|
||||
bool eventFilter(QObject *watched, QEvent *event) override;
|
||||
|
||||
private:
|
||||
void createIcon();
|
||||
void render(const QString &fileName);
|
||||
void resizeContent(int size);
|
||||
|
||||
int m_size = 16;
|
||||
double m_ratio = 1.;
|
||||
QString m_filePath;
|
||||
QString m_source;
|
||||
QQuickView *m_quickView = nullptr;
|
||||
QQuickItem *m_contentItem = nullptr;
|
||||
QQuickItem *m_containerItem = nullptr;
|
||||
DesignerSupport m_designerSupport;
|
||||
bool m_is3D = false;
|
||||
};
|
||||
|
@@ -78,7 +78,6 @@
|
||||
#include <QDir>
|
||||
#include <QFileSystemWatcher>
|
||||
#include <QMetaType>
|
||||
#include <QMutableVectorIterator>
|
||||
#include <QQmlApplicationEngine>
|
||||
#include <QQmlComponent>
|
||||
#include <QQmlContext>
|
||||
@@ -1477,4 +1476,8 @@ void NodeInstanceServer::sheduleRootItemRender()
|
||||
}
|
||||
}
|
||||
|
||||
void NodeInstanceServer::initializeAuxiliaryViews()
|
||||
{
|
||||
}
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
@@ -253,6 +253,7 @@ protected:
|
||||
void setSlowRenderTimerInterval(int timerInterval);
|
||||
|
||||
virtual void initializeView() = 0;
|
||||
virtual void initializeAuxiliaryViews();
|
||||
virtual void setupScene(const CreateSceneCommand &command) = 0;
|
||||
void setTranslationLanguage(const QString &language);
|
||||
void loadDummyDataFiles(const QString& directory);
|
||||
|
@@ -76,6 +76,7 @@
|
||||
|
||||
#include <designersupportdelegate.h>
|
||||
#include <qmlprivategate.h>
|
||||
#include <quickitemnodeinstance.h>
|
||||
|
||||
#include <QVector3D>
|
||||
#include <QQmlProperty>
|
||||
@@ -92,6 +93,9 @@
|
||||
#include <QtQuick3D/private/qquick3dabstractlight_p.h>
|
||||
#include <QtQuick3D/private/qquick3dviewport_p.h>
|
||||
#include <QtQuick3D/private/qquick3dscenerootnode_p.h>
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
#include "../editor3d/qt5compat/qquick3darealight_p.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
namespace QmlDesigner {
|
||||
@@ -128,9 +132,14 @@ static bool imageHasContent(const QImage &image)
|
||||
QQuickView *Qt5InformationNodeInstanceServer::createAuxiliaryQuickView(const QUrl &url,
|
||||
QQuickItem *&rootItem)
|
||||
{
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
auto view = new QQuickView(quickView()->engine(), quickView());
|
||||
view->setFormat(quickView()->format());
|
||||
DesignerSupport::createOpenGLContext(view);
|
||||
#else
|
||||
auto view = new QQuickView(quickView()->engine(), nullptr);
|
||||
view->setFormat(quickView()->format());
|
||||
#endif
|
||||
QQmlComponent component(engine());
|
||||
component.loadUrl(url);
|
||||
rootItem = qobject_cast<QQuickItem *>(component.create());
|
||||
@@ -151,10 +160,13 @@ void Qt5InformationNodeInstanceServer::createEditView3D()
|
||||
qmlRegisterRevision<QQuick3DNode, 1>("MouseArea3D", 1, 0);
|
||||
qmlRegisterType<QmlDesigner::Internal::MouseArea3D>("MouseArea3D", 1, 0, "MouseArea3D");
|
||||
qmlRegisterType<QmlDesigner::Internal::CameraGeometry>("CameraGeometry", 1, 0, "CameraGeometry");
|
||||
qmlRegisterType<QmlDesigner::Internal::LightGeometry>("LightGeometry", 1, 0, "LightGeometry");
|
||||
qmlRegisterType<QmlDesigner::Internal::LightGeometry>("LightUtils", 1, 0, "LightGeometry");
|
||||
qmlRegisterType<QmlDesigner::Internal::GridGeometry>("GridGeometry", 1, 0, "GridGeometry");
|
||||
qmlRegisterType<QmlDesigner::Internal::SelectionBoxGeometry>("SelectionBoxGeometry", 1, 0, "SelectionBoxGeometry");
|
||||
qmlRegisterType<QmlDesigner::Internal::LineGeometry>("LineGeometry", 1, 0, "LineGeometry");
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
qmlRegisterType<QmlDesigner::Internal::QQuick3DAreaLight>("LightUtils", 1, 0, "AreaLight");
|
||||
#endif
|
||||
|
||||
auto helper = new QmlDesigner::Internal::GeneralHelper();
|
||||
QObject::connect(helper, &QmlDesigner::Internal::GeneralHelper::toolStateChanged,
|
||||
@@ -166,24 +178,8 @@ void Qt5InformationNodeInstanceServer::createEditView3D()
|
||||
|
||||
m_editView3D = createAuxiliaryQuickView(QUrl("qrc:/qtquickplugin/mockfiles/EditView3D.qml"), m_editView3DRootItem);
|
||||
|
||||
if (m_editView3DRootItem) {
|
||||
QObject::connect(m_editView3DRootItem, SIGNAL(selectionChanged(QVariant)),
|
||||
this, SLOT(handleSelectionChanged(QVariant)));
|
||||
QObject::connect(m_editView3DRootItem, SIGNAL(commitObjectProperty(QVariant, QVariant)),
|
||||
this, SLOT(handleObjectPropertyCommit(QVariant, QVariant)));
|
||||
QObject::connect(m_editView3DRootItem, SIGNAL(changeObjectProperty(QVariant, QVariant)),
|
||||
this, SLOT(handleObjectPropertyChange(QVariant, QVariant)));
|
||||
QObject::connect(m_editView3DRootItem, SIGNAL(notifyActiveSceneChange()),
|
||||
this, SLOT(handleActiveSceneChange()));
|
||||
QObject::connect(&m_propertyChangeTimer, &QTimer::timeout,
|
||||
this, &Qt5InformationNodeInstanceServer::handleObjectPropertyChangeTimeout);
|
||||
QObject::connect(&m_selectionChangeTimer, &QTimer::timeout,
|
||||
this, &Qt5InformationNodeInstanceServer::handleSelectionChangeTimeout);
|
||||
QObject::connect(&m_render3DEditViewTimer, &QTimer::timeout,
|
||||
this, &Qt5InformationNodeInstanceServer::doRender3DEditView);
|
||||
|
||||
if (m_editView3DRootItem)
|
||||
helper->setParent(m_editView3DRootItem);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -380,6 +376,9 @@ void Qt5InformationNodeInstanceServer::updateView3DRect(QObject *view3D)
|
||||
void Qt5InformationNodeInstanceServer::updateActiveSceneToEditView3D()
|
||||
{
|
||||
#ifdef QUICK3D_MODULE
|
||||
if (!m_editView3DSetupDone)
|
||||
return;
|
||||
|
||||
// Active scene change handling on qml side is async, so a deleted importScene would crash
|
||||
// editView when it updates next. Disable/enable edit view update synchronously to avoid this.
|
||||
QVariant activeSceneVar = objectToVariant(m_active3DScene);
|
||||
@@ -431,6 +430,9 @@ void Qt5InformationNodeInstanceServer::removeNode3D(QObject *node)
|
||||
void Qt5InformationNodeInstanceServer::resolveSceneRoots()
|
||||
{
|
||||
#ifdef QUICK3D_MODULE
|
||||
if (!m_editView3DSetupDone)
|
||||
return;
|
||||
|
||||
const auto oldMap = m_3DSceneMap;
|
||||
m_3DSceneMap.clear();
|
||||
auto it = oldMap.begin();
|
||||
@@ -477,15 +479,22 @@ ServerNodeInstance Qt5InformationNodeInstanceServer::active3DSceneInstance() con
|
||||
|
||||
void Qt5InformationNodeInstanceServer::updateNodesRecursive(QQuickItem *item)
|
||||
{
|
||||
for (QQuickItem *childItem : item->childItems())
|
||||
const auto childItems = item->childItems();
|
||||
for (QQuickItem *childItem : childItems)
|
||||
updateNodesRecursive(childItem);
|
||||
if (Internal::QuickItemNodeInstance::unifiedRenderPath()) {
|
||||
if (item->flags() & QQuickItem::ItemHasContents)
|
||||
item->update();
|
||||
} else {
|
||||
DesignerSupport::updateDirtyNode(item);
|
||||
}
|
||||
}
|
||||
|
||||
QQuickItem *Qt5InformationNodeInstanceServer::getContentItemForRendering(QQuickItem *rootItem)
|
||||
{
|
||||
QQuickItem *contentItem = QQmlProperty::read(rootItem, "contentItem").value<QQuickItem *>();
|
||||
if (contentItem) {
|
||||
if (!Internal::QuickItemNodeInstance::unifiedRenderPath())
|
||||
designerSupport()->refFromEffectItem(contentItem, false);
|
||||
QmlDesigner::Internal::QmlPrivateGate::disableNativeTextRendering(contentItem);
|
||||
}
|
||||
@@ -502,22 +511,32 @@ void Qt5InformationNodeInstanceServer::render3DEditView(int count)
|
||||
// render the 3D edit view and send the result to creator process
|
||||
void Qt5InformationNodeInstanceServer::doRender3DEditView()
|
||||
{
|
||||
if (m_editView3DRootItem) {
|
||||
if (m_editView3DSetupDone) {
|
||||
if (!m_editView3DContentItem)
|
||||
m_editView3DContentItem = getContentItemForRendering(m_editView3DRootItem);
|
||||
|
||||
QImage renderImage;
|
||||
|
||||
updateNodesRecursive(m_editView3DContentItem);
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
if (Internal::QuickItemNodeInstance::unifiedRenderPath()) {
|
||||
renderImage = m_editView3D->grabWindow();
|
||||
} else {
|
||||
// Fake render loop signaling to update things like QML items as 3D textures
|
||||
m_editView3D->beforeSynchronizing();
|
||||
m_editView3D->beforeRendering();
|
||||
|
||||
QSizeF size = qobject_cast<QQuickItem *>(m_editView3DContentItem)->size();
|
||||
QRectF renderRect(QPointF(0., 0.), size);
|
||||
QImage renderImage = designerSupport()->renderImageForItem(m_editView3DContentItem,
|
||||
renderImage = designerSupport()->renderImageForItem(m_editView3DContentItem,
|
||||
renderRect, size.toSize());
|
||||
|
||||
m_editView3D->afterRendering();
|
||||
}
|
||||
#else
|
||||
renderImage = m_editView3D->grabWindow();
|
||||
#endif
|
||||
|
||||
// There's no instance related to image, so instance id is -1.
|
||||
// Key number is selected so that it is unlikely to conflict other ImageContainer use.
|
||||
@@ -581,17 +600,28 @@ void Qt5InformationNodeInstanceServer::doRenderModelNode3DImageView()
|
||||
instanceObj = instance.internalObject();
|
||||
}
|
||||
QSize renderSize = m_modelNodePreviewImageCommand.size();
|
||||
if (Internal::QuickItemNodeInstance::unifiedRenderPath()) {
|
||||
// Requested size is already adjusted for target pixel ratio, so we have to adjust
|
||||
// back if ratio is not default for our window.
|
||||
double ratio = m_ModelNode3DImageView->devicePixelRatio();
|
||||
renderSize.setWidth(qRound(qreal(renderSize.width()) / ratio));
|
||||
renderSize.setHeight(qRound(qreal(renderSize.height()) / ratio));
|
||||
}
|
||||
|
||||
QMetaObject::invokeMethod(m_ModelNode3DImageViewRootItem, "createViewForObject",
|
||||
Q_ARG(QVariant, objectToVariant(instanceObj)),
|
||||
Q_ARG(QVariant, QVariant::fromValue(renderSize.width())),
|
||||
Q_ARG(QVariant, QVariant::fromValue(renderSize.height())));
|
||||
|
||||
|
||||
bool ready = false;
|
||||
int count = 0; // Ensure we don't ever get stuck in an infinite loop
|
||||
while (!ready && ++count < 10) {
|
||||
updateNodesRecursive(m_ModelNode3DImageViewContentItem);
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
if (Internal::QuickItemNodeInstance::unifiedRenderPath()) {
|
||||
renderImage = m_ModelNode3DImageView->grabWindow();
|
||||
} else {
|
||||
// Fake render loop signaling to update things like QML items as 3D textures
|
||||
m_ModelNode3DImageView->beforeSynchronizing();
|
||||
m_ModelNode3DImageView->beforeRendering();
|
||||
@@ -600,8 +630,12 @@ void Qt5InformationNodeInstanceServer::doRenderModelNode3DImageView()
|
||||
QRectF renderRect(QPointF(0., 0.), size);
|
||||
renderImage = designerSupport()->renderImageForItem(m_ModelNode3DImageViewContentItem,
|
||||
renderRect, size.toSize());
|
||||
m_ModelNode3DImageView->afterRendering();
|
||||
|
||||
m_ModelNode3DImageView->afterRendering();
|
||||
}
|
||||
#else
|
||||
renderImage = m_ModelNode3DImageView->grabWindow();
|
||||
#endif
|
||||
QMetaObject::invokeMethod(m_ModelNode3DImageViewRootItem, "afterRender");
|
||||
ready = QQmlProperty::read(m_ModelNode3DImageViewRootItem, "ready").value<bool>();
|
||||
}
|
||||
@@ -682,12 +716,23 @@ void Qt5InformationNodeInstanceServer::doRenderModelNode2DImageView()
|
||||
if (renderSize.isEmpty()) {
|
||||
renderSize = finalSize;
|
||||
renderRect = QRectF(QPointF(0., 0.), QSizeF(renderSize));
|
||||
instanceItem->setSize(renderSize);
|
||||
}
|
||||
m_ModelNode2DImageView->resize(renderSize);
|
||||
m_ModelNode2DImageViewRootItem->setSize(renderSize);
|
||||
m_ModelNode2DImageViewContentItem->setPosition(QPointF(-renderRect.x(), -renderRect.y()));
|
||||
|
||||
updateNodesRecursive(m_ModelNode2DImageViewContentItem);
|
||||
|
||||
renderImage = designerSupport()->renderImageForItem(m_ModelNode2DImageViewContentItem, renderRect, renderSize);
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
if (Internal::QuickItemNodeInstance::unifiedRenderPath()) {
|
||||
renderImage = m_ModelNode2DImageView->grabWindow();
|
||||
} else {
|
||||
renderImage = designerSupport()->renderImageForItem(m_ModelNode2DImageViewContentItem,
|
||||
renderRect, renderSize);
|
||||
}
|
||||
#else
|
||||
renderImage = m_ModelNode2DImageView->grabWindow();
|
||||
#endif
|
||||
|
||||
if (!imageHasContent(renderImage))
|
||||
renderImage = nonVisualComponentPreviewImage();
|
||||
@@ -721,6 +766,12 @@ Qt5InformationNodeInstanceServer::Qt5InformationNodeInstanceServer(NodeInstanceC
|
||||
m_renderModelNodeImageViewTimer.setSingleShot(true);
|
||||
}
|
||||
|
||||
Qt5InformationNodeInstanceServer::~Qt5InformationNodeInstanceServer()
|
||||
{
|
||||
for (auto view : qAsConst(m_view3Ds))
|
||||
QObject::disconnect(view, nullptr, this, nullptr);
|
||||
}
|
||||
|
||||
void Qt5InformationNodeInstanceServer::sendTokenBack()
|
||||
{
|
||||
foreach (const TokenCommand &command, m_tokenList)
|
||||
@@ -795,7 +846,7 @@ QList<ServerNodeInstance> Qt5InformationNodeInstanceServer::createInstances(
|
||||
{
|
||||
const auto createdInstances = NodeInstanceServer::createInstances(container);
|
||||
|
||||
if (m_editView3DRootItem) {
|
||||
if (m_editView3DSetupDone) {
|
||||
add3DViewPorts(createdInstances);
|
||||
add3DScenes(createdInstances);
|
||||
createCameraAndLightGizmos(createdInstances);
|
||||
@@ -806,6 +857,37 @@ QList<ServerNodeInstance> Qt5InformationNodeInstanceServer::createInstances(
|
||||
return createdInstances;
|
||||
}
|
||||
|
||||
void Qt5InformationNodeInstanceServer::initializeAuxiliaryViews()
|
||||
{
|
||||
#ifdef QUICK3D_MODULE
|
||||
if (qEnvironmentVariableIsSet("QMLDESIGNER_QUICK3D_MODE")) {
|
||||
createEditView3D();
|
||||
m_ModelNode3DImageView = createAuxiliaryQuickView(QUrl("qrc:/qtquickplugin/mockfiles/ModelNode3DImageView.qml"),
|
||||
m_ModelNode3DImageViewRootItem);
|
||||
}
|
||||
#endif
|
||||
|
||||
m_ModelNode2DImageView = createAuxiliaryQuickView(QUrl("qrc:/qtquickplugin/mockfiles/ModelNode2DImageView.qml"),
|
||||
m_ModelNode2DImageViewRootItem);
|
||||
m_ModelNode2DImageView->setDefaultAlphaBuffer(true);
|
||||
m_ModelNode2DImageView->setColor(Qt::transparent);
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
if (!m_editView3D.isNull()) {
|
||||
m_editView3D->show();
|
||||
m_editView3D->lower();
|
||||
}
|
||||
if (!m_ModelNode3DImageView.isNull()) {
|
||||
m_ModelNode3DImageView->show();
|
||||
m_ModelNode3DImageView->lower();
|
||||
}
|
||||
if (!m_ModelNode2DImageView.isNull()) {
|
||||
m_ModelNode2DImageView->show();
|
||||
m_ModelNode2DImageView->lower();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void Qt5InformationNodeInstanceServer::handleObjectPropertyChangeTimeout()
|
||||
{
|
||||
modifyVariantValue(m_changedNode, m_changedProperty,
|
||||
@@ -1028,14 +1110,28 @@ void Qt5InformationNodeInstanceServer::setup3DEditView(const QList<ServerNodeIns
|
||||
const QHash<QString, QVariantMap> &toolStates)
|
||||
{
|
||||
#ifdef QUICK3D_MODULE
|
||||
if (!m_editView3DRootItem)
|
||||
return;
|
||||
|
||||
ServerNodeInstance root = rootNodeInstance();
|
||||
|
||||
add3DViewPorts(instanceList);
|
||||
add3DScenes(instanceList);
|
||||
|
||||
createEditView3D();
|
||||
m_ModelNode3DImageView = createAuxiliaryQuickView(QUrl("qrc:/qtquickplugin/mockfiles/ModelNode3DImageView.qml"),
|
||||
m_ModelNode3DImageViewRootItem);
|
||||
QObject::connect(m_editView3DRootItem, SIGNAL(selectionChanged(QVariant)),
|
||||
this, SLOT(handleSelectionChanged(QVariant)));
|
||||
QObject::connect(m_editView3DRootItem, SIGNAL(commitObjectProperty(QVariant, QVariant)),
|
||||
this, SLOT(handleObjectPropertyCommit(QVariant, QVariant)));
|
||||
QObject::connect(m_editView3DRootItem, SIGNAL(changeObjectProperty(QVariant, QVariant)),
|
||||
this, SLOT(handleObjectPropertyChange(QVariant, QVariant)));
|
||||
QObject::connect(m_editView3DRootItem, SIGNAL(notifyActiveSceneChange()),
|
||||
this, SLOT(handleActiveSceneChange()));
|
||||
QObject::connect(&m_propertyChangeTimer, &QTimer::timeout,
|
||||
this, &Qt5InformationNodeInstanceServer::handleObjectPropertyChangeTimeout);
|
||||
QObject::connect(&m_selectionChangeTimer, &QTimer::timeout,
|
||||
this, &Qt5InformationNodeInstanceServer::handleSelectionChangeTimeout);
|
||||
QObject::connect(&m_render3DEditViewTimer, &QTimer::timeout,
|
||||
this, &Qt5InformationNodeInstanceServer::doRender3DEditView);
|
||||
|
||||
QString lastSceneId;
|
||||
auto helper = qobject_cast<QmlDesigner::Internal::GeneralHelper *>(m_3dHelper);
|
||||
@@ -1056,7 +1152,7 @@ void Qt5InformationNodeInstanceServer::setup3DEditView(const QList<ServerNodeIns
|
||||
// Find a scene to show
|
||||
m_active3DScene = nullptr;
|
||||
m_active3DView = nullptr;
|
||||
if (m_editView3DRootItem && !m_3DSceneMap.isEmpty()) {
|
||||
if (!m_3DSceneMap.isEmpty()) {
|
||||
// Restore the previous scene if possible
|
||||
if (!lastSceneId.isEmpty()) {
|
||||
const auto keys = m_3DSceneMap.uniqueKeys();
|
||||
@@ -1073,6 +1169,8 @@ void Qt5InformationNodeInstanceServer::setup3DEditView(const QList<ServerNodeIns
|
||||
}
|
||||
}
|
||||
|
||||
m_editView3DSetupDone = true;
|
||||
|
||||
if (toolStates.contains({})) {
|
||||
// Update tool state to an existing no-scene state before updating the active scene to
|
||||
// ensure the previous state is inherited properly in all cases.
|
||||
@@ -1175,7 +1273,7 @@ void Qt5InformationNodeInstanceServer::reparentInstances(const ReparentInstances
|
||||
|
||||
Qt5NodeInstanceServer::reparentInstances(command);
|
||||
|
||||
if (m_editView3DRootItem)
|
||||
if (m_editView3DSetupDone)
|
||||
resolveSceneRoots();
|
||||
|
||||
// Make sure selection is in sync after all reparentings are done
|
||||
@@ -1195,14 +1293,14 @@ void Qt5InformationNodeInstanceServer::createScene(const CreateSceneCommand &com
|
||||
Qt5NodeInstanceServer::createScene(command);
|
||||
|
||||
QList<ServerNodeInstance> instanceList;
|
||||
foreach (const InstanceContainer &container, command.instances()) {
|
||||
const auto instances = command.instances();
|
||||
for (const InstanceContainer &container : instances) {
|
||||
if (hasInstanceForId(container.instanceId())) {
|
||||
ServerNodeInstance instance = instanceForId(container.instanceId());
|
||||
if (instance.isValid()) {
|
||||
if (instance.isValid())
|
||||
instanceList.append(instance);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nodeInstanceClient()->informationChanged(createAllInformationChangedCommand(instanceList, true));
|
||||
nodeInstanceClient()->valuesChanged(createValuesChangedCommand(instanceList));
|
||||
@@ -1212,8 +1310,6 @@ void Qt5InformationNodeInstanceServer::createScene(const CreateSceneCommand &com
|
||||
if (qEnvironmentVariableIsSet("QMLDESIGNER_QUICK3D_MODE"))
|
||||
setup3DEditView(instanceList, command.edit3dToolStates());
|
||||
|
||||
m_ModelNode2DImageView = createAuxiliaryQuickView(QUrl("qrc:/qtquickplugin/mockfiles/ModelNode2DImageView.qml"),
|
||||
m_ModelNode2DImageViewRootItem);
|
||||
QObject::connect(&m_renderModelNodeImageViewTimer, &QTimer::timeout,
|
||||
this, &Qt5InformationNodeInstanceServer::doRenderModelNodeImageView);
|
||||
}
|
||||
@@ -1274,7 +1370,7 @@ void QmlDesigner::Qt5InformationNodeInstanceServer::removeSharedMemory(const Qml
|
||||
|
||||
void Qt5InformationNodeInstanceServer::changeSelection(const ChangeSelectionCommand &command)
|
||||
{
|
||||
if (!m_editView3DRootItem)
|
||||
if (!m_editView3DSetupDone)
|
||||
return;
|
||||
|
||||
m_lastSelectionChangeCommand = command;
|
||||
@@ -1380,7 +1476,7 @@ void Qt5InformationNodeInstanceServer::removeInstances(const RemoveInstancesComm
|
||||
resolveSceneRoots();
|
||||
}
|
||||
|
||||
if (m_editView3DRootItem && (!m_active3DScene || !m_active3DView)) {
|
||||
if (m_editView3DSetupDone && (!m_active3DScene || !m_active3DView)) {
|
||||
if (!m_active3DScene && !m_3DSceneMap.isEmpty())
|
||||
m_active3DScene = m_3DSceneMap.begin().key();
|
||||
m_active3DView = findView3DForSceneRoot(m_active3DScene);
|
||||
@@ -1417,6 +1513,9 @@ void Qt5InformationNodeInstanceServer::inputEvent(const InputEventCommand &comma
|
||||
|
||||
void Qt5InformationNodeInstanceServer::view3DAction(const View3DActionCommand &command)
|
||||
{
|
||||
if (!m_editView3DSetupDone)
|
||||
return;
|
||||
|
||||
QVariantMap updatedState;
|
||||
int renderCount = 1;
|
||||
|
||||
@@ -1486,6 +1585,7 @@ void Qt5InformationNodeInstanceServer::changeIds(const ChangeIdsCommand &command
|
||||
Qt5NodeInstanceServer::changeIds(command);
|
||||
|
||||
#ifdef QUICK3D_MODULE
|
||||
if (m_editView3DSetupDone) {
|
||||
ServerNodeInstance sceneInstance = active3DSceneInstance();
|
||||
if (m_active3DSceneUpdatePending) {
|
||||
const QString sceneId = sceneInstance.id();
|
||||
@@ -1503,6 +1603,7 @@ void Qt5InformationNodeInstanceServer::changeIds(const ChangeIdsCommand &command
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1525,7 +1626,7 @@ void Qt5InformationNodeInstanceServer::update3DViewState(const Update3dViewState
|
||||
{
|
||||
#ifdef QUICK3D_MODULE
|
||||
if (command.type() == Update3dViewStateCommand::SizeChange) {
|
||||
if (m_editView3DRootItem) {
|
||||
if (m_editView3DSetupDone) {
|
||||
m_editView3DRootItem->setSize(command.size());
|
||||
auto helper = qobject_cast<QmlDesigner::Internal::GeneralHelper *>(m_3dHelper);
|
||||
if (helper)
|
||||
|
@@ -49,6 +49,7 @@ class Qt5InformationNodeInstanceServer : public Qt5NodeInstanceServer
|
||||
|
||||
public:
|
||||
explicit Qt5InformationNodeInstanceServer(NodeInstanceClientInterface *nodeInstanceClient);
|
||||
~Qt5InformationNodeInstanceServer() override;
|
||||
|
||||
void reparentInstances(const ReparentInstancesCommand &command) override;
|
||||
void clearScene(const ClearSceneCommand &command) override;
|
||||
@@ -89,6 +90,7 @@ protected:
|
||||
void selectInstances(const QList<ServerNodeInstance> &instanceList);
|
||||
void modifyProperties(const QVector<InstancePropertyValueTriple> &properties);
|
||||
QList<ServerNodeInstance> createInstances(const QVector<InstanceContainer> &container) override;
|
||||
void initializeAuxiliaryViews() override;
|
||||
|
||||
private:
|
||||
void handleObjectPropertyChangeTimeout();
|
||||
@@ -129,6 +131,7 @@ private:
|
||||
QPointer<QQuickView> m_editView3D;
|
||||
QQuickItem *m_editView3DRootItem = nullptr;
|
||||
QQuickItem *m_editView3DContentItem = nullptr;
|
||||
bool m_editView3DSetupDone = false;
|
||||
QPointer<QQuickView> m_ModelNode3DImageView;
|
||||
QQuickItem *m_ModelNode3DImageViewRootItem = nullptr;
|
||||
QQuickItem *m_ModelNode3DImageViewContentItem = nullptr;
|
||||
|
@@ -81,6 +81,14 @@ void Qt5NodeInstanceServer::initializeView()
|
||||
QStringList customSelectors = QString::fromUtf8(qgetenv("QML_FILE_SELECTORS")).split(',');
|
||||
fileSelector->setExtraSelectors(customSelectors);
|
||||
}
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
// View needs to be shown for all puppets before any instances are created in case there is a View3D
|
||||
quickView()->show();
|
||||
quickView()->lower();
|
||||
#endif
|
||||
|
||||
initializeAuxiliaryViews();
|
||||
}
|
||||
|
||||
QQmlView *Qt5NodeInstanceServer::declarativeView() const
|
||||
|
@@ -147,11 +147,6 @@ void Qt5RenderNodeInstanceServer::createScene(const CreateSceneCommand &command)
|
||||
}
|
||||
|
||||
nodeInstanceClient()->pixmapChanged(createPixmapChangedCommand(instanceList));
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
#else
|
||||
quickView()->show();
|
||||
#endif
|
||||
}
|
||||
|
||||
void Qt5RenderNodeInstanceServer::clearScene(const ClearSceneCommand &command)
|
||||
|
@@ -262,10 +262,8 @@ QStringList QuickItemNodeInstance::allStates() const
|
||||
|
||||
void QuickItemNodeInstance::updateDirtyNode(QQuickItem *item)
|
||||
{
|
||||
if (s_unifiedRenderPath) {
|
||||
item->update();
|
||||
if (s_unifiedRenderPath)
|
||||
return;
|
||||
}
|
||||
DesignerSupport::updateDirtyNode(item);
|
||||
}
|
||||
|
||||
@@ -417,23 +415,24 @@ QImage QuickItemNodeInstance::renderImage() const
|
||||
static double devicePixelRatio = qgetenv("FORMEDITOR_DEVICE_PIXEL_RATIO").toDouble();
|
||||
size *= devicePixelRatio;
|
||||
|
||||
QImage renderImage;
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
if (s_unifiedRenderPath) {
|
||||
renderImage = nodeInstanceServer()->quickView()->grabWindow();
|
||||
} else {
|
||||
// Fake render loop signaling to update things like QML items as 3D textures
|
||||
nodeInstanceServer()->quickView()->beforeSynchronizing();
|
||||
nodeInstanceServer()->quickView()->beforeRendering();
|
||||
|
||||
QImage renderImage;
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
if (s_unifiedRenderPath)
|
||||
renderImage = nodeInstanceServer()->quickView()->grabWindow();
|
||||
else
|
||||
renderImage = designerSupport()->renderImageForItem(quickItem(), renderBoundingRect, size);
|
||||
|
||||
nodeInstanceServer()->quickView()->afterRendering();
|
||||
}
|
||||
#else
|
||||
renderImage = nodeInstanceServer()->quickView()->grabWindow();
|
||||
#endif
|
||||
|
||||
nodeInstanceServer()->quickView()->afterRendering();
|
||||
|
||||
renderImage.setDevicePixelRatio(devicePixelRatio);
|
||||
|
||||
return renderImage;
|
||||
@@ -447,27 +446,27 @@ QImage QuickItemNodeInstance::renderPreviewImage(const QSize &previewImageSize)
|
||||
static double devicePixelRatio = qgetenv("FORMEDITOR_DEVICE_PIXEL_RATIO").toDouble();
|
||||
const QSize size = previewImageSize * devicePixelRatio;
|
||||
if (quickItem()->isVisible()) {
|
||||
QImage image;
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
if (s_unifiedRenderPath) {
|
||||
image = nodeInstanceServer()->quickView()->grabWindow();
|
||||
} else {
|
||||
// Fake render loop signaling to update things like QML items as 3D textures
|
||||
nodeInstanceServer()->quickView()->beforeSynchronizing();
|
||||
nodeInstanceServer()->quickView()->beforeRendering();
|
||||
|
||||
QImage image;
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
if (s_unifiedRenderPath)
|
||||
image = nodeInstanceServer()->quickView()->grabWindow();
|
||||
else
|
||||
image = designerSupport()->renderImageForItem(quickItem(),
|
||||
previewItemBoundingRect,
|
||||
size);
|
||||
|
||||
nodeInstanceServer()->quickView()->afterRendering();
|
||||
}
|
||||
#else
|
||||
image = nodeInstanceServer()->quickView()->grabWindow();
|
||||
#endif
|
||||
|
||||
image = image.scaledToWidth(size.width());
|
||||
|
||||
nodeInstanceServer()->quickView()->afterRendering();
|
||||
|
||||
return image;
|
||||
} else {
|
||||
QImage transparentImage(size, QImage::Format_ARGB32_Premultiplied);
|
||||
@@ -686,7 +685,8 @@ void QuickItemNodeInstance::reparent(const ObjectNodeInstance::Pointer &oldParen
|
||||
|
||||
if (quickItem()->parentItem()) {
|
||||
refresh();
|
||||
DesignerSupport::updateDirtyNode(quickItem());
|
||||
|
||||
updateDirtyNode(quickItem());
|
||||
|
||||
if (instanceIsValidLayoutable(oldParentInstance, oldParentProperty))
|
||||
oldParentInstance->refreshLayoutable();
|
||||
|
@@ -31,8 +31,11 @@
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <qt5nodeinstanceclientproxy.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "iconrenderer/iconrenderer.h"
|
||||
#include <qt5nodeinstanceclientproxy.h>
|
||||
|
||||
#include <QQmlComponent>
|
||||
#include <QQmlEngine>
|
||||
@@ -46,6 +49,54 @@
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
void myMessageOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg)
|
||||
{
|
||||
QByteArray localMsg = msg.toLocal8Bit();
|
||||
switch (type) {
|
||||
case QtDebugMsg:
|
||||
fprintf(stderr,
|
||||
"Debug: %s (%s:%u, %s)\n",
|
||||
localMsg.constData(),
|
||||
context.file,
|
||||
context.line,
|
||||
context.function);
|
||||
break;
|
||||
case QtInfoMsg:
|
||||
fprintf(stderr,
|
||||
"Info: %s (%s:%u, %s)\n",
|
||||
localMsg.constData(),
|
||||
context.file,
|
||||
context.line,
|
||||
context.function);
|
||||
break;
|
||||
case QtWarningMsg:
|
||||
fprintf(stderr,
|
||||
"Warning: %s (%s:%u, %s)\n",
|
||||
localMsg.constData(),
|
||||
context.file,
|
||||
context.line,
|
||||
context.function);
|
||||
break;
|
||||
case QtCriticalMsg:
|
||||
fprintf(stderr,
|
||||
"Critical: %s (%s:%u, %s)\n",
|
||||
localMsg.constData(),
|
||||
context.file,
|
||||
context.line,
|
||||
context.function);
|
||||
break;
|
||||
case QtFatalMsg:
|
||||
fprintf(stderr,
|
||||
"Fatal: %s (%s:%u, %s)\n",
|
||||
localMsg.constData(),
|
||||
context.file,
|
||||
context.line,
|
||||
context.function);
|
||||
abort();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
int internalMain(QGuiApplication *application)
|
||||
{
|
||||
@@ -144,6 +195,9 @@ int internalMain(QGuiApplication *application)
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
qInstallMessageHandler(myMessageOutput);
|
||||
#endif
|
||||
// Since we always render text into an FBO, we need to globally disable
|
||||
// subpixel antialiasing and instead use gray.
|
||||
qputenv("QSG_DISTANCEFIELD_ANTIALIASING", "gray");
|
||||
|
@@ -92,7 +92,7 @@ void Edit3DCanvas::paintEvent(QPaintEvent *e)
|
||||
|
||||
QPainter painter(this);
|
||||
|
||||
painter.drawImage(rect(), m_image, rect());
|
||||
painter.drawImage(rect(), m_image, QRect(0, 0, m_image.width(), m_image.height()));
|
||||
}
|
||||
|
||||
void Edit3DCanvas::resizeEvent(QResizeEvent *e)
|
||||
|
@@ -137,6 +137,14 @@ extend_qtc_executable(qml2puppet
|
||||
icongizmoimageprovider.cpp icongizmoimageprovider.h
|
||||
)
|
||||
|
||||
extend_qtc_executable(qml2puppet
|
||||
CONDITION Qt5_VERSION VERSION_GREATER_EQUAL 6.0.0
|
||||
|
||||
SOURCES_PREFIX "${SRCDIR}/qml2puppet/editor3d/qt5compat"
|
||||
SOURCES
|
||||
qquick3darealight.cpp qquick3darealight_p.h
|
||||
)
|
||||
|
||||
extend_qtc_executable(qml2puppet
|
||||
SOURCES_PREFIX "${SRCDIR}/qml2puppet/iconrenderer"
|
||||
SOURCES
|
||||
|
@@ -19,6 +19,8 @@ QtcTool {
|
||||
property bool useQuick3d: Utilities.versionCompare(Qt.core.version, "5.15") >= 0
|
||||
&& Qt["quick3d-private"].present
|
||||
|
||||
property bool useQt5Compat: Utilities.versionCompare(Qt.core.version, "6.0") >= 0
|
||||
|
||||
cpp.defines: {
|
||||
var defines = base.filter(function(d) { return d != "QT_CREATOR"; });
|
||||
if (useQuick3d)
|
||||
@@ -258,6 +260,20 @@ QtcTool {
|
||||
fileTags: product.useQuick3d ? [] : ["unmocable"]
|
||||
overrideTags: false
|
||||
}
|
||||
|
||||
Group {
|
||||
name: "puppet2 Qt 5 compatibility sources"
|
||||
condition: useQt5Compat
|
||||
files: ["editor3d/qt5compat/qquick3darealight.cpp"]
|
||||
}
|
||||
|
||||
Group {
|
||||
name: "puppet2 Qt 5 compatibility headers"
|
||||
condition: useQt5Compat
|
||||
files: ["editor3d/qt5compat/qquick3darealight_p.h"]
|
||||
fileTags: product.useQuick3d ? [] : ["unmocable"]
|
||||
overrideTags: false
|
||||
}
|
||||
}
|
||||
|
||||
Group {
|
||||
|
Reference in New Issue
Block a user