From 61abcddeebd6969b375bd63decde98300ed2eecf Mon Sep 17 00:00:00 2001 From: quadbyte Date: Sun, 10 Aug 2025 11:59:54 -0400 Subject: [PATCH] qmlformat + fix build --- Modules/Background/Background.qml | 61 +++++++------ Modules/Background/Overview.qml | 88 +++++++++---------- .../{ScreenCorner.qml => ScreenCorners.qml} | 64 +++++++------- Modules/Bar/Bars.qml | 10 +++ Services/Settings.qml | 3 +- Services/Time.qml | 6 +- Services/Wallpapers.qml | 3 +- Widgets/NPanel.qml | 20 +++-- shell.qml | 15 +--- 9 files changed, 140 insertions(+), 130 deletions(-) rename Modules/Background/{ScreenCorner.qml => ScreenCorners.qml} (65%) diff --git a/Modules/Background/Background.qml b/Modules/Background/Background.qml index 25c4236..f81f79b 100644 --- a/Modules/Background/Background.qml +++ b/Modules/Background/Background.qml @@ -4,40 +4,39 @@ import Quickshell.Wayland import qs.Services Variants { - model: Quickshell.screens + model: Quickshell.screens - PanelWindow { - required property ShellScreen modelData - property string wallpaperSource: Qt.resolvedUrl("../../Assets/Tests/wallpaper.png") + PanelWindow { + required property ShellScreen modelData + property string wallpaperSource: Qt.resolvedUrl( + "../../Assets/Tests/wallpaper.png") - visible: wallpaperSource !== "" - color: "transparent" - screen: modelData - WlrLayershell.layer: WlrLayer.Background - WlrLayershell.exclusionMode: ExclusionMode.Ignore - WlrLayershell.namespace: "quickshell-wallpaper" - - anchors { - bottom: true - top: true - right: true - left: true - } - - margins { - top: 0 - } - - Image { - anchors.fill: parent - fillMode: Image.PreserveAspectCrop - source: wallpaperSource - visible: wallpaperSource !== "" - cache: true - smooth: true - mipmap: false - } + visible: wallpaperSource !== "" + color: "transparent" + screen: modelData + WlrLayershell.layer: WlrLayer.Background + WlrLayershell.exclusionMode: ExclusionMode.Ignore + WlrLayershell.namespace: "quickshell-wallpaper" + anchors { + bottom: true + top: true + right: true + left: true } + margins { + top: 0 + } + + Image { + anchors.fill: parent + fillMode: Image.PreserveAspectCrop + source: wallpaperSource + visible: wallpaperSource !== "" + cache: true + smooth: true + mipmap: false + } + } } diff --git a/Modules/Background/Overview.qml b/Modules/Background/Overview.qml index 454ba18..2d9cea8 100644 --- a/Modules/Background/Overview.qml +++ b/Modules/Background/Overview.qml @@ -5,53 +5,53 @@ import Quickshell.Wayland import qs.Services Variants { - model: Quickshell.screens + model: Quickshell.screens - PanelWindow { - required property ShellScreen modelData - property string wallpaperSource: Qt.resolvedUrl("../../Assets/Tests/wallpaper.png") + PanelWindow { + required property ShellScreen modelData + property string wallpaperSource: Qt.resolvedUrl( + "../../Assets/Tests/wallpaper.png") - visible: wallpaperSource !== "" - color: "transparent" - screen: modelData - WlrLayershell.layer: WlrLayer.Background - WlrLayershell.exclusionMode: ExclusionMode.Ignore - WlrLayershell.namespace: "quickshell-overview" - - anchors { - top: true - bottom: true - right: true - left: true - } - - Image { - id: bgImage - - anchors.fill: parent - fillMode: Image.PreserveAspectCrop - source: wallpaperSource - cache: true - smooth: true - mipmap: false - visible: wallpaperSource !== "" - } - - MultiEffect { - id: overviewBgBlur - - anchors.fill: parent - source: bgImage - blurEnabled: true - blur: 0.48 - blurMax: 128 - } - - Rectangle { - anchors.fill: parent - color: Qt.rgba(Colors.backgroundPrimary.r, Colors.backgroundPrimary.g, Colors.backgroundPrimary.b, 0.5) - } + visible: wallpaperSource !== "" + color: "transparent" + screen: modelData + WlrLayershell.layer: WlrLayer.Background + WlrLayershell.exclusionMode: ExclusionMode.Ignore + WlrLayershell.namespace: "quickshell-overview" + anchors { + top: true + bottom: true + right: true + left: true } + Image { + id: bgImage + + anchors.fill: parent + fillMode: Image.PreserveAspectCrop + source: wallpaperSource + cache: true + smooth: true + mipmap: false + visible: wallpaperSource !== "" + } + + MultiEffect { + id: overviewBgBlur + + anchors.fill: parent + source: bgImage + blurEnabled: true + blur: 0.48 + blurMax: 128 + } + + Rectangle { + anchors.fill: parent + color: Qt.rgba(Colors.backgroundPrimary.r, Colors.backgroundPrimary.g, + Colors.backgroundPrimary.b, 0.5) + } + } } diff --git a/Modules/Background/ScreenCorner.qml b/Modules/Background/ScreenCorners.qml similarity index 65% rename from Modules/Background/ScreenCorner.qml rename to Modules/Background/ScreenCorners.qml index 46b9595..4167b46 100644 --- a/Modules/Background/ScreenCorner.qml +++ b/Modules/Background/ScreenCorners.qml @@ -66,37 +66,38 @@ NLoader { anchors.fill: parent antialiasing: true renderTarget: Canvas.FramebufferObject - onPaint: function() { - const ctx = getContext("2d"); - ctx.reset(); - ctx.clearRect(0, 0, width, height); + onPaint: function () { + const ctx = getContext("2d") + ctx.reset() + ctx.clearRect(0, 0, width, height) // Solid white base (alpha=1) - ctx.globalCompositeOperation = "source-over"; - ctx.fillStyle = "#ffffffff"; - ctx.fillRect(0, 0, width, height); + ctx.globalCompositeOperation = "source-over" + ctx.fillStyle = "#ffffffff" + ctx.fillRect(0, 0, width, height) // Punch hole using destination-out with rounded rect path - const x = Math.round(root.borderWidth / 2); - const y = Math.round(root.borderWidth / 2); - const w = Math.max(0, width - root.borderWidth); - const h = Math.max(0, height - root.borderWidth); - const r = Math.max(0, Math.min(root.innerRadius, Math.min(w, h) / 2)); + const x = Math.round(root.borderWidth / 2) + const y = Math.round(root.borderWidth / 2) + const w = Math.max(0, width - root.borderWidth) + const h = Math.max(0, height - root.borderWidth) + const r = Math.max(0, Math.min(root.innerRadius, + Math.min(w, h) / 2)) - ctx.globalCompositeOperation = "destination-out"; - ctx.fillStyle = "#ffffffff"; - ctx.beginPath(); + ctx.globalCompositeOperation = "destination-out" + ctx.fillStyle = "#ffffffff" + ctx.beginPath() // rounded rectangle path using arcTo - ctx.moveTo(x + r, y); - ctx.lineTo(x + w - r, y); - ctx.arcTo(x + w, y, x + w, y + r, r); - ctx.lineTo(x + w, y + h - r); - ctx.arcTo(x + w, y + h, x + w - r, y + h, r); - ctx.lineTo(x + r, y + h); - ctx.arcTo(x, y + h, x, y + h - r, r); - ctx.lineTo(x, y + r); - ctx.arcTo(x, y, x + r, y, r); - ctx.closePath(); - ctx.fill(); + ctx.moveTo(x + r, y) + ctx.lineTo(x + w - r, y) + ctx.arcTo(x + w, y, x + w, y + r, r) + ctx.lineTo(x + w, y + h - r) + ctx.arcTo(x + w, y + h, x + w - r, y + h, r) + ctx.lineTo(x + r, y + h) + ctx.arcTo(x, y + h, x, y + h - r, r) + ctx.lineTo(x, y + r) + ctx.arcTo(x, y, x + r, y, r) + ctx.closePath() + ctx.fill() } onWidthChanged: requestPaint() onHeightChanged: requestPaint() @@ -105,9 +106,13 @@ NLoader { // Repaint mask when properties change Connections { target: root - function onBorderWidthChanged() { maskSource.requestPaint() } - function onRingColorChanged() { /* no-op for mask */ } - function onInnerRadiusChanged() { maskSource.requestPaint() } + function onBorderWidthChanged() { + maskSource.requestPaint() + } + function onRingColorChanged() {/* no-op for mask */ } + function onInnerRadiusChanged() { + maskSource.requestPaint() + } } // Texture for maskSource; hides the original @@ -133,4 +138,3 @@ NLoader { } } } - diff --git a/Modules/Bar/Bars.qml b/Modules/Bar/Bars.qml index e69de29..0b549e4 100644 --- a/Modules/Bar/Bars.qml +++ b/Modules/Bar/Bars.qml @@ -0,0 +1,10 @@ +import Quickshell +import qs.Modules.Bar + +Variants { + model: Quickshell.screens + + delegate: Bar { + modelData: item + } +} diff --git a/Services/Settings.qml b/Services/Settings.qml index 5b4869a..feb44b5 100644 --- a/Services/Settings.qml +++ b/Services/Settings.qml @@ -15,7 +15,7 @@ Singleton { property string colorsFile: Quickshell.env("NOCTALIA_COLORS_FILE") || (settingsDir + "colors.json") property var data: settingAdapter - + // Needed to only have one NPanel loaded at a time. property var openPanel: null @@ -32,7 +32,6 @@ Singleton { // Qt.callLater(function () { // WallpaperManager.setCurrentWallpaper(settings.currentWallpaper, true); // }) - id: settingFileView path: settingsFile diff --git a/Services/Time.qml b/Services/Time.qml index c9838b8..27718ef 100644 --- a/Services/Time.qml +++ b/Services/Time.qml @@ -9,9 +9,9 @@ Singleton { property var date: new Date() property string time: Settings.data.location.use12HourClock ? Qt.formatDateTime( - date, - "h:mm AP") : Qt.formatDateTime( - date, "HH:mm") + date, + "h:mm AP") : Qt.formatDateTime( + date, "HH:mm") property string dateString: { let now = date let dayName = now.toLocaleDateString(Qt.locale(), "ddd") diff --git a/Services/Wallpapers.qml b/Services/Wallpapers.qml index 2540a7a..545c083 100644 --- a/Services/Wallpapers.qml +++ b/Services/Wallpapers.qml @@ -69,8 +69,7 @@ Singleton { if (Settings.data.wallpaper.isRandom && !randomWallpaperTimer.running) { randomWallpaperTimer.start() setRandomWallpaper() - } else if (!Settings.data.randomWallpaper - && randomWallpaperTimer.running) { + } else if (!Settings.data.randomWallpaper && randomWallpaperTimer.running) { randomWallpaperTimer.stop() } } diff --git a/Widgets/NPanel.qml b/Widgets/NPanel.qml index c4b7a4b..7fc42ab 100644 --- a/Widgets/NPanel.qml +++ b/Widgets/NPanel.qml @@ -20,11 +20,13 @@ PanelWindow { function show() { // Ensure only one panel is visible at a time using Settings as ephemeral store try { - if (Settings.openPanel && Settings.openPanel !== outerPanel && Settings.openPanel.hide) { + if (Settings.openPanel && Settings.openPanel !== outerPanel + && Settings.openPanel.hide) { Settings.openPanel.hide() } Settings.openPanel = outerPanel } catch (e) { + // ignore } visible = true @@ -56,13 +58,19 @@ PanelWindow { Component.onDestruction: { try { - if (visible && Settings.openPanel === outerPanel) Settings.openPanel = null - } catch (e) {} + if (visible && Settings.openPanel === outerPanel) + Settings.openPanel = null + } catch (e) { + + } } - onVisibleChanged: function() { + onVisibleChanged: function () { try { - if (!visible && Settings.openPanel === outerPanel) Settings.openPanel = null - } catch (e) {} + if (!visible && Settings.openPanel === outerPanel) + Settings.openPanel = null + } catch (e) { + + } } } diff --git a/shell.qml b/shell.qml index 4f3eed4..4230c8c 100644 --- a/shell.qml +++ b/shell.qml @@ -1,6 +1,6 @@ + // Disable reload popup //@ pragma Env QS_NO_RELOAD_POPUP=1 - import QtQuick import Quickshell import Quickshell.Io @@ -15,19 +15,10 @@ import qs.Services ShellRoot { id: root - - Variants { - model: Quickshell.screens - - delegate: Bar { - modelData: item - } - } - Background {} Overview {} - - ScreenCorner {} + ScreenCorners {} + Bars {} DemoPanel { id: demoPanel