mirror of
https://github.com/zoriya/noctalia-shell.git
synced 2026-06-03 19:01:50 +00:00
Overview: resources optimization
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user