commits
tags
import QtQuick
import TvLauncher
// En ruta på hemskärmen i Bigscreen-stil: färgat kort med ikon,
// namn och undertext under.
Item {
id: tile
property string name
property string subtitle
property string icon
property string glyph
property bool isWeb: false
property string customColor // egen färg, tom = enligt temat
signal activated()
signal menuRequested()
signal hovered()
width: Theme.tile(340)
height: Theme.tile(300)
z: activeFocus ? 10 : 0
Keys.onReturnPressed: tile.activated()
Keys.onEnterPressed: tile.activated()
Keys.onMenuPressed: tile.menuRequested()
Item {
id: body
anchors.fill: parent
scale: tile.activeFocus ? 1.05 : 1.0
transformOrigin: Item.Top
Behavior on scale { NumberAnimation { duration: 140; easing.type: Easing.OutCubic } }
Rectangle {
id: card
anchors { left: parent.left; right: parent.right; top: parent.top }
height: Theme.tile(205)
radius: Theme.r(12)
color: tile.glyph !== "" ? Theme.cardFocus : Theme.tileColor(tile.name, tile.customColor)
border.width: tile.activeFocus ? Theme.dp(5) : 0
border.color: Theme.accent
Image {
id: img
anchors.centerIn: parent
width: Theme.tile(112)
height: width
sourceSize: Qt.size(256, 256)
fillMode: Image.PreserveAspectFit
asynchronous: true
smooth: true
source: tile.icon !== "" ? "image://icon/" + encodeURIComponent(tile.icon) : ""
visible: status === Image.Ready && implicitWidth > 1
}
Text {
anchors.centerIn: parent
visible: !img.visible
text: tile.glyph !== "" ? tile.glyph : tile.name.charAt(0).toUpperCase()
color: Theme.text
font.family: Theme.fontFamily
font.pixelSize: tile.glyph !== "" ? Theme.tile(64) : Theme.tile(88)
font.weight: Font.DemiBold
}
Rectangle {
visible: tile.isWeb
anchors { right: parent.right; top: parent.top; margins: Theme.dp(12) }
radius: Theme.r(6)
color: "#80000000"
width: webLabel.implicitWidth + Theme.dp(14)
height: webLabel.implicitHeight + Theme.dp(6)
Text {
id: webLabel
anchors.centerIn: parent
text: "WEBB"
color: Theme.textDim
font.pixelSize: Theme.dp(14)
font.weight: Font.Bold
}
}
}
Column {
anchors { left: parent.left; right: parent.right; top: card.bottom; topMargin: Theme.dp(14); leftMargin: Theme.dp(4) }
spacing: Theme.dp(2)
Text {
width: parent.width
text: tile.name
elide: Text.ElideRight
color: Theme.text
font.family: Theme.fontFamily
font.pixelSize: Theme.dp(28)
}
Text {
width: parent.width
visible: text !== ""
text: tile.subtitle
elide: Text.ElideRight
color: Theme.textDim
font.family: Theme.fontFamily
font.pixelSize: Theme.dp(21)
}
}
}
MouseArea {
anchors.fill: parent
hoverEnabled: true
acceptedButtons: Qt.LeftButton | Qt.RightButton
onEntered: tile.hovered()
onClicked: (mouse) => {
tile.hovered()
if (mouse.button === Qt.RightButton)
tile.menuRequested()
else
tile.activated()
}
onPressAndHold: tile.menuRequested()
}
}