shift-shell/containments/homescreens/folio/package/contents/ui/HomeScreenPages.qml

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

67 lines
2.6 KiB
QML
Raw Normal View History

// SPDX-FileCopyrightText: 2023 Devin Lin <devin@kde.org>
// SPDX-License-Identifier: LGPL-2.0-or-later
2021-03-19 16:30:43 +00:00
import QtQuick
import QtQuick.Window
import QtQuick.Layouts
2021-03-19 16:30:43 +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
MouseArea {
id: root
2021-03-19 16:30:43 +00:00
property var homeScreen
2021-03-19 16:30:43 +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
onPressAndHold: Folio.HomeScreenState.openSettingsView()
2021-03-19 16:30:43 +00:00
Repeater {
model: Folio.PageListModel
delegate: HomeScreenPage {
id: homeScreenPage
pageNum: model.index
pageModel: model.delegate
homeScreen: root.homeScreen
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
// animation so that full opacity is only when the page is in view
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))
opacity: 1 - Math.min(1, Math.max(0, distanceToCenter / root.width))
2021-03-19 16:30:43 +00:00
// x position of page
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);
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-19 16:30:43 +00:00
}