Add sample qml application
[staging/HomeScreen.git] / sample-qml / apps / HVAC_org / SeatHeatButton.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 Rectangle {
11     width: 239
12     height: 194
13     color: "#aa000000"
14     border.color: "#ff53b5ce"
15
16     property string side: "left"
17     property string propertyName: side + "SeatHeat"
18     property int seatHeat: HVACModel[propertyName]
19
20     Image {
21         source: "./images/" + side + "_heat_seat_off.png"
22     }
23
24     Image {
25         y: 150 - seatHeat*40
26         height: implicitHeight - y
27         fillMode: Image.Tile
28         verticalAlignment: Image.AlignBottom
29         source: "./images/" + side + "_heat_seat_on.png"
30     }
31
32     MouseArea {
33         anchors.fill: parent
34         onClicked: {
35             var value = HVACModel[propertyName]
36             HVACModel[propertyName] = value > 0 ? value - 1 : 3
37         }
38     }
39 }