Don't let the user modify static IPv4 addresses unless IPv4 mode is Manual

main
Aaron Rainbolt 1 year ago
parent 652ade8704
commit 881256f232

@ -7,6 +7,7 @@ Ipv4SettingsTab::Ipv4SettingsTab(QWidget *parent) :
{ {
ui->setupUi(this); ui->setupUi(this);
ui->methodComboBox->addItems(QStringList() << tr("Automatic") << tr("Automatic (address-only)") << tr("Link-Local") << tr("Manual") << tr("Shared to other computers") << tr("Disabled")); ui->methodComboBox->addItems(QStringList() << tr("Automatic") << tr("Automatic (address-only)") << tr("Link-Local") << tr("Manual") << tr("Shared to other computers") << tr("Disabled"));
connect(ui->methodComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &Ipv4SettingsTab::onMethodComboBoxCurrentIndexChanged);
connect(ui->editDnsServersButton, &QPushButton::clicked, this, &Ipv4SettingsTab::onEditDnsServersButtonClicked); connect(ui->editDnsServersButton, &QPushButton::clicked, this, &Ipv4SettingsTab::onEditDnsServersButtonClicked);
connect(ui->editSearchDomainsButton, &QPushButton::clicked, this, &Ipv4SettingsTab::onEditSearchDomainsButtonClicked); connect(ui->editSearchDomainsButton, &QPushButton::clicked, this, &Ipv4SettingsTab::onEditSearchDomainsButtonClicked);
connect(ui->manualIpv4ConfigurationAddButton, &QPushButton::clicked, this, &Ipv4SettingsTab::onManualIpv4ConfigurationAddButtonClicked); connect(ui->manualIpv4ConfigurationAddButton, &QPushButton::clicked, this, &Ipv4SettingsTab::onManualIpv4ConfigurationAddButtonClicked);
@ -84,6 +85,8 @@ void Ipv4SettingsTab::loadSettings(QVariantMap settings)
} }
} }
onMethodComboBoxCurrentIndexChanged(ui->methodComboBox->currentIndex());
if (settings["ipv4DnsServers"].isValid()) { if (settings["ipv4DnsServers"].isValid()) {
ui->dnsServersLineEdit->setText(settings["ipv4DnsServers"].toString()); ui->dnsServersLineEdit->setText(settings["ipv4DnsServers"].toString());
} }
@ -112,6 +115,15 @@ void Ipv4SettingsTab::loadSettings(QVariantMap settings)
} }
} }
void Ipv4SettingsTab::onMethodComboBoxCurrentIndexChanged(int index)
{
if (index == 3) { // manual
ui->manualIpv4ConfigurationTable->setEnabled(true);
} else {
ui->manualIpv4ConfigurationTable->setEnabled(false);
}
}
void Ipv4SettingsTab::onEditDnsServersButtonClicked() void Ipv4SettingsTab::onEditDnsServersButtonClicked()
{ {
ListEditorDialog led(this, ui->dnsServersLineEdit->text(), ','); ListEditorDialog led(this, ui->dnsServersLineEdit->text(), ',');

@ -26,6 +26,7 @@ private slots:
void onEditSearchDomainsButtonClicked(); void onEditSearchDomainsButtonClicked();
void onManualIpv4ConfigurationAddButtonClicked(); void onManualIpv4ConfigurationAddButtonClicked();
void onManualIpv4ConfigurationRemoveButtonClicked(); void onManualIpv4ConfigurationRemoveButtonClicked();
void onMethodComboBoxCurrentIndexChanged(int index);
private: private:
Ui::Ipv4SettingsTab *ui; Ui::Ipv4SettingsTab *ui;

Loading…
Cancel
Save