- In many cases, using QLatin1String is a de-optimization, when
applied to a C string literal. Kevin Kofler pointed out that
those should basically all be QStringLiteral, instead. (Compile
tests with -O3 show that in the optimized object file, the
code size difference is negligible).
- Drop the explicit constructor entirely in cases where we're calling
QProcess::execute(), for consistency.
- Do a little less messing around in the mapping of keyboard locales
to keyboard map names.
Use QProcess::execute() with the 'safer' argument-list, rather than
escaping and de-escaping strings. Also reduce noise by only passing
a variant if there is one.
Split locale into <language>_<country> and go looking for keyboard
layouts that match. Do that in reverse, so look for country first.
- known weakness is el_CY (should get layout gr) because CY and el
don't name any keyboard layout.
- known weakness are Hausa, Igbo .. which are ha_NG and ig_NG. They select
keyboard layout ng, which is labeled "English (Nigeria)"; they ought
to select ng(hausa) and ng(igbo), which are the right variant keyboard
layouts to use.
- similar selecting a locale in Canada (en_CA, fr_CA, iu_CA ...) will
select keyboard layout ca, which is for French-speaking Canada.
Locale en_CA should select keyboard en -- e.g. en(us). But iu_CA
(Inuktituk) needs layout ca(ike).
When selecting keyboard layout, pause, then select another, the
QTimer wasn't being disconnected from the previously selected
language, so the second selection would fire the timeout, and
then call *two* slots .. and then three, ... Disconnect when
the timer fires, too.
In order to avoid deep copies, Qt containers over which we iterate must be const
The remaining unported cases require qAsConst (Qt 5.7) or std::as_const (C++17)
This is implemented as a new SetKeyboardLayout job that does the work.
Portions of the code are adapted from systemd-localed's source code,
which is under a compatible license (LGPLv2.1+, can be converted to our
GPLv3+ license). I ported it from C to to C++/Qt and made some minor
tweaks to the mapping logic (from X11 to vconsole layouts) though.
Fixes#31.
Tested on a Fedora Remix (Kannolo 21) with the default module settings
(finds the converted X11 keymaps for the virtual console) and with
convertedKeymapPath: "" (does the legacy keymap conversion as expected).