Add sample qml application
[staging/HomeScreen.git] / sample-qml / apps / HVAC_org / FanControl.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 import QtQuick 2.0
8 import "models"
9
10 Item {
11     width: childrenRect.width
12     height: childrenRect.height
13
14     property real value: 0
15
16     Image {
17         y: 15
18         source: "images/fan_icon_off.png"
19     }
20
21     Image {
22         id: fanBar
23         x: 100
24         source: "images/fan_bar_off.png"
25     }
26
27     Image {
28         x: 100
29         width: value * fanBar.width
30         fillMode: Image.PreserveAspectCrop
31         horizontalAlignment: Image.AlignLeft
32         source: "images/fan_bar_on.png"
33
34         Image {
35             width: 20
36             height: width
37             anchors.verticalCenter: parent.bottom
38             anchors.verticalCenterOffset: -1
39             anchors.horizontalCenter: parent.right
40             source: "images/drag_knob.svg"
41         }
42     }
43
44     MouseArea {
45         x: 100
46         width: fanBar.width
47         height: parent.height
48
49         onPositionChanged: {
50             value = Math.min(Math.max(mouse.x / fanBar.width, 0), 1)
51             HVACModel.fanSpeed = value;
52         }
53     }
54 }