C
Qt Quick Ultralite Thermostat Demo
// Copyright (C) 2024 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial import QtQuick 2.15 import QtQuick.Templates 2.15 import Thermo 1.0 Button { id: root width: Theme.roomButtonSize height: Theme.roomButtonSize checkable: false property Room currentRoom signal fanLevelChanged icon.source: enabled ? currentRoom.fanImage() : currentRoom.fanOffImage() contentItem: Item { Image { source: root.pressed ? "btn-bg-down.png" : (root.enabled && root.checked) ? "btn-bg-big-on.png" : "btn-bg-big-off.png"; anchors.horizontalCenter: parent.horizontalCenter y: root.pressed ? 0 : -6 // Because of the 6 pixel shadow in the on and off image } Image { source: root.icon.source anchors.centerIn: parent } } onClicked: { if (!enabled) return if (currentRoom.fan === Room.FanOff) { currentRoom.fan = Room.FanQuarter } else if (currentRoom.fan === Room.FanQuarter) { currentRoom.fan = Room.FanHalf } else if (currentRoom.fan === Room.FanHalf) { currentRoom.fan = Room.FanThreeQuarters } else if (currentRoom.fan === Room.FanThreeQuarters) { currentRoom.fan = Room.FanFull } else if (currentRoom.fan === Room.FanFull) { currentRoom.fan = Room.FanOff } } }