bazzite-xmb/qml/VerticalList.qml

40 lines
988 B
QML

import QtQuick
import QtQuick.Controls
Item {
id: vl
property var itemsModel: []
property int currentIndex: 0
signal activated(int idx)
signal triggered(var entryObj)
readonly property int count: lv.count
function positionViewAtIndex(i, mode) { lv.positionViewAtIndex(i, mode) }
function triggerCurrent() {
if (lv.currentItem && lv.currentItem.entryObj) triggered(lv.currentItem.entryObj)
}
ListView {
id: lv
anchors.fill: parent
model: vl.itemsModel
spacing: 10
currentIndex: vl.currentIndex
clip: true
boundsBehavior: Flickable.StopAtBounds
delegate: XmbItemDelegate {
width: lv.width
entryObj: modelData
focused: (index === lv.currentIndex)
onClicked: {
vl.activated(index)
vl.triggered(entryObj)
}
}
onCurrentIndexChanged: vl.activated(currentIndex)
}
}