blob: 471d160fac0a1a566755bdba02bd06437314de84 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
import QtQuick 2.0
import QtQuick.Controls 2.2
import QtQuick.Window 2.11
import "qrc:/qml"
ApplicationWindow {
id: tbtnavi
title: "Turn By Turn Navigation Demo"
height: Window.height
width: Window.width
flags: Qt.FramelessWindowHint
visible: true
property double vehicleSpeed: 0
property double engineSpeed: 0
property bool mphDisplay: false
Component.onCompleted : {
VehicleSignals.connect()
}
Connections {
target: VehicleSignals
onConnected: {
VehicleSignals.authorize()
}
onAuthorized: {
VehicleSignals.subscribe("Vehicle.Speed")
VehicleSignals.subscribe("Vehicle.Powertrain.CombustionEngine.Engine.Speed")
VehicleSignals.subscribe("Vehicle.Cabin.Infotainment.Cluster.Mode")
VehicleSignals.get("Vehicle.Cabin.Infotainment.HMI.DistanceUnit")
VehicleSignals.subscribe("Vehicle.Cabin.Infotainment.HMI.DistanceUnit")
}
onGetSuccessResponse: {
//console.log("response path = " + path + ", value = " + value)
if (path === "Vehicle.Cabin.Infotainment.HMI.DistanceUnit") {
if (value === "km") {
mphDisplay = false
} else if (value === "mi") {
mphDisplay = true
}
}
}
onSignalNotification: {
//console.log("signal path = " + path + ", value = " + value)
if (path === "Vehicle.Speed") {
// value units are always km/h
if (mphDisplay)
vehicleSpeed = parseFloat(value) * 0.621504
else
vehicleSpeed = parseFloat(value)
} else if (path === "Vehicle.Powertrain.CombustionEngine.Engine.Speed") {
engineSpeed = parseFloat(value)
} else if (path === "Vehicle.Cabin.Infotainment.Cluster.Mode" && value === "true") {
console.log ("Switching views!")
console.log ("currentIndex = " + container.currentIndex)
if (container.currentIndex === 0) {
console.log ("Switching to info")
container.currentIndex = 1
} else if (container.currentIndex === 1) {
console.log ("Switching to map")
container.currentIndex = 0
}
} else if (path === "Vehicle.Cabin.Infotainment.HMI.DistanceUnit") {
if (value === "km") {
mphDisplay = false
} else if (value === "mi") {
mphDisplay = true
}
}
}
}
Item {
id: container
anchors.centerIn: parent
width: parent.width
height: parent.height
property int currentIndex: 0
MapWindow {
visible: parent.currentIndex === 0
opacity: parent.currentIndex === 0 ? 1.0 : 0.0
anchors.fill: parent
objectName: "mapwindow"
}
InfoWindow {
visible: parent.currentIndex === 1
opacity: parent.currentIndex === 1 ? 1.0 : 0.0
anchors.fill: parent
}
}
}
|