[keyboard] Use Config methods rather than own copy
- this continues the port of the keyboard module to use the Config object, which was horribly botched earlier.
This commit is contained in:
parent
679f613955
commit
acb5190217
@ -93,108 +93,6 @@ KeyboardPage::~KeyboardPage()
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
KeyboardPage::init()
|
||||
{
|
||||
//### Detect current keyboard layout and variant
|
||||
QString currentLayout;
|
||||
QString currentVariant;
|
||||
QProcess process;
|
||||
process.start( "setxkbmap", QStringList() << "-print" );
|
||||
|
||||
if ( process.waitForFinished() )
|
||||
{
|
||||
const QStringList list = QString( process.readAll() ).split( "\n", SplitSkipEmptyParts );
|
||||
|
||||
for ( QString line : list )
|
||||
{
|
||||
line = line.trimmed();
|
||||
if ( !line.startsWith( "xkb_symbols" ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
line = line.remove( "}" ).remove( "{" ).remove( ";" );
|
||||
line = line.mid( line.indexOf( "\"" ) + 1 );
|
||||
|
||||
QStringList split = line.split( "+", SplitSkipEmptyParts );
|
||||
if ( split.size() >= 2 )
|
||||
{
|
||||
currentLayout = split.at( 1 );
|
||||
|
||||
if ( currentLayout.contains( "(" ) )
|
||||
{
|
||||
int parenthesisIndex = currentLayout.indexOf( "(" );
|
||||
currentVariant = currentLayout.mid( parenthesisIndex + 1 ).trimmed();
|
||||
currentVariant.chop( 1 );
|
||||
currentLayout = currentLayout.mid( 0, parenthesisIndex ).trimmed();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//### Models
|
||||
m_models = KeyboardGlobal::getKeyboardModels();
|
||||
QMapIterator< QString, QString > mi( m_models );
|
||||
|
||||
ui->comboBoxModel->blockSignals( true );
|
||||
|
||||
while ( mi.hasNext() )
|
||||
{
|
||||
mi.next();
|
||||
|
||||
if ( mi.value() == "pc105" )
|
||||
{
|
||||
m_defaultIndex = ui->comboBoxModel->count();
|
||||
}
|
||||
|
||||
ui->comboBoxModel->addItem( mi.key() );
|
||||
}
|
||||
|
||||
ui->comboBoxModel->blockSignals( false );
|
||||
|
||||
// Set to default value pc105
|
||||
ui->comboBoxModel->setCurrentIndex( m_defaultIndex );
|
||||
|
||||
|
||||
//### Layouts and Variants
|
||||
|
||||
KeyboardLayoutModel* klm = new KeyboardLayoutModel( this );
|
||||
ui->listLayout->setModel( klm );
|
||||
connect( ui->listLayout->selectionModel(),
|
||||
&QItemSelectionModel::currentChanged,
|
||||
this,
|
||||
&KeyboardPage::onListLayoutCurrentItemChanged );
|
||||
|
||||
// Block signals
|
||||
ui->listLayout->blockSignals( true );
|
||||
|
||||
QPersistentModelIndex currentLayoutItem = findLayout( klm, currentLayout );
|
||||
if ( !currentLayoutItem.isValid() && ( ( currentLayout == "latin" ) || ( currentLayout == "pc" ) ) )
|
||||
{
|
||||
currentLayout = "us";
|
||||
currentLayoutItem = findLayout( klm, currentLayout );
|
||||
}
|
||||
|
||||
// Set current layout and variant
|
||||
if ( currentLayoutItem.isValid() )
|
||||
{
|
||||
ui->listLayout->setCurrentIndex( currentLayoutItem );
|
||||
updateVariants( currentLayoutItem, currentVariant );
|
||||
}
|
||||
|
||||
// Unblock signals
|
||||
ui->listLayout->blockSignals( false );
|
||||
|
||||
// Default to the first available layout if none was set
|
||||
// Do this after unblocking signals so we get the default variant handling.
|
||||
if ( !currentLayoutItem.isValid() && klm->rowCount() > 0 )
|
||||
{
|
||||
ui->listLayout->setCurrentIndex( klm->index( 0 ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QString
|
||||
|
@ -36,8 +36,6 @@ public:
|
||||
explicit KeyboardPage( QWidget* parent = nullptr );
|
||||
~KeyboardPage() override;
|
||||
|
||||
void init();
|
||||
|
||||
QString prettyStatus() const;
|
||||
|
||||
Calamares::JobList
|
||||
|
@ -23,7 +23,7 @@ KeyboardViewStep::KeyboardViewStep( QObject* parent )
|
||||
, m_widget( new KeyboardPage() )
|
||||
, m_nextEnabled( false )
|
||||
{
|
||||
m_widget->init();
|
||||
m_config->detectCurrentKeyboardLayout();
|
||||
m_nextEnabled = true;
|
||||
emit nextStatusChanged( m_nextEnabled );
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user