2023-10-22 03:59:27 +00:00
|
|
|
// SPDX-FileCopyrightText: 2023 Devin Lin <devin@kde.org>
|
|
|
|
|
// SPDX-License-Identifier: LGPL-2.0-or-later
|
2021-03-19 16:30:43 +00:00
|
|
|
|
2023-10-22 03:59:27 +00:00
|
|
|
import QtQuick
|
|
|
|
|
import QtQuick.Window
|
|
|
|
|
import QtQuick.Layouts
|
2021-03-19 16:30:43 +00:00
|
|
|
|
2023-10-22 03:59:27 +00:00
|
|
|
import org.kde.plasma.components 3.0 as PC3
|
2025-05-01 09:04:38 +00:00
|
|
|
import org.kde.plasma.private.mobileshell as MobileShell
|
2023-10-22 03:59:27 +00:00
|
|
|
import org.kde.kirigami 2.10 as Kirigami
|
|
|
|
|
import org.kde.private.mobile.homescreen.folio 1.0 as Folio
|
2023-07-25 01:13:52 +00:00
|
|
|
|
2023-10-22 03:59:27 +00:00
|
|
|
MouseArea {
|
|
|
|
|
id: root
|
2024-06-21 04:42:14 +00:00
|
|
|
property Folio.HomeScreen folio
|
2021-03-19 16:30:43 +00:00
|
|
|
|
2023-10-22 03:59:27 +00:00
|
|
|
property var homeScreen
|
2021-03-19 16:30:43 +00:00
|
|
|
|
2024-06-21 04:42:14 +00:00
|
|
|
readonly property real verticalMargin: Math.round((folio.HomeScreenState.pageHeight - folio.HomeScreenState.pageContentHeight) / 2)
|
|
|
|
|
readonly property real horizontalMargin: Math.round((folio.HomeScreenState.pageWidth - folio.HomeScreenState.pageContentWidth) / 2)
|
2021-03-19 16:30:43 +00:00
|
|
|
|
2025-06-27 04:14:26 +00:00
|
|
|
onPressAndHold: {
|
|
|
|
|
folio.HomeScreenState.openSettingsView()
|
|
|
|
|
haptics.buttonVibrate();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onDoubleClicked: {
|
|
|
|
|
if (folio.FolioSettings.doubleTapToLock) {
|
|
|
|
|
deviceLock.triggerLock();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-05-01 09:04:38 +00:00
|
|
|
MobileShell.HapticsEffect {
|
|
|
|
|
id: haptics
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-27 04:14:26 +00:00
|
|
|
MobileShell.DeviceLock {
|
|
|
|
|
id: deviceLock
|
2025-05-01 09:04:38 +00:00
|
|
|
}
|
2021-03-19 16:30:43 +00:00
|
|
|
|
2023-10-22 03:59:27 +00:00
|
|
|
Repeater {
|
2024-06-21 04:42:14 +00:00
|
|
|
model: folio.PageListModel
|
2021-03-26 16:21:30 +00:00
|
|
|
|
2023-10-22 03:59:27 +00:00
|
|
|
delegate: HomeScreenPage {
|
|
|
|
|
id: homeScreenPage
|
2024-06-21 04:42:14 +00:00
|
|
|
folio: root.folio
|
2023-10-22 03:59:27 +00:00
|
|
|
pageNum: model.index
|
|
|
|
|
pageModel: model.delegate
|
|
|
|
|
homeScreen: root.homeScreen
|
2021-12-31 00:49:08 +00:00
|
|
|
|
2023-10-22 03:59:27 +00:00
|
|
|
anchors.fill: root
|
|
|
|
|
anchors.leftMargin: root.horizontalMargin
|
|
|
|
|
anchors.rightMargin: root.horizontalMargin
|
|
|
|
|
anchors.topMargin: root.verticalMargin
|
|
|
|
|
anchors.bottomMargin: root.verticalMargin
|
2021-03-19 16:30:43 +00:00
|
|
|
|
2023-10-22 03:59:27 +00:00
|
|
|
// animation so that full opacity is only when the page is in view
|
2024-06-21 04:42:14 +00:00
|
|
|
readonly property real distanceToCenter: Math.abs(-folio.HomeScreenState.pageViewX - root.width * pageNum)
|
|
|
|
|
readonly property real positionX: root.width * index + folio.HomeScreenState.pageViewX
|
2023-10-23 02:47:16 +00:00
|
|
|
readonly property real progressToCenter: 1 - Math.min(1, Math.max(0, distanceToCenter / root.width))
|
2023-10-22 19:34:02 +00:00
|
|
|
|
2023-10-23 03:41:44 +00:00
|
|
|
visible: opacity > 0
|
|
|
|
|
opacity: {
|
2024-06-21 04:42:14 +00:00
|
|
|
switch (folio.FolioSettings.pageTransitionEffect) {
|
2023-10-23 03:41:44 +00:00
|
|
|
case Folio.FolioSettings.StackTransition:
|
|
|
|
|
return (positionX < 0) ? progressToCenter :
|
|
|
|
|
((progressToCenter < 0.3) ? 0 : ((1 / 0.7) * (progressToCenter - 0.3)))
|
|
|
|
|
default:
|
|
|
|
|
return progressToCenter;
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-03-19 16:30:43 +00:00
|
|
|
|
2023-10-22 03:59:27 +00:00
|
|
|
// x position of page
|
2023-10-23 03:41:44 +00:00
|
|
|
transform: {
|
2024-06-21 04:42:14 +00:00
|
|
|
switch (folio.FolioSettings.pageTransitionEffect) {
|
2023-10-23 03:41:44 +00:00
|
|
|
case Folio.FolioSettings.SlideTransition:
|
|
|
|
|
return [translate];
|
|
|
|
|
case Folio.FolioSettings.CubeTransition:
|
|
|
|
|
return [translate, cubeTransitionRotation];
|
|
|
|
|
case Folio.FolioSettings.FadeTransition:
|
|
|
|
|
return [];
|
|
|
|
|
case Folio.FolioSettings.StackTransition:
|
|
|
|
|
return [stackScale, stackTranslate];
|
|
|
|
|
case Folio.FolioSettings.RotationTransition:
|
|
|
|
|
return [translate, rotationTransitionRotation];
|
|
|
|
|
default:
|
|
|
|
|
return [translate];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Translate {
|
|
|
|
|
id: translate
|
|
|
|
|
x: homeScreenPage.positionX
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Scale {
|
|
|
|
|
id: stackScale
|
2024-06-21 04:42:14 +00:00
|
|
|
origin.x: folio.HomeScreenState.pageWidth / 2
|
|
|
|
|
origin.y: folio.HomeScreenState.pageHeight / 2
|
2023-10-23 03:41:44 +00:00
|
|
|
xScale: (homeScreenPage.positionX < 0) ? 1 : 0.5 + homeScreenPage.progressToCenter * 0.5
|
|
|
|
|
yScale: (homeScreenPage.positionX < 0) ? 1 : 0.5 + homeScreenPage.progressToCenter * 0.5
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Translate {
|
|
|
|
|
id: stackTranslate
|
|
|
|
|
x: Math.min(0, homeScreenPage.positionX)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Rotation {
|
|
|
|
|
id: cubeTransitionRotation
|
|
|
|
|
origin.x: (positionX < 0) ?
|
2024-06-21 04:42:14 +00:00
|
|
|
(folio.HomeScreenState.pageWidth / 2) * homeScreenPage.progressToCenter :
|
|
|
|
|
(folio.HomeScreenState.pageWidth / 2) + (folio.HomeScreenState.pageWidth / 2) * (1 - homeScreenPage.progressToCenter);
|
2024-07-14 02:36:17 +00:00
|
|
|
origin.y: folio.HomeScreenState.pageHeight / 2;
|
2023-10-23 03:41:44 +00:00
|
|
|
axis { x: 0; y: 1; z: 0 }
|
|
|
|
|
angle: {
|
|
|
|
|
return Math.min(1, Math.max(0, distanceToCenter / root.width)) * 90 * ((positionX > 0) ? 1 : -1)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Rotation {
|
|
|
|
|
id: rotationTransitionRotation
|
|
|
|
|
origin.x: (positionX < 0) ?
|
2024-06-21 04:42:14 +00:00
|
|
|
(folio.HomeScreenState.pageWidth / 2) * homeScreenPage.progressToCenter :
|
|
|
|
|
(folio.HomeScreenState.pageWidth / 2) + (folio.HomeScreenState.pageWidth / 2) * (1 - homeScreenPage.progressToCenter);
|
2023-10-23 03:41:44 +00:00
|
|
|
origin.y: 0
|
|
|
|
|
axis { x: -0.2; y: 0.3; z: 0.5 }
|
|
|
|
|
angle: {
|
|
|
|
|
return Math.min(1, Math.max(0, distanceToCenter / root.width)) * 90 * ((positionX > 0) ? 1 : -1)
|
2023-10-22 19:34:02 +00:00
|
|
|
}
|
2023-10-23 03:41:44 +00:00
|
|
|
}
|
2021-03-24 13:48:56 +00:00
|
|
|
}
|
|
|
|
|
}
|
2021-03-19 16:30:43 +00:00
|
|
|
}
|