import QtQuick import TvLauncher // Välj bakgrundsbild bland bilder i ~/Bilder, ~/Pictures och systemets mappar. Item { id: page property var images: [] function focusFirst() { list.focusFirst() } Component.onCompleted: images = prefs.findWallpapers() CardList { id: list anchors.fill: parent SliderCard { icon: "image" title: "Dämpning av bakgrunden" value: prefs.dim / 0.9 valueText: Math.round(prefs.dim * 100) + " %" onMoved: (v) => prefs.dim = v * 0.9 } SettingsCard { icon: "image" title: "Ingen bild" subtitle: "Mörk färgtoning" checked: prefs.wallpaper === "" onActivated: prefs.wallpaper = "" } SectionTitle { text: "Bilder" } SettingsCard { visible: page.images.length === 0 focusable: false icon: "image" title: "Inga bilder hittades" subtitle: "Lägg bilder (jpg/png) i ~/Bilder så dyker de upp här." } GridView { id: grid property bool focusable: page.images.length > 0 visible: page.images.length > 0 width: parent.width readonly property int columns: 4 cellWidth: Math.floor(width / columns) cellHeight: Math.round(cellWidth * 0.62) height: Math.ceil(page.images.length / columns) * cellHeight interactive: false // kolumnen runt omkring skrollar keyNavigationEnabled: true // annars stänger interactive:false av piltangenterna model: page.images keyNavigationWraps: false onCurrentIndexChanged: if (currentItem) list.ensureRange(y + currentItem.y, cellHeight) onActiveFocusChanged: if (activeFocus && currentItem) list.ensureRange(y + currentItem.y, cellHeight) delegate: Item { id: cell required property string modelData required property int index width: grid.cellWidth height: grid.cellHeight readonly property bool current: GridView.isCurrentItem && grid.activeFocus Keys.onReturnPressed: prefs.wallpaper = modelData Keys.onEnterPressed: prefs.wallpaper = modelData Rectangle { anchors.fill: parent anchors.margins: Theme.dp(8) radius: Theme.r(10) color: Theme.card border.width: cell.current ? Theme.dp(4) : 0 border.color: Theme.accent clip: true Image { anchors.fill: parent anchors.margins: cell.current ? Theme.dp(4) : 0 source: "file://" + cell.modelData sourceSize.width: 400 fillMode: Image.PreserveAspectCrop asynchronous: true } Rectangle { visible: prefs.wallpaper === cell.modelData anchors { right: parent.right; top: parent.top; margins: Theme.dp(10) } width: Theme.dp(44); height: width radius: width / 2 color: Theme.accent Icon { anchors.centerIn: parent; width: Theme.dp(28); height: width; name: "check" } } } MouseArea { anchors.fill: parent onClicked: { grid.currentIndex = cell.index grid.forceActiveFocus() prefs.wallpaper = cell.modelData } } } } } }