Fix checkbox update when default state changes
Make sure to update checkboxes when their default value changes and the user hasn't already changed the value themselves. This fixes a dangerous issue with new room switching and room settings checkboxes keeping their value from the previous room.
This commit is contained in:
parent
9ac4cd0a97
commit
e65202cfbe
|
@ -12,6 +12,8 @@ CheckBox {
|
||||||
property bool defaultChecked: false
|
property bool defaultChecked: false
|
||||||
readonly property bool changed: checked !== defaultChecked
|
readonly property bool changed: checked !== defaultChecked
|
||||||
|
|
||||||
|
property bool previousDefaultChecked: false // private
|
||||||
|
|
||||||
function reset() { checked = defaultChecked }
|
function reset() { checked = defaultChecked }
|
||||||
|
|
||||||
|
|
||||||
|
@ -92,5 +94,15 @@ CheckBox {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onDefaultCheckedChanged: {
|
||||||
|
if (checked === previousDefaultChecked)
|
||||||
|
checked = Qt.binding(() => defaultChecked)
|
||||||
|
|
||||||
|
previousDefaultChecked = defaultChecked
|
||||||
|
}
|
||||||
|
|
||||||
|
// Break binding
|
||||||
|
Component.onCompleted: previousDefaultChecked = previousDefaultChecked
|
||||||
|
|
||||||
Behavior on opacity { HNumberAnimation { factor: 2 } }
|
Behavior on opacity { HNumberAnimation { factor: 2 } }
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user