better management of dragging to new pages

This commit is contained in:
Marco Martin 2021-03-24 18:01:58 +01:00
parent 70805d04eb
commit dff5809c59
3 changed files with 13 additions and 6 deletions

View file

@ -14,6 +14,7 @@ import org.kde.plasma.components 3.0 as PC3
import org.kde.kirigami 2.10 as Kirigami
import org.kde.plasma.private.nanoshell 2.0 as NanoShell
import org.kde.plasma.private.mobileshell 1.0 as MobileShell
import org.kde.phone.homescreen 1.0
@ -194,6 +195,7 @@ Item {
}
oldContentY = contentY;
root.offset = contentY + view.originY + view.height*2
MobileShell.HomeScreenControls.homeScreenPosition = contentY
}
onMovementEnded: root.snapDrawerStatus()
onFlickEnded: movementEnded()

View file

@ -27,6 +27,9 @@ Flickable {
property AppDrawer appDrawer
readonly property int totalPages: Math.ceil(contentWidth / width)
property int currentIndex: 0
opacity: 1 - appDrawer.openFactor
transform: Translate {
y: -mainFlickable.height/10 * appDrawer.openFactor
@ -34,7 +37,6 @@ Flickable {
scale: (3 - appDrawer.openFactor) /3
//bottomMargin: favoriteStrip.height
contentWidth: appletsLayout.width
contentHeight: height
//interactive: !plasmoid.editMode && !launcherDragManager.active
interactive: false
@ -45,10 +47,11 @@ Flickable {
onFlickStarted: cancelEditModeForItemsRequested()
onFlickEnded: cancelEditModeForItemsRequested()
onContentYChanged: MobileShell.HomeScreenControls.homeScreenPosition = contentY
onCurrentIndexChanged: contentX = width * currentIndex;
onContentXChanged: mainFlickable.currentIndex = Math.floor(contentX / width)
//Autoscroll related functions
//Autoscroll related functions
function scrollLeft() {
if (mainFlickable.atXBeginning) {
return;
@ -124,7 +127,7 @@ Flickable {
PlasmaCore.ColorScope.inherit: false
PlasmaCore.ColorScope.colorGroup: PlasmaCore.Theme.ComplementaryColorGroup
parent: mainFlickable
count: Math.ceil(dropArea.width / mainFlickable.width)
count: mainFlickable.totalPages
visible: count > 1
currentIndex: Math.round(mainFlickable.contentX / mainFlickable.width)
}

View file

@ -114,12 +114,14 @@ FocusScope {
}
appDrawer: appDrawer
contentWidth: Math.max(width, width * Math.ceil(appletsLayout.childrenRect.width/width)) + (launcherDragManager.active ? width : 0)
// TODO: span on multiple pages
DragDrop.DropArea {
id: dropArea
width: Math.max(mainFlickable.width, mainFlickable.width * Math.ceil(appletsLayout.childrenRect.width/mainFlickable.width))
height: mainFlickable.height + favoriteStrip.height
width: mainFlickable.width * 100
//width: Math.max(mainFlickable.width, mainFlickable.width * Math.ceil(appletsLayout.childrenRect.width/mainFlickable.width))
height: mainFlickable.height + favoriteStrip.height + units.gridUnit
onDragEnter: {
event.accept(event.proposedAction);