C
Qt Quick Ultralite Thermostat Demo
// Copyright (C) 2024 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial
import QtQuick 2.15
import Thermo 1.0
Item {
id: root
property int maxIndex: 48
signal roomSwitched()
onRoomSwitched: {
rightHandleAnimation.enabled = GlobalState.scheduleViewLoaded
leftHandleAnimation.enabled = GlobalState.scheduleViewLoaded
leftHandle.x = GlobalState.selectedRoom.leftHandleX
rightHandle.x = GlobalState.selectedRoom.rightHandleX
}
Image {
id: background
anchors.verticalCenter: parent.verticalCenter
source: "scrollbar-off-track.png"
}
Rectangle {
id: middleBackground
anchors.verticalCenter: parent.verticalCenter
anchors.left: leftHandle.horizontalCenter
anchors.right: rightHandle.horizontalCenter
height: background.height
color: ColorStyle.greyMedium3
}
TimeIntervalSliderHandle {
id: leftHandle
minX: 0
maxX: rightHandle.x - width
x: GlobalState.selectedRoom.leftHandleX
onXChanged: GlobalState.selectedRoom.leftHandleX = leftHandle.x
currentIndex: leftHandle.x/(root.width-rightHandle.width) * root.maxIndex
y: -height/2 + parent.height/2
Behavior on x {
id: leftHandleAnimation
enabled: GlobalState.scheduleViewLoaded
NumberAnimation {
onRunningChanged: {
if (!running) {
leftHandleAnimation.enabled = false
}
}
}
}
}
TimeIntervalSliderHandle {
id: rightHandle
minX: leftHandle.x + width
maxX: root.width - width
x: GlobalState.selectedRoom.rightHandleX
onXChanged: GlobalState.selectedRoom.rightHandleX = rightHandle.x
currentIndex: rightHandle.x/(root.width-rightHandle.width) * root.maxIndex
y: -height/2 + parent.height/2
Behavior on x {
id: rightHandleAnimation
enabled: GlobalState.scheduleViewLoaded
NumberAnimation {
onRunningChanged: {
if (!running) {
rightHandleAnimation.enabled = false
}
}
}
}
}
}