From d716d019949920c7a2a5492cdcdf43cbaf3e548f Mon Sep 17 00:00:00 2001 From: zhangjiaping Date: Mon, 25 Jan 2021 20:40:16 +0800 Subject: [PATCH] fix(confform): Ipv6 address can not be edit. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Description: 修复ipv6地址设置项缺失的问题 Log: 修复ipv6地址设置项缺失的问题 Bug: http://172.17.66.192/biz/bug-view-19885.html --- src/confform.cpp | 34 +++++++++++++++++ src/confform.h | 3 ++ src/confform.ui | 68 ++++++++++++++++++++++++--------- translations/kylin-nm_zh_CN.qm | Bin 22082 -> 22153 bytes translations/kylin-nm_zh_CN.ts | 7 +++- 5 files changed, 94 insertions(+), 18 deletions(-) diff --git a/src/confform.cpp b/src/confform.cpp index 88bcdedb..a63da4f8 100644 --- a/src/confform.cpp +++ b/src/confform.cpp @@ -87,6 +87,7 @@ ConfForm::ConfForm(QWidget *parent) : ui->lbTxt4->setText(tr("Gateway: "));//"默认网关:" ui->lbTxt5->setText(tr("DNS 1: "));//"首选DNS:" ui->lbTxt6->setText(tr("DNS 2: "));//"备选DNS:" + ui->lbTxt_ipv6->setText(tr("Ipv6 Address: ")); ui->lbLeftupTitle->setText(tr("Edit Conn"));//"网络设置" ui->cbType->addItem(tr("Auto(DHCP)"));//"自动(DHCP)" @@ -110,10 +111,12 @@ ConfForm::ConfForm(QWidget *parent) : // 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"); + 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*$"); ui->leAddr->setValidator(new QRegExpValidator(rx, this)); ui->leGateway->setValidator(new QRegExpValidator(rx, this)); ui->leDns->setValidator(new QRegExpValidator(rx, this)); ui->leDns2->setValidator(new QRegExpValidator(rx, this)); + ui->leAddr_ipv6->setValidator(new QRegExpValidator(ipv6_rx, this)); KWindowEffects::enableBlurBehind(this->winId(), true, QRegion(path.toFillPolygon().toPolygon())); } @@ -234,6 +237,11 @@ void ConfForm::on_btnCreate_clicked() kylindbus.showDesktopNotify(txt); } + if (!ui->leAddr_ipv6->text().isEmpty()) { + QString cmdStr = "nmcli connection modify " + ui->leName->text() + " ipv6.addresses " + ui->leAddr_ipv6->text(); + Utils::m_system(cmdStr.toUtf8().data()); + } + this->hide(); } @@ -307,6 +315,11 @@ void ConfForm::on_btnSave_clicked() this->saveNetworkConfiguration(); } + if (!ui->leAddr_ipv6->text().isEmpty()) { + QString cmdStr = "nmcli connection modify " + ui->leName->text() + " ipv6.addresses " + ui->leAddr_ipv6->text(); + Utils::m_system(cmdStr.toUtf8().data()); + } + QString txt(tr("New network settings already finished")); kylindbus.showDesktopNotify(txt); } @@ -480,6 +493,12 @@ void ConfForm::on_leAddr_textEdited(const QString &arg1) this->setEnableOfBtn(); } +//编辑ipv6地址 +void ConfForm::on_leAddr_ipv6_textChanged(const QString &arg1) +{ + this->setEnableOfBtn(); +} + //编辑网络网关 void ConfForm::on_leGateway_textEdited(const QString &arg1) { @@ -521,6 +540,11 @@ void ConfForm::setEnableOfBtn() this->setBtnEnableFalse(); return; } + + if (!ui->leAddr_ipv6->text().isEmpty() && ! this->getIpv6EditState(ui->leAddr_ipv6->text())) { + this->setBtnEnableFalse(); + return; + } } ui->btnSave->setEnabled(true); @@ -538,6 +562,16 @@ bool ConfForm::getTextEditState(QString text) return match; } +bool ConfForm::getIpv6EditState(QString text) +{ + QRegExp 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*$"); + + bool match = false; + match = rx.exactMatch(text); + + return match; +} + //设置创建或保存按钮不可点击 void ConfForm::setBtnEnableFalse() { diff --git a/src/confform.h b/src/confform.h index 292cdef9..436cc48f 100644 --- a/src/confform.h +++ b/src/confform.h @@ -67,9 +67,12 @@ private slots: void setEnableOfBtn(); bool getTextEditState(QString text); + bool getIpv6EditState(QString text); void setBtnEnableFalse(); void saveNetworkConfiguration(); + void on_leAddr_ipv6_textChanged(const QString &arg1); + private: Ui::ConfForm *ui; diff --git a/src/confform.ui b/src/confform.ui index cf838c3c..b4526a40 100644 --- a/src/confform.ui +++ b/src/confform.ui @@ -29,16 +29,16 @@ 1 - 180 + 169 430 - 260 + 271 175 - 15 + 10 182 32 @@ -53,7 +53,7 @@ 175 - 60 + 95 182 32 @@ -68,7 +68,7 @@ 175 - 105 + 140 182 32 @@ -83,7 +83,7 @@ 175 - 150 + 185 182 32 @@ -98,7 +98,7 @@ 76 - 20 + 15 80 20 @@ -117,7 +117,7 @@ 76 - 65 + 100 80 20 @@ -136,7 +136,7 @@ 76 - 110 + 145 80 20 @@ -155,7 +155,7 @@ 76 - 155 + 190 80 20 @@ -174,7 +174,7 @@ 175 - 195 + 230 182 32 @@ -189,7 +189,7 @@ 76 - 200 + 235 80 20 @@ -204,6 +204,40 @@ + + + + 76 + 57 + 91 + 20 + + + + + Noto Sans CJK SC + 11 + + + + + + + + + + 175 + 52 + 182 + 32 + + + + + 10 + + + @@ -296,7 +330,7 @@ 315 - 15 + 20 90 30 @@ -314,7 +348,7 @@ 215 - 15 + 20 90 30 @@ -332,7 +366,7 @@ 315 - 15 + 20 90 30 @@ -359,7 +393,7 @@ 10 - 175 + 170 412 1 @@ -372,7 +406,7 @@ 10 - 430 + 440 412 1 diff --git a/translations/kylin-nm_zh_CN.qm b/translations/kylin-nm_zh_CN.qm index 3505f5069787535116747100ccd856c7588ef560..ba45c83eb331f5039e2c75feab046c8f3c133d72 100644 GIT binary patch delta 2532 zcmXxldr(w$6bJCLyLT7%?hEAol=u6wu)DlLKoEA>9BuM3YLgmhHjE;^MY_~L6BTMH zhNBjup`oS&h?V9O&DFFFwIo9w!Nx4jM>;c^4fxVf-6m6VeUiJY9F))%@qLhq?CzzD;v zFs2jnyKRY&+K_}*gSZm2~cl^ZuQXTj}avr9e_YYHj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` zbWZi(b5U-F_Lt%KVi@o#jJAWuVO_4gnNPaQx{s6G`MmJfeLQ2-LfyVn-U4Ziu6qN& zjI3teIsJN`0KsvcV~XVY9s<6{3}28p@?ft%It3Y3qEAkM)1s*_R6d diff --git a/translations/kylin-nm_zh_CN.ts b/translations/kylin-nm_zh_CN.ts index 5bd15398..e2e3cc1a 100644 --- a/translations/kylin-nm_zh_CN.ts +++ b/translations/kylin-nm_zh_CN.ts @@ -25,10 +25,15 @@ Method: 编辑IP设置: + + + Ipv6 Address: + IPV6地址: + Address: - IP地址: + IPV4地址: