From 5a1231a17e73a26208e8d12b3b5652a36ab080ec Mon Sep 17 00:00:00 2001 From: LemmyCook Date: Sun, 7 Sep 2025 22:55:28 -0400 Subject: [PATCH] Settings: completed migration of old settings on startup --- Commons/Settings.qml | 54 +++++++++++---- Modules/Bar/Widgets/ActiveWindow.qml | 11 ++-- .../Bar/WidgetSettings/ClockSettings.qml | 2 +- Services/BarWidgetRegistry.qml | 66 +++++++++---------- 4 files changed, 83 insertions(+), 50 deletions(-) diff --git a/Commons/Settings.qml b/Commons/Settings.qml index 24e83d4..9c2268f 100644 --- a/Commons/Settings.qml +++ b/Commons/Settings.qml @@ -109,23 +109,53 @@ Singleton { continue } - _migrateWidget(widget) + migrateWidget(widget) Logger.log("Settings", JSON.stringify(widget)) } } } // ----------------------------------------------------- - function _migrateWidget(widget) { + function migrateWidget(widget) { Logger.log("Settings", `Migrating '${widget.id}' widget`) switch (widget.id) { + case "ActiveWindow": + widget.showIcon = adapter.bar.showActiveWindowIcon + break + case "Battery": + widget.alwaysShowPercentage = adapter.bar.alwaysShowBatteryPercentage + break + case "Brightness": + widget.alwaysShowPercentage = BarWidgetRegistry.widgetMetadata[widget.id].alwaysShowPercentage + break case "Clock": widget.showDate = adapter.location.showDateWithClock widget.use12HourClock = adapter.location.use12HourClock widget.reverseDayMonth = adapter.location.reverseDayMonth widget.showSeconds = BarWidgetRegistry.widgetMetadata[widget.id].showSeconds break + case "MediaMini": + widget.showAlbumArt = adapter.audio.showMiniplayerAlbumArt + widget.showVisualizer = adapter.audio.showMiniplayerCava + widget.visualizerType = BarWidgetRegistry.widgetMetadata[widget.id].visualizerType + break + case "NotificationHistory": + widget.showUnreadBadge = BarWidgetRegistry.widgetMetadata[widget.id].showUnreadBadge + widget.hideWhenZero = BarWidgetRegistry.widgetMetadata[widget.id].hideWhenZero + break + case "SidePanelToggle": + widget.useDistroLogo = adapter.bar.useDistroLogo + break + case "SystemMonitor": + widget.showNetworkStats = adapter.bar.showNetworkStats + break + case "Volume": + widget.alwaysShowPercentage = BarWidgetRegistry.widgetMetadata[widget.id].alwaysShowPercentage + break + case "Workspace": + widget.labelMode = adapter.bar.showWorkspaceLabel + break } } // ----------------------------------------------------- @@ -204,13 +234,14 @@ Singleton { // bar property JsonObject bar: JsonObject { property string position: "top" // "top" or "bottom" + property real backgroundOpacity: 1.0 + property list monitors: [] + property bool showActiveWindowIcon: true // TODO: delete property bool alwaysShowBatteryPercentage: false // TODO: delete property bool showNetworkStats: false // TODO: delete - property real backgroundOpacity: 1.0 property bool useDistroLogo: false // TODO: delete property string showWorkspaceLabel: "none" // TODO: delete - property list monitors: [] // Widget configuration for modular bar system property JsonObject widgets @@ -265,6 +296,7 @@ Singleton { property JsonObject location: JsonObject { property string name: defaultLocation property bool useFahrenheit: false + property bool reverseDayMonth: false // TODO: delete property bool use12HourClock: false // TODO: delete property bool showDateWithClock: false // TODO: delete @@ -334,21 +366,21 @@ Singleton { // audio property JsonObject audio: JsonObject { - property bool showMiniplayerAlbumArt: false // TODO: delete - property bool showMiniplayerCava: false // TODO: delete - property string visualizerType: "linear" property int volumeStep: 5 property int cavaFrameRate: 60 - // MPRIS controls + property string visualizerType: "linear" property list mprisBlacklist: [] property string preferredPlayer: "" + + property bool showMiniplayerAlbumArt: false // TODO: delete + property bool showMiniplayerCava: false // TODO: delete } // ui property JsonObject ui: JsonObject { - property string fontDefault: "Roboto" // Default font for all text - property string fontFixed: "DejaVu Sans Mono" // Fixed width font for terminal - property string fontBillboard: "Inter" // Large bold font for clocks and prominent displays + property string fontDefault: "Roboto" + property string fontFixed: "DejaVu Sans Mono" + property string fontBillboard: "Inter" property list monitorsScaling: [] property bool idleInhibitorEnabled: false } diff --git a/Modules/Bar/Widgets/ActiveWindow.qml b/Modules/Bar/Widgets/ActiveWindow.qml index d2d4578..8fb5961 100644 --- a/Modules/Bar/Widgets/ActiveWindow.qml +++ b/Modules/Bar/Widgets/ActiveWindow.qml @@ -12,11 +12,6 @@ RowLayout { id: root 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: getTitle() !== "" // Widget properties passed from Bar.qml for per-instance settings property string widgetId: "" @@ -38,6 +33,12 @@ RowLayout { readonly property bool showIcon: (widgetSettings.showIcon !== undefined) ? widgetSettings.showIcon : widgetMetadata.showIcon + readonly property real minWidth: 160 + readonly property real maxWidth: 400 + Layout.alignment: Qt.AlignVCenter + spacing: Style.marginS * scaling + visible: getTitle() !== "" + function getTitle() { return CompositorService.focusedWindowTitle !== "(No active window)" ? CompositorService.focusedWindowTitle : "" } diff --git a/Modules/SettingsPanel/Bar/WidgetSettings/ClockSettings.qml b/Modules/SettingsPanel/Bar/WidgetSettings/ClockSettings.qml index d285681..e701ed0 100644 --- a/Modules/SettingsPanel/Bar/WidgetSettings/ClockSettings.qml +++ b/Modules/SettingsPanel/Bar/WidgetSettings/ClockSettings.qml @@ -29,7 +29,7 @@ ColumnLayout { } NCheckbox { - label: "Show date next to time" + label: "Show date" checked: valueShowDate onToggled: checked => valueShowDate = checked } diff --git a/Services/BarWidgetRegistry.qml b/Services/BarWidgetRegistry.qml index 80a8ed9..294db65 100644 --- a/Services/BarWidgetRegistry.qml +++ b/Services/BarWidgetRegistry.qml @@ -38,17 +38,6 @@ Singleton { }) property var widgetMetadata: ({ - "CustomButton": { - "allowUserSettings": true, - "icon": "favorite", - "leftClickExec": "", - "rightClickExec": "", - "middleClickExec": "" - }, - "Spacer": { - "allowUserSettings": true, - "width": 20 - }, "ActiveWindow": { "allowUserSettings": true, "showIcon": true @@ -58,6 +47,37 @@ Singleton { "alwaysShowPercentage": false, "warningThreshold": 30 }, + "Brightness": { + "allowUserSettings": true, + "alwaysShowPercentage": false + }, + "Clock": { + "allowUserSettings": true, + "showDate": false, + "use12HourClock": false, + "showSeconds": false, + "reverseDayMonth": true + }, + "CustomButton": { + "allowUserSettings": true, + "icon": "favorite", + "leftClickExec": "", + "rightClickExec": "", + "middleClickExec": "" + }, + "Microphone": { + "allowUserSettings": true, + "alwaysShowPercentage": false + }, + "NotificationHistory": { + "allowUserSettings": true, + "showUnreadBadge": true, + "hideWhenZero": false + }, + "Spacer": { + "allowUserSettings": true, + "width": 20 + }, "SystemMonitor": { "allowUserSettings": true, "showCpuUsage": true, @@ -75,33 +95,13 @@ Singleton { "showVisualizer": false, "visualizerType": "linear" }, - "Clock": { - "allowUserSettings": true, - "showDate": false, - "use12HourClock": false, - "showSeconds": false, - "reverseDayMonth": true - }, - "Volume": { - "allowUserSettings": true, - "alwaysShowPercentage": false - }, - "Microphone": { - "allowUserSettings": true, - "alwaysShowPercentage": false - }, - "Brightness": { - "allowUserSettings": true, - "alwaysShowPercentage": false - }, "SidePanelToggle": { "allowUserSettings": true, "useDistroLogo": false }, - "NotificationHistory": { + "Volume": { "allowUserSettings": true, - "showUnreadBadge": true, - "hideWhenZero": false + "alwaysShowPercentage": false } })