parent
881256f232
commit
04c53a4e03
@ -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…
Reference in new issue