Optimizations memory/cpu
- Only load bar widgets once the settings are done loading, and the widget is actually in use. - Only load bar on screens that request it, instead of hiding it.
This commit is contained in:
parent
38efdc8f36
commit
9fb4aff635
4 changed files with 86 additions and 83 deletions
|
|
@ -28,8 +28,7 @@ Singleton {
|
|||
// Used to access via Settings.data.xxx.yyy
|
||||
property alias data: adapter
|
||||
|
||||
// Flag to prevent unnecessary wallpaper calls during reloads
|
||||
property bool isInitialLoad: true
|
||||
property bool isLoaded: false
|
||||
|
||||
// Function to validate monitor configurations
|
||||
function validateMonitorConfigurations() {
|
||||
|
|
@ -91,9 +90,10 @@ Singleton {
|
|||
}
|
||||
onLoaded: function () {
|
||||
Qt.callLater(function () {
|
||||
if (isInitialLoad) {
|
||||
Logger.log("Settings", "OnLoaded")
|
||||
// Only set wallpaper on initial load, not on reloads
|
||||
// Some stuff like wallpaper setup and settings validation should just be executed once on startup
|
||||
// And not on every reload
|
||||
if (!isLoaded) {
|
||||
Logger.log("Settings", "JSON completed loading")
|
||||
if (adapter.wallpaper.current !== "") {
|
||||
Logger.log("Settings", "Set current wallpaper", adapter.wallpaper.current)
|
||||
WallpaperService.setCurrentWallpaper(adapter.wallpaper.current, true)
|
||||
|
|
@ -102,9 +102,9 @@ Singleton {
|
|||
// Validate monitor configurations, only once
|
||||
// if none of the configured monitors exist, clear the lists
|
||||
validateMonitorConfigurations()
|
||||
}
|
||||
|
||||
isInitialLoad = false
|
||||
isLoaded = true
|
||||
}
|
||||
})
|
||||
}
|
||||
onLoadFailed: function (error) {
|
||||
|
|
|
|||
|
|
@ -12,11 +12,16 @@ import qs.Modules.Notification
|
|||
Variants {
|
||||
model: Quickshell.screens
|
||||
|
||||
delegate: PanelWindow {
|
||||
delegate: Loader {
|
||||
id: root
|
||||
|
||||
required property ShellScreen modelData
|
||||
readonly property real scaling: ScalingService.scale(screen)
|
||||
readonly property real scaling: ScalingService.scale(modelData)
|
||||
|
||||
active: modelData ? (Settings.data.bar.monitors.includes(modelData.name)
|
||||
|| (Settings.data.bar.monitors.length === 0)) : false
|
||||
|
||||
sourceComponent: PanelWindow {
|
||||
screen: modelData
|
||||
|
||||
WlrLayershell.namespace: "noctalia-bar"
|
||||
|
|
@ -24,10 +29,6 @@ Variants {
|
|||
implicitHeight: Style.barHeight * scaling
|
||||
color: Color.transparent
|
||||
|
||||
// If no bar activated in settings, then show them all
|
||||
visible: modelData ? (Settings.data.bar.monitors.includes(modelData.name)
|
||||
|| (Settings.data.bar.monitors.length === 0)) : false
|
||||
|
||||
anchors {
|
||||
top: Settings.data.bar.position === "top"
|
||||
bottom: Settings.data.bar.position === "bottom"
|
||||
|
|
@ -118,3 +119,4 @@ Variants {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ Singleton {
|
|||
property var items: [] // [{id, preview, mime, isImage}]
|
||||
property bool loading: false
|
||||
// Active only when feature is enabled and settings have finished initial load
|
||||
property bool active: Settings.data.appLauncher.enableClipboardHistory && !Settings.isInitialLoad
|
||||
property bool active: Settings.data.appLauncher.enableClipboardHistory && Settings.isLoaded
|
||||
|
||||
// Optional automatic watchers to feed cliphist DB
|
||||
property bool autoWatch: true
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ Item {
|
|||
id: loader
|
||||
|
||||
anchors.fill: parent
|
||||
active: enabled && widgetName !== ""
|
||||
active: Settings.isLoaded && enabled && widgetName !== ""
|
||||
sourceComponent: {
|
||||
if (!active) {
|
||||
return null
|
||||
|
|
@ -35,6 +35,7 @@ Item {
|
|||
}
|
||||
}
|
||||
}
|
||||
Logger.log("NWidgetLoader", "Loaded", widgetName, "on screen", item.screen.name)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue