parent
dfdd2737ff
commit
549119459a
@ -0,0 +1,109 @@
|
||||
#include "ipv4settingstab.h"
|
||||
#include "ui_ipv4settingstab.h"
|
||||
|
||||
Ipv4SettingsTab::Ipv4SettingsTab(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::Ipv4SettingsTab)
|
||||
{
|
||||
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"));
|
||||
}
|
||||
|
||||
Ipv4SettingsTab::~Ipv4SettingsTab()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
QVariantMap Ipv4SettingsTab::readSettings()
|
||||
{
|
||||
QVariantMap output;
|
||||
switch (ui->methodComboBox->currentIndex()) {
|
||||
case 0: // Automatic
|
||||
output.insert("ipv4Method", ConnectionSettingsEngine::Ipv4Automatic);
|
||||
break;
|
||||
case 1: // Automatic (address-only)
|
||||
output.insert("ipv4Method", ConnectionSettingsEngine::Ipv4AutomaticAddressOnly);
|
||||
break;
|
||||
case 2: // Link-local
|
||||
output.insert("ipv4Method", ConnectionSettingsEngine::Ipv4LinkLocal);
|
||||
break;
|
||||
case 3: // Manual
|
||||
output.insert("ipv4Method", ConnectionSettingsEngine::Ipv4Manual);
|
||||
break;
|
||||
case 4: // Shared
|
||||
output.insert("ipv4Method", ConnectionSettingsEngine::Ipv4Shared);
|
||||
break;
|
||||
case 5: // Disabled
|
||||
output.insert("ipv4Method", ConnectionSettingsEngine::Ipv4Disabled);
|
||||
break;
|
||||
}
|
||||
output.insert("ipv4DnsServers", ui->dnsServersLineEdit->text());
|
||||
output.insert("ipv4SearchDomains", ui->searchDomainsLineEdit->text());
|
||||
output.insert("ipv4DhcpClientId", ui->dhcpClientIdLineEdit->text());
|
||||
QList<NetworkManager::IpAddress> ipAddrList;
|
||||
if (ui->methodComboBox->currentIndex() == 3) { // Manual
|
||||
for (int i = 0, rowCount = ui->manualIpv4ConfigurationTable->rowCount(); i < rowCount; i++) {
|
||||
NetworkManager::IpAddress ipAddr;
|
||||
ipAddr.setIp(QHostAddress(ui->manualIpv4ConfigurationTable->item(i, 0)->text()));
|
||||
ipAddr.setNetmask(QHostAddress(ui->manualIpv4ConfigurationTable->item(i, 1)->text()));
|
||||
ipAddr.setGateway(QHostAddress(ui->manualIpv4ConfigurationTable->item(i, 2)->text()));
|
||||
ipAddrList.append(ipAddr);
|
||||
}
|
||||
}
|
||||
output.insert("ipv4AddressList", QVariant::fromValue(ipAddrList));
|
||||
output.insert("ipv4Required", ui->ipv4RequiredCheckBox->isChecked());
|
||||
return output;
|
||||
}
|
||||
|
||||
void Ipv4SettingsTab::loadSettings(QVariantMap settings)
|
||||
{
|
||||
if (settings["ipv4Method"].isValid()) {
|
||||
switch (settings["ipv4Method"].toInt()) {
|
||||
case ConnectionSettingsEngine::Ipv4Automatic:
|
||||
ui->methodComboBox->setCurrentIndex(0);
|
||||
break;
|
||||
case ConnectionSettingsEngine::Ipv4AutomaticAddressOnly:
|
||||
ui->methodComboBox->setCurrentIndex(1);
|
||||
break;
|
||||
case ConnectionSettingsEngine::Ipv4LinkLocal:
|
||||
ui->methodComboBox->setCurrentIndex(2);
|
||||
break;
|
||||
case ConnectionSettingsEngine::Ipv4Manual:
|
||||
ui->methodComboBox->setCurrentIndex(3);
|
||||
break;
|
||||
case ConnectionSettingsEngine::Ipv4Shared:
|
||||
ui->methodComboBox->setCurrentIndex(4);
|
||||
break;
|
||||
case ConnectionSettingsEngine::Ipv4Disabled:
|
||||
ui->methodComboBox->setCurrentIndex(5);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (settings["ipv4DnsServers"].isValid()) {
|
||||
ui->dnsServersLineEdit->setText(settings["ipv4DnsServers"].toString());
|
||||
}
|
||||
|
||||
if (settings["ipv4SearchDomains"].isValid()) {
|
||||
ui->searchDomainsLineEdit->setText(settings["ipv4SearchDomains"].toString());
|
||||
}
|
||||
|
||||
if (settings["ipv4DhcpClientId"].isValid()) {
|
||||
ui->dhcpClientIdLineEdit->setText(settings["ipv4DhcpClientId"].toString());
|
||||
}
|
||||
|
||||
if (settings["ipv4AddressList"].isValid()) {
|
||||
QList<NetworkManager::IpAddress> ipAddrList = settings["ipv4AddressList"].value<QList<NetworkManager::IpAddress>>();
|
||||
for (int i = 0; i < ipAddrList.length(); i++) {
|
||||
int newRow = ui->manualIpv4ConfigurationTable->rowCount();
|
||||
ui->manualIpv4ConfigurationTable->insertRow(newRow);
|
||||
ui->manualIpv4ConfigurationTable->setItem(newRow, 0, new QTableWidgetItem(ipAddrList[i].ip().toString()));
|
||||
ui->manualIpv4ConfigurationTable->setItem(newRow, 1, new QTableWidgetItem(ipAddrList[i].netmask().toString()));
|
||||
ui->manualIpv4ConfigurationTable->setItem(newRow, 2, new QTableWidgetItem(ipAddrList[i].gateway().toString()));
|
||||
}
|
||||
}
|
||||
|
||||
if (settings["ipv4Required"].isValid()) {
|
||||
ui->ipv4RequiredCheckBox->setChecked(settings["ipv4Required"].toBool());
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
#ifndef IPV4SETTINGSTAB_H
|
||||
#define IPV4SETTINGSTAB_H
|
||||
|
||||
#include "qvarianthelper.h"
|
||||
#include "connectionsettingsengine.h"
|
||||
#include <QWidget>
|
||||
|
||||
namespace Ui {
|
||||
class Ipv4SettingsTab;
|
||||
}
|
||||
|
||||
class Ipv4SettingsTab : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit Ipv4SettingsTab(QWidget *parent = nullptr);
|
||||
~Ipv4SettingsTab();
|
||||
|
||||
QVariantMap readSettings();
|
||||
void loadSettings(QVariantMap settings);
|
||||
|
||||
private:
|
||||
Ui::Ipv4SettingsTab *ui;
|
||||
};
|
||||
|
||||
#endif // IPV4SETTINGSTAB_H
|
@ -0,0 +1,171 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Ipv4SettingsTab</class>
|
||||
<widget class="QWidget" name="Ipv4SettingsTab">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>540</width>
|
||||
<height>479</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="1" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="dnsServersLineEdit"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="editDnsServersButton">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Edit...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<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="dnsServersLabel">
|
||||
<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"/>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLineEdit" name="dhcpClientIdLineEdit"/>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>DHCP client ID:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0" colspan="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QTableWidget" name="manualIpv4ConfigurationTable">
|
||||
<attribute name="horizontalHeaderDefaultSectionSize">
|
||||
<number>125</number>
|
||||
</attribute>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Address</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Netmask</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Gateway</string>
|
||||
</property>
|
||||
</column>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QPushButton" name="manualIpv4ConfigurationAddButton">
|
||||
<property name="text">
|
||||
<string>Add</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="manualIpv4ConfigurationRemoveButton">
|
||||
<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="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="searchDomainsLineEdit"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="editSearchDomainsButton">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Edit...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Search domains:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="ipv4RequiredCheckBox">
|
||||
<property name="text">
|
||||
<string>IPv4 is required for this connection</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
@ -0,0 +1,9 @@
|
||||
#ifndef QVARIANTHELPER_H
|
||||
#define QVARIANTHELPER_H
|
||||
|
||||
#include <NetworkManagerQt/Ipv4Setting>
|
||||
#include <QList>
|
||||
|
||||
Q_DECLARE_METATYPE(QList<NetworkManager::IpAddress>)
|
||||
|
||||
#endif // QVARIANTHELPER_H
|
Loading…
Reference in new issue