From c45f4eb654fd2a71c377f551bf8e5a55da54e2dc Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Tue, 18 Oct 2022 12:35:55 +0300 Subject: [PATCH 1/4] QmlDesigner: Add support for easingCurve property to EasingCurveDialog QtQuick3D.Particles3D.ScaleAffector has easingCurve property. We want to use existing EasingCurveDialog to edit the value, but the current dialog only supports property named 'easing' (used in animations). Added support for 'easingCurve' property as well. Task-number: QDS-8014 Change-Id: If0f47608f7ed3cb9db4a44f632d15b2135856800 Reviewed-by: Mahmoud Badri Reviewed-by: Qt CI Bot Reviewed-by: Thomas Hartmann --- .../timelineeditor/easingcurvedialog.cpp | 22 ++++++++++++++----- .../timelineeditor/easingcurvedialog.h | 4 +++- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/plugins/qmldesigner/components/timelineeditor/easingcurvedialog.cpp b/src/plugins/qmldesigner/components/timelineeditor/easingcurvedialog.cpp index 99e97d72de8..79f8141bf0b 100644 --- a/src/plugins/qmldesigner/components/timelineeditor/easingcurvedialog.cpp +++ b/src/plugins/qmldesigner/components/timelineeditor/easingcurvedialog.cpp @@ -159,9 +159,11 @@ EasingCurveDialog::EasingCurveDialog(const QList &frames, QWidget *pa resize(QSize(1421, 918)); } -void EasingCurveDialog::initialize(const QString &curveString) +void EasingCurveDialog::initialize(const PropertyName &propName, const QString &curveString) { EasingCurve curve; + m_easingCurveProperty = propName; + if (curveString.isEmpty()) { QEasingCurve qcurve; qcurve.addCubicBezierSegment(QPointF(0.2, 0.2), QPointF(0.8, 0.8), QPointF(1.0, 1.0)); @@ -180,11 +182,19 @@ void EasingCurveDialog::runDialog(const QList &frames, QWidget *paren EasingCurveDialog dialog(frames, parent); ModelNode current = frames.last(); + PropertyName propName; - if (current.hasBindingProperty("easing.bezierCurve")) - dialog.initialize(current.bindingProperty("easing.bezierCurve").expression()); - else - dialog.initialize(""); + NodeMetaInfo metaInfo = current.metaInfo(); + if (metaInfo.hasProperty("easing")) + propName = "easing.bezierCurve"; + else if (metaInfo.hasProperty("easingCurve")) + propName = "easingCurve.bezierCurve"; + + QString expression; + if (!propName.isEmpty() && current.hasBindingProperty(propName)) + expression = current.bindingProperty(propName).expression(); + + dialog.initialize(propName, expression); dialog.exec(); } @@ -207,7 +217,7 @@ bool EasingCurveDialog::apply() return view->executeInTransaction("EasingCurveDialog::apply", [this](){ auto expression = m_splineEditor->easingCurve().toString(); for (const auto &frame : qAsConst(m_frames)) - frame.bindingProperty("easing.bezierCurve").setExpression(expression); + frame.bindingProperty(m_easingCurveProperty).setExpression(expression); }); } diff --git a/src/plugins/qmldesigner/components/timelineeditor/easingcurvedialog.h b/src/plugins/qmldesigner/components/timelineeditor/easingcurvedialog.h index a8c026989c2..3f6ea95a5e0 100644 --- a/src/plugins/qmldesigner/components/timelineeditor/easingcurvedialog.h +++ b/src/plugins/qmldesigner/components/timelineeditor/easingcurvedialog.h @@ -49,7 +49,7 @@ class EasingCurveDialog : public QDialog public: EasingCurveDialog(const QList &frames, QWidget *parent = nullptr); - void initialize(const QString &curveString); + void initialize(const PropertyName &propName, const QString &curveString); static void runDialog(const QList &frames, QWidget *parent = nullptr); @@ -80,6 +80,8 @@ private: QLabel *m_label = nullptr; QList m_frames; + + PropertyName m_easingCurveProperty; }; } // namespace QmlDesigner From 0ac1920ed2e083191891756ba3ac3309500cd5e0 Mon Sep 17 00:00:00 2001 From: Mahmoud Badri Date: Wed, 19 Oct 2022 14:46:13 +0300 Subject: [PATCH 2/4] QmlDesigner: Clear search upon adding a bundle material Fixes: QDS-8025 Change-Id: Iaa1f7d9f94b602e60171a00d0cc51d5b19d71468 Reviewed-by: Reviewed-by: Miikka Heikkinen --- .../components/materialbrowser/materialbrowserview.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/plugins/qmldesigner/components/materialbrowser/materialbrowserview.cpp b/src/plugins/qmldesigner/components/materialbrowser/materialbrowserview.cpp index 0e13521206a..015b76630c7 100644 --- a/src/plugins/qmldesigner/components/materialbrowser/materialbrowserview.cpp +++ b/src/plugins/qmldesigner/components/materialbrowser/materialbrowserview.cpp @@ -315,6 +315,7 @@ void MaterialBrowserView::refreshModel(bool updateImages) } } + m_widget->clearSearchFilter(); m_widget->materialBrowserModel()->setMaterials(materials, m_hasQuick3DImport); if (updateImages) { From ac0251e1067ec363033b44772cba77adaff724b7 Mon Sep 17 00:00:00 2001 From: Henning Gruendl Date: Thu, 6 Oct 2022 11:15:22 +0200 Subject: [PATCH 3/4] QmlDesigner: Block DragHandler when menu open Task-number: QDS-7851 Change-Id: Ia48e326c1f33d7b405eb2f93936e3aa99f0a9e60 Reviewed-by: Reviewed-by: Thomas Hartmann --- .../qtcreator/qmldesigner/newstateseditor/Main.qml | 14 +++++++++++++- .../qmldesigner/newstateseditor/StateThumbnail.qml | 5 +++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/share/qtcreator/qmldesigner/newstateseditor/Main.qml b/share/qtcreator/qmldesigner/newstateseditor/Main.qml index 540f70b4857..4431252eccd 100644 --- a/share/qtcreator/qmldesigner/newstateseditor/Main.qml +++ b/share/qtcreator/qmldesigner/newstateseditor/Main.qml @@ -253,6 +253,10 @@ Rectangle { property bool tinyMode: Constants.thumbnailSize <= Constants.thumbnailBreak property int currentStateInternalId: 0 + // Using an int instead of a bool, because when opening a menu on one state and without closing + // opening a menu on another state will first trigger the open of the new popup and afterwards + // the close of the old popup. Using an int keeps track of number of opened popups. + property int menuOpen: 0 // This timer is used to delay the current state animation as it didn't work due to the // repeaters item not being positioned in time resulting in 0 x and y position if the grids @@ -797,10 +801,18 @@ Rectangle { hasWhenCondition: delegateRoot.hasWhenCondition - scrollViewActive: horizontalBar.active || verticalBar.active + blockDragHandler: horizontalBar.active || verticalBar.active + || root.menuOpen dragParent: scrollView + onMenuOpenChanged: { + if (stateThumbnail.menuOpen) + root.menuOpen++ + else + root.menuOpen-- + } + // Fix ScrollView taking over the dragging event onGrabbing: { frame.interactive = false diff --git a/share/qtcreator/qmldesigner/newstateseditor/StateThumbnail.qml b/share/qtcreator/qmldesigner/newstateseditor/StateThumbnail.qml index ce95aa21983..e154bb4d39b 100644 --- a/share/qtcreator/qmldesigner/newstateseditor/StateThumbnail.qml +++ b/share/qtcreator/qmldesigner/newstateseditor/StateThumbnail.qml @@ -55,7 +55,8 @@ Item { property bool hasWhenCondition: false - property bool scrollViewActive: false + property bool menuOpen: stateMenu.opened + property bool blockDragHandler: false property Item dragParent @@ -91,7 +92,7 @@ Item { DragHandler { id: dragHandler - enabled: !root.baseState && !root.extendedState && !root.scrollViewActive + enabled: !root.baseState && !root.extendedState && !root.blockDragHandler onGrabChanged: function (transition, point) { if (transition === PointerDevice.GrabPassive || transition === PointerDevice.GrabExclusive) From cf9b36a6c774eee851cdffbdd821a91587bae1f5 Mon Sep 17 00:00:00 2001 From: Henning Gruendl Date: Thu, 29 Sep 2022 12:59:07 +0200 Subject: [PATCH 4/4] QmlDesigner: Use AUX property to remember state Use AUX properties to save the StateThumbnail state (property changes or thumbnail). Also the save the state of the property changes state section (expanded or collapsed). Task-number: QDS-7732 Change-Id: I607bb05b7c71bb98e7781d058bb5736ab4b77e72 Reviewed-by: Reviewed-by: Thomas Hartmann --- .../qmldesigner/newstateseditor/Main.qml | 2 +- .../newstateseditor/StateThumbnail.qml | 21 ++++++++++++++----- .../stateseditornew/propertychangesmodel.cpp | 20 ++++++++++++++++++ .../stateseditornew/propertychangesmodel.h | 6 ++++++ .../stateseditornew/propertymodel.cpp | 20 ++++++++++++++++++ .../stateseditornew/propertymodel.h | 5 +++++ 6 files changed, 68 insertions(+), 6 deletions(-) diff --git a/share/qtcreator/qmldesigner/newstateseditor/Main.qml b/share/qtcreator/qmldesigner/newstateseditor/Main.qml index 4431252eccd..21385de257e 100644 --- a/share/qtcreator/qmldesigner/newstateseditor/Main.qml +++ b/share/qtcreator/qmldesigner/newstateseditor/Main.qml @@ -659,7 +659,7 @@ Rectangle { required property var extendString function setPropertyChangesVisible(value) { - stateThumbnail.propertyChangesVisible = value + stateThumbnail.setPropertyChangesVisible(value) } width: Constants.thumbnailSize diff --git a/share/qtcreator/qmldesigner/newstateseditor/StateThumbnail.qml b/share/qtcreator/qmldesigner/newstateseditor/StateThumbnail.qml index e154bb4d39b..6d4a84e44c7 100644 --- a/share/qtcreator/qmldesigner/newstateseditor/StateThumbnail.qml +++ b/share/qtcreator/qmldesigner/newstateseditor/StateThumbnail.qml @@ -46,7 +46,7 @@ Item { property alias menuChecked: menuButton.checked property bool baseState: false property bool isTiny: false - property bool propertyChangesVisible: false + property bool propertyChangesVisible: propertyChangesModel.propertyChangesVisible property bool isChecked: false property bool hasExtend: false @@ -80,6 +80,11 @@ Item { return statesEditorModel.hasAnnotation(root.internalNodeId) } + function setPropertyChangesVisible(value) { + root.propertyChangesVisible = value + propertyChangesModel.setPropertyChangesVisible(value) + } + onIsTinyChanged: { if (root.isTiny) { buttonGrid.rows = 2 @@ -315,6 +320,9 @@ Item { Column { id: column + property bool hoverEnabled: false + onPositioningComplete: column.hoverEnabled = true + // Grid sizes property int gridSpacing: 20 property int gridRowSpacing: 5 @@ -354,7 +362,7 @@ Item { Item { id: section property int animationDuration: 120 - property bool expanded: false + property bool expanded: propertyModel.expanded clip: true width: stateBackground.innerWidth @@ -416,6 +424,7 @@ Item { anchors.fill: parent onClicked: { section.expanded = !section.expanded + propertyModel.setExpanded(section.expanded) if (!section.expanded) section.forceActiveFocus() root.focusSignal() @@ -519,6 +528,8 @@ Item { Repeater { model: propertyModel + onModelChanged: column.hoverEnabled = false + delegate: ItemDelegate { id: propertyDelegate @@ -528,7 +539,7 @@ Item { width: stateBackground.innerWidth - 2 * column.gridPadding height: 26 - hoverEnabled: true + hoverEnabled: column.hoverEnabled onClicked: root.focusSignal() @@ -561,7 +572,7 @@ Item { MouseArea { id: propertyDelegateMouseArea anchors.fill: parent - hoverEnabled: true + hoverEnabled: column.hoverEnabled onClicked: { root.focusSignal() propertyModel.removeProperty( @@ -718,7 +729,7 @@ Item { onClone: root.clone() onExtend: root.extend() onRemove: root.remove() - onToggle: root.propertyChangesVisible = !root.propertyChangesVisible + onToggle: root.setPropertyChangesVisible(!root.propertyChangesVisible) onResetWhenCondition: statesEditorModel.resetWhenCondition(root.internalNodeId) onEditAnnotation: { statesEditorModel.setAnnotation(root.internalNodeId) diff --git a/src/plugins/qmldesigner/components/stateseditornew/propertychangesmodel.cpp b/src/plugins/qmldesigner/components/stateseditornew/propertychangesmodel.cpp index a2f022c1194..85a81537b78 100644 --- a/src/plugins/qmldesigner/components/stateseditornew/propertychangesmodel.cpp +++ b/src/plugins/qmldesigner/components/stateseditornew/propertychangesmodel.cpp @@ -123,6 +123,7 @@ void PropertyChangesModel::setModelNodeBackend(const QVariant &modelNodeBackend) m_view->registerPropertyChangesModel(this); emit modelNodeBackendChanged(); + emit propertyChangesVisibleChanged(); } void PropertyChangesModel::reset() @@ -138,6 +139,25 @@ int PropertyChangesModel::count() const return rowCount(); } +void PropertyChangesModel::setPropertyChangesVisible(bool value) +{ + if (!m_modelNode.isValid() || !m_modelNode.view()->isAttached()) + return; + + if (value) + m_modelNode.setAuxiliaryData("propertyChangesVisible@Internal", value); + else + m_modelNode.removeAuxiliaryData("propertyChangesVisible@Internal"); +} + +bool PropertyChangesModel::propertyChangesVisible() const +{ + if (!m_modelNode.isValid() || !m_modelNode.view()->isAttached()) + return false; + + return m_modelNode.hasAuxiliaryData("propertyChangesVisible@Internal"); +} + void PropertyChangesModel::registerDeclarativeType() { qmlRegisterType("HelperWidgets", 2, 0, "PropertyChangesModel"); diff --git a/src/plugins/qmldesigner/components/stateseditornew/propertychangesmodel.h b/src/plugins/qmldesigner/components/stateseditornew/propertychangesmodel.h index 622a1d29467..b73d4dad693 100644 --- a/src/plugins/qmldesigner/components/stateseditornew/propertychangesmodel.h +++ b/src/plugins/qmldesigner/components/stateseditornew/propertychangesmodel.h @@ -42,6 +42,8 @@ class PropertyChangesModel : public QAbstractListModel Q_PROPERTY(int count READ count NOTIFY countChanged) Q_PROPERTY(QVariant modelNodeBackendProperty READ modelNodeBackend WRITE setModelNodeBackend NOTIFY modelNodeBackendChanged) + Q_PROPERTY(bool propertyChangesVisible READ propertyChangesVisible NOTIFY + propertyChangesVisibleChanged) enum { Target = Qt::DisplayRole, @@ -62,11 +64,15 @@ public: void reset(); int count() const; + Q_INVOKABLE void setPropertyChangesVisible(bool value); + Q_INVOKABLE bool propertyChangesVisible() const; + static void registerDeclarativeType(); signals: void modelNodeBackendChanged(); void countChanged(); + void propertyChangesVisibleChanged(); private: QVariant modelNodeBackend() const; diff --git a/src/plugins/qmldesigner/components/stateseditornew/propertymodel.cpp b/src/plugins/qmldesigner/components/stateseditornew/propertymodel.cpp index ef589465b97..f53ecce3af1 100644 --- a/src/plugins/qmldesigner/components/stateseditornew/propertymodel.cpp +++ b/src/plugins/qmldesigner/components/stateseditornew/propertymodel.cpp @@ -114,6 +114,7 @@ void PropertyModel::setModelNodeBackend(const QVariant &modelNodeBackend) setupModel(); emit modelNodeBackendChanged(); + emit expandedChanged(); } void PropertyModel::setExplicit(bool value) @@ -146,6 +147,25 @@ void PropertyModel::removeProperty(const QString &name) m_modelNode.removeProperty(name.toUtf8()); } +void PropertyModel::setExpanded(bool value) +{ + if (!m_modelNode.isValid() || !m_modelNode.view()->isAttached()) + return; + + if (value) + m_modelNode.setAuxiliaryData("expanded@Internal", value); + else + m_modelNode.removeAuxiliaryData("expanded@Internal"); +} + +bool PropertyModel::expanded() const +{ + if (!m_modelNode.isValid() || !m_modelNode.view()->isAttached()) + return false; + + return m_modelNode.hasAuxiliaryData("expanded@Internal"); +} + void PropertyModel::registerDeclarativeType() { qmlRegisterType("HelperWidgets", 2, 0, "PropertyModel"); diff --git a/src/plugins/qmldesigner/components/stateseditornew/propertymodel.h b/src/plugins/qmldesigner/components/stateseditornew/propertymodel.h index 26c92cb7634..492b1362c0e 100644 --- a/src/plugins/qmldesigner/components/stateseditornew/propertymodel.h +++ b/src/plugins/qmldesigner/components/stateseditornew/propertymodel.h @@ -39,6 +39,7 @@ class PropertyModel : public QAbstractListModel Q_PROPERTY(QVariant modelNodeBackendProperty READ modelNodeBackend WRITE setModelNodeBackend NOTIFY modelNodeBackendChanged) + Q_PROPERTY(bool expanded READ expanded NOTIFY expandedChanged) enum { Name = Qt::DisplayRole, Value = Qt::UserRole, Type }; @@ -55,10 +56,14 @@ public: Q_INVOKABLE void setRestoreEntryValues(bool value); Q_INVOKABLE void removeProperty(const QString &name); + Q_INVOKABLE void setExpanded(bool value); + Q_INVOKABLE bool expanded() const; + static void registerDeclarativeType(); signals: void modelNodeBackendChanged(); + void expandedChanged(); private: QVariant modelNodeBackend() const;