mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-08-02 01:34:46 +00:00
homescreen: Fix non-existent property calls and remove unused file
This commit is contained in:
parent
058de1555e
commit
68b7d3897e
3 changed files with 17 additions and 125 deletions
|
|
@ -200,6 +200,7 @@ DragDrop.DropArea {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
appletContainerComponent: MobileAppletContainer {
|
appletContainerComponent: MobileAppletContainer {
|
||||||
|
homeScreenState: dropArea.homeScreenState
|
||||||
launcherDragManager: dropArea.launcherDragManager
|
launcherDragManager: dropArea.launcherDragManager
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,11 @@ import "private" as Private
|
||||||
|
|
||||||
ContainmentLayoutManager.BasicAppletContainer {
|
ContainmentLayoutManager.BasicAppletContainer {
|
||||||
id: appletContainer
|
id: appletContainer
|
||||||
|
|
||||||
|
property var homeScreenState
|
||||||
|
property real screenWidth: homeScreenState.availableScreenWidth
|
||||||
|
property real screenHeight: homeScreenState.availableScreenHeight
|
||||||
|
|
||||||
configOverlayComponent: Private.ConfigOverlay {}
|
configOverlayComponent: Private.ConfigOverlay {}
|
||||||
|
|
||||||
property LauncherDragManager launcherDragManager
|
property LauncherDragManager launcherDragManager
|
||||||
|
|
@ -62,19 +67,19 @@ ContainmentLayoutManager.BasicAppletContainer {
|
||||||
if (pos.x < PlasmaCore.Units.gridUnit) {
|
if (pos.x < PlasmaCore.Units.gridUnit) {
|
||||||
launcherRepeater.scrollLeftRequested();
|
launcherRepeater.scrollLeftRequested();
|
||||||
//SCROLL RIGHT
|
//SCROLL RIGHT
|
||||||
} else if (pos.x > mainFlickable.width - PlasmaCore.Units.gridUnit) {
|
} else if (pos.x > screenWidth - PlasmaCore.Units.gridUnit) {
|
||||||
launcherRepeater.scrollRightRequested();
|
launcherRepeater.scrollRightRequested();
|
||||||
//DON't SCROLL
|
//DON't SCROLL
|
||||||
} else {
|
} else {
|
||||||
launcherRepeater.stopScrollRequested();
|
launcherRepeater.stopScrollRequested();
|
||||||
}
|
}
|
||||||
|
|
||||||
appletContainer.x = Math.max(0, Math.min(mainFlickable.width - appletContainer.width, appletContainer.x));
|
appletContainer.x = Math.max(0, Math.min(screenWidth - appletContainer.width, appletContainer.x));
|
||||||
}
|
}
|
||||||
onWidthChanged: {
|
onWidthChanged: {
|
||||||
if (appletContainer.x + appletContainer.width > mainFlickable.width * Math.max(1, Math.ceil(appletContainer.x / mainFlickable.width))) {
|
if (appletContainer.x + appletContainer.width > screenWidth * Math.max(1, Math.ceil(appletContainer.x / screenWidth))) {
|
||||||
appletsLayout.releaseSpace(appletContainer);
|
appletsLayout.releaseSpace(appletContainer);
|
||||||
appletContainer.width = (mainFlickable.width * Math.max(1, Math.ceil(appletContainer.x / mainFlickable.width)) - appletContainer.x);
|
appletContainer.width = (screenWidth * Math.max(1, Math.ceil(appletContainer.x / screenWidth)) - appletContainer.x);
|
||||||
appletsLayout.positionItem(appletContainer);
|
appletsLayout.positionItem(appletContainer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -88,21 +93,21 @@ ContainmentLayoutManager.BasicAppletContainer {
|
||||||
target: dropArea
|
target: dropArea
|
||||||
function onWidthChanged () {
|
function onWidthChanged () {
|
||||||
let spaceReleased = false;
|
let spaceReleased = false;
|
||||||
if (appletContainer.width > mainFlickable.width || appletContainer.height > mainFlickable.height) {
|
if (appletContainer.width > screenWidth || appletContainer.height > screenHeight) {
|
||||||
appletsLayout.releaseSpace(appletContainer);
|
appletsLayout.releaseSpace(appletContainer);
|
||||||
appletContainer.width = Math.min(appletContainer.width, mainFlickable.width);
|
appletContainer.width = Math.min(appletContainer.width, screenWidth);
|
||||||
appletContainer.height = Math.min(appletContainer.height, mainFlickable.height);
|
appletContainer.height = Math.min(appletContainer.height, screenHeight);
|
||||||
spaceReleased = true;
|
spaceReleased = true;
|
||||||
}
|
}
|
||||||
if (Math.floor((appletContainer.x) / mainFlickable.width) < Math.floor((appletContainer.x + appletContainer.width/2) / mainFlickable.width)) {
|
if (Math.floor((appletContainer.x) / screenWidth) < Math.floor((appletContainer.x + appletContainer.width/2) / screenWidth)) {
|
||||||
appletsLayout.releaseSpace(appletContainer);
|
appletsLayout.releaseSpace(appletContainer);
|
||||||
appletContainer.x = Math.floor((appletContainer.x + appletContainer.width) / mainFlickable.width) * mainFlickable.width;
|
appletContainer.x = Math.floor((appletContainer.x + appletContainer.width) / screenWidth) * screenWidth;
|
||||||
appletsLayout.positionItem(appletContainer);
|
appletsLayout.positionItem(appletContainer);
|
||||||
spaceReleased = false;
|
spaceReleased = false;
|
||||||
|
|
||||||
} else if (Math.floor((appletContainer.x + appletContainer.width/2) / mainFlickable.width) < Math.floor((appletContainer.x + appletContainer.width) / mainFlickable.width)) {
|
} else if (Math.floor((appletContainer.x + appletContainer.width/2) / screenWidth) < Math.floor((appletContainer.x + appletContainer.width) / screenWidth)) {
|
||||||
appletsLayout.releaseSpace(appletContainer);
|
appletsLayout.releaseSpace(appletContainer);
|
||||||
appletContainer.x = Math.ceil(appletContainer.x / mainFlickable.width) * mainFlickable.width - appletContainer.width;
|
appletContainer.x = Math.ceil(appletContainer.x / screenWidth) * screenWidth - screenWidth;
|
||||||
appletsLayout.positionItem(appletContainer);
|
appletsLayout.positionItem(appletContainer);
|
||||||
spaceReleased = false;
|
spaceReleased = false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,114 +0,0 @@
|
||||||
/*
|
|
||||||
* SPDX-FileCopyrightText: 2021 Marco Martin <mart@kde.org>
|
|
||||||
* SPDX-FileCopyrightText: 2021 Devin Lin <devin@kde.org>
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: LGPL-2.0-or-later
|
|
||||||
*/
|
|
||||||
|
|
||||||
import QtQuick 2.14
|
|
||||||
|
|
||||||
import org.kde.plasma.core 2.0 as PlasmaCore
|
|
||||||
import org.kde.plasma.private.mobileshell 1.0 as MobileShell
|
|
||||||
|
|
||||||
import ".." as Launcher
|
|
||||||
|
|
||||||
DragHandler {
|
|
||||||
id: root
|
|
||||||
yAxis.enabled: enabled
|
|
||||||
xAxis.enabled: enabled
|
|
||||||
property Flickable mainFlickable
|
|
||||||
property Launcher.AbstractAppDrawer appDrawer
|
|
||||||
signal snapPage
|
|
||||||
signal snapNextPage
|
|
||||||
signal snapPrevPage
|
|
||||||
|
|
||||||
enum ScrollDirection {
|
|
||||||
None,
|
|
||||||
Left,
|
|
||||||
Right,
|
|
||||||
Vertical
|
|
||||||
}
|
|
||||||
|
|
||||||
property real __initialMainFlickableX
|
|
||||||
property real __oldTranslationY: 0
|
|
||||||
property int __scrollDirection: DragGestureHandler.None
|
|
||||||
onTranslationChanged: {
|
|
||||||
if (active) {
|
|
||||||
if (root.appDrawer) {
|
|
||||||
if (__scrollDirection === DragGestureHandler.None) {
|
|
||||||
if (root.appDrawer.flickable.contentY > PlasmaCore.Units.gridUnit * 2) {
|
|
||||||
|
|
||||||
__scrollDirection = DragGestureHandler.Vertical;
|
|
||||||
snapPage();
|
|
||||||
} else if (mainFlickable.contentX - __initialMainFlickableX > PlasmaCore.Units.gridUnit) {
|
|
||||||
|
|
||||||
__scrollDirection = DragGestureHandler.Right;
|
|
||||||
root.appDrawer.close();
|
|
||||||
} else if (__initialMainFlickableX - mainFlickable.contentX > PlasmaCore.Units.gridUnit) {
|
|
||||||
|
|
||||||
__scrollDirection = DragGestureHandler.Left;
|
|
||||||
root.appDrawer.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (__scrollDirection !== DragGestureHandler.Left && __scrollDirection !== DragGestureHandler.Right) {
|
|
||||||
|
|
||||||
// ensure it does not conflict with task switcher
|
|
||||||
if (!MobileShell.HomeScreenControls.taskSwitcher.visible) {
|
|
||||||
// if swipe up, scroll app drawer
|
|
||||||
root.appDrawer.flickable.contentY = Math.min(root.appDrawer.drawerTopMargin, Math.max(0, -translation.y));
|
|
||||||
|
|
||||||
if (translation.y < 0 && MobileShell.TopPanelControls.inSwipe) {
|
|
||||||
MobileShell.TopPanelControls.endSwipe();
|
|
||||||
}
|
|
||||||
|
|
||||||
// if swipe down, scroll top panel
|
|
||||||
if (translation.y > 0) {
|
|
||||||
if (!MobileShell.TopPanelControls.inSwipe) {
|
|
||||||
MobileShell.TopPanelControls.startSwipe();
|
|
||||||
}
|
|
||||||
MobileShell.TopPanelControls.requestRelativeScroll(translation.y - __oldTranslationY);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (__scrollDirection !== DragGestureHandler.Vertical) {
|
|
||||||
let newContentX = Math.min((mainFlickable.width * mainFlickable.totalPages) - mainFlickable.width, Math.max(0, __initialMainFlickableX - translation.x));
|
|
||||||
|
|
||||||
if (__scrollDirection !== DragGestureHandler.None) {
|
|
||||||
if (mainFlickable.contentX < newContentX) {
|
|
||||||
__scrollDirection = DragGestureHandler.Right;
|
|
||||||
} else {
|
|
||||||
__scrollDirection = DragGestureHandler.Left;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
mainFlickable.contentX = newContentX;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
__oldTranslationY = translation.y;
|
|
||||||
}
|
|
||||||
|
|
||||||
onActiveChanged: {
|
|
||||||
if (active) {
|
|
||||||
__initialMainFlickableX = mainFlickable.contentX;
|
|
||||||
} else {
|
|
||||||
if (root.appDrawer) {
|
|
||||||
root.appDrawer.snapDrawerStatus();
|
|
||||||
}
|
|
||||||
if (MobileShell.TopPanelControls.inSwipe) {
|
|
||||||
MobileShell.TopPanelControls.endSwipe();
|
|
||||||
}
|
|
||||||
if (__scrollDirection === DragGestureHandler.Left && (__initialMainFlickableX - mainFlickable.contentX > PlasmaCore.Units.gridUnit * 5)) {
|
|
||||||
snapPrevPage();
|
|
||||||
} else if (__scrollDirection === DragGestureHandler.Right && (mainFlickable.contentX - __initialMainFlickableX > PlasmaCore.Units.gridUnit * 5)) {
|
|
||||||
snapNextPage();
|
|
||||||
} else {
|
|
||||||
snapPage();
|
|
||||||
}
|
|
||||||
__scrollDirection = DragGestureHandler.None;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Loading…
Reference in a new issue