2019-07-13 05:39:01 -04:00
|
|
|
import QtQuick 2.12
|
2019-07-20 15:06:38 -04:00
|
|
|
import QtQuick.Controls 2.12
|
2019-05-13 13:15:03 -04:00
|
|
|
|
2019-08-21 05:02:37 -04:00
|
|
|
ListView {
|
|
|
|
id: listView
|
2019-08-30 11:17:13 -04:00
|
|
|
interactive: enableFlicking
|
2019-08-21 05:02:37 -04:00
|
|
|
currentIndex: -1
|
2019-08-17 16:59:13 -04:00
|
|
|
keyNavigationWraps: true
|
2019-08-21 05:02:37 -04:00
|
|
|
highlightMoveDuration: theme.animationDuration
|
2019-08-17 16:59:13 -04:00
|
|
|
|
2019-08-21 05:02:37 -04:00
|
|
|
// Keep highlighted delegate at the center
|
|
|
|
highlightRangeMode: ListView.ApplyRange
|
|
|
|
preferredHighlightBegin: height / 2 - currentItemHeight
|
|
|
|
preferredHighlightEnd: height / 2 + currentItemHeight
|
|
|
|
|
2019-09-06 17:03:52 -04:00
|
|
|
maximumFlickVelocity: 4000
|
2019-08-21 05:02:37 -04:00
|
|
|
|
2019-08-30 11:17:13 -04:00
|
|
|
property bool enableFlicking: true
|
|
|
|
|
2019-08-21 05:02:37 -04:00
|
|
|
readonly property int currentItemHeight:
|
|
|
|
currentItem ? currentItem.height : 0
|
|
|
|
|
|
|
|
|
2019-08-27 22:46:31 -04:00
|
|
|
highlight: Rectangle {
|
2019-08-21 05:02:37 -04:00
|
|
|
color: theme.controls.listView.highlight
|
|
|
|
}
|
|
|
|
|
2019-09-06 16:46:04 -04:00
|
|
|
ScrollBar.vertical: ScrollBar {
|
|
|
|
visible: listView.interactive || ! listView.enableFlicking
|
|
|
|
}
|
2019-08-21 05:02:37 -04:00
|
|
|
|
2019-11-30 16:27:34 -04:00
|
|
|
// FIXME: HOpacityAnimator creates flickering
|
|
|
|
|
2019-08-21 05:02:37 -04:00
|
|
|
add: Transition {
|
|
|
|
ParallelAnimation {
|
2019-11-30 16:27:34 -04:00
|
|
|
HNumberAnimation { property: "opacity"; from: 0; to: 1 }
|
|
|
|
HXAnimator { from: 100 }
|
|
|
|
HYAnimator { from: 100 }
|
2019-08-21 05:02:37 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
move: Transition {
|
|
|
|
ParallelAnimation {
|
|
|
|
// Ensure opacity goes to 1 if add/remove transition is interrupted
|
2019-11-30 16:27:34 -04:00
|
|
|
HNumberAnimation { property: "opacity"; to: 1 }
|
|
|
|
HXAnimator {}
|
|
|
|
HYAnimator {}
|
2019-08-21 05:02:37 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
remove: Transition {
|
|
|
|
ParallelAnimation {
|
2019-11-30 16:27:34 -04:00
|
|
|
HNumberAnimation { property: "opacity"; to: 0 }
|
|
|
|
HXAnimator { to: 100 }
|
|
|
|
HYAnimator { to: 100 }
|
2019-08-21 05:02:37 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
displaced: move
|
2019-05-13 13:15:03 -04:00
|
|
|
}
|