Merge branch 'dbusInter-bugfix' into 'dbus-interface'

修改ipv4page/ipv6page手动输入提示的判断逻辑

See merge request kylin-desktop/kylin-nm!645
This commit is contained in:
赵世旭 2022-07-01 07:05:06 +00:00
commit 1fd5d96768
4 changed files with 59 additions and 64 deletions

View File

@ -13,21 +13,6 @@ Ipv4Page::Ipv4Page(QWidget *parent):QFrame(parent)
initComponent();
}
bool Ipv4Page::eventFilter(QObject *w, QEvent *e)
{
if (w == ipv4addressEdit) {
if (ipv4addressEdit->text().isEmpty() || getTextEditState(ipv4addressEdit->text())) {
m_addressHintLabel->clear();
}
} else if (w == netMaskEdit) {
if (netMaskEdit->text().isEmpty() || netMaskIsValide(netMaskEdit->text())) {
m_maskHintLabel->clear();
}
}
return QObject::eventFilter(w,e);
}
void Ipv4Page::initUI() {
ipv4ConfigCombox = new QComboBox(this);
ipv4addressEdit = new LineEdit(this);
@ -132,6 +117,9 @@ void Ipv4Page::initComponent() {
}
connect(ipv4ConfigCombox, SIGNAL(currentIndexChanged(int)), this, SLOT(configChanged(int)));
connect(ipv4addressEdit, SIGNAL(textChanged(QString)), this, SLOT(onAddressTextChanged()));
connect(netMaskEdit, SIGNAL(textChanged(QString)), this, SLOT(onNetMaskTextChanged()));
connect(ipv4ConfigCombox, SIGNAL(currentIndexChanged(int)), this, SLOT(setEnableOfSaveBtn()));
connect(ipv4addressEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn()));
connect(netMaskEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn()));
@ -231,23 +219,13 @@ bool Ipv4Page::checkConnectBtnIsEnabled()
if (ipv4ConfigCombox->currentIndex() == AUTO_CONFIG) {
return true;
} else {
if (ipv4addressEdit->text().isEmpty()) {
qDebug() << "ipv4address empty";
return false;
}
if (!getTextEditState(ipv4addressEdit->text())) {
m_addressHintLabel->setText(tr("Invalid address"));
qDebug() << "ipv4address invalid";
if (ipv4addressEdit->text().isEmpty() || !getTextEditState(ipv4addressEdit->text())) {
qDebug() << "ipv4address empty or invalid";
return false;
}
if (netMaskEdit->text().isEmpty()) {
qDebug() << "ipv4 netMask empty";
return false;
}
if (!netMaskIsValide(netMaskEdit->text())) {
m_maskHintLabel->setText(tr("Invalid subnet mask"));
qDebug() << "ipv4 netMask invalid";
if (netMaskEdit->text().isEmpty() || !netMaskIsValide(netMaskEdit->text())) {
qDebug() << "ipv4 netMask empty or invalid";
return false;
}
@ -283,6 +261,26 @@ void Ipv4Page::configChanged(int index) {
}
}
void Ipv4Page::onAddressTextChanged()
{
if (!getTextEditState(ipv4addressEdit->text())) {
m_addressHintLabel->setText(tr("Invalid address"));
qDebug() << "ipv4address invalid";
} else {
m_addressHintLabel->clear();
}
}
void Ipv4Page::onNetMaskTextChanged()
{
if (!netMaskIsValide(netMaskEdit->text())) {
m_maskHintLabel->setText(tr("Invalid subnet mask"));
qDebug() << "ipv4 netMask invalid";
} else {
m_maskHintLabel->clear();
}
}
void Ipv4Page::setLineEnabled(bool check) {
if (!check) {

View File

@ -29,9 +29,6 @@ public:
bool checkIsChanged(const ConInfo info, KyConnectSetting &setting);
protected:
bool eventFilter(QObject *w, QEvent *e);
private:
QComboBox *ipv4ConfigCombox;
LineEdit *ipv4addressEdit;
@ -69,6 +66,9 @@ private:
private slots:
void setEnableOfSaveBtn();
void configChanged(int index);
void onAddressTextChanged();
void onNetMaskTextChanged();
Q_SIGNALS:
void setIpv4PageState(bool);

View File

@ -12,21 +12,6 @@ Ipv6Page::Ipv6Page(QWidget *parent):QFrame(parent)
initComponent();
}
bool Ipv6Page::eventFilter(QObject *w, QEvent *e)
{
if (w == ipv6AddressEdit) {
if (ipv6AddressEdit->text().isEmpty() || getIpv6EditState(ipv6AddressEdit->text())) {
m_addressHintLabel->clear();
}
} else if (w == gateWayEdit) {
if (gateWayEdit->text().isEmpty() || getIpv6EditState(gateWayEdit->text())) {
m_gateWayHintLabel->clear();
}
}
return QObject::eventFilter(w,e);
}
void Ipv6Page::setIpv6Config(KyIpConfigType ipv6Config)
{
if (ipv6Config == CONFIG_IP_MANUAL) {
@ -205,6 +190,9 @@ void Ipv6Page::initComponent() {
}
connect(ipv6ConfigCombox, SIGNAL(currentIndexChanged(int)), this, SLOT(configChanged(int)));
connect(ipv6AddressEdit, SIGNAL(textChanged(QString)), this, SLOT(onAddressTextChanged()));
connect(gateWayEdit, SIGNAL(textChanged(QString)), this, SLOT(onGatewayTextChanged()));
connect(ipv6ConfigCombox, SIGNAL(currentIndexChanged(int)), this, SLOT(setEnableOfSaveBtn()));
connect(ipv6AddressEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn()));
connect(lengthEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn()));
@ -252,18 +240,33 @@ void Ipv6Page::setEnableOfSaveBtn()
emit setIpv6PageState(checkConnectBtnIsEnabled());
}
void Ipv6Page::onAddressTextChanged()
{
if (!getIpv6EditState(ipv6AddressEdit->text())) {
m_addressHintLabel->setText(tr("Invalid address"));
qDebug() << "ipv6address invalid";
} else {
m_addressHintLabel->clear();
}
}
void Ipv6Page::onGatewayTextChanged()
{
if (!getIpv6EditState(gateWayEdit->text())) {
m_gateWayHintLabel->setText(tr("Invalid gateway"));
qDebug() << "ipv6 gateway invalid";
} else {
m_gateWayHintLabel->clear();
}
}
bool Ipv6Page::checkConnectBtnIsEnabled()
{
if (ipv6ConfigCombox->currentIndex() == AUTO_CONFIG) {
return true;
} else {
if (ipv6AddressEdit->text().isEmpty()) {
qDebug() << "ipv6address empty";
return false;
}
if (!getIpv6EditState(ipv6AddressEdit->text())) {
m_addressHintLabel->setText(tr("Invalid address"));
qDebug() << "ipv6address invalid";
if (ipv6AddressEdit->text().isEmpty() || !getIpv6EditState(ipv6AddressEdit->text())) {
qDebug() << "ipv6address empty or invalid";
return false;
}
@ -272,13 +275,8 @@ bool Ipv6Page::checkConnectBtnIsEnabled()
return false;
}
if (gateWayEdit->text().isEmpty()) {
qDebug() << "ipv6 gateway empty";
return false;
}
if (!getIpv6EditState(gateWayEdit->text())) {
m_gateWayHintLabel->setText(tr("Invalid gateway"));
qDebug() << "ipv6 gateway invalid";
if (gateWayEdit->text().isEmpty() || !getIpv6EditState(gateWayEdit->text())) {
qDebug() << "ipv6 gateway empty or invalid";
return false;
}

View File

@ -31,9 +31,6 @@ public:
int getPerfixLength(QString text);
protected:
bool eventFilter(QObject *w, QEvent *e);
public:
QComboBox *ipv6ConfigCombox;
LineEdit *ipv6AddressEdit;
@ -67,6 +64,8 @@ private:
private slots:
void configChanged(int index);
void setEnableOfSaveBtn();
void onAddressTextChanged();
void onGatewayTextChanged();
signals:
void setIpv6PageState(bool);