mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-29 15:03: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
|
required property var taskSwitcherState
|
||||||
|
|
||||||
// we use flickable solely for capturing flicks, not positioning elements
|
// we use flickable solely for capturing flicks, not positioning elements
|
||||||
contentWidth: width + 99999
|
contentWidth: width * tasksCount
|
||||||
contentHeight: height
|
contentHeight: height
|
||||||
contentX: startContentX
|
contentX: startContentX
|
||||||
|
|
||||||
readonly property real startContentX: contentWidth / 2
|
readonly property real startContentX: 0
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// update position from horizontal flickable movement
|
// update position from horizontal flickable movement
|
||||||
property real oldContentX
|
property real oldContentX
|
||||||
onContentXChanged: {
|
onContentXChanged: {
|
||||||
positionChangedDueToFlickable = true;
|
|
||||||
taskSwitcherState.xPosition += contentX - oldContentX;
|
taskSwitcherState.xPosition += contentX - oldContentX;
|
||||||
oldContentX = contentX;
|
oldContentX = contentX;
|
||||||
}
|
}
|
||||||
|
|
@ -58,6 +37,10 @@ Flickable {
|
||||||
resetPosition();
|
resetPosition();
|
||||||
taskSwitcherState.updateState();
|
taskSwitcherState.updateState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onFlickStarted: {
|
||||||
|
root.cancelFlick();
|
||||||
|
}
|
||||||
onFlickEnded: {
|
onFlickEnded: {
|
||||||
resetPosition();
|
resetPosition();
|
||||||
taskSwitcherState.updateState();
|
taskSwitcherState.updateState();
|
||||||
|
|
@ -65,7 +48,6 @@ Flickable {
|
||||||
|
|
||||||
onDraggingChanged: {
|
onDraggingChanged: {
|
||||||
if (!dragging) {
|
if (!dragging) {
|
||||||
cancelMovement();
|
|
||||||
resetPosition();
|
resetPosition();
|
||||||
taskSwitcherState.updateState();
|
taskSwitcherState.updateState();
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -73,15 +55,7 @@ Flickable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function cancelMovement() {
|
|
||||||
root.cancelFlick();
|
|
||||||
|
|
||||||
// HACK: cancelFlick() doesn't seem to cancel flicks...
|
|
||||||
root.flick(-horizontalVelocity, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
function resetPosition() {
|
function resetPosition() {
|
||||||
positionChangedDueToFlickable = true;
|
|
||||||
oldContentX = startContentX;
|
oldContentX = startContentX;
|
||||||
contentX = startContentX;
|
contentX = startContentX;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -49,13 +49,12 @@ Flickable {
|
||||||
|
|
||||||
// we use flickable solely for capturing flicks, not positioning elements
|
// we use flickable solely for capturing flicks, not positioning elements
|
||||||
contentWidth: width
|
contentWidth: width
|
||||||
contentHeight: height + 99999
|
contentHeight: height * 2
|
||||||
contentX: 0
|
contentX: 0
|
||||||
contentY: startContentY
|
contentY: startContentY
|
||||||
|
|
||||||
readonly property real startContentY: contentHeight / 2
|
readonly property real startContentY: contentHeight / 2
|
||||||
|
|
||||||
property bool positionChangedDueToFlickable: false
|
|
||||||
|
|
||||||
property int oldPosition: position
|
property int oldPosition: position
|
||||||
property bool movingUp: false
|
property bool movingUp: false
|
||||||
|
|
@ -63,18 +62,11 @@ Flickable {
|
||||||
onPositionChanged: {
|
onPositionChanged: {
|
||||||
movingUp = oldPosition <= position;
|
movingUp = oldPosition <= position;
|
||||||
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
|
// update position from flickable movement
|
||||||
property real oldContentY
|
property real oldContentY
|
||||||
onContentYChanged: {
|
onContentYChanged: {
|
||||||
positionChangedDueToFlickable = true;
|
|
||||||
position = Math.max(0, Math.min(keypadHeight, position + (contentY - oldContentY)));
|
position = Math.max(0, Math.min(keypadHeight, position + (contentY - oldContentY)));
|
||||||
oldContentY = contentY;
|
oldContentY = contentY;
|
||||||
}
|
}
|
||||||
|
|
@ -86,11 +78,12 @@ Flickable {
|
||||||
}
|
}
|
||||||
resetPosition();
|
resetPosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onFlickStarted: root.cancelFlick()
|
||||||
onFlickEnded: resetPosition();
|
onFlickEnded: resetPosition();
|
||||||
|
|
||||||
onDraggingChanged: {
|
onDraggingChanged: {
|
||||||
if (!dragging) {
|
if (!dragging) {
|
||||||
cancelMovement();
|
|
||||||
resetPosition();
|
resetPosition();
|
||||||
if (!positionAnim.running) {
|
if (!positionAnim.running) {
|
||||||
root.updateState();
|
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() {
|
function resetPosition() {
|
||||||
positionChangedDueToFlickable = true;
|
|
||||||
oldContentY = startContentY;
|
oldContentY = startContentY;
|
||||||
contentY = startContentY;
|
contentY = startContentY;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue