From 517c7c97d4787e78c742490a07254e5da33ca099 Mon Sep 17 00:00:00 2001 From: LemmyCook Date: Sun, 7 Sep 2025 22:23:45 -0400 Subject: [PATCH] Bar Widgets FrontEnd: Simplified access to editable widget settings --- Modules/Bar/Bar.qml | 3 ++ Modules/Bar/Widgets/ActiveWindow.qml | 7 ++- Modules/Bar/Widgets/Battery.qml | 7 +-- Modules/Bar/Widgets/Brightness.qml | 8 +++- Modules/Bar/Widgets/Clock.qml | 15 +++---- Modules/Bar/Widgets/CustomButton.qml | 49 ++++++++++----------- Modules/Bar/Widgets/KeyboardLayout.qml | 3 -- Modules/Bar/Widgets/MediaMini.qml | 40 +++++++++-------- Modules/Bar/Widgets/Microphone.qml | 11 +++-- Modules/Bar/Widgets/NightLight.qml | 1 - Modules/Bar/Widgets/NotificationHistory.qml | 14 +++--- Modules/Bar/Widgets/SidePanelToggle.qml | 13 ++++-- Modules/Bar/Widgets/Spacer.qml | 19 +++----- Modules/Bar/Widgets/SystemMonitor.qml | 25 ++++++----- Modules/Bar/Widgets/Tray.qml | 1 + Modules/Bar/Widgets/Volume.qml | 13 ++++-- Modules/Bar/Widgets/Workspace.qml | 11 +++-- 17 files changed, 135 insertions(+), 105 deletions(-) diff --git a/Modules/Bar/Bar.qml b/Modules/Bar/Bar.qml index 30308e0..dfcb721 100644 --- a/Modules/Bar/Bar.qml +++ b/Modules/Bar/Bar.qml @@ -76,6 +76,7 @@ Variants { widgetProps: { "screen": root.modelData || null, "scaling": ScalingService.getScreenScale(screen), + "widgetId": modelData.id, "barSection": parent.objectName, "sectionWidgetIndex": index, "sectionWidgetsCount": Settings.data.bar.widgets.left.length @@ -103,6 +104,7 @@ Variants { widgetProps: { "screen": root.modelData || null, "scaling": ScalingService.getScreenScale(screen), + "widgetId": modelData.id, "barSection": parent.objectName, "sectionWidgetIndex": index, "sectionWidgetsCount": Settings.data.bar.widgets.center.length @@ -131,6 +133,7 @@ Variants { widgetProps: { "screen": root.modelData || null, "scaling": ScalingService.getScreenScale(screen), + "widgetId": modelData.id, "barSection": parent.objectName, "sectionWidgetIndex": index, "sectionWidgetsCount": Settings.data.bar.widgets.right.length diff --git a/Modules/Bar/Widgets/ActiveWindow.qml b/Modules/Bar/Widgets/ActiveWindow.qml index e817bb1..d2d4578 100644 --- a/Modules/Bar/Widgets/ActiveWindow.qml +++ b/Modules/Bar/Widgets/ActiveWindow.qml @@ -18,10 +18,13 @@ RowLayout { spacing: Style.marginS * scaling visible: getTitle() !== "" + // Widget properties passed from Bar.qml for per-instance settings + property string widgetId: "" property string barSection: "" property int sectionWidgetIndex: -1 property int sectionWidgetsCount: 0 + property var widgetMetadata: BarWidgetRegistry.widgetMetadata[widgetId] property var widgetSettings: { var section = barSection.replace("Section", "").toLowerCase() if (section && sectionWidgetIndex >= 0) { @@ -33,7 +36,7 @@ RowLayout { return {} } - readonly property bool userShowIcon: (widgetSettings.showIcon !== undefined) ? widgetSettings.showIcon : ((Settings.data.bar.showActiveWindowIcon !== undefined) ? Settings.data.bar.showActiveWindowIcon : BarWidgetRegistry.widgetMetadata["ActiveWindow"].showIcon) + readonly property bool showIcon: (widgetSettings.showIcon !== undefined) ? widgetSettings.showIcon : widgetMetadata.showIcon function getTitle() { return CompositorService.focusedWindowTitle !== "(No active window)" ? CompositorService.focusedWindowTitle : "" @@ -91,7 +94,7 @@ RowLayout { Layout.preferredWidth: Style.fontSizeL * scaling * 1.2 Layout.preferredHeight: Style.fontSizeL * scaling * 1.2 Layout.alignment: Qt.AlignVCenter - visible: getTitle() !== "" && userShowIcon + visible: getTitle() !== "" && showIcon IconImage { id: windowIcon diff --git a/Modules/Bar/Widgets/Battery.qml b/Modules/Bar/Widgets/Battery.qml index d27c2cb..060d3e1 100644 --- a/Modules/Bar/Widgets/Battery.qml +++ b/Modules/Bar/Widgets/Battery.qml @@ -13,11 +13,12 @@ Item { property real scaling: 1.0 // Widget properties passed from Bar.qml for per-instance settings + property string widgetId: "" property string barSection: "" property int sectionWidgetIndex: -1 property int sectionWidgetsCount: 0 - // Resolve per-instance widget settings from Settings.data + property var widgetMetadata: BarWidgetRegistry.widgetMetadata[widgetId] property var widgetSettings: { var section = barSection.replace("Section", "").toLowerCase() if (section && sectionWidgetIndex >= 0) { @@ -31,9 +32,9 @@ Item { // Resolve settings: try user settings or defaults from BarWidgetRegistry readonly property bool alwaysShowPercentage: widgetSettings.alwaysShowPercentage - !== undefined ? widgetSettings.alwaysShowPercentage : BarWidgetRegistry.widgetMetadata["Battery"].alwaysShowPercentage + !== undefined ? widgetSettings.alwaysShowPercentage : widgetMetadata.alwaysShowPercentage readonly property real warningThreshold: widgetSettings.warningThreshold - !== undefined ? widgetSettings.warningThreshold : BarWidgetRegistry.widgetMetadata["Battery"].warningThreshold + !== undefined ? widgetSettings.warningThreshold : widgetMetadata.warningThreshold // Test mode readonly property bool testMode: true diff --git a/Modules/Bar/Widgets/Brightness.qml b/Modules/Bar/Widgets/Brightness.qml index aa434a2..30948c3 100644 --- a/Modules/Bar/Widgets/Brightness.qml +++ b/Modules/Bar/Widgets/Brightness.qml @@ -10,10 +10,14 @@ Item { property ShellScreen screen property real scaling: 1.0 + + // Widget properties passed from Bar.qml for per-instance settings + property string widgetId: "" property string barSection: "" - property int sectionWidgetIndex: 0 + property int sectionWidgetIndex: -1 property int sectionWidgetsCount: 0 + property var widgetMetadata: BarWidgetRegistry.widgetMetadata[widgetId] property var widgetSettings: { var section = barSection.replace("Section", "").toLowerCase() if (section && sectionWidgetIndex >= 0) { @@ -26,7 +30,7 @@ Item { } readonly property bool userAlwaysShowPercentage: (widgetSettings.alwaysShowPercentage - !== undefined) ? widgetSettings.alwaysShowPercentage : BarWidgetRegistry.widgetMetadata["Brightness"].alwaysShowPercentage + !== undefined) ? widgetSettings.alwaysShowPercentage : widgetMetadata.alwaysShowPercentage // Used to avoid opening the pill on Quickshell startup property bool firstBrightnessReceived: false diff --git a/Modules/Bar/Widgets/Clock.qml b/Modules/Bar/Widgets/Clock.qml index 3067e7c..3b472d9 100644 --- a/Modules/Bar/Widgets/Clock.qml +++ b/Modules/Bar/Widgets/Clock.qml @@ -11,11 +11,12 @@ Rectangle { property real scaling: 1.0 // Widget properties passed from Bar.qml for per-instance settings + property string widgetId: "" property string barSection: "" property int sectionWidgetIndex: -1 property int sectionWidgetsCount: 0 - // Resolve per-instance widget settings from Settings.data + property var widgetMetadata: BarWidgetRegistry.widgetMetadata[widgetId] property var widgetSettings: { var section = barSection.replace("Section", "").toLowerCase() if (section && sectionWidgetIndex >= 0) { @@ -28,13 +29,11 @@ Rectangle { } // Resolve settings: try user settings or defaults from BarWidgetRegistry - readonly property bool showDate: widgetSettings.showDate - !== undefined ? widgetSettings.showDate : BarWidgetRegistry.widgetMetadata["Clock"].showDate - readonly property bool use12h: widgetSettings.use12HourClock - !== undefined ? widgetSettings.use12HourClock : BarWidgetRegistry.widgetMetadata["Clock"].use12HourClock - readonly property bool showSeconds: widgetSettings.showSeconds - !== undefined ? widgetSettings.showSeconds : BarWidgetRegistry.widgetMetadata["Clock"].showSeconds - readonly property bool reverseDayMonth: widgetSettings.reverseDayMonth !== undefined ? widgetSettings.reverseDayMonth : BarWidgetRegistry.widgetMetadata["Clock"].reverseDayMonth + readonly property bool showDate: widgetSettings.showDate !== undefined ? widgetSettings.showDate : widgetMetadata.showDate + readonly property bool use12h: widgetSettings.use12HourClock !== undefined ? widgetSettings.use12HourClock : widgetMetadata.use12HourClock + readonly property bool showSeconds: widgetSettings.showSeconds !== undefined ? widgetSettings.showSeconds : widgetMetadata.showSeconds + readonly property bool reverseDayMonth: widgetSettings.reverseDayMonth + !== undefined ? widgetSettings.reverseDayMonth : widgetMetadata.reverseDayMonth implicitWidth: clock.width + Style.marginM * 2 * scaling implicitHeight: Math.round(Style.capsuleHeight * scaling) diff --git a/Modules/Bar/Widgets/CustomButton.qml b/Modules/Bar/Widgets/CustomButton.qml index de8f96d..08d3dc8 100644 --- a/Modules/Bar/Widgets/CustomButton.qml +++ b/Modules/Bar/Widgets/CustomButton.qml @@ -13,11 +13,13 @@ NIconButton { property var screen property real scaling: 1.0 + // Widget properties passed from Bar.qml for per-instance settings + property string widgetId: "" property string barSection: "" property int sectionWidgetIndex: -1 property int sectionWidgetsCount: 0 - // Get user settings from Settings data + property var widgetMetadata: BarWidgetRegistry.widgetMetadata[widgetId] property var widgetSettings: { var section = barSection.replace("Section", "").toLowerCase() if (section && sectionWidgetIndex >= 0) { @@ -30,30 +32,27 @@ NIconButton { } // Use settings or defaults from BarWidgetRegistry - readonly property string userIcon: widgetSettings.icon || BarWidgetRegistry.widgetMetadata["CustomButton"].icon - readonly property string userLeftClickExec: widgetSettings.leftClickExec - || BarWidgetRegistry.widgetMetadata["CustomButton"].leftClickExec - readonly property string userRightClickExec: widgetSettings.rightClickExec - || BarWidgetRegistry.widgetMetadata["CustomButton"].rightClickExec - readonly property string userMiddleClickExec: widgetSettings.middleClickExec - || BarWidgetRegistry.widgetMetadata["CustomButton"].middleClickExec - readonly property bool hasExec: (userLeftClickExec || userRightClickExec || userMiddleClickExec) + readonly property string customIcon: widgetSettings.icon || widgetMetadata.icon + readonly property string leftClickExec: widgetSettings.leftClickExec || widgetMetadata.leftClickExec + readonly property string rightClickExec: widgetSettings.rightClickExec || widgetMetadata.rightClickExec + readonly property string middleClickExec: widgetSettings.middleClickExec || widgetMetadata.middleClickExec + readonly property bool hasExec: (leftClickExec || rightClickExec || middleClickExec) sizeRatio: 0.8 - icon: userIcon + icon: customIcon tooltipText: { if (!hasExec) { return "Custom Button - Configure in settings" } else { var lines = [] - if (userLeftClickExec !== "") { - lines.push(`Left click: ${userLeftClickExec}.`) + if (leftClickExec !== "") { + lines.push(`Left click: ${leftClickExec}.`) } - if (userRightClickExec !== "") { - lines.push(`Right click: ${userRightClickExec}.`) + if (rightClickExec !== "") { + lines.push(`Right click: ${rightClickExec}.`) } - if (userMiddleClickExec !== "") { - lines.push(`Middle click: ${userMiddleClickExec}.`) + if (middleClickExec !== "") { + lines.push(`Middle click: ${middleClickExec}.`) } return lines.join("
") } @@ -61,9 +60,9 @@ NIconButton { opacity: hasExec ? Style.opacityFull : Style.opacityMedium onClicked: { - if (userLeftClickExec) { - Quickshell.execDetached(["sh", "-c", userLeftClickExec]) - Logger.log("CustomButton", `Executing command: ${userLeftClickExec}`) + if (leftClickExec) { + Quickshell.execDetached(["sh", "-c", leftClickExec]) + Logger.log("CustomButton", `Executing command: ${leftClickExec}`) } else if (!hasExec) { // No script was defined, open settings var settingsPanel = PanelService.getPanel("settingsPanel") @@ -73,16 +72,16 @@ NIconButton { } onRightClicked: { - if (userRightClickExec) { - Quickshell.execDetached(["sh", "-c", userRightClickExec]) - Logger.log("CustomButton", `Executing command: ${userRightClickExec}`) + if (rightClickExec) { + Quickshell.execDetached(["sh", "-c", rightClickExec]) + Logger.log("CustomButton", `Executing command: ${rightClickExec}`) } } onMiddleClicked: { - if (userMiddleClickExec) { - Quickshell.execDetached(["sh", "-c", userMiddleClickExec]) - Logger.log("CustomButton", `Executing command: ${userMiddleClickExec}`) + if (middleClickExec) { + Quickshell.execDetached(["sh", "-c", middleClickExec]) + Logger.log("CustomButton", `Executing command: ${middleClickExec}`) } } } diff --git a/Modules/Bar/Widgets/KeyboardLayout.qml b/Modules/Bar/Widgets/KeyboardLayout.qml index b9b44a5..7de3a6d 100644 --- a/Modules/Bar/Widgets/KeyboardLayout.qml +++ b/Modules/Bar/Widgets/KeyboardLayout.qml @@ -12,9 +12,6 @@ Item { property ShellScreen screen property real scaling: 1.0 - property string barSection: "" - property int sectionWidgetIndex: 0 - property int sectionWidgetsCount: 0 // Use the shared service for keyboard layout property string currentLayout: KeyboardLayoutService.currentLayout diff --git a/Modules/Bar/Widgets/MediaMini.qml b/Modules/Bar/Widgets/MediaMini.qml index ba5fd5c..141698a 100644 --- a/Modules/Bar/Widgets/MediaMini.qml +++ b/Modules/Bar/Widgets/MediaMini.qml @@ -12,18 +12,14 @@ RowLayout { property ShellScreen screen property real scaling: 1.0 - readonly property real minWidth: 160 - readonly property real maxWidth: 400 - - Layout.alignment: Qt.AlignVCenter - spacing: Style.marginS * scaling - visible: MediaService.currentPlayer !== null && MediaService.canPlay - Layout.preferredWidth: MediaService.currentPlayer !== null && MediaService.canPlay ? implicitWidth : 0 + // Widget properties passed from Bar.qml for per-instance settings + property string widgetId: "" property string barSection: "" property int sectionWidgetIndex: -1 property int sectionWidgetsCount: 0 + property var widgetMetadata: BarWidgetRegistry.widgetMetadata[widgetId] property var widgetSettings: { var section = barSection.replace("Section", "").toLowerCase() if (section && sectionWidgetIndex >= 0) { @@ -35,17 +31,25 @@ RowLayout { return {} } - readonly property bool userShowAlbumArt: (widgetSettings.showAlbumArt !== undefined) ? widgetSettings.showAlbumArt : ((Settings.data.audio.showMiniplayerAlbumArt !== undefined) ? Settings.data.audio.showMiniplayerAlbumArt : BarWidgetRegistry.widgetMetadata["MediaMini"].showAlbumArt) - readonly property bool userShowVisualizer: (widgetSettings.showVisualizer !== undefined) ? widgetSettings.showVisualizer : ((Settings.data.audio.showMiniplayerCava !== undefined) ? Settings.data.audio.showMiniplayerCava : BarWidgetRegistry.widgetMetadata["MediaMini"].showVisualizer) - readonly property string userVisualizerType: (widgetSettings.visualizerType !== undefined - && widgetSettings.visualizerType - !== "") ? widgetSettings.visualizerType : ((Settings.data.audio.visualizerType !== undefined - && Settings.data.audio.visualizerType !== "") ? Settings.data.audio.visualizerType : BarWidgetRegistry.widgetMetadata["MediaMini"].visualizerType) + readonly property bool showAlbumArt: (widgetSettings.showAlbumArt + !== undefined) ? widgetSettings.showAlbumArt : widgetMetadata.showAlbumArt + readonly property bool showVisualizer: (widgetSettings.showVisualizer + !== undefined) ? widgetSettings.showVisualizer : widgetMetadata.showVisualizer + readonly property string visualizerType: (widgetSettings.visualizerType !== undefined && widgetSettings.visualizerType + !== "") ? widgetSettings.visualizerType : widgetMetadata.visualizerType + + readonly property real minWidth: 160 + readonly property real maxWidth: 400 function getTitle() { return MediaService.trackTitle + (MediaService.trackArtist !== "" ? ` - ${MediaService.trackArtist}` : "") } + Layout.alignment: Qt.AlignVCenter + spacing: Style.marginS * scaling + visible: MediaService.currentPlayer !== null && MediaService.canPlay + Layout.preferredWidth: MediaService.currentPlayer !== null && MediaService.canPlay ? implicitWidth : 0 + // A hidden text element to safely measure the full title width NText { id: fullTitleMetrics @@ -80,7 +84,7 @@ RowLayout { Loader { anchors.verticalCenter: parent.verticalCenter anchors.horizontalCenter: parent.horizontalCenter - active: userShowVisualizer && userVisualizerType == "linear" && MediaService.isPlaying + active: showVisualizer && visualizerType == "linear" && MediaService.isPlaying z: 0 sourceComponent: LinearSpectrum { @@ -95,7 +99,7 @@ RowLayout { Loader { anchors.verticalCenter: parent.verticalCenter anchors.horizontalCenter: parent.horizontalCenter - active: userShowVisualizer && userVisualizerType == "mirrored" && MediaService.isPlaying + active: showVisualizer && visualizerType == "mirrored" && MediaService.isPlaying z: 0 sourceComponent: MirroredSpectrum { @@ -110,7 +114,7 @@ RowLayout { Loader { anchors.verticalCenter: parent.verticalCenter anchors.horizontalCenter: parent.horizontalCenter - active: userShowVisualizer && userVisualizerType == "wave" && MediaService.isPlaying + active: showVisualizer && visualizerType == "wave" && MediaService.isPlaying z: 0 sourceComponent: WaveSpectrum { @@ -134,12 +138,12 @@ RowLayout { font.pointSize: Style.fontSizeL * scaling verticalAlignment: Text.AlignVCenter Layout.alignment: Qt.AlignVCenter - visible: !userShowAlbumArt && getTitle() !== "" && !trackArt.visible + visible: !showAlbumArt && getTitle() !== "" && !trackArt.visible } ColumnLayout { Layout.alignment: Qt.AlignVCenter - visible: userShowAlbumArt + visible: showAlbumArt spacing: 0 Item { diff --git a/Modules/Bar/Widgets/Microphone.qml b/Modules/Bar/Widgets/Microphone.qml index 2b983a4..15f4437 100644 --- a/Modules/Bar/Widgets/Microphone.qml +++ b/Modules/Bar/Widgets/Microphone.qml @@ -12,10 +12,14 @@ Item { property ShellScreen screen property real scaling: 1.0 + + // Widget properties passed from Bar.qml for per-instance settings + property string widgetId: "" property string barSection: "" - property int sectionWidgetIndex: 0 + property int sectionWidgetIndex: -1 property int sectionWidgetsCount: 0 + property var widgetMetadata: BarWidgetRegistry.widgetMetadata[widgetId] property var widgetSettings: { var section = barSection.replace("Section", "").toLowerCase() if (section && sectionWidgetIndex >= 0) { @@ -27,7 +31,8 @@ Item { return {} } - readonly property bool userAlwaysShowPercentage: widgetSettings?.alwaysShowPercentage + readonly property bool alwaysShowPercentage: (widgetSettings.alwaysShowPercentage + !== undefined) ? widgetSettings.alwaysShowPercentage : widgetMetadata.alwaysShowPercentage // Used to avoid opening the pill on Quickshell startup property bool firstInputVolumeReceived: false @@ -91,7 +96,7 @@ Item { collapsedIconColor: Color.mOnSurface autoHide: false // Important to be false so we can hover as long as we want text: Math.floor(AudioService.inputVolume * 100) + "%" - forceOpen: userAlwaysShowPercentage + forceOpen: alwaysShowPercentage tooltipText: "Microphone: " + Math.round(AudioService.inputVolume * 100) + "%\nLeft click for advanced settings.\nScroll up/down to change volume.\nRight click to toggle mute." diff --git a/Modules/Bar/Widgets/NightLight.qml b/Modules/Bar/Widgets/NightLight.qml index 6ea2e20..90c8540 100644 --- a/Modules/Bar/Widgets/NightLight.qml +++ b/Modules/Bar/Widgets/NightLight.qml @@ -14,7 +14,6 @@ NIconButton { property real scaling: 1.0 sizeRatio: 0.8 - colorBg: Color.mSurfaceVariant colorFg: Color.mOnSurface colorBorder: Color.transparent diff --git a/Modules/Bar/Widgets/NotificationHistory.qml b/Modules/Bar/Widgets/NotificationHistory.qml index b79e63c..31657f1 100644 --- a/Modules/Bar/Widgets/NotificationHistory.qml +++ b/Modules/Bar/Widgets/NotificationHistory.qml @@ -13,10 +13,13 @@ NIconButton { property ShellScreen screen property real scaling: 1.0 + // Widget properties passed from Bar.qml for per-instance settings + property string widgetId: "" property string barSection: "" property int sectionWidgetIndex: -1 property int sectionWidgetsCount: 0 + property var widgetMetadata: BarWidgetRegistry.widgetMetadata[widgetId] property var widgetSettings: { var section = barSection.replace("Section", "").toLowerCase() if (section && sectionWidgetIndex >= 0) { @@ -27,9 +30,10 @@ NIconButton { } return {} } - - readonly property bool userShowUnreadBadge: (widgetSettings.showUnreadBadge !== undefined) ? widgetSettings.showUnreadBadge : BarWidgetRegistry.widgetMetadata["NotificationHistory"].showUnreadBadge - readonly property bool userHideWhenZero: (widgetSettings.hideWhenZero !== undefined) ? widgetSettings.hideWhenZero : BarWidgetRegistry.widgetMetadata["NotificationHistory"].hideWhenZero + readonly property bool showUnreadBadge: (widgetSettings.showUnreadBadge + !== undefined) ? widgetSettings.showUnreadBadge : widgetMetadata.showUnreadBadge + readonly property bool hideWhenZero: (widgetSettings.hideWhenZero + !== undefined) ? widgetSettings.hideWhenZero : widgetMetadata.hideWhenZero function lastSeenTs() { return Settings.data.notifications?.lastSeenTs || 0 @@ -70,7 +74,7 @@ NIconButton { anchors.rightMargin: -4 * scaling anchors.topMargin: -4 * scaling z: 2 - active: userShowUnreadBadge && (!userHideWhenZero || computeUnreadCount() > 0) + active: showUnreadBadge && (!hideWhenZero || computeUnreadCount() > 0) sourceComponent: Rectangle { id: badge readonly property int count: computeUnreadCount() @@ -82,7 +86,7 @@ NIconButton { color: Color.mError border.color: Color.mSurface border.width: 1 - visible: count > 0 || !userHideWhenZero + visible: count > 0 || !hideWhenZero NText { id: textNode anchors.centerIn: parent diff --git a/Modules/Bar/Widgets/SidePanelToggle.qml b/Modules/Bar/Widgets/SidePanelToggle.qml index 7c6b4f3..14a8c6f 100644 --- a/Modules/Bar/Widgets/SidePanelToggle.qml +++ b/Modules/Bar/Widgets/SidePanelToggle.qml @@ -11,10 +11,14 @@ NIconButton { property ShellScreen screen property real scaling: 1.0 + + // Widget properties passed from Bar.qml for per-instance settings + property string widgetId: "" property string barSection: "" property int sectionWidgetIndex: -1 property int sectionWidgetsCount: 0 + property var widgetMetadata: BarWidgetRegistry.widgetMetadata[widgetId] property var widgetSettings: { var section = barSection.replace("Section", "").toLowerCase() if (section && sectionWidgetIndex >= 0) { @@ -26,9 +30,10 @@ NIconButton { return {} } - readonly property bool userUseDistroLogo: (widgetSettings.useDistroLogo !== undefined) ? widgetSettings.useDistroLogo : ((Settings.data.bar.useDistroLogo !== undefined) ? Settings.data.bar.useDistroLogo : BarWidgetRegistry.widgetMetadata["SidePanelToggle"].useDistroLogo) + readonly property bool useDistroLogo: (widgetSettings.useDistroLogo + !== undefined) ? widgetSettings.useDistroLogo : widgetMetadata.useDistroLogo - icon: userUseDistroLogo ? "" : "widgets" + icon: useDistroLogo ? "" : "widgets" tooltipText: "Open side panel." sizeRatio: 0.8 @@ -46,8 +51,8 @@ NIconButton { anchors.centerIn: parent width: root.width * 0.6 height: width - source: userUseDistroLogo ? DistroLogoService.osLogo : "" - visible: userUseDistroLogo && source !== "" + source: useDistroLogo ? DistroLogoService.osLogo : "" + visible: useDistroLogo && source !== "" smooth: true } diff --git a/Modules/Bar/Widgets/Spacer.qml b/Modules/Bar/Widgets/Spacer.qml index 5a62372..dc2651c 100644 --- a/Modules/Bar/Widgets/Spacer.qml +++ b/Modules/Bar/Widgets/Spacer.qml @@ -12,11 +12,13 @@ Item { property var screen property real scaling: 1.0 + // Widget properties passed from Bar.qml for per-instance settings + property string widgetId: "" property string barSection: "" property int sectionWidgetIndex: -1 property int sectionWidgetsCount: 0 - // Get user settings from Settings data - make it reactive + property var widgetMetadata: BarWidgetRegistry.widgetMetadata[widgetId] property var widgetSettings: { var section = barSection.replace("Section", "").toLowerCase() if (section && sectionWidgetIndex >= 0) { @@ -29,19 +31,10 @@ Item { } // Use settings or defaults from BarWidgetRegistry - readonly property int userWidth: { - var section = barSection.replace("Section", "").toLowerCase() - if (section && sectionWidgetIndex >= 0) { - var widgets = Settings.data.bar.widgets[section] - if (widgets && sectionWidgetIndex < widgets.length) { - return widgets[sectionWidgetIndex].width || BarWidgetRegistry.widgetMetadata["Spacer"].width - } - } - return BarWidgetRegistry.widgetMetadata["Spacer"].width - } + readonly property int spacerWidth: widgetSettings.width !== undefined ? widgetSettings.width : widgetMetadata.width // Set the width based on user settings - implicitWidth: userWidth * scaling + implicitWidth: spacerWidth * scaling implicitHeight: Style.barHeight * scaling width: implicitWidth height: implicitHeight @@ -51,6 +44,6 @@ Item { anchors.fill: parent color: Qt.rgba(1, 0, 0, 0.1) // Very subtle red tint visible: Settings.data.general.debugMode || false - radius: 2 * scaling + radius: Style.radiusXXS * scaling } } diff --git a/Modules/Bar/Widgets/SystemMonitor.qml b/Modules/Bar/Widgets/SystemMonitor.qml index 49dceef..e9c4ad2 100644 --- a/Modules/Bar/Widgets/SystemMonitor.qml +++ b/Modules/Bar/Widgets/SystemMonitor.qml @@ -11,10 +11,13 @@ RowLayout { property ShellScreen screen property real scaling: 1.0 + // Widget properties passed from Bar.qml for per-instance settings + property string widgetId: "" property string barSection: "" property int sectionWidgetIndex: -1 property int sectionWidgetsCount: 0 + property var widgetMetadata: BarWidgetRegistry.widgetMetadata[widgetId] property var widgetSettings: { var section = barSection.replace("Section", "").toLowerCase() if (section && sectionWidgetIndex >= 0) { @@ -26,11 +29,13 @@ RowLayout { return {} } - readonly property bool userShowCpuUsage: (widgetSettings.showCpuUsage !== undefined) ? widgetSettings.showCpuUsage : BarWidgetRegistry.widgetMetadata["SystemMonitor"].showCpuUsage - readonly property bool userShowCpuTemp: (widgetSettings.showCpuTemp !== undefined) ? widgetSettings.showCpuTemp : BarWidgetRegistry.widgetMetadata["SystemMonitor"].showCpuTemp - readonly property bool userShowMemoryUsage: (widgetSettings.showMemoryUsage !== undefined) ? widgetSettings.showMemoryUsage : BarWidgetRegistry.widgetMetadata["SystemMonitor"].showMemoryUsage - readonly property bool userShowNetworkStats: (widgetSettings.showNetworkStats - !== undefined) ? widgetSettings.showNetworkStats : ((Settings.data.bar.showNetworkStats !== undefined) ? Settings.data.bar.showNetworkStats : BarWidgetRegistry.widgetMetadata["SystemMonitor"].showNetworkStats) + readonly property bool showCpuUsage: (widgetSettings.showCpuUsage + !== undefined) ? widgetSettings.showCpuUsage : widgetMetadata.showCpuUsage + readonly property bool showCpuTemp: (widgetSettings.showCpuTemp !== undefined) ? widgetSettings.showCpuTemp : widgetMetadata.showCpuTemp + readonly property bool showMemoryUsage: (widgetSettings.showMemoryUsage + !== undefined) ? widgetSettings.showMemoryUsage : widgetMetadata.showMemoryUsage + readonly property bool showNetworkStats: (widgetSettings.showNetworkStats + !== undefined) ? widgetSettings.showNetworkStats : widgetMetadata.showNetworkStats Layout.alignment: Qt.AlignVCenter spacing: Style.marginS * scaling @@ -55,7 +60,7 @@ RowLayout { id: cpuUsageLayout spacing: Style.marginXS * scaling Layout.alignment: Qt.AlignVCenter - visible: userShowCpuUsage + visible: showCpuUsage NIcon { id: cpuUsageIcon @@ -81,7 +86,7 @@ RowLayout { // spacing is thin here to compensate for the vertical thermometer icon spacing: Style.marginXXS * scaling Layout.alignment: Qt.AlignVCenter - visible: userShowCpuTemp + visible: showCpuTemp NIcon { text: "thermometer" @@ -104,7 +109,7 @@ RowLayout { id: memoryUsageLayout spacing: Style.marginXS * scaling Layout.alignment: Qt.AlignVCenter - visible: userShowMemoryUsage + visible: showMemoryUsage NIcon { text: "memory" @@ -127,7 +132,7 @@ RowLayout { id: networkDownloadLayout spacing: Style.marginXS * scaling Layout.alignment: Qt.AlignVCenter - visible: userShowNetworkStats + visible: showNetworkStats NIcon { text: "download" @@ -150,7 +155,7 @@ RowLayout { id: networkUploadLayout spacing: Style.marginXS * scaling Layout.alignment: Qt.AlignVCenter - visible: userShowNetworkStats + visible: showNetworkStats NIcon { text: "upload" diff --git a/Modules/Bar/Widgets/Tray.qml b/Modules/Bar/Widgets/Tray.qml index 06de40f..5c1b090 100644 --- a/Modules/Bar/Widgets/Tray.qml +++ b/Modules/Bar/Widgets/Tray.qml @@ -15,6 +15,7 @@ Rectangle { property ShellScreen screen property real scaling: 1.0 + readonly property real itemSize: 24 * scaling function onLoaded() { diff --git a/Modules/Bar/Widgets/Volume.qml b/Modules/Bar/Widgets/Volume.qml index 21035f8..80e79db 100644 --- a/Modules/Bar/Widgets/Volume.qml +++ b/Modules/Bar/Widgets/Volume.qml @@ -12,10 +12,14 @@ Item { property ShellScreen screen property real scaling: 1.0 + + // Widget properties passed from Bar.qml for per-instance settings + property string widgetId: "" property string barSection: "" - property int sectionWidgetIndex: 0 + property int sectionWidgetIndex: -1 property int sectionWidgetsCount: 0 + property var widgetMetadata: BarWidgetRegistry.widgetMetadata[widgetId] property var widgetSettings: { var section = barSection.replace("Section", "").toLowerCase() if (section && sectionWidgetIndex >= 0) { @@ -26,8 +30,9 @@ Item { } return {} } - readonly property bool userAlwaysShowPercentage: (widgetSettings.alwaysShowPercentage - !== undefined) ? widgetSettings.alwaysShowPercentage : ((Settings.data.bar.alwaysShowBatteryPercentage !== undefined) ? Settings.data.bar.alwaysShowBatteryPercentage : BarWidgetRegistry.widgetMetadata["Volume"].alwaysShowPercentage) + + readonly property bool alwaysShowPercentage: (widgetSettings.alwaysShowPercentage + !== undefined) ? widgetSettings.alwaysShowPercentage : widgetMetadata.alwaysShowPercentage // Used to avoid opening the pill on Quickshell startup property bool firstVolumeReceived: false @@ -76,7 +81,7 @@ Item { collapsedIconColor: Color.mOnSurface autoHide: false // Important to be false so we can hover as long as we want text: Math.floor(AudioService.volume * 100) + "%" - forceOpen: userAlwaysShowPercentage + forceOpen: alwaysShowPercentage tooltipText: "Volume: " + Math.round(AudioService.volume * 100) + "%\nLeft click for advanced settings.\nScroll up/down to change volume.\nRight click to toggle mute." diff --git a/Modules/Bar/Widgets/Workspace.qml b/Modules/Bar/Widgets/Workspace.qml index a9e8c1d..1a629dc 100644 --- a/Modules/Bar/Widgets/Workspace.qml +++ b/Modules/Bar/Widgets/Workspace.qml @@ -14,10 +14,13 @@ Item { property ShellScreen screen property real scaling: 1.0 + // Widget properties passed from Bar.qml for per-instance settings + property string widgetId: "" property string barSection: "" property int sectionWidgetIndex: -1 property int sectionWidgetsCount: 0 + property var widgetMetadata: BarWidgetRegistry.widgetMetadata[widgetId] property var widgetSettings: { var section = barSection.replace("Section", "").toLowerCase() if (section && sectionWidgetIndex >= 0) { @@ -29,7 +32,7 @@ Item { return {} } - readonly property string userLabelMode: (widgetSettings.labelMode !== undefined) ? widgetSettings.labelMode : ((Settings.data.bar.showWorkspaceLabel !== undefined) ? Settings.data.bar.showWorkspaceLabel : BarWidgetRegistry.widgetMetadata["Workspace"].labelMode) + readonly property string labelMode: (widgetSettings.labelMode !== undefined) ? widgetSettings.labelMode : widgetMetadata.labelMode property bool isDestroying: false property bool hovered: false @@ -162,7 +165,7 @@ Item { model: localWorkspaces Item { id: workspacePillContainer - height: (userLabelMode !== "none") ? Math.round(18 * scaling) : Math.round(14 * scaling) + height: (labelMode !== "none") ? Math.round(18 * scaling) : Math.round(14 * scaling) width: root.calculatedWsWidth(model) Rectangle { @@ -170,13 +173,13 @@ Item { anchors.fill: parent Loader { - active: (userLabelMode !== "none") + active: (labelMode !== "none") sourceComponent: Component { Text { x: (pill.width - width) / 2 y: (pill.height - height) / 2 + (height - contentHeight) / 2 text: { - if (userLabelMode === "name" && model.name && model.name.length > 0) { + if (labelMode === "name" && model.name && model.name.length > 0) { return model.name.substring(0, 2) } else { return model.idx.toString()