[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.
This commit is contained in:
parent
b1b801e5f6
commit
fdfe3937e9
@ -198,6 +198,16 @@ KeyboardLayoutModel::item( const int& index ) const
|
|||||||
return m_layouts.at( index );
|
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
|
void
|
||||||
KeyboardLayoutModel::init()
|
KeyboardLayoutModel::init()
|
||||||
{
|
{
|
||||||
|
@ -118,6 +118,13 @@ public:
|
|||||||
int currentIndex() const;
|
int currentIndex() const;
|
||||||
const QPair< QString, KeyboardGlobal::KeyboardInfo > item( const int& index ) 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:
|
protected:
|
||||||
QHash< int, QByteArray > roleNames() const override;
|
QHash< int, QByteArray > roleNames() const override;
|
||||||
|
|
||||||
|
@ -70,8 +70,9 @@ KeyboardPage::KeyboardPage( Config* config, QWidget* parent )
|
|||||||
cDebug() << "Variants now" << model->rowCount() << model->currentIndex();
|
cDebug() << "Variants now" << model->rowCount() << model->currentIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
connect(
|
connect( ui->buttonRestore, &QPushButton::clicked, [ config = config ] {
|
||||||
ui->buttonRestore, &QPushButton::clicked, [config = config] { config->keyboardModels()->setCurrentIndex(); } );
|
config->keyboardModels()->setCurrentIndex();
|
||||||
|
} );
|
||||||
|
|
||||||
connect( ui->physicalModelSelector,
|
connect( ui->physicalModelSelector,
|
||||||
QOverload< int >::of( &QComboBox::currentIndexChanged ),
|
QOverload< int >::of( &QComboBox::currentIndexChanged ),
|
||||||
@ -82,18 +83,22 @@ KeyboardPage::KeyboardPage( Config* config, QWidget* parent )
|
|||||||
ui->physicalModelSelector,
|
ui->physicalModelSelector,
|
||||||
&QComboBox::setCurrentIndex );
|
&QComboBox::setCurrentIndex );
|
||||||
|
|
||||||
connect( ui->layoutSelector->selectionModel(),
|
connect(
|
||||||
&QItemSelectionModel::currentChanged,
|
ui->layoutSelector->selectionModel(),
|
||||||
[this]( const QModelIndex& current ) { m_config->keyboardLayouts()->setCurrentIndex( current.row() ); } );
|
&QItemSelectionModel::currentChanged,
|
||||||
connect( config->keyboardLayouts(), &KeyboardLayoutModel::currentIndexChanged, [this]( int index ) {
|
[ 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 ) );
|
ui->layoutSelector->setCurrentIndex( m_config->keyboardLayouts()->index( index ) );
|
||||||
|
m_keyboardPreview->setLayout( m_config->keyboardLayouts()->key( index ) );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
connect( ui->variantSelector->selectionModel(),
|
connect(
|
||||||
&QItemSelectionModel::currentChanged,
|
ui->variantSelector->selectionModel(),
|
||||||
[this]( const QModelIndex& current ) { m_config->keyboardVariants()->setCurrentIndex( current.row() ); } );
|
&QItemSelectionModel::currentChanged,
|
||||||
connect( config->keyboardVariants(), &KeyboardVariantsModel::currentIndexChanged, [this]( int index ) {
|
[ 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 ) );
|
ui->variantSelector->setCurrentIndex( m_config->keyboardVariants()->index( index ) );
|
||||||
|
m_keyboardPreview->setVariant( m_config->keyboardVariants()->key( index ) );
|
||||||
} );
|
} );
|
||||||
CALAMARES_RETRANSLATE_SLOT( &KeyboardPage::retranslate )
|
CALAMARES_RETRANSLATE_SLOT( &KeyboardPage::retranslate )
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user