C
Qt Quick Ultralite multitask Example
// Copyright (C) 2024 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial import QtQuick 2.15 Rectangle { id: root Image { id: background source: "images/background-dark.png" anchors.fill: root } Column { anchors.horizontalCenter: parent.horizontalCenter anchors.top: parent.top anchors.topMargin: 10 Text { anchors.horizontalCenter: parent.horizontalCenter horizontalAlignment: Text.AlignHCenter color: "white" text: "Speed: " + HardwareControl.fanSpeed font.pixelSize: 34 } Text { topPadding: 10 anchors.horizontalCenter: parent.horizontalCenter horizontalAlignment: Text.AlignHCenter color: "silver" text: "LED cycle count:" font.pixelSize: 17 } Text { anchors.horizontalCenter: parent.horizontalCenter horizontalAlignment: Text.AlignHCenter color: "white" text: HardwareControl.ledCycleCount font.pixelSize: 17 font.bold: true } } Text { horizontalAlignment: Text.AlignHCenter anchors.horizontalCenter: parent.horizontalCenter anchors.bottom: parent.bottom anchors.bottomMargin: 10 color: "gray" text: "Tap to change fan and LED speed!" } Image { id: fan source: "images/fan-off.png" anchors.horizontalCenter: parent.horizontalCenter anchors.verticalCenter: parent.verticalCenter transform: Rotation { origin.x: fan.width / 2 origin.y: fan.height / 2 RotationAnimation on angle { id: imageRotation loops: Animation.Infinite from: 0 to: 360 duration: 0 running: false } } } MouseArea { id: ta anchors.fill: parent onPressed: { HardwareControl.updateSpeed((HardwareControl.fanSpeed + 1) % 6); } } HardwareControl.onFanRotationPeriodChanged: { imageRotation.duration = rotationPeriod imageRotation.running = rotationPeriod > 0 } Component.onCompleted: { HardwareControl.updateSpeed(HardwareControl.fanSpeed) } }