refactor: move anim loader -> new component

This commit is contained in:
2 * r + 2 * t 2026-06-07 00:02:10 +10:00
parent 3310cfafa3
commit b874dfc983
2 changed files with 42 additions and 35 deletions

40
components/AnimLoader.qml Normal file
View file

@ -0,0 +1,40 @@
import QtQuick
Loader {
id: root
property Component sourceComp
property bool isComplete
asynchronous: true
Component.onCompleted: {
isComplete = true;
sourceComponent = sourceComp;
}
onSourceCompChanged: {
if (isComplete)
anim.restart();
}
SequentialAnimation {
id: anim
running: false
Anim {
target: root
property: "opacity"
to: 0
type: Anim.FastEffects
}
ScriptAction {
script: root.sourceComponent = root.sourceComp
}
Anim {
target: root
property: "opacity"
to: 1
type: Anim.DefaultEffects
}
}
}

View file

@ -169,8 +169,6 @@ PageBase {
id: network
required property Nmcli.AccessPoint modelData
readonly property Component rightComp: Nmcli.connectingSsid() === modelData.ssid ? loadingComp : iconComp
property bool isComplete
property bool currentSelected
property real textOpacity: disabled ? 0.5 : 1
@ -190,12 +188,6 @@ PageBase {
}
}
Component.onCompleted: isComplete = true
onRightCompChanged: {
if (isComplete)
rightCompAnim.restart();
}
Behavior on textOpacity {
Anim {
type: Anim.DefaultEffects
@ -220,28 +212,6 @@ PageBase {
target: root
}
SequentialAnimation {
id: rightCompAnim
running: false
Anim {
target: rightLoader
property: "opacity"
to: 0
type: Anim.FastEffects
}
ScriptAction {
script: rightLoader.sourceComponent = network.rightComp
}
Anim {
target: rightLoader
property: "opacity"
to: 1
type: Anim.DefaultEffects
}
}
RowLayout {
id: networkLayout
@ -279,11 +249,8 @@ PageBase {
}
}
Loader {
id: rightLoader
asynchronous: true
sourceComponent: iconComp
AnimLoader {
sourceComp: Nmcli.connectingSsid() === network.modelData.ssid ? loadingComp : iconComp
Component {
id: iconComp