commits
tags
import QtQuick
import TvLauncher
// Förhandsvisningen överst på hemskärmen för en app. Används också i
// dialogen "Utseende och förhandsvisning" (nerskalad).
//
// Appens fält som påverkar visningen:
// heroImage egen bild (sökväg, ~/..., eller http(s)-adress)
// heroText egen text under namnet (annars adress/kommando)
// heroShowIcon false = dölj ikonen
Item {
id: hv
property var app: null
// Höjden på själva förhandsvisningen. Bilden fyller hela vyn (även bakom
// raderna på hemskärmen), text och ikon placeras inom heroHeight.
property real heroHeight: height
readonly property bool hasIcon: bigIcon.status === Image.Ready && bigIcon.implicitWidth > 1
readonly property bool showIcon: app !== null && app.heroShowIcon !== false
readonly property bool hasImage: bgImg.status === Image.Ready
function hostOf(url) { return (url || "").replace(/^[a-z]+:\/\//i, "").replace(/\/.*$/, "") }
// Egen bild som täcker hela vyn och tonar ut mot vänster och nedåt.
Image {
id: bgImg
anchors.fill: parent
source: hv.app && hv.app.heroImage ? Theme.imageUrl(hv.app.heroImage) : ""
fillMode: Image.PreserveAspectCrop
horizontalAlignment: Image.AlignRight
verticalAlignment: Image.AlignTop
sourceSize.width: 1920
asynchronous: true
visible: status === Image.Ready
Rectangle {
anchors.fill: parent
gradient: Gradient {
orientation: Gradient.Horizontal
GradientStop { position: 0.0; color: "#f2000000" }
GradientStop { position: 0.3; color: "#b0000000" }
GradientStop { position: 0.65; color: "#00000000" }
}
}
Rectangle {
anchors.fill: parent
gradient: Gradient {
GradientStop { position: 0.0; color: "#00000000" }
GradientStop { position: Math.min(0.95, hv.heroHeight / Math.max(1, hv.height) * 0.75); color: "#00000000" }
GradientStop { position: 1.0; color: "#f0000000" }
}
}
}
Item {
visible: hv.showIcon
anchors { right: parent.right; rightMargin: Theme.dp(220) }
y: hv.heroHeight / 2 - height / 2 + Theme.dp(50)
width: Theme.dp(240); height: width
Image {
id: bigIcon
anchors.fill: parent
sourceSize: Qt.size(256, 256)
fillMode: Image.PreserveAspectFit
asynchronous: true
source: hv.app && hv.app.icon ? "image://icon/" + encodeURIComponent(hv.app.icon) : ""
visible: hv.hasIcon
}
Text {
anchors.centerIn: parent
visible: !hv.hasIcon && hv.app !== null
text: hv.app ? (hv.app.name || "").charAt(0).toUpperCase() : ""
color: Theme.text
opacity: 0.85
font.family: Theme.fontFamily
font.pixelSize: Theme.dp(200)
font.weight: Font.Bold
}
}
Column {
anchors { left: parent.left; leftMargin: Theme.dp(110) }
y: hv.heroHeight - height - Theme.dp(50)
width: parent.width * 0.5
spacing: Theme.dp(14)
visible: hv.app !== null
Text {
text: hv.app ? (hv.app.type === "web" ? "WEBBAPP" : "PROGRAM") + " · " + (hv.app.category || "").toUpperCase() : ""
color: Theme.accent
font.family: Theme.fontFamily
font.pixelSize: Theme.dp(22)
font.weight: Font.Bold
font.letterSpacing: Theme.dp(3)
}
Text {
width: parent.width
text: hv.app ? (hv.app.name || "") : ""
color: Theme.text
elide: Text.ElideRight
font.family: Theme.fontFamily
font.pixelSize: Theme.dp(88)
font.weight: Font.Bold
}
Text {
width: parent.width
text: {
const s = hv.app
if (!s) return ""
if (s.heroText) return s.heroText
if (s.chromiumAppId)
return (s.url ? hv.hostOf(s.url) + " · " : "") + "installerad i Chromium"
if (s.type === "web")
return hv.hostOf(s.url) + (s.engine === "chromium" ? " · öppnas i Chromium" : "")
return s.command || ""
}
color: Theme.textDim
wrapMode: Text.Wrap
maximumLineCount: 3
elide: Text.ElideRight
font.family: Theme.fontFamily
font.pixelSize: Theme.dp(28)
}
}
}