From 89535f10256cc1db2d5d04f4b6427bf918b5f8cd Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Fri, 16 Sep 2022 17:19:02 +0200 Subject: [PATCH] QmlDesigner: Hide dynamic properties if multiple items are selected If multiple items get selected it is not clear to which item the property belongs. Therefore we hide the section. Task-number: QDS-7688 Change-Id: Ieaa0114d87974fea3135adc2d1bcd979c2236ed2 Reviewed-by: Miikka Heikkinen --- .../propertyEditorQmlSources/QtQuick/ItemPane.qml | 1 + .../QtQuick3D/Object3DPane.qml | 1 + .../propertyeditor/propertyeditorcontextobject.cpp | 14 ++++++++++++++ .../propertyeditor/propertyeditorcontextobject.h | 10 ++++++++++ 4 files changed, 26 insertions(+) diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/ItemPane.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/ItemPane.qml index 140f05c1071..2a724bd58de 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/ItemPane.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/ItemPane.qml @@ -39,6 +39,7 @@ PropertyEditorPane { DynamicPropertiesSection { propertiesModel: SelectionDynamicPropertiesModel {} + visible: !hasMultiSelection } GeometrySection {} diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick3D/Object3DPane.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick3D/Object3DPane.qml index f0261c7c753..5483ca67ac4 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick3D/Object3DPane.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick3D/Object3DPane.qml @@ -42,6 +42,7 @@ PropertyEditorPane { DynamicPropertiesSection { propertiesModel: SelectionDynamicPropertiesModel {} + visible: !hasMultiSelection } Loader { diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorcontextobject.cpp b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorcontextobject.cpp index 8ba1325efaf..75c63159247 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorcontextobject.cpp +++ b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorcontextobject.cpp @@ -429,6 +429,20 @@ QQmlComponent *PropertyEditorContextObject::specificQmlComponent() return m_qmlComponent; } +bool PropertyEditorContextObject::hasMultiSelection() const +{ + return m_hasMultiSelection; +} + +void PropertyEditorContextObject::setHasMultiSelection(bool b) +{ + if (b == m_hasMultiSelection) + return; + + m_hasMultiSelection = b; + emit hasMultiSelectionChanged(); +} + void PropertyEditorContextObject::setSpecificsUrl(const QUrl &newSpecificsUrl) { if (newSpecificsUrl == m_specificsUrl) diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorcontextobject.h b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorcontextobject.h index 05ebe47ec28..fba0e4a66cb 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorcontextobject.h +++ b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorcontextobject.h @@ -68,6 +68,9 @@ class PropertyEditorContextObject : public QObject Q_PROPERTY(QQmlComponent* specificQmlComponent READ specificQmlComponent NOTIFY specificQmlComponentChanged) + Q_PROPERTY(bool hasMultiSelection READ hasMultiSelection WRITE setHasMultiSelection NOTIFY + hasMultiSelectionChanged) + public: PropertyEditorContextObject(QObject *parent = nullptr); @@ -126,6 +129,10 @@ public: bool hasAliasExport() const { return m_aliasExport; } + bool hasMultiSelection() const; + + void setHasMultiSelection(bool); + signals: void specificsUrlChanged(); void specificQmlDataChanged(); @@ -142,6 +149,7 @@ signals: void hasAliasExportChanged(); void hasActiveTimelineChanged(); void activeDragSuffixChanged(); + void hasMultiSelectionChanged(); public slots: @@ -192,6 +200,8 @@ private: bool m_setHasActiveTimeline = false; QString m_activeDragSuffix; + + bool m_hasMultiSelection = false; }; class EasingCurveEditor : public QObject