From 127580b71bbf374c28c8075b1c15e775d16a7fd4 Mon Sep 17 00:00:00 2001 From: Jasmine Iwanek Date: Fri, 9 May 2025 21:06:31 -0400 Subject: [PATCH] Clean QT Network UI --- src/qt/qt_settingsnetwork.cpp | 44 +-- src/qt/qt_settingsnetwork.ui | 513 ++++++++++++++++++---------------- 2 files changed, 288 insertions(+), 269 deletions(-) diff --git a/src/qt/qt_settingsnetwork.cpp b/src/qt/qt_settingsnetwork.cpp index 1ea48ee6b..2e64175eb 100644 --- a/src/qt/qt_settingsnetwork.cpp +++ b/src/qt/qt_settingsnetwork.cpp @@ -36,17 +36,17 @@ SettingsNetwork::enableElements(Ui::SettingsNetwork *ui) auto *nic_cbox = findChild(QString("comboBoxNIC%1").arg(i + 1)); auto *net_type_cbox = findChild(QString("comboBoxNet%1").arg(i + 1)); - auto *intf_label = findChild(QString("interfaceLabel%1").arg(i + 1)); + auto *intf_label = findChild(QString("labelIntf%1").arg(i + 1)); auto *intf_cbox = findChild(QString("comboBoxIntf%1").arg(i + 1)); auto *conf_btn = findChild(QString("pushButtonConf%1").arg(i + 1)); // auto *net_type_conf_btn = findChild(QString("pushButtonNetTypeConf%1").arg(i + 1)); - auto *vde_socket_label = findChild(QString("socketVDELabel%1").arg(i + 1)); + auto *vde_socket_label = findChild(QString("labelSocketVDENIC%1").arg(i + 1)); auto *socket_line = findChild(QString("socketVDENIC%1").arg(i + 1)); - auto *option_list_label = findChild(QString("optionListLabel%1").arg(i + 1)); - auto *option_list_line = findChild(QString("optionListLine%1").arg(i + 1)); + auto *option_list_label = findChild(QString("labelOptionList%1").arg(i + 1)); + auto *option_list_line = findChild(QString("lineOptionList%1").arg(i + 1)); intf_cbox->setEnabled(net_type_cbox->currentData().toInt() == NET_TYPE_PCAP); conf_btn->setEnabled(network_card_has_config(nic_cbox->currentData().toInt())); @@ -56,7 +56,6 @@ SettingsNetwork::enableElements(Ui::SettingsNetwork *ui) option_list_label->setVisible(false); option_list_line->setVisible(false); - // VDE vde_socket_label->setVisible(false); socket_line->setVisible(false); @@ -70,21 +69,26 @@ SettingsNetwork::enableElements(Ui::SettingsNetwork *ui) // Then only enable as needed based on network type switch (net_type_cbox->currentData().toInt()) { case NET_TYPE_VDE: - // option_list_label->setText("VDE Options"); + // option_list_label->setText("VDE Options"); option_list_label->setVisible(true); option_list_line->setVisible(true); vde_socket_label->setVisible(true); socket_line->setVisible(true); break; + case NET_TYPE_PCAP: - // option_list_label->setText("PCAP Options"); + // option_list_label->setText("PCAP Options"); option_list_label->setVisible(true); option_list_line->setVisible(true); intf_cbox->setVisible(true); intf_label->setVisible(true); break; + + case NET_TYPE_SLIRP: + default: + break; } } } @@ -124,11 +128,10 @@ SettingsNetwork::save() net_cards_conf[i].net_type = cbox->currentData().toInt(); cbox = findChild(QString("comboBoxIntf%1").arg(i + 1)); memset(net_cards_conf[i].host_dev_name, '\0', sizeof(net_cards_conf[i].host_dev_name)); - if (net_cards_conf[i].net_type == NET_TYPE_PCAP) { + if (net_cards_conf[i].net_type == NET_TYPE_PCAP) strncpy(net_cards_conf[i].host_dev_name, network_devs[cbox->currentData().toInt()].device, sizeof(net_cards_conf[i].host_dev_name) - 1); - } else if (net_cards_conf[i].net_type == NET_TYPE_VDE) { + else if (net_cards_conf[i].net_type == NET_TYPE_VDE) strncpy(net_cards_conf[i].host_dev_name, socket_line->text().toUtf8().constData(), sizeof(net_cards_conf[i].host_dev_name)); - } } } @@ -141,7 +144,7 @@ SettingsNetwork::onCurrentMachineChanged(int machineId) int selectedRow = 0; // Network Card - QComboBox * cbox_[NET_CARD_MAX] = { 0 }; + QComboBox *cbox_[NET_CARD_MAX] = { 0 }; QAbstractItemModel *models[NET_CARD_MAX] = { 0 }; int removeRows_[NET_CARD_MAX] = { 0 }; int selectedRows[NET_CARD_MAX] = { 0 }; @@ -226,9 +229,8 @@ SettingsNetwork::onCurrentMachineChanged(int machineId) void SettingsNetwork::on_comboIndexChanged(int index) { - if (index < 0) { + if (index < 0) return; - } enableElements(ui); } @@ -236,8 +238,8 @@ SettingsNetwork::on_comboIndexChanged(int index) void SettingsNetwork::on_pushButtonConf1_clicked() { - int netCard = ui->comboBoxNIC1->currentData().toInt(); - auto *device = network_card_getdevice(netCard); + int netCard = ui->comboBoxNIC1->currentData().toInt(); + auto *device = network_card_getdevice(netCard); if (netCard == NET_INTERNAL) device = machine_get_net_device(machineId); DeviceConfig::ConfigureDevice(device, 1); @@ -246,23 +248,23 @@ SettingsNetwork::on_pushButtonConf1_clicked() void SettingsNetwork::on_pushButtonConf2_clicked() { - int netCard = ui->comboBoxNIC2->currentData().toInt(); - auto *device = network_card_getdevice(netCard); + int netCard = ui->comboBoxNIC2->currentData().toInt(); + auto *device = network_card_getdevice(netCard); DeviceConfig::ConfigureDevice(device, 2); } void SettingsNetwork::on_pushButtonConf3_clicked() { - int netCard = ui->comboBoxNIC3->currentData().toInt(); - auto *device = network_card_getdevice(netCard); + int netCard = ui->comboBoxNIC3->currentData().toInt(); + auto *device = network_card_getdevice(netCard); DeviceConfig::ConfigureDevice(device, 3); } void SettingsNetwork::on_pushButtonConf4_clicked() { - int netCard = ui->comboBoxNIC4->currentData().toInt(); - auto *device = network_card_getdevice(netCard); + int netCard = ui->comboBoxNIC4->currentData().toInt(); + auto *device = network_card_getdevice(netCard); DeviceConfig::ConfigureDevice(device, 4); } diff --git a/src/qt/qt_settingsnetwork.ui b/src/qt/qt_settingsnetwork.ui index 8fb048f71..0c0979c46 100644 --- a/src/qt/qt_settingsnetwork.ui +++ b/src/qt/qt_settingsnetwork.ui @@ -27,15 +27,29 @@ 0 - + 0 - + + Network Card #1 - + + + + + + 0 + 0 + + + + Mode: + + + @@ -50,7 +64,7 @@ - + 0 @@ -62,79 +76,6 @@ - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - 0 - 0 - - - - Mode: - - - - - - - Qt::Horizontal - - - - - - - - 0 - 0 - - - - Configure - - - - - - - Options - - - - - - - - 0 - 0 - - - - Interface: - - - - - - - VDE Socket: - - - @@ -151,10 +92,43 @@ - - - - 127 + + + + + 0 + 0 + + + + Configure + + + + + + + Options + + + + + + + Qt::Horizontal + + + + + + + + 0 + 0 + + + + Interface: @@ -168,15 +142,22 @@ - - - - - Network Card #2 - - + + + + VDE Socket: + + + + + + + 127 + + + - + Qt::Vertical @@ -188,28 +169,16 @@ - - - - - 0 - 0 - - - - Interface: - - - - - - - Options - - - + + + + + + Network Card #2 + + - + 0 @@ -234,22 +203,8 @@ - - - - VDE Socket: - - - - - - - Qt::Horizontal - - - - + 0 @@ -261,6 +216,22 @@ + + + + + 0 + 0 + + + + QComboBox::AdjustToContents + + + 30 + + + @@ -274,25 +245,33 @@ - - - - 30 + + + + Options + + + + + + Qt::Horizontal + + + + + - + 0 0 - - QComboBox::AdjustToContents + + Interface: - - - @@ -303,13 +282,54 @@ + + + + VDE Socket: + + + + + + + 127 + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + - + + Network Card #3 - + + + + + + 0 + 0 + + + + Mode: + + + @@ -323,17 +343,16 @@ - - - - VDE Socket: + + + + + 0 + 0 + - - - - - Options + Adapter: @@ -353,39 +372,6 @@ - - - - - 0 - 0 - - - - Interface: - - - - - - - Qt::Horizontal - - - - - - - - 0 - 0 - - - - Mode: - - - @@ -399,8 +385,22 @@ - - + + + + Options + + + + + + + Qt::Horizontal + + + + + 0 @@ -408,13 +408,10 @@ - Adapter: + Interface: - - - @@ -425,8 +422,22 @@ + + + + VDE Socket: + + + + + + + 127 + + + - + Qt::Vertical @@ -440,20 +451,14 @@ - + + Network Card #4 - - - - - Options - - - + - + 0 @@ -465,28 +470,21 @@ - - - - Qt::Vertical + + + + 30 - - - 20 - 40 - - - - - - - - VDE Socket: + + + 0 + 0 + - + 0 @@ -498,26 +496,6 @@ - - - - Qt::Horizontal - - - - - - - - 0 - 0 - - - - Interface: - - - @@ -534,19 +512,6 @@ - - - - 30 - - - - 0 - 0 - - - - @@ -560,8 +525,32 @@ - - + + + + Options + + + + + + + Qt::Horizontal + + + + + + + + 0 + 0 + + + + Interface: + + @@ -573,8 +562,36 @@ + + + + VDE Socket: + + + + + + + 127 + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + +