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: mainmodel
enum ClusterMode { ModeNormal, ModeSport, ModeEco }
property int clusterMode: MainModel.ModeNormal
property bool introSequenceStarted: false
property bool introSequenceCompleted: false
property bool forceInteractiveMode: false
property int speedLimitWarning: SpeedLimitValues.Slow
property real initialOdo: 300
property real odo: initialOdo
property int travelTime: 0
readonly property int fullRange: 895
readonly property int initialRange: fullRange - odo
property int range: initialRange
property real speed: 0
property real rpm: 0
property int gear: 0
property string gearShiftText: "P"
property real temp: 0
property bool showSimulatedDriveData: true
readonly property real initialFuelLevel: range / fullRange
readonly property real initialBatteryLevel: 0.2
property real fuelLevel: initialFuelLevel
property real batteryLevel: initialBatteryLevel
readonly property int maxSpeed: Units.longDistanceUnitToKilometers(Units.maximumSpeed)
readonly property int maxRpm: 7000
property bool telltalesVisible: true
property bool clusterVisible: true
property real clusterOpacity: 0
property real gaugesOpacity: 0
readonly property int clusterOpacityChangeDuration: 750
readonly property int gaugesOpacityChangeDuration: 750;
readonly property int gaugesValueChangeDurationNormal: 500
readonly property int gaugesValueChangeDurationSlow: 1250
property int gaugesValueChangeDuration: gaugesValueChangeDurationNormal
property bool laneAssistCarMoving: false
property bool laneAssistEnabled: true
signal triggerLaneAssist(int side)
signal triggerGuideArrow(int index)
onClusterModeChanged : {
if (MainModel.introSequenceCompleted) {
if (clusterMode == MainModel.ModeNormal) {
ConnectivityService.clusterMode = ConnectivityService.NormalMode
}
else {
ConnectivityService.clusterMode = ConnectivityService.SportMode
ConnectivityService.currentMenu = ConnectivityService.None
}
SettingsMenuModel.notifyConnectivityService()
}
}
onIntroSequenceStartedChanged: {
if (introSequenceStarted) {
ConnectivityService.clusterMode = ConnectivityService.IntroMode;
}
}
onIntroSequenceCompletedChanged: {
if (introSequenceCompleted) {
ConnectivityService.clusterMode = ConnectivityService.NormalMode;
ConnectivityService.currentMenu = ConnectivityService.Media;
}
}
}