C
Qt Quick Ultralite Motorcycle Cluster Demo
// Copyright (C) 2024 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial
import QtQuick 2.0
import QtQuickUltralite.Extras 2.0
ItemWithAcivationAnimations {
id: root
width: 620
height: 152
welcomeAnimationDelay: 500
property bool isDayMode: false
property alias tripDistance: tripDistance.text
property color textColor: getFontColor()
Behavior on textColor { NumberAnimation { duration: welcomeAnimationDuration} }
function getFontColor() : color {
return isDayMode ? Style.black : Style.white
}
Text {
anchors.bottom: motorbikeStatus.top
anchors.bottomMargin: 10
anchors.left: motorbikeStatus.left
font.pixelSize: 18
font.family: "Barlow-mono";
color: textColor
text: "Motorbike status"
}
Column {
id: motorbikeStatus
anchors.bottom: root.bottom
ColorizedImage {
id: batteryImg
source: "qrc:///images/status/battery-status.png"
color: textColor
}
ColorizedImage {
id: oilImg
source: "qrc:///images/status/engine-oil-status.png"
color: textColor
}
ColorizedImage {
id: serviceImg
source: "qrc:///images/status/service-status.png"
color: textColor
}
}
Column {
id: motorbikeStatusTxts
anchors.left: motorbikeStatus.right
anchors.verticalCenter: motorbikeStatus.verticalCenter
width: 95
spacing: 18
Text {
anchors.right: motorbikeStatusTxts.right
font.pixelSize: 18
font.family: "Barlow-mono";
color: textColor
text: "12.5 V"
}
Text {
anchors.right: motorbikeStatusTxts.right
font.pixelSize: 18
font.family: "Barlow-mono";
color: textColor
text: "OK"
}
Text {
anchors.right: motorbikeStatusTxts.right
font.pixelSize: 18
font.family: "Barlow-mono";
color: textColor
text: "1258 km"
}
}
Text {
anchors.bottom: tripSummaryImgs.top
anchors.bottomMargin: 10
anchors.left: tripSummaryImgs.left
anchors.leftMargin: 25
font.pixelSize: 18
font.family: "Barlow-mono";
color: textColor
text: "Trip Summary"
}
Column {
id: tripSummaryImgs
anchors.right: tripSummaryTxts.left
anchors.bottom: root.bottom
ColorizedImage {
id: distanceImg
source: "qrc:///images/status/distance-status.png"
color: textColor
}
ColorizedImage {
id: fuelImg
source: "qrc:///images/status/fuel-avg-status.png"
color: textColor
}
ColorizedImage {
id: timeImg
source: "qrc:///images/status/time-status.png"
color: textColor
}
}
Column {
id: tripSummaryTxts
anchors.right: parent.right
anchors.verticalCenter: tripSummaryImgs.verticalCenter
width: 120
spacing: 18
Text {
id: tripDistance
anchors.right: tripSummaryTxts.right
font.pixelSize: 18
font.family: "Barlow-mono";
color: textColor
}
Text {
anchors.right: tripSummaryTxts.right
font.pixelSize: 18
font.family: "Barlow-mono";
color: textColor
text: "4.5 l/100 km"
}
Text {
anchors.right: tripSummaryTxts.right
font.pixelSize: 18
font.family: "Barlow-mono";
color: textColor
text: "2h 35 min"
}
}
onIsDayModeChanged: {
if(active) {
changeDayModeAnimation.start()
}
}
SequentialAnimation {
id: changeDayModeAnimation
PauseAnimation { duration: 900 }
ScriptAction { script: root.textColor = getFontColor() }
}
}