Keyboard: simplify execution of setxkbmap.
Use QProcess::execute() with the 'safer' argument-list, rather than escaping and de-escaping strings. Also reduce noise by only passing a variant if there is one.
This commit is contained in:
parent
70b098a2b0
commit
35c1ab61bf
@ -67,8 +67,8 @@ KeyboardPage::KeyboardPage( QWidget* parent )
|
|||||||
QString model = m_models.value( text, "pc105" );
|
QString model = m_models.value( text, "pc105" );
|
||||||
|
|
||||||
// Set Xorg keyboard model
|
// Set Xorg keyboard model
|
||||||
QProcess::execute( QString( "setxkbmap -model \"%1\"" )
|
QProcess::execute( QLatin1Literal( "setxkbmap" ),
|
||||||
.arg( model ).toUtf8() );
|
QStringList() << "-model" << model );
|
||||||
});
|
});
|
||||||
|
|
||||||
CALAMARES_RETRANSLATE( ui->retranslateUi( this ); )
|
CALAMARES_RETRANSLATE( ui->retranslateUi( this ); )
|
||||||
@ -292,6 +292,13 @@ KeyboardPage::onListLayoutCurrentItemChanged( const QModelIndex& current,
|
|||||||
updateVariants( QPersistentModelIndex( current ) );
|
updateVariants( QPersistentModelIndex( current ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline QStringList xkbmap_args( QStringList&& r, const QString& layout, const QString& variant)
|
||||||
|
{
|
||||||
|
r << "-layout" << layout;
|
||||||
|
if ( !variant.isEmpty() )
|
||||||
|
r << "-variant" << variant;
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
KeyboardPage::onListVariantCurrentItemChanged( QListWidgetItem* current, QListWidgetItem* previous )
|
KeyboardPage::onListVariantCurrentItemChanged( QListWidgetItem* current, QListWidgetItem* previous )
|
||||||
@ -320,8 +327,8 @@ KeyboardPage::onListVariantCurrentItemChanged( QListWidgetItem* current, QListWi
|
|||||||
connect( &m_setxkbmapTimer, &QTimer::timeout,
|
connect( &m_setxkbmapTimer, &QTimer::timeout,
|
||||||
this, [=]
|
this, [=]
|
||||||
{
|
{
|
||||||
QProcess::execute( QString( "setxkbmap -layout \"%1\" -variant \"%2\"" )
|
QProcess::execute( QLatin1Literal( "setxkbmap" ),
|
||||||
.arg( layout, variant ).toUtf8() );
|
xkbmap_args( QStringList(), layout, variant ) );
|
||||||
cDebug() << "xkbmap selection changed to: " << layout << "-" << variant;
|
cDebug() << "xkbmap selection changed to: " << layout << "-" << variant;
|
||||||
m_setxkbmapTimer.disconnect( this );
|
m_setxkbmapTimer.disconnect( this );
|
||||||
} );
|
} );
|
||||||
|
Loading…
Reference in New Issue
Block a user