import QtQuick 2.5 import "../Shared" import "../Shared/Remote.js" as Remote import "../Shared/Format.js" as Format // Rangée horizontale de cartes avec un titre (accueil, saisons…). // `items` : éléments aplatis par Session._toItem(). FocusScope { id: row property string title: "" property var items: [] property bool landscape: false property var session: null property alias currentIndex: list.currentIndex signal activated(var item) readonly property int cardWidth: landscape ? Theme.thumbWidth : Theme.posterWidth readonly property int imageHeight: landscape ? Theme.thumbHeight : Theme.posterHeight height: titleText.height + Theme.spacingM + imageHeight + Theme.cardTextHeight + Theme.spacingM Text { id: titleText text: row.title color: row.activeFocus ? Theme.text : Theme.textMuted font.pixelSize: Theme.fontBody font.bold: true } ListView { id: list anchors { top: titleText.bottom topMargin: Theme.spacingM left: parent.left right: parent.right bottom: parent.bottom } orientation: ListView.Horizontal spacing: Theme.spacingM focus: true // Marge pour la carte agrandie (scale) au bord gauche. leftMargin: 8 rightMargin: 8 highlightMoveDuration: 150 model: row.items delegate: MediaCard { width: row.cardWidth imageHeight: row.imageHeight title: Format.cardTitle(modelData) subtitle: Format.cardSubtitle(modelData) imageSource: !row.session ? "" : row.landscape ? row.session.thumbUrl(modelData) : row.session.posterUrl(modelData) progress: Format.progress(modelData) played: modelData.played highlighted: ListView.isCurrentItem && list.activeFocus onClicked: { list.currentIndex = index; row.activated(modelData); } } Keys.onPressed: { if (Remote.isAccept(event.key) && currentIndex >= 0) { event.accepted = true; row.activated(row.items[currentIndex]); } } } }