C
Qt Quick Ultralite Motorcycle Cluster Demo
/****************************************************************************** ** ** Copyright (C) 2020 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 Item { id: root property bool isDayMode: false property bool isDayModeOld: false readonly property image sourceDayMode: "qrc:///images/bg/main-light.png" readonly property image sourceNightMode: "qrc:///images/bg/main.png" property int fadingTime: 500 property real imagesOpacity: 1 Behavior on opacity { NumberAnimation { duration: fadingTime } } Image { id: imageLeft opacity: imagesOpacity source: sourceNightMode } Image { id: imageRight anchors.right: parent.right opacity: imagesOpacity source: sourceNightMode transform: Scale { xScale: -1 origin.x: imageLeft.width / 2 } } onIsDayModeChanged: { if (isDayModeOld !== isDayMode) { changeDayMode.start() isDayModeOld = isDayMode } } SequentialAnimation { id: changeDayMode PauseAnimation { duration: 600 } NumberAnimation { target: root property: "imagesOpacity" to: 0 duration: fadingTime /*easing.type: Easing.OutCubic*/ } ScriptAction { script: { imageLeft.source = isDayMode ? sourceDayMode : sourceNightMode imageRight.source = isDayMode ? sourceDayMode : sourceNightMode } } NumberAnimation { target: root property: "imagesOpacity" to: 1 duration: fadingTime /*easing.type: Easing.OutCubic*/ } } }