C
Qt Quick Ultralite Motorcycle Cluster Demo
// Copyright (C) 2024 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial
import QtQuick
import QtQuickUltralite.Extras 2.0
ColorizedImage {
id: root
property bool active: false
property color activeColor: Style.telltallesRed
property color inactiveColor: root.isDayMode ? Style.telltallesInactiveDayMode : Style.gray
readonly property real activeOpacity: 1
readonly property real inactiveOpacity: 0.1
property bool isVisible: false
property bool isDayMode: false
color: active ? activeColor : inactiveColor
opacity: active ? activeOpacity : inactiveOpacity
states: [
State {
name: "hidden"
when: !isVisible
PropertyChanges {
target: root
color: inactiveColor
}
PropertyChanges {
target: root
opacity: 0
}
},
State {
name: "inactive"
when: !active
PropertyChanges {
target: root
color: inactiveColor
}
PropertyChanges {
target: root
opacity: inactiveOpacity
}
},
State {
name: "active"
when: !active
PropertyChanges {
target: root
color: inactiveColor
}
PropertyChanges {
target: root
opacity: activeOpacity
}
}
]
Behavior on color {
ColorAnimation {
duration: 300
easing.type: Easing.InOutQuad
}
}
Behavior on opacity {
NumberAnimation {
easing.type: Easing.InOutQuad
duration: 300
}
}
}