From 87aafb2442c3208a256c7c01b92d1b9aa405b1df Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 28 Oct 2020 13:55:21 +0100 Subject: [PATCH] [keyboard] Tear up connections between widgets and model --- src/modules/keyboard/Config.cpp | 7 +++++-- src/modules/keyboard/KeyboardPage.cpp | 16 +++------------- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/src/modules/keyboard/Config.cpp b/src/modules/keyboard/Config.cpp index d821146b3..13954eb20 100644 --- a/src/modules/keyboard/Config.cpp +++ b/src/modules/keyboard/Config.cpp @@ -156,22 +156,25 @@ Config::Config( QObject* parent ) // Connect signals and slots connect( m_keyboardModelsModel, &KeyboardModelsModel::currentIndexChanged, [&]( int index ) { + // Set Xorg keyboard model m_selectedModel = m_keyboardModelsModel->modelKey( index ); - // Set Xorg keyboard model + cDebug() << "Setting model" << index << m_selectedModel; QProcess::execute( "setxkbmap", xkbmap_model_args( m_selectedModel ) ); emit prettyStatusChanged(); } ); connect( m_keyboardLayoutsModel, &KeyboardLayoutModel::currentIndexChanged, [&]( int index ) { m_selectedLayout = m_keyboardLayoutsModel->item( index ).first; + cDebug() << "Setting layout" << index << m_selectedLayout; updateVariants( QPersistentModelIndex( m_keyboardLayoutsModel->index( index ) ) ); emit prettyStatusChanged(); } ); connect( m_keyboardVariantsModel, &KeyboardVariantsModel::currentIndexChanged, [&]( int index ) { + // Set Xorg keyboard layout + variant m_selectedVariant = m_keyboardVariantsModel->item( index )[ "key" ]; + cDebug() << "Setting variant" << index << m_selectedVariant; - // Set Xorg keyboard layout if ( m_setxkbmapTimer.isActive() ) { m_setxkbmapTimer.stop(); diff --git a/src/modules/keyboard/KeyboardPage.cpp b/src/modules/keyboard/KeyboardPage.cpp index a6b1d3a16..9974f7bf7 100644 --- a/src/modules/keyboard/KeyboardPage.cpp +++ b/src/modules/keyboard/KeyboardPage.cpp @@ -52,22 +52,12 @@ KeyboardPage::KeyboardPage( Config* config, QWidget* parent ) ui->KBPreviewLayout->addWidget( m_keyboardPreview ); ui->physicalModelSelector->setModel( config->keyboardModels() ); - // Connect signals and slots - connect( - ui->variantSelector, &QListWidget::currentItemChanged, this, &KeyboardPage::onListVariantCurrentItemChanged ); + ui->layoutSelector->setModel( config->keyboardLayouts() ); - connect( ui->buttonRestore, &QPushButton::clicked, [this] { - cDebug() << "Restore clicked"; - // ui->physicalModelSelector->setCurrentIndex( m_defaultIndex ); + connect( ui->buttonRestore, &QPushButton::clicked, [config=config] { + config->keyboardModels()->setCurrentIndex(); } ); - connect( ui->physicalModelSelector, &QComboBox::currentTextChanged, [this]( const QString& text ) { - cDebug() << "ComboBox changed to" << text; - // QString model = m_models.value( text, "pc105" ); - - // Set Xorg keyboard model - // QProcess::execute( "setxkbmap", QStringList { "-model", model } ); - } ); CALAMARES_RETRANSLATE( ui->retranslateUi( this ); ) }