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.plasmoid 2.0
|
|
|
|
|
import org.kde.plasma.core 2.0 as PlasmaCore
|
|
|
|
|
import org.kde.plasma.components 3.0 as PC3
|
|
|
|
|
import org.kde.plasma.extras 2.0 as PlasmaExtras
|
|
|
|
|
import org.kde.kirigami 2.10 as Kirigami
|
|
|
|
|
|
|
|
|
|
import org.kde.plasma.private.nanoshell 2.0 as NanoShell
|
|
|
|
|
import org.kde.plasma.private.mobileshell 1.0 as MobileShell
|
2022-06-18 19:42:29 +00:00
|
|
|
import org.kde.phone.homescreen.halcyon 1.0 as Halcyon
|
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-07-08 22:34:04 +00:00
|
|
|
layer.enabled: true
|
2022-06-08 22:09:35 +00:00
|
|
|
|
|
|
|
|
readonly property int reservedSpaceForLabel: metrics.height
|
2022-06-25 16:43:11 +00:00
|
|
|
required property real effectiveContentWidth
|
2022-06-08 22:09:35 +00:00
|
|
|
|
2022-06-24 19:31:46 +00:00
|
|
|
cellWidth: effectiveContentWidth / Math.min(Math.floor(effectiveContentWidth / (PlasmaCore.Units.iconSizes.huge + Kirigami.Units.largeSpacing * 2)), 8)
|
2022-06-08 22:09:35 +00:00
|
|
|
cellHeight: cellWidth + reservedSpaceForLabel
|
|
|
|
|
|
2022-06-24 19:31:46 +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
|
|
|
|
|
|
|
|
cacheBuffer: Math.max(0, rows * cellHeight)
|
|
|
|
|
|
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
|
|
|
|
|
topPadding: PlasmaCore.Units.largeSpacing + Math.round(gridView.height * 0.2)
|
2022-06-08 22:09:35 +00:00
|
|
|
bottomPadding: PlasmaCore.Units.largeSpacing
|
|
|
|
|
leftPadding: PlasmaCore.Units.smallSpacing
|
|
|
|
|
|
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")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PC3.Label {
|
|
|
|
|
id: metrics
|
|
|
|
|
text: "M\nM"
|
|
|
|
|
visible: false
|
|
|
|
|
font.pointSize: PlasmaCore.Theme.defaultFont.pointSize * 0.85
|
|
|
|
|
font.weight: Font.Bold
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
delegate: GridAppDelegate {
|
|
|
|
|
id: delegate
|
|
|
|
|
|
2022-06-18 19:42:29 +00:00
|
|
|
property Halcyon.Application application: model.application
|
|
|
|
|
|
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 !== "") {
|
|
|
|
|
MobileShell.HomeScreenControls.openAppLaunchAnimation(
|
|
|
|
|
icon,
|
|
|
|
|
title,
|
|
|
|
|
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-18 19:42:29 +00:00
|
|
|
application.setMinimizedDelegate(delegate);
|
|
|
|
|
application.runApplication();
|
2022-06-08 22:09:35 +00:00
|
|
|
}
|
|
|
|
|
}
|
2022-06-24 19:31:46 +00:00
|
|
|
|
|
|
|
|
PC3.ScrollBar.vertical: PC3.ScrollBar {
|
|
|
|
|
id: scrollBar
|
|
|
|
|
interactive: true
|
|
|
|
|
enabled: true
|
|
|
|
|
Behavior on opacity {
|
|
|
|
|
OpacityAnimator {
|
|
|
|
|
duration: PlasmaCore.Units.longDuration * 2
|
|
|
|
|
easing.type: Easing.InOutQuad
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
implicitWidth: PlasmaCore.Units.smallSpacing
|
|
|
|
|
contentItem: Rectangle {
|
|
|
|
|
radius: width/2
|
|
|
|
|
color: Qt.rgba(1, 1, 1, 0.3)
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-06-08 22:09:35 +00:00
|
|
|
}
|