OSDN Git Service

[keyboard] Rename UI widgets to make code clearer
authorAdriaan de Groot <groot@kde.org>
Wed, 28 Oct 2020 09:38:51 +0000 (10:38 +0100)
committerAdriaan de Groot <groot@kde.org>
Wed, 28 Oct 2020 09:38:51 +0000 (10:38 +0100)
src/modules/keyboard/KeyboardPage.cpp
src/modules/keyboard/KeyboardPage.ui

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