From 4d00eef8220db0de3502bc884f66030ebacaf494 Mon Sep 17 00:00:00 2001 From: Ivan Borzenkov Date: Thu, 7 Sep 2023 23:26:21 +0300 Subject: [PATCH] fixes --- CHANGES-3.3 | 1 + src/modules/keyboard/Config.cpp | 4 ++-- .../keyboard/keyboardwidget/keyboardglobal.cpp | 18 ++++++++++-------- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/CHANGES-3.3 b/CHANGES-3.3 index ca3a02813..7add5ca5d 100644 --- a/CHANGES-3.3 +++ b/CHANGES-3.3 @@ -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) diff --git a/src/modules/keyboard/Config.cpp b/src/modules/keyboard/Config.cpp index 9cd23d059..785f12458 100644 --- a/src/modules/keyboard/Config.cpp +++ b/src/modules/keyboard/Config.cpp @@ -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(); } ); diff --git a/src/modules/keyboard/keyboardwidget/keyboardglobal.cpp b/src/modules/keyboard/keyboardwidget/keyboardglobal.cpp index 0e0fea010..83b8d825f 100644 --- a/src/modules/keyboard/keyboardwidget/keyboardglobal.cpp +++ b/src/modules/keyboard/keyboardwidget/keyboardglobal.cpp @@ -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 ); } }