diff --git a/Assets/Translations/en.json b/Assets/Translations/en.json index 818438cc..e258290e 100644 --- a/Assets/Translations/en.json +++ b/Assets/Translations/en.json @@ -119,6 +119,10 @@ "stream-description": "Enter a command to run continuously." }, "dynamic-text": "Dynamic text", + "hide-vertical": { + "description": "If enabled, the text from the command output will not be shown when the bar is in a vertical layout (left or right).", + "label": "Hide text in vertical bar" + }, "icon": { "description": "Select an icon from the library.", "label": "Icon" diff --git a/Modules/Bar/Widgets/CustomButton.qml b/Modules/Bar/Widgets/CustomButton.qml index 7e474fde..1d59f329 100644 --- a/Modules/Bar/Widgets/CustomButton.qml +++ b/Modules/Bar/Widgets/CustomButton.qml @@ -30,7 +30,8 @@ Item { return {} } - // Use settings or defaults from BarWidgetRegistry + readonly property bool isVerticalBar: Settings.data.bar.position === "left" || Settings.data.bar.position === "right" + readonly property string customIcon: widgetSettings.icon || widgetMetadata.icon readonly property string leftClickExec: widgetSettings.leftClickExec || widgetMetadata.leftClickExec readonly property string rightClickExec: widgetSettings.rightClickExec || widgetMetadata.rightClickExec @@ -40,8 +41,11 @@ Item { readonly property int textIntervalMs: widgetSettings.textIntervalMs !== undefined ? widgetSettings.textIntervalMs : (widgetMetadata.textIntervalMs || 3000) readonly property string textCollapse: widgetSettings.textCollapse !== undefined ? widgetSettings.textCollapse : (widgetMetadata.textCollapse || "") readonly property bool parseJson: widgetSettings.parseJson !== undefined ? widgetSettings.parseJson : (widgetMetadata.parseJson || false) + readonly property bool hideTextInVerticalBar: widgetSettings.hideTextInVerticalBar !== undefined ? widgetSettings.hideTextInVerticalBar : (widgetMetadata.hideTextInVerticalBar || false) readonly property bool hasExec: (leftClickExec || rightClickExec || middleClickExec) + readonly property bool shouldShowText: !isVerticalBar || !hideTextInVerticalBar + implicitWidth: pill.width implicitHeight: pill.height @@ -50,7 +54,7 @@ Item { oppositeDirection: BarService.getPillDirection(root) icon: _dynamicIcon !== "" ? _dynamicIcon : customIcon - text: _dynamicText + text: shouldShowText ? _dynamicText : "" density: Settings.data.bar.density autoHide: false forceOpen: _dynamicText !== "" @@ -86,7 +90,7 @@ Item { id: refreshTimer interval: Math.max(250, textIntervalMs) repeat: true - running: !textStream && textCommand && textCommand.length > 0 + running: shouldShowText && !textStream && textCommand && textCommand.length > 0 triggeredOnStart: true onTriggered: root.runTextCommand() } @@ -95,7 +99,7 @@ Item { Timer { id: restartTimer interval: 1000 - running: textStream && !textProc.running + running: shouldShowText && textStream && !textProc.running onTriggered: root.runTextCommand() } diff --git a/Modules/Panels/Settings/Bar/WidgetSettings/CustomButtonSettings.qml b/Modules/Panels/Settings/Bar/WidgetSettings/CustomButtonSettings.qml index 5d11c8de..715e4ef9 100644 --- a/Modules/Panels/Settings/Bar/WidgetSettings/CustomButtonSettings.qml +++ b/Modules/Panels/Settings/Bar/WidgetSettings/CustomButtonSettings.qml @@ -15,6 +15,7 @@ ColumnLayout { property string valueIcon: widgetData.icon !== undefined ? widgetData.icon : widgetMetadata.icon property bool valueTextStream: widgetData.textStream !== undefined ? widgetData.textStream : widgetMetadata.textStream property bool valueParseJson: widgetData.parseJson !== undefined ? widgetData.parseJson : widgetMetadata.parseJson + property bool valueHideTextInVerticalBar: widgetData.hideTextInVerticalBar !== undefined ? widgetData.hideTextInVerticalBar : widgetMetadata.hideTextInVerticalBar function saveSettings() { var settings = Object.assign({}, widgetData || {}) @@ -26,6 +27,7 @@ ColumnLayout { settings.textCollapse = textCollapseInput.text settings.textStream = valueTextStream settings.parseJson = valueParseJson + settings.hideTextInVerticalBar = valueHideTextInVerticalBar settings.textIntervalMs = parseInt(textIntervalInput.text || textIntervalInput.placeholderText, 10) return settings } @@ -94,6 +96,13 @@ ColumnLayout { label: I18n.tr("bar.widget-settings.custom-button.dynamic-text") } + NToggle { + label: I18n.tr("bar.widget-settings.custom-button.hide-vertical.label", "Hide text in vertical bar") + description: I18n.tr("bar.widget-settings.custom-button.hide-vertical.description", "If enabled, the text from the command output will not be shown when the bar is in a vertical layout (left or right).") + checked: valueHideTextInVerticalBar + onToggled: checked => valueHideTextInVerticalBar = checked + } + NToggle { id: textStreamInput label: I18n.tr("bar.widget-settings.custom-button.text-stream.label") diff --git a/Services/UI/BarWidgetRegistry.qml b/Services/UI/BarWidgetRegistry.qml index 5cd91190..89ac49c1 100644 --- a/Services/UI/BarWidgetRegistry.qml +++ b/Services/UI/BarWidgetRegistry.qml @@ -98,7 +98,8 @@ Singleton { "textStream": false, "textIntervalMs": 3000, "textCollapse": "", - "parseJson": false + "parseJson": false, + "hideTextInVerticalBar": false }, "KeyboardLayout": { "allowUserSettings": true,