This commit is contained in:
ItsLemmy
2025-10-10 08:02:10 -04:00
parent a493061bae
commit 93803f1309
3 changed files with 55 additions and 51 deletions
-1
View File
@@ -140,7 +140,6 @@ Singleton {
property real marginVertical: 0.25
property real marginHorizontal: 0.25
// Widget configuration for modular bar system
property JsonObject widgets
widgets: JsonObject {
+12 -11
View File
@@ -42,26 +42,27 @@ Rectangle {
function wildCardMatch(str, rule) {
if (!str || !rule) {
return false;
return false
}
Logger.log("Tray", "wildCardMatch - Input str:", str, "rule:", rule);
Logger.log("Tray", "wildCardMatch - Input str:", str, "rule:", rule)
// Escape all special regex characters in the rule
let escapedRule = rule.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
let escapedRule = rule.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
// Convert '*' to '.*' for wildcard matching
let pattern = escapedRule.replace(/\\\*/g, '.*');
let pattern = escapedRule.replace(/\\\*/g, '.*')
// Add ^ and $ to match the entire string
pattern = '^' + pattern + '$';
pattern = '^' + pattern + '$'
Logger.log("Tray", "wildCardMatch - Generated pattern:", pattern);
Logger.log("Tray", "wildCardMatch - Generated pattern:", pattern)
try {
const regex = new RegExp(pattern, 'i'); // 'i' for case-insensitive
Logger.log("Tray", "wildCardMatch - Regex test result:", regex.test(str));
return regex.test(str);
const regex = new RegExp(pattern, 'i')
// 'i' for case-insensitive
Logger.log("Tray", "wildCardMatch - Regex test result:", regex.test(str))
return regex.test(str)
} catch (e) {
Logger.warn("Tray", "Invalid regex pattern for wildcard match:", rule, e.message);
return false; // If regex is invalid, it won't match
Logger.warn("Tray", "Invalid regex pattern for wildcard match:", rule, e.message)
return false // If regex is invalid, it won't match
}
}
@@ -19,7 +19,9 @@ ColumnLayout {
Component.onCompleted: {
// Populate the ListModel from localBlacklist
for (var i = 0; i < localBlacklist.length; i++) {
blacklistModel.append({"rule": localBlacklist[i]})
blacklistModel.append({
"rule": localBlacklist[i]
})
}
}
@@ -59,7 +61,9 @@ ColumnLayout {
}
}
if (!exists) {
blacklistModel.append({"rule": newRule})
blacklistModel.append({
"rule": newRule
})
newRuleInput.text = ""
}
}
@@ -77,47 +81,47 @@ ColumnLayout {
clip: true
model: blacklistModel
delegate: Item {
width: ListView.width
height: 40 * scaling
width: ListView.width
height: 40 * scaling
Rectangle {
id: itemBackground
anchors.fill: parent
anchors.margins: Style.marginXS * scaling
color: Color.transparent // Make background transparent
border.color: Color.mOutline
border.width: Math.max(1, Style.borderS * scaling)
radius: Style.radiusS * scaling
visible: model.rule !== undefined && model.rule !== "" // Only visible if rule exists
Rectangle {
id: itemBackground
anchors.fill: parent
anchors.margins: Style.marginXS * scaling
color: Color.transparent // Make background transparent
border.color: Color.mOutline
border.width: Math.max(1, Style.borderS * scaling)
radius: Style.radiusS * scaling
visible: model.rule !== undefined && model.rule !== "" // Only visible if rule exists
}
Row {
anchors.fill: parent
anchors.leftMargin: Style.marginS * scaling
anchors.rightMargin: Style.marginS * scaling
spacing: Style.marginS * scaling
NText {
text: model.rule
elide: Text.ElideRight
verticalAlignment: Text.AlignVCenter
Layout.fillWidth: true
}
Row {
anchors.fill: parent
anchors.leftMargin: Style.marginS * scaling
anchors.rightMargin: Style.marginS * scaling
spacing: Style.marginS * scaling
NText {
text: model.rule
elide: Text.ElideRight
verticalAlignment: Text.AlignVCenter
Layout.fillWidth: true
}
NIconButton {
width: 16 * scaling
height: 16 * scaling
icon: "close"
baseSize: 8 * scaling
colorBg: Color.mSurfaceVariant
colorFg: Color.mOnSurface
colorBgHover: Color.mError
colorFgHover: Color.mOnError
onClicked: {
blacklistModel.remove(index)
}
}
NIconButton {
width: 16 * scaling
height: 16 * scaling
icon: "close"
baseSize: 8 * scaling
colorBg: Color.mSurfaceVariant
colorFg: Color.mOnSurface
colorBgHover: Color.mError
colorFgHover: Color.mOnError
onClicked: {
blacklistModel.remove(index)
}
}
}
}
}