From 4af09535c3a4515d9a067b90cf6f793fa1865919 Mon Sep 17 00:00:00 2001 From: OBattler Date: Fri, 6 Oct 2023 05:47:40 +0200 Subject: [PATCH] Phase 4 (list Internal as an option only for the first sound or network card). --- src/qt/qt_settingsnetwork.cpp | 12 +++--------- src/qt/qt_settingssound.cpp | 28 +++++----------------------- 2 files changed, 8 insertions(+), 32 deletions(-) diff --git a/src/qt/qt_settingsnetwork.cpp b/src/qt/qt_settingsnetwork.cpp index 5845149c9..2aa3705fd 100644 --- a/src/qt/qt_settingsnetwork.cpp +++ b/src/qt/qt_settingsnetwork.cpp @@ -48,7 +48,7 @@ SettingsNetwork::enableElements(Ui::SettingsNetwork *ui) intf_cbox->setEnabled(net_type_cbox->currentData().toInt() == NET_TYPE_PCAP); nic_cbox->setEnabled(adaptersEnabled); int netCard = nic_cbox->currentData().toInt(); - if (netCard == NET_INTERNAL) + if ((i == 0) && (netCard == NET_INTERNAL)) conf_btn->setEnabled(adaptersEnabled && machine_has_flags(machineId, MACHINE_NIC) && device_has_config(machine_get_net_device(machineId))); else @@ -115,8 +115,8 @@ SettingsNetwork::onCurrentMachineChanged(int machineId) selectedRow = 0; while (true) { - /* Skip "internal" if machine doesn't have it. */ - if ((c == 1) && (machine_has_flags(machineId, MACHINE_NIC) == 0)) { + /* Skip "internal" if machine doesn't have it or this is not the primary card. */ + if ((c == 1) && ((i > 0) || (machine_has_flags(machineId, MACHINE_NIC) == 0))) { c++; continue; } @@ -205,8 +205,6 @@ SettingsNetwork::on_pushButtonConf2_clicked() { int netCard = ui->comboBoxNIC2->currentData().toInt(); auto *device = network_card_getdevice(netCard); - if (netCard == NET_INTERNAL) - device = machine_get_net_device(machineId); DeviceConfig::ConfigureDevice(device, 2, qobject_cast(Settings::settings)); } @@ -215,8 +213,6 @@ SettingsNetwork::on_pushButtonConf3_clicked() { int netCard = ui->comboBoxNIC3->currentData().toInt(); auto *device = network_card_getdevice(netCard); - if (netCard == NET_INTERNAL) - device = machine_get_net_device(machineId); DeviceConfig::ConfigureDevice(device, 3, qobject_cast(Settings::settings)); } @@ -225,7 +221,5 @@ SettingsNetwork::on_pushButtonConf4_clicked() { int netCard = ui->comboBoxNIC4->currentData().toInt(); auto *device = network_card_getdevice(netCard); - if (netCard == NET_INTERNAL) - device = machine_get_net_device(machineId); DeviceConfig::ConfigureDevice(device, 4, qobject_cast(Settings::settings)); } diff --git a/src/qt/qt_settingssound.cpp b/src/qt/qt_settingssound.cpp index d51249d9c..b4df4ff69 100644 --- a/src/qt/qt_settingssound.cpp +++ b/src/qt/qt_settingssound.cpp @@ -82,8 +82,8 @@ SettingsSound::onCurrentMachineChanged(int machineId) selectedRow = 0; while (true) { - /* Skip "internal" if machine doesn't have it. */ - if ((c == 1) && (machine_has_flags(machineId, MACHINE_SOUND) == 0)) { + /* Skip "internal" if machine doesn't have it or this is not the primary card. */ + if ((c == 1) && ((i > 0) || (machine_has_flags(machineId, MACHINE_SOUND) == 0))) { c++; continue; } @@ -217,11 +217,7 @@ SettingsSound::on_comboBoxSoundCard2_currentIndexChanged(int index) return; } int sndCard = ui->comboBoxSoundCard2->currentData().toInt(); - if (sndCard == SOUND_INTERNAL) - ui->pushButtonConfigureSoundCard2->setEnabled(machine_has_flags(machineId, MACHINE_SOUND) && - device_has_config(machine_get_snd_device(machineId))); - else - ui->pushButtonConfigureSoundCard2->setEnabled(sound_card_has_config(ui->comboBoxSoundCard2->currentData().toInt())); + ui->pushButtonConfigureSoundCard2->setEnabled(sound_card_has_config(sndCard)); } void @@ -229,8 +225,6 @@ SettingsSound::on_pushButtonConfigureSoundCard2_clicked() { int sndCard = ui->comboBoxSoundCard2->currentData().toInt(); auto *device = sound_card_getdevice(sndCard); - if (sndCard == SOUND_INTERNAL) - device = machine_get_snd_device(machineId); DeviceConfig::ConfigureDevice(device, 0, qobject_cast(Settings::settings)); } @@ -241,11 +235,7 @@ SettingsSound::on_comboBoxSoundCard3_currentIndexChanged(int index) return; } int sndCard = ui->comboBoxSoundCard3->currentData().toInt(); - if (sndCard == SOUND_INTERNAL) - ui->pushButtonConfigureSoundCard3->setEnabled(machine_has_flags(machineId, MACHINE_SOUND) && - device_has_config(machine_get_snd_device(machineId))); - else - ui->pushButtonConfigureSoundCard3->setEnabled(sound_card_has_config(ui->comboBoxSoundCard3->currentData().toInt())); + ui->pushButtonConfigureSoundCard3->setEnabled(sound_card_has_config(sndCard)); } void @@ -253,8 +243,6 @@ SettingsSound::on_pushButtonConfigureSoundCard3_clicked() { int sndCard = ui->comboBoxSoundCard3->currentData().toInt(); auto *device = sound_card_getdevice(sndCard); - if (sndCard == SOUND_INTERNAL) - device = machine_get_snd_device(machineId); DeviceConfig::ConfigureDevice(device, 0, qobject_cast(Settings::settings)); } @@ -265,11 +253,7 @@ SettingsSound::on_comboBoxSoundCard4_currentIndexChanged(int index) return; } int sndCard = ui->comboBoxSoundCard4->currentData().toInt(); - if (sndCard == SOUND_INTERNAL) - ui->pushButtonConfigureSoundCard4->setEnabled(machine_has_flags(machineId, MACHINE_SOUND) && - device_has_config(machine_get_snd_device(machineId))); - else - ui->pushButtonConfigureSoundCard4->setEnabled(sound_card_has_config(ui->comboBoxSoundCard4->currentData().toInt())); + ui->pushButtonConfigureSoundCard4->setEnabled(sound_card_has_config(sndCard)); } void @@ -277,8 +261,6 @@ SettingsSound::on_pushButtonConfigureSoundCard4_clicked() { int sndCard = ui->comboBoxSoundCard4->currentData().toInt(); auto *device = sound_card_getdevice(sndCard); - if (sndCard == SOUND_INTERNAL) - device = machine_get_snd_device(machineId); DeviceConfig::ConfigureDevice(device, 0, qobject_cast(Settings::settings)); }