aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiikka Heikkinen <miikka.heikkinen@qt.io>2020-10-08 10:50:15 +0300
committerMiikka Heikkinen <miikka.heikkinen@qt.io>2020-10-20 14:55:43 +0000
commit6b8d8e414ac45ed74fd3968da9525c704178eae8 (patch)
tree87bb5bf65d562eccddc2aeeb5f85d3583f730694
parent49a8266d5869d221b16066378ad89ff7cb105e70 (diff)
QmlDesigner: Port 3D edit view to Qt6
Task-number: QDS-2899 Change-Id: Iedbe5e8561e5ab71ef32922e69da43cd3cc57e90 Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
-rw-r--r--share/qtcreator/qml/qmlpuppet/commands/valueschangedcommand.cpp4
-rw-r--r--share/qtcreator/qml/qmlpuppet/mockfiles/EditView3D.qml28
-rw-r--r--share/qtcreator/qml/qmlpuppet/mockfiles/LightGizmo.qml16
-rw-r--r--share/qtcreator/qml/qmlpuppet/mockfiles/LightIconGizmo.qml1
-rw-r--r--share/qtcreator/qml/qmlpuppet/mockfiles/LightModel.qml2
-rw-r--r--share/qtcreator/qml/qmlpuppet/mockfiles/ModelNode2DImageView.qml7
-rw-r--r--share/qtcreator/qml/qmlpuppet/mockfiles/ModelNode3DImageView.qml5
-rw-r--r--share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/camerageometry.cpp22
-rw-r--r--share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/camerageometry.h15
-rw-r--r--share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/editor3d.pri5
-rw-r--r--share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/generalhelper.cpp18
-rw-r--r--share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/generalhelper.h3
-rw-r--r--share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/gridgeometry.cpp13
-rw-r--r--share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/gridgeometry.h15
-rw-r--r--share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/lightgeometry.cpp13
-rw-r--r--share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/lightgeometry.h15
-rw-r--r--share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/linegeometry.cpp13
-rw-r--r--share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/linegeometry.h15
-rw-r--r--share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/qt5compat/qquick3darealight.cpp59
-rw-r--r--share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/qt5compat/qquick3darealight_p.h66
-rw-r--r--share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/selectionboxgeometry.cpp22
-rw-r--r--share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/selectionboxgeometry.h15
-rw-r--r--share/qtcreator/qml/qmlpuppet/qml2puppet/iconrenderer/iconrenderer.cpp157
-rw-r--r--share/qtcreator/qml/qmlpuppet/qml2puppet/iconrenderer/iconrenderer.h8
-rw-r--r--share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstanceserver.cpp5
-rw-r--r--share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstanceserver.h1
-rw-r--r--share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.cpp239
-rw-r--r--share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.h3
-rw-r--r--share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5nodeinstanceserver.cpp8
-rw-r--r--share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5rendernodeinstanceserver.cpp5
-rw-r--r--share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickitemnodeinstance.cpp40
-rw-r--r--share/qtcreator/qml/qmlpuppet/qml2puppet/qml2puppetmain.cpp56
-rw-r--r--src/plugins/qmldesigner/components/edit3d/edit3dcanvas.cpp2
-rw-r--r--src/tools/qml2puppet/CMakeLists.txt8
-rw-r--r--src/tools/qml2puppet/qml2puppet.qbs16
35 files changed, 740 insertions, 180 deletions
diff --git a/share/qtcreator/qml/qmlpuppet/commands/valueschangedcommand.cpp b/share/qtcreator/qml/qmlpuppet/commands/valueschangedcommand.cpp
index 18370be9fc..530447cb94 100644
--- a/share/qtcreator/qml/qmlpuppet/commands/valueschangedcommand.cpp
+++ b/share/qtcreator/qml/qmlpuppet/commands/valueschangedcommand.cpp
@@ -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;
diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/EditView3D.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/EditView3D.qml
index 95245aae5e..2842d70637 100644
--- a/share/qtcreator/qml/qmlpuppet/mockfiles/EditView3D.qml
+++ b/share/qtcreator/qml/qmlpuppet/mockfiles/EditView3D.qml
@@ -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");
diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/LightGizmo.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/LightGizmo.qml
index 2e9791dc28..b69884cb7d 100644
--- a/share/qtcreator/qml/qmlpuppet/mockfiles/LightGizmo.qml
+++ b/share/qtcreator/qml/qmlpuppet/mockfiles/LightGizmo.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;
}
diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/LightIconGizmo.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/LightIconGizmo.qml
index 6f0d426c1f..8cbce4d1d9 100644
--- a/share/qtcreator/qml/qmlpuppet/mockfiles/LightIconGizmo.qml
+++ b/share/qtcreator/qml/qmlpuppet/mockfiles/LightIconGizmo.qml
@@ -25,6 +25,7 @@
import QtQuick 2.0
import QtQuick3D 1.15
+import LightUtils 1.0
IconGizmo {
id: lightIconGizmo
diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/LightModel.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/LightModel.qml
index 9ccb3c49ae..3e42760ca1 100644
--- a/share/qtcreator/qml/qmlpuppet/mockfiles/LightModel.qml
+++ b/share/qtcreator/qml/qmlpuppet/mockfiles/LightModel.qml
@@ -25,7 +25,7 @@
import QtQuick 2.0
import QtQuick3D 1.15
-import LightGeometry 1.0
+import LightUtils 1.0
Model {
id: lightModel
diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/ModelNode2DImageView.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/ModelNode2DImageView.qml
index c4bd31d7e7..2302547715 100644
--- a/share/qtcreator/qml/qmlpuppet/mockfiles/ModelNode2DImageView.qml
+++ b/share/qtcreator/qml/qmlpuppet/mockfiles/ModelNode2DImageView.qml
@@ -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
}
}
diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/ModelNode3DImageView.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/ModelNode3DImageView.qml
index 277bc8431f..c09275b32e 100644
--- a/share/qtcreator/qml/qmlpuppet/mockfiles/ModelNode3DImageView.qml
+++ b/share/qtcreator/qml/qmlpuppet/mockfiles/ModelNode3DImageView.qml
@@ -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
diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/camerageometry.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/camerageometry.cpp
index 9c81fdc970..0fbc28c6b5 100644
--- a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/camerageometry.cpp
+++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/camerageometry.cpp
@@ -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();
}
diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/camerageometry.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/camerageometry.h
index 73722cd7a1..55d31ca389 100644
--- a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/camerageometry.h
+++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/camerageometry.h
@@ -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();
diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/editor3d.pri b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/editor3d.pri
index 755aef73e2..bcfbc5e12e 100644
--- a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/editor3d.pri
+++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/editor3d.pri
@@ -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
+}
diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/generalhelper.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/generalhelper.cpp
index afa02625d4..6222c84ce7 100644
--- a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/generalhelper.cpp
+++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/generalhelper.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
diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/generalhelper.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/generalhelper.h
index 92893cc546..f162eb0d30 100644
--- a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/generalhelper.h
+++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/generalhelper.h
@@ -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:
diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/gridgeometry.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/gridgeometry.cpp
index 4b548239ca..66a2a6b2a5 100644
--- a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/gridgeometry.cpp
+++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/gridgeometry.cpp
@@ -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;
diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/gridgeometry.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/gridgeometry.h
index 50b41288e2..6074fb4245 100644
--- a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/gridgeometry.h
+++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/gridgeometry.h
@@ -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();
diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/lightgeometry.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/lightgeometry.cpp
index cebf3232f1..2facb77139 100644
--- a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/lightgeometry.cpp
+++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/lightgeometry.cpp
@@ -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;
diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/lightgeometry.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/lightgeometry.h
index cac375d675..e9ba718218 100644
--- a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/lightgeometry.h
+++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/lightgeometry.h
@@ -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:
diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/linegeometry.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/linegeometry.cpp
index cd2e890f86..5b6110d2af 100644
--- a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/linegeometry.cpp
+++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/linegeometry.cpp
@@ -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;
diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/linegeometry.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/linegeometry.h
index 2e87ff8748..df83f89b25 100644
--- a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/linegeometry.h
+++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/linegeometry.h
@@ -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();
diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/qt5compat/qquick3darealight.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/qt5compat/qquick3darealight.cpp
new file mode 100644
index 0000000000..6fcbdcb89e
--- /dev/null
+++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/qt5compat/qquick3darealight.cpp
@@ -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
diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/qt5compat/qquick3darealight_p.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/qt5compat/qquick3darealight_p.h
new file mode 100644
index 0000000000..8db5487960
--- /dev/null
+++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/qt5compat/qquick3darealight_p.h
@@ -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
diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/selectionboxgeometry.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/selectionboxgeometry.cpp
index 621508c499..1e1fe8937c 100644
--- a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/selectionboxgeometry.cpp
+++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/selectionboxgeometry.cpp
@@ -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);
diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/selectionboxgeometry.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/selectionboxgeometry.h
index 6cf9a153c2..947ef7d54a 100644
--- a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/selectionboxgeometry.h
+++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/selectionboxgeometry.h
@@ -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();
diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/iconrenderer/iconrenderer.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/iconrenderer/iconrenderer.cpp
index 54ba6bed07..cb9d867b0f 100644
--- a/share/qtcreator/qml/qmlpuppet/qml2puppet/iconrenderer/iconrenderer.cpp
+++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/iconrenderer/iconrenderer.cpp
@@ -58,102 +58,123 @@ 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]() {
- m_designerSupport.refFromEffectItem(m_quickView->rootObject(), false);
- QQuickDesignerSupportItems::disableNativeTextRendering(m_quickView->rootObject());
+ // 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) {
- // Render once to make sure scene is up to date before we set up the selection box
- render({});
- QMetaObject::invokeMethod(containerItem, "setSceneToBox");
- int tries = 0;
- while (tries < 10) {
- ++tries;
- render({});
- QMetaObject::invokeMethod(containerItem, "fitAndHideBox");
- }
- }
-#else
- Q_UNUSED(is3D)
- Q_UNUSED(containerItem)
+ if (m_is3D) {
+ // Render once to make sure scene is up to date before we set up the selection box
+ render({});
+ QMetaObject::invokeMethod(m_containerItem, "setSceneToBox");
+ int tries = 0;
+ while (tries < 10) {
+ ++tries;
+ render({});
+ QMetaObject::invokeMethod(m_containerItem, "fitAndHideBox");
+ }
+ }
#endif
- QFileInfo fi(m_filePath);
+ QFileInfo fi(m_filePath);
- // Render regular size image
- render(fi.absoluteFilePath());
+ // Render regular size image
+ render(fi.absoluteFilePath());
- // Render @2x image
- m_contentItem->setSize(QSizeF(m_size * 2, m_size * 2));
+ // Render @2x image
+ resizeContent(m_size * 2);
- QString saveFile;
- saveFile = fi.absolutePath() + '/' + fi.completeBaseName() + "@2x";
- if (!fi.suffix().isEmpty())
- saveFile += '.' + fi.suffix();
+ QString saveFile;
+ saveFile = fi.absolutePath() + '/' + fi.completeBaseName() + "@2x";
+ if (!fi.suffix().isEmpty())
+ saveFile += '.' + fi.suffix();
- fi.absoluteDir().mkpath(".");
+ fi.absoluteDir().mkpath(".");
- render(saveFile);
+ render(saveFile);
- // 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);
- }
+ // Allow little time for file operations to finish
+ QTimer::singleShot(1000, 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());
+}
diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/iconrenderer/iconrenderer.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/iconrenderer/iconrenderer.h
index f7bab0f6fc..64afed6f8a 100644
--- a/share/qtcreator/qml/qmlpuppet/qml2puppet/iconrenderer/iconrenderer.h
+++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/iconrenderer/iconrenderer.h
@@ -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;
};
diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstanceserver.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstanceserver.cpp
index 183f036bf7..ece608fdc9 100644
--- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstanceserver.cpp
+++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstanceserver.cpp
@@ -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
diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstanceserver.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstanceserver.h
index d5726a31f6..78e35d98a9 100644
--- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstanceserver.h
+++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstanceserver.h
@@ -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);
diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.cpp
index ecd066d16c..94702ed609 100644
--- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.cpp
+++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.cpp
@@ -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,16 +479,23 @@ 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);
- DesignerSupport::updateDirtyNode(item);
+ 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) {
- designerSupport()->refFromEffectItem(contentItem, false);
+ if (!Internal::QuickItemNodeInstance::unifiedRenderPath())
+ designerSupport()->refFromEffectItem(contentItem, false);
QmlDesigner::Internal::QmlPrivateGate::disableNativeTextRendering(contentItem);
}
return 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);
- // Fake render loop signaling to update things like QML items as 3D textures
- m_editView3D->beforeSynchronizing();
- m_editView3D->beforeRendering();
+#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,
- renderRect, size.toSize());
+ QSizeF size = qobject_cast<QQuickItem *>(m_editView3DContentItem)->size();
+ QRectF renderRect(QPointF(0., 0.), size);
+ renderImage = designerSupport()->renderImageForItem(m_editView3DContentItem,
+ renderRect, size.toSize());
- m_editView3D->afterRendering();
+ 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,27 +600,42 @@ 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();
- // Fake render loop signaling to update things like QML items as 3D textures
- m_ModelNode3DImageView->beforeSynchronizing();
- m_ModelNode3DImageView->beforeRendering();
-
- QSizeF size = qobject_cast<QQuickItem *>(m_ModelNode3DImageViewContentItem)->size();
- QRectF renderRect(QPointF(0., 0.), size);
- renderImage = designerSupport()->renderImageForItem(m_ModelNode3DImageViewContentItem,
- renderRect, size.toSize());
- m_ModelNode3DImageView->afterRendering();
+ QSizeF size = qobject_cast<QQuickItem *>(m_ModelNode3DImageViewContentItem)->size();
+ QRectF renderRect(QPointF(0., 0.), size);
+ renderImage = designerSupport()->renderImageForItem(m_ModelNode3DImageViewContentItem,
+ renderRect, size.toSize());
+ 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,12 +1293,12 @@ 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);
- }
}
}
@@ -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,20 +1585,22 @@ void Qt5InformationNodeInstanceServer::changeIds(const ChangeIdsCommand &command
Qt5NodeInstanceServer::changeIds(command);
#ifdef QUICK3D_MODULE
- ServerNodeInstance sceneInstance = active3DSceneInstance();
- if (m_active3DSceneUpdatePending) {
- const QString sceneId = sceneInstance.id();
- if (!sceneId.isEmpty())
- updateActiveSceneToEditView3D();
- } else {
- qint32 sceneInstanceId = sceneInstance.instanceId();
- for (const auto &id : command.ids) {
- if (sceneInstanceId == id.instanceId()) {
- QMetaObject::invokeMethod(m_editView3DRootItem, "handleActiveSceneIdChange",
- Qt::QueuedConnection,
- Q_ARG(QVariant, QVariant(sceneInstance.id())));
- render3DEditView();
- break;
+ if (m_editView3DSetupDone) {
+ ServerNodeInstance sceneInstance = active3DSceneInstance();
+ if (m_active3DSceneUpdatePending) {
+ const QString sceneId = sceneInstance.id();
+ if (!sceneId.isEmpty())
+ updateActiveSceneToEditView3D();
+ } else {
+ qint32 sceneInstanceId = sceneInstance.instanceId();
+ for (const auto &id : command.ids) {
+ if (sceneInstanceId == id.instanceId()) {
+ QMetaObject::invokeMethod(m_editView3DRootItem, "handleActiveSceneIdChange",
+ Qt::QueuedConnection,
+ Q_ARG(QVariant, QVariant(sceneInstance.id())));
+ render3DEditView();
+ break;
+ }
}
}
}
@@ -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)
diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.h
index 881e676915..8f3af1ccdb 100644
--- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.h
+++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.h
@@ -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;
diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5nodeinstanceserver.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5nodeinstanceserver.cpp
index c2015299c5..3cc541545e 100644
--- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5nodeinstanceserver.cpp
+++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5nodeinstanceserver.cpp
@@ -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
diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5rendernodeinstanceserver.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5rendernodeinstanceserver.cpp
index fd3446f396..9722280dfa 100644
--- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5rendernodeinstanceserver.cpp
+++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5rendernodeinstanceserver.cpp
@@ -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)
diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickitemnodeinstance.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickitemnodeinstance.cpp
index 1f54bffdbd..1c08b408e6 100644
--- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickitemnodeinstance.cpp
+++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickitemnodeinstance.cpp
@@ -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;
- // 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)
+ if (s_unifiedRenderPath) {
renderImage = nodeInstanceServer()->quickView()->grabWindow();
- else
+ } else {
+ // Fake render loop signaling to update things like QML items as 3D textures
+ nodeInstanceServer()->quickView()->beforeSynchronizing();
+ nodeInstanceServer()->quickView()->beforeRendering();
+
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()) {
- // 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)
+ if (s_unifiedRenderPath) {
image = nodeInstanceServer()->quickView()->grabWindow();
- else
+ } else {
+ // Fake render loop signaling to update things like QML items as 3D textures
+ nodeInstanceServer()->quickView()->beforeSynchronizing();
+ nodeInstanceServer()->quickView()->beforeRendering();
+
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();
diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/qml2puppetmain.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/qml2puppetmain.cpp
index 1f94bc3e59..cd2877a4f5 100644
--- a/share/qtcreator/qml/qmlpuppet/qml2puppet/qml2puppetmain.cpp
+++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/qml2puppetmain.cpp
@@ -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");
diff --git a/src/plugins/qmldesigner/components/edit3d/edit3dcanvas.cpp b/src/plugins/qmldesigner/components/edit3d/edit3dcanvas.cpp
index 91aa006299..de3757e68c 100644
--- a/src/plugins/qmldesigner/components/edit3d/edit3dcanvas.cpp
+++ b/src/plugins/qmldesigner/components/edit3d/edit3dcanvas.cpp
@@ -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)
diff --git a/src/tools/qml2puppet/CMakeLists.txt b/src/tools/qml2puppet/CMakeLists.txt
index 85809020d8..1dbdd5b7fa 100644
--- a/src/tools/qml2puppet/CMakeLists.txt
+++ b/src/tools/qml2puppet/CMakeLists.txt
@@ -138,6 +138,14 @@ extend_qtc_executable(qml2puppet
)
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
iconrenderer.cpp iconrenderer.h
diff --git a/src/tools/qml2puppet/qml2puppet.qbs b/src/tools/qml2puppet/qml2puppet.qbs
index 742c20406e..63341b5dc2 100644
--- a/src/tools/qml2puppet/qml2puppet.qbs
+++ b/src/tools/qml2puppet/qml2puppet.qbs
@@ -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 {