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

View file

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

View file

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