From 148f3dfc052bc6a4161073e59505bd547ab347c3 Mon Sep 17 00:00:00 2001 From: Jules Aguillon Date: Wed, 10 Jan 2024 23:39:19 +0100 Subject: prefs: Show custom layout names if provided Show the name of custom layouts in the list if it's provided using the `name` attribute. This should make managing several custom layouts easier. --- srcs/juloo.keyboard2/KeyboardData.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'srcs/juloo.keyboard2/KeyboardData.java') diff --git a/srcs/juloo.keyboard2/KeyboardData.java b/srcs/juloo.keyboard2/KeyboardData.java index ed5aa9a..557e42f 100644 --- a/srcs/juloo.keyboard2/KeyboardData.java +++ b/srcs/juloo.keyboard2/KeyboardData.java @@ -27,6 +27,8 @@ class KeyboardData public final String script; /** Might be different from [script]. Might be null. */ public final String numpad_script; + /** The [name] attribute. Might be null. */ + public final String name; /** Position of every keys on the layout, see [getKeys()]. */ private Map _key_pos = null; @@ -229,6 +231,7 @@ class KeyboardData String numpad_script = parser.getAttributeValue(null, "numpad_script"); if (numpad_script == null) numpad_script = script; + String name = parser.getAttributeValue(null, "name"); ArrayList rows = new ArrayList(); Modmap modmap = null; while (next_tag(parser)) @@ -248,7 +251,7 @@ class KeyboardData float kw = (specified_kw != 0f) ? specified_kw : compute_max_width(rows); if (add_bottom_row) rows.add(bottom_row.updateWidth(kw)); - return new KeyboardData(rows, kw, modmap, script, numpad_script); + return new KeyboardData(rows, kw, modmap, script, numpad_script, name); } private static float compute_max_width(List rows) @@ -266,7 +269,8 @@ class KeyboardData return Row.parse(parser); } - protected KeyboardData(List rows_, float kw, Modmap mm, String sc, String npsc) + protected KeyboardData(List rows_, float kw, Modmap mm, String sc, + String npsc, String name_) { float kh = 0.f; for (Row r : rows_) @@ -275,6 +279,7 @@ class KeyboardData modmap = mm; script = sc; numpad_script = npsc; + name = name_; keysWidth = kw; keysHeight = kh; } @@ -282,7 +287,8 @@ class KeyboardData /** Copies the fields of an other keyboard, with rows changed. */ protected KeyboardData(KeyboardData src, List rows) { - this(rows, compute_max_width(rows), src.modmap, src.script, src.numpad_script); + this(rows, compute_max_width(rows), src.modmap, src.script, + src.numpad_script, src.name); } public static class Row -- cgit v1.2.3