1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
|
import QtQuick
import QtQuick.Layouts
import qs.Commons
import qs.Widgets
ColumnLayout {
id: root
property var pluginApi: null
property var cfg: pluginApi?.pluginSettings || ({})
property var defaults: pluginApi?.manifest?.metadata?.defaultSettings || ({})
property bool hideInactive: cfg.hideInactive ?? defaults.hideInactive ?? false
property bool enableToast: cfg.enableToast ?? defaults.enableToast ?? true
property bool removeMargins: cfg.removeMargins ?? defaults.removeMargins ?? false
property int iconSpacing: cfg.iconSpacing ?? defaults.iconSpacing ?? 4
property string activeColor: cfg.activeColor ?? defaults.activeColor ?? "primary"
property string inactiveColor: cfg.inactiveColor ?? defaults.inactiveColor ?? "none"
property string micFilterRegex: cfg.micFilterRegex ?? defaults.micFilterRegex
property string camFilterRegex: cfg.camFilterRegex ?? defaults.camFilterRegex
spacing: Style.marginL
Component.onCompleted: {
Logger.i("PrivacyIndicator", "Settings UI loaded");
}
ColumnLayout {
spacing: Style.marginM
Layout.fillWidth: true
NToggle {
label: pluginApi?.tr("settings.hideInactive.label")
description: pluginApi?.tr("settings.hideInactive.desc")
checked: root.hideInactive
onToggled: checked => {
root.hideInactive = checked;
}
}
NToggle {
label: pluginApi?.tr("settings.enableToast.label")
description: pluginApi?.tr("settings.enableToast.desc")
checked: root.enableToast
onToggled: checked => {
root.enableToast = checked;
}
}
NToggle {
label: pluginApi?.tr("settings.removeMargins.label")
description: pluginApi?.tr("settings.removeMargins.desc")
checked: root.removeMargins
onToggled: checked => {
root.removeMargins = checked;
}
}
NColorChoice {
label: pluginApi?.tr("settings.activeColor.label")
description: pluginApi?.tr("settings.activeColor.desc")
currentKey: root.activeColor
onSelected: key => root.activeColor = key
}
NColorChoice {
label: pluginApi?.tr("settings.inactiveColor.label")
description: pluginApi?.tr("settings.inactiveColor.desc")
currentKey: root.inactiveColor
onSelected: key => root.inactiveColor = key
noneColor: Qt.alpha(Color.mOnSurfaceVariant, 0.3)
noneOnColor: Qt.alpha(Color.mOnSurface, 0.7)
}
NComboBox {
label: pluginApi?.tr("settings.iconSpacing.label")
description: pluginApi?.tr("settings.iconSpacing.desc")
model: {
const labels = ["XXS", "XS", "S", "M", "L", "XL"];
const values = [Style.marginXXS, Style.marginXS, Style.marginS, Style.marginM, Style.marginL, Style.marginXL];
const result = [];
for (var i = 0; i < labels.length; ++i) {
const v = values[i];
result.push({
key: v.toFixed(0),
name: `${labels[i]} (${v}px)`
});
}
return result;
}
// INFO: From my understanding, the toFixed(0) shouldn't be needed here and there, but without the
// current key does not show when opening the settings window.
currentKey: root.iconSpacing.toFixed(0)
onSelected: key => root.iconSpacing = key
}
NTextInput {
Layout.fillWidth: true
label: pluginApi?.tr("settings.micFilterRegex.label")
description: pluginApi?.tr("settings.micFilterRegex.desc")
placeholderText: "effect_input.rnnoise|easyeffects"
text: root.micFilterRegex
onTextChanged: root.micFilterRegex = text
}
NTextInput {
Layout.fillWidth: true
label: pluginApi?.tr("settings.camFilterRegex.label")
description: pluginApi?.tr("settings.camFilterRegex.desc")
placeholderText: "droidcam"
text: root.camFilterRegex
onTextChanged: root.camFilterRegex = text
}
}
function saveSettings() {
if (!pluginApi) {
Logger.e("PrivacyIndicator", "Cannot save settings: pluginApi is null");
return;
}
pluginApi.pluginSettings.hideInactive = root.hideInactive;
pluginApi.pluginSettings.enableToast = root.enableToast;
pluginApi.pluginSettings.iconSpacing = root.iconSpacing;
pluginApi.pluginSettings.removeMargins = root.removeMargins;
pluginApi.pluginSettings.activeColor = root.activeColor;
pluginApi.pluginSettings.inactiveColor = root.inactiveColor;
pluginApi.pluginSettings.micFilterRegex = root.micFilterRegex;
pluginApi.pluginSettings.camFilterRegex = root.camFilterRegex;
pluginApi.saveSettings();
Logger.i("PrivacyIndicator", "Settings saved successfully");
}
}
|