Fix cleared key bindings not being reloaded

This commit is contained in:
Alexander Babikov
2025-04-23 12:49:29 +05:00
parent 52ebe22bd1
commit 79cefc5299

View File

@@ -1774,9 +1774,12 @@ load_keybinds(void)
/* Now load values from config */ /* Now load values from config */
for (int x = 0; x < NUM_ACCELS; x++) { for (int x = 0; x < NUM_ACCELS; x++) {
p = ini_section_get_string(cat, acc_keys[x].name, "none"); p = ini_section_get_string(cat, acc_keys[x].name, "default");
/* Check if the binding was marked as cleared */
if (strcmp(p, "none") == 0)
acc_keys[x].seq[0] = '\0';
/* If there's no binding in the file, leave it alone. */ /* If there's no binding in the file, leave it alone. */
if (strcmp(p, "none") != 0) { else if (strcmp(p, "default") != 0) {
/* /*
It would be ideal to validate whether the user entered a It would be ideal to validate whether the user entered a
valid combo at this point, but the Qt method for testing that is valid combo at this point, but the Qt method for testing that is
@@ -2527,6 +2530,9 @@ save_keybinds(void)
/* Has accelerator been changed from default? */ /* Has accelerator been changed from default? */
if (strcmp(def_acc_keys[x].seq, acc_keys[x].seq) == 0) if (strcmp(def_acc_keys[x].seq, acc_keys[x].seq) == 0)
ini_section_delete_var(cat, acc_keys[x].name); ini_section_delete_var(cat, acc_keys[x].name);
/* Check for a cleared binding to avoid saving it as an empty string */
else if (acc_keys[x].seq[0] == '\0')
ini_section_set_string(cat, acc_keys[x].name, "none");
else else
ini_section_set_string(cat, acc_keys[x].name, acc_keys[x].seq); ini_section_set_string(cat, acc_keys[x].name, acc_keys[x].seq);
} }