mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-10-28 14:07:47 -04:00
fix(settings-search): resolve placeholders (#3985)
port 2.0
(cherry picked from commit 083b9c55e2)
This commit is contained in:
1 parent
15ddcf2ae1
commit
d90ff54ab9
6 files changed
+54
-7
No files matched your search
@@ -18,6 +18,8 @@ Item {
|
||||
property bool pendingAdmin: false
|
||||
property bool pendingGreeter: false
|
||||
|
||||
Component.onCompleted: UsersService.refresh()
|
||||
|
||||
function _resetForm() {
|
||||
pendingUsername = "";
|
||||
pendingPassword = "";
|
||||
|
||||
@@ -15,6 +15,9 @@ Item {
|
||||
property string statusText: ""
|
||||
property bool statusIsError: false
|
||||
property bool operationPending: false
|
||||
|
||||
Component.onCompleted: UsersService.refresh()
|
||||
|
||||
Connections {
|
||||
target: UsersService
|
||||
function onOperationCompleted(op, username, success, message) {
|
||||
|
||||
@@ -49,6 +49,18 @@ Singleton {
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: UsersService
|
||||
|
||||
function onAdminGroupChanged() {
|
||||
root._refreshTranslatedCache();
|
||||
}
|
||||
|
||||
function onGreeterGroupChanged() {
|
||||
root._refreshTranslatedCache();
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: SettingsTabs
|
||||
|
||||
@@ -362,7 +374,21 @@ Singleton {
|
||||
function _withArgs(text, args) {
|
||||
if (!args)
|
||||
return text;
|
||||
return args.reduce((acc, arg) => acc.arg(arg), text);
|
||||
return args.reduce((acc, arg) => acc.arg(_descriptionArgument(arg)), text);
|
||||
}
|
||||
|
||||
function _descriptionArgument(arg) {
|
||||
if (typeof arg === "string")
|
||||
return arg;
|
||||
if (arg?.service !== "UsersService")
|
||||
return "";
|
||||
switch (arg.property) {
|
||||
case "adminGroup":
|
||||
case "greeterGroup":
|
||||
return UsersService[arg.property];
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
function _rebuildTranslationCache() {
|
||||
|
||||
@@ -477,5 +477,4 @@ Singleton {
|
||||
proc.running = true;
|
||||
}
|
||||
|
||||
Component.onCompleted: refresh()
|
||||
}
|
||||
@@ -279,14 +279,18 @@ def enrich_keywords(label, description, category, existing_tags, parent_label=No
|
||||
|
||||
|
||||
def literal_args(value):
|
||||
"""Positional .arg() values after the first I18n.tr call, None where the arg is not a string literal."""
|
||||
"""Extract literal and supported runtime .arg() values from a setting description."""
|
||||
call_tail = value.split("I18n.tr(", 1)[-1].split("I18n.tr(", 1)[0]
|
||||
args = []
|
||||
for match in re.finditer(r"\.arg\(\s*(?:" + STR_DQ + "|" + STR_SQ + r")?", call_tail):
|
||||
pattern = r"\.arg\(\s*(?:" + STR_DQ + "|" + STR_SQ + r"|(?P<dynamic>UsersService\.(?:adminGroup|greeterGroup)))?"
|
||||
for match in re.finditer(pattern, call_tail):
|
||||
if match.group(1) is not None:
|
||||
args.append(decode_string_literal(match.group(1), '"'))
|
||||
elif match.group(2) is not None:
|
||||
args.append(decode_string_literal(match.group(2), "'"))
|
||||
elif match.group("dynamic") is not None:
|
||||
service, prop = match.group("dynamic").split(".", 1)
|
||||
args.append({"service": service, "property": prop})
|
||||
else:
|
||||
args.append(None)
|
||||
return args
|
||||
@@ -294,7 +298,7 @@ def literal_args(value):
|
||||
|
||||
def apply_args(text, args):
|
||||
for index, arg in enumerate(args, start=1):
|
||||
if arg is not None:
|
||||
if isinstance(arg, str):
|
||||
text = text.replace(f"%{index}", arg)
|
||||
return text
|
||||
|
||||
|
||||
@@ -17282,7 +17282,14 @@
|
||||
"users"
|
||||
],
|
||||
"parentLabel": "Users & accounts",
|
||||
"description": "Adds them to the %1 group so they can run %2"
|
||||
"description": "Adds them to the %1 group so they can run %2",
|
||||
"descriptionArgs": [
|
||||
{
|
||||
"service": "UsersService",
|
||||
"property": "greeterGroup"
|
||||
},
|
||||
"dms-greeter sync --profile"
|
||||
]
|
||||
},
|
||||
{
|
||||
"section": "createUserAdmin",
|
||||
@@ -17305,7 +17312,13 @@
|
||||
"wheel"
|
||||
],
|
||||
"parentLabel": "Users & accounts",
|
||||
"description": "Adds them to the %1 group so they can use sudo"
|
||||
"description": "Adds them to the %1 group so they can use sudo",
|
||||
"descriptionArgs": [
|
||||
{
|
||||
"service": "UsersService",
|
||||
"property": "adminGroup"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"section": "greeterAuth",
|
||||
|
||||
Reference in new issue
Block a user