[keyboard] Rename UI widgets to make code clearer
This commit is contained in:
parent
d464e98e89
commit
5f1d7b2e8d
@ -51,17 +51,17 @@ KeyboardPage::KeyboardPage( Config* config, QWidget* parent )
|
|||||||
// Keyboard Preview
|
// Keyboard Preview
|
||||||
ui->KBPreviewLayout->addWidget( m_keyboardPreview );
|
ui->KBPreviewLayout->addWidget( m_keyboardPreview );
|
||||||
|
|
||||||
ui->comboBoxModel->setModel( config->keyboardModels() );
|
ui->physicalModelSelector->setModel( config->keyboardModels() );
|
||||||
// Connect signals and slots
|
// Connect signals and slots
|
||||||
connect( ui->listVariant, &QListWidget::currentItemChanged, this, &KeyboardPage::onListVariantCurrentItemChanged );
|
connect( ui->variantSelector, &QListWidget::currentItemChanged, this, &KeyboardPage::onListVariantCurrentItemChanged );
|
||||||
|
|
||||||
connect(
|
connect(
|
||||||
ui->buttonRestore, &QPushButton::clicked, [this] {
|
ui->buttonRestore, &QPushButton::clicked, [this] {
|
||||||
cDebug() << "Restore clicked";
|
cDebug() << "Restore clicked";
|
||||||
// ui->comboBoxModel->setCurrentIndex( m_defaultIndex );
|
// ui->physicalModelSelector->setCurrentIndex( m_defaultIndex );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
connect( ui->comboBoxModel, &QComboBox::currentTextChanged, [this]( const QString& text ) {
|
connect( ui->physicalModelSelector, &QComboBox::currentTextChanged, [this]( const QString& text ) {
|
||||||
cDebug() << "ComboBox changed to" << text;
|
cDebug() << "ComboBox changed to" << text;
|
||||||
// QString model = m_models.value( text, "pc105" );
|
// QString model = m_models.value( text, "pc105" );
|
||||||
|
|
||||||
@ -82,14 +82,14 @@ void
|
|||||||
KeyboardPage::updateVariants( const QPersistentModelIndex& currentItem, QString currentVariant )
|
KeyboardPage::updateVariants( const QPersistentModelIndex& currentItem, QString currentVariant )
|
||||||
{
|
{
|
||||||
// Block signals
|
// Block signals
|
||||||
ui->listVariant->blockSignals( true );
|
ui->variantSelector->blockSignals( true );
|
||||||
|
|
||||||
QMap< QString, QString > variants
|
QMap< QString, QString > variants
|
||||||
= currentItem.data( KeyboardLayoutModel::KeyboardVariantsRole ).value< QMap< QString, QString > >();
|
= currentItem.data( KeyboardLayoutModel::KeyboardVariantsRole ).value< QMap< QString, QString > >();
|
||||||
QMapIterator< QString, QString > li( variants );
|
QMapIterator< QString, QString > li( variants );
|
||||||
LayoutItem* defaultItem = nullptr;
|
LayoutItem* defaultItem = nullptr;
|
||||||
|
|
||||||
ui->listVariant->clear();
|
ui->variantSelector->clear();
|
||||||
|
|
||||||
while ( li.hasNext() )
|
while ( li.hasNext() )
|
||||||
{
|
{
|
||||||
@ -98,7 +98,7 @@ KeyboardPage::updateVariants( const QPersistentModelIndex& currentItem, QString
|
|||||||
LayoutItem* item = new LayoutItem();
|
LayoutItem* item = new LayoutItem();
|
||||||
item->setText( li.key() );
|
item->setText( li.key() );
|
||||||
item->data = li.value();
|
item->data = li.value();
|
||||||
ui->listVariant->addItem( item );
|
ui->variantSelector->addItem( item );
|
||||||
|
|
||||||
// currentVariant defaults to QString(). It is only non-empty during the
|
// currentVariant defaults to QString(). It is only non-empty during the
|
||||||
// initial setup.
|
// initial setup.
|
||||||
@ -109,12 +109,12 @@ KeyboardPage::updateVariants( const QPersistentModelIndex& currentItem, QString
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Unblock signals
|
// Unblock signals
|
||||||
ui->listVariant->blockSignals( false );
|
ui->variantSelector->blockSignals( false );
|
||||||
|
|
||||||
// Set to default value
|
// Set to default value
|
||||||
if ( defaultItem )
|
if ( defaultItem )
|
||||||
{
|
{
|
||||||
ui->listVariant->setCurrentItem( defaultItem );
|
ui->variantSelector->setCurrentItem( defaultItem );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,7 +138,7 @@ KeyboardPage::onListVariantCurrentItemChanged( QListWidgetItem* current, QListWi
|
|||||||
|
|
||||||
cDebug() << "item" << Logger::Pointer( current );
|
cDebug() << "item" << Logger::Pointer( current );
|
||||||
|
|
||||||
QPersistentModelIndex layoutIndex = ui->listLayout->currentIndex();
|
QPersistentModelIndex layoutIndex = ui->layoutSelector->currentIndex();
|
||||||
LayoutItem* variantItem = dynamic_cast< LayoutItem* >( current );
|
LayoutItem* variantItem = dynamic_cast< LayoutItem* >( current );
|
||||||
|
|
||||||
if ( !layoutIndex.isValid() || !variantItem )
|
if ( !layoutIndex.isValid() || !variantItem )
|
||||||
|
@ -76,7 +76,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QComboBox" name="comboBoxModel">
|
<widget class="QComboBox" name="physicalModelSelector">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
@ -110,10 +110,10 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
|||||||
<number>9</number>
|
<number>9</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QListView" name="listLayout"/>
|
<widget class="QListView" name="layoutSelector"/>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QListWidget" name="listVariant"/>
|
<widget class="QListWidget" name="variantSelector"/>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
@ -139,9 +139,9 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
|||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<tabstops>
|
<tabstops>
|
||||||
<tabstop>comboBoxModel</tabstop>
|
<tabstop>physicalModelSelector</tabstop>
|
||||||
<tabstop>listLayout</tabstop>
|
<tabstop>layoutSelector</tabstop>
|
||||||
<tabstop>listVariant</tabstop>
|
<tabstop>variantSelector</tabstop>
|
||||||
<tabstop>LE_TestKeyboard</tabstop>
|
<tabstop>LE_TestKeyboard</tabstop>
|
||||||
<tabstop>buttonRestore</tabstop>
|
<tabstop>buttonRestore</tabstop>
|
||||||
</tabstops>
|
</tabstops>
|
||||||
|
Loading…
Reference in New Issue
Block a user