diff --git a/quickshell/Modules/DDash/DashRegistry.qml b/quickshell/Modules/DDash/DashRegistry.qml index a88bf9658..407e82830 100644 --- a/quickshell/Modules/DDash/DashRegistry.qml +++ b/quickshell/Modules/DDash/DashRegistry.qml @@ -67,6 +67,13 @@ Singleton { }; } + function slider(key, text, def, min, max, step, minimumLabel) { + return Object.assign(number(key, text, def, min, max, step), { + "type": "slider", + "minimumLabel": minimumLabel ?? "" + }); + } + function toneOption(def = "") { return choice("tone", I18n.tr("Tone", "noun, dashboard widget color tone option label"), def, toneChoices); } @@ -231,7 +238,7 @@ Singleton { "value": "analog", "text": I18n.tr("Analog", "clock style option") } - ]), toggle("seconds", I18n.tr("Show seconds"), false), toggle("date", I18n.tr("Show date"), false), toggle("numbers", I18n.tr("Show hour numbers"), false), choice("tone", I18n.tr("Tone"), "primary", toneChoices)] + ]), slider("weight", I18n.tr("Weight"), 0, 0, Font.Black, 100, I18n.tr("Default")), toggle("seconds", I18n.tr("Show seconds"), false), toggle("date", I18n.tr("Show date"), false), toggle("numbers", I18n.tr("Show hour numbers"), false), choice("tone", I18n.tr("Tone"), "primary", toneChoices)] }, { "id": "calendar", diff --git a/quickshell/Modules/DDash/Overview/ClockCard.qml b/quickshell/Modules/DDash/Overview/ClockCard.qml index 91845adb8..06ea0d69e 100644 --- a/quickshell/Modules/DDash/Overview/ClockCard.qml +++ b/quickshell/Modules/DDash/Overview/ClockCard.qml @@ -42,6 +42,7 @@ Card { minutes: root.minuteText seconds: root.showSeconds ? root.secondText : "" dateText: root.dateText + weight: root.options.weight color: root.accentColor supportingColor: root.supportingColor } diff --git a/quickshell/Modules/DDash/Overview/DashOptionRow.qml b/quickshell/Modules/DDash/Overview/DashOptionRow.qml index 96f28066c..ff348fa4d 100644 --- a/quickshell/Modules/DDash/Overview/DashOptionRow.qml +++ b/quickshell/Modules/DDash/Overview/DashOptionRow.qml @@ -35,11 +35,19 @@ SettingsRow { return choiceControl; case "number": return numberControl; + case "slider": + return sliderLabel; } return null; } } + body: Loader { + width: parent?.width ?? 0 + active: root.spec.type === "slider" + sourceComponent: sliderControl + } + Component { id: toggleControl @@ -79,4 +87,29 @@ SettingsRow { onDecrement: () => root.commit(current - step) } } + + Component { + id: sliderLabel + + StyledText { + visible: root.value === root.spec.min + text: root.spec.minimumLabel ?? "" + font.pixelSize: Theme.fontSizeSmall + color: Theme.surfaceVariantText + } + } + + Component { + id: sliderControl + + SettingsSliderControl { + value: Number(root.value) || 0 + minimum: root.spec.min + maximum: root.spec.max + step: root.spec.step + showValue: root.value !== root.spec.min + accessibleName: root.title + onSliderValueChanged: newValue => root.commit(newValue) + } + } } diff --git a/quickshell/Modules/DDash/utils/options.js b/quickshell/Modules/DDash/utils/options.js index 718de9d1a..ada574036 100644 --- a/quickshell/Modules/DDash/utils/options.js +++ b/quickshell/Modules/DDash/utils/options.js @@ -7,6 +7,7 @@ function value(spec, stored) { case "choice": return spec.choices.some(c => c.value === stored) ? stored : spec.def; case "number": + case "slider": if (!Number.isFinite(stored)) return spec.def; return Math.max(spec.min, Math.min(spec.max, stored)); diff --git a/quickshell/Modules/Settings/DesktopWidgetSettings/ClockSettings.qml b/quickshell/Modules/Settings/DesktopWidgetSettings/ClockSettings.qml index 32f7d435c..8f7a0f09f 100644 --- a/quickshell/Modules/Settings/DesktopWidgetSettings/ClockSettings.qml +++ b/quickshell/Modules/Settings/DesktopWidgetSettings/ClockSettings.qml @@ -34,7 +34,7 @@ DesktopWidgetInstanceSettings { visible: !root.analog text: I18n.tr("Weight") minimum: 0 - maximum: 900 + maximum: Font.Black step: 100 minimumLabel: I18n.tr("Default") value: root.cfg.weight ?? 0