调整弹窗界面DNS为多DNS

This commit is contained in:
zhangyuanyuan1 2023-06-05 11:12:36 +08:00
parent db27cca27c
commit 83b67d43d7
18 changed files with 477 additions and 172 deletions

View File

@ -107,6 +107,7 @@ public:
QString strIPV4FirDns;
QString strIPV4SecDns;
QString strIPV4GateWay;
QList<QHostAddress> ipv4DnsList;
KyIpConfigType ipv6ConfigType = CONFIG_IP_DHCP;
QString strIPV6Address;
@ -114,6 +115,7 @@ public:
QString strIPV6FirDns;
QString strIPV6SecDns;
QString strIPV6GateWay;
QList<QHostAddress> ipv6DnsList;
KyEapMethodType enterpriseType;
KyEapMethodTlsInfo tlsInfo;

View File

@ -38,16 +38,16 @@ void CreatNetPage::initUI()
ipv4addressEdit = new LineEdit(this);
netMaskEdit = new LineEdit(this);
gateWayEdit = new LineEdit(this);
firstDnsEdit = new LineEdit(this);
secondDnsEdit = new LineEdit(this);
m_connNameLabel = new QLabel(this);
m_configLabel = new QLabel(this);
m_addressLabel = new QLabel(this);
m_maskLabel = new QLabel(this);
m_gateWayLabel = new QLabel(this);
m_dnsLabel = new QLabel(this);
m_secDnsLabel = new QLabel(this);
// IP的正则格式限制
QRegExp rx("\\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\b");
m_dnsWidget = new MultipleDnsWidget(rx, this);
QLabel *nameEmptyLabel = new QLabel(this);
QLabel *configEmptyLabel = new QLabel(this);
@ -89,8 +89,6 @@ void CreatNetPage::initUI()
m_addressLabel->setText(tr("Address"));
m_maskLabel->setText(tr("Netmask"));
m_gateWayLabel->setText(tr("Default Gateway"));
m_dnsLabel->setText(tr("Prefs DNS"));
m_secDnsLabel->setText(tr("Alternative DNS"));
m_detailLayout = new QFormLayout(this);
m_detailLayout->setVerticalSpacing(0);
@ -103,22 +101,15 @@ void CreatNetPage::initUI()
m_detailLayout->addRow(m_maskLabel, maskWidget);
m_detailLayout->addRow(m_gateWayLabel,gateWayEdit);
m_detailLayout->addRow(gateWayEmptyLabel);
m_detailLayout->addRow(m_dnsLabel,firstDnsEdit);
m_detailLayout->addRow(firstDnsEmptyLabel);
m_detailLayout->addRow(m_secDnsLabel,secondDnsEdit);
m_detailLayout->addRow(m_dnsWidget);
ipv4ConfigCombox->addItem(tr("Auto(DHCP)"), AUTO_CONFIG); //"自动(DHCP)"
ipv4ConfigCombox->addItem(tr("Manual"), MANUAL_CONFIG); //"手动"
// IP的正则格式限制
QRegExp rx("\\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\b");
ipv4addressEdit->setValidator(new QRegExpValidator(rx, this));
gateWayEdit->setValidator(new QRegExpValidator(rx, this));
netMaskEdit->setValidator(new QRegExpValidator(rx, this));
firstDnsEdit->setValidator(new QRegExpValidator(rx, this));
secondDnsEdit->setValidator(new QRegExpValidator(rx, this));
}
void CreatNetPage::initComponent() {
@ -133,9 +124,6 @@ void CreatNetPage::initComponent() {
connect(ipv4ConfigCombox, SIGNAL(currentIndexChanged(int)), this, SLOT(setEnableOfSaveBtn()));
connect(netMaskEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn()));
connect(gateWayEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn()));
connect(firstDnsEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn()));
connect(secondDnsEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn()));
connect(ipv4addressEdit, SIGNAL(textChanged(QString)), this, SLOT(onAddressTextChanged()));
connect(netMaskEdit, SIGNAL(textChanged(QString)), this, SLOT(onNetMaskTextChanged()));
}
@ -165,20 +153,6 @@ bool CreatNetPage::checkConnectBtnIsEnabled()
// return false;
// }
if (firstDnsEdit->text().isEmpty() && !secondDnsEdit->text().isEmpty()) {
qDebug() << "create ipv4 dns sort invalid";
return false;
}
if (!getTextEditState(firstDnsEdit->text())) {
qDebug() << "create ipv4 first dns invalid";
return false;
}
if (!getTextEditState(secondDnsEdit->text())) {
qDebug() << "create ipv4 second dns invalid";
return false;
}
}
return true;
}
@ -215,15 +189,12 @@ void CreatNetPage::setLineEnabled(bool check) {
ipv4addressEdit->setEnabled(check);
netMaskEdit->setEnabled(check);
gateWayEdit->setEnabled(check);
firstDnsEdit->setEnabled(check);
secondDnsEdit->setEnabled(check);
m_dnsWidget->setEditEnabled(check);
if (!check) {
ipv4addressEdit->clear();
netMaskEdit->clear();
gateWayEdit->clear();
firstDnsEdit->clear();
secondDnsEdit->clear();
ipv4addressEdit->setPlaceholderText(" ");
netMaskEdit->setPlaceholderText(" ");
@ -261,13 +232,23 @@ void CreatNetPage::constructIpv4Info(KyConnectSetting &setting)
<< " gateWay " << gateWay;
QStringList dnsList;
dnsList.empty();
dnsList.clear();
#if 0
if (!firstDnsEdit->text().isEmpty()) {
dnsList << firstDnsEdit->text();
if (!secondDnsEdit->text().isEmpty()) {
dnsList << secondDnsEdit->text();
}
}
#endif
QList<QHostAddress> ipv4dnsList;
ipv4dnsList.clear();
ipv4dnsList = m_dnsWidget->getDns();
for (QHostAddress str: ipv4dnsList) {
dnsList << str.toString();
}
if (ipv4ConfigCombox->currentData() == AUTO_CONFIG) {
setting.setIpConfigType(IPADDRESS_V4, CONFIG_IP_DHCP);
} else {

View File

@ -32,6 +32,7 @@
#include <QDebug>
#include "coninfo.h"
#include "multiplednswidget.h"
class CreatNetPage : public QFrame
{
@ -46,10 +47,7 @@ private:
LineEdit *ipv4addressEdit;
LineEdit *netMaskEdit;
LineEdit *gateWayEdit;
LineEdit *firstDnsEdit;
LineEdit *secondDnsEdit;
private:
QFormLayout *m_detailLayout;
QVBoxLayout *mvBoxLayout;
QLabel *m_connNameLabel;
@ -57,11 +55,12 @@ private:
QLabel *m_addressLabel;
QLabel *m_maskLabel;
QLabel *m_gateWayLabel;
QLabel *m_dnsLabel;
QLabel *m_secDnsLabel;
QLabel *m_addressHintLabel;
QLabel *m_maskHintLabel;
MultipleDnsWidget *m_dnsWidget = nullptr;
private:
void initUI();
void initComponent();

View File

@ -87,7 +87,7 @@ void DetailPage::setIpv4(const QString &ipv4) {
}
void DetailPage::setIpv4Dns(const QString &ipv4Dns) {
this->m_IPV4Dns->setText(ipv4Dns);
this->m_IPV4Dns->setLabelText(ipv4Dns);
}
void DetailPage::setIpv6(const QString &ipv6) {
@ -246,7 +246,9 @@ void DetailPage::initUI() {
m_ipv4Widget = new DetailWidget(qobject_cast<QWidget *>(m_IPV4), m_listWidget);
m_ipv4Widget->setKey(tr("IPv4:"));
m_IPV4Dns = new QLabel(this);
m_IPV4Dns = new FixLabel(this);
m_IPV4Dns->setFixedWidth(MAX_LABEL_WIDTH);
m_IPV4Dns->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
m_ipv4DnsWidget = new DetailWidget(qobject_cast<QWidget *>(m_IPV4Dns), m_listWidget);
m_ipv4DnsWidget->setKey(tr("IPv4 DNS:"));

View File

@ -91,7 +91,7 @@ public:
QLabel *m_Chan;
QLabel *m_BandWidth;
QLabel *m_IPV4;
QLabel *m_IPV4Dns;
FixLabel *m_IPV4Dns;
FixLabel *m_IPV6;
QLabel *m_Mac;
QLabel *m_autoConnect;

View File

@ -39,15 +39,11 @@ void Ipv4Page::initUI() {
ipv4addressEdit = new LineEdit(this);
netMaskEdit = new LineEdit(this);
gateWayEdit = new LineEdit(this);
firstDnsEdit = new LineEdit(this);
secondDnsEdit = new LineEdit(this);
m_configLabel = new QLabel(this);
m_addressLabel = new QLabel(this);
m_maskLabel = new QLabel(this);
m_gateWayLabel = new QLabel(this);
m_dnsLabel = new QLabel(this);
m_secDnsLabel = new QLabel(this);
m_configEmptyLabel = new QLabel(this);
m_configEmptyLabel->setFixedHeight(LABEL_HEIGHT);
@ -64,16 +60,10 @@ void Ipv4Page::initUI() {
m_gateWayEmptyLabel = new QLabel(this);
m_gateWayEmptyLabel->setFixedHeight(LABEL_HEIGHT);
m_firstDnsEmptyLabel = new QLabel(this);
m_firstDnsEmptyLabel->setFixedHeight(LABEL_HEIGHT);
m_configLabel->setText(tr("IPv4Config"));
m_addressLabel->setText(tr("Address"));
m_maskLabel->setText(tr("Netmask"));
m_gateWayLabel->setText(tr("Default Gateway"));
m_dnsLabel->setText(tr("Prefs DNS"));
m_secDnsLabel->setText(tr("Alternative DNS"));
m_statusLabel = new QLabel(this);
m_statusLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
@ -100,6 +90,10 @@ void Ipv4Page::initUI() {
maskLayout->addWidget(netMaskEdit);
maskLayout->addWidget(m_maskHintLabel);
// IP的正则格式限制
QRegExp rx("\\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\b");
m_dnsWidget = new MultipleDnsWidget(rx, this);
m_detailLayout = new QFormLayout(this);
m_detailLayout->setVerticalSpacing(0);
m_detailLayout->setContentsMargins(LAYOUT_MARGINS);
@ -109,9 +103,7 @@ void Ipv4Page::initUI() {
m_detailLayout->addRow(m_maskLabel,maskWidget);
m_detailLayout->addRow(m_gateWayLabel,gateWayEdit);
m_detailLayout->addRow(m_gateWayEmptyLabel);
m_detailLayout->addRow(m_dnsLabel,firstDnsEdit);
m_detailLayout->addRow(m_firstDnsEmptyLabel);
m_detailLayout->addRow(m_secDnsLabel,secondDnsEdit);
m_detailLayout->addRow(m_dnsWidget);
ipv4ConfigCombox->addItem(tr("Auto(DHCP)")); //"自动(DHCP)"
ipv4ConfigCombox->addItem(tr("Manual")); //"手动"
@ -124,14 +116,9 @@ void Ipv4Page::initUI() {
// netMaskCombox->addItem("255.0.0.0"); //8
// IP的正则格式限制
QRegExp rx("\\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\b");
ipv4addressEdit->setValidator(new QRegExpValidator(rx, this));
gateWayEdit->setValidator(new QRegExpValidator(rx, this));
netMaskEdit->setValidator(new QRegExpValidator(rx, this));
firstDnsEdit->setValidator(new QRegExpValidator(rx, this));
secondDnsEdit->setValidator(new QRegExpValidator(rx, this));
initLoadingIcon();
}
@ -152,8 +139,6 @@ void Ipv4Page::initComponent() {
connect(ipv4addressEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn()));
connect(netMaskEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn()));
connect(gateWayEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn()));
connect(firstDnsEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn()));
connect(secondDnsEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn()));
}
void Ipv4Page::setIpv4Config(KyIpConfigType ipv4Config)
@ -175,14 +160,9 @@ void Ipv4Page::setNetMask(const QString &netMask)
netMaskEdit->setText(netMask);
}
void Ipv4Page::setIpv4FirDns(const QString &ipv4FirDns)
void Ipv4Page::setMulDns(const QList<QHostAddress> &dns)
{
firstDnsEdit->setText(ipv4FirDns);
}
void Ipv4Page::setIpv4SecDns(const QString &ipv4SecDns)
{
secondDnsEdit->setText(ipv4SecDns);
m_dnsWidget->setDnsListText(dns);
}
void Ipv4Page::setGateWay(const QString &gateWay)
@ -213,20 +193,21 @@ bool Ipv4Page::checkIsChanged(const ConInfo info, KyConnectSetting &setting)
isChanged = true;
}
qDebug() << "ipv4 netmask " << getNetMaskText(netMaskEdit->text());
QList<QHostAddress> ipv4dnsList;
ipv4dnsList.clear();
ipv4dnsList = m_dnsWidget->getDns();
if(info.strIPV4Address != ipv4addressEdit->text()
|| info.strIPV4NetMask != /*netMaskEdit->text()*/getNetMaskText(netMaskEdit->text())
|| info.strIPV4GateWay != gateWayEdit->text()
|| info.strIPV4FirDns != firstDnsEdit->text()
|| info.strIPV4SecDns != secondDnsEdit->text()) {
|| info.ipv4DnsList != ipv4dnsList) {
qDebug() << "ipv4 info changed";
QStringList dnsList;
dnsList.empty();
if (!firstDnsEdit->text().isEmpty()) {
dnsList << firstDnsEdit->text();
if (!secondDnsEdit->text().isEmpty()) {
dnsList << secondDnsEdit->text();
}
dnsList.clear();
for (QHostAddress str: ipv4dnsList) {
dnsList << str.toString();
}
QString ipv4address =ipv4addressEdit->text();
@ -262,20 +243,6 @@ bool Ipv4Page::checkConnectBtnIsEnabled()
// return false;
// }
if (firstDnsEdit->text().isEmpty() && !secondDnsEdit->text().isEmpty()) {
qDebug() << "ipv4 dns sort invalid";
return false;
}
if (!getTextEditState(firstDnsEdit->text())) {
qDebug() << "ipv4 first dns invalid";
return false;
}
if (!getTextEditState(secondDnsEdit->text())) {
qDebug() << "ipv4 second dns invalid";
return false;
}
}
return true;
}
@ -325,8 +292,6 @@ void Ipv4Page::setLineEnabled(bool check) {
ipv4addressEdit->clear();
netMaskEdit->clear();
gateWayEdit->clear();
firstDnsEdit->clear();
secondDnsEdit->clear();
ipv4addressEdit->setPlaceholderText(" ");
netMaskEdit->setPlaceholderText(" ");
@ -339,8 +304,7 @@ void Ipv4Page::setLineEnabled(bool check) {
ipv4addressEdit->setEnabled(check);
netMaskEdit->setEnabled(check);
gateWayEdit->setEnabled(check);
firstDnsEdit->setEnabled(check);
secondDnsEdit->setEnabled(check);
m_dnsWidget->setEditEnabled(check);
}
void Ipv4Page::setEnableOfSaveBtn() {

View File

@ -33,6 +33,7 @@
//#include "kylinconnectsetting.h"
#include "coninfo.h"
#include "multiplednswidget.h"
class Ipv4Page : public QFrame
{
@ -42,8 +43,7 @@ public:
void setIpv4Config(KyIpConfigType ipv4Config);
void setIpv4(const QString &ipv4);
void setNetMask(const QString &netMask);
void setIpv4FirDns(const QString &ipv4FirDns);
void setIpv4SecDns(const QString &ipv4SecDns);
void setMulDns(const QList<QHostAddress> &dns);
void setGateWay(const QString &gateWay);
bool checkIsChanged(const ConInfo info, KyConnectSetting &setting);
@ -57,8 +57,6 @@ private:
LineEdit *ipv4addressEdit;
LineEdit *netMaskEdit;
LineEdit *gateWayEdit;
LineEdit *firstDnsEdit;
LineEdit *secondDnsEdit;
QFormLayout *m_detailLayout;
QVBoxLayout *mvBoxLayout;
@ -66,14 +64,13 @@ private:
QLabel *m_addressLabel;
QLabel *m_maskLabel;
QLabel *m_gateWayLabel;
QLabel *m_dnsLabel;
QLabel *m_secDnsLabel;
QLabel *m_configEmptyLabel;
QLabel *m_addressHintLabel;
QLabel *m_maskHintLabel;
QLabel *m_gateWayEmptyLabel;
QLabel *m_firstDnsEmptyLabel;
MultipleDnsWidget *m_dnsWidget = nullptr;
QLabel *m_statusLabel = nullptr;
QList<QIcon> m_loadIcons;

View File

@ -52,14 +52,9 @@ void Ipv6Page::setIpv6Perfix(const int &ipv6Perfix)
lengthEdit->setText(QString::number(ipv6Perfix));
}
void Ipv6Page::setIpv6FirDns(const QString &ipv6FirDns)
void Ipv6Page::setMulDns(const QList<QHostAddress> &dns)
{
firstDnsEdit->setText(ipv6FirDns);
}
void Ipv6Page::setIpv6SecDns(const QString &ipv6SecDns)
{
secondDnsEdit->setText(ipv6SecDns);
m_dnsWidget->setDnsListText(dns);
}
void Ipv6Page::setGateWay(const QString &gateWay)
@ -88,20 +83,20 @@ bool Ipv6Page::checkIsChanged(const ConInfo info, KyConnectSetting &setting)
setting.setIpConfigType(IPADDRESS_V6, CONFIG_IP_MANUAL);
isChanged = true;
}
QList<QHostAddress> ipv6dnsList;
ipv6dnsList.clear();
ipv6dnsList = m_dnsWidget->getDns();
if(info.strIPV6Address != ipv6AddressEdit->text()
|| info.iIPV6Prefix != lengthEdit->text().toInt()
|| info.strIPV6GateWay != gateWayEdit->text()
|| info.strIPV6FirDns != firstDnsEdit->text()
|| info.strIPV6SecDns != secondDnsEdit->text()) {
|| info.ipv6DnsList != ipv6dnsList) {
qDebug() << "ipv6 info changed";
QStringList dnsList;
dnsList.empty();
if (!firstDnsEdit->text().isEmpty()) {
dnsList << firstDnsEdit->text();
if (!secondDnsEdit->text().isEmpty()) {
dnsList << secondDnsEdit->text();
}
dnsList.clear();
for (QHostAddress str: ipv6dnsList) {
dnsList << str.toString();
}
QString ipv6address =ipv6AddressEdit->text();
@ -120,15 +115,11 @@ void Ipv6Page::initUI() {
ipv6AddressEdit = new LineEdit(this);
lengthEdit = new LineEdit(this);
gateWayEdit = new LineEdit(this);
firstDnsEdit = new LineEdit(this);
secondDnsEdit = new LineEdit(this);
m_configLabel = new QLabel(this);
m_addressLabel = new QLabel(this);
m_subnetLabel = new QLabel(this);
m_gateWayLabel = new QLabel(this);
m_dnsLabel = new QLabel(this);
m_secDnsLabel = new QLabel(this);
m_configEmptyLabel = new QLabel(this);
m_configEmptyLabel->setFixedHeight(LABEL_HEIGHT);
@ -145,16 +136,10 @@ void Ipv6Page::initUI() {
m_subnetEmptyLabel = new QLabel(this);
m_subnetEmptyLabel->setFixedHeight(LABEL_HEIGHT);
m_firstDnsEmptyLabel = new QLabel(this);
m_firstDnsEmptyLabel->setFixedHeight(LABEL_HEIGHT);
m_configLabel->setText(tr("IPv6Config"));
m_addressLabel->setText(tr("Address"));
m_subnetLabel->setText(tr("Subnet prefix Length"));
m_gateWayLabel->setText(tr("Default Gateway"));
m_dnsLabel->setText(tr("Prefs DNS"));
m_secDnsLabel->setText(tr("Alternative DNS"));
m_statusLabel = new QLabel(this);
m_statusLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
@ -181,6 +166,9 @@ void Ipv6Page::initUI() {
gateWayLayout->addWidget(gateWayEdit);
gateWayLayout->addWidget(m_gateWayHintLabel);
QRegExp ipv6_rx("^\\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:)))(%.+)?\\s*$");
m_dnsWidget = new MultipleDnsWidget(ipv6_rx, this);
m_detailLayout = new QFormLayout(this);
m_detailLayout->setContentsMargins(0, 0, 0, 0);
m_detailLayout->setVerticalSpacing(0);
@ -190,18 +178,13 @@ void Ipv6Page::initUI() {
m_detailLayout->addRow(m_subnetLabel,lengthEdit);
m_detailLayout->addRow(m_subnetEmptyLabel);
m_detailLayout->addRow(m_gateWayLabel,gateWayWidget);
m_detailLayout->addRow(m_dnsLabel,firstDnsEdit);
m_detailLayout->addRow(m_firstDnsEmptyLabel);
m_detailLayout->addRow(m_secDnsLabel,secondDnsEdit);
m_detailLayout->addRow(m_dnsWidget);
ipv6ConfigCombox->addItem(tr("Auto(DHCP)")); //"自动(DHCP)"
ipv6ConfigCombox->addItem(tr("Manual")); //"手动"
QRegExp ipv6_rx("^\\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:)))(%.+)?\\s*$");
ipv6AddressEdit->setValidator(new QRegExpValidator(ipv6_rx, this));
gateWayEdit->setValidator(new QRegExpValidator(ipv6_rx, this));
firstDnsEdit->setValidator(new QRegExpValidator(ipv6_rx, this));
secondDnsEdit->setValidator(new QRegExpValidator(ipv6_rx, this));
QRegExp prefix_rx("\\b(?:(?:12[0-8]|1[0-1][0-9]|^[1-9][0-9]?$)\\.){3}(?:12[0-8]|1[0-1][0-9]|^[1-9][0-9]?$)\\b");
lengthEdit->setValidator(new QRegExpValidator(prefix_rx,this));
@ -225,8 +208,6 @@ void Ipv6Page::initComponent() {
connect(ipv6AddressEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn()));
connect(lengthEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn()));
connect(gateWayEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn()));
connect(firstDnsEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn()));
connect(secondDnsEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn()));
}
void Ipv6Page::configChanged(int index) {
@ -244,8 +225,6 @@ void Ipv6Page::setControlEnabled(bool check)
ipv6AddressEdit->clear();
lengthEdit->clear();
gateWayEdit->clear();
firstDnsEdit->clear();
secondDnsEdit->clear();
ipv6AddressEdit->setPlaceholderText(" ");
lengthEdit->setPlaceholderText(" ");
@ -258,8 +237,7 @@ void Ipv6Page::setControlEnabled(bool check)
ipv6AddressEdit->setEnabled(check);
lengthEdit->setEnabled(check);
gateWayEdit->setEnabled(check);
firstDnsEdit->setEnabled(check);
secondDnsEdit->setEnabled(check);
m_dnsWidget->setEditEnabled(check);
}
void Ipv6Page::setEnableOfSaveBtn()
@ -316,21 +294,6 @@ bool Ipv6Page::checkConnectBtnIsEnabled()
// qDebug() << "ipv6 gateway empty or invalid";
// return false;
// }
if (firstDnsEdit->text().isEmpty() && !secondDnsEdit->text().isEmpty()) {
qDebug() << "ipv6 dns sort invalid";
return false;
}
if (!getIpv6EditState(firstDnsEdit->text())) {
qDebug() << "ipv6 first dns invalid";
return false;
}
if (!getIpv6EditState(secondDnsEdit->text())) {
qDebug() << "ipv6 second dns invalid";
return false;
}
}
return true;
}

View File

@ -33,6 +33,7 @@
//#include "kylinconnectsetting.h"
#include "coninfo.h"
#include "multiplednswidget.h"
class Ipv6Page : public QFrame
{
@ -42,8 +43,7 @@ public:
void setIpv6Config(KyIpConfigType ipv6Config);
void setIpv6(const QString &ipv4);
void setIpv6Perfix(const int &ipv6Perfix);
void setIpv6FirDns(const QString &ipv6FirDns);
void setIpv6SecDns(const QString &ipv6SecDns);
void setMulDns(const QList<QHostAddress> &dns);
void setGateWay(const QString &gateWay);
bool checkIsChanged(const ConInfo info, KyConnectSetting &setting);
@ -54,27 +54,24 @@ public:
void stopLoading();
void showIpv6AddressConflict(bool isConflict);
public:
private:
QComboBox *ipv6ConfigCombox;
LineEdit *ipv6AddressEdit;
LineEdit *lengthEdit;
LineEdit *gateWayEdit;
LineEdit *firstDnsEdit;
LineEdit *secondDnsEdit;
private:
QFormLayout *m_detailLayout;
QLabel *m_configLabel;
QLabel *m_addressLabel;
QLabel *m_subnetLabel;
QLabel *m_gateWayLabel;
QLabel *m_dnsLabel;
QLabel *m_secDnsLabel;
QLabel *m_configEmptyLabel;
QLabel *m_addressHintLabel;
QLabel *m_subnetEmptyLabel;
QLabel *m_gateWayHintLabel;
QLabel *m_firstDnsEmptyLabel;
MultipleDnsWidget *m_dnsWidget = nullptr;
QLabel *m_statusLabel = nullptr;
QList<QIcon> m_loadIcons;
@ -83,6 +80,7 @@ private:
QLabel *m_iconLabel;
QLabel *m_textLabel;
private:
void initUI();
void initComponent();

View File

@ -0,0 +1,194 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2022 Tianjin KYLIN Information Technology Co., Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#include "multiplednswidget.h"
#include <QApplication>
#define DNS_LISTWIDGET_HEIGHT 76 + 60
#define BUTTON_SIZE 36,36
#define ITEM_HEIGHT 36
MultipleDnsWidget::MultipleDnsWidget(const QRegExp &rx, QWidget *parent)
: m_regExp(rx),
QWidget(parent)
{
initUI();
initComponent();
}
void MultipleDnsWidget::initUI()
{
QVBoxLayout *mulDnsVLayout = new QVBoxLayout(this);
mulDnsVLayout->setContentsMargins(0, 0, 0, 0);
m_mulDnsLabel = new QLabel(this);
m_mulDnsLabel->setText(tr("DNS server:")); //DNS服务器
m_dnsListWidget = new QListWidget(this);
m_dnsListWidget->setFixedHeight(DNS_LISTWIDGET_HEIGHT);
m_dnsListWidget->setBackgroundRole(QPalette::Base);
m_dnsListWidget->setFocusPolicy(Qt::FocusPolicy::NoFocus);
m_dnsListWidget->setFrameShape(QFrame::Shape::StyledPanel);
m_dnsListWidget->setEditTriggers(QAbstractItemView::DoubleClicked);
//item可拖拽
m_dnsListWidget->setSelectionMode(QAbstractItemView::SingleSelection);
m_dnsListWidget->setDragEnabled(true);
m_dnsListWidget->viewport()->setAcceptDrops(true);
m_dnsListWidget->setDropIndicatorShown(true);
m_dnsListWidget->setDragDropMode(QAbstractItemView::DragDropMode::InternalMove);
setDnsListWidgetStyle();
m_addDnsBtn = new QPushButton(this);
m_addDnsBtn->setFixedSize(BUTTON_SIZE);
m_addDnsBtn->setProperty("useButtonPalette", true);
m_addDnsBtn->setIcon(QIcon::fromTheme("list-add-symbolic"));
m_removeDnsBtn = new QPushButton(this);
m_removeDnsBtn->setFixedSize(BUTTON_SIZE);
m_removeDnsBtn->setProperty("useButtonPalette", true);
m_removeDnsBtn->setIcon(QIcon::fromTheme("list-remove-symbolic"));
m_removeDnsBtn->setEnabled(false);
QHBoxLayout *btnHLayout = new QHBoxLayout();
btnHLayout->setContentsMargins(0, 0, 0, 0);
btnHLayout->setSpacing(1);
btnHLayout->setAlignment(Qt::AlignLeft);
btnHLayout->addWidget(m_addDnsBtn);
btnHLayout->addWidget(m_removeDnsBtn);
mulDnsVLayout->addWidget(m_mulDnsLabel, Qt::AlignLeft);
mulDnsVLayout->addWidget(m_dnsListWidget);
mulDnsVLayout->addLayout(btnHLayout);
}
void MultipleDnsWidget::initComponent()
{
connect(qApp, &QApplication::paletteChanged, this, &MultipleDnsWidget::setDnsListWidgetStyle);
connect(m_addDnsBtn, &QPushButton::clicked, this, &MultipleDnsWidget::onAddBtnClicked);
connect(m_removeDnsBtn, &QPushButton::clicked, this, &MultipleDnsWidget::onRemoveBtnClicked);
connect(m_dnsListWidget, &QListWidget::itemClicked, this, [=]() {
if (m_dnsListWidget->count() < 1) {
m_removeDnsBtn->setEnabled(false);
} else {
m_removeDnsBtn->setEnabled(true);
}
});
connect(m_dnsListWidget, &QListWidget::itemDoubleClicked, this, [=](QListWidgetItem *item) {
m_dnsListWidget->edit(m_dnsListWidget->currentIndex());
item->setFlags(item->flags() | Qt::ItemIsEditable);
});
}
void MultipleDnsWidget::setEditEnabled(bool state)
{
m_addDnsBtn->setEnabled(state);
if (!state) {
m_dnsListWidget->clear();
}
}
QList<QHostAddress> MultipleDnsWidget::getDns() const
{
QStringList dnsList;
dnsList.clear();
QList<QHostAddress> ipv4dnsList;
ipv4dnsList.clear();
int row = 0;
QString aDns;
while (m_dnsListWidget->count() > row) {
aDns = m_dnsListWidget->item(row)->text();
if (!dnsList.contains(aDns)) {
dnsList << aDns;
ipv4dnsList << QHostAddress(aDns);
}
row ++;
}
return ipv4dnsList;
}
void MultipleDnsWidget::setDnsListText(const QList<QHostAddress> &dns)
{
m_dnsListWidget->clear();
for (QHostAddress str: dns) {
QListWidgetItem *dnsListWidgetItem = new QListWidgetItem(m_dnsListWidget);
dnsListWidgetItem->setSizeHint(QSize(0,ITEM_HEIGHT));
dnsListWidgetItem->setText(str.toString());
}
}
void MultipleDnsWidget::AddOneDnsItem(QListWidget *listWidget)
{
QListWidgetItem *dnsListWidgetItem = new QListWidgetItem(listWidget);
dnsListWidgetItem->setSizeHint(QSize(0,ITEM_HEIGHT));
dnsListWidgetItem->setFlags(dnsListWidgetItem->flags() | Qt::ItemIsEditable);
listWidget->addItem(dnsListWidgetItem);
listWidget->setCurrentItem(dnsListWidgetItem);
ListItemEdit *dnsListItemEdit = new ListItemEdit(m_regExp);
listWidget->setItemDelegateForRow(listWidget->currentIndex().row() , dnsListItemEdit);
listWidget->editItem(dnsListWidgetItem);
}
void MultipleDnsWidget::RemoveOneDnsItem(QListWidgetItem *aItem, QListWidget *listWidget)
{
if (aItem) {
listWidget->removeItemWidget(aItem);
delete aItem;
}
}
void MultipleDnsWidget::setDnsListWidgetStyle()
{
QPalette mpal(m_dnsListWidget->palette());
mpal.setColor(QPalette::Base, qApp->palette().base().color());
mpal.setColor(QPalette::AlternateBase, qApp->palette().alternateBase().color());
m_dnsListWidget->setAlternatingRowColors(true);
m_dnsListWidget->setPalette(mpal);
}
void MultipleDnsWidget::onAddBtnClicked()
{
AddOneDnsItem(m_dnsListWidget);
//避免重复添加空白项
int row = m_dnsListWidget->count() - 1;
while (row >= 0) {
if (!m_dnsListWidget->item(row)->isSelected()
&& m_dnsListWidget->item(row)->text().isEmpty()) {
m_dnsListWidget->removeItemWidget(m_dnsListWidget->item(row));
delete m_dnsListWidget->item(row);
}
row --;
}
m_removeDnsBtn->setEnabled(true);
}
void MultipleDnsWidget::onRemoveBtnClicked()
{
QListWidgetItem *aItem = m_dnsListWidget->currentItem();
if (!aItem) {
return;
}
RemoveOneDnsItem(aItem, m_dnsListWidget);
if (m_dnsListWidget->count()< 1) {
m_removeDnsBtn->setEnabled(false);
}
}

View File

@ -0,0 +1,66 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2022 Tianjin KYLIN Information Technology Co., Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#ifndef MULTIPLEDNSWIDGET_H
#define MULTIPLEDNSWIDGET_H
#include <QWidget>
#include <QLabel>
#include <QLayout>
#include <QLineEdit>
#include <QListWidget>
#include <QPushButton>
#include <QAbstractItemView>
#include <QString>
#include <QList>
#include <QHostAddress>
#include <QDebug>
#include "listitemedit.h"
class MultipleDnsWidget: public QWidget
{
Q_OBJECT
public:
MultipleDnsWidget(const QRegExp &rx, QWidget *parent = nullptr);
~MultipleDnsWidget() = default;
void setEditEnabled(bool state);
QList<QHostAddress> getDns() const;
void setDnsListText(const QList<QHostAddress> &dns);
private:
void initUI();
void initComponent();
void AddOneDnsItem(QListWidget *listWidget);
void RemoveOneDnsItem(QListWidgetItem *aItem, QListWidget *listWidget);
QLabel *m_mulDnsLabel;
QListWidget *m_dnsListWidget = nullptr;
QPushButton *m_addDnsBtn;
QPushButton *m_removeDnsBtn;
QRegExp m_regExp;
private Q_SLOTS:
void setDnsListWidgetStyle();
void onAddBtnClicked();
void onRemoveBtnClicked();
};
#endif // MULTIPLEDNSWIDGET_H

View File

@ -497,8 +497,9 @@ void NetDetail::pagePadding(QString netName, bool isWlan)
ipv4Page->setIpv4Config(m_info.ipv4ConfigType);
ipv4Page->setIpv4(m_info.strIPV4Address);
ipv4Page->setNetMask(m_info.strIPV4NetMask);
ipv4Page->setIpv4FirDns(m_info.strIPV4FirDns);
ipv4Page->setIpv4SecDns(m_info.strIPV4SecDns);
// ipv4Page->setIpv4FirDns(m_info.strIPV4FirDns);
// ipv4Page->setIpv4SecDns(m_info.strIPV4SecDns);
ipv4Page->setMulDns(m_info.ipv4DnsList);
ipv4Page->setGateWay(m_info.strIPV4GateWay);
} else {
ipv4Page->setIpv4Config(m_info.ipv4ConfigType);
@ -509,8 +510,9 @@ void NetDetail::pagePadding(QString netName, bool isWlan)
ipv6Page->setIpv6Config(m_info.ipv6ConfigType);
ipv6Page->setIpv6(m_info.strIPV6Address);
ipv6Page->setIpv6Perfix(m_info.iIPV6Prefix);
ipv6Page->setIpv6FirDns(m_info.strIPV6FirDns);
ipv6Page->setIpv6SecDns(m_info.strIPV6SecDns);
// ipv6Page->setIpv6FirDns(m_info.strIPV6FirDns);
// ipv6Page->setIpv6SecDns(m_info.strIPV6SecDns);
ipv6Page->setMulDns(m_info.ipv6DnsList);
ipv6Page->setGateWay(m_info.strIPV6GateWay);
} else {
ipv6Page->setIpv6Config(m_info.ipv6ConfigType);
@ -653,7 +655,15 @@ void NetDetail::getDynamicIpInfo(ConInfo &conInfo, bool bActived)
}
if (!ipv4Dns.isEmpty()) {
conInfo.strDynamicIpv4Dns = ipv4Dns.at(0).toString();
//conInfo.strDynamicIpv4Dns = ipv4Dns.at(0).toString();
QString dnsList;
dnsList.clear();
for (QHostAddress str: ipv4Dns) {
dnsList.append(str.toString());
dnsList.append("; ");
}
dnsList.chop(2);
conInfo.strDynamicIpv4Dns = dnsList;
}
}
@ -675,12 +685,16 @@ void NetDetail::getStaticIpInfo(ConInfo &conInfo, bool bActived)
conInfo.strIPV4NetMask = connetSetting.m_ipv4Address.at(0).netmask().toString();
conInfo.strIPV4GateWay = connetSetting.m_ipv4Address.at(0).gateway().toString();
}
#if 0
if (connetSetting.m_ipv4Dns.size() == 1) {
conInfo.strIPV4FirDns = connetSetting.m_ipv4Dns.at(0).toString();
} else if (connetSetting.m_ipv4Dns.size() > 1) {
conInfo.strIPV4FirDns = connetSetting.m_ipv4Dns.at(0).toString();
conInfo.strIPV4SecDns = connetSetting.m_ipv4Dns.at(1).toString();
}
#endif
conInfo.ipv4DnsList = connetSetting.m_ipv4Dns;
}
if (connetSetting.m_ipv6ConfigIpType == CONFIG_IP_MANUAL) {
@ -689,13 +703,16 @@ void NetDetail::getStaticIpInfo(ConInfo &conInfo, bool bActived)
conInfo.iIPV6Prefix = ipv6Page->getPerfixLength(connetSetting.m_ipv6Address.at(0).netmask().toString());
conInfo.strIPV6GateWay = connetSetting.m_ipv6Address.at(0).gateway().toString();
}
#if 0
if (connetSetting.m_ipv6Dns.size() == 1) {
conInfo.strIPV6FirDns = connetSetting.m_ipv6Dns.at(0).toString();
} else if (connetSetting.m_ipv6Dns.size() > 1) {
conInfo.strIPV6FirDns = connetSetting.m_ipv6Dns.at(0).toString();
conInfo.strIPV6SecDns = connetSetting.m_ipv6Dns.at(1).toString();
}
#endif
conInfo.ipv6DnsList = connetSetting.m_ipv6Dns;
}
if (!bActived) {

View File

@ -10,6 +10,7 @@ HEADERS += \
$$PWD/ipv4page.h \
$$PWD/ipv6page.h \
$$PWD/joinhiddenwifipage.h \
$$PWD/multiplednswidget.h \
$$PWD/netdetail.h \
$$PWD/securitypage.h
@ -22,5 +23,6 @@ SOURCES += \
$$PWD/ipv4page.cpp \
$$PWD/ipv6page.cpp \
$$PWD/joinhiddenwifipage.cpp \
$$PWD/multiplednswidget.cpp \
$$PWD/netdetail.cpp \
$$PWD/securitypage.cpp

View File

@ -0,0 +1,53 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2022 Tianjin KYLIN Information Technology Co., Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#include "listitemedit.h"
ListItemEdit::ListItemEdit(const QRegExp &rx, QObject *parent)
: m_regExp(rx),
QStyledItemDelegate(parent)
{
}
QWidget *ListItemEdit::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
QLineEdit *editor = new QLineEdit(parent);
editor->setValidator(new QRegExpValidator(m_regExp, parent));
return editor;
}
void ListItemEdit::setEditorData(QWidget *editor, const QModelIndex &index) const
{
QLineEdit *lineEdit = static_cast <QLineEdit*>(editor);
QString text = index.model()->data(index, Qt::EditRole).toString();
lineEdit->setText(text);
}
void ListItemEdit::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
{
QLineEdit *lineEdit = static_cast <QLineEdit*>(editor);
QString text = lineEdit->text();
model->setData(index, text, Qt::EditRole);
}
void ListItemEdit::updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
editor->setGeometry(option.rect);
}

View File

@ -0,0 +1,49 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2022 Tianjin KYLIN Information Technology Co., Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#ifndef LISTITEMEDIT_H
#define LISTITEMEDIT_H
#include <QWidget>
#include <QStyledItemDelegate>
#include <QLineEdit>
class ListItemEdit: public QStyledItemDelegate
{
Q_OBJECT
public:
ListItemEdit(const QRegExp &rx, QObject *parent = nullptr);
~ListItemEdit() = default;
//创建一个控件
virtual QWidget *createEditor (QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const;
//将数据设置到控件中
virtual void setEditorData (QWidget *editor, const QModelIndex &index) const;
//将控件中的数据更新到对应的model中
virtual void setModelData (QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const;
//更新控件位置
void updateEditorGeometry(QWidget *editor,
const QStyleOptionViewItem &option,
const QModelIndex &index) const override;
private:
QRegExp m_regExp;
};
#endif // LISTITEMEDIT_H

View File

@ -3,6 +3,7 @@ INCLUDEPATH += $$PWD
HEADERS += \
$$PWD/divider.h \
$$PWD/infobutton.h \
$$PWD/listitemedit.h \
$$PWD/loadingdiv.h \
$$PWD/radioitembutton.h \
$$PWD/switchbutton.h \
@ -12,6 +13,7 @@ HEADERS += \
SOURCES += \
$$PWD/divider.cpp \
$$PWD/infobutton.cpp \
$$PWD/listitemedit.cpp \
$$PWD/loadingdiv.cpp \
$$PWD/radioitembutton.cpp \
$$PWD/switchbutton.cpp \

View File

@ -32,6 +32,14 @@
<translation type="obsolete">ip地址冲突ip {6 ?}</translation>
</message>
</context>
<context>
<name>MultipleDnsWidget</name>
<message>
<location filename="../src/frontend/netdetails/multiplednswidget.cpp" line="42"/>
<source>DNS server:</source>
<translation>DNSཞབས:</translation>
</message>
</context>
<context>
<name>ConfigPage</name>
<message>

View File

@ -32,6 +32,14 @@
<translation type="obsolete">ip地址冲突ip {6 ?}</translation>
</message>
</context>
<context>
<name>MultipleDnsWidget</name>
<message>
<location filename="../src/frontend/netdetails/multiplednswidget.cpp" line="42"/>
<source>DNS server:</source>
<translation>DNS服务器</translation>
</message>
</context>
<context>
<name>ConfigPage</name>
<message>