From acb51902174a435bbc58ea45abb407e3533f3711 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 27 Oct 2020 15:51:48 +0100 Subject: [PATCH] [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. --- src/modules/keyboard/KeyboardPage.cpp | 102 ---------------------- src/modules/keyboard/KeyboardPage.h | 2 - src/modules/keyboard/KeyboardViewStep.cpp | 2 +- 3 files changed, 1 insertion(+), 105 deletions(-) diff --git a/src/modules/keyboard/KeyboardPage.cpp b/src/modules/keyboard/KeyboardPage.cpp index 07c5cf763..f97e3ac52 100644 --- a/src/modules/keyboard/KeyboardPage.cpp +++ b/src/modules/keyboard/KeyboardPage.cpp @@ -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 diff --git a/src/modules/keyboard/KeyboardPage.h b/src/modules/keyboard/KeyboardPage.h index 4faeebd57..4e85ae8b7 100644 --- a/src/modules/keyboard/KeyboardPage.h +++ b/src/modules/keyboard/KeyboardPage.h @@ -36,8 +36,6 @@ public: explicit KeyboardPage( QWidget* parent = nullptr ); ~KeyboardPage() override; - void init(); - QString prettyStatus() const; Calamares::JobList diff --git a/src/modules/keyboard/KeyboardViewStep.cpp b/src/modules/keyboard/KeyboardViewStep.cpp index 03159268e..0ba20dd87 100644 --- a/src/modules/keyboard/KeyboardViewStep.cpp +++ b/src/modules/keyboard/KeyboardViewStep.cpp @@ -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 ); }