Preliminary IPv6 settings editing support (glitchy)

main
Aaron Rainbolt 1 year ago
parent 881256f232
commit 04c53a4e03

@ -52,6 +52,9 @@ set(PROJECT_SOURCES
listeditordialog.h listeditordialog.h
listeditordialog.cpp listeditordialog.cpp
listeditordialog.ui listeditordialog.ui
ipv6settingstab.h
ipv6settingstab.cpp
ipv6settingstab.ui
${TS_FILES} ${TS_FILES}
) )

@ -26,6 +26,15 @@ QString ConnectionSettingsEngine::targetConnUuidStr = QString();
* ipv4AddressList: QList<NetworkManager::IpAddress> * ipv4AddressList: QList<NetworkManager::IpAddress>
* ipv4Required: bool * ipv4Required: bool
* *
* All things IPv6:
*
* ipv6Method: ConnectionSettingsEngine::Ipv6Method
* ipv6DnsServers: QString
* ipv6SearchDomains: QString
* ipv6Privacy: ConnectionSettingsEngine::Ipv6Privacy
* ipv6AddressList: QList<NetworkManager::IpAddress>
* ipv6Required: bool
*
* All things 802.1x: * All things 802.1x:
* *
* NOTE: File names begin with "file://"! * NOTE: File names begin with "file://"!
@ -88,6 +97,7 @@ QVariantMap ConnectionSettingsEngine::readConnectionSettings(QString connUuidStr
NetworkManager::WiredSetting::Ptr connWiredSetting = connSettings->setting(NetworkManager::Setting::Wired).dynamicCast<NetworkManager::WiredSetting>(); NetworkManager::WiredSetting::Ptr connWiredSetting = connSettings->setting(NetworkManager::Setting::Wired).dynamicCast<NetworkManager::WiredSetting>();
NetworkManager::WirelessSetting::Ptr connWirelessSetting = connSettings->setting(NetworkManager::Setting::Wireless).dynamicCast<NetworkManager::WirelessSetting>(); NetworkManager::WirelessSetting::Ptr connWirelessSetting = connSettings->setting(NetworkManager::Setting::Wireless).dynamicCast<NetworkManager::WirelessSetting>();
NetworkManager::Ipv4Setting::Ptr connIpv4Setting = connSettings->setting(NetworkManager::Setting::Ipv4).dynamicCast<NetworkManager::Ipv4Setting>(); NetworkManager::Ipv4Setting::Ptr connIpv4Setting = connSettings->setting(NetworkManager::Setting::Ipv4).dynamicCast<NetworkManager::Ipv4Setting>();
NetworkManager::Ipv6Setting::Ptr connIpv6Setting = connSettings->setting(NetworkManager::Setting::Ipv6).dynamicCast<NetworkManager::Ipv6Setting>();
QVariantMap result; QVariantMap result;
result.insert("connName", connSettings->id()); result.insert("connName", connSettings->id());
result.insert("autoconnectEnabled", connSettings->autoconnect()); result.insert("autoconnectEnabled", connSettings->autoconnect());
@ -169,6 +179,55 @@ QVariantMap ConnectionSettingsEngine::readConnectionSettings(QString connUuidStr
result.insert("ipv4Required", !connIpv4Setting->mayFail()); result.insert("ipv4Required", !connIpv4Setting->mayFail());
} }
if (!connIpv6Setting.isNull()) {
switch (connIpv6Setting->method()) {
case NetworkManager::Ipv6Setting::Automatic:
if (connIpv6Setting->ignoreAutoDns()) {
result.insert("ipv6Method", ConnectionSettingsEngine::Ipv6AutomaticAddressOnly);
} else {
result.insert("ipv6Method", ConnectionSettingsEngine::Ipv6Automatic);
}
break;
case NetworkManager::Ipv6Setting::Dhcp:
result.insert("ipv6Method", ConnectionSettingsEngine::Ipv6AutomaticDhcpOnly);
break;
case NetworkManager::Ipv6Setting::LinkLocal:
result.insert("ipv6Method", ConnectionSettingsEngine::Ipv6LinkLocal);
break;
case NetworkManager::Ipv6Setting::Manual:
result.insert("ipv6Method", ConnectionSettingsEngine::Ipv6Manual);
break;
case NetworkManager::Ipv6Setting::Ignored:
result.insert("ipv6Method", ConnectionSettingsEngine::Ipv6Ignored);
break;
case NetworkManager::Ipv6Setting::ConfigDisabled:
result.insert("ipv6Method", ConnectionSettingsEngine::Ipv6Disabled);
break;
}
QStringList dnsStringList;
for (const QHostAddress &addr : connIpv6Setting->dns()) {
dnsStringList.append(addr.toString());
}
result.insert("ipv6DnsServers", dnsStringList.join(","));
result.insert("ipv6SearchDomains", connIpv6Setting->dnsSearch().join(","));
switch (connIpv6Setting->privacy()) {
case NetworkManager::Ipv6Setting::Unknown:
result.insert("ipv6Privacy", ConnectionSettingsEngine::Ipv6PrivacyDefault);
break;
case NetworkManager::Ipv6Setting::Disabled:
result.insert("ipv6Privacy", ConnectionSettingsEngine::Ipv6PrivacyDisabled);
break;
case NetworkManager::Ipv6Setting::PreferPublic:
result.insert("ipv6Privacy", ConnectionSettingsEngine::Ipv6PrivacyEnabledPublicAddress);
break;
case NetworkManager::Ipv6Setting::PreferTemporary:
result.insert("ipv6Privacy", ConnectionSettingsEngine::Ipv6PrivacyEnabledTempAddress);
break;
}
result.insert("ipv6AddressList", QVariant::fromValue(connIpv6Setting->addresses()));
result.insert("ipv6Required", !connIpv6Setting->mayFail());
}
if (!connSecurity802_1xSetting.isNull()) { if (!connSecurity802_1xSetting.isNull()) {
QList<NetworkManager::Security8021xSetting::EapMethod> eapMethods = connSecurity802_1xSetting->eapMethods(); QList<NetworkManager::Security8021xSetting::EapMethod> eapMethods = connSecurity802_1xSetting->eapMethods();
if (eapMethods.length() != 0) { if (eapMethods.length() != 0) {
@ -369,7 +428,6 @@ void ConnectionSettingsEngine::modifyConnectionSettings(QString connUuidStr, QVa
{ {
// Contains adapted code from plasma-nm // Contains adapted code from plasma-nm
bool wipeClonedMacAddress = false; bool wipeClonedMacAddress = false;
bool wipeManualIpv4Addresses = false;
bool ensure802_1xSettings = false; bool ensure802_1xSettings = false;
NetworkManager::Connection::Ptr conn = NetworkManager::findConnectionByUuid(connUuidStr); NetworkManager::Connection::Ptr conn = NetworkManager::findConnectionByUuid(connUuidStr);
NetworkManager::ConnectionSettings::Ptr connSettings = conn->settings(); NetworkManager::ConnectionSettings::Ptr connSettings = conn->settings();
@ -377,6 +435,7 @@ void ConnectionSettingsEngine::modifyConnectionSettings(QString connUuidStr, QVa
NetworkManager::WirelessSetting::Ptr connWirelessSetting = connSettings->setting(NetworkManager::Setting::Wireless).dynamicCast<NetworkManager::WirelessSetting>(); NetworkManager::WirelessSetting::Ptr connWirelessSetting = connSettings->setting(NetworkManager::Setting::Wireless).dynamicCast<NetworkManager::WirelessSetting>();
NetworkManager::Security8021xSetting secSetting; NetworkManager::Security8021xSetting secSetting;
NetworkManager::Ipv4Setting::Ptr connIpv4Setting = connSettings->setting(NetworkManager::Setting::Ipv4).dynamicCast<NetworkManager::Ipv4Setting>(); NetworkManager::Ipv4Setting::Ptr connIpv4Setting = connSettings->setting(NetworkManager::Setting::Ipv4).dynamicCast<NetworkManager::Ipv4Setting>();
NetworkManager::Ipv6Setting::Ptr connIpv6Setting = connSettings->setting(NetworkManager::Setting::Ipv6).dynamicCast<NetworkManager::Ipv6Setting>();
if (settings["connName"].isValid()) { if (settings["connName"].isValid()) {
connSettings->setId(settings["connName"].toString()); connSettings->setId(settings["connName"].toString());
} }
@ -469,8 +528,6 @@ void ConnectionSettingsEngine::modifyConnectionSettings(QString connUuidStr, QVa
QList<NetworkManager::IpAddress> ipv4AddrList = settings["ipv4AddressList"].value<QList<NetworkManager::IpAddress>>(); QList<NetworkManager::IpAddress> ipv4AddrList = settings["ipv4AddressList"].value<QList<NetworkManager::IpAddress>>();
if (!ipv4AddrList.isEmpty()) { if (!ipv4AddrList.isEmpty()) {
connIpv4Setting->setAddresses(ipv4AddrList); connIpv4Setting->setAddresses(ipv4AddrList);
} else {
wipeManualIpv4Addresses = true;
} }
} }
@ -478,6 +535,78 @@ void ConnectionSettingsEngine::modifyConnectionSettings(QString connUuidStr, QVa
connIpv4Setting->setMayFail(!settings["ipv4Required"].toBool()); connIpv4Setting->setMayFail(!settings["ipv4Required"].toBool());
} }
if (settings["ipv6Method"].isValid()) {
switch(settings["ipv6Method"].toInt()) {
case ConnectionSettingsEngine::Ipv6Automatic:
connIpv6Setting->setMethod(NetworkManager::Ipv6Setting::Automatic);
connIpv6Setting->setIgnoreAutoDns(false);
break;
case ConnectionSettingsEngine::Ipv6AutomaticAddressOnly:
connIpv6Setting->setMethod(NetworkManager::Ipv6Setting::Automatic);
connIpv6Setting->setIgnoreAutoDns(true);
break;
case ConnectionSettingsEngine::Ipv6AutomaticDhcpOnly:
connIpv6Setting->setMethod(NetworkManager::Ipv6Setting::Dhcp);
break;
case ConnectionSettingsEngine::Ipv6LinkLocal:
connIpv6Setting->setMethod(NetworkManager::Ipv6Setting::LinkLocal);
break;
case ConnectionSettingsEngine::Ipv6Manual:
connIpv6Setting->setMethod(NetworkManager::Ipv6Setting::Manual);
break;
case ConnectionSettingsEngine::Ipv6Ignored:
connIpv6Setting->setMethod(NetworkManager::Ipv6Setting::Ignored);
break;
case ConnectionSettingsEngine::Ipv6Disabled:
connIpv6Setting->setMethod(NetworkManager::Ipv6Setting::ConfigDisabled);
break;
}
}
if (settings["ipv6DnsServers"].isValid()) {
QStringList dnsStringList = settings["ipv46nsServers"].toString().split(',');
QList<QHostAddress> dnsAddrList;
for (const QString &dnsStr : dnsStringList) {
QHostAddress dnsAddr(dnsStr);
if (!dnsAddr.isNull()) {
dnsAddrList.append(dnsAddr);
}
}
connIpv6Setting->setDns(dnsAddrList);
}
if (settings["ipv6SearchDomains"].isValid()) {
connIpv6Setting->setDnsSearch(settings["ipv6SearchDomains"].toString().split(','));
}
if (settings["ipv6Privacy"].isValid()) {
switch (settings["ipv6Privacy"].toInt()) {
case ConnectionSettingsEngine::Ipv6PrivacyDefault:
connIpv6Setting->setPrivacy(NetworkManager::Ipv6Setting::Unknown);
break;
case ConnectionSettingsEngine::Ipv6PrivacyDisabled:
connIpv6Setting->setPrivacy(NetworkManager::Ipv6Setting::Disabled);
break;
case ConnectionSettingsEngine::Ipv6PrivacyEnabledPublicAddress:
connIpv6Setting->setPrivacy(NetworkManager::Ipv6Setting::PreferPublic);
break;
case ConnectionSettingsEngine::Ipv6PrivacyEnabledTempAddress:
connIpv6Setting->setPrivacy(NetworkManager::Ipv6Setting::PreferTemporary);
break;
}
}
if (settings["ipv6AddressList"].isValid()) {
QList<NetworkManager::IpAddress> ipv6AddrList = settings["ipv6AddressList"].value<QList<NetworkManager::IpAddress>>();
if (!ipv6AddrList.isEmpty()) {
connIpv6Setting->setAddresses(ipv6AddrList);
}
}
if (settings["ipv6Required"].isValid()) {
connIpv6Setting->setMayFail(!settings["ipv6Required"].toBool());
}
if (settings["802.1xEnabled"].isValid() && settings["802.1xEnabled"].toBool()) { if (settings["802.1xEnabled"].isValid() && settings["802.1xEnabled"].toBool()) {
QList<NetworkManager::Security8021xSetting::EapMethod> eapMethodsList; QList<NetworkManager::Security8021xSetting::EapMethod> eapMethodsList;
switch (settings["802.1xAuthMode"].toInt()) { switch (settings["802.1xAuthMode"].toInt()) {
@ -698,17 +827,6 @@ void ConnectionSettingsEngine::modifyConnectionSettings(QString connUuidStr, QVa
} }
// TODO: Handle WiFi here // TODO: Handle WiFi here
} }
if (wipeManualIpv4Addresses) {
QVariantMap ipv4SettingsMap = connSettingsMap.value("ipv4");
if (!ipv4SettingsMap.isEmpty()) {
qWarning() << "made it";
ipv4SettingsMap.remove("addresses");
ipv4SettingsMap.remove("address-data");
ipv4SettingsMap.remove("gateway");
connSettingsMap.remove("ipv4");
connSettingsMap.insert("ipv4", ipv4SettingsMap);
}
}
qWarning() << connSettingsMap; qWarning() << connSettingsMap;
// TODO: Do something to surpress app exit here // TODO: Do something to surpress app exit here
QDBusPendingReply<> reply = conn->update(connSettingsMap); QDBusPendingReply<> reply = conn->update(connSettingsMap);

@ -39,6 +39,23 @@ public:
Ipv4Disabled Ipv4Disabled
}; };
enum Ipv6Method {
Ipv6Automatic,
Ipv6AutomaticAddressOnly,
Ipv6AutomaticDhcpOnly,
Ipv6LinkLocal,
Ipv6Manual,
Ipv6Ignored,
Ipv6Disabled
};
enum Ipv6Privacy {
Ipv6PrivacyDefault,
Ipv6PrivacyDisabled,
Ipv6PrivacyEnabledPublicAddress,
Ipv6PrivacyEnabledTempAddress
};
enum LinkSpeed { enum LinkSpeed {
SpeedUnknown, SpeedUnknown,
Speed10Mbps, Speed10Mbps,

@ -14,14 +14,17 @@ EthernetSettings::EthernetSettings(QString connUuidStr, QWidget *parent) :
ethernetSettingsTab = new EthernetSettingsTab(); ethernetSettingsTab = new EthernetSettingsTab();
security802_1xSettingsTab = new Security802_1xTab(); security802_1xSettingsTab = new Security802_1xTab();
ipv4SettingsTab = new Ipv4SettingsTab(); ipv4SettingsTab = new Ipv4SettingsTab();
ipv6SettingsTab = new Ipv6SettingsTab();
ui->tabWidget->addTab(generalSettingsTab, tr("General")); ui->tabWidget->addTab(generalSettingsTab, tr("General"));
ui->tabWidget->addTab(ethernetSettingsTab, tr("Ethernet")); ui->tabWidget->addTab(ethernetSettingsTab, tr("Ethernet"));
ui->tabWidget->addTab(security802_1xSettingsTab, tr("802.1x Security")); ui->tabWidget->addTab(security802_1xSettingsTab, tr("802.1x Security"));
ui->tabWidget->addTab(ipv4SettingsTab, tr("IPv4")); ui->tabWidget->addTab(ipv4SettingsTab, tr("IPv4"));
ui->tabWidget->addTab(ipv6SettingsTab, tr("IPv6"));
generalSettingsTab->loadSettings(connSettings); generalSettingsTab->loadSettings(connSettings);
ethernetSettingsTab->loadSettings(connSettings); ethernetSettingsTab->loadSettings(connSettings);
security802_1xSettingsTab->loadSettings(connSettings); security802_1xSettingsTab->loadSettings(connSettings);
ipv4SettingsTab->loadSettings(connSettings); ipv4SettingsTab->loadSettings(connSettings);
ipv6SettingsTab->loadSettings(connSettings);
connect(ui->cancelButton, &QPushButton::clicked, this, &EthernetSettings::onCancelButtonClicked); connect(ui->cancelButton, &QPushButton::clicked, this, &EthernetSettings::onCancelButtonClicked);
connect(ui->saveButton, &QPushButton::clicked, this, &EthernetSettings::onSaveButtonClicked); connect(ui->saveButton, &QPushButton::clicked, this, &EthernetSettings::onSaveButtonClicked);
} }
@ -33,6 +36,7 @@ EthernetSettings::~EthernetSettings()
delete ethernetSettingsTab; delete ethernetSettingsTab;
delete security802_1xSettingsTab; delete security802_1xSettingsTab;
delete ipv4SettingsTab; delete ipv4SettingsTab;
delete ipv6SettingsTab;
} }
void EthernetSettings::onCancelButtonClicked() void EthernetSettings::onCancelButtonClicked()
@ -46,6 +50,7 @@ void EthernetSettings::onSaveButtonClicked()
settings.insert(ethernetSettingsTab->readSettings()); settings.insert(ethernetSettingsTab->readSettings());
settings.insert(security802_1xSettingsTab->readSettings()); settings.insert(security802_1xSettingsTab->readSettings());
settings.insert(ipv4SettingsTab->readSettings()); settings.insert(ipv4SettingsTab->readSettings());
settings.insert(ipv6SettingsTab->readSettings());
settings.insert("connName", ui->connectionNameLineEdit->text()); settings.insert("connName", ui->connectionNameLineEdit->text());
ConnectionSettingsEngine::modifyConnectionSettings(targetConnUuidStr, settings); ConnectionSettingsEngine::modifyConnectionSettings(targetConnUuidStr, settings);
this->done(0); this->done(0);

@ -6,6 +6,7 @@
#include "ethernetsettingstab.h" #include "ethernetsettingstab.h"
#include "security802_1xtab.h" #include "security802_1xtab.h"
#include "ipv4settingstab.h" #include "ipv4settingstab.h"
#include "ipv6settingstab.h"
#include <QDialog> #include <QDialog>
@ -33,6 +34,7 @@ private:
EthernetSettingsTab *ethernetSettingsTab; EthernetSettingsTab *ethernetSettingsTab;
Security802_1xTab *security802_1xSettingsTab; Security802_1xTab *security802_1xSettingsTab;
Ipv4SettingsTab *ipv4SettingsTab; Ipv4SettingsTab *ipv4SettingsTab;
Ipv6SettingsTab *ipv6SettingsTab;
}; };
#endif // ETHERNETSETTINGS_H #endif // ETHERNETSETTINGS_H

@ -22,11 +22,11 @@ public:
void loadSettings(QVariantMap settings); void loadSettings(QVariantMap settings);
private slots: private slots:
void onMethodComboBoxCurrentIndexChanged(int index);
void onEditDnsServersButtonClicked(); void onEditDnsServersButtonClicked();
void onEditSearchDomainsButtonClicked(); void onEditSearchDomainsButtonClicked();
void onManualIpv4ConfigurationAddButtonClicked(); void onManualIpv4ConfigurationAddButtonClicked();
void onManualIpv4ConfigurationRemoveButtonClicked(); void onManualIpv4ConfigurationRemoveButtonClicked();
void onMethodComboBoxCurrentIndexChanged(int index);
private: private:
Ui::Ipv4SettingsTab *ui; Ui::Ipv4SettingsTab *ui;

@ -0,0 +1,181 @@
#include "ipv6settingstab.h"
#include "ui_ipv6settingstab.h"
Ipv6SettingsTab::Ipv6SettingsTab(QWidget *parent) :
QWidget(parent),
ui(new Ui::Ipv6SettingsTab)
{
ui->setupUi(this);
ui->methodComboBox->addItems(QStringList() << tr("Automatic") << tr("Automatic (only addresses)") << tr("Automatic (only DHCP)") << tr("Link-Local") << tr("Manual") << tr("Ignored") << tr("Disabled"));
ui->privacyComboBox->addItems(QStringList() << tr("Default") << tr("Disabled") << tr("Enabled (prefer public address)") << tr("Enabled (prefer temporary address)"));
connect(ui->methodComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &Ipv6SettingsTab::onMethodComboBoxCurrentIndexChanged);
connect(ui->editDnsServersButton, &QPushButton::clicked, this, &Ipv6SettingsTab::onEditDnsServersButtonClicked);
connect(ui->editSearchDomainsButton, &QPushButton::clicked, this, &Ipv6SettingsTab::onEditSearchDomainsButtonClicked);
connect(ui->manualIpv6ConfigurationAddButton, &QPushButton::clicked, this, &Ipv6SettingsTab::onManualIpv6ConfigurationAddButtonClicked);
connect(ui->manualIpv6ConfigurationRemoveButton, &QPushButton::clicked, this, &Ipv6SettingsTab::onManualIpv6ConfigurationRemoveButtonClicked);
}
Ipv6SettingsTab::~Ipv6SettingsTab()
{
delete ui;
}
QVariantMap Ipv6SettingsTab::readSettings()
{
QVariantMap output;
switch (ui->methodComboBox->currentIndex()) {
case 0: // Automatic
output.insert("ipv6Method", ConnectionSettingsEngine::Ipv6Automatic);
break;
case 1: // Automatic (only addresses)
output.insert("ipv6Method", ConnectionSettingsEngine::Ipv6AutomaticAddressOnly);
break;
case 2: // Automatic (only DHCP)
output.insert("ipv6Method", ConnectionSettingsEngine::Ipv6AutomaticDhcpOnly);
break;
case 3: // Link-Local
output.insert("ipv6Method", ConnectionSettingsEngine::Ipv6LinkLocal);
break;
case 4: // Manual
output.insert("ipv6Method", ConnectionSettingsEngine::Ipv6Manual);
break;
case 5: // Ignored
output.insert("ipv6Method", ConnectionSettingsEngine::Ipv6Ignored);
break;
case 6: // Disabled
output.insert("ipv6Method", ConnectionSettingsEngine::Ipv6Disabled);
break;
}
output.insert("ipv6DnsServers", ui->dnsServersLineEdit->text());
output.insert("ipv6SearchDomains", ui->searchDomainsLineEdit->text());
switch (ui->privacyComboBox->currentIndex()) {
case 0: // Default
output.insert("ipv6Privacy", ConnectionSettingsEngine::Ipv6PrivacyDefault);
break;
case 1: // Disabled
output.insert("ipv6Privacy", ConnectionSettingsEngine::Ipv6PrivacyDisabled);
break;
case 2: // Enabled (prefer public address)
output.insert("ipv6Privacy", ConnectionSettingsEngine::Ipv6PrivacyEnabledPublicAddress);
break;
case 3: // Enabled (prefer temporary address)
output.insert("ipv6Privacy", ConnectionSettingsEngine::Ipv6PrivacyEnabledTempAddress);
break;
}
QList<NetworkManager::IpAddress> ipAddrList;
if (ui->methodComboBox->currentIndex() == 4) { // Manual
for (int i = 0, rowCount = ui->manualIpv6ConfigurationTable->rowCount(); i < rowCount; i++) {
NetworkManager::IpAddress ipAddr;
ipAddr.setIp(QHostAddress(ui->manualIpv6ConfigurationTable->item(i, 0)->text()));
ipAddr.setPrefixLength(ui->manualIpv6ConfigurationTable->item(i, 1)->text().toInt());
ipAddr.setGateway(QHostAddress(ui->manualIpv6ConfigurationTable->item(i, 2)->text()));
ipAddrList.append(ipAddr);
}
}
output.insert("ipv6AddressList", QVariant::fromValue(ipAddrList));
output.insert("ipv6Required", ui->ipv6RequiredCheckBox->isChecked());
return output;
}
void Ipv6SettingsTab::loadSettings(QVariantMap settings)
{
if (settings["ipv6Method"].isValid()) {
switch (settings["ipv6Method"].toInt()) {
case ConnectionSettingsEngine::Ipv6Automatic:
ui->methodComboBox->setCurrentIndex(0);
break;
case ConnectionSettingsEngine::Ipv6AutomaticAddressOnly:
ui->methodComboBox->setCurrentIndex(1);
break;
case ConnectionSettingsEngine::Ipv6AutomaticDhcpOnly:
ui->methodComboBox->setCurrentIndex(2);
break;
case ConnectionSettingsEngine::Ipv6LinkLocal:
ui->methodComboBox->setCurrentIndex(3);
break;
case ConnectionSettingsEngine::Ipv6Manual:
ui->methodComboBox->setCurrentIndex(4);
break;
case ConnectionSettingsEngine::Ipv6Ignored:
ui->methodComboBox->setCurrentIndex(5);
break;
case ConnectionSettingsEngine::Ipv6Disabled:
ui->methodComboBox->setCurrentIndex(6);
break;
}
}
if (settings["ipv6DnsServers"].isValid()) {
ui->dnsServersLineEdit->setText(settings["ipv6DnsServers"].toString());
}
if (settings["ipv6SearchDomains"].isValid()) {
ui->searchDomainsLineEdit->setText(settings["ipv6SearchDomais"].toString());
}
if (settings["ipv6Privacy"].isValid()) {
switch (settings["ipv6Privacy"].toInt()) {
case ConnectionSettingsEngine::Ipv6PrivacyDefault:
ui->privacyComboBox->setCurrentIndex(0);
break;
case ConnectionSettingsEngine::Ipv6PrivacyDisabled:
ui->privacyComboBox->setCurrentIndex(1);
break;
case ConnectionSettingsEngine::Ipv6PrivacyEnabledPublicAddress:
ui->privacyComboBox->setCurrentIndex(2);
break;
case ConnectionSettingsEngine::Ipv6PrivacyEnabledTempAddress:
ui->privacyComboBox->setCurrentIndex(3);
break;
}
}
if (settings["ipv6AddressList"].isValid()) {
QList<NetworkManager::IpAddress> ipAddrList = settings["ipv6AddressList"].value<QList<NetworkManager::IpAddress>>();
for (int i = 0; i < ipAddrList.length(); i++) {
int newRow = ui->manualIpv6ConfigurationTable->rowCount();
ui->manualIpv6ConfigurationTable->insertRow(newRow);
ui->manualIpv6ConfigurationTable->setItem(newRow, 0, new QTableWidgetItem(ipAddrList[i].ip().toString()));
ui->manualIpv6ConfigurationTable->setItem(newRow, 1, new QTableWidgetItem(QString(ipAddrList[i].prefixLength())));
ui->manualIpv6ConfigurationTable->setItem(newRow, 2, new QTableWidgetItem(ipAddrList[i].gateway().toString()));
}
}
if (settings["ipv6Required"].isValid()) {
ui->ipv6RequiredCheckBox->setChecked(settings["ipv6Required"].toBool());
}
}
void Ipv6SettingsTab::onMethodComboBoxCurrentIndexChanged(int index)
{
if (index == 4) { // manual
ui->manualIpv6ConfigurationTable->setEnabled(true);
} else {
ui->manualIpv6ConfigurationTable->setEnabled(false);
}
}
void Ipv6SettingsTab::onEditDnsServersButtonClicked()
{
ListEditorDialog led(this, ui->dnsServersLineEdit->text(), ',');
led.exec();
ui->dnsServersLineEdit->setText(led.list());
}
void Ipv6SettingsTab::onEditSearchDomainsButtonClicked()
{
ListEditorDialog led(this, ui->searchDomainsLineEdit->text(), ',');
led.exec();
ui->searchDomainsLineEdit->setText(led.list());
}
void Ipv6SettingsTab::onManualIpv6ConfigurationAddButtonClicked()
{
int newRow = ui->manualIpv6ConfigurationTable->rowCount();
ui->manualIpv6ConfigurationTable->insertRow(newRow);
}
void Ipv6SettingsTab::onManualIpv6ConfigurationRemoveButtonClicked()
{
ui->manualIpv6ConfigurationTable->removeRow(ui->manualIpv6ConfigurationTable->currentRow());
}

@ -0,0 +1,35 @@
#ifndef IPV6SETTINGSTAB_H
#define IPV6SETTINGSTAB_H
#include "qvarianthelper.h"
#include "connectionsettingsengine.h"
#include "listeditordialog.h"
#include <QWidget>
namespace Ui {
class Ipv6SettingsTab;
}
class Ipv6SettingsTab : public QWidget
{
Q_OBJECT
public:
explicit Ipv6SettingsTab(QWidget *parent = nullptr);
~Ipv6SettingsTab();
QVariantMap readSettings();
void loadSettings(QVariantMap settings);
private slots:
void onMethodComboBoxCurrentIndexChanged(int index);
void onEditDnsServersButtonClicked();
void onEditSearchDomainsButtonClicked();
void onManualIpv6ConfigurationAddButtonClicked();
void onManualIpv6ConfigurationRemoveButtonClicked();
private:
Ui::Ipv6SettingsTab *ui;
};
#endif // IPV6SETTINGSTAB_H

@ -0,0 +1,194 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Ipv6SettingsTab</class>
<widget class="QWidget" name="Ipv6SettingsTab">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>745</width>
<height>486</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="3" column="1">
<widget class="QComboBox" name="privacyComboBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_4">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Privacy:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="5" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QTableWidget" name="manualIpv6ConfigurationTable">
<attribute name="horizontalHeaderDefaultSectionSize">
<number>150</number>
</attribute>
<column>
<property name="text">
<string>Address</string>
</property>
</column>
<column>
<property name="text">
<string>Prefix</string>
</property>
</column>
<column>
<property name="text">
<string>Gateway</string>
</property>
</column>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QPushButton" name="manualIpv6ConfigurationAddButton">
<property name="text">
<string>Add</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="manualIpv6ConfigurationRemoveButton">
<property name="text">
<string>Remove</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Search Domains:</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Method:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>DNS Servers:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="methodComboBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="6" column="0" colspan="2">
<widget class="QCheckBox" name="ipv6RequiredCheckBox">
<property name="text">
<string>IPv6 is required for this connection</string>
</property>
</widget>
</item>
<item row="1" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLineEdit" name="dnsServersLineEdit"/>
</item>
<item>
<widget class="QPushButton" name="editDnsServersButton">
<property name="text">
<string>Edit...</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLineEdit" name="searchDomainsLineEdit"/>
</item>
<item>
<widget class="QPushButton" name="editSearchDomainsButton">
<property name="text">
<string>Edit...</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
Loading…
Cancel
Save