Warning, /plasma/plasma-mobile/containments/homescreens/folio/package/contents/ui/AppDrawerGrid.qml is written in an unsupported language. File is not indexed.
0001 // SPDX-FileCopyrightText: 2023 Devin Lin <devin@kde.org> 0002 // SPDX-License-Identifier: LGPL-2.0-or-later 0003 0004 import QtQuick 0005 import QtQuick.Layouts 0006 import QtQuick.Controls as Controls 0007 0008 import org.kde.plasma.plasmoid 2.0 0009 import org.kde.plasma.components 3.0 as PC3 0010 import org.kde.kirigami as Kirigami 0011 0012 import org.kde.plasma.private.mobileshell as MobileShell 0013 import org.kde.plasma.private.mobileshell.state as MobileShellState 0014 import org.kde.private.mobile.homescreen.folio 1.0 as Folio 0015 0016 import "./delegate" 0017 0018 MobileShell.GridView { 0019 id: root 0020 cacheBuffer: cellHeight * 20 0021 reuseItems: true 0022 layer.enabled: true 0023 0024 property var homeScreen 0025 property real headerHeight 0026 0027 readonly property int reservedSpaceForLabel: Folio.HomeScreenState.pageDelegateLabelHeight 0028 readonly property real effectiveContentWidth: width - leftMargin - rightMargin 0029 readonly property real horizontalMargin: Math.round(width * 0.05) 0030 0031 leftMargin: horizontalMargin 0032 rightMargin: horizontalMargin 0033 0034 cellWidth: effectiveContentWidth / Math.min(Math.floor(effectiveContentWidth / (Folio.FolioSettings.delegateIconSize + Kirigami.Units.largeSpacing * 3.5)), 8) 0035 cellHeight: cellWidth + reservedSpaceForLabel 0036 0037 boundsBehavior: Flickable.DragAndOvershootBounds 0038 0039 readonly property int columns: Math.floor(effectiveContentWidth / cellWidth) 0040 readonly property int rows: Math.ceil(root.count / columns) 0041 0042 // HACK: the first swipe from the top of the app drawer is done from HomeScreenState, not the flickable 0043 // due to issues with Flickable getting its swipe stolen by SwipeArea 0044 interactive: (dragging || !atYBeginning) // allow us to drag to the top 0045 && Folio.HomeScreenState.swipeState !== Folio.HomeScreenState.SwipingAppDrawerGrid 0046 0047 Connections { 0048 target: Folio.HomeScreenState 0049 0050 function onSwipeStateChanged() { 0051 if (Folio.HomeScreenState.swipeState === Folio.HomeScreenState.SwipingAppDrawerGrid) { 0052 velocityCalculator.startMeasure(); 0053 velocityCalculator.changePosition(root.contentY); 0054 } 0055 } 0056 0057 function onAppDrawerGridYChanged(y) { 0058 const maxContentY = Math.max(0, root.contentHeight - root.height); 0059 let contentY = root.contentY - y; 0060 0061 if (root.contentHeight < root.height) { 0062 // prevent bottom overscroll only if contents are smaller than the view 0063 contentY = Math.min(maxContentY, contentY); 0064 } 0065 0066 root.contentY = contentY; 0067 velocityCalculator.changePosition(root.contentY); 0068 } 0069 0070 function onAppDrawerGridFlickRequested() { 0071 root.flick(0, -velocityCalculator.velocity); 0072 } 0073 } 0074 0075 MobileShell.VelocityCalculator { 0076 id: velocityCalculator 0077 } 0078 0079 model: Folio.ApplicationListModel 0080 0081 delegate: AppDelegate { 0082 id: delegate 0083 shadow: false 0084 application: model.delegate.application 0085 0086 width: root.cellWidth 0087 height: root.cellHeight 0088 0089 onPressAndHold: { 0090 const mappedCoords = root.homeScreen.prepareStartDelegateDrag(model.delegate, delegate.delegateItem); 0091 Folio.HomeScreenState.closeAppDrawer(); 0092 0093 // we need to adjust because app drawer delegates have a different size than regular homescreen delegates 0094 const centerX = mappedCoords.x + root.cellWidth / 2; 0095 const centerY = mappedCoords.y + root.cellHeight / 2; 0096 0097 Folio.HomeScreenState.startDelegateAppDrawerDrag( 0098 centerX - Folio.HomeScreenState.pageCellWidth / 2, 0099 centerY - Folio.HomeScreenState.pageCellHeight / 2, 0100 delegate.pressPosition.x * (Folio.HomeScreenState.pageCellWidth / root.cellWidth), 0101 delegate.pressPosition.y * (Folio.HomeScreenState.pageCellHeight / root.cellHeight), 0102 model.delegate.application.storageId 0103 ); 0104 } 0105 } 0106 0107 PC3.ScrollBar.vertical: PC3.ScrollBar { 0108 id: scrollBar 0109 interactive: true 0110 enabled: true 0111 implicitWidth: Kirigami.Units.smallSpacing 0112 0113 Behavior on opacity { 0114 OpacityAnimator { 0115 duration: Kirigami.Units.longDuration * 2 0116 easing.type: Easing.InOutQuad 0117 } 0118 } 0119 0120 contentItem: Rectangle { 0121 radius: width / 2 0122 color: Qt.rgba(1, 1, 1, 0.3) 0123 } 0124 } 0125 }