diff --git a/share/qtcreator/qmldesigner/newstateseditor/Main.qml b/share/qtcreator/qmldesigner/newstateseditor/Main.qml index 540f70b4857..21385de257e 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 @@ -655,7 +659,7 @@ Rectangle { required property var extendString function setPropertyChangesVisible(value) { - stateThumbnail.propertyChangesVisible = value + stateThumbnail.setPropertyChangesVisible(value) } width: Constants.thumbnailSize @@ -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..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 @@ -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 @@ -79,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 @@ -91,7 +97,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) @@ -314,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 @@ -353,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 @@ -415,6 +424,7 @@ Item { anchors.fill: parent onClicked: { section.expanded = !section.expanded + propertyModel.setExpanded(section.expanded) if (!section.expanded) section.forceActiveFocus() root.focusSignal() @@ -518,6 +528,8 @@ Item { Repeater { model: propertyModel + onModelChanged: column.hoverEnabled = false + delegate: ItemDelegate { id: propertyDelegate @@ -527,7 +539,7 @@ Item { width: stateBackground.innerWidth - 2 * column.gridPadding height: 26 - hoverEnabled: true + hoverEnabled: column.hoverEnabled onClicked: root.focusSignal() @@ -560,7 +572,7 @@ Item { MouseArea { id: propertyDelegateMouseArea anchors.fill: parent - hoverEnabled: true + hoverEnabled: column.hoverEnabled onClicked: { root.focusSignal() propertyModel.removeProperty( @@ -717,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/materialbrowser/materialbrowserview.cpp b/src/plugins/qmldesigner/components/materialbrowser/materialbrowserview.cpp index 64b7f6ccd81..28a37a5be82 100644 --- a/src/plugins/qmldesigner/components/materialbrowser/materialbrowserview.cpp +++ b/src/plugins/qmldesigner/components/materialbrowser/materialbrowserview.cpp @@ -293,6 +293,7 @@ void MaterialBrowserView::refreshModel(bool updateImages) } } + m_widget->clearSearchFilter(); m_widget->materialBrowserModel()->setMaterials(materials, m_hasQuick3DImport); if (updateImages) { diff --git a/src/plugins/qmldesigner/components/stateseditornew/propertychangesmodel.cpp b/src/plugins/qmldesigner/components/stateseditornew/propertychangesmodel.cpp index a2f022c1194..7330cf8d70e 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,20 @@ int PropertyChangesModel::count() const return rowCount(); } +namespace { +constexpr AuxiliaryDataKeyDefaultValue propertyChangesVisibleProperty{AuxiliaryDataType::Temporary, + "propertyChangesVisible", + false}; +} +void PropertyChangesModel::setPropertyChangesVisible(bool value) +{ + m_modelNode.setAuxiliaryData(propertyChangesVisibleProperty, value); +} +bool PropertyChangesModel::propertyChangesVisible() const +{ + return m_modelNode.auxiliaryDataWithDefault(propertyChangesVisibleProperty).toBool(); +} + 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 71a76d93160..35a64dd5a02 100644 --- a/src/plugins/qmldesigner/components/stateseditornew/propertymodel.cpp +++ b/src/plugins/qmldesigner/components/stateseditornew/propertymodel.cpp @@ -117,6 +117,7 @@ void PropertyModel::setModelNodeBackend(const QVariant &modelNodeBackend) setupModel(); emit modelNodeBackendChanged(); + emit expandedChanged(); } void PropertyModel::setExplicit(bool value) @@ -149,6 +150,20 @@ void PropertyModel::removeProperty(const QString &name) m_modelNode.removeProperty(name.toUtf8()); } +namespace { +constexpr AuxiliaryDataKeyDefaultValue expandedProperty{AuxiliaryDataType::Temporary, + "propertyModelExpanded", + false}; +} +void PropertyModel::setExpanded(bool value) +{ + m_modelNode.setAuxiliaryData(expandedProperty, value); +} +bool PropertyModel::expanded() const +{ + return m_modelNode.auxiliaryDataWithDefault(expandedProperty).toBool(); +} + 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; diff --git a/src/plugins/qmldesigner/components/timelineeditor/easingcurvedialog.cpp b/src/plugins/qmldesigner/components/timelineeditor/easingcurvedialog.cpp index 96e6140f618..5d3521b1675 100644 --- a/src/plugins/qmldesigner/components/timelineeditor/easingcurvedialog.cpp +++ b/src/plugins/qmldesigner/components/timelineeditor/easingcurvedialog.cpp @@ -129,9 +129,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)); @@ -150,11 +152,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(); } @@ -177,7 +187,7 @@ bool EasingCurveDialog::apply() return view->executeInTransaction("EasingCurveDialog::apply", [this](){ auto expression = m_splineEditor->easingCurve().toString(); for (const auto &frame : std::as_const(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 413db30b2f9..a9152f4044d 100644 --- a/src/plugins/qmldesigner/components/timelineeditor/easingcurvedialog.h +++ b/src/plugins/qmldesigner/components/timelineeditor/easingcurvedialog.h @@ -27,7 +27,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); @@ -58,6 +58,8 @@ private: QLabel *m_label = nullptr; QList m_frames; + + PropertyName m_easingCurveProperty; }; } // namespace QmlDesigner