kcms/keyboard: Improve preview of keyboard layouts
We have a nice tool to display previews of the keyboard layouts (tastenbrett
), using their reported geometry via XKB.
The looks are a bit rough though, so let's polish some rough edges (literally!)
How to Test
- Within the KCM keyboard selecting "Preview layout" on a certain layout
- or more easily using the CLI to show the different models and language layouts:
tastenbrett -m pc104 -l us
tastenbrett -m pc105 -l es
tastenbrett -m thinkpad -l us
tastenbrett -m microsoft -l us
Some general screenshots
BEFORE | AFTER | |
---|---|---|
US PC104 | ||
ES PC105 | ||
Thinkpad | ||
LK PC86 | ||
ISO Return key | ||
Hide ISO prefix (latest commit) | ||
Hide KP prefix (latest commit) |
Commits
Changes are split out in different commits but it is my idea to merge them as necessary
-
Use the defined colors to draw keys, labels and shapes
-
Do not draw outlines for shapes
Except when it is an explicit outline or for the key tooltips
-
Respect corner radius for complex shapes (ex. Return ISO key)
Use
arcTo
to draw the corners of the shapes so they match the aspect of simpler rectangles -
Center the labels on complex shaped keys
We cannot adapt easily to the actual key shape, but by centering the text it is less likely to be out of bounds.
Mainly fixes the Return text cutting the shape on ISO layouts
-
Reduce visual impact of 3rd/4th level symbols
On layouts that make use of 3rd level symbols (Alt-Gr), those are useful to show but very heavy visually, so let's reduce their impact to make the layout more clear
-
Improve text sizing for keycaps
Use a fixed point size for labels instead of adapting to height individually, which leads to high inconsistencies between them.
Use a higher font size for single characters (leters, numbers, symbols) and a smaller one for command keys. Values were chosen empirically.
In case the text is still longer than the avilable width, let's still use
Text.Fit
but allowing to wrap up to two lines, which improves cases likeNum Lock
-
Remove repeated code to replace "_"
-
Hide unnecessary keycap prefixes like ISO or KP
They can take up necessary space like in "ISO Left Tab"