Merge remote-tracking branch 'origin/8.0' into 9.0

Conflicts:
	src/plugins/qmldesigner/components/timelineeditor/easingcurvedialog.cpp

Change-Id: I435b955899fcc70faaec6332de55283cf16b694f
This commit is contained in:
Eike Ziller
2022-10-20 15:07:52 +02:00
9 changed files with 94 additions and 16 deletions

View File

@@ -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

View File

@@ -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)

View File

@@ -293,6 +293,7 @@ void MaterialBrowserView::refreshModel(bool updateImages)
}
}
m_widget->clearSearchFilter();
m_widget->materialBrowserModel()->setMaterials(materials, m_hasQuick3DImport);
if (updateImages) {

View File

@@ -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<PropertyChangesModel>("HelperWidgets", 2, 0, "PropertyChangesModel");

View File

@@ -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;

View File

@@ -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<PropertyModel>("HelperWidgets", 2, 0, "PropertyModel");

View File

@@ -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;

View File

@@ -129,9 +129,11 @@ EasingCurveDialog::EasingCurveDialog(const QList<ModelNode> &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<ModelNode> &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);
});
}

View File

@@ -27,7 +27,7 @@ class EasingCurveDialog : public QDialog
public:
EasingCurveDialog(const QList<ModelNode> &frames, QWidget *parent = nullptr);
void initialize(const QString &curveString);
void initialize(const PropertyName &propName, const QString &curveString);
static void runDialog(const QList<ModelNode> &frames, QWidget *parent = nullptr);
@@ -58,6 +58,8 @@ private:
QLabel *m_label = nullptr;
QList<ModelNode> m_frames;
PropertyName m_easingCurveProperty;
};
} // namespace QmlDesigner