Warning, /plasma/plasma-mobile/containments/homescreens/halcyon/package/contents/ui/GridAppList.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 * SPDX-FileCopyrightText: 2021 Devin Lin <espidev@gmail.com> 0003 * SPDX-License-Identifier: GPL-2.0-or-later 0004 */ 0005 0006 import QtQuick 2.15 0007 import QtQuick.Layouts 1.1 0008 import QtQuick.Controls 2.15 as Controls 0009 0010 import org.kde.plasma.components 3.0 as PC3 0011 import org.kde.kirigami 2.10 as Kirigami 0012 0013 import org.kde.plasma.private.mobileshell as MobileShell 0014 import org.kde.plasma.private.mobileshell.state as MobileShellState 0015 import org.kde.private.mobile.homescreen.halcyon 1.0 as Halcyon 0016 0017 MobileShell.GridView { 0018 id: gridView 0019 cacheBuffer: cellHeight * 20 // 10 rows above and below 0020 reuseItems: true 0021 0022 Controls.ScrollBar.vertical: Controls.ScrollBar {} 0023 0024 Connections { 0025 target: parent 0026 0027 function onFocusRequested() { 0028 forceActiveFocus(); 0029 } 0030 } 0031 0032 // ensure items aren't visible out of bounds 0033 layer.enabled: true 0034 0035 readonly property int reservedSpaceForLabel: metrics.height 0036 readonly property real effectiveContentWidth: width - leftMargin - rightMargin 0037 0038 cellWidth: gridView.effectiveContentWidth / Math.min(Math.floor(effectiveContentWidth / (Kirigami.Units.iconSizes.huge + Kirigami.Units.largeSpacing * 2)), 8) 0039 cellHeight: cellWidth + reservedSpaceForLabel 0040 0041 property int columns: Math.floor(effectiveContentWidth / cellWidth) 0042 property int rows: Math.ceil(Halcyon.ApplicationListModel.count / columns) 0043 0044 function goToBeginning() { 0045 goToBeginningAnim.restart(); 0046 } 0047 0048 NumberAnimation on contentY { 0049 id: goToBeginningAnim 0050 to: gridView.originY 0051 duration: 200 0052 easing.type: Easing.InOutQuad 0053 } 0054 0055 model: Halcyon.ApplicationListModel 0056 0057 header: MobileShell.BaseItem { 0058 implicitWidth: gridView.effectiveContentWidth 0059 topPadding: Kirigami.Units.gridUnit + Math.round(gridView.height * 0.1) 0060 bottomPadding: Kirigami.Units.gridUnit 0061 leftPadding: Kirigami.Units.smallSpacing 0062 0063 contentItem: PC3.Label { 0064 color: "white" 0065 font.pointSize: 16 0066 font.weight: Font.Bold 0067 text: i18n("Applications") 0068 } 0069 } 0070 0071 PC3.Label { 0072 id: metrics 0073 text: "M\nM" 0074 visible: false 0075 font.pointSize: Kirigami.Theme.defaultFont.pointSize * 0.85 0076 font.weight: Font.Bold 0077 } 0078 0079 Keys.onReturnPressed: currentItem.launchApp() 0080 delegate: GridAppDelegate { 0081 id: delegate 0082 0083 property Halcyon.Application application: model.application 0084 0085 width: gridView.cellWidth 0086 height: gridView.cellHeight 0087 reservedSpaceForLabel: gridView.reservedSpaceForLabel 0088 0089 onLaunch: (x, y, icon, title, storageId) => { 0090 if (icon !== "") { 0091 MobileShellState.ShellDBusClient.openAppLaunchAnimation( 0092 icon, 0093 title, 0094 delegate.iconItem.Kirigami.ScenePosition.x + delegate.iconItem.width/2, 0095 delegate.iconItem.Kirigami.ScenePosition.y + delegate.iconItem.height/2, 0096 Math.min(delegate.iconItem.width, delegate.iconItem.height)); 0097 } 0098 0099 application.setMinimizedDelegate(delegate); 0100 MobileShell.AppLaunch.launchOrActivateApp(application.storageId); 0101 } 0102 } 0103 0104 Component.onCompleted: { 0105 goToBeginning(); 0106 } 0107 }