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
This commit is contained in:
commit
8b22786bd2
4
CHANGES
4
CHANGES
@ -16,7 +16,9 @@ This release contains contributions from (alphabetically by first name):
|
||||
- No core changes yet
|
||||
|
||||
## Modules ##
|
||||
- No module changes yet
|
||||
- The *keyboard* module now recognizes Turkish "F" layout and
|
||||
will set the vconsole keyboard layout correctly even if xkb
|
||||
keymaps are not found.
|
||||
|
||||
|
||||
# 3.2.30 (2020-09-03) #
|
||||
|
@ -14,6 +14,7 @@
|
||||
# calamares_add_test(
|
||||
# <NAME>
|
||||
# [GUI]
|
||||
# [RESOURCES FILE]
|
||||
# SOURCES <FILE..>
|
||||
# )
|
||||
|
||||
@ -24,13 +25,14 @@ function( calamares_add_test )
|
||||
# parse arguments (name needs to be saved before passing ARGN into the macro)
|
||||
set( NAME ${ARGV0} )
|
||||
set( options GUI )
|
||||
set( oneValueArgs NAME RESOURCES )
|
||||
set( multiValueArgs SOURCES LIBRARIES DEFINITIONS )
|
||||
cmake_parse_arguments( TEST "${options}" "" "${multiValueArgs}" ${ARGN} )
|
||||
cmake_parse_arguments( TEST "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
|
||||
set( TEST_NAME ${NAME} )
|
||||
|
||||
if( ECM_FOUND AND BUILD_TESTING )
|
||||
ecm_add_test(
|
||||
${TEST_SOURCES}
|
||||
${TEST_SOURCES} ${TEST_RESOURCES}
|
||||
TEST_NAME
|
||||
${TEST_NAME}
|
||||
LINK_LIBRARIES
|
||||
@ -44,5 +46,8 @@ function( calamares_add_test )
|
||||
if( TEST_GUI )
|
||||
target_link_libraries( ${TEST_NAME} calamaresui Qt5::Gui )
|
||||
endif()
|
||||
if( TEST_RESOURCES )
|
||||
calamares_autorcc( ${TEST_NAME} ${TEST_RESOURCES} )
|
||||
endif()
|
||||
endif()
|
||||
endfunction()
|
||||
|
@ -21,3 +21,12 @@ calamares_add_plugin( keyboard
|
||||
calamaresui
|
||||
SHARED_LIB
|
||||
)
|
||||
|
||||
calamares_add_test(
|
||||
keyboardtest
|
||||
SOURCES
|
||||
Tests.cpp
|
||||
SetKeyboardLayoutJob.cpp
|
||||
RESOURCES
|
||||
keyboard.qrc
|
||||
)
|
||||
|
@ -79,16 +79,21 @@ SetKeyboardLayoutJob::findConvertedKeymap( const QString& convertedKeymapPath )
|
||||
}
|
||||
|
||||
|
||||
QString
|
||||
SetKeyboardLayoutJob::findLegacyKeymap() const
|
||||
STATICTEST QString
|
||||
findLegacyKeymap( const QString& layout, const QString& model, const QString& variant )
|
||||
{
|
||||
cDebug() << "Looking for legacy keymap in QRC";
|
||||
cDebug() << "Looking for legacy keymap" << layout << model << variant << "in QRC";
|
||||
|
||||
int bestMatching = 0;
|
||||
QString name;
|
||||
|
||||
QFile file( ":/kbd-model-map" );
|
||||
file.open( QIODevice::ReadOnly | QIODevice::Text );
|
||||
if ( !file.open( QIODevice::ReadOnly | QIODevice::Text ) )
|
||||
{
|
||||
cDebug() << Logger::SubEntry << "Could not read QRC";
|
||||
return QString();
|
||||
}
|
||||
|
||||
QTextStream stream( &file );
|
||||
while ( !stream.atEnd() )
|
||||
{
|
||||
@ -109,20 +114,20 @@ SetKeyboardLayoutJob::findLegacyKeymap() const
|
||||
// Determine how well matching this entry is
|
||||
// We assume here that we have one X11 layout. If the UI changes to
|
||||
// allow more than one layout, this should change too.
|
||||
if ( m_layout == mapping[ 1 ] )
|
||||
if ( layout == mapping[ 1 ] )
|
||||
// If we got an exact match, this is best
|
||||
{
|
||||
matching = 10;
|
||||
}
|
||||
// Look for an entry whose first layout matches ours
|
||||
else if ( mapping[ 1 ].startsWith( m_layout + ',' ) )
|
||||
else if ( mapping[ 1 ].startsWith( layout + ',' ) )
|
||||
{
|
||||
matching = 5;
|
||||
}
|
||||
|
||||
if ( matching > 0 )
|
||||
{
|
||||
if ( m_model.isEmpty() || m_model == mapping[ 2 ] )
|
||||
if ( model.isEmpty() || model == mapping[ 2 ] )
|
||||
{
|
||||
matching++;
|
||||
}
|
||||
@ -137,7 +142,7 @@ SetKeyboardLayoutJob::findLegacyKeymap() const
|
||||
mappingVariant.remove( 1, 0 );
|
||||
}
|
||||
|
||||
if ( m_variant == mappingVariant )
|
||||
if ( variant == mappingVariant )
|
||||
{
|
||||
matching++;
|
||||
}
|
||||
@ -162,6 +167,12 @@ SetKeyboardLayoutJob::findLegacyKeymap() const
|
||||
return name;
|
||||
}
|
||||
|
||||
QString
|
||||
SetKeyboardLayoutJob::findLegacyKeymap() const
|
||||
{
|
||||
return ::findLegacyKeymap( m_layout, m_model, m_variant );
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
SetKeyboardLayoutJob::writeVConsoleData( const QString& vconsoleConfPath, const QString& convertedKeymapPath ) const
|
||||
|
67
src/modules/keyboard/Tests.cpp
Normal file
67
src/modules/keyboard/Tests.cpp
Normal file
@ -0,0 +1,67 @@
|
||||
/* === This file is part of Calamares - <https://calamares.io> ===
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2020 Adriaan de Groot <groot@kde.org>
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*
|
||||
* Calamares is Free Software: see the License-Identifier above.
|
||||
*
|
||||
*/
|
||||
#include "utils/Logger.h"
|
||||
|
||||
#include <QtTest/QtTest>
|
||||
|
||||
// Internals of SetKeyboardLayoutJob.cpp
|
||||
extern QString findLegacyKeymap( const QString& layout, const QString& model, const QString& variant );
|
||||
|
||||
class KeyboardLayoutTests : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
KeyboardLayoutTests() {}
|
||||
virtual ~KeyboardLayoutTests() {}
|
||||
|
||||
private Q_SLOTS:
|
||||
void initTestCase();
|
||||
|
||||
void testSimpleLayoutLookup_data();
|
||||
void testSimpleLayoutLookup();
|
||||
};
|
||||
|
||||
void
|
||||
KeyboardLayoutTests::initTestCase()
|
||||
{
|
||||
Logger::setupLogLevel( Logger::LOGDEBUG );
|
||||
}
|
||||
|
||||
void
|
||||
KeyboardLayoutTests::testSimpleLayoutLookup_data()
|
||||
{
|
||||
QTest::addColumn< QString >( "layout" );
|
||||
QTest::addColumn< QString >( "model" );
|
||||
QTest::addColumn< QString >( "variant" );
|
||||
QTest::addColumn< QString >( "vconsole" );
|
||||
|
||||
QTest::newRow( "us" ) << QString( "us" ) << QString() << QString() << QString( "us" );
|
||||
QTest::newRow( "turkish default" ) << QString( "tr" ) << QString() << QString() << QString( "trq" );
|
||||
QTest::newRow( "turkish alt-q" ) << QString( "tr" ) << QString() << QString( "alt" ) << QString( "trq" );
|
||||
QTest::newRow( "turkish f" ) << QString( "tr" ) << QString() << QString( "f" ) << QString( "trf" );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
KeyboardLayoutTests::testSimpleLayoutLookup()
|
||||
{
|
||||
QFETCH( QString, layout );
|
||||
QFETCH( QString, model );
|
||||
QFETCH( QString, variant );
|
||||
QFETCH( QString, vconsole );
|
||||
|
||||
QCOMPARE( findLegacyKeymap( layout, model, variant ), vconsole );
|
||||
}
|
||||
|
||||
|
||||
QTEST_GUILESS_MAIN( KeyboardLayoutTests )
|
||||
|
||||
#include "utils/moc-warnings.h"
|
||||
|
||||
#include "Tests.moc"
|
@ -12,6 +12,13 @@
|
||||
#
|
||||
# Updates:
|
||||
# - 2018-09-26 Added "Austrian" keyboard (de at). Issue #1035
|
||||
# - 2020-09-09 Added "Turkish F" keyboard. Issue #1397
|
||||
#
|
||||
# Note that keyboard variants should be listed from least to most-specific
|
||||
# within a layout. Keyboard lookups only consider a subsequent
|
||||
# line if it has a strictly better match than previous ones:
|
||||
# listing specific variants early can mean a poor match with them
|
||||
# is not overridden by a poor match with a later generic variant.
|
||||
#
|
||||
# Generated from system-config-keyboard's model list
|
||||
# consolelayout xlayout xmodel xvariant xoptions
|
||||
@ -19,6 +26,7 @@ sg ch pc105 de_nodeadkeys terminate:ctrl_alt_bksp
|
||||
nl nl pc105 - terminate:ctrl_alt_bksp
|
||||
mk-utf mk,us pc105 - terminate:ctrl_alt_bksp,grp:shifts_toggle,grp_led:scroll
|
||||
trq tr pc105 - terminate:ctrl_alt_bksp
|
||||
trf tr pc105 f terminate:ctrl_alt_bksp
|
||||
uk gb pc105 - terminate:ctrl_alt_bksp
|
||||
is-latin1 is pc105 - terminate:ctrl_alt_bksp
|
||||
de de pc105 - terminate:ctrl_alt_bksp
|
||||
|
@ -9,8 +9,12 @@
|
||||
# Relative paths are assumed to be relative to /etc/X11/xorg.conf.d
|
||||
xOrgConfFileName: "/etc/X11/xorg.conf.d/00-keyboard.conf"
|
||||
|
||||
# The path to search for keymaps converted from X11 to kbd format
|
||||
# The path to search for keymaps converted from X11 to kbd format.
|
||||
# Common paths for this are:
|
||||
# - /lib/kbd/keymaps/xkb
|
||||
# - /usr/share/kbd/keymaps/xkb
|
||||
# Leave this empty if the setting does not make sense on your distribution.
|
||||
#
|
||||
convertedKeymapPath: "/lib/kbd/keymaps/xkb"
|
||||
|
||||
# Write keymap configuration to /etc/default/keyboard, usually
|
||||
|
Loading…
Reference in New Issue
Block a user