startupnotifier: Import and integrate into homescreen for performance

This commit is contained in:
Devin Lin 2021-12-29 00:08:32 -05:00
parent 76b923f48d
commit 906c169f26
16 changed files with 229 additions and 14 deletions

View file

@ -85,7 +85,7 @@ AbstractAppDrawer {
} }
onLaunch: (x, y, icon, title, storageId) => { onLaunch: (x, y, icon, title, storageId) => {
if (icon !== "") { if (icon !== "") {
NanoShell.StartupFeedback.open( MobileShell.HomeScreenControls.openAppAnimation(
icon, icon,
title, title,
delegate.iconItem.Kirigami.ScenePosition.x + delegate.iconItem.width/2, delegate.iconItem.Kirigami.ScenePosition.x + delegate.iconItem.width/2,

View file

@ -15,6 +15,7 @@ import org.kde.kirigami 2.10 as Kirigami
import org.kde.plasma.private.containmentlayoutmanager 1.0 as ContainmentLayoutManager import org.kde.plasma.private.containmentlayoutmanager 1.0 as ContainmentLayoutManager
import org.kde.plasma.private.nanoshell 2.0 as NanoShell import org.kde.plasma.private.nanoshell 2.0 as NanoShell
import org.kde.plasma.private.mobileshell 1.0 as MobileShell
import org.kde.plasma.private.mobilehomescreencomponents 0.1 as HomeScreenComponents import org.kde.plasma.private.mobilehomescreencomponents 0.1 as HomeScreenComponents
@ -55,7 +56,7 @@ LauncherContainer {
} }
onLaunch: (x, y, icon, title) => { onLaunch: (x, y, icon, title) => {
if (icon !== "") { if (icon !== "") {
NanoShell.StartupFeedback.open( MobileShell.HomeScreenControls.openAppAnimation(
icon, icon,
title, title,
delegate.iconItem.Kirigami.ScenePosition.x + delegate.iconItem.width/2, delegate.iconItem.Kirigami.ScenePosition.x + delegate.iconItem.width/2,

View file

@ -101,7 +101,7 @@ Repeater {
onLaunch: (x, y, icon, title) => { onLaunch: (x, y, icon, title) => {
if (icon !== "") { if (icon !== "") {
print(delegate.iconItem) print(delegate.iconItem)
NanoShell.StartupFeedback.open( MobileShell.HomeScreenControls.openAppAnimation(
icon, icon,
title, title,
delegate.iconItem.Kirigami.ScenePosition.x + delegate.iconItem.width/2, delegate.iconItem.Kirigami.ScenePosition.x + delegate.iconItem.width/2,

View file

@ -81,7 +81,7 @@ AbstractAppDrawer {
} }
onLaunch: (x, y, icon, title, storageId) => { onLaunch: (x, y, icon, title, storageId) => {
if (icon !== "") { if (icon !== "") {
NanoShell.StartupFeedback.open( MobileShell.HomeScreenControls.openAppAnimation(
icon, icon,
title, title,
delegate.iconItem.Kirigami.ScenePosition.x + delegate.iconItem.width/2, delegate.iconItem.Kirigami.ScenePosition.x + delegate.iconItem.width/2,

View file

@ -10,6 +10,9 @@ import QtQuick.Window 2.2
pragma Singleton pragma Singleton
/**
* Provides access to the homescreen plasmoid containment within the shell.
*/
QtObject { QtObject {
id: delegate id: delegate
@ -18,6 +21,8 @@ QtObject {
signal snapHomeScreenPosition() signal snapHomeScreenPosition()
signal requestRelativeScroll(point pos) signal requestRelativeScroll(point pos)
signal openAppAnimation(string splashIcon, string title, real x, real y, real sourceIconSize)
property var taskSwitcher property var taskSwitcher
property QtObject homeScreenWindow property QtObject homeScreenWindow
property bool homeScreenVisible: true property bool homeScreenVisible: true

View file

@ -10,7 +10,7 @@ import org.kde.plasma.core 2.0 as PlasmaCore
pragma Singleton pragma Singleton
/** /**
* Properties exposed by the taskpanel containment. * Provides access to the taskpanel plasmoid containment within the shell.
*/ */
QtObject { QtObject {
id: root id: root

View file

@ -9,6 +9,9 @@ import org.kde.plasma.core 2.0 as PlasmaCore
pragma Singleton pragma Singleton
/**
* Provides access to the panel plasmoid containment within the shell.
*/
QtObject { QtObject {
id: root id: root

View file

@ -76,6 +76,10 @@ Item {
enabled: modelData.enabled enabled: modelData.enabled
settingsCommand: modelData.settingsCommand settingsCommand: modelData.settingsCommand
toggleFunction: modelData.toggle toggleFunction: modelData.toggle
onCloseRequested: {
actionDrawer.close();
}
} }
} }
} }
@ -122,6 +126,10 @@ Item {
enabled: modelData.enabled enabled: modelData.enabled
settingsCommand: modelData.settingsCommand settingsCommand: modelData.settingsCommand
toggleFunction: modelData.toggle toggleFunction: modelData.toggle
onCloseRequested: {
actionDrawer.close();
}
} }
} }
} }

View file

@ -28,6 +28,8 @@ Components.BaseItem {
required property string settingsCommand required property string settingsCommand
required property var toggleFunction required property var toggleFunction
signal closeRequested()
// set by children // set by children
property var iconItem property var iconItem
@ -44,7 +46,8 @@ Components.BaseItem {
} else if (root.toggleFunction) { } else if (root.toggleFunction) {
root.toggleFunction(); root.toggleFunction();
} else if (root.settingsCommand) { } else if (root.settingsCommand) {
NanoShell.StartupFeedback.open( closeRequested();
MobileShell.HomeScreenControls.openAppAnimation(
root.icon, root.icon,
root.text, root.text,
iconItem.Kirigami.ScenePosition.x + iconItem.width/2, iconItem.Kirigami.ScenePosition.x + iconItem.width/2,
@ -56,13 +59,13 @@ Components.BaseItem {
function delegatePressAndHold() { function delegatePressAndHold() {
if (root.settingsCommand) { if (root.settingsCommand) {
NanoShell.StartupFeedback.open( closeRequested();
MobileShell.HomeScreenControls.openAppAnimation(
root.icon, root.icon,
root.text, root.text,
iconItem.Kirigami.ScenePosition.x + iconItem.width/2, iconItem.Kirigami.ScenePosition.x + iconItem.width/2,
iconItem.Kirigami.ScenePosition.y + iconItem.height/2, iconItem.Kirigami.ScenePosition.y + iconItem.height/2,
Math.min(iconItem.width, iconItem.height)) Math.min(iconItem.width, iconItem.height))
closeRequested();
MobileShell.ShellUtil.executeCommand(root.settingsCommand); MobileShell.ShellUtil.executeCommand(root.settingsCommand);
} else if (root.toggleFunction) { } else if (root.toggleFunction) {
root.toggleFunction(); root.toggleFunction();

View file

@ -0,0 +1,183 @@
/*
* SPDX-FileCopyrightText: 2015 Marco Martin <notmart@gmail.com>
* SPDX-FileCopyrightText: 2021 Devin Lin <devin@kde.org>
*
* SPDX-License-Identifier: LGPL-2.0-or-later
*/
import QtQuick 2.12
import QtQuick.Layouts 1.1
import QtQuick.Window 2.2
import org.kde.plasma.core 2.0 as PlasmaCore
import QtGraphicalEffects 1.12
import org.kde.kirigami 2.13 as Kirigami
import org.kde.plasma.private.nanoshell 2.0 as NanoShell
import org.kde.plasma.private.mobileshell 1.0 as MobileShell
/**
* Component that animates an app opening from a location.
*/
Item {
id: root
visible: false
property alias backgroundColor: background.color
Kirigami.ImageColors {
id: colorGenerator
source: icon.source
}
function open(splashIcon, title, x, y, sourceIconSize, color) {
iconParent.scale = sourceIconSize/iconParent.width;
background.scale = 0;
backgroundParent.x = -root.width/2 + x
backgroundParent.y = -root.height/2 + y
icon.source = splashIcon;
if (color !== undefined) {
// Break binding to use custom color
background.color = color
} else {
// Recreate binding
background.color = Qt.binding(function() { return colorGenerator.dominant})
}
background.state = "open";
MobileShell.HomeScreenControls.taskSwitcher.minimizeAll();
}
// close when an app opens
property bool windowActive: Window.active
onWindowActiveChanged: {
background.state = "closed";
}
// close when homescreen requested
Connections {
target: MobileShell.HomeScreenControls
function onOpenHomeScreen() {
background.state = "closed";
}
}
Connections {
target: NanoShell.StartupNotifier
enabled: NanoShell.StartupNotifier.isValid
function onActivationStarted(appId, iconName) {
icon.source = iconName
background.state = "open";
}
}
property alias state: background.state
property alias icon: icon.source
onVisibleChanged: {
if (!visible) {
background.state = "closed";
}
}
Item {
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: [
Transition {
from: "closed"
SequentialAnimation {
ScriptAction {
script: {
root.visible = true;
}
}
ParallelAnimation {
ScaleAnimator {
target: background
from: background.scale
to: 1
duration: PlasmaCore.Units.longDuration
easing.type: Easing.InOutQuad
}
ScaleAnimator {
target: iconParent
from: iconParent.scale
to: 1
duration: PlasmaCore.Units.longDuration
easing.type: Easing.InOutQuad
}
XAnimator {
target: backgroundParent
from: backgroundParent.x
to: 0
duration: PlasmaCore.Units.longDuration
easing.type: Easing.OutCubic
}
YAnimator {
target: backgroundParent
from: backgroundParent.y
to: 0
duration: PlasmaCore.Units.longDuration
easing.type: Easing.OutCubic
}
}
}
}
]
}
}
}

View file

@ -152,7 +152,7 @@ QtObject {
property SinkModel paSinkModel: SinkModel {} property SinkModel paSinkModel: SinkModel {}
property VolumeOSD osd: VolumeOSD { property var osd: VolumeOSD {
volume: volumeValue volume: volumeValue
} }

View file

@ -17,6 +17,7 @@ import org.kde.plasma.extras 2.0 as PlasmaExtra
import org.kde.plasma.components 3.0 as PlasmaComponents import org.kde.plasma.components 3.0 as PlasmaComponents
import org.kde.plasma.extras 2.0 as PlasmaExtra import org.kde.plasma.extras 2.0 as PlasmaExtra
import org.kde.plasma.private.nanoshell 2.0 as NanoShell import org.kde.plasma.private.nanoshell 2.0 as NanoShell
import org.kde.plasma.private.mobileshell 1.0 as MobileShell
import org.kde.kirigami 2.12 as Kirigami import org.kde.kirigami 2.12 as Kirigami
@ -170,7 +171,7 @@ NanoShell.FullScreenOverlay {
onClicked: { onClicked: {
let coords = mapToItem(flickable, 0, 0); let coords = mapToItem(flickable, 0, 0);
NanoShell.StartupFeedback.open("audio-volume-high", i18n("Audio Settings"), coords.x, coords.y, PlasmaCore.Units.iconSizes.medium); MobileShell.HomeScreenControls.openAppAnimation("audio-volume-high", i18n("Audio Settings"), coords.x, coords.y, PlasmaCore.Units.iconSizes.medium);
plasmoid.nativeInterface.executeCommand("plasma-open-settings kcm_pulseaudio"); plasmoid.nativeInterface.executeCommand("plasma-open-settings kcm_pulseaudio");
} }
} }

View file

@ -12,6 +12,7 @@ ActionDrawerOpenSurface 1.0 actiondrawer/ActionDrawerOpenSurface.qml
# /components # /components
BaseItem 1.0 components/BaseItem.qml BaseItem 1.0 components/BaseItem.qml
Direction 1.0 components/Direction.qml Direction 1.0 components/Direction.qml
StartupFeedback 1.0 components/StartupFeedback.qml
# /dataproviders # /dataproviders
singleton BatteryProvider 1.0 dataproviders/BatteryProvider.qml singleton BatteryProvider 1.0 dataproviders/BatteryProvider.qml

View file

@ -66,6 +66,10 @@ FocusScope {
homescreen.appDrawer.offset -= pos.y; homescreen.appDrawer.offset -= pos.y;
lastRequestedPosition = pos.y; lastRequestedPosition = pos.y;
} }
function onOpenAppAnimation(splashIcon, title, x, y, sourceIconSize) {
startupFeedback.open(splashIcon, title, x, y, sourceIconSize);
}
} }
Plasmoid.onScreenChanged: { Plasmoid.onScreenChanged: {
@ -150,6 +154,8 @@ FocusScope {
// hide homescreen elements to make use of wallpaper // hide homescreen elements to make use of wallpaper
onVisibleChanged: { onVisibleChanged: {
if (visible) { if (visible) {
startupFeedback.visible = false;
// only animate if going from homescreen // only animate if going from homescreen
if (taskSwitcher.wasInActiveTask) { if (taskSwitcher.wasInActiveTask) {
opacityAnimation.to = 0; opacityAnimation.to = 0;
@ -164,5 +170,11 @@ FocusScope {
} }
} }
} }
// start app animation
MobileShell.StartupFeedback {
id: startupFeedback
anchors.fill: parent
}
} }

View file

@ -22,9 +22,7 @@ Item {
id: root id: root
readonly property bool showingApp: !MobileShell.HomeScreenControls.homeScreenVisible readonly property bool showingApp: !MobileShell.HomeScreenControls.homeScreenVisible
readonly property color backgroundColor: NanoShell.StartupFeedback.visible readonly property color backgroundColor: topPanel.colorScopeColor
? NanoShell.StartupFeedback.backgroundColor
: topPanel.colorScopeColor
Plasmoid.backgroundHints: showingApp ? PlasmaCore.Types.StandardBackground : PlasmaCore.Types.NoBackground Plasmoid.backgroundHints: showingApp ? PlasmaCore.Types.StandardBackground : PlasmaCore.Types.NoBackground

View file

@ -25,7 +25,7 @@ PlasmaCore.ColorScope {
Plasmoid.backgroundHints: PlasmaCore.Types.NoBackground Plasmoid.backgroundHints: PlasmaCore.Types.NoBackground
readonly property color backgroundColor: NanoShell.StartupFeedback.visible ? NanoShell.StartupFeedback.backgroundColor : PlasmaCore.ColorScope.backgroundColor readonly property color backgroundColor: PlasmaCore.ColorScope.backgroundColor
readonly property bool showingApp: !plasmoid.nativeInterface.allMinimized readonly property bool showingApp: !plasmoid.nativeInterface.allMinimized
readonly property bool hasTasks: tasksModel.count > 0 readonly property bool hasTasks: tasksModel.count > 0