2019-07-29 16:49:36 +00:00
|
|
|
/*
|
2021-03-01 20:03:25 +00:00
|
|
|
* SPDX-FileCopyrightText: 2019 Marco Martin <mart@kde.org>
|
2019-07-29 16:49:36 +00:00
|
|
|
*
|
2021-03-01 20:03:25 +00:00
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
2019-07-29 16:49:36 +00:00
|
|
|
*/
|
|
|
|
|
|
2022-04-06 17:13:38 +00:00
|
|
|
import QtQuick 2.15
|
2019-07-29 16:49:36 +00:00
|
|
|
import QtQuick.Layouts 1.1
|
|
|
|
|
import QtQuick.Controls 2.3 as Controls
|
2023-03-03 05:48:24 +00:00
|
|
|
import Qt5Compat.GraphicalEffects
|
2019-07-29 16:49:36 +00:00
|
|
|
|
|
|
|
|
import org.kde.plasma.plasmoid 2.0
|
|
|
|
|
import org.kde.plasma.core 2.0 as PlasmaCore
|
2021-02-15 10:44:48 +00:00
|
|
|
import org.kde.plasma.components 3.0 as PC3
|
2019-07-29 16:49:36 +00:00
|
|
|
import org.kde.kquickcontrolsaddons 2.0
|
|
|
|
|
|
2019-07-30 10:20:21 +00:00
|
|
|
import org.kde.plasma.private.containmentlayoutmanager 1.0 as ContainmentLayoutManager
|
2020-07-30 15:20:07 +00:00
|
|
|
import org.kde.plasma.private.mobileshell 1.0 as MobileShell
|
2022-11-11 16:21:12 +00:00
|
|
|
import org.kde.plasma.private.mobileshell.state 1.0 as MobileShellState
|
2023-03-06 19:13:48 +00:00
|
|
|
import org.kde.private.mobile.homescreen.folio 1.0 as Folio
|
2019-08-22 14:59:30 +00:00
|
|
|
|
2021-02-15 10:44:48 +00:00
|
|
|
import "private" as Private
|
|
|
|
|
|
2019-07-30 10:20:21 +00:00
|
|
|
ContainmentLayoutManager.ItemContainer {
|
2019-07-29 16:49:36 +00:00
|
|
|
id: delegate
|
2023-03-05 17:39:03 +00:00
|
|
|
required property Folio.DesktopModel desktopModel
|
2019-07-29 16:49:36 +00:00
|
|
|
|
2022-05-17 19:52:22 +00:00
|
|
|
enabled: homeScreenState.currentView === HomeScreenState.PageView || homeScreenState.currentSwipeState === HomeScreenState.SwipingAppDrawerVisibility
|
2022-05-17 19:51:25 +00:00
|
|
|
|
2021-12-31 00:49:08 +00:00
|
|
|
property var homeScreenState
|
|
|
|
|
|
2019-08-30 09:07:31 +00:00
|
|
|
z: dragActive ? 1 : 0
|
2019-07-29 16:49:36 +00:00
|
|
|
|
|
|
|
|
property var modelData: typeof model !== "undefined" ? model : null
|
|
|
|
|
|
2021-02-15 10:44:48 +00:00
|
|
|
Layout.minimumWidth: appletsLayout.cellWidth
|
|
|
|
|
Layout.minimumHeight: appletsLayout.cellHeight
|
2019-07-29 16:49:36 +00:00
|
|
|
|
2021-02-15 10:44:48 +00:00
|
|
|
key: model.applicationUniqueId
|
|
|
|
|
property ContainmentLayoutManager.AppletsLayout appletsLayout
|
|
|
|
|
property int reservedSpaceForLabel
|
2019-08-22 11:14:28 +00:00
|
|
|
property real dragCenterX
|
|
|
|
|
property real dragCenterY
|
2020-02-11 15:14:54 +00:00
|
|
|
property alias iconItem: icon
|
2019-08-22 11:14:28 +00:00
|
|
|
|
2019-08-22 16:11:14 +00:00
|
|
|
editModeCondition: ContainmentLayoutManager.ItemContainer.AfterPressAndHold
|
2019-08-29 11:45:01 +00:00
|
|
|
|
2019-12-20 06:44:15 +00:00
|
|
|
signal launch(int x, int y, var source, string title)
|
|
|
|
|
|
2020-07-31 09:11:26 +00:00
|
|
|
function syncDelegateGeometry() {
|
|
|
|
|
if (!applicationRunning) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-11 16:21:12 +00:00
|
|
|
if (!MobileShellState.Shell.taskSwitcherVisible) {
|
2023-03-05 17:39:03 +00:00
|
|
|
desktopModel.setMinimizedDelegate(index, delegate);
|
2020-07-31 09:11:26 +00:00
|
|
|
} else {
|
2023-03-05 17:39:03 +00:00
|
|
|
desktopModel.unsetMinimizedDelegate(index, delegate);
|
2020-07-30 15:20:07 +00:00
|
|
|
}
|
|
|
|
|
}
|
2022-04-06 17:13:38 +00:00
|
|
|
|
|
|
|
|
function launchApp() {
|
|
|
|
|
if (modelData.applicationRunning) {
|
|
|
|
|
delegate.launch(0, 0, "", modelData.applicationName);
|
|
|
|
|
} else {
|
|
|
|
|
delegate.launch(delegate.x + (PlasmaCore.Units.smallSpacing * 2), delegate.y + (PlasmaCore.Units.smallSpacing * 2), icon.source, modelData.applicationName);
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-05 17:39:03 +00:00
|
|
|
desktopModel.setMinimizedDelegate(index, delegate);
|
2022-10-12 22:10:08 +00:00
|
|
|
MobileShell.ShellUtil.launchApp(modelData.applicationStorageId);
|
2022-04-06 17:13:38 +00:00
|
|
|
}
|
2020-07-31 09:11:26 +00:00
|
|
|
|
|
|
|
|
readonly property bool applicationRunning: model.applicationRunning
|
|
|
|
|
onApplicationRunningChanged: {
|
|
|
|
|
syncDelegateGeometry();
|
|
|
|
|
}
|
2021-03-24 13:48:56 +00:00
|
|
|
onDragActiveChanged: {
|
|
|
|
|
if (dragActive) {
|
|
|
|
|
removeButton.show();
|
|
|
|
|
mouseArea.enabled = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-02-07 12:48:34 +00:00
|
|
|
Connections {
|
2021-12-31 00:49:08 +00:00
|
|
|
target: homeScreenState
|
2020-07-30 15:20:07 +00:00
|
|
|
function onCancelEditModeForItemsRequested() {
|
|
|
|
|
cancelEdit()
|
|
|
|
|
}
|
2021-12-31 00:49:08 +00:00
|
|
|
function onXPositionChanged() {
|
2020-07-31 09:11:26 +00:00
|
|
|
syncDelegateGeometry()
|
2020-07-30 15:20:07 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Connections {
|
2022-11-11 16:21:12 +00:00
|
|
|
target: MobileShellState.Shell
|
2020-07-31 09:11:26 +00:00
|
|
|
function onTaskSwitcherVisibleChanged() {
|
|
|
|
|
syncDelegateGeometry();
|
2020-07-30 15:20:07 +00:00
|
|
|
}
|
2020-02-07 12:48:34 +00:00
|
|
|
}
|
2021-02-15 10:44:48 +00:00
|
|
|
Connections {
|
|
|
|
|
target: appletsLayout
|
|
|
|
|
function onAppletsLayoutInteracted() {
|
|
|
|
|
removeButton.hide();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-22 15:14:30 +00:00
|
|
|
contentItem: MouseArea {
|
2021-02-15 10:44:48 +00:00
|
|
|
id: mouseArea
|
2022-04-06 17:13:38 +00:00
|
|
|
|
|
|
|
|
// grow/shrink animation
|
|
|
|
|
property real zoomScale: 1
|
|
|
|
|
transform: Scale {
|
|
|
|
|
origin.x: mouseArea.width / 2;
|
|
|
|
|
origin.y: mouseArea.height / 2;
|
|
|
|
|
xScale: mouseArea.zoomScale
|
|
|
|
|
yScale: mouseArea.zoomScale
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
property bool launchAppRequested: false
|
|
|
|
|
|
|
|
|
|
NumberAnimation on zoomScale {
|
|
|
|
|
id: shrinkAnim
|
2022-04-06 17:49:59 +00:00
|
|
|
running: false
|
2022-04-30 00:02:33 +00:00
|
|
|
duration: MobileShell.MobileShellSettings.animationsEnabled ? 80 : 1
|
|
|
|
|
to: MobileShell.MobileShellSettings.animationsEnabled ? 0.8 : 1
|
2022-04-06 17:13:38 +00:00
|
|
|
onFinished: {
|
|
|
|
|
if (!mouseArea.pressed) {
|
|
|
|
|
growAnim.restart();
|
|
|
|
|
}
|
2020-07-28 11:24:13 +00:00
|
|
|
}
|
2020-05-28 13:58:27 +00:00
|
|
|
}
|
2022-04-06 17:13:38 +00:00
|
|
|
|
|
|
|
|
NumberAnimation on zoomScale {
|
|
|
|
|
id: growAnim
|
2022-04-06 17:49:59 +00:00
|
|
|
running: false
|
2022-04-30 00:02:33 +00:00
|
|
|
duration: MobileShell.MobileShellSettings.animationsEnabled ? 80 : 1
|
2022-04-06 17:13:38 +00:00
|
|
|
to: 1
|
|
|
|
|
onFinished: {
|
|
|
|
|
if (mouseArea.launchAppRequested) {
|
|
|
|
|
delegate.launchApp();
|
|
|
|
|
mouseArea.launchAppRequested = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
|
|
|
|
hoverEnabled: true
|
|
|
|
|
onPressedChanged: {
|
|
|
|
|
if (pressed) {
|
|
|
|
|
growAnim.stop();
|
|
|
|
|
shrinkAnim.restart();
|
|
|
|
|
} else if (!pressed && !shrinkAnim.running) {
|
|
|
|
|
growAnim.restart();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// launch app handled by press animation
|
|
|
|
|
onClicked: launchAppRequested = true;
|
2019-10-10 11:56:35 +00:00
|
|
|
|
2019-07-29 16:49:36 +00:00
|
|
|
ColumnLayout {
|
2019-10-11 09:54:01 +00:00
|
|
|
anchors {
|
|
|
|
|
fill: parent
|
2021-04-01 14:56:29 +00:00
|
|
|
leftMargin: PlasmaCore.Units.smallSpacing * 2
|
|
|
|
|
topMargin: PlasmaCore.Units.smallSpacing * 2
|
|
|
|
|
rightMargin: PlasmaCore.Units.smallSpacing * 2
|
|
|
|
|
bottomMargin: PlasmaCore.Units.smallSpacing * 2
|
2019-10-11 09:54:01 +00:00
|
|
|
}
|
2019-07-29 16:49:36 +00:00
|
|
|
spacing: 0
|
2019-07-30 10:20:21 +00:00
|
|
|
|
2019-07-29 16:49:36 +00:00
|
|
|
PlasmaCore.IconItem {
|
|
|
|
|
id: icon
|
|
|
|
|
|
|
|
|
|
Layout.alignment: Qt.AlignHCenter | Qt.AlignTop
|
|
|
|
|
Layout.fillWidth: true
|
2021-04-01 14:56:29 +00:00
|
|
|
Layout.minimumHeight: Math.min(PlasmaCore.Units.iconSizes.large, parent.height - delegate.reservedSpaceForLabel)
|
2019-08-29 09:50:49 +00:00
|
|
|
Layout.preferredHeight: Layout.minimumHeight
|
2019-07-29 16:49:36 +00:00
|
|
|
|
2020-02-12 15:17:20 +00:00
|
|
|
usesPlasmaTheme: false
|
2020-03-20 00:58:46 +00:00
|
|
|
source: modelData ? modelData.applicationIcon : ""
|
2020-07-28 11:24:13 +00:00
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
|
anchors {
|
|
|
|
|
horizontalCenter: parent.horizontalCenter
|
|
|
|
|
bottom: parent.bottom
|
2019-07-29 16:49:36 +00:00
|
|
|
}
|
2020-07-28 11:24:13 +00:00
|
|
|
visible: model.applicationRunning
|
|
|
|
|
radius: width
|
2021-04-01 14:56:29 +00:00
|
|
|
width: PlasmaCore.Units.smallSpacing
|
2020-07-28 11:24:13 +00:00
|
|
|
height: width
|
2021-06-10 14:14:41 +00:00
|
|
|
color: PlasmaCore.Theme.highlightColor
|
2019-07-29 16:49:36 +00:00
|
|
|
}
|
2022-04-06 17:13:38 +00:00
|
|
|
|
|
|
|
|
// darken effect when hovered/pressed
|
|
|
|
|
layer {
|
2022-06-22 15:14:30 +00:00
|
|
|
enabled: mouseArea.pressed || mouseArea.containsMouse
|
2022-04-06 17:13:38 +00:00
|
|
|
effect: ColorOverlay {
|
|
|
|
|
color: Qt.rgba(0, 0, 0, 0.3)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-15 10:44:48 +00:00
|
|
|
//TODO: in loader?
|
|
|
|
|
Private.DelegateRemoveButton {
|
|
|
|
|
id: removeButton
|
2023-03-05 17:39:03 +00:00
|
|
|
desktopModel: delegate.desktopModel
|
2021-02-15 10:44:48 +00:00
|
|
|
}
|
2019-07-29 16:49:36 +00:00
|
|
|
}
|
|
|
|
|
|
2021-02-15 10:44:48 +00:00
|
|
|
PC3.Label {
|
2019-07-29 16:49:36 +00:00
|
|
|
id: label
|
|
|
|
|
visible: text.length > 0
|
|
|
|
|
|
|
|
|
|
Layout.fillWidth: true
|
2021-02-15 10:44:48 +00:00
|
|
|
Layout.preferredHeight: delegate.reservedSpaceForLabel
|
|
|
|
|
Layout.alignment: Qt.AlignTop
|
2022-04-06 16:04:57 +00:00
|
|
|
Layout.topMargin: PlasmaCore.Units.smallSpacing
|
|
|
|
|
Layout.leftMargin: -parent.anchors.leftMargin + PlasmaCore.Units.smallSpacing * 2
|
|
|
|
|
Layout.rightMargin: -parent.anchors.rightMargin + PlasmaCore.Units.smallSpacing * 2
|
|
|
|
|
|
|
|
|
|
wrapMode: Text.WordWrap
|
2019-07-29 16:49:36 +00:00
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
|
verticalAlignment: Text.AlignTop
|
|
|
|
|
maximumLineCount: 2
|
2020-02-14 12:36:29 +00:00
|
|
|
elide: Text.ElideRight
|
|
|
|
|
|
2022-04-06 16:04:57 +00:00
|
|
|
text: model.applicationName
|
2020-02-14 12:36:29 +00:00
|
|
|
|
2022-04-06 16:04:57 +00:00
|
|
|
font.pointSize: PlasmaCore.Theme.defaultFont.pointSize * 0.8
|
|
|
|
|
font.weight: Font.Bold
|
|
|
|
|
color: "white"
|
2019-08-26 12:15:06 +00:00
|
|
|
|
2022-04-06 16:04:57 +00:00
|
|
|
layer.enabled: true
|
2019-08-26 12:15:06 +00:00
|
|
|
layer.effect: DropShadow {
|
|
|
|
|
horizontalOffset: 0
|
|
|
|
|
verticalOffset: 2
|
2022-04-06 17:13:38 +00:00
|
|
|
radius: 6.0
|
|
|
|
|
samples: 10
|
2020-02-12 06:00:28 +00:00
|
|
|
cached: true
|
2022-04-06 17:13:38 +00:00
|
|
|
color: Qt.rgba(0, 0, 0, 0.3)
|
2019-08-26 12:15:06 +00:00
|
|
|
}
|
2019-07-29 16:49:36 +00:00
|
|
|
}
|
2022-06-17 04:48:53 +00:00
|
|
|
Item { Layout.fillHeight: true }
|
2019-07-29 16:49:36 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|