Fix HSwipeView binding loop
This commit is contained in:
parent
17452ea69b
commit
d8639db8ee
@ -1,14 +1,22 @@
|
|||||||
|
import QtQuick 2.12
|
||||||
import QtQuick.Controls 2.12
|
import QtQuick.Controls 2.12
|
||||||
|
|
||||||
SwipeView {
|
SwipeView {
|
||||||
currentIndex: window.getState(this, "currentIndex", defaultIndex)
|
Component.onCompleted: if (! changed) {
|
||||||
onCurrentIndexChanged: window.saveState(this)
|
setCurrentIndex(window.getState(this, "currentIndex", defaultIndex))
|
||||||
|
saveEnabled = true
|
||||||
|
}
|
||||||
|
|
||||||
|
onCurrentIndexChanged: if (saveEnabled) window.saveState(this)
|
||||||
|
|
||||||
|
|
||||||
property string saveName: ""
|
property string saveName: ""
|
||||||
property var saveId: "ALL"
|
property var saveId: "ALL"
|
||||||
property var saveProperties: ["currentIndex"]
|
property var saveProperties: ["currentIndex"]
|
||||||
|
|
||||||
|
// Prevent onCurrentIndexChanged from running before Component.onCompleted
|
||||||
|
property bool saveEnabled: false
|
||||||
|
|
||||||
property int defaultIndex: 0
|
property int defaultIndex: 0
|
||||||
property bool changed: currentIndex !== defaultIndex
|
property bool changed: currentIndex !== defaultIndex
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user