From 9ed92310709095daa4236d96420d5bfb1126dbd3 Mon Sep 17 00:00:00 2001 From: ItsLemmy Date: Mon, 29 Sep 2025 09:11:37 -0400 Subject: [PATCH] Init Sequence: removed a bunch of no longer necessary Settings.isLoaded --- Modules/Background/Background.qml | 37 ++++++++++---------------- Modules/Background/Overview.qml | 2 +- Modules/Bar/Bar.qml | 2 +- Modules/Bar/Extras/BarWidgetLoader.qml | 2 +- Modules/Dock/Dock.qml | 6 ++--- Modules/Notification/Notification.qml | 6 ++--- Modules/OSD/OSD.qml | 4 +-- Modules/Toast/ToastOverlay.qml | 2 +- Modules/Toast/ToastScreen.qml | 2 +- Services/ClipboardService.qml | 2 +- Services/MatugenService.qml | 7 +---- Services/WallpaperService.qml | 6 ++++- 12 files changed, 34 insertions(+), 44 deletions(-) diff --git a/Modules/Background/Background.qml b/Modules/Background/Background.qml index fefdcc6a..a83aed58 100644 --- a/Modules/Background/Background.qml +++ b/Modules/Background/Background.qml @@ -13,7 +13,7 @@ Variants { required property ShellScreen modelData - active: Settings.isLoaded && modelData && Settings.data.wallpaper.enabled + active: modelData && Settings.data.wallpaper.enabled sourceComponent: PanelWindow { id: root @@ -41,29 +41,10 @@ Variants { property string futureWallpaper: "" // Fillmode default is "crop" - property real fillMode: 1.0 + property real fillMode: WallpaperService.getFillModeUniform() property vector4d fillColor: Qt.vector4d(Settings.data.wallpaper.fillColor.r, Settings.data.wallpaper.fillColor.g, Settings.data.wallpaper.fillColor.b, 1.0) - // On startup, defer assigning wallpaper until the service cache is ready - function _startWallpaperOnceReady() { - if (!modelData) { - Qt.callLater(_startWallpaperOnceReady) - return - } - - var cacheReady = WallpaperService && WallpaperService.currentWallpapers && Object.keys(WallpaperService.currentWallpapers).length > 0 - if (!cacheReady) { - // Try again on the next tick until WallpaperService.init() populates cache - Qt.callLater(_startWallpaperOnceReady) - return - } - - fillMode = WallpaperService.getFillModeUniform() - var path = WallpaperService.getWallpaper(modelData.name) - setWallpaperImmediate(path) - } - - Component.onCompleted: _startWallpaperOnceReady() + Component.onCompleted: setWallpaperInitial() Connections { target: Settings.data.wallpaper @@ -254,6 +235,16 @@ Variants { }) } } + + function setWallpaperInitial() { + // On startup, defer assigning wallpaper until the service cache is ready, retries every tick + if (!WallpaperService || !WallpaperService.isInitialized) { + Qt.callLater(setWallpaperInitial) + return + } + + setWallpaperImmediate(WallpaperService.getWallpaper(modelData.name)) + } function setWallpaperImmediate(source) { transitionAnimation.stop() @@ -324,4 +315,4 @@ Variants { } } } -} +} \ No newline at end of file diff --git a/Modules/Background/Overview.qml b/Modules/Background/Overview.qml index 0828be9a..7aa67240 100644 --- a/Modules/Background/Overview.qml +++ b/Modules/Background/Overview.qml @@ -12,7 +12,7 @@ Variants { delegate: Loader { required property ShellScreen modelData - active: Settings.isLoaded && CompositorService.isNiri && modelData && Settings.data.wallpaper.enabled + active: CompositorService.isNiri && modelData && Settings.data.wallpaper.enabled property string wallpaper: "" diff --git a/Modules/Bar/Bar.qml b/Modules/Bar/Bar.qml index d6d4e356..f1140d8e 100644 --- a/Modules/Bar/Bar.qml +++ b/Modules/Bar/Bar.qml @@ -28,7 +28,7 @@ Variants { } } - active: Settings.isLoaded && BarService.isVisible && modelData && modelData.name ? (Settings.data.bar.monitors.includes(modelData.name) || (Settings.data.bar.monitors.length === 0)) : false + active: BarService.isVisible && modelData && modelData.name ? (Settings.data.bar.monitors.includes(modelData.name) || (Settings.data.bar.monitors.length === 0)) : false sourceComponent: PanelWindow { screen: modelData || null diff --git a/Modules/Bar/Extras/BarWidgetLoader.qml b/Modules/Bar/Extras/BarWidgetLoader.qml index 3aa5911f..358a42ef 100644 --- a/Modules/Bar/Extras/BarWidgetLoader.qml +++ b/Modules/Bar/Extras/BarWidgetLoader.qml @@ -29,7 +29,7 @@ Item { id: loader anchors.fill: parent - active: Settings.isLoaded && widgetId !== "" + active: widgetId !== "" sourceComponent: { if (!active) { return null diff --git a/Modules/Dock/Dock.qml b/Modules/Dock/Dock.qml index f6fab110..ca3e6ae7 100644 --- a/Modules/Dock/Dock.qml +++ b/Modules/Dock/Dock.qml @@ -55,7 +55,7 @@ Variants { // Initial update when component is ready Component.onCompleted: { - if (Settings.isLoaded && ToplevelManager) { + if (ToplevelManager) { updateDockApps() } } @@ -198,7 +198,7 @@ Variants { // PEEK WINDOW - Always visible when auto-hide is enabled Loader { - active: Settings.isLoaded && barIsReady && modelData && Settings.data.dock.monitors.includes(modelData.name) && autoHide + active: barIsReady && modelData && Settings.data.dock.monitors.includes(modelData.name) && autoHide sourceComponent: PanelWindow { id: peekWindow @@ -244,7 +244,7 @@ Variants { // DOCK WINDOW Loader { - active: Settings.isLoaded && barIsReady && modelData && Settings.data.dock.monitors.includes(modelData.name) && dockLoaded && ToplevelManager && (dockApps.length > 0) + active: barIsReady && modelData && Settings.data.dock.monitors.includes(modelData.name) && dockLoaded && ToplevelManager && (dockApps.length > 0) sourceComponent: PanelWindow { id: dockWindow diff --git a/Modules/Notification/Notification.qml b/Modules/Notification/Notification.qml index 3bb1383c..bb868bd6 100644 --- a/Modules/Notification/Notification.qml +++ b/Modules/Notification/Notification.qml @@ -22,7 +22,7 @@ Variants { property ListModel notificationModel: NotificationService.activeList // If no notification display activated in settings, then show them all - active: Settings.isLoaded && modelData && (Settings.data.notifications.monitors.includes(modelData.name) || (Settings.data.notifications.monitors.length === 0)) + active: modelData && (Settings.data.notifications.monitors.includes(modelData.name) || (Settings.data.notifications.monitors.length === 0)) Connections { target: ScalingService @@ -37,11 +37,11 @@ Variants { screen: modelData WlrLayershell.namespace: "noctalia-notifications" - WlrLayershell.layer: (Settings.isLoaded && Settings.data && Settings.data.notifications && Settings.data.notifications.alwaysOnTop) ? WlrLayer.Overlay : WlrLayer.Top + WlrLayershell.layer: (Settings.data.notifications && Settings.data.notifications.alwaysOnTop) ? WlrLayer.Overlay : WlrLayer.Top color: Color.transparent - readonly property string location: (Settings.isLoaded && Settings.data && Settings.data.notifications && Settings.data.notifications.location) ? Settings.data.notifications.location : "top_right" + readonly property string location: (Settings.data.notifications && Settings.data.notifications.location) ? Settings.data.notifications.location : "top_right" readonly property bool isTop: (location === "top") || (location.length >= 3 && location.substring(0, 3) === "top") readonly property bool isBottom: (location === "bottom") || (location.length >= 6 && location.substring(0, 6) === "bottom") readonly property bool isLeft: location.indexOf("_left") >= 0 diff --git a/Modules/OSD/OSD.qml b/Modules/OSD/OSD.qml index 07b028e5..e518cf89 100644 --- a/Modules/OSD/OSD.qml +++ b/Modules/OSD/OSD.qml @@ -22,7 +22,7 @@ Variants { property ListModel notificationModel: NotificationService.activeList // If no notification display activated in settings, then show them all - property bool canShowOnThisScreen: Settings.isLoaded && modelData && (Settings.data.osd.monitors.includes(modelData.name) || (Settings.data.osd.monitors.length === 0)) + property bool canShowOnThisScreen: modelData && (Settings.data.osd.monitors.includes(modelData.name) || (Settings.data.osd.monitors.length === 0)) // Loader is only active when actually showing something active: false @@ -104,7 +104,7 @@ Variants { id: panel screen: modelData - readonly property string location: (Settings.isLoaded && Settings.data && Settings.data.osd && Settings.data.osd.location) ? Settings.data.osd.location : "top_right" + readonly property string location: (Settings.data.osd && Settings.data.osd.location) ? Settings.data.osd.location : "top_right" readonly property bool isTop: (location === "top") || (location.length >= 3 && location.substring(0, 3) === "top") readonly property bool isBottom: (location === "bottom") || (location.length >= 6 && location.substring(0, 6) === "bottom") readonly property bool isLeft: (location.indexOf("_left") >= 0) || (location === "left") diff --git a/Modules/Toast/ToastOverlay.qml b/Modules/Toast/ToastOverlay.qml index 78cb670a..11cb5037 100644 --- a/Modules/Toast/ToastOverlay.qml +++ b/Modules/Toast/ToastOverlay.qml @@ -16,6 +16,6 @@ Variants { scaling: ScalingService.getScreenScale(modelData) // Only activate on enabled screens - active: Settings.isLoaded && modelData && (Settings.data.notifications.monitors.includes(modelData.name) || Settings.data.notifications.monitors.length === 0) + active: modelData && (Settings.data.notifications.monitors.includes(modelData.name) || Settings.data.notifications.monitors.length === 0) } } diff --git a/Modules/Toast/ToastScreen.qml b/Modules/Toast/ToastScreen.qml index 6a635aea..ca35c68c 100644 --- a/Modules/Toast/ToastScreen.qml +++ b/Modules/Toast/ToastScreen.qml @@ -128,7 +128,7 @@ Item { screen: root.screen - readonly property string location: (Settings.isLoaded && Settings.data && Settings.data.notifications && Settings.data.notifications.location) ? Settings.data.notifications.location : "top_right" + readonly property string location: (Settings.data.notifications && Settings.data.notifications.location) ? Settings.data.notifications.location : "top_right" readonly property bool isTop: (location === "top") || (location.length >= 3 && location.substring(0, 3) === "top") readonly property bool isBottom: (location === "bottom") || (location.length >= 6 && location.substring(0, 6) === "bottom") readonly property bool isLeft: location.indexOf("_left") >= 0 diff --git a/Services/ClipboardService.qml b/Services/ClipboardService.qml index 65287ea4..bb224a28 100644 --- a/Services/ClipboardService.qml +++ b/Services/ClipboardService.qml @@ -10,7 +10,7 @@ Singleton { id: root // Public API - property bool active: Settings.isLoaded && Settings.data.appLauncher.enableClipboardHistory && cliphistAvailable + property bool active: Settings.data.appLauncher.enableClipboardHistory && cliphistAvailable property bool loading: false property var items: [] // [{id, preview, mime, isImage}] diff --git a/Services/MatugenService.qml b/Services/MatugenService.qml index e3410d57..694bb1e7 100644 --- a/Services/MatugenService.qml +++ b/Services/MatugenService.qml @@ -10,7 +10,7 @@ import qs.Services Singleton { id: root - property string dynamicConfigPath: Settings.isLoaded ? Settings.cacheDir + "matugen.dynamic.toml" : "" + property string dynamicConfigPath: Settings.cacheDir + "matugen.dynamic.toml" // External state management Connections { @@ -47,11 +47,6 @@ Singleton { // Generate colors using current wallpaper and settings function generateFromWallpaper() { - if (!Settings.isLoaded) { - Logger.log("Matugen", "Settings not loaded yet, skipping wallpaper color generation") - return - } - Logger.log("Matugen", "Generating from wallpaper on screen:", Screen.name) var wp = WallpaperService.getWallpaper(Screen.name).replace(/'/g, "'\\''") if (wp === "") { diff --git a/Services/WallpaperService.qml b/Services/WallpaperService.qml index 37181a64..8b01f76c 100644 --- a/Services/WallpaperService.qml +++ b/Services/WallpaperService.qml @@ -26,6 +26,8 @@ Singleton { // Cache for current wallpapers - can be updated directly since we use signals for notifications property var currentWallpapers: ({}) + property bool isInitialized: false + // Signals for reactive UI updates signal wallpaperChanged(string screenName, string path) // Emitted when a wallpaper changes @@ -75,6 +77,8 @@ Singleton { function init() { Logger.log("Wallpaper", "Service started") + translateModels() + // Rebuild cache from persisted settings var monitors = Settings.data.wallpaper.monitors || [] currentWallpapers = ({}) @@ -86,7 +90,7 @@ Singleton { } } - translateModels() + isInitialized = true } // -------------------------------------------------