2022-06-08 22:09:35 +00:00
|
|
|
/*
|
|
|
|
|
* SPDX-FileCopyrightText: 2021 Devin Lin <espidev@gmail.com>
|
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import QtQuick 2.15
|
|
|
|
|
import QtQuick.Layouts 1.1
|
|
|
|
|
import QtQuick.Controls 2.15 as Controls
|
|
|
|
|
|
|
|
|
|
import org.kde.plasma.components 3.0 as PC3
|
2024-11-11 05:01:28 +00:00
|
|
|
import org.kde.kirigami 2.10 as Kirigami
|
2022-06-08 22:09:35 +00:00
|
|
|
|
2023-11-02 11:08:17 +00:00
|
|
|
import org.kde.plasma.private.mobileshell as MobileShell
|
|
|
|
|
import org.kde.plasma.private.mobileshell.state as MobileShellState
|
2023-03-05 02:40:06 +00:00
|
|
|
import org.kde.private.mobile.homescreen.halcyon 1.0 as Halcyon
|
2024-03-10 03:50:55 +00:00
|
|
|
import org.kde.plasma.plasmoid
|
2022-06-08 22:09:35 +00:00
|
|
|
|
2022-07-08 22:34:04 +00:00
|
|
|
MobileShell.GridView {
|
2022-06-08 22:09:35 +00:00
|
|
|
id: gridView
|
2022-11-14 03:17:48 +00:00
|
|
|
cacheBuffer: cellHeight * 20 // 10 rows above and below
|
2022-09-18 04:00:28 +00:00
|
|
|
reuseItems: true
|
2024-07-13 16:30:07 +00:00
|
|
|
|
2023-03-13 10:44:56 +00:00
|
|
|
Controls.ScrollBar.vertical: Controls.ScrollBar {}
|
|
|
|
|
|
|
|
|
|
Connections {
|
|
|
|
|
target: parent
|
2023-03-12 19:41:55 +00:00
|
|
|
|
2023-03-13 10:44:56 +00:00
|
|
|
function onFocusRequested() {
|
2023-03-12 19:41:55 +00:00
|
|
|
forceActiveFocus();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-14 03:17:48 +00:00
|
|
|
// ensure items aren't visible out of bounds
|
|
|
|
|
layer.enabled: true
|
2024-07-13 16:30:07 +00:00
|
|
|
|
2022-06-08 22:09:35 +00:00
|
|
|
readonly property int reservedSpaceForLabel: metrics.height
|
2022-09-05 20:09:50 +00:00
|
|
|
readonly property real effectiveContentWidth: width - leftMargin - rightMargin
|
2024-07-13 16:30:07 +00:00
|
|
|
|
2024-01-01 11:53:08 +00:00
|
|
|
cellWidth: gridView.effectiveContentWidth / Math.min(Math.floor(effectiveContentWidth / (Kirigami.Units.iconSizes.huge + Kirigami.Units.largeSpacing * 2)), 8)
|
2022-06-08 22:09:35 +00:00
|
|
|
cellHeight: cellWidth + reservedSpaceForLabel
|
|
|
|
|
|
2022-11-14 03:17:48 +00:00
|
|
|
property int columns: Math.floor(effectiveContentWidth / cellWidth)
|
2022-06-23 20:39:55 +00:00
|
|
|
property int rows: Math.ceil(Halcyon.ApplicationListModel.count / columns)
|
2022-06-08 22:09:35 +00:00
|
|
|
|
2022-07-12 02:39:33 +00:00
|
|
|
function goToBeginning() {
|
|
|
|
|
goToBeginningAnim.restart();
|
|
|
|
|
}
|
2024-07-13 16:30:07 +00:00
|
|
|
|
2022-07-12 02:39:33 +00:00
|
|
|
NumberAnimation on contentY {
|
|
|
|
|
id: goToBeginningAnim
|
|
|
|
|
to: gridView.originY
|
|
|
|
|
duration: 200
|
|
|
|
|
easing.type: Easing.InOutQuad
|
|
|
|
|
}
|
2024-07-13 16:30:07 +00:00
|
|
|
|
2022-06-18 19:42:29 +00:00
|
|
|
model: Halcyon.ApplicationListModel
|
2022-06-08 22:09:35 +00:00
|
|
|
|
2022-06-24 19:31:46 +00:00
|
|
|
header: MobileShell.BaseItem {
|
|
|
|
|
implicitWidth: gridView.effectiveContentWidth
|
2023-07-25 01:13:52 +00:00
|
|
|
topPadding: Kirigami.Units.gridUnit + Math.round(gridView.height * 0.1)
|
|
|
|
|
bottomPadding: Kirigami.Units.gridUnit
|
|
|
|
|
leftPadding: Kirigami.Units.smallSpacing
|
2024-07-13 16:30:07 +00:00
|
|
|
|
2022-06-23 20:39:55 +00:00
|
|
|
contentItem: PC3.Label {
|
2022-06-08 22:09:35 +00:00
|
|
|
color: "white"
|
2022-06-23 20:39:55 +00:00
|
|
|
font.pointSize: 16
|
2022-06-08 22:09:35 +00:00
|
|
|
font.weight: Font.Bold
|
|
|
|
|
text: i18n("Applications")
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-07-13 16:30:07 +00:00
|
|
|
|
2022-06-08 22:09:35 +00:00
|
|
|
PC3.Label {
|
|
|
|
|
id: metrics
|
|
|
|
|
text: "M\nM"
|
|
|
|
|
visible: false
|
2023-07-25 01:13:52 +00:00
|
|
|
font.pointSize: Kirigami.Theme.defaultFont.pointSize * 0.85
|
2022-06-08 22:09:35 +00:00
|
|
|
font.weight: Font.Bold
|
|
|
|
|
}
|
2024-07-13 16:30:07 +00:00
|
|
|
|
2023-03-12 19:41:55 +00:00
|
|
|
Keys.onReturnPressed: currentItem.launchApp()
|
2022-06-08 22:09:35 +00:00
|
|
|
delegate: GridAppDelegate {
|
|
|
|
|
id: delegate
|
2024-07-13 16:30:07 +00:00
|
|
|
|
2022-06-18 19:42:29 +00:00
|
|
|
property Halcyon.Application application: model.application
|
2024-07-13 16:30:07 +00:00
|
|
|
|
2022-06-08 22:09:35 +00:00
|
|
|
width: gridView.cellWidth
|
|
|
|
|
height: gridView.cellHeight
|
|
|
|
|
reservedSpaceForLabel: gridView.reservedSpaceForLabel
|
|
|
|
|
|
|
|
|
|
onLaunch: (x, y, icon, title, storageId) => {
|
|
|
|
|
if (icon !== "") {
|
2024-03-10 03:50:55 +00:00
|
|
|
MobileShellState.ShellDBusClient.openAppLaunchAnimationWithPosition(
|
|
|
|
|
Plasmoid.screen,
|
|
|
|
|
icon,
|
|
|
|
|
title,
|
2024-07-13 16:30:07 +00:00
|
|
|
storageId,
|
2024-03-10 03:50:55 +00:00
|
|
|
delegate.iconItem.Kirigami.ScenePosition.x + delegate.iconItem.width/2,
|
|
|
|
|
delegate.iconItem.Kirigami.ScenePosition.y + delegate.iconItem.height/2,
|
|
|
|
|
Math.min(delegate.iconItem.width, delegate.iconItem.height));
|
2022-06-08 22:09:35 +00:00
|
|
|
}
|
|
|
|
|
|
2022-06-18 19:42:29 +00:00
|
|
|
application.setMinimizedDelegate(delegate);
|
2023-03-15 06:29:46 +00:00
|
|
|
MobileShell.AppLaunch.launchOrActivateApp(application.storageId);
|
2022-06-08 22:09:35 +00:00
|
|
|
}
|
|
|
|
|
}
|
2023-03-12 20:03:21 +00:00
|
|
|
|
|
|
|
|
Component.onCompleted: {
|
|
|
|
|
goToBeginning();
|
|
|
|
|
}
|
2022-06-08 22:09:35 +00:00
|
|
|
}
|