Files
Jellyfin-Freebox/Components/FocusButton.qml
T
2026-11-08 10:26:27 +01:00

47 lines
1.2 KiB
QML

import QtQuick 2.5
import "."
// Bouton navigable à la télécommande : surbrillance blanche quand il a le focus.
Rectangle {
id: root
property alias text: label.text
property bool primary: false
signal clicked()
implicitWidth: Math.max(160, label.implicitWidth + Theme.spacingL * 2)
implicitHeight: Theme.controlHeight
radius: Theme.radius
opacity: enabled ? 1 : 0.5
color: activeFocus ? Theme.focusBackground : (primary ? Theme.accent : Theme.surface)
scale: activeFocus ? 1.05 : 1
Behavior on scale { NumberAnimation { duration: Theme.animFast } }
Behavior on color { ColorAnimation { duration: Theme.animFast } }
Text {
id: label
anchors.centerIn: parent
color: root.activeFocus ? Theme.textOnFocus : Theme.text
font.pixelSize: Theme.fontBody
font.bold: root.activeFocus
}
Keys.onPressed: {
if (Remote.isAccept(event.key)) {
event.accepted = true;
root.clicked();
}
}
// Souris : pratique pour tester hors de la box.
MouseArea {
anchors.fill: parent
enabled: root.enabled
onClicked: {
root.forceActiveFocus();
root.clicked();
}
}
}