Add sample qml application
[staging/HomeScreen.git] / sample-qml / imports / vehicle / FuelModel.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
11 Item {
12     property bool metric: false
13
14     function galToL(value) {
15         return (metric ? 3.78541 : 1) * value
16     }
17
18     function mpgToLp100(value) {
19         return metric ? 235.214583571 / value : value
20     }
21
22     property real baseTank: 25
23     property real tankSize: galToL(baseTank)
24     property real level: tankSize * percentage * 0.01
25     property real percentage: 100
26     property real range: metric ? 100 * level / average : level * average
27     property real baseAverage: 20.7
28     property real average: mpgToLp100(baseAverage + mpgDiff)
29     property real mpgDiff: 0
30
31     NumberAnimation on percentage {
32         from: 100
33         to: 0
34         duration: 5000
35         loops: Animation.Infinite
36         easing.type: Easing.CosineCurve
37     }
38
39     NumberAnimation on mpgDiff {
40         from: -2
41         to: 2
42         duration: 11200
43         loops: Animation.Infinite
44         easing.type: Easing.CosineCurve
45     }
46 }