mirror of
https://github.com/zoriya/noctalia-shell.git
synced 2026-08-15 18:43:59 +00:00
feat(bar): Add option to hide CustomButton text in vertical bar
This commit is contained in:
@@ -119,6 +119,10 @@
|
|||||||
"stream-description": "Enter a command to run continuously."
|
"stream-description": "Enter a command to run continuously."
|
||||||
},
|
},
|
||||||
"dynamic-text": "Dynamic text",
|
"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": {
|
"icon": {
|
||||||
"description": "Select an icon from the library.",
|
"description": "Select an icon from the library.",
|
||||||
"label": "Icon"
|
"label": "Icon"
|
||||||
|
|||||||
@@ -30,7 +30,8 @@ Item {
|
|||||||
return {}
|
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 customIcon: widgetSettings.icon || widgetMetadata.icon
|
||||||
readonly property string leftClickExec: widgetSettings.leftClickExec || widgetMetadata.leftClickExec
|
readonly property string leftClickExec: widgetSettings.leftClickExec || widgetMetadata.leftClickExec
|
||||||
readonly property string rightClickExec: widgetSettings.rightClickExec || widgetMetadata.rightClickExec
|
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 int textIntervalMs: widgetSettings.textIntervalMs !== undefined ? widgetSettings.textIntervalMs : (widgetMetadata.textIntervalMs || 3000)
|
||||||
readonly property string textCollapse: widgetSettings.textCollapse !== undefined ? widgetSettings.textCollapse : (widgetMetadata.textCollapse || "")
|
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 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 hasExec: (leftClickExec || rightClickExec || middleClickExec)
|
||||||
|
|
||||||
|
readonly property bool shouldShowText: !isVerticalBar || !hideTextInVerticalBar
|
||||||
|
|
||||||
implicitWidth: pill.width
|
implicitWidth: pill.width
|
||||||
implicitHeight: pill.height
|
implicitHeight: pill.height
|
||||||
|
|
||||||
@@ -50,7 +54,7 @@ Item {
|
|||||||
|
|
||||||
oppositeDirection: BarService.getPillDirection(root)
|
oppositeDirection: BarService.getPillDirection(root)
|
||||||
icon: _dynamicIcon !== "" ? _dynamicIcon : customIcon
|
icon: _dynamicIcon !== "" ? _dynamicIcon : customIcon
|
||||||
text: _dynamicText
|
text: shouldShowText ? _dynamicText : ""
|
||||||
density: Settings.data.bar.density
|
density: Settings.data.bar.density
|
||||||
autoHide: false
|
autoHide: false
|
||||||
forceOpen: _dynamicText !== ""
|
forceOpen: _dynamicText !== ""
|
||||||
@@ -86,7 +90,7 @@ Item {
|
|||||||
id: refreshTimer
|
id: refreshTimer
|
||||||
interval: Math.max(250, textIntervalMs)
|
interval: Math.max(250, textIntervalMs)
|
||||||
repeat: true
|
repeat: true
|
||||||
running: !textStream && textCommand && textCommand.length > 0
|
running: shouldShowText && !textStream && textCommand && textCommand.length > 0
|
||||||
triggeredOnStart: true
|
triggeredOnStart: true
|
||||||
onTriggered: root.runTextCommand()
|
onTriggered: root.runTextCommand()
|
||||||
}
|
}
|
||||||
@@ -95,7 +99,7 @@ Item {
|
|||||||
Timer {
|
Timer {
|
||||||
id: restartTimer
|
id: restartTimer
|
||||||
interval: 1000
|
interval: 1000
|
||||||
running: textStream && !textProc.running
|
running: shouldShowText && textStream && !textProc.running
|
||||||
onTriggered: root.runTextCommand()
|
onTriggered: root.runTextCommand()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ ColumnLayout {
|
|||||||
property string valueIcon: widgetData.icon !== undefined ? widgetData.icon : widgetMetadata.icon
|
property string valueIcon: widgetData.icon !== undefined ? widgetData.icon : widgetMetadata.icon
|
||||||
property bool valueTextStream: widgetData.textStream !== undefined ? widgetData.textStream : widgetMetadata.textStream
|
property bool valueTextStream: widgetData.textStream !== undefined ? widgetData.textStream : widgetMetadata.textStream
|
||||||
property bool valueParseJson: widgetData.parseJson !== undefined ? widgetData.parseJson : widgetMetadata.parseJson
|
property bool valueParseJson: widgetData.parseJson !== undefined ? widgetData.parseJson : widgetMetadata.parseJson
|
||||||
|
property bool valueHideTextInVerticalBar: widgetData.hideTextInVerticalBar !== undefined ? widgetData.hideTextInVerticalBar : widgetMetadata.hideTextInVerticalBar
|
||||||
|
|
||||||
function saveSettings() {
|
function saveSettings() {
|
||||||
var settings = Object.assign({}, widgetData || {})
|
var settings = Object.assign({}, widgetData || {})
|
||||||
@@ -26,6 +27,7 @@ ColumnLayout {
|
|||||||
settings.textCollapse = textCollapseInput.text
|
settings.textCollapse = textCollapseInput.text
|
||||||
settings.textStream = valueTextStream
|
settings.textStream = valueTextStream
|
||||||
settings.parseJson = valueParseJson
|
settings.parseJson = valueParseJson
|
||||||
|
settings.hideTextInVerticalBar = valueHideTextInVerticalBar
|
||||||
settings.textIntervalMs = parseInt(textIntervalInput.text || textIntervalInput.placeholderText, 10)
|
settings.textIntervalMs = parseInt(textIntervalInput.text || textIntervalInput.placeholderText, 10)
|
||||||
return settings
|
return settings
|
||||||
}
|
}
|
||||||
@@ -94,6 +96,13 @@ ColumnLayout {
|
|||||||
label: I18n.tr("bar.widget-settings.custom-button.dynamic-text")
|
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 {
|
NToggle {
|
||||||
id: textStreamInput
|
id: textStreamInput
|
||||||
label: I18n.tr("bar.widget-settings.custom-button.text-stream.label")
|
label: I18n.tr("bar.widget-settings.custom-button.text-stream.label")
|
||||||
|
|||||||
@@ -98,7 +98,8 @@ Singleton {
|
|||||||
"textStream": false,
|
"textStream": false,
|
||||||
"textIntervalMs": 3000,
|
"textIntervalMs": 3000,
|
||||||
"textCollapse": "",
|
"textCollapse": "",
|
||||||
"parseJson": false
|
"parseJson": false,
|
||||||
|
"hideTextInVerticalBar": false
|
||||||
},
|
},
|
||||||
"KeyboardLayout": {
|
"KeyboardLayout": {
|
||||||
"allowUserSettings": true,
|
"allowUserSettings": true,
|
||||||
|
|||||||
Reference in New Issue
Block a user