foxygit / TV-Launcher Log in
commits tags

/qml/TvButton.qml · 885 B

raw
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import TvLauncher

Button {
    id: btn
    property bool danger: false
    Layout.preferredHeight: Theme.dp(60)
    Layout.preferredWidth: Theme.dp(200)
    implicitHeight: Theme.dp(60)
    implicitWidth: Math.max(Theme.dp(200), label.implicitWidth + Theme.dp(48))
    font.family: Theme.fontFamily
    font.pixelSize: Theme.dp(24)
    Keys.onReturnPressed: clicked()
    Keys.onEnterPressed: clicked()
    contentItem: Text {
        id: label
        text: btn.text
        font: btn.font
        color: btn.activeFocus && !btn.danger ? Theme.onAccent : Theme.text
        horizontalAlignment: Text.AlignHCenter
        verticalAlignment: Text.AlignVCenter
    }
    background: Rectangle {
        radius: Theme.r(8)
        color: btn.activeFocus ? (btn.danger ? Theme.danger : Theme.accent) : Theme.surfaceHi
    }
}