From 68e76abfc78f9cedc0d4181149321b22d0a3e38b Mon Sep 17 00:00:00 2001 From: DiscoNiri Date: Wed, 1 Oct 2025 20:26:13 +1000 Subject: [PATCH] Move clock font settings to widget-specific configuration - Moved clock font selection from general settings to clock widget settings - Added custom font toggle and selection in ClockSettings.qml - Updated BarWidgetRegistry.qml with new clock font metadata - Removed global clockFont setting from Settings.qml and GeneralTab.qml - Updated Clock.qml to use widget-specific custom font setting - Added proper translation keys for new font options - Maintained backward compatibility with existing font hierarchy --- Assets/Translations/en.json | 10 ++++++ Commons/Settings.qml | 1 - Modules/Bar/Widgets/Clock.qml | 6 ++-- .../Bar/WidgetSettings/ClockSettings.qml | 32 +++++++++++++++++-- Modules/Settings/Tabs/GeneralTab.qml | 13 -------- Services/BarWidgetRegistry.qml | 2 ++ 6 files changed, 46 insertions(+), 18 deletions(-) diff --git a/Assets/Translations/en.json b/Assets/Translations/en.json index a9d7b1c7..22047e5c 100644 --- a/Assets/Translations/en.json +++ b/Assets/Translations/en.json @@ -990,6 +990,16 @@ "label": "Use monospaced font", "description": "When enabled, the clock will use the monospaced font." }, + "use-custom-font": { + "label": "Use custom font", + "description": "Override the default font selection with a custom font for the clock." + }, + "custom-font": { + "label": "Custom font", + "description": "Select a custom font for the clock display.", + "placeholder": "Select custom font...", + "search-placeholder": "Search fonts..." + }, "clock-display": { "label": "Clock display", "description": "Customize your clock's display by adding tokens from the list below. To use the 12-hour format, you must include the 'AP' token." diff --git a/Commons/Settings.qml b/Commons/Settings.qml index 12138b8c..8fd245c7 100644 --- a/Commons/Settings.qml +++ b/Commons/Settings.qml @@ -272,7 +272,6 @@ Singleton { property JsonObject ui: JsonObject { property string fontDefault: "Roboto" property string fontFixed: "DejaVu Sans Mono" - property string clockFont: "Roboto" property real fontDefaultScale: 1.0 property real fontFixedScale: 1.0 property list monitorsScaling: [] diff --git a/Modules/Bar/Widgets/Clock.qml b/Modules/Bar/Widgets/Clock.qml index fbffbb29..26b40617 100644 --- a/Modules/Bar/Widgets/Clock.qml +++ b/Modules/Bar/Widgets/Clock.qml @@ -37,6 +37,8 @@ Rectangle { // Resolve settings: try user settings or defaults from BarWidgetRegistry readonly property bool usePrimaryColor: widgetSettings.usePrimaryColor !== undefined ? widgetSettings.usePrimaryColor : widgetMetadata.usePrimaryColor property bool useMonospacedFont: widgetSettings.useMonospacedFont !== undefined ? widgetSettings.useMonospacedFont : widgetMetadata.useMonospacedFont + readonly property bool useCustomFont: widgetSettings.useCustomFont !== undefined ? widgetSettings.useCustomFont : widgetMetadata.useCustomFont + readonly property string customFont: widgetSettings.customFont !== undefined ? widgetSettings.customFont : widgetMetadata.customFont readonly property string formatHorizontal: widgetSettings.formatHorizontal !== undefined ? widgetSettings.formatHorizontal : widgetMetadata.formatHorizontal readonly property string formatVertical: widgetSettings.formatVertical !== undefined ? widgetSettings.formatVertical : widgetMetadata.formatVertical @@ -65,7 +67,7 @@ Rectangle { NText { visible: text !== "" text: modelData - family: Settings.data.ui.clockFont || (useMonospacedFont ? Settings.data.ui.fontFixed : Settings.data.ui.fontDefault) + family: useCustomFont && customFont ? customFont : (useMonospacedFont ? Settings.data.ui.fontFixed : Settings.data.ui.fontDefault) pointSize: { if (repeater.model.length == 1) { return Style.fontSizeS * scaling @@ -95,7 +97,7 @@ Rectangle { delegate: NText { visible: text !== "" text: modelData - family: Settings.data.ui.clockFont || (useMonospacedFont ? Settings.data.ui.fontFixed : Settings.data.ui.fontDefault) + family: useCustomFont && customFont ? customFont : (useMonospacedFont ? Settings.data.ui.fontFixed : Settings.data.ui.fontDefault) pointSize: Style.fontSizeS * scaling font.weight: Style.fontWeightBold color: usePrimaryColor ? Color.mPrimary : Color.mOnSurface diff --git a/Modules/Settings/Bar/WidgetSettings/ClockSettings.qml b/Modules/Settings/Bar/WidgetSettings/ClockSettings.qml index fe3f1e73..025d6f28 100644 --- a/Modules/Settings/Bar/WidgetSettings/ClockSettings.qml +++ b/Modules/Settings/Bar/WidgetSettings/ClockSettings.qml @@ -17,6 +17,8 @@ ColumnLayout { // Local state property bool valueUsePrimaryColor: widgetData.usePrimaryColor !== undefined ? widgetData.usePrimaryColor : widgetMetadata.usePrimaryColor property bool valueUseMonospacedFont: widgetData.useMonospacedFont !== undefined ? widgetData.useMonospacedFont : widgetMetadata.useMonospacedFont + property bool valueUseCustomFont: widgetData.useCustomFont !== undefined ? widgetData.useCustomFont : widgetMetadata.useCustomFont + property string valueCustomFont: widgetData.customFont !== undefined ? widgetData.customFont : widgetMetadata.customFont property string valueFormatHorizontal: widgetData.formatHorizontal !== undefined ? widgetData.formatHorizontal : widgetMetadata.formatHorizontal property string valueFormatVertical: widgetData.formatVertical !== undefined ? widgetData.formatVertical : widgetMetadata.formatVertical @@ -30,6 +32,8 @@ ColumnLayout { var settings = Object.assign({}, widgetData || {}) settings.usePrimaryColor = valueUsePrimaryColor settings.useMonospacedFont = valueUseMonospacedFont + settings.useCustomFont = valueUseCustomFont + settings.customFont = valueCustomFont settings.formatHorizontal = valueFormatHorizontal.trim() settings.formatVertical = valueFormatVertical.trim() return settings @@ -78,6 +82,30 @@ ColumnLayout { onToggled: checked => valueUseMonospacedFont = checked } + NToggle { + Layout.fillWidth: true + label: I18n.tr("bar.widget-settings.clock.use-custom-font.label") + description: I18n.tr("bar.widget-settings.clock.use-custom-font.description") + checked: valueUseCustomFont + onToggled: checked => valueUseCustomFont = checked + } + + NSearchableComboBox { + Layout.fillWidth: true + visible: valueUseCustomFont + label: I18n.tr("bar.widget-settings.clock.custom-font.label") + description: I18n.tr("bar.widget-settings.clock.custom-font.description") + model: FontService.availableFonts + currentKey: valueCustomFont + placeholder: I18n.tr("bar.widget-settings.clock.custom-font.placeholder") + searchPlaceholder: I18n.tr("bar.widget-settings.clock.custom-font.search-placeholder") + popupHeight: 420 * scaling + minimumWidth: 300 * scaling + onSelected: function (key) { + valueCustomFont = key + } + } + NDivider { Layout.fillWidth: true } @@ -186,7 +214,7 @@ ColumnLayout { delegate: NText { visible: text !== "" text: modelData - family: valueUseMonospacedFont ? Settings.data.ui.fontFixed : Settings.data.ui.fontDefault + family: valueUseCustomFont && valueCustomFont ? valueCustomFont : (valueUseMonospacedFont ? Settings.data.ui.fontFixed : Settings.data.ui.fontDefault) pointSize: Style.fontSizeM * scaling font.weight: Style.fontWeightBold color: valueUsePrimaryColor ? Color.mPrimary : Color.mOnSurface @@ -217,7 +245,7 @@ ColumnLayout { delegate: NText { visible: text !== "" text: modelData - family: valueUseMonospacedFont ? Settings.data.ui.fontFixed : Settings.data.ui.fontDefault + family: valueUseCustomFont && valueCustomFont ? valueCustomFont : (valueUseMonospacedFont ? Settings.data.ui.fontFixed : Settings.data.ui.fontDefault) pointSize: Style.fontSizeM * scaling font.weight: Style.fontWeightBold color: valueUsePrimaryColor ? Color.mPrimary : Color.mOnSurface diff --git a/Modules/Settings/Tabs/GeneralTab.qml b/Modules/Settings/Tabs/GeneralTab.qml index 12658189..cba95fc6 100644 --- a/Modules/Settings/Tabs/GeneralTab.qml +++ b/Modules/Settings/Tabs/GeneralTab.qml @@ -237,19 +237,6 @@ ColumnLayout { } } - NSearchableComboBox { - label: "Clock Font" - description: "Font used specifically for clock displays in the bar and widgets." - model: FontService.availableFonts - currentKey: Settings.data.ui.clockFont - placeholder: "Select clock font..." - searchPlaceholder: "Search fonts..." - popupHeight: 420 * scaling - minimumWidth: 300 * scaling - onSelected: function (key) { - Settings.data.ui.clockFont = key - } - } ColumnLayout { NLabel { diff --git a/Services/BarWidgetRegistry.qml b/Services/BarWidgetRegistry.qml index 6beda333..be286e07 100644 --- a/Services/BarWidgetRegistry.qml +++ b/Services/BarWidgetRegistry.qml @@ -57,6 +57,8 @@ Singleton { "allowUserSettings": true, "usePrimaryColor": true, "useMonospacedFont": true, + "useCustomFont": false, + "customFont": "", "formatHorizontal": "HH:mm ddd, MMM dd", "formatVertical": "HH mm - dd MM" },