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 ListModel warningsModel: ListModel { ListElement { warningImg: "qrc:///images/warnings/engine-failure-warning.png" text: "Engine Malfunction\n Stop Now!" } ListElement { warningImg: "qrc:///images/warnings/engine-oil-warning.png" text: " Low Oil Pressure\nService immediately" } ListElement { warningImg: "qrc:///images/warnings/battery-warning.png" text: " 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: warningsModel.get(root.warningId).warningImg anchors.centerIn: parent color: Style.red } } Text { id: warningText anchors.centerIn: parent anchors.horizontalCenterOffset: 51 text: warningsModel.get(root.warningId).text font.pixelSize: 36 font.family: "Barlow-mono" color: Style.white } } }