This commit is contained in:
Ivan Borzenkov 2023-09-07 23:26:21 +03:00
parent ea725da79b
commit 4d00eef822
3 changed files with 13 additions and 10 deletions

View File

@ -30,6 +30,7 @@ This release contains contributions from (alphabetically by first name):
in a Wayland session. (thanks Hector)
- *keyboard* module now writes X11 layout configuration with variants
for all non-ASCII (e.g. us) layouts. (thanks Ivan)
- *keyboard* module now can configure keyboard switch. (thanks Ivan)
# 3.3.0-alpha3 (2023-08-28)

View File

@ -196,7 +196,7 @@ Config::Config( QObject* parent )
[ & ]( int index )
{
m_selectedVariant = m_keyboardVariantsModel->key( index );
Config::xkbChanged();
xkbChanged();
emit prettyStatusChanged();
} );
connect( m_KeyboardGroupSwitcherModel,
@ -204,7 +204,7 @@ Config::Config( QObject* parent )
[ & ]( int index )
{
m_selectedGroup = m_KeyboardGroupSwitcherModel->key( index );
Config::xkbChanged();
xkbChanged();
emit prettyStatusChanged();
} );

View File

@ -213,9 +213,12 @@ parseKeyboardGroupsSwitchers( const char* filepath )
return models;
}
bool modelsFound = findSection( fh, "! option" );
QRegularExpression rx;
rx.setPattern( "^\\s+grp:(\\S+)\\s+(\\w.*)\n$" );
bool optionSectionFound = findSection( fh, "! option" );
// read the file until the end or until we break the loop
while ( modelsFound && !fh.atEnd() )
while ( optionSectionFound && !fh.atEnd() )
{
QByteArray line = fh.readLine();
@ -225,15 +228,14 @@ parseKeyboardGroupsSwitchers( const char* filepath )
break;
}
// here we are in the model section, otherwise we would continue or break
QRegExp rx;
rx.setPattern( "^\\s+grp:(\\S+)\\s+(\\w.*)\n$" );
// here we are in the option section - find all "grp:" options
// insert into the model map
if ( rx.indexIn( line ) != -1 )
QRegularExpressionMatch match = rx.match( line );
if ( match.hasMatch() )
{
QString modelDesc = rx.cap( 2 );
QString model = rx.cap( 1 );
QString modelDesc = match.captured( 2 );
QString model = match.captured( 1 );
models.insert( modelDesc, model );
}
}