shift-shell/components/mobileshell/qml/actiondrawer/ActionDrawerOpenSurface.qml
Devin Lin acde5b389d lockscreen: Dynamically load status bar and action drawer as needed for performance
Currently the lockscreen takes 5 seconds to load for me on the OnePlus 6. This MR moves the quicksettings and status bar to only load once the initial lockscreen has loaded (to avoid blocking it). This brings it down the initial load to 1 second for me.
2024-06-29 20:29:06 +00:00

59 lines
1.8 KiB
QML

/*
* SPDX-FileCopyrightText: 2021-2022 Devin Lin <devin@kde.org>
*
* SPDX-License-Identifier: LGPL-2.0-or-later
*/
import QtQuick 2.15
import org.kde.plasma.private.mobileshell.shellsettingsplugin as ShellSettings
import org.kde.plasma.private.mobileshell as MobileShell
/**
* Component that triggers the opening and closing of an ActionDrawer when dragged on with touch or mouse.
*/
MobileShell.SwipeArea {
id: root
mode: MobileShell.SwipeArea.VerticalOnly
required property ActionDrawer actionDrawer
function startSwipe() {
if (actionDrawer.visible) {
// ensure the action drawer state is consistent
actionDrawer.closeImmediately();
}
actionDrawer.cancelAnimations();
actionDrawer.dragging = true;
actionDrawer.opened = false;
// must be after properties other are set, we cannot have actionDrawer.updateState() be called
actionDrawer.offset = 0;
actionDrawer.oldOffset = 0;
actionDrawer.visible = true;
}
function endSwipe() {
actionDrawer.dragging = false;
actionDrawer.updateState();
}
function updateOffset(offsetY) {
actionDrawer.offset += offsetY;
}
anchors.fill: parent
onSwipeStarted: (point) => {
// if the user swiped from the top left, otherwise it's from the top right
if (point.x < root.width / 2) {
actionDrawer.openToPinnedMode = ShellSettings.Settings.actionDrawerTopLeftMode == ShellSettings.Settings.Pinned;
} else {
actionDrawer.openToPinnedMode = ShellSettings.Settings.actionDrawerTopRightMode == ShellSettings.Settings.Pinned;
}
startSwipe();
}
onSwipeEnded: endSwipe()
onSwipeMove: (totalDeltaX, totalDeltaY, deltaX, deltaY) => updateOffset(deltaY);
}