C
Qt Quick Ultralite Automotive Cluster Demo
// Copyright (C) 2024 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial pragma Singleton import QtQuick 2.15 QtObject { id: navimodel enum ArrowType { ArrowNone, ArrowForward, ArrowRight, ArrowSharpRight, ArrowRound } property int distanceToNextManoeuver property int filteredDistanceToNextManoeuver onDistanceToNextManoeuverChanged: { filteredDistanceToNextManoeuver = Math.max(Units.metersToShortDistanceUnit(distanceToNextManoeuver), 1) if (distanceToNextManoeuver <= 50) { filteredDistanceToNextManoeuver = Math.ceil(filteredDistanceToNextManoeuver/10) * 10 } else { filteredDistanceToNextManoeuver = Math.ceil(filteredDistanceToNextManoeuver/50) * 50 } } property int arrowType: NaviModel.ArrowNone property string instruction: "" property string street: "" property int _lastStreetIndex: -1 function getArrowSource() : image { switch (arrowType) { case NaviModel.ArrowRight: return "images/arrow-45.png"; case NaviModel.ArrowSharpRight: return "images/arrow-90.png"; case NaviModel.ArrowRound: return "images/arrow-round.png"; default: return "images/arrow-0.png"; } } function updateInstruction() { switch (arrowType) { case NaviModel.ArrowRight: instruction = "Turn right onto"; break; case NaviModel.ArrowSharpRight: instruction = "Turn sharp right onto"; break; case NaviModel.ArrowRound: instruction = "At the roundabout,\n go straight ahead"; break; default: instruction = "Continue straight"; break; } } signal triggerInstruction(NaviModel.ArrowType nextArrowIndex) onTriggerInstruction: { arrowType = nextArrowIndex street = Region.streetNames[Math.random() * Region.namesCount] updateInstruction() } }