[keyboard] Removed unnecessary repacking in xkbmap_layout_args

This commit is contained in:
Artem Grinev 2020-10-26 18:22:43 +03:00
parent 09b5e42734
commit 354dc1613a

View File

@ -50,15 +50,12 @@ xkbmap_layout_args( const QString& layout, const QString& variant )
} }
static inline QStringList static inline QStringList
xkbmap_layout_args( const QList<QPair<QString, QString>> layoutsAndVariantsList, const QString& switchOption = "grp:alt_shift_toggle") xkbmap_layout_args( const QStringList& layouts, const QStringList& variants, const QString& switchOption = "grp:alt_shift_toggle")
{ {
QStringList layouts; if ( layouts.size() != variants.size() )
QStringList variants;
for( auto& [layout,variant] : layoutsAndVariantsList )
{ {
layouts.append(layout); cError() << "Number of layouts and variants must be equal (empty string should be used if there is no corresponding variant)";
variants.append(variant); return QStringList();
} }
QStringList r{ "-layout", layouts.join( "," ) }; QStringList r{ "-layout", layouts.join( "," ) };
@ -183,11 +180,10 @@ Config::Config( QObject* parent )
m_selectedLayoutsAdditionalLayoutInfo = info; m_selectedLayoutsAdditionalLayoutInfo = info;
QString switchOption = xkbmap_query_grp_option(); QString switchOption = xkbmap_query_grp_option();
QProcess::execute( "setxkbmap", xkbmap_layout_args( { QProcess::execute( "setxkbmap", xkbmap_layout_args(
{m_selectedLayout, m_selectedVariant}, { m_selectedLayout, info.additionalLayout },
{info.additionalLayout, info.additionalVariant} { m_selectedVariant, info.additionalVariant },
}, switchOption.isEmpty()?"grp:alt_shift_toggle":QString() )
switchOption.isEmpty()?"grp:alt_shift_toggle":QString() )
); );
cDebug() << "xkbmap selection changed to: " << m_selectedLayout << '-' << m_selectedVariant cDebug() << "xkbmap selection changed to: " << m_selectedLayout << '-' << m_selectedVariant
<< "(added " << info.additionalLayout << "-" << info.additionalVariant << " since current layout is not ASCII-capable)"; << "(added " << info.additionalLayout << "-" << info.additionalVariant << " since current layout is not ASCII-capable)";