fix(confform): Set ipv6.address failed.
Description: 修复设置ipv6地址失败的Bug Log: 修复设置ipv6地址失败的Bug Bug: http://172.17.66.192/biz/bug-view-38287.html
This commit is contained in:
parent
aa2803337b
commit
9899f573a5
|
@ -407,15 +407,35 @@ QString BackThread::getConnProp(QString connName)
|
|||
if (line.startsWith("ipv4.addresses:")) {
|
||||
QString value = line.mid(15).trimmed();
|
||||
if (value == "--" || value == "") {
|
||||
rtn += "addr:|mask:|";
|
||||
rtn += "v4addr:|mask:|";
|
||||
} else {
|
||||
QString addr = value.split("/").at(0);
|
||||
QString mask = value.trimmed().split("/").at(1);
|
||||
rtn += "addr:" + addr + "|";
|
||||
rtn += "v4addr:" + addr + "|";
|
||||
rtn += "mask:" + mask + "|";
|
||||
}
|
||||
}
|
||||
|
||||
if (line.startsWith("ipv6.method:")) {
|
||||
QString value = line.mid(12).trimmed();
|
||||
if (value == "auto") {
|
||||
rtn += "v6method:auto|v6addr:|";
|
||||
} else {
|
||||
rtn += "v6method:manual|";
|
||||
}
|
||||
}
|
||||
|
||||
if (line.startsWith("ipv6.addresses:")) {
|
||||
QString value = line.mid(15).trimmed();
|
||||
if (value == "--" || value == "") {
|
||||
rtn += "v6addr:|";
|
||||
} else {
|
||||
QString addr = value.split("/").at(0);
|
||||
rtn += "v6addr:" + addr + "|";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (line.startsWith("ipv4.gateway:")) {
|
||||
QString value = line.mid(13).trimmed();
|
||||
if (value == "--" || value == "") {
|
||||
|
|
|
@ -162,12 +162,12 @@ void ConfForm::mouseMoveEvent(QMouseEvent *event)
|
|||
}
|
||||
|
||||
//网络配置参数设置界面的显示内容
|
||||
void ConfForm::setProp(QString connName, QString uuidName, QString v4method, QString addr, QString mask, QString gateway, QString dns, bool isActConf, bool isWiFi)
|
||||
void ConfForm::setProp(QString connName, QString uuidName, QString v4method, QString v4addr, QString v6method, QString v6addr, QString mask, QString gateway, QString dns, bool isActConf, bool isWiFi)
|
||||
{
|
||||
this->isActConf = isActConf;
|
||||
ui->leName->setText(connName);
|
||||
lastConnName = connName;
|
||||
lastIpv4 = addr;
|
||||
lastIpv4 = v4addr;
|
||||
netUuid = uuidName;
|
||||
|
||||
if (isWiFi) {
|
||||
|
@ -183,7 +183,11 @@ void ConfForm::setProp(QString connName, QString uuidName, QString v4method, QSt
|
|||
cbTypeChanged(1);
|
||||
}
|
||||
|
||||
ui->leAddr->setText(addr);
|
||||
if (v6method == "manual") {
|
||||
ui->leAddr_ipv6->setText(v6addr);
|
||||
}
|
||||
|
||||
ui->leAddr->setText(v4addr);
|
||||
ui->leGateway->setText(gateway);
|
||||
|
||||
// 配置中有多个DNS,只处理前两个
|
||||
|
@ -250,7 +254,10 @@ void ConfForm::on_btnCreate_clicked()
|
|||
}
|
||||
|
||||
if (!ui->leAddr_ipv6->text().isEmpty()) {
|
||||
QString cmdStr = "nmcli connection modify " + ui->leName->text() + " ipv6.addresses " + ui->leAddr_ipv6->text();
|
||||
QString cmdStr = "nmcli connection modify " + ui->leName->text() + " ipv6.method manual ipv6.addresses " + ui->leAddr_ipv6->text();
|
||||
Utils::m_system(cmdStr.toUtf8().data());
|
||||
} else {
|
||||
QString cmdStr = "nmcli connection modify " + ui->leName->text() + " ipv6.method auto";
|
||||
Utils::m_system(cmdStr.toUtf8().data());
|
||||
}
|
||||
|
||||
|
@ -343,9 +350,14 @@ void ConfForm::on_btnSave_clicked()
|
|||
}
|
||||
}
|
||||
|
||||
if (ui->cbType->currentIndex() == 1 && !ui->leAddr_ipv6->text().isEmpty()) {
|
||||
QString cmdStr = "nmcli connection modify " + ui->leName->text() + " ipv6.addresses " + ui->leAddr_ipv6->text();
|
||||
if (ui->cbType->currentIndex() == 1) {
|
||||
if (!ui->leAddr_ipv6->text().isEmpty()) {
|
||||
QString cmdStr = "nmcli connection modify " + ui->leName->text() + " ipv6.method manual ipv6.addresses " + ui->leAddr_ipv6->text();
|
||||
Utils::m_system(cmdStr.toUtf8().data());
|
||||
} else {
|
||||
QString cmdStr = "nmcli connection modify " + ui->leName->text() + " ipv6.method auto";
|
||||
Utils::m_system(cmdStr.toUtf8().data());
|
||||
}
|
||||
}
|
||||
|
||||
QString txt(tr("New network settings already finished"));
|
||||
|
|
|
@ -40,7 +40,7 @@ public:
|
|||
explicit ConfForm(QWidget *parent = 0);
|
||||
~ConfForm();
|
||||
|
||||
void setProp(QString connName, QString uuidName, QString v4method, QString addr, QString mask, QString gateway, QString dns, bool isActConf, bool isWiFi);
|
||||
void setProp(QString connName, QString uuidName, QString v4method, QString v4addr, QString v6method, QString v6addr, QString mask, QString gateway, QString dns, bool isActConf, bool isWiFi);
|
||||
|
||||
public slots:
|
||||
void cbTypeChanged(int index);
|
||||
|
|
|
@ -791,7 +791,7 @@ void OneConnForm::on_btnInfo_clicked()
|
|||
BackThread *bt = new BackThread();
|
||||
QString connProp = bt->getConnProp(lbNameText->text());
|
||||
QStringList propList = connProp.split("|");
|
||||
QString v4method, addr, mask, gateway, dns;
|
||||
QString v4method, addr, mask, gateway, dns, v6method, v6addr;
|
||||
foreach (QString line, propList) {
|
||||
if (line.startsWith("method:")) {
|
||||
v4method = line.split(":").at(1);
|
||||
|
@ -802,6 +802,12 @@ void OneConnForm::on_btnInfo_clicked()
|
|||
if (line.startsWith("mask:")) {
|
||||
mask = line.split(":").at(1);
|
||||
}
|
||||
if (line.startsWith("v6method:")) {
|
||||
v6method = line.split(":").at(1);
|
||||
}
|
||||
if (line.startsWith("v6addr:")) {
|
||||
v6addr = line.right(line.length() - line.indexOf(":") - 1);
|
||||
}
|
||||
if (line.startsWith("gateway:")) {
|
||||
gateway= line.split(":").at(1);
|
||||
}
|
||||
|
@ -811,7 +817,7 @@ void OneConnForm::on_btnInfo_clicked()
|
|||
}
|
||||
// qDebug()<<"v4method:"<<v4method<<" addr:"<<addr<<" mask:"<<mask<<" gateway:"<<gateway<<" dns:"<<dns;
|
||||
|
||||
cf->setProp(lbNameText->text(), wifiUuid, v4method, addr, mask, gateway, dns, this->isActive, true);
|
||||
cf->setProp(lbNameText->text(), wifiUuid, v4method, addr, v6method, v6addr, mask, gateway, dns, this->isActive, true);
|
||||
cf->move(primaryGeometry.width() / 2 - cf->width() / 2, primaryGeometry.height() / 2 - cf->height() / 2);
|
||||
cf->show();
|
||||
cf->raise();
|
||||
|
|
|
@ -408,17 +408,23 @@ void OneLancForm::on_btnInfo_clicked()
|
|||
BackThread *bt = new BackThread();
|
||||
QString connProp = bt->getConnProp(uuidName);
|
||||
QStringList propList = connProp.split("|");
|
||||
QString v4method, addr, mask, gateway, dns;
|
||||
QString v4method, addr, mask, gateway, dns, v6method, v6addr;
|
||||
foreach (QString line, propList) {
|
||||
if (line.startsWith("method:")) {
|
||||
v4method = line.split(":").at(1);
|
||||
}
|
||||
if (line.startsWith("addr:")) {
|
||||
if (line.startsWith("v4addr:")) {
|
||||
addr = line.split(":").at(1);
|
||||
}
|
||||
if (line.startsWith("mask:")) {
|
||||
mask = line.split(":").at(1);
|
||||
}
|
||||
if (line.startsWith("v6method:")) {
|
||||
v6method = line.split(":").at(1);
|
||||
}
|
||||
if (line.startsWith("v6addr:")) {
|
||||
v6addr = line.right(line.length() - line.indexOf(":") - 1);
|
||||
}
|
||||
if (line.startsWith("gateway:")) {
|
||||
gateway= line.split(":").at(1);
|
||||
}
|
||||
|
@ -429,7 +435,7 @@ void OneLancForm::on_btnInfo_clicked()
|
|||
// qDebug()<<v4method<<addr<<mask<<gateway<<dns;
|
||||
|
||||
connect(cf, SIGNAL(requestRefreshLanList(int)), mw, SLOT(onBtnNetListClicked(int)));
|
||||
cf->setProp(ui->lbName->text(), uuidName, v4method, addr, mask, gateway, dns, this->isActive, false);
|
||||
cf->setProp(ui->lbName->text(), uuidName, v4method, addr, v6method, v6addr, mask, gateway, dns, this->isActive, false);
|
||||
cf->move(primaryGeometry.width() / 2 - cf->width() / 2, primaryGeometry.height() / 2 - cf->height() / 2);
|
||||
cf->exec();
|
||||
cf->raise();
|
||||
|
|
Loading…
Reference in New Issue