shift-shell/kwin/mobiletaskswitcher/qml/FlickContainer.qml
Micah Stanley fdc8958ce5 taskswitcher: Gesture Navigation: Quality of Life Improvements
Most Notable Changes Here Include:
1. If the user moves and lifts their finger up halfway up the screen, the navigation gesture will now go home.
2. The task drawer will now move in and out of view depending on the gesture navigation state.
3. The app window will now continue to shrink with resistance as the window moves further up.
4. When in the task drawer, if the user drags up from the bottom, the current task will now follow the users finger like the task does when dragging up from within an app.
5. The task drawer will now slide in from the side when it is not within an app.

I would upload a video here to showcase these changes. However, I was unable to get OBS to record my screen while in my plasma mobile session.
2024-10-15 00:55:29 +00:00

72 lines
2.5 KiB
QML

// SPDX-FileCopyrightText: 2021-2023 Devin Lin <devin@kde.org>
// SPDX-License-Identifier: LGPL-2.0-or-later
import QtQuick
Flickable {
// TODO flickable is busted, it refuses to actually do any flicks with touch input, only works with mouse
// we work around this somewhat by snapping to the nearest task in which direction it was moving when letting go
// no matter how far away we are (and no matter how fast we go)
id: root
required property var taskSwitcherState
required property var taskSwitcherHelpers
// we use flickable solely for capturing flicks, not positioning elements
// the horizontal distance we can swipe in one flick
contentWidth: (taskSwitcherHelpers.taskWidth + taskSwitcherHelpers.taskSpacing) * tasksCount
contentHeight: height
contentX: startContentX
readonly property real startContentX: (taskSwitcherHelpers.taskWidth + taskSwitcherHelpers.taskSpacing) * tasksCount
property bool movingRight: false // TODO needed for flickable not flicking workaround
// update position from horizontal flickable movement
property real oldContentX
onContentXChanged: {
// disable if animations are running to prevent bugs
if (taskSwitcherHelpers.currentlyBeingClosed) {return}
if (moving) {
// TODO whenever flicking actually works this should probably be swapped with
// a minimum velocity after which it should snap to the nearest task
taskSwitcherState.xPosition += contentX - oldContentX;
}
movingRight = contentX < oldContentX;
oldContentX = contentX;
}
onMovementStarted: {
if (taskSwitcherHelpers.currentlyBeingClosed) {return}
taskSwitcherHelpers.cancelAnimations();
}
onMovementEnded: {
if (taskSwitcherHelpers.currentlyBeingClosed) {return}
taskSwitcherHelpers.snapToNearestTaskWorkaround(movingRight);
resetPosition();
}
onFlickStarted: {
if (taskSwitcherHelpers.currentlyBeingClosed) {return}
root.cancelFlick();
}
onFlickEnded: {
// taskSwitcherHelpers.snapToNearestTaskWorkaround(movingRight);
// resetPosition();
}
onDraggingChanged: {
if (taskSwitcherHelpers.currentlyBeingClosed) {return}
if (dragging) {
taskSwitcherHelpers.cancelAnimations();
} else {
resetPosition();
}
}
function resetPosition() {
oldContentX = startContentX;
contentX = startContentX;
}
}