Files
dotfiles/quickshell/MobileNavigation.qml
T
2026-11-17 18:15:16 +07:00

50 lines
1.7 KiB
QML

pragma ComponentBehavior: Bound
import QtQuick
import QtQuick.Layouts
import Quickshell
import Quickshell.Wayland
import "services"
import "components"
PanelWindow {
id: navigation
signal navigate(string name)
signal cycleApplication(int direction)
required property var output
screen: output
visible: Preferences.modeFor(output) !== "desktop"
anchors { left: true; right: true; bottom: true }
implicitHeight: 38
color: Theme.background
WlrLayershell.namespace: "adaptive-navigation"
Rectangle {
id: pill
anchors.centerIn: parent
width: 108; height: 5; radius: 3
color: Theme.foreground
}
MouseArea {
anchors.fill: parent
property real startY: 0
property real startX: 0
property double startAt: 0
onPressed: mouse => { startX = mouse.x; startY = mouse.y; startAt = Date.now(); }
onReleased: mouse => {
const dy = startY - mouse.y;
const dx = mouse.x - startX;
// Only gestures that reach this panel are captured. Global edge
// interception requires explicit compositor support.
const elapsed = Date.now() - startAt;
// A horizontal swipe on the navigation handle cycles open windows.
if (Math.abs(dx) > 55 && Math.abs(dx) > Math.abs(dy) * 1.3)
navigation.cycleApplication(dx < 0 ? 1 : -1);
else if (dy > 14 && elapsed >= 450)
navigation.navigate("recent");
else if (dy > 14)
navigation.navigate("home");
else if (Math.abs(dx) < 12 && Math.abs(dy) < 12)
navigation.navigate("home");
}
}
}