Merge branch '2209bug-new' into 'yhkylin/v101'
fix bug 97863 添加有线网络界面输入框必填标识 输入无效提示 See merge request kylinos-src/kylin-nm!65
This commit is contained in:
commit
e1f1ef4f18
|
@ -21,6 +21,8 @@
|
|||
#include "math.h"
|
||||
|
||||
#define MAX_NAME_LENGTH 32
|
||||
#define HINT_TEXT_MARGINS 8, 1, 0, 3
|
||||
#define LABEL_HEIGHT 24
|
||||
|
||||
CreatNetPage::CreatNetPage(QWidget *parent):QFrame(parent)
|
||||
{
|
||||
|
@ -47,6 +49,41 @@ void CreatNetPage::initUI()
|
|||
m_dnsLabel = new QLabel(this);
|
||||
m_secDnsLabel = new QLabel(this);
|
||||
|
||||
QLabel *nameEmptyLabel = new QLabel(this);
|
||||
QLabel *configEmptyLabel = new QLabel(this);
|
||||
QLabel *gateWayEmptyLabel = new QLabel(this);
|
||||
QLabel *firstDnsEmptyLabel = new QLabel(this);
|
||||
nameEmptyLabel->setFixedHeight(LABEL_HEIGHT);
|
||||
configEmptyLabel->setFixedHeight(LABEL_HEIGHT);
|
||||
gateWayEmptyLabel->setFixedHeight(LABEL_HEIGHT);
|
||||
firstDnsEmptyLabel->setFixedHeight(LABEL_HEIGHT);
|
||||
|
||||
m_addressHintLabel = new QLabel(this);
|
||||
m_maskHintLabel = new QLabel(this);
|
||||
m_addressHintLabel->setFixedHeight(LABEL_HEIGHT);
|
||||
m_maskHintLabel->setFixedHeight(LABEL_HEIGHT);
|
||||
m_addressHintLabel->setContentsMargins(HINT_TEXT_MARGINS);
|
||||
m_maskHintLabel->setContentsMargins(HINT_TEXT_MARGINS);
|
||||
|
||||
QPalette hintTextColor;
|
||||
hintTextColor.setColor(QPalette::WindowText, Qt::red);
|
||||
m_addressHintLabel->setPalette(hintTextColor);
|
||||
m_maskHintLabel->setPalette(hintTextColor);
|
||||
|
||||
QWidget *addressWidget = new QWidget(this);
|
||||
QVBoxLayout *addressLayout = new QVBoxLayout(addressWidget);
|
||||
addressLayout->setContentsMargins(0, 0, 0, 0);
|
||||
addressLayout->setSpacing(0);
|
||||
addressLayout->addWidget(ipv4addressEdit);
|
||||
addressLayout->addWidget(m_addressHintLabel);
|
||||
|
||||
QWidget *maskWidget = new QWidget(this);
|
||||
QVBoxLayout *maskLayout = new QVBoxLayout(maskWidget);
|
||||
maskLayout->setContentsMargins(0, 0, 0, 0);
|
||||
maskLayout->setSpacing(0);
|
||||
maskLayout->addWidget(netMaskEdit);
|
||||
maskLayout->addWidget(m_maskHintLabel);
|
||||
|
||||
m_connNameLabel->setText(tr("Connection Name"));
|
||||
m_configLabel->setText(tr("IPv4Config"));
|
||||
m_addressLabel->setText(tr("Address"));
|
||||
|
@ -56,12 +93,18 @@ void CreatNetPage::initUI()
|
|||
m_secDnsLabel->setText(tr("Alternative DNS"));
|
||||
|
||||
m_detailLayout = new QFormLayout(this);
|
||||
m_detailLayout->setVerticalSpacing(0);
|
||||
m_detailLayout->setContentsMargins(0, 0, 0, 0);
|
||||
m_detailLayout->addRow(m_connNameLabel,connNameEdit);
|
||||
m_detailLayout->addRow(nameEmptyLabel);
|
||||
m_detailLayout->addRow(m_configLabel,ipv4ConfigCombox);
|
||||
m_detailLayout->addRow(m_addressLabel,ipv4addressEdit);
|
||||
m_detailLayout->addRow(m_maskLabel,netMaskEdit);
|
||||
m_detailLayout->addRow(configEmptyLabel);
|
||||
m_detailLayout->addRow(m_addressLabel, addressWidget);
|
||||
m_detailLayout->addRow(m_maskLabel, maskWidget);
|
||||
m_detailLayout->addRow(m_gateWayLabel,gateWayEdit);
|
||||
m_detailLayout->addRow(gateWayEmptyLabel);
|
||||
m_detailLayout->addRow(m_dnsLabel,firstDnsEdit);
|
||||
m_detailLayout->addRow(firstDnsEmptyLabel);
|
||||
m_detailLayout->addRow(m_secDnsLabel,secondDnsEdit);
|
||||
|
||||
ipv4ConfigCombox->addItem(tr("Auto(DHCP)"), AUTO_CONFIG); //"自动(DHCP)"
|
||||
|
@ -92,6 +135,9 @@ void CreatNetPage::initComponent() {
|
|||
connect(gateWayEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn()));
|
||||
connect(firstDnsEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn()));
|
||||
connect(secondDnsEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn()));
|
||||
|
||||
connect(ipv4addressEdit, SIGNAL(textChanged(QString)), this, SLOT(onAddressTextChanged()));
|
||||
connect(netMaskEdit, SIGNAL(textChanged(QString)), this, SLOT(onNetMaskTextChanged()));
|
||||
}
|
||||
|
||||
bool CreatNetPage::checkConnectBtnIsEnabled()
|
||||
|
@ -146,6 +192,24 @@ void CreatNetPage::configChanged(int index) {
|
|||
}
|
||||
}
|
||||
|
||||
void CreatNetPage::onAddressTextChanged()
|
||||
{
|
||||
if (!getTextEditState(ipv4addressEdit->text())) {
|
||||
m_addressHintLabel->setText(tr("Invalid address"));
|
||||
} else {
|
||||
m_addressHintLabel->clear();
|
||||
}
|
||||
}
|
||||
|
||||
void CreatNetPage::onNetMaskTextChanged()
|
||||
{
|
||||
if (!netMaskIsValide(netMaskEdit->text())) {
|
||||
m_maskHintLabel->setText(tr("Invalid subnet mask"));
|
||||
} else {
|
||||
m_maskHintLabel->clear();
|
||||
}
|
||||
}
|
||||
|
||||
void CreatNetPage::setLineEnabled(bool check) {
|
||||
|
||||
ipv4addressEdit->setEnabled(check);
|
||||
|
@ -160,6 +224,12 @@ void CreatNetPage::setLineEnabled(bool check) {
|
|||
gateWayEdit->clear();
|
||||
firstDnsEdit->clear();
|
||||
secondDnsEdit->clear();
|
||||
|
||||
ipv4addressEdit->setPlaceholderText(" ");
|
||||
netMaskEdit->setPlaceholderText(" ");
|
||||
} else {
|
||||
ipv4addressEdit->setPlaceholderText(tr("Required")); //必填
|
||||
netMaskEdit->setPlaceholderText(tr("Required")); //必填
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -59,6 +59,9 @@ private:
|
|||
QLabel *m_gateWayLabel;
|
||||
QLabel *m_dnsLabel;
|
||||
QLabel *m_secDnsLabel;
|
||||
|
||||
QLabel *m_addressHintLabel;
|
||||
QLabel *m_maskHintLabel;
|
||||
private:
|
||||
void initUI();
|
||||
void initComponent();
|
||||
|
@ -73,6 +76,9 @@ private:
|
|||
private Q_SLOTS:
|
||||
void setEnableOfSaveBtn();
|
||||
void configChanged(int index);
|
||||
void onAddressTextChanged();
|
||||
void onNetMaskTextChanged();
|
||||
|
||||
Q_SIGNALS:
|
||||
void setCreatePageState(bool);
|
||||
|
||||
|
|
Binary file not shown.
|
@ -125,6 +125,22 @@
|
|||
<source>Manual</source>
|
||||
<translation>ལག་དེབ།</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/frontend/netdetails/creatnetpage.cpp" line="198"/>
|
||||
<source>Invalid address</source>
|
||||
<translation>རྩིས་འགྲོ་མེད་པའི་ས་གནས།</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/frontend/netdetails/creatnetpage.cpp" line="207"/>
|
||||
<source>Invalid subnet mask</source>
|
||||
<translation>རྩིས་འགྲོ་མེད་པའི་དྲ་བ་འགེབས་སྲུང་བྱེད་པ།</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/frontend/netdetails/creatnetpage.cpp" line="231"/>
|
||||
<location filename="../src/frontend/netdetails/creatnetpage.cpp" line="232"/>
|
||||
<source>Required</source>
|
||||
<translation>ངེས་པར་དུ་སྐོང་དགོས།</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>DetailPage</name>
|
||||
|
|
Binary file not shown.
|
@ -125,6 +125,22 @@
|
|||
<source>Manual</source>
|
||||
<translation>手动</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/frontend/netdetails/creatnetpage.cpp" line="198"/>
|
||||
<source>Invalid address</source>
|
||||
<translation>无效地址</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/frontend/netdetails/creatnetpage.cpp" line="207"/>
|
||||
<source>Invalid subnet mask</source>
|
||||
<translation>无效子网掩码</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/frontend/netdetails/creatnetpage.cpp" line="231"/>
|
||||
<location filename="../src/frontend/netdetails/creatnetpage.cpp" line="232"/>
|
||||
<source>Required</source>
|
||||
<translation>必填</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>DetailPage</name>
|
||||
|
|
Loading…
Reference in New Issue