diff --git a/Commons/Settings.qml b/Commons/Settings.qml index 771cbf9..ee50968 100644 --- a/Commons/Settings.qml +++ b/Commons/Settings.qml @@ -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) { diff --git a/Modules/Bar/Bar.qml b/Modules/Bar/Bar.qml index 9e3dd4d..d9c7da2 100644 --- a/Modules/Bar/Bar.qml +++ b/Modules/Bar/Bar.qml @@ -12,106 +12,108 @@ 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) - screen: modelData + readonly property real scaling: ScalingService.scale(modelData) - WlrLayershell.namespace: "noctalia-bar" + active: modelData ? (Settings.data.bar.monitors.includes(modelData.name) + || (Settings.data.bar.monitors.length === 0)) : false - implicitHeight: Style.barHeight * scaling - color: Color.transparent + sourceComponent: PanelWindow { + screen: modelData - // 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 + WlrLayershell.namespace: "noctalia-bar" - anchors { - top: Settings.data.bar.position === "top" - bottom: Settings.data.bar.position === "bottom" - left: true - right: true - } + implicitHeight: Style.barHeight * scaling + color: Color.transparent - Item { - anchors.fill: parent - clip: true - - // Background fill - Rectangle { - id: bar + anchors { + top: Settings.data.bar.position === "top" + bottom: Settings.data.bar.position === "bottom" + left: true + right: true + } + Item { anchors.fill: parent - color: Qt.rgba(Color.mSurface.r, Color.mSurface.g, Color.mSurface.b, Settings.data.bar.backgroundOpacity) - layer.enabled: true - } + clip: true - // ------------------------------ - // Left Section - Dynamic Widgets - Row { - id: leftSection + // Background fill + Rectangle { + id: bar - height: parent.height - anchors.left: parent.left - anchors.leftMargin: Style.marginS * scaling - anchors.verticalCenter: parent.verticalCenter - spacing: Style.marginS * scaling + anchors.fill: parent + color: Qt.rgba(Color.mSurface.r, Color.mSurface.g, Color.mSurface.b, Settings.data.bar.backgroundOpacity) + layer.enabled: true + } - Repeater { - model: Settings.data.bar.widgets.left - delegate: NWidgetLoader { - widgetName: modelData - widgetProps: { - "screen": screen + // ------------------------------ + // Left Section - Dynamic Widgets + Row { + id: leftSection + + height: parent.height + anchors.left: parent.left + anchors.leftMargin: Style.marginS * scaling + anchors.verticalCenter: parent.verticalCenter + spacing: Style.marginS * scaling + + Repeater { + model: Settings.data.bar.widgets.left + delegate: NWidgetLoader { + widgetName: modelData + widgetProps: { + "screen": screen + } + anchors.verticalCenter: parent.verticalCenter } - anchors.verticalCenter: parent.verticalCenter } } - } - // ------------------------------ - // Center Section - Dynamic Widgets - Row { - id: centerSection + // ------------------------------ + // Center Section - Dynamic Widgets + Row { + id: centerSection - height: parent.height - anchors.horizontalCenter: parent.horizontalCenter - anchors.verticalCenter: parent.verticalCenter - spacing: Style.marginS * scaling + height: parent.height + anchors.horizontalCenter: parent.horizontalCenter + anchors.verticalCenter: parent.verticalCenter + spacing: Style.marginS * scaling - Repeater { - model: Settings.data.bar.widgets.center - delegate: NWidgetLoader { - widgetName: modelData - widgetProps: { - "screen": screen + Repeater { + model: Settings.data.bar.widgets.center + delegate: NWidgetLoader { + widgetName: modelData + widgetProps: { + "screen": screen + } + anchors.verticalCenter: parent.verticalCenter } - anchors.verticalCenter: parent.verticalCenter } } - } - // ------------------------------ - // Right Section - Dynamic Widgets - Row { - id: rightSection + // ------------------------------ + // Right Section - Dynamic Widgets + Row { + id: rightSection - height: parent.height - anchors.right: bar.right - anchors.rightMargin: Style.marginS * scaling - anchors.verticalCenter: bar.verticalCenter - spacing: Style.marginS * scaling + height: parent.height + anchors.right: bar.right + anchors.rightMargin: Style.marginS * scaling + anchors.verticalCenter: bar.verticalCenter + spacing: Style.marginS * scaling - Repeater { - model: Settings.data.bar.widgets.right - delegate: NWidgetLoader { - widgetName: modelData - widgetProps: { - "screen": screen + Repeater { + model: Settings.data.bar.widgets.right + delegate: NWidgetLoader { + widgetName: modelData + widgetProps: { + "screen": screen + } + anchors.verticalCenter: parent.verticalCenter } - anchors.verticalCenter: parent.verticalCenter } } } diff --git a/Services/CliphistService.qml b/Services/CliphistService.qml index d7f8f0b..88ba140 100644 --- a/Services/CliphistService.qml +++ b/Services/CliphistService.qml @@ -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 diff --git a/Widgets/NWidgetLoader.qml b/Widgets/NWidgetLoader.qml index e0ec294..a9e7ac5 100644 --- a/Widgets/NWidgetLoader.qml +++ b/Widgets/NWidgetLoader.qml @@ -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) } }