shift-shell/kwin/mobiletaskswitcher/qml/FlickContainer.qml

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

58 lines
1.4 KiB
QML
Raw Normal View History

2023-03-06 06:38:43 +00:00
// SPDX-FileCopyrightText: 2021-2023 Devin Lin <devin@kde.org>
// SPDX-License-Identifier: LGPL-2.0-or-later
import QtQuick 2.15
import QtQuick.Layouts 1.15
import org.kde.taskmanager 0.1 as TaskManager
import org.kde.plasma.core 2.1 as PlasmaCore
import org.kde.plasma.components 3.0 as PlasmaComponents
Flickable {
id: root
2023-03-06 06:38:43 +00:00
required property var taskSwitcherState
2023-03-06 06:38:43 +00:00
// we use flickable solely for capturing flicks, not positioning elements
contentWidth: width * tasksCount
contentHeight: height
contentX: startContentX
2023-03-06 06:38:43 +00:00
readonly property real startContentX: 0
2023-03-06 06:38:43 +00:00
// update position from horizontal flickable movement
property real oldContentX
onContentXChanged: {
taskSwitcherState.xPosition += contentX - oldContentX;
oldContentX = contentX;
}
2023-03-06 06:38:43 +00:00
onMovementStarted: taskSwitcherState.cancelAnimations();
onMovementEnded: {
resetPosition();
taskSwitcherState.updateState();
}
2023-03-06 06:38:43 +00:00
onFlickStarted: {
root.cancelFlick();
}
onFlickEnded: {
resetPosition();
taskSwitcherState.updateState();
}
2023-03-06 06:38:43 +00:00
onDraggingChanged: {
if (!dragging) {
resetPosition();
taskSwitcherState.updateState();
} else {
taskSwitcherState.cancelAnimations();
}
}
2023-03-06 06:38:43 +00:00
function resetPosition() {
oldContentX = startContentX;
contentX = startContentX;
}
}