shift-shell/containments/homescreens/halcyon/package/contents/ui/FavoritesView.qml
Micah Stanley d4eaf693c6 Folio/Halcyon: Expand Background Blur Effect using a MaskLayer
This merge request expands upon the folio and halcyon background blur effects, making the folio background blur include the backgrounds of folder icons, the favorites bar, and wallpaper selector, and for halcyon, it now includes the folder icons, app library, search, and wallpaper selector. To accomplish this, a mask layer plugin was created to easily attach to these elements. This way, we can use a `OpacityMask` to cut out from the existing blur layer, thus hopefully keeping the performance cost low. And with my limited testing, it does at least seems to run about the same on my oneplus 6t, though it is not really a low end device, so I can not fairly judge the impact for something slower (eg. PinePhone). To be on the safe side, a third option was also added to the folio settings, allowing for the ability to toggle back to the old functionality if needed.

![Screenshot_20250613_135521](/uploads/d5aa81d6589b61fbba675e4a6e621b55/Screenshot_20250613_135521.png)
![Screenshot_20250613_135536](/uploads/bd726459a131f736e2711ced3fe90d4f/Screenshot_20250613_135536.png)
![Screenshot_20250613_135505](/uploads/c603627b4e65d4b956a1e0b6463d28f3/Screenshot_20250613_135505.png)
![Screenshot_20250627_093729](/uploads/e5f1ad672361c2b9bae23e57905336eb/Screenshot_20250627_093729.png)
2025-06-27 14:27:30 -04:00

209 lines
5.7 KiB
QML

// SPDX-FileCopyrightText: 2022 Devin Lin <devin@kde.org>
// SPDX-License-Identifier: LGPL-2.0-or-later
import QtQuick 2.12
import QtQuick.Controls 2.15 as QQC2
import QtQuick.Layouts 1.1
import QtQml.Models 2.15
import org.kde.plasma.components 3.0 as PC3
import org.kde.draganddrop 2.0 as DragDrop
import org.kde.kirigami 2.19 as Kirigami
import org.kde.plasma.private.mobileshell as MobileShell
import org.kde.plasma.private.mobileshell.shellsettingsplugin as ShellSettings
Item {
id: root
layer.enabled: true
property MobileShell.MaskManager maskManager
required property bool interactive
required property var searchWidget
readonly property real twoColumnThreshold: Kirigami.Units.gridUnit * 16
readonly property bool twoColumn: root.width / 2 > twoColumnThreshold
readonly property real cellWidth: twoColumn ? (root.width - leftMargin - rightMargin) / 2 : (root.width - leftMargin - rightMargin)
readonly property real cellHeight: delegateHeight
readonly property real leftMargin: Math.round(width * 0.1)
readonly property real rightMargin: Math.round(width * 0.1)
readonly property real delegateHeight: Math.round(Kirigami.Units.gridUnit * 3)
property bool folderShown: false
signal openConfigureRequested()
signal pageForwardRequested();
Connections {
target: parent
function onFocusRequested() {
favoritesGrid.forceActiveFocus();
}
}
function goToBeginning() {
goToBeginningAnim.restart();
}
function closeFolder() {
folderShown = false;
closeFolderAnim.restart()
}
function openFolder() {
folderShown = true;
openFolderAnim.restart()
}
function resetHighlight() {
favoritesGrid.currentIndex = -1;
}
FavoritesGrid {
id: favoritesGrid
property real openFolderProgress: 0
anchors.fill: parent
maskManager: root.maskManager
interactive: root.interactive
searchWidget: root.searchWidget
cellWidth: root.cellWidth
cellHeight: root.cellHeight
leftMargin: root.leftMargin
rightMargin: root.rightMargin
twoColumn: root.twoColumn
onOpenConfigureRequested: root.openConfigureRequested()
onRequestOpenFolder: (folder) => {
folderGrid.folder = folder;
root.openFolder();
}
property real translateX: openFolderProgress * -Kirigami.Units.gridUnit
transform: Translate { x: favoritesGrid.translateX }
opacity: 1 - openFolderProgress
visible: opacity !== 0
rightEdgeCallback: () => {
pageForwardRequested();
}
}
FolderGrid {
id: folderGrid
property real openProgress: 0
anchors.fill: parent
folder: null
interactive: root.interactive
cellWidth: root.cellWidth
cellHeight: root.cellHeight
leftMargin: root.leftMargin
rightMargin: root.rightMargin
twoColumn: root.twoColumn
onOpenConfigureRequested: root.openConfigureRequested()
onCloseRequested: root.closeFolder()
property real translateX: (1 - openProgress) * Kirigami.Units.gridUnit
transform: Translate { x: folderGrid.translateX }
opacity: openProgress
visible: opacity !== 0
}
// handle horizontal dragging in a folder
DragHandler {
id: dragHandler
target: folderGrid
enabled: folderGrid.visible
yAxis.enabled: false
xAxis.enabled: true
grabPermissions: PointerHandler.TakeOverForbidden
property real oldTranslationX
property bool isClosing: false
// when dragged
onTranslationChanged: {
let moveAmount = Math.max(0, translation.x) / (Kirigami.Units.gridUnit * 5);
folderGrid.openProgress = 1 - Math.min(1, Math.max(0, moveAmount));
isClosing = translation.x > oldTranslationX;
oldTranslationX = translation.x;
}
// when drag is let go
onActiveChanged: {
if (!active) {
isClosing ? closeFolder() : openFolder();
}
}
}
NumberAnimation {
id: goToBeginningAnim
target: favoritesGrid
properties: 'contentY'
to: favoritesGrid.originY
duration: 200
easing.type: Easing.InOutQuad
}
SequentialAnimation {
id: openFolderAnim
ParallelAnimation {
NumberAnimation {
target: favoritesGrid
properties: 'openFolderProgress'
duration: ShellSettings.Settings.animationsEnabled ? 200 : 0
to: 1
easing.type: Easing.InOutQuad
}
}
ParallelAnimation {
NumberAnimation {
target: folderGrid
properties: 'openProgress'
duration: ShellSettings.Settings.animationsEnabled ? 200 : 0
to: 1
easing.type: Easing.InOutQuad
}
}
}
SequentialAnimation {
id: closeFolderAnim
ParallelAnimation {
NumberAnimation {
target: folderGrid
properties: 'openProgress'
duration: ShellSettings.Settings.animationsEnabled ? 200 : 0
to: 0
easing.type: Easing.InOutQuad
}
}
ParallelAnimation {
NumberAnimation {
target: favoritesGrid
properties: 'openFolderProgress'
duration: ShellSettings.Settings.animationsEnabled ? 200 : 0
to: 0
easing.type: Easing.InOutQuad
}
}
}
}