commits
tags
import QtQuick
import TvLauncher
// Tema: färgtema, accentfärg, rutstorlek och hörn. Allt ändras direkt
// och sparas i ~/.config/tv-launcher/settings.ini.
Item {
id: page
function focusFirst() { list.focusFirst() }
// Vågrät rad med val (färgteman, accentfärger). Upp/ner går vidare i listan.
component ChoiceRow: ListView {
id: row
property bool focusable: true
property var selected
signal picked(var value)
width: parent ? parent.width : 0
orientation: ListView.Horizontal
spacing: Theme.dp(18)
clip: false
keyNavigationWraps: false
boundsBehavior: Flickable.StopAtBounds
highlightRangeMode: ListView.ApplyRange
preferredHighlightBegin: Theme.dp(10)
preferredHighlightEnd: width - Theme.dp(10)
highlightMoveDuration: 150
onActiveFocusChanged: if (activeFocus) list.ensureVisible(row)
}
CardList {
id: list
anchors.fill: parent
SectionTitle { text: "Färgtema"; topPadding: 0 }
ChoiceRow {
id: presetRow
height: Theme.dp(190)
model: Theme.presetKeys
selected: prefs.themePreset
currentIndex: Math.max(0, Theme.presetKeys.indexOf(prefs.themePreset))
delegate: Item {
id: presetItem
required property string modelData
required property int index
readonly property var pal: Theme.presets[modelData]
readonly property bool current: ListView.isCurrentItem && presetRow.activeFocus
width: Theme.dp(220)
height: presetRow.height
Keys.onReturnPressed: prefs.themePreset = modelData
Keys.onEnterPressed: prefs.themePreset = modelData
// Miniatyr av temat: bakgrund, kort och accent.
Rectangle {
id: swatch
width: parent.width
height: Theme.dp(130)
radius: Theme.r(12)
border.width: presetItem.current ? Theme.dp(4) : Theme.dp(1)
border.color: presetItem.current ? Theme.accent : Theme.border
gradient: Gradient {
GradientStop { position: 0; color: presetItem.pal.backdropTop }
GradientStop { position: 1; color: presetItem.pal.bg }
}
Column {
anchors { left: parent.left; right: parent.right; bottom: parent.bottom; margins: Theme.dp(16) }
spacing: Theme.dp(8)
Rectangle { width: parent.width; height: Theme.dp(20); radius: Theme.r(4); color: presetItem.pal.cardFocus; border.width: Theme.dp(2); border.color: Theme.accent }
Rectangle { width: parent.width * 0.7; height: Theme.dp(20); radius: Theme.r(4); color: presetItem.pal.card }
}
Rectangle {
visible: prefs.themePreset === presetItem.modelData
anchors { right: parent.right; top: parent.top; margins: Theme.dp(10) }
width: Theme.dp(36); height: width; radius: width / 2
color: Theme.accent
Icon { anchors.centerIn: parent; width: Theme.dp(24); height: width; name: "check" }
}
}
Text {
anchors { top: swatch.bottom; topMargin: Theme.dp(12); horizontalCenter: parent.horizontalCenter }
text: presetItem.pal.name
color: presetItem.current ? Theme.text : Theme.textDim
font.family: Theme.fontFamily
font.pixelSize: Theme.dp(24)
}
MouseArea {
anchors.fill: parent
onClicked: { presetRow.currentIndex = presetItem.index; presetRow.forceActiveFocus(); prefs.themePreset = presetItem.modelData }
}
}
}
SectionTitle { text: "Accentfärg" }
ChoiceRow {
id: accentRow
height: Theme.dp(130)
model: Theme.accents
currentIndex: Math.max(0, Theme.accents.findIndex(a => Qt.colorEqual(a.color, prefs.accent)))
delegate: Item {
id: accentItem
required property var modelData
required property int index
readonly property bool current: ListView.isCurrentItem && accentRow.activeFocus
readonly property bool selected: Qt.colorEqual(modelData.color, prefs.accent)
width: Theme.dp(96)
height: accentRow.height
Keys.onReturnPressed: prefs.accent = modelData.color
Keys.onEnterPressed: prefs.accent = modelData.color
Rectangle {
id: dot
anchors.horizontalCenter: parent.horizontalCenter
y: Theme.dp(6)
width: Theme.dp(72); height: width
radius: width / 2
color: accentItem.modelData.color
border.width: accentItem.current ? Theme.dp(5) : 0
border.color: Theme.text
scale: accentItem.current ? 1.1 : 1
Behavior on scale { NumberAnimation { duration: 120 } }
Icon {
visible: accentItem.selected
anchors.centerIn: parent
width: Theme.dp(36); height: width
name: "check"
}
}
Text {
anchors { top: dot.bottom; topMargin: Theme.dp(12); horizontalCenter: parent.horizontalCenter }
text: accentItem.modelData.name
color: accentItem.current ? Theme.text : Theme.textDim
font.family: Theme.fontFamily
font.pixelSize: Theme.dp(20)
}
MouseArea {
anchors.fill: parent
onClicked: { accentRow.currentIndex = accentItem.index; accentRow.forceActiveFocus(); prefs.accent = accentItem.modelData.color }
}
}
}
SectionTitle { text: "Utseende" }
SettingsCard {
icon: "palette"
title: "Rutornas färg"
subtitle: "En app med egen färg (Y → Utseende) behåller den"
options: [{ value: "app", label: "Färg per app" }, { value: "theme", label: "Temats färg" },
{ value: "accent", label: "Accentfärgen" }]
value: prefs.tileMode
onChosen: (v) => prefs.tileMode = v
}
SliderCard {
icon: "image"
title: "Rutornas genomskinlighet"
// 0 % = täckande, 90 % = nästan genomskinlig
value: (1 - Number(prefs.tileOpacity)) / 0.9
valueText: Math.round((1 - Number(prefs.tileOpacity)) * 100) + " %"
onMoved: (v) => prefs.tileOpacity = 1 - v * 0.9
}
SettingsCard {
icon: "apps"
title: "Rutstorlek"
subtitle: "Storlek på apparna på hemskärmen"
options: [{ value: 0.85, label: "Liten" }, { value: 1.0, label: "Normal" }, { value: 1.15, label: "Stor" }]
value: Number(prefs.tileScale)
onChosen: (v) => prefs.tileScale = v
}
SettingsCard {
icon: "image"
title: "Hörn"
subtitle: "Hur rundade rutor, kort och knappar är"
options: [{ value: 0.3, label: "Raka" }, { value: 1.0, label: "Rundade" }, { value: 1.8, label: "Extra rundade" }]
value: Number(prefs.radiusScale)
onChosen: (v) => prefs.radiusScale = v
}
SettingsCard {
icon: "refresh"
title: "Återställ standardtemat"
onActivated: prefs.resetTheme()
}
}
}