2021-12-22 23:29:00 +00:00
|
|
|
/*
|
2024-10-31 05:05:44 +00:00
|
|
|
* SPDX-FileCopyrightText: 2021-2024 Devin Lin <devin@kde.org>
|
2021-12-22 23:29:00 +00:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: LGPL-2.0-or-later
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import QtQuick 2.15
|
|
|
|
|
|
2023-03-18 19:28:17 +00:00
|
|
|
import org.kde.plasma.private.mobileshell.shellsettingsplugin as ShellSettings
|
2023-09-30 05:57:24 +00:00
|
|
|
import org.kde.plasma.private.mobileshell as MobileShell
|
2022-05-31 03:37:00 +00:00
|
|
|
|
2021-12-22 23:29:00 +00:00
|
|
|
/**
|
|
|
|
|
* Component that triggers the opening and closing of an ActionDrawer when dragged on with touch or mouse.
|
|
|
|
|
*/
|
2023-09-30 05:57:24 +00:00
|
|
|
MobileShell.SwipeArea {
|
2021-12-22 23:29:00 +00:00
|
|
|
id: root
|
2023-09-30 17:06:41 +00:00
|
|
|
mode: MobileShell.SwipeArea.VerticalOnly
|
2024-06-28 15:04:32 +00:00
|
|
|
|
2021-12-22 23:29:00 +00:00
|
|
|
required property ActionDrawer actionDrawer
|
|
|
|
|
|
|
|
|
|
function startSwipe() {
|
2024-10-31 05:05:44 +00:00
|
|
|
if (actionDrawer.intendedToBeVisible) {
|
2021-12-28 00:03:00 +00:00
|
|
|
// ensure the action drawer state is consistent
|
|
|
|
|
actionDrawer.closeImmediately();
|
|
|
|
|
}
|
2021-12-22 23:29:00 +00:00
|
|
|
actionDrawer.cancelAnimations();
|
|
|
|
|
actionDrawer.dragging = true;
|
|
|
|
|
actionDrawer.opened = false;
|
2024-06-28 15:04:32 +00:00
|
|
|
|
2021-12-22 23:29:00 +00:00
|
|
|
// must be after properties other are set, we cannot have actionDrawer.updateState() be called
|
|
|
|
|
actionDrawer.offset = 0;
|
|
|
|
|
actionDrawer.oldOffset = 0;
|
2024-10-31 05:05:44 +00:00
|
|
|
actionDrawer.intendedToBeVisible = true;
|
2021-12-22 23:29:00 +00:00
|
|
|
}
|
2024-06-28 15:04:32 +00:00
|
|
|
|
2024-07-16 02:32:01 +00:00
|
|
|
function startSwipeWithPoint(point) {
|
2026-04-15 12:58:15 +00:00
|
|
|
if (ShellSettings.Settings.convergenceModeEnabled) {
|
|
|
|
|
actionDrawer.openToPinnedMode = false;
|
|
|
|
|
} else if (point.x < root.width / 2) {
|
2024-07-16 02:32:01 +00:00
|
|
|
actionDrawer.openToPinnedMode = ShellSettings.Settings.actionDrawerTopLeftMode == ShellSettings.Settings.Pinned;
|
|
|
|
|
} else {
|
|
|
|
|
actionDrawer.openToPinnedMode = ShellSettings.Settings.actionDrawerTopRightMode == ShellSettings.Settings.Pinned;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
startSwipe();
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-22 23:29:00 +00:00
|
|
|
function endSwipe() {
|
|
|
|
|
actionDrawer.dragging = false;
|
|
|
|
|
actionDrawer.updateState();
|
|
|
|
|
}
|
2024-06-28 15:04:32 +00:00
|
|
|
|
2021-12-22 23:29:00 +00:00
|
|
|
function updateOffset(offsetY) {
|
|
|
|
|
actionDrawer.offset += offsetY;
|
|
|
|
|
}
|
2024-06-28 15:04:32 +00:00
|
|
|
|
2021-12-22 23:29:00 +00:00
|
|
|
anchors.fill: parent
|
2023-09-30 05:57:24 +00:00
|
|
|
|
2024-07-16 02:32:01 +00:00
|
|
|
onSwipeStarted: (point) => startSwipeWithPoint(point)
|
2023-09-30 05:57:24 +00:00
|
|
|
onSwipeEnded: endSwipe()
|
|
|
|
|
onSwipeMove: (totalDeltaX, totalDeltaY, deltaX, deltaY) => updateOffset(deltaY);
|
2024-07-16 02:32:01 +00:00
|
|
|
|
|
|
|
|
onTouchpadScrollStarted: (point) => startSwipeWithPoint(point)
|
|
|
|
|
onTouchpadScrollEnded: endSwipe()
|
|
|
|
|
onTouchpadScrollMove: (totalDeltaX, totalDeltaY, deltaX, deltaY) => updateOffset(deltaY);
|
2026-04-08 17:07:12 +00:00
|
|
|
|
|
|
|
|
// In convergence mode, allow click to toggle the action drawer (mouse-friendly)
|
|
|
|
|
onClicked: {
|
|
|
|
|
if (ShellSettings.Settings.convergenceModeEnabled) {
|
|
|
|
|
if (actionDrawer.intendedToBeVisible) {
|
|
|
|
|
actionDrawer.close();
|
|
|
|
|
} else {
|
2026-04-15 12:58:15 +00:00
|
|
|
actionDrawer.openToPinnedMode = false;
|
|
|
|
|
actionDrawer.intendedToBeVisible = true;
|
2026-04-08 17:07:12 +00:00
|
|
|
actionDrawer.open();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-12-22 23:29:00 +00:00
|
|
|
}
|