C
Qt Quick Ultralite Automotive Cluster Demo
// Copyright (C) 2024 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial
import QtQuick 2.15
import Automotive 1.0
NormalModeContentItem {
Repeater {
id: repeater
readonly property list artists: ["Thomas Lammer", "Thievery Corporation", "Tycho", "De Phazz", "AK"]
readonly property list songs: ["Setsuna", "Le Monde", "Aweke", "Chocolate", "Discovery"]
readonly property list covers: ["images/albums/juno.png", "images/albums/thievery-corp.png", "images/albums/tycho.png", "images/albums/phazz.png", "images/albums/ak.png"]
model: repeater.artists.length
Item {
anchors.fill: parent
property int pos: -(-(10 + index - MediaPlayerModel.track%5 + 2) % 5) - 2
Text {
id: artistTxt
anchors.horizontalCenter: parent.horizontalCenter;
y: 77
text: repeater.artists[index];
font.bold: true
font.pixelSize: 16
font.family: "Sarabun"
color: Style.lightPeriwinkle
opacity: pos == 0 ? 1 : 0;
Behavior on opacity { NumberAnimation{ duration: MediaPlayerModel.changeSongDuration } }
}
Text {
id: songTxt
anchors.horizontalCenter: parent.horizontalCenter;
y: 96
text: repeater.songs[index];
font.pixelSize: 14
font.family: "Sarabun"
color: Style.lightPeriwinkle
opacity: artistTxt.opacity
}
Image {
id: img
x: (parent.width - width) / 2 + Math.max(Math.min(pos, 1), -1) * 49
Behavior on x {
NumberAnimation{
duration: MediaPlayerModel.changeSongDuration
easing.type: pos == 1 ? Easing.OutQuad : Easing.OutCubic
}
}
opacity: pos == 0 ? 1 : Math.abs(pos) == 1 ? 0.25 : 0
Behavior on opacity { NumberAnimation{ duration: MediaPlayerModel.changeSongDuration } }
y: 121
source: repeater.covers[index]
}
z: img.opacity > 0.90 ? 1 : -Math.abs(pos);
}
}
Row {
anchors.horizontalCenter: parent.horizontalCenter;
y: 262
id: durationLabel
visible: MainModel.introSequenceCompleted
Text {
text: Math.floor(MediaPlayerModel.timePassed / 60)
font.pixelSize: 14
font.family: "Sarabun"
color: Style.lightPeriwinkle
}
Text {
text: (MediaPlayerModel.timePassed % 60) < 10 ? ":0" : ":"
font.pixelSize: 14
font.family: "Sarabun"
color: Style.lightPeriwinkle
}
Text {
text: Math.floor(MediaPlayerModel.timePassed % 60)
font.pixelSize: 14
font.family: "Sarabun"
color: Style.lightPeriwinkle
}
}
SequentialAnimation {
running: !MediaPlayerModel.mediaPlayback && MainModel.introSequenceCompleted
loops: Animation.Infinite
alwaysRunToEnd: true
PropertyAnimation {
target: durationLabel
property: "opacity"
duration: 400
from: 1.0
to: 0.0
}
PauseAnimation {
duration: 100
}
PropertyAnimation {
target: durationLabel
property: "opacity"
duration: 400
from: 0.0
to: 1.0
}
}
}