fix(main): replace the frozen splash screen with an animator

this runs on the GPU, therefore not prone to main thread being blocked

Fixes: #9524
This commit is contained in:
Lukáš Tinkl 2023-02-10 17:18:46 +01:00 committed by Lukáš Tinkl
parent 32dc26cba7
commit a93320f684
9 changed files with 36 additions and 38 deletions

View File

@ -8,30 +8,32 @@ Item {
signal animationFinished()
function show() {
splashLogo.playing = true
animator.start()
}
implicitWidth: splashLogo.implicitWidth
implicitHeight: splashLogo.implicitHeight
visible: (opacity > 0.0001)
// TODO: consider bringing POC attempt to use lottie animations
AnimatedImage {
Image {
id: splashLogo
anchors.centerIn: parent
scale: 0.5
source: Resources.gif("status_splash_" + Style.theme.name)
sourceSize.width: width || undefined
sourceSize.height: height || undefined
mipmap: true
antialiasing: true
source: Resources.svg("status-logo-circle")
width: 60
height: 60
fillMode: Image.Stretch
readonly property real frameToStartAnimation: frameCount/2
readonly property real animationRange: (frameCount - frameToStartAnimation)
onCurrentFrameChanged: {
if(currentFrame > frameToStartAnimation)
root.opacity = 1 - (currentFrame - frameToStartAnimation)/animationRange
if(currentFrame === (frameCount - 1))
root.animationFinished()
RotationAnimator {
id: animator
target: splashLogo
from: 0
to: 360
duration: 2000
loops: Animation.Infinite
onStopped: root.animationFinished()
}
playing: false
}
}

View File

@ -737,7 +737,7 @@ Item {
anchors.centerIn: parent
spacing: 6
StatusBaseText {
text: qsTr("Loading...")
text: qsTr("Loading chats...")
}
LoadingAnimation {}
}

View File

@ -1,24 +1,23 @@
import QtQuick 2.12
import QtQuick 2.15
import QtQuick.Layouts 1.15
import StatusQ.Core 0.1
import utils 1.0
// import Qt.labs.lottieqt 1.0
import shared 1.0
Item {
id: root
AnimatedImage {
width: 128
height: 128
ColumnLayout {
anchors.centerIn: parent
source: Style.gif("status_splash_" + Style.current.name)
LoadingAnimation {
Layout.alignment: Qt.AlignHCenter
Layout.preferredWidth: 128
Layout.preferredHeight: 128
source: Style.svg("status-logo-circle")
}
StatusBaseText {
Layout.alignment: Qt.AlignHCenter
text: qsTr("Loading Status...")
}
}
// NOTE: keep it if we will decide to switch on lottie
// LottieAnimation {
// anchors.centerIn: parent
// autoPlay: true
// loops: LottieAnimation.Infinite
// quality: LottieAnimation.HighQuality
// source: Style.lottie("status_splash")
// }
}

View File

@ -18,11 +18,9 @@ qt6_add_qml_module(${PROJECT_NAME}
STATIC
# TODO: temporary until we make qt_target_qml_sources work
RESOURCES
gif/status_splash_dark.gif
gif/status_splash_light.gif
icons/status-logo-icon.svg
icons/status-logo-dark.svg
icons/status-logo-circle.svg
png/traffic_lights/close.png
png/traffic_lights/close_pressed.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 121 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 118 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 802 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 786 KiB

File diff suppressed because one or more lines are too long