mirror of
https://github.com/zoriya/noctalia-shell.git
synced 2026-08-15 18:43:59 +00:00
feat: Implement automatic regex interpretation for custom button collapse condition
This commit is contained in:
@@ -1339,7 +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')",
|
||||
"enter-text-to-collapse": "Enter text or regex to collapse (e.g., 'nothing is playing' or '^nothing is playing')",
|
||||
"search-wallpapers": "Type to filter wallpapers...",
|
||||
"search-launcher": "Search entries... or use > for commands",
|
||||
"search": "Search...",
|
||||
|
||||
@@ -38,7 +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 string textCollapse: widgetSettings.textCollapse !== undefined ? widgetSettings.textCollapse : (widgetMetadata.textCollapse || "")
|
||||
readonly property bool hasExec: (leftClickExec || rightClickExec || middleClickExec)
|
||||
|
||||
implicitWidth: pill.width
|
||||
@@ -101,7 +101,19 @@ Item {
|
||||
id: textStdoutSplit
|
||||
onRead: function(line) {
|
||||
var lineStr = String(line || "").trim()
|
||||
if (textCollapse && textCollapse === lineStr) {
|
||||
var shouldCollapse = false
|
||||
|
||||
if (textCollapse && textCollapse.length > 0) {
|
||||
try {
|
||||
var regex = new RegExp(textCollapse)
|
||||
shouldCollapse = regex.test(lineStr)
|
||||
} catch (e) {
|
||||
// If it's not a valid regex, treat it as a plain string
|
||||
shouldCollapse = (textCollapse === lineStr)
|
||||
}
|
||||
}
|
||||
|
||||
if (shouldCollapse) {
|
||||
_dynamicText = ""
|
||||
} else {
|
||||
_dynamicText = lineStr
|
||||
@@ -116,7 +128,19 @@ Item {
|
||||
if (out.indexOf("\n") !== -1) {
|
||||
out = out.split("\n")[0]
|
||||
}
|
||||
if (textCollapse && textCollapse === out) {
|
||||
var shouldCollapse = false
|
||||
|
||||
if (textCollapse && textCollapse.length > 0) {
|
||||
try {
|
||||
var regex = new RegExp(textCollapse)
|
||||
shouldCollapse = regex.test(out)
|
||||
} catch (e) {
|
||||
// If it's not a valid regex, treat it as a plain string
|
||||
shouldCollapse = (textCollapse === out)
|
||||
}
|
||||
}
|
||||
|
||||
if (shouldCollapse) {
|
||||
_dynamicText = ""
|
||||
} else {
|
||||
_dynamicText = out
|
||||
|
||||
@@ -116,7 +116,7 @@ ColumnLayout {
|
||||
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")
|
||||
placeholderText: I18n.tr("placeholders.enter-text-to-collapse")
|
||||
text: widgetData?.textCollapse || widgetMetadata.textCollapse
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user