From bc14ab95f96620eed018cdadce78e9cebbfc281a Mon Sep 17 00:00:00 2001 From: ItsLemmy Date: Sat, 4 Oct 2025 14:33:04 -0400 Subject: [PATCH] ActiveWindow: new setting to set your favorite width. Fix #417 --- Assets/Translations/de.json | 4 ++++ Assets/Translations/en.json | 4 ++++ Assets/Translations/es.json | 4 ++++ Assets/Translations/fr.json | 4 ++++ Assets/Translations/pt.json | 4 ++++ Assets/Translations/zh-CN.json | 4 ++++ Modules/Bar/Widgets/ActiveWindow.qml | 3 +-- .../Bar/WidgetSettings/ActiveWindowSettings.qml | 11 +++++++++++ Services/BarWidgetRegistry.qml | 3 ++- 9 files changed, 38 insertions(+), 3 deletions(-) diff --git a/Assets/Translations/de.json b/Assets/Translations/de.json index 5034e44d..3a8c8afb 100644 --- a/Assets/Translations/de.json +++ b/Assets/Translations/de.json @@ -865,6 +865,10 @@ "scrolling-mode": { "label": "Scrollmodus", "description": "Steuern, wann Textscrolling für lange Fenstertitel aktiviert ist." + }, + "width": { + "description": "Steuert die horizontale Größe des Widgets.", + "label": "Widget-Breite" } }, "system-monitor": { diff --git a/Assets/Translations/en.json b/Assets/Translations/en.json index fa6708cf..b131a7d6 100644 --- a/Assets/Translations/en.json +++ b/Assets/Translations/en.json @@ -846,6 +846,10 @@ "scrolling-mode": { "label": "Scrolling mode", "description": "Control when text scrolling is enabled for long window titles." + }, + "width": { + "label": "Widget Width", + "description": "Controls the horizontal size of the widget." } }, "system-monitor": { diff --git a/Assets/Translations/es.json b/Assets/Translations/es.json index 3d98057b..77a39d3c 100644 --- a/Assets/Translations/es.json +++ b/Assets/Translations/es.json @@ -844,6 +844,10 @@ "scrolling-mode": { "label": "Modo de desplazamiento", "description": "Controlar cuándo está habilitado el desplazamiento de texto para títulos de ventana largos." + }, + "width": { + "description": "Controla el tamaño horizontal del widget.", + "label": "Ancho del widget" } }, "system-monitor": { diff --git a/Assets/Translations/fr.json b/Assets/Translations/fr.json index 29ecab0b..58887b76 100644 --- a/Assets/Translations/fr.json +++ b/Assets/Translations/fr.json @@ -844,6 +844,10 @@ "auto-hide": { "label": "Masquer automatiquement", "description": "Masquer automatiquement le widget quand aucune fenêtre n'est active." + }, + "width": { + "description": "Contrôle la taille horizontale du widget.", + "label": "Largeur du widget" } }, "system-monitor": { diff --git a/Assets/Translations/pt.json b/Assets/Translations/pt.json index 31d281c5..d7322b40 100644 --- a/Assets/Translations/pt.json +++ b/Assets/Translations/pt.json @@ -844,6 +844,10 @@ "scrolling-mode": { "label": "Modo de rolagem", "description": "Controlar quando a rolagem de texto está habilitada para títulos de janela longos." + }, + "width": { + "description": "Controla o tamanho horizontal do widget.", + "label": "Largura do Widget" } }, "system-monitor": { diff --git a/Assets/Translations/zh-CN.json b/Assets/Translations/zh-CN.json index c69e7173..56829562 100644 --- a/Assets/Translations/zh-CN.json +++ b/Assets/Translations/zh-CN.json @@ -844,6 +844,10 @@ "scrolling-mode": { "label": "滚动模式", "description": "控制何时为长窗口标题启用文本滚动。" + }, + "width": { + "description": "控制小部件的水平尺寸。", + "label": "小部件宽度" } }, "system-monitor": { diff --git a/Modules/Bar/Widgets/ActiveWindow.qml b/Modules/Bar/Widgets/ActiveWindow.qml index 5b1272dd..774489bf 100644 --- a/Modules/Bar/Widgets/ActiveWindow.qml +++ b/Modules/Bar/Widgets/ActiveWindow.qml @@ -41,9 +41,8 @@ Item { readonly property bool showIcon: (widgetSettings.showIcon !== undefined) ? widgetSettings.showIcon : widgetMetadata.showIcon readonly property bool autoHide: (widgetSettings.autoHide !== undefined) ? widgetSettings.autoHide : widgetMetadata.autoHide readonly property string scrollingMode: (widgetSettings.scrollingMode !== undefined) ? widgetSettings.scrollingMode : (widgetMetadata.scrollingMode !== undefined ? widgetMetadata.scrollingMode : "hover") + readonly property int widgetWidth: (widgetSettings.width !== undefined) ? widgetSettings.width : Math.max(widgetMetadata.width, screen.width * 0.06) - // Fixed width - readonly property real widgetWidth: Math.max(145, screen.width * 0.06) implicitHeight: visible ? ((barPosition === "left" || barPosition === "right") ? calculatedVerticalHeight() : Math.round(Style.barHeight * scaling)) : 0 implicitWidth: visible ? ((barPosition === "left" || barPosition === "right") ? Math.round(Style.baseWidgetSize * 0.8 * scaling) : (widgetWidth * scaling)) : 0 diff --git a/Modules/Settings/Bar/WidgetSettings/ActiveWindowSettings.qml b/Modules/Settings/Bar/WidgetSettings/ActiveWindowSettings.qml index cb4f2c5e..3d1be163 100644 --- a/Modules/Settings/Bar/WidgetSettings/ActiveWindowSettings.qml +++ b/Modules/Settings/Bar/WidgetSettings/ActiveWindowSettings.qml @@ -17,12 +17,14 @@ ColumnLayout { property bool valueShowIcon: widgetData.showIcon !== undefined ? widgetData.showIcon : widgetMetadata.showIcon property bool valueAutoHide: widgetData.autoHide !== undefined ? widgetData.autoHide : widgetMetadata.autoHide property string valueScrollingMode: widgetData.scrollingMode || widgetMetadata.scrollingMode + property int valueWidth: widgetData.width !== undefined ? widgetData.width : widgetMetadata.width function saveSettings() { var settings = Object.assign({}, widgetData || {}) settings.autoHide = valueAutoHide settings.showIcon = valueShowIcon settings.scrollingMode = valueScrollingMode + settings.width = parseInt(widthInput.text) || widgetMetadata.width return settings } @@ -42,6 +44,15 @@ ColumnLayout { onToggled: checked => root.valueShowIcon = checked } + NTextInput { + id: widthInput + Layout.fillWidth: true + label: I18n.tr("bar.widget-settings.active-window.width.label") + description: I18n.tr("bar.widget-settings.active-window.width.description") + placeholderText: widgetMetadata.width + text: valueWidth + } + NComboBox { label: I18n.tr("bar.widget-settings.active-window.scrolling-mode.label") description: I18n.tr("bar.widget-settings.active-window.scrolling-mode.description") diff --git a/Services/BarWidgetRegistry.qml b/Services/BarWidgetRegistry.qml index 598817c8..cddb544a 100644 --- a/Services/BarWidgetRegistry.qml +++ b/Services/BarWidgetRegistry.qml @@ -42,7 +42,8 @@ Singleton { "allowUserSettings": true, "showIcon": true, "autoHide": false, - "scrollingMode": "hover" + "scrollingMode": "hover", + "width": 145 }, "Battery": { "allowUserSettings": true,