bazzite-xmb/qml/XmbRoot.qml
2026-01-14 16:02:39 +01:00

119 lines
3.0 KiB
QML

import QtQuick
import QtQuick.Controls
import XMB 1.0
Item {
id: root
focus: true
property int catIndex: 0
property int itemIndex: 0
Sounds { id: sounds }
Rectangle {
anchors.fill: parent
color: "#071022"
}
// Hintergrund-Glow (dezent)
Rectangle {
width: parent.width
height: parent.height
opacity: 0.20
gradient: Gradient {
GradientStop { position: 0.0; color: "#10284a" }
GradientStop { position: 1.0; color: "#071022" }
}
}
CategoryStrip {
id: strip
anchors.left: parent.left
anchors.right: parent.right
anchors.top: parent.top
anchors.topMargin: 80
height: 130
model: XmbModel.categories
currentIndex: root.catIndex
onActivated: (idx) => {
root.catIndex = idx
root.itemIndex = 0
sounds.move()
}
}
VerticalList {
id: vlist
anchors.left: parent.left
anchors.right: parent.right
anchors.top: strip.bottom
anchors.bottom: parent.bottom
anchors.topMargin: 20
anchors.bottomMargin: 40
itemsModel: XmbModel.itemsForCategory(root.catIndex)
currentIndex: root.itemIndex
onActivated: (idx) => {
root.itemIndex = idx
sounds.move()
}
onTriggered: (entryObj) => {
sounds.select()
Launcher.launch(entryObj)
}
}
// Controller / Keyboard input
Keys.onPressed: (e) => {
if (e.isAutoRepeat) return
switch (e.key) {
case Qt.Key_Left:
root.catIndex = Math.max(0, root.catIndex - 1)
root.itemIndex = 0
strip.positionViewAtIndex(root.catIndex, ListView.Visible)
sounds.move()
e.accepted = true
break
case Qt.Key_Right:
root.catIndex = Math.min(XmbModel.categoryCount - 1, root.catIndex + 1)
root.itemIndex = 0
strip.positionViewAtIndex(root.catIndex, ListView.Visible)
sounds.move()
e.accepted = true
break
case Qt.Key_Up:
root.itemIndex = Math.max(0, root.itemIndex - 1)
vlist.positionViewAtIndex(root.itemIndex, ListView.Visible)
sounds.move()
e.accepted = true
break
case Qt.Key_Down:
root.itemIndex = Math.min(vlist.count - 1, root.itemIndex + 1)
vlist.positionViewAtIndex(root.itemIndex, ListView.Visible)
sounds.move()
e.accepted = true
break
case Qt.Key_Return:
case Qt.Key_Enter:
case Qt.Key_Space:
vlist.triggerCurrent()
e.accepted = true
break
case Qt.Key_Escape:
case Qt.Key_Backspace:
sounds.back()
// optional: zurück in Kategorie-Root
root.itemIndex = 0
e.accepted = true
break
default:
break
}
}
}