This commit is contained in:
chenlelin 2021-03-04 11:47:31 +08:00
commit 6b0d083aad
4 changed files with 32 additions and 6 deletions

View File

@ -132,6 +132,7 @@ ConfForm::ConfForm(QWidget *parent) :
setModal(false); setModal(false);
KWindowEffects::enableBlurBehind(this->winId(), true, QRegion(path.toFillPolygon().toPolygon())); KWindowEffects::enableBlurBehind(this->winId(), true, QRegion(path.toFillPolygon().toPolygon()));
setEnableOfBtn();
} }
ConfForm::~ConfForm() ConfForm::~ConfForm()
@ -254,11 +255,22 @@ void ConfForm::on_btnCreate_clicked()
kylindbus.showDesktopNotify(txt); kylindbus.showDesktopNotify(txt);
} }
QString name = ui->leName->text();
QStringList charToEscape;
charToEscape << "~" << "(" << ")" << "<" << ">" <<"\\" << "*" << "|" << "&" << "#"; //一些命令行特殊字符,需要转义
foreach (auto ch , charToEscape) {
if (name.contains(ch)) {
name.replace(ch, QString("%1%2").arg("\\").arg(ch));
}
}
if (name.contains(" ")) { //空格会影响命令行参数的判断,需要转义
name.replace(QRegExp("[\\s]"), "\\\ ");
}
if (!ui->leAddr_ipv6->text().isEmpty()) { if (!ui->leAddr_ipv6->text().isEmpty()) {
QString cmdStr = "nmcli connection modify " + ui->leName->text() + " ipv6.method manual ipv6.addresses " + ui->leAddr_ipv6->text(); QString cmdStr = "nmcli connection modify " + name + " ipv6.method manual ipv6.addresses " + ui->leAddr_ipv6->text();
Utils::m_system(cmdStr.toUtf8().data()); Utils::m_system(cmdStr.toUtf8().data());
} else { } else {
QString cmdStr = "nmcli connection modify " + ui->leName->text() + " ipv6.method auto"; QString cmdStr = "nmcli connection modify " + name + " ipv6.method auto";
Utils::m_system(cmdStr.toUtf8().data()); Utils::m_system(cmdStr.toUtf8().data());
} }
@ -352,15 +364,15 @@ void ConfForm::on_btnSave_clicked()
} }
if (ui->cbType->currentIndex() == 1) { if (ui->cbType->currentIndex() == 1) {
//对于已保存连接修改ipv6地址使用UUID区分各网络配置排除名称含空格或特殊字符的干扰
if (!ui->leAddr_ipv6->text().isEmpty()) { if (!ui->leAddr_ipv6->text().isEmpty()) {
QString cmdStr = "nmcli connection modify " + ui->leName->text() + " ipv6.method manual ipv6.addresses " + ui->leAddr_ipv6->text(); QString cmdStr = "nmcli connection modify " + netUuid + " ipv6.method manual ipv6.addresses " + ui->leAddr_ipv6->text();
Utils::m_system(cmdStr.toUtf8().data()); Utils::m_system(cmdStr.toUtf8().data());
} else { } else {
QString cmdStr = "nmcli connection modify " + ui->leName->text() + " ipv6.method auto"; QString cmdStr = "nmcli connection modify " + netUuid + " ipv6.method auto";
Utils::m_system(cmdStr.toUtf8().data()); Utils::m_system(cmdStr.toUtf8().data());
} }
} }
QString txt(tr("New network settings already finished")); QString txt(tr("New network settings already finished"));
kylindbus.showDesktopNotify(txt); kylindbus.showDesktopNotify(txt);
} }
@ -554,7 +566,7 @@ void ConfForm::on_leDns_textEdited(const QString &arg1)
//编辑网络备用DNS //编辑网络备用DNS
void ConfForm::on_leDns2_textEdited(const QString &arg1) void ConfForm::on_leDns2_textEdited(const QString &arg1)
{ {
// this->setEnableOfBtn(); this->setEnableOfBtn();
} }
//设置界面按钮是否可点击 //设置界面按钮是否可点击
@ -585,6 +597,14 @@ void ConfForm::setEnableOfBtn()
this->setBtnEnableFalse(); this->setBtnEnableFalse();
return; return;
} }
if(ui->leDns2->text().isEmpty()){
}else{
if(!this->getTextEditState(ui->leDns2->text())){
this->setBtnEnableFalse();
return ;
}
}
} }

View File

@ -369,6 +369,8 @@ void KylinDBus::getLanIpDNS(QString uuidName, bool isActNet)
dbusArg2nd.endArray(); dbusArg2nd.endArray();
dbusLanIpv6 = m_map.value("address").toString(); dbusLanIpv6 = m_map.value("address").toString();
} else if (inner_key == "method") {
dbusLanIpv6Method = innerMap.value(inner_key).toString();
} }
} }
} }

View File

@ -88,6 +88,7 @@ public:
QString dbusLanIpv4 = ""; QString dbusLanIpv4 = "";
QString dbusLanIpv6 = ""; QString dbusLanIpv6 = "";
QString dbusLanIpv6Method = "";
QString dbusActiveLanIpv4 = ""; QString dbusActiveLanIpv4 = "";
QString dbusActiveLanIpv6 = ""; QString dbusActiveLanIpv6 = "";
QString dbusLanGateway = ""; QString dbusLanGateway = "";

View File

@ -1604,6 +1604,9 @@ void MainWindow::getLanListDone(QStringList slist)
} else if ((oldActLanName == actLanSsidName.at(kk)) && (oldDbusActLanDNS != objKyDBus->dbusActLanDNS)) { } else if ((oldActLanName == actLanSsidName.at(kk)) && (oldDbusActLanDNS != objKyDBus->dbusActLanDNS)) {
//在第三方nm-connection-editor进行新的DNS配置后重新连接网络 //在第三方nm-connection-editor进行新的DNS配置后重新连接网络
objKyDBus->reConnectWiredNet(nuuid); objKyDBus->reConnectWiredNet(nuuid);
} else if (!objKyDBus->dbusActiveLanIpv6.isEmpty() && objKyDBus->dbusActiveLanIpv6 != objKyDBus->dbusLanIpv6 && objKyDBus->dbusLanIpv6Method == "manual") {
//在第三方nm-connection-editor或kylin-nm配置页进行新的IPV6配置后重新连接网络
objKyDBus->reConnectWiredNet(nuuid);
} }
} }