fix bug 126830 手动修改IP冲突提示优化
This commit is contained in:
parent
7e4e90d371
commit
bafaa206e2
|
@ -25,6 +25,8 @@
|
||||||
#define LAYOUT_SPACING 0
|
#define LAYOUT_SPACING 0
|
||||||
#define HINT_TEXT_MARGINS 8, 1, 0, 3
|
#define HINT_TEXT_MARGINS 8, 1, 0, 3
|
||||||
#define LABEL_HEIGHT 24
|
#define LABEL_HEIGHT 24
|
||||||
|
#define FRAME_SPEED 150
|
||||||
|
#define ICON_SIZE 16,16
|
||||||
|
|
||||||
Ipv4Page::Ipv4Page(QWidget *parent):QFrame(parent)
|
Ipv4Page::Ipv4Page(QWidget *parent):QFrame(parent)
|
||||||
{
|
{
|
||||||
|
@ -53,6 +55,7 @@ void Ipv4Page::initUI() {
|
||||||
m_addressHintLabel = new QLabel(this);
|
m_addressHintLabel = new QLabel(this);
|
||||||
m_addressHintLabel->setFixedHeight(LABEL_HEIGHT);
|
m_addressHintLabel->setFixedHeight(LABEL_HEIGHT);
|
||||||
m_addressHintLabel->setContentsMargins(HINT_TEXT_MARGINS);
|
m_addressHintLabel->setContentsMargins(HINT_TEXT_MARGINS);
|
||||||
|
initConflictHintLable();
|
||||||
|
|
||||||
m_maskHintLabel = new QLabel(this);
|
m_maskHintLabel = new QLabel(this);
|
||||||
m_maskHintLabel->setFixedHeight(LABEL_HEIGHT);
|
m_maskHintLabel->setFixedHeight(LABEL_HEIGHT);
|
||||||
|
@ -72,6 +75,12 @@ void Ipv4Page::initUI() {
|
||||||
m_dnsLabel->setText(tr("Prefs DNS"));
|
m_dnsLabel->setText(tr("Prefs DNS"));
|
||||||
m_secDnsLabel->setText(tr("Alternative DNS"));
|
m_secDnsLabel->setText(tr("Alternative DNS"));
|
||||||
|
|
||||||
|
m_statusLabel = new QLabel(this);
|
||||||
|
m_statusLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
||||||
|
QHBoxLayout *pPwdLayout = new QHBoxLayout(ipv4addressEdit);
|
||||||
|
pPwdLayout->addStretch();
|
||||||
|
pPwdLayout->addWidget(m_statusLabel);
|
||||||
|
|
||||||
QPalette hintTextColor;
|
QPalette hintTextColor;
|
||||||
hintTextColor.setColor(QPalette::WindowText, Qt::red);
|
hintTextColor.setColor(QPalette::WindowText, Qt::red);
|
||||||
m_addressHintLabel->setPalette(hintTextColor);
|
m_addressHintLabel->setPalette(hintTextColor);
|
||||||
|
@ -123,6 +132,8 @@ void Ipv4Page::initUI() {
|
||||||
netMaskEdit->setValidator(new QRegExpValidator(rx, this));
|
netMaskEdit->setValidator(new QRegExpValidator(rx, this));
|
||||||
firstDnsEdit->setValidator(new QRegExpValidator(rx, this));
|
firstDnsEdit->setValidator(new QRegExpValidator(rx, this));
|
||||||
secondDnsEdit->setValidator(new QRegExpValidator(rx, this));
|
secondDnsEdit->setValidator(new QRegExpValidator(rx, this));
|
||||||
|
|
||||||
|
initLoadingIcon();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Ipv4Page::initComponent() {
|
void Ipv4Page::initComponent() {
|
||||||
|
@ -134,6 +145,7 @@ void Ipv4Page::initComponent() {
|
||||||
connect(ipv4ConfigCombox, SIGNAL(currentIndexChanged(int)), this, SLOT(configChanged(int)));
|
connect(ipv4ConfigCombox, SIGNAL(currentIndexChanged(int)), this, SLOT(configChanged(int)));
|
||||||
|
|
||||||
connect(ipv4addressEdit, SIGNAL(textChanged(QString)), this, SLOT(onAddressTextChanged()));
|
connect(ipv4addressEdit, SIGNAL(textChanged(QString)), this, SLOT(onAddressTextChanged()));
|
||||||
|
connect(ipv4addressEdit, SIGNAL(editingFinished()), this, SLOT(onAddressEidtFinished()));
|
||||||
connect(netMaskEdit, SIGNAL(textChanged(QString)), this, SLOT(onNetMaskTextChanged()));
|
connect(netMaskEdit, SIGNAL(textChanged(QString)), this, SLOT(onNetMaskTextChanged()));
|
||||||
|
|
||||||
connect(ipv4ConfigCombox, SIGNAL(currentIndexChanged(int)), this, SLOT(setEnableOfSaveBtn()));
|
connect(ipv4ConfigCombox, SIGNAL(currentIndexChanged(int)), this, SLOT(setEnableOfSaveBtn()));
|
||||||
|
@ -280,8 +292,12 @@ void Ipv4Page::configChanged(int index) {
|
||||||
void Ipv4Page::onAddressTextChanged()
|
void Ipv4Page::onAddressTextChanged()
|
||||||
{
|
{
|
||||||
if (!getTextEditState(ipv4addressEdit->text())) {
|
if (!getTextEditState(ipv4addressEdit->text())) {
|
||||||
|
m_iconLabel->hide();
|
||||||
|
m_textLabel->hide();
|
||||||
m_addressHintLabel->setText(tr("Invalid address"));
|
m_addressHintLabel->setText(tr("Invalid address"));
|
||||||
} else {
|
} else {
|
||||||
|
m_iconLabel->hide();
|
||||||
|
m_textLabel->hide();
|
||||||
m_addressHintLabel->clear();
|
m_addressHintLabel->clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -295,6 +311,15 @@ void Ipv4Page::onNetMaskTextChanged()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Ipv4Page::onAddressEidtFinished()
|
||||||
|
{
|
||||||
|
if (ipv4addressEdit->isModified()) {
|
||||||
|
if (!ipv4addressEdit->text().isEmpty() && getTextEditState(ipv4addressEdit->text())) {
|
||||||
|
Q_EMIT ipv4EditFinished(ipv4addressEdit->text());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Ipv4Page::setLineEnabled(bool check) {
|
void Ipv4Page::setLineEnabled(bool check) {
|
||||||
|
|
||||||
if (!check) {
|
if (!check) {
|
||||||
|
@ -372,3 +397,65 @@ QString Ipv4Page::getNetMaskText(QString text)
|
||||||
}
|
}
|
||||||
return QString("%1.%2.%3.%4").arg(list[0],list[1],list[2],list[3]);
|
return QString("%1.%2.%3.%4").arg(list[0],list[1],list[2],list[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Ipv4Page::initConflictHintLable()
|
||||||
|
{
|
||||||
|
QIcon icon = QIcon::fromTheme("dialog-warning");
|
||||||
|
m_iconLabel = new QLabel(m_addressHintLabel);
|
||||||
|
m_iconLabel->setPixmap(icon.pixmap(ICON_SIZE));
|
||||||
|
m_textLabel = new QLabel(m_addressHintLabel);
|
||||||
|
m_textLabel->setText(tr("Address conflict"));
|
||||||
|
QHBoxLayout *conflictHintLayout = new QHBoxLayout();
|
||||||
|
conflictHintLayout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
conflictHintLayout->addWidget(m_iconLabel);
|
||||||
|
conflictHintLayout->addWidget(m_textLabel);
|
||||||
|
conflictHintLayout->addStretch();
|
||||||
|
m_addressHintLabel->setLayout(conflictHintLayout);
|
||||||
|
m_iconLabel->hide();
|
||||||
|
m_textLabel->hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Ipv4Page::initLoadingIcon()
|
||||||
|
{
|
||||||
|
m_loadIcons.append(QIcon::fromTheme("ukui-loading-1-symbolic"));
|
||||||
|
m_loadIcons.append(QIcon::fromTheme("ukui-loading-2-symbolic"));
|
||||||
|
m_loadIcons.append(QIcon::fromTheme("ukui-loading-3-symbolic"));
|
||||||
|
m_loadIcons.append(QIcon::fromTheme("ukui-loading-4-symbolic"));
|
||||||
|
m_loadIcons.append(QIcon::fromTheme("ukui-loading-5-symbolic"));
|
||||||
|
m_loadIcons.append(QIcon::fromTheme("ukui-loading-6-symbolic"));
|
||||||
|
m_loadIcons.append(QIcon::fromTheme("ukui-loading-7-symbolic"));
|
||||||
|
m_iconTimer = new QTimer(this);
|
||||||
|
connect(m_iconTimer, &QTimer::timeout, this, &Ipv4Page::updateIcon);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Ipv4Page::updateIcon()
|
||||||
|
{
|
||||||
|
if (m_currentIconIndex > 6) {
|
||||||
|
m_currentIconIndex = 0;
|
||||||
|
}
|
||||||
|
m_statusLabel->setPixmap(m_loadIcons.at(m_currentIconIndex).pixmap(ICON_SIZE));
|
||||||
|
m_currentIconIndex ++;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Ipv4Page::startLoading()
|
||||||
|
{
|
||||||
|
m_iconTimer->start(FRAME_SPEED);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Ipv4Page::stopLoading()
|
||||||
|
{
|
||||||
|
m_iconTimer->stop();
|
||||||
|
m_statusLabel->clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Ipv4Page::showIpv4AddressConflict(bool isConflict)
|
||||||
|
{
|
||||||
|
if (isConflict) {
|
||||||
|
m_iconLabel->show();
|
||||||
|
m_textLabel->show();
|
||||||
|
} else {
|
||||||
|
m_iconLabel->hide();
|
||||||
|
m_textLabel->hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -48,6 +48,10 @@ public:
|
||||||
|
|
||||||
bool checkIsChanged(const ConInfo info, KyConnectSetting &setting);
|
bool checkIsChanged(const ConInfo info, KyConnectSetting &setting);
|
||||||
|
|
||||||
|
void startLoading();
|
||||||
|
void stopLoading();
|
||||||
|
void showIpv4AddressConflict(bool isConflict);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QComboBox *ipv4ConfigCombox;
|
QComboBox *ipv4ConfigCombox;
|
||||||
LineEdit *ipv4addressEdit;
|
LineEdit *ipv4addressEdit;
|
||||||
|
@ -56,7 +60,6 @@ private:
|
||||||
LineEdit *firstDnsEdit;
|
LineEdit *firstDnsEdit;
|
||||||
LineEdit *secondDnsEdit;
|
LineEdit *secondDnsEdit;
|
||||||
|
|
||||||
private:
|
|
||||||
QFormLayout *m_detailLayout;
|
QFormLayout *m_detailLayout;
|
||||||
QVBoxLayout *mvBoxLayout;
|
QVBoxLayout *mvBoxLayout;
|
||||||
QLabel *m_configLabel;
|
QLabel *m_configLabel;
|
||||||
|
@ -71,6 +74,15 @@ private:
|
||||||
QLabel *m_maskHintLabel;
|
QLabel *m_maskHintLabel;
|
||||||
QLabel *m_gateWayEmptyLabel;
|
QLabel *m_gateWayEmptyLabel;
|
||||||
QLabel *m_firstDnsEmptyLabel;
|
QLabel *m_firstDnsEmptyLabel;
|
||||||
|
|
||||||
|
QLabel *m_statusLabel = nullptr;
|
||||||
|
QList<QIcon> m_loadIcons;
|
||||||
|
QTimer *m_iconTimer = nullptr;
|
||||||
|
int m_currentIconIndex =0;
|
||||||
|
|
||||||
|
QLabel *m_iconLabel;
|
||||||
|
QLabel *m_textLabel;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void initUI();
|
void initUI();
|
||||||
void initComponent();
|
void initComponent();
|
||||||
|
@ -80,17 +92,20 @@ private:
|
||||||
bool netMaskIsValide(QString text);
|
bool netMaskIsValide(QString text);
|
||||||
QString getNetMaskText(QString text);
|
QString getNetMaskText(QString text);
|
||||||
bool checkConnectBtnIsEnabled();
|
bool checkConnectBtnIsEnabled();
|
||||||
|
void initConflictHintLable();
|
||||||
|
void initLoadingIcon();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void setEnableOfSaveBtn();
|
void setEnableOfSaveBtn();
|
||||||
void configChanged(int index);
|
void configChanged(int index);
|
||||||
void onAddressTextChanged();
|
void onAddressTextChanged();
|
||||||
void onNetMaskTextChanged();
|
void onNetMaskTextChanged();
|
||||||
|
void onAddressEidtFinished();
|
||||||
|
void updateIcon();
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void setIpv4PageState(bool);
|
void setIpv4PageState(bool);
|
||||||
|
void ipv4EditFinished(const QString &address);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // IPV4PAGE_H
|
#endif // IPV4PAGE_H
|
||||||
|
|
|
@ -24,6 +24,8 @@
|
||||||
#define LAYOUT_SPACING 0
|
#define LAYOUT_SPACING 0
|
||||||
#define HINT_TEXT_MARGINS 8, 1, 0, 3
|
#define HINT_TEXT_MARGINS 8, 1, 0, 3
|
||||||
#define LABEL_HEIGHT 24
|
#define LABEL_HEIGHT 24
|
||||||
|
#define FRAME_SPEED 150
|
||||||
|
#define ICON_SIZE 16,16
|
||||||
|
|
||||||
Ipv6Page::Ipv6Page(QWidget *parent):QFrame(parent)
|
Ipv6Page::Ipv6Page(QWidget *parent):QFrame(parent)
|
||||||
{
|
{
|
||||||
|
@ -134,6 +136,7 @@ void Ipv6Page::initUI() {
|
||||||
m_addressHintLabel = new QLabel(this);
|
m_addressHintLabel = new QLabel(this);
|
||||||
m_addressHintLabel->setFixedHeight(LABEL_HEIGHT);
|
m_addressHintLabel->setFixedHeight(LABEL_HEIGHT);
|
||||||
m_addressHintLabel->setContentsMargins(HINT_TEXT_MARGINS);
|
m_addressHintLabel->setContentsMargins(HINT_TEXT_MARGINS);
|
||||||
|
initConflictHintLable();
|
||||||
|
|
||||||
m_gateWayHintLabel = new QLabel(this);
|
m_gateWayHintLabel = new QLabel(this);
|
||||||
m_gateWayHintLabel->setFixedHeight(LABEL_HEIGHT);
|
m_gateWayHintLabel->setFixedHeight(LABEL_HEIGHT);
|
||||||
|
@ -153,6 +156,12 @@ void Ipv6Page::initUI() {
|
||||||
m_dnsLabel->setText(tr("Prefs DNS"));
|
m_dnsLabel->setText(tr("Prefs DNS"));
|
||||||
m_secDnsLabel->setText(tr("Alternative DNS"));
|
m_secDnsLabel->setText(tr("Alternative DNS"));
|
||||||
|
|
||||||
|
m_statusLabel = new QLabel(this);
|
||||||
|
m_statusLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
||||||
|
QHBoxLayout *pPwdLayout = new QHBoxLayout(ipv6AddressEdit);
|
||||||
|
pPwdLayout->addStretch();
|
||||||
|
pPwdLayout->addWidget(m_statusLabel);
|
||||||
|
|
||||||
QPalette hintTextColor;
|
QPalette hintTextColor;
|
||||||
hintTextColor.setColor(QPalette::WindowText, Qt::red);
|
hintTextColor.setColor(QPalette::WindowText, Qt::red);
|
||||||
m_addressHintLabel->setPalette(hintTextColor);
|
m_addressHintLabel->setPalette(hintTextColor);
|
||||||
|
@ -196,6 +205,8 @@ void Ipv6Page::initUI() {
|
||||||
|
|
||||||
QRegExp prefix_rx("\\b(?:(?:12[0-8]|1[0-1][0-9]|^[1-9][0-9]?$)\\.){3}(?:12[0-8]|1[0-1][0-9]|^[1-9][0-9]?$)\\b");
|
QRegExp prefix_rx("\\b(?:(?:12[0-8]|1[0-1][0-9]|^[1-9][0-9]?$)\\.){3}(?:12[0-8]|1[0-1][0-9]|^[1-9][0-9]?$)\\b");
|
||||||
lengthEdit->setValidator(new QRegExpValidator(prefix_rx,this));
|
lengthEdit->setValidator(new QRegExpValidator(prefix_rx,this));
|
||||||
|
|
||||||
|
initLoadingIcon();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Ipv6Page::initComponent() {
|
void Ipv6Page::initComponent() {
|
||||||
|
@ -207,6 +218,7 @@ void Ipv6Page::initComponent() {
|
||||||
connect(ipv6ConfigCombox, SIGNAL(currentIndexChanged(int)), this, SLOT(configChanged(int)));
|
connect(ipv6ConfigCombox, SIGNAL(currentIndexChanged(int)), this, SLOT(configChanged(int)));
|
||||||
|
|
||||||
connect(ipv6AddressEdit, SIGNAL(textChanged(QString)), this, SLOT(onAddressTextChanged()));
|
connect(ipv6AddressEdit, SIGNAL(textChanged(QString)), this, SLOT(onAddressTextChanged()));
|
||||||
|
connect(ipv6AddressEdit, SIGNAL(editingFinished()), this, SLOT(onAddressEidtFinished()));
|
||||||
connect(gateWayEdit, SIGNAL(textChanged(QString)), this, SLOT(onGatewayTextChanged()));
|
connect(gateWayEdit, SIGNAL(textChanged(QString)), this, SLOT(onGatewayTextChanged()));
|
||||||
|
|
||||||
connect(ipv6ConfigCombox, SIGNAL(currentIndexChanged(int)), this, SLOT(setEnableOfSaveBtn()));
|
connect(ipv6ConfigCombox, SIGNAL(currentIndexChanged(int)), this, SLOT(setEnableOfSaveBtn()));
|
||||||
|
@ -259,8 +271,12 @@ void Ipv6Page::setEnableOfSaveBtn()
|
||||||
void Ipv6Page::onAddressTextChanged()
|
void Ipv6Page::onAddressTextChanged()
|
||||||
{
|
{
|
||||||
if (!getIpv6EditState(ipv6AddressEdit->text())) {
|
if (!getIpv6EditState(ipv6AddressEdit->text())) {
|
||||||
|
m_iconLabel->hide();
|
||||||
|
m_textLabel->hide();
|
||||||
m_addressHintLabel->setText(tr("Invalid address"));
|
m_addressHintLabel->setText(tr("Invalid address"));
|
||||||
} else {
|
} else {
|
||||||
|
m_iconLabel->hide();
|
||||||
|
m_textLabel->hide();
|
||||||
m_addressHintLabel->clear();
|
m_addressHintLabel->clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -274,6 +290,15 @@ void Ipv6Page::onGatewayTextChanged()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Ipv6Page::onAddressEidtFinished()
|
||||||
|
{
|
||||||
|
if (ipv6AddressEdit->isModified()) {
|
||||||
|
if (!ipv6AddressEdit->text().isEmpty() && getIpv6EditState(ipv6AddressEdit->text())) {
|
||||||
|
Q_EMIT ipv6EditFinished(ipv6AddressEdit->text());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool Ipv6Page::checkConnectBtnIsEnabled()
|
bool Ipv6Page::checkConnectBtnIsEnabled()
|
||||||
{
|
{
|
||||||
if (ipv6ConfigCombox->currentIndex() == AUTO_CONFIG) {
|
if (ipv6ConfigCombox->currentIndex() == AUTO_CONFIG) {
|
||||||
|
@ -312,6 +337,23 @@ bool Ipv6Page::checkConnectBtnIsEnabled()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Ipv6Page::initConflictHintLable()
|
||||||
|
{
|
||||||
|
QIcon icon = QIcon::fromTheme("dialog-warning");
|
||||||
|
m_iconLabel = new QLabel(m_addressHintLabel);
|
||||||
|
m_iconLabel->setPixmap(icon.pixmap(ICON_SIZE));
|
||||||
|
m_textLabel = new QLabel(m_addressHintLabel);
|
||||||
|
m_textLabel->setText(tr("Address conflict"));
|
||||||
|
QHBoxLayout *conflictHintLayout = new QHBoxLayout();
|
||||||
|
conflictHintLayout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
conflictHintLayout->addWidget(m_iconLabel);
|
||||||
|
conflictHintLayout->addWidget(m_textLabel);
|
||||||
|
conflictHintLayout->addStretch();
|
||||||
|
m_addressHintLabel->setLayout(conflictHintLayout);
|
||||||
|
m_iconLabel->hide();
|
||||||
|
m_textLabel->hide();
|
||||||
|
}
|
||||||
|
|
||||||
bool Ipv6Page::getIpv6EditState(QString text)
|
bool Ipv6Page::getIpv6EditState(QString text)
|
||||||
{
|
{
|
||||||
if (text.isEmpty()) {
|
if (text.isEmpty()) {
|
||||||
|
@ -348,3 +390,47 @@ int Ipv6Page::getPerfixLength(QString text)
|
||||||
return length;
|
return length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Ipv6Page::initLoadingIcon()
|
||||||
|
{
|
||||||
|
m_loadIcons.append(QIcon::fromTheme("ukui-loading-1-symbolic"));
|
||||||
|
m_loadIcons.append(QIcon::fromTheme("ukui-loading-2-symbolic"));
|
||||||
|
m_loadIcons.append(QIcon::fromTheme("ukui-loading-3-symbolic"));
|
||||||
|
m_loadIcons.append(QIcon::fromTheme("ukui-loading-4-symbolic"));
|
||||||
|
m_loadIcons.append(QIcon::fromTheme("ukui-loading-5-symbolic"));
|
||||||
|
m_loadIcons.append(QIcon::fromTheme("ukui-loading-6-symbolic"));
|
||||||
|
m_loadIcons.append(QIcon::fromTheme("ukui-loading-7-symbolic"));
|
||||||
|
m_iconTimer = new QTimer(this);
|
||||||
|
connect(m_iconTimer, &QTimer::timeout, this, &Ipv6Page::updateIcon);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Ipv6Page::updateIcon()
|
||||||
|
{
|
||||||
|
if (m_currentIconIndex > 6) {
|
||||||
|
m_currentIconIndex = 0;
|
||||||
|
}
|
||||||
|
m_statusLabel->setPixmap(m_loadIcons.at(m_currentIconIndex).pixmap(ICON_SIZE));
|
||||||
|
m_currentIconIndex ++;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Ipv6Page::startLoading()
|
||||||
|
{
|
||||||
|
m_iconTimer->start(FRAME_SPEED);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Ipv6Page::stopLoading()
|
||||||
|
{
|
||||||
|
m_iconTimer->stop();
|
||||||
|
m_statusLabel->clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Ipv6Page::showIpv6AddressConflict(bool isConflict)
|
||||||
|
{
|
||||||
|
if (isConflict) {
|
||||||
|
m_iconLabel->show();
|
||||||
|
m_textLabel->show();
|
||||||
|
} else {
|
||||||
|
m_iconLabel->hide();
|
||||||
|
m_textLabel->hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,6 +50,10 @@ public:
|
||||||
|
|
||||||
int getPerfixLength(QString text);
|
int getPerfixLength(QString text);
|
||||||
|
|
||||||
|
void startLoading();
|
||||||
|
void stopLoading();
|
||||||
|
void showIpv6AddressConflict(bool isConflict);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QComboBox *ipv6ConfigCombox;
|
QComboBox *ipv6ConfigCombox;
|
||||||
LineEdit *ipv6AddressEdit;
|
LineEdit *ipv6AddressEdit;
|
||||||
|
@ -71,6 +75,14 @@ private:
|
||||||
QLabel *m_subnetEmptyLabel;
|
QLabel *m_subnetEmptyLabel;
|
||||||
QLabel *m_gateWayHintLabel;
|
QLabel *m_gateWayHintLabel;
|
||||||
QLabel *m_firstDnsEmptyLabel;
|
QLabel *m_firstDnsEmptyLabel;
|
||||||
|
|
||||||
|
QLabel *m_statusLabel = nullptr;
|
||||||
|
QList<QIcon> m_loadIcons;
|
||||||
|
QTimer *m_iconTimer = nullptr;
|
||||||
|
int m_currentIconIndex =0;
|
||||||
|
|
||||||
|
QLabel *m_iconLabel;
|
||||||
|
QLabel *m_textLabel;
|
||||||
private:
|
private:
|
||||||
void initUI();
|
void initUI();
|
||||||
void initComponent();
|
void initComponent();
|
||||||
|
@ -80,14 +92,20 @@ private:
|
||||||
|
|
||||||
bool checkConnectBtnIsEnabled();
|
bool checkConnectBtnIsEnabled();
|
||||||
|
|
||||||
|
void initConflictHintLable();
|
||||||
|
void initLoadingIcon();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void configChanged(int index);
|
void configChanged(int index);
|
||||||
void setEnableOfSaveBtn();
|
void setEnableOfSaveBtn();
|
||||||
void onAddressTextChanged();
|
void onAddressTextChanged();
|
||||||
void onGatewayTextChanged();
|
void onGatewayTextChanged();
|
||||||
|
void onAddressEidtFinished();
|
||||||
|
void updateIcon();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void setIpv6PageState(bool);
|
void setIpv6PageState(bool);
|
||||||
|
void ipv6EditFinished(const QString &address);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // IPV6PAGE_H
|
#endif // IPV6PAGE_H
|
||||||
|
|
|
@ -89,6 +89,37 @@ void NetDetail::setNetdetailSomeEnable(bool on)
|
||||||
confimBtn->setEnabled(on);
|
confimBtn->setEnabled(on);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NetDetail::startObjectThread()
|
||||||
|
{
|
||||||
|
m_objectThread = new QThread();
|
||||||
|
m_object = new ThreadObject(m_deviceName);
|
||||||
|
m_object->moveToThread(m_objectThread);
|
||||||
|
connect(m_objectThread, &QThread::finished, m_objectThread, &QObject::deleteLater);
|
||||||
|
connect(m_objectThread, &QThread::finished, m_object, &QObject::deleteLater);
|
||||||
|
connect(ipv4Page, &Ipv4Page::ipv4EditFinished, this, [=](){
|
||||||
|
ipv4Page->startLoading();
|
||||||
|
});
|
||||||
|
connect(ipv6Page, &Ipv6Page::ipv6EditFinished, this, [=](){
|
||||||
|
ipv6Page->startLoading();
|
||||||
|
});
|
||||||
|
|
||||||
|
connect(ipv4Page, SIGNAL(ipv4EditFinished(const QString &)), m_object, SLOT(checkIpv4ConflictThread(const QString &)));
|
||||||
|
connect(ipv6Page, SIGNAL(ipv6EditFinished(const QString &)), m_object, SLOT(checkIpv6ConflictThread(const QString &)));
|
||||||
|
connect(this, SIGNAL(checkCurrentIpv4Conflict(const QString &)), m_object, SLOT(checkIpv4ConflictThread(const QString &)));
|
||||||
|
connect(this, SIGNAL(checkCurrentIpv6Conflict(const QString &)), m_object, SLOT(checkIpv6ConflictThread(const QString &)));
|
||||||
|
|
||||||
|
connect(m_object, &ThreadObject::ipv4IsConflict, this, [=](bool ipv4IsConf) {
|
||||||
|
ipv4Page->stopLoading();
|
||||||
|
ipv4Page->showIpv4AddressConflict(ipv4IsConf);
|
||||||
|
});
|
||||||
|
connect(m_object, &ThreadObject::ipv6IsConflict, this, [=](bool ipv6IsConf) {
|
||||||
|
ipv6Page->stopLoading();
|
||||||
|
ipv6Page->showIpv6AddressConflict(ipv6IsConf);
|
||||||
|
});
|
||||||
|
|
||||||
|
m_objectThread->start();
|
||||||
|
}
|
||||||
|
|
||||||
NetDetail::NetDetail(QString interface, QString name, QString uuid, bool isActive, bool isWlan, bool isCreateNet, QWidget *parent)
|
NetDetail::NetDetail(QString interface, QString name, QString uuid, bool isActive, bool isWlan, bool isCreateNet, QWidget *parent)
|
||||||
:m_deviceName(interface),
|
:m_deviceName(interface),
|
||||||
m_name(name),
|
m_name(name),
|
||||||
|
@ -130,6 +161,7 @@ NetDetail::NetDetail(QString interface, QString name, QString uuid, bool isActiv
|
||||||
loadPage();
|
loadPage();
|
||||||
initComponent();
|
initComponent();
|
||||||
getConInfo(m_info);
|
getConInfo(m_info);
|
||||||
|
startObjectThread();
|
||||||
pagePadding(name,isWlan);
|
pagePadding(name,isWlan);
|
||||||
|
|
||||||
connect(qApp, &QApplication::paletteChanged, this, &NetDetail::onPaletteChanged);
|
connect(qApp, &QApplication::paletteChanged, this, &NetDetail::onPaletteChanged);
|
||||||
|
@ -150,7 +182,10 @@ NetDetail::NetDetail(QString interface, QString name, QString uuid, bool isActiv
|
||||||
|
|
||||||
NetDetail::~NetDetail()
|
NetDetail::~NetDetail()
|
||||||
{
|
{
|
||||||
|
if (m_objectThread->isRunning()) {
|
||||||
|
m_objectThread->quit();
|
||||||
|
m_objectThread->wait();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetDetail::onPaletteChanged()
|
void NetDetail::onPaletteChanged()
|
||||||
|
@ -417,6 +452,7 @@ void NetDetail::pagePadding(QString netName, bool isWlan)
|
||||||
|
|
||||||
//ipv4页面填充
|
//ipv4页面填充
|
||||||
if (m_info.ipv4ConfigType == CONFIG_IP_MANUAL) {
|
if (m_info.ipv4ConfigType == CONFIG_IP_MANUAL) {
|
||||||
|
emit checkCurrentIpv4Conflict(m_info.strIPV4Address);
|
||||||
ipv4Page->setIpv4Config(m_info.ipv4ConfigType);
|
ipv4Page->setIpv4Config(m_info.ipv4ConfigType);
|
||||||
ipv4Page->setIpv4(m_info.strIPV4Address);
|
ipv4Page->setIpv4(m_info.strIPV4Address);
|
||||||
ipv4Page->setNetMask(m_info.strIPV4NetMask);
|
ipv4Page->setNetMask(m_info.strIPV4NetMask);
|
||||||
|
@ -428,6 +464,7 @@ void NetDetail::pagePadding(QString netName, bool isWlan)
|
||||||
}
|
}
|
||||||
//ipv6页面填充
|
//ipv6页面填充
|
||||||
if (m_info.ipv6ConfigType == CONFIG_IP_MANUAL) {
|
if (m_info.ipv6ConfigType == CONFIG_IP_MANUAL) {
|
||||||
|
emit checkCurrentIpv6Conflict(m_info.strIPV6Address);
|
||||||
ipv6Page->setIpv6Config(m_info.ipv6ConfigType);
|
ipv6Page->setIpv6Config(m_info.ipv6ConfigType);
|
||||||
ipv6Page->setIpv6(m_info.strIPV6Address);
|
ipv6Page->setIpv6(m_info.strIPV6Address);
|
||||||
ipv6Page->setIpv6Perfix(m_info.iIPV6Prefix);
|
ipv6Page->setIpv6Perfix(m_info.iIPV6Prefix);
|
||||||
|
@ -734,6 +771,7 @@ void NetDetail::setConfirmEnable()
|
||||||
confimBtn->setEnabled(isConfirmBtnEnable);
|
confimBtn->setEnabled(isConfirmBtnEnable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
bool NetDetail::checkIpv4Conflict(QString ipv4Address)
|
bool NetDetail::checkIpv4Conflict(QString ipv4Address)
|
||||||
{
|
{
|
||||||
showDesktopNotify(tr("start check ipv4 address conflict"), "networkwrong");
|
showDesktopNotify(tr("start check ipv4 address conflict"), "networkwrong");
|
||||||
|
@ -767,6 +805,7 @@ bool NetDetail::checkIpv6Conflict(QString ipv6address)
|
||||||
ipv46rping = nullptr;
|
ipv46rping = nullptr;
|
||||||
return isConflict;
|
return isConflict;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void NetDetail::updateWirelessPersonalConnect()
|
void NetDetail::updateWirelessPersonalConnect()
|
||||||
{
|
{
|
||||||
|
@ -796,13 +835,13 @@ bool NetDetail::createWiredConnect()
|
||||||
KyWirelessConnectSetting connetSetting;
|
KyWirelessConnectSetting connetSetting;
|
||||||
connetSetting.setIfaceName(m_deviceName);
|
connetSetting.setIfaceName(m_deviceName);
|
||||||
createNetPage->constructIpv4Info(connetSetting);
|
createNetPage->constructIpv4Info(connetSetting);
|
||||||
if (connetSetting.m_ipv4ConfigIpType != CONFIG_IP_DHCP) {
|
// if (connetSetting.m_ipv4ConfigIpType != CONFIG_IP_DHCP) {
|
||||||
if (checkIpv4Conflict(connetSetting.m_ipv4Address.at(0).ip().toString())) {
|
// if (checkIpv4Conflict(connetSetting.m_ipv4Address.at(0).ip().toString())) {
|
||||||
qDebug() << "ipv4 conflict";
|
// qDebug() << "ipv4 conflict";
|
||||||
showDesktopNotify(tr("ipv4 address conflict!"), "networkwrong");
|
// showDesktopNotify(tr("ipv4 address conflict!"), "networkwrong");
|
||||||
return false;
|
// return false;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
m_wiredConnOperation->createWiredConnect(connetSetting);
|
m_wiredConnOperation->createWiredConnect(connetSetting);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -847,21 +886,21 @@ bool NetDetail::createWirelessConnect()
|
||||||
connetSetting.dumpInfo();
|
connetSetting.dumpInfo();
|
||||||
|
|
||||||
qDebug() << "ipv4Changed" << ipv4Change << "ipv6Change" << ipv6Change;
|
qDebug() << "ipv4Changed" << ipv4Change << "ipv6Change" << ipv6Change;
|
||||||
if (ipv4Change && connetSetting.m_ipv4ConfigIpType == CONFIG_IP_MANUAL) {
|
// if (ipv4Change && connetSetting.m_ipv4ConfigIpType == CONFIG_IP_MANUAL) {
|
||||||
if (checkIpv4Conflict(connetSetting.m_ipv4Address.at(0).ip().toString())) {
|
// if (checkIpv4Conflict(connetSetting.m_ipv4Address.at(0).ip().toString())) {
|
||||||
qDebug() << "ipv4 conflict";
|
// qDebug() << "ipv4 conflict";
|
||||||
showDesktopNotify(tr("ipv4 address conflict!"), "networkwrong");
|
// showDesktopNotify(tr("ipv4 address conflict!"), "networkwrong");
|
||||||
return false;
|
// return false;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (ipv6Change && connetSetting.m_ipv6ConfigIpType == CONFIG_IP_MANUAL) {
|
// if (ipv6Change && connetSetting.m_ipv6ConfigIpType == CONFIG_IP_MANUAL) {
|
||||||
if (checkIpv6Conflict(connetSetting.m_ipv6Address.at(0).ip().toString())) {
|
// if (checkIpv6Conflict(connetSetting.m_ipv6Address.at(0).ip().toString())) {
|
||||||
qDebug() << "ipv6 conflict";
|
// qDebug() << "ipv6 conflict";
|
||||||
showDesktopNotify(tr("ipv6 address conflict!"), "networkwrong");
|
// showDesktopNotify(tr("ipv6 address conflict!"), "networkwrong");
|
||||||
return false;
|
// return false;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
//wifi安全性
|
//wifi安全性
|
||||||
if (secuType == WPA_AND_WPA2_ENTERPRISE) {
|
if (secuType == WPA_AND_WPA2_ENTERPRISE) {
|
||||||
connetSetting.m_type = WpaEap;
|
connetSetting.m_type = WpaEap;
|
||||||
|
@ -935,21 +974,21 @@ bool NetDetail::updateConnect()
|
||||||
|
|
||||||
qDebug() << "ipv4Changed" << ipv4Change << "ipv6Change" << ipv6Change;
|
qDebug() << "ipv4Changed" << ipv4Change << "ipv6Change" << ipv6Change;
|
||||||
|
|
||||||
if (ipv4Change && connetSetting.m_ipv4ConfigIpType == CONFIG_IP_MANUAL) {
|
// if (ipv4Change && connetSetting.m_ipv4ConfigIpType == CONFIG_IP_MANUAL) {
|
||||||
if (checkIpv4Conflict(connetSetting.m_ipv4Address.at(0).ip().toString())) {
|
// if (checkIpv4Conflict(connetSetting.m_ipv4Address.at(0).ip().toString())) {
|
||||||
qDebug() << "ipv4 conflict";
|
// qDebug() << "ipv4 conflict";
|
||||||
showDesktopNotify(tr("ipv4 address conflict!"), "networkwrong");
|
// showDesktopNotify(tr("ipv4 address conflict!"), "networkwrong");
|
||||||
return false;
|
// return false;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (ipv6Change && connetSetting.m_ipv6ConfigIpType == CONFIG_IP_MANUAL) {
|
// if (ipv6Change && connetSetting.m_ipv6ConfigIpType == CONFIG_IP_MANUAL) {
|
||||||
if (checkIpv6Conflict(connetSetting.m_ipv6Address.at(0).ip().toString())) {
|
// if (checkIpv6Conflict(connetSetting.m_ipv6Address.at(0).ip().toString())) {
|
||||||
qDebug() << "ipv6 conflict";
|
// qDebug() << "ipv6 conflict";
|
||||||
showDesktopNotify(tr("ipv6 address conflict!"), "networkwrong");
|
// showDesktopNotify(tr("ipv6 address conflict!"), "networkwrong");
|
||||||
return false;
|
// return false;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (ipv4Change || ipv6Change) {
|
if (ipv4Change || ipv6Change) {
|
||||||
connetSetting.dumpInfo();
|
connetSetting.dumpInfo();
|
||||||
|
@ -1053,3 +1092,57 @@ QSize NetTabBar::minimumTabSizeHint(int index) const
|
||||||
Q_UNUSED(index)
|
Q_UNUSED(index)
|
||||||
return QSize(TAB_WIDTH, TAB_HEIGHT);
|
return QSize(TAB_WIDTH, TAB_HEIGHT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ThreadObject::ThreadObject(QString deviceName, QObject *parent)
|
||||||
|
:m_devName(deviceName), QObject(parent)
|
||||||
|
{
|
||||||
|
m_isStop = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
ThreadObject::~ThreadObject()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void ThreadObject::stop()
|
||||||
|
{
|
||||||
|
m_isStop = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ThreadObject::checkIpv4ConflictThread(const QString &ipv4Address)
|
||||||
|
{
|
||||||
|
if (m_isStop) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
bool isConflict = false;
|
||||||
|
KyIpv4Arping* ipv4Arping = new KyIpv4Arping(m_devName, ipv4Address);
|
||||||
|
if (ipv4Arping->ipv4ConflictCheck() >= 0) {
|
||||||
|
isConflict = ipv4Arping->ipv4IsConflict();
|
||||||
|
} else {
|
||||||
|
qWarning() << "checkIpv4Conflict internal error";
|
||||||
|
}
|
||||||
|
|
||||||
|
delete ipv4Arping;
|
||||||
|
ipv4Arping = nullptr;
|
||||||
|
emit ipv4IsConflict(isConflict);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ThreadObject::checkIpv6ConflictThread(const QString &ipv6Address)
|
||||||
|
{
|
||||||
|
if (m_isStop) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
bool isConflict = false;
|
||||||
|
KyIpv6Arping* ipv6rping = new KyIpv6Arping(m_devName, ipv6Address);
|
||||||
|
|
||||||
|
if (ipv6rping->ipv6ConflictCheck() >= 0) {
|
||||||
|
isConflict = ipv6rping->ipv6IsConflict();
|
||||||
|
} else {
|
||||||
|
qWarning() << "checkIpv6Conflict internal error";
|
||||||
|
}
|
||||||
|
|
||||||
|
delete ipv6rping;
|
||||||
|
ipv6rping = nullptr;
|
||||||
|
emit ipv6IsConflict(isConflict);
|
||||||
|
}
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
|
#include <QThread>
|
||||||
|
|
||||||
#include <QDBusMessage>
|
#include <QDBusMessage>
|
||||||
#include <QDBusObjectPath>
|
#include <QDBusObjectPath>
|
||||||
|
@ -65,6 +66,25 @@ public:
|
||||||
QSize sizeHint() const;
|
QSize sizeHint() const;
|
||||||
QSize minimumTabSizeHint(int index) const;
|
QSize minimumTabSizeHint(int index) const;
|
||||||
};
|
};
|
||||||
|
class ThreadObject : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
ThreadObject(QString deviceName, QObject *parent = nullptr);
|
||||||
|
~ThreadObject();
|
||||||
|
void stop();
|
||||||
|
private:
|
||||||
|
QString m_devName;
|
||||||
|
volatile bool m_isStop;
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void checkIpv4ConflictThread(const QString &ipv4Address);
|
||||||
|
void checkIpv6ConflictThread(const QString &ipv6Address);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
bool ipv4IsConflict(bool isConflict);
|
||||||
|
bool ipv6IsConflict(bool isConflict);
|
||||||
|
};
|
||||||
|
|
||||||
class NetDetail : public QWidget
|
class NetDetail : public QWidget
|
||||||
{
|
{
|
||||||
|
@ -103,8 +123,8 @@ private:
|
||||||
|
|
||||||
void setConfirmEnable();
|
void setConfirmEnable();
|
||||||
|
|
||||||
bool checkIpv4Conflict(QString ipv4Address);
|
// bool checkIpv4Conflict(QString ipv4Address);
|
||||||
bool checkIpv6Conflict(QString ipv6Address);
|
// bool checkIpv6Conflict(QString ipv6Address);
|
||||||
|
|
||||||
bool createWiredConnect();
|
bool createWiredConnect();
|
||||||
bool createWirelessConnect();
|
bool createWirelessConnect();
|
||||||
|
@ -115,6 +135,8 @@ private:
|
||||||
void showDesktopNotify(const QString &message, QString soundName);
|
void showDesktopNotify(const QString &message, QString soundName);
|
||||||
|
|
||||||
void setNetdetailSomeEnable(bool on);
|
void setNetdetailSomeEnable(bool on);
|
||||||
|
void startObjectThread();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
KyNetworkDeviceResourse *m_netDeviceResource = nullptr;
|
KyNetworkDeviceResourse *m_netDeviceResource = nullptr;
|
||||||
KyConnectOperation* m_connectOperation = nullptr;
|
KyConnectOperation* m_connectOperation = nullptr;
|
||||||
|
@ -159,6 +181,9 @@ private:
|
||||||
|
|
||||||
ConInfo m_info;
|
ConInfo m_info;
|
||||||
|
|
||||||
|
ThreadObject *m_object;
|
||||||
|
QThread *m_objectThread;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_btnConfirm_clicked();
|
void on_btnConfirm_clicked();
|
||||||
void on_btnForget_clicked();
|
void on_btnForget_clicked();
|
||||||
|
@ -171,8 +196,8 @@ signals:
|
||||||
void detailPageClose(bool on);
|
void detailPageClose(bool on);
|
||||||
void createPageClose(QString);
|
void createPageClose(QString);
|
||||||
void currentChanged(int);
|
void currentChanged(int);
|
||||||
|
void checkCurrentIpv4Conflict(const QString &address);
|
||||||
|
void checkCurrentIpv6Conflict(const QString &address);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif // NETDETAIL_H
|
#endif // NETDETAIL_H
|
||||||
|
|
Loading…
Reference in New Issue