C 语言
Qt Quick Ultralite 温控器演示
/****************************************************************************** ** ** Copyright (C) 2023 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the Qt Quick Ultralite module. ** ** $QT_BEGIN_LICENSE:COMM$ ** ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms ** and conditions see http://www.qt.io/terms-conditions. For further ** information use the contact form at http://www.qt.io/contact-us. ** ** $QT_END_LICENSE$ ** ******************************************************************************/import QtQuick 2.15 import QtQuick.Templates 2.15 import QtQuickUltralite.Extras 2.0 import Thermo 1.0 Item { id: root Connections { target: GlobalState function onSelectedRoomChanged(selectedRoom: Room) { tempSliderAnimations.enabled = GlobalState.scheduleViewLoaded; timeSlider.roomSwitched(); tempSlider.value = GlobalState.selectedRoom.temperature; } } Column { id: columnItem anchors.fill: parent spacing: Theme.sliderSpacing y: Theme.roomScheduleTopMargin Column { anchors.horizontalCenter: parent.horizontalCenter spacing: Theme.sliderLabelSpacing width: Theme.sliderWidth StaticText { anchors.left: parent.left anchors.right: parent.right color: "#3c94eb" font.pixelSize: Theme.sliderLabelFontSize //% "Set interval time" text: qsTrId("id-setintervaltime") } TimeIntervalSlider { id: timeSlider height: sliderContainer.height width: Theme.sliderWidth } } Column { anchors.horizontalCenter: parent.horizontalCenter spacing: Theme.sliderLabelSpacing width: Theme.sliderWidth StaticText { id: tempText anchors.left: parent.left anchors.right: parent.right color: "#3c94eb" font.pixelSize: Theme.sliderLabelFontSize //% "Set temperature" text: qsTrId("id-settemperature") } Item { id: sliderContainer height: tempSlider.handle.height + tempSlider.topPadding + tempSlider.bottomPadding Slider { id: tempSlider anchors.verticalCenter: parent.verticalCenter from: Units.fahrenheitToTemperatureUnit(50) height: sliderContainer.height + 20 // to improve touchability implicitWidth: Theme.sliderWidth stepSize: 1 to: Units.fahrenheitToTemperatureUnit(90) value: GlobalState.selectedRoom.temperature background: Image { anchors.verticalCenter: parent.verticalCenter source: "scrollbar-temperature-track.png" } handle: Item { height: Theme.sliderHandleSize width: Theme.sliderHandleSize x: tempSlider.leftPadding + tempSlider.visualPosition * (tempSlider.availableWidth - width) y: (tempSlider.height - height) / 2 Behavior on x { id: tempSliderAnimations enabled: GlobalState.scheduleViewLoaded NumberAnimation { onRunningChanged: { if (!running) { tempSliderAnimations.enabled = false; } } } } Image { anchors.centerIn: parent anchors.verticalCenterOffset: 6 // account for shadow source: "slider-handle.png" } Row { anchors.bottom: parent.top anchors.bottomMargin: 4 anchors.horizontalCenter: parent.horizontalCenter spacing: 2 Text { color: "#3d464d" font.pixelSize: Theme.sliderHandleLabelFontSize text: tempSlider.value.toString() } StaticText { color: "#3d464d" font.pixelSize: Theme.sliderHandleLabelFontSize text: Units.temperatureSymbol } } } onMoved: GlobalState.selectedRoom.temperature = value } } } } }