Add plumbing for updates on machine change to the port settings page

This commit is contained in:
Alexander Babikov
2025-03-01 15:22:36 +05:00
parent b018017c55
commit 3bbeae91d1
3 changed files with 116 additions and 104 deletions

View File

@@ -153,6 +153,8 @@ Settings::Settings(QWidget *parent)
&SettingsSound::onCurrentMachineChanged); &SettingsSound::onCurrentMachineChanged);
connect(machine, &SettingsMachine::currentMachineChanged, network, connect(machine, &SettingsMachine::currentMachineChanged, network,
&SettingsNetwork::onCurrentMachineChanged); &SettingsNetwork::onCurrentMachineChanged);
connect(machine, &SettingsMachine::currentMachineChanged, ports,
&SettingsPorts::onCurrentMachineChanged);
connect(machine, &SettingsMachine::currentMachineChanged, storageControllers, connect(machine, &SettingsMachine::currentMachineChanged, storageControllers,
&SettingsStorageControllers::onCurrentMachineChanged); &SettingsStorageControllers::onCurrentMachineChanged);
connect(machine, &SettingsMachine::currentMachineChanged, otherPeripherals, connect(machine, &SettingsMachine::currentMachineChanged, otherPeripherals,

View File

@@ -38,6 +38,40 @@ SettingsPorts::SettingsPorts(QWidget *parent)
, ui(new Ui::SettingsPorts) , ui(new Ui::SettingsPorts)
{ {
ui->setupUi(this); ui->setupUi(this);
onCurrentMachineChanged(machine);
}
SettingsPorts::~SettingsPorts()
{
delete ui;
}
void
SettingsPorts::save()
{
for (int i = 0; i < PARALLEL_MAX; i++) {
auto *cbox = findChild<QComboBox *>(QString("comboBoxLpt%1").arg(i + 1));
auto *checkBox = findChild<QCheckBox *>(QString("checkBoxParallel%1").arg(i + 1));
if (cbox != NULL)
lpt_ports[i].device = cbox->currentData().toInt();
if (checkBox != NULL)
lpt_ports[i].enabled = checkBox->isChecked() ? 1 : 0;
}
for (int i = 0; i < SERIAL_MAX; i++) {
auto *checkBox = findChild<QCheckBox *>(QString("checkBoxSerial%1").arg(i + 1));
auto *checkBoxPass = findChild<QCheckBox *>(QString("checkBoxSerialPassThru%1").arg(i + 1));
if (checkBox != NULL)
com_ports[i].enabled = checkBox->isChecked() ? 1 : 0;
if (checkBoxPass != NULL)
serial_passthrough_enabled[i] = checkBoxPass->isChecked();
}
}
void
SettingsPorts::onCurrentMachineChanged(int machineId)
{
this->machineId = machineId;
for (int i = 0; i < PARALLEL_MAX; i++) { for (int i = 0; i < PARALLEL_MAX; i++) {
auto *cbox = findChild<QComboBox *>(QString("comboBoxLpt%1").arg(i + 1)); auto *cbox = findChild<QComboBox *>(QString("comboBoxLpt%1").arg(i + 1));
@@ -79,33 +113,6 @@ SettingsPorts::SettingsPorts(QWidget *parent)
} }
} }
SettingsPorts::~SettingsPorts()
{
delete ui;
}
void
SettingsPorts::save()
{
for (int i = 0; i < PARALLEL_MAX; i++) {
auto *cbox = findChild<QComboBox *>(QString("comboBoxLpt%1").arg(i + 1));
auto *checkBox = findChild<QCheckBox *>(QString("checkBoxParallel%1").arg(i + 1));
if (cbox != NULL)
lpt_ports[i].device = cbox->currentData().toInt();
if (checkBox != NULL)
lpt_ports[i].enabled = checkBox->isChecked() ? 1 : 0;
}
for (int i = 0; i < SERIAL_MAX; i++) {
auto *checkBox = findChild<QCheckBox *>(QString("checkBoxSerial%1").arg(i + 1));
auto *checkBoxPass = findChild<QCheckBox *>(QString("checkBoxSerialPassThru%1").arg(i + 1));
if (checkBox != NULL)
com_ports[i].enabled = checkBox->isChecked() ? 1 : 0;
if (checkBoxPass != NULL)
serial_passthrough_enabled[i] = checkBoxPass->isChecked();
}
}
void void
SettingsPorts::on_checkBoxParallel1_stateChanged(int state) SettingsPorts::on_checkBoxParallel1_stateChanged(int state)
{ {
@@ -130,50 +137,6 @@ SettingsPorts::on_checkBoxParallel4_stateChanged(int state)
ui->comboBoxLpt4->setEnabled(state == Qt::Checked); ui->comboBoxLpt4->setEnabled(state == Qt::Checked);
} }
void
SettingsPorts::on_pushButtonSerialPassThru1_clicked()
{
DeviceConfig::ConfigureDevice(&serial_passthrough_device, 1, qobject_cast<Settings *>(Settings::settings));
}
void
SettingsPorts::on_pushButtonSerialPassThru2_clicked()
{
DeviceConfig::ConfigureDevice(&serial_passthrough_device, 2, qobject_cast<Settings *>(Settings::settings));
}
void
SettingsPorts::on_pushButtonSerialPassThru3_clicked()
{
DeviceConfig::ConfigureDevice(&serial_passthrough_device, 3, qobject_cast<Settings *>(Settings::settings));
}
void
SettingsPorts::on_pushButtonSerialPassThru4_clicked()
{
DeviceConfig::ConfigureDevice(&serial_passthrough_device, 4, qobject_cast<Settings *>(Settings::settings));
}
#if 0
void
SettingsPorts::on_pushButtonSerialPassThru5_clicked()
{
DeviceConfig::ConfigureDevice(&serial_passthrough_device, 5, qobject_cast<Settings *>(Settings::settings));
}
void
SettingsPorts::on_pushButtonSerialPassThru6_clicked()
{
DeviceConfig::ConfigureDevice(&serial_passthrough_device, 6, qobject_cast<Settings *>(Settings::settings));
}
void
SettingsPorts::on_pushButtonSerialPassThru7_clicked()
{
DeviceConfig::ConfigureDevice(&serial_passthrough_device, 7, qobject_cast<Settings *>(Settings::settings));
}
#endif
void void
SettingsPorts::on_checkBoxSerial1_stateChanged(int state) SettingsPorts::on_checkBoxSerial1_stateChanged(int state)
{ {
@@ -268,3 +231,47 @@ SettingsPorts::on_checkBoxSerialPassThru7_stateChanged(int state)
ui->pushButtonSerialPassThru7->setEnabled(state == Qt::Checked); ui->pushButtonSerialPassThru7->setEnabled(state == Qt::Checked);
} }
#endif #endif
void
SettingsPorts::on_pushButtonSerialPassThru1_clicked()
{
DeviceConfig::ConfigureDevice(&serial_passthrough_device, 1, qobject_cast<Settings *>(Settings::settings));
}
void
SettingsPorts::on_pushButtonSerialPassThru2_clicked()
{
DeviceConfig::ConfigureDevice(&serial_passthrough_device, 2, qobject_cast<Settings *>(Settings::settings));
}
void
SettingsPorts::on_pushButtonSerialPassThru3_clicked()
{
DeviceConfig::ConfigureDevice(&serial_passthrough_device, 3, qobject_cast<Settings *>(Settings::settings));
}
void
SettingsPorts::on_pushButtonSerialPassThru4_clicked()
{
DeviceConfig::ConfigureDevice(&serial_passthrough_device, 4, qobject_cast<Settings *>(Settings::settings));
}
#if 0
void
SettingsPorts::on_pushButtonSerialPassThru5_clicked()
{
DeviceConfig::ConfigureDevice(&serial_passthrough_device, 5, qobject_cast<Settings *>(Settings::settings));
}
void
SettingsPorts::on_pushButtonSerialPassThru6_clicked()
{
DeviceConfig::ConfigureDevice(&serial_passthrough_device, 6, qobject_cast<Settings *>(Settings::settings));
}
void
SettingsPorts::on_pushButtonSerialPassThru7_clicked()
{
DeviceConfig::ConfigureDevice(&serial_passthrough_device, 7, qobject_cast<Settings *>(Settings::settings));
}
#endif

View File

@@ -16,44 +16,47 @@ public:
void save(); void save();
public slots:
void onCurrentMachineChanged(int machineId);
private slots: private slots:
#if 0
void on_checkBoxSerialPassThru7_stateChanged(int state);
void on_checkBoxSerialPassThru6_stateChanged(int state);
void on_checkBoxSerialPassThru5_stateChanged(int state);
#endif
void on_checkBoxSerialPassThru4_stateChanged(int state);
void on_checkBoxSerialPassThru3_stateChanged(int state);
void on_checkBoxSerialPassThru2_stateChanged(int state);
void on_checkBoxSerialPassThru1_stateChanged(int state);
#if 0
void on_checkBoxSerial7_stateChanged(int state);
void on_checkBoxSerial6_stateChanged(int state);
void on_checkBoxSerial5_stateChanged(int state);
#endif
void on_checkBoxSerial4_stateChanged(int state);
void on_checkBoxSerial3_stateChanged(int state);
void on_checkBoxSerial2_stateChanged(int state);
void on_checkBoxSerial1_stateChanged(int state);
#if 0
void on_pushButtonSerialPassThru7_clicked();
void on_pushButtonSerialPassThru6_clicked();
void on_pushButtonSerialPassThru5_clicked();
#endif
void on_pushButtonSerialPassThru4_clicked();
void on_pushButtonSerialPassThru3_clicked();
void on_pushButtonSerialPassThru2_clicked();
void on_pushButtonSerialPassThru1_clicked();
void on_checkBoxParallel4_stateChanged(int state);
void on_checkBoxParallel3_stateChanged(int state);
void on_checkBoxParallel2_stateChanged(int state);
void on_checkBoxParallel1_stateChanged(int state); 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_checkBoxSerial5_stateChanged(int state);
void on_checkBoxSerial6_stateChanged(int state);
void on_checkBoxSerial7_stateChanged(int state);
#endif
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();
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: private:
Ui::SettingsPorts *ui; Ui::SettingsPorts *ui;
int machineId = 0;
}; };
#endif // QT_SETTINGSPORTS_HPP #endif // QT_SETTINGSPORTS_HPP