同步3.22需求
This commit is contained in:
parent
469b7c2d8e
commit
a6dad2d75e
|
@ -1,3 +1,9 @@
|
|||
kylin-nm (3.14.0.0+0512-1k10) yangtz; urgency=medium
|
||||
|
||||
* 同步3.22需求
|
||||
|
||||
-- zhaoshixu <zhaoshixu@kylinos.cn> Wed, 19 Oct 2022 10:01:07 +0800
|
||||
|
||||
kylin-nm (3.14.0.0+0512-0k10) yangtz; urgency=medium
|
||||
|
||||
* close-cd #131075 【网络】普通用户在详情界面修改网络IP信息时会弹出授权框,如果不进行授权详情界面也会显示修改成功,但是实际未修改
|
||||
|
|
|
@ -23,11 +23,27 @@ LanItem::LanItem(bool isAcitve, QWidget *parent)
|
|||
statusLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
||||
// statusLabel->setMinimumSize(36,36);
|
||||
infoLabel = new InfoButton(this);
|
||||
//【更多】菜单
|
||||
m_moreButton = new QToolButton(this);
|
||||
m_moreButton->setProperty("useButtonPalette", true);
|
||||
m_moreButton->setPopupMode(QToolButton::InstantPopup);
|
||||
m_moreButton->setAutoRaise(true);
|
||||
m_moreButton->setIcon(QIcon::fromTheme("view-more-horizontal-symbolic"));
|
||||
m_moreMenu = new QMenu(m_moreButton);
|
||||
m_connectAction = new QAction(m_moreMenu);
|
||||
m_deleteAction = new QAction(tr("Delete"), m_moreMenu);
|
||||
setConnectActionText(isAcitve);
|
||||
|
||||
m_moreMenu->addAction(m_connectAction);
|
||||
m_moreMenu->addAction(m_deleteAction);
|
||||
m_moreButton->setMenu(m_moreMenu);
|
||||
|
||||
mLanLyt->addWidget(iconLabel);
|
||||
mLanLyt->addWidget(titileLabel,Qt::AlignLeft);
|
||||
mLanLyt->addStretch();
|
||||
mLanLyt->addWidget(statusLabel);
|
||||
mLanLyt->addWidget(infoLabel);
|
||||
mLanLyt->addWidget(m_moreButton);
|
||||
|
||||
loadIcons.append(QIcon::fromTheme("ukui-loading-1-symbolic"));
|
||||
loadIcons.append(QIcon::fromTheme("ukui-loading-2-symbolic"));
|
||||
|
@ -38,6 +54,10 @@ LanItem::LanItem(bool isAcitve, QWidget *parent)
|
|||
loadIcons.append(QIcon::fromTheme("ukui-loading-7-symbolic"));
|
||||
waitTimer = new QTimer(this);
|
||||
connect(waitTimer, &QTimer::timeout, this, &LanItem::updateIcon);
|
||||
|
||||
connect(m_connectAction, &QAction::triggered, this, &LanItem::onConnectTriggered);
|
||||
connect(m_deleteAction, &QAction::triggered, this, &LanItem::onDeletetTriggered);
|
||||
m_moreMenu->installEventFilter(this);
|
||||
}
|
||||
|
||||
LanItem::~LanItem()
|
||||
|
@ -65,6 +85,40 @@ void LanItem::stopLoading(){
|
|||
loading = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief LanItem::setConnectActionText
|
||||
* 【更多】菜单状态切换 连接/断开
|
||||
* @param isAcitve
|
||||
*/
|
||||
void LanItem::setConnectActionText(bool isAcitve)
|
||||
{
|
||||
if (isAcitve) {
|
||||
m_connectAction->setText(tr("Disconnect"));
|
||||
} else {
|
||||
m_connectAction->setText(tr("Connect"));
|
||||
}
|
||||
}
|
||||
|
||||
void LanItem::onConnectTriggered()
|
||||
{
|
||||
if (!m_connectAction) {
|
||||
return;
|
||||
}
|
||||
if (m_connectAction->text() == tr("Connect")) {
|
||||
Q_EMIT connectActionTriggered();
|
||||
} else if (m_connectAction->text() == tr("Disconnect")) {
|
||||
Q_EMIT disconnectActionTriggered();
|
||||
}
|
||||
}
|
||||
|
||||
void LanItem::onDeletetTriggered()
|
||||
{
|
||||
if (!m_deleteAction) {
|
||||
return;
|
||||
}
|
||||
Q_EMIT deleteActionTriggered();
|
||||
}
|
||||
|
||||
void LanItem::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
QPalette pal = this->palette();
|
||||
|
@ -80,3 +134,17 @@ void LanItem::paintEvent(QPaintEvent *event)
|
|||
QPushButton::paintEvent(event);
|
||||
}
|
||||
|
||||
bool LanItem::eventFilter(QObject *watched, QEvent *event)
|
||||
{
|
||||
//菜单右边界与按钮右边界对齐
|
||||
if (event->type() == QEvent::Show && watched == m_moreMenu) {
|
||||
int menuXPos = m_moreMenu->pos().x();
|
||||
int menuWidth = m_moreMenu->size().width();
|
||||
int btnWidth = m_moreButton->size().width();
|
||||
|
||||
QPoint pos = QPoint (menuXPos - menuWidth + btnWidth, m_moreMenu->pos().y());
|
||||
m_moreMenu->move(pos);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -10,11 +10,15 @@
|
|||
#include <QDebug>
|
||||
#include <QImage>
|
||||
#include <QPainter>
|
||||
#include <QToolButton>
|
||||
#include <QMenu>
|
||||
#include <QEvent>
|
||||
#include "fixlabel.h"
|
||||
#include "infobutton.h"
|
||||
|
||||
class LanItem : public QPushButton
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
LanItem(bool isAcitve, QWidget *parent = nullptr);
|
||||
~LanItem();
|
||||
|
@ -23,10 +27,15 @@ public:
|
|||
InfoButton * infoLabel = nullptr;
|
||||
FixLabel * titileLabel = nullptr;
|
||||
QLabel * statusLabel = nullptr;
|
||||
QToolButton* m_moreButton = nullptr;
|
||||
QMenu* m_moreMenu = nullptr;
|
||||
QAction* m_connectAction = nullptr;
|
||||
QAction* m_deleteAction = nullptr;
|
||||
|
||||
public:
|
||||
void startLoading();
|
||||
void stopLoading();
|
||||
void setConnectActionText(bool isAcitve);
|
||||
|
||||
bool loading = false;
|
||||
bool isAcitve = false;
|
||||
|
@ -36,6 +45,7 @@ public:
|
|||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *);
|
||||
bool eventFilter(QObject *watched, QEvent *event);
|
||||
|
||||
private:
|
||||
QTimer *waitTimer = nullptr;
|
||||
|
@ -45,6 +55,13 @@ private:
|
|||
|
||||
private slots:
|
||||
void updateIcon();
|
||||
void onConnectTriggered();
|
||||
void onDeletetTriggered();
|
||||
|
||||
Q_SIGNALS:
|
||||
void connectActionTriggered();
|
||||
void disconnectActionTriggered();
|
||||
void deleteActionTriggered();
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -353,6 +353,14 @@ void NetConnect::runExternalApp() {
|
|||
process.startDetached(cmd);
|
||||
}
|
||||
|
||||
//刪除
|
||||
void NetConnect::deleteOneLan(QString ssid, int type)
|
||||
{
|
||||
qDebug() << "[NetConnect]call deleteConnect" << __LINE__;
|
||||
m_interface->call(QStringLiteral("deleteConnect"), type, ssid);
|
||||
qDebug() << "[NetConnect]call deleteConnect respond" << __LINE__;
|
||||
}
|
||||
|
||||
//激活
|
||||
void NetConnect::activeConnect(QString ssid, QString deviceName, int type) {
|
||||
qDebug() << "[NetConnect]call activateConnect" << __LINE__;
|
||||
|
@ -421,12 +429,12 @@ void NetConnect::addLanItem(ItemFrame *frame, QString devName, QStringList infoL
|
|||
return;
|
||||
}
|
||||
|
||||
LanItem * lanItem = new LanItem(pluginWidget);
|
||||
LanItem * lanItem = new LanItem(isActived, pluginWidget);
|
||||
QString iconPath = KLanSymbolic;
|
||||
if (isActived) {
|
||||
lanItem->statusLabel->setText(tr("connected"));
|
||||
} else {
|
||||
lanItem->statusLabel->setText("");
|
||||
lanItem->statusLabel->setText(tr("not connected"));
|
||||
}
|
||||
QIcon searchIcon = QIcon::fromTheme(iconPath);
|
||||
// if (iconPath != KLanSymbolic && iconPath != NoNetSymbolic) {
|
||||
|
@ -449,6 +457,7 @@ void NetConnect::addLanItem(ItemFrame *frame, QString devName, QStringList infoL
|
|||
});
|
||||
|
||||
lanItem->isAcitve = isActived;
|
||||
lanItem->setConnectActionText(lanItem->isAcitve);
|
||||
|
||||
connect(lanItem, &QPushButton::clicked, this, [=] {
|
||||
if (lanItem->isAcitve || lanItem->loading) {
|
||||
|
@ -458,6 +467,16 @@ void NetConnect::addLanItem(ItemFrame *frame, QString devName, QStringList infoL
|
|||
}
|
||||
});
|
||||
|
||||
connect(lanItem, &LanItem::connectActionTriggered, this, [=] {
|
||||
activeConnect(lanItem->uuid, devName, WIRED_TYPE);
|
||||
});
|
||||
connect(lanItem, &LanItem::disconnectActionTriggered, this, [=] {
|
||||
deActiveConnect(lanItem->uuid, devName, WIRED_TYPE);
|
||||
});
|
||||
connect(lanItem, &LanItem::deleteActionTriggered, this, [=] {
|
||||
deleteOneLan(lanItem->uuid, WIRED_TYPE);
|
||||
});
|
||||
|
||||
//记录到deviceFrame的itemMap中
|
||||
deviceFrameMap[devName]->itemMap.insert(infoList.at(1), lanItem);
|
||||
qDebug()<<"insert " << infoList.at(1) << " to " << devName << " list";
|
||||
|
@ -695,7 +714,7 @@ void NetConnect::addOneLanFrame(ItemFrame *frame, QString deviceName, QStringLis
|
|||
|
||||
QString iconPath;
|
||||
iconPath = KLanSymbolic;
|
||||
lanItem->statusLabel->setText("");
|
||||
lanItem->statusLabel->setText(tr("not connected"));
|
||||
|
||||
QIcon searchIcon = QIcon::fromTheme(iconPath);
|
||||
// if (iconPath != KLanSymbolic && iconPath != NoNetSymbolic) {
|
||||
|
@ -718,6 +737,7 @@ void NetConnect::addOneLanFrame(ItemFrame *frame, QString deviceName, QStringLis
|
|||
});
|
||||
|
||||
lanItem->isAcitve = false;
|
||||
lanItem->setConnectActionText(lanItem->isAcitve);
|
||||
|
||||
connect(lanItem, &QPushButton::clicked, this, [=] {
|
||||
if (lanItem->isAcitve || lanItem->loading) {
|
||||
|
@ -727,6 +747,16 @@ void NetConnect::addOneLanFrame(ItemFrame *frame, QString deviceName, QStringLis
|
|||
}
|
||||
});
|
||||
|
||||
connect(lanItem, &LanItem::connectActionTriggered, this, [=] {
|
||||
activeConnect(lanItem->uuid, deviceName, WIRED_TYPE);
|
||||
});
|
||||
connect(lanItem, &LanItem::disconnectActionTriggered, this, [=] {
|
||||
deActiveConnect(lanItem->uuid, deviceName, WIRED_TYPE);
|
||||
});
|
||||
connect(lanItem, &LanItem::deleteActionTriggered, this, [=] {
|
||||
deleteOneLan(lanItem->uuid, WIRED_TYPE);
|
||||
});
|
||||
|
||||
//记录到deviceFrame的itemMap中
|
||||
deviceFrameMap[deviceName]->itemMap.insert(connUuid, lanItem);
|
||||
int index = getInsertPos(connName, deviceName);
|
||||
|
@ -841,7 +871,9 @@ void NetConnect::itemActiveConnectionStatusChanged(LanItem *item, int status)
|
|||
item->statusLabel->setMaximumSize(16777215,16777215);
|
||||
item->statusLabel->clear();
|
||||
item->isAcitve = false;
|
||||
item->statusLabel->setText(tr("not connected"));
|
||||
}
|
||||
item->setConnectActionText(item->isAcitve);
|
||||
|
||||
// QIcon searchIcon = QIcon::fromTheme(iconPath);
|
||||
// item->iconLabel->setPixmap(searchIcon.pixmap(searchIcon.actualSize(QSize(24, 24))));
|
||||
|
|
|
@ -101,7 +101,7 @@ private:
|
|||
int getInsertPos(QString connName, QString deviceName);
|
||||
|
||||
|
||||
void deleteOneLan(QString ssid);
|
||||
void deleteOneLan(QString ssid, int type);
|
||||
void activeConnect(QString ssid, QString deviceName, int type);
|
||||
void deActiveConnect(QString ssid, QString deviceName, int type);
|
||||
|
||||
|
|
|
@ -4,61 +4,93 @@
|
|||
<context>
|
||||
<name>AddNetBtn</name>
|
||||
<message>
|
||||
<location filename="../addnetbtn.cpp" line="22"/>
|
||||
<location filename="../../component/AddBtn/addnetbtn.cpp" line="24"/>
|
||||
<source>Add Others</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../component/AddBtn/addnetbtn.cpp" line="28"/>
|
||||
<source>Add WiredNetork</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>LanItem</name>
|
||||
<message>
|
||||
<location filename="../lanitem.cpp" line="34"/>
|
||||
<source>Delete</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../lanitem.cpp" line="96"/>
|
||||
<location filename="../lanitem.cpp" line="109"/>
|
||||
<source>Disconnect</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../lanitem.cpp" line="98"/>
|
||||
<location filename="../lanitem.cpp" line="107"/>
|
||||
<source>Connect</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>NetConnect</name>
|
||||
<message>
|
||||
<location filename="../netconnect.ui" line="50"/>
|
||||
<location filename="../netconnect.cpp" line="152"/>
|
||||
<location filename="../netconnect.cpp" line="153"/>
|
||||
<source>Wired Network</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../netconnect.ui" line="112"/>
|
||||
<location filename="../netconnect.cpp" line="154"/>
|
||||
<location filename="../netconnect.cpp" line="155"/>
|
||||
<source>open</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<extra-contents_path>/netconnect/open</extra-contents_path>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../netconnect.ui" line="198"/>
|
||||
<location filename="../netconnect.cpp" line="151"/>
|
||||
<location filename="../netconnect.cpp" line="152"/>
|
||||
<source>Advanced settings</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<extra-contents_path>/netconnect/Advanced settings"</extra-contents_path>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../netconnect.cpp" line="63"/>
|
||||
<location filename="../netconnect.cpp" line="64"/>
|
||||
<source>ukui control center</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../netconnect.cpp" line="66"/>
|
||||
<location filename="../netconnect.cpp" line="67"/>
|
||||
<source>ukui control center desktop message</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../netconnect.cpp" line="80"/>
|
||||
<location filename="../netconnect.cpp" line="81"/>
|
||||
<source>WiredConnect</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../netconnect.cpp" line="177"/>
|
||||
<location filename="../netconnect.cpp" line="169"/>
|
||||
<source>No ethernet device avaliable</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../netconnect.cpp" line="426"/>
|
||||
<location filename="../netconnect.cpp" line="833"/>
|
||||
<location filename="../netconnect.cpp" line="435"/>
|
||||
<location filename="../netconnect.cpp" line="864"/>
|
||||
<source>connected</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../netconnect.cpp" line="490"/>
|
||||
<location filename="../netconnect.cpp" line="437"/>
|
||||
<location filename="../netconnect.cpp" line="717"/>
|
||||
<location filename="../netconnect.cpp" line="874"/>
|
||||
<source>not connected</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../netconnect.cpp" line="510"/>
|
||||
<source>card</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
|
|
|
@ -4,61 +4,93 @@
|
|||
<context>
|
||||
<name>AddNetBtn</name>
|
||||
<message>
|
||||
<location filename="../addnetbtn.cpp" line="22"/>
|
||||
<location filename="../../component/AddBtn/addnetbtn.cpp" line="24"/>
|
||||
<source>Add Others</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../component/AddBtn/addnetbtn.cpp" line="28"/>
|
||||
<source>Add WiredNetork</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>LanItem</name>
|
||||
<message>
|
||||
<location filename="../lanitem.cpp" line="34"/>
|
||||
<source>Delete</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../lanitem.cpp" line="96"/>
|
||||
<location filename="../lanitem.cpp" line="109"/>
|
||||
<source>Disconnect</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../lanitem.cpp" line="98"/>
|
||||
<location filename="../lanitem.cpp" line="107"/>
|
||||
<source>Connect</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>NetConnect</name>
|
||||
<message>
|
||||
<location filename="../netconnect.ui" line="50"/>
|
||||
<location filename="../netconnect.cpp" line="152"/>
|
||||
<location filename="../netconnect.cpp" line="153"/>
|
||||
<source>Wired Network</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../netconnect.ui" line="112"/>
|
||||
<location filename="../netconnect.cpp" line="154"/>
|
||||
<location filename="../netconnect.cpp" line="155"/>
|
||||
<source>open</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<extra-contents_path>/netconnect/open</extra-contents_path>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../netconnect.ui" line="198"/>
|
||||
<location filename="../netconnect.cpp" line="151"/>
|
||||
<location filename="../netconnect.cpp" line="152"/>
|
||||
<source>Advanced settings</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<extra-contents_path>/netconnect/Advanced settings"</extra-contents_path>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../netconnect.cpp" line="63"/>
|
||||
<location filename="../netconnect.cpp" line="64"/>
|
||||
<source>ukui control center</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../netconnect.cpp" line="66"/>
|
||||
<location filename="../netconnect.cpp" line="67"/>
|
||||
<source>ukui control center desktop message</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../netconnect.cpp" line="80"/>
|
||||
<location filename="../netconnect.cpp" line="81"/>
|
||||
<source>WiredConnect</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../netconnect.cpp" line="177"/>
|
||||
<location filename="../netconnect.cpp" line="169"/>
|
||||
<source>No ethernet device avaliable</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../netconnect.cpp" line="426"/>
|
||||
<location filename="../netconnect.cpp" line="833"/>
|
||||
<location filename="../netconnect.cpp" line="435"/>
|
||||
<location filename="../netconnect.cpp" line="864"/>
|
||||
<source>connected</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../netconnect.cpp" line="490"/>
|
||||
<location filename="../netconnect.cpp" line="437"/>
|
||||
<location filename="../netconnect.cpp" line="717"/>
|
||||
<location filename="../netconnect.cpp" line="874"/>
|
||||
<source>not connected</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../netconnect.cpp" line="510"/>
|
||||
<source>card</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
|
|
Binary file not shown.
|
@ -4,61 +4,93 @@
|
|||
<context>
|
||||
<name>AddNetBtn</name>
|
||||
<message>
|
||||
<location filename="../addnetbtn.cpp" line="22"/>
|
||||
<location filename="../../component/AddBtn/addnetbtn.cpp" line="24"/>
|
||||
<source>Add Others</source>
|
||||
<translation>加入其他网络</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../component/AddBtn/addnetbtn.cpp" line="28"/>
|
||||
<source>Add WiredNetork</source>
|
||||
<translation>添加有线网络</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>LanItem</name>
|
||||
<message>
|
||||
<location filename="../lanitem.cpp" line="34"/>
|
||||
<source>Delete</source>
|
||||
<translation>删除</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../lanitem.cpp" line="96"/>
|
||||
<location filename="../lanitem.cpp" line="109"/>
|
||||
<source>Disconnect</source>
|
||||
<translation>断开</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../lanitem.cpp" line="98"/>
|
||||
<location filename="../lanitem.cpp" line="107"/>
|
||||
<source>Connect</source>
|
||||
<translation>连接</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>NetConnect</name>
|
||||
<message>
|
||||
<location filename="../netconnect.ui" line="50"/>
|
||||
<location filename="../netconnect.cpp" line="152"/>
|
||||
<location filename="../netconnect.cpp" line="153"/>
|
||||
<source>Wired Network</source>
|
||||
<translation>有线网络</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../netconnect.ui" line="112"/>
|
||||
<location filename="../netconnect.cpp" line="154"/>
|
||||
<location filename="../netconnect.cpp" line="155"/>
|
||||
<source>open</source>
|
||||
<translation>开启</translation>
|
||||
<extra-contents_path>/netconnect/open</extra-contents_path>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../netconnect.ui" line="198"/>
|
||||
<location filename="../netconnect.cpp" line="151"/>
|
||||
<location filename="../netconnect.cpp" line="152"/>
|
||||
<source>Advanced settings</source>
|
||||
<translation>高级设置</translation>
|
||||
<extra-contents_path>/netconnect/Advanced settings"</extra-contents_path>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../netconnect.cpp" line="63"/>
|
||||
<location filename="../netconnect.cpp" line="64"/>
|
||||
<source>ukui control center</source>
|
||||
<translation>控制面板</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../netconnect.cpp" line="66"/>
|
||||
<location filename="../netconnect.cpp" line="67"/>
|
||||
<source>ukui control center desktop message</source>
|
||||
<translation>控制面板桌面通知</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../netconnect.cpp" line="80"/>
|
||||
<location filename="../netconnect.cpp" line="81"/>
|
||||
<source>WiredConnect</source>
|
||||
<translation>有线网络</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../netconnect.cpp" line="177"/>
|
||||
<location filename="../netconnect.cpp" line="169"/>
|
||||
<source>No ethernet device avaliable</source>
|
||||
<translation>未检测到有线设备</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../netconnect.cpp" line="426"/>
|
||||
<location filename="../netconnect.cpp" line="833"/>
|
||||
<location filename="../netconnect.cpp" line="435"/>
|
||||
<location filename="../netconnect.cpp" line="864"/>
|
||||
<source>connected</source>
|
||||
<translation>已连接</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../netconnect.cpp" line="490"/>
|
||||
<location filename="../netconnect.cpp" line="437"/>
|
||||
<location filename="../netconnect.cpp" line="717"/>
|
||||
<location filename="../netconnect.cpp" line="874"/>
|
||||
<source>not connected</source>
|
||||
<translation>未连接</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../netconnect.cpp" line="510"/>
|
||||
<source>card</source>
|
||||
<translation>网卡</translation>
|
||||
</message>
|
||||
|
|
|
@ -143,6 +143,18 @@ void DbusAdaptor::setDeviceEnable(QString devName, bool enable)
|
|||
// return deviceName;
|
||||
//}
|
||||
|
||||
//删除
|
||||
void DbusAdaptor::deleteConnect(int type, QString ssid)
|
||||
{
|
||||
if (type == WIRED) {
|
||||
parent()->deleteWired(ssid);
|
||||
} else if (type == WIRELESS) {
|
||||
//待实现
|
||||
} else {
|
||||
qDebug() << "[DbusAdaptor] deleteConnect type is invalid";
|
||||
}
|
||||
}
|
||||
|
||||
//连接 根据网卡类型 参数1 0:lan 1:wlan 参数3 为ssid/uuid
|
||||
void DbusAdaptor::activateConnect(int type, QString devName, QString ssid)
|
||||
{
|
||||
|
|
|
@ -62,6 +62,8 @@ public Q_SLOTS: // METHODS
|
|||
// QString getDefaultWiredDevice();
|
||||
// Q_NOREPLY void setDefaultWirelessDevice(QString deviceName);
|
||||
// QString getDefaultWirelessDevice();
|
||||
//刪除 根据网络名称 参数1 0:lan 1:wlan 参数2 为ssid/uuid
|
||||
Q_NOREPLY void deleteConnect(int type, QString ssid);
|
||||
//连接 根据网卡类型 参数1 0:lan 1:wlan 参数3 为ssid/uuid
|
||||
Q_NOREPLY void activateConnect(int type, QString devName, QString ssid);
|
||||
//断开连接 根据网卡类型 参数1 0:lan 1:wlan 参数3 为ssid/uuid
|
||||
|
|
|
@ -802,6 +802,12 @@ void MainWindow::getWirelessDeviceCap(QMap<QString, int> &map)
|
|||
m_wlanWidget->getWirelessDeviceCap(map);
|
||||
}
|
||||
|
||||
//有线连接删除
|
||||
void MainWindow::deleteWired(const QString &connUuid)
|
||||
{
|
||||
m_lanWidget->deleteWired(connUuid);
|
||||
}
|
||||
|
||||
//有线连接断开
|
||||
void MainWindow::activateWired(const QString& devName, const QString& connUuid)
|
||||
{
|
||||
|
|
|
@ -55,6 +55,8 @@ public:
|
|||
//获取热点
|
||||
void getStoredApInfo(QStringList &list);
|
||||
void getApInfoBySsid(QString devName, QString ssid, QStringList &list);
|
||||
//删除有线连接
|
||||
void deleteWired(const QString& connUuid);
|
||||
//有线连接断开
|
||||
void activateWired(const QString& devName, const QString& connUuid);
|
||||
void deactivateWired(const QString& devName, const QString& connUuid);
|
||||
|
|
|
@ -71,16 +71,18 @@ public:
|
|||
KyIpConfigType ipv4ConfigType = CONFIG_IP_DHCP;
|
||||
QString strIPV4Address;
|
||||
QString strIPV4NetMask;
|
||||
QString strIPV4FirDns;
|
||||
QString strIPV4SecDns;
|
||||
// QString strIPV4FirDns;
|
||||
// QString strIPV4SecDns;
|
||||
QString strIPV4GateWay;
|
||||
QList<QHostAddress> ipv4DnsList;
|
||||
|
||||
KyIpConfigType ipv6ConfigType = CONFIG_IP_DHCP;
|
||||
QString strIPV6Address;
|
||||
int iIPV6Prefix;
|
||||
QString strIPV6FirDns;
|
||||
QString strIPV6SecDns;
|
||||
// QString strIPV6FirDns;
|
||||
// QString strIPV6SecDns;
|
||||
QString strIPV6GateWay;
|
||||
QList<QHostAddress> ipv6DnsList;
|
||||
|
||||
KyEapMethodType enterpriseType;
|
||||
KyEapMethodTlsInfo tlsInfo;
|
||||
|
|
|
@ -17,46 +17,49 @@ void CreatNetPage::initUI()
|
|||
ipv4addressEdit = new LineEdit(this);
|
||||
netMaskEdit = new LineEdit(this);
|
||||
gateWayEdit = new LineEdit(this);
|
||||
firstDnsEdit = new LineEdit(this);
|
||||
secondDnsEdit = new LineEdit(this);
|
||||
// firstDnsEdit = new LineEdit(this);
|
||||
// secondDnsEdit = new LineEdit(this);
|
||||
|
||||
m_connNameLabel = new QLabel(this);
|
||||
m_configLabel = new QLabel(this);
|
||||
m_addressLabel = new QLabel(this);
|
||||
m_maskLabel = new QLabel(this);
|
||||
m_gateWayLabel = new QLabel(this);
|
||||
m_dnsLabel = new QLabel(this);
|
||||
m_secDnsLabel = new QLabel(this);
|
||||
// m_dnsLabel = new QLabel(this);
|
||||
// m_secDnsLabel = new QLabel(this);
|
||||
|
||||
m_connNameLabel->setText(tr("Connection Name"));
|
||||
m_configLabel->setText(tr("Ipv4Config"));
|
||||
m_addressLabel->setText(tr("Address"));
|
||||
m_maskLabel->setText(tr("Netmask"));
|
||||
m_gateWayLabel->setText(tr("Default Gateway"));
|
||||
m_dnsLabel->setText(tr("Prefs DNS"));
|
||||
m_secDnsLabel->setText(tr("Alternative DNS"));
|
||||
// m_dnsLabel->setText(tr("Prefs DNS"));
|
||||
// m_secDnsLabel->setText(tr("Alternative DNS"));
|
||||
|
||||
// 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_detailLayout = new QFormLayout(this);
|
||||
m_detailLayout->setContentsMargins(0, 0, 0, 0);
|
||||
m_detailLayout->setSpacing(24);
|
||||
m_detailLayout->addRow(m_connNameLabel,connNameEdit);
|
||||
m_detailLayout->addRow(m_configLabel,ipv4ConfigCombox);
|
||||
m_detailLayout->addRow(m_addressLabel,ipv4addressEdit);
|
||||
m_detailLayout->addRow(m_maskLabel,netMaskEdit);
|
||||
m_detailLayout->addRow(m_gateWayLabel,gateWayEdit);
|
||||
m_detailLayout->addRow(m_dnsLabel,firstDnsEdit);
|
||||
m_detailLayout->addRow(m_secDnsLabel,secondDnsEdit);
|
||||
// m_detailLayout->addRow(m_dnsLabel,firstDnsEdit);
|
||||
// m_detailLayout->addRow(m_secDnsLabel,secondDnsEdit);
|
||||
m_detailLayout->addRow(m_dnsWidget);
|
||||
|
||||
ipv4ConfigCombox->addItem(tr("Auto(DHCP)"), AUTO_CONFIG); //"自动(DHCP)"
|
||||
ipv4ConfigCombox->addItem(tr("Manual"), MANUAL_CONFIG); //"手动"
|
||||
|
||||
|
||||
// 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");
|
||||
|
||||
ipv4addressEdit->setValidator(new QRegExpValidator(rx, this));
|
||||
gateWayEdit->setValidator(new QRegExpValidator(rx, this));
|
||||
netMaskEdit->setValidator(new QRegExpValidator(rx, this));
|
||||
firstDnsEdit->setValidator(new QRegExpValidator(rx, this));
|
||||
secondDnsEdit->setValidator(new QRegExpValidator(rx, this));
|
||||
// firstDnsEdit->setValidator(new QRegExpValidator(rx, this));
|
||||
// secondDnsEdit->setValidator(new QRegExpValidator(rx, this));
|
||||
}
|
||||
|
||||
void CreatNetPage::initComponent() {
|
||||
|
@ -71,8 +74,14 @@ void CreatNetPage::initComponent() {
|
|||
connect(ipv4ConfigCombox, SIGNAL(currentIndexChanged(int)), this, SLOT(setEnableOfSaveBtn()));
|
||||
connect(netMaskEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn()));
|
||||
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(firstDnsEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn()));
|
||||
// connect(secondDnsEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn()));
|
||||
connect(m_dnsWidget, &MultipleDnsWidget::dnsTextChanged, this, [=]() {
|
||||
setCreatePageState(false);
|
||||
});
|
||||
connect(m_dnsWidget, &MultipleDnsWidget::dnsEditingFinished, this, [=]() {
|
||||
setCreatePageState(true);
|
||||
});
|
||||
}
|
||||
|
||||
bool CreatNetPage::checkConnectBtnIsEnabled()
|
||||
|
@ -99,7 +108,7 @@ bool CreatNetPage::checkConnectBtnIsEnabled()
|
|||
qDebug() << "create ipv4 gateway empty or invalid";
|
||||
return false;
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (firstDnsEdit->text().isEmpty() && !secondDnsEdit->text().isEmpty()) {
|
||||
qDebug() << "create ipv4 dns sort invalid";
|
||||
return false;
|
||||
|
@ -114,6 +123,7 @@ bool CreatNetPage::checkConnectBtnIsEnabled()
|
|||
qDebug() << "create ipv4 second dns invalid";
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -132,15 +142,22 @@ void CreatNetPage::setLineEnabled(bool check) {
|
|||
ipv4addressEdit->setEnabled(check);
|
||||
netMaskEdit->setEnabled(check);
|
||||
gateWayEdit->setEnabled(check);
|
||||
firstDnsEdit->setEnabled(check);
|
||||
secondDnsEdit->setEnabled(check);
|
||||
// firstDnsEdit->setEnabled(check);
|
||||
// secondDnsEdit->setEnabled(check);
|
||||
m_dnsWidget->setEditEnabled(check);
|
||||
|
||||
if (!check) {
|
||||
ipv4addressEdit->clear();
|
||||
netMaskEdit->clear();
|
||||
gateWayEdit->clear();
|
||||
firstDnsEdit->clear();
|
||||
secondDnsEdit->clear();
|
||||
// firstDnsEdit->clear();
|
||||
// secondDnsEdit->clear();
|
||||
|
||||
ipv4addressEdit->setPlaceholderText(" ");
|
||||
netMaskEdit->setPlaceholderText(" ");
|
||||
} else {
|
||||
ipv4addressEdit->setPlaceholderText(tr("Required")); //必填
|
||||
netMaskEdit->setPlaceholderText(tr("Required")); //必填
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -172,13 +189,23 @@ void CreatNetPage::constructIpv4Info(KyConnectSetting &setting)
|
|||
<< " gateWay " << gateWay;
|
||||
|
||||
QStringList dnsList;
|
||||
dnsList.empty();
|
||||
dnsList.clear();
|
||||
#if 0
|
||||
if (!firstDnsEdit->text().isEmpty()) {
|
||||
dnsList << firstDnsEdit->text();
|
||||
if (!secondDnsEdit->text().isEmpty()) {
|
||||
dnsList << secondDnsEdit->text();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
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 {
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include <QDebug>
|
||||
|
||||
#include "coninfo.h"
|
||||
#include "multiplednswidget.h"
|
||||
|
||||
class CreatNetPage : public QFrame
|
||||
{
|
||||
|
@ -27,10 +28,9 @@ private:
|
|||
LineEdit *ipv4addressEdit;
|
||||
LineEdit *netMaskEdit;
|
||||
LineEdit *gateWayEdit;
|
||||
LineEdit *firstDnsEdit;
|
||||
LineEdit *secondDnsEdit;
|
||||
// LineEdit *firstDnsEdit;
|
||||
// LineEdit *secondDnsEdit;
|
||||
|
||||
private:
|
||||
QFormLayout *m_detailLayout;
|
||||
QVBoxLayout *mvBoxLayout;
|
||||
QLabel *m_connNameLabel;
|
||||
|
@ -38,8 +38,9 @@ private:
|
|||
QLabel *m_addressLabel;
|
||||
QLabel *m_maskLabel;
|
||||
QLabel *m_gateWayLabel;
|
||||
QLabel *m_dnsLabel;
|
||||
QLabel *m_secDnsLabel;
|
||||
// QLabel *m_dnsLabel;
|
||||
// QLabel *m_secDnsLabel;
|
||||
MultipleDnsWidget *m_dnsWidget = nullptr;
|
||||
private:
|
||||
void initUI();
|
||||
void initComponent();
|
||||
|
|
|
@ -13,30 +13,35 @@ void Ipv4Page::initUI() {
|
|||
ipv4addressEdit = new LineEdit(this);
|
||||
netMaskEdit = new LineEdit(this);
|
||||
gateWayEdit = new LineEdit(this);
|
||||
firstDnsEdit = new LineEdit(this);
|
||||
secondDnsEdit = new LineEdit(this);
|
||||
// firstDnsEdit = new LineEdit(this);
|
||||
// secondDnsEdit = new LineEdit(this);
|
||||
|
||||
m_configLabel = new QLabel(this);
|
||||
m_addressLabel = new QLabel(this);
|
||||
m_maskLabel = new QLabel(this);
|
||||
m_gateWayLabel = new QLabel(this);
|
||||
m_dnsLabel = new QLabel(this);
|
||||
m_secDnsLabel = new QLabel(this);
|
||||
// m_dnsLabel = new QLabel(this);
|
||||
// m_secDnsLabel = new QLabel(this);
|
||||
|
||||
m_configLabel->setText(tr("Ipv4Config"));
|
||||
m_addressLabel->setText(tr("Address"));
|
||||
m_maskLabel->setText(tr("Netmask"));
|
||||
m_gateWayLabel->setText(tr("Default Gateway"));
|
||||
m_dnsLabel->setText(tr("Prefs DNS"));
|
||||
m_secDnsLabel->setText(tr("Alternative DNS"));
|
||||
// m_dnsLabel->setText(tr("Prefs DNS"));
|
||||
// m_secDnsLabel->setText(tr("Alternative DNS"));
|
||||
|
||||
// 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_detailLayout = new QFormLayout(this);
|
||||
m_detailLayout->addRow(m_configLabel,ipv4ConfigCombox);
|
||||
m_detailLayout->addRow(m_addressLabel,ipv4addressEdit);
|
||||
m_detailLayout->addRow(m_maskLabel,netMaskEdit);
|
||||
m_detailLayout->addRow(m_gateWayLabel,gateWayEdit);
|
||||
m_detailLayout->addRow(m_dnsLabel,firstDnsEdit);
|
||||
m_detailLayout->addRow(m_secDnsLabel,secondDnsEdit);
|
||||
// m_detailLayout->addRow(m_dnsLabel,firstDnsEdit);
|
||||
// m_detailLayout->addRow(m_secDnsLabel,secondDnsEdit);
|
||||
m_detailLayout->addRow(m_dnsWidget);
|
||||
|
||||
ipv4ConfigCombox->addItem(tr("Auto(DHCP)")); //"自动(DHCP)"
|
||||
ipv4ConfigCombox->addItem(tr("Manual")); //"手动"
|
||||
|
@ -48,15 +53,11 @@ void Ipv4Page::initUI() {
|
|||
// netMaskCombox->addItem("255.255.0.0"); //16
|
||||
// netMaskCombox->addItem("255.0.0.0"); //8
|
||||
|
||||
|
||||
// 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");
|
||||
|
||||
ipv4addressEdit->setValidator(new QRegExpValidator(rx, this));
|
||||
gateWayEdit->setValidator(new QRegExpValidator(rx, this));
|
||||
netMaskEdit->setValidator(new QRegExpValidator(rx, this));
|
||||
firstDnsEdit->setValidator(new QRegExpValidator(rx, this));
|
||||
secondDnsEdit->setValidator(new QRegExpValidator(rx, this));
|
||||
// firstDnsEdit->setValidator(new QRegExpValidator(rx, this));
|
||||
// secondDnsEdit->setValidator(new QRegExpValidator(rx, this));
|
||||
}
|
||||
|
||||
void Ipv4Page::initComponent() {
|
||||
|
@ -71,8 +72,14 @@ 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(firstDnsEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn()));
|
||||
connect(secondDnsEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn()));
|
||||
// connect(firstDnsEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn()));
|
||||
// connect(secondDnsEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn()));
|
||||
connect(m_dnsWidget, &MultipleDnsWidget::dnsTextChanged, this, [=]() {
|
||||
setIpv4PageState(false);
|
||||
});
|
||||
connect(m_dnsWidget, &MultipleDnsWidget::dnsEditingFinished, this, [=]() {
|
||||
setIpv4PageState(true);
|
||||
});
|
||||
}
|
||||
|
||||
void Ipv4Page::setIpv4Config(KyIpConfigType ipv4Config)
|
||||
|
@ -94,6 +101,11 @@ void Ipv4Page::setNetMask(const QString &netMask)
|
|||
netMaskEdit->setText(netMask);
|
||||
}
|
||||
|
||||
void Ipv4Page::setMulDns(const QList<QHostAddress> &dns)
|
||||
{
|
||||
m_dnsWidget->setDnsListText(dns);
|
||||
}
|
||||
#if 0
|
||||
void Ipv4Page::setIpv4FirDns(const QString &ipv4FirDns)
|
||||
{
|
||||
firstDnsEdit->setText(ipv4FirDns);
|
||||
|
@ -103,7 +115,7 @@ void Ipv4Page::setIpv4SecDns(const QString &ipv4SecDns)
|
|||
{
|
||||
secondDnsEdit->setText(ipv4SecDns);
|
||||
}
|
||||
|
||||
#endif
|
||||
void Ipv4Page::setGateWay(const QString &gateWay)
|
||||
{
|
||||
gateWayEdit->setText(gateWay);
|
||||
|
@ -132,15 +144,25 @@ bool Ipv4Page::checkIsChanged(const ConInfo info, KyConnectSetting &setting)
|
|||
isChanged = true;
|
||||
}
|
||||
qDebug() << "ipv4 netmask " << getNetMaskText(netMaskEdit->text());
|
||||
|
||||
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.strIPV4FirDns != firstDnsEdit->text()
|
||||
|| info.strIPV4SecDns != secondDnsEdit->text()) {
|
||||
// || info.strIPV4FirDns != firstDnsEdit->text()
|
||||
// || info.strIPV4SecDns != secondDnsEdit->text()
|
||||
|| info.ipv4DnsList != ipv4dnsList) {
|
||||
|
||||
qDebug() << "ipv4 info changed";
|
||||
QStringList dnsList;
|
||||
dnsList.empty();
|
||||
dnsList.clear();
|
||||
for (QHostAddress str: ipv4dnsList) {
|
||||
dnsList << str.toString();
|
||||
}
|
||||
#if 0
|
||||
if (!firstDnsEdit->text().isEmpty()) {
|
||||
dnsList << firstDnsEdit->text();
|
||||
if (!secondDnsEdit->text().isEmpty()) {
|
||||
|
@ -148,6 +170,7 @@ bool Ipv4Page::checkIsChanged(const ConInfo info, KyConnectSetting &setting)
|
|||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
QString ipv4address =ipv4addressEdit->text();
|
||||
QString netMask = getNetMaskText(netMaskEdit->text());
|
||||
QString gateWay = gateWayEdit->text();
|
||||
|
@ -180,7 +203,7 @@ bool Ipv4Page::checkConnectBtnIsEnabled()
|
|||
// qDebug() << "ipv4 gateway empty or invalid";
|
||||
// return false;
|
||||
// }
|
||||
|
||||
#if 0
|
||||
if (firstDnsEdit->text().isEmpty() && !secondDnsEdit->text().isEmpty()) {
|
||||
qDebug() << "ipv4 dns sort invalid";
|
||||
return false;
|
||||
|
@ -195,6 +218,7 @@ bool Ipv4Page::checkConnectBtnIsEnabled()
|
|||
qDebug() << "ipv4 second dns invalid";
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -213,15 +237,16 @@ void Ipv4Page::setLineEnabled(bool check) {
|
|||
ipv4addressEdit->setEnabled(check);
|
||||
netMaskEdit->setEnabled(check);
|
||||
gateWayEdit->setEnabled(check);
|
||||
firstDnsEdit->setEnabled(check);
|
||||
secondDnsEdit->setEnabled(check);
|
||||
// firstDnsEdit->setEnabled(check);
|
||||
// secondDnsEdit->setEnabled(check);
|
||||
m_dnsWidget->setEditEnabled(check);
|
||||
|
||||
if (!check) {
|
||||
ipv4addressEdit->clear();
|
||||
netMaskEdit->clear();
|
||||
gateWayEdit->clear();
|
||||
firstDnsEdit->clear();
|
||||
secondDnsEdit->clear();
|
||||
// firstDnsEdit->clear();
|
||||
// secondDnsEdit->clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
//#include "kylinconnectsetting.h"
|
||||
#include "coninfo.h"
|
||||
#include "multiplednswidget.h"
|
||||
|
||||
class Ipv4Page : public QFrame
|
||||
{
|
||||
|
@ -23,8 +24,9 @@ public:
|
|||
void setIpv4Config(KyIpConfigType ipv4Config);
|
||||
void setIpv4(const QString &ipv4);
|
||||
void setNetMask(const QString &netMask);
|
||||
void setIpv4FirDns(const QString &ipv4FirDns);
|
||||
void setIpv4SecDns(const QString &ipv4SecDns);
|
||||
// void setIpv4FirDns(const QString &ipv4FirDns);
|
||||
// void setIpv4SecDns(const QString &ipv4SecDns);
|
||||
void setMulDns(const QList<QHostAddress> &dns);
|
||||
void setGateWay(const QString &gateWay);
|
||||
|
||||
QString getNetMaskText(QString text);
|
||||
|
@ -35,8 +37,8 @@ private:
|
|||
LineEdit *ipv4addressEdit;
|
||||
LineEdit *netMaskEdit;
|
||||
LineEdit *gateWayEdit;
|
||||
LineEdit *firstDnsEdit;
|
||||
LineEdit *secondDnsEdit;
|
||||
// LineEdit *firstDnsEdit;
|
||||
// LineEdit *secondDnsEdit;
|
||||
|
||||
private:
|
||||
QFormLayout *m_detailLayout;
|
||||
|
@ -45,8 +47,9 @@ private:
|
|||
QLabel *m_addressLabel;
|
||||
QLabel *m_maskLabel;
|
||||
QLabel *m_gateWayLabel;
|
||||
QLabel *m_dnsLabel;
|
||||
QLabel *m_secDnsLabel;
|
||||
// QLabel *m_dnsLabel;
|
||||
// QLabel *m_secDnsLabel;
|
||||
MultipleDnsWidget *m_dnsWidget = nullptr;
|
||||
private:
|
||||
void initUI();
|
||||
void initComponent();
|
||||
|
|
|
@ -26,6 +26,11 @@ void Ipv6Page::setIpv6Perfix(const int &ipv6Perfix)
|
|||
lengthEdit->setText(QString::number(ipv6Perfix));
|
||||
}
|
||||
|
||||
void Ipv6Page::setMulDns(const QList<QHostAddress> &dns)
|
||||
{
|
||||
m_dnsWidget->setDnsListText(dns);
|
||||
}
|
||||
#if 0
|
||||
void Ipv6Page::setIpv6FirDns(const QString &ipv6FirDns)
|
||||
{
|
||||
firstDnsEdit->setText(ipv6FirDns);
|
||||
|
@ -35,7 +40,7 @@ void Ipv6Page::setIpv6SecDns(const QString &ipv6SecDns)
|
|||
{
|
||||
secondDnsEdit->setText(ipv6SecDns);
|
||||
}
|
||||
|
||||
#endif
|
||||
void Ipv6Page::setGateWay(const QString &gateWay)
|
||||
{
|
||||
gateWayEdit->setText(gateWay);
|
||||
|
@ -62,22 +67,32 @@ bool Ipv6Page::checkIsChanged(const ConInfo info, KyConnectSetting &setting)
|
|||
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.strIPV6FirDns != firstDnsEdit->text()
|
||||
|| info.strIPV6SecDns != secondDnsEdit->text()) {
|
||||
// || info.strIPV6FirDns != firstDnsEdit->text()
|
||||
// || info.strIPV6SecDns != secondDnsEdit->text()
|
||||
|| info.ipv6DnsList != ipv6dnsList) {
|
||||
|
||||
qDebug() << "ipv6 info changed";
|
||||
QStringList dnsList;
|
||||
dnsList.empty();
|
||||
dnsList.clear();
|
||||
for (QHostAddress str: ipv6dnsList) {
|
||||
dnsList << str.toString();
|
||||
}
|
||||
#if 0
|
||||
if (!firstDnsEdit->text().isEmpty()) {
|
||||
dnsList << firstDnsEdit->text();
|
||||
if (!secondDnsEdit->text().isEmpty()) {
|
||||
dnsList << secondDnsEdit->text();
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
QString ipv6address =ipv6AddressEdit->text();
|
||||
QString prefix = lengthEdit->text();
|
||||
QString gateWay = gateWayEdit->text();
|
||||
|
@ -94,41 +109,43 @@ void Ipv6Page::initUI() {
|
|||
ipv6AddressEdit = new LineEdit(this);
|
||||
lengthEdit = new LineEdit(this);
|
||||
gateWayEdit = new LineEdit(this);
|
||||
firstDnsEdit = new LineEdit(this);
|
||||
secondDnsEdit = new LineEdit(this);
|
||||
// firstDnsEdit = new LineEdit(this);
|
||||
// secondDnsEdit = new LineEdit(this);
|
||||
|
||||
m_configLabel = new QLabel(this);
|
||||
m_addressLabel = new QLabel(this);
|
||||
m_subnetLabel = new QLabel(this);
|
||||
m_gateWayLabel = new QLabel(this);
|
||||
m_dnsLabel = new QLabel(this);
|
||||
m_secDnsLabel = new QLabel(this);
|
||||
// m_dnsLabel = new QLabel(this);
|
||||
// m_secDnsLabel = new QLabel(this);
|
||||
|
||||
|
||||
m_configLabel->setText(tr("Ipv6Config"));
|
||||
m_addressLabel->setText(tr("Address"));
|
||||
m_subnetLabel->setText(tr("Subnet prefix Length"));
|
||||
m_gateWayLabel->setText(tr("Default Gateway"));
|
||||
m_dnsLabel->setText(tr("Prefs DNS"));
|
||||
m_secDnsLabel->setText(tr("Alternative DNS"));
|
||||
// m_dnsLabel->setText(tr("Prefs DNS"));
|
||||
// m_secDnsLabel->setText(tr("Alternative DNS"));
|
||||
|
||||
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_detailLayout = new QFormLayout(this);
|
||||
m_detailLayout->addRow(m_configLabel,ipv6ConfigCombox);
|
||||
m_detailLayout->addRow(m_addressLabel,ipv6AddressEdit);
|
||||
m_detailLayout->addRow(m_subnetLabel,lengthEdit);
|
||||
m_detailLayout->addRow(m_gateWayLabel,gateWayEdit);
|
||||
m_detailLayout->addRow(m_dnsLabel,firstDnsEdit);
|
||||
m_detailLayout->addRow(m_secDnsLabel,secondDnsEdit);
|
||||
// m_detailLayout->addRow(m_dnsLabel,firstDnsEdit);
|
||||
// m_detailLayout->addRow(m_secDnsLabel,secondDnsEdit);
|
||||
m_detailLayout->addRow(m_dnsWidget);
|
||||
|
||||
ipv6ConfigCombox->addItem(tr("Auto(DHCP)")); //"自动(DHCP)"
|
||||
ipv6ConfigCombox->addItem(tr("Manual")); //"手动"
|
||||
|
||||
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*$");
|
||||
ipv6AddressEdit->setValidator(new QRegExpValidator(ipv6_rx, this));
|
||||
gateWayEdit->setValidator(new QRegExpValidator(ipv6_rx, this));
|
||||
firstDnsEdit->setValidator(new QRegExpValidator(ipv6_rx, this));
|
||||
secondDnsEdit->setValidator(new QRegExpValidator(ipv6_rx, this));
|
||||
// firstDnsEdit->setValidator(new QRegExpValidator(ipv6_rx, this));
|
||||
// secondDnsEdit->setValidator(new QRegExpValidator(ipv6_rx, this));
|
||||
|
||||
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));
|
||||
|
@ -146,8 +163,14 @@ 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(firstDnsEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn()));
|
||||
connect(secondDnsEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn()));
|
||||
// connect(firstDnsEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn()));
|
||||
// connect(secondDnsEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn()));
|
||||
connect(m_dnsWidget, &MultipleDnsWidget::dnsTextChanged, this, [=]() {
|
||||
setIpv6PageState(false);
|
||||
});
|
||||
connect(m_dnsWidget, &MultipleDnsWidget::dnsEditingFinished, this, [=]() {
|
||||
setIpv6PageState(true);
|
||||
});
|
||||
}
|
||||
|
||||
void Ipv6Page::configChanged(int index) {
|
||||
|
@ -164,15 +187,16 @@ void Ipv6Page::setControlEnabled(bool check)
|
|||
ipv6AddressEdit->setEnabled(check);
|
||||
lengthEdit->setEnabled(check);
|
||||
gateWayEdit->setEnabled(check);
|
||||
firstDnsEdit->setEnabled(check);
|
||||
secondDnsEdit->setEnabled(check);
|
||||
m_dnsWidget->setEditEnabled(check);
|
||||
// firstDnsEdit->setEnabled(check);
|
||||
// secondDnsEdit->setEnabled(check);
|
||||
|
||||
if (!check) {
|
||||
ipv6AddressEdit->clear();
|
||||
lengthEdit->clear();
|
||||
gateWayEdit->clear();
|
||||
firstDnsEdit->clear();
|
||||
secondDnsEdit->clear();
|
||||
// firstDnsEdit->clear();
|
||||
// secondDnsEdit->clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -200,7 +224,7 @@ bool Ipv6Page::checkConnectBtnIsEnabled()
|
|||
qDebug() << "ipv6 gateway empty or invalid";
|
||||
return false;
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (firstDnsEdit->text().isEmpty() && !secondDnsEdit->text().isEmpty()) {
|
||||
qDebug() << "ipv6 dns sort invalid";
|
||||
return false;
|
||||
|
@ -215,6 +239,7 @@ bool Ipv6Page::checkConnectBtnIsEnabled()
|
|||
qDebug() << "ipv6 second dns invalid";
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
//#include "kylinconnectsetting.h"
|
||||
#include "coninfo.h"
|
||||
#include "multiplednswidget.h"
|
||||
|
||||
class Ipv6Page : public QFrame
|
||||
{
|
||||
|
@ -23,29 +24,32 @@ public:
|
|||
void setIpv6Config(KyIpConfigType ipv6Config);
|
||||
void setIpv6(const QString &ipv4);
|
||||
void setIpv6Perfix(const int &ipv6Perfix);
|
||||
void setIpv6FirDns(const QString &ipv6FirDns);
|
||||
void setIpv6SecDns(const QString &ipv6SecDns);
|
||||
// void setIpv6FirDns(const QString &ipv6FirDns);
|
||||
// void setIpv6SecDns(const QString &ipv6SecDns);
|
||||
void setMulDns(const QList<QHostAddress> &dns);
|
||||
void setGateWay(const QString &gateWay);
|
||||
|
||||
bool checkIsChanged(const ConInfo info, KyConnectSetting &setting);
|
||||
|
||||
int getPerfixLength(QString text);
|
||||
|
||||
public:
|
||||
private:
|
||||
QComboBox *ipv6ConfigCombox;
|
||||
LineEdit *ipv6AddressEdit;
|
||||
LineEdit *lengthEdit;
|
||||
LineEdit *gateWayEdit;
|
||||
LineEdit *firstDnsEdit;
|
||||
LineEdit *secondDnsEdit;
|
||||
// LineEdit *firstDnsEdit;
|
||||
// LineEdit *secondDnsEdit;
|
||||
private:
|
||||
QFormLayout *m_detailLayout;
|
||||
QLabel *m_configLabel;
|
||||
QLabel *m_addressLabel;
|
||||
QLabel *m_subnetLabel;
|
||||
QLabel *m_gateWayLabel;
|
||||
QLabel *m_dnsLabel;
|
||||
QLabel *m_secDnsLabel;
|
||||
// QLabel *m_dnsLabel;
|
||||
// QLabel *m_secDnsLabel;
|
||||
|
||||
MultipleDnsWidget *m_dnsWidget = nullptr;
|
||||
private:
|
||||
void initUI();
|
||||
void initComponent();
|
||||
|
|
|
@ -0,0 +1,185 @@
|
|||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* Copyright (C) 2022 Tianjin KYLIN Information Technology Co., Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
*/
|
||||
#include "multiplednswidget.h"
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
#define DNS_LISTWIDGET_HEIGHT 76
|
||||
#define BUTTON_SIZE 36,36
|
||||
#define ITEM_HEIGHT 36
|
||||
|
||||
MultipleDnsWidget::MultipleDnsWidget(const QRegExp &rx, QWidget *parent)
|
||||
: m_regExp(rx),
|
||||
QWidget(parent)
|
||||
{
|
||||
initUI();
|
||||
initComponent();
|
||||
}
|
||||
|
||||
void MultipleDnsWidget::initUI()
|
||||
{
|
||||
QVBoxLayout *mulDnsVLayout = new QVBoxLayout(this);
|
||||
mulDnsVLayout->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
m_mulDnsLabel = new QLabel(this);
|
||||
m_mulDnsLabel->setText(tr("DNS server:")); //DNS服务器:
|
||||
m_dnsListWidget = new QListWidget(this);
|
||||
m_dnsListWidget->setFixedHeight(DNS_LISTWIDGET_HEIGHT);
|
||||
m_dnsListWidget->setBackgroundRole(QPalette::Base);
|
||||
m_dnsListWidget->setFocusPolicy(Qt::FocusPolicy::NoFocus);
|
||||
m_dnsListWidget->setFrameShape(QFrame::Shape::StyledPanel);
|
||||
m_dnsListWidget->setEditTriggers(QAbstractItemView::DoubleClicked);
|
||||
setDnsListWidgetStyle();
|
||||
|
||||
m_addDnsBtn = new QPushButton(this);
|
||||
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->setFixedSize(BUTTON_SIZE);
|
||||
m_removeDnsBtn->setProperty("useButtonPalette", true);
|
||||
m_removeDnsBtn->setIcon(QIcon::fromTheme("list-remove-symbolic"));
|
||||
m_removeDnsBtn->setEnabled(false);
|
||||
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);
|
||||
|
||||
mulDnsVLayout->addWidget(m_mulDnsLabel, Qt::AlignLeft);
|
||||
mulDnsVLayout->addWidget(m_dnsListWidget);
|
||||
mulDnsVLayout->addLayout(btnHLayout);
|
||||
}
|
||||
|
||||
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_dnsListWidget, &QListWidget::itemClicked, this, [=]() {
|
||||
if (m_dnsListWidget->count() < 1) {
|
||||
m_removeDnsBtn->setEnabled(false);
|
||||
} else {
|
||||
m_removeDnsBtn->setEnabled(true);
|
||||
}
|
||||
});
|
||||
connect(m_dnsListWidget, &QListWidget::itemDoubleClicked, this, [=](QListWidgetItem *item) {
|
||||
m_dnsListWidget->edit(m_dnsListWidget->currentIndex());
|
||||
item->setFlags(item->flags() | Qt::ItemIsEditable);
|
||||
});
|
||||
}
|
||||
|
||||
void MultipleDnsWidget::setEditEnabled(bool state)
|
||||
{
|
||||
m_addDnsBtn->setEnabled(state);
|
||||
|
||||
if (!state) {
|
||||
m_dnsListWidget->clear();
|
||||
}
|
||||
}
|
||||
|
||||
QList<QHostAddress> MultipleDnsWidget::getDns() const
|
||||
{
|
||||
QStringList dnsList;
|
||||
dnsList.clear();
|
||||
QList<QHostAddress> ipv4dnsList;
|
||||
ipv4dnsList.clear();
|
||||
int row = 0;
|
||||
QString aDns;
|
||||
while (m_dnsListWidget->count() > row) {
|
||||
aDns = m_dnsListWidget->item(row)->text();
|
||||
if (!dnsList.contains(aDns)) {
|
||||
dnsList << aDns;
|
||||
ipv4dnsList << QHostAddress(aDns);
|
||||
}
|
||||
row ++;
|
||||
}
|
||||
return ipv4dnsList;
|
||||
}
|
||||
|
||||
void MultipleDnsWidget::setDnsListText(const QList<QHostAddress> &dns)
|
||||
{
|
||||
m_dnsListWidget->clear();
|
||||
for (QHostAddress str: dns) {
|
||||
QListWidgetItem *dnsListWidgetItem = new QListWidgetItem(m_dnsListWidget);
|
||||
dnsListWidgetItem->setSizeHint(QSize(0,ITEM_HEIGHT));
|
||||
dnsListWidgetItem->setText(str.toString());
|
||||
}
|
||||
}
|
||||
|
||||
void MultipleDnsWidget::AddOneDnsItem(QListWidget *listWidget)
|
||||
{
|
||||
QListWidgetItem *dnsListWidgetItem = new QListWidgetItem(listWidget);
|
||||
dnsListWidgetItem->setSizeHint(QSize(0,ITEM_HEIGHT));
|
||||
dnsListWidgetItem->setFlags(dnsListWidgetItem->flags() | Qt::ItemIsEditable);
|
||||
listWidget->addItem(dnsListWidgetItem);
|
||||
listWidget->setCurrentItem(dnsListWidgetItem);
|
||||
|
||||
ListItemEdit *dnsListItemEdit = new ListItemEdit(m_regExp);
|
||||
listWidget->setItemDelegateForRow(listWidget->currentIndex().row() , dnsListItemEdit);
|
||||
listWidget->editItem(dnsListWidgetItem);
|
||||
|
||||
connect(dnsListItemEdit, SIGNAL(textChanged(QString)), this, SIGNAL(dnsTextChanged(QString)));
|
||||
connect(dnsListItemEdit, SIGNAL(editingFinished()), this, SIGNAL(dnsEditingFinished()));
|
||||
}
|
||||
|
||||
void MultipleDnsWidget::RemoveOneDnsItem(QListWidgetItem *aItem, QListWidget *listWidget)
|
||||
{
|
||||
if (aItem) {
|
||||
listWidget->removeItemWidget(aItem);
|
||||
delete aItem;
|
||||
}
|
||||
}
|
||||
|
||||
void MultipleDnsWidget::setDnsListWidgetStyle()
|
||||
{
|
||||
QPalette mpal(m_dnsListWidget->palette());
|
||||
mpal.setColor(QPalette::Base, qApp->palette().base().color());
|
||||
mpal.setColor(QPalette::AlternateBase, qApp->palette().alternateBase().color());
|
||||
m_dnsListWidget->setAlternatingRowColors(true);
|
||||
m_dnsListWidget->setPalette(mpal);
|
||||
}
|
||||
|
||||
void MultipleDnsWidget::onAddBtnClicked()
|
||||
{
|
||||
//避免重复添加空白项
|
||||
if (m_dnsListWidget->currentItem()) {
|
||||
if (m_dnsListWidget->currentItem()->text().isEmpty()) {
|
||||
m_dnsListWidget->removeItemWidget(m_dnsListWidget->currentItem());
|
||||
delete m_dnsListWidget->currentItem();
|
||||
}
|
||||
}
|
||||
|
||||
AddOneDnsItem(m_dnsListWidget);
|
||||
m_removeDnsBtn->setEnabled(true);
|
||||
}
|
||||
|
||||
void MultipleDnsWidget::onRemoveBtnClicked()
|
||||
{
|
||||
QListWidgetItem *aItem = m_dnsListWidget->currentItem();
|
||||
if (!aItem) {
|
||||
return;
|
||||
}
|
||||
RemoveOneDnsItem(aItem, m_dnsListWidget);
|
||||
if (m_dnsListWidget->count()< 1) {
|
||||
m_removeDnsBtn->setEnabled(false);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* Copyright (C) 2022 Tianjin KYLIN Information Technology Co., Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
*/
|
||||
#ifndef MULTIPLEDNSWIDGET_H
|
||||
#define MULTIPLEDNSWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QLabel>
|
||||
#include <QLayout>
|
||||
#include <QLineEdit>
|
||||
#include <QListWidget>
|
||||
#include <QPushButton>
|
||||
#include <QAbstractItemView>
|
||||
#include <QString>
|
||||
#include <QList>
|
||||
#include <QHostAddress>
|
||||
#include <QDebug>
|
||||
|
||||
#include "listitemedit.h"
|
||||
|
||||
class MultipleDnsWidget: public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MultipleDnsWidget(const QRegExp &rx, QWidget *parent = nullptr);
|
||||
~MultipleDnsWidget() = default;
|
||||
void setEditEnabled(bool state);
|
||||
QList<QHostAddress> getDns() const;
|
||||
void setDnsListText(const QList<QHostAddress> &dns);
|
||||
|
||||
private:
|
||||
void initUI();
|
||||
void initComponent();
|
||||
void AddOneDnsItem(QListWidget *listWidget);
|
||||
void RemoveOneDnsItem(QListWidgetItem *aItem, QListWidget *listWidget);
|
||||
|
||||
QLabel *m_mulDnsLabel;
|
||||
QListWidget *m_dnsListWidget = nullptr;
|
||||
QPushButton *m_addDnsBtn;
|
||||
QPushButton *m_removeDnsBtn;
|
||||
QRegExp m_regExp;
|
||||
|
||||
private Q_SLOTS:
|
||||
void setDnsListWidgetStyle();
|
||||
void onAddBtnClicked();
|
||||
void onRemoveBtnClicked();
|
||||
|
||||
Q_SIGNALS:
|
||||
void dnsTextChanged(const QString &);
|
||||
void dnsEditingFinished();
|
||||
};
|
||||
|
||||
#endif // MULTIPLEDNSWIDGET_H
|
|
@ -367,8 +367,9 @@ void NetDetail::pagePadding(QString netName, bool isWlan)
|
|||
ipv4Page->setIpv4Config(m_info.ipv4ConfigType);
|
||||
ipv4Page->setIpv4(m_info.strIPV4Address);
|
||||
ipv4Page->setNetMask(m_info.strIPV4NetMask);
|
||||
ipv4Page->setIpv4FirDns(m_info.strIPV4FirDns);
|
||||
ipv4Page->setIpv4SecDns(m_info.strIPV4SecDns);
|
||||
// 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);
|
||||
|
@ -378,8 +379,9 @@ void NetDetail::pagePadding(QString netName, bool isWlan)
|
|||
ipv6Page->setIpv6Config(m_info.ipv6ConfigType);
|
||||
ipv6Page->setIpv6(m_info.strIPV6Address);
|
||||
ipv6Page->setIpv6Perfix(m_info.iIPV6Prefix);
|
||||
ipv6Page->setIpv6FirDns(m_info.strIPV6FirDns);
|
||||
ipv6Page->setIpv6SecDns(m_info.strIPV6SecDns);
|
||||
// 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);
|
||||
|
@ -553,18 +555,13 @@ void NetDetail::getStaticIpInfo(ConInfo &conInfo, bool bActived)
|
|||
conInfo.strIPV6GateWay = connetSetting.m_ipv6Address.at(0).gateway().toString();
|
||||
}
|
||||
|
||||
if (connetSetting.m_ipv6Dns.size() == 1) {
|
||||
conInfo.strIPV6FirDns = connetSetting.m_ipv6Dns.at(0).toString();
|
||||
} else if (connetSetting.m_ipv4Dns.size() > 1) {
|
||||
conInfo.strIPV6FirDns = connetSetting.m_ipv6Dns.at(0).toString();
|
||||
conInfo.strIPV6SecDns = connetSetting.m_ipv6Dns.at(1).toString();
|
||||
}
|
||||
conInfo.ipv6DnsList = connetSetting.m_ipv6Dns;
|
||||
}
|
||||
|
||||
if (!bActived) {
|
||||
conInfo.strDynamicIpv4 = conInfo.strIPV4Address.isEmpty() ? tr("Auto") : conInfo.strIPV4Address;
|
||||
conInfo.strDynamicIpv6 = conInfo.strIPV6Address.isEmpty() ? tr("Auto") : conInfo.strIPV6Address;
|
||||
conInfo.strDynamicIpv4Dns = conInfo.strIPV4FirDns.isEmpty() ? tr("Auto") : conInfo.strIPV4FirDns;
|
||||
conInfo.strDynamicIpv4Dns = conInfo.ipv4DnsList.isEmpty() ? tr("Auto") : conInfo.ipv4DnsList.at(0).toString();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1014,19 +1011,10 @@ void NetDetail::getIpv4Info(QString objPath, ConInfo &conInfo)
|
|||
while (!dbusArg2nd.atEnd()) {
|
||||
uint tempMap;
|
||||
dbusArg2nd >> tempMap;
|
||||
addressVector.append(tempMap);
|
||||
QString dns(inet_ntoa(*(struct in_addr *)&tempMap));
|
||||
conInfo.ipv4DnsList << QHostAddress(dns);
|
||||
}
|
||||
dbusArg2nd.endArray();
|
||||
if (addressVector.size() == 1) {
|
||||
QString dns(inet_ntoa(*(struct in_addr *)&addressVector.at(0)));
|
||||
conInfo.strIPV4FirDns = dns;
|
||||
} else if (addressVector.size() > 1) {
|
||||
QString dns1(inet_ntoa(*(struct in_addr *)&addressVector.at(0)));
|
||||
QString dns2(inet_ntoa(*(struct in_addr *)&addressVector.at(1)));
|
||||
conInfo.strIPV4FirDns = dns1;
|
||||
conInfo.strIPV4SecDns = dns2;
|
||||
}
|
||||
|
||||
} else if (inner_key == "gateway") {
|
||||
//gateway
|
||||
conInfo.strIPV4GateWay = innerMap.value(inner_key).toString();
|
||||
|
|
|
@ -9,7 +9,8 @@ HEADERS += \
|
|||
$$PWD/ipv4page.h \
|
||||
$$PWD/ipv6page.h \
|
||||
$$PWD/netdetail.h \
|
||||
$$PWD/securitypage.h
|
||||
$$PWD/securitypage.h \
|
||||
$$PWD/multiplednswidget.h
|
||||
|
||||
SOURCES += \
|
||||
$$PWD/creatnetpage.cpp \
|
||||
|
@ -19,4 +20,5 @@ SOURCES += \
|
|||
$$PWD/ipv4page.cpp \
|
||||
$$PWD/ipv6page.cpp \
|
||||
$$PWD/netdetail.cpp \
|
||||
$$PWD/securitypage.cpp
|
||||
$$PWD/securitypage.cpp \
|
||||
$$PWD/multiplednswidget.cpp
|
||||
|
|
|
@ -1170,6 +1170,15 @@ void LanPage::setWiredDeviceEnable(const QString& devName, bool enable)
|
|||
return;
|
||||
}
|
||||
|
||||
void LanPage::deleteWired(const QString &connUuid)
|
||||
{
|
||||
qDebug() << "[LanPage] deleteWired" << connUuid;
|
||||
if (connUuid == nullptr) {
|
||||
return;
|
||||
}
|
||||
m_wiredConnectOperation->deleteWiredConnect(connUuid);
|
||||
}
|
||||
|
||||
bool LanPage::eventFilter(QObject *watched, QEvent *event)
|
||||
{
|
||||
if (watched == m_settingsBtn) {
|
||||
|
|
|
@ -25,6 +25,7 @@ public:
|
|||
|
||||
//for dbus
|
||||
void getWiredList(QMap<QString, QVector<QStringList> > &map);
|
||||
void deleteWired(const QString& connUuid);
|
||||
void activateWired(const QString& devName, const QString& connUuid);
|
||||
void deactivateWired(const QString& devName, const QString& connUuid);
|
||||
void showDetailPage(QString devName, QString uuid);
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* Copyright (C) 2022 Tianjin KYLIN Information Technology Co., Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
*/
|
||||
#include "listitemedit.h"
|
||||
|
||||
ListItemEdit::ListItemEdit(const QRegExp &rx, QObject *parent)
|
||||
: m_regExp(rx),
|
||||
QStyledItemDelegate(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QWidget *ListItemEdit::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
|
||||
{
|
||||
QLineEdit *editor = new QLineEdit(parent);
|
||||
editor->setValidator(new QRegExpValidator(m_regExp, parent));
|
||||
connect(editor, SIGNAL(textChanged(QString)), this, SIGNAL(textChanged(QString)));
|
||||
connect(editor, SIGNAL(editingFinished()), this, SIGNAL(editingFinished()));
|
||||
return editor;
|
||||
}
|
||||
|
||||
void ListItemEdit::setEditorData(QWidget *editor, const QModelIndex &index) const
|
||||
{
|
||||
QLineEdit *lineEdit = static_cast <QLineEdit*>(editor);
|
||||
QString text = index.model()->data(index, Qt::EditRole).toString();
|
||||
lineEdit->setText(text);
|
||||
}
|
||||
|
||||
void ListItemEdit::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
|
||||
{
|
||||
QLineEdit *lineEdit = static_cast <QLineEdit*>(editor);
|
||||
QString text = lineEdit->text();
|
||||
model->setData(index, text, Qt::EditRole);
|
||||
}
|
||||
|
||||
void ListItemEdit::updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const
|
||||
{
|
||||
editor->setGeometry(option.rect);
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* Copyright (C) 2022 Tianjin KYLIN Information Technology Co., Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
*/
|
||||
#ifndef LISTITEMEDIT_H
|
||||
#define LISTITEMEDIT_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QStyledItemDelegate>
|
||||
#include <QLineEdit>
|
||||
|
||||
class ListItemEdit: public QStyledItemDelegate
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ListItemEdit(const QRegExp &rx, QObject *parent = nullptr);
|
||||
~ListItemEdit() = default;
|
||||
|
||||
//创建一个控件
|
||||
virtual QWidget *createEditor (QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
||||
//将数据设置到控件中
|
||||
virtual void setEditorData (QWidget *editor, const QModelIndex &index) const;
|
||||
//将控件中的数据更新到对应的model中
|
||||
virtual void setModelData (QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const;
|
||||
//更新控件位置
|
||||
void updateEditorGeometry(QWidget *editor,
|
||||
const QStyleOptionViewItem &option,
|
||||
const QModelIndex &index) const override;
|
||||
private:
|
||||
QRegExp m_regExp;
|
||||
|
||||
Q_SIGNALS:
|
||||
void textChanged(const QString &);
|
||||
void editingFinished();
|
||||
};
|
||||
|
||||
#endif // LISTITEMEDIT_H
|
|
@ -3,6 +3,7 @@ INCLUDEPATH += $$PWD
|
|||
HEADERS += \
|
||||
$$PWD/divider.h \
|
||||
$$PWD/infobutton.h \
|
||||
$$PWD/listitemedit.h \
|
||||
$$PWD/loadingdiv.h \
|
||||
$$PWD/radioitembutton.h \
|
||||
$$PWD/switchbutton.h \
|
||||
|
@ -12,6 +13,7 @@ HEADERS += \
|
|||
SOURCES += \
|
||||
$$PWD/divider.cpp \
|
||||
$$PWD/infobutton.cpp \
|
||||
$$PWD/listitemedit.cpp \
|
||||
$$PWD/loadingdiv.cpp \
|
||||
$$PWD/radioitembutton.cpp \
|
||||
$$PWD/switchbutton.cpp \
|
||||
|
|
Binary file not shown.
|
@ -94,6 +94,19 @@
|
|||
<source>Manual</source>
|
||||
<translation>手动</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/frontend/netdetails/creatnetpage.cpp" line="173"/>
|
||||
<source>Required</source>
|
||||
<translation>必填</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>MultipleDnsWidget</name>
|
||||
<message>
|
||||
<location filename="../src/frontend/netdetails/multiplednswidget.cpp" line="42"/>
|
||||
<source>DNS server:</source>
|
||||
<translation>DNS服务器:</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>DetailPage</name>
|
||||
|
|
Loading…
Reference in New Issue