Merge pull request #609 from lonerOrz/feat/parseJson

feat(custom-button): Add JSON parsing support
This commit is contained in:
Lysec
2025-10-29 13:44:07 +01:00
committed by GitHub
4 changed files with 77 additions and 59 deletions
@@ -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
function saveSettings() {
var settings = Object.assign({}, widgetData || {})
@@ -25,6 +26,7 @@ ColumnLayout {
settings.textCommand = textCommandInput.text
settings.textCollapse = textCollapseInput.text
settings.textStream = valueTextStream
settings.parseJson = valueParseJson
settings.textIntervalMs = parseInt(textIntervalInput.text || textIntervalInput.placeholderText, 10)
return settings
}
@@ -101,6 +103,14 @@ ColumnLayout {
onToggled: checked => valueTextStream = checked
}
NToggle {
id: parseJsonInput
label: I18n.tr("bar.widget-settings.custom-button.parse-json.label", "Parse output as JSON")
description: I18n.tr("bar.widget-settings.custom-button.parse-json.description", "Parse the command output as a JSON object to dynamically set text and icon.")
checked: valueParseJson
onToggled: checked => valueParseJson = checked
}
NTextInput {
id: textCommandInput
Layout.fillWidth: true