Fix serial passthrough configure buttons not re-enabling when the checkboxes are toggled

This commit is contained in:
Alexander Babikov
2025-03-01 02:01:00 +05:00
parent 1973289de3
commit e6f96352e0
2 changed files with 25 additions and 32 deletions

View File

@@ -68,21 +68,14 @@ SettingsPorts::SettingsPorts(QWidget *parent)
for (int i = 0; i < SERIAL_MAX; i++) { for (int i = 0; i < SERIAL_MAX; i++) {
auto *checkBox = findChild<QCheckBox *>(QString("checkBoxSerial%1").arg(i + 1)); auto *checkBox = findChild<QCheckBox *>(QString("checkBoxSerial%1").arg(i + 1));
auto *checkBoxPass = findChild<QCheckBox *>(QString("checkBoxSerialPassThru%1").arg(i + 1)); auto *checkBoxPass = findChild<QCheckBox *>(QString("checkBoxSerialPassThru%1").arg(i + 1));
auto *buttonPass = findChild<QPushButton *>(QString("pushButtonSerialPassThru%1").arg(i + 1));
if (checkBox != NULL) if (checkBox != NULL)
checkBox->setChecked(com_ports[i].enabled > 0); checkBox->setChecked(com_ports[i].enabled > 0);
if (checkBoxPass != NULL) if (checkBoxPass != NULL) {
checkBoxPass->setChecked(serial_passthrough_enabled[i]); checkBoxPass->setChecked(serial_passthrough_enabled[i]);
buttonPass->setEnabled(serial_passthrough_enabled[i]);
}
} }
ui->pushButtonSerialPassThru1->setEnabled(serial_passthrough_enabled[0]);
ui->pushButtonSerialPassThru2->setEnabled(serial_passthrough_enabled[1]);
ui->pushButtonSerialPassThru3->setEnabled(serial_passthrough_enabled[2]);
ui->pushButtonSerialPassThru4->setEnabled(serial_passthrough_enabled[3]);
#if 0
ui->pushButtonSerialPassThru5->setEnabled(serial_passthrough_enabled[4]);
ui->pushButtonSerialPassThru6->setEnabled(serial_passthrough_enabled[5]);
ui->pushButtonSerialPassThru7->setEnabled(serial_passthrough_enabled[6]);
#endif
} }
SettingsPorts::~SettingsPorts() SettingsPorts::~SettingsPorts()
@@ -181,45 +174,45 @@ SettingsPorts::on_pushButtonSerialPassThru7_clicked()
#endif #endif
void void
SettingsPorts::on_checkBoxSerialPassThru1_clicked(bool checked) SettingsPorts::on_checkBoxSerialPassThru1_stateChanged(int state)
{ {
ui->pushButtonSerialPassThru1->setEnabled(checked); ui->pushButtonSerialPassThru1->setEnabled(state == Qt::Checked);
} }
void void
SettingsPorts::on_checkBoxSerialPassThru2_clicked(bool checked) SettingsPorts::on_checkBoxSerialPassThru2_stateChanged(int state)
{ {
ui->pushButtonSerialPassThru2->setEnabled(checked); ui->pushButtonSerialPassThru2->setEnabled(state == Qt::Checked);
} }
void void
SettingsPorts::on_checkBoxSerialPassThru3_clicked(bool checked) SettingsPorts::on_checkBoxSerialPassThru3_stateChanged(int state)
{ {
ui->pushButtonSerialPassThru3->setEnabled(checked); ui->pushButtonSerialPassThru3->setEnabled(state == Qt::Checked);
} }
void void
SettingsPorts::on_checkBoxSerialPassThru4_clicked(bool checked) SettingsPorts::on_checkBoxSerialPassThru4_stateChanged(int state)
{ {
ui->pushButtonSerialPassThru4->setEnabled(checked); ui->pushButtonSerialPassThru4->setEnabled(state == Qt::Checked);
} }
#if 0 #if 0
void void
SettingsPorts::on_checkBoxSerialPassThru5_clicked(bool checked) SettingsPorts::on_checkBoxSerialPassThru5_stateChanged(int state)
{ {
ui->pushButtonSerialPassThru5->setEnabled(checked); ui->pushButtonSerialPassThru5->setEnabled(state == Qt::Checked);
} }
void void
SettingsPorts::on_checkBoxSerialPassThru6_clicked(bool checked) SettingsPorts::on_checkBoxSerialPassThru6_stateChanged(int state)
{ {
ui->pushButtonSerialPassThru6->setEnabled(checked); ui->pushButtonSerialPassThru6->setEnabled(state == Qt::Checked);
} }
void void
SettingsPorts::on_checkBoxSerialPassThru7_clicked(bool checked) SettingsPorts::on_checkBoxSerialPassThru7_stateChanged(int state)
{ {
ui->pushButtonSerialPassThru7->setEnabled(checked); ui->pushButtonSerialPassThru7->setEnabled(state == Qt::Checked);
} }
#endif #endif

View File

@@ -18,14 +18,14 @@ public:
#if 0 #if 0
private slots: private slots:
void on_checkBoxSerialPassThru7_clicked(bool checked); void on_checkBoxSerialPassThru7_stateChanged(int state);
void on_checkBoxSerialPassThru6_clicked(bool checked); void on_checkBoxSerialPassThru6_stateChanged(int state);
void on_checkBoxSerialPassThru5_clicked(bool checked); void on_checkBoxSerialPassThru5_stateChanged(int state);
#endif #endif
void on_checkBoxSerialPassThru4_clicked(bool checked); void on_checkBoxSerialPassThru4_stateChanged(int state);
void on_checkBoxSerialPassThru3_clicked(bool checked); void on_checkBoxSerialPassThru3_stateChanged(int state);
void on_checkBoxSerialPassThru2_clicked(bool checked); void on_checkBoxSerialPassThru2_stateChanged(int state);
void on_checkBoxSerialPassThru1_clicked(bool checked); void on_checkBoxSerialPassThru1_stateChanged(int state);
private slots: private slots:
#if 0 #if 0