Overview: resources optimization

This commit is contained in:
ItsLemmy
2025-11-07 22:22:43 -05:00
parent 385ac20241
commit 5c287996f2
+47 -13
View File
@@ -17,6 +17,7 @@ Loader {
required property ShellScreen modelData
property string wallpaper: ""
property bool overviewIsSeen: false
Component.onCompleted: {
if (modelData) {
@@ -25,6 +26,13 @@ Loader {
setWallpaperInitial()
}
Component.onDestruction: {
// Clean up resources to prevent memory leak when overviewEnabled is toggled off
timerDisableFx.stop()
bgImage.layer.enabled = false
bgImage.source = ""
}
// External state management
Connections {
target: WallpaperService
@@ -35,6 +43,27 @@ Loader {
}
}
Connections {
target: CompositorService.backend
function onOverviewActiveChanged() {
if (CompositorService.backend.overviewActive) {
overviewIsSeen = true
timerDisableFx.stop()
} else {
timerDisableFx.restart()
}
}
}
// Use to disable effects when overview is no longer necessary.
Timer {
id: timerDisableFx
interval: 2000
onTriggered: {
overviewIsSeen = false
}
}
function setWallpaperInitial() {
if (!WallpaperService || !WallpaperService.isInitialized) {
Qt.callLater(setWallpaperInitial)
@@ -64,23 +93,28 @@ Loader {
anchors.fill: parent
fillMode: Image.PreserveAspectCrop
source: wallpaper
smooth: true
smooth: false
mipmap: false
cache: false
asynchronous: true
// Image is heavily blurred, so might as well save a lot of memory here.
sourceSize: Qt.size(1280, 720)
}
visible: overviewIsSeen
MultiEffect {
anchors.fill: parent
source: bgImage
autoPaddingEnabled: false
blurEnabled: true
blur: 1.0
blurMax: 64
colorization: Style.opacityMedium
colorizationColor: Settings.data.colorSchemes.darkMode ? Color.mSurface : Color.mOnSurface
// Image is heavily blurred, so use low resolution to save memory
sourceSize: Qt.size(1280, 720)
layer.enabled: overviewIsSeen
layer.smooth: false
layer.effect: MultiEffect {
blurEnabled: true
blur: 1.0
blurMax: 32
}
Rectangle {
anchors.fill: parent
color: Settings.data.colorSchemes.darkMode ? Color.mSurface : Color.mOnSurface
opacity: 0.8
}
}
}
}