From 4948f634edfef3c7484033a563e0aae4d7dbd998 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 6 Sep 2021 12:06:11 +0200 Subject: [PATCH 1/2] [keyboard] Code tidy - complain just once (globally) if ckbcomp is not found, rather than at every update to the layout. - tighten up QStringList constructor. --- .../keyboard/keyboardwidget/keyboardpreview.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/modules/keyboard/keyboardwidget/keyboardpreview.cpp b/src/modules/keyboard/keyboardwidget/keyboardpreview.cpp index 572965de5..0bb1add87 100644 --- a/src/modules/keyboard/keyboardwidget/keyboardpreview.cpp +++ b/src/modules/keyboard/keyboardwidget/keyboardpreview.cpp @@ -124,10 +124,7 @@ KeyBoardPreview::loadCodes() return false; } - QStringList param; - param << "-model" - << "pc106" - << "-layout" << layout << "-compact"; + QStringList param { "-model", "pc106", "-layout", layout, "-compact" }; if ( !variant.isEmpty() ) { param << "-variant" << variant; @@ -140,13 +137,18 @@ KeyBoardPreview::loadCodes() process.start( "ckbcomp", param ); if ( !process.waitForStarted() ) { - cWarning() << "ckbcomp not found , keyboard preview disabled"; + static bool need_warning = true; + if ( need_warning ) + { + cWarning() << "ckbcomp not found , keyboard preview disabled"; + need_warning = false; + } return false; } if ( !process.waitForFinished() ) { - cWarning() << "ckbcomp failed, keyboard preview disabled"; + cWarning() << "ckbcomp failed, keyboard preview skipped for" << layout << variant; return false; } From 44e66c1318221a8eb398dba1a6d7f9ff6903a918 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 6 Sep 2021 13:16:23 +0200 Subject: [PATCH 2/2] [keyboard] Fix mapping for India + English - India (when in English) should use the English variant, not Hindi - While here, fix up minor items in code: - Typo in comment - Asturian doesn't need a special case (which didn't match, anyway) - Don't debug-log a country-name that might be entirely wrong (the layout is English, variant "in" but "in" interpreted as a country is Indonesia, and the actually-desired name is eng_in which isn't a QLocale name at all -- just like the Hausa and Igbo special cases) --- src/modules/keyboard/Config.cpp | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/modules/keyboard/Config.cpp b/src/modules/keyboard/Config.cpp index b77282a18..7140bd790 100644 --- a/src/modules/keyboard/Config.cpp +++ b/src/modules/keyboard/Config.cpp @@ -467,12 +467,12 @@ Config::guessLocaleKeyboardLayout() { "ar_TN", arabic }, { "ar_YE", arabic }, { "ca_ES", "cat_ES" }, /* Catalan */ - { "as_ES", "ast_ES" }, /* Asturian */ { "en_CA", "us" }, /* Canadian English */ { "el_CY", "gr" }, /* Greek in Cyprus */ - { "el_GR", "gr" }, /* Greek in Greeze */ + { "el_GR", "gr" }, /* Greek in Greece */ { "ig_NG", "igbo_NG" }, /* Igbo in Nigeria */ - { "ha_NG", "hausa_NG" } /* Hausa */ + { "ha_NG", "hausa_NG" }, /* Hausa */ + { "en_IN", "eng_in" }, /* India, English with Rupee */ } ); // Try to preselect a layout, depending on language and locale @@ -508,14 +508,7 @@ Config::guessLocaleKeyboardLayout() } if ( !lang.isEmpty() ) { - const auto langParts = lang.split( '_', SplitSkipEmptyParts ); - - // Note that this his string is not fit for display purposes! - // It doesn't come from QLocale::nativeCountryName. - QString country = QLocale::countryToString( QLocale( lang ).country() ); - cDebug() << Logger::SubEntry << "extracted country" << country << "::" << langParts; - - guessLayout( langParts, m_keyboardLayoutsModel, m_keyboardVariantsModel ); + guessLayout( lang.split( '_', SplitSkipEmptyParts ), m_keyboardLayoutsModel, m_keyboardVariantsModel ); } }