startupfeedback: Refactor so that fade in effect can be used for startupnotifier

This commit is contained in:
Devin Lin 2023-03-18 17:31:13 -07:00
parent 79e99a9cfe
commit 9560d784a8

View file

@ -23,6 +23,7 @@ MouseArea { // use mousearea to ensure clicks don't go behind
visible: false visible: false
property alias backgroundColor: background.color property alias backgroundColor: background.color
property alias icon: icon.source
function open(splashIcon, title, x, y, sourceIconSize, color) { function open(splashIcon, title, x, y, sourceIconSize, color) {
iconParent.scale = sourceIconSize/iconParent.width; iconParent.scale = sourceIconSize/iconParent.width;
@ -39,7 +40,11 @@ MouseArea { // use mousearea to ensure clicks don't go behind
background.color = Qt.binding(function() { return colorGenerator.dominant}) background.color = Qt.binding(function() { return colorGenerator.dominant})
} }
background.state = "open"; if (ShellSettings.Settings.animationsEnabled) {
openAnimComplex.restart();
} else {
openAnimSimple.restart();
}
} }
function close() { function close() {
@ -48,137 +53,36 @@ MouseArea { // use mousearea to ensure clicks don't go behind
// close when an app opens // close when an app opens
property bool windowActive: Window.active property bool windowActive: Window.active
onWindowActiveChanged: { onWindowActiveChanged: root.close();
background.state = "closed";
}
// close when homescreen requested // close when homescreen requested
Connections { Connections {
target: MobileShellState.HomeScreenControls target: MobileShellState.HomeScreenControls
function onOpenHomeScreen() { function onOpenHomeScreen() {
background.state = "closed"; root.close();
} }
} }
// TODO // open startupfeedback when notifier gives an app
// Connections { // Connections {
// target: NanoShell.StartupNotifier // target: NanoShell.StartupNotifier
// enabled: NanoShell.StartupNotifier.isValid // enabled: NanoShell.StartupNotifier.isValid
// //
// function onActivationStarted(appId, iconName) { // function onActivationStarted(appId, iconName) {
// icon.source = iconName // icon.source = iconName
// background.state = "open"; // openAnimSimple.restart();
// } // }
// } // }
property alias state: background.state
property alias icon: icon.source
onVisibleChanged: {
if (!visible) {
background.state = "closed";
}
}
Kirigami.ImageColors { Kirigami.ImageColors {
id: colorGenerator id: colorGenerator
source: icon.source source: icon.source
} }
Item { // animation that moves the icon
id: backgroundParent
width: root.width
height: root.height
Item {
id: iconParent
z: 2
anchors.centerIn: background
width: PlasmaCore.Units.iconSizes.enormous
height: width
PlasmaCore.IconItem {
id: icon
anchors.fill: parent
colorGroup: PlasmaCore.Theme.ComplementaryColorGroup
}
DropShadow {
anchors.fill: icon
horizontalOffset: 0
verticalOffset: 0
radius: 8.0
samples: 17
color: "#80000000"
source: icon
}
}
Rectangle {
id: background
anchors.fill: parent
color: colorGenerator.dominant
state: "closed"
states: [
State {
name: "closed"
PropertyChanges {
target: root
visible: false
}
},
State {
name: "open"
PropertyChanges {
target: root
visible: true
}
}
]
transitions: [
// no-animation mode transition
Transition {
from: "closed"
enabled: !ShellSettings.Settings.animationsEnabled
SequentialAnimation { SequentialAnimation {
ScriptAction { id: openAnimComplex
script: {
root.opacity = 0;
root.visible = true;
background.scale = 1;
iconParent.scale = 1;
backgroundParent.x = 0;
backgroundParent.y = 0;
}
}
NumberAnimation {
target: root
properties: "opacity"
from: 0
to: 1
duration: PlasmaCore.Units.longDuration
easing.type: Easing.OutCubic
}
ScriptAction {
script: {
// close the app drawer after it isn't visible
MobileShellState.HomeScreenControls.resetHomeScreenPosition();
}
}
}
},
// full animation transition
Transition {
from: "closed"
enabled: ShellSettings.Settings.animationsEnabled
SequentialAnimation {
ScriptAction { ScriptAction {
script: { script: {
root.opacity = 1; root.opacity = 1;
@ -187,6 +91,7 @@ MouseArea { // use mousearea to ensure clicks don't go behind
} }
// slight pause to give slower devices time to catch up when the item becomes visible // slight pause to give slower devices time to catch up when the item becomes visible
PauseAnimation { duration: 20 } PauseAnimation { duration: 20 }
ParallelAnimation { ParallelAnimation {
id: parallelAnim id: parallelAnim
property real animationDuration: PlasmaCore.Units.longDuration + PlasmaCore.Units.shortDuration property real animationDuration: PlasmaCore.Units.longDuration + PlasmaCore.Units.shortDuration
@ -228,8 +133,71 @@ MouseArea { // use mousearea to ensure clicks don't go behind
} }
} }
} }
// animation that just fades in
SequentialAnimation {
id: openAnimSimple
ScriptAction {
script: {
root.opacity = 0;
root.visible = true;
background.scale = 1;
iconParent.scale = 1;
backgroundParent.x = 0;
backgroundParent.y = 0;
}
}
NumberAnimation {
target: root
properties: "opacity"
from: 0
to: 1
duration: PlasmaCore.Units.longDuration
easing.type: Easing.OutCubic
}
ScriptAction {
script: {
// close the app drawer after it isn't visible
MobileShellState.HomeScreenControls.resetHomeScreenPosition();
}
}
}
Item {
id: backgroundParent
width: root.width
height: root.height
Rectangle {
id: background
anchors.fill: parent
color: colorGenerator.dominant
}
Item {
id: iconParent
anchors.centerIn: background
width: PlasmaCore.Units.iconSizes.enormous
height: width
PlasmaCore.IconItem {
id: icon
anchors.fill: parent
colorGroup: PlasmaCore.Theme.ComplementaryColorGroup
}
DropShadow {
anchors.fill: icon
horizontalOffset: 0
verticalOffset: 0
radius: 8.0
samples: 17
color: "#80000000"
source: icon
} }
]
} }
} }
} }