!14 解决添加DNS功能异常问题 优化编辑DNS功能逻辑
Merge pull request !14 from zy-yuan1/muldns
This commit is contained in:
commit
bd884253d6
|
@ -386,6 +386,7 @@ void KyConnectResourse::getIpv4ConnectSetting(
|
|||
{
|
||||
if (NetworkManager::Ipv4Setting::Automatic == ipv4Setting->method()) {
|
||||
connectSetting.m_ipv4ConfigIpType = CONFIG_IP_DHCP;
|
||||
connectSetting.m_ipv4Dns = ipv4Setting->dns();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -404,6 +405,7 @@ void KyConnectResourse::getIpv6ConnectSetting(
|
|||
|
||||
if (NetworkManager::Ipv6Setting::Automatic == ipv6Setting->method()) {
|
||||
connectSetting.m_ipv6ConfigIpType = CONFIG_IP_DHCP;
|
||||
connectSetting.m_ipv6Dns = ipv6Setting->dns();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ int KyConnectSetting::setIpConfigType(KyIpAddressType ipType, KyIpConfigType ipC
|
|||
|
||||
return 0;
|
||||
}
|
||||
void KyConnectSetting::ipv4AddressConstruct(QString &ipv4Address, QString &ipv4NetMask, QString &ipv4GateWay, QStringList &ipv4Dns)
|
||||
void KyConnectSetting::ipv4AddressConstruct(QString &ipv4Address, QString &ipv4NetMask, QString &ipv4GateWay)
|
||||
{
|
||||
qDebug()<<"ipv4 address"<<ipv4Address << ipv4NetMask << ipv4GateWay;
|
||||
NetworkManager::IpAddress nmIpv4Address;
|
||||
|
@ -79,15 +79,9 @@ void KyConnectSetting::ipv4AddressConstruct(QString &ipv4Address, QString &ipv4N
|
|||
m_ipv4Address.clear();
|
||||
m_ipv4Address << nmIpv4Address;
|
||||
|
||||
m_ipv4Dns.clear();
|
||||
for (int index = 0; index < ipv4Dns.size(); ++index) {
|
||||
qDebug()<<"dns"<<ipv4Dns[index];
|
||||
m_ipv4Dns << QHostAddress(ipv4Dns[index]);
|
||||
}
|
||||
|
||||
return ;
|
||||
}
|
||||
void KyConnectSetting::ipv6AddressConstruct(QString &ipv6Address, QString &ipv6NetMask, QString &ipv6GateWay, QStringList &ipv6Dns)
|
||||
void KyConnectSetting::ipv6AddressConstruct(QString &ipv6Address, QString &ipv6NetMask, QString &ipv6GateWay)
|
||||
{
|
||||
NetworkManager::IpAddress nmIpv6Address;
|
||||
nmIpv6Address.setIp(QHostAddress(ipv6Address));
|
||||
|
@ -96,14 +90,19 @@ void KyConnectSetting::ipv6AddressConstruct(QString &ipv6Address, QString &ipv6N
|
|||
m_ipv6Address.clear();
|
||||
m_ipv6Address << nmIpv6Address;
|
||||
|
||||
m_ipv6Dns.clear();
|
||||
for (int index = 0; index < ipv6Dns.size(); index++) {
|
||||
m_ipv6Dns << QHostAddress(ipv6Dns[index]);
|
||||
}
|
||||
|
||||
return ;
|
||||
}
|
||||
|
||||
void KyConnectSetting::ipv4DnsConstruct(QList<QHostAddress> &ipv4DnsList)
|
||||
{
|
||||
m_ipv4Dns = ipv4DnsList;
|
||||
}
|
||||
|
||||
void KyConnectSetting::ipv6DnsConstruct(QList<QHostAddress> &ipv6DnsList)
|
||||
{
|
||||
m_ipv6Dns = ipv6DnsList;
|
||||
}
|
||||
|
||||
void KyConnectSetting::dumpInfo()
|
||||
{
|
||||
qDebug()<<"connect setting info:";
|
||||
|
|
|
@ -50,8 +50,10 @@ public:
|
|||
void setIfaceName(QString &ifaceName);
|
||||
void setConnectName(QString &connectName);
|
||||
int setIpConfigType(KyIpAddressType ipType, KyIpConfigType configType);
|
||||
void ipv4AddressConstruct(QString &ipv4Address, QString &ipv4NetMask, QString &ipv4GateWay, QStringList &ipv4Dns);
|
||||
void ipv6AddressConstruct(QString &ipv6Address, QString &ipv6NetMask, QString &ipv6GateWay, QStringList &ipv6Dns);
|
||||
void ipv4AddressConstruct(QString &ipv4Address, QString &ipv4NetMask, QString &ipv4GateWay);
|
||||
void ipv6AddressConstruct(QString &ipv6Address, QString &ipv6NetMask, QString &ipv6GateWay);
|
||||
void ipv4DnsConstruct(QList<QHostAddress> &ipv4DnsList);
|
||||
void ipv6DnsConstruct(QList<QHostAddress> &ipv6DnsList);
|
||||
void dumpInfo();
|
||||
|
||||
public:
|
||||
|
|
|
@ -17,24 +17,18 @@ 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);
|
||||
|
||||
m_connNameLabel->setText(tr("Connection Name"));
|
||||
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"));
|
||||
|
||||
// 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");
|
||||
|
@ -48,8 +42,6 @@ void CreatNetPage::initUI()
|
|||
m_detailLayout->addRow(m_addressLabel,ipv4addressEdit);
|
||||
m_detailLayout->addRow(m_maskLabel,netMaskEdit);
|
||||
m_detailLayout->addRow(m_gateWayLabel,gateWayEdit);
|
||||
// m_detailLayout->addRow(m_dnsLabel,firstDnsEdit);
|
||||
// m_detailLayout->addRow(m_secDnsLabel,secondDnsEdit);
|
||||
m_detailLayout->addRow(m_dnsWidget);
|
||||
|
||||
ipv4ConfigCombox->addItem(tr("Auto(DHCP)"), AUTO_CONFIG); //"自动(DHCP)"
|
||||
|
@ -58,8 +50,6 @@ void CreatNetPage::initUI()
|
|||
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() {
|
||||
|
@ -74,14 +64,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(m_dnsWidget, &MultipleDnsWidget::dnsTextChanged, this, [=]() {
|
||||
setCreatePageState(false);
|
||||
});
|
||||
connect(m_dnsWidget, &MultipleDnsWidget::dnsEditingFinished, this, [=]() {
|
||||
setCreatePageState(true);
|
||||
});
|
||||
}
|
||||
|
||||
bool CreatNetPage::checkConnectBtnIsEnabled()
|
||||
|
@ -142,16 +124,11 @@ 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(" ");
|
||||
|
@ -188,31 +165,13 @@ void CreatNetPage::constructIpv4Info(KyConnectSetting &setting)
|
|||
<< " netMask " << netMask
|
||||
<< " gateWay " << gateWay;
|
||||
|
||||
QStringList dnsList;
|
||||
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 {
|
||||
setting.setIpConfigType(IPADDRESS_V4, CONFIG_IP_MANUAL);
|
||||
setting.ipv4AddressConstruct(ipv4address, netMask, gateWay, dnsList);
|
||||
}
|
||||
|
||||
setting.ipv4AddressConstruct(ipv4address, netMask, gateWay);
|
||||
setting.ipv4DnsConstruct(ipv4dnsList);
|
||||
}
|
||||
|
||||
bool CreatNetPage::netMaskIsValide(QString text)
|
||||
|
|
|
@ -222,7 +222,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:"));
|
||||
|
||||
|
|
|
@ -72,7 +72,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;
|
||||
|
|
|
@ -72,14 +72,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()));
|
||||
connect(m_dnsWidget, &MultipleDnsWidget::dnsTextChanged, this, [=]() {
|
||||
setIpv4PageState(false);
|
||||
});
|
||||
connect(m_dnsWidget, &MultipleDnsWidget::dnsEditingFinished, this, [=]() {
|
||||
setIpv4PageState(true);
|
||||
});
|
||||
}
|
||||
|
||||
void Ipv4Page::setIpv4Config(KyIpConfigType ipv4Config)
|
||||
|
@ -124,6 +116,15 @@ void Ipv4Page::setGateWay(const QString &gateWay)
|
|||
bool Ipv4Page::checkIsChanged(const ConInfo info, KyConnectSetting &setting)
|
||||
{
|
||||
bool isChanged = false;
|
||||
QList<QHostAddress> ipv4DnsList;
|
||||
ipv4DnsList.clear();
|
||||
ipv4DnsList = m_dnsWidget->getDns();
|
||||
if (info.ipv4DnsList != ipv4DnsList) {
|
||||
qDebug() << "ipv4 dns changed";
|
||||
setting.ipv4DnsConstruct(ipv4DnsList);
|
||||
isChanged = true;
|
||||
}
|
||||
|
||||
if (ipv4ConfigCombox->currentIndex() == AUTO_CONFIG) {
|
||||
if (info.ipv4ConfigType != CONFIG_IP_DHCP) {
|
||||
qDebug() << "ipv4ConfigType change to Auto";
|
||||
|
@ -131,10 +132,8 @@ bool Ipv4Page::checkIsChanged(const ConInfo info, KyConnectSetting &setting)
|
|||
QString ipv4address("");
|
||||
QString netMask("");
|
||||
QString gateWay("");
|
||||
QStringList dnsList;
|
||||
dnsList.empty();
|
||||
qDebug() << ipv4address << netMask << gateWay;
|
||||
setting.ipv4AddressConstruct(ipv4address, netMask, gateWay, dnsList);
|
||||
setting.ipv4AddressConstruct(ipv4address, netMask, gateWay);
|
||||
isChanged = true;
|
||||
}
|
||||
} else {
|
||||
|
@ -145,37 +144,17 @@ bool Ipv4Page::checkIsChanged(const ConInfo info, KyConnectSetting &setting)
|
|||
}
|
||||
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) {
|
||||
|| info.strIPV4GateWay != gateWayEdit->text()) {
|
||||
|
||||
qDebug() << "ipv4 info changed";
|
||||
QStringList dnsList;
|
||||
dnsList.clear();
|
||||
for (QHostAddress str: ipv4dnsList) {
|
||||
dnsList << str.toString();
|
||||
}
|
||||
#if 0
|
||||
if (!firstDnsEdit->text().isEmpty()) {
|
||||
dnsList << firstDnsEdit->text();
|
||||
if (!secondDnsEdit->text().isEmpty()) {
|
||||
dnsList << secondDnsEdit->text();
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
QString ipv4address =ipv4addressEdit->text();
|
||||
QString netMask = getNetMaskText(netMaskEdit->text());
|
||||
QString gateWay = gateWayEdit->text();
|
||||
qDebug() << ipv4address << netMask << gateWay;
|
||||
setting.ipv4AddressConstruct(ipv4address, netMask, gateWay, dnsList);
|
||||
setting.ipv4AddressConstruct(ipv4address, netMask, gateWay);
|
||||
setting.dumpInfo();
|
||||
isChanged = true;
|
||||
}
|
||||
|
@ -237,16 +216,11 @@ void Ipv4Page::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();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -49,6 +49,15 @@ void Ipv6Page::setGateWay(const QString &gateWay)
|
|||
bool Ipv6Page::checkIsChanged(const ConInfo info, KyConnectSetting &setting)
|
||||
{
|
||||
bool isChanged = false;
|
||||
QList<QHostAddress> ipv6DnsList;
|
||||
ipv6DnsList.clear();
|
||||
ipv6DnsList = m_dnsWidget->getDns();
|
||||
if (info.ipv6DnsList != ipv6DnsList) {
|
||||
qDebug() << "ipv6 dns changed";
|
||||
setting.ipv6DnsConstruct(ipv6DnsList);
|
||||
isChanged = true;
|
||||
}
|
||||
|
||||
if (ipv6ConfigCombox->currentIndex() == AUTO_CONFIG) {
|
||||
if (info.ipv6ConfigType != CONFIG_IP_DHCP) {
|
||||
qDebug() << "ipv6ConfigType change to Auto";
|
||||
|
@ -56,9 +65,7 @@ bool Ipv6Page::checkIsChanged(const ConInfo info, KyConnectSetting &setting)
|
|||
QString ipv6address("");
|
||||
QString prefix("");
|
||||
QString gateWay("");
|
||||
QStringList dnsList;
|
||||
dnsList.empty();
|
||||
setting.ipv6AddressConstruct(ipv6address, prefix, gateWay, dnsList);
|
||||
setting.ipv6AddressConstruct(ipv6address, prefix, gateWay);
|
||||
isChanged = true;
|
||||
}
|
||||
} else {
|
||||
|
@ -68,35 +75,16 @@ bool Ipv6Page::checkIsChanged(const ConInfo info, KyConnectSetting &setting)
|
|||
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) {
|
||||
|| info.strIPV6GateWay != gateWayEdit->text()) {
|
||||
|
||||
qDebug() << "ipv6 info changed";
|
||||
QStringList dnsList;
|
||||
dnsList.clear();
|
||||
for (QHostAddress str: ipv6dnsList) {
|
||||
dnsList << str.toString();
|
||||
}
|
||||
#if 0
|
||||
if (!firstDnsEdit->text().isEmpty()) {
|
||||
dnsList << firstDnsEdit->text();
|
||||
if (!secondDnsEdit->text().isEmpty()) {
|
||||
dnsList << secondDnsEdit->text();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
QString ipv6address =ipv6AddressEdit->text();
|
||||
QString prefix = lengthEdit->text();
|
||||
QString gateWay = gateWayEdit->text();
|
||||
setting.ipv6AddressConstruct(ipv6address, prefix, gateWay, dnsList);
|
||||
setting.ipv6AddressConstruct(ipv6address, prefix, gateWay);
|
||||
setting.dumpInfo();
|
||||
isChanged = true;
|
||||
}
|
||||
|
@ -163,14 +151,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()));
|
||||
connect(m_dnsWidget, &MultipleDnsWidget::dnsTextChanged, this, [=]() {
|
||||
setIpv6PageState(false);
|
||||
});
|
||||
connect(m_dnsWidget, &MultipleDnsWidget::dnsEditingFinished, this, [=]() {
|
||||
setIpv6PageState(true);
|
||||
});
|
||||
}
|
||||
|
||||
void Ipv6Page::configChanged(int index) {
|
||||
|
@ -187,16 +167,12 @@ void Ipv6Page::setControlEnabled(bool check)
|
|||
ipv6AddressEdit->setEnabled(check);
|
||||
lengthEdit->setEnabled(check);
|
||||
gateWayEdit->setEnabled(check);
|
||||
m_dnsWidget->setEditEnabled(check);
|
||||
// firstDnsEdit->setEnabled(check);
|
||||
// secondDnsEdit->setEnabled(check);
|
||||
|
||||
|
||||
if (!check) {
|
||||
ipv6AddressEdit->clear();
|
||||
lengthEdit->clear();
|
||||
gateWayEdit->clear();
|
||||
// firstDnsEdit->clear();
|
||||
// secondDnsEdit->clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -86,8 +86,6 @@ void MultipleDnsWidget::initComponent()
|
|||
item->setFlags(item->flags() | Qt::ItemIsEditable);
|
||||
ListItemEdit *dnsListItemEdit = new ListItemEdit(m_regExp);
|
||||
m_dnsListWidget ->setItemDelegateForRow(m_dnsListWidget->currentIndex().row(), dnsListItemEdit);
|
||||
connect(dnsListItemEdit, SIGNAL(textChanged(QString)), this, SIGNAL(dnsTextChanged(QString)));
|
||||
connect(dnsListItemEdit, SIGNAL(editingFinished()), this, SIGNAL(dnsEditingFinished()));
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -110,7 +108,7 @@ QList<QHostAddress> MultipleDnsWidget::getDns() const
|
|||
QString aDns;
|
||||
while (m_dnsListWidget->count() > row) {
|
||||
aDns = m_dnsListWidget->item(row)->text();
|
||||
if (!dnsList.contains(aDns)) {
|
||||
if (!dnsList.contains(aDns) && !aDns.isEmpty()) {
|
||||
dnsList << aDns;
|
||||
ipv4dnsList << QHostAddress(aDns);
|
||||
}
|
||||
|
@ -140,9 +138,6 @@ void MultipleDnsWidget::AddOneDnsItem(QListWidget *listWidget)
|
|||
ListItemEdit *dnsListItemEdit = new ListItemEdit(m_regExp);
|
||||
listWidget->setItemDelegateForRow(listWidget->currentIndex().row() , dnsListItemEdit);
|
||||
listWidget->editItem(dnsListWidgetItem);
|
||||
|
||||
connect(dnsListItemEdit, SIGNAL(textChanged(QString)), this, SIGNAL(dnsTextChanged(QString)));
|
||||
connect(dnsListItemEdit, SIGNAL(editingFinished()), this, SIGNAL(dnsEditingFinished()));
|
||||
}
|
||||
|
||||
void MultipleDnsWidget::RemoveOneDnsItem(QListWidgetItem *aItem, QListWidget *listWidget)
|
||||
|
@ -164,15 +159,18 @@ void MultipleDnsWidget::setDnsListWidgetStyle()
|
|||
|
||||
void MultipleDnsWidget::onAddBtnClicked()
|
||||
{
|
||||
//避免重复添加空白项
|
||||
if (m_dnsListWidget->currentItem()) {
|
||||
if (m_dnsListWidget->currentItem()->text().isEmpty()) {
|
||||
m_dnsListWidget->removeItemWidget(m_dnsListWidget->currentItem());
|
||||
delete m_dnsListWidget->currentItem();
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -62,9 +62,6 @@ private Q_SLOTS:
|
|||
void onAddBtnClicked();
|
||||
void onRemoveBtnClicked();
|
||||
|
||||
Q_SIGNALS:
|
||||
void dnsTextChanged(const QString &);
|
||||
void dnsEditingFinished();
|
||||
};
|
||||
|
||||
#endif // MULTIPLEDNSWIDGET_H
|
||||
|
|
|
@ -363,28 +363,20 @@ void NetDetail::pagePadding(QString netName, bool isWlan)
|
|||
detailPage->setAutoConnect(m_info.isAutoConnect);
|
||||
|
||||
//ipv4页面填充
|
||||
if (m_info.ipv4ConfigType == CONFIG_IP_MANUAL) {
|
||||
ipv4Page->setIpv4Config(m_info.ipv4ConfigType);
|
||||
ipv4Page->setMulDns(m_info.ipv4DnsList);
|
||||
if (m_info.ipv4ConfigType == CONFIG_IP_MANUAL) {
|
||||
ipv4Page->setIpv4(m_info.strIPV4Address);
|
||||
ipv4Page->setNetMask(m_info.strIPV4NetMask);
|
||||
// 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);
|
||||
}
|
||||
//ipv6页面填充
|
||||
if (m_info.ipv6ConfigType == CONFIG_IP_MANUAL) {
|
||||
ipv6Page->setIpv6Config(m_info.ipv6ConfigType);
|
||||
ipv6Page->setMulDns(m_info.ipv6DnsList);
|
||||
if (m_info.ipv6ConfigType == CONFIG_IP_MANUAL) {
|
||||
ipv6Page->setIpv6(m_info.strIPV6Address);
|
||||
ipv6Page->setIpv6Perfix(m_info.iIPV6Prefix);
|
||||
// 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);
|
||||
}
|
||||
|
||||
//安全页面
|
||||
|
@ -554,14 +546,25 @@ 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();
|
||||
}
|
||||
}
|
||||
|
||||
conInfo.ipv4DnsList = connetSetting.m_ipv4Dns;
|
||||
conInfo.ipv6DnsList = connetSetting.m_ipv6Dns;
|
||||
QString dnsList;
|
||||
dnsList.clear();
|
||||
if (!conInfo.ipv4DnsList.isEmpty()) {
|
||||
for (QHostAddress str: conInfo.ipv4DnsList) {
|
||||
dnsList.append(str.toString());
|
||||
dnsList.append("; ");
|
||||
}
|
||||
dnsList.chop(2);
|
||||
conInfo.strDynamicIpv4Dns = dnsList;
|
||||
}
|
||||
|
||||
if (!bActived) {
|
||||
conInfo.strDynamicIpv4 = conInfo.strIPV4Address.isEmpty() ? tr("Auto") : conInfo.strIPV4Address;
|
||||
conInfo.strDynamicIpv6 = conInfo.strIPV6Address.isEmpty() ? tr("Auto") : conInfo.strIPV6Address;
|
||||
conInfo.strDynamicIpv4Dns = conInfo.ipv4DnsList.isEmpty() ? tr("Auto") : conInfo.ipv4DnsList.at(0).toString();
|
||||
conInfo.strDynamicIpv4Dns = conInfo.ipv4DnsList.isEmpty() ? tr("Auto") : conInfo.strDynamicIpv4Dns;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -30,8 +30,6 @@ QWidget *ListItemEdit::createEditor(QWidget *parent, const QStyleOptionViewItem
|
|||
{
|
||||
QLineEdit *editor = new QLineEdit(parent);
|
||||
editor->setValidator(new QRegExpValidator(m_regExp, parent));
|
||||
connect(editor, SIGNAL(textChanged(QString)), this, SIGNAL(textChanged(QString)));
|
||||
connect(editor, SIGNAL(editingFinished()), this, SIGNAL(editingFinished()));
|
||||
return editor;
|
||||
}
|
||||
|
||||
|
|
|
@ -44,9 +44,6 @@ public:
|
|||
private:
|
||||
QRegExp m_regExp;
|
||||
|
||||
Q_SIGNALS:
|
||||
void textChanged(const QString &);
|
||||
void editingFinished();
|
||||
};
|
||||
|
||||
#endif // LISTITEMEDIT_H
|
||||
|
|
Loading…
Reference in New Issue