C

Qt Quick Ultralite Thermostat Demo

/****************************************************************************** ** ** 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 QtQuickUltralite.Extras 2.0 import Thermo 1.0 Item { id: root width: Theme.sliderHandleSize height: Theme.sliderHandleSize Image { anchors.centerIn: parent anchors.verticalCenterOffset: 6 // account for shadow source: "slider-handle.png" } property alias mouseX: ta.mouseX property int minX: -1 property int maxX: -1 property int currentIndex: -1 property string hour: Math.floor(currentIndex/2) property string minute: currentIndex%2 == 1 ? "30" : "00" Row { id: time anchors.bottom: parent.top anchors.bottomMargin: 4 Text { text: root.hour color: "#3d464d" font.pixelSize: Theme.sliderHandleLabelFontSize } StaticText { text: ":" color: "#3d464d" font.pixelSize: Theme.sliderHandleLabelFontSize horizontalAlignment: Text.AlignLeft } Text { id: txt text: root.minute color: "#3d464d" font.pixelSize: Theme.sliderHandleLabelFontSize } } MouseArea { id: ta anchors.fill: parent anchors.margins: -10 property real pressedX: 0 property real pressedY: 0 onPressed: { pressedX = mouse.x pressedY = mouse.y } onMouseXChanged: { var newX = root.x - (ta.pressedX - ta.mouseX) root.x = Math.max(root.minX, Math.min(root.maxX, newX)) } } }