mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-06-11 00:47:22 +00:00
Keep Folio responsible for the visible convergence chrome, but let the panel containment keep its transparent ActionDrawerOpenSurface for the topbar hit target. This restores the old click and drag behavior while keeping the legacy statusbar visual hidden in convergence. Add a passive hover-only MouseArea to show the pointing-hand cursor without stealing input from the drawer swipe surface.
86 lines
2.8 KiB
QML
86 lines
2.8 KiB
QML
/*
|
|
* SPDX-FileCopyrightText: 2021-2024 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.intendedToBeVisible) {
|
|
// 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.intendedToBeVisible = true;
|
|
}
|
|
|
|
function startSwipeWithPoint(point) {
|
|
if (ShellSettings.Settings.convergenceModeEnabled) {
|
|
actionDrawer.openToPinnedMode = false;
|
|
} else if (point.x < root.width / 2) {
|
|
actionDrawer.openToPinnedMode = ShellSettings.Settings.actionDrawerTopLeftMode == ShellSettings.Settings.Pinned;
|
|
} else {
|
|
actionDrawer.openToPinnedMode = ShellSettings.Settings.actionDrawerTopRightMode == ShellSettings.Settings.Pinned;
|
|
}
|
|
|
|
startSwipe();
|
|
}
|
|
|
|
function endSwipe() {
|
|
actionDrawer.dragging = false;
|
|
actionDrawer.updateState();
|
|
}
|
|
|
|
function updateOffset(offsetY) {
|
|
actionDrawer.offset += offsetY;
|
|
}
|
|
|
|
anchors.fill: parent
|
|
|
|
MouseArea {
|
|
anchors.fill: parent
|
|
acceptedButtons: Qt.NoButton
|
|
hoverEnabled: true
|
|
cursorShape: ShellSettings.Settings.convergenceModeEnabled ? Qt.PointingHandCursor : Qt.ArrowCursor
|
|
}
|
|
|
|
onSwipeStarted: (point) => startSwipeWithPoint(point)
|
|
onSwipeEnded: endSwipe()
|
|
onSwipeMove: (totalDeltaX, totalDeltaY, deltaX, deltaY) => updateOffset(deltaY);
|
|
|
|
onTouchpadScrollStarted: (point) => startSwipeWithPoint(point)
|
|
onTouchpadScrollEnded: endSwipe()
|
|
onTouchpadScrollMove: (totalDeltaX, totalDeltaY, deltaX, deltaY) => updateOffset(deltaY);
|
|
|
|
// In convergence mode, allow click to toggle the action drawer (mouse-friendly)
|
|
onClicked: {
|
|
if (ShellSettings.Settings.convergenceModeEnabled) {
|
|
if (actionDrawer.intendedToBeVisible) {
|
|
actionDrawer.close();
|
|
} else {
|
|
actionDrawer.openToPinnedMode = false;
|
|
actionDrawer.intendedToBeVisible = true;
|
|
actionDrawer.open();
|
|
}
|
|
}
|
|
}
|
|
}
|