diff --git a/src/qt/qt_settings.cpp b/src/qt/qt_settings.cpp index 67064b73a..471558e22 100644 --- a/src/qt/qt_settings.cpp +++ b/src/qt/qt_settings.cpp @@ -153,6 +153,8 @@ Settings::Settings(QWidget *parent) &SettingsSound::onCurrentMachineChanged); connect(machine, &SettingsMachine::currentMachineChanged, network, &SettingsNetwork::onCurrentMachineChanged); + connect(machine, &SettingsMachine::currentMachineChanged, ports, + &SettingsPorts::onCurrentMachineChanged); connect(machine, &SettingsMachine::currentMachineChanged, storageControllers, &SettingsStorageControllers::onCurrentMachineChanged); connect(machine, &SettingsMachine::currentMachineChanged, otherPeripherals, diff --git a/src/qt/qt_settingsports.cpp b/src/qt/qt_settingsports.cpp index 9679c9e21..630c843b9 100644 --- a/src/qt/qt_settingsports.cpp +++ b/src/qt/qt_settingsports.cpp @@ -38,51 +38,7 @@ SettingsPorts::SettingsPorts(QWidget *parent) , ui(new Ui::SettingsPorts) { ui->setupUi(this); - - for (int i = 0; i < PARALLEL_MAX; i++) { - auto *cbox = findChild(QString("comboBoxLpt%1").arg(i + 1)); - auto *model = cbox->model(); - int c = 0; - int selectedRow = 0; - while (true) { - const char *lptName = lpt_device_get_name(c); - if (lptName == nullptr) { - break; - } - - Models::AddEntry(model, tr(lptName), c); - if (c == lpt_ports[i].device) { - selectedRow = c; - } - c++; - } - cbox->setCurrentIndex(selectedRow); - - auto *checkBox = findChild(QString("checkBoxParallel%1").arg(i + 1)); - if (checkBox != NULL) - checkBox->setChecked(lpt_ports[i].enabled > 0); - if (cbox != NULL) - cbox->setEnabled(lpt_ports[i].enabled > 0); - } - - for (int i = 0; i < SERIAL_MAX; i++) { - auto *checkBox = findChild(QString("checkBoxSerial%1").arg(i + 1)); - auto *checkBoxPass = findChild(QString("checkBoxSerialPassThru%1").arg(i + 1)); - if (checkBox != NULL) - checkBox->setChecked(com_ports[i].enabled > 0); - if (checkBoxPass != NULL) - checkBoxPass->setChecked(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 + onCurrentMachineChanged(machine); } SettingsPorts::~SettingsPorts() @@ -112,6 +68,51 @@ SettingsPorts::save() } } +void +SettingsPorts::onCurrentMachineChanged(int machineId) +{ + this->machineId = machineId; + + for (int i = 0; i < PARALLEL_MAX; i++) { + auto *cbox = findChild(QString("comboBoxLpt%1").arg(i + 1)); + auto *model = cbox->model(); + int c = 0; + int selectedRow = 0; + while (true) { + const char *lptName = lpt_device_get_name(c); + if (lptName == nullptr) { + break; + } + + Models::AddEntry(model, tr(lptName), c); + if (c == lpt_ports[i].device) { + selectedRow = c; + } + c++; + } + cbox->setCurrentIndex(selectedRow); + + auto *checkBox = findChild(QString("checkBoxParallel%1").arg(i + 1)); + if (checkBox != NULL) + checkBox->setChecked(lpt_ports[i].enabled > 0); + if (cbox != NULL) + cbox->setEnabled(lpt_ports[i].enabled > 0); + } + + for (int i = 0; i < SERIAL_MAX; i++) { + auto *checkBox = findChild(QString("checkBoxSerial%1").arg(i + 1)); + auto *checkBoxPass = findChild(QString("checkBoxSerialPassThru%1").arg(i + 1)); + auto *buttonPass = findChild(QString("pushButtonSerialPassThru%1").arg(i + 1)); + if (checkBox != NULL) + checkBox->setChecked(com_ports[i].enabled > 0); + if (checkBoxPass != NULL) { + checkBoxPass->setEnabled(com_ports[i].enabled > 0); + checkBoxPass->setChecked(serial_passthrough_enabled[i]); + buttonPass->setEnabled((com_ports[i].enabled > 0) && serial_passthrough_enabled[i]); + } + } +} + void SettingsPorts::on_checkBoxParallel1_stateChanged(int state) { @@ -136,6 +137,101 @@ SettingsPorts::on_checkBoxParallel4_stateChanged(int state) ui->comboBoxLpt4->setEnabled(state == Qt::Checked); } +void +SettingsPorts::on_checkBoxSerial1_stateChanged(int state) +{ + ui->checkBoxSerialPassThru1->setEnabled(state == Qt::Checked); + ui->pushButtonSerialPassThru1->setEnabled((state == Qt::Checked) && ui->checkBoxSerialPassThru1->isChecked()); +} + +void +SettingsPorts::on_checkBoxSerial2_stateChanged(int state) +{ + ui->checkBoxSerialPassThru2->setEnabled(state == Qt::Checked); + ui->pushButtonSerialPassThru2->setEnabled((state == Qt::Checked) && ui->checkBoxSerialPassThru2->isChecked()); +} + +void +SettingsPorts::on_checkBoxSerial3_stateChanged(int state) +{ + ui->checkBoxSerialPassThru3->setEnabled(state == Qt::Checked); + ui->pushButtonSerialPassThru3->setEnabled((state == Qt::Checked) && ui->checkBoxSerialPassThru3->isChecked()); +} + +void +SettingsPorts::on_checkBoxSerial4_stateChanged(int state) +{ + ui->checkBoxSerialPassThru4->setEnabled(state == Qt::Checked); + ui->pushButtonSerialPassThru4->setEnabled((state == Qt::Checked) && ui->checkBoxSerialPassThru4->isChecked()); +} + +#if 0 +void +SettingsPorts::on_checkBoxSerial5_stateChanged(int state) +{ + ui->checkBoxSerialPassThru5->setEnabled(state == Qt::Checked); + ui->pushButtonSerialPassThru5->setEnabled((state == Qt::Checked) && ui->checkBoxSerialPassThru5->isChecked()); +} + +void +SettingsPorts::on_checkBoxSerial6_stateChanged(int state) +{ + ui->checkBoxSerialPassThru6->setEnabled(state == Qt::Checked); + ui->pushButtonSerialPassThru6->setEnabled((state == Qt::Checked) && ui->checkBoxSerialPassThru6->isChecked()); +} + +void +SettingsPorts::on_checkBoxSerial7_stateChanged(int state) +{ + ui->checkBoxSerialPassThru7->setEnabled(state == Qt::Checked); + ui->pushButtonSerialPassThru7->setEnabled((state == Qt::Checked) && ui->checkBoxSerialPassThru7->isChecked()); +} +#endif + +void +SettingsPorts::on_checkBoxSerialPassThru1_stateChanged(int state) +{ + ui->pushButtonSerialPassThru1->setEnabled(state == Qt::Checked); +} + +void +SettingsPorts::on_checkBoxSerialPassThru2_stateChanged(int state) +{ + ui->pushButtonSerialPassThru2->setEnabled(state == Qt::Checked); +} + +void +SettingsPorts::on_checkBoxSerialPassThru3_stateChanged(int state) +{ + ui->pushButtonSerialPassThru3->setEnabled(state == Qt::Checked); +} + +void +SettingsPorts::on_checkBoxSerialPassThru4_stateChanged(int state) +{ + ui->pushButtonSerialPassThru4->setEnabled(state == Qt::Checked); +} + +#if 0 +void +SettingsPorts::on_checkBoxSerialPassThru5_stateChanged(int state) +{ + ui->pushButtonSerialPassThru5->setEnabled(state == Qt::Checked); +} + +void +SettingsPorts::on_checkBoxSerialPassThru6_stateChanged(int state) +{ + ui->pushButtonSerialPassThru6->setEnabled(state == Qt::Checked); +} + +void +SettingsPorts::on_checkBoxSerialPassThru7_stateChanged(int state) +{ + ui->pushButtonSerialPassThru7->setEnabled(state == Qt::Checked); +} +#endif + void SettingsPorts::on_pushButtonSerialPassThru1_clicked() { @@ -179,47 +275,3 @@ SettingsPorts::on_pushButtonSerialPassThru7_clicked() DeviceConfig::ConfigureDevice(&serial_passthrough_device, 7, qobject_cast(Settings::settings)); } #endif - -void -SettingsPorts::on_checkBoxSerialPassThru1_clicked(bool checked) -{ - ui->pushButtonSerialPassThru1->setEnabled(checked); -} - -void -SettingsPorts::on_checkBoxSerialPassThru2_clicked(bool checked) -{ - ui->pushButtonSerialPassThru2->setEnabled(checked); -} - -void -SettingsPorts::on_checkBoxSerialPassThru3_clicked(bool checked) -{ - ui->pushButtonSerialPassThru3->setEnabled(checked); -} - -void -SettingsPorts::on_checkBoxSerialPassThru4_clicked(bool checked) -{ - ui->pushButtonSerialPassThru4->setEnabled(checked); -} - -#if 0 -void -SettingsPorts::on_checkBoxSerialPassThru5_clicked(bool checked) -{ - ui->pushButtonSerialPassThru5->setEnabled(checked); -} - -void -SettingsPorts::on_checkBoxSerialPassThru6_clicked(bool checked) -{ - ui->pushButtonSerialPassThru6->setEnabled(checked); -} - -void -SettingsPorts::on_checkBoxSerialPassThru7_clicked(bool checked) -{ - ui->pushButtonSerialPassThru7->setEnabled(checked); -} -#endif diff --git a/src/qt/qt_settingsports.hpp b/src/qt/qt_settingsports.hpp index fb9cdb343..83560914f 100644 --- a/src/qt/qt_settingsports.hpp +++ b/src/qt/qt_settingsports.hpp @@ -16,36 +16,47 @@ public: void save(); -#if 0 -private slots: - void on_checkBoxSerialPassThru7_clicked(bool checked); - void on_checkBoxSerialPassThru6_clicked(bool checked); - void on_checkBoxSerialPassThru5_clicked(bool checked); -#endif - void on_checkBoxSerialPassThru4_clicked(bool checked); - void on_checkBoxSerialPassThru3_clicked(bool checked); - void on_checkBoxSerialPassThru2_clicked(bool checked); - void on_checkBoxSerialPassThru1_clicked(bool checked); +public slots: + void onCurrentMachineChanged(int machineId); private slots: + void on_checkBoxParallel1_stateChanged(int state); + void on_checkBoxParallel2_stateChanged(int state); + void on_checkBoxParallel3_stateChanged(int state); + void on_checkBoxParallel4_stateChanged(int state); + + void on_checkBoxSerial1_stateChanged(int state); + void on_checkBoxSerial2_stateChanged(int state); + void on_checkBoxSerial3_stateChanged(int state); + void on_checkBoxSerial4_stateChanged(int state); #if 0 - void on_pushButtonSerialPassThru7_clicked(); - void on_pushButtonSerialPassThru6_clicked(); - void on_pushButtonSerialPassThru5_clicked(); + void on_checkBoxSerial5_stateChanged(int state); + void on_checkBoxSerial6_stateChanged(int state); + void on_checkBoxSerial7_stateChanged(int state); #endif - void on_pushButtonSerialPassThru4_clicked(); - void on_pushButtonSerialPassThru3_clicked(); - void on_pushButtonSerialPassThru2_clicked(); + void on_checkBoxSerialPassThru1_stateChanged(int state); + void on_checkBoxSerialPassThru2_stateChanged(int state); + void on_checkBoxSerialPassThru3_stateChanged(int state); + void on_checkBoxSerialPassThru4_stateChanged(int state); +#if 0 + void on_checkBoxSerialPassThru5_stateChanged(int state); + void on_checkBoxSerialPassThru6_stateChanged(int state); + void on_checkBoxSerialPassThru7_stateChanged(int state); +#endif + void on_pushButtonSerialPassThru1_clicked(); - -private slots: - void on_checkBoxParallel4_stateChanged(int arg1); - void on_checkBoxParallel3_stateChanged(int arg1); - void on_checkBoxParallel2_stateChanged(int arg1); - void on_checkBoxParallel1_stateChanged(int arg1); + void on_pushButtonSerialPassThru2_clicked(); + void on_pushButtonSerialPassThru3_clicked(); + void on_pushButtonSerialPassThru4_clicked(); +#if 0 + void on_pushButtonSerialPassThru5_clicked(); + void on_pushButtonSerialPassThru6_clicked(); + void on_pushButtonSerialPassThru7_clicked(); +#endif private: Ui::SettingsPorts *ui; + int machineId = 0; }; #endif // QT_SETTINGSPORTS_HPP