summaryrefslogtreecommitdiffstats
path: root/app/Dashboard.qml
diff options
context:
space:
mode:
Diffstat (limited to 'app/Dashboard.qml')
-rw-r--r--app/Dashboard.qml62
1 files changed, 48 insertions, 14 deletions
diff --git a/app/Dashboard.qml b/app/Dashboard.qml
index ad6aec4..1a797c6 100644
--- a/app/Dashboard.qml
+++ b/app/Dashboard.qml
@@ -34,21 +34,54 @@ ApplicationWindow {
property double vehicleSpeed: 0
property double engineSpeed: 0
+ property bool mphDisplay: false
+
+ Component.onCompleted : {
+ VehicleSignals.connect()
+ }
Connections {
- target: SignalComposer
+ target: VehicleSignals
+
+ onConnected: {
+ VehicleSignals.authorize()
+ }
+
+ onAuthorized: {
+ VehicleSignals.subscribe("Vehicle.Speed")
+ VehicleSignals.subscribe("Vehicle.Powertrain.CombustionEngine.Speed")
+ VehicleSignals.get("Vehicle.Cabin.Infotainment.HMI.DistanceUnit")
+ VehicleSignals.subscribe("Vehicle.Cabin.Infotainment.HMI.DistanceUnit")
+ }
- onSignalEvent: {
- if (uid === "event.vehicle.speed") {
- var speed_tmp = parseFloat(value)
- if(units == "km/h") {
- speed_tmp /= 1.609
+ 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
}
- vehicleSpeed = speed_tmp
}
- else if (uid === "event.engine.speed") {
+ }
+
+ 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.Speed") {
engineSpeed = parseFloat(value)
tachometer.value = engineSpeed / 7000
+ } else if (path === "Vehicle.Cabin.Infotainment.HMI.DistanceUnit") {
+ if (value === "km") {
+ mphDisplay = false
+ } else if (value === "mi") {
+ mphDisplay = true
+ }
}
}
}
@@ -58,28 +91,26 @@ ApplicationWindow {
anchors.centerIn: parent
width: Window.width
height: Window.height
- //scale: screenInfo.scale_factor()
- scale: 1
Label {
id: speed
anchors.left: parent.left
anchors.top: parent.top
anchors.margins: 20
- text: vehicleSpeed.toFixed(0) /* MPH */
+ text: vehicleSpeed.toFixed(0)
font.pixelSize: 256
}
Label {
id: unit
anchors.left: speed.right
anchors.baseline: speed.baseline
- text: 'MPH'
+ text: root.mphDisplay ? 'MPH' : "KPH"
font.pixelSize: 64
}
Label {
anchors.left: unit.left
anchors.top: unit.bottom
- text: '10,000.5 miles'
+ text: root.mphDisplay ? '10,000.5 miles' : "10,000.5 km"
font.pixelSize: 32
opacity: 0.5
}
@@ -261,13 +292,16 @@ ApplicationWindow {
code: 'zh_CN'
language: QT_TR_NOOP('中文简体')
}
+ ListElement {
+ code: 'ko_KR'
+ language: QT_TR_NOOP('한국어')
+ }
}
Button {
text: qsTr(model.language)
onClicked: {
translator.language = model.code
- console.log ("Scale = " + screenInfo.scale_factor())
}
}
}