Merge pull request #68 from mammonsama666/0125-dev
fix(confform): Ipv6 address can not be edit.
This commit is contained in:
commit
889e41d7e7
|
@ -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()
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -29,16 +29,16 @@
|
|||
<property name="geometry">
|
||||
<rect>
|
||||
<x>1</x>
|
||||
<y>180</y>
|
||||
<y>169</y>
|
||||
<width>430</width>
|
||||
<height>260</height>
|
||||
<height>271</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QLineEdit" name="leAddr">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>175</x>
|
||||
<y>15</y>
|
||||
<y>10</y>
|
||||
<width>182</width>
|
||||
<height>32</height>
|
||||
</rect>
|
||||
|
@ -53,7 +53,7 @@
|
|||
<property name="geometry">
|
||||
<rect>
|
||||
<x>175</x>
|
||||
<y>60</y>
|
||||
<y>95</y>
|
||||
<width>182</width>
|
||||
<height>32</height>
|
||||
</rect>
|
||||
|
@ -68,7 +68,7 @@
|
|||
<property name="geometry">
|
||||
<rect>
|
||||
<x>175</x>
|
||||
<y>105</y>
|
||||
<y>140</y>
|
||||
<width>182</width>
|
||||
<height>32</height>
|
||||
</rect>
|
||||
|
@ -83,7 +83,7 @@
|
|||
<property name="geometry">
|
||||
<rect>
|
||||
<x>175</x>
|
||||
<y>150</y>
|
||||
<y>185</y>
|
||||
<width>182</width>
|
||||
<height>32</height>
|
||||
</rect>
|
||||
|
@ -98,7 +98,7 @@
|
|||
<property name="geometry">
|
||||
<rect>
|
||||
<x>76</x>
|
||||
<y>20</y>
|
||||
<y>15</y>
|
||||
<width>80</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
|
@ -117,7 +117,7 @@
|
|||
<property name="geometry">
|
||||
<rect>
|
||||
<x>76</x>
|
||||
<y>65</y>
|
||||
<y>100</y>
|
||||
<width>80</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
|
@ -136,7 +136,7 @@
|
|||
<property name="geometry">
|
||||
<rect>
|
||||
<x>76</x>
|
||||
<y>110</y>
|
||||
<y>145</y>
|
||||
<width>80</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
|
@ -155,7 +155,7 @@
|
|||
<property name="geometry">
|
||||
<rect>
|
||||
<x>76</x>
|
||||
<y>155</y>
|
||||
<y>190</y>
|
||||
<width>80</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
|
@ -174,7 +174,7 @@
|
|||
<property name="geometry">
|
||||
<rect>
|
||||
<x>175</x>
|
||||
<y>195</y>
|
||||
<y>230</y>
|
||||
<width>182</width>
|
||||
<height>32</height>
|
||||
</rect>
|
||||
|
@ -189,7 +189,7 @@
|
|||
<property name="geometry">
|
||||
<rect>
|
||||
<x>76</x>
|
||||
<y>200</y>
|
||||
<y>235</y>
|
||||
<width>80</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
|
@ -204,6 +204,40 @@
|
|||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="lbTxt_ipv6">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>76</x>
|
||||
<y>57</y>
|
||||
<width>91</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Noto Sans CJK SC</family>
|
||||
<pointsize>11</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="leAddr_ipv6">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>175</x>
|
||||
<y>52</y>
|
||||
<width>182</width>
|
||||
<height>32</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QWidget" name="wdHead" native="true">
|
||||
<property name="geometry">
|
||||
|
@ -296,7 +330,7 @@
|
|||
<property name="geometry">
|
||||
<rect>
|
||||
<x>315</x>
|
||||
<y>15</y>
|
||||
<y>20</y>
|
||||
<width>90</width>
|
||||
<height>30</height>
|
||||
</rect>
|
||||
|
@ -314,7 +348,7 @@
|
|||
<property name="geometry">
|
||||
<rect>
|
||||
<x>215</x>
|
||||
<y>15</y>
|
||||
<y>20</y>
|
||||
<width>90</width>
|
||||
<height>30</height>
|
||||
</rect>
|
||||
|
@ -332,7 +366,7 @@
|
|||
<property name="geometry">
|
||||
<rect>
|
||||
<x>315</x>
|
||||
<y>15</y>
|
||||
<y>20</y>
|
||||
<width>90</width>
|
||||
<height>30</height>
|
||||
</rect>
|
||||
|
@ -359,7 +393,7 @@
|
|||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>175</y>
|
||||
<y>170</y>
|
||||
<width>412</width>
|
||||
<height>1</height>
|
||||
</rect>
|
||||
|
@ -372,7 +406,7 @@
|
|||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>430</y>
|
||||
<y>440</y>
|
||||
<width>412</width>
|
||||
<height>1</height>
|
||||
</rect>
|
||||
|
|
Binary file not shown.
|
@ -25,10 +25,15 @@
|
|||
<source>Method: </source>
|
||||
<translation>编辑IP设置: </translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/confform.cpp" line="90"/>
|
||||
<source>Ipv6 Address: </source>
|
||||
<translation>IPV6地址: </translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/confform.cpp" line="85"/>
|
||||
<source>Address: </source>
|
||||
<translation>IP地址: </translation>
|
||||
<translation>IPV4地址: </translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/confform.cpp" line="86"/>
|
||||
|
|
Loading…
Reference in New Issue