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
|
|
|
|
|
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
|
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
|
|
|
|
2023-10-22 03:59:27 +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
|
|
|
|
2023-10-22 03:59:27 +00:00
|
|
|
onPressAndHold: Folio.HomeScreenState.openSettingsView()
|
2021-03-19 16:30:43 +00:00
|
|
|
|
2023-10-22 03:59:27 +00:00
|
|
|
Repeater {
|
|
|
|
|
model: Folio.PageListModel
|
2021-03-26 16:21:30 +00:00
|
|
|
|
2023-10-22 03:59:27 +00:00
|
|
|
delegate: HomeScreenPage {
|
|
|
|
|
id: homeScreenPage
|
|
|
|
|
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
|
2023-10-22 19:34:02 +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
|
|
|
|
|
|
|
|
opacity: 1 - Math.min(1, Math.max(0, distanceToCenter / root.width))
|
2021-03-19 16:30:43 +00:00
|
|
|
|
2023-10-22 03:59:27 +00:00
|
|
|
// x position of page
|
2023-10-22 19:34:02 +00:00
|
|
|
transform: [
|
|
|
|
|
Translate {
|
|
|
|
|
x: homeScreenPage.positionX
|
|
|
|
|
},
|
|
|
|
|
Rotation {
|
2023-10-23 02:47:16 +00:00
|
|
|
origin.x: (positionX < 0) ?
|
|
|
|
|
(Folio.HomeScreenState.pageWidth / 2) * homeScreenPage.progressToCenter :
|
|
|
|
|
(Folio.HomeScreenState.pageWidth / 2) + (Folio.HomeScreenState.pageWidth / 2) * (1 - homeScreenPage.progressToCenter);
|
2023-10-22 19:34:02 +00:00
|
|
|
origin.y: Folio.HomeScreenState.pageHeight / 2;
|
|
|
|
|
axis { x: 0; y: 1; z: 0 }
|
|
|
|
|
angle: {
|
|
|
|
|
if (Folio.FolioSettings.pageTransitionEffect !== Folio.FolioSettings.CubeTransition) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Math.min(1, Math.max(0, distanceToCenter / root.width)) * 90 * ((positionX > 0) ? 1 : -1)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
]
|
2021-03-24 13:48:56 +00:00
|
|
|
}
|
|
|
|
|
}
|
2021-03-19 16:30:43 +00:00
|
|
|
}
|