9a592024ce87b92f455490890c6437b3116cb587
[staging/HomeScreen.git] / sample-qml / apps / HVAC / ClimateButton.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     id: root
12
13     width: imageItem.width
14     height: imageItem.height
15     color: "#aa000000"
16
17     property string target: ""
18     property string image: ""
19     property bool value: HVACModel[target]
20
21     Image {
22         id: imageItem
23         source: "images/" + image + "_" + (value ? "on" : "off") + ".png"
24     }
25
26     MouseArea {
27         anchors.fill: parent
28         onClicked: {
29             HVACModel[target] = !HVACModel[target]
30             hsa.consoleout()
31             hsa.refresh()
32         }
33     } 
34 }