2019-07-13 19:39:01 +10:00
|
|
|
import QtQuick 2.12
|
2019-07-21 05:06:38 +10:00
|
|
|
import QtQuick.Controls 2.12
|
2019-05-14 03:15:03 +10:00
|
|
|
|
2019-08-21 19:02:37 +10:00
|
|
|
ListView {
|
|
|
|
id: listView
|
2019-08-31 01:17:13 +10:00
|
|
|
interactive: enableFlicking
|
2019-08-21 19:02:37 +10:00
|
|
|
currentIndex: -1
|
2019-08-18 06:59:13 +10:00
|
|
|
keyNavigationWraps: true
|
2019-08-21 19:02:37 +10:00
|
|
|
highlightMoveDuration: theme.animationDuration
|
2019-08-18 06:59:13 +10:00
|
|
|
|
2019-08-21 19:02:37 +10:00
|
|
|
// Keep highlighted delegate at the center
|
|
|
|
highlightRangeMode: ListView.ApplyRange
|
|
|
|
preferredHighlightBegin: height / 2 - currentItemHeight
|
|
|
|
preferredHighlightEnd: height / 2 + currentItemHeight
|
|
|
|
|
|
|
|
|
2019-08-31 01:17:13 +10:00
|
|
|
property bool enableFlicking: true
|
|
|
|
|
2019-08-21 19:02:37 +10:00
|
|
|
readonly property int currentItemHeight:
|
|
|
|
currentItem ? currentItem.height : 0
|
|
|
|
|
|
|
|
|
2019-08-28 12:46:31 +10:00
|
|
|
highlight: Rectangle {
|
2019-08-21 19:02:37 +10:00
|
|
|
color: theme.controls.listView.highlight
|
|
|
|
}
|
|
|
|
|
2019-09-07 06:46:04 +10:00
|
|
|
ScrollBar.vertical: ScrollBar {
|
|
|
|
visible: listView.interactive || ! listView.enableFlicking
|
|
|
|
}
|
2019-08-21 19:02:37 +10:00
|
|
|
|
|
|
|
add: Transition {
|
|
|
|
ParallelAnimation {
|
|
|
|
HNumberAnimation { property: "opacity"; from: 0; to: 1 }
|
|
|
|
HNumberAnimation { properties: "x,y"; from: 100 }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
move: Transition {
|
|
|
|
ParallelAnimation {
|
|
|
|
// Ensure opacity goes to 1 if add/remove transition is interrupted
|
|
|
|
HNumberAnimation { property: "opacity"; to: 1 }
|
|
|
|
HNumberAnimation { properties: "x,y" }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
remove: Transition {
|
|
|
|
ParallelAnimation {
|
|
|
|
HNumberAnimation { property: "opacity"; to: 0 }
|
|
|
|
HNumberAnimation { properties: "x,y"; to: 100 }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
displaced: move
|
2019-05-14 03:15:03 +10:00
|
|
|
}
|