• R/O
  • HTTP
  • SSH
  • HTTPS

alterlinux-calamares: Commit

GitHubのミラーです
https://github.com/FascodeNet/alterlinux-calamares


Commit MetaInfo

Revision8b22786bd2366e8c651caf03544288305a0b9815 (tree)
Time2020-09-09 19:21:48
AuthorAdriaan de Groot <groot@kde....>
CommiterAdriaan de Groot

Log Message

Merge branch 'issue-1397' into calamares

Document keyboard change for Turkish F layout, and document
the keyboard configuration value better, with alternate
path used in e.g. openSUSE

FIXES #1397

Change Summary

Incremental Difference

--- a/CHANGES
+++ b/CHANGES
@@ -16,7 +16,9 @@ This release contains contributions from (alphabetically by first name):
1616 - No core changes yet
1717
1818 ## Modules ##
19- - No module changes yet
19+ - The *keyboard* module now recognizes Turkish "F" layout and
20+ will set the vconsole keyboard layout correctly even if xkb
21+ keymaps are not found.
2022
2123
2224 # 3.2.30 (2020-09-03) #
--- a/CMakeModules/CalamaresAddTest.cmake
+++ b/CMakeModules/CalamaresAddTest.cmake
@@ -14,6 +14,7 @@
1414 # calamares_add_test(
1515 # <NAME>
1616 # [GUI]
17+# [RESOURCES FILE]
1718 # SOURCES <FILE..>
1819 # )
1920
@@ -24,13 +25,14 @@ function( calamares_add_test )
2425 # parse arguments (name needs to be saved before passing ARGN into the macro)
2526 set( NAME ${ARGV0} )
2627 set( options GUI )
28+ set( oneValueArgs NAME RESOURCES )
2729 set( multiValueArgs SOURCES LIBRARIES DEFINITIONS )
28- cmake_parse_arguments( TEST "${options}" "" "${multiValueArgs}" ${ARGN} )
30+ cmake_parse_arguments( TEST "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
2931 set( TEST_NAME ${NAME} )
3032
3133 if( ECM_FOUND AND BUILD_TESTING )
3234 ecm_add_test(
33- ${TEST_SOURCES}
35+ ${TEST_SOURCES} ${TEST_RESOURCES}
3436 TEST_NAME
3537 ${TEST_NAME}
3638 LINK_LIBRARIES
@@ -44,5 +46,8 @@ function( calamares_add_test )
4446 if( TEST_GUI )
4547 target_link_libraries( ${TEST_NAME} calamaresui Qt5::Gui )
4648 endif()
49+ if( TEST_RESOURCES )
50+ calamares_autorcc( ${TEST_NAME} ${TEST_RESOURCES} )
51+ endif()
4752 endif()
4853 endfunction()
--- a/src/modules/keyboard/CMakeLists.txt
+++ b/src/modules/keyboard/CMakeLists.txt
@@ -21,3 +21,12 @@ calamares_add_plugin( keyboard
2121 calamaresui
2222 SHARED_LIB
2323 )
24+
25+calamares_add_test(
26+ keyboardtest
27+ SOURCES
28+ Tests.cpp
29+ SetKeyboardLayoutJob.cpp
30+ RESOURCES
31+ keyboard.qrc
32+)
--- a/src/modules/keyboard/SetKeyboardLayoutJob.cpp
+++ b/src/modules/keyboard/SetKeyboardLayoutJob.cpp
@@ -79,16 +79,21 @@ SetKeyboardLayoutJob::findConvertedKeymap( const QString& convertedKeymapPath )
7979 }
8080
8181
82-QString
83-SetKeyboardLayoutJob::findLegacyKeymap() const
82+STATICTEST QString
83+findLegacyKeymap( const QString& layout, const QString& model, const QString& variant )
8484 {
85- cDebug() << "Looking for legacy keymap in QRC";
85+ cDebug() << "Looking for legacy keymap" << layout << model << variant << "in QRC";
8686
8787 int bestMatching = 0;
8888 QString name;
8989
9090 QFile file( ":/kbd-model-map" );
91- file.open( QIODevice::ReadOnly | QIODevice::Text );
91+ if ( !file.open( QIODevice::ReadOnly | QIODevice::Text ) )
92+ {
93+ cDebug() << Logger::SubEntry << "Could not read QRC";
94+ return QString();
95+ }
96+
9297 QTextStream stream( &file );
9398 while ( !stream.atEnd() )
9499 {
@@ -109,20 +114,20 @@ SetKeyboardLayoutJob::findLegacyKeymap() const
109114 // Determine how well matching this entry is
110115 // We assume here that we have one X11 layout. If the UI changes to
111116 // allow more than one layout, this should change too.
112- if ( m_layout == mapping[ 1 ] )
117+ if ( layout == mapping[ 1 ] )
113118 // If we got an exact match, this is best
114119 {
115120 matching = 10;
116121 }
117122 // Look for an entry whose first layout matches ours
118- else if ( mapping[ 1 ].startsWith( m_layout + ',' ) )
123+ else if ( mapping[ 1 ].startsWith( layout + ',' ) )
119124 {
120125 matching = 5;
121126 }
122127
123128 if ( matching > 0 )
124129 {
125- if ( m_model.isEmpty() || m_model == mapping[ 2 ] )
130+ if ( model.isEmpty() || model == mapping[ 2 ] )
126131 {
127132 matching++;
128133 }
@@ -137,7 +142,7 @@ SetKeyboardLayoutJob::findLegacyKeymap() const
137142 mappingVariant.remove( 1, 0 );
138143 }
139144
140- if ( m_variant == mappingVariant )
145+ if ( variant == mappingVariant )
141146 {
142147 matching++;
143148 }
@@ -162,6 +167,12 @@ SetKeyboardLayoutJob::findLegacyKeymap() const
162167 return name;
163168 }
164169
170+QString
171+SetKeyboardLayoutJob::findLegacyKeymap() const
172+{
173+ return ::findLegacyKeymap( m_layout, m_model, m_variant );
174+}
175+
165176
166177 bool
167178 SetKeyboardLayoutJob::writeVConsoleData( const QString& vconsoleConfPath, const QString& convertedKeymapPath ) const
--- /dev/null
+++ b/src/modules/keyboard/Tests.cpp
@@ -0,0 +1,67 @@
1+/* === This file is part of Calamares - <https://calamares.io> ===
2+ *
3+ * SPDX-FileCopyrightText: 2020 Adriaan de Groot <groot@kde.org>
4+ * SPDX-License-Identifier: GPL-3.0-or-later
5+ *
6+ * Calamares is Free Software: see the License-Identifier above.
7+ *
8+ */
9+#include "utils/Logger.h"
10+
11+#include <QtTest/QtTest>
12+
13+// Internals of SetKeyboardLayoutJob.cpp
14+extern QString findLegacyKeymap( const QString& layout, const QString& model, const QString& variant );
15+
16+class KeyboardLayoutTests : public QObject
17+{
18+ Q_OBJECT
19+public:
20+ KeyboardLayoutTests() {}
21+ virtual ~KeyboardLayoutTests() {}
22+
23+private Q_SLOTS:
24+ void initTestCase();
25+
26+ void testSimpleLayoutLookup_data();
27+ void testSimpleLayoutLookup();
28+};
29+
30+void
31+KeyboardLayoutTests::initTestCase()
32+{
33+ Logger::setupLogLevel( Logger::LOGDEBUG );
34+}
35+
36+void
37+KeyboardLayoutTests::testSimpleLayoutLookup_data()
38+{
39+ QTest::addColumn< QString >( "layout" );
40+ QTest::addColumn< QString >( "model" );
41+ QTest::addColumn< QString >( "variant" );
42+ QTest::addColumn< QString >( "vconsole" );
43+
44+ QTest::newRow( "us" ) << QString( "us" ) << QString() << QString() << QString( "us" );
45+ QTest::newRow( "turkish default" ) << QString( "tr" ) << QString() << QString() << QString( "trq" );
46+ QTest::newRow( "turkish alt-q" ) << QString( "tr" ) << QString() << QString( "alt" ) << QString( "trq" );
47+ QTest::newRow( "turkish f" ) << QString( "tr" ) << QString() << QString( "f" ) << QString( "trf" );
48+}
49+
50+
51+void
52+KeyboardLayoutTests::testSimpleLayoutLookup()
53+{
54+ QFETCH( QString, layout );
55+ QFETCH( QString, model );
56+ QFETCH( QString, variant );
57+ QFETCH( QString, vconsole );
58+
59+ QCOMPARE( findLegacyKeymap( layout, model, variant ), vconsole );
60+}
61+
62+
63+QTEST_GUILESS_MAIN( KeyboardLayoutTests )
64+
65+#include "utils/moc-warnings.h"
66+
67+#include "Tests.moc"
--- a/src/modules/keyboard/kbd-model-map
+++ b/src/modules/keyboard/kbd-model-map
@@ -12,6 +12,13 @@
1212 #
1313 # Updates:
1414 # - 2018-09-26 Added "Austrian" keyboard (de at). Issue #1035
15+# - 2020-09-09 Added "Turkish F" keyboard. Issue #1397
16+#
17+# Note that keyboard variants should be listed from least to most-specific
18+# within a layout. Keyboard lookups only consider a subsequent
19+# line if it has a strictly better match than previous ones:
20+# listing specific variants early can mean a poor match with them
21+# is not overridden by a poor match with a later generic variant.
1522 #
1623 # Generated from system-config-keyboard's model list
1724 # consolelayout xlayout xmodel xvariant xoptions
@@ -19,6 +26,7 @@ sg ch pc105 de_nodeadkeys terminate:ctrl_alt_bksp
1926 nl nl pc105 - terminate:ctrl_alt_bksp
2027 mk-utf mk,us pc105 - terminate:ctrl_alt_bksp,grp:shifts_toggle,grp_led:scroll
2128 trq tr pc105 - terminate:ctrl_alt_bksp
29+trf tr pc105 f terminate:ctrl_alt_bksp
2230 uk gb pc105 - terminate:ctrl_alt_bksp
2331 is-latin1 is pc105 - terminate:ctrl_alt_bksp
2432 de de pc105 - terminate:ctrl_alt_bksp
--- a/src/modules/keyboard/keyboard.conf
+++ b/src/modules/keyboard/keyboard.conf
@@ -9,8 +9,12 @@
99 # Relative paths are assumed to be relative to /etc/X11/xorg.conf.d
1010 xOrgConfFileName: "/etc/X11/xorg.conf.d/00-keyboard.conf"
1111
12-# The path to search for keymaps converted from X11 to kbd format
12+# The path to search for keymaps converted from X11 to kbd format.
13+# Common paths for this are:
14+# - /lib/kbd/keymaps/xkb
15+# - /usr/share/kbd/keymaps/xkb
1316 # Leave this empty if the setting does not make sense on your distribution.
17+#
1418 convertedKeymapPath: "/lib/kbd/keymaps/xkb"
1519
1620 # Write keymap configuration to /etc/default/keyboard, usually
Show on old repository browser