Add sample qml application
[staging/HomeScreen.git] / sample-qml / imports / vehicle / SpeedModel.qml
1 /* Copyright (C) 2015, Jaguar Land Rover. All Rights Reserved.
2  *
3  * This Source Code Form is subject to the terms of the Mozilla Public
4  * License, v. 2.0. If a copy of the MPL was not distributed with this
5  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7 pragma Singleton
8
9 import QtQuick 2.0
10 import amb 0.1
11
12 Item {
13     property bool metric: false
14
15     function mphToKph(value) {
16         return (metric ? 1.60934 : 1 ) * value
17     }
18
19     property real max:Math.ceil(mphToKph(baseMaxSpeed)/30)*30
20     property real baseMaxSpeed: 255
21     property real textSpeed: prop.value
22     property real percentage: textSpeed / max * 100
23
24     AutomotivePropertyItem {
25         id: prop
26
27         objectName: "VehicleSpeed"
28         propertyName: "Speed"
29
30         Component.onCompleted: prop.connect();
31     }
32
33     Behavior on percentage {
34         SmoothedAnimation {
35             velocity: 100
36         }
37     }
38 }