C

Qt Quick Ultralite Motorcycle Cluster Demo

/****************************************************************************** ** ** Copyright (C) 2024 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.0 import QtQuickUltralite.Extras 2.0 Item { id: root clip: true width: 555 height: 162 property bool showWarning: false property bool isWarningVisible: warning.topMarginForAnimation === 0 readonly property int warningTimeout: 3000 property int warningId: 0 readonly property list warningsImages: [ "qrc:///images/warnings/engine-failure-warning.png", "qrc:///images/warnings/engine-oil-warning.png", "qrc:///images/warnings/battery-warning.png" ] readonly property list warningsTexts: [ "Engine Malfunction\n Stop Now!", " Low Oil Pressure\nService immediately", " Low Battery Charge\nDon't drive long distance" ] onShowWarningChanged: { if (showWarning) { hideWarningAnimation.stop() warningsAniamtion.stop() warningsAniamtion.start() } } onWarningIdChanged: { hideWarningAnimation.stop() warningsAniamtion.stop() if (showWarning) { warningsAniamtion.start() } else { hideWarningAnimation.start() } } SequentialAnimation { id: warningsAniamtion NumberAnimation { target: warning property: "topMarginForAnimation" to: 0 duration: 330 easing.type: Easing.OutCubic } PauseAnimation { duration: warningTimeout } NumberAnimation { target: warning property: "topMarginForAnimation" to: -height duration: 330 easing.type: Easing.InCubic } } NumberAnimation { id: hideWarningAnimation target: warning property: "topMarginForAnimation" to: -height duration: 330 easing.type: Easing.InCubic } Rectangle { id: warning width: 555 height: 162 anchors.top: root.top property int topMarginForAnimation: -height anchors.topMargin: topMarginForAnimation radius: 6 color: Style.red Rectangle { id: iconRectangle width: 120 height: 147 radius: 6 color: Style.white anchors.top: parent.top anchors.topMargin: 8 anchors.left: parent.left anchors.leftMargin: 6 ColorizedImage { id: warningIcon source: root.warningsImages[root.warningId] anchors.centerIn: parent color: Style.red } } Text { id: warningText anchors.centerIn: parent anchors.horizontalCenterOffset: 51 text: root.warningsTexts[root.warningId] font.pixelSize: 36 font.family: "Barlow-mono" color: Style.white } } }