dns高级配置需求
This commit is contained in:
parent
83b67d43d7
commit
061a069967
|
@ -3,6 +3,7 @@ TEMPLATE = subdirs
|
|||
|
||||
CONFIG += \
|
||||
ordered \
|
||||
qt \
|
||||
qt
|
||||
|
||||
SUBDIRS = \
|
||||
|
@ -10,8 +11,4 @@ SUBDIRS = \
|
|||
src-vpn/src-vpn.pro \
|
||||
src
|
||||
|
||||
TRANSLATIONS += \
|
||||
translations/kylin-nm_zh_CN.ts \
|
||||
translations/kylin-nm_tr.ts \
|
||||
translations/kylin-nm_bo.ts \
|
||||
translations/kylin-nm_bo_CN.ts
|
||||
QT += widgets
|
||||
|
|
|
@ -451,36 +451,28 @@ void KyConnectResourse::getIpv4ConnectSetting(
|
|||
NetworkManager::Ipv4Setting::Ptr &ipv4Setting,
|
||||
KyConnectSetting &connectSetting)
|
||||
{
|
||||
connectSetting.m_ipv4Dns = ipv4Setting->dns();
|
||||
if (NetworkManager::Ipv4Setting::Automatic == ipv4Setting->method()) {
|
||||
connectSetting.m_ipv4ConfigIpType = CONFIG_IP_DHCP;
|
||||
return;
|
||||
}
|
||||
|
||||
connectSetting.m_ipv4ConfigIpType = CONFIG_IP_MANUAL;
|
||||
|
||||
connectSetting.m_ipv4Address = ipv4Setting->addresses();
|
||||
connectSetting.m_ipv4Dns = ipv4Setting->dns();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void KyConnectResourse::getIpv6ConnectSetting(
|
||||
NetworkManager::Ipv6Setting::Ptr &ipv6Setting,
|
||||
KyConnectSetting &connectSetting)
|
||||
{
|
||||
|
||||
connectSetting.m_ipv6Dns = ipv6Setting->dns();
|
||||
if (NetworkManager::Ipv6Setting::Automatic == ipv6Setting->method()) {
|
||||
connectSetting.m_ipv6ConfigIpType = CONFIG_IP_DHCP;
|
||||
return;
|
||||
}
|
||||
|
||||
connectSetting.m_ipv6ConfigIpType = CONFIG_IP_MANUAL;
|
||||
|
||||
connectSetting.m_ipv6Address = ipv6Setting->addresses();
|
||||
|
||||
connectSetting.m_ipv6Dns = ipv6Setting->dns();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void KyConnectResourse::getConnectivity(NetworkManager::Connectivity &connectivity)
|
||||
|
|
|
@ -69,7 +69,8 @@ int KyConnectSetting::setIpConfigType(KyIpAddressType ipType, KyIpConfigType ipC
|
|||
|
||||
return 0;
|
||||
}
|
||||
void KyConnectSetting::ipv4AddressConstruct(QString &ipv4Address, QString &ipv4NetMask, QString &ipv4GateWay, QStringList &ipv4Dns)
|
||||
|
||||
void KyConnectSetting::ipv4AddressConstruct(QString &ipv4Address, QString &ipv4NetMask, QString &ipv4GateWay)
|
||||
{
|
||||
qDebug()<<"ipv4 address"<<ipv4Address << ipv4NetMask << ipv4GateWay;
|
||||
NetworkManager::IpAddress nmIpv4Address;
|
||||
|
@ -78,16 +79,14 @@ void KyConnectSetting::ipv4AddressConstruct(QString &ipv4Address, QString &ipv4N
|
|||
nmIpv4Address.setNetmask(QHostAddress(ipv4NetMask));
|
||||
m_ipv4Address.clear();
|
||||
m_ipv4Address << nmIpv4Address;
|
||||
|
||||
m_ipv4Dns.clear();
|
||||
for (int index = 0; index < ipv4Dns.size(); ++index) {
|
||||
qDebug()<<"dns"<<ipv4Dns[index];
|
||||
m_ipv4Dns << QHostAddress(ipv4Dns[index]);
|
||||
}
|
||||
|
||||
return ;
|
||||
}
|
||||
void KyConnectSetting::ipv6AddressConstruct(QString &ipv6Address, QString &ipv6NetMask, QString &ipv6GateWay, QStringList &ipv6Dns)
|
||||
|
||||
void KyConnectSetting::ipv4DnsConstruct(QList<QHostAddress> &ipv4Dns)
|
||||
{
|
||||
m_ipv4Dns = ipv4Dns;
|
||||
}
|
||||
|
||||
void KyConnectSetting::ipv6AddressConstruct(QString &ipv6Address, QString &ipv6NetMask, QString &ipv6GateWay)
|
||||
{
|
||||
NetworkManager::IpAddress nmIpv6Address;
|
||||
nmIpv6Address.setIp(QHostAddress(ipv6Address));
|
||||
|
@ -96,12 +95,11 @@ void KyConnectSetting::ipv6AddressConstruct(QString &ipv6Address, QString &ipv6N
|
|||
m_ipv6Address.clear();
|
||||
m_ipv6Address << nmIpv6Address;
|
||||
|
||||
m_ipv6Dns.clear();
|
||||
for (int index = 0; index < ipv6Dns.size(); index++) {
|
||||
m_ipv6Dns << QHostAddress(ipv6Dns[index]);
|
||||
}
|
||||
}
|
||||
|
||||
return ;
|
||||
void KyConnectSetting::ipv6DnsConstruct(QList<QHostAddress> &ipv6Dns)
|
||||
{
|
||||
m_ipv6Dns = ipv6Dns;
|
||||
}
|
||||
|
||||
void KyConnectSetting::dumpInfo()
|
||||
|
|
|
@ -50,8 +50,10 @@ public:
|
|||
void setIfaceName(QString &ifaceName);
|
||||
void setConnectName(QString &connectName);
|
||||
int setIpConfigType(KyIpAddressType ipType, KyIpConfigType configType);
|
||||
void ipv4AddressConstruct(QString &ipv4Address, QString &ipv4NetMask, QString &ipv4GateWay, QStringList &ipv4Dns);
|
||||
void ipv6AddressConstruct(QString &ipv6Address, QString &ipv6NetMask, QString &ipv6GateWay, QStringList &ipv6Dns);
|
||||
void ipv4DnsConstruct(QList<QHostAddress> &ipv4Dns);
|
||||
void ipv4AddressConstruct(QString &ipv4Address, QString &ipv4NetMask, QString &ipv4GateWay);
|
||||
void ipv6DnsConstruct(QList<QHostAddress> &ipv6Dns);
|
||||
void ipv6AddressConstruct(QString &ipv6Address, QString &ipv6NetMask, QString &ipv6GateWay);
|
||||
void dumpInfo();
|
||||
|
||||
public:
|
||||
|
|
|
@ -47,7 +47,7 @@ void CreatNetPage::initUI()
|
|||
|
||||
// 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");
|
||||
m_dnsWidget = new MultipleDnsWidget(rx, this);
|
||||
m_dnsWidget = new MultipleDnsWidget(rx, false, this);
|
||||
|
||||
QLabel *nameEmptyLabel = new QLabel(this);
|
||||
QLabel *configEmptyLabel = new QLabel(this);
|
||||
|
@ -189,7 +189,6 @@ void CreatNetPage::setLineEnabled(bool check) {
|
|||
ipv4addressEdit->setEnabled(check);
|
||||
netMaskEdit->setEnabled(check);
|
||||
gateWayEdit->setEnabled(check);
|
||||
m_dnsWidget->setEditEnabled(check);
|
||||
|
||||
if (!check) {
|
||||
ipv4addressEdit->clear();
|
||||
|
@ -245,16 +244,14 @@ void CreatNetPage::constructIpv4Info(KyConnectSetting &setting)
|
|||
QList<QHostAddress> ipv4dnsList;
|
||||
ipv4dnsList.clear();
|
||||
ipv4dnsList = m_dnsWidget->getDns();
|
||||
for (QHostAddress str: ipv4dnsList) {
|
||||
dnsList << str.toString();
|
||||
}
|
||||
|
||||
if (ipv4ConfigCombox->currentData() == AUTO_CONFIG) {
|
||||
setting.setIpConfigType(IPADDRESS_V4, CONFIG_IP_DHCP);
|
||||
} else {
|
||||
setting.setIpConfigType(IPADDRESS_V4, CONFIG_IP_MANUAL);
|
||||
setting.ipv4AddressConstruct(ipv4address, netMask, gateWay, dnsList);
|
||||
setting.ipv4AddressConstruct(ipv4address, netMask, gateWay);
|
||||
}
|
||||
setting.ipv4DnsConstruct(ipv4dnsList);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,156 @@
|
|||
#include "dnssettingwidget.h"
|
||||
#include <QLayout>
|
||||
#include <QFormLayout>
|
||||
#include <QApplication>
|
||||
#include <QGSettings>
|
||||
|
||||
#include "coninfo.h"
|
||||
|
||||
#define THEME_SCHAME "org.ukui.style"
|
||||
#define COLOR_THEME "styleName"
|
||||
|
||||
#define BOTTOM_LAYOUT_MARGINS 24, 16, 24, 24
|
||||
#define LAYOUT_SPACING 16
|
||||
|
||||
DnsSettingWidget::DnsSettingWidget(QString timeout, QString retry, QString tactic, QWidget *parent)
|
||||
:m_timeout(timeout), m_retry(retry), m_tactic(tactic), QDialog(parent)
|
||||
{
|
||||
this->setFixedSize(420, 420);
|
||||
setAttribute(Qt::WA_DeleteOnClose, false);
|
||||
setProperty("useStyleWindowManager", false);
|
||||
initUi();
|
||||
initConnect();
|
||||
onPaletteChanged();
|
||||
}
|
||||
|
||||
void DnsSettingWidget::initUi()
|
||||
{
|
||||
m_titleWidget = new QWidget(this);
|
||||
m_centerWidget = new QWidget(this);
|
||||
m_bottomWidget = new QWidget(this);
|
||||
|
||||
m_titleLabel = new QLabel(this);
|
||||
m_titleLabel->setContentsMargins(24,14,0,0);
|
||||
m_titleLabel->setText(tr("DNS Server Advanced Settings"));
|
||||
|
||||
m_tacticLabel = new QLabel(this);
|
||||
m_tacticLabel->setText(tr("Tactic"));
|
||||
|
||||
m_timeoutLabel = new QLabel(this);
|
||||
m_timeoutLabel->setText(tr("Timeout"));
|
||||
|
||||
m_retryLabel = new QLabel(this);
|
||||
m_retryLabel->setText(tr("Retry Count"));
|
||||
|
||||
m_tacticComboBox = new QComboBox(this);
|
||||
m_tacticComboBox->addItem(tr("order"), "order");
|
||||
m_tacticComboBox->addItem(tr("rotate"), "rotate");
|
||||
m_tacticComboBox->addItem(tr("concurrency"), "concurrency");
|
||||
m_tacticComboBox->setCurrentIndex(m_tacticComboBox->findData(m_tactic));
|
||||
|
||||
m_timeoutComboBox = new QComboBox(this);
|
||||
for (int i = 0; i < 30; ++i) {
|
||||
m_timeoutComboBox->insertItem(i, QString::number(i+1) + tr(" s"), QString::number(i+1));
|
||||
}
|
||||
m_timeoutComboBox->setCurrentIndex(m_timeoutComboBox->findData(m_timeout.toInt()));
|
||||
|
||||
m_retryComboBox = new QComboBox(this);
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
m_retryComboBox->insertItem(i, QString::number(i+1) + tr(" times"), QString::number(i+1));
|
||||
}
|
||||
m_retryComboBox->setCurrentIndex(m_retryComboBox->findData(m_retry.toInt()));
|
||||
|
||||
m_bottomDivider = new Divider(true, this);
|
||||
|
||||
m_closeBtn = new QPushButton(this);
|
||||
m_closeBtn->setFixedSize(32,32);
|
||||
m_closeBtn->setIcon(QIcon::fromTheme("application-exit-symbolic"));
|
||||
m_closeBtn->setProperty("useButtonPalette", true);
|
||||
m_closeBtn->setFlat(true);
|
||||
|
||||
m_cancelBtn = new QPushButton(this);
|
||||
m_cancelBtn->setText(tr("Cancel"));
|
||||
|
||||
m_confirmBtn = new QPushButton(this);
|
||||
m_confirmBtn->setText(tr("Confirm"));
|
||||
|
||||
|
||||
QHBoxLayout* titleLayout = new QHBoxLayout(m_titleWidget);
|
||||
titleLayout->setContentsMargins(0,4,3,0);
|
||||
titleLayout->addStretch();
|
||||
titleLayout->addWidget(m_closeBtn);
|
||||
|
||||
QVBoxLayout* mainLayout = new QVBoxLayout(this);
|
||||
mainLayout->setContentsMargins(0,0,0,0);
|
||||
mainLayout->setSpacing(0);
|
||||
mainLayout->addWidget(m_titleWidget);
|
||||
mainLayout->addWidget(m_titleLabel, Qt::AlignLeft);
|
||||
mainLayout->addWidget(m_centerWidget);
|
||||
mainLayout->addSpacing(115);
|
||||
mainLayout->addWidget(m_bottomDivider);
|
||||
mainLayout->addWidget(m_bottomWidget);
|
||||
this->setLayout(mainLayout);
|
||||
|
||||
//中间页面
|
||||
QFormLayout* centerLayout = new QFormLayout(m_centerWidget);
|
||||
centerLayout->setContentsMargins(24,10,24,0);
|
||||
centerLayout->setSpacing(16);
|
||||
centerLayout->addRow(m_tacticLabel, m_tacticComboBox);
|
||||
centerLayout->addRow(m_timeoutLabel, m_timeoutComboBox);
|
||||
centerLayout->addRow(m_retryLabel, m_retryComboBox);
|
||||
|
||||
//底部按钮
|
||||
QHBoxLayout* bottomLayout = new QHBoxLayout(m_bottomWidget);
|
||||
bottomLayout->setContentsMargins(BOTTOM_LAYOUT_MARGINS);
|
||||
bottomLayout->setSpacing(LAYOUT_SPACING);
|
||||
bottomLayout->addStretch();
|
||||
bottomLayout->addWidget(m_cancelBtn);
|
||||
bottomLayout->addWidget(m_confirmBtn);
|
||||
|
||||
this->setWindowFlags(Qt::Dialog);
|
||||
}
|
||||
|
||||
void DnsSettingWidget::initConnect()
|
||||
{
|
||||
connect(m_closeBtn, &QPushButton::released, this, [=](){
|
||||
reject();
|
||||
});
|
||||
connect(m_cancelBtn, &QPushButton::released, this, [=](){
|
||||
reject();
|
||||
});
|
||||
connect(m_confirmBtn, &QPushButton::released, this, [=](){
|
||||
m_timeout = m_timeoutComboBox->currentData().toString();
|
||||
m_tactic = m_tacticComboBox->currentData().toString();
|
||||
m_retry = m_retryComboBox->currentData().toString();
|
||||
accept();
|
||||
});
|
||||
connect(qApp, &QApplication::paletteChanged, this, &DnsSettingWidget::onPaletteChanged);
|
||||
}
|
||||
|
||||
void DnsSettingWidget::onPaletteChanged()
|
||||
{
|
||||
QPalette pal = qApp->palette();
|
||||
|
||||
QGSettings * styleGsettings = nullptr;
|
||||
const QByteArray style_id(THEME_SCHAME);
|
||||
if (QGSettings::isSchemaInstalled(style_id)) {
|
||||
styleGsettings = new QGSettings(style_id);
|
||||
QString currentTheme = styleGsettings->get(COLOR_THEME).toString();
|
||||
if(currentTheme == "ukui-default"){
|
||||
pal = lightPalette(this);
|
||||
}
|
||||
}
|
||||
this->setPalette(pal);
|
||||
QList<QComboBox *> comboBoxList = this->findChildren<QComboBox *>();
|
||||
for (int i = 0; i < comboBoxList.count(); ++i) {
|
||||
comboBoxList.at(i)->setPalette(pal);
|
||||
if (comboBoxList.at(i)->view()) {
|
||||
comboBoxList.at(i)->view()->setPalette(pal);
|
||||
}
|
||||
}
|
||||
|
||||
if (styleGsettings != nullptr) {
|
||||
delete styleGsettings;
|
||||
styleGsettings = nullptr;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
#ifndef DNSSETTINGWIDGET_H
|
||||
#define DNSSETTINGWIDGET_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QDialog>
|
||||
#include <QLabel>
|
||||
#include <QComboBox>
|
||||
#include <QDBusInterface>
|
||||
#include <QPushButton>
|
||||
|
||||
#include "divider.h"
|
||||
|
||||
class DnsSettingWidget : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit DnsSettingWidget(QString timeout = "", QString retry = "", QString tactic = "", QWidget *parent = nullptr);
|
||||
|
||||
void getDnsSettings(QString& timeout, QString& retry, QString& tactic) {
|
||||
timeout = QString::number(m_timeoutComboBox->currentData().toInt());
|
||||
retry = QString::number(m_retryComboBox->currentData().toInt());
|
||||
tactic = m_tacticComboBox->currentData().toString();
|
||||
}
|
||||
|
||||
private:
|
||||
QWidget* m_titleWidget;
|
||||
QWidget* m_centerWidget;
|
||||
QWidget* m_bottomWidget;
|
||||
|
||||
QString m_timeout;
|
||||
QString m_retry;
|
||||
QString m_tactic;
|
||||
|
||||
QLabel* m_titleLabel;
|
||||
QLabel* m_tacticLabel;
|
||||
QLabel* m_timeoutLabel;
|
||||
QLabel* m_retryLabel;
|
||||
|
||||
QComboBox* m_tacticComboBox;
|
||||
QComboBox* m_timeoutComboBox;
|
||||
QComboBox* m_retryComboBox;
|
||||
|
||||
Divider *m_bottomDivider = nullptr;
|
||||
|
||||
QPushButton *m_closeBtn;
|
||||
QPushButton *m_cancelBtn;
|
||||
QPushButton *m_confirmBtn;
|
||||
|
||||
void initUi();
|
||||
void initConnect();
|
||||
|
||||
private Q_SLOTS:
|
||||
void onPaletteChanged();
|
||||
|
||||
};
|
||||
|
||||
#endif // DNSSETTINGWIDGET_H
|
|
@ -60,6 +60,9 @@ void Ipv4Page::initUI() {
|
|||
m_gateWayEmptyLabel = new QLabel(this);
|
||||
m_gateWayEmptyLabel->setFixedHeight(LABEL_HEIGHT);
|
||||
|
||||
m_dnsEmptyLabel = new QLabel(this);
|
||||
m_dnsEmptyLabel->setFixedHeight(21);
|
||||
|
||||
m_configLabel->setText(tr("IPv4Config"));
|
||||
m_addressLabel->setText(tr("Address"));
|
||||
m_maskLabel->setText(tr("Netmask"));
|
||||
|
@ -92,7 +95,9 @@ void Ipv4Page::initUI() {
|
|||
|
||||
// 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");
|
||||
m_dnsWidget = new MultipleDnsWidget(rx, this);
|
||||
|
||||
Divider* divider = new Divider(true, this);
|
||||
m_dnsWidget = new MultipleDnsWidget(rx, true, this);
|
||||
|
||||
m_detailLayout = new QFormLayout(this);
|
||||
m_detailLayout->setVerticalSpacing(0);
|
||||
|
@ -103,6 +108,8 @@ void Ipv4Page::initUI() {
|
|||
m_detailLayout->addRow(m_maskLabel,maskWidget);
|
||||
m_detailLayout->addRow(m_gateWayLabel,gateWayEdit);
|
||||
m_detailLayout->addRow(m_gateWayEmptyLabel);
|
||||
m_detailLayout->addRow(divider);
|
||||
m_detailLayout->addRow(m_dnsEmptyLabel);
|
||||
m_detailLayout->addRow(m_dnsWidget);
|
||||
|
||||
ipv4ConfigCombox->addItem(tr("Auto(DHCP)")); //"自动(DHCP)"
|
||||
|
@ -139,6 +146,8 @@ void Ipv4Page::initComponent() {
|
|||
connect(ipv4addressEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn()));
|
||||
connect(netMaskEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn()));
|
||||
connect(gateWayEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn()));
|
||||
|
||||
connect(m_dnsWidget, &MultipleDnsWidget::scrollToBottom, this, &Ipv4Page::scrollToBottom);
|
||||
}
|
||||
|
||||
void Ipv4Page::setIpv4Config(KyIpConfigType ipv4Config)
|
||||
|
@ -173,55 +182,53 @@ void Ipv4Page::setGateWay(const QString &gateWay)
|
|||
bool Ipv4Page::checkIsChanged(const ConInfo info, KyConnectSetting &setting)
|
||||
{
|
||||
bool isChanged = false;
|
||||
KyIpConfigType type;
|
||||
if (ipv4ConfigCombox->currentIndex() == AUTO_CONFIG) {
|
||||
type = CONFIG_IP_DHCP;
|
||||
if (info.ipv4ConfigType != CONFIG_IP_DHCP) {
|
||||
qDebug() << "ipv4ConfigType change to Auto";
|
||||
setting.setIpConfigType(IPADDRESS_V4, CONFIG_IP_DHCP);
|
||||
QString ipv4address("");
|
||||
QString netMask("");
|
||||
QString gateWay("");
|
||||
QStringList dnsList;
|
||||
dnsList.empty();
|
||||
qDebug() << ipv4address << netMask << gateWay;
|
||||
setting.ipv4AddressConstruct(ipv4address, netMask, gateWay, dnsList);
|
||||
isChanged = true;
|
||||
}
|
||||
} else {
|
||||
type = CONFIG_IP_MANUAL;
|
||||
if (info.ipv4ConfigType != CONFIG_IP_MANUAL) {
|
||||
qDebug() << "ipv4ConfigType change to Manual";
|
||||
setting.setIpConfigType(IPADDRESS_V4, CONFIG_IP_MANUAL);
|
||||
isChanged = true;
|
||||
}
|
||||
qDebug() << "ipv4 netmask " << getNetMaskText(netMaskEdit->text());
|
||||
} else {
|
||||
|
||||
QList<QHostAddress> ipv4dnsList;
|
||||
ipv4dnsList.clear();
|
||||
ipv4dnsList = m_dnsWidget->getDns();
|
||||
|
||||
if(info.strIPV4Address != ipv4addressEdit->text()
|
||||
|| info.strIPV4NetMask != /*netMaskEdit->text()*/getNetMaskText(netMaskEdit->text())
|
||||
|| info.strIPV4GateWay != gateWayEdit->text()
|
||||
|| info.ipv4DnsList != ipv4dnsList) {
|
||||
|
||||
qDebug() << "ipv4 info changed";
|
||||
QStringList dnsList;
|
||||
dnsList.clear();
|
||||
for (QHostAddress str: ipv4dnsList) {
|
||||
dnsList << str.toString();
|
||||
if(info.strIPV4Address != ipv4addressEdit->text()
|
||||
|| info.strIPV4NetMask != getNetMaskText(netMaskEdit->text())
|
||||
|| info.strIPV4GateWay != gateWayEdit->text()) {
|
||||
qDebug() << "ipv4 info changed";
|
||||
isChanged = true;
|
||||
}
|
||||
|
||||
QString ipv4address =ipv4addressEdit->text();
|
||||
QString netMask = getNetMaskText(netMaskEdit->text());
|
||||
QString gateWay = gateWayEdit->text();
|
||||
qDebug() << ipv4address << netMask << gateWay;
|
||||
setting.ipv4AddressConstruct(ipv4address, netMask, gateWay, dnsList);
|
||||
setting.dumpInfo();
|
||||
isChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
QList<QHostAddress> ipv4dnsList;
|
||||
ipv4dnsList.clear();
|
||||
ipv4dnsList = m_dnsWidget->getDns();
|
||||
if(info.ipv4DnsList != ipv4dnsList) {
|
||||
isChanged = true;
|
||||
}
|
||||
|
||||
if (isChanged) {
|
||||
setting.setIpConfigType(IPADDRESS_V4, type);
|
||||
QString ipv4address = ipv4addressEdit->text();
|
||||
QString netMask = getNetMaskText(netMaskEdit->text());
|
||||
QString gateWay = gateWayEdit->text();
|
||||
setting.ipv4AddressConstruct(ipv4address, netMask, gateWay);
|
||||
setting.ipv4DnsConstruct(ipv4dnsList);
|
||||
setting.dumpInfo();
|
||||
}
|
||||
|
||||
return isChanged;
|
||||
}
|
||||
|
||||
bool Ipv4Page::checkDnsSettingsIsChanged() {
|
||||
return m_dnsWidget->getDnsSettingsChanged();
|
||||
}
|
||||
|
||||
bool Ipv4Page::checkConnectBtnIsEnabled()
|
||||
{
|
||||
qDebug() << "checkConnectBtnIsEnabled currentIndex" << ipv4ConfigCombox->currentIndex();
|
||||
|
@ -304,7 +311,7 @@ void Ipv4Page::setLineEnabled(bool check) {
|
|||
ipv4addressEdit->setEnabled(check);
|
||||
netMaskEdit->setEnabled(check);
|
||||
gateWayEdit->setEnabled(check);
|
||||
m_dnsWidget->setEditEnabled(check);
|
||||
// m_dnsWidget->setEditEnabled(check);
|
||||
}
|
||||
|
||||
void Ipv4Page::setEnableOfSaveBtn() {
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
//#include "kylinconnectsetting.h"
|
||||
#include "coninfo.h"
|
||||
#include "multiplednswidget.h"
|
||||
#include "divider.h"
|
||||
|
||||
class Ipv4Page : public QFrame
|
||||
{
|
||||
|
@ -45,8 +46,14 @@ public:
|
|||
void setNetMask(const QString &netMask);
|
||||
void setMulDns(const QList<QHostAddress> &dns);
|
||||
void setGateWay(const QString &gateWay);
|
||||
void setUuid(QString uuid) {
|
||||
if (m_dnsWidget != nullptr) {
|
||||
m_dnsWidget->setUuid(uuid);
|
||||
}
|
||||
}
|
||||
|
||||
bool checkIsChanged(const ConInfo info, KyConnectSetting &setting);
|
||||
bool checkDnsSettingsIsChanged();
|
||||
|
||||
void startLoading();
|
||||
void stopLoading();
|
||||
|
@ -69,6 +76,7 @@ private:
|
|||
QLabel *m_addressHintLabel;
|
||||
QLabel *m_maskHintLabel;
|
||||
QLabel *m_gateWayEmptyLabel;
|
||||
QLabel *m_dnsEmptyLabel;
|
||||
|
||||
MultipleDnsWidget *m_dnsWidget = nullptr;
|
||||
|
||||
|
@ -103,6 +111,7 @@ private Q_SLOTS:
|
|||
Q_SIGNALS:
|
||||
void setIpv4PageState(bool);
|
||||
void ipv4EditFinished(const QString &address);
|
||||
void scrollToBottom();
|
||||
};
|
||||
|
||||
#endif // IPV4PAGE_H
|
||||
|
|
|
@ -65,48 +65,43 @@ void Ipv6Page::setGateWay(const QString &gateWay)
|
|||
bool Ipv6Page::checkIsChanged(const ConInfo info, KyConnectSetting &setting)
|
||||
{
|
||||
bool isChanged = false;
|
||||
KyIpConfigType type;
|
||||
if (ipv6ConfigCombox->currentIndex() == AUTO_CONFIG) {
|
||||
type = CONFIG_IP_DHCP;
|
||||
if (info.ipv6ConfigType != CONFIG_IP_DHCP) {
|
||||
qDebug() << "ipv6ConfigType change to Auto";
|
||||
setting.setIpConfigType(IPADDRESS_V6, CONFIG_IP_DHCP);
|
||||
QString ipv6address("");
|
||||
QString prefix("");
|
||||
QString gateWay("");
|
||||
QStringList dnsList;
|
||||
dnsList.empty();
|
||||
setting.ipv6AddressConstruct(ipv6address, prefix, gateWay, dnsList);
|
||||
isChanged = true;
|
||||
}
|
||||
} else {
|
||||
type = CONFIG_IP_DHCP;
|
||||
if (info.ipv6ConfigType != CONFIG_IP_MANUAL) {
|
||||
qDebug() << "ipv6ConfigType change to Manual";
|
||||
setting.setIpConfigType(IPADDRESS_V6, CONFIG_IP_MANUAL);
|
||||
isChanged = true;
|
||||
}
|
||||
|
||||
QList<QHostAddress> ipv6dnsList;
|
||||
ipv6dnsList.clear();
|
||||
ipv6dnsList = m_dnsWidget->getDns();
|
||||
if(info.strIPV6Address != ipv6AddressEdit->text()
|
||||
|| info.iIPV6Prefix != lengthEdit->text().toInt()
|
||||
|| info.strIPV6GateWay != gateWayEdit->text()
|
||||
|| info.ipv6DnsList != ipv6dnsList) {
|
||||
|| info.strIPV6GateWay != gateWayEdit->text()) {
|
||||
|
||||
qDebug() << "ipv6 info changed";
|
||||
QStringList dnsList;
|
||||
dnsList.clear();
|
||||
for (QHostAddress str: ipv6dnsList) {
|
||||
dnsList << str.toString();
|
||||
}
|
||||
|
||||
QString ipv6address =ipv6AddressEdit->text();
|
||||
QString prefix = lengthEdit->text();
|
||||
QString gateWay = gateWayEdit->text();
|
||||
setting.ipv6AddressConstruct(ipv6address, prefix, gateWay, dnsList);
|
||||
setting.dumpInfo();
|
||||
isChanged = true;
|
||||
}
|
||||
}
|
||||
QList<QHostAddress> ipv6dnsList;
|
||||
ipv6dnsList.clear();
|
||||
ipv6dnsList = m_dnsWidget->getDns();
|
||||
if (info.ipv6DnsList != ipv6dnsList) {
|
||||
isChanged = true;
|
||||
}
|
||||
|
||||
if (isChanged) {
|
||||
setting.setIpConfigType(IPADDRESS_V6, type);
|
||||
QString ipv6address =ipv6AddressEdit->text();
|
||||
QString prefix = lengthEdit->text();
|
||||
QString gateWay = gateWayEdit->text();
|
||||
setting.ipv6AddressConstruct(ipv6address, prefix, gateWay);
|
||||
setting.ipv6DnsConstruct(ipv6dnsList);
|
||||
setting.dumpInfo();
|
||||
}
|
||||
return isChanged;
|
||||
}
|
||||
|
||||
|
@ -167,7 +162,7 @@ void Ipv6Page::initUI() {
|
|||
gateWayLayout->addWidget(m_gateWayHintLabel);
|
||||
|
||||
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*$");
|
||||
m_dnsWidget = new MultipleDnsWidget(ipv6_rx, this);
|
||||
m_dnsWidget = new MultipleDnsWidget(ipv6_rx, false, this);
|
||||
|
||||
m_detailLayout = new QFormLayout(this);
|
||||
m_detailLayout->setContentsMargins(0, 0, 0, 0);
|
||||
|
@ -208,6 +203,8 @@ void Ipv6Page::initComponent() {
|
|||
connect(ipv6AddressEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn()));
|
||||
connect(lengthEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn()));
|
||||
connect(gateWayEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn()));
|
||||
|
||||
connect(m_dnsWidget, &MultipleDnsWidget::scrollToBottom, this, &Ipv6Page::scrollToBottom);
|
||||
}
|
||||
|
||||
void Ipv6Page::configChanged(int index) {
|
||||
|
@ -237,7 +234,6 @@ void Ipv6Page::setControlEnabled(bool check)
|
|||
ipv6AddressEdit->setEnabled(check);
|
||||
lengthEdit->setEnabled(check);
|
||||
gateWayEdit->setEnabled(check);
|
||||
m_dnsWidget->setEditEnabled(check);
|
||||
}
|
||||
|
||||
void Ipv6Page::setEnableOfSaveBtn()
|
||||
|
|
|
@ -104,6 +104,7 @@ private Q_SLOTS:
|
|||
Q_SIGNALS:
|
||||
void setIpv6PageState(bool);
|
||||
void ipv6EditFinished(const QString &address);
|
||||
void scrollToBottom();
|
||||
};
|
||||
|
||||
#endif // IPV6PAGE_H
|
||||
|
|
|
@ -20,13 +20,28 @@
|
|||
#include "multiplednswidget.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QDBusInterface>
|
||||
#include <QPlainTextEdit>
|
||||
#include <QGSettings>
|
||||
|
||||
#define DNS_LISTWIDGET_HEIGHT 76 + 60
|
||||
#include "ukuistylehelper/ukuistylehelper.h"
|
||||
#include "coninfo.h"
|
||||
|
||||
#define THEME_SCHAME "org.ukui.style"
|
||||
#define COLOR_THEME "styleName"
|
||||
|
||||
#define DNS_LISTWIDGET_EMPTY_HEIGHT 79
|
||||
#define DNS_LISTWIDGET_HEIGHT 188
|
||||
#define BUTTON_SIZE 36,36
|
||||
#define ITEM_HEIGHT 36
|
||||
|
||||
MultipleDnsWidget::MultipleDnsWidget(const QRegExp &rx, QWidget *parent)
|
||||
#define STR_ATTEMPTS "attempts"
|
||||
#define STR_TIMEOUT "timeout"
|
||||
#define STR_TYPE "type"
|
||||
|
||||
MultipleDnsWidget::MultipleDnsWidget(const QRegExp &rx, bool settingShow, QWidget *parent)
|
||||
: m_regExp(rx),
|
||||
m_settingShow(settingShow),
|
||||
QWidget(parent)
|
||||
{
|
||||
initUI();
|
||||
|
@ -36,12 +51,22 @@ MultipleDnsWidget::MultipleDnsWidget(const QRegExp &rx, QWidget *parent)
|
|||
void MultipleDnsWidget::initUI()
|
||||
{
|
||||
QVBoxLayout *mulDnsVLayout = new QVBoxLayout(this);
|
||||
mulDnsVLayout->setContentsMargins(0, 0, 0, 0);
|
||||
mulDnsVLayout->setContentsMargins(0, 0, 0, 30);
|
||||
|
||||
m_mulDnsLabel = new QLabel(this);
|
||||
m_mulDnsLabel->setText(tr("DNS server:")); //DNS服务器:
|
||||
m_mulDnsLabel->setText(tr("DNS server(Drag to sort)")); //DNS服务器:
|
||||
|
||||
m_emptyWidget = new QFrame(this);
|
||||
m_emptyWidget->setFrameShape(QFrame::Shape::StyledPanel);
|
||||
m_emptyWidget->setFixedHeight(DNS_LISTWIDGET_EMPTY_HEIGHT);
|
||||
emptyLabel = new QLabel(m_emptyWidget);
|
||||
emptyLabel->setAlignment(Qt::AlignCenter);
|
||||
emptyLabel->setText(tr("Click \"+\" to configure DNS"));
|
||||
QVBoxLayout* emptyLayout = new QVBoxLayout(m_emptyWidget);
|
||||
emptyLayout->addWidget(emptyLabel,Qt::AlignCenter);
|
||||
|
||||
m_dnsListWidget = new QListWidget(this);
|
||||
m_dnsListWidget->setFixedHeight(DNS_LISTWIDGET_HEIGHT);
|
||||
m_dnsListWidget->setFixedHeight(DNS_LISTWIDGET_EMPTY_HEIGHT);
|
||||
m_dnsListWidget->setBackgroundRole(QPalette::Base);
|
||||
m_dnsListWidget->setFocusPolicy(Qt::FocusPolicy::NoFocus);
|
||||
m_dnsListWidget->setFrameShape(QFrame::Shape::StyledPanel);
|
||||
|
@ -56,32 +81,51 @@ void MultipleDnsWidget::initUI()
|
|||
|
||||
setDnsListWidgetStyle();
|
||||
|
||||
m_addDnsBtn = new QPushButton(this);
|
||||
m_buttonBox = new KButtonBox(this);
|
||||
m_buttonBox->setExclusive(false);
|
||||
|
||||
m_addDnsBtn = new KPushButton(this);
|
||||
m_addDnsBtn->setIcon(QIcon::fromTheme("list-add-symbolic"));
|
||||
m_addDnsBtn->setFixedSize(BUTTON_SIZE);
|
||||
m_addDnsBtn->setProperty("useButtonPalette", true);
|
||||
m_addDnsBtn->setIcon(QIcon::fromTheme("list-add-symbolic"));
|
||||
m_removeDnsBtn = new QPushButton(this);
|
||||
m_removeDnsBtn = new KPushButton(this);
|
||||
m_removeDnsBtn->setIcon(QIcon::fromTheme("list-remove-symbolic"));
|
||||
m_removeDnsBtn->setFixedSize(BUTTON_SIZE);
|
||||
m_removeDnsBtn->setProperty("useButtonPalette", true);
|
||||
m_removeDnsBtn->setIcon(QIcon::fromTheme("list-remove-symbolic"));
|
||||
m_removeDnsBtn->setEnabled(false);
|
||||
m_buttonBox->addButton(m_addDnsBtn);
|
||||
m_buttonBox->addButton(m_removeDnsBtn);
|
||||
|
||||
|
||||
m_settingsLabel = new KBorderlessButton(this);
|
||||
m_settingsLabel->setText(tr("Settings"));
|
||||
|
||||
QHBoxLayout *btnHLayout = new QHBoxLayout();
|
||||
btnHLayout->setContentsMargins(0, 0, 0, 0);
|
||||
btnHLayout->setSpacing(1);
|
||||
btnHLayout->setAlignment(Qt::AlignLeft);
|
||||
btnHLayout->addWidget(m_addDnsBtn);
|
||||
btnHLayout->addWidget(m_removeDnsBtn);
|
||||
btnHLayout->addWidget(m_buttonBox);
|
||||
btnHLayout->addSpacing(23);
|
||||
btnHLayout->addWidget(m_settingsLabel);
|
||||
|
||||
mulDnsVLayout->addWidget(m_mulDnsLabel, Qt::AlignLeft);
|
||||
mulDnsVLayout->addWidget(m_emptyWidget);
|
||||
mulDnsVLayout->addWidget(m_dnsListWidget);
|
||||
mulDnsVLayout->addLayout(btnHLayout);
|
||||
|
||||
m_emptyWidget->show();
|
||||
m_dnsListWidget->hide();
|
||||
|
||||
if (!m_settingShow) {
|
||||
m_settingsLabel->hide();
|
||||
}
|
||||
}
|
||||
|
||||
void MultipleDnsWidget::initComponent()
|
||||
{
|
||||
connect(qApp, &QApplication::paletteChanged, this, &MultipleDnsWidget::setDnsListWidgetStyle);
|
||||
connect(m_addDnsBtn, &QPushButton::clicked, this, &MultipleDnsWidget::onAddBtnClicked);
|
||||
connect(m_removeDnsBtn, &QPushButton::clicked, this, &MultipleDnsWidget::onRemoveBtnClicked);
|
||||
connect(m_addDnsBtn, &KPushButton::clicked, this, &MultipleDnsWidget::onAddBtnClicked);
|
||||
connect(m_removeDnsBtn, &KPushButton::clicked, this, &MultipleDnsWidget::onRemoveBtnClicked);
|
||||
connect(m_dnsListWidget, &QListWidget::itemClicked, this, [=]() {
|
||||
if (m_dnsListWidget->count() < 1) {
|
||||
m_removeDnsBtn->setEnabled(false);
|
||||
|
@ -93,6 +137,10 @@ void MultipleDnsWidget::initComponent()
|
|||
m_dnsListWidget->edit(m_dnsListWidget->currentIndex());
|
||||
item->setFlags(item->flags() | Qt::ItemIsEditable);
|
||||
});
|
||||
|
||||
connect(m_settingsLabel, &KBorderlessButton::clicked, this, [&](){
|
||||
showDnsSettingWidget();
|
||||
});
|
||||
}
|
||||
|
||||
void MultipleDnsWidget::setEditEnabled(bool state)
|
||||
|
@ -126,6 +174,11 @@ QList<QHostAddress> MultipleDnsWidget::getDns() const
|
|||
void MultipleDnsWidget::setDnsListText(const QList<QHostAddress> &dns)
|
||||
{
|
||||
m_dnsListWidget->clear();
|
||||
if (!dns.isEmpty()) {
|
||||
m_dnsListWidget->setFixedHeight(DNS_LISTWIDGET_HEIGHT);
|
||||
m_emptyWidget->hide();
|
||||
m_dnsListWidget->show();
|
||||
}
|
||||
for (QHostAddress str: dns) {
|
||||
QListWidgetItem *dnsListWidgetItem = new QListWidgetItem(m_dnsListWidget);
|
||||
dnsListWidgetItem->setSizeHint(QSize(0,ITEM_HEIGHT));
|
||||
|
@ -135,6 +188,12 @@ void MultipleDnsWidget::setDnsListText(const QList<QHostAddress> &dns)
|
|||
|
||||
void MultipleDnsWidget::AddOneDnsItem(QListWidget *listWidget)
|
||||
{
|
||||
if (m_dnsListWidget->count() == 0) {
|
||||
m_emptyWidget->hide();
|
||||
m_dnsListWidget->show();
|
||||
m_dnsListWidget->setFixedHeight(DNS_LISTWIDGET_HEIGHT);
|
||||
Q_EMIT scrollToBottom();
|
||||
}
|
||||
QListWidgetItem *dnsListWidgetItem = new QListWidgetItem(listWidget);
|
||||
dnsListWidgetItem->setSizeHint(QSize(0,ITEM_HEIGHT));
|
||||
dnsListWidgetItem->setFlags(dnsListWidgetItem->flags() | Qt::ItemIsEditable);
|
||||
|
@ -152,15 +211,32 @@ void MultipleDnsWidget::RemoveOneDnsItem(QListWidgetItem *aItem, QListWidget *li
|
|||
listWidget->removeItemWidget(aItem);
|
||||
delete aItem;
|
||||
}
|
||||
if (m_dnsListWidget->count() == 0) {
|
||||
m_emptyWidget->show();
|
||||
m_dnsListWidget->hide();
|
||||
m_dnsListWidget->setFixedHeight(DNS_LISTWIDGET_EMPTY_HEIGHT);
|
||||
}
|
||||
}
|
||||
|
||||
void MultipleDnsWidget::setDnsListWidgetStyle()
|
||||
{
|
||||
QPalette mpal(m_dnsListWidget->palette());
|
||||
mpal.setColor(QPalette::Base, qApp->palette().base().color());
|
||||
mpal.setColor(QPalette::AlternateBase, qApp->palette().alternateBase().color());
|
||||
QPalette pal = qApp->palette();
|
||||
const QByteArray style_id(THEME_SCHAME);
|
||||
if (QGSettings::isSchemaInstalled(style_id)) {
|
||||
QGSettings styleGsettings(style_id);
|
||||
QString currentTheme = styleGsettings.get(COLOR_THEME).toString();
|
||||
if(currentTheme == "ukui-default"){
|
||||
pal = lightPalette(this);
|
||||
}
|
||||
}
|
||||
|
||||
this->setPalette(pal);
|
||||
|
||||
m_dnsListWidget->setAlternatingRowColors(true);
|
||||
m_dnsListWidget->setPalette(mpal);
|
||||
|
||||
QColor color = pal.color(QPalette::PlaceholderText);
|
||||
pal.setColor(QPalette::WindowText, color);
|
||||
emptyLabel->setPalette(pal);
|
||||
}
|
||||
|
||||
void MultipleDnsWidget::onAddBtnClicked()
|
||||
|
@ -192,3 +268,45 @@ void MultipleDnsWidget::onRemoveBtnClicked()
|
|||
m_removeDnsBtn->setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
void MultipleDnsWidget::showDnsSettingWidget()
|
||||
{
|
||||
QDBusInterface iface("com.kylin.network.enhancement.optimization",
|
||||
"/com/kylin/network/enhancement/optimization/DNS",
|
||||
"com.kylin.network.enhancement.optimization.DNS",
|
||||
QDBusConnection::systemBus());
|
||||
|
||||
if (!iface.isValid()) {
|
||||
return;
|
||||
}
|
||||
|
||||
QDBusMessage result = iface.call("GetExtraDns", m_uuid);
|
||||
const QDBusArgument &dbusArg1st = result.arguments().at( 0 ).value<QDBusArgument>();
|
||||
QVariantMap map = result.arguments().at(0).toMap();
|
||||
QString timeout, retry, tactic;
|
||||
dbusArg1st >> map;
|
||||
|
||||
QString originTimeout,originRetry,originType;
|
||||
originTimeout = map.value(STR_TIMEOUT).toString();
|
||||
originRetry = map.value(STR_ATTEMPTS).toString();
|
||||
originType = map.value(STR_TYPE).toString();
|
||||
|
||||
timeout = !originTimeout.isEmpty() ? map.value(STR_TIMEOUT).toString() : "5";
|
||||
retry = !originRetry.isEmpty() ? map.value(STR_ATTEMPTS).toString() : "2";
|
||||
tactic = !originType.isEmpty() ? map.value(STR_TYPE).toString() : "order";
|
||||
|
||||
DnsSettingWidget* dialog = new DnsSettingWidget(timeout, retry, tactic);
|
||||
kdk::UkuiStyleHelper::self()->removeHeader(dialog);
|
||||
if (dialog->exec() == QDialog::Accepted) {
|
||||
QString timeout, retry, tactic;
|
||||
dialog->getDnsSettings(timeout, retry, tactic);
|
||||
if (iface.isValid()) {
|
||||
iface.call("SetOptions", m_uuid, timeout, retry, tactic);
|
||||
}
|
||||
if (timeout != originTimeout || retry != originRetry || tactic != originType) {
|
||||
m_dnsSettingChanged = true;
|
||||
}
|
||||
}
|
||||
delete dialog;
|
||||
dialog = nullptr;
|
||||
}
|
||||
|
|
|
@ -33,34 +33,56 @@
|
|||
#include <QDebug>
|
||||
|
||||
#include "listitemedit.h"
|
||||
#include "dnssettingwidget.h"
|
||||
#include "kborderlessbutton.h"
|
||||
#include "kbuttonbox.h"
|
||||
|
||||
using namespace kdk;
|
||||
|
||||
class MultipleDnsWidget: public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MultipleDnsWidget(const QRegExp &rx, QWidget *parent = nullptr);
|
||||
MultipleDnsWidget(const QRegExp &rx, bool settingShow = true, QWidget *parent = nullptr);
|
||||
~MultipleDnsWidget() = default;
|
||||
void setEditEnabled(bool state);
|
||||
QList<QHostAddress> getDns() const;
|
||||
void setDnsListText(const QList<QHostAddress> &dns);
|
||||
void setUuid(QString uuid) {
|
||||
m_uuid = uuid;
|
||||
}
|
||||
bool getDnsSettingsChanged() {
|
||||
return m_dnsSettingChanged;
|
||||
}
|
||||
|
||||
private:
|
||||
void initUI();
|
||||
void initComponent();
|
||||
void AddOneDnsItem(QListWidget *listWidget);
|
||||
void RemoveOneDnsItem(QListWidgetItem *aItem, QListWidget *listWidget);
|
||||
void showDnsSettingWidget();
|
||||
|
||||
QLabel *m_mulDnsLabel;
|
||||
QLabel *emptyLabel;
|
||||
QFrame *m_emptyWidget;
|
||||
QListWidget *m_dnsListWidget = nullptr;
|
||||
QPushButton *m_addDnsBtn;
|
||||
QPushButton *m_removeDnsBtn;
|
||||
KPushButton *m_addDnsBtn;
|
||||
KPushButton *m_removeDnsBtn;
|
||||
KButtonBox *m_buttonBox;
|
||||
KBorderlessButton* m_settingsLabel;
|
||||
QRegExp m_regExp;
|
||||
QString m_uuid;
|
||||
bool m_settingShow;
|
||||
bool m_dnsSettingChanged = false;
|
||||
|
||||
private Q_SLOTS:
|
||||
void setDnsListWidgetStyle();
|
||||
void onAddBtnClicked();
|
||||
void onRemoveBtnClicked();
|
||||
|
||||
Q_SIGNALS:
|
||||
void scrollToBottom();
|
||||
};
|
||||
|
||||
#endif // MULTIPLEDNSWIDGET_H
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include <QMenu>
|
||||
#include <QToolTip>
|
||||
#include <QFontMetrics>
|
||||
#include <QScrollBar>
|
||||
|
||||
#include "windowmanager/windowmanager.h"
|
||||
|
||||
|
@ -282,7 +283,7 @@ void NetDetail::initUI()
|
|||
{
|
||||
QVBoxLayout *mainLayout = new QVBoxLayout(this);
|
||||
mainLayout->setContentsMargins(0,9,0,24);
|
||||
mainLayout->setSpacing(24);
|
||||
mainLayout->setSpacing(0);
|
||||
|
||||
this->installEventFilter(this);
|
||||
pageFrame = new QFrame(this);
|
||||
|
@ -318,6 +319,11 @@ void NetDetail::initUI()
|
|||
m_ipv4ScrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
m_ipv4ScrollArea->setWidget(ipv4Page);
|
||||
m_ipv4ScrollArea->setWidgetResizable(true);
|
||||
connect(ipv4Page, &Ipv4Page::scrollToBottom, this, [&](){
|
||||
QTimer::singleShot(50,this,[=]() {
|
||||
m_ipv4ScrollArea->verticalScrollBar()->setValue(m_ipv4ScrollArea->verticalScrollBar()->maximum());
|
||||
});
|
||||
});
|
||||
|
||||
m_ipv6ScrollArea = new QScrollArea(centerWidget);
|
||||
m_ipv6ScrollArea->setFixedWidth(SCRO_WIDTH);
|
||||
|
@ -325,12 +331,25 @@ void NetDetail::initUI()
|
|||
m_ipv6ScrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
m_ipv6ScrollArea->setWidget(ipv6Page);
|
||||
m_ipv6ScrollArea->setWidgetResizable(true);
|
||||
connect(ipv6Page, &Ipv6Page::scrollToBottom, this, [&](){
|
||||
QTimer::singleShot(50,this,[=]() {
|
||||
m_ipv6ScrollArea->verticalScrollBar()->setValue(m_ipv6ScrollArea->verticalScrollBar()->maximum());
|
||||
});
|
||||
});
|
||||
|
||||
m_createNetPageScrollArea = new QScrollArea(centerWidget);
|
||||
m_createNetPageScrollArea->setFixedWidth(SCRO_WIDTH);
|
||||
m_createNetPageScrollArea->setFrameShape(QFrame::NoFrame);
|
||||
m_createNetPageScrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
m_createNetPageScrollArea->setWidget(createNetPage);
|
||||
m_createNetPageScrollArea->setWidgetResizable(true);
|
||||
|
||||
QPalette pal = m_secuPageScrollArea->palette();
|
||||
pal.setBrush(QPalette::Base, QColor(0,0,0,0));
|
||||
m_secuPageScrollArea->setPalette(pal);
|
||||
m_ipv4ScrollArea->setPalette(pal);
|
||||
m_ipv6ScrollArea->setPalette(pal);
|
||||
m_createNetPageScrollArea->setPalette(pal);
|
||||
|
||||
stackWidget = new QStackedWidget(centerWidget);
|
||||
stackWidget->addWidget(detailPage);
|
||||
|
@ -338,7 +357,7 @@ void NetDetail::initUI()
|
|||
stackWidget->addWidget(m_ipv6ScrollArea);
|
||||
stackWidget->addWidget(m_secuPageScrollArea);
|
||||
stackWidget->addWidget(configPage);
|
||||
stackWidget->addWidget(createNetPage);
|
||||
stackWidget->addWidget(m_createNetPageScrollArea);
|
||||
|
||||
// TabBar
|
||||
onPaletteChanged();
|
||||
|
@ -382,6 +401,8 @@ void NetDetail::initUI()
|
|||
centerlayout->setContentsMargins(CENTER_LAYOUT_MARGINS); // 右边距为0,为安全页滚动区域留出空间
|
||||
centerlayout->addWidget(stackWidget);
|
||||
|
||||
Divider *divider = new Divider(true, this);
|
||||
|
||||
QHBoxLayout *bottomLayout = new QHBoxLayout(bottomWidget);
|
||||
bottomLayout->setContentsMargins(BOTTOM_LAYOUT_MARGINS);
|
||||
bottomLayout->setSpacing(BOTTOM_LAYOUT_SPACING);
|
||||
|
@ -392,7 +413,10 @@ void NetDetail::initUI()
|
|||
bottomWidget->setMinimumHeight(PAGE_MIN_HEIGHT);
|
||||
|
||||
mainLayout->addWidget(pageFrame);
|
||||
mainLayout->addSpacing(24);
|
||||
mainLayout->addWidget(centerWidget);
|
||||
mainLayout->addWidget(divider);
|
||||
mainLayout->addSpacing(16);
|
||||
mainLayout->addWidget(bottomWidget);
|
||||
|
||||
this->setAutoFillBackground(true);
|
||||
|
@ -492,6 +516,8 @@ void NetDetail::pagePadding(QString netName, bool isWlan)
|
|||
detailPage->setAutoConnect(m_info.isAutoConnect);
|
||||
|
||||
//ipv4页面填充
|
||||
ipv4Page->setUuid(m_uuid);
|
||||
ipv4Page->setMulDns(m_info.ipv4DnsList);
|
||||
if (m_info.ipv4ConfigType == CONFIG_IP_MANUAL) {
|
||||
Q_EMIT checkCurrentIpv4Conflict(m_info.strIPV4Address);
|
||||
ipv4Page->setIpv4Config(m_info.ipv4ConfigType);
|
||||
|
@ -499,12 +525,12 @@ void NetDetail::pagePadding(QString netName, bool isWlan)
|
|||
ipv4Page->setNetMask(m_info.strIPV4NetMask);
|
||||
// ipv4Page->setIpv4FirDns(m_info.strIPV4FirDns);
|
||||
// ipv4Page->setIpv4SecDns(m_info.strIPV4SecDns);
|
||||
ipv4Page->setMulDns(m_info.ipv4DnsList);
|
||||
ipv4Page->setGateWay(m_info.strIPV4GateWay);
|
||||
} else {
|
||||
ipv4Page->setIpv4Config(m_info.ipv4ConfigType);
|
||||
}
|
||||
//ipv6页面填充
|
||||
ipv6Page->setMulDns(m_info.ipv6DnsList);
|
||||
if (m_info.ipv6ConfigType == CONFIG_IP_MANUAL) {
|
||||
Q_EMIT checkCurrentIpv6Conflict(m_info.strIPV6Address);
|
||||
ipv6Page->setIpv6Config(m_info.ipv6ConfigType);
|
||||
|
@ -512,7 +538,6 @@ void NetDetail::pagePadding(QString netName, bool isWlan)
|
|||
ipv6Page->setIpv6Perfix(m_info.iIPV6Prefix);
|
||||
// ipv6Page->setIpv6FirDns(m_info.strIPV6FirDns);
|
||||
// ipv6Page->setIpv6SecDns(m_info.strIPV6SecDns);
|
||||
ipv6Page->setMulDns(m_info.ipv6DnsList);
|
||||
ipv6Page->setGateWay(m_info.strIPV6GateWay);
|
||||
} else {
|
||||
ipv6Page->setIpv6Config(m_info.ipv6ConfigType);
|
||||
|
@ -678,6 +703,8 @@ void NetDetail::getStaticIpInfo(ConInfo &conInfo, bool bActived)
|
|||
conInfo.ipv4ConfigType = connetSetting.m_ipv4ConfigIpType;
|
||||
conInfo.ipv6ConfigType = connetSetting.m_ipv6ConfigIpType;
|
||||
conInfo.isAutoConnect = connetSetting.m_isAutoConnect;
|
||||
conInfo.ipv4DnsList = connetSetting.m_ipv4Dns;
|
||||
conInfo.ipv6DnsList = connetSetting.m_ipv6Dns;
|
||||
|
||||
if (connetSetting.m_ipv4ConfigIpType == CONFIG_IP_MANUAL) {
|
||||
if (connetSetting.m_ipv4Address.size() > 0) {
|
||||
|
@ -693,8 +720,6 @@ void NetDetail::getStaticIpInfo(ConInfo &conInfo, bool bActived)
|
|||
conInfo.strIPV4SecDns = connetSetting.m_ipv4Dns.at(1).toString();
|
||||
}
|
||||
#endif
|
||||
|
||||
conInfo.ipv4DnsList = connetSetting.m_ipv4Dns;
|
||||
}
|
||||
|
||||
if (connetSetting.m_ipv6ConfigIpType == CONFIG_IP_MANUAL) {
|
||||
|
@ -711,8 +736,6 @@ void NetDetail::getStaticIpInfo(ConInfo &conInfo, bool bActived)
|
|||
conInfo.strIPV6SecDns = connetSetting.m_ipv6Dns.at(1).toString();
|
||||
}
|
||||
#endif
|
||||
|
||||
conInfo.ipv6DnsList = connetSetting.m_ipv6Dns;
|
||||
}
|
||||
|
||||
if (!bActived) {
|
||||
|
@ -1099,22 +1122,6 @@ bool NetDetail::updateConnect()
|
|||
|
||||
qDebug() << "ipv4Changed" << ipv4Change << "ipv6Change" << ipv6Change;
|
||||
|
||||
// if (ipv4Change && connetSetting.m_ipv4ConfigIpType == CONFIG_IP_MANUAL) {
|
||||
// if (checkIpv4Conflict(connetSetting.m_ipv4Address.at(0).ip().toString())) {
|
||||
// qDebug() << "ipv4 conflict";
|
||||
// showDesktopNotify(tr("ipv4 address conflict!"), "networkwrong");
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
|
||||
// if (ipv6Change && connetSetting.m_ipv6ConfigIpType == CONFIG_IP_MANUAL) {
|
||||
// if (checkIpv6Conflict(connetSetting.m_ipv6Address.at(0).ip().toString())) {
|
||||
// qDebug() << "ipv6 conflict";
|
||||
// showDesktopNotify(tr("ipv6 address conflict!"), "networkwrong");
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
|
||||
if (ipv4Change || ipv6Change) {
|
||||
connetSetting.dumpInfo();
|
||||
m_wiredConnOperation->updateWiredConnect(m_uuid, connetSetting);
|
||||
|
@ -1129,7 +1136,7 @@ bool NetDetail::updateConnect()
|
|||
}
|
||||
}
|
||||
|
||||
if (ipv4Change || ipv6Change || securityChange) {
|
||||
if (ipv4Change || ipv6Change || securityChange || ipv4Page->checkDnsSettingsIsChanged()) {
|
||||
if (isActive) {
|
||||
//信息变化 断开-重连 更新需要時間 不可以立即重連
|
||||
// sleep(1);
|
||||
|
|
|
@ -165,6 +165,7 @@ private:
|
|||
QScrollArea * m_secuPageScrollArea;
|
||||
QScrollArea * m_ipv4ScrollArea;
|
||||
QScrollArea * m_ipv6ScrollArea;
|
||||
QScrollArea * m_createNetPageScrollArea;
|
||||
|
||||
QPushButton * cancelBtn;
|
||||
QPushButton * forgetBtn;
|
||||
|
|
|
@ -12,7 +12,8 @@ HEADERS += \
|
|||
$$PWD/joinhiddenwifipage.h \
|
||||
$$PWD/multiplednswidget.h \
|
||||
$$PWD/netdetail.h \
|
||||
$$PWD/securitypage.h
|
||||
$$PWD/securitypage.h \
|
||||
$$PWD/dnssettingwidget.h
|
||||
|
||||
SOURCES += \
|
||||
$$PWD/configpage.cpp \
|
||||
|
@ -25,4 +26,5 @@ SOURCES += \
|
|||
$$PWD/joinhiddenwifipage.cpp \
|
||||
$$PWD/multiplednswidget.cpp \
|
||||
$$PWD/netdetail.cpp \
|
||||
$$PWD/securitypage.cpp
|
||||
$$PWD/securitypage.cpp \
|
||||
$$PWD/dnssettingwidget.cpp
|
||||
|
|
|
@ -1192,8 +1192,14 @@ void SecurityPage::onClientPrivateKeyComboxIndexChanged(QString str)
|
|||
{
|
||||
if (str.contains("Choose from file...") || str.contains("从文件选择..."))
|
||||
{
|
||||
QString fileName = QFileDialog::getOpenFileName(this, tr("Choose a CA certificate"), "recent:///",
|
||||
tr("CA Files (*.pem *.der *.p12 *.crt *.cer *.pfx)"));
|
||||
QString fileName;
|
||||
// = QFileDialog::getOpenFileName(this, tr("Choose a CA certificate"), "recent:///",
|
||||
// tr("CA Files (*.pem *.der *.p12 *.crt *.cer *.pfx)"));
|
||||
QFileDialog aa;
|
||||
aa.setPalette(lightPalette(this));aa.update();
|
||||
if (aa.exec()) {
|
||||
|
||||
}
|
||||
if (!fileName.isNull()) {
|
||||
QStringList nameList = fileName.split("/");
|
||||
clientPrivateKeyCombox->blockSignals(true);
|
||||
|
|
|
@ -21,20 +21,47 @@
|
|||
#include <QPainter>
|
||||
#include <QApplication>
|
||||
|
||||
Divider::Divider(QWidget * parent) : QFrame(parent)
|
||||
#include "../netdetails/coninfo.h"
|
||||
|
||||
#define THEME_SCHAME "org.ukui.style"
|
||||
#define COLOR_THEME "styleName"
|
||||
|
||||
Divider::Divider(bool useLightPal, QWidget * parent)
|
||||
:m_useLightPal(useLightPal),
|
||||
QFrame(parent)
|
||||
{
|
||||
this->setFixedHeight(1);
|
||||
connect(qApp, &QApplication::paletteChanged, this ,&Divider::onPaletteChanged);
|
||||
onPaletteChanged();
|
||||
}
|
||||
|
||||
void Divider::onPaletteChanged()
|
||||
{
|
||||
QPalette pal = qApp->palette();
|
||||
|
||||
QGSettings * styleGsettings = nullptr;
|
||||
const QByteArray style_id(THEME_SCHAME);
|
||||
if (QGSettings::isSchemaInstalled(style_id) && m_useLightPal) {
|
||||
styleGsettings = new QGSettings(style_id);
|
||||
QString currentTheme = styleGsettings->get(COLOR_THEME).toString();
|
||||
if(currentTheme == "ukui-default"){
|
||||
pal = lightPalette(this);
|
||||
}
|
||||
}
|
||||
m_color = pal.color(QPalette::BrightText);
|
||||
m_color.setAlphaF(0.08);
|
||||
|
||||
if (styleGsettings != nullptr) {
|
||||
delete styleGsettings;
|
||||
styleGsettings = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void Divider::paintEvent(QPaintEvent * e)
|
||||
{
|
||||
QPainter p(this);
|
||||
QColor color = qApp->palette().color(QPalette::BrightText);
|
||||
color.setAlphaF(0.08);
|
||||
p.save();
|
||||
p.setBrush(color);
|
||||
p.setBrush(m_color);
|
||||
p.setPen(Qt::transparent);
|
||||
p.drawRoundedRect(this->rect(), 6, 6);
|
||||
p.restore();
|
||||
|
|
|
@ -24,11 +24,15 @@
|
|||
class Divider : public QFrame
|
||||
{
|
||||
public:
|
||||
Divider(QWidget * parent = nullptr);
|
||||
Divider(bool useLightPal = false, QWidget * parent = nullptr);
|
||||
~Divider() = default;
|
||||
|
||||
private:
|
||||
bool m_useLightPal;
|
||||
QColor m_color;
|
||||
private Q_SLOTS:
|
||||
void onPaletteChanged();
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *event);
|
||||
void paintEvent(QPaintEvent * e);
|
||||
};
|
||||
|
||||
#endif // DIVIDER_H
|
||||
|
|
|
@ -74,3 +74,9 @@ unix {
|
|||
|
||||
DISTFILES += \
|
||||
org.ukui.kylin-nm.switch.gschema.xml
|
||||
|
||||
TRANSLATIONS += \
|
||||
translations/kylin-nm_zh_CN.ts \
|
||||
translations/kylin-nm_tr.ts \
|
||||
translations/kylin-nm_bo.ts \
|
||||
translations/kylin-nm_bo_CN.ts
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue