Merge branch 'master' of https://github.com/calamares/calamares into development
This commit is contained in:
commit
af89d58647
@ -37,6 +37,21 @@
|
|||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
|
|
||||||
|
static QPersistentModelIndex
|
||||||
|
findLayout( const KeyboardLayoutModel* klm, const QString& currentLayout )
|
||||||
|
{
|
||||||
|
QPersistentModelIndex currentLayoutItem;
|
||||||
|
|
||||||
|
for ( int i = 0; i < klm->rowCount(); ++i )
|
||||||
|
{
|
||||||
|
QModelIndex idx = klm->index( i );
|
||||||
|
if ( idx.isValid() &&
|
||||||
|
idx.data( KeyboardLayoutModel::KeyboardLayoutKeyRole ).toString() == currentLayout )
|
||||||
|
currentLayoutItem = idx;
|
||||||
|
}
|
||||||
|
|
||||||
|
return currentLayoutItem;
|
||||||
|
}
|
||||||
|
|
||||||
KeyboardPage::KeyboardPage( QWidget* parent )
|
KeyboardPage::KeyboardPage( QWidget* parent )
|
||||||
: QWidget()
|
: QWidget()
|
||||||
@ -68,8 +83,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 ); )
|
||||||
@ -160,14 +175,13 @@ KeyboardPage::init()
|
|||||||
// Block signals
|
// Block signals
|
||||||
ui->listLayout->blockSignals( true );
|
ui->listLayout->blockSignals( true );
|
||||||
|
|
||||||
QPersistentModelIndex currentLayoutItem;
|
QPersistentModelIndex currentLayoutItem = findLayout( klm, currentLayout );
|
||||||
|
if ( !currentLayoutItem.isValid() && (
|
||||||
for ( int i = 0; i < klm->rowCount(); ++i )
|
( currentLayout == "latin" )
|
||||||
|
|| ( currentLayout == "pc" ) ) )
|
||||||
{
|
{
|
||||||
QModelIndex idx = klm->index( i );
|
currentLayout = "us";
|
||||||
if ( idx.isValid() &&
|
currentLayoutItem = findLayout( klm, currentLayout );
|
||||||
idx.data( KeyboardLayoutModel::KeyboardLayoutKeyRole ).toString() == currentLayout )
|
|
||||||
currentLayoutItem = idx;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set current layout and variant
|
// Set current layout and variant
|
||||||
@ -341,6 +355,16 @@ KeyboardPage::onListLayoutCurrentItemChanged( const QModelIndex& current,
|
|||||||
updateVariants( QPersistentModelIndex( current ) );
|
updateVariants( QPersistentModelIndex( current ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Returns stringlist with suitable setxkbmap command-line arguments
|
||||||
|
* to set the given @p layout and @p variant.
|
||||||
|
*/
|
||||||
|
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 )
|
||||||
@ -369,8 +393,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 );
|
||||||
} );
|
} );
|
||||||
@ -379,4 +403,3 @@ KeyboardPage::onListVariantCurrentItemChanged( QListWidgetItem* current, QListWi
|
|||||||
m_selectedLayout = layout;
|
m_selectedLayout = layout;
|
||||||
m_selectedVariant = variant;
|
m_selectedVariant = variant;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user