mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-08-04 02:34:45 +00:00
multi page horizontal scrolling
possibility of dragging icons and applets beyon the horizontal screen boundaries, creating multiple pages that can be horizontally flicked
This commit is contained in:
parent
cf48f79a81
commit
e4d297dd73
3 changed files with 99 additions and 8 deletions
|
|
@ -0,0 +1,48 @@
|
||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: 2021 Marco Martin <mart@kde.org>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: LGPL-2.0-or-later
|
||||||
|
*/
|
||||||
|
|
||||||
|
import QtQuick 2.14
|
||||||
|
|
||||||
|
import org.kde.plasma.core 2.0 as PlasmaCore
|
||||||
|
|
||||||
|
import ".." as Launcher
|
||||||
|
|
||||||
|
DragHandler {
|
||||||
|
yAxis.enabled: enabled
|
||||||
|
xAxis.enabled: enabled
|
||||||
|
property Flickable mainFlickable
|
||||||
|
property Launcher.AppDrawer appDrawer
|
||||||
|
enum ScrollDirection {
|
||||||
|
None,
|
||||||
|
Horizontal,
|
||||||
|
Vertical
|
||||||
|
}
|
||||||
|
property real __initialMainFlickableX
|
||||||
|
property int __scrollDirection: DragGestureHandler.None
|
||||||
|
onTranslationChanged: {print(translation.x)
|
||||||
|
if (active) {
|
||||||
|
if (appDrawer.offset > PlasmaCore.Units.gridUnit) {
|
||||||
|
__scrollDirection = DragGestureHandler.Vertical;
|
||||||
|
} else if (Math.abs(mainFlickable.contentX - __initialMainFlickableX) > PlasmaCore.Units.gridUnit) {
|
||||||
|
__scrollDirection = DragGestureHandler.Horizontal;
|
||||||
|
}
|
||||||
|
if (__scrollDirection !== DragGestureHandler.Horizontal) {
|
||||||
|
appDrawer.offset = -translation.y;
|
||||||
|
}
|
||||||
|
if (__scrollDirection !== DragGestureHandler.Vertical) {
|
||||||
|
mainFlickable.contentX = Math.max(0, __initialMainFlickableX - translation.x);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
onActiveChanged: {
|
||||||
|
if (active) {
|
||||||
|
__initialMainFlickableX = mainFlickable.contentX;
|
||||||
|
} else {
|
||||||
|
appDrawer.snapDrawerStatus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -15,6 +15,8 @@ import org.kde.plasma.components 3.0 as PlasmaComponents
|
||||||
import org.kde.draganddrop 2.0 as DragDrop
|
import org.kde.draganddrop 2.0 as DragDrop
|
||||||
|
|
||||||
import "launcher" as Launcher
|
import "launcher" as Launcher
|
||||||
|
//TODO: everything using this will eventually move in Launcher
|
||||||
|
import "launcher/private" as LauncherPrivate
|
||||||
|
|
||||||
import org.kde.plasma.private.containmentlayoutmanager 1.0 as ContainmentLayoutManager
|
import org.kde.plasma.private.containmentlayoutmanager 1.0 as ContainmentLayoutManager
|
||||||
|
|
||||||
|
|
@ -163,7 +165,8 @@ Item {
|
||||||
//bottomMargin: favoriteStrip.height
|
//bottomMargin: favoriteStrip.height
|
||||||
contentWidth: appletsLayout.width
|
contentWidth: appletsLayout.width
|
||||||
contentHeight: height
|
contentHeight: height
|
||||||
interactive: !plasmoid.editMode && !launcherDragManager.active
|
//interactive: !plasmoid.editMode && !launcherDragManager.active
|
||||||
|
interactive: false
|
||||||
|
|
||||||
signal cancelEditModeForItemsRequested
|
signal cancelEditModeForItemsRequested
|
||||||
onDragStarted: cancelEditModeForItemsRequested()
|
onDragStarted: cancelEditModeForItemsRequested()
|
||||||
|
|
@ -173,22 +176,48 @@ Item {
|
||||||
|
|
||||||
onContentYChanged: MobileShell.HomeScreenControls.homeScreenPosition = contentY
|
onContentYChanged: MobileShell.HomeScreenControls.homeScreenPosition = contentY
|
||||||
|
|
||||||
|
LauncherPrivate.DragGestureHandler {
|
||||||
|
appDrawer: appDrawer
|
||||||
|
mainFlickable: mainFlickable
|
||||||
|
enabled: root.focus && appDrawer.status !== Launcher.AppDrawer.Status.Open && !appletsLayout.editMode && !plasmoid.editMode && !launcherDragManager.active
|
||||||
|
}
|
||||||
|
/*
|
||||||
DragHandler {
|
DragHandler {
|
||||||
target: mainFlickable
|
target: mainFlickable
|
||||||
yAxis.enabled: !appletsLayout.editMode
|
yAxis.enabled: !appletsLayout.editMode && !plasmoid.editMode && !launcherDragManager.active
|
||||||
|
xAxis.enabled: yAxis.enabled
|
||||||
enabled: root.focus && appDrawer.status !== Launcher.AppDrawer.Status.Open
|
enabled: root.focus && appDrawer.status !== Launcher.AppDrawer.Status.Open
|
||||||
onTranslationChanged: {
|
property real initialMainFlickableX
|
||||||
|
enum ScrollDirection {
|
||||||
|
None,
|
||||||
|
Horizontal,
|
||||||
|
Vertical
|
||||||
|
}
|
||||||
|
property int scrollDirection: None
|
||||||
|
onTranslationChanged: {print(translation.x)
|
||||||
if (active) {
|
if (active) {
|
||||||
appDrawer.offset = -translation.y
|
if (appDrawer.offset > PlasmaCore.Units.gridUnit) {
|
||||||
|
scrollDirection = Vertical;
|
||||||
|
} else if (Math.abs(mainFlickable.contentX - initialMainFlickableX) > PlasmaCore.Units.gridUnit) {
|
||||||
|
scrollDirection = Horizontal;
|
||||||
|
}
|
||||||
|
if (scrollDirection !== Horizontal) {
|
||||||
|
appDrawer.offset = -translation.y;
|
||||||
|
}
|
||||||
|
if (scrollDirection !== Vertical) {
|
||||||
|
mainFlickable.contentX = Math.max(0, initialMainFlickableX - translation.x);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onActiveChanged: {
|
onActiveChanged: {
|
||||||
if (!active) {
|
if (active) {
|
||||||
|
initialMainFlickableX = mainFlickable.contentX;
|
||||||
|
} else {
|
||||||
appDrawer.snapDrawerStatus();
|
appDrawer.snapDrawerStatus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
NumberAnimation {
|
NumberAnimation {
|
||||||
id: scrollAnim
|
id: scrollAnim
|
||||||
target: mainFlickable
|
target: mainFlickable
|
||||||
|
|
@ -201,7 +230,7 @@ Item {
|
||||||
// TODO: span on multiple pages
|
// TODO: span on multiple pages
|
||||||
DragDrop.DropArea {
|
DragDrop.DropArea {
|
||||||
id: dropArea
|
id: dropArea
|
||||||
width: mainFlickable.width
|
width: Math.max(mainFlickable.width, mainFlickable.width * Math.ceil(appletsLayout.childrenRect.width/mainFlickable.width))
|
||||||
height: mainFlickable.height + favoriteStrip.height
|
height: mainFlickable.height + favoriteStrip.height
|
||||||
|
|
||||||
onDragEnter: {
|
onDragEnter: {
|
||||||
|
|
@ -297,7 +326,7 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
signal appletsLayoutInteracted
|
signal appletsLayoutInteracted
|
||||||
|
onChildrenRectChanged: print("AAAAAA"+childrenRect.width)
|
||||||
TapHandler {
|
TapHandler {
|
||||||
target: mainFlickable
|
target: mainFlickable
|
||||||
enabled: appDrawer.status !== Launcher.AppDrawer.Status.Open
|
enabled: appDrawer.status !== Launcher.AppDrawer.Status.Open
|
||||||
|
|
@ -362,6 +391,19 @@ Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
PlasmaComponents.PageIndicator {
|
||||||
|
anchors {
|
||||||
|
bottom: parent.bottom
|
||||||
|
horizontalCenter: parent.horizontalCenter
|
||||||
|
bottomMargin: PlasmaCore.Units.gridUnit * 2
|
||||||
|
}
|
||||||
|
PlasmaCore.ColorScope.inherit: false
|
||||||
|
PlasmaCore.ColorScope.colorGroup: PlasmaCore.Theme.ComplementaryColorGroup
|
||||||
|
parent: mainFlickable
|
||||||
|
count: Math.ceil(dropArea.width / mainFlickable.width)
|
||||||
|
visible: count > 1
|
||||||
|
currentIndex: Math.round(mainFlickable.contentX / mainFlickable.width)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Launcher.AppDrawer {
|
Launcher.AppDrawer {
|
||||||
|
|
|
||||||
|
|
@ -232,6 +232,7 @@ Item {
|
||||||
z: 4
|
z: 4
|
||||||
Layout.alignment: Qt.AlignTop
|
Layout.alignment: Qt.AlignTop
|
||||||
Layout.preferredWidth: slidingPanel.wideScreen ? Math.min(slidingPanel.width/2, units.gridUnit * 25) : panelContents.width
|
Layout.preferredWidth: slidingPanel.wideScreen ? Math.min(slidingPanel.width/2, units.gridUnit * 25) : panelContents.width
|
||||||
|
|
||||||
parentSlidingPanel: slidingPanel
|
parentSlidingPanel: slidingPanel
|
||||||
onCloseRequested: slidingPanel.hide()
|
onCloseRequested: slidingPanel.hide()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue