From 2e5301c5c91e211c73069d72d516dd6218ca63d8 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 28 Oct 2020 16:51:34 +0100 Subject: [PATCH] [keyboard] Simplify back down to lambdas - With debugging and untangling done, the lambdas are simple and short, so return to using them. One point of improvement might be to give the models suitable slots themselves, to avoid even this indirection. --- src/modules/keyboard/KeyboardPage.cpp | 45 +++++---------------------- src/modules/keyboard/KeyboardPage.h | 7 ----- 2 files changed, 8 insertions(+), 44 deletions(-) diff --git a/src/modules/keyboard/KeyboardPage.cpp b/src/modules/keyboard/KeyboardPage.cpp index cb8aada5b..2be897e58 100644 --- a/src/modules/keyboard/KeyboardPage.cpp +++ b/src/modules/keyboard/KeyboardPage.cpp @@ -84,49 +84,20 @@ KeyboardPage::KeyboardPage( Config* config, QWidget* parent ) connect( ui->layoutSelector->selectionModel(), &QItemSelectionModel::currentChanged, - this, - &KeyboardPage::layoutChangedByUser ); - connect( config->keyboardLayouts(), - &KeyboardLayoutModel::currentIndexChanged, - this, - &KeyboardPage::layoutChangedByConfig ); + [this]( const QModelIndex& current ) { m_config->keyboardLayouts()->setCurrentIndex( current.row() ); } ); + connect( config->keyboardLayouts(), &KeyboardLayoutModel::currentIndexChanged, [this]( int index ) { + ui->layoutSelector->setCurrentIndex( m_config->keyboardLayouts()->index( index ) ); + } ); connect( ui->variantSelector->selectionModel(), &QItemSelectionModel::currentChanged, - this, - &KeyboardPage::variantChangedByUser ); - connect( config->keyboardVariants(), - &KeyboardVariantsModel::currentIndexChanged, - this, - &KeyboardPage::variantChangedByConfig ); - + [this]( const QModelIndex& current ) { m_config->keyboardVariants()->setCurrentIndex( current.row() ); } ); + connect( config->keyboardVariants(), &KeyboardVariantsModel::currentIndexChanged, [this]( int index ) { + ui->variantSelector->setCurrentIndex( m_config->keyboardVariants()->index( index ) ); + } ); CALAMARES_RETRANSLATE( ui->retranslateUi( this ); ) } -void -KeyboardPage::layoutChangedByUser( const QModelIndex& current, const QModelIndex& previous ) -{ - m_config->keyboardLayouts()->setCurrentIndex( current.row() ); -} - -void -KeyboardPage::layoutChangedByConfig( int index ) -{ - ui->layoutSelector->setCurrentIndex( m_config->keyboardLayouts()->index( index ) ); -} - -void -KeyboardPage::variantChangedByUser( const QModelIndex& current, const QModelIndex& previous ) -{ - m_config->keyboardVariants()->setCurrentIndex( current.row() ); -} - -void -KeyboardPage::variantChangedByConfig( int index ) -{ - ui->variantSelector->setCurrentIndex( m_config->keyboardVariants()->index( index ) ); -} - KeyboardPage::~KeyboardPage() { delete ui; diff --git a/src/modules/keyboard/KeyboardPage.h b/src/modules/keyboard/KeyboardPage.h index 582b614e3..98925fcad 100644 --- a/src/modules/keyboard/KeyboardPage.h +++ b/src/modules/keyboard/KeyboardPage.h @@ -37,13 +37,6 @@ public: explicit KeyboardPage( Config* config, QWidget* parent = nullptr ); ~KeyboardPage() override; -protected slots: - void layoutChangedByUser( const QModelIndex& current, const QModelIndex& previous ); - void layoutChangedByConfig( int index ); - - void variantChangedByUser( const QModelIndex& current, const QModelIndex& previous ); - void variantChangedByConfig( int index ); - private: Ui::Page_Keyboard* ui; KeyBoardPreview* m_keyboardPreview;