From 32d9aa0cf281fed68632d0793bebc8ceb6a7c312 Mon Sep 17 00:00:00 2001 From: bbedward Date: Tue, 7 Oct 2025 08:29:48 -0400 Subject: [PATCH] Separate bar font scale --- Common/SettingsData.qml | 8 +++ Common/Theme.qml | 7 +-- Modules/Settings/DankBarTab.qml | 91 +++++++++++++++++++++++++++++++++ 3 files changed, 103 insertions(+), 3 deletions(-) diff --git a/Common/SettingsData.qml b/Common/SettingsData.qml index 68a715f6..1a782d21 100644 --- a/Common/SettingsData.qml +++ b/Common/SettingsData.qml @@ -115,6 +115,7 @@ Singleton { property string monoFontFamily: "Fira Code" property int fontWeight: Font.Normal property real fontScale: 1.0 + property real dankBarFontScale: 1.0 property bool notepadUseMonospace: true property string notepadFontFamily: "" property real notepadFontSize: 14 @@ -373,6 +374,7 @@ Singleton { monoFontFamily = settings.monoFontFamily !== undefined ? settings.monoFontFamily : defaultMonoFontFamily fontWeight = settings.fontWeight !== undefined ? settings.fontWeight : Font.Normal fontScale = settings.fontScale !== undefined ? settings.fontScale : 1.0 + dankBarFontScale = settings.dankBarFontScale !== undefined ? settings.dankBarFontScale : 1.0 notepadUseMonospace = settings.notepadUseMonospace !== undefined ? settings.notepadUseMonospace : true notepadFontFamily = settings.notepadFontFamily !== undefined ? settings.notepadFontFamily : "" notepadFontSize = settings.notepadFontSize !== undefined ? settings.notepadFontSize : 14 @@ -503,6 +505,7 @@ Singleton { "monoFontFamily": monoFontFamily, "fontWeight": fontWeight, "fontScale": fontScale, + "dankBarFontScale": dankBarFontScale, "notepadUseMonospace": notepadUseMonospace, "notepadFontFamily": notepadFontFamily, "notepadFontSize": notepadFontSize, @@ -1059,6 +1062,11 @@ Singleton { saveSettings() } + function setDankBarFontScale(scale) { + dankBarFontScale = scale + saveSettings() + } + function setGtkThemingEnabled(enabled) { gtkThemingEnabled = enabled saveSettings() diff --git a/Common/Theme.qml b/Common/Theme.qml index 216a1f30..08685b9d 100644 --- a/Common/Theme.qml +++ b/Common/Theme.qml @@ -480,9 +480,10 @@ Singleton { function barTextSize(barThickness) { const scale = barThickness / 48 - if (scale <= 0.75) return fontSizeSmall * 0.9 - if (scale >= 1.25) return fontSizeMedium - return fontSizeSmall + const dankBarScale = (typeof SettingsData !== "undefined" ? SettingsData.dankBarFontScale : 1.0) + if (scale <= 0.75) return fontSizeSmall * 0.9 * dankBarScale + if (scale >= 1.25) return fontSizeMedium * dankBarScale + return fontSizeSmall * dankBarScale } function getBatteryIcon(level, isCharging, batteryAvailable) { diff --git a/Modules/Settings/DankBarTab.qml b/Modules/Settings/DankBarTab.qml index 7cc02d40..b93621c9 100644 --- a/Modules/Settings/DankBarTab.qml +++ b/Modules/Settings/DankBarTab.qml @@ -1065,6 +1065,97 @@ Item { SettingsData.setDankBarBorderEnabled(checked) } } + + Rectangle { + width: parent.width + height: 1 + color: Theme.outline + opacity: 0.2 + } + + Rectangle { + width: parent.width + height: 60 + radius: Theme.cornerRadius + color: "transparent" + + Column { + anchors.left: parent.left + anchors.right: dankBarFontScaleControls.left + anchors.verticalCenter: parent.verticalCenter + anchors.leftMargin: Theme.spacingM + anchors.rightMargin: Theme.spacingM + spacing: Theme.spacingXS + + StyledText { + text: qsTr("DankBar Font Scale") + font.pixelSize: Theme.fontSizeMedium + font.weight: Font.Medium + color: Theme.surfaceText + } + + StyledText { + text: qsTr("Scale DankBar font sizes independently") + font.pixelSize: Theme.fontSizeSmall + color: Theme.surfaceVariantText + width: parent.width + } + } + + Row { + id: dankBarFontScaleControls + + width: 180 + height: 36 + anchors.right: parent.right + anchors.rightMargin: 0 + anchors.verticalCenter: parent.verticalCenter + spacing: Theme.spacingS + + DankActionButton { + buttonSize: 32 + iconName: "remove" + iconSize: Theme.iconSizeSmall + enabled: SettingsData.dankBarFontScale > 0.5 + backgroundColor: Theme.surfaceContainerHigh + iconColor: Theme.surfaceText + onClicked: { + var newScale = Math.max(0.5, SettingsData.dankBarFontScale - 0.05) + SettingsData.setDankBarFontScale(newScale) + } + } + + StyledRect { + width: 60 + height: 32 + radius: Theme.cornerRadius + color: Theme.surfaceContainerHigh + border.color: Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.2) + border.width: 0 + + StyledText { + anchors.centerIn: parent + text: (SettingsData.dankBarFontScale * 100).toFixed(0) + "%" + font.pixelSize: Theme.fontSizeSmall + font.weight: Font.Medium + color: Theme.surfaceText + } + } + + DankActionButton { + buttonSize: 32 + iconName: "add" + iconSize: Theme.iconSizeSmall + enabled: SettingsData.dankBarFontScale < 2.0 + backgroundColor: Theme.surfaceContainerHigh + iconColor: Theme.surfaceText + onClicked: { + var newScale = Math.min(2.0, SettingsData.dankBarFontScale + 0.05) + SettingsData.setDankBarFontScale(newScale) + } + } + } + } } }