[keyboard] Tell the keyboard preview to update on config changes

These calls to setLayout() and setVariant() got lost in
the transition to Config object, in 5afe5413.

Reported by Harald Sitter.
main
Adriaan de Groot 5 years ago
parent b1b801e5f6
commit fdfe3937e9

@ -198,6 +198,16 @@ KeyboardLayoutModel::item( const int& index ) const
return m_layouts.at( index );
}
QString
KeyboardLayoutModel::key( int index ) const
{
if ( index >= m_layouts.count() || index < 0 )
{
return QString();
}
return m_layouts.at( index ).first;
}
void
KeyboardLayoutModel::init()
{

@ -118,6 +118,13 @@ public:
int currentIndex() const;
const QPair< QString, KeyboardGlobal::KeyboardInfo > item( const int& index ) const;
/** @brief xkb key for a given index (row)
*
* This is like calling data( QModelIndex( index ), KeyboardLayoutKeyRole ).toString(),
* but shorter and faster. Can return an empty string if index is invalid.
*/
QString key( int index ) const;
protected:
QHash< int, QByteArray > roleNames() const override;

@ -70,8 +70,9 @@ KeyboardPage::KeyboardPage( Config* config, QWidget* parent )
cDebug() << "Variants now" << model->rowCount() << model->currentIndex();
}
connect(
ui->buttonRestore, &QPushButton::clicked, [config = config] { config->keyboardModels()->setCurrentIndex(); } );
connect( ui->buttonRestore, &QPushButton::clicked, [ config = config ] {
config->keyboardModels()->setCurrentIndex();
} );
connect( ui->physicalModelSelector,
QOverload< int >::of( &QComboBox::currentIndexChanged ),
@ -82,18 +83,22 @@ KeyboardPage::KeyboardPage( Config* config, QWidget* parent )
ui->physicalModelSelector,
&QComboBox::setCurrentIndex );
connect( ui->layoutSelector->selectionModel(),
&QItemSelectionModel::currentChanged,
[this]( const QModelIndex& current ) { m_config->keyboardLayouts()->setCurrentIndex( current.row() ); } );
connect( config->keyboardLayouts(), &KeyboardLayoutModel::currentIndexChanged, [this]( int index ) {
connect(
ui->layoutSelector->selectionModel(),
&QItemSelectionModel::currentChanged,
[ 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 ) );
m_keyboardPreview->setLayout( m_config->keyboardLayouts()->key( index ) );
} );
connect( ui->variantSelector->selectionModel(),
&QItemSelectionModel::currentChanged,
[this]( const QModelIndex& current ) { m_config->keyboardVariants()->setCurrentIndex( current.row() ); } );
connect( config->keyboardVariants(), &KeyboardVariantsModel::currentIndexChanged, [this]( int index ) {
connect(
ui->variantSelector->selectionModel(),
&QItemSelectionModel::currentChanged,
[ 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 ) );
m_keyboardPreview->setVariant( m_config->keyboardVariants()->key( index ) );
} );
CALAMARES_RETRANSLATE_SLOT( &KeyboardPage::retranslate )
}

Loading…
Cancel
Save