mirror of
https://github.com/noctalia-dev/noctalia-shell.git
synced 2026-05-11 17:08:27 +08:00
feat: Add custom button collapse condition
This commit is contained in:
@@ -1091,6 +1091,10 @@
|
||||
"refresh-interval": {
|
||||
"label": "Refresh interval",
|
||||
"description": "Interval in milliseconds."
|
||||
},
|
||||
"collapse-condition": {
|
||||
"label": "Collapse condition",
|
||||
"description": "If the output text matches this value, the button will collapse."
|
||||
}
|
||||
},
|
||||
"media-mini": {
|
||||
@@ -1335,6 +1339,7 @@
|
||||
"enter-width-pixels": "Enter width in pixels",
|
||||
"enter-command": "Enter command to execute (app or custom script)",
|
||||
"command-example": "echo \"Hello World\"",
|
||||
"enter-text": "Enter text to collapse (e.g., 'nothing is playing')",
|
||||
"search-wallpapers": "Type to filter wallpapers...",
|
||||
"search-launcher": "Search entries... or use > for commands",
|
||||
"search": "Search...",
|
||||
|
||||
@@ -38,6 +38,7 @@ Item {
|
||||
readonly property string textCommand: widgetSettings.textCommand !== undefined ? widgetSettings.textCommand : (widgetMetadata.textCommand || "")
|
||||
readonly property bool textStream: widgetSettings.textStream !== undefined ? widgetSettings.textStream : (widgetMetadata.textStream || false)
|
||||
readonly property int textIntervalMs: widgetSettings.textIntervalMs !== undefined ? widgetSettings.textIntervalMs : (widgetMetadata.textIntervalMs || 3000)
|
||||
readonly property string textCollapse: widgetSettings.textCollapse || widgetMetadata.textCollapse || ""
|
||||
readonly property bool hasExec: (leftClickExec || rightClickExec || middleClickExec)
|
||||
|
||||
implicitWidth: pill.width
|
||||
@@ -98,7 +99,14 @@ Item {
|
||||
|
||||
SplitParser {
|
||||
id: textStdoutSplit
|
||||
onRead: line => _dynamicText = String(line || "").trim()
|
||||
onRead: function(line) {
|
||||
var lineStr = String(line || "").trim()
|
||||
if (textCollapse && textCollapse === lineStr) {
|
||||
_dynamicText = ""
|
||||
} else {
|
||||
_dynamicText = lineStr
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
StdioCollector {
|
||||
@@ -108,7 +116,11 @@ Item {
|
||||
if (out.indexOf("\n") !== -1) {
|
||||
out = out.split("\n")[0]
|
||||
}
|
||||
_dynamicText = out
|
||||
if (textCollapse && textCollapse === out) {
|
||||
_dynamicText = ""
|
||||
} else {
|
||||
_dynamicText = out
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ ColumnLayout {
|
||||
settings.rightClickExec = rightClickExecInput.text
|
||||
settings.middleClickExec = middleClickExecInput.text
|
||||
settings.textCommand = textCommandInput.text
|
||||
settings.textCollapse = textCollapseInput.text
|
||||
settings.textStream = valueTextStream
|
||||
settings.textIntervalMs = parseInt(textIntervalInput.text || textIntervalInput.placeholderText, 10)
|
||||
return settings
|
||||
@@ -109,6 +110,16 @@ ColumnLayout {
|
||||
text: widgetData?.textCommand || widgetMetadata.textCommand
|
||||
}
|
||||
|
||||
NTextInput {
|
||||
id: textCollapseInput
|
||||
Layout.fillWidth: true
|
||||
visible: valueTextStream
|
||||
label: I18n.tr("bar.widget-settings.custom-button.collapse-condition.label")
|
||||
description: I18n.tr("bar.widget-settings.custom-button.collapse-condition.description")
|
||||
placeholderText: I18n.tr("placeholders.enter-text")
|
||||
text: widgetData?.textCollapse || widgetMetadata.textCollapse
|
||||
}
|
||||
|
||||
NTextInput {
|
||||
id: textIntervalInput
|
||||
Layout.fillWidth: true
|
||||
|
||||
@@ -84,7 +84,8 @@ Singleton {
|
||||
"middleClickExec": "",
|
||||
"textCommand": "",
|
||||
"textStream": false,
|
||||
"textIntervalMs": 3000
|
||||
"textIntervalMs": 3000,
|
||||
"textCollapse": ""
|
||||
},
|
||||
"KeyboardLayout": {
|
||||
"allowUserSettings": true,
|
||||
|
||||
Reference in New Issue
Block a user