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
Item {
id: root
property real scale: 1
property int arrowType: NaviModel.arrowType
visible: arrowType != NaviModel.ArrowNone
property bool _newArrowPending: false;
GuideArrow {
id: arrow
scale: root.scale
xOrigin: root.width / 2
yOrigin: root.height
}
property bool _arrowSwitchAnimationActive: false
ParallelAnimation {
running: true
loops: Animation.Infinite
NumberAnimation {
target: arrow
property: "arrowOffset"
from: -8
to: 0
duration: 2400
}
SequentialAnimation {
NumberAnimation {
easing.type: Easing.InQuad
duration: 150
target: arrow
property: "opacity"
from: _arrowSwitchAnimationActive ? 0 : 1
to: 1
}
ScriptAction {
script: _arrowSwitchAnimationActive = false;
}
PauseAnimation {
duration: 2100
}
ScriptAction {
script: {
if (_newArrowPending) {
_arrowSwitchAnimationActive = true;
_newArrowPending = false;
}
}
}
NumberAnimation {
easing.type: Easing.OutQuad
duration: 150
target: arrow
property: "opacity"
from: 1
to: _arrowSwitchAnimationActive ? 0 : 1
}
ScriptAction {
script: if (_arrowSwitchAnimationActive) arrow.source = NaviModel.getArrowSource();
}
}
}
Component.onCompleted: arrow.source = NaviModel.getArrowSource()
Connections {
target: NaviModel
function onArrowTypeChanged(arrow: int) {
_newArrowPending = true;
}
}
}