mirror of
https://github.com/parchlinux/calamares.git
synced 2025-07-01 19:35:36 -04:00
[keyboard] Factor out lambdas to regular slots
- Long and complicated, nested, lambdas are not convenient for reasoning. - The debug messages from the innermost lambda have a totally useless function name, which makes debugging harder.
This commit is contained in:
parent
d6825c4986
commit
f38b518e86
2 changed files with 64 additions and 42 deletions
|
@ -168,54 +168,64 @@ Config::Config( QObject* parent )
|
|||
emit prettyStatusChanged();
|
||||
} );
|
||||
|
||||
connect( m_keyboardVariantsModel, &KeyboardVariantsModel::currentIndexChanged, [&]( int index ) {
|
||||
// Set Xorg keyboard layout + variant
|
||||
m_selectedVariant = m_keyboardVariantsModel->key( index );
|
||||
|
||||
if ( m_setxkbmapTimer.isActive() )
|
||||
{
|
||||
m_setxkbmapTimer.stop();
|
||||
m_setxkbmapTimer.disconnect( this );
|
||||
}
|
||||
|
||||
connect( &m_setxkbmapTimer, &QTimer::timeout, this, [=] {
|
||||
m_additionalLayoutInfo = getAdditionalLayoutInfo( m_selectedLayout );
|
||||
|
||||
if ( !m_additionalLayoutInfo.additionalLayout.isEmpty() )
|
||||
{
|
||||
m_additionalLayoutInfo.groupSwitcher = xkbmap_query_grp_option();
|
||||
|
||||
if ( m_additionalLayoutInfo.groupSwitcher.isEmpty() )
|
||||
{
|
||||
m_additionalLayoutInfo.groupSwitcher = "grp:alt_shift_toggle";
|
||||
}
|
||||
|
||||
QProcess::execute( "setxkbmap",
|
||||
xkbmap_layout_args( { m_additionalLayoutInfo.additionalLayout, m_selectedLayout },
|
||||
{ m_additionalLayoutInfo.additionalVariant, m_selectedVariant },
|
||||
m_additionalLayoutInfo.groupSwitcher ) );
|
||||
|
||||
|
||||
cDebug() << "xkbmap selection changed to: " << m_selectedLayout << '-' << m_selectedVariant << "(added "
|
||||
<< m_additionalLayoutInfo.additionalLayout << "-" << m_additionalLayoutInfo.additionalVariant
|
||||
<< " since current layout is not ASCII-capable)";
|
||||
}
|
||||
else
|
||||
{
|
||||
QProcess::execute( "setxkbmap", xkbmap_layout_args( m_selectedLayout, m_selectedVariant ) );
|
||||
cDebug() << "xkbmap selection changed to: " << m_selectedLayout << '-' << m_selectedVariant;
|
||||
}
|
||||
m_setxkbmapTimer.disconnect( this );
|
||||
} );
|
||||
m_setxkbmapTimer.start( QApplication::keyboardInputInterval() );
|
||||
emit prettyStatusChanged();
|
||||
} );
|
||||
connect( m_keyboardVariantsModel, &KeyboardVariantsModel::currentIndexChanged, this, &Config::xkbChanged );
|
||||
|
||||
m_selectedModel = m_keyboardModelsModel->key( m_keyboardModelsModel->currentIndex() );
|
||||
m_selectedLayout = m_keyboardLayoutsModel->item( m_keyboardLayoutsModel->currentIndex() ).first;
|
||||
m_selectedVariant = m_keyboardVariantsModel->key( m_keyboardVariantsModel->currentIndex() );
|
||||
}
|
||||
|
||||
void
|
||||
Config::xkbChanged( int index )
|
||||
{
|
||||
// Set Xorg keyboard layout + variant
|
||||
m_selectedVariant = m_keyboardVariantsModel->key( index );
|
||||
|
||||
if ( m_setxkbmapTimer.isActive() )
|
||||
{
|
||||
m_setxkbmapTimer.stop();
|
||||
m_setxkbmapTimer.disconnect( this );
|
||||
}
|
||||
|
||||
connect( &m_setxkbmapTimer, &QTimer::timeout, this, &Config::xkbApply );
|
||||
|
||||
m_setxkbmapTimer.start( QApplication::keyboardInputInterval() );
|
||||
emit prettyStatusChanged();
|
||||
}
|
||||
|
||||
void
|
||||
Config::xkbApply()
|
||||
{
|
||||
m_additionalLayoutInfo = getAdditionalLayoutInfo( m_selectedLayout );
|
||||
|
||||
if ( !m_additionalLayoutInfo.additionalLayout.isEmpty() )
|
||||
{
|
||||
m_additionalLayoutInfo.groupSwitcher = xkbmap_query_grp_option();
|
||||
|
||||
if ( m_additionalLayoutInfo.groupSwitcher.isEmpty() )
|
||||
{
|
||||
m_additionalLayoutInfo.groupSwitcher = "grp:alt_shift_toggle";
|
||||
}
|
||||
|
||||
QProcess::execute( "setxkbmap",
|
||||
xkbmap_layout_args( { m_additionalLayoutInfo.additionalLayout, m_selectedLayout },
|
||||
{ m_additionalLayoutInfo.additionalVariant, m_selectedVariant },
|
||||
m_additionalLayoutInfo.groupSwitcher ) );
|
||||
|
||||
|
||||
cDebug() << "xkbmap selection changed to: " << m_selectedLayout << '-' << m_selectedVariant << "(added "
|
||||
<< m_additionalLayoutInfo.additionalLayout << "-" << m_additionalLayoutInfo.additionalVariant
|
||||
<< " since current layout is not ASCII-capable)";
|
||||
}
|
||||
else
|
||||
{
|
||||
QProcess::execute( "setxkbmap", xkbmap_layout_args( m_selectedLayout, m_selectedVariant ) );
|
||||
cDebug() << "xkbmap selection changed to: " << m_selectedLayout << '-' << m_selectedVariant;
|
||||
}
|
||||
m_setxkbmapTimer.disconnect( this );
|
||||
}
|
||||
|
||||
|
||||
KeyboardModelsModel*
|
||||
Config::keyboardModels() const
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue