refactor: move anim loader -> new component
This commit is contained in:
parent
3310cfafa3
commit
b874dfc983
2 changed files with 42 additions and 35 deletions
40
components/AnimLoader.qml
Normal file
40
components/AnimLoader.qml
Normal 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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -169,8 +169,6 @@ PageBase {
|
||||||
id: network
|
id: network
|
||||||
|
|
||||||
required property Nmcli.AccessPoint modelData
|
required property Nmcli.AccessPoint modelData
|
||||||
readonly property Component rightComp: Nmcli.connectingSsid() === modelData.ssid ? loadingComp : iconComp
|
|
||||||
property bool isComplete
|
|
||||||
property bool currentSelected
|
property bool currentSelected
|
||||||
property real textOpacity: disabled ? 0.5 : 1
|
property real textOpacity: disabled ? 0.5 : 1
|
||||||
|
|
||||||
|
|
@ -190,12 +188,6 @@ PageBase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: isComplete = true
|
|
||||||
onRightCompChanged: {
|
|
||||||
if (isComplete)
|
|
||||||
rightCompAnim.restart();
|
|
||||||
}
|
|
||||||
|
|
||||||
Behavior on textOpacity {
|
Behavior on textOpacity {
|
||||||
Anim {
|
Anim {
|
||||||
type: Anim.DefaultEffects
|
type: Anim.DefaultEffects
|
||||||
|
|
@ -220,28 +212,6 @@ PageBase {
|
||||||
target: root
|
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 {
|
RowLayout {
|
||||||
id: networkLayout
|
id: networkLayout
|
||||||
|
|
||||||
|
|
@ -279,11 +249,8 @@ PageBase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Loader {
|
AnimLoader {
|
||||||
id: rightLoader
|
sourceComp: Nmcli.connectingSsid() === network.modelData.ssid ? loadingComp : iconComp
|
||||||
|
|
||||||
asynchronous: true
|
|
||||||
sourceComponent: iconComp
|
|
||||||
|
|
||||||
Component {
|
Component {
|
||||||
id: iconComp
|
id: iconComp
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue