From c342d3f32165d77538b69392d6107249af37d7d5 Mon Sep 17 00:00:00 2001
From: Mats Honkamaa
Date: Tue, 27 Dec 2022 10:28:41 +0200
Subject: [PATCH 01/28] Doc: Remove confusing word
Task-number: QDS-8248
Change-Id: I0f3fe1c6f3437b6fe1c29df4606aa2f8abb7c24b
Reviewed-by: Leena Miettinen
---
.../src/qtquick3d-editor/qtdesignstudio-3d-lights.qdoc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/doc/qtdesignstudio/src/qtquick3d-editor/qtdesignstudio-3d-lights.qdoc b/doc/qtdesignstudio/src/qtquick3d-editor/qtdesignstudio-3d-lights.qdoc
index f2063e6a05c..6d1fbc5bd1f 100644
--- a/doc/qtdesignstudio/src/qtquick3d-editor/qtdesignstudio-3d-lights.qdoc
+++ b/doc/qtdesignstudio/src/qtquick3d-editor/qtdesignstudio-3d-lights.qdoc
@@ -181,7 +181,7 @@
Aside from the size, an area light has the same properties as a directional
light.
- The image below shows an example on how to light a component with different
+ The image shows an example on how to light a component with different
colors using two different area lights.
You can rotate, scale, and move area lights.
From 9a335c9f670fbddb3200df8f8bce3fc17f7acb39 Mon Sep 17 00:00:00 2001
From: Mats Honkamaa
Date: Tue, 27 Dec 2022 12:57:58 +0200
Subject: [PATCH 02/28] Doc: Fix typo
Task-number: QDS-8197
Change-Id: Iaf6ad34bf64273574daa715da522fe90a2010976
Reviewed-by: Leena Miettinen
---
.../src/qtquick3d-editor/qtdesignstudio-3d-view.qdoc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/doc/qtdesignstudio/src/qtquick3d-editor/qtdesignstudio-3d-view.qdoc b/doc/qtdesignstudio/src/qtquick3d-editor/qtdesignstudio-3d-view.qdoc
index 8d001071cb7..5f2f53ca96e 100644
--- a/doc/qtdesignstudio/src/qtquick3d-editor/qtdesignstudio-3d-view.qdoc
+++ b/doc/qtdesignstudio/src/qtquick3d-editor/qtdesignstudio-3d-view.qdoc
@@ -32,7 +32,7 @@
By default, a directional light and a perspective camera are used in a 3D
scene created by using the wizard template mentioned above. To use other
light and camera types, select the component in the \uicontrol{3D} or
- \uicontrol Navigatorn view and change the type of the component in the \uicontrol
+ \uicontrol Navigator view and change the type of the component in the \uicontrol
Type field in \l Properties. For example, to use a point light, enter
\e {PointLight}.
From 180c990dffc8f872b279d337019ec92e03c6206b Mon Sep 17 00:00:00 2001
From: Vikas Pachdha
Date: Mon, 2 Jan 2023 13:37:11 +0100
Subject: [PATCH 03/28] Docs: Minor fix in XD QtBridge docs
Fixes: QDS-8706
Change-Id: Icf6ad34bf64273574daa715da522fe90a201a9b6
Reviewed-by: Pranta Ghosh Dastider
Reviewed-by: Thomas Hartmann
---
doc/qtdesignstudio/src/qtbridge/qtbridge-xd-using.qdoc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/doc/qtdesignstudio/src/qtbridge/qtbridge-xd-using.qdoc b/doc/qtdesignstudio/src/qtbridge/qtbridge-xd-using.qdoc
index 6faef0cfc85..f4728fa415a 100644
--- a/doc/qtdesignstudio/src/qtbridge/qtbridge-xd-using.qdoc
+++ b/doc/qtdesignstudio/src/qtbridge/qtbridge-xd-using.qdoc
@@ -84,7 +84,7 @@
\list
\li \uicontrol Component exports the layer as a separate UI file
that contains all the exportable artwork and text in it. Only
- Artboards can be exported as components.
+ Artboards and XD component layers can be exported as components.
\li \uicontrol Child exports each asset of the selected group
or layer a separate PNG file, with references
to the images in the component file.
From 7f748acc3eece087bfcf254bf11211454508dce2 Mon Sep 17 00:00:00 2001
From: Henning Gruendl
Date: Fri, 16 Dec 2022 17:07:40 +0100
Subject: [PATCH 04/28] QmlDesigner: Fix ColorEditor anchor warning
Fix warning caused by the ColorEditor. Detected anchors on an item that
is managed by a layout. This is undefined behavior; use Layout.alignment
instead.
Change-Id: I58a618054e7e269e770aa53585472474a1b77cdd
Reviewed-by:
Reviewed-by: Thomas Hartmann
---
.../imports/HelperWidgets/ColorEditor.qml | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/ColorEditor.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/ColorEditor.qml
index 4d17cafd93d..32e33744330 100644
--- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/ColorEditor.qml
+++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/ColorEditor.qml
@@ -216,19 +216,15 @@ SecondColumnLayout {
property alias active: popupLoader.loader.active
property Loader loader: Loader {
- parent: colorEditor
+ parent: preview
active: colorEditor.supportGradient
- anchors.left: parent.left
- anchors.leftMargin: 0
sourceComponent: ColorEditorPopup {
id: cePopup
x: cePopup.__defaultX
y: cePopup.__defaultY
}
- onLoaded: {
- popupLoader.dialog.initEditor()
- }
+ onLoaded: popupLoader.dialog.initEditor()
}
}
}
From afe7d48b6c77771fb373b7fa16ab27f72627242e Mon Sep 17 00:00:00 2001
From: Henning Gruendl
Date: Tue, 3 Jan 2023 17:38:50 +0100
Subject: [PATCH 05/28] UpdateInfo: Fix size policy on "show details" list
Task-number: QTCREATORBUG-28642
Change-Id: Id3b69aaf1532e54101824e8baa65a929c1a47a72
Reviewed-by: Alessandro Portale
Reviewed-by:
---
src/plugins/updateinfo/updateinfoplugin.cpp | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/plugins/updateinfo/updateinfoplugin.cpp b/src/plugins/updateinfo/updateinfoplugin.cpp
index aa1f5463fb5..c71418f35a5 100644
--- a/src/plugins/updateinfo/updateinfoplugin.cpp
+++ b/src/plugins/updateinfo/updateinfoplugin.cpp
@@ -221,9 +221,10 @@ static void showUpdateInfo(const QList &updates, const std::functionsetText("" + UpdateInfoPlugin::tr("Available updates:") + "
");
- label->setContentsMargins(0, 0, 0, 8);
+ label->setContentsMargins(2, 2, 2, 2);
auto scrollArea = new QScrollArea;
+ scrollArea->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum);
scrollArea->setWidget(label);
scrollArea->setFrameShape(QFrame::NoFrame);
scrollArea->viewport()->setAutoFillBackground(false);
From 56b9f99d76d489b1cadd2b87064d74534f11befe Mon Sep 17 00:00:00 2001
From: Thomas Hartmann
Date: Wed, 4 Jan 2023 12:06:46 +0100
Subject: [PATCH 06/28] QmlDesigner: The type name of Component is now
QML.Component
See also: 90b8e482c94e133203d1e26f88b4c002d546c671
Task-number: QDS-8725
Change-Id: I20cbf8a10015306fee708191095215b19a85614c
Reviewed-by: Miikka Heikkinen
---
.../qmldesigner/designercore/model/texttomodelmerger.cpp | 3 ++-
src/plugins/qmldesigner/qtquickplugin/quick.metainfo | 8 ++++----
2 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp b/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp
index 8070319a2d4..bb7bbb16c0b 100644
--- a/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp
+++ b/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp
@@ -280,7 +280,8 @@ bool isListElementType(const QmlDesigner::TypeName &type)
bool isComponentType(const QmlDesigner::TypeName &type)
{
return type == "Component" || type == "Qt.Component" || type == "QtQuick.Component"
- || type == "QtQml.Component" || type == ".QQmlComponent" || type == "QQmlComponent";
+ || type == "QtQml.Component" || type == ".QQmlComponent" || type == "QQmlComponent"
+ || type == "QML.Component";
}
bool isCustomParserType(const QmlDesigner::TypeName &type)
diff --git a/src/plugins/qmldesigner/qtquickplugin/quick.metainfo b/src/plugins/qmldesigner/qtquickplugin/quick.metainfo
index ec420e27200..87b9edcbc08 100644
--- a/src/plugins/qmldesigner/qtquickplugin/quick.metainfo
+++ b/src/plugins/qmldesigner/qtquickplugin/quick.metainfo
@@ -535,7 +535,7 @@ MetaInfo {
}
Type {
- name: "QtQml.Component"
+ name: "QML.Component"
icon: ":/qtquickplugin/images/component-icon16.png"
Hints {
@@ -547,7 +547,7 @@ MetaInfo {
name: "Component"
category: "e.Qt Quick - Component"
libraryIcon: ":/qtquickplugin/images/component-icon.png"
- version: "2.0"
+ version: "1.0"
QmlSource { source: ":/qtquickplugin/source/component.qml" }
toolTip: qsTr("Allows you to define components inline, within a QML document.")
@@ -555,7 +555,7 @@ MetaInfo {
}
Type {
- name: "QtQml.Component"
+ name: "QML.Component"
icon: ":/qtquickplugin/images/component-icon16.png"
Hints {
@@ -567,7 +567,7 @@ MetaInfo {
name: "Component 3D"
category: "Qt Quick 3D Component"
libraryIcon: ":/qtquickplugin/images/component-icon.png"
- version: "2.0"
+ version: "1.0"
requiredImport: "QtQuick3D"
QmlSource { source: ":/qtquickplugin/source/component3d.qml" }
From c81f5ba7d144d18d042963c11da4ff2cb160a8fb Mon Sep 17 00:00:00 2001
From: Thomas Hartmann
Date: Wed, 4 Jan 2023 10:40:26 +0100
Subject: [PATCH 07/28] QmlDesigner: Fix resizeToItem with live preview
The live preview recreates the "containedObject" and reparents it
to the window. But the containedObject was not tracking this.
Now we track the children accordingly.
Using bindings to keep the size in sync.
Change-Id: I051e9621f150befffec548ae0bbd431bd18480ce
Reviewed-by: Burak Hancerli
Reviewed-by:
Reviewed-by: Thomas Hartmann
---
.../qmlruntime/content/resizeItemToWindow.qml | 44 ++++++++++++++-----
1 file changed, 34 insertions(+), 10 deletions(-)
diff --git a/src/tools/qml2puppet/runnerconf/qmlruntime/content/resizeItemToWindow.qml b/src/tools/qml2puppet/runnerconf/qmlruntime/content/resizeItemToWindow.qml
index ca4618ba734..7b99d4530a9 100644
--- a/src/tools/qml2puppet/runnerconf/qmlruntime/content/resizeItemToWindow.qml
+++ b/src/tools/qml2puppet/runnerconf/qmlruntime/content/resizeItemToWindow.qml
@@ -4,22 +4,46 @@ import QtQuick.Window 2.0
import QtQuick 2.0
Window {
+ id: window
property Item containedObject: null
- property bool __resizeGuard: false
+
+ readonly property Item firstChild: window.contentItem.children.length > 0 ? window.contentItem.children[0] : null
+
+ property bool writeGuard: false
+
+ onFirstChildChanged: {
+ window.writeGuard = true
+ window.containedObject = window.firstChild
+ window.writeGuard = false
+ }
+
onContainedObjectChanged: {
+ if (window.writeGuard)
+ return
+
if (containedObject == undefined || containedObject == null) {
visible = false
return
}
- __resizeGuard = true
- width = containedObject.width
- height = containedObject.height
+
+ window.width = containedObject.width
+ window.height = containedObject.height
+
containedObject.parent = contentItem
- visible = true
- __resizeGuard = false
+ window.visible = true
+ }
+
+ Binding {
+ target: window.firstChild
+ when: window.firstChild
+ property: "height"
+ value: window.height
+ }
+
+ Binding {
+ target: window.firstChild
+ when: window.firstChild
+ property: "width"
+ value: window.width
}
- onWidthChanged: if (!__resizeGuard && containedObject)
- containedObject.width = width
- onHeightChanged: if (!__resizeGuard && containedObject)
- containedObject.height = height
}
From 1482bc0ae1d6cbc4accfe9001986a23feab41544 Mon Sep 17 00:00:00 2001
From: Amr Essam
Date: Wed, 4 Jan 2023 11:39:54 +0200
Subject: [PATCH 08/28] QmlDesigner: Allow drag effects to only QtQuickItem
elements
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- While drag an effect from asset library,
it only applies to elements that are type of QtQuickItem and has layer.effect property.
- Highlight those elements when start dragging an effect,
so user know correct elements to drag to.
Task-number: QDS-8579
Change-Id: Iedeed0e5ac65ce8b635f5cca6311b05c85197695
Reviewed-by: Tomi Korpipää
Reviewed-by: Thomas Hartmann
---
.../navigator/choosefrompropertylistdialog.cpp | 5 +++++
.../components/navigator/navigatortreemodel.cpp | 3 ++-
.../components/navigator/navigatorview.cpp | 14 ++++++++++++++
.../designercore/include/nodemetainfo.h | 1 +
.../designercore/metainfo/nodemetainfo.cpp | 10 ++++++++++
5 files changed, 32 insertions(+), 1 deletion(-)
diff --git a/src/plugins/qmldesigner/components/navigator/choosefrompropertylistdialog.cpp b/src/plugins/qmldesigner/components/navigator/choosefrompropertylistdialog.cpp
index 8c1d2b360c3..fd286d74808 100644
--- a/src/plugins/qmldesigner/components/navigator/choosefrompropertylistdialog.cpp
+++ b/src/plugins/qmldesigner/components/navigator/choosefrompropertylistdialog.cpp
@@ -39,6 +39,8 @@ ChooseFromPropertyListFilter::ChooseFromPropertyListFilter(const NodeMetaInfo &i
// -> Model
// BundleMaterial
// -> Model
+ // Effect
+ // -> Item
if (insertInfo.isQtQuick3DTexture()) {
if (parentInfo.isQtQuick3DDefaultMaterial() || parentInfo.isQtQuick3DPrincipledMaterial()
@@ -93,6 +95,9 @@ ChooseFromPropertyListFilter::ChooseFromPropertyListFilter(const NodeMetaInfo &i
// TODO merge conflict between Change-Id: If3c58f82797beabe76baf99ea2dddc59032729df and Change-Id: Iff2dea66e253b412105427134bd49cb16ed76193
// } else if (insertInfo.typeName().startsWith("ComponentBundles.MaterialBundle")) {
// if (parentInfo.isSubclassOf("QtQuick3D.Model"))
+ } else if (insertInfo.isEffectMaker()) {
+ if (parentInfo.isQtQuickItem())
+ propertyList.append("effect");
}
}
diff --git a/src/plugins/qmldesigner/components/navigator/navigatortreemodel.cpp b/src/plugins/qmldesigner/components/navigator/navigatortreemodel.cpp
index a7a163ab18b..699974b7c0c 100644
--- a/src/plugins/qmldesigner/components/navigator/navigatortreemodel.cpp
+++ b/src/plugins/qmldesigner/components/navigator/navigatortreemodel.cpp
@@ -1019,7 +1019,8 @@ ModelNode NavigatorTreeModel::handleItemLibraryEffectDrop(const QString &effectP
ModelNode targetNode(modelNodeForIndex(rowModelIndex));
ModelNode newModelNode;
- if (targetNode.hasParentProperty() && targetNode.parentProperty().name() == "layer.effect")
+ if ((targetNode.hasParentProperty() && targetNode.parentProperty().name() == "layer.effect")
+ || !targetNode.metaInfo().isQtQuickItem())
return newModelNode;
if (ModelNodeOperations::validateEffect(effectPath)) {
diff --git a/src/plugins/qmldesigner/components/navigator/navigatorview.cpp b/src/plugins/qmldesigner/components/navigator/navigatorview.cpp
index 31106a87356..87eae0a7235 100644
--- a/src/plugins/qmldesigner/components/navigator/navigatorview.cpp
+++ b/src/plugins/qmldesigner/components/navigator/navigatorview.cpp
@@ -7,6 +7,7 @@
#include "qmldesignerconstants.h"
#include "qmldesignericons.h"
#include "qmldesignerplugin.h"
+#include "assetslibrarywidget.h"
#include "nameitemdelegate.h"
#include "iconcheckboxitemdelegate.h"
@@ -266,6 +267,19 @@ void NavigatorView::dragStarted(QMimeData *mimeData)
m_widget->setDragType(bundleMatType);
m_widget->update();
+ } else if (mimeData->hasFormat(Constants::MIME_TYPE_ASSETS)) {
+ const QStringList assetsPaths = QString::fromUtf8(mimeData->data(Constants::MIME_TYPE_ASSETS)).split(',');
+ if (assetsPaths.count() > 0) {
+ auto assetTypeAndData = AssetsLibraryWidget::getAssetTypeAndData(assetsPaths[0]);
+ QString assetType = assetTypeAndData.first;
+ if (assetType == Constants::MIME_TYPE_ASSET_EFFECT) {
+ qint32 internalId = mimeData->data(Constants::MIME_TYPE_ASSET_EFFECT).toInt();
+ ModelNode effectNode = modelNodeForInternalId(internalId);
+
+ m_widget->setDragType(effectNode.metaInfo().typeName());
+ m_widget->update();
+ }
+ }
}
}
diff --git a/src/plugins/qmldesigner/designercore/include/nodemetainfo.h b/src/plugins/qmldesigner/designercore/include/nodemetainfo.h
index 36469d6f309..390a0482491 100644
--- a/src/plugins/qmldesigner/designercore/include/nodemetainfo.h
+++ b/src/plugins/qmldesigner/designercore/include/nodemetainfo.h
@@ -100,6 +100,7 @@ public:
bool isAlias() const;
bool isBool() const;
bool isColor() const;
+ bool isEffectMaker() const;
bool isFloat() const;
bool isFlowViewFlowActionArea() const;
bool isFlowViewFlowDecision() const;
diff --git a/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp b/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp
index 7914ca76437..95d3765d9eb 100644
--- a/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp
+++ b/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp
@@ -2535,6 +2535,16 @@ bool NodeMetaInfo::isColor() const
}
}
+bool NodeMetaInfo::isEffectMaker() const
+{
+ if constexpr (useProjectStorage()) {
+ using namespace Storage::Info;
+ return isBasedOnCommonType(m_projectStorage, m_typeId);
+ } else {
+ return isValid() && m_privateData->properties().contains("layer.effect");
+ }
+}
+
bool NodeMetaInfo::isBool() const
{
if constexpr (useProjectStorage()) {
From 63e885e7a1778e0c548fb116a13d3fed84bf65b9 Mon Sep 17 00:00:00 2001
From: Amr Essam
Date: Wed, 4 Jan 2023 18:19:00 +0200
Subject: [PATCH 09/28] QmlDesigner: Create arbitrary type for effects to
identify them in qds
Using arbitrary type name because at this time we don't have effect maker specific type
Task-number: QDS-8729
Change-Id: I3f70e241a03e0ce14512af1cafa066ef0a6c90d5
Reviewed-by:
Reviewed-by: Thomas Hartmann
---
.../qmldesigner/components/navigator/navigatorview.cpp | 8 ++++----
.../qmldesigner/designercore/metainfo/nodemetainfo.cpp | 9 +++------
.../designercore/projectstorage/commontypecache.h | 1 +
3 files changed, 8 insertions(+), 10 deletions(-)
diff --git a/src/plugins/qmldesigner/components/navigator/navigatorview.cpp b/src/plugins/qmldesigner/components/navigator/navigatorview.cpp
index 87eae0a7235..9a8aa127721 100644
--- a/src/plugins/qmldesigner/components/navigator/navigatorview.cpp
+++ b/src/plugins/qmldesigner/components/navigator/navigatorview.cpp
@@ -8,6 +8,7 @@
#include "qmldesignericons.h"
#include "qmldesignerplugin.h"
#include "assetslibrarywidget.h"
+#include "commontypecache.h"
#include "nameitemdelegate.h"
#include "iconcheckboxitemdelegate.h"
@@ -273,10 +274,9 @@ void NavigatorView::dragStarted(QMimeData *mimeData)
auto assetTypeAndData = AssetsLibraryWidget::getAssetTypeAndData(assetsPaths[0]);
QString assetType = assetTypeAndData.first;
if (assetType == Constants::MIME_TYPE_ASSET_EFFECT) {
- qint32 internalId = mimeData->data(Constants::MIME_TYPE_ASSET_EFFECT).toInt();
- ModelNode effectNode = modelNodeForInternalId(internalId);
-
- m_widget->setDragType(effectNode.metaInfo().typeName());
+ // We use arbitrary type name because at this time we don't have effect maker
+ // specific type
+ m_widget->setDragType(Storage::Info::EffectMaker);
m_widget->update();
}
}
diff --git a/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp b/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp
index 95d3765d9eb..ff5ca2236c3 100644
--- a/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp
+++ b/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp
@@ -2537,12 +2537,9 @@ bool NodeMetaInfo::isColor() const
bool NodeMetaInfo::isEffectMaker() const
{
- if constexpr (useProjectStorage()) {
- using namespace Storage::Info;
- return isBasedOnCommonType(m_projectStorage, m_typeId);
- } else {
- return isValid() && m_privateData->properties().contains("layer.effect");
- }
+ // We use arbitrary type name because at this time we don't have effect maker
+ // specific type
+ return typeName() == QString::fromUtf8(Storage::Info::EffectMaker);
}
bool NodeMetaInfo::isBool() const
diff --git a/src/plugins/qmldesigner/designercore/projectstorage/commontypecache.h b/src/plugins/qmldesigner/designercore/projectstorage/commontypecache.h
index 2d041df9cf7..36dff12dd51 100644
--- a/src/plugins/qmldesigner/designercore/projectstorage/commontypecache.h
+++ b/src/plugins/qmldesigner/designercore/projectstorage/commontypecache.h
@@ -35,6 +35,7 @@ inline constexpr char DefaultMaterial[] = "DefaultMaterial";
inline constexpr char Dialog[] = "Dialog";
inline constexpr char DoubleType[] = "double";
inline constexpr char Effect[] = "Effect";
+inline constexpr char EffectMaker[] = "EffectMaker";
inline constexpr char FloatType[] = "float";
inline constexpr char FlowActionArea[] = "FlowActionArea";
inline constexpr char FlowDecision[] = "FlowDecision";
From 28b6c30bd8ffdb1bbdb61fe2369f39464e958eaa Mon Sep 17 00:00:00 2001
From: Thomas Hartmann
Date: Wed, 4 Jan 2023 16:50:16 +0100
Subject: [PATCH 10/28] QmlDesigner: Fix lingering merge conflict
Materials are applied to Quick3DModel not QtQuick3DParticles3DModel
(Which does not exist).
Change-Id: I350d9864c7eb3a7b6879e8d58646c7c2c7b8e0d2
Reviewed-by: Miikka Heikkinen
---
.../components/navigator/choosefrompropertylistdialog.cpp | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/plugins/qmldesigner/components/navigator/choosefrompropertylistdialog.cpp b/src/plugins/qmldesigner/components/navigator/choosefrompropertylistdialog.cpp
index fd286d74808..dc3bf99ba6d 100644
--- a/src/plugins/qmldesigner/components/navigator/choosefrompropertylistdialog.cpp
+++ b/src/plugins/qmldesigner/components/navigator/choosefrompropertylistdialog.cpp
@@ -90,11 +90,11 @@ ChooseFromPropertyListFilter::ChooseFromPropertyListFilter(const NodeMetaInfo &i
|| parentInfo.isQtQuick3DParticles3DAttractor3D())
propertyList.append("shape");
} else if (insertInfo.isQtQuick3DMaterial()) {
- if (parentInfo.isQtQuick3DParticles3DModel())
+ if (parentInfo.isQtQuick3DModel())
+ propertyList.append("materials");
+ } else if (insertInfo.typeName().startsWith("ComponentBundles.MaterialBundle")) {
+ if (parentInfo.isQtQuick3DModel())
propertyList.append("materials");
-// TODO merge conflict between Change-Id: If3c58f82797beabe76baf99ea2dddc59032729df and Change-Id: Iff2dea66e253b412105427134bd49cb16ed76193
-// } else if (insertInfo.typeName().startsWith("ComponentBundles.MaterialBundle")) {
-// if (parentInfo.isSubclassOf("QtQuick3D.Model"))
} else if (insertInfo.isEffectMaker()) {
if (parentInfo.isQtQuickItem())
propertyList.append("effect");
From c1a16d51a64a759a5dae0d0971fd7a34ef54dfb6 Mon Sep 17 00:00:00 2001
From: Thomas Hartmann
Date: Wed, 4 Jan 2023 17:10:40 +0100
Subject: [PATCH 11/28] QmlDesigner: Remove isQtQuick3DParticles3DModel
The type does not exist.
Change-Id: I03df9f67d49af1ff37a254f3ef17693f5d975ea9
Reviewed-by:
Reviewed-by: Miikka Heikkinen
---
.../qmldesigner/designercore/include/nodemetainfo.h | 1 -
.../designercore/metainfo/nodemetainfo.cpp | 11 -----------
2 files changed, 12 deletions(-)
diff --git a/src/plugins/qmldesigner/designercore/include/nodemetainfo.h b/src/plugins/qmldesigner/designercore/include/nodemetainfo.h
index 390a0482491..f3429ecce90 100644
--- a/src/plugins/qmldesigner/designercore/include/nodemetainfo.h
+++ b/src/plugins/qmldesigner/designercore/include/nodemetainfo.h
@@ -130,7 +130,6 @@ public:
bool isQtQuick3DNode() const;
bool isQtQuick3DParticles3DAffector3D() const;
bool isQtQuick3DParticles3DAttractor3D() const;
- bool isQtQuick3DParticles3DModel() const;
bool isQtQuick3DParticles3DParticle3D() const;
bool isQtQuick3DParticles3DParticleEmitter3D() const;
bool isQtQuick3DParticles3DSpriteParticle3D() const;
diff --git a/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp b/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp
index ff5ca2236c3..871c8b4c2a5 100644
--- a/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp
+++ b/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp
@@ -2731,17 +2731,6 @@ bool NodeMetaInfo::isQtQuick3DView3D() const
}
}
-bool NodeMetaInfo::isQtQuick3DParticles3DModel() const
-{
- if constexpr (useProjectStorage()) {
- using namespace Storage::Info;
- return isBasedOnCommonType(m_projectStorage,
- m_typeId);
- } else {
- return isValid() && isSubclassOf("QtQuick3D.Particles3D.Model");
- }
-}
-
bool NodeMetaInfo::isQtQuick3DPrincipledMaterial() const
{
if constexpr (useProjectStorage()) {
From ff59de94e9bb3d4102424c3bcd12fa1e95e0837d Mon Sep 17 00:00:00 2001
From: Miikka Heikkinen
Date: Thu, 5 Jan 2023 13:08:27 +0200
Subject: [PATCH 12/28] QmlDesigner: Create dragged item to correct position in
3d view
Fixes: QDS-8655
Change-Id: I8ab397e4dc571e50c4495f6690418b177afa4dbe
Reviewed-by: Mahmoud Badri
---
.../components/edit3d/edit3dcanvas.cpp | 38 -------------------
.../components/edit3d/edit3dcanvas.h | 5 ---
.../components/edit3d/edit3dview.cpp | 18 +++++++++
.../components/edit3d/edit3dview.h | 4 ++
.../components/edit3d/edit3dwidget.cpp | 28 +++++++++++++-
.../components/edit3d/edit3dwidget.h | 1 +
6 files changed, 49 insertions(+), 45 deletions(-)
diff --git a/src/plugins/qmldesigner/components/edit3d/edit3dcanvas.cpp b/src/plugins/qmldesigner/components/edit3d/edit3dcanvas.cpp
index 10c71c23ca6..7cc837026a7 100644
--- a/src/plugins/qmldesigner/components/edit3d/edit3dcanvas.cpp
+++ b/src/plugins/qmldesigner/components/edit3d/edit3dcanvas.cpp
@@ -5,9 +5,6 @@
#include "edit3dview.h"
#include "edit3dwidget.h"
-#include "nodehints.h"
-#include "qmlvisualnode.h"
-
#include
#include
#include
@@ -143,41 +140,6 @@ void Edit3DCanvas::resizeEvent(QResizeEvent *e)
m_parent->view()->edit3DViewResized(e->size());
}
-void Edit3DCanvas::dragEnterEvent(QDragEnterEvent *e)
-{
- // Block all drags if scene root node is locked
- ModelNode node;
- if (m_parent->view()->hasModelNodeForInternalId(m_activeScene))
- node = m_parent->view()->modelNodeForInternalId(m_activeScene);
-
- // Allow drop when there is no valid active scene, as the drop goes under the root node of
- // the document in that case.
- if (!ModelNode::isThisOrAncestorLocked(node)) {
- QByteArray data = e->mimeData()->data(Constants::MIME_TYPE_ITEM_LIBRARY_INFO);
- if (!data.isEmpty()) {
- QDataStream stream(data);
- stream >> m_itemLibraryEntry;
- if (NodeHints::fromItemLibraryEntry(m_itemLibraryEntry).canBeDroppedInView3D())
- e->accept();
- }
- }
-}
-
-void Edit3DCanvas::dropEvent(QDropEvent *e)
-{
- m_parent->view()->executeInTransaction(__FUNCTION__, [&] {
- auto modelNode = QmlVisualNode::createQml3DNode(m_parent->view(), m_itemLibraryEntry, m_activeScene).modelNode();
- QTC_ASSERT(modelNode.isValid(), return);
-
- e->accept();
- m_parent->view()->setSelectedModelNode(modelNode);
-
- // if added node is a Model, assign it a material
- if (modelNode.metaInfo().isQtQuick3DModel())
- m_parent->view()->assignMaterialTo3dModel(modelNode);
- });
-}
-
void Edit3DCanvas::focusOutEvent(QFocusEvent *focusEvent)
{
QmlDesignerPlugin::emitUsageStatisticsTime(Constants::EVENT_3DEDITOR_TIME,
diff --git a/src/plugins/qmldesigner/components/edit3d/edit3dcanvas.h b/src/plugins/qmldesigner/components/edit3d/edit3dcanvas.h
index af54bd17be0..b505681711b 100644
--- a/src/plugins/qmldesigner/components/edit3d/edit3dcanvas.h
+++ b/src/plugins/qmldesigner/components/edit3d/edit3dcanvas.h
@@ -2,8 +2,6 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
#pragma once
-#include "itemlibraryinfo.h"
-
#include
#include
#include
@@ -38,8 +36,6 @@ protected:
void keyReleaseEvent(QKeyEvent *e) override;
void paintEvent(QPaintEvent *e) override;
void resizeEvent(QResizeEvent *e) override;
- void dragEnterEvent(QDragEnterEvent *e) override;
- void dropEvent(QDropEvent *e) override;
void focusOutEvent(QFocusEvent *focusEvent) override;
void focusInEvent(QFocusEvent *focusEvent) override;
@@ -49,7 +45,6 @@ private:
QPointer m_parent;
QImage m_image;
qint32 m_activeScene = -1;
- ItemLibraryEntry m_itemLibraryEntry;
QElapsedTimer m_usageTimer;
qreal m_opacity = 1.0;
QWidget *m_busyIndicator = nullptr;
diff --git a/src/plugins/qmldesigner/components/edit3d/edit3dview.cpp b/src/plugins/qmldesigner/components/edit3d/edit3dview.cpp
index 038c658c51e..5a61f2fa093 100644
--- a/src/plugins/qmldesigner/components/edit3d/edit3dview.cpp
+++ b/src/plugins/qmldesigner/components/edit3d/edit3dview.cpp
@@ -16,6 +16,7 @@
#include "qmldesignerconstants.h"
#include "qmldesignericons.h"
#include "qmldesignerplugin.h"
+#include "qmlvisualnode.h"
#include "seekerslider.h"
#include
@@ -304,6 +305,16 @@ void Edit3DView::nodeAtPosReady(const ModelNode &modelNode, const QVector3D &pos
if (modelNode.isValid() && !modelNode.isSelected())
setSelectedModelNode(modelNode);
m_edit3DWidget->showContextMenu(m_contextMenuPos, modelNode, pos3d);
+ } else if (m_nodeAtPosReqType == NodeAtPosReqType::ComponentDrop) {
+ ModelNode createdNode;
+ executeInTransaction(__FUNCTION__, [&] {
+ createdNode = QmlVisualNode::createQml3DNode(
+ this, m_droppedEntry, edit3DWidget()->canvas()->activeScene(), pos3d).modelNode();
+ if (createdNode.metaInfo().isQtQuick3DModel())
+ assignMaterialTo3dModel(createdNode);
+ });
+ if (createdNode.isValid())
+ setSelectedModelNode(createdNode);
} else if (m_nodeAtPosReqType == NodeAtPosReqType::MaterialDrop) {
bool isModel = modelNode.metaInfo().isQtQuick3DModel();
if (m_droppedModelNode.isValid() && modelNode.isValid() && isModel) {
@@ -895,4 +906,11 @@ void Edit3DView::dropTexture(const ModelNode &textureNode, const QPointF &pos)
emitView3DAction(View3DActionType::GetNodeAtPos, pos);
}
+void Edit3DView::dropComponent(const ItemLibraryEntry &entry, const QPointF &pos)
+{
+ m_nodeAtPosReqType = NodeAtPosReqType::ComponentDrop;
+ m_droppedEntry = entry;
+ emitView3DAction(View3DActionType::GetNodeAtPos, pos);
+}
+
} // namespace QmlDesigner
diff --git a/src/plugins/qmldesigner/components/edit3d/edit3dview.h b/src/plugins/qmldesigner/components/edit3d/edit3dview.h
index 7653730480f..8dd7fbbc677 100644
--- a/src/plugins/qmldesigner/components/edit3d/edit3dview.h
+++ b/src/plugins/qmldesigner/components/edit3d/edit3dview.h
@@ -2,6 +2,7 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
#pragma once
+#include "itemlibraryinfo.h"
#include
#include
@@ -65,6 +66,7 @@ public:
void dropMaterial(const ModelNode &matNode, const QPointF &pos);
void dropBundleMaterial(const QPointF &pos);
void dropTexture(const ModelNode &textureNode, const QPointF &pos);
+ void dropComponent(const ItemLibraryEntry &entry, const QPointF &pos);
private slots:
void onEntriesChanged();
@@ -72,6 +74,7 @@ private slots:
private:
enum class NodeAtPosReqType {
BundleMaterialDrop,
+ ComponentDrop,
MaterialDrop,
TextureDrop,
ContextMenu,
@@ -122,6 +125,7 @@ private:
int particlemode;
ModelCache m_canvasCache;
ModelNode m_droppedModelNode;
+ ItemLibraryEntry m_droppedEntry;
NodeAtPosReqType m_nodeAtPosReqType;
QPoint m_contextMenuPos;
QTimer m_compressionTimer;
diff --git a/src/plugins/qmldesigner/components/edit3d/edit3dwidget.cpp b/src/plugins/qmldesigner/components/edit3d/edit3dwidget.cpp
index c6cc8e43717..f7c6ae22cfe 100644
--- a/src/plugins/qmldesigner/components/edit3d/edit3dwidget.cpp
+++ b/src/plugins/qmldesigner/components/edit3d/edit3dwidget.cpp
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
#include "edit3dwidget.h"
-#include "designdocumentview.h"
+#include "designdocument.h"
#include "edit3dactions.h"
#include "edit3dcanvas.h"
#include "edit3dview.h"
@@ -10,10 +10,10 @@
#include "metainfo.h"
#include "modelnodeoperations.h"
#include "nodeabstractproperty.h"
+#include "nodehints.h"
#include "qmldesignerconstants.h"
#include "qmldesignerplugin.h"
#include "qmlvisualnode.h"
-#include "timelineactions.h"
#include "viewmanager.h"
#include
@@ -407,6 +407,15 @@ Edit3DView *Edit3DWidget::view() const
void Edit3DWidget::dragEnterEvent(QDragEnterEvent *dragEnterEvent)
{
+ // Block all drags if scene root node is locked
+ if (m_view->hasModelNodeForInternalId(m_canvas->activeScene())) {
+ ModelNode node = m_view->modelNodeForInternalId(m_canvas->activeScene());
+ if (ModelNode::isThisOrAncestorLocked(node))
+ return;
+ }
+
+ m_draggedEntry = {};
+
const DesignerActionManager &actionManager = QmlDesignerPlugin::instance()
->viewManager().designerActionManager();
if (actionManager.externalDragHasSupportedAssets(dragEnterEvent->mimeData())
@@ -414,6 +423,14 @@ void Edit3DWidget::dragEnterEvent(QDragEnterEvent *dragEnterEvent)
|| dragEnterEvent->mimeData()->hasFormat(Constants::MIME_TYPE_BUNDLE_MATERIAL)
|| dragEnterEvent->mimeData()->hasFormat(Constants::MIME_TYPE_TEXTURE)) {
dragEnterEvent->acceptProposedAction();
+ } else if (dragEnterEvent->mimeData()->hasFormat(Constants::MIME_TYPE_ITEM_LIBRARY_INFO)) {
+ QByteArray data = dragEnterEvent->mimeData()->data(Constants::MIME_TYPE_ITEM_LIBRARY_INFO);
+ if (!data.isEmpty()) {
+ QDataStream stream(data);
+ stream >> m_draggedEntry;
+ if (NodeHints::fromItemLibraryEntry(m_draggedEntry).canBeDroppedInView3D())
+ dragEnterEvent->acceptProposedAction();
+ }
}
}
@@ -443,6 +460,13 @@ void Edit3DWidget::dropEvent(QDropEvent *dropEvent)
return;
}
+ // handle dropping from component view
+ if (dropEvent->mimeData()->hasFormat(Constants::MIME_TYPE_ITEM_LIBRARY_INFO)) {
+ if (!m_draggedEntry.name().isEmpty())
+ m_view->dropComponent(m_draggedEntry, pos);
+ return;
+ }
+
// handle dropping external assets
const DesignerActionManager &actionManager = QmlDesignerPlugin::instance()
->viewManager().designerActionManager();
diff --git a/src/plugins/qmldesigner/components/edit3d/edit3dwidget.h b/src/plugins/qmldesigner/components/edit3d/edit3dwidget.h
index f1a9c09f445..b7d1ec996a7 100644
--- a/src/plugins/qmldesigner/components/edit3d/edit3dwidget.h
+++ b/src/plugins/qmldesigner/components/edit3d/edit3dwidget.h
@@ -77,6 +77,7 @@ private:
ModelNode m_contextMenuTarget;
QVector3D m_contextMenuPos3d;
QHash m_nameToEntry;
+ ItemLibraryEntry m_draggedEntry;
};
} // namespace QmlDesigner
From ac93351c93f6fc272f293372f1be63e648be6ef5 Mon Sep 17 00:00:00 2001
From: Miikka Heikkinen
Date: Thu, 5 Jan 2023 15:05:02 +0200
Subject: [PATCH 13/28] QmlDesigner: Respect node locking in navigator and 3D
view
If 3D scene root is locked, disable create options from context menu
in 3D view.
Also, don't highlight locked nodes as drop targets in navigator.
Fixes: QDS-8731
Change-Id: If0c8b5497781c2623f2c57966d4689e345b85785
Reviewed-by: Mahmoud Badri
---
.../components/edit3d/edit3dwidget.cpp | 15 +++++++++-
.../components/edit3d/edit3dwidget.h | 1 +
.../components/navigator/nameitemdelegate.cpp | 28 ++++++++++---------
3 files changed, 30 insertions(+), 14 deletions(-)
diff --git a/src/plugins/qmldesigner/components/edit3d/edit3dwidget.cpp b/src/plugins/qmldesigner/components/edit3d/edit3dwidget.cpp
index f7c6ae22cfe..cb16233475d 100644
--- a/src/plugins/qmldesigner/components/edit3d/edit3dwidget.cpp
+++ b/src/plugins/qmldesigner/components/edit3d/edit3dwidget.cpp
@@ -248,6 +248,16 @@ bool Edit3DWidget::isPasteAvailable() const
return QApplication::clipboard()->text().startsWith(Constants::HEADER_3DPASTE_CONTENT);
}
+bool Edit3DWidget::isSceneLocked() const
+{
+ if (m_view && m_view->hasModelNodeForInternalId(m_canvas->activeScene())) {
+ ModelNode node = m_view->modelNodeForInternalId(m_canvas->activeScene());
+ if (ModelNode::isThisOrAncestorLocked(node))
+ return true;
+ }
+ return false;
+}
+
// Called by the view to update the "create" sub-menu when the Quick3D entries are ready.
void Edit3DWidget::updateCreateSubMenu(const QStringList &keys,
const QHash> &entriesMap)
@@ -286,7 +296,7 @@ void Edit3DWidget::updateCreateSubMenu(const QStringList &keys,
void Edit3DWidget::onCreateAction()
{
QAction *action = qobject_cast(sender());
- if (!action || !m_view || !m_view->model())
+ if (!action || !m_view || !m_view->model() || isSceneLocked())
return;
m_view->executeInTransaction(__FUNCTION__, [&] {
@@ -374,6 +384,9 @@ void Edit3DWidget::showContextMenu(const QPoint &pos, const ModelNode &modelNode
const bool anyNodeSelected = view()->hasSelectedModelNodes();
const bool selectionExcludingRoot = anyNodeSelected && !view()->rootModelNode().isSelected();
+ if (m_createSubMenu)
+ m_createSubMenu->setEnabled(!isSceneLocked());
+
m_editComponentAction->setEnabled(isSingleComponent);
m_editMaterialAction->setEnabled(isModel);
m_duplicateAction->setEnabled(selectionExcludingRoot);
diff --git a/src/plugins/qmldesigner/components/edit3d/edit3dwidget.h b/src/plugins/qmldesigner/components/edit3d/edit3dwidget.h
index b7d1ec996a7..37298dfb281 100644
--- a/src/plugins/qmldesigner/components/edit3d/edit3dwidget.h
+++ b/src/plugins/qmldesigner/components/edit3d/edit3dwidget.h
@@ -52,6 +52,7 @@ private:
void createContextMenu();
bool isPasteAvailable() const;
+ bool isSceneLocked() const;
QPointer m_edit3DView;
QPointer m_view;
diff --git a/src/plugins/qmldesigner/components/navigator/nameitemdelegate.cpp b/src/plugins/qmldesigner/components/navigator/nameitemdelegate.cpp
index f56a5477fec..65822094394 100644
--- a/src/plugins/qmldesigner/components/navigator/nameitemdelegate.cpp
+++ b/src/plugins/qmldesigner/components/navigator/nameitemdelegate.cpp
@@ -211,21 +211,23 @@ void NameItemDelegate::paint(QPainter *painter,
}
ModelNode node = getModelNode(modelIndex);
- NavigatorWidget *widget = qobject_cast(styleOption.widget->parent());
- if (widget && !widget->dragType().isEmpty()) {
- QByteArray dragType = widget->dragType();
- const NodeMetaInfo metaInfo = node.metaInfo();
- const NodeMetaInfo dragInfo = node.model()->metaInfo(dragType);
- ChooseFromPropertyListFilter *filter = new ChooseFromPropertyListFilter(dragInfo, metaInfo, true);
+ if (!ModelNode::isThisOrAncestorLocked(node)) {
+ NavigatorWidget *widget = qobject_cast(styleOption.widget->parent());
+ if (widget && !widget->dragType().isEmpty()) {
+ QByteArray dragType = widget->dragType();
+ const NodeMetaInfo metaInfo = node.metaInfo();
+ const NodeMetaInfo dragInfo = node.model()->metaInfo(dragType);
+ ChooseFromPropertyListFilter *filter = new ChooseFromPropertyListFilter(dragInfo, metaInfo, true);
- if (!filter->propertyList.isEmpty()) {
- painter->setOpacity(0.5);
- painter->fillRect(styleOption.rect.adjusted(0, delegateMargin, 0, -delegateMargin),
- Theme::getColor(Theme::Color::DSnavigatorDropIndicatorBackground));
- painter->setOpacity(1.0);
- painter->setPen(Theme::getColor(Theme::Color::DSnavigatorTextSelected));
+ if (!filter->propertyList.isEmpty()) {
+ painter->setOpacity(0.5);
+ painter->fillRect(styleOption.rect.adjusted(0, delegateMargin, 0, -delegateMargin),
+ Theme::getColor(Theme::Color::DSnavigatorDropIndicatorBackground));
+ painter->setOpacity(1.0);
+ painter->setPen(Theme::getColor(Theme::Color::DSnavigatorTextSelected));
+ }
+ delete filter;
}
- delete filter;
}
iconOffset = drawIcon(painter, styleOption, modelIndex);
From fb14965dfe031a6b83e6aa928035125623adc19a Mon Sep 17 00:00:00 2001
From: Burak Hancerli
Date: Thu, 5 Jan 2023 18:37:28 +0100
Subject: [PATCH 14/28] QmlDesigner: fix for coreApp initialization problem and
loadwatcher scope failure
Change-Id: I7a82cdd32757a7d37a0e88fad3e0f83527e49094
Reviewed-by:
Reviewed-by: Qt CI Bot
Reviewed-by: Thomas Hartmann
---
src/tools/qml2puppet/qml2puppet/qmlbase.h | 21 +++++++++----------
.../qml2puppet/runner/qmlruntime.cpp | 3 ++-
2 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/src/tools/qml2puppet/qml2puppet/qmlbase.h b/src/tools/qml2puppet/qml2puppet/qmlbase.h
index 9bc41bef752..63a64f0147b 100644
--- a/src/tools/qml2puppet/qml2puppet/qmlbase.h
+++ b/src/tools/qml2puppet/qml2puppet/qmlbase.h
@@ -41,18 +41,22 @@ public:
, m_args({argc, argv})
{
m_argParser.setApplicationDescription("QML Runtime Provider for QDS");
- m_argParser.addOptions(
- {{"qml-puppet", "Run QML Puppet (default)"},
- {"qml-runtime", "Run QML Runtime"},
- {"appinfo", "Print build information"},
- {"test", "Run test mode"}
- });
+ m_argParser.addOptions({{"qml-puppet", "Run QML Puppet (default)"},
+ {"qml-runtime", "Run QML Runtime"},
+ {"appinfo", "Print build information"},
+ {"test", "Run test mode"}});
}
int run()
{
populateParser();
initCoreApp();
+
+ if (!m_coreApp) { //default to QGuiApplication
+ createCoreApp();
+ qWarning() << "CoreApp is not initialized! Falling back to QGuiApplication!";
+ }
+
initParser();
initQmlRunner();
return m_coreApp->exec();
@@ -89,11 +93,6 @@ private:
QCommandLineOption optHelp = m_argParser.addHelpOption();
QCommandLineOption optVers = m_argParser.addVersionOption();
- if (!m_coreApp) {
- qCritical() << "Cannot initialize coreapp!";
- m_argParser.showHelp();
- }
-
if (!m_argParser.parse(m_coreApp->arguments())) {
std::cout << "Error: " << m_argParser.errorText().toStdString() << std::endl
<< std::endl;
diff --git a/src/tools/qml2puppet/qml2puppet/runner/qmlruntime.cpp b/src/tools/qml2puppet/qml2puppet/runner/qmlruntime.cpp
index e3e962483f8..ed20c1a9d55 100644
--- a/src/tools/qml2puppet/qml2puppet/runner/qmlruntime.cpp
+++ b/src/tools/qml2puppet/qml2puppet/runner/qmlruntime.cpp
@@ -241,7 +241,8 @@ void QmlRuntime::initQmlRunner()
loadConf(confFile, !m_verboseMode);
// Load files
- QScopedPointer lw(new LoadWatcher(m_qmlEngine.data(), files.size(), m_conf.data()));
+ LoadWatcher *lw = new LoadWatcher(m_qmlEngine.data(), files.size(), m_conf.data());
+ lw->setParent(this);
for (const QString &path : std::as_const(files)) {
QUrl url = QUrl::fromUserInput(path, QDir::currentPath(), QUrl::AssumeLocalFile);
From df3ace009ac0371610337e8efee0299469b0ef6a Mon Sep 17 00:00:00 2001
From: Miikka Heikkinen
Date: Mon, 9 Jan 2023 13:49:41 +0200
Subject: [PATCH 15/28] QmlDesigner: Fix clearing node lock/eyeball
Lock/eyeball status was not propagated to puppet when lock/eyeball
was cleared, as clearing these aux properties instead removes them,
which triggers change notification with invalid value. Fixed by
allowing invalid value to be propagated for these properties.
Fixes: QDS-8735
Change-Id: Ic5c4818afeef71612f9620b3a0af503793a37e90
Reviewed-by: Mahmoud Badri
---
.../designercore/instances/nodeinstanceview.cpp | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/src/plugins/qmldesigner/designercore/instances/nodeinstanceview.cpp b/src/plugins/qmldesigner/designercore/instances/nodeinstanceview.cpp
index c715b659787..ed8436d6a0b 100644
--- a/src/plugins/qmldesigner/designercore/instances/nodeinstanceview.cpp
+++ b/src/plugins/qmldesigner/designercore/instances/nodeinstanceview.cpp
@@ -640,14 +640,12 @@ void NodeInstanceView::auxiliaryDataChanged(const ModelNode &node,
case AuxiliaryDataType::Document:
if ((key == lockedProperty || key == invisibleProperty) && hasInstanceForModelNode(node)) {
NodeInstance instance = instanceForModelNode(node);
- if (value.isValid()) {
- PropertyValueContainer container{instance.instanceId(),
- PropertyName{key.name},
- value,
- TypeName(),
- key.type};
- m_nodeInstanceServer->changeAuxiliaryValues({{container}});
- }
+ PropertyValueContainer container{instance.instanceId(),
+ PropertyName{key.name},
+ value,
+ TypeName(),
+ key.type};
+ m_nodeInstanceServer->changeAuxiliaryValues({{container}});
};
break;
From 20cbf4d34b5256e28139b15875f67d2ffdd3f279 Mon Sep 17 00:00:00 2001
From: Pranta Dastider
Date: Wed, 4 Jan 2023 16:33:38 +0100
Subject: [PATCH 16/28] QmlDesigner: Update Tooltips for Component Section
This patch update tooltip text for Componemt Section fields.
Fixes: QDS-8724
Change-Id: Id3fed9163c4ad6e61b762a5760cd5f2d7c079183
Reviewed-by: Mats Honkamaa
Reviewed-by: Thomas Hartmann
---
.../imports/HelperWidgets/ComponentSection.qml | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/ComponentSection.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/ComponentSection.qml
index b61c15cece2..0196000cee3 100644
--- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/ComponentSection.qml
+++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/ComponentSection.qml
@@ -19,7 +19,10 @@ Section {
property bool showState: false
SectionLayout {
- PropertyLabel { text: qsTr("Type") }
+ PropertyLabel {
+ text: qsTr("Type")
+ tooltip: qsTr("Sets the QML type of the component.")
+ }
SecondColumnLayout {
z: 2
@@ -44,7 +47,7 @@ Section {
typeLineEdit.visible = !typeLineEdit.visible
typeLineEdit.forceActiveFocus()
}
- tooltip: qsTr("Changes the type of this component.")
+ tooltip: qsTr("Sets the QML type of the component.")
enabled: !modelNodeBackend.multiSelection
}
@@ -83,7 +86,10 @@ Section {
ExpandingSpacer {}
}
- PropertyLabel { text: qsTr("ID") }
+ PropertyLabel {
+ text: qsTr("ID")
+ tooltip: qsTr("Sets a unique identification or name.")
+ }
SecondColumnLayout {
Spacer { implicitWidth: StudioTheme.Values.actionIndicatorWidth }
@@ -167,7 +173,10 @@ Section {
ExpandingSpacer {}
}
- PropertyLabel { text: qsTr("Name") }
+ PropertyLabel {
+ text: qsTr("Name")
+ tooltip: qsTr("Adds a note with a title to explain the component.")
+ }
SecondColumnLayout {
enabled: !modelNodeBackend.multiSelection
@@ -247,6 +256,7 @@ Section {
PropertyLabel {
visible: root.showState
text: qsTr("State")
+ tooltip: qsTr("Sets the state of the component.")
}
SecondColumnLayout {
From f673d3d0b02722e90b7a43378bbeb765719b67dc Mon Sep 17 00:00:00 2001
From: Miikka Heikkinen
Date: Mon, 9 Jan 2023 15:54:15 +0200
Subject: [PATCH 17/28] QmlDesigner: Update child nodes in navigator when lock
state changes
Child nodes of a locked node should also appear locked, so they need
to be updated whenever locked state changes on a ancestor node.
Fixes: QDS-8732
Change-Id: I5675e129fb60c5ad8c0fdbc7e0a0a7fef410747a
Reviewed-by: Mahmoud Badri
---
.../qmldesigner/components/navigator/navigatorview.cpp | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/src/plugins/qmldesigner/components/navigator/navigatorview.cpp b/src/plugins/qmldesigner/components/navigator/navigatorview.cpp
index 9a8aa127721..73ef6a32d47 100644
--- a/src/plugins/qmldesigner/components/navigator/navigatorview.cpp
+++ b/src/plugins/qmldesigner/components/navigator/navigatorview.cpp
@@ -403,6 +403,13 @@ void NavigatorView::auxiliaryDataChanged(const ModelNode &modelNode,
[[maybe_unused]] const QVariant &data)
{
m_currentModelInterface->notifyDataChanged(modelNode);
+
+ if (key == lockedProperty) {
+ // Also notify data changed on child nodes to redraw them
+ const QList childNodes = modelNode.allSubModelNodes();
+ for (const auto &childNode : childNodes)
+ m_currentModelInterface->notifyDataChanged(childNode);
+ }
}
void NavigatorView::instanceErrorChanged(const QVector &errorNodeList)
From 1c480899790c2f2654977818164cddb86aa2c440 Mon Sep 17 00:00:00 2001
From: Miikka Heikkinen
Date: Mon, 9 Jan 2023 14:13:17 +0200
Subject: [PATCH 18/28] QmlDesigner: Fix rotation block property name in puppet
Property name was changed on creator side when aux property handling
was refactored, but corresponding change was not done in puppet.
Change-Id: Iba21661908d6c46d7f586c18f0d34fcece597c9a
Reviewed-by: Mahmoud Badri
---
.../qml2puppet/instances/qt5informationnodeinstanceserver.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/tools/qml2puppet/qml2puppet/instances/qt5informationnodeinstanceserver.cpp b/src/tools/qml2puppet/qml2puppet/instances/qt5informationnodeinstanceserver.cpp
index c806edcdb65..48e6aeb13ce 100644
--- a/src/tools/qml2puppet/qml2puppet/instances/qt5informationnodeinstanceserver.cpp
+++ b/src/tools/qml2puppet/qml2puppet/instances/qt5informationnodeinstanceserver.cpp
@@ -345,7 +345,7 @@ void Qt5InformationNodeInstanceServer::updateRotationBlocks(
if (helper) {
QSet blockedNodes;
QSet unblockedNodes;
- const PropertyName rotBlocked = "rotBlocked";
+ const PropertyName rotBlocked = "rotBlock";
for (const auto &container : valueChanges) {
if (container.name() == rotBlocked
&& container.auxiliaryDataType() == AuxiliaryDataType::NodeInstanceAuxiliary) {
From 03eb5daf8dcab98c7ca543abdcf3d43d49ec4a6c Mon Sep 17 00:00:00 2001
From: Pranta Dastider
Date: Thu, 5 Jan 2023 14:56:41 +0100
Subject: [PATCH 19/28] QmlDesigner: Update Tooltips for 2D Geometry Section
This patch update tooltip text for 2D Geometry Section fields.
Fixes: QDS-8722
Change-Id: Id2db204057778fd141bbe17204e200d59070db8a
Reviewed-by: Thomas Hartmann
---
.../QtQuick/GeometrySection.qml | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/GeometrySection.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/GeometrySection.qml
index e37ee61cbd8..05683cb2160 100644
--- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/GeometrySection.qml
+++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/GeometrySection.qml
@@ -47,6 +47,7 @@ Section {
SectionLayout {
PropertyLabel {
text: qsTr("Position")
+ tooltip: qsTr("Sets the position of the component relative to its parent.")
enabled: xSpinBox.enabled || ySpinBox.enabled
}
@@ -66,7 +67,7 @@ Section {
ControlLabel {
text: "X"
- tooltip: xSpinBox.enabled ? "X" : root.disabledTooltip
+ tooltip: xSpinBox.enabled ? qsTr("X-coordinate") : root.disabledTooltip
enabled: xSpinBox.enabled
}
@@ -87,7 +88,7 @@ Section {
ControlLabel {
text: "Y"
- tooltip: xSpinBox.enabled ? "Y" : root.disabledTooltip
+ tooltip: xSpinBox.enabled ? qsTr("Y-coordinate") : root.disabledTooltip
enabled: ySpinBox.enabled
}
/*
@@ -101,6 +102,7 @@ Section {
PropertyLabel {
text: qsTr("Size")
+ tooltip: qsTr("Sets the width and height of the component.")
enabled: widthSpinBox.enabled || heightSpinBox.enabled
}
@@ -157,11 +159,13 @@ Section {
PropertyLabel {
text: qsTr("Rotation")
+ tooltip: qsTr("Rotate the component at an angle.")
blockedByTemplate: !backendValues.rotation.isAvailable
}
SecondColumnLayout {
SpinBox {
+ id: rotationSpinBox
implicitWidth: StudioTheme.Values.twoControlColumnWidth
+ StudioTheme.Values.actionIndicatorWidth
backendValue: backendValues.rotation
@@ -175,6 +179,7 @@ Section {
ControlLabel {
text: "°"
+ tooltip: rotationSpinBox.enabled ? qsTr("Angle (in degree)") : root.disabledTooltip
enabled: backendValues.rotation.isAvailable
}
/*
@@ -210,11 +215,13 @@ Section {
PropertyLabel {
text: qsTr("Scale")
+ tooltip: qsTr("Sets the scale of the component by percentage.")
blockedByTemplate: !backendValues.scale.isAvailable
}
SecondColumnLayout {
SpinBox {
+ id: scaleSpinBox
implicitWidth: StudioTheme.Values.singleControlColumnWidth
+ StudioTheme.Values.actionIndicatorWidth
sliderIndicatorVisible: true
@@ -230,13 +237,17 @@ Section {
ControlLabel {
text: "%"
+ tooltip: scaleSpinBox.enabled ? qsTr("Percentage") : root.disabledTooltip
enabled: backendValues.scale.isAvailable
}
ExpandingSpacer {}
}
- PropertyLabel { text: qsTr("Z stack") }
+ PropertyLabel {
+ text: qsTr("Z stack")
+ tooltip: qsTr("Sets the stacking order of the component.")
+ }
SecondColumnLayout {
SpinBox {
@@ -252,6 +263,7 @@ Section {
PropertyLabel {
text: qsTr("Origin")
+ tooltip: qsTr("Sets the modification point of the component.")
blockedByTemplate: !backendValues.transformOrigin.isAvailable
}
From 91998cd80aa4c248c250276053a6b1c9dc032168 Mon Sep 17 00:00:00 2001
From: Miikka Heikkinen
Date: Tue, 10 Jan 2023 14:12:18 +0200
Subject: [PATCH 20/28] QmlDesigner: When changing material type, copy base
color
All material types have a so called base color that determines the
diffuse color of the material, though the property is named differently
in different material types:
DefaultMaterial: diffuseColor
PrincipledMaterial: baseColor
SpecularGlossyMaterial: albedoColor
When changing a material type in material editor, if the base color
or the corresponding base map properties have been set, the values
are copied to the corresponding property in the new type.
Fixes: QDS-8738
Change-Id: Ia8e767ebf9b2d9026ff107e4245b37a788fd98d4
Reviewed-by: Mahmoud Badri
Reviewed-by: Thomas Hartmann
---
.../materialeditorcontextobject.cpp | 84 ++++++++++++++++++-
1 file changed, 83 insertions(+), 1 deletion(-)
diff --git a/src/plugins/qmldesigner/components/materialeditor/materialeditorcontextobject.cpp b/src/plugins/qmldesigner/components/materialeditor/materialeditorcontextobject.cpp
index 3f788e7f3fd..22e6964f60e 100644
--- a/src/plugins/qmldesigner/components/materialeditor/materialeditorcontextobject.cpp
+++ b/src/plugins/qmldesigner/components/materialeditor/materialeditorcontextobject.cpp
@@ -4,13 +4,16 @@
#include "materialeditorcontextobject.h"
#include
+#include
+#include
#include
#include
#include
#include
#include
#include
-#include
+#include
+#include
#include
#include
@@ -129,6 +132,48 @@ void MaterialEditorContextObject::changeTypeName(const QString &typeName)
incompatibleProperties.append(property.name());
}
+ // When switching between material types, copy base (diffuse) color and map properties of
+ // source type into corresponding properties of the target type.
+ const QList baseColors = {"baseColor", "diffuseColor", "albedoColor"};
+ const QList baseMaps = {"baseColorMap", "diffuseMap", "albedoMap"};
+ int sourceIndex = -1;
+ int targetIndex = -1;
+ NodeMetaInfo oldMetaInfo = m_selectedMaterial.metaInfo();
+ struct CopyData {
+ CopyData() {};
+ CopyData(PropertyName n) : name(n) {}
+ PropertyName name;
+ QVariant value;
+ bool isBinding = false;
+ };
+ QHash copyMap;
+
+ if (oldMetaInfo.isQtQuick3DPrincipledMaterial())
+ sourceIndex = 0;
+ else if (oldMetaInfo.isQtQuick3DDefaultMaterial())
+ sourceIndex = 1;
+ else if (oldMetaInfo.isQtQuick3DSpecularGlossyMaterial())
+ sourceIndex = 2;
+
+ if (metaInfo.isQtQuick3DPrincipledMaterial())
+ targetIndex = 0;
+ else if (metaInfo.isQtQuick3DDefaultMaterial())
+ targetIndex = 1;
+ else if (metaInfo.isQtQuick3DSpecularGlossyMaterial())
+ targetIndex = 2;
+
+ if (sourceIndex >= 0 && targetIndex >= 0) {
+ if (incompatibleProperties.contains(baseColors[sourceIndex])) {
+ copyMap.insert(baseColors[sourceIndex], baseColors[targetIndex]);
+ incompatibleProperties.removeOne(baseColors[sourceIndex]);
+ }
+ if (incompatibleProperties.contains(baseMaps[sourceIndex])) {
+ copyMap.insert(baseMaps[sourceIndex], baseMaps[targetIndex]);
+ incompatibleProperties.removeOne(baseMaps[sourceIndex]);
+ }
+ }
+ const auto ©Keys = copyMap.keys();
+
Utils::sort(incompatibleProperties);
// Create a dialog showing incompatible properties and signals
@@ -159,10 +204,47 @@ void MaterialEditorContextObject::changeTypeName(const QString &typeName)
m_selectedMaterial.removeProperty(p);
}
+ if (!copyKeys.isEmpty()) {
+ // Copy mapped properties to new name. Note that this will only copy the base
+ // property value and adjust the keyframe groups. Any other bindings related
+ // to the property will be ignored.
+ const QList timeLines = QmlObjectNode(m_selectedMaterial).allTimelines();
+ for (const auto &key : std::as_const(copyKeys)) {
+ CopyData ©Data = copyMap[key];
+ for (const auto &timeLineNode : timeLines) {
+ QmlTimeline timeLine(timeLineNode);
+ if (timeLine.hasKeyframeGroup(m_selectedMaterial, key)) {
+ QmlTimelineKeyframeGroup group = timeLine.keyframeGroup(m_selectedMaterial,
+ key);
+ group.setPropertyName(copyData.name);
+ }
+ }
+ // Property value itself cannot be copied until type has been changed, so store it
+ AbstractProperty prop = m_selectedMaterial.property(key);
+ if (prop.isValid()) {
+ if (prop.isBindingProperty()) {
+ copyData.isBinding = true;
+ copyData.value = prop.toBindingProperty().expression();
+ } else {
+ copyData.value = prop.toVariantProperty().value();
+ }
+ }
+ m_selectedMaterial.removeProperty(key);
+ }
+ }
+
if (m_selectedMaterial.isRootNode())
rewriterView->changeRootNodeType(metaInfo.typeName(), metaInfo.majorVersion(), metaInfo.minorVersion());
else
m_selectedMaterial.changeType(metaInfo.typeName(), metaInfo.majorVersion(), metaInfo.minorVersion());
+
+ for (const auto &key : copyKeys) {
+ const CopyData ©Data = copyMap[key];
+ if (copyData.isBinding)
+ m_selectedMaterial.bindingProperty(copyData.name).setExpression(copyData.value.toString());
+ else
+ m_selectedMaterial.variantProperty(copyData.name).setValue(copyData.value);
+ }
});
}
From ff9c170053588999670df83457df5b912ea1d996 Mon Sep 17 00:00:00 2001
From: Samuel Ghinet
Date: Thu, 15 Dec 2022 23:20:43 +0200
Subject: [PATCH 21/28] QmlDesigner: Show metadata of assets when being hovered
on
This change does not affect font files.
For all other assets, the file type is now also shown in tooltips
For image assets, the image size is also displayed.
Task-number: QDS-8177
Change-Id: Iceb93a0ffe1cb284a87cc93f1da2060f6f4f1529
Reviewed-by: Miikka Heikkinen
Reviewed-by: Thomas Hartmann
---
.../itemLibraryQmlSources/AssetDelegate.qml | 34 +++++++-
.../assetslibraryiconprovider.cpp | 81 ++++++++++++++-----
.../assetslibrary/assetslibraryiconprovider.h | 18 ++++-
.../assetslibrary/assetslibrarymodel.cpp | 5 ++
.../assetslibrary/assetslibrarymodel.h | 1 +
.../assetslibrary/assetslibrarywidget.cpp | 16 ++++
.../assetslibrary/assetslibrarywidget.h | 4 +
.../propertyeditorimageprovider.cpp | 2 +-
src/plugins/qmldesigner/utils/asset.cpp | 5 ++
src/plugins/qmldesigner/utils/asset.h | 3 +-
10 files changed, 143 insertions(+), 26 deletions(-)
diff --git a/share/qtcreator/qmldesigner/itemLibraryQmlSources/AssetDelegate.qml b/share/qtcreator/qmldesigner/itemLibraryQmlSources/AssetDelegate.qml
index 2bbfff5223c..3e8f346fdeb 100644
--- a/share/qtcreator/qmldesigner/itemLibraryQmlSources/AssetDelegate.qml
+++ b/share/qtcreator/qmldesigner/itemLibraryQmlSources/AssetDelegate.qml
@@ -182,9 +182,36 @@ TreeViewDelegate {
}
ToolTip {
+ id: assetTooltip
visible: !root.isFont && mouseArea.containsMouse && !root.assetsView.contextMenu.visible
- text: model.filePath
+ text: assetTooltip.__computeText()
delay: 1000
+
+ function __computeText()
+ {
+ let filePath = model.filePath.replace(assetsModel.contentDirPath(), "")
+ let fileSize = rootView.assetFileSize(model.filePath)
+ let fileExtMatches = model.filePath.match(/\.(.*)$/)
+ let fileExt = fileExtMatches ? "(" + fileExtMatches[1] + ")" : ""
+
+ if (rootView.assetIsImage(model.filePath)) {
+ let size = rootView.imageSize(model.filePath)
+
+ return filePath + "\n"
+ + size.width + " x " + size.height
+ + "\n" + fileSize
+ + " " + fileExt
+ } else {
+ return filePath + "\n"
+ + fileSize
+ + " " + fileExt
+ }
+ }
+
+ function refresh()
+ {
+ text = assetTooltip.__computeText()
+ }
}
Timer {
@@ -293,5 +320,10 @@ TreeViewDelegate {
: "image://qmldesigner_assets/" + model.filePath
}
+ onStatusChanged: {
+ if (thumbnailImage.status === Image.Ready)
+ assetTooltip.refresh()
+ }
+
} // Image
} // TreeViewDelegate
diff --git a/src/plugins/qmldesigner/components/assetslibrary/assetslibraryiconprovider.cpp b/src/plugins/qmldesigner/components/assetslibrary/assetslibraryiconprovider.cpp
index 14a433e8602..0dc73120f1f 100644
--- a/src/plugins/qmldesigner/components/assetslibrary/assetslibraryiconprovider.cpp
+++ b/src/plugins/qmldesigner/components/assetslibrary/assetslibraryiconprovider.cpp
@@ -22,20 +22,13 @@ QPixmap AssetsLibraryIconProvider::requestPixmap(const QString &id, QSize *size,
QPixmap pixmap;
if (m_thumbnails.contains(id)) {
- pixmap = m_thumbnails[id];
+ pixmap = m_thumbnails[id].pixmap;
} else {
- pixmap = fetchPixmap(id, requestedSize);
- bool haveValidImage = true;
- if (pixmap.isNull()) {
- pixmap = Utils::StyleHelper::dpiSpecificImageFile(":/AssetsLibrary/images/assets_default.png");
- haveValidImage = false;
- }
+ Thumbnail thumbnail = createThumbnail(id, requestedSize);
+ pixmap = thumbnail.pixmap;
- if (requestedSize.isValid())
- pixmap = pixmap.scaled(requestedSize, Qt::KeepAspectRatio);
-
- if (haveValidImage)
- m_thumbnails[id] = pixmap;
+ if (thumbnail.assetType != Asset::MissingImage)
+ m_thumbnails[id] = thumbnail;
}
if (size) {
@@ -46,6 +39,25 @@ QPixmap AssetsLibraryIconProvider::requestPixmap(const QString &id, QSize *size,
return pixmap;
}
+Thumbnail AssetsLibraryIconProvider::createThumbnail(const QString &id, const QSize &requestedSize)
+{
+ auto [pixmap, fileSize] = fetchPixmap(id, requestedSize);
+ QSize originalSize = pixmap.size();
+ Asset::Type assetType = Asset(id).type();
+
+ if (pixmap.isNull()) {
+ pixmap = Utils::StyleHelper::dpiSpecificImageFile(":/AssetsLibrary/images/assets_default.png");
+
+ if (assetType == Asset::Image)
+ assetType = Asset::MissingImage;
+ }
+
+ if (requestedSize.isValid())
+ pixmap = pixmap.scaled(requestedSize, Qt::KeepAspectRatio);
+
+ return Thumbnail{pixmap, originalSize, assetType, fileSize};
+}
+
QPixmap AssetsLibraryIconProvider::generateFontIcons(const QString &filePath, const QSize &requestedSize) const
{
QSize reqSize = requestedSize.isValid() ? requestedSize : QSize{48, 48};
@@ -55,18 +67,25 @@ QPixmap AssetsLibraryIconProvider::generateFontIcons(const QString &filePath, co
"Abc"}).pixmap(reqSize);
}
-QPixmap AssetsLibraryIconProvider::fetchPixmap(const QString &id, const QSize &requestedSize) const
+QPair AssetsLibraryIconProvider::fetchPixmap(const QString &id, const QSize &requestedSize) const
{
Asset asset(id);
if (id == "browse") {
- return Utils::StyleHelper::dpiSpecificImageFile(":/AssetsLibrary/images/browse.png");
+ QString filePath = Utils::StyleHelper::dpiSpecificImageFile(":/AssetsLibrary/images/browse.png");
+ return {QPixmap{filePath}, 0};
} else if (asset.isFont()) {
- return generateFontIcons(id, requestedSize);
+ qint64 size = QFileInfo(id).size();
+ QPixmap pixmap = generateFontIcons(id, requestedSize);
+ return {pixmap, size};
} else if (asset.isImage()) {
- return Utils::StyleHelper::dpiSpecificImageFile(id);
- } else if (asset.isTexture3D()) {
- return HdrImage{id}.toPixmap();
+ QString filePath = Utils::StyleHelper::dpiSpecificImageFile(id);
+ qint64 size = QFileInfo(filePath).size();
+ return {QPixmap{filePath}, size};
+ } else if (asset.isHdrFile()) {
+ qint64 size = QFileInfo(id).size();
+ QPixmap pixmap = HdrImage{id}.toPixmap();
+ return {pixmap, size};
} else {
QString type;
if (asset.isShader())
@@ -81,9 +100,11 @@ QPixmap AssetsLibraryIconProvider::fetchPixmap(const QString &id, const QSize &r
QString pathTemplate = QString(":/AssetsLibrary/images/asset_%1%2.png").arg(type);
QString path = pathTemplate.arg('_' + QString::number(requestedSize.width()));
- return Utils::StyleHelper::dpiSpecificImageFile(QFileInfo::exists(path)
- ? path
- : pathTemplate.arg(""));
+ QString filePath = Utils::StyleHelper::dpiSpecificImageFile(QFileInfo::exists(path)
+ ? path
+ : pathTemplate.arg(""));
+ qint64 size = QFileInfo(filePath).size();
+ return {QPixmap{filePath}, size};
}
}
@@ -97,5 +118,23 @@ void AssetsLibraryIconProvider::invalidateThumbnail(const QString &id)
m_thumbnails.remove(id);
}
+QSize AssetsLibraryIconProvider::imageSize(const QString &id)
+{
+ static QSize invalidSize = {};
+ return m_thumbnails.contains(id) ? m_thumbnails[id].originalSize : invalidSize;
+}
+
+qint64 AssetsLibraryIconProvider::fileSize(const QString &id)
+{
+ return m_thumbnails.contains(id) ? m_thumbnails[id].fileSize : 0;
+}
+
+bool AssetsLibraryIconProvider::assetIsImage(const QString &id)
+{
+ return m_thumbnails.contains(id)
+ ? (m_thumbnails[id].assetType == Asset::Type::Image || Asset(id).isHdrFile())
+ : false;
+}
+
} // namespace QmlDesigner
diff --git a/src/plugins/qmldesigner/components/assetslibrary/assetslibraryiconprovider.h b/src/plugins/qmldesigner/components/assetslibrary/assetslibraryiconprovider.h
index b18d8e70111..b089af4c89a 100644
--- a/src/plugins/qmldesigner/components/assetslibrary/assetslibraryiconprovider.h
+++ b/src/plugins/qmldesigner/components/assetslibrary/assetslibraryiconprovider.h
@@ -7,8 +7,18 @@
#include
+#include "asset.h"
+
namespace QmlDesigner {
+struct Thumbnail
+{
+ QPixmap pixmap;
+ QSize originalSize;
+ Asset::Type assetType;
+ qint64 fileSize;
+};
+
class AssetsLibraryIconProvider : public QQuickImageProvider
{
public:
@@ -17,10 +27,14 @@ public:
QPixmap requestPixmap(const QString &id, QSize *size, const QSize &requestedSize) override;
void clearCache();
void invalidateThumbnail(const QString &id);
+ QSize imageSize(const QString &id);
+ qint64 fileSize(const QString &id);
+ bool assetIsImage(const QString &id);
private:
QPixmap generateFontIcons(const QString &filePath, const QSize &requestedSize) const;
- QPixmap fetchPixmap(const QString &id, const QSize &requestedSize) const;
+ QPair fetchPixmap(const QString &id, const QSize &requestedSize) const;
+ Thumbnail createThumbnail(const QString &id, const QSize &requestedSize);
SynchronousImageCache &m_fontImageCache;
@@ -29,7 +43,7 @@ private:
std::vector iconSizes = {{128, 128}, // Drag
{96, 96}, // list @2x
{48, 48}}; // list
- QHash m_thumbnails;
+ QHash m_thumbnails;
};
} // namespace QmlDesigner
diff --git a/src/plugins/qmldesigner/components/assetslibrary/assetslibrarymodel.cpp b/src/plugins/qmldesigner/components/assetslibrary/assetslibrarymodel.cpp
index 0953eff9eb1..940a0b85fe1 100644
--- a/src/plugins/qmldesigner/components/assetslibrary/assetslibrarymodel.cpp
+++ b/src/plugins/qmldesigner/components/assetslibrary/assetslibrarymodel.cpp
@@ -91,6 +91,11 @@ QString AssetsLibraryModel::currentProjectDirPath() const
return DocumentManager::currentProjectDirPath().toString().append('/');
}
+QString AssetsLibraryModel::contentDirPath() const
+{
+ return DocumentManager::currentResourcePath().toString().append('/');
+}
+
bool AssetsLibraryModel::requestDeleteFiles(const QStringList &filePaths)
{
bool askBeforeDelete = QmlDesignerPlugin::settings()
diff --git a/src/plugins/qmldesigner/components/assetslibrary/assetslibrarymodel.h b/src/plugins/qmldesigner/components/assetslibrary/assetslibrarymodel.h
index 0538bedf42b..71d5c6fa457 100644
--- a/src/plugins/qmldesigner/components/assetslibrary/assetslibrarymodel.h
+++ b/src/plugins/qmldesigner/components/assetslibrary/assetslibrarymodel.h
@@ -40,6 +40,7 @@ public:
Q_INVOKABLE QList parentIndices(const QModelIndex &index) const;
Q_INVOKABLE bool indexIsValid(const QModelIndex &index) const;
Q_INVOKABLE QString currentProjectDirPath() const;
+ Q_INVOKABLE QString contentDirPath() const;
Q_INVOKABLE bool requestDeleteFiles(const QStringList &filePaths);
Q_INVOKABLE void deleteFiles(const QStringList &filePaths, bool dontAskAgain);
Q_INVOKABLE bool renameFolder(const QString &folderPath, const QString &newName);
diff --git a/src/plugins/qmldesigner/components/assetslibrary/assetslibrarywidget.cpp b/src/plugins/qmldesigner/components/assetslibrary/assetslibrarywidget.cpp
index cc9263eda46..032317eb4db 100644
--- a/src/plugins/qmldesigner/components/assetslibrary/assetslibrarywidget.cpp
+++ b/src/plugins/qmldesigner/components/assetslibrary/assetslibrarywidget.cpp
@@ -165,6 +165,22 @@ void AssetsLibraryWidget::invalidateThumbnail(const QString &id)
m_assetsIconProvider->invalidateThumbnail(id);
}
+QSize AssetsLibraryWidget::imageSize(const QString &id)
+{
+ return m_assetsIconProvider->imageSize(id);
+}
+
+QString AssetsLibraryWidget::assetFileSize(const QString &id)
+{
+ qint64 fileSize = m_assetsIconProvider->fileSize(id);
+ return QLocale::system().formattedDataSize(fileSize, 2, QLocale::DataSizeTraditionalFormat);
+}
+
+bool AssetsLibraryWidget::assetIsImage(const QString &id)
+{
+ return m_assetsIconProvider->assetIsImage(id);
+}
+
QList AssetsLibraryWidget::createToolBarWidgets()
{
return {};
diff --git a/src/plugins/qmldesigner/components/assetslibrary/assetslibrarywidget.h b/src/plugins/qmldesigner/components/assetslibrary/assetslibrarywidget.h
index 90a7038b5db..2ef59ac9584 100644
--- a/src/plugins/qmldesigner/components/assetslibrary/assetslibrarywidget.h
+++ b/src/plugins/qmldesigner/components/assetslibrary/assetslibrarywidget.h
@@ -74,6 +74,10 @@ public:
Q_INVOKABLE void openEffectMaker(const QString &filePath);
Q_INVOKABLE bool qtVersionIsAtLeast6_4() const;
Q_INVOKABLE void invalidateThumbnail(const QString &id);
+ Q_INVOKABLE QSize imageSize(const QString &id);
+ Q_INVOKABLE QString assetFileSize(const QString &id);
+ Q_INVOKABLE bool assetIsImage(const QString &id);
+
Q_INVOKABLE void addTextures(const QStringList &filePaths);
Q_INVOKABLE void addLightProbe(const QString &filePaths);
diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorimageprovider.cpp b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorimageprovider.cpp
index fc5a09818ca..fb17f6dee82 100644
--- a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorimageprovider.cpp
+++ b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorimageprovider.cpp
@@ -36,7 +36,7 @@ QQuickImageResponse *PropertyEditorImageProvider::requestImageResponse(const QSt
response->setImage(image.scaled(requestedSize, Qt::KeepAspectRatio));
return;
}
- } else if (asset.isTexture3D()) {
+ } else if (asset.isHdrFile()) {
HdrImage hdr{asset.id()};
if (!hdr.image().isNull()) {
response->setImage(hdr.image().scaled(requestedSize, Qt::KeepAspectRatio));
diff --git a/src/plugins/qmldesigner/utils/asset.cpp b/src/plugins/qmldesigner/utils/asset.cpp
index 6a0a4658429..0dc66eeb3c6 100644
--- a/src/plugins/qmldesigner/utils/asset.cpp
+++ b/src/plugins/qmldesigner/utils/asset.cpp
@@ -154,6 +154,11 @@ bool Asset::isTexture3D() const
return type() == Asset::Type::Texture3D;
}
+bool Asset::isHdrFile() const
+{
+ return m_suffix == "*.hdr";
+}
+
bool Asset::isEffect() const
{
return type() == Asset::Type::Effect;
diff --git a/src/plugins/qmldesigner/utils/asset.h b/src/plugins/qmldesigner/utils/asset.h
index 279edb93e1b..e673f102387 100644
--- a/src/plugins/qmldesigner/utils/asset.h
+++ b/src/plugins/qmldesigner/utils/asset.h
@@ -8,7 +8,7 @@ namespace QmlDesigner {
class Asset
{
public:
- enum Type { Unknown, Image, FragmentShader, Font, Audio, Video, Texture3D, Effect, Shader };
+ enum Type { Unknown, Image, MissingImage, FragmentShader, Font, Audio, Video, Texture3D, Effect, Shader };
Asset(const QString &filePath);
@@ -34,6 +34,7 @@ public:
bool isAudio() const;
bool isVideo() const;
bool isTexture3D() const;
+ bool isHdrFile() const;
bool isEffect() const;
bool isSupported() const;
From 9df7a6bdadcb5804041b18c6f9452a06653cd454 Mon Sep 17 00:00:00 2001
From: Henning Gruendl
Date: Mon, 12 Dec 2022 16:44:20 +0100
Subject: [PATCH 22/28] QmlDesigner: Fix SpinBox dragging
Change-Id: I9d6ef0fa03e7d9a26dea9eb98602238d5dacd28c
Reviewed-by:
Reviewed-by: Thomas Hartmann
---
.../imports/StudioControls/SpinBoxInput.qml | 46 +++++--------------
1 file changed, 11 insertions(+), 35 deletions(-)
diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioControls/SpinBoxInput.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioControls/SpinBoxInput.qml
index f1735f96a0e..d5fede0fcbd 100644
--- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioControls/SpinBoxInput.qml
+++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioControls/SpinBoxInput.qml
@@ -51,33 +51,6 @@ TextInput {
border.width: 0
}
- DragHandler {
- id: dragHandler
- target: null
- acceptedDevices: PointerDevice.Mouse
- enabled: true
-
- property int initialValue: 0
-
- onActiveChanged: {
- if (active) {
- initialValue = myControl.value
- mouseArea.cursorShape = Qt.ClosedHandCursor
- myControl.drag = true
- } else {
- mouseArea.cursorShape = Qt.PointingHandCursor
- myControl.drag = false
- }
- }
- onTranslationChanged: {
- var currValue = myControl.value
- myControl.value = initialValue + translation.x
-
- if (currValue !== myControl.value)
- myControl.valueModified()
- }
- }
-
Item {
id: dragModifierWorkaround
Keys.onPressed: function(event) {
@@ -86,17 +59,20 @@ TextInput {
if (event.modifiers & Qt.ControlModifier) {
mouseArea.stepSize = myControl.minStepSize
mouseArea.calcValue()
+ myControl.valueModified()
}
if (event.modifiers & Qt.ShiftModifier) {
mouseArea.stepSize = myControl.maxStepSize
mouseArea.calcValue()
+ myControl.valueModified()
}
}
Keys.onReleased: function(event) {
event.accepted = true
- mouseArea.stepSize = myControl.realStepSize
+ mouseArea.stepSize = myControl.stepSize
mouseArea.calcValue()
+ myControl.valueModified()
}
}
@@ -117,13 +93,13 @@ TextInput {
property int initialValue: myControl.value // value on drag operation starts
- property int pressStartX: 0
- property int dragStartX: 0
- property int translationX: 0
+ property real pressStartX: 0.0
+ property real dragStartX: 0.0
+ property real translationX: 0.0
- property int dragDirection: 0
- property int totalUnits: 0 // total number of units dragged
- property int units: 0
+ property real dragDirection: 0.0
+ property real totalUnits: 0.0 // total number of units dragged
+ property real units: 0.0
property real __pixelsPerUnit: textInput.devicePixelRatio * textInput.pixelsPerUnit
@@ -176,7 +152,7 @@ TextInput {
mouseArea.translationX += translationX
mouseArea.calcValue()
- //myControl.realValueModified()
+ myControl.valueModified()
}
onClicked: function(mouse) {
From f7ef0c31e8868ddd2e413de2e5644b09e752ef63 Mon Sep 17 00:00:00 2001
From: Henning Gruendl
Date: Mon, 9 Jan 2023 15:53:08 +0100
Subject: [PATCH 23/28] QmlDesigner: Add QRect to node meta value types
Change-Id: I205d30a362dce4df5834dfa99974e63b3b9bf608
Reviewed-by: Thomas Hartmann
---
.../qmldesigner/designercore/metainfo/nodemetainfo.cpp | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp b/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp
index 871c8b4c2a5..524ab45716e 100644
--- a/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp
+++ b/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp
@@ -343,6 +343,8 @@ static inline bool isValueType(const TypeName &type)
"QPointF",
"QSize",
"QSizeF",
+ "QRect",
+ "QRectF",
"QVector2D",
"QVector3D",
"QVector4D",
@@ -361,6 +363,8 @@ static inline bool isValueType(const QString &type)
"QPointF",
"QSize",
"QSizeF",
+ "QRect",
+ "QRectF",
"QVector2D",
"QVector3D",
"QVector4D",
From 4a897e0395d436fa7109e43a0e2781e5676e81df Mon Sep 17 00:00:00 2001
From: Henning Gruendl
Date: Mon, 9 Jan 2023 15:54:53 +0100
Subject: [PATCH 24/28] QmlDesigner: Enable sourceRect property
Enable sourceRect property to Item layer specifics
Change-Id: If2f47c2ad47a083d5c4a30c9154a7631616ea257
Reviewed-by: Pranta Ghosh Dastider
Reviewed-by: Thomas Hartmann
---
.../propertyEditorQmlSources/QtQuick/LayerSection.qml | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/LayerSection.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/LayerSection.qml
index 72455eeef50..b4752192f51 100644
--- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/LayerSection.qml
+++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/LayerSection.qml
@@ -235,10 +235,10 @@ Section {
ExpandingSpacer {}
}
-/*
+
PropertyLabel {
- text: qsTr("Source Rectangle")
- tooltip: qsTr("TODO.")
+ text: qsTr("Source rectangle")
+ tooltip: qsTr("Sets the rectangular area of the component that should be rendered into the texture.")
}
SecondColumnLayout {
@@ -313,6 +313,5 @@ Section {
ExpandingSpacer {}
}
-*/
}
}
From 6fba34f5a73c3df2c8b23ddc1fff8b41bd4e07ee Mon Sep 17 00:00:00 2001
From: Henning Gruendl
Date: Wed, 11 Jan 2023 11:12:50 +0100
Subject: [PATCH 25/28] QmlDesigner: Fix reflection in ColorEditor
Change-Id: I0d4cced42dd2b1d98f46c9870ca206e83b3aa4db
Reviewed-by: Thomas Hartmann
---
.../imports/HelperWidgets/ColorEditor.qml | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/ColorEditor.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/ColorEditor.qml
index 32e33744330..4742f1c0277 100644
--- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/ColorEditor.qml
+++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/ColorEditor.qml
@@ -38,12 +38,21 @@ SecondColumnLayout {
property alias spacer: spacer
+ property bool __block: false
+
function resetShapeColor() {
colorEditor.backendValue.resetValue()
}
function initEditor() {
+ colorEditor.syncColor()
+ }
+
+ // Syncing color from backend to frontend and block reflection
+ function syncColor() {
+ colorEditor.__block = true
colorEditor.color = colorEditor.value
+ colorEditor.__block = false
}
Connections {
@@ -52,12 +61,12 @@ SecondColumnLayout {
function onValueChanged() {
if (popupLoader.isNotInGradientMode())
- colorEditor.color = colorEditor.value
+ colorEditor.syncColor()
}
function onBackendValueChanged() {
if (popupLoader.isNotInGradientMode())
- colorEditor.color = colorEditor.value
+ colorEditor.syncColor()
}
}
@@ -83,6 +92,9 @@ SecondColumnLayout {
}
onColorChanged: {
+ if (colorEditor.__block)
+ return
+
if (!popupLoader.isInValidState)
return
@@ -211,7 +223,7 @@ SecondColumnLayout {
if (popupLoader.active && popupLoader.dialog)
popupLoader.dialog.determineActiveColorMode()
else
- colorEditor.color = colorEditor.value
+ colorEditor.syncColor()
}
property alias active: popupLoader.loader.active
From 65567b4717a1280a8c25c5690148067cec96011b Mon Sep 17 00:00:00 2001
From: Henning Gruendl
Date: Tue, 10 Jan 2023 15:28:13 +0100
Subject: [PATCH 26/28] QmlDesigner: Fix value types in property editor
Currently the value types of e.g. layer.textureSize and layer.sourceRect
are only resolved for QML Item, but not QML Control. This patch
increases the recursion depth while collecting the attributes of values
types in order to be able to set layer.textureSize.width or
layer.sourceRect.x.
It also adds those attributes to be able to read the values.
Change-Id: I61ba1468d1443953f0a5b6ab2241114dc441bb79
Reviewed-by: Thomas Hartmann
Reviewed-by:
Reviewed-by: Qt CI Bot
---
.../designercore/metainfo/nodemetainfo.cpp | 19 +++++---
.../instances/objectnodeinstance.cpp | 45 ++++++++++++++++++-
.../qml2puppet/instances/objectnodeinstance.h | 1 +
3 files changed, 58 insertions(+), 7 deletions(-)
diff --git a/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp b/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp
index 524ab45716e..b61dff80a45 100644
--- a/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp
+++ b/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp
@@ -409,7 +409,7 @@ QVector getQmlTypes(const CppComponentValue *objectValue, const Co
if (objectValue->className().isEmpty())
return propertyList;
- if (rec > 2)
+ if (rec > 4)
return propertyList;
PropertyMemberProcessor processor(context);
@@ -431,9 +431,14 @@ QVector getQmlTypes(const CppComponentValue *objectValue, const Co
}
}
if (isValueType(objectValue->propertyType(nameAsString))) {
- const ObjectValue *dotObjectValue = value_cast(objectValue->lookupMember(nameAsString, context));
+ const ObjectValue *dotObjectValue = value_cast(
+ objectValue->lookupMember(nameAsString, context));
+
if (dotObjectValue) {
- const QVector dotProperties = getObjectTypes(dotObjectValue, context, false, rec + 1);
+ const QVector dotProperties = getObjectTypes(dotObjectValue,
+ context,
+ false,
+ rec + 1);
for (const PropertyInfo &propertyInfo : dotProperties) {
const PropertyName dotName = name + '.' + propertyInfo.first;
const TypeName type = propertyInfo.second;
@@ -525,7 +530,7 @@ QVector getObjectTypes(const ObjectValue *objectValue, const Conte
if (objectValue->className().isEmpty())
return propertyList;
- if (rec > 2)
+ if (rec > 4)
return propertyList;
PropertyMemberProcessor processor(context);
@@ -539,6 +544,7 @@ QVector getObjectTypes(const ObjectValue *objectValue, const Conte
if (isValueType(property.second)) {
const Value *dotValue = objectValue->lookupMember(nameAsString, context);
+
if (!dotValue)
continue;
@@ -546,7 +552,10 @@ QVector getObjectTypes(const ObjectValue *objectValue, const Conte
dotValue = context->lookupReference(ref);
if (const ObjectValue *dotObjectValue = dotValue->asObjectValue()) {
- const QVector dotProperties = getObjectTypes(dotObjectValue, context, false, rec + 1);
+ const QVector dotProperties = getObjectTypes(dotObjectValue,
+ context,
+ false,
+ rec + 1);
for (const PropertyInfo &propertyInfo : dotProperties) {
const PropertyName dotName = name + '.' + propertyInfo.first;
const TypeName type = propertyInfo.second;
diff --git a/src/tools/qml2puppet/qml2puppet/instances/objectnodeinstance.cpp b/src/tools/qml2puppet/qml2puppet/instances/objectnodeinstance.cpp
index 49720c38d46..0d601cb91e9 100644
--- a/src/tools/qml2puppet/qml2puppet/instances/objectnodeinstance.cpp
+++ b/src/tools/qml2puppet/qml2puppet/instances/objectnodeinstance.cpp
@@ -567,6 +567,15 @@ void ObjectNodeInstance::doResetProperty(const PropertyName &propertyName)
QmlPrivateGate::doResetProperty(object(), context(), propertyName);
}
+static bool isPropertyBlackListed(const PropertyName &propertyName)
+{
+ if (propertyName.contains(".") && propertyName.contains("__"))
+ return true;
+ if (propertyName.count(".") > 2)
+ return true;
+ return false;
+}
+
QVariant ObjectNodeInstance::property(const PropertyName &name) const
{
if (ignoredProperties().contains(name))
@@ -574,7 +583,7 @@ QVariant ObjectNodeInstance::property(const PropertyName &name) const
// TODO: handle model nodes
- if (QmlPrivateGate::isPropertyBlackListed(name))
+ if (isPropertyBlackListed(name))
return QVariant();
QQmlProperty property(object(), QString::fromUtf8(name), context());
@@ -612,6 +621,37 @@ void ObjectNodeInstance::ensureVector3DDotProperties(PropertyNameList &list) con
}
}
+void ObjectNodeInstance::ensureValueTypeProperties(PropertyNameList &list) const
+{
+ const PropertyNameList pointDotProperties = {"x", "y"};
+ const PropertyNameList sizeDotProperties = {"width", "height"};
+ const PropertyNameList rectDotProperties = {"x", "y", "width", "height"};
+
+ PropertyNameList valueTypeProperties;
+
+ for (const auto &property : list) {
+ const QString name = instanceType(property);
+ PropertyNameList dotProperties;
+
+ if (name == "QPoint" || name == "QPointF")
+ dotProperties = pointDotProperties;
+
+ if (name == "QSize" || name == "QSizeF")
+ dotProperties = sizeDotProperties;
+
+ if (name == "QRect" || name == "QRectF")
+ dotProperties = rectDotProperties;
+
+ for (const auto &dotProperty : dotProperties)
+ valueTypeProperties.append(property + "." + dotProperty);
+ }
+
+ for (const auto &valueTypeProperty : valueTypeProperties) {
+ if (!list.contains(valueTypeProperty))
+ list.append(valueTypeProperty);
+ }
+}
+
PropertyNameList ObjectNodeInstance::propertyNames() const
{
PropertyNameList list;
@@ -619,13 +659,14 @@ PropertyNameList ObjectNodeInstance::propertyNames() const
list = QmlPrivateGate::allPropertyNames(object());
ensureVector3DDotProperties(list);
+ ensureValueTypeProperties(list);
return list;
}
QString ObjectNodeInstance::instanceType(const PropertyName &name) const
{
- if (QmlPrivateGate::isPropertyBlackListed(name))
+ if (isPropertyBlackListed(name))
return QLatin1String("undefined");
QQmlProperty property(object(), QString::fromUtf8(name), context());
diff --git a/src/tools/qml2puppet/qml2puppet/instances/objectnodeinstance.h b/src/tools/qml2puppet/qml2puppet/instances/objectnodeinstance.h
index f4724e6cd71..0b2c0e6337c 100644
--- a/src/tools/qml2puppet/qml2puppet/instances/objectnodeinstance.h
+++ b/src/tools/qml2puppet/qml2puppet/instances/objectnodeinstance.h
@@ -199,6 +199,7 @@ protected:
void initializePropertyWatcher(const ObjectNodeInstance::Pointer &objectNodeInstance);
void ensureVector3DDotProperties(PropertyNameList &list) const;
+ void ensureValueTypeProperties(PropertyNameList &list) const;
private:
QString m_id;
From b2163f672f8bc2a64280697492e349fa72ba0dc9 Mon Sep 17 00:00:00 2001
From: Ali Kianian
Date: Fri, 16 Dec 2022 10:38:59 +0200
Subject: [PATCH 27/28] QmlDesigner: Add designer icons to the context menu
New Icon-Font is available in this patch.
Designer Icons are visible in the context menu.
Icon settings would be loaded from a json file.
Task-number: QDS-8502
Change-Id: Ia5fb570317507e6f50a79231d5b6831df079ed8b
Reviewed-by:
Reviewed-by: Thomas Hartmann
---
.../qtcreator/qmldesigner/designericons.json | 81 ++++
.../imports/StudioTheme/InternalConstants.qml | 179 ++++----
.../imports/StudioTheme/icons.ttf | Bin 24432 -> 29604 bytes
src/plugins/qmldesigner/CMakeLists.txt | 1 +
.../componentcore/designeractionmanager.cpp | 90 ++--
.../componentcore/designeractionmanager.h | 5 +
.../componentcore/designericons.cpp | 418 ++++++++++++++++++
.../components/componentcore/designericons.h | 133 ++++++
.../componentcore/modelnodecontextmenu.cpp | 2 +-
.../modelnodecontextmenu_helper.h | 3 +-
.../components/componentcore/theme.h | 27 ++
.../eventlist/eventlistpluginview.cpp | 2 +
.../formeditor/formeditorwidget.cpp | 2 +
.../timelineeditor/timelineview.cpp | 2 +
.../qmlpreviewplugin/qmlpreviewplugin.cpp | 1 +
15 files changed, 843 insertions(+), 103 deletions(-)
create mode 100644 share/qtcreator/qmldesigner/designericons.json
create mode 100644 src/plugins/qmldesigner/components/componentcore/designericons.cpp
create mode 100644 src/plugins/qmldesigner/components/componentcore/designericons.h
diff --git a/share/qtcreator/qmldesigner/designericons.json b/share/qtcreator/qmldesigner/designericons.json
new file mode 100644
index 00000000000..e4201291c64
--- /dev/null
+++ b/share/qtcreator/qmldesigner/designericons.json
@@ -0,0 +1,81 @@
+{
+ "ContextMenuArea": {
+ "size": "28x28",
+ "Off": {
+ "Disabled": { "color": "DSiconColorDisabled" },
+ "Hovered": { "color": "DSnavigatorIconHover" },
+ "Normal": { "color": "DSnavigatorIcon" },
+ "Selected": { "color": "DSnavigatorIconSelected" }
+ },
+ "On": {
+ "Disabled": { "color": "DSiconColorDisabled" },
+ "Hovered": { "color": "DSnavigatorIconHover" },
+ "Normal": { "color": "DSnavigatorIcon" },
+ "Selected": { "color": "DSnavigatorIconSelected" }
+ }
+ },
+ "AddMouseAreaIcon": {
+ "iconName": "s_mouseArea"
+ },
+ "AnchorsIcon": {
+ "iconName": "s_anchors"
+ },
+ "AnnotationIcon": {
+ "iconName": "s_annotations"
+ },
+ "ArrangeIcon": {
+ "iconName": "s_arrange"
+ },
+ "ConnectionsIcon": {
+ "iconName": "s_connections"
+ },
+ "EditIcon": {
+ "iconName": "s_edit"
+ },
+ "EnterComponentIcon": {
+ "iconName": "s_enterComponent"
+ },
+ "EventListIcon": {
+ "iconName": "s_eventList"
+ },
+ "GroupSelectionIcon": {
+ "iconName": "s_group"
+ },
+ "LayoutsIcon": {
+ "iconName": "s_layouts"
+ },
+ "MakeComponentIcon": {
+ "iconName": "s_component"
+ },
+ "MergeWithTemplateIcon": {
+ "iconName": "s_merging"
+ },
+ "PositionsersIcon": {
+ "iconName": "s_positioners"
+ },
+ "SelecionIcon": {
+ "iconName": "s_selection"
+ },
+ "ShowBoundsIcon": {
+ "Off": {
+ "iconName": "visibilityOff"
+ },
+ "On": {
+ "iconName": "visibilityOn"
+ }
+ },
+ "SnappingIcon": {
+ "iconName": "s_snapping"
+ },
+ "TimelineIcon": {
+ "iconName": "s_timeline"
+ },
+ "VisibilityIcon": {
+ "Off": {
+ "iconName": "visibilityOff"
+ },
+ "On": {
+ "iconName": "visibilityOn"
+ }
+ }
+}
diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioTheme/InternalConstants.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioTheme/InternalConstants.qml
index 9339fda0daa..cdad4b7e1a7 100644
--- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioTheme/InternalConstants.qml
+++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioTheme/InternalConstants.qml
@@ -95,82 +95,109 @@ QtObject {
readonly property string gridView: "\u0070"
readonly property string idAliasOff: "\u0071"
readonly property string idAliasOn: "\u0072"
- readonly property string infinity: "\u0073"
- readonly property string keyframe: "\u0074"
- readonly property string linkTriangle: "\u0075"
- readonly property string linked: "\u0076"
- readonly property string listView: "\u0077"
- readonly property string lockOff: "\u0078"
- readonly property string lockOn: "\u0079"
- readonly property string materialPreviewEnvironment: "\u007A"
- readonly property string materialPreviewModel: "\u007B"
- readonly property string mergeCells: "\u007C"
- readonly property string minus: "\u007D"
- readonly property string mirror: "\u007E"
- readonly property string newMaterial: "\u007F"
- readonly property string openLink: "\u0080"
- readonly property string openMaterialBrowser: "\u0081"
- readonly property string orientation: "\u0082"
- readonly property string paddingEdge: "\u0083"
- readonly property string paddingFrame: "\u0084"
- readonly property string pasteStyle: "\u0085"
- readonly property string pause: "\u0086"
- readonly property string pin: "\u0087"
- readonly property string play: "\u0088"
- readonly property string plus: "\u0089"
- readonly property string promote: "\u008A"
- readonly property string readOnly: "\u008B"
- readonly property string redo: "\u008C"
- readonly property string rotationFill: "\u008D"
- readonly property string rotationOutline: "\u008E"
- readonly property string search: "\u008F"
- readonly property string sectionToggle: "\u0090"
- readonly property string splitColumns: "\u0091"
- readonly property string splitRows: "\u0092"
- readonly property string startNode: "\u0093"
- readonly property string testIcon: "\u0094"
- readonly property string textAlignBottom: "\u0095"
- readonly property string textAlignCenter: "\u0096"
- readonly property string textAlignJustified: "\u0097"
- readonly property string textAlignLeft: "\u0098"
- readonly property string textAlignMiddle: "\u0099"
- readonly property string textAlignRight: "\u009A"
- readonly property string textAlignTop: "\u009B"
- readonly property string textBulletList: "\u009D"
- readonly property string textFullJustification: "\u009E"
- readonly property string textNumberedList: "\u009F"
- readonly property string tickIcon: "\u00A0"
- readonly property string translationCreateFiles: "\u00A1"
- readonly property string translationCreateReport: "\u00A2"
- readonly property string translationExport: "\u00A3"
- readonly property string translationImport: "\u00A4"
- readonly property string translationSelectLanguages: "\u00A5"
- readonly property string translationTest: "\u00A6"
- readonly property string transparent: "\u00A7"
- readonly property string triState: "\u00A8"
- readonly property string triangleArcA: "\u00A9"
- readonly property string triangleArcB: "\u00AA"
- readonly property string triangleCornerA: "\u00AB"
- readonly property string triangleCornerB: "\u00AC"
- readonly property string unLinked: "\u00AE"
- readonly property string undo: "\u00AF"
- readonly property string unpin: "\u00B0"
- readonly property string upDownIcon: "\u00B1"
- readonly property string upDownSquare2: "\u00B2"
- readonly property string visibilityOff: "\u00B3"
- readonly property string visibilityOn: "\u00B4"
- readonly property string wildcard: "\u00B5"
- readonly property string wizardsAutomotive: "\u00B6"
- readonly property string wizardsDesktop: "\u00B7"
- readonly property string wizardsGeneric: "\u00B8"
- readonly property string wizardsMcuEmpty: "\u00B9"
- readonly property string wizardsMcuGraph: "\u00BA"
- readonly property string wizardsMobile: "\u00BB"
- readonly property string wizardsUnknown: "\u00BC"
- readonly property string zoomAll: "\u00BD"
- readonly property string zoomIn: "\u00BE"
- readonly property string zoomOut: "\u00BF"
- readonly property string zoomSelection: "\u00C0"
+ readonly property string imported: "\u0073"
+ readonly property string infinity: "\u0074"
+ readonly property string keyframe: "\u0075"
+ readonly property string linkTriangle: "\u0076"
+ readonly property string linked: "\u0077"
+ readonly property string listView: "\u0078"
+ readonly property string lockOff: "\u0079"
+ readonly property string lockOn: "\u007A"
+ readonly property string materialPreviewEnvironment: "\u007B"
+ readonly property string materialPreviewModel: "\u007C"
+ readonly property string mergeCells: "\u007D"
+ readonly property string minus: "\u007E"
+ readonly property string mirror: "\u007F"
+ readonly property string newMaterial: "\u0080"
+ readonly property string openLink: "\u0081"
+ readonly property string openMaterialBrowser: "\u0082"
+ readonly property string orientation: "\u0083"
+ readonly property string paddingEdge: "\u0084"
+ readonly property string paddingFrame: "\u0085"
+ readonly property string pasteStyle: "\u0086"
+ readonly property string pause: "\u0087"
+ readonly property string pin: "\u0088"
+ readonly property string play: "\u0089"
+ readonly property string plus: "\u008A"
+ readonly property string promote: "\u008B"
+ readonly property string readOnly: "\u008C"
+ readonly property string redo: "\u008D"
+ readonly property string rotationFill: "\u008E"
+ readonly property string rotationOutline: "\u008F"
+ readonly property string s_anchors: "\u0090"
+ readonly property string s_annotations: "\u0091"
+ readonly property string s_arrange: "\u0092"
+ readonly property string s_boundingBox: "\u0093"
+ readonly property string s_component: "\u0094"
+ readonly property string s_connections: "\u0095"
+ readonly property string s_edit: "\u0096"
+ readonly property string s_enterComponent: "\u0097"
+ readonly property string s_eventList: "\u0098"
+ readonly property string s_group: "\u0099"
+ readonly property string s_layouts: "\u009A"
+ readonly property string s_merging: "\u009B"
+ readonly property string s_mouseArea: "\u009D"
+ readonly property string s_positioners: "\u009E"
+ readonly property string s_selection: "\u009F"
+ readonly property string s_snapping: "\u00A0"
+ readonly property string s_timeline: "\u00A1"
+ readonly property string s_visibility: "\u00A2"
+ readonly property string search: "\u00A3"
+ readonly property string sectionToggle: "\u00A4"
+ readonly property string splitColumns: "\u00A5"
+ readonly property string splitRows: "\u00A6"
+ readonly property string startNode: "\u00A7"
+ readonly property string testIcon: "\u00A8"
+ readonly property string textAlignBottom: "\u00A9"
+ readonly property string textAlignCenter: "\u00AA"
+ readonly property string textAlignJustified: "\u00AB"
+ readonly property string textAlignLeft: "\u00AC"
+ readonly property string textAlignMiddle: "\u00AE"
+ readonly property string textAlignRight: "\u00AF"
+ readonly property string textAlignTop: "\u00B0"
+ readonly property string textBulletList: "\u00B1"
+ readonly property string textFullJustification: "\u00B2"
+ readonly property string textNumberedList: "\u00B3"
+ readonly property string tickIcon: "\u00B4"
+ readonly property string topToolbar_annotations: "\u00B5"
+ readonly property string topToolbar_closeFile: "\u00B6"
+ readonly property string topToolbar_designMode: "\u00B7"
+ readonly property string topToolbar_enterComponent: "\u00B8"
+ readonly property string topToolbar_home: "\u00B9"
+ readonly property string topToolbar_makeComponent: "\u00BA"
+ readonly property string topToolbar_navFile: "\u00BB"
+ readonly property string topToolbar_runProject: "\u00BC"
+ readonly property string translationCreateFiles: "\u00BD"
+ readonly property string translationCreateReport: "\u00BE"
+ readonly property string translationExport: "\u00BF"
+ readonly property string translationImport: "\u00C0"
+ readonly property string translationSelectLanguages: "\u00C1"
+ readonly property string translationTest: "\u00C2"
+ readonly property string transparent: "\u00C3"
+ readonly property string triState: "\u00C4"
+ readonly property string triangleArcA: "\u00C5"
+ readonly property string triangleArcB: "\u00C6"
+ readonly property string triangleCornerA: "\u00C7"
+ readonly property string triangleCornerB: "\u00C8"
+ readonly property string unLinked: "\u00C9"
+ readonly property string undo: "\u00CA"
+ readonly property string unpin: "\u00CB"
+ readonly property string upDownIcon: "\u00CC"
+ readonly property string upDownSquare2: "\u00CD"
+ readonly property string visibilityOff: "\u00CE"
+ readonly property string visibilityOn: "\u00CF"
+ readonly property string wildcard: "\u00D0"
+ readonly property string wizardsAutomotive: "\u00D1"
+ readonly property string wizardsDesktop: "\u00D2"
+ readonly property string wizardsGeneric: "\u00D3"
+ readonly property string wizardsMcuEmpty: "\u00D4"
+ readonly property string wizardsMcuGraph: "\u00D5"
+ readonly property string wizardsMobile: "\u00D6"
+ readonly property string wizardsUnknown: "\u00D7"
+ readonly property string zoomAll: "\u00D8"
+ readonly property string zoomIn: "\u00D9"
+ readonly property string zoomOut: "\u00DA"
+ readonly property string zoomSelection: "\u00DB"
readonly property font iconFont: Qt.font({
"family": controlIcons.name,
diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioTheme/icons.ttf b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioTheme/icons.ttf
index acd8df6ce3ff87fe98d8d5df178d672e0d6d070e..cacd0c3cb9f879d4b1923036b4b61cd952a74f6a 100644
GIT binary patch
delta 5853
zcmeyck8#O!#(D-u1_lORh6V;^h5$FW5Z}4GukB}GDDGfjV36?-);EfroLa%az!<^6
zz>tufn^^EwaCa^P1G5DK17lEfS&0IJB2y&;14|DB0|QHXVsXL${|w9w48;u$3=ACU
zIhAQ|LRP3TFtG73FvNIdq$Z}Q{tQ;)v6
zW68jf6vDv3^t2$qxWwS-xt$CQsWuD@d@f+mF)}cCOqbdj&u{aUft&dS0|NuY{p~fg
zAhcY~tp6YWYqM7~D}!9jzyuOzU;t@kR{pO&S%y)Oc@M*;$qtOs+_#w({#!6aF)K4%
zoxF_k*Vjuyb8;9Fid1%XqyVs!O#tI?fj-*5T|E0L*s(QTPHtc
z78aS#z`(F*)xy;))~;K>X7d(?O}lpQob1iAw_f0vppRgRV3ptjAqAlnp;f{%!Ue)R
zgf9rc5>XSW5qTl1A!;J(AzC5YBYH*jk(hv(lh`S7CUGP281ZuwOcE86LXs(xOC;Y&
z1xam_dLeBf-6Oq4`iD$_%p#d*vMRC>vT3qYWDm(+kbNiTA~!+qmb{vLjr<7(IfW{P
zV~R6#pr`Q;t#Iqr#_Rp^~SvMO8vIOm&KyfSQ%s3bg}jx75C<3#hxPx2W&Y
z2++vUXwYQREYLipwLn`++eiC|j*-qZoqxI!y0dhz=&3L;Y+k^+Q_-4;;LPC9z`&@i#3suqB4*8KWM<1~qNZ+aBqqx!!luorq-M)#
zVy0pwCMqbxrle*nXoAdUFflV$G!heGQ&v=BLS|d_Xj)rqf{3j>AtfatAmZO)t$JBm
zEm`J;S|I9gtgI;GAyHXb(SLRz63%A42GI%9o&wPd($9*aP!?>!Ut_RwP*XuE1QbeU
z;85aaP+(wCRWvd)6*N&(R#d8I6BSft=VR1kG!=w67vwEv#(c(&Aou=Vp=r&i^HJPN
zPoXrJDI&PEG&sdtlW_uA&Lw4w5Q~I?9Mc|<_`ibSQU;d)-~L-Le_~c(5Ma<^uwigz
zU=ZeGlxH+IGXfE6>Z)q&jCzb_=Bj2!;;eFvZ1wDNjBMeQ>}*Q;`TGCPnd`|i+kVy0*Z;uSj5ujLZ~P$qbpDe0;m4
zGo{Rnq@|0h`1rtu11#|gFeoq>FgP&yFhnqGp+}x6*e_fa4HgEQ&v&~DKs-R5rQN*aB@>YVl$YSSu=ukX)}US7@Yms
z(qCFtx;0Knno*kZp_FiZtF)@LzoqbB4K-K&FHA{%w&Gwg`|?lVWO(6PA_|j%$%plM1j9W^Bb`
z3ZpyN2B<|03>@$r$I8H6&mhPk&LGR6%%I7j&%nT{ZfY(rsxEGBs?M&etZr^B&Tee3
zuFTGg#8yR8!}w+G+O^+2Jv}`cZ=Og=Ig#=yL`y3~>t6yAhp_>s=0ple*b1aVD|GGJ
zwVs}y^`2`X3{Q~mloJq11_n@-1ua%}oC4+Ux4tPZVREp|0zhkufnt>|X|y#rO>*rOOlmrhIhO|7FyRWlYS-@YGdj
zoB?M2tp#gmU;x!SPzNY87%(tEb0??_0w)Pj=4BHV1eZ`^kaEeC(acDkQA~tQNu5#6
zWO6#=m-NZ9TCx##|9I>oBJ4hb%9M}klNn|BwE381_++&B{ywhfV^T|>JUJaA2~q}9
zEUP6uIi2wmAK%}{d|EOf#hMTYS%M1@eFjek24SS)LJ{O7V^DfVlq_trjG&aSY@!A!
zGa1FjMEDuml+;Y@8C8|kOhMY!)#^>m&5ZOzY?x+Sg@joBv$hUNkP&7)Dk3c-{5MrZ
z+QTX&L0ULZT$xFJ4j@4q)evP|mUe0==sOfxJ30xbS&S^E21MnwrrOA9ky
z6PA(^?g+3DmR1m3^Y8sMUUi;nyprm??o6Om?7^eX%Lj^H_Wx$g51H!~7}Oc88Jrmy
z7?k)JMMcEK65ErY?Og+dmJOTXb!8tTq3Zfn=B!G_4sJ7+B$X
zmW_dzL4-k?L6?DnQBhRU)I?2KQ4kdCjHaL}lL?$61y#Y(3o5k)!BwG}DYL@AMU026
zt^e6E#%Wsry)_MF`m}%bi(vK2-xa~7OnXkGXj=cf@{h+_lkv+5Yt59De+8P>j9-kV
zfvT8k|Li~%s77OkJBXdZgu#Y^LCDAq91Y^20u&T2?Ba^*Y9^2z!46G#itJ+GQrX1J
z+(_J9olVH39+Ii2`&(G}TO{}w6wED<>R}AO$0wuC$EeT8_wOQ~x(wg_e`{O$3g#9R
z_&b_p)M#s3fRr}dzke=X8pM&
zt0ij$7Sodba|vVAT59I!>TAf#u>uW(rQxw9`UM4@iNN&yCN(l4Jrc|{?}_W
ze`Z!-;ARkKFk)a305wxU1*krw8UqrW8O$~^Gtp-RB`JAEIYvGvH4sN$o8MCaOfYVf
z(-!dLm(%9=;y)vx%|F@u+BEOUApT@mBcrZeyIm*qG5W~yd+}?_@p}p|K9CpiI=)r2*<^PicI~CASY02cJxnMe_?&v0Y>9D
zE9zIgS;3?~Nk$k{yog9o;Ha^^9!af24Mzi
z24w~YRXb3_SdUSOjh&AXTyh$ju_>qss3@=qsDP?R6Eh=bSrcPp6N_2vW?8@(O8=7n
z-DXr}oX4p8FGbbF!^Fg+O(i@mTt!`1R~^Qfc$QJ=?Ad?!b_ST62bgb`HaW&o4@zKq
z%&(ah7z7!#85qP>&5RXI1#KA>LDitB9HXc@w31|p6gupTY@oKfnzE8wGb6v0JmcFx
z<&5e&&60x5(}g4$C58U+@NxfpBBC!TC@9hQU7VFEjgf`*?_4HUMkZU;9HwM3d3mwF
zv&7`N|NRk`SEyevCa=K2`2YWZbLN-KiVV^W4C0*N^dQd32#NuAPDmE!1eZ44j2r*?
z^GGQ0Fm7br$fF>^^Ut4gBZ&Xc|DQjPfI~)#
z)(qazMrI8|2g4MGg$zp>HZm{>iyE6MLz;%5HUg;5HDyHOE1D{cnxb`N7_sP6h3Esd
zD)bnIjX}keHltF#nu!?$s7MDztu3P&E4U~Hb%u<@R1iAU;2P9S%oq{s?HJibjZIaN
zH0f@CA}zEXl#{m$Ni*F5v8APjw+l)C)hfw6w_*mqI$5ZXs987J)lM?@o}|r@`LQ-?10dGe2XEjfIG(?>|U_T
ze{J9XxPyxi%m(!#m>8t~TQZ+#2K67j85mfV)J(-iK-D&^hX(70iq(s%!`f1iN&}M2
zg%#Bmjm-2J)y(Y}|mY=Iw39
zw9(9m$=mE-_>;e<7?~_sSy+O3xLNtxI@s7c*#uZw8QFrFnUC3;GASq|?sd%*WUCue_NLqoN@vvo|jv8zWmCn;>gFDh5n1dU(_23@2
zvLf?N{(qT#Dt!NP1*An@a+<1cQ#Iv$B`ovz+%0Kv_e1yJF%5Hh#;MX?(u`B(%{BfV
zV{{M`V65Tc`PU*K@-IqMR#^P8s;Q~!6A58C5d&V?$DoLRENgG6$+%2cma$e!>R+?0
z?!PEaOXSWCY{fXwT9WE{%f2;O`q|9CFK?-jy
zTe`HoysT{5vZYIx>6e$4m4kwrk&*Gg1rul#M3jL+Rm}t(U}7TdjBFyH4gou;N1&*n
zz_^f2h=Y~&U!0H-<04j8HevSr3Q-_YHZ~!Se~H58LjU5~gxT5HKxTqUTXW`*%*qVh
z3^EK1;*61Iptu7^948~29+Rn{i5-(TqZ}jKG^U@jvVYm-Y;Bm${<6zCm?$ZkILI;m
zRFjqMX6)d%<7e#Rmy`SRPCtBT+i=>epvyiNjB#XemG7%3ChRyeFY(?2E7<3s7
z8H^??2U)OK=o%VLjt~0AxMy=%uoI&h;{wKojEfi-GcI9V%D9YiIpYe(m5i$xS2M0*
zT+6tQaXsS(#*K`d7&kL+Vcg2Njd45U4#u5~yEe}VIm*hOTaaH=lA5wPJZctWJ#TS*
zVqS7aeo?Vraap<`h?kdNl30?Np9dBJ$rlwR=B1}X<&*MD^HMVN(w*`vKqCCb@yYqQ
z1^IcYc_kpeAc&urmzoSWfvY$^H6;@)DN-DtnpcuqaeQumX>qD!QEDQHFIXI3kYAh$
zvN#pu9sc6@;?x|7TRNPd1!QeshjVjfDkNR%L?l5_HlQ{6Iiz=lX7Nu;C}XQt=*=BI#VWRYah
zf}yx9T^LC=BR?0cL&g(HFgGzf6%la7W$9u_l6i?`*c?z)nio)%pOul;OOq{c8XFh(#i
zFeD`BCKlX(w|W)>12YQ)17lEfS&0IJB2y&;0}Du=B|WjY;QxOHW(J0M9|i^nj`W<$
zw2bd*pBNZe7cek*t;tADOi|SoI>^AlaEF0`!7L*qwLX#S<^PEc42&WS3=Aq6xg`~1
zh1?+i4h9BBublkkM6>^1Wef}~AV;|5CRP+Md}TPzz`$t1z`&r8mzbNn@5NhV28IA1
z1_q|51^LA#X^9`47#M<07#MgYz@B4dU^x40&*^x6o39Mq%r6)i7#QyRryqjQa_NWu
zfB0|4Ud^loaxnuFNSJ{Eq>)+azu9CNMn&d@46`OXFh+A9U{?5V!4So)#BgfzGRBjW
z3zpXdBlbjGMBGliNW4LOo%kK`R}vf&aT2Q}zDPPqPLq5jWg#_1>Vb5P^aAN;GF~zr
zGRI_{WOHP1$$paKkyDd%lBd5~Z;T5!
j$E7+kZoZawly&opoGFZ(!}ARpH-{BEGjYR1HvJF)AtJA9
diff --git a/src/plugins/qmldesigner/CMakeLists.txt b/src/plugins/qmldesigner/CMakeLists.txt
index ce772baf43c..a3f0fbbf6f6 100644
--- a/src/plugins/qmldesigner/CMakeLists.txt
+++ b/src/plugins/qmldesigner/CMakeLists.txt
@@ -609,6 +609,7 @@ extend_qtc_plugin(QmlDesigner
crumblebar.cpp crumblebar.h
designeractionmanager.cpp designeractionmanager.h
designeractionmanagerview.cpp designeractionmanagerview.h
+ designericons.cpp designericons.h
findimplementation.cpp findimplementation.h
layoutingridlayout.cpp layoutingridlayout.h
modelnodecontextmenu.cpp modelnodecontextmenu.h
diff --git a/src/plugins/qmldesigner/components/componentcore/designeractionmanager.cpp b/src/plugins/qmldesigner/components/componentcore/designeractionmanager.cpp
index dd07f433ca5..5f952319f16 100644
--- a/src/plugins/qmldesigner/components/componentcore/designeractionmanager.cpp
+++ b/src/plugins/qmldesigner/components/componentcore/designeractionmanager.cpp
@@ -6,6 +6,7 @@
#include "anchoraction.h"
#include "changestyleaction.h"
#include "designeractionmanagerview.h"
+#include "designericons.h"
#include "designermcumanager.h"
#include "formatoperation.h"
#include "modelnodecontextmenu_helper.h"
@@ -286,14 +287,19 @@ QHash DesignerActionManager::handleExternalAssetsDrop(cons
return addedCategoryFiles;
}
+QIcon DesignerActionManager::contextIcon(int contextId) const
+{
+ return m_designerIcons->icon(DesignerIcons::IconId(contextId), DesignerIcons::ContextMenuArea);
+}
+
class VisiblityModelNodeAction : public ModelNodeContextMenuAction
{
public:
- VisiblityModelNodeAction(const QByteArray &id, const QString &description, const QByteArray &category, const QKeySequence &key, int priority,
+ VisiblityModelNodeAction(const QByteArray &id, const QString &description, const QIcon &icon, const QByteArray &category, const QKeySequence &key, int priority,
SelectionContextOperation action,
SelectionContextPredicate enabled = &SelectionContextFunctors::always,
SelectionContextPredicate visibility = &SelectionContextFunctors::always) :
- ModelNodeContextMenuAction(id, description, {}, category, key, priority, action, enabled, visibility)
+ ModelNodeContextMenuAction(id, description, icon, category, key, priority, action, enabled, visibility)
{}
void updateContext() override
@@ -376,9 +382,9 @@ public:
class SelectionModelNodeAction : public ActionGroup
{
public:
- SelectionModelNodeAction(const QString &displayName, const QByteArray &menuId, int priority) :
- ActionGroup(displayName, menuId, priority,
- &SelectionContextFunctors::always, &SelectionContextFunctors::selectionEnabled)
+ SelectionModelNodeAction(const QString &displayName, const QByteArray &menuId, const QIcon &icon, int priority) :
+ ActionGroup(displayName, menuId, icon, priority,
+ &SelectionContextFunctors::always, &SelectionContextFunctors::selectionEnabled)
{}
@@ -599,9 +605,10 @@ void removeSignal(SignalHandlerProperty signalHandler)
class ConnectionsModelNodeActionGroup : public ActionGroup
{
public:
- ConnectionsModelNodeActionGroup(const QString &displayName, const QByteArray &menuId, int priority)
+ ConnectionsModelNodeActionGroup(const QString &displayName, const QByteArray &menuId, const QIcon &icon, int priority)
: ActionGroup(displayName,
menuId,
+ icon,
priority,
&SelectionContextFunctors::always,
&SelectionContextFunctors::selectionEnabled)
@@ -968,8 +975,8 @@ bool isFlowTargetOrTransition(const SelectionContext &context)
class FlowActionConnectAction : public ActionGroup
{
public:
- FlowActionConnectAction(const QString &displayName, const QByteArray &menuId, int priority) :
- ActionGroup(displayName, menuId, priority,
+ FlowActionConnectAction(const QString &displayName, const QByteArray &menuId, const QIcon &icon, int priority) :
+ ActionGroup(displayName, menuId, icon, priority,
&isFlowActionItemItem, &flowOptionVisible)
{}
@@ -1341,16 +1348,19 @@ void DesignerActionManager::createDefaultDesignerActions()
addDesignerAction(new SelectionModelNodeAction(
selectionCategoryDisplayName,
selectionCategory,
+ contextIcon(DesignerIcons::SelecionIcon),
Priorities::SelectionCategory));
addDesignerAction(new ConnectionsModelNodeActionGroup(
connectionsCategoryDisplayName,
connectionsCategory,
+ contextIcon(DesignerIcons::ConnectionsIcon),
Priorities::ConnectionsCategory));
addDesignerAction(new ActionGroup(
arrangeCategoryDisplayName,
arrangeCategory,
+ contextIcon(DesignerIcons::ArrangeIcon),
Priorities::ArrangeCategory,
&selectionNotEmpty));
@@ -1408,7 +1418,11 @@ void DesignerActionManager::createDefaultDesignerActions()
&reverse,
&multiSelectionAndHasSameParent));
- addDesignerAction(new ActionGroup(editCategoryDisplayName, editCategory, Priorities::EditCategory, &selectionNotEmpty));
+ addDesignerAction(new ActionGroup(editCategoryDisplayName,
+ editCategory,
+ contextIcon(DesignerIcons::EditIcon),
+ Priorities::EditCategory,
+ &selectionNotEmpty));
addDesignerAction(new SeperatorDesignerAction(editCategory, 30));
@@ -1491,6 +1505,7 @@ void DesignerActionManager::createDefaultDesignerActions()
addDesignerAction(new VisiblityModelNodeAction(
visiblityCommandId,
visibilityDisplayName,
+ contextIcon(DesignerIcons::VisibilityIcon),
rootCategory,
QKeySequence("Ctrl+g"),
Priorities::Visibility,
@@ -1499,6 +1514,7 @@ void DesignerActionManager::createDefaultDesignerActions()
addDesignerAction(new ActionGroup(anchorsCategoryDisplayName,
anchorsCategory,
+ contextIcon(DesignerIcons::AnchorsIcon),
Priorities::AnchorsCategory,
&anchorsMenuEnabled));
@@ -1596,18 +1612,21 @@ void DesignerActionManager::createDefaultDesignerActions()
addDesignerAction(new ActionGroup(
positionerCategoryDisplayName,
positionerCategory,
+ contextIcon(DesignerIcons::PositionsersIcon),
Priorities::PositionCategory,
&positionOptionVisible));
addDesignerAction(new ActionGroup(
layoutCategoryDisplayName,
layoutCategory,
+ contextIcon(DesignerIcons::LayoutsIcon),
Priorities::LayoutCategory,
&layoutOptionVisible));
addDesignerAction(new ActionGroup(
snappingCategoryDisplayName,
snappingCategory,
+ contextIcon(DesignerIcons::SnappingIcon),
Priorities::SnappingCategory,
&selectionEnabled,
&selectionEnabled));
@@ -1615,12 +1634,14 @@ void DesignerActionManager::createDefaultDesignerActions()
addDesignerAction(new ActionGroup(
groupCategoryDisplayName,
groupCategory,
+ contextIcon(DesignerIcons::GroupSelectionIcon),
Priorities::Group,
&studioComponentsAvailableAndSelectionCanBeLayouted));
addDesignerAction(new ActionGroup(
flowCategoryDisplayName,
flowCategory,
+ {},
Priorities::FlowCategory,
&isFlowTargetOrTransition,
&flowOptionVisible));
@@ -1629,6 +1650,7 @@ void DesignerActionManager::createDefaultDesignerActions()
auto effectMenu = new ActionGroup(
flowEffectCategoryDisplayName,
flowEffectCategory,
+ {},
Priorities::FlowCategory,
&isFlowTransitionItem,
&flowOptionVisible);
@@ -1660,9 +1682,10 @@ void DesignerActionManager::createDefaultDesignerActions()
&flowOptionVisible));
addDesignerAction(new FlowActionConnectAction(
- flowConnectionCategoryDisplayName,
- flowConnectionCategory,
- Priorities::FlowCategory));
+ flowConnectionCategoryDisplayName,
+ flowConnectionCategory,
+ {},
+ Priorities::FlowCategory));
const QList transitionTypes = {"FlowFadeEffect",
@@ -1688,6 +1711,7 @@ void DesignerActionManager::createDefaultDesignerActions()
addDesignerAction(new ActionGroup(
stackedContainerCategoryDisplayName,
stackedContainerCategory,
+ {},
Priorities::StackedContainerCategory,
&isStackedContainer));
@@ -1888,7 +1912,7 @@ void DesignerActionManager::createDefaultDesignerActions()
addDesignerAction(new ModelNodeContextMenuAction(
goIntoComponentCommandId,
enterComponentDisplayName,
- {},
+ contextIcon(DesignerIcons::EnterComponentIcon),
rootCategory,
QKeySequence(Qt::Key_F2),
Priorities::ComponentActions + 2,
@@ -1898,7 +1922,7 @@ void DesignerActionManager::createDefaultDesignerActions()
addDesignerAction(new ModelNodeContextMenuAction(
editAnnotationsCommandId,
editAnnotationsDisplayName,
- {},
+ contextIcon(DesignerIcons::AnnotationIcon),
rootCategory,
QKeySequence(),
Priorities::EditAnnotations,
@@ -1907,15 +1931,15 @@ void DesignerActionManager::createDefaultDesignerActions()
&singleSelection));
addDesignerAction(new ModelNodeContextMenuAction(
- addMouseAreaFillCommandId,
- addMouseAreaFillDisplayName,
- {},
- rootCategory,
- QKeySequence(),
- Priorities::AddMouseArea,
- &addMouseAreaFill,
- &addMouseAreaFillCheck,
- &singleSelection));
+ addMouseAreaFillCommandId,
+ addMouseAreaFillDisplayName,
+ contextIcon(DesignerIcons::AddMouseAreaIcon),
+ rootCategory,
+ QKeySequence(),
+ Priorities::AddMouseArea,
+ &addMouseAreaFill,
+ &addMouseAreaFillCheck,
+ &singleSelection));
const bool standaloneMode = QmlProjectManager::QmlProject::isQtDesignStudio();
@@ -1943,7 +1967,7 @@ void DesignerActionManager::createDefaultDesignerActions()
addDesignerAction(new ModelNodeContextMenuAction(
makeComponentCommandId,
makeComponentDisplayName,
- {},
+ contextIcon(DesignerIcons::MakeComponentIcon),
rootCategory,
QKeySequence(),
Priorities::ComponentActions + 1,
@@ -1954,7 +1978,7 @@ void DesignerActionManager::createDefaultDesignerActions()
addDesignerAction(new ModelNodeContextMenuAction(
editMaterialCommandId,
editMaterialDisplayName,
- {},
+ contextIcon(DesignerIcons::EditIcon),
rootCategory,
QKeySequence(),
44,
@@ -1974,6 +1998,7 @@ void DesignerActionManager::createDefaultDesignerActions()
addDesignerAction(new ActionGroup(
"",
genericToolBarCategory,
+ {},
Priorities::GenericToolBar));
addDesignerAction(new ChangeStyleAction());
@@ -2114,6 +2139,7 @@ DesignerActionManager::DesignerActionManager(DesignerActionManagerView *designer
: m_designerActionManagerView(designerActionManagerView)
, m_externalDependencies(externalDependencies)
{
+ setupIcons();
}
DesignerActionManager::~DesignerActionManager() = default;
@@ -2145,6 +2171,20 @@ void DesignerActionManager::addCustomTransitionEffectAction()
&isFlowTransitionItem));
}
+void DesignerActionManager::setupIcons()
+{
+ m_designerIcons.reset(new DesignerIcons("qtds_propertyIconFont.ttf", designerIconResourcesPath()));
+}
+
+QString DesignerActionManager::designerIconResourcesPath() const
+{
+#ifdef SHARE_QML_PATH
+ if (Utils::qtcEnvironmentVariableIsSet("LOAD_QML_FROM_SOURCE"))
+ return QLatin1String(SHARE_QML_PATH) + "/designericons.json";
+#endif
+ return Core::ICore::resourcePath("qmldesigner/designericons.json").toString();
+}
+
DesignerActionToolBar::DesignerActionToolBar(QWidget *parentWidget) : Utils::StyledBar(parentWidget),
m_toolBar(new QToolBar("ActionToolBar", this))
{
diff --git a/src/plugins/qmldesigner/components/componentcore/designeractionmanager.h b/src/plugins/qmldesigner/components/componentcore/designeractionmanager.h
index 928d136a02e..41bf7b83876 100644
--- a/src/plugins/qmldesigner/components/componentcore/designeractionmanager.h
+++ b/src/plugins/qmldesigner/components/componentcore/designeractionmanager.h
@@ -23,6 +23,7 @@ QT_END_NAMESPACE
namespace QmlDesigner {
class DesignerActionManagerView;
+class DesignerIcons;
using AddResourceOperation = std::function;
using ModelNodePreviewImageOperation = std::function;
@@ -118,16 +119,20 @@ public:
ModelNodePreviewImageOperation modelNodePreviewOperation(const ModelNode &node) const;
bool externalDragHasSupportedAssets(const QMimeData *data) const;
QHash handleExternalAssetsDrop(const QMimeData *data) const;
+ QIcon contextIcon(int contextId) const;
private:
void addTransitionEffectAction(const TypeName &typeName);
void addCustomTransitionEffectAction();
+ void setupIcons();
+ QString designerIconResourcesPath() const;
QList > m_designerActions;
DesignerActionManagerView *m_designerActionManagerView;
QList m_addResourceHandler;
QList m_modelNodePreviewImageHandlers;
ExternalDependenciesInterface &m_externalDependencies;
+ QScopedPointer m_designerIcons;
};
} //QmlDesigner
diff --git a/src/plugins/qmldesigner/components/componentcore/designericons.cpp b/src/plugins/qmldesigner/components/componentcore/designericons.cpp
new file mode 100644
index 00000000000..ce604d6d8cd
--- /dev/null
+++ b/src/plugins/qmldesigner/components/componentcore/designericons.cpp
@@ -0,0 +1,418 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
+
+#include "designericons.h"
+
+#include
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+using namespace QmlDesigner;
+namespace { // Blank namespace
+
+template
+struct DesignerIconEnums
+{
+ typedef EType EnumType;
+ static QString toString(const EnumType &enumValue);
+ static EnumType value(const QString &keyStr, bool *ok = nullptr);
+
+ static const QMetaEnum metaEnum;
+ static const QString keyName;
+};
+
+template
+struct DesignerEnumConfidentType
+{
+ typedef EType EnumType;
+};
+
+template <>
+struct DesignerEnumConfidentType
+{
+ typedef DesignerIcons::Mode EnumType;
+};
+
+template <>
+struct DesignerEnumConfidentType
+{
+ typedef DesignerIcons::State EnumType;
+};
+
+template
+QString getEnumName() {
+ QMetaEnum metaEnum = QMetaEnum::fromType();
+ QString enumName = QString::fromLatin1(metaEnum.enumName());
+ if (enumName.size() && enumName.at(0).isUpper())
+ enumName.replace(0, 1, enumName.at(0).toLower());
+ return enumName;
+};
+
+template <>
+QString getEnumName() {
+ return QLatin1String("iconName");
+};
+
+template
+const QMetaEnum DesignerIconEnums::metaEnum =
+ QMetaEnum::fromType::EnumType>();
+
+template
+const QString DesignerIconEnums::keyName =
+ getEnumName::EnumType>();
+
+template
+QString DesignerIconEnums::toString(const EType &enumValue)
+{
+ return QString::fromLatin1(metaEnum.valueToKey(enumValue));
+}
+
+template
+EType DesignerIconEnums::value(const QString &keyStr, bool *ok)
+{
+ return static_cast(metaEnum.keyToValue(keyStr.toLatin1(), ok));
+}
+
+Q_GLOBAL_STATIC(QStringList, _iconFontMandatoryKeys);
+
+const QStringList & iconFontMandatoryKeys()
+{
+ if (_iconFontMandatoryKeys->isEmpty()) {
+ *_iconFontMandatoryKeys
+ << DesignerIconEnums::keyName
+ << DesignerIconEnums::keyName
+ << DesignerIconEnums::keyName
+ << DesignerIconEnums::keyName
+ << "size";
+ }
+ return *_iconFontMandatoryKeys;
+}
+
+QJsonObject mergeJsons(const QJsonObject &prior, const QJsonObject &joiner)
+{
+ QJsonObject object = prior;
+ const QStringList joinerKeys = joiner.keys();
+ for (const QString &joinerKey : joinerKeys) {
+ if (!object.contains(joinerKey)) {
+ object.insert(joinerKey, joiner.value(joinerKey));
+ } else {
+ QJsonValue ov = object.value(joinerKey);
+ QJsonValue jv = joiner.value(joinerKey);
+ if (ov.isObject() && jv.isObject()) {
+ QJsonObject mg = mergeJsons(ov.toObject(), jv.toObject());
+ object.insert(joinerKey, mg);
+ }
+ }
+ }
+ return object;
+}
+
+inline QString toJsonSize(const QSize &size)
+{
+ return QString::fromLatin1("%1x%2").arg(size.width()).arg(size.height());
+}
+
+template
+void pushSimpleEnumValue(QJsonObject &object, const EnumType &enumVal)
+{
+ const QString &enumKey = DesignerIconEnums::keyName;
+ QString enumValue = DesignerIconEnums::toString(enumVal);
+ object.insert(enumKey, enumValue);
+}
+
+template
+T jsonSafeValue(const QJsonObject &jsonObject, const QString &symbolName,
+ std::function validityCheck = [](const T&) -> bool {return true;})
+{
+ if (!jsonObject.contains(symbolName))
+ throw InvalidArgumentException(__LINE__, __FUNCTION__, __FILE__, symbolName.toLatin1());
+
+ QVariant symbolVar = jsonObject.value(symbolName);
+ T extractedVal = symbolVar.value();
+ if (!validityCheck(extractedVal))
+ throw InvalidArgumentException(__LINE__, __FUNCTION__, __FILE__, symbolName.toLatin1());
+
+ return extractedVal;
+}
+
+QSize jsonSafeSize(const QJsonObject &jsonObject, const QString &symbolName)
+{
+ QString extractedVal = jsonSafeValue(jsonObject, symbolName);
+ QStringList dims = extractedVal.split("x");
+ if (dims.size() == 2) {
+ bool wOk;
+ bool hOk;
+ int cWidth = dims.first().toInt(&wOk);
+ int cHeight = dims.last().toInt(&hOk);
+ if (wOk && hOk)
+ return {cWidth, cHeight};
+ }
+ throw InvalidArgumentException(__LINE__, __FUNCTION__, __FILE__, symbolName.toLatin1());
+ return {};
+}
+
+template
+T jsonSafeMetaEnum(const QJsonObject &jsonObject, const QString &symbolName = DesignerIconEnums::keyName)
+{
+ QString extractedVal = jsonSafeValue(jsonObject, symbolName);
+ bool ok;
+ T enumIndex = static_cast (DesignerIconEnums::value(extractedVal, &ok));
+ if (ok)
+ return enumIndex;
+
+ throw InvalidArgumentException(__LINE__, __FUNCTION__, __FILE__, symbolName.toLatin1());
+ return {};
+}
+
+template
+struct JsonMap
+{};
+
+template <>
+struct JsonMap
+{
+ static IconFontHelper value(const QJsonObject &jsonObject, const QJsonObject &telescopingMap)
+ {
+ QJsonObject fontHelperJson = mergeJsons(jsonObject, telescopingMap);
+ return IconFontHelper::fromJson(fontHelperJson);
+ }
+
+ static QJsonObject json(const IconFontHelper &iconFontHelper)
+ {
+ QJsonObject object;
+ pushSimpleEnumValue(object, iconFontHelper.themeIcon());
+ pushSimpleEnumValue(object, iconFontHelper.themeColor());
+ object.insert("size", toJsonSize(iconFontHelper.size()));
+ return object;
+ }
+};
+
+template
+struct JsonMap>
+{
+ typedef QMap MapType;
+ static MapType value(const QJsonObject &mapObject, const QJsonObject &telescopingMap)
+ {
+ typedef typename MapType::key_type KeyType;
+ typedef typename MapType::mapped_type ValueType;
+
+ QMap output;
+ QJsonObject curObject = mergeJsons(mapObject, telescopingMap);
+ const QStringList keyList = curObject.keys();
+ QStringList validKeys;
+ QString keyTypeStr = DesignerIconEnums::keyName;
+ QJsonObject nextTelescopingMap = telescopingMap;
+
+ for (const QString &jsonKey : keyList) {
+ bool keyAvailable = false;
+ DesignerIconEnums::value(jsonKey, &keyAvailable);
+ if (keyAvailable)
+ validKeys.append(jsonKey);
+ else
+ nextTelescopingMap.insert(jsonKey, curObject.value(jsonKey));
+ }
+
+ for (const QString &jsonKey : validKeys) {
+ bool keyAvailable = false;
+ const KeyType key = DesignerIconEnums::value(jsonKey, &keyAvailable);
+ QJsonValue jsonValue = curObject.value(jsonKey);
+
+ nextTelescopingMap.insert(keyTypeStr, jsonKey);
+ if (!jsonValue.isObject()) {
+ qWarning() << Q_FUNC_INFO << __LINE__ << "Value of the" << jsonKey << "should be a json object.";
+ continue;
+ }
+ output.insert(key, JsonMap::value(jsonValue.toObject(), nextTelescopingMap));
+ }
+
+ return output;
+ }
+
+ static QJsonObject json(const QMap &map)
+ {
+ QJsonObject output;
+ for (const auto &[key, val] : map.asKeyValueRange())
+ output[DesignerIconEnums::toString(key)] = JsonMap::json(val);
+
+ return output;
+ }
+};
+
+} // End of blank namespace
+
+class QmlDesigner::DesignerIconsPrivate
+{
+public:
+ DesignerIconsPrivate(const QString &fontName)
+ : mFontName(fontName) {}
+
+ QString mFontName;
+ DesignerIcons::IconsMap icons;
+ static QCache cache;
+};
+
+QCache DesignerIconsPrivate::cache(100);
+
+IconFontHelper::IconFontHelper(Theme::Icon themeIcon, Theme::Color color, const QSize &size, QIcon::Mode mode, QIcon::State state)
+ : Super(Theme::getIconUnicode(themeIcon),
+ Theme::getColor(color),
+ size,
+ mode, state)
+ , mThemeIcon(themeIcon)
+ , mThemeColor(color)
+{}
+
+IconFontHelper IconFontHelper::fromJson(const QJsonObject &jsonObject)
+{
+ try {
+ Theme::Icon iconName = jsonSafeMetaEnum(jsonObject);
+ Theme::Color iconColor = jsonSafeMetaEnum(jsonObject);
+ QSize iconSize = jsonSafeSize(jsonObject, "size");
+ QIcon::Mode iconMode = jsonSafeMetaEnum(jsonObject);
+ QIcon::State iconState = jsonSafeMetaEnum(jsonObject);
+ return IconFontHelper(iconName, iconColor, iconSize, iconMode, iconState);
+ } catch (const Exception &exception) {
+ exception.showException("Faild to load IconFontHelper");
+ return {};
+ }
+}
+
+QJsonObject IconFontHelper::toJson() const
+{
+ QJsonObject jsonObject;
+ pushSimpleEnumValue(jsonObject, themeIcon());
+ pushSimpleEnumValue(jsonObject, themeColor());
+ pushSimpleEnumValue(jsonObject, mode());
+ pushSimpleEnumValue(jsonObject, state());
+ jsonObject.insert("size", toJsonSize(size()));
+ return jsonObject;
+}
+
+Theme::Icon IconFontHelper::themeIcon() const
+{
+ return mThemeIcon;
+}
+
+Theme::Color IconFontHelper::themeColor() const
+{
+ return mThemeColor;
+}
+
+IconFontHelper::IconFontHelper()
+ : IconFontHelper({}, {}, {}, {}, {}) {}
+
+DesignerIcons::DesignerIcons(const QString &fontName, const QString &iconDatabase)
+ : d(new DesignerIconsPrivate(fontName))
+{
+ if (iconDatabase.size())
+ loadIconSettings(iconDatabase);
+}
+
+DesignerIcons::~DesignerIcons()
+{
+ delete d;
+}
+
+QIcon DesignerIcons::icon(IconId icon, Area area) const
+{
+ return Utils::StyleHelper::getIconFromIconFont(d->mFontName, helperList(icon, area));
+}
+
+void DesignerIcons::loadIconSettings(const QString &fileName)
+{
+ if (d->cache.contains(fileName)) {
+ d->icons = *d->cache.object(fileName);
+ return;
+ }
+
+ QFile designerIconFile(fileName);
+
+ if (!designerIconFile.open(QFile::ReadOnly)) {
+ qWarning() << Q_FUNC_INFO << __LINE__ << "Can not open file:" << fileName << designerIconFile.errorString();
+ return;
+ }
+
+ if (designerIconFile.size() > 100e3) {
+ qWarning() << Q_FUNC_INFO << __LINE__ << "Large File:" << fileName;
+ return;
+ }
+
+ QJsonParseError parseError;
+ QJsonDocument jsonDoc = QJsonDocument::fromJson(designerIconFile.readAll(), &parseError);
+
+ if (parseError.error != QJsonParseError::NoError) {
+ qWarning() << Q_FUNC_INFO << __LINE__ << "Json Parse Error - " << parseError.errorString() << "---\t File: " << fileName;
+ return;
+ }
+
+ if (!jsonDoc.isObject()) {
+ qWarning() << Q_FUNC_INFO << __LINE__ << "Invalid Json Array in file: " << fileName;
+ return;
+ }
+
+ clearAll();
+ d->icons = JsonMap::value(jsonDoc.object(), {});
+ d->cache.insert(fileName, new IconsMap(d->icons), 1);
+}
+
+void DesignerIcons::exportSettings(const QString &fileName) const
+{
+ QFile outFile(fileName);
+ if (!outFile.open(QFile::WriteOnly)) {
+ qWarning() << Q_FUNC_INFO << __LINE__ << "Can not open file for writing:" << fileName;
+ return;
+ }
+
+ QJsonDocument jsonDocument;
+ jsonDocument.setObject(JsonMap::json(d->icons));
+
+ outFile.write(jsonDocument.toJson());
+ outFile.close();
+}
+
+void DesignerIcons::clearAll()
+{
+ d->icons.clear();
+}
+
+void DesignerIcons::addIcon(const IconId &iconId, const Area &area, const IconFontHelper &fontHelper)
+{
+ AreaMap &areaMap = d->icons[iconId];
+ IconMap &iconMap = areaMap[area];
+ ModeMap &modeMap = iconMap[static_cast(fontHelper.state())];
+ modeMap.insert(static_cast(fontHelper.mode()), fontHelper);
+}
+
+void DesignerIcons::addIcon(IconId iconId,
+ Area area,
+ QIcon::Mode mode,
+ QIcon::State state,
+ Theme::Icon themeIcon,
+ Theme::Color color,
+ const QSize &size)
+{
+ addIcon(iconId, area, {themeIcon, color, size, mode, state});
+}
+
+void DesignerIcons::addIcon(IconId iconId, Area area, Theme::Icon themeIcon, Theme::Color color, const QSize &size)
+{
+ addIcon(iconId, area, {themeIcon, color, size});
+}
+
+QList DesignerIcons::helperList(const IconId &iconId,
+ const Area &area) const
+{
+ QList helperList;
+ const IconMap &iconMap = d->icons.value(iconId).value(area);
+ for (const ModeMap &modMap : iconMap) {
+ for (const IconFontHelper &iconFontHelper : modMap)
+ helperList.append(iconFontHelper);
+ }
+ return helperList;
+}
diff --git a/src/plugins/qmldesigner/components/componentcore/designericons.h b/src/plugins/qmldesigner/components/componentcore/designericons.h
new file mode 100644
index 00000000000..342016b77c1
--- /dev/null
+++ b/src/plugins/qmldesigner/components/componentcore/designericons.h
@@ -0,0 +1,133 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
+
+#pragma once
+
+#include "theme.h"
+
+#include
+
+#include
+
+namespace QmlDesigner {
+
+class DesignerIconsPrivate;
+
+class IconFontHelper : public Utils::StyleHelper::IconFontHelper
+{
+ typedef Utils::StyleHelper::IconFontHelper Super;
+
+public:
+ IconFontHelper(Theme::Icon themeIcon,
+ Theme::Color color,
+ const QSize &size,
+ QIcon::Mode mode = QIcon::Normal,
+ QIcon::State state = QIcon::Off);
+
+ static IconFontHelper fromJson(const QJsonObject &jsonObject);
+ QJsonObject toJson() const;
+ Theme::Icon themeIcon() const;
+ Theme::Color themeColor() const;
+
+private:
+ IconFontHelper();
+
+ Theme::Icon mThemeIcon;
+ Theme::Color mThemeColor;
+};
+
+class DesignerIcons
+{
+ Q_GADGET
+ friend DesignerIconsPrivate;
+
+public:
+ enum IconId {
+ AddMouseAreaIcon,
+ AlignBottomIcon,
+ AlignLeftIcon,
+ AlignRightIcon,
+ AlignTopIcon,
+ AnchorsIcon,
+ AnnotationIcon,
+ ArrangeIcon,
+ ConnectionsIcon,
+ EditIcon,
+ EnterComponentIcon,
+ EventListIcon,
+ GroupSelectionIcon,
+ LayoutsIcon,
+ MakeComponentIcon,
+ MergeWithTemplateIcon,
+ PositionsersIcon,
+ SelecionIcon,
+ SnappingIcon,
+ TimelineIcon,
+ ShowBoundsIcon,
+ VisibilityIcon
+ };
+ Q_ENUM(IconId)
+
+ enum Area {
+ TopToolbarArea,
+ ContextMenuArea
+ };
+ Q_ENUM(Area)
+
+ enum Mode {
+ Normal = QIcon::Normal,
+ Disabled = QIcon::Disabled,
+ Hovered = QIcon::Active,
+ Selected = QIcon::Selected
+ };
+
+ Q_ENUM(Mode)
+
+ enum State {
+ Off = QIcon::Off,
+ On = QIcon::On
+ };
+ Q_ENUM(State)
+
+ typedef QMap ModeMap;
+ typedef QMap IconMap;
+ typedef QMap AreaMap;
+ typedef QMap IconsMap;
+
+ explicit DesignerIcons(const QString &fontName,
+ const QString &iconDatabase = QString());
+
+ ~DesignerIcons();
+
+ QIcon icon(IconId icon, Area area) const;
+
+ void loadIconSettings(const QString &fileName);
+ void exportSettings(const QString &fileName) const;
+
+ void clearAll();
+ void addIcon(const IconId &iconId,
+ const Area &area,
+ const IconFontHelper &fontHelper);
+
+ void addIcon(IconId iconId,
+ Area area,
+ QIcon::Mode mode,
+ QIcon::State state,
+ Theme::Icon themeIcon,
+ Theme::Color color,
+ const QSize &size);
+
+ void addIcon(IconId iconId,
+ Area area,
+ Theme::Icon themeIcon,
+ Theme::Color color,
+ const QSize &size);
+
+private:
+ QList helperList(const IconId &iconId,
+ const Area &area) const;
+
+ DesignerIconsPrivate *d = nullptr;
+};
+
+}
diff --git a/src/plugins/qmldesigner/components/componentcore/modelnodecontextmenu.cpp b/src/plugins/qmldesigner/components/componentcore/modelnodecontextmenu.cpp
index ebe51d8a3a8..2e36fe6f926 100644
--- a/src/plugins/qmldesigner/components/componentcore/modelnodecontextmenu.cpp
+++ b/src/plugins/qmldesigner/components/componentcore/modelnodecontextmenu.cpp
@@ -60,7 +60,7 @@ void populateMenu(QSet &actionInterfaces,
|| actionInterface->type() == ActionInterface::FormEditorAction) {
QAction* action = actionInterface->action();
actionInterface->currentContextChanged(selectionContext);
- action->setIconVisibleInMenu(false);
+ action->setIconVisibleInMenu(true);
menu->addAction(action);
}
}
diff --git a/src/plugins/qmldesigner/components/componentcore/modelnodecontextmenu_helper.h b/src/plugins/qmldesigner/components/componentcore/modelnodecontextmenu_helper.h
index a32f5e8d154..a948d7479af 100644
--- a/src/plugins/qmldesigner/components/componentcore/modelnodecontextmenu_helper.h
+++ b/src/plugins/qmldesigner/components/componentcore/modelnodecontextmenu_helper.h
@@ -141,7 +141,7 @@ public:
class ActionGroup : public AbstractActionGroup
{
public:
- ActionGroup(const QString &displayName, const QByteArray &menuId, int priority,
+ ActionGroup(const QString &displayName, const QByteArray &menuId, const QIcon &icon, int priority,
SelectionContextPredicate enabled = &SelectionContextFunctors::always,
SelectionContextPredicate visibility = &SelectionContextFunctors::always) :
AbstractActionGroup(displayName),
@@ -150,6 +150,7 @@ public:
m_enabled(enabled),
m_visibility(visibility)
{
+ menu()->setIcon(icon);
}
bool isVisible(const SelectionContext &m_selectionState) const override { return m_visibility(m_selectionState); }
diff --git a/src/plugins/qmldesigner/components/componentcore/theme.h b/src/plugins/qmldesigner/components/componentcore/theme.h
index 4864e6e4c94..23b9039ed95 100644
--- a/src/plugins/qmldesigner/components/componentcore/theme.h
+++ b/src/plugins/qmldesigner/components/componentcore/theme.h
@@ -103,6 +103,7 @@ public:
gridView,
idAliasOff,
idAliasOn,
+ imported,
infinity,
keyframe,
linkTriangle,
@@ -131,6 +132,24 @@ public:
redo,
rotationFill,
rotationOutline,
+ s_anchors,
+ s_annotations,
+ s_arrange,
+ s_boundingBox,
+ s_component,
+ s_connections,
+ s_edit,
+ s_enterComponent,
+ s_eventList,
+ s_group,
+ s_layouts,
+ s_merging,
+ s_mouseArea,
+ s_positioners,
+ s_selection,
+ s_snapping,
+ s_timeline,
+ s_visibility,
search,
sectionToggle,
splitColumns,
@@ -148,6 +167,14 @@ public:
textFullJustification,
textNumberedList,
tickIcon,
+ topToolbar_annotations,
+ topToolbar_closeFile,
+ topToolbar_designMode,
+ topToolbar_enterComponent,
+ topToolbar_home,
+ topToolbar_makeComponent,
+ topToolbar_navFile,
+ topToolbar_runProject,
translationCreateFiles,
translationCreateReport,
translationExport,
diff --git a/src/plugins/qmldesigner/components/eventlist/eventlistpluginview.cpp b/src/plugins/qmldesigner/components/eventlist/eventlistpluginview.cpp
index f45d609d927..9124d65475f 100644
--- a/src/plugins/qmldesigner/components/eventlist/eventlistpluginview.cpp
+++ b/src/plugins/qmldesigner/components/eventlist/eventlistpluginview.cpp
@@ -3,6 +3,7 @@
#include "eventlistpluginview.h"
#include "assigneventdialog.h"
#include "connectsignaldialog.h"
+#include "designericons.h"
#include "eventlistactions.h"
#include "eventlistdialog.h"
@@ -45,6 +46,7 @@ void EventListPluginView::registerActions()
designerActionManager.addDesignerAction(new ActionGroup(tr("Event List"),
ComponentCoreConstants::eventListCategory,
+ designerActionManager.contextIcon(DesignerIcons::EventListIcon),
ComponentCoreConstants::Priorities::EventListCategory,
&SelectionContextFunctors::always,
&SelectionContextFunctors::always));
diff --git a/src/plugins/qmldesigner/components/formeditor/formeditorwidget.cpp b/src/plugins/qmldesigner/components/formeditor/formeditorwidget.cpp
index 331f7fbe97b..07638ba5389 100644
--- a/src/plugins/qmldesigner/components/formeditor/formeditorwidget.cpp
+++ b/src/plugins/qmldesigner/components/formeditor/formeditorwidget.cpp
@@ -3,6 +3,7 @@
#include "formeditorwidget.h"
#include "designeractionmanager.h"
+#include "designericons.h"
#include "designersettings.h"
#include "formeditoritem.h"
#include "formeditorscene.h"
@@ -104,6 +105,7 @@ FormEditorWidget::FormEditorWidget(FormEditorView *view)
m_showBoundingRectAction = new QAction(tr("Show Bounds"), this);
m_showBoundingRectAction->setCheckable(true);
m_showBoundingRectAction->setChecked(false);
+ m_showBoundingRectAction->setIcon(DesignerActionManager::instance().contextIcon(DesignerIcons::ShowBoundsIcon));
registerActionAsCommand(m_showBoundingRectAction,
Constants::FORMEDITOR_NO_SHOW_BOUNDING_RECTANGLE,
QKeySequence(Qt::Key_A),
diff --git a/src/plugins/qmldesigner/components/timelineeditor/timelineview.cpp b/src/plugins/qmldesigner/components/timelineeditor/timelineview.cpp
index 6249ce94484..13958695d08 100644
--- a/src/plugins/qmldesigner/components/timelineeditor/timelineview.cpp
+++ b/src/plugins/qmldesigner/components/timelineeditor/timelineview.cpp
@@ -3,6 +3,7 @@
#include "timelineview.h"
+#include "designericons.h"
#include "easingcurve.h"
#include "timelineactions.h"
#include "timelineconstants.h"
@@ -584,6 +585,7 @@ void TimelineView::registerActions()
actionManager.addDesignerAction(new ActionGroup(TimelineConstants::timelineCategoryDisplayName,
TimelineConstants::timelineCategory,
+ actionManager.contextIcon(DesignerIcons::TimelineIcon),
ComponentCoreConstants::Priorities::TimelineCategory,
timelineEnabled,
&SelectionContextFunctors::always));
diff --git a/src/plugins/qmldesigner/qmlpreviewplugin/qmlpreviewplugin.cpp b/src/plugins/qmldesigner/qmlpreviewplugin/qmlpreviewplugin.cpp
index fb7296ec947..3ff9242ce5c 100644
--- a/src/plugins/qmldesigner/qmlpreviewplugin/qmlpreviewplugin.cpp
+++ b/src/plugins/qmldesigner/qmlpreviewplugin/qmlpreviewplugin.cpp
@@ -40,6 +40,7 @@ QmlPreviewWidgetPlugin::QmlPreviewWidgetPlugin()
designerActionManager.addDesignerAction(new ActionGroup(
QString(),
ComponentCoreConstants::qmlPreviewCategory,
+ {},
ComponentCoreConstants::Priorities::QmlPreviewCategory,
&SelectionContextFunctors::always));
s_previewPlugin = getPreviewPlugin();
From a61f8b02d30d2dfd8716e2ed7b7a23d287b68677 Mon Sep 17 00:00:00 2001
From: Thiago Macieira
Date: Tue, 10 Jan 2023 10:26:01 -0800
Subject: [PATCH 28/28] Fix build with Qt 6's QList under
QT_STRICT_QLIST_ITERATORS
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
modelnode.cpp:1395:91: error: no matching function for call to ‘Utils::span::span(QList::const_iterator, QList::const_iterator)’
Change-Id: Ide4dbd0777a44ed0870efffd173905d7eb32fa26
Reviewed-by: hjk
---
src/plugins/qmldesigner/designercore/model/modelnode.cpp | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/src/plugins/qmldesigner/designercore/model/modelnode.cpp b/src/plugins/qmldesigner/designercore/model/modelnode.cpp
index ced1a0de44b..a58e6c60079 100644
--- a/src/plugins/qmldesigner/designercore/model/modelnode.cpp
+++ b/src/plugins/qmldesigner/designercore/model/modelnode.cpp
@@ -1392,8 +1392,7 @@ ModelNode ModelNode::lowestCommonAncestor(const QList &nodes)
ModelNode accumulatedNode = nodes.first();
int accumulatedNodeDepth = -1;
- Utils::span nodesExceptFirst(nodes.constBegin() + 1, nodes.constEnd());
- for (const ModelNode &node : nodesExceptFirst) {
+ for (const ModelNode &node : Utils::span(nodes).subspan(1)) {
accumulatedNode = QmlDesigner::lowestCommonAncestor(accumulatedNode,
node,
accumulatedNodeDepth,