mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-26 14:23:09 +00:00
taskswitcher/lockscreen: trim flick containers and optimise
This commit is contained in:
parent
a173cf9b9d
commit
131c3bd911
2 changed files with 9 additions and 50 deletions
|
|
@ -19,36 +19,15 @@ Flickable {
|
|||
required property var taskSwitcherState
|
||||
|
||||
// we use flickable solely for capturing flicks, not positioning elements
|
||||
contentWidth: width + 99999
|
||||
contentWidth: width * tasksCount
|
||||
contentHeight: height
|
||||
contentX: startContentX
|
||||
|
||||
readonly property real startContentX: contentWidth / 2
|
||||
|
||||
property bool positionChangedDueToFlickable: false
|
||||
|
||||
// ensure that flickable is not moving when other sources are changing position
|
||||
Connections {
|
||||
target: root.taskSwitcherState
|
||||
|
||||
onXPositionChanged: {
|
||||
if (!root.positionChangedDueToFlickable) {
|
||||
root.cancelMovement();
|
||||
}
|
||||
root.positionChangedDueToFlickable = true;
|
||||
}
|
||||
onYPositionChanged: {
|
||||
if (!root.positionChangedDueToFlickable) {
|
||||
root.cancelMovement();
|
||||
}
|
||||
root.positionChangedDueToFlickable = true;
|
||||
}
|
||||
}
|
||||
readonly property real startContentX: 0
|
||||
|
||||
// update position from horizontal flickable movement
|
||||
property real oldContentX
|
||||
onContentXChanged: {
|
||||
positionChangedDueToFlickable = true;
|
||||
taskSwitcherState.xPosition += contentX - oldContentX;
|
||||
oldContentX = contentX;
|
||||
}
|
||||
|
|
@ -58,6 +37,10 @@ Flickable {
|
|||
resetPosition();
|
||||
taskSwitcherState.updateState();
|
||||
}
|
||||
|
||||
onFlickStarted: {
|
||||
root.cancelFlick();
|
||||
}
|
||||
onFlickEnded: {
|
||||
resetPosition();
|
||||
taskSwitcherState.updateState();
|
||||
|
|
@ -65,7 +48,6 @@ Flickable {
|
|||
|
||||
onDraggingChanged: {
|
||||
if (!dragging) {
|
||||
cancelMovement();
|
||||
resetPosition();
|
||||
taskSwitcherState.updateState();
|
||||
} else {
|
||||
|
|
@ -73,15 +55,7 @@ Flickable {
|
|||
}
|
||||
}
|
||||
|
||||
function cancelMovement() {
|
||||
root.cancelFlick();
|
||||
|
||||
// HACK: cancelFlick() doesn't seem to cancel flicks...
|
||||
root.flick(-horizontalVelocity, 0);
|
||||
}
|
||||
|
||||
function resetPosition() {
|
||||
positionChangedDueToFlickable = true;
|
||||
oldContentX = startContentX;
|
||||
contentX = startContentX;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,13 +49,12 @@ Flickable {
|
|||
|
||||
// we use flickable solely for capturing flicks, not positioning elements
|
||||
contentWidth: width
|
||||
contentHeight: height + 99999
|
||||
contentHeight: height * 2
|
||||
contentX: 0
|
||||
contentY: startContentY
|
||||
|
||||
readonly property real startContentY: contentHeight / 2
|
||||
|
||||
property bool positionChangedDueToFlickable: false
|
||||
|
||||
property int oldPosition: position
|
||||
property bool movingUp: false
|
||||
|
|
@ -63,18 +62,11 @@ Flickable {
|
|||
onPositionChanged: {
|
||||
movingUp = oldPosition <= position;
|
||||
oldPosition = position;
|
||||
|
||||
// ensure that flickable is not moving when other sources are changing position
|
||||
if (!positionChangedDueToFlickable) {
|
||||
cancelMovement();
|
||||
}
|
||||
positionChangedDueToFlickable = true;
|
||||
}
|
||||
|
||||
// update position from flickable movement
|
||||
property real oldContentY
|
||||
onContentYChanged: {
|
||||
positionChangedDueToFlickable = true;
|
||||
position = Math.max(0, Math.min(keypadHeight, position + (contentY - oldContentY)));
|
||||
oldContentY = contentY;
|
||||
}
|
||||
|
|
@ -86,11 +78,12 @@ Flickable {
|
|||
}
|
||||
resetPosition();
|
||||
}
|
||||
|
||||
onFlickStarted: root.cancelFlick()
|
||||
onFlickEnded: resetPosition();
|
||||
|
||||
onDraggingChanged: {
|
||||
if (!dragging) {
|
||||
cancelMovement();
|
||||
resetPosition();
|
||||
if (!positionAnim.running) {
|
||||
root.updateState();
|
||||
|
|
@ -100,15 +93,7 @@ Flickable {
|
|||
}
|
||||
}
|
||||
|
||||
function cancelMovement() {
|
||||
root.cancelFlick();
|
||||
|
||||
// HACK: cancelFlick() doesn't seem to cancel flicks...
|
||||
root.flick(-horizontalVelocity, -verticalVelocity);
|
||||
}
|
||||
|
||||
function resetPosition() {
|
||||
positionChangedDueToFlickable = true;
|
||||
oldContentY = startContentY;
|
||||
contentY = startContentY;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue