From ad8c64db660a3fa717b101fef4eac68923c6072b Mon Sep 17 00:00:00 2001
From: jzxc95 <907297917@qq.com>
Date: Thu, 6 Apr 2023 14:09:59 +0800
Subject: [PATCH 01/10] import 2303
---
kylin-nm.pro | 9 +
nmqrc.qrc | 4 -
plugins/component/AddBtn/addnetbtn.cpp | 27 +-
plugins/component/AddBtn/addnetbtn.h | 8 -
plugins/mobilehotspot/blacklistpage.cpp | 16 +-
plugins/mobilehotspot/blacklistpage.h | 15 +-
plugins/mobilehotspot/connectdevpage.cpp | 16 +-
plugins/mobilehotspot/connectdevpage.h | 15 +-
plugins/mobilehotspot/mobilehotspot.pro | 3 +-
plugins/mobilehotspot/mobilehotspotwidget.cpp | 28 +-
plugins/mobilehotspot/mobilehotspotwidget.h | 2 +-
plugins/mobilehotspot/translations/bo.ts | 48 +--
plugins/mobilehotspot/translations/bo_CN.ts | 44 +-
plugins/mobilehotspot/translations/en_US.ts | 126 ++++++
plugins/mobilehotspot/translations/tr.ts | 48 +--
plugins/mobilehotspot/translations/zh_CN.ts | 44 +-
plugins/netconnect/lanitem.cpp | 87 +---
plugins/netconnect/lanitem.h | 21 +-
plugins/netconnect/netconnect.cpp | 95 ++---
plugins/netconnect/netconnect.h | 4 +-
plugins/netconnect/netconnect.pro | 3 +-
plugins/netconnect/translations/bo.ts | 29 +-
plugins/netconnect/translations/bo_CN.qm | Bin 1440 -> 1159 bytes
plugins/netconnect/translations/bo_CN.ts | 48 +--
plugins/netconnect/translations/en_US.ts | 71 ++++
plugins/netconnect/translations/tr.ts | 29 +-
plugins/netconnect/translations/zh_CN.qm | Bin 922 -> 711 bytes
plugins/netconnect/translations/zh_CN.ts | 46 +-
plugins/plugin.pro | 3 +-
plugins/proxy/applistwidget.cpp | 12 +-
plugins/proxy/aptproxydialog.cpp | 20 +-
plugins/proxy/proxy.cpp | 94 +++--
plugins/proxy/proxy.h | 6 +-
plugins/wlanconnect/translations/bo.ts | 14 +-
plugins/wlanconnect/translations/bo_CN.ts | 14 +-
plugins/wlanconnect/translations/en_US.ts | 73 ++++
plugins/wlanconnect/translations/tr.ts | 14 +-
plugins/wlanconnect/translations/zh_CN.ts | 14 +-
plugins/wlanconnect/wlanconnect.cpp | 74 ++--
plugins/wlanconnect/wlanconnect.h | 5 +-
plugins/wlanconnect/wlanconnect.pro | 3 +-
plugins/wlanconnect/wlanconnect.ui | 2 +-
plugins/wlanconnect/wlanitem.cpp | 19 +-
src/backend/backend.pri | 2 -
.../kylinactiveconnectresource.cpp | 32 ++
.../kylinactiveconnectresource.h | 1 +
.../dbus-interface/kylinagentinterface.c | 16 +-
.../dbus-interface/kylinconnectresource.cpp | 111 +----
.../dbus-interface/kylinconnectresource.h | 2 -
.../kylinnetworkdeviceresource.cpp | 46 +-
.../kylinnetworkdeviceresource.h | 3 +
.../kylinnetworkresourcemanager.cpp | 85 ++--
.../kylinnetworkresourcemanager.h | 4 +-
.../kywirelessconnectoperation.cpp | 44 +-
.../kywirelessconnectoperation.h | 5 +
.../dbus-interface/kywirelessnetitem.cpp | 79 ++--
.../dbus-interface/kywirelessnetitem.h | 3 +-
.../dbus-interface/kywirelessnetresource.cpp | 72 ++--
.../dbus-interface/kywirelessnetresource.h | 2 +-
src/backend/dbusadaptor.cpp | 12 -
src/backend/dbusadaptor.h | 2 -
src/backend/kylinipv6arping.cpp | 15 +
.../enterprise-wlan/enterprisewlandialog.cpp | 51 ++-
src/frontend/frontend.pri | 3 -
src/frontend/list-items/lanlistitem.cpp | 72 +++-
src/frontend/list-items/lanlistitem.h | 2 +
src/frontend/list-items/list-items.pri | 6 +-
src/frontend/list-items/listitem.cpp | 186 ++++++++-
src/frontend/list-items/listitem.h | 64 ++-
src/frontend/list-items/wlanlistitem.cpp | 104 ++++-
src/frontend/list-items/wlanlistitem.h | 6 +-
src/frontend/list-items/wlanmoreitem.cpp | 3 +-
src/frontend/mainwindow.cpp | 163 ++++----
src/frontend/mainwindow.h | 10 +-
src/frontend/netdetails/configpage.cpp | 4 +-
src/frontend/netdetails/coninfo.h | 58 +--
src/frontend/netdetails/creatnetpage.cpp | 126 +++++-
src/frontend/netdetails/creatnetpage.h | 12 +-
src/frontend/netdetails/detailpage.cpp | 4 +-
src/frontend/netdetails/detailwidget.cpp | 41 --
src/frontend/netdetails/detailwidget.h | 18 +-
src/frontend/netdetails/ipv4page.cpp | 76 +++-
src/frontend/netdetails/ipv4page.h | 15 +-
src/frontend/netdetails/ipv6page.cpp | 72 +++-
src/frontend/netdetails/ipv6page.h | 22 +-
.../netdetails/joinhiddenwifipage.cpp | 51 +--
src/frontend/netdetails/joinhiddenwifipage.h | 5 +-
src/frontend/netdetails/netdetail.cpp | 392 ++++++------------
src/frontend/netdetails/netdetail.h | 21 +-
src/frontend/netdetails/netdetails.pri | 2 -
src/frontend/netdetails/securitypage.cpp | 10 +-
src/frontend/netdetails/securitypage.h | 3 +-
src/frontend/networkmode/firewalldialog.cpp | 63 ++-
src/frontend/networkmode/firewalldialog.h | 15 +-
.../networkmode/networkmodeconfig.cpp | 179 +++++++-
src/frontend/networkmode/networkmodeconfig.h | 33 ++
src/frontend/tab-pages/lanpage.cpp | 163 ++++----
src/frontend/tab-pages/lanpage.h | 5 +-
src/frontend/tab-pages/tabpage.cpp | 143 ++++++-
src/frontend/tab-pages/tabpage.h | 21 +-
src/frontend/tab-pages/wlanpage.cpp | 218 ++++++----
src/frontend/tab-pages/wlanpage.h | 14 +-
src/frontend/tools/kylable.cpp | 40 ++
src/frontend/tools/kylable.h | 17 +
src/frontend/tools/radioitembutton.cpp | 2 +-
src/frontend/tools/tools.pri | 2 -
src/main.cpp | 26 +-
src/org.ukui.kylin-nm.switch.gschema.xml | 7 -
translate_generation.sh | 15 +
translations/kylin-nm_bo.ts | 380 ++++++++---------
translations/kylin-nm_bo_CN.ts | 365 ++++++++--------
translations/kylin-nm_tr.ts | 350 ++++++++--------
translations/kylin-nm_zh_CN.ts | 369 ++++++++---------
113 files changed, 3354 insertions(+), 2464 deletions(-)
create mode 100644 plugins/mobilehotspot/translations/en_US.ts
create mode 100644 plugins/netconnect/translations/en_US.ts
create mode 100644 plugins/wlanconnect/translations/en_US.ts
create mode 100755 translate_generation.sh
diff --git a/kylin-nm.pro b/kylin-nm.pro
index 7b52af76..1f13a7c2 100644
--- a/kylin-nm.pro
+++ b/kylin-nm.pro
@@ -12,3 +12,12 @@ TRANSLATIONS += \
translations/kylin-nm_tr.ts \
translations/kylin-nm_bo.ts \
translations/kylin-nm_bo_CN.ts
+
+CONFIG(release, debug|release) {
+ !system($$PWD/translate_generation.sh): error("Failed to generate translation")
+}
+
+qm_files.path = $${PREFIX}/share/kylin-nm/kylin-nm/
+qm_files.files = translations/*.qm
+
+INSTALLS += qm_files \
diff --git a/nmqrc.qrc b/nmqrc.qrc
index c379b198..aea1ec48 100644
--- a/nmqrc.qrc
+++ b/nmqrc.qrc
@@ -17,9 +17,6 @@
res/h/right-pwd.png
res/h/show-pwd.png
res/h/no-pwd-wifi.png
- translations/kylin-nm_bo.qm
- translations/kylin-nm_tr.qm
- translations/kylin-nm_zh_CN.qm
res/x/fly-mode-off.svg
res/x/fly-mode-on.svg
res/x/hot-spot-off.svg
@@ -128,6 +125,5 @@
res/s/conning-b/10.png
res/s/conning-b/11.png
res/s/conning-b/12.png
- translations/kylin-nm_bo_CN.qm
diff --git a/plugins/component/AddBtn/addnetbtn.cpp b/plugins/component/AddBtn/addnetbtn.cpp
index eb1bc6fb..811a0c99 100644
--- a/plugins/component/AddBtn/addnetbtn.cpp
+++ b/plugins/component/AddBtn/addnetbtn.cpp
@@ -20,6 +20,7 @@
#include "addnetbtn.h"
#include
#include
+#include
#include
#include
#include
@@ -33,15 +34,11 @@ AddNetBtn::AddNetBtn(bool isWlan, QWidget *parent) : QPushButton(parent)
this->setMaximumSize(QSize(16777215, 60));
this->setProperty("useButtonPalette", true);
this->setFlat(true);
- QPalette pal = this->palette();
- QColor color = pal.color(QPalette::Button);
- color.setAlphaF(0.5);
- pal.setColor(QPalette::Button, color);
- this->setPalette(pal);
- QHBoxLayout *addLyt = new QHBoxLayout(this);
- QLabel *iconLabel = new QLabel(this);
- textLabel = new QLabel(this);
+ QHBoxLayout *addLyt = new QHBoxLayout;
+
+ QLabel *iconLabel = new QLabel();
+ QLabel *textLabel = new QLabel();
if (isWlan) {
textLabel->setText(tr("Add Others"));
@@ -51,8 +48,8 @@ AddNetBtn::AddNetBtn(bool isWlan, QWidget *parent) : QPushButton(parent)
textLabel->setText(tr("Add WiredNetork"));
QIcon mAddIcon = QIcon::fromTheme("list-add-symbolic");
iconLabel->setPixmap(mAddIcon.pixmap(mAddIcon.actualSize(QSize(24, 24))));
- iconLabel->setProperty("useIconHighlightEffect", true);
- iconLabel->setProperty("iconHighlightEffectMode", 1);
+ iconLabel->setProperty("useIconHighlightEffect", 0x2);
+// iconLabel->setProperty("iconHighlightEffectMode", 1);
addLyt->addStretch();
addLyt->addWidget(iconLabel);
@@ -61,7 +58,6 @@ AddNetBtn::AddNetBtn(bool isWlan, QWidget *parent) : QPushButton(parent)
addLyt->addStretch();
this->setLayout(addLyt);
-
}
AddNetBtn::~AddNetBtn()
@@ -83,12 +79,17 @@ void AddNetBtn::leaveEvent(QEvent *event){
void AddNetBtn::paintEvent(QPaintEvent *event)
{
- QPalette pal = this->palette();
+ QPalette pal = qApp->palette();
QPainter painter(this);
painter.setRenderHint(QPainter:: Antialiasing, true); //设置渲染,启动反锯齿
painter.setPen(Qt::NoPen);
- painter.setBrush(pal.color(QPalette::Base));
+ painter.setBrush(this->palette().base().color());
+
+ QColor color = pal.color(QPalette::Button);
+ color.setAlphaF(0.5);
+ pal.setColor(QPalette::Button, color);
+ this->setPalette(pal);
QRect rect = this->rect();
QPainterPath path;
diff --git a/plugins/component/AddBtn/addnetbtn.h b/plugins/component/AddBtn/addnetbtn.h
index 60ba8028..959d2d09 100644
--- a/plugins/component/AddBtn/addnetbtn.h
+++ b/plugins/component/AddBtn/addnetbtn.h
@@ -25,7 +25,6 @@
#include
#include
#include
-#include
class AddNetBtn : public QPushButton
{
@@ -34,18 +33,11 @@ public:
AddNetBtn(bool isWlan, QWidget *parent = nullptr);
~AddNetBtn();
- void setTextLabel(QString str) {
- textLabel->setText(str);
- }
-
protected:
virtual void leaveEvent(QEvent * event);
virtual void enterEvent(QEvent * event);
void paintEvent(QPaintEvent *event);
-private:
- QLabel* textLabel;
-
Q_SIGNALS:
void enterWidget();
void leaveWidget();
diff --git a/plugins/mobilehotspot/blacklistpage.cpp b/plugins/mobilehotspot/blacklistpage.cpp
index 1b82d8bd..d923749c 100644
--- a/plugins/mobilehotspot/blacklistpage.cpp
+++ b/plugins/mobilehotspot/blacklistpage.cpp
@@ -34,12 +34,12 @@ BlacklistPage::BlacklistPage(QWidget *parent) : QWidget(parent)
Vlayout->setContentsMargins(CONTENTS_MARGINS);
Vlayout->setSpacing(0);
- QFrame *blacklistFrame = new QFrame(this);
- blacklistFrame->setMinimumSize(FRAME_MIN_SIZE);
- blacklistFrame->setMaximumSize(FRAME_MAX_SIZE);
- blacklistFrame->setFrameShape(QFrame::Box);
+ m_blacklistFrame = new QFrame(this);
+ m_blacklistFrame->setMinimumSize(FRAME_MIN_SIZE);
+ m_blacklistFrame->setMaximumSize(FRAME_MAX_SIZE);
+ m_blacklistFrame->setFrameShape(QFrame::Box);
- m_blacklistLayout = new QVBoxLayout(blacklistFrame);
+ m_blacklistLayout = new QVBoxLayout(m_blacklistFrame);
m_blacklistLayout->setContentsMargins(0, 0, 0, 0);
m_blacklistLayout->setSpacing(0);
@@ -48,7 +48,7 @@ BlacklistPage::BlacklistPage(QWidget *parent) : QWidget(parent)
Vlayout->addWidget(m_titleLabel);
Vlayout->addSpacing(8);
- Vlayout->addWidget(blacklistFrame);
+ Vlayout->addWidget(m_blacklistFrame);
}
QFrame* BlacklistPage::myLine()
@@ -87,7 +87,7 @@ void BlacklistPage::getBlacklistDevice(QMap &blacklistMap)
for (int index = 0; index < macList.count() && macList.at(index) != nullptr; index ++) {
QString macTemp = macList.at(index);
macTemp = macTemp.trimmed();
- if (!blacklistMap.contains(macTemp)) {
+ if (!blacklistMap.contains(macTemp) && hostNameList.at(index) != nullptr) {
blacklistMap[macTemp] = hostNameList.at(index);
}
}
@@ -166,7 +166,7 @@ void BlacklistPage::resetLayoutHight()
height += w->height();
}
}
- this->setFixedHeight(height + m_titleLabel->height() + 8);
+ m_blacklistFrame->setFixedHeight(height);
if (m_blacklistMap.isEmpty()) {
this->hide();
diff --git a/plugins/mobilehotspot/blacklistpage.h b/plugins/mobilehotspot/blacklistpage.h
index a1e3f01d..8a511c1d 100644
--- a/plugins/mobilehotspot/blacklistpage.h
+++ b/plugins/mobilehotspot/blacklistpage.h
@@ -49,15 +49,8 @@ public:
}
private:
-
QFrame* myLine();
- TitleLabel *m_titleLabel = nullptr;
- QVBoxLayout *m_blacklistLayout = nullptr;
- QMap m_blacklistMap;
-
- QDBusInterface *m_settingPathInterface = nullptr;
-
void getBlacklistDevice(QMap &blacklistMap);
bool removeStaFromBlacklist(QString staMac, QString staName);
void initBlacklistDev();
@@ -65,6 +58,14 @@ private:
void clearBlacklistLayout();
void resetLayoutHight();
+private:
+ QFrame *m_blacklistFrame = nullptr;
+ TitleLabel *m_titleLabel = nullptr;
+ QVBoxLayout *m_blacklistLayout = nullptr;
+ QMap m_blacklistMap;
+
+ QDBusInterface *m_settingPathInterface = nullptr;
+
private slots:
void onsetStaIntoBlacklist(QString staMac, QString staName);
void onRemoveFromBlacklistBtnClicked(QString staMac, QString staName);
diff --git a/plugins/mobilehotspot/connectdevpage.cpp b/plugins/mobilehotspot/connectdevpage.cpp
index f8862e01..473a4c69 100644
--- a/plugins/mobilehotspot/connectdevpage.cpp
+++ b/plugins/mobilehotspot/connectdevpage.cpp
@@ -35,12 +35,12 @@ ConnectdevPage::ConnectdevPage(QWidget *parent) :
Vlayout->setContentsMargins(CONTENTS_MARGINS);
Vlayout->setSpacing(0);
- QFrame *staistFrame = new QFrame(this);
- staistFrame->setMinimumSize(FRAME_MIN_SIZE);
- staistFrame->setMaximumSize(FRAME_MAX_SIZE);
- staistFrame->setFrameShape(QFrame::Box);
+ m_staistFrame = new QFrame(this);
+ m_staistFrame->setMinimumSize(FRAME_MIN_SIZE);
+ m_staistFrame->setMaximumSize(FRAME_MAX_SIZE);
+ m_staistFrame->setFrameShape(QFrame::Box);
- m_staListLayout = new QVBoxLayout(staistFrame);
+ m_staListLayout = new QVBoxLayout(m_staistFrame);
m_staListLayout->setContentsMargins(0, 0, 0, 0);
m_staListLayout->setSpacing(0);
@@ -49,7 +49,7 @@ ConnectdevPage::ConnectdevPage(QWidget *parent) :
Vlayout->addWidget(m_titleLabel);
Vlayout->addSpacing(8);
- Vlayout->addWidget(staistFrame);
+ Vlayout->addWidget(m_staistFrame);
}
QFrame* ConnectdevPage::myLine()
@@ -90,7 +90,7 @@ void ConnectdevPage::getConnectStaDevice(QMap &staMap)
QStringList macList = reply.arguments().at(0).toString().split(";");
QStringList hostNameList = reply.arguments().at(1).toString().split(";");
for (int index = 0; index < macList.count() && macList.at(index) != nullptr; index ++) {
- if (!staMap.contains(macList.at(index))) {
+ if (!staMap.contains(macList.at(index)) && hostNameList.at(index) != nullptr) {
staMap[macList.at(index)] = hostNameList.at(index);
}
}
@@ -158,7 +158,7 @@ void ConnectdevPage::resetLayoutHight()
height += w->height();
}
}
- this->setFixedHeight(height + m_titleLabel->height() + 8);
+ m_staistFrame->setFixedHeight(height);
if (m_staMap.isEmpty()) {
this->hide();
diff --git a/plugins/mobilehotspot/connectdevpage.h b/plugins/mobilehotspot/connectdevpage.h
index 944fc995..ce9abb09 100644
--- a/plugins/mobilehotspot/connectdevpage.h
+++ b/plugins/mobilehotspot/connectdevpage.h
@@ -50,12 +50,6 @@ public:
private:
QFrame* myLine();
- TitleLabel *m_titleLabel = nullptr;
- QVBoxLayout *m_staListLayout = nullptr;
- QMap m_staMap;
-
- QDBusInterface *m_activePathInterface = nullptr;
-
void getConnectStaDevice(QMap &blacklistMap);
bool removeStaFromBlacklist(QString staMac);
void initStaDev();
@@ -67,6 +61,15 @@ private:
void onStaDevChanged(bool istrue, QString staMac, QString staName);
void resetLayoutHight();
+private:
+ QFrame *m_staistFrame = nullptr;
+
+ TitleLabel *m_titleLabel = nullptr;
+ QVBoxLayout *m_staListLayout = nullptr;
+ QMap m_staMap;
+
+ QDBusInterface *m_activePathInterface = nullptr;
+
signals:
void setStaIntoBlacklist(QString staMac, QString staName);
diff --git a/plugins/mobilehotspot/mobilehotspot.pro b/plugins/mobilehotspot/mobilehotspot.pro
index 0bb86a93..90c84dab 100644
--- a/plugins/mobilehotspot/mobilehotspot.pro
+++ b/plugins/mobilehotspot/mobilehotspot.pro
@@ -49,4 +49,5 @@ TRANSLATIONS += \
translations/zh_CN.ts \
translations/tr.ts \
translations/bo.ts\
- translations/bo_CN.ts
+ translations/bo_CN.ts \
+ translations/en_US.ts
diff --git a/plugins/mobilehotspot/mobilehotspotwidget.cpp b/plugins/mobilehotspot/mobilehotspotwidget.cpp
index a5a35240..a03a2af1 100644
--- a/plugins/mobilehotspot/mobilehotspotwidget.cpp
+++ b/plugins/mobilehotspot/mobilehotspotwidget.cpp
@@ -264,13 +264,10 @@ void MobileHotspotWidget::initDbusConnect()
connect(m_interface,SIGNAL(hotspotActivated(QString, QString, QString, QString, QString)), this, SLOT(onHotspotActivated(QString, QString, QString, QString, QString)), Qt::QueuedConnection);
connect(m_interface, SIGNAL(wlanactiveConnectionStateChanged(QString, QString, QString, int)), this, SLOT(onActiveConnectionChanged(QString, QString, QString, int)), Qt::QueuedConnection);
+
+ connect(m_interface, SIGNAL(wirelessSwitchBtnChanged(bool)), this, SLOT(onWirelessBtnChanged(bool)), Qt::QueuedConnection);
}
- if (QGSettings::isSchemaInstalled(GSETTINGS_SCHEMA)) {
- m_switchGsettings = new QGSettings(GSETTINGS_SCHEMA);
- onGsettingChanged(WIRELESS_SWITCH);
- connect(m_switchGsettings, &QGSettings::changed, this, &MobileHotspotWidget::onGsettingChanged, Qt::QueuedConnection);
- }
connect(m_apNameLine, &QLineEdit::textEdited, this, &MobileHotspotWidget::onApLineEditTextEdit);
#ifdef HOTSPOT_CONTROL
@@ -317,17 +314,14 @@ void MobileHotspotWidget::onActiveConnectionChanged(QString deviceName, QString
}
}
-void MobileHotspotWidget::onGsettingChanged(const QString &key)
+void MobileHotspotWidget::onWirelessBtnChanged(bool state)
{
- if (key == WIRELESS_SWITCH) {
- bool status = m_switchGsettings->get(WIRELESS_SWITCH).toBool();
- if (!status) {
- m_switchBtn->setChecked(status);
- m_uuid.clear();
- m_switchBtn->setCheckable(false);
- } else {
- m_switchBtn->setCheckable(true);
- }
+ if (!state) {
+ m_switchBtn->setChecked(state);
+ m_uuid.clear();
+ m_switchBtn->setCheckable(false);
+ } else {
+ m_switchBtn->setCheckable(true);
}
}
@@ -720,7 +714,9 @@ void MobileHotspotWidget::setWidgetHidden(bool isHidden)
m_uuid = "";
} else {
m_switchBtn->setCheckable(true);
- onGsettingChanged(WIRELESS_SWITCH);
+ QDBusReply reply = m_interface->call("getWirelessSwitchBtnState");
+ bool state = reply.value();
+ onWirelessBtnChanged(state);
}
resetFrameSize();
diff --git a/plugins/mobilehotspot/mobilehotspotwidget.h b/plugins/mobilehotspot/mobilehotspotwidget.h
index 7b6fe876..13b29d9d 100644
--- a/plugins/mobilehotspot/mobilehotspotwidget.h
+++ b/plugins/mobilehotspot/mobilehotspotwidget.h
@@ -151,7 +151,7 @@ private slots:
//热点连接
void onHotspotActivated(QString devName, QString ssid, QString uuid, QString activePath, QString settingPath);
- void onGsettingChanged(const QString &key);
+ void onWirelessBtnChanged(bool state);
void onActiveConnectionChanged(QString deviceName, QString ssid, QString uuid, int status);
diff --git a/plugins/mobilehotspot/translations/bo.ts b/plugins/mobilehotspot/translations/bo.ts
index 70f2c4b7..2c1f8b3d 100644
--- a/plugins/mobilehotspot/translations/bo.ts
+++ b/plugins/mobilehotspot/translations/bo.ts
@@ -4,7 +4,7 @@
BlacklistItem
-
+
@@ -12,7 +12,7 @@
BlacklistPage
-
+
@@ -20,7 +20,7 @@
ConnectDevListItem
-
+
@@ -28,7 +28,7 @@
ConnectdevPage
-
+
@@ -56,79 +56,69 @@
MobileHotspotWidget
-
+
-
+
-
+
-
-
-
-
-
-
+
-
-
-
-
-
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
diff --git a/plugins/mobilehotspot/translations/bo_CN.ts b/plugins/mobilehotspot/translations/bo_CN.ts
index 2e4fb436..f2f82810 100644
--- a/plugins/mobilehotspot/translations/bo_CN.ts
+++ b/plugins/mobilehotspot/translations/bo_CN.ts
@@ -4,7 +4,7 @@
BlacklistItem
-
+
སྤོ་སྐྱོད་བྱས་པ།
@@ -12,7 +12,7 @@
BlacklistPage
-
+
སྒྲིག་ཆས་ཀྱི་མིང་ཐོ་ནག་པོ།
@@ -20,7 +20,7 @@
ConnectDevListItem
-
+
མིང་ཐོ་ནག་པོའི་ཁ་སྣོན་རྒྱག་པ།
@@ -28,7 +28,7 @@
ConnectdevPage
-
+
འབྲེལ་མཐུད་སྒྲིག་ཆས།
@@ -56,27 +56,26 @@
MobileHotspotWidget
-
+
ཝུའུ་ཁི་ལན་གྱི་ཚོད་འཛིན་ལྟེ་གནས།
-
+
ukui ཚོད་འཛིན་ལྟེ་གནས་ཀྱི་ཅོག་ངོས་ཆ་འཕྲིན།
-
+
སྐུད་མེད་གློག་སྒོ་རྒྱག་པའམ་ཡང་ན་སྐུད་མེད་སྒྲིག་ཆས་མེད་པ།
-
- སྒོ་རྒྱག་འགོ་བརྩམས།
+ སྒོ་རྒྱག་འགོ་བརྩམས།
-
+
ཚ་བ་ཆེ་བའི་མིང་ངམ་སྒྲིག་ཆས་ལ་ནུས་པ་མེད།
@@ -85,54 +84,53 @@
གསང་གྲངས་ཀྱི་རིང་ཚད་ནི་གླེང་མང་བའི་གནད་དོན་བརྒྱད་ལས་ཆུང་བ་བྱེད་མི་རུང་།!
-
- ཀུན་གྱིས་དོ་སྣང་བྱེད་ཡུལ་གསར་སྐྲུན་བྱེད་འགོ་
+ ཀུན་གྱིས་དོ་སྣང་བྱེད་ཡུལ་གསར་སྐྲུན་བྱེད་འགོ་
-
+
མ་མཐར་ཡང་ཡིག་རྟགས་བརྒྱད་འདུས་ཡོད།
-
+
ཚ་བ་ཆེ་བ།
-
-
+
+
ཚ་བ་ཆེ་བའི་གནད་དོན་ཐག་ཉེ་རུ་སོང་ཡོད།
-
+
སྒོ་ཕྱེ་བ།
-
+
Wi-Fiཡི་མིང་།
-
+
གསང་གྲངས།
-
+
ཐེངས་གྲངས་ཀྱི་རོལ་ཆའི་རུ་ཁག
-
+
དྲ་རྒྱའི་བྱང་བུ།
-
-
+
+
ཚ་བ་ཆེ་བའི་གནད་དོན་དེ་སྒོ་ཕྱེ་ཟིན།
diff --git a/plugins/mobilehotspot/translations/en_US.ts b/plugins/mobilehotspot/translations/en_US.ts
new file mode 100644
index 00000000..bb4f55f3
--- /dev/null
+++ b/plugins/mobilehotspot/translations/en_US.ts
@@ -0,0 +1,126 @@
+
+
+
+
+ BlacklistItem
+
+
+
+ Remove
+
+
+
+ BlacklistPage
+
+
+
+ Blacklist
+
+
+
+ ConnectDevListItem
+
+
+
+ drag into blacklist
+
+
+
+ ConnectdevPage
+
+
+
+ Connect device
+
+
+
+ MobileHotspot
+
+
+
+ MobileHotspot
+
+
+
+
+ mobilehotspot
+ /mobilehotspot/mobilehotspot
+
+
+
+
+ mobilehotspot open
+ /mobilehotspot/mobilehotspot open
+
+
+
+ MobileHotspotWidget
+
+
+
+ ukui control center
+
+
+
+
+ ukui control center desktop message
+
+
+
+
+ wirless switch is close or no wireless device
+
+
+
+
+ hotpots name or device is invalid
+
+
+
+
+ Hotspot
+
+
+
+
+
+ hotspot already close
+
+
+
+
+ Open
+
+
+
+
+ Wi-Fi Name
+
+
+
+
+ Password
+
+
+
+
+ Contains at least 8 characters
+
+
+
+
+ Frequency band
+
+
+
+
+ Net card
+
+
+
+
+
+ hotspot already open
+
+
+
diff --git a/plugins/mobilehotspot/translations/tr.ts b/plugins/mobilehotspot/translations/tr.ts
index 70f2c4b7..2c1f8b3d 100644
--- a/plugins/mobilehotspot/translations/tr.ts
+++ b/plugins/mobilehotspot/translations/tr.ts
@@ -4,7 +4,7 @@
BlacklistItem
-
+
@@ -12,7 +12,7 @@
BlacklistPage
-
+
@@ -20,7 +20,7 @@
ConnectDevListItem
-
+
@@ -28,7 +28,7 @@
ConnectdevPage
-
+
@@ -56,79 +56,69 @@
MobileHotspotWidget
-
+
-
+
-
+
-
-
-
-
-
-
+
-
-
-
-
-
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
diff --git a/plugins/mobilehotspot/translations/zh_CN.ts b/plugins/mobilehotspot/translations/zh_CN.ts
index 4d44a72a..a9fb2288 100644
--- a/plugins/mobilehotspot/translations/zh_CN.ts
+++ b/plugins/mobilehotspot/translations/zh_CN.ts
@@ -4,7 +4,7 @@
BlacklistItem
-
+
移出
@@ -12,7 +12,7 @@
BlacklistPage
-
+
设备黑名单
@@ -20,7 +20,7 @@
ConnectDevListItem
-
+
添加进黑名单
@@ -28,7 +28,7 @@
ConnectdevPage
-
+
连接设备
@@ -56,27 +56,26 @@
MobileHotspotWidget
-
+
控制面板
-
+
控制面板桌面通知
-
+
无线开关已关闭或不存在有热点功能的无线网卡
-
- 开始关闭热点
+ 开始关闭热点
-
+
热点名称或设备错误
@@ -85,54 +84,53 @@
不能创建密码长度小于八位的热点!
-
- 开始创建热点
+ 开始创建热点
-
+
至少包含8个字符
-
+
移动热点
-
-
+
+
热点已关闭
-
+
开启
-
+
Wi-Fi名称
-
+
网络密码
-
+
网络频带
-
+
共享网卡端口
-
-
+
+
热点已开启
diff --git a/plugins/netconnect/lanitem.cpp b/plugins/netconnect/lanitem.cpp
index ad0aad0c..2df49237 100644
--- a/plugins/netconnect/lanitem.cpp
+++ b/plugins/netconnect/lanitem.cpp
@@ -18,6 +18,8 @@
*
*/
#include "lanitem.h"
+#include
+
#define FRAME_SPEED 150
#define LIMIT_TIME 60*1000
#define TOTAL_PAGE 8
@@ -31,11 +33,6 @@ LanItem::LanItem(bool isAcitve, QWidget *parent)
this->setMinimumSize(550, 58);
this->setProperty("useButtonPalette", true);
this->setFlat(true);
- QPalette pal = this->palette();
- QColor color = pal.color(QPalette::Button);
- color.setAlphaF(0.5);
- pal.setColor(QPalette::Button, color);
- this->setPalette(pal);
// setStyleSheet("QPushButton:!checked{background-color: palette(base)}");
QHBoxLayout *mLanLyt = new QHBoxLayout(this);
mLanLyt->setContentsMargins(16,0,16,0);
@@ -44,31 +41,15 @@ LanItem::LanItem(bool isAcitve, QWidget *parent)
iconLabel->setProperty("useIconHighlightEffect", 0x2);
titileLabel = new FixLabel(this);
statusLabel = new QLabel(this);
+ statusLabel->setProperty("useIconHighlightEffect", 0x2);
statusLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
// statusLabel->setMinimumSize(36,36);
infoLabel = new GrayInfoButton(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"));
@@ -79,10 +60,6 @@ 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()
@@ -110,48 +87,19 @@ 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();
+ QPalette pal = qApp->palette();
QPainter painter(this);
painter.setRenderHint(QPainter:: Antialiasing, true); //设置渲染,启动反锯齿
painter.setPen(Qt::NoPen);
- painter.setBrush(pal.color(QPalette::Base));
+ painter.setBrush(this->palette().base().color());
+
+ QColor color = pal.color(QPalette::Button);
+ color.setAlphaF(0.5);
+ pal.setColor(QPalette::Button, color);
+ this->setPalette(pal);
QRect rect = this->rect();
@@ -159,18 +107,3 @@ 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;
-}
-
diff --git a/plugins/netconnect/lanitem.h b/plugins/netconnect/lanitem.h
index b27a9df2..ea1b1355 100644
--- a/plugins/netconnect/lanitem.h
+++ b/plugins/netconnect/lanitem.h
@@ -29,16 +29,12 @@
#include
#include
#include
-#include
-#include
-#include
#include "fixlabel.h"
//#include "infobutton.h"
#include "../component/AddBtn/grayinfobutton.h"
class LanItem : public QPushButton
{
- Q_OBJECT
public:
LanItem(bool isAcitve, QWidget *parent = nullptr);
~LanItem();
@@ -47,15 +43,10 @@ public:
GrayInfoButton * 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;
@@ -65,23 +56,15 @@ public:
protected:
void paintEvent(QPaintEvent *);
- bool eventFilter(QObject *watched, QEvent *event);
private:
QTimer *waitTimer = nullptr;
QGSettings *themeGsettings = nullptr;
QList loadIcons;
- int currentIconIndex=0;
+ int currentIconIndex=0;
private slots:
- void updateIcon();
- void onConnectTriggered();
- void onDeletetTriggered();
-
-Q_SIGNALS:
- void connectActionTriggered();
- void disconnectActionTriggered();
- void deleteActionTriggered();
+ void updateIcon();
};
diff --git a/plugins/netconnect/netconnect.cpp b/plugins/netconnect/netconnect.cpp
index 21fbe697..71bb66ee 100644
--- a/plugins/netconnect/netconnect.cpp
+++ b/plugins/netconnect/netconnect.cpp
@@ -32,9 +32,6 @@
#define ITEMHEIGH 50
#define LAN_TYPE 0
#define CONTROL_CENTER_WIFI "org.ukui.control-center.wifi.switch"
-#define KYLIN_APP_MANAGER_NAME "com.kylin.AppManager"
-#define KYLIN_APP_MANAGER_PATH "/com/kylin/AppManager"
-#define KYLIN_APP_MANAGER_INTERFACE "com.kylin.AppManager"
const QString KLanSymbolic = "network-wired-connected-symbolic";
const QString NoNetSymbolic = "network-wired-disconnected-symbolic";
@@ -81,7 +78,7 @@ NetConnect::NetConnect() : mFirstLoad(true) {
translator->load("/usr/share/kylin-nm/netconnect/" + QLocale::system().name());
QApplication::installTranslator(translator);
- pluginName = tr("WiredConnect");
+ pluginName = tr("LAN");
pluginType = NETWORK;
}
@@ -153,7 +150,7 @@ QString NetConnect::translationPath() const
void NetConnect::initSearchText() {
//~ contents_path /netconnect/Advanced settings"
ui->detailBtn->setText(tr("Advanced settings"));
- ui->titleLabel->setText(tr("Wired Network"));
+ ui->titleLabel->setText(tr("LAN"));
//~ contents_path /netconnect/open
ui->openLabel->setText(tr("open"));
}
@@ -171,7 +168,9 @@ bool NetConnect::eventFilter(QObject *w, QEvent *e) {
if (!wiredSwitch->isCheckable()) {
showDesktopNotify(tr("No ethernet device avaliable"));
} else {
- m_interface->call(QStringLiteral("setWiredSwitchEnable"), !wiredSwitch->isChecked());
+ if (m_interface != nullptr && m_interface->isValid()) {
+ m_interface->call(QStringLiteral("setWiredSwitchEnable"), !wiredSwitch->isChecked());
+ }
return true;
}
}
@@ -245,7 +244,7 @@ void NetConnect::initComponent() {
//获取网卡列表
void NetConnect::getDeviceStatusMap(QMap &map)
{
- if (!m_interface->isValid()) {
+ if (m_interface == nullptr || !m_interface->isValid()) {
return;
}
qDebug() << "[NetConnect]call getDeviceListAndEnabled" << __LINE__;
@@ -353,22 +352,16 @@ void NetConnect::initNet()
}
void NetConnect::runExternalApp() {
-// QString cmd = "nm-connection-editor";
-// QProcess process(this);
-// process.startDetached(cmd);
- LaunchApp("nm-connection-editor.desktop");
-}
-
-//刪除
-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__;
+ QString cmd = "nm-connection-editor";
+ QProcess process(this);
+ process.startDetached(cmd);
}
//激活
void NetConnect::activeConnect(QString ssid, QString deviceName, int type) {
+ if (m_interface == nullptr || !m_interface->isValid()) {
+ return;
+ }
qDebug() << "[NetConnect]call activateConnect" << __LINE__;
m_interface->call(QStringLiteral("activateConnect"),type, deviceName, ssid);
qDebug() << "[NetConnect]call activateConnect respond" << __LINE__;
@@ -376,6 +369,9 @@ void NetConnect::activeConnect(QString ssid, QString deviceName, int type) {
//断开
void NetConnect::deActiveConnect(QString ssid, QString deviceName, int type) {
+ if (m_interface == nullptr || !m_interface->isValid()) {
+ return;
+ }
qDebug() << "[NetConnect]call deActivateConnect" << __LINE__;
m_interface->call(QStringLiteral("deActivateConnect"),type, deviceName, ssid);
qDebug() << "[NetConnect]call deActivateConnect respond" << __LINE__;
@@ -389,7 +385,7 @@ void NetConnect::initNetListFromDevice(QString deviceName)
qDebug() << "[NetConnect]initNetListFromDevice " << deviceName << " not exist";
return;
}
- if (!m_interface->isValid()) {
+ if (m_interface == nullptr || !m_interface->isValid()) {
return;
}
qDebug() << "[NetConnect]call getWiredList" << __LINE__;
@@ -435,12 +431,12 @@ void NetConnect::addLanItem(ItemFrame *frame, QString devName, QStringList infoL
return;
}
- LanItem * lanItem = new LanItem(isActived, pluginWidget);
+ LanItem * lanItem = new LanItem(pluginWidget);
QString iconPath = KLanSymbolic;
if (isActived) {
lanItem->statusLabel->setText(tr("connected"));
} else {
- lanItem->statusLabel->setText(tr("not connected"));
+ lanItem->statusLabel->setText("");
}
QIcon searchIcon = QIcon::fromTheme(iconPath);
// if (iconPath != KLanSymbolic && iconPath != NoNetSymbolic) {
@@ -454,7 +450,7 @@ void NetConnect::addLanItem(ItemFrame *frame, QString devName, QStringList infoL
connect(lanItem->infoLabel, &GrayInfoButton::clicked, this, [=]{
// open landetail page
- if (!m_interface->isValid()) {
+ if (m_interface == nullptr || !m_interface->isValid()) {
return;
}
qDebug() << "[NetConnect]call showPropertyWidget" << __LINE__;
@@ -463,7 +459,6 @@ 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) {
@@ -473,16 +468,6 @@ 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";
@@ -492,6 +477,9 @@ void NetConnect::addLanItem(ItemFrame *frame, QString devName, QStringList infoL
//增加设备
void NetConnect::addDeviceFrame(QString devName)
{
+ if (m_interface == nullptr || !m_interface->isValid()) {
+ return;
+ }
qDebug() << "[NetConnect]addDeviceFrame " << devName;
qDebug() << "[NetConnect]call getDeviceListAndEnabled" << __LINE__;
@@ -538,18 +526,20 @@ void NetConnect::addDeviceFrame(QString devName)
qDebug() << "[NetConnect]set " << devName << "status" << true;
itemFrame->lanItemFrame->show();
itemFrame->deviceFrame->dropDownLabel->show();
+ itemFrame->addLanWidget->show();
itemFrame->deviceFrame->dropDownLabel->setDropDownStatus(true);
deviceStatusMap[devName] = true;
} else {
qDebug() << "[NetConnect]set " << devName << "status" << false;
itemFrame->lanItemFrame->hide();
itemFrame->deviceFrame->dropDownLabel->hide();
+ itemFrame->addLanWidget->hide();
deviceStatusMap[devName] = false;
}
});
connect(itemFrame->addLanWidget, &AddNetBtn::clicked, this, [=](){
- if (m_interface->isValid()) {
+ if (m_interface != nullptr && m_interface->isValid()) {
qDebug() << "[NetConnect]call showCreateWiredConnectWidget" << devName << __LINE__;
m_interface->call(QStringLiteral("showCreateWiredConnectWidget"), devName);
qDebug() << "[NetConnect]call setDeviceEnable Respond" << __LINE__;
@@ -732,7 +722,7 @@ void NetConnect::addOneLanFrame(ItemFrame *frame, QString deviceName, QStringLis
QString iconPath;
iconPath = KLanSymbolic;
- lanItem->statusLabel->setText(tr("not connected"));
+ lanItem->statusLabel->setText("");
QIcon searchIcon = QIcon::fromTheme(iconPath);
// if (iconPath != KLanSymbolic && iconPath != NoNetSymbolic) {
@@ -746,7 +736,7 @@ void NetConnect::addOneLanFrame(ItemFrame *frame, QString deviceName, QStringLis
connect(lanItem->infoLabel, &GrayInfoButton::clicked, this, [=]{
// open landetail page
- if (!m_interface->isValid()) {
+ if (m_interface == nullptr || !m_interface->isValid()) {
return;
}
qDebug() << "[NetConnect]call showPropertyWidget" << deviceName << connUuid << __LINE__;
@@ -755,7 +745,6 @@ 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) {
@@ -765,16 +754,6 @@ 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);
@@ -889,9 +868,7 @@ 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))));
@@ -901,7 +878,7 @@ int NetConnect::getInsertPos(QString connName, QString deviceName)
{
qDebug() << "[NetConnect]getInsertPos" << connName << deviceName;
int index = 0;
- if(!m_interface->isValid()) {
+ if(m_interface == nullptr || !m_interface->isValid()) {
index = 0;
} else {
qDebug() << "[NetConnect]call getWiredList" << __LINE__;
@@ -932,19 +909,3 @@ int NetConnect::getInsertPos(QString connName, QString deviceName)
}
return index;
}
-
-bool NetConnect::LaunchApp(QString desktopFile)
-{
- QDBusInterface m_appManagerDbusInterface(KYLIN_APP_MANAGER_NAME,
- KYLIN_APP_MANAGER_PATH,
- KYLIN_APP_MANAGER_INTERFACE,
- QDBusConnection::sessionBus());//局部变量
-
- if (!m_appManagerDbusInterface.isValid()) {
- qWarning()<<"m_appManagerDbusInterface init error";
- return false;
- } else {
- QDBusReply reply =m_appManagerDbusInterface.call("LaunchApp",desktopFile);
- return reply;
- }
-}
diff --git a/plugins/netconnect/netconnect.h b/plugins/netconnect/netconnect.h
index 99ce6855..f991540f 100644
--- a/plugins/netconnect/netconnect.h
+++ b/plugins/netconnect/netconnect.h
@@ -101,7 +101,7 @@ private:
int getInsertPos(QString connName, QString deviceName);
- void deleteOneLan(QString ssid, int type);
+ void deleteOneLan(QString ssid);
void activeConnect(QString ssid, QString deviceName, int type);
void deActiveConnect(QString ssid, QString deviceName, int type);
@@ -123,7 +123,6 @@ private:
//单个lan连接状态变化
void itemActiveConnectionStatusChanged(LanItem *item, int status);
- bool LaunchApp(QString desktopFile);
protected:
bool eventFilter(QObject *w,QEvent *e);
@@ -153,7 +152,6 @@ private slots:
void onDeviceStatusChanged();
void onDeviceNameChanged(QString, QString, int);
-
};
Q_DECLARE_METATYPE(QList);
diff --git a/plugins/netconnect/netconnect.pro b/plugins/netconnect/netconnect.pro
index be66275c..500a3b7e 100644
--- a/plugins/netconnect/netconnect.pro
+++ b/plugins/netconnect/netconnect.pro
@@ -51,4 +51,5 @@ TRANSLATIONS += \
translations/zh_CN.ts \
translations/tr.ts \
translations/bo.ts \
- translations/bo_CN.ts
+ translations/bo_CN.ts \
+ translations/en_US.ts
diff --git a/plugins/netconnect/translations/bo.ts b/plugins/netconnect/translations/bo.ts
index 16910853..dce9ee13 100644
--- a/plugins/netconnect/translations/bo.ts
+++ b/plugins/netconnect/translations/bo.ts
@@ -4,7 +4,12 @@
AddNetBtn
-
+
+
+
+
+
+
@@ -13,52 +18,52 @@
NetConnect
-
-
+
/netconnect/open
-
+
/netconnect/Advanced settings"
-
+
-
+
-
-
+
+
+
-
+
-
-
+
+
-
+
diff --git a/plugins/netconnect/translations/bo_CN.qm b/plugins/netconnect/translations/bo_CN.qm
index 22c45a00425af355193733d71d9b8f950e01f60b..f41e3534efdcb889e7081dd17f84ec6fa044b0d4 100644
GIT binary patch
delta 164
zcmZ3$-Of2dBrbx1As~){f#EU(+l&?l2Bt^`_OyLK`WlmEu_yxrb3Lo~fh$0M7e|`?
zXP~-b&Qf(&1_nk!uEPbZf%FQVHUepN9#8?QW8)Y4IUA^sA(MfDMRek`@<~hy
zS~C1;{1f;~_yhU5`4jnTz;q!0CLk}2pO*uqnhl7VeH{HJJ2H!GPGCCDxH+B0k`VwC
C>m&*Q
delta 437
zcmZqYT);g+q`rcIZAJ?N1G5kVd)huAeV$480EpkuWLYfAz`#<$vPNeq0|Ub^R__B>
zfa1=qdDA`v`3xLs_CT63i?dXn6-b}rO8jjCq|LZey`KQ3k8>R^Sk1t|l*sc&@)FP-
zHr}HLRDk^b{6arx1LZ?985mgkm?MBp9sWT6P5j*aN&J)eHv(xV{y6?%ARP!~aq}kw
zaU6dMkevo(@p1q)Ft7nJmt#tbf`3UyYEdyekjn|=`lXgQmEcAvyN&yv(!uwE(t2%z#nplu;QH*xca@yGMm
zfN6wgHkZ_#)RI&Ty?j7-x&l>0baQja0}Y2b*Cn$!8PmdvPf|CxGahGDi~w4I%cZ<|
M`6UXQ^_e3W0c$>4+yDRo
diff --git a/plugins/netconnect/translations/bo_CN.ts b/plugins/netconnect/translations/bo_CN.ts
index 897b2285..e31cef7e 100644
--- a/plugins/netconnect/translations/bo_CN.ts
+++ b/plugins/netconnect/translations/bo_CN.ts
@@ -4,41 +4,20 @@
AddNetBtn
-
+
- དྲ་རྒྱ་གཞན་དག་ལ་ཞུགས་།
+
-
+
སྐུད་ཡོད་བརྙན་འཕྲིན་ཁ་སྣོན་བྱས་ཡོད།
-
- LanItem
-
-
-
- མེད་པར་བཟོ་བ་
-
-
-
-
-
- གཅོད་པ་
-
-
-
-
-
- སྦྲེལ་བ་
-
-
NetConnect
-
སྐུད་ཡོད་བརྙན་འཕྲིན་དྲ་བ།
@@ -67,9 +46,14 @@
ukui ཚོད་འཛིན་ལྟེ་གནས་ཀྱི་ཅོག་ངོས་ཆ་འཕྲིན།
-
- སྐུད་ཡོད་སྦྲེལ་མཐུད།
+ སྐུད་ཡོད་སྦྲེལ་མཐུད།
+
+
+
+
+
+ སྐུད་ཡོད་དྲ་བ།
@@ -77,21 +61,15 @@
ཨེ་ཙི་དྲ་རྒྱའི་སྒྲིག་ཆས་ལ་བཙན་འཛུལ་བྱས་མི་ཆོག།
-
-
+
+
འབྲེལ་མཐུད་བྱེད་པ།
-
+
བྱང་བུ།
-
-
-
-
- མ་སྦྲེལ་བ་
-
diff --git a/plugins/netconnect/translations/en_US.ts b/plugins/netconnect/translations/en_US.ts
new file mode 100644
index 00000000..43e8a786
--- /dev/null
+++ b/plugins/netconnect/translations/en_US.ts
@@ -0,0 +1,71 @@
+
+
+
+
+ AddNetBtn
+
+
+
+ Add Others
+
+
+
+
+ Add WiredNetork
+
+
+
+ NetConnect
+
+
+
+ Wired Network
+
+
+
+
+
+ open
+ /netconnect/open
+
+
+
+
+
+ Advanced settings
+ /netconnect/Advanced settings"
+
+
+
+
+ ukui control center
+
+
+
+
+ ukui control center desktop message
+
+
+
+
+
+ LAN
+
+
+
+
+ No ethernet device avaliable
+
+
+
+
+
+ connected
+
+
+
+
+ card
+
+
+
diff --git a/plugins/netconnect/translations/tr.ts b/plugins/netconnect/translations/tr.ts
index 16910853..dce9ee13 100644
--- a/plugins/netconnect/translations/tr.ts
+++ b/plugins/netconnect/translations/tr.ts
@@ -4,7 +4,12 @@
AddNetBtn
-
+
+
+
+
+
+
@@ -13,52 +18,52 @@
NetConnect
-
-
+
/netconnect/open
-
+
/netconnect/Advanced settings"
-
+
-
+
-
-
+
+
+
-
+
-
-
+
+
-
+
diff --git a/plugins/netconnect/translations/zh_CN.qm b/plugins/netconnect/translations/zh_CN.qm
index 93f01012ac811386415117a8204ddcc5caee79f8..f8fe4d7bbb6520cb61929cde1055dc42171c755b 100644
GIT binary patch
delta 130
zcmbQmew=lJNL&O1LqHq@14AJL+l&?l21Z{7_OyLKdJ&Ulu_yxr6Emy#fh$0M2}hd!
zXP`Pu&Qf(&AU&JwaKUOI{fy_0ual)&l^{`5_tr
delta 351
zcmX@kI*WaRNPPtZ+l&?l2F7y?>}mTL7??ttbPoXeOv+4_#iBrZ8_OD4%9=OrGmy`~k!BB~pKz9{vjW9sxDtPx0QtMPQoWx5>0GYE1*?JL={#>FF9FS|
z;XQgl1<0SxFZ6RZP~Ieyfq|KW*%-*=30e@C8dw(HTpw6>hXW|Uzy`!zjwvY${v{cy
zMaAquE+>%dms;XflE*l)$hMxP|6cM^xLS7S{Jgx>
AddNetBtn
-
+
- 加入其它网络
+
-
+
添加有线网络
-
- LanItem
-
-
-
- 删除
-
-
-
-
-
- 断开
-
-
-
-
-
- 连接
-
-
NetConnect
-
有线网络
@@ -67,8 +46,13 @@
控制面板桌面通知
-
+ 有线网络
+
+
+
+
+
有线网络
@@ -77,21 +61,15 @@
未检测到有线设备
-
-
+
+
已连接
-
+
网卡
-
-
-
-
- 未连接
-
diff --git a/plugins/plugin.pro b/plugins/plugin.pro
index 1ef03f43..cee11d57 100644
--- a/plugins/plugin.pro
+++ b/plugins/plugin.pro
@@ -3,5 +3,4 @@ SUBDIRS = \
netconnect \
wlanconnect \
mobilehotspot \
- proxy \
- vpn
+ proxy
diff --git a/plugins/proxy/applistwidget.cpp b/plugins/proxy/applistwidget.cpp
index c3c87109..dc2e5cd3 100644
--- a/plugins/proxy/applistwidget.cpp
+++ b/plugins/proxy/applistwidget.cpp
@@ -29,7 +29,7 @@ AppListWidget::AppListWidget(QString path, QWidget *parent)
AppListWidget::~AppListWidget()
{
-
+ delete m_dbusInterface;
}
/**
@@ -79,8 +79,9 @@ void AppListWidget::onAppCheckStateChanged()
*/
void AppListWidget::AddAppProxyConfig()
{
- if(!m_dbusInterface->isValid()) {
+ if(m_dbusInterface == nullptr || !m_dbusInterface->isValid()) {
qWarning ()<< "init AppProxy dbus error";
+ return;
}
qDebug() << "call QDBusInterface addAppIntoProxy";
@@ -93,8 +94,9 @@ void AppListWidget::AddAppProxyConfig()
*/
void AppListWidget::RemoveAppProxyConfig()
{
- if(!m_dbusInterface->isValid()) {
+ if(m_dbusInterface == nullptr || !m_dbusInterface->isValid()) {
qWarning ()<< "init AppProxy dbus error";
+ return;
}
qDebug() << "call QDBusInterface delAppIntoProxy";
@@ -116,7 +118,6 @@ void AppListWidget::initUI()
mainLayout->setContentsMargins(17, 0, 17, 0);
mainLayout->setSpacing(8);
m_checkBox = new QCheckBox(this);
- m_checkBox->setFixedSize(16, 16);
m_checkBox->setAttribute(Qt::WA_TransparentForMouseEvents, true); //m_checkBox不响应鼠标事件,将其传递给父窗口
m_iconLabel = new QLabel(this);
m_iconLabel->setFixedSize(24, 24);
@@ -135,4 +136,7 @@ void AppListWidget::initDbus()
"/org/ukui/SettingsDaemon/AppProxy",
"org.ukui.SettingsDaemon.AppProxy",
QDBusConnection::sessionBus());
+ if(!m_dbusInterface->isValid()) {
+ qWarning() << qPrintable(QDBusConnection::sessionBus().lastError().message());
+ }
}
diff --git a/plugins/proxy/aptproxydialog.cpp b/plugins/proxy/aptproxydialog.cpp
index eb87e779..2c1cc21a 100644
--- a/plugins/proxy/aptproxydialog.cpp
+++ b/plugins/proxy/aptproxydialog.cpp
@@ -22,14 +22,14 @@ AptProxyDialog::~AptProxyDialog()
void AptProxyDialog::initUi()
{
setWindowTitle(tr("Set Apt Proxy"));
- this->setFixedSize(480, 204);
+ this->setFixedSize(480, 200);
QVBoxLayout *mAptProxyLyt = new QVBoxLayout(this);
mAptProxyLyt->setContentsMargins(24, 24, 24, 24);
- mAptProxyLyt->setSpacing(8);
+ mAptProxyLyt->setSpacing(16);
QFrame *mHostFrame = new QFrame(this);
- mHostFrame->setFixedWidth(432);
+ mHostFrame->setFixedSize(432, 36);
mHostFrame->setFrameShape(QFrame::NoFrame);
QHBoxLayout *mLyt_1= new QHBoxLayout(mHostFrame);
@@ -37,19 +37,19 @@ void AptProxyDialog::initUi()
mLyt_1->setSpacing(8);
FixLabel *mSetHostLabel = new FixLabel(mHostFrame);
- mSetHostLabel->setFixedWidth(92);
+ mSetHostLabel->setFixedSize(92, 36);
mSetHostLabel->setText(tr("Server Address"));
mHostEdit = new QLineEdit(mHostFrame);
mHostEdit->setAttribute(Qt::WA_InputMethodEnabled, false); //限制中文输入法
- mHostEdit->setFixedWidth(332);
+ mHostEdit->setFixedSize(332, 36);
mHostEdit->installEventFilter(this);
mLyt_1->addWidget(mSetHostLabel);
mLyt_1->addWidget(mHostEdit);
QFrame *mPortFrame = new QFrame(this);
- mPortFrame->setFixedWidth(432);
+ mPortFrame->setFixedSize(432, 36);
mPortFrame->setFrameShape(QFrame::NoFrame);
QHBoxLayout *mLyt_2= new QHBoxLayout(mPortFrame);
@@ -57,11 +57,11 @@ void AptProxyDialog::initUi()
mLyt_2->setSpacing(8);
QLabel *mSetPortLabel = new QLabel(tr("Port") ,mPortFrame);
- mSetPortLabel->setFixedWidth(92);
+ mSetPortLabel->setFixedSize(92, 36);
mPortEdit = new QLineEdit(mPortFrame);
mPortEdit->setAttribute(Qt::WA_InputMethodEnabled, false); //限制中文输入法
- mPortEdit->setFixedWidth(332);
+ mPortEdit->setFixedSize(332, 36);
mPortEdit->installEventFilter(this);
mLyt_2->addWidget(mSetPortLabel);
@@ -76,9 +76,11 @@ void AptProxyDialog::initUi()
mLyt_3->setSpacing(16);
mCancelBtn = new QPushButton(mChooseFrame);
+ mCancelBtn->setMinimumWidth(96);
mCancelBtn->setText(tr("Cancel"));
mConfirmBtn = new QPushButton(mChooseFrame);
+ mConfirmBtn->setMinimumWidth(96);
mConfirmBtn->setText(tr("Confirm"));
mLyt_3->addStretch();
@@ -87,7 +89,7 @@ void AptProxyDialog::initUi()
mAptProxyLyt->addWidget(mHostFrame);
mAptProxyLyt->addWidget(mPortFrame);
- mAptProxyLyt->addStretch();
+ mAptProxyLyt->addSpacing(16);
mAptProxyLyt->addWidget(mChooseFrame);
}
diff --git a/plugins/proxy/proxy.cpp b/plugins/proxy/proxy.cpp
index 6a009a3f..33032fd4 100644
--- a/plugins/proxy/proxy.cpp
+++ b/plugins/proxy/proxy.cpp
@@ -45,11 +45,11 @@
#define PROXY_HOST_KEY "host"
#define PROXY_PORT_KEY "port"
-
+#define THEME_SCHAME "org.ukui.style"
#define FRAME_LAYOUT_MARGINS 16,0,16,0
#define FRAME_LAYOUT_SPACING 8
#define LABEL_WIDTH 136
-#define IP_FRAME_MAX_HEIGHT 76
+#define LINE_EDIT_HEIGHT 36
Proxy::Proxy() : mFirstLoad(true)
{
@@ -67,7 +67,8 @@ Proxy::Proxy() : mFirstLoad(true)
Proxy::~Proxy()
{
if (!mFirstLoad) {
- plugin_leave();
+ plugin_leave();
+ delete m_appProxyDbus;
}
}
@@ -162,6 +163,11 @@ QIcon Proxy::icon() const
return QIcon::fromTheme("ukui-network-agent-symbolic");
}
+QString Proxy::translationPath() const
+{
+ return "/usr/share/kylin-nm/proxy/%1.ts";
+}
+
bool Proxy::isEnable() const
{
return true;
@@ -233,6 +239,7 @@ void Proxy::initUi(QWidget *widget)
mUrlLabel->setFixedWidth(136);
mUrlLineEdit = new QLineEdit(mUrlFrame);
+ mUrlLineEdit->setFixedHeight(36);
mUrlLayout->addWidget(mUrlLabel);
mUrlLayout->addWidget(mUrlLineEdit);
@@ -254,6 +261,7 @@ void Proxy::initUi(QWidget *widget)
mHTTPLineEdit_1 = new QLineEdit(mHTTPFrame);
mHTTPLineEdit_1->resize(300, 36);
mHTTPLineEdit_2 = new QLineEdit(mHTTPFrame);
+ mHTTPLineEdit_2->setFixedHeight(36);
mHTTPLineEdit_2->setValidator(new QRegExpValidator(QRegExp("[0-9]*") , this));
mHTTPLayout_1->addWidget(mHTTPLabel);
mHTTPLayout_1->addWidget(mHTTPLineEdit_1);
@@ -276,6 +284,7 @@ void Proxy::initUi(QWidget *widget)
mHTTPSLineEdit_1 = new QLineEdit(mHTTPSFrame);
mHTTPSLineEdit_1->resize(300, 36);
mHTTPSLineEdit_2 = new QLineEdit(mHTTPSFrame);
+ mHTTPSLineEdit_2->setFixedHeight(36);
mHTTPSLineEdit_2->setValidator(new QRegExpValidator(QRegExp("[0-9]*") , this));
mHTTPSLayout->addWidget(mHTTPSLabel);
mHTTPSLayout->addWidget(mHTTPSLineEdit_1);
@@ -298,6 +307,7 @@ void Proxy::initUi(QWidget *widget)
mFTPLineEdit_1 = new QLineEdit(mFTPFrame);
mFTPLineEdit_1->resize(300, 36);
mFTPLineEdit_2 = new QLineEdit(mFTPFrame);
+ mFTPLineEdit_2->setFixedHeight(36);
mFTPLineEdit_2->setValidator(new QRegExpValidator(QRegExp("[0-9]*") , this));
mFTPLayout->addWidget(mFTPLabel);
mFTPLayout->addWidget(mFTPLineEdit_1);
@@ -320,6 +330,7 @@ void Proxy::initUi(QWidget *widget)
mSOCKSLineEdit_1 = new QLineEdit(mSOCKSFrame);
mSOCKSLineEdit_1->resize(300, 36);
mSOCKSLineEdit_2 = new QLineEdit(mSOCKSFrame);
+ mSOCKSLineEdit_2->setFixedHeight(36);
mSOCKSLineEdit_2->setValidator(new QRegExpValidator(QRegExp("[0-9]*") , this));
mSOCKSLayout->addWidget(mSOCKSLabel);
mSOCKSLayout->addWidget(mSOCKSLineEdit_1);
@@ -697,6 +708,9 @@ void Proxy::initDbus()
"/org/ukui/SettingsDaemon/AppProxy",
"org.ukui.SettingsDaemon.AppProxy",
QDBusConnection::sessionBus());
+ if(!m_appProxyDbus->isValid()) {
+ qWarning() << qPrintable(QDBusConnection::sessionBus().lastError().message());
+ }
}
void Proxy::initAppProxyStatus()
@@ -747,8 +761,11 @@ void Proxy::setAptProxy(QString host, QString port, bool status)
"/",
"com.control.center.interface",
QDBusConnection::systemBus());
- if (mAptproxyDbus->isValid())
+ if (mAptproxyDbus->isValid()) {
QDBusReply reply = mAptproxyDbus->call("setaptproxy", host, port , status);
+ }
+ delete mAptproxyDbus;
+ mAptproxyDbus = nullptr;
}
QHash Proxy::getAptProxy()
@@ -781,6 +798,8 @@ QHash Proxy::getAptProxy()
mAptInfo.insert(it.arg, it.out.variant());
}
}
+ delete mAptproxyDbus;
+ mAptproxyDbus = nullptr;
return mAptInfo;
}
@@ -809,8 +828,9 @@ void Proxy::reboot()
"/org/gnome/SessionManager",
"org.gnome.SessionManager",
QDBusConnection::sessionBus());
-
- rebootDbus->call("reboot");
+ if (rebootDbus->isValid()) {
+ rebootDbus->call("reboot");
+ }
delete rebootDbus;
rebootDbus = nullptr;
}
@@ -836,8 +856,9 @@ QFrame *Proxy::setLine(QFrame *frame)
bool Proxy::getAppProxyState()
{
bool state = true;
- if(!m_appProxyDbus->isValid()) {
+ if(m_appProxyDbus == nullptr || !m_appProxyDbus->isValid()) {
qWarning ()<< "init AppProxy dbus error";
+ return false;
}
//获取应用代理开启状态
@@ -854,7 +875,7 @@ bool Proxy::getAppProxyState()
void Proxy::setAppProxyState(bool state)
{
- if(!m_appProxyDbus->isValid()) {
+ if(m_appProxyDbus == nullptr || !m_appProxyDbus->isValid()) {
qWarning ()<< "init AppProxy dbus error";
return;
}
@@ -876,6 +897,7 @@ QStringList Proxy::getAppProxyConf()
if(!dbusInterface.isValid()) {
qWarning ()<< "init AppProxy dbus error";
+ return info;
}
//获取应用代理配置信息
@@ -898,11 +920,12 @@ QStringList Proxy::getAppProxyConf()
void Proxy::setAppProxyConf(QStringList list)
{
+ //AppProxyConf 必填项数量为3
if (list.count() < 3) {
return;
}
- if(!m_appProxyDbus->isValid()) {
+ if(m_appProxyDbus == nullptr || !m_appProxyDbus->isValid()) {
qWarning ()<< "init AppProxy dbus error";
return;
}
@@ -1003,23 +1026,27 @@ void Proxy::setAppProxyFrameUi(QWidget *widget)
//IP地址ui布局
m_ipAddressFrame = new QFrame(m_appProxyFrame);
m_ipAddressFrame->setMinimumSize(QSize(550, 60));
- m_ipAddressFrame->setMaximumSize(QSize(16777215, IP_FRAME_MAX_HEIGHT));
+ m_ipAddressFrame->setMaximumSize(QSize(16777215, 88));
m_ipAddressFrame->setFrameShape(QFrame::NoFrame);
m_ipAddressLabel = new QLabel(tr("IP address"), m_ipAddressFrame);
m_ipAddressLabel->setFixedWidth(LABEL_WIDTH);
m_ipHintsLabel = new QLabel(m_ipAddressFrame);
- m_ipHintsLabel->setFixedHeight(20);
m_ipHintsLabel->setContentsMargins(8, 0, 0, 0);
m_ipAddressLineEdit = new QLineEdit(m_ipAddressFrame);
- m_ipAddressLineEdit->setMinimumHeight(36);
+ m_ipAddressLineEdit->setFixedHeight(LINE_EDIT_HEIGHT);
m_ipAddressLineEdit->setPlaceholderText(tr("Required")); //必填
- QGridLayout *ipAddressLayout = new QGridLayout(m_ipAddressFrame);
- ipAddressLayout->setContentsMargins(16, 0, 16, 0);
- ipAddressLayout->setVerticalSpacing(0);
- ipAddressLayout->addWidget(m_ipAddressLabel, 0, 0);
- ipAddressLayout->addWidget(m_ipAddressLineEdit, 0, 1);
- ipAddressLayout->addWidget(m_ipHintsLabel, 1, 1);
+ QWidget *ipInputWidget = new QWidget(m_ipAddressFrame);
+ QVBoxLayout *ipVLayout = new QVBoxLayout(ipInputWidget);
+ ipVLayout->setContentsMargins(0, 0, 0, 0);
+ ipVLayout->setSpacing(3);
+ ipVLayout->addWidget(m_ipAddressLineEdit);
+ ipVLayout->addWidget(m_ipHintsLabel);
+
+ QFormLayout *ipAddressLayout = new QFormLayout(m_ipAddressFrame);
+ ipAddressLayout->setContentsMargins(16, 12, 16, 12);
+ ipAddressLayout->setSpacing(FRAME_LAYOUT_SPACING);
+ ipAddressLayout->addRow(m_ipAddressLabel, ipInputWidget);
// 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");
@@ -1151,18 +1178,22 @@ void Proxy::setAppListFrameUi(QWidget *widget)
m_allowAppProxyLabel->setText(tr("The following applications are allowed to use this configuration:")); //允许以下应用使用该配置:
m_appListWidget = new QListWidget(m_appListFrame);
m_appListWidget->setMinimumHeight(240);
- m_appListWidget->setBackgroundRole(QPalette::Base);
m_appListWidget->setFocusPolicy(Qt::FocusPolicy::NoFocus);
m_appListWidget->setFrameShape(QFrame::Shape::Panel);
appListLayout->addWidget(m_allowAppProxyLabel);
appListLayout->addWidget(m_appListWidget);
- QPalette mpal(m_appListWidget->palette());
- mpal.setColor(QPalette::Base, qApp->palette().base().color());
- mpal.setColor(QPalette::AlternateBase, qApp->palette().alternateBase().color());
- m_appListWidget->setAlternatingRowColors(true);
- m_appListWidget->setPalette(mpal);
+ onPaletteChanged();
+ const QByteArray style_id(THEME_SCHAME);
+ if (QGSettings::isSchemaInstalled(style_id)) {
+ QGSettings * styleGsettings = new QGSettings(style_id, QByteArray(), this);
+ connect(styleGsettings, &QGSettings::changed, this, [=](QString key){
+ if ("styleName" == key) {
+ onPaletteChanged();
+ }
+ });
+ }
}
void Proxy::appProxyInfoPadding()
@@ -1219,7 +1250,7 @@ bool Proxy::getipEditState(QString text)
void Proxy::onipEditStateChanged()
{
if (!getipEditState(m_ipAddressLineEdit->text())) {
- m_ipAddressFrame->setFixedHeight(IP_FRAME_MAX_HEIGHT);
+ m_ipAddressFrame->setFixedHeight(88);
m_ipHintsLabel->show();
} else {
m_ipHintsLabel->hide();
@@ -1231,7 +1262,6 @@ void Proxy::onAppProxyConfChanged()
{
if (!getipEditState(m_ipAddressLineEdit->text()) || m_portLineEdit->text().isEmpty()) {
return;
- qDebug() << "onAppProxyConfChanged return";
}
if (m_ipAddressLineEdit->text().isEmpty()) {
@@ -1248,8 +1278,6 @@ void Proxy::onAppProxyConfChanged()
m_appProxyInfo.append("");
m_appProxyInfo.append("");
}
-
- qDebug() << m_appProxyInfo << Q_FUNC_INFO << __LINE__;
}
}
@@ -1260,6 +1288,16 @@ void Proxy::onAppProxyConfEditFinished()
}
}
+void Proxy::onPaletteChanged()
+{
+ QPalette mpal(m_appListWidget->palette());
+ mpal.setColor(QPalette::Base, qApp->palette().base().color());
+ mpal.setColor(QPalette::AlternateBase, qApp->palette().alternateBase().color());
+ m_appListWidget->setBackgroundRole(QPalette::Base);
+ m_appListWidget->setAlternatingRowColors(true);
+ m_appListWidget->setPalette(mpal);
+}
+
void Proxy::onappProxyEnableChanged(bool enable)
{
m_proxyTypeFrame->setVisible(enable);
diff --git a/plugins/proxy/proxy.h b/plugins/proxy/proxy.h
index 48d9cc30..6d690847 100644
--- a/plugins/proxy/proxy.h
+++ b/plugins/proxy/proxy.h
@@ -103,6 +103,7 @@ public:
bool isShowOnHomePage() const Q_DECL_OVERRIDE;
QIcon icon() const Q_DECL_OVERRIDE;
bool isEnable() const Q_DECL_OVERRIDE;
+ QString translationPath() const Q_DECL_OVERRIDE;
public:
void initUi(QWidget *widget);
@@ -262,8 +263,8 @@ private:
QFileSystemWatcher *mfileWatch_1;
QFileSystemWatcher *mfileWatch_2;
- QDBusInterface *mAptproxyDbus;
- QDBusInterface *m_appProxyDbus;
+// QDBusInterface *mAptproxyDbus;
+ QDBusInterface *m_appProxyDbus = nullptr;
bool isExistSettings = false;
bool settingsCreate;
@@ -277,6 +278,7 @@ private slots:
void onipEditStateChanged(); //IP地址无效提示
void onAppProxyConfChanged(); //应用代理配置信息变化
void onAppProxyConfEditFinished();
+ void onPaletteChanged();
// void onCancelBtnClicked();
// void onSaveBtnClicked();
// void setBtnEnable();
diff --git a/plugins/wlanconnect/translations/bo.ts b/plugins/wlanconnect/translations/bo.ts
index f8fab3a1..c678f22f 100644
--- a/plugins/wlanconnect/translations/bo.ts
+++ b/plugins/wlanconnect/translations/bo.ts
@@ -4,12 +4,12 @@
AddNetBtn
-
+
-
+
@@ -18,12 +18,12 @@
WlanConnect
-
+
@@ -58,14 +58,14 @@
-
-
-
+
+
+
-
+
diff --git a/plugins/wlanconnect/translations/bo_CN.ts b/plugins/wlanconnect/translations/bo_CN.ts
index 0d7ff07a..47de7db1 100644
--- a/plugins/wlanconnect/translations/bo_CN.ts
+++ b/plugins/wlanconnect/translations/bo_CN.ts
@@ -4,12 +4,12 @@
AddNetBtn
-
+
དྲ་རྒྱ་གཞན་དག་ནང་ཞུགས་དགོས།
-
+
@@ -18,12 +18,12 @@
WlanConnect
-
ཝུའུ་ལན་འབྲེལ་མཐུད།
+
སྐུད་མེད་ཅུས་ཁོངས་ཀྱི་དྲ་བ།
@@ -58,14 +58,14 @@
སྐུད་མེད་དྲ་རྒྱའི་བྱང་བུ་མ་རྙེད་པ།
-
-
-
+
+
+
འབྲེལ་མཐུད་བྱེད་པ།
-
+
བྱང་བུ།
diff --git a/plugins/wlanconnect/translations/en_US.ts b/plugins/wlanconnect/translations/en_US.ts
new file mode 100644
index 00000000..801e684f
--- /dev/null
+++ b/plugins/wlanconnect/translations/en_US.ts
@@ -0,0 +1,73 @@
+
+
+
+
+ AddNetBtn
+
+
+
+ Add Others
+
+
+
+
+ Add WiredNetork
+
+
+
+ WlanConnect
+
+
+
+ WlanConnect
+
+
+
+
+
+
+ WLAN
+
+
+
+
+
+ open
+ /wlanconnect/open
+
+
+
+
+
+ Advanced settings
+ /wlanconnect/Advanced settings"
+
+
+
+
+ ukui control center
+
+
+
+
+ ukui control center desktop message
+
+
+
+
+ No wireless network card detected
+
+
+
+
+
+
+ connected
+
+
+
+
+ card
+
+
+
diff --git a/plugins/wlanconnect/translations/tr.ts b/plugins/wlanconnect/translations/tr.ts
index f8fab3a1..c678f22f 100644
--- a/plugins/wlanconnect/translations/tr.ts
+++ b/plugins/wlanconnect/translations/tr.ts
@@ -4,12 +4,12 @@
AddNetBtn
-
+
-
+
@@ -18,12 +18,12 @@
WlanConnect
-
+
@@ -58,14 +58,14 @@
-
-
-
+
+
+
-
+
diff --git a/plugins/wlanconnect/translations/zh_CN.ts b/plugins/wlanconnect/translations/zh_CN.ts
index a62ddac2..216d188b 100644
--- a/plugins/wlanconnect/translations/zh_CN.ts
+++ b/plugins/wlanconnect/translations/zh_CN.ts
@@ -4,12 +4,12 @@
AddNetBtn
-
+
加入其它网络
-
+
@@ -18,12 +18,12 @@
WlanConnect
-
无线局域网
+
无线局域网
@@ -58,14 +58,14 @@
未检测到无线网卡
-
-
-
+
+
+
已连接
-
+
网卡
diff --git a/plugins/wlanconnect/wlanconnect.cpp b/plugins/wlanconnect/wlanconnect.cpp
index bfbc6dd0..0e2402c5 100644
--- a/plugins/wlanconnect/wlanconnect.cpp
+++ b/plugins/wlanconnect/wlanconnect.cpp
@@ -99,9 +99,6 @@ const QString KApSymbolic = "network-wireless-hotspot-symbolic";
const QString IsApConnection = "1";
-#define KYLIN_APP_MANAGER_NAME "com.kylin.AppManager"
-#define KYLIN_APP_MANAGER_PATH "/com/kylin/AppManager"
-#define KYLIN_APP_MANAGER_INTERFACE "com.kylin.AppManager"
#define ACTIVATING 1
#define ACTIVATED 2
@@ -140,7 +137,7 @@ WlanConnect::WlanConnect() : m_firstLoad(true) {
translator->load("/usr/share/kylin-nm/wlanconnect/" + QLocale::system().name());
QApplication::installTranslator(translator);
- pluginName = tr("WlanConnect");
+ pluginName = tr("WLAN");
pluginType = NETWORK;
}
@@ -230,7 +227,9 @@ bool WlanConnect::eventFilter(QObject *w, QEvent *e) {
if (!getSwitchBtnEnable()) {
showDesktopNotify(tr("No wireless network card detected"));
} else {
- m_interface->call(QStringLiteral("setWirelessSwitchEnable"), !getSwitchBtnState());
+ if (m_interface != nullptr && m_interface->isValid()) {
+ m_interface->call(QStringLiteral("setWirelessSwitchEnable"), !getSwitchBtnState());
+ }
return true;
}
}
@@ -301,7 +300,7 @@ void WlanConnect::initComponent() {
void WlanConnect::reScan()
{
qDebug() << "time to rescan wifi";
- if (m_interface->isValid()) {
+ if (m_interface != nullptr && m_interface->isValid()) {
qDebug() << "[WlanConnect]call reScan" << __LINE__;
m_interface->call("reScan");
qDebug() << "[WlanConnect]call reScan respond" << __LINE__;
@@ -315,7 +314,7 @@ void WlanConnect::updateList()
return;
}
qDebug() << "update list";
- if(m_interface->isValid()) {
+ if(m_interface != nullptr && m_interface->isValid()) {
qDebug() << "[WlanConnect]call getWirelessList" << __LINE__;
QDBusMessage result = m_interface->call(QStringLiteral("getWirelessList"));
qDebug() << "[WlanConnect]call getWirelessList respond" << __LINE__;
@@ -429,9 +428,9 @@ void WlanConnect::updateIcon(WlanItem *item, QString signalStrength, QString sec
iconamePath = wifiIcon(isLock, sign, category);
}
QIcon searchIcon = QIcon::fromTheme(iconamePath);
- if (iconamePath != KLanSymbolic && iconamePath != NoNetSymbolic) {
- item->iconLabel->setProperty("useIconHighlightEffect", 0x10);
- }
+// if (iconamePath != KLanSymbolic && iconamePath != NoNetSymbolic) {
+// item->iconLabel->setProperty("useIconHighlightEffect", 0x10);
+// }
item->iconLabel->setPixmap(searchIcon.pixmap(searchIcon.actualSize(QSize(ICON_SIZE))));
qDebug() << "updateIcon" << item->titileLabel->text() << " finish";
}
@@ -522,6 +521,12 @@ void WlanConnect::onDeviceStatusChanged()
setSwitchBtnEnable(true);
initSwtichState();
}
+
+ if (!getSwitchBtnState()) {
+ hideLayout(ui->availableLayout);
+ } else {
+ showLayout(ui->availableLayout);
+ }
}
void WlanConnect::onDeviceNameChanged(QString oldName, QString newName, int type)
@@ -554,7 +559,7 @@ void WlanConnect::onSwitchBtnChanged(bool state)
if (getSwitchBtnState() == state) {
return;
}
-
+ setSwitchBtnEnable(true);
setSwitchBtnState(state);
if (!getSwitchBtnState()) {
hideLayout(ui->availableLayout);
@@ -681,7 +686,7 @@ void WlanConnect::onNetworkRemove(QString deviceName, QString wlannName)
//获取设备列表=======================================================
void WlanConnect::getDeviceList(QStringList &list)
{
- if (!m_interface->isValid()) {
+ if (m_interface == nullptr || !m_interface->isValid()) {
return;
}
qDebug() << "[WlanConnect]call getDeviceListAndEnabled" << __LINE__;
@@ -700,7 +705,7 @@ void WlanConnect::getDeviceList(QStringList &list)
void WlanConnect::initSwtichState()
{
- if (!m_interface->isValid()) {
+ if (m_interface == nullptr || !m_interface->isValid()) {
return;
}
@@ -713,25 +718,10 @@ void WlanConnect::initSwtichState()
}
bool state = result.arguments().at(0).toBool();
+ setSwitchBtnEnable(true);
setSwitchBtnState(state);
}
-bool WlanConnect::LaunchApp(QString desktopFile)
-{
- QDBusInterface m_appManagerDbusInterface(KYLIN_APP_MANAGER_NAME,
- KYLIN_APP_MANAGER_PATH,
- KYLIN_APP_MANAGER_INTERFACE,
- QDBusConnection::sessionBus());//局部变量
-
- if (!m_appManagerDbusInterface.isValid()) {
- qWarning()<<"m_appManagerDbusInterface init error";
- return false;
- } else {
- QDBusReply reply =m_appManagerDbusInterface.call("LaunchApp",desktopFile);
- return reply;
- }
-}
-
//初始化整体列表和单设备列表
void WlanConnect::initNet() {
// int count = 1;
@@ -757,7 +747,7 @@ void WlanConnect::initNetListFromDevice(QString deviceName)
qDebug() << "[WlanConnect]initNetListFromDevice " << deviceName << " not exist";
return;
}
- if (!m_interface->isValid()) {
+ if (m_interface == nullptr || !m_interface->isValid()) {
return;
}
qDebug() << "[WlanConnect]call getWirelessList" << __LINE__;
@@ -795,10 +785,9 @@ void WlanConnect::initNetListFromDevice(QString deviceName)
//高级设置
void WlanConnect::runExternalApp() {
-// QString cmd = "nm-connection-editor";
-// QProcess process(this);
-// process.startDetached(cmd);
- LaunchApp("nm-connection-editor.desktop");
+ QString cmd = "nm-connection-editor";
+ QProcess process(this);
+ process.startDetached(cmd);
}
//根据信号强度分级+安全性分图标
@@ -891,6 +880,9 @@ void WlanConnect::showLayout(QVBoxLayout * layout) {
//获取应该插入哪个位置
int WlanConnect::sortWlanNet(QString deviceName, QString name, QString signal)
{
+ if (m_interface == nullptr || !m_interface->isValid()) {
+ return 0;
+ }
qDebug() << "[WlanConnect]call getWirelessList" << __LINE__;
QDBusMessage result = m_interface->call(QStringLiteral("getWirelessList"));
qDebug() << "[WlanConnect]call getWirelessList respond" << __LINE__;
@@ -917,7 +909,7 @@ int WlanConnect::sortWlanNet(QString deviceName, QString name, QString signal)
}
void WlanConnect::activeConnect(QString netName, QString deviceName, int type) {
- if (!m_interface->isValid()) {
+ if (m_interface == nullptr || !m_interface->isValid()) {
return;
}
qDebug() << "[WlanConnect]call activateConnect" << __LINE__;
@@ -926,7 +918,7 @@ void WlanConnect::activeConnect(QString netName, QString deviceName, int type) {
}
void WlanConnect::deActiveConnect(QString netName, QString deviceName, int type) {
- if (!m_interface->isValid()) {
+ if (m_interface == nullptr || !m_interface->isValid()) {
return;
}
qDebug() << "[WlanConnect]call deActivateConnect" << __LINE__;
@@ -979,7 +971,7 @@ void WlanConnect::addDeviceFrame(QString devName)
deviceFrameMap.insert(devName, itemFrame);
connect(itemFrame->addWlanWidget, &AddNetBtn::clicked, this, [=](){
- if (m_interface->isValid()) {
+ if (m_interface != nullptr && m_interface->isValid()) {
qDebug() << "[NetConnect]call showAddOtherWlanWidget" << devName << __LINE__;
m_interface->call(QStringLiteral("showAddOtherWlanWidget"), devName);
qDebug() << "[NetConnect]call setDeviceEnable Respond" << __LINE__;
@@ -1031,9 +1023,9 @@ void WlanConnect::addOneWlanFrame(ItemFrame *frame, QString deviceName, QString
} else {
iconamePath = wifiIcon(isLock, sign, category);
}
- if (iconamePath != KLanSymbolic && iconamePath != NoNetSymbolic) {
- wlanItem->iconLabel->setProperty("useIconHighlightEffect", 0x10);
- }
+// if (iconamePath != KLanSymbolic && iconamePath != NoNetSymbolic) {
+// wlanItem->iconLabel->setProperty("useIconHighlightEffect", 0x10);
+// }
QIcon searchIcon = QIcon::fromTheme(iconamePath);
wlanItem->iconLabel->setPixmap(searchIcon.pixmap(searchIcon.actualSize(QSize(ICON_SIZE))));
wlanItem->titileLabel->setText(name);
@@ -1047,7 +1039,7 @@ void WlanConnect::addOneWlanFrame(ItemFrame *frame, QString deviceName, QString
connect(wlanItem->infoLabel, &GrayInfoButton::clicked, this, [=]{
// open detail page
- if (!m_interface->isValid()) {
+ if (m_interface == nullptr || !m_interface->isValid()) {
return;
}
qDebug() << "[WlanConnect]call showPropertyWidget" << __LINE__;
diff --git a/plugins/wlanconnect/wlanconnect.h b/plugins/wlanconnect/wlanconnect.h
index 45983aeb..38bff337 100644
--- a/plugins/wlanconnect/wlanconnect.h
+++ b/plugins/wlanconnect/wlanconnect.h
@@ -127,12 +127,12 @@ private:
void initSwtichState();
inline void setSwitchBtnEnable(bool state) {
if (m_wifiSwitch != nullptr) {
- m_wifiSwitch->setCheckable(state);
+ m_wifiSwitch->setEnabled(state);
}
}
inline bool getSwitchBtnEnable() {
if (m_wifiSwitch != nullptr) {
- return m_wifiSwitch->isCheckable();
+ return m_wifiSwitch->isEnabled();
}
}
@@ -149,7 +149,6 @@ private:
}
}
- bool LaunchApp(QString desktopFile);
protected:
bool eventFilter(QObject *w,QEvent *e);
diff --git a/plugins/wlanconnect/wlanconnect.pro b/plugins/wlanconnect/wlanconnect.pro
index 0864f9f6..d558656a 100644
--- a/plugins/wlanconnect/wlanconnect.pro
+++ b/plugins/wlanconnect/wlanconnect.pro
@@ -51,4 +51,5 @@ TRANSLATIONS += \
translations/zh_CN.ts \
translations/tr.ts \
translations/bo.ts \
- translations/bo_CN.ts
+ translations/bo_CN.ts \
+ translations/en_US.ts
diff --git a/plugins/wlanconnect/wlanconnect.ui b/plugins/wlanconnect/wlanconnect.ui
index 99b9e7c2..fa8cfe41 100644
--- a/plugins/wlanconnect/wlanconnect.ui
+++ b/plugins/wlanconnect/wlanconnect.ui
@@ -184,7 +184,7 @@
TitleLabel
QLabel
-
+
diff --git a/plugins/wlanconnect/wlanitem.cpp b/plugins/wlanconnect/wlanitem.cpp
index 01d8b269..539e454c 100644
--- a/plugins/wlanconnect/wlanitem.cpp
+++ b/plugins/wlanconnect/wlanitem.cpp
@@ -19,6 +19,7 @@
*/
#include "wlanitem.h"
#include
+#include
#define FRAME_SPEED 150
#define LIMIT_TIME 60*1000
#define TOTAL_PAGE 8
@@ -33,17 +34,15 @@ WlanItem::WlanItem(bool bAcitve, bool isLock, QWidget *parent)
this->setMinimumSize(550, 58);
this->setProperty("useButtonPalette", true);
this->setFlat(true);
- QPalette pal = this->palette();
- QColor color = pal.color(QPalette::Button);
- color.setAlphaF(0.5);
- pal.setColor(QPalette::Button, color);
- this->setPalette(pal);
+
QHBoxLayout *mLanLyt = new QHBoxLayout(this);
mLanLyt->setContentsMargins(16,0,16,0);
mLanLyt->setSpacing(16);
iconLabel = new QLabel(this);
+ iconLabel->setProperty("useIconHighlightEffect", 0x2);
titileLabel = new FixLabel(this);
statusLabel = new QLabel(this);
+ statusLabel->setProperty("useIconHighlightEffect", 0x2);
statusLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
// statusLabel->setMinimumSize(36,36);
infoLabel = new GrayInfoButton(this);
@@ -63,7 +62,6 @@ WlanItem::WlanItem(bool bAcitve, bool isLock, QWidget *parent)
waitTimer = new QTimer(this);
connect(waitTimer, &QTimer::timeout, this, &WlanItem::updateIcon);
-
}
WlanItem::~WlanItem()
@@ -93,12 +91,17 @@ void WlanItem::stopLoading(){
void WlanItem::paintEvent(QPaintEvent *event)
{
- QPalette pal = this->palette();
+ QPalette pal = qApp->palette();
QPainter painter(this);
painter.setRenderHint(QPainter:: Antialiasing, true); //设置渲染,启动反锯齿
painter.setPen(Qt::NoPen);
- painter.setBrush(pal.color(QPalette::Base));
+ painter.setBrush(this->palette().base().color());
+
+ QColor color = pal.color(QPalette::Button);
+ color.setAlphaF(0.5);
+ pal.setColor(QPalette::Button, color);
+ this->setPalette(pal);
QRect rect = this->rect();
diff --git a/src/backend/backend.pri b/src/backend/backend.pri
index 10314e58..feb4853f 100644
--- a/src/backend/backend.pri
+++ b/src/backend/backend.pri
@@ -4,7 +4,6 @@ include(dbus-interface/dbus-interface.pri)
HEADERS += \
$$PWD/dbusadaptor.h \
- $$PWD/vpndbusadaptor.h \
$$PWD/kylinarping.h \
$$PWD/kylinipv4arping.h \
$$PWD/kylinipv6arping.h \
@@ -14,7 +13,6 @@ HEADERS += \
SOURCES += \
$$PWD/dbusadaptor.cpp \
- $$PWD/vpndbusadaptor.cpp \
$$PWD/kylinipv4arping.cpp \
$$PWD/kylinipv6arping.cpp \
$$PWD/sysdbusregister.cpp \
diff --git a/src/backend/dbus-interface/kylinactiveconnectresource.cpp b/src/backend/dbus-interface/kylinactiveconnectresource.cpp
index 0a613f75..07b13d09 100644
--- a/src/backend/dbus-interface/kylinactiveconnectresource.cpp
+++ b/src/backend/dbus-interface/kylinactiveconnectresource.cpp
@@ -747,3 +747,35 @@ QString KyActiveConnectResourse::getAcitveConnectionPathByUuid(QString connectUu
return activeAonnectPtr->path();
}
+
+int KyActiveConnectResourse::getAcivateWifiSignal()
+{
+ int signalStrength = 0;
+ KyNetworkDeviceResourse devResource;
+ QStringList devList;
+ devResource.getNetworkDeviceList(NetworkManager::Device::Type::Wifi, devList);
+
+ for (int i = 0; i < devList.size(); ++i) {
+
+ NetworkManager::Device::Ptr connectDevice =
+ m_networkResourceInstance->findDeviceInterface(devList.at(i));
+
+ if (nullptr == connectDevice || !connectDevice->isValid()) {
+ qWarning()<< LOG_FLAG <<"getDeviceActiveAPInfo failed, the device" << devList.at(i) << "is not existed";
+ continue;
+ }
+
+ if (connectDevice->type() == NetworkManager::Device::Wifi) {
+ NetworkManager::WirelessDevice *wirelessDevicePtr =
+ qobject_cast(connectDevice.data());
+ NetworkManager::AccessPoint::Ptr apPtr = wirelessDevicePtr->activeAccessPoint();
+ if (apPtr.isNull()) {
+ continue;
+ }
+ signalStrength = apPtr->signalStrength();
+ break;
+ }
+ }
+
+ return signalStrength;
+}
diff --git a/src/backend/dbus-interface/kylinactiveconnectresource.h b/src/backend/dbus-interface/kylinactiveconnectresource.h
index d38196a9..6c648fa6 100644
--- a/src/backend/dbus-interface/kylinactiveconnectresource.h
+++ b/src/backend/dbus-interface/kylinactiveconnectresource.h
@@ -60,6 +60,7 @@ public:
bool wiredConnectIsActived();
bool checkWirelessStatus(NetworkManager::ActiveConnection::State state);
QString getAcitveConnectionPathByUuid(QString uuid);
+ int getAcivateWifiSignal();
private:
void getActiveConnectIp(NetworkManager::ActiveConnection::Ptr activeConnectPtr,
diff --git a/src/backend/dbus-interface/kylinagentinterface.c b/src/backend/dbus-interface/kylinagentinterface.c
index d8c21c0b..35a7d41a 100644
--- a/src/backend/dbus-interface/kylinagentinterface.c
+++ b/src/backend/dbus-interface/kylinagentinterface.c
@@ -212,6 +212,14 @@ wifi_get_secrets (SecretsRequest *req, GError **error)
g_return_val_if_fail (!info->dialog, FALSE);
+#if GTK_CHECK_VERSION(3,90,0)
+ gtk_init ();
+#else
+ int argc = 0;
+ char ***argv = NULL;
+ gtk_init (&argc, &argv);
+#endif
+
NMClient *nm_client = nm_client_new (NULL, NULL);
if (!nm_client) {
g_set_error (error,
@@ -401,14 +409,6 @@ void agent_init()
GError *error = NULL;
kylinAgent = applet_agent_new (&error);
-#if GTK_CHECK_VERSION(3,90,0)
- gtk_init ();
-#else
- int argc = 0;
- char ***argv = NULL;
- gtk_init (&argc, &argv);
-#endif
-
g_signal_connect (kylinAgent, APPLET_AGENT_GET_SECRETS,
G_CALLBACK (applet_agent_get_secrets_cb), NULL);
g_signal_connect (kylinAgent, APPLET_AGENT_CANCEL_SECRETS,
diff --git a/src/backend/dbus-interface/kylinconnectresource.cpp b/src/backend/dbus-interface/kylinconnectresource.cpp
index dfdfb1cb..7de89382 100644
--- a/src/backend/dbus-interface/kylinconnectresource.cpp
+++ b/src/backend/dbus-interface/kylinconnectresource.cpp
@@ -42,36 +42,11 @@ static bool subLanListSort(const KyConnectItem* info1, const KyConnectItem* info
return result;
}
-static bool subVpnListSort(const KyConnectItem* info1, const KyConnectItem* info2)
-{
- if (info1->m_connectState != info2->m_connectState) {
- if (info1->m_connectState == 2) {
- return true;
- }
-
- if (info2->m_connectState == 2) {
- return false;
- }
- }
- QString name1 = info1->m_connectName;
- QString name2 = info2->m_connectName;
- bool result = true;
- if (QString::compare(name1, name2, Qt::CaseInsensitive) > 0) {
- result = false;
- }
- return result;
-}
-
static void lanListSort(QList &list)
{
qSort(list.begin(), list.end(), subLanListSort);
}
-static void vpnListSort(QList &list)
-{
- qSort(list.begin(), list.end(), subVpnListSort);
-}
-
KyConnectResourse::KyConnectResourse(QObject *parent) : QObject(parent)
{
m_networkResourceInstance = KyNetworkResourceManager::getInstance();
@@ -225,61 +200,6 @@ KyConnectItem * KyConnectResourse::getConnectionItemByUuid(QString connectUuid,
return nullptr;
}
-void KyConnectResourse::getVpnAndVirtualConnections(QList &connectItemList)
-{
- int index = 0;
- NetworkManager::Connection::List connectList;
-
- qDebug()<<"[KyConnectResourse]"<<"get vpn && virtual connections";
-
- connectList.clear();
- connectList = m_networkResourceInstance->getConnectList();
-
- if (connectList.empty()) {
- qWarning()<<"[KyConnectResourse]"<<"get vpn connections failed, the connect list is empty";
- return;
- }
-
- NetworkManager::Connection::Ptr connectPtr = nullptr;
- for (index = 0; index < connectList.size(); index++) {
- connectPtr = connectList.at(index);
- if (connectPtr.isNull()) {
- continue;
- }
- if (NetworkManager::ConnectionSettings::ConnectionType::Vpn != connectPtr->settings()->connectionType()
- && NetworkManager::ConnectionSettings::ConnectionType::Bond != connectPtr->settings()->connectionType()
- && NetworkManager::ConnectionSettings::ConnectionType::Bridge != connectPtr->settings()->connectionType()
- && NetworkManager::ConnectionSettings::ConnectionType::Vlan != connectPtr->settings()->connectionType()
- && NetworkManager::ConnectionSettings::ConnectionType::Team != connectPtr->settings()->connectionType()
- && NetworkManager::ConnectionSettings::ConnectionType::IpTunnel != connectPtr->settings()->connectionType()
- && NetworkManager::ConnectionSettings::ConnectionType::Wired != connectPtr->settings()->connectionType()) {
- continue;
- }
- NetworkManager::Device::Ptr devicePtr = nullptr;
- devicePtr = m_networkResourceInstance->findDeviceInterface(connectPtr->settings()->interfaceName());
- if (NetworkManager::ConnectionSettings::ConnectionType::Wired == connectPtr->settings()->connectionType()) {
- if (devicePtr == nullptr || !devicePtr->udi().startsWith("/sys/devices/virtual/net")) {
- continue;
- }
- }
- QString devName = "";
- if (!devicePtr.isNull()) {
- devName = devicePtr->interfaceName();
- }
-
- KyConnectItem *connectItem = getConnectionItem(connectPtr, devName);
- if (nullptr != connectItem) {
- connectItemList << connectItem;
- }
-
- connectPtr = nullptr;
- }
-
- if (connectItemList.size() > 1) {
- vpnListSort(connectItemList);
- }
-}
-
void KyConnectResourse::getConnectionList(QString deviceName,
NetworkManager::ConnectionSettings::ConnectionType connectionType,
QList &connectItemList)
@@ -721,11 +641,13 @@ KyApConnectItem *KyConnectResourse::getApConnectItem(NetworkManager::Connection:
return nullptr;
}
+#ifdef CHECKDEVICE
KyNetworkDeviceResourse deviceResource;
if (!deviceResource.wirelessDeviceIsExist(settingPtr->interfaceName())) {
qDebug() << "[KyConnectResourse]" <<"get ap item failed, the ap device is not exist yet";
return nullptr;
}
+#endif
QByteArray rawSsid = wirelessSetting->ssid();
@@ -824,35 +746,6 @@ void KyConnectResourse::getApConnections(QList &apConnectItem
return;
}
-bool KyConnectResourse::isVirtualConncection(QString uuid)
-{
- NetworkManager::Connection::Ptr connectPtr = nullptr;
-
- connectPtr = m_networkResourceInstance->getConnect(uuid);
- if (nullptr == connectPtr) {
- return false;
- }
-
- if (NetworkManager::ConnectionSettings::ConnectionType::Vpn == connectPtr->settings()->connectionType()
- ||NetworkManager::ConnectionSettings::ConnectionType::Bond == connectPtr->settings()->connectionType()
- ||NetworkManager::ConnectionSettings::ConnectionType::Bridge == connectPtr->settings()->connectionType()
- ||NetworkManager::ConnectionSettings::ConnectionType::Vlan == connectPtr->settings()->connectionType()
- ||NetworkManager::ConnectionSettings::ConnectionType::Team == connectPtr->settings()->connectionType()
- ||NetworkManager::ConnectionSettings::ConnectionType::IpTunnel == connectPtr->settings()->connectionType()) {
- return true;
- }
-
- NetworkManager::Device::Ptr devicePtr = nullptr;
- devicePtr = m_networkResourceInstance->findDeviceInterface(connectPtr->settings()->interfaceName());
- if (devicePtr.isNull()) {
- return false;
- }
- if (devicePtr->udi().startsWith("/sys/devices/virtual/net")) {
- return true;
- }
-
- return false;
-}
bool KyConnectResourse::isWiredConnection(QString uuid)
{
diff --git a/src/backend/dbus-interface/kylinconnectresource.h b/src/backend/dbus-interface/kylinconnectresource.h
index 8c1228a2..9b334d34 100644
--- a/src/backend/dbus-interface/kylinconnectresource.h
+++ b/src/backend/dbus-interface/kylinconnectresource.h
@@ -40,7 +40,6 @@ public:
KyConnectItem *getConnectionItemByUuid(QString connectUuid);
KyConnectItem *getConnectionItemByUuidWithoutActivateChecking(QString connectUuid);
KyConnectItem *getConnectionItemByUuid(QString connectUuid, QString deviceName);
- void getVpnAndVirtualConnections(QList &connectItemList);
void getConnectionList(QString deviceName,
NetworkManager::ConnectionSettings::ConnectionType connectionType,
QList &connectItemList);
@@ -56,7 +55,6 @@ public:
bool getInterfaceByUuid(QString &deviceName, const QString connUuid);
void getConnectivity(NetworkManager::Connectivity &connectivity);
- bool isVirtualConncection(QString uuid);
bool isWiredConnection(QString uuid);
bool isWirelessConnection(QString uuid);
bool isActivatedConnection(QString uuid);
diff --git a/src/backend/dbus-interface/kylinnetworkdeviceresource.cpp b/src/backend/dbus-interface/kylinnetworkdeviceresource.cpp
index 73adbd15..fb7f8a62 100644
--- a/src/backend/dbus-interface/kylinnetworkdeviceresource.cpp
+++ b/src/backend/dbus-interface/kylinnetworkdeviceresource.cpp
@@ -36,14 +36,14 @@ KyNetworkDeviceResourse::KyNetworkDeviceResourse(QObject *parent) : QObject(pare
initDeviceMap();
connect(m_networkResourceInstance, &KyNetworkResourceManager::deviceAdd,
- this, &KyNetworkDeviceResourse::onDeviceAdd, Qt::ConnectionType::DirectConnection);
+ this, &KyNetworkDeviceResourse::onDeviceAdd/*, Qt::ConnectionType::DirectConnection*/);
connect(m_networkResourceInstance, &KyNetworkResourceManager::deviceRemove,
- this, &KyNetworkDeviceResourse::onDeviceRemove, Qt::ConnectionType::DirectConnection);
+ this, &KyNetworkDeviceResourse::onDeviceRemove/*, Qt::ConnectionType::DirectConnection*/);
connect(m_networkResourceInstance, &KyNetworkResourceManager::deviceUpdate,
- this, &KyNetworkDeviceResourse::onDeviceUpdate, Qt::ConnectionType::DirectConnection);
+ this, &KyNetworkDeviceResourse::onDeviceUpdate/*, Qt::ConnectionType::DirectConnection*/);
connect(m_networkResourceInstance, &KyNetworkResourceManager::stateChanged,
- this, &KyNetworkDeviceResourse::stateChanged, Qt::ConnectionType::DirectConnection);
+ this, &KyNetworkDeviceResourse::stateChanged/*, Qt::ConnectionType::DirectConnection*/);
connect(m_networkResourceInstance, &KyNetworkResourceManager::deviceCarrierChanage,
this, &KyNetworkDeviceResourse::carrierChanage);
@@ -213,6 +213,42 @@ void KyNetworkDeviceResourse::setDeviceRefreshRate(QString deviceName, int ms)
return;
}
+qulonglong KyNetworkDeviceResourse::getDeviceRxRefreshRate(QString deviceName)
+{
+ NetworkManager::Device::Ptr connectDevice =
+ m_networkResourceInstance->findDeviceInterface(deviceName);
+ if (connectDevice->isValid()) {
+ NetworkManager::DeviceStatistics::Ptr deviceStatistics = connectDevice->deviceStatistics();
+ qulonglong rx = 0;
+ rx = deviceStatistics->rxBytes();
+ if (rx != 0) {
+ return rx;
+ } else {
+ qDebug() << "connectDevice is invalid we do not get rxrate";
+ }
+ }
+
+ return 0;
+}
+
+qulonglong KyNetworkDeviceResourse::getDeviceTxRefreshRate(QString deviceName)
+{
+ NetworkManager::Device::Ptr connectDevice =
+ m_networkResourceInstance->findDeviceInterface(deviceName);
+ if (connectDevice->isValid()) {
+ NetworkManager::DeviceStatistics::Ptr deviceStatistics = connectDevice->deviceStatistics();
+ qulonglong tx = 0;
+ tx = deviceStatistics->txBytes();
+ if (tx != 0){
+ return tx;
+ } else {
+ qDebug() << "connectDevice is invalid we do not get txrate";
+ }
+ }
+
+ return 0;
+}
+
bool KyNetworkDeviceResourse::getActiveConnectionInfo(const QString devName, int &signalStrength, QString &uni, QString &secuType)
{
signalStrength = 0;
@@ -385,7 +421,7 @@ bool KyNetworkDeviceResourse::getDeviceManaged(QString deviceName)
{
NetworkManager::Device::Ptr connectDevice =
m_networkResourceInstance->findDeviceInterface(deviceName);
- if (connectDevice->isValid()) {
+ if (connectDevice != nullptr && connectDevice->isValid()) {
return connectDevice->managed();
} else {
qWarning()<<"[KyNetworkDeviceResourse] can not find device " << deviceName;
diff --git a/src/backend/dbus-interface/kylinnetworkdeviceresource.h b/src/backend/dbus-interface/kylinnetworkdeviceresource.h
index 32639803..4ad5881a 100644
--- a/src/backend/dbus-interface/kylinnetworkdeviceresource.h
+++ b/src/backend/dbus-interface/kylinnetworkdeviceresource.h
@@ -69,6 +69,9 @@ public:
void setDeviceManaged(QString devName, bool managed);
bool getDeviceManaged(QString devName);
+ qulonglong getDeviceRxRefreshRate(QString deviceName);
+ qulonglong getDeviceTxRefreshRate(QString deviceName);
+
private:
KyWiredConnectOperation wiredOperation;
KyNetworkResourceManager *m_networkResourceInstance = nullptr;
diff --git a/src/backend/dbus-interface/kylinnetworkresourcemanager.cpp b/src/backend/dbus-interface/kylinnetworkresourcemanager.cpp
index 084f600e..d38ee6d2 100644
--- a/src/backend/dbus-interface/kylinnetworkresourcemanager.cpp
+++ b/src/backend/dbus-interface/kylinnetworkresourcemanager.cpp
@@ -26,6 +26,32 @@
#define LOG_FLAG "[KyNetworkResourceManager]"
+
+QString enumToQstring(NetworkManager::AccessPoint::Capabilities cap, NetworkManager::AccessPoint::WpaFlags wpa_flags,NetworkManager::AccessPoint::WpaFlags rsn_flags)
+{
+ QString out;
+ if ( (cap & NM_802_11_AP_FLAGS_PRIVACY)
+ && (wpa_flags == NM_802_11_AP_SEC_NONE)
+ && (rsn_flags == NM_802_11_AP_SEC_NONE)) {
+ out += "WEP ";
+ }
+ if (wpa_flags != NM_802_11_AP_SEC_NONE) {
+ out += "WPA1 ";
+ }
+ if ((rsn_flags & NM_802_11_AP_SEC_KEY_MGMT_PSK)
+ || (rsn_flags & NM_802_11_AP_SEC_KEY_MGMT_802_1X)) {
+ out += "WPA2 ";
+ }
+ if (rsn_flags & NM_802_11_AP_SEC_KEY_MGMT_SAE) {
+ out += "WPA3 ";
+ }
+ if ( (wpa_flags & NM_802_11_AP_SEC_KEY_MGMT_802_1X)
+ || (rsn_flags & NM_802_11_AP_SEC_KEY_MGMT_802_1X)) {
+ out += "802.1X ";
+ }
+ return out;
+}
+
KyNetworkResourceManager* KyNetworkResourceManager::m_pInstance = nullptr;
KyNetworkResourceManager* KyNetworkResourceManager::getInstance()
@@ -52,8 +78,6 @@ KyNetworkResourceManager::KyNetworkResourceManager(QObject *parent) : QObject(pa
qRegisterMetaType("NetworkManager::Device::Type");
qRegisterMetaType("NetworkManager::Device::State");
qRegisterMetaType("NetworkManager::Device::StateChangeReason");
- qRegisterMetaType("NetworkManager::VpnConnection::State");
- qRegisterMetaType("NetworkManager::VpnConnection::StateChangeReason");
QDBusConnection::systemBus().connect(QString("org.freedesktop.DBus"),
QString("/org/freedesktop/DBus"),
@@ -780,37 +804,46 @@ void KyNetworkResourceManager::onWifiNetworkUpdate(NetworkManager::WirelessNetwo
return;
}
+ bool bFlag = false;
+ QString devIface;
+ NetworkManager::Device::Ptr dev = findDeviceUni(net->device());
+ if(dev.isNull()) {
+ qDebug()<< LOG_FLAG << "device invalid";
+ bFlag = true;
+ } else {
+ devIface = dev->interfaceName();
+ }
+ if(bFlag) {
+ //device invalid
+ qDebug() << LOG_FLAG << "wifiNetworkDeviceDisappear";
+ Q_EMIT wifiNetworkDeviceDisappear();
+ return;
+ }
+
+
auto index = std::find(m_wifiNets.cbegin(), m_wifiNets.cend(), net);
if (m_wifiNets.cend() != index) {
if (net->accessPoints().isEmpty()) {
- //Q_EMIT
- bool bFlag = false;
- QString devIface;
- NetworkManager::Device::Ptr dev = findDeviceUni(net->device());
- if(dev.isNull()) {
- qDebug()<< LOG_FLAG << "device invalid";
- bFlag = true;
- } else {
- devIface = dev->interfaceName();
- }
-
//remove
auto pos = index - m_wifiNets.cbegin();
removeWifiNetwork(pos);
- if(bFlag) {
- //device invalid
- qDebug() << LOG_FLAG << "wifiNetworkDeviceDisappear";
- Q_EMIT wifiNetworkDeviceDisappear();
- } else {
- qDebug()<< LOG_FLAG << "wifiNetwork disappear" << net << net->ssid();
- NetworkManager::AccessPoint::Ptr accessPoitPtr = net->referenceAccessPoint();
- QByteArray rawSsid = accessPoitPtr->rawSsid();
- QString wifiSsid = getSsidFromByteArray(rawSsid);
- Q_EMIT wifiNetworkRemoved(devIface, wifiSsid);
- }
+ qDebug()<< LOG_FLAG << "wifiNetwork disappear" << net << net->ssid();
+ NetworkManager::AccessPoint::Ptr accessPoitPtr = net->referenceAccessPoint();
+ QByteArray rawSsid = accessPoitPtr->rawSsid();
+ QString wifiSsid = getSsidFromByteArray(rawSsid);
+ Q_EMIT wifiNetworkRemoved(devIface, wifiSsid);
} else {
- qDebug()<< LOG_FLAG << "wifiNetworkPropertyChange " << net << net->ssid();
- Q_EMIT wifiNetworkPropertyChange(net);
+ NetworkManager::AccessPoint::Ptr accessPointPtr = net->referenceAccessPoint();
+ if (accessPointPtr.isNull()) {
+ return;
+ }
+ QByteArray rawSsid = accessPointPtr->rawSsid();
+ QString wifiSsid = getSsidFromByteArray(rawSsid);
+ QString bssid = accessPointPtr->hardwareAddress();
+ QString secuType = enumToQstring(accessPointPtr->capabilities(),
+ accessPointPtr->wpaFlags(),
+ accessPointPtr->rsnFlags());
+ Q_EMIT wifiNetworkPropertyChange(devIface, wifiSsid, net->signalStrength(), bssid, secuType);
}
}
diff --git a/src/backend/dbus-interface/kylinnetworkresourcemanager.h b/src/backend/dbus-interface/kylinnetworkresourcemanager.h
index 0de8ce9a..b43b0dcf 100644
--- a/src/backend/dbus-interface/kylinnetworkresourcemanager.h
+++ b/src/backend/dbus-interface/kylinnetworkresourcemanager.h
@@ -45,6 +45,8 @@
#include
#include
+QString enumToQstring(NetworkManager::AccessPoint::Capabilities cap, NetworkManager::AccessPoint::WpaFlags wpa_flags,NetworkManager::AccessPoint::WpaFlags rsn_flags);
+
class KyNetworkResourceManager : public QObject
{
Q_OBJECT
@@ -122,7 +124,7 @@ Q_SIGNALS:
//to KyWirelessNetResource
void wifiNetworkRemoved(QString, QString);
void wifiNetworkAdded(QString, QString);
- void wifiNetworkPropertyChange(NetworkManager::WirelessNetwork * net);
+ void wifiNetworkPropertyChange(QString, QString, int, QString, QString);
void wifiNetworkSecuChange(NetworkManager::AccessPoint *);
void wifiNetworkDeviceDisappear();
void wifiEnabledChanged(bool);
diff --git a/src/backend/dbus-interface/kywirelessconnectoperation.cpp b/src/backend/dbus-interface/kywirelessconnectoperation.cpp
index 9f4b2bea..38f46afe 100644
--- a/src/backend/dbus-interface/kywirelessconnectoperation.cpp
+++ b/src/backend/dbus-interface/kywirelessconnectoperation.cpp
@@ -826,6 +826,40 @@ NetworkManager::ConnectionSettings::Ptr
return connectionSettings;
}
+QStringList KyWirelessConnectOperation::getBlackListHostName(QString apConnectPath)
+{
+ QStringList blackList;
+ blackList.clear();
+
+ QDBusInterface dbusInterface("org.freedesktop.NetworkManager",
+ apConnectPath,
+ "org.freedesktop.NetworkManager.Settings.Connection",
+ QDBusConnection::systemBus());
+ if (!dbusInterface.isValid()) {
+ qWarning()<();
+ QMap> map;
+ dbusArg1st >> map;
+ if (map.isEmpty()) {
+ qWarning() << Q_FUNC_INFO << __LINE__ <<"map is empty!";
+ return blackList;
+ }
+
+ QMap wirelessMap = map.value(KEY_802_11_WIRELESS);
+ if (wirelessMap.isEmpty()) {
+ qWarning() << Q_FUNC_INFO << __LINE__ <<"wirelessMap is empty!";
+ return blackList;
+ }
+ if (wirelessMap.contains(KEY_BLACKLIST_HOSTNAME)) {
+ blackList = wirelessMap.value(KEY_BLACKLIST_HOSTNAME).toStringList();
+ }
+ return blackList;
+}
+
void KyWirelessConnectOperation::updateWirelessApSetting(
NetworkManager::Connection::Ptr apConnectPtr,
const QString apName, const QString apPassword,
@@ -850,7 +884,6 @@ void KyWirelessConnectOperation::updateWirelessApSetting(
wirelessSetting->setBand(NetworkManager::WirelessSetting::FrequencyBand::Automatic);
}
-
NetworkManager::WirelessSecuritySetting::Ptr wirelessSecuritySetting
= apConnectSettingPtr->setting(NetworkManager::Setting::WirelessSecurity).dynamicCast();
if (apPassword.isEmpty()) {
@@ -861,7 +894,12 @@ void KyWirelessConnectOperation::updateWirelessApSetting(
wirelessSecuritySetting->setPsk(apPassword);
}
- apConnectPtr->update(apConnectSettingPtr->toMap());
+ QStringList blackList = getBlackListHostName(apConnectPtr->path());
+ NMVariantMapMap newMap = apConnectSettingPtr->toMap();
+ if (newMap.contains(KEY_802_11_WIRELESS)) {
+ newMap[KEY_802_11_WIRELESS].insert(KEY_BLACKLIST_HOSTNAME, blackList);
+ }
+ apConnectPtr->update(newMap);
}
void KyWirelessConnectOperation::activeWirelessAp(const QString apUuid, const QString apName,
@@ -999,7 +1037,7 @@ void KyWirelessConnectOperation::activateApConnectionByUuid(const QString apUuid
QString connectPath = "";
QString deviceIdentifier = "";
QString connectName = "";
- QString specificObject = "";
+ QString specificObject = "/";
qDebug()<<"it will activate hotspot connect"<referenceAccessPoint()->hardwareAddress();
m_device = net->device();
m_uni = net->referenceAccessPoint()->uni();
+
+ NetworkManager::Device::Ptr devicePtr = nullptr;
+ devicePtr = m_networkResourceInstance->findDeviceInterface(m_device);
+ if (!devicePtr.isNull()) {
+ QString devUni = devicePtr->uni();
+ NetworkManager::WirelessNetwork::Ptr wirelessPtr = nullptr;
+ wirelessPtr = m_networkResourceInstance->findWifiNetwork(m_NetSsid, devUni);
+ if (!wirelessPtr.isNull()) {
+ NetworkManager::AccessPoint::List apList = wirelessPtr->accessPoints();
+ bool b2G = false;
+ bool b5G = false;
+ if (!apList.empty()) {
+ for (int i = 0; i < apList.count(); ++i) {
+ if (apList.at(i)->frequency() < FREQ_5GHZ) {
+ b2G = true;
+ }
+ if (apList.at(i)->frequency() >= FREQ_5GHZ) {
+ b5G = true;
+ }
+ if (b2G && b5G) {
+ m_isMix = true;
+ break;
+ }
+ }
+ }
+ devicePtr = m_networkResourceInstance->findDeviceInterface(m_device);
+ if (!devicePtr.isNull()) {
+ QString devUni = devicePtr->uni();
+ NetworkManager::WirelessNetwork::Ptr wirelessPtr = nullptr;
+ wirelessPtr = m_networkResourceInstance->findWifiNetwork(m_NetSsid, devUni);
+ if (!wirelessPtr.isNull()) {
+ NetworkManager::AccessPoint::List apList = wirelessPtr->accessPoints();
+ bool b2G = false;
+ bool b5G = false;
+ if (!apList.empty()) {
+ for (int i = 0; i < apList.count(); ++i) {
+ if (apList.at(i)->frequency() < FREQ_5GHZ) {
+ b2G = true;
+ }
+ if (apList.at(i)->frequency() >= FREQ_5GHZ) {
+ b5G = true;
+ }
+ if (b2G && b5G) {
+ m_isMix = true;
+ break;
+ }
+
+ }
+ }
+ }
+ }
+ }
+ }
initInfoBySsid();
}
diff --git a/src/backend/dbus-interface/kywirelessnetitem.h b/src/backend/dbus-interface/kywirelessnetitem.h
index 36eecc76..533e6ca6 100644
--- a/src/backend/dbus-interface/kywirelessnetitem.h
+++ b/src/backend/dbus-interface/kywirelessnetitem.h
@@ -25,8 +25,6 @@
#include "kylinnetworkresourcemanager.h"
#include "kywirelessconnectoperation.h"
-QString enumToQstring(NetworkManager::AccessPoint::Capabilities, NetworkManager::AccessPoint::WpaFlags, NetworkManager::AccessPoint::WpaFlags);
-
class KyWirelessNetItem
{
public:
@@ -47,6 +45,7 @@ public:
QString m_secuType;
KySecuType m_kySecuType;
QString m_uni;
+ bool m_isMix;
//only for m_isConfiged = true
bool m_isConfigured;
diff --git a/src/backend/dbus-interface/kywirelessnetresource.cpp b/src/backend/dbus-interface/kywirelessnetresource.cpp
index e851b539..2ec9bcf0 100644
--- a/src/backend/dbus-interface/kywirelessnetresource.cpp
+++ b/src/backend/dbus-interface/kywirelessnetresource.cpp
@@ -61,15 +61,15 @@ KyWirelessNetResource::KyWirelessNetResource(QObject *parent)
//TODO:connect device signal
connect(m_networkResourceInstance, &KyNetworkResourceManager::wifiNetworkAdded,
- this, &KyWirelessNetResource::onWifiNetworkAdded, Qt::ConnectionType::DirectConnection);
+ this, &KyWirelessNetResource::onWifiNetworkAdded/*, Qt::ConnectionType::DirectConnection*/);
connect(m_networkResourceInstance, &KyNetworkResourceManager::wifiNetworkRemoved,
- this, &KyWirelessNetResource::onWifiNetworkRemoved, Qt::ConnectionType::DirectConnection);
+ this, &KyWirelessNetResource::onWifiNetworkRemoved/*, Qt::ConnectionType::DirectConnection*/);
connect(m_networkResourceInstance, &KyNetworkResourceManager::wifiNetworkPropertyChange,
- this, &KyWirelessNetResource::onWifiNetworkPropertyChange, Qt::ConnectionType::DirectConnection);
+ this, &KyWirelessNetResource::onWifiNetworkPropertyChange/*, Qt::ConnectionType::DirectConnection*/);
connect(m_networkResourceInstance, &KyNetworkResourceManager::wifiNetworkSecuChange,
- this, &KyWirelessNetResource::onWifiNetworkSecuChange, Qt::ConnectionType::DirectConnection);
+ this, &KyWirelessNetResource::onWifiNetworkSecuChange/*, Qt::ConnectionType::DirectConnection*/);
connect(m_networkResourceInstance, &KyNetworkResourceManager::wifiNetworkDeviceDisappear,
- this, &KyWirelessNetResource::onWifiNetworkDeviceDisappear, Qt::ConnectionType::DirectConnection);
+ this, &KyWirelessNetResource::onWifiNetworkDeviceDisappear/*, Qt::ConnectionType::DirectConnection*/);
connect(m_networkResourceInstance, &KyNetworkResourceManager::connectionAdd,
this, &KyWirelessNetResource::onConnectionAdd);
@@ -457,50 +457,36 @@ void KyWirelessNetResource::onWifiNetworkSecuChange(NetworkManager::AccessPoint
}
-void KyWirelessNetResource::onWifiNetworkPropertyChange(NetworkManager::WirelessNetwork * net)
+void KyWirelessNetResource::onWifiNetworkPropertyChange(QString interface, QString ssid, int signal, QString bssid, QString sec)
{
- if (nullptr == net) {
- return;
- }
- qDebug() << "onWifiNetworkPropertyChange" << net->ssid();
- NetworkManager::AccessPoint::Ptr accessPointPtr = net->referenceAccessPoint();
- QByteArray rawSsid = accessPointPtr->rawSsid();
- QString wifiSsid = getSsidFromByteArray(rawSsid);
+ if (m_WifiNetworkList.contains(interface)) {
+ QList::iterator iter = m_WifiNetworkList[interface].begin();
+ while (iter != m_WifiNetworkList[interface].end()) {
+ qDebug() << iter->m_NetSsid;
+ if (iter->m_NetSsid == ssid) {
+ // qDebug()<< LOG_FLAG <<"recive properity changed signal, sender is" << iter->m_NetSsid;
+ if (iter->m_signalStrength != signal) {
+ iter->m_signalStrength = signal;
+ Q_EMIT signalStrengthChange(interface, ssid, iter->m_signalStrength);
+ }
- if (net->device().isEmpty()) {
- return;
- }
+ if (iter->m_bssid != bssid) {
+ qDebug() << "bssid";
+ iter->m_bssid = bssid;
+ Q_EMIT bssidChange(interface, ssid, iter->m_bssid);
+ }
- QString devIface = m_networkResourceInstance->findDeviceUni(net->device())->interfaceName();
- if (m_WifiNetworkList.contains(devIface)) {
- QList::iterator iter = m_WifiNetworkList[devIface].begin();
- while (iter != m_WifiNetworkList[devIface].end()) {
- if (iter->m_NetSsid == wifiSsid) {
-// qDebug()<< LOG_FLAG <<"recive properity changed signal, sender is" << iter->m_NetSsid;
- if (iter->m_signalStrength != net->signalStrength()) {
- iter->m_signalStrength = net->signalStrength();
- Q_EMIT signalStrengthChange(devIface, wifiSsid, iter->m_signalStrength);
- }
+ if (iter->m_secuType != sec) {
+ iter->setKySecuType(sec);
+ Q_EMIT secuTypeChange(interface, ssid, sec);
+ }
- if (iter->m_bssid != accessPointPtr->hardwareAddress()) {
- iter->m_bssid = accessPointPtr->hardwareAddress();
- Q_EMIT bssidChange(devIface, wifiSsid, iter->m_bssid);
- }
+ break;
+ }
- QString secuType = enumToQstring(accessPointPtr->capabilities(),
- accessPointPtr->wpaFlags(),
- accessPointPtr->rsnFlags());
- if (iter->m_secuType != secuType) {
- //qDebug() << "!!!!secuTypeChange" << wifiSsid << iter->m_secuType << "change to " << secuType;
- iter->setKySecuType(secuType);
- Q_EMIT secuTypeChange(devIface, wifiSsid, secuType);
- }
-
- break;
- }
- iter++;
- }
+ iter++;
+ }
}
}
diff --git a/src/backend/dbus-interface/kywirelessnetresource.h b/src/backend/dbus-interface/kywirelessnetresource.h
index 807746d0..7afe52fe 100644
--- a/src/backend/dbus-interface/kywirelessnetresource.h
+++ b/src/backend/dbus-interface/kywirelessnetresource.h
@@ -63,7 +63,7 @@ private:
public Q_SLOTS:
void onWifiNetworkAdded(QString, QString);
void onWifiNetworkRemoved(QString, QString);
- void onWifiNetworkPropertyChange(NetworkManager::WirelessNetwork * net);
+ void onWifiNetworkPropertyChange(QString interface, QString ssid, int signal, QString bssid, QString sec);
void onWifiNetworkSecuChange(NetworkManager::AccessPoint *accessPointPtr);
void onWifiNetworkDeviceDisappear();
diff --git a/src/backend/dbusadaptor.cpp b/src/backend/dbusadaptor.cpp
index d3325af3..0f22c845 100644
--- a/src/backend/dbusadaptor.cpp
+++ b/src/backend/dbusadaptor.cpp
@@ -147,18 +147,6 @@ 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)
{
diff --git a/src/backend/dbusadaptor.h b/src/backend/dbusadaptor.h
index 500ebfa3..6cb0f411 100644
--- a/src/backend/dbusadaptor.h
+++ b/src/backend/dbusadaptor.h
@@ -62,8 +62,6 @@ 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
diff --git a/src/backend/kylinipv6arping.cpp b/src/backend/kylinipv6arping.cpp
index bb4d78e3..a6969a6b 100644
--- a/src/backend/kylinipv6arping.cpp
+++ b/src/backend/kylinipv6arping.cpp
@@ -187,6 +187,18 @@ int KyIpv6Arping::parseIpv6Packet(const uint8_t *buf, size_t len, const struct s
/* looks for Target Link-layer address option */
ptr = buf + sizeof (struct nd_neighbor_advert);
+ int index;
+ char macAddress[64] = {0};
+ uint8_t hw_addr[6] = {0};
+ getLocalMacAddress(m_ifaceName.toUtf8().constData(), hw_addr);
+ for (index = 0; index < 6; index++) {
+ snprintf(&macAddress[strlen(macAddress)], sizeof(macAddress) - strlen(macAddress), "%02X", hw_addr[index]);
+ if (index != 5) {
+ snprintf(&macAddress[strlen(macAddress)], sizeof(macAddress) - strlen(macAddress), "%s", ":");
+ }
+ }
+ QString localAddr(macAddress);
+
while (len >= 8)
{
uint16_t optlen;
@@ -212,6 +224,9 @@ int KyIpv6Arping::parseIpv6Packet(const uint8_t *buf, size_t len, const struct s
optlen -= 2;
saveMacAddress (ptr, optlen);
+ if (!localAddr.isEmpty() && getConflictMacAddress() == localAddr) {
+ break;
+ }
setIpv6ConflictFlag(true);
return 0;
}
diff --git a/src/frontend/enterprise-wlan/enterprisewlandialog.cpp b/src/frontend/enterprise-wlan/enterprisewlandialog.cpp
index 7b772076..3a589886 100644
--- a/src/frontend/enterprise-wlan/enterprisewlandialog.cpp
+++ b/src/frontend/enterprise-wlan/enterprisewlandialog.cpp
@@ -23,7 +23,8 @@
#include "xatom-helper.h"
#define MAIN_SIZE_EXPAND 480,580
#define MAIN_SIZE_NARROW 480,484
-#define SCROAREA_WIDTH 480
+#define PEAP_SCRO_HEIGHT 390
+#define TLS_SCRO_HEIGHT 590
#define MAIN_LAYOUT_MARGINS 0,0,0,0
#define CENTER_LAYOUT_MARGINS 24, 16, 24, 8
#define BUTTON_LAYOUT_MARGINS 24, 24, 24, 24
@@ -81,11 +82,11 @@ void EnterpriseWlanDialog::closeEvent(QCloseEvent *event)
void EnterpriseWlanDialog::paintEvent(QPaintEvent *event)
{
- QPalette pal = qApp->palette();
- QPainter painter(this);
- painter.setBrush(pal.color(QPalette::Base));
- painter.drawRect(this->rect());
- painter.fillRect(rect(), QBrush(pal.color(QPalette::Base)));
+// QPalette pal = qApp->palette();
+// QPainter painter(this);
+// painter.setBrush(pal.color(QPalette::Base));
+// painter.drawRect(this->rect());
+// painter.fillRect(rect(), QBrush(pal.color(QPalette::Base)));
return QWidget::paintEvent(event);
}
@@ -126,15 +127,11 @@ void EnterpriseWlanDialog::initUI()
m_enterWlanScrollArea = new QScrollArea(this);
m_enterWlanScrollArea->setFrameShape(QFrame::NoFrame);
m_enterWlanScrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
-
- m_centerWidget->setFixedWidth(SCROAREA_WIDTH);
- m_enterWlanScrollArea->setFixedWidth(SCROAREA_WIDTH);
m_enterWlanScrollArea->setWidget(m_centerWidget);
- m_enterWlanScrollArea->setWidgetResizable(true);
-
QPalette pal = m_enterWlanScrollArea->palette();
- pal.setBrush(QPalette::Window, Qt::transparent);
+ pal.setBrush(QPalette::Base, QColor(0,0,0,0));
m_enterWlanScrollArea->setPalette(pal);
+ m_enterWlanScrollArea->setWidgetResizable(true);
m_bottomDivider = new Divider(this);
@@ -199,19 +196,24 @@ void EnterpriseWlanDialog::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);
-// }
-// }
-
+ 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);
+ }
+ }
+ pal.setColor(QPalette::Background, pal.base().color());
this->setPalette(pal);
setFramePalette(m_securityPage, pal);
+
+ if (styleGsettings != nullptr) {
+ delete styleGsettings;
+ styleGsettings = nullptr;
+ }
}
void EnterpriseWlanDialog::initData()
@@ -238,7 +240,7 @@ void EnterpriseWlanDialog::onBtnConnectClicked()
KyWirelessConnectSetting connetSetting;
connetSetting.setConnectName(m_wirelessNetItem.m_NetSsid);
connetSetting.setIfaceName(m_deviceName);
-// connetSetting.isAutoConnect = true; //ZJP_TODO 自动连接选项
+ connetSetting.isAutoConnect = m_securityPage->getAutoConnectState(); //ZJP_TODO 自动连接选项
connetSetting.m_type = KyKeyMgmt::WpaEap;
connetSetting.m_ssid = m_wirelessNetItem.m_NetSsid;
connetSetting.m_secretFlag = 0;
@@ -268,18 +270,21 @@ void EnterpriseWlanDialog::onEapTypeChanged(const KyEapMethodType &type)
m_resource->getEnterPriseInfoTls(m_wirelessNetItem.m_connectUuid, m_info.tlsInfo);
}
this->setFixedSize(MAIN_SIZE_EXPAND);
+// m_centerWidget->setFixedHeight(TLS_SCRO_HEIGHT);
break;
case KyEapMethodType::PEAP:
if (m_wirelessNetItem.m_connectUuid.isEmpty()) {
m_resource->getEnterPriseInfoPeap(m_wirelessNetItem.m_connectUuid, m_info.peapInfo);
}
this->setFixedSize(MAIN_SIZE_NARROW);
+// m_centerWidget->setFixedHeight(PEAP_SCRO_HEIGHT);
break;
case KyEapMethodType::TTLS:
if (!m_wirelessNetItem.m_connectUuid.isEmpty()) {
m_resource->getEnterPriseInfoTtls(m_wirelessNetItem.m_connectUuid, m_info.ttlsInfo);
}
this->setFixedSize(MAIN_SIZE_NARROW);
+// m_centerWidget->setFixedHeight(PEAP_SCRO_HEIGHT);
break;
default:
break;
diff --git a/src/frontend/frontend.pri b/src/frontend/frontend.pri
index c8eb1cd7..b7703595 100644
--- a/src/frontend/frontend.pri
+++ b/src/frontend/frontend.pri
@@ -6,7 +6,6 @@ include(list-items/list-items.pri)
include(netdetails/netdetails.pri)
include(enterprise-wlan/enterprise-wlan.pri)
include(networkmode/networkmode.pri)
-include(single-pages/single-pages.pri)
FORMS += \
$$PWD/wificonfigdialog.ui
@@ -14,13 +13,11 @@ FORMS += \
HEADERS += \
$$PWD/customstyle.h \
$$PWD/mainwindow.h \
- $$PWD/vpnmainwindow.h \
$$PWD/wificonfigdialog.h
SOURCES += \
$$PWD/customstyle.cpp \
$$PWD/mainwindow.cpp \
- $$PWD/vpnmainwindow.cpp \
$$PWD/wificonfigdialog.cpp
DISTFILES += \
diff --git a/src/frontend/list-items/lanlistitem.cpp b/src/frontend/list-items/lanlistitem.cpp
index 1560d668..ab9a7a01 100644
--- a/src/frontend/list-items/lanlistitem.cpp
+++ b/src/frontend/list-items/lanlistitem.cpp
@@ -23,6 +23,9 @@
#include
#define LOG_FLAG "[LanListItem]"
+#define NAMELABLE_MAX_WIDTH_HOVER 220
+#define NAMELABLE_MAX_WIDTH_ACTIVATED 190
+#define NAMELABLE_MAX_WIDTH_DEACTIVATED 326
LanListItem::LanListItem(const KyConnectItem *lanConnectItem,
const QString &deviceName, QWidget *parent):ListItem(parent)
@@ -42,16 +45,19 @@ LanListItem::LanListItem(const KyConnectItem *lanConnectItem,
m_netButton->stopLoading();
if (m_lanConnectItem.m_connectState == Activated) {
setIcon(true);
+ m_nameLabel->setLabelMaximumWidth(NAMELABLE_MAX_WIDTH_ACTIVATED);
} else {
setIcon(false);
+ m_nameLabel->setLabelMaximumWidth(NAMELABLE_MAX_WIDTH_DEACTIVATED);
}
} else {
m_netButton->startLoading();
}
m_itemFrame->installEventFilter(this);
- connect(this->m_infoButton, &InfoButton::clicked, this, &LanListItem::onInfoButtonClicked);
+// connect(this->m_infoButton, &InfoButton::clicked, this, &LanListItem::onInfoButtonClicked);
connect(m_menu, &QMenu::triggered, this, &LanListItem::onMenuTriggered);
+ connect(m_hoverButton, &FixPushButton::clicked, this, &LanListItem::onNetButtonClicked);
}
@@ -62,7 +68,7 @@ LanListItem::LanListItem(QWidget *parent) : ListItem(parent)
setIcon(false);
const QString str=tr("Not connected");
m_nameLabel->setLabelText(str);
- this->m_infoButton->hide();
+// this->m_infoButton->hide();
}
LanListItem::~LanListItem()
@@ -120,8 +126,7 @@ void LanListItem::onNetButtonClicked()
this->showDesktopNotify(tr("Wired Device not carried"), "networkwrong");
}
} else {
- qDebug() << LOG_FLAG <<"the connection" << m_lanConnectItem.m_connectName
- << "is not deactived, so it can not be operation.";
+ m_connectOperation->deactivateWiredConnection(m_lanConnectItem.m_connectName, m_lanConnectItem.m_connectUuid);
}
return;
@@ -144,9 +149,10 @@ void LanListItem::onRightButtonClicked()
} else {
return;
}
+ m_menu->addAction(new QAction(tr("Property"), this));
+ m_menu->addAction(new QAction(tr("Delete"), this));
- m_menu->move(cursor().pos());
- m_menu->show();
+ m_menu->popup(cursor().pos());
return;
}
@@ -159,6 +165,10 @@ void LanListItem::onMenuTriggered(QAction *action)
qDebug() << LOG_FLAG << "it will disconnect connection" << m_lanConnectItem.m_connectName
<< ". it's device is" << m_deviceName;
m_netButton->startLoading();
+ } else if (action->text() == tr("Property")) {
+ onInfoButtonClicked();
+ } else if (action->text() == tr("Delete")) {
+ m_connectOperation->deleteConnect(m_lanConnectItem.m_connectUuid);
}
return;
}
@@ -171,15 +181,15 @@ void LanListItem::onInfoButtonClicked()
return;
}
- if(netDetail != nullptr){
- netDetail->activateWindow();
- return;
- }
+// if(netDetail != nullptr){
+// netDetail->activateWindow();
+// return;
+// }
qDebug()<< LOG_FLAG << "the info button of lan is clicked! uuid = "
<< m_lanConnectItem.m_connectUuid << "; name = " << m_lanConnectItem.m_connectName
<< "." <show();
- Q_EMIT this->detailShow(true);
+#endif
+ Q_EMIT this->detailShow(m_deviceName, m_lanConnectItem.m_connectUuid);
return;
}
@@ -239,3 +250,40 @@ void LanListItem::updateConnectionPath(QString connectionPath)
{
m_lanConnectItem.m_connectPath = connectionPath;
}
+
+void LanListItem::enterEvent(QEvent *event)
+{
+ m_nameLabel->setLabelMaximumWidth(NAMELABLE_MAX_WIDTH_HOVER);
+ if (m_lanConnectItem.m_connectState != UnknownState) {
+ if (Deactivated != m_lanConnectItem.m_connectState) {
+ m_hoverButton->setProperty("useButtonPalette", true);
+ m_hoverButton->setProperty("isImportant", false);
+ m_hoverButton->setButtonText(tr("Disconnect"));
+ } else {
+ m_hoverButton->setProperty("isImportant", true);
+ m_hoverButton->setProperty("useButtonPalette", false);
+ m_hoverButton->setButtonText(tr("Connect"));
+ }
+ m_hoverButton->show();
+ m_lbLoadUp->hide();
+ m_lbLoadDown->hide();
+ m_lbLoadDownImg->hide();
+ m_lbLoadUpImg->hide();
+ }
+ return ListItem::enterEvent(event);
+}
+
+void LanListItem::leaveEvent(QEvent *event)
+{
+ m_hoverButton->hide();
+ if (m_lanConnectItem.m_connectState == Activated) {
+ m_nameLabel->setLabelMaximumWidth(NAMELABLE_MAX_WIDTH_ACTIVATED);
+ m_lbLoadUp->show();
+ m_lbLoadDown->show();
+ m_lbLoadDownImg->show();
+ m_lbLoadUpImg->show();
+ } else {
+ m_nameLabel->setLabelMaximumWidth(NAMELABLE_MAX_WIDTH_DEACTIVATED);
+ }
+ return ListItem::leaveEvent(event);
+}
diff --git a/src/frontend/list-items/lanlistitem.h b/src/frontend/list-items/lanlistitem.h
index e0209494..d6acd958 100644
--- a/src/frontend/list-items/lanlistitem.h
+++ b/src/frontend/list-items/lanlistitem.h
@@ -48,6 +48,8 @@ public:
protected:
void setIcon(bool isOn);
void onRightButtonClicked();
+ void enterEvent(QEvent *event);
+ void leaveEvent(QEvent *event);
private:
void connectItemCopy(const KyConnectItem *lanConnectItem);
diff --git a/src/frontend/list-items/list-items.pri b/src/frontend/list-items/list-items.pri
index 42550113..8fdc468e 100644
--- a/src/frontend/list-items/list-items.pri
+++ b/src/frontend/list-items/list-items.pri
@@ -8,13 +8,11 @@ HEADERS += \
$$PWD/lanlistitem.h \
$$PWD/listitem.h \
$$PWD/wlanlistitem.h \
- $$PWD/wlanmoreitem.h \
- $$PWD/vpnlistitem.h
+ $$PWD/wlanmoreitem.h
SOURCES += \
$$PWD/lanlistitem.cpp \
$$PWD/listitem.cpp \
$$PWD/wlanlistitem.cpp \
- $$PWD/wlanmoreitem.cpp \
- $$PWD/vpnlistitem.cpp
+ $$PWD/wlanmoreitem.cpp
diff --git a/src/frontend/list-items/listitem.cpp b/src/frontend/list-items/listitem.cpp
index 52b86ebd..cd42a724 100644
--- a/src/frontend/list-items/listitem.cpp
+++ b/src/frontend/list-items/listitem.cpp
@@ -31,6 +31,85 @@
#define LIGHT_HOVER_COLOR QColor(240,240,240,255)
#define DARK_HOVER_COLOR QColor(15,15,15,255)
+#define CONNECT_BUTTON_WIDTH 96
+#define PWD_AREA_HEIGHT 36
+
+#define FREQLABLE_HIGHT 18
+#define FREQLABLE_MARGINS 4,0,4,0
+#define LOADIMG_SIZE 16,16
+
+FreqLabel::FreqLabel(QWidget *parent) : QLabel(parent)
+{
+ const QByteArray id("org.ukui.style");
+ QGSettings * fontSetting = new QGSettings(id, QByteArray(), this);
+ if(QGSettings::isSchemaInstalled(id)){
+ connect(fontSetting, &QGSettings::changed,[=](QString key) {
+ if ("systemFontSize" ==key) {
+ changedFontSlot();
+ }
+ });
+ }
+ changedFontSlot();
+}
+
+void FreqLabel::changedFontSlot()
+{
+ const QByteArray id("org.ukui.style");
+ if(QGSettings::isSchemaInstalled(id)){
+ QGSettings * fontSetting = new QGSettings(id, QByteArray(), this);
+ QVariant fontVariant = fontSetting->get("systemFontSize");
+ QFont font;
+ font.setPointSize(fontVariant.toInt()*0.85);
+ this->setFont(font);
+ }
+}
+
+void FreqLabel::paintEvent(QPaintEvent *event)
+{
+ QPainter painter(this);
+ painter.setRenderHint(QPainter::Antialiasing); //抗锯齿效果
+ auto rect = this->rect();
+ painter.drawRoundedRect(rect, 6, 6);
+ QLabel::paintEvent(event);
+}
+
+FixPushButton::FixPushButton(QWidget *parent) :
+ QPushButton(parent)
+{
+ const QByteArray id("org.ukui.style");
+ QGSettings * fontSetting = new QGSettings(id, QByteArray(), this);
+ if(QGSettings::isSchemaInstalled(id)){
+ connect(fontSetting, &QGSettings::changed,[=](QString key) {
+ if ("systemFont" == key || "systemFontSize" ==key) {
+ changedLabelSlot();
+ }
+ });
+ }
+}
+
+
+void FixPushButton::setButtonText(QString text) {
+
+ mStr = text;
+ changedLabelSlot();
+}
+
+QString FixPushButton::getText(){
+ return mStr;
+}
+
+void FixPushButton::changedLabelSlot() {
+ QFontMetrics fontMetrics(this->font());
+ int fontSize = fontMetrics.width(mStr);
+ if (fontSize > 65) {
+ setText(fontMetrics.elidedText(mStr, Qt::ElideRight, 65));
+ setToolTip(mStr);
+ } else {
+ setText(mStr);
+ setToolTip("");
+ }
+}
+
ListItem::ListItem(QWidget *parent) : QFrame(parent)
{
m_connectState = UnknownState;
@@ -48,10 +127,10 @@ ListItem::~ListItem()
m_netButton = nullptr;
}
- if (nullptr != m_infoButton) {
- delete m_infoButton;
- m_infoButton = nullptr;
- }
+// if (nullptr != m_infoButton) {
+// delete m_infoButton;
+// m_infoButton = nullptr;
+// }
}
@@ -156,22 +235,66 @@ void ListItem::initUI()
m_hItemLayout = new QHBoxLayout(m_itemFrame);
m_hItemLayout->setContentsMargins(ITEM_FRAME_MARGINS);
- m_hItemLayout->setSpacing(ITEM_FRAME_SPACING);
+ m_hItemLayout->setSpacing(0);
m_hItemLayout->setAlignment(Qt::AlignHCenter);
m_netButton = new RadioItemButton(m_itemFrame);
- m_nameLabel = new FixLabel(m_itemFrame);
- m_nameLabel->setMinimumWidth(262);
- m_infoButton = new InfoButton(m_itemFrame);
- m_infoButton->setIconSize(QSize(INFO_ICON_WIDTH,INFO_ICON_HEIGHT));
+ m_freq = new FreqLabel(m_itemFrame);
+ m_freq->setEnabled(false);
+ m_freq->setText("...");
+ m_freq->setAlignment(Qt::AlignCenter);
+ m_freq->hide();
+ m_freq->setFixedHeight(FREQLABLE_HIGHT);
+ m_freq->setContentsMargins(FREQLABLE_MARGINS);
+ m_nameLabel = new NameLabel(m_itemFrame);
+ m_hoverButton = new FixPushButton(m_itemFrame);
+ m_hoverButton->setProperty("needTranslucent", true);
+ m_hoverButton->setFixedSize(CONNECT_BUTTON_WIDTH, PWD_AREA_HEIGHT);
+// m_infoButton = new InfoButton(m_itemFrame);
+// m_infoButton->setIconSize(QSize(INFO_ICON_WIDTH,INFO_ICON_HEIGHT));
+
+ m_lbLoadUp = new QLabel(m_itemFrame);
+ m_lbLoadUp->setAlignment(Qt::AlignCenter);
+ m_lbLoadDown = new QLabel(m_itemFrame);
+ m_lbLoadDown->setAlignment(Qt::AlignCenter);
+ m_lbLoadDownImg = new QLabel(m_itemFrame);
+ m_lbLoadUpImg = new QLabel(m_itemFrame);
+ m_lbLoadUp->hide();
+ m_lbLoadDown->hide();
+ m_lbLoadDownImg->hide();
+ m_lbLoadUpImg->hide();
+ m_lbLoadDownImg->setFixedSize(LOADIMG_SIZE);
+ m_lbLoadDownImg->setAlignment(Qt::AlignCenter);
+ m_lbLoadUpImg->setFixedSize(LOADIMG_SIZE);
+ m_lbLoadUpImg->setAlignment(Qt::AlignCenter);
+ QFont font;
+ font.setPointSize(10);
+ m_lbLoadUp->setFont(font);
+ m_lbLoadDown->setFont(font);
+ m_lbLoadUp->setText("0KB/s");
+ m_lbLoadDown->setText("0KB/s");
+ m_lbLoadDownImg->setPixmap(QPixmap(QLatin1String(":/res/x/load-down.png")));
+ m_lbLoadUpImg->setPixmap(QPixmap(QLatin1String(":/res/x/load-up.png")));
m_hItemLayout->addWidget(m_netButton);
+ m_hItemLayout->addSpacing(10);
m_hItemLayout->addWidget(m_nameLabel);
+ m_hItemLayout->addSpacing(8);
+ m_hItemLayout->addWidget(m_freq);
m_hItemLayout->addStretch();
- m_hItemLayout->addWidget(m_infoButton);
+ m_hItemLayout->addWidget(m_lbLoadUpImg);
+ m_hItemLayout->addWidget(m_lbLoadUp);
+ m_hItemLayout->addSpacing(2);
+ m_hItemLayout->addWidget(m_lbLoadDownImg);
+ m_hItemLayout->addWidget(m_lbLoadDown);
+ m_hItemLayout->addSpacing(2);
+ m_hItemLayout->addWidget(m_hoverButton);
+// m_hItemLayout->addWidget(m_infoButton);
m_mainLayout->addWidget(m_itemFrame);
+ m_hoverButton->hide();
+
// this->setAutoFillBackground(true);
// this->setBackgroundRole(QPalette::Base);
// QPalette pal = qApp->palette();
@@ -193,3 +316,46 @@ void ListItem::onPaletteChanged()
// this->setPalette(pal);
}
+
+NameLabel::NameLabel(QWidget *parent)
+ :QLabel(parent)
+{
+ const QByteArray id("org.ukui.style");
+ QGSettings * fontSetting = new QGSettings(id, QByteArray(), this);
+ if(QGSettings::isSchemaInstalled(id)){
+ connect(fontSetting, &QGSettings::changed,[=](QString key) {
+ if ("systemFont" == key || "systemFontSize" ==key) {
+ changedLabelSlot();
+ }
+ });
+ }
+}
+
+void NameLabel::setLabelText(QString text)
+{
+ m_name = text;
+ changedLabelSlot();
+}
+
+void NameLabel::setLabelMaximumWidth(int width)
+{
+ m_maximumWidth = width;
+ this->setMaximumWidth(m_maximumWidth);
+ if (m_name != nullptr) {
+ changedLabelSlot();
+ }
+}
+
+void NameLabel::changedLabelSlot()
+{
+ QFontMetrics fontMetrics(this->font());
+ int fontSize = fontMetrics.width(m_name);
+ if (fontSize > m_maximumWidth) {
+ setText(fontMetrics.elidedText(m_name, Qt::ElideRight, m_maximumWidth));
+ setToolTip(m_name);
+ } else {
+ this->setFixedWidth(fontMetrics.width(m_name));
+ setText(m_name);
+ setToolTip("");
+ }
+}
diff --git a/src/frontend/list-items/listitem.h b/src/frontend/list-items/listitem.h
index df59b9b4..7789e3b3 100644
--- a/src/frontend/list-items/listitem.h
+++ b/src/frontend/list-items/listitem.h
@@ -37,6 +37,54 @@ typedef enum{
Deactivated /**< The connection is no longer active */
}ConnectState;
+class FreqLabel : public QLabel
+{
+ Q_OBJECT
+public:
+ FreqLabel(QWidget *parent = nullptr);
+ ~FreqLabel() = default;
+protected:
+ void paintEvent(QPaintEvent *event);
+
+private Q_SLOTS:
+ void changedFontSlot();
+};
+
+class FixPushButton : public QPushButton
+{
+ Q_OBJECT
+public:
+ explicit FixPushButton(QWidget *parent = 0);
+
+public:
+ void setButtonText(QString text);
+ QString getText();
+
+private Q_SLOTS:
+ void changedLabelSlot();
+private:
+ QString mStr;
+
+};
+
+class NameLabel : public QLabel
+{
+ Q_OBJECT
+public:
+ explicit NameLabel(QWidget *parent = 0);
+ ~NameLabel() = default;
+ void setLabelText(QString text);
+ void setLabelMaximumWidth(int width);
+
+private:
+ QString m_name;
+ int m_maximumWidth = 120;
+
+private Q_SLOTS:
+ void changedLabelSlot();
+
+};
+
class ListItem : public QFrame
{
Q_OBJECT
@@ -58,19 +106,29 @@ protected:
protected:
QFrame * m_itemFrame = nullptr;
- FixLabel * m_nameLabel = nullptr;
+ NameLabel * m_nameLabel = nullptr;
RadioItemButton * m_netButton = nullptr;
- InfoButton * m_infoButton = nullptr;
+// InfoButton * m_infoButton = nullptr;
bool m_isActive = false;
ConnectState m_connectState;
QMenu *m_menu = nullptr;
+
+
public:
QVBoxLayout * m_mainLayout = nullptr;
QHBoxLayout * m_hItemLayout = nullptr;
+ QLabel *m_lbLoadDown = nullptr;
+ QLabel *m_lbLoadUp = nullptr;
+ QLabel *m_lbLoadDownImg = nullptr;
+ QLabel *m_lbLoadUpImg = nullptr;
+ QLabel *m_freq = nullptr;
+
NetDetail *netDetail = nullptr;
+
+ FixPushButton *m_hoverButton = nullptr;
private:
void initUI();
void initConnection();
@@ -81,7 +139,7 @@ public Q_SLOTS:
virtual void onMenuTriggered(QAction *action)=0;
Q_SIGNALS:
- void detailShow(bool isShow);
+ void detailShow(QString, QString);
};
#endif // LISTITEM_H
diff --git a/src/frontend/list-items/wlanlistitem.cpp b/src/frontend/list-items/wlanlistitem.cpp
index 61dbe675..4b5ef274 100644
--- a/src/frontend/list-items/wlanlistitem.cpp
+++ b/src/frontend/list-items/wlanlistitem.cpp
@@ -27,6 +27,9 @@
#define WAIT_US 10*1000
#define ENABLE_BUTTON_COLOR qApp->palette().highlight().color()
#define UNABLE_BUTTON_COLOR qApp->palette().button().color()
+#define NAMELABLE_MAX_WIDTH_HOVER 176
+#define NAMELABLE_MAX_WIDTH_ACTIVATED 142
+#define NAMELABLE_MAX_WIDTH_DEACTIVATED 276
const QString ENTERPRICE_TYPE = "802.1X";
const QString WPA1_AND_WPA2 = "WPA";
@@ -49,8 +52,9 @@ WlanListItem::WlanListItem(KyWirelessNetItem &wirelessNetItem, QString device, Q
initWlanUI();
setExpanded(false);
- connect(this->m_infoButton, &InfoButton::clicked, this, &WlanListItem::onInfoButtonClicked);
+// connect(this->m_infoButton, &InfoButton::clicked, this, &WlanListItem::onInfoButtonClicked);
connect(m_menu, &QMenu::triggered, this, &WlanListItem::onMenuTriggered);
+ connect(m_hoverButton, &FixPushButton::clicked, this, &WlanListItem::onNetButtonClicked);
m_wirelessConnectOperation = new KyWirelessConnectOperation(this);
m_deviceResource = new KyNetworkDeviceResourse(this);
@@ -69,7 +73,7 @@ WlanListItem::WlanListItem(QWidget *parent) : ListItem(parent)
setExpanded(false);
this->setName(name);
// this->m_netButton->setEnabled(false);
- this->m_infoButton->hide();
+// this->m_infoButton->hide();
}
WlanListItem::~WlanListItem()
@@ -133,6 +137,8 @@ void WlanListItem::setExpanded(const bool &expanded)
if (expanded) {
m_pwdLineEdit->setFocus();
setFixedHeight(EXPANDED_HEIGHT);
+ m_hoverButton->hide();
+ m_nameLabel->setLabelMaximumWidth(NAMELABLE_MAX_WIDTH_DEACTIVATED);
} else {
setFixedHeight(NORMAL_HEIGHT);
}
@@ -176,12 +182,14 @@ void WlanListItem::onRightButtonClicked()
return;
}
+
if (m_wirelessNetItem.m_isConfigured) {
+ m_menu->addAction(new QAction(tr("Property"), this));
m_menu->addAction(new QAction(tr("Forget"), this));
}
- m_menu->move(cursor().pos());
- m_menu->show();
+// m_menu->move(cursor().pos());
+ m_menu->popup(cursor().pos());
return;
}
@@ -190,6 +198,23 @@ void WlanListItem::enterEvent(QEvent *event)
{
//qDebug()<< LOG_FLAG <<"enterEvent" << m_wirelessNetItem.m_NetSsid;
m_mouseIsOut = false;
+ if (m_pwdFrame != nullptr && !m_pwdFrame->isVisible()) {
+ if (Deactivated != m_connectState) {
+ m_hoverButton->setProperty("useButtonPalette", true);
+ m_hoverButton->setProperty("isImportant", false);
+ m_hoverButton->setButtonText(tr("Disconnect"));
+ } else {
+ m_hoverButton->setProperty("isImportant", true);
+ m_hoverButton->setProperty("useButtonPalette", false);
+ m_hoverButton->setButtonText(tr("Connect"));
+ }
+ m_hoverButton->show();
+ m_lbLoadUp->hide();
+ m_lbLoadDown->hide();
+ m_lbLoadDownImg->hide();
+ m_lbLoadUpImg->hide();
+ }
+ m_nameLabel->setLabelMaximumWidth(NAMELABLE_MAX_WIDTH_HOVER);
return ListItem::enterEvent(event);
}
@@ -197,6 +222,16 @@ void WlanListItem::leaveEvent(QEvent *event)
{
//qDebug()<< LOG_FLAG <<"leaveEvent"<< m_wirelessNetItem.m_NetSsid;
m_mouseIsOut = true;
+ m_hoverButton->hide();
+ if (m_connectState == Activated) {
+ m_nameLabel->setLabelMaximumWidth(NAMELABLE_MAX_WIDTH_ACTIVATED);
+ m_lbLoadUp->show();
+ m_lbLoadDown->show();
+ m_lbLoadDownImg->show();
+ m_lbLoadUpImg->show();
+ } else {
+ m_nameLabel->setLabelMaximumWidth(NAMELABLE_MAX_WIDTH_DEACTIVATED);
+ }
if (m_pwdFrame && m_pwdFrame->isVisible()) {
if (m_focusIsOut) {
setExpanded(false);
@@ -245,6 +280,7 @@ void WlanListItem::paintEvent(QPaintEvent *event)
{
QPalette pal = qApp->palette();
if (m_pwdLineEdit != nullptr) {
+ pal.setColor(QPalette::Base, pal.color(QPalette::Base));
m_pwdLineEdit->setPalette(pal);
}
@@ -293,11 +329,11 @@ void WlanListItem::initWlanUI()
m_pwdLineEdit->setFixedHeight(PWD_AREA_HEIGHT);
m_pwdFrameLyt->addWidget(m_pwdLineEdit);
- m_connectButton = new QPushButton(m_pwdFrame);
+ m_connectButton = new FixPushButton(m_pwdFrame);
m_connectButton->setProperty("isImportant", true);
m_connectButton->setProperty("needTranslucent", true);
m_connectButton->setFixedSize(CONNECT_BUTTON_WIDTH, PWD_AREA_HEIGHT);
- m_connectButton->setText(tr("Connect"));
+ m_connectButton->setButtonText(tr("Connect"));
m_connectButton->setEnabled(false);
connect(m_connectButton, &QPushButton::clicked, this, &WlanListItem::onConnectButtonClicked);
m_pwdFrameLyt->addWidget(m_connectButton);
@@ -328,6 +364,9 @@ void WlanListItem::initWlanUI()
m_pwdFrame->hide();
m_autoConnectFrame->hide();
+
+ this->m_freq->show();
+ this->setFrequency();
}
QString getIcon(bool isEncrypted, int signalStrength, int category) {
@@ -435,17 +474,17 @@ void WlanListItem::refreshIcon(bool isActivated)
void WlanListItem::onInfoButtonClicked()
{
//ZJP_TODO 呼出无线详情页
- if(netDetail != nullptr){
- netDetail->activateWindow();
- return;
- }
+// if(netDetail != nullptr){
+// netDetail->activateWindow();
+// return;
+// }
qDebug() << LOG_FLAG << "Net active or not:"<< m_connectState;
qDebug() << LOG_FLAG << "On wlan info button clicked! ssid = "
<< m_wirelessNetItem.m_NetSsid << "; name = "
<< m_wirelessNetItem.m_connName << "." <show();
- Q_EMIT this->detailShow(true);
+#endif
+ Q_EMIT this->detailShow(m_wlanDevice, m_wirelessNetItem.m_NetSsid);
}
void WlanListItem::onNetButtonClicked()
@@ -471,8 +511,7 @@ void WlanListItem::onNetButtonClicked()
}
if (Deactivated != m_connectState) {
- qDebug() << LOG_FLAG <<"the connection" << m_wirelessNetItem.m_connName
- << "is not deactived, so it can not be operation." << Q_FUNC_INFO << __LINE__;
+ m_wirelessConnectOperation->deActivateWirelessConnection(m_wlanDevice, m_wirelessNetItem.m_connectUuid);
return;
}
@@ -510,6 +549,7 @@ void WlanListItem::onNetButtonClicked()
if (m_wirelessNetItem.m_secuType.contains("802.1x", Qt::CaseInsensitive)) {
if (isEnterpriseWlanDialogShow && enterpriseWlanDialog != nullptr) {
qDebug() << LOG_FLAG <<"EnterpriseWlanDialog is show do not show again!";
+ KWindowSystem::activateWindow(enterpriseWlanDialog->winId());
KWindowSystem::raiseWindow(enterpriseWlanDialog->winId());
return;
} else {
@@ -619,13 +659,28 @@ void WlanListItem::updateConnectState(ConnectState state)
if (Activated == state) {
m_netButton->stopLoading();
m_netButton->setActive(true);
+ m_hoverButton->setProperty("useButtonPalette", true);
+ m_hoverButton->setProperty("isImportant", false);
+ m_hoverButton->setButtonText(tr("Disconnect"));
+ if (m_hoverButton->isHidden()) {
+ m_nameLabel->setLabelMaximumWidth(NAMELABLE_MAX_WIDTH_ACTIVATED);
+ }
} else if(Deactivated == state) {
qDebug() << "[WlanListItem] stop loading connect state:" << state;
m_netButton->stopLoading();
m_netButton->setActive(false);
+ m_hoverButton->setProperty("isImportant", true);
+ m_hoverButton->setProperty("useButtonPalette", false);
+ m_hoverButton->setButtonText(tr("Connect"));
+ if (m_hoverButton->isHidden()) {
+ m_nameLabel->setLabelMaximumWidth(NAMELABLE_MAX_WIDTH_DEACTIVATED);
+ }
} else {
qDebug() << "[WlanListItem] start loading connect state:" << state;
m_netButton->startLoading();
+ m_hoverButton->setProperty("useButtonPalette", true);
+ m_hoverButton->setProperty("isImportant", false);
+ m_hoverButton->setButtonText(tr("Disconnect"));
}
return;
@@ -645,6 +700,8 @@ void WlanListItem::onMenuTriggered(QAction *action)
m_pwdLineEdit->clear();
}
m_wirelessConnectOperation->deleteWirelessConnect(m_wirelessNetItem.m_connectUuid);
+ } else if (action->text() == tr("Property")) {
+ onInfoButtonClicked();
}
return;
@@ -664,3 +721,22 @@ void WlanListItem::forgetPwd()
return;
}
}
+
+
+void WlanListItem::setFrequency()
+{
+ uint freq = m_wirelessNetItem.m_frequency;
+ bool isMix = m_wirelessNetItem.m_isMix;
+
+ if (isMix) {
+ this->m_freq->setText("2.4/5G");
+ return;
+ }
+ if (freq < FREQ_5GHZ) {
+ this->m_freq->setText("2.4G");
+ } else {
+ this->m_freq->setText("5G");
+ }
+
+ return;
+}
diff --git a/src/frontend/list-items/wlanlistitem.h b/src/frontend/list-items/wlanlistitem.h
index 4427ad24..5325d3e1 100644
--- a/src/frontend/list-items/wlanlistitem.h
+++ b/src/frontend/list-items/wlanlistitem.h
@@ -48,6 +48,8 @@ using namespace kdk;
#define LOW_SIGNAL 5
#define NONE_SIGNAL 0
+#define FREQ_5GHZ 5000
+
class WlanListItem : public ListItem
{
Q_OBJECT
@@ -79,6 +81,8 @@ public:
void forgetPwd();
+ void setFrequency();
+
protected:
void resizeEvent(QResizeEvent *event);
void onRightButtonClicked();
@@ -110,7 +114,7 @@ private:
QFrame *m_pwdFrame = nullptr;
QHBoxLayout *m_pwdFrameLyt = nullptr;
KPasswordEdit *m_pwdLineEdit = nullptr;
- QPushButton *m_connectButton = nullptr;
+ FixPushButton *m_connectButton = nullptr;
//自动连接选择区域UI
QFrame *m_autoConnectFrame = nullptr;
diff --git a/src/frontend/list-items/wlanmoreitem.cpp b/src/frontend/list-items/wlanmoreitem.cpp
index 450d40b6..576e3363 100644
--- a/src/frontend/list-items/wlanmoreitem.cpp
+++ b/src/frontend/list-items/wlanmoreitem.cpp
@@ -23,7 +23,8 @@ WlanMoreItem::WlanMoreItem(QWidget *parent) : ListItem(parent)
{
setObjectName(WMI_OB_NAME);
m_netButton->setVisible(false);
- m_infoButton->setVisible(false);
+// m_infoButton->setVisible(false);
+ m_nameLabel->setLabelMaximumWidth(326);
m_nameLabel->setLabelText(tr("Add Others..."));
}
diff --git a/src/frontend/mainwindow.cpp b/src/frontend/mainwindow.cpp
index 7c98d89a..56fcf996 100644
--- a/src/frontend/mainwindow.cpp
+++ b/src/frontend/mainwindow.cpp
@@ -49,6 +49,24 @@ const QString intel = "V10SP1-edu";
#define KEY_PRODUCT_FEATURES "PRODUCT_FEATURES"
+#define MW_EXCELLENT_SIGNAL 80
+#define MW_GOOD_SIGNAL 55
+#define MW_OK_SIGNAL 30
+#define MW_LOW_SIGNAL 5
+#define MW_NONE_SIGNAL 0
+
+#define EXCELLENT_SIGNAL_ICON "network-wireless-signal-excellent-symbolic"
+#define GOOD_SIGNAL_ICON "network-wireless-signal-good-symbolic"
+#define OK_SIGNAL_ICON "network-wireless-signal-ok-symbolic"
+#define LOW_SIGNAL_ICON "network-wireless-signal-weak-symbolic"
+#define NONE_SIGNAL_ICON "network-wireless-signal-none-symbolic"
+
+#define EXCELLENT_SIGNAL_LIMIT_ICON "ukui-network-wireless-signal-excellent-error-symbolic"
+#define GOOD_SIGNAL_LIMIT_ICON "ukui-network-wireless-signal-good-error-symbolic"
+#define OK_SIGNAL_LIMIT_ICON "ukui-network-wireless-signal-ok-error-symbolic"
+#define LOW_SIGNAL_LIMIT_ICON "ukui-network-wireless-signal-weak-error-symbolic"
+#define NONE_SIGNAL_LIMIT_ICON "ukui-network-wireless-signal-none-error-symbolic"
+
#include
#include
@@ -139,6 +157,7 @@ void MainWindow::firstlyStart()
initDbusConnnect();
initWindowTheme();
initTrayIcon();
+ initPlatform();
m_secondaryStartTimer = new QTimer(this);
connect(m_secondaryStartTimer, &QTimer::timeout, this, [ = ]() {
m_secondaryStartTimer->stop();
@@ -148,6 +167,10 @@ void MainWindow::firstlyStart()
m_createPagePtrMap.clear();
+ m_networkMode = new NetworkMode(this);
+ m_networkMode->initWiredNetworkMode();
+ m_networkMode->initWirelessNetworkMode();
+
//加载key ring
agent_init();
}
@@ -167,19 +190,19 @@ void MainWindow::secondaryStart()
*/
void MainWindow::initPlatform()
{
-// char* projectName = kdk_system_get_projectName();
-// QString strProjectName(projectName);
-// free(projectName);
-// projectName = NULL;
-// if(v10Sp1.compare(strProjectName,Qt::CaseInsensitive) == 0) {
-// unsigned int feature = kdk_system_get_productFeatures();
-// if (feature == 3) {
-// m_isShowInCenter = true;
-// }
-// } else if (intel.compare(strProjectName,Qt::CaseInsensitive) == 0) {
-// m_isShowInCenter = true;
-// }
-// qDebug() << "projectName" << projectName << m_isShowInCenter;
+ char* projectName = kdk_system_get_projectName();
+ QString strProjectName(projectName);
+ free(projectName);
+ projectName = NULL;
+ if(v10Sp1.compare(strProjectName,Qt::CaseInsensitive) == 0) {
+ unsigned int feature = kdk_system_get_productFeatures();
+ if (feature == 3) {
+ m_isShowInCenter = true;
+ }
+ } else if (intel.compare(strProjectName,Qt::CaseInsensitive) == 0) {
+ m_isShowInCenter = true;
+ }
+ qDebug() << "projectName" << projectName << m_isShowInCenter;
}
/**
@@ -289,18 +312,14 @@ void MainWindow::initUI()
*/
void MainWindow::initTrayIcon()
{
- loadIcons.append(QIcon::fromTheme("kylin-network-1"));
- loadIcons.append(QIcon::fromTheme("kylin-network-2"));
- loadIcons.append(QIcon::fromTheme("kylin-network-3"));
- loadIcons.append(QIcon::fromTheme("kylin-network-4"));
- loadIcons.append(QIcon::fromTheme("kylin-network-5"));
- loadIcons.append(QIcon::fromTheme("kylin-network-6"));
- loadIcons.append(QIcon::fromTheme("kylin-network-7"));
- loadIcons.append(QIcon::fromTheme("kylin-network-8"));
- loadIcons.append(QIcon::fromTheme("kylin-network-9"));
- loadIcons.append(QIcon::fromTheme("kylin-network-10"));
- loadIcons.append(QIcon::fromTheme("kylin-network-11"));
- loadIcons.append(QIcon::fromTheme("kylin-network-12"));
+ loadIcons.append(QIcon::fromTheme("ukui-loading-0-symbolic"));
+ loadIcons.append(QIcon::fromTheme("ukui-loading-1-symbolic"));
+ loadIcons.append(QIcon::fromTheme("ukui-loading-2-symbolic"));
+ loadIcons.append(QIcon::fromTheme("ukui-loading-3-symbolic"));
+ loadIcons.append(QIcon::fromTheme("ukui-loading-4-symbolic"));
+ loadIcons.append(QIcon::fromTheme("ukui-loading-5-symbolic"));
+ loadIcons.append(QIcon::fromTheme("ukui-loading-6-symbolic"));
+ loadIcons.append(QIcon::fromTheme("ukui-loading-7-symbolic"));
iconTimer = new QTimer(this);
connect(iconTimer, &QTimer::timeout, this, &MainWindow::onSetTrayIconLoading);
@@ -357,7 +376,7 @@ void MainWindow::initDbusConnnect()
connect(m_wlanWidget, &WlanPage::connectivityChanged, this, &MainWindow::onConnectivityChanged);
//模式切换
- QDBusConnection::sessionBus().connect(QString("com.kylin.statusmanager.interface"),
+ QDBusConnection::sessionBus().connect(QString("com.kylin.statusmanager.interfacer"),
QString("/"),
QString("com.kylin.statusmanager.interface"),
QString("mode_change_signal"), this, SLOT(onTabletModeChanged(bool)));
@@ -514,7 +533,6 @@ void MainWindow::showByWaylandHelper()
//去除窗管标题栏,传入参数为QWidget*
kdk::UkuiStyleHelper::self()->removeHeader(this);
this->show();
- getTabletMode();
resetWindowPosition();
//设置窗体位置,传入参数为QWindow*,QRect
@@ -535,24 +553,6 @@ void MainWindow::setCentralWidgetType(IconActiveType iconStatus)
}
}
-void MainWindow::getTabletMode()
-{
-// QDBusInterface interface(QString("com.kylin.statusmanager.interface"),
-// QString("/"),
-// QString("com.kylin.statusmanager.interface"),
-// QDBusConnection::sessionBus());
-// if(!interface.isValid()) {
-// m_isShowInCenter = true;
-// return;
-// }
-// QDBusReply reply = interface.call("get_current_tabletmode");
-// if (!reply.isValid()) {
-// m_isShowInCenter = true;
-// return;
-// }
-// m_isShowInCenter = reply.value();
-}
-
/**
* @brief MainWindow::onTrayIconActivated 点击托盘图标的槽函数
*/
@@ -597,12 +597,14 @@ void MainWindow::onThemeChanged(const QString &key)
void MainWindow::onRefreshTrayIcon()
{
//更新托盘图标显示
+ int signalStrength = 0;
iconTimer->stop();
if (m_lanWidget->lanIsConnected()) {
m_trayIcon->setIcon(QIcon::fromTheme("network-wired-connected-symbolic"));
iconStatus = IconActiveType::LAN_CONNECTED;
} else if (m_wlanWidget->checkWlanStatus(NetworkManager::ActiveConnection::State::Activated)){
- m_trayIcon->setIcon(QIcon::fromTheme("network-wireless-connected-symbolic"));
+// m_trayIcon->setIcon(QIcon::fromTheme("network-wireless-connected-symbolic"));
+ signalStrength = m_wlanWidget->getAcivateWifiSignal();
iconStatus = IconActiveType::WLAN_CONNECTED;
} else {
m_trayIcon->setIcon(QIcon::fromTheme("network-wired-disconnected-symbolic"));
@@ -617,15 +619,42 @@ void MainWindow::onRefreshTrayIcon()
iconStatus = IconActiveType::LAN_CONNECTED_LIMITED;
} else if (iconStatus == IconActiveType::WLAN_CONNECTED) {
//todo 信号强度
- m_trayIcon->setIcon(QIcon::fromTheme("network-wireless-signal-excellent-error-symbolic"));
+// m_trayIcon->setIcon(QIcon::fromTheme("network-wireless-signal-excellent-error-symbolic"));
iconStatus = IconActiveType::WLAN_CONNECTED_LIMITED;
}
}
+
+ if (iconStatus == IconActiveType::WLAN_CONNECTED
+ || iconStatus == IconActiveType::WLAN_CONNECTED_LIMITED) {
+ if (signalStrength > MW_EXCELLENT_SIGNAL){
+ m_trayIcon->setIcon(QIcon::fromTheme(EXCELLENT_SIGNAL_ICON));
+ } else if (signalStrength > MW_GOOD_SIGNAL) {
+ m_trayIcon->setIcon(QIcon::fromTheme(GOOD_SIGNAL_ICON));
+ } else if (signalStrength > MW_OK_SIGNAL) {
+ m_trayIcon->setIcon(QIcon::fromTheme(OK_SIGNAL_ICON));
+ } else if (signalStrength > MW_LOW_SIGNAL) {
+ m_trayIcon->setIcon(QIcon::fromTheme(LOW_SIGNAL_ICON));
+ } else {
+ m_trayIcon->setIcon(QIcon::fromTheme(NONE_SIGNAL_ICON));
+ }
+ } else if (iconStatus == IconActiveType::WLAN_CONNECTED_LIMITED) {
+ if (signalStrength > MW_EXCELLENT_SIGNAL){
+ m_trayIcon->setIcon(QIcon::fromTheme(EXCELLENT_SIGNAL_LIMIT_ICON));
+ } else if (signalStrength > MW_GOOD_SIGNAL) {
+ m_trayIcon->setIcon(QIcon::fromTheme(GOOD_SIGNAL_LIMIT_ICON));
+ } else if (signalStrength > MW_OK_SIGNAL) {
+ m_trayIcon->setIcon(QIcon::fromTheme(OK_SIGNAL_LIMIT_ICON));
+ } else if (signalStrength > MW_LOW_SIGNAL) {
+ m_trayIcon->setIcon(QIcon::fromTheme(LOW_SIGNAL_LIMIT_ICON));
+ } else {
+ m_trayIcon->setIcon(QIcon::fromTheme(NONE_SIGNAL_LIMIT_ICON));
+ }
+ }
}
void MainWindow::onSetTrayIconLoading()
{
- if (currentIconIndex > 11) {
+ if (currentIconIndex > 7) {
currentIconIndex = 0;
}
m_trayIcon->setIcon(loadIcons.at(currentIconIndex));
@@ -833,7 +862,7 @@ void MainWindow::showCreateWiredConnectWidget(const QString devName)
if (m_createPagePtrMap.contains(devName)) {
if (m_createPagePtrMap[devName] != nullptr) {
qDebug() << "showCreateWiredConnectWidget" << devName << "already create,just raise";
-
+ KWindowSystem::activateWindow(m_createPagePtrMap[devName]->winId());
KWindowSystem::raiseWindow(m_createPagePtrMap[devName]->winId());
return;
}
@@ -851,35 +880,7 @@ void MainWindow::showCreateWiredConnectWidget(const QString devName)
void MainWindow::showAddOtherWlanWidget(QString devName)
{
qDebug() << "showAddOtherWlanWidget! devName = " << devName;
- if (m_addOtherPagePtrMap.contains(devName)) {
- if (m_addOtherPagePtrMap[devName] != nullptr) {
- qDebug() << "showAddOtherWlanWidget" << devName << "already create,just raise";
-
- KWindowSystem::raiseWindow(m_addOtherPagePtrMap[devName]->winId());
- return;
- }
- }
-
-#if 0
- NetDetail *netDetail = new NetDetail(devName, "", "", false, true, true, this);
- connect(netDetail, &NetDetail::createPageClose, [&](QString interfaceName){
- if (m_addOtherPagePtrMap.contains(interfaceName)) {
- m_addOtherPagePtrMap[interfaceName] = nullptr;
- }
- });
- m_addOtherPagePtrMap.insert(devName, netDetail);
- netDetail->show();
-#endif
-
- JoinHiddenWiFiPage *hiddenWiFi =new JoinHiddenWiFiPage(devName);
- connect(hiddenWiFi, &JoinHiddenWiFiPage::hiddenWiFiPageClose, [&](QString interfaceName){
- if (m_addOtherPagePtrMap.contains(interfaceName)) {
- m_addOtherPagePtrMap[interfaceName] = nullptr;
- }
- });
- m_addOtherPagePtrMap.insert(devName, hiddenWiFi);
- connect(hiddenWiFi, &JoinHiddenWiFiPage::showWlanList, this, &MainWindow::onShowMainWindow);
- hiddenWiFi->show();
+ m_wlanWidget->showAddOtherPage(devName);
}
void MainWindow::getWirelessDeviceCap(QMap &map)
@@ -887,12 +888,6 @@ void MainWindow::getWirelessDeviceCap(QMap &map)
m_wlanWidget->getWirelessDeviceCap(map);
}
-//有线连接删除
-void MainWindow::deleteWired(const QString &connUuid)
-{
- m_lanWidget->deleteWired(connUuid);
-}
-
//有线连接断开
void MainWindow::activateWired(const QString& devName, const QString& connUuid)
{
diff --git a/src/frontend/mainwindow.h b/src/frontend/mainwindow.h
index fe5d5691..b7bcb591 100644
--- a/src/frontend/mainwindow.h
+++ b/src/frontend/mainwindow.h
@@ -34,6 +34,8 @@
#include "wlanpage.h"
#include "netdetails/netdetail.h"
#include "netdetails/joinhiddenwifipage.h"
+//安全中心-网络防火墙模式配置
+#include "networkmodeconfig.h"
//删除此头文件,别在添加
//#include
@@ -81,8 +83,6 @@ public:
void getApConnectionPath(QString &path, QString uuid);
//获取热点ActivePath
void getActiveConnectionPath(QString &path, QString uuid);
- //删除有线连接
- void deleteWired(const QString& connUuid);
//有线连接断开
void activateWired(const QString& devName, const QString& connUuid);
void deactivateWired(const QString& devName, const QString& connUuid);
@@ -154,13 +154,13 @@ private:
void initUI();
void initDbusConnnect();
void initTrayIcon();
+
void resetTrayIconTool();
void initWindowTheme();
void resetWindowTheme();
void showControlCenter();
void showByWaylandHelper();
void setCentralWidgetType(IconActiveType iconStatus);
- void getTabletMode();
double m_transparency=1.0; //透明度
QGSettings * m_transGsettings; //透明度配置文件
int currentIconIndex=0;
@@ -197,8 +197,8 @@ private:
IconActiveType iconStatus = IconActiveType::NOT_CONNECTED;
QMap m_createPagePtrMap;
-// QMap m_addOtherPagePtrMap;
- QMap m_addOtherPagePtrMap;
+
+ NetworkMode *m_networkMode;
public Q_SLOTS:
void onShowMainWindow(int type);
diff --git a/src/frontend/netdetails/configpage.cpp b/src/frontend/netdetails/configpage.cpp
index 0218480a..ebb5fb94 100644
--- a/src/frontend/netdetails/configpage.cpp
+++ b/src/frontend/netdetails/configpage.cpp
@@ -22,6 +22,7 @@
#include
#define VERTICAL_SPACING 24
+#define KSC_FIREWALL_NOCONFIG -1
#define KSC_FIREWALL_PUBLIC 0
#define KSC_FIREWALL_PRIVATE 1
@@ -65,7 +66,7 @@ void ConfigPage::initUi()
"it is suitable for networks in public places, such as airports or coffee shops, etc."));
m_publicLabel->setWordWrap(true);
//专用 网络中的设备可发现此电脑。一般情况下适用于家庭或工作单位的网络,您认识并信任网络上的个人和设备。
- m_privateLabel->setText(tr("Devices on the network can discover this computer. Generally applicable to a network "
+ m_privateLabel->setText(tr("Private Devices on the network can discover this computer. Generally applicable to a network "
"at home or work where you know and trust the individuals and devices on the network."));
m_privateLabel->setWordWrap(true);
//配置防火墙和安全设置
@@ -111,6 +112,7 @@ int ConfigPage::getConfigState()
} else if (m_privateButton->isChecked()) {
return KSC_FIREWALL_PRIVATE;
}
+ return KSC_FIREWALL_NOCONFIG;
}
diff --git a/src/frontend/netdetails/coninfo.h b/src/frontend/netdetails/coninfo.h
index a2b8cce2..1aef5fb4 100644
--- a/src/frontend/netdetails/coninfo.h
+++ b/src/frontend/netdetails/coninfo.h
@@ -20,6 +20,7 @@
#ifndef CONINFO_H
#define CONINFO_H
+#include
#include
#include
#include
@@ -93,7 +94,6 @@ public:
QString strIPV4FirDns;
QString strIPV4SecDns;
QString strIPV4GateWay;
- QList ipv4DnsList;
KyIpConfigType ipv6ConfigType = CONFIG_IP_DHCP;
QString strIPV6Address;
@@ -101,7 +101,6 @@ public:
QString strIPV6FirDns;
QString strIPV6SecDns;
QString strIPV6GateWay;
- QList ipv6DnsList;
KyEapMethodType enterpriseType;
KyEapMethodTlsInfo tlsInfo;
@@ -126,11 +125,12 @@ static void setFramePalette(QFrame *widget, QPalette &pal) {
static QPalette lightPalette(QWidget *widget)
{
- auto palette = widget->palette();
- //ukui-light palette UKUI3.1
+ QPalette palette = qApp->palette();
+
+ //ukui-light palette UKUI3.1 亮主题色板
QColor windowText_at(38, 38, 38),
- windowText_iat(38, 38, 38),
- windowText_dis(166, 166, 166),
+ windowText_iat(0, 0, 0, 255 * 0.55),
+ windowText_dis(0, 0, 0, 255 * 0.3),
button_at(230, 230, 230),
button_iat(230, 230, 230),
button_dis(233, 233, 233),
@@ -148,10 +148,10 @@ static QPalette lightPalette(QWidget *widget)
mid_dis(102, 102, 102),
text_at(38, 38, 38),
text_iat(38, 38, 38),
- text_dis(140, 140, 140),
- brightText_at(89, 89, 89),
- brightText_iat(89, 89, 89),
- brightText_dis(77, 77, 77),
+ text_dis(0, 0, 0, 255 * 0.3),
+ brightText_at(0, 0, 0),
+ brightText_iat(0, 0, 0),
+ brightText_dis(0, 0, 0),
buttonText_at(38, 38, 38),
buttonText_iat(38, 38, 38),
buttonText_dis(179, 179, 179),
@@ -161,24 +161,12 @@ static QPalette lightPalette(QWidget *widget)
window_at(245, 245, 245),
window_iat(237, 237, 237),
window_dis(230, 230, 230),
- shadow_at(0, 0, 0, 16),
- shadow_iat(0, 0, 0, 16),
- shadow_dis(0, 0, 0, 21),
-// shadow_at(214, 214, 214),
-// shadow_iat(214, 214, 214),
-// shadow_dis(201, 201, 201),
- highLight_at(55, 144, 250),
- highLight_iat(55, 144, 250),
- highLight_dis(233, 233, 233),
+ shadow_at(0, 0, 0, 255 * 0.16),
+ shadow_iat(0, 0, 0, 255 * 0.16),
+ shadow_dis(0, 0, 0, 255 * 0.21),
highLightText_at(255, 255, 255),
highLightText_iat(255, 255, 255),
highLightText_dis(179, 179, 179),
- link_at(55, 144, 250),
- link_iat(55, 144, 250),
- link_dis(55, 144, 250),
- linkVisited_at(114, 46, 209),
- linkVisited_iat(114, 46, 209),
- linkVisited_dis(114, 46, 209),
alternateBase_at(245, 245, 245),
alternateBase_iat(245, 245, 245),
alternateBase_dis(245, 245, 245),
@@ -191,11 +179,9 @@ static QPalette lightPalette(QWidget *widget)
toolTipText_at(38, 38, 38),
toolTipText_iat(38, 38, 38),
toolTipText_dis(38, 38, 38),
- placeholderText_at(38, 38, 38),
- placeholderText_iat(38, 38, 38),
- placeholderText_dis(38, 38, 38);
-
-
+ placeholderText_at(0, 0, 0, 255 * 0.35),
+ placeholderText_iat(0, 0, 0, 255 * 0.35),
+ placeholderText_dis(0, 0, 0, 255 * 0.3);
palette.setColor(QPalette::Active, QPalette::WindowText, windowText_at);
palette.setColor(QPalette::Inactive, QPalette::WindowText, windowText_iat);
@@ -245,22 +231,10 @@ static QPalette lightPalette(QWidget *widget)
palette.setColor(QPalette::Inactive, QPalette::Shadow, shadow_iat);
palette.setColor(QPalette::Disabled, QPalette::Shadow, shadow_dis);
- palette.setColor(QPalette::Active, QPalette::Highlight, highLight_at);
- palette.setColor(QPalette::Inactive, QPalette::Highlight, highLight_iat);
- palette.setColor(QPalette::Disabled, QPalette::Highlight, highLight_dis);
-
palette.setColor(QPalette::Active, QPalette::HighlightedText, highLightText_at);
palette.setColor(QPalette::Inactive, QPalette::HighlightedText, highLightText_iat);
palette.setColor(QPalette::Disabled, QPalette::HighlightedText, highLightText_dis);
- palette.setColor(QPalette::Active, QPalette::Link, link_at);
- palette.setColor(QPalette::Inactive, QPalette::Link, link_iat);
- palette.setColor(QPalette::Disabled, QPalette::Link, link_dis);
-
- palette.setColor(QPalette::Active, QPalette::LinkVisited, linkVisited_at);
- palette.setColor(QPalette::Inactive, QPalette::LinkVisited, linkVisited_iat);
- palette.setColor(QPalette::Disabled, QPalette::LinkVisited, linkVisited_dis);
-
palette.setColor(QPalette::Active, QPalette::AlternateBase, alternateBase_at);
palette.setColor(QPalette::Inactive, QPalette::AlternateBase, alternateBase_iat);
palette.setColor(QPalette::Disabled, QPalette::AlternateBase, alternateBase_dis);
diff --git a/src/frontend/netdetails/creatnetpage.cpp b/src/frontend/netdetails/creatnetpage.cpp
index ba5d0f98..7f242c5e 100644
--- a/src/frontend/netdetails/creatnetpage.cpp
+++ b/src/frontend/netdetails/creatnetpage.cpp
@@ -21,6 +21,8 @@
#include "math.h"
#define MAX_NAME_LENGTH 32
+#define HINT_TEXT_MARGINS 8, 1, 0, 3
+#define LABEL_HEIGHT 24
CreatNetPage::CreatNetPage(QWidget *parent):QFrame(parent)
{
@@ -36,39 +38,87 @@ void CreatNetPage::initUI()
ipv4addressEdit = new LineEdit(this);
netMaskEdit = new LineEdit(this);
gateWayEdit = 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);
- // 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);
+ QLabel *nameEmptyLabel = new QLabel(this);
+ QLabel *configEmptyLabel = new QLabel(this);
+ QLabel *gateWayEmptyLabel = new QLabel(this);
+ QLabel *firstDnsEmptyLabel = new QLabel(this);
+ nameEmptyLabel->setFixedHeight(LABEL_HEIGHT);
+ configEmptyLabel->setFixedHeight(LABEL_HEIGHT);
+ gateWayEmptyLabel->setFixedHeight(LABEL_HEIGHT);
+ firstDnsEmptyLabel->setFixedHeight(LABEL_HEIGHT);
+
+ m_addressHintLabel = new QLabel(this);
+ m_maskHintLabel = new QLabel(this);
+ m_addressHintLabel->setFixedHeight(LABEL_HEIGHT);
+ m_maskHintLabel->setFixedHeight(LABEL_HEIGHT);
+ m_addressHintLabel->setContentsMargins(HINT_TEXT_MARGINS);
+ m_maskHintLabel->setContentsMargins(HINT_TEXT_MARGINS);
+
+ QPalette hintTextColor;
+ hintTextColor.setColor(QPalette::WindowText, Qt::red);
+ m_addressHintLabel->setPalette(hintTextColor);
+ m_maskHintLabel->setPalette(hintTextColor);
+
+ QWidget *addressWidget = new QWidget(this);
+ QVBoxLayout *addressLayout = new QVBoxLayout(addressWidget);
+ addressLayout->setContentsMargins(0, 0, 0, 0);
+ addressLayout->setSpacing(0);
+ addressLayout->addWidget(ipv4addressEdit);
+ addressLayout->addWidget(m_addressHintLabel);
+
+ QWidget *maskWidget = new QWidget(this);
+ QVBoxLayout *maskLayout = new QVBoxLayout(maskWidget);
+ maskLayout->setContentsMargins(0, 0, 0, 0);
+ maskLayout->setSpacing(0);
+ maskLayout->addWidget(netMaskEdit);
+ maskLayout->addWidget(m_maskHintLabel);
m_connNameLabel->setText(tr("Connection Name"));
m_configLabel->setText(tr("IPv4Config"));
m_addressLabel->setText(tr("Address"));
m_maskLabel->setText(tr("Netmask"));
m_gateWayLabel->setText(tr("Default Gateway"));
+ m_dnsLabel->setText(tr("Prefs DNS"));
+ m_secDnsLabel->setText(tr("Alternative DNS"));
m_detailLayout = new QFormLayout(this);
+ m_detailLayout->setVerticalSpacing(0);
m_detailLayout->setContentsMargins(0, 0, 0, 0);
- m_detailLayout->setSpacing(24);
m_detailLayout->addRow(m_connNameLabel,connNameEdit);
+ m_detailLayout->addRow(nameEmptyLabel);
m_detailLayout->addRow(m_configLabel,ipv4ConfigCombox);
- m_detailLayout->addRow(m_addressLabel,ipv4addressEdit);
- m_detailLayout->addRow(m_maskLabel,netMaskEdit);
+ m_detailLayout->addRow(configEmptyLabel);
+ m_detailLayout->addRow(m_addressLabel, addressWidget);
+ m_detailLayout->addRow(m_maskLabel, maskWidget);
m_detailLayout->addRow(m_gateWayLabel,gateWayEdit);
- m_detailLayout->addRow(m_dnsWidget);
+ m_detailLayout->addRow(gateWayEmptyLabel);
+ m_detailLayout->addRow(m_dnsLabel,firstDnsEdit);
+ m_detailLayout->addRow(firstDnsEmptyLabel);
+ m_detailLayout->addRow(m_secDnsLabel,secondDnsEdit);
ipv4ConfigCombox->addItem(tr("Auto(DHCP)"), AUTO_CONFIG); //"自动(DHCP)"
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));
}
void CreatNetPage::initComponent() {
@@ -83,6 +133,11 @@ 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(ipv4addressEdit, SIGNAL(textChanged(QString)), this, SLOT(onAddressTextChanged()));
+ connect(netMaskEdit, SIGNAL(textChanged(QString)), this, SLOT(onNetMaskTextChanged()));
}
bool CreatNetPage::checkConnectBtnIsEnabled()
@@ -104,6 +159,26 @@ bool CreatNetPage::checkConnectBtnIsEnabled()
qDebug() << "create ipv4 netMask empty or invalid";
return false;
}
+
+// if (gateWayEdit->text().isEmpty() || !getTextEditState(gateWayEdit->text())) {
+// qDebug() << "create ipv4 gateway empty or invalid";
+// return false;
+// }
+
+ if (firstDnsEdit->text().isEmpty() && !secondDnsEdit->text().isEmpty()) {
+ qDebug() << "create ipv4 dns sort invalid";
+ return false;
+ }
+
+ if (!getTextEditState(firstDnsEdit->text())) {
+ qDebug() << "create ipv4 first dns invalid";
+ return false;
+ }
+
+ if (!getTextEditState(secondDnsEdit->text())) {
+ qDebug() << "create ipv4 second dns invalid";
+ return false;
+ }
}
return true;
}
@@ -117,17 +192,38 @@ void CreatNetPage::configChanged(int index) {
}
}
+void CreatNetPage::onAddressTextChanged()
+{
+ if (!getTextEditState(ipv4addressEdit->text())) {
+ m_addressHintLabel->setText(tr("Invalid address"));
+ } else {
+ m_addressHintLabel->clear();
+ }
+}
+
+void CreatNetPage::onNetMaskTextChanged()
+{
+ if (!netMaskIsValide(netMaskEdit->text())) {
+ m_maskHintLabel->setText(tr("Invalid subnet mask"));
+ } else {
+ m_maskHintLabel->clear();
+ }
+}
+
void CreatNetPage::setLineEnabled(bool check) {
ipv4addressEdit->setEnabled(check);
netMaskEdit->setEnabled(check);
gateWayEdit->setEnabled(check);
- m_dnsWidget->setEditEnabled(check);
+ firstDnsEdit->setEnabled(check);
+ secondDnsEdit->setEnabled(check);
if (!check) {
ipv4addressEdit->clear();
netMaskEdit->clear();
gateWayEdit->clear();
+ firstDnsEdit->clear();
+ secondDnsEdit->clear();
ipv4addressEdit->setPlaceholderText(" ");
netMaskEdit->setPlaceholderText(" ");
@@ -165,17 +261,13 @@ void CreatNetPage::constructIpv4Info(KyConnectSetting &setting)
<< " gateWay " << gateWay;
QStringList dnsList;
- dnsList.clear();
-
- QList ipv4dnsList;
- ipv4dnsList.clear();
- ipv4dnsList = m_dnsWidget->getDns();
- for (QHostAddress str: ipv4dnsList) {
- if (!dnsList.contains(str.toString())) {
- dnsList << str.toString();
+ dnsList.empty();
+ if (!firstDnsEdit->text().isEmpty()) {
+ dnsList << firstDnsEdit->text();
+ if (!secondDnsEdit->text().isEmpty()) {
+ dnsList << secondDnsEdit->text();
}
}
-
if (ipv4ConfigCombox->currentData() == AUTO_CONFIG) {
setting.setIpConfigType(IPADDRESS_V4, CONFIG_IP_DHCP);
} else {
diff --git a/src/frontend/netdetails/creatnetpage.h b/src/frontend/netdetails/creatnetpage.h
index 31885b3b..71ccefd7 100644
--- a/src/frontend/netdetails/creatnetpage.h
+++ b/src/frontend/netdetails/creatnetpage.h
@@ -32,7 +32,6 @@
#include
#include "coninfo.h"
-#include "multiplednswidget.h"
class CreatNetPage : public QFrame
{
@@ -47,7 +46,10 @@ private:
LineEdit *ipv4addressEdit;
LineEdit *netMaskEdit;
LineEdit *gateWayEdit;
+ LineEdit *firstDnsEdit;
+ LineEdit *secondDnsEdit;
+private:
QFormLayout *m_detailLayout;
QVBoxLayout *mvBoxLayout;
QLabel *m_connNameLabel;
@@ -55,8 +57,11 @@ private:
QLabel *m_addressLabel;
QLabel *m_maskLabel;
QLabel *m_gateWayLabel;
- MultipleDnsWidget *m_dnsWidget = nullptr;
+ QLabel *m_dnsLabel;
+ QLabel *m_secDnsLabel;
+ QLabel *m_addressHintLabel;
+ QLabel *m_maskHintLabel;
private:
void initUI();
void initComponent();
@@ -71,6 +76,9 @@ private:
private Q_SLOTS:
void setEnableOfSaveBtn();
void configChanged(int index);
+ void onAddressTextChanged();
+ void onNetMaskTextChanged();
+
Q_SIGNALS:
void setCreatePageState(bool);
diff --git a/src/frontend/netdetails/detailpage.cpp b/src/frontend/netdetails/detailpage.cpp
index 9356f1c1..159dbb2a 100644
--- a/src/frontend/netdetails/detailpage.cpp
+++ b/src/frontend/netdetails/detailpage.cpp
@@ -248,7 +248,7 @@ void DetailPage::initUI() {
m_IPV4Dns = new QLabel(this);
m_ipv4DnsWidget = new DetailWidget(qobject_cast(m_IPV4Dns), m_listWidget);
- m_ipv4DnsWidget->setKey(tr("IPv4 Dns:"));
+ m_ipv4DnsWidget->setKey(tr("IPv4 DNS:"));
m_IPV6 = new FixLabel(this);
m_IPV6->setFixedWidth(MAX_LABEL_WIDTH);
@@ -324,7 +324,7 @@ void DetailPage::on_btnCopyNetDetail_clicked()
QString chanCopy= tr ("Chan:");
QString bandwithCopy = tr("BandWidth:");
QString ipv4Copy = tr("IPv4:");
- QString ipv4dnsCopy = tr("IPv4 Dns:");
+ QString ipv4dnsCopy = tr("IPv4 DNS:");
QString ipv6Copy = tr("IPv6:");
QString macCopy = tr("Mac:");
QString netDetailCopyText;
diff --git a/src/frontend/netdetails/detailwidget.cpp b/src/frontend/netdetails/detailwidget.cpp
index 2c0d1864..8a02c59a 100644
--- a/src/frontend/netdetails/detailwidget.cpp
+++ b/src/frontend/netdetails/detailwidget.cpp
@@ -18,9 +18,7 @@
*
*/
#include "detailwidget.h"
-#include
#include
-#include
#define ITEM_HEIGHT 36
#define ITEM_MARGINS 18,0,16,0
@@ -28,45 +26,6 @@
#define MAX_LABEL_WIDTH 154
#define MAX_WIDGET_WIDTH 270
-FixLabel::FixLabel(QWidget *parent) :
- QLabel(parent)
-{
- const QByteArray id("org.ukui.style");
- QGSettings * fontSetting = new QGSettings(id, QByteArray(), this);
- if(QGSettings::isSchemaInstalled(id)){
- connect(fontSetting, &QGSettings::changed,[=](QString key) {
- if ("systemFont" == key || "systemFontSize" ==key) {
- changedLabelSlot();
- }
- });
- }
-}
-
-
-void FixLabel::setLabelText(QString text) {
-
- mStr = text;
- changedLabelSlot();
-}
-
-QString FixLabel::getText(){
- return mStr;
-}
-
-void FixLabel::changedLabelSlot() {
- QFontMetrics fontMetrics(this->font());
- int fontSize = fontMetrics.width(mStr);
- if (fontSize > this->width()) {
- setText(fontMetrics.elidedText(mStr, Qt::ElideRight, this->width()));
- setToolTip(mStr);
- } else {
- setText(mStr);
- setToolTip("");
- }
-}
-
-
-
DetailWidget::DetailWidget(QWidget *valueWidget, QWidget *parent, QWidget *buttonWidget)
: m_valueWidget(valueWidget) , QWidget(parent) , m_copyButton(buttonWidget)
{
diff --git a/src/frontend/netdetails/detailwidget.h b/src/frontend/netdetails/detailwidget.h
index c82a5eb5..dcfa6c28 100644
--- a/src/frontend/netdetails/detailwidget.h
+++ b/src/frontend/netdetails/detailwidget.h
@@ -23,23 +23,7 @@
#include
#include
#include
-
-class FixLabel : public QLabel
-{
- Q_OBJECT
-public:
- explicit FixLabel(QWidget *parent = 0);
-
-public:
- void setLabelText(QString text);
- QString getText();
-
-private Q_SLOTS:
- void changedLabelSlot();
-private:
- QString mStr;
-
-};
+#include "kylable.h"
class DetailWidget : public QWidget
{
diff --git a/src/frontend/netdetails/ipv4page.cpp b/src/frontend/netdetails/ipv4page.cpp
index 8e0bae39..6e2ca81c 100644
--- a/src/frontend/netdetails/ipv4page.cpp
+++ b/src/frontend/netdetails/ipv4page.cpp
@@ -39,11 +39,15 @@ void Ipv4Page::initUI() {
ipv4addressEdit = new LineEdit(this);
netMaskEdit = new LineEdit(this);
gateWayEdit = 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_configEmptyLabel = new QLabel(this);
m_configEmptyLabel->setFixedHeight(LABEL_HEIGHT);
@@ -60,10 +64,16 @@ void Ipv4Page::initUI() {
m_gateWayEmptyLabel = new QLabel(this);
m_gateWayEmptyLabel->setFixedHeight(LABEL_HEIGHT);
+ m_firstDnsEmptyLabel = new QLabel(this);
+ m_firstDnsEmptyLabel->setFixedHeight(LABEL_HEIGHT);
+
+
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_statusLabel = new QLabel(this);
m_statusLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
@@ -90,10 +100,6 @@ void Ipv4Page::initUI() {
maskLayout->addWidget(netMaskEdit);
maskLayout->addWidget(m_maskHintLabel);
- // 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->setVerticalSpacing(0);
m_detailLayout->setContentsMargins(LAYOUT_MARGINS);
@@ -103,7 +109,9 @@ void Ipv4Page::initUI() {
m_detailLayout->addRow(m_maskLabel,maskWidget);
m_detailLayout->addRow(m_gateWayLabel,gateWayEdit);
m_detailLayout->addRow(m_gateWayEmptyLabel);
- m_detailLayout->addRow(m_dnsWidget);
+ m_detailLayout->addRow(m_dnsLabel,firstDnsEdit);
+ m_detailLayout->addRow(m_firstDnsEmptyLabel);
+ m_detailLayout->addRow(m_secDnsLabel,secondDnsEdit);
ipv4ConfigCombox->addItem(tr("Auto(DHCP)")); //"自动(DHCP)"
ipv4ConfigCombox->addItem(tr("Manual")); //"手动"
@@ -116,9 +124,14 @@ void Ipv4Page::initUI() {
// 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));
initLoadingIcon();
}
@@ -139,6 +152,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(firstDnsEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn()));
+ connect(secondDnsEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn()));
}
void Ipv4Page::setIpv4Config(KyIpConfigType ipv4Config)
@@ -160,9 +175,14 @@ void Ipv4Page::setNetMask(const QString &netMask)
netMaskEdit->setText(netMask);
}
-void Ipv4Page::setMulDns(const QList &dns)
+void Ipv4Page::setIpv4FirDns(const QString &ipv4FirDns)
{
- m_dnsWidget->setDnsListText(dns);
+ firstDnsEdit->setText(ipv4FirDns);
+}
+
+void Ipv4Page::setIpv4SecDns(const QString &ipv4SecDns)
+{
+ secondDnsEdit->setText(ipv4SecDns);
}
void Ipv4Page::setGateWay(const QString &gateWay)
@@ -193,22 +213,19 @@ bool Ipv4Page::checkIsChanged(const ConInfo info, KyConnectSetting &setting)
isChanged = true;
}
qDebug() << "ipv4 netmask " << getNetMaskText(netMaskEdit->text());
-
- QList 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) {
+ || info.strIPV4FirDns != firstDnsEdit->text()
+ || info.strIPV4SecDns != secondDnsEdit->text()) {
qDebug() << "ipv4 info changed";
QStringList dnsList;
- dnsList.clear();
- for (QHostAddress str: ipv4dnsList) {
- if (!dnsList.contains(str.toString())) {
- dnsList << str.toString();
+ dnsList.empty();
+ if (!firstDnsEdit->text().isEmpty()) {
+ dnsList << firstDnsEdit->text();
+ if (!secondDnsEdit->text().isEmpty()) {
+ dnsList << secondDnsEdit->text();
}
}
@@ -239,6 +256,26 @@ bool Ipv4Page::checkConnectBtnIsEnabled()
qDebug() << "ipv4 netMask empty or invalid";
return false;
}
+
+// if (gateWayEdit->text().isEmpty() || !getTextEditState(gateWayEdit->text())) {
+// qDebug() << "ipv4 gateway empty or invalid";
+// return false;
+// }
+
+ if (firstDnsEdit->text().isEmpty() && !secondDnsEdit->text().isEmpty()) {
+ qDebug() << "ipv4 dns sort invalid";
+ return false;
+ }
+
+ if (!getTextEditState(firstDnsEdit->text())) {
+ qDebug() << "ipv4 first dns invalid";
+ return false;
+ }
+
+ if (!getTextEditState(secondDnsEdit->text())) {
+ qDebug() << "ipv4 second dns invalid";
+ return false;
+ }
}
return true;
}
@@ -288,6 +325,8 @@ void Ipv4Page::setLineEnabled(bool check) {
ipv4addressEdit->clear();
netMaskEdit->clear();
gateWayEdit->clear();
+ firstDnsEdit->clear();
+ secondDnsEdit->clear();
ipv4addressEdit->setPlaceholderText(" ");
netMaskEdit->setPlaceholderText(" ");
@@ -300,7 +339,8 @@ void Ipv4Page::setLineEnabled(bool check) {
ipv4addressEdit->setEnabled(check);
netMaskEdit->setEnabled(check);
gateWayEdit->setEnabled(check);
- m_dnsWidget->setEditEnabled(check);
+ firstDnsEdit->setEnabled(check);
+ secondDnsEdit->setEnabled(check);
}
void Ipv4Page::setEnableOfSaveBtn() {
diff --git a/src/frontend/netdetails/ipv4page.h b/src/frontend/netdetails/ipv4page.h
index fbb5422e..f5e9a779 100644
--- a/src/frontend/netdetails/ipv4page.h
+++ b/src/frontend/netdetails/ipv4page.h
@@ -33,7 +33,6 @@
//#include "kylinconnectsetting.h"
#include "coninfo.h"
-#include "multiplednswidget.h"
class Ipv4Page : public QFrame
{
@@ -43,11 +42,10 @@ public:
void setIpv4Config(KyIpConfigType ipv4Config);
void setIpv4(const QString &ipv4);
void setNetMask(const QString &netMask);
- void setMulDns(const QList &dns);
+ void setIpv4FirDns(const QString &ipv4FirDns);
+ void setIpv4SecDns(const QString &ipv4SecDns);
void setGateWay(const QString &gateWay);
- QString getNetMaskText(QString text);
-
bool checkIsChanged(const ConInfo info, KyConnectSetting &setting);
void startLoading();
@@ -59,6 +57,8 @@ private:
LineEdit *ipv4addressEdit;
LineEdit *netMaskEdit;
LineEdit *gateWayEdit;
+ LineEdit *firstDnsEdit;
+ LineEdit *secondDnsEdit;
QFormLayout *m_detailLayout;
QVBoxLayout *mvBoxLayout;
@@ -66,13 +66,14 @@ private:
QLabel *m_addressLabel;
QLabel *m_maskLabel;
QLabel *m_gateWayLabel;
+ QLabel *m_dnsLabel;
+ QLabel *m_secDnsLabel;
QLabel *m_configEmptyLabel;
QLabel *m_addressHintLabel;
QLabel *m_maskHintLabel;
QLabel *m_gateWayEmptyLabel;
-
- MultipleDnsWidget *m_dnsWidget = nullptr;
+ QLabel *m_firstDnsEmptyLabel;
QLabel *m_statusLabel = nullptr;
QList m_loadIcons;
@@ -89,7 +90,7 @@ private:
void configSave();
bool getTextEditState(QString text);
bool netMaskIsValide(QString text);
-
+ QString getNetMaskText(QString text);
bool checkConnectBtnIsEnabled();
void initConflictHintLable();
void initLoadingIcon();
diff --git a/src/frontend/netdetails/ipv6page.cpp b/src/frontend/netdetails/ipv6page.cpp
index a08fa73b..ed34bce8 100644
--- a/src/frontend/netdetails/ipv6page.cpp
+++ b/src/frontend/netdetails/ipv6page.cpp
@@ -52,9 +52,14 @@ void Ipv6Page::setIpv6Perfix(const int &ipv6Perfix)
lengthEdit->setText(QString::number(ipv6Perfix));
}
-void Ipv6Page::setMulDns(const QList &dns)
+void Ipv6Page::setIpv6FirDns(const QString &ipv6FirDns)
{
- m_dnsWidget->setDnsListText(dns);
+ firstDnsEdit->setText(ipv6FirDns);
+}
+
+void Ipv6Page::setIpv6SecDns(const QString &ipv6SecDns)
+{
+ secondDnsEdit->setText(ipv6SecDns);
}
void Ipv6Page::setGateWay(const QString &gateWay)
@@ -83,21 +88,19 @@ bool Ipv6Page::checkIsChanged(const ConInfo info, KyConnectSetting &setting)
setting.setIpConfigType(IPADDRESS_V6, CONFIG_IP_MANUAL);
isChanged = true;
}
-
- QList 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.strIPV6FirDns != firstDnsEdit->text()
+ || info.strIPV6SecDns != secondDnsEdit->text()) {
qDebug() << "ipv6 info changed";
QStringList dnsList;
- dnsList.clear();
- for (QHostAddress str: ipv6dnsList) {
- if (!dnsList.contains(str.toString())) {
- dnsList << str.toString();
+ dnsList.empty();
+ if (!firstDnsEdit->text().isEmpty()) {
+ dnsList << firstDnsEdit->text();
+ if (!secondDnsEdit->text().isEmpty()) {
+ dnsList << secondDnsEdit->text();
}
}
@@ -117,11 +120,15 @@ void Ipv6Page::initUI() {
ipv6AddressEdit = new LineEdit(this);
lengthEdit = new LineEdit(this);
gateWayEdit = 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_configEmptyLabel = new QLabel(this);
m_configEmptyLabel->setFixedHeight(LABEL_HEIGHT);
@@ -138,10 +145,16 @@ void Ipv6Page::initUI() {
m_subnetEmptyLabel = new QLabel(this);
m_subnetEmptyLabel->setFixedHeight(LABEL_HEIGHT);
+ m_firstDnsEmptyLabel = new QLabel(this);
+ m_firstDnsEmptyLabel->setFixedHeight(LABEL_HEIGHT);
+
+
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_statusLabel = new QLabel(this);
m_statusLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
@@ -168,9 +181,6 @@ void Ipv6Page::initUI() {
gateWayLayout->addWidget(gateWayEdit);
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_detailLayout = new QFormLayout(this);
m_detailLayout->setContentsMargins(0, 0, 0, 0);
m_detailLayout->setVerticalSpacing(0);
@@ -180,13 +190,18 @@ void Ipv6Page::initUI() {
m_detailLayout->addRow(m_subnetLabel,lengthEdit);
m_detailLayout->addRow(m_subnetEmptyLabel);
m_detailLayout->addRow(m_gateWayLabel,gateWayWidget);
- m_detailLayout->addRow(m_dnsWidget);
+ m_detailLayout->addRow(m_dnsLabel,firstDnsEdit);
+ m_detailLayout->addRow(m_firstDnsEmptyLabel);
+ m_detailLayout->addRow(m_secDnsLabel,secondDnsEdit);
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));
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));
@@ -210,6 +225,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(firstDnsEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn()));
+ connect(secondDnsEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn()));
}
void Ipv6Page::configChanged(int index) {
@@ -227,6 +244,8 @@ void Ipv6Page::setControlEnabled(bool check)
ipv6AddressEdit->clear();
lengthEdit->clear();
gateWayEdit->clear();
+ firstDnsEdit->clear();
+ secondDnsEdit->clear();
ipv6AddressEdit->setPlaceholderText(" ");
lengthEdit->setPlaceholderText(" ");
@@ -234,13 +253,13 @@ void Ipv6Page::setControlEnabled(bool check)
} else {
ipv6AddressEdit->setPlaceholderText(tr("Required")); //必填
lengthEdit->setPlaceholderText(tr("Required")); //必填
- gateWayEdit->setPlaceholderText(tr("Required")); //必填
}
ipv6AddressEdit->setEnabled(check);
lengthEdit->setEnabled(check);
gateWayEdit->setEnabled(check);
- m_dnsWidget->setEditEnabled(check);
+ firstDnsEdit->setEnabled(check);
+ secondDnsEdit->setEnabled(check);
}
void Ipv6Page::setEnableOfSaveBtn()
@@ -293,8 +312,23 @@ bool Ipv6Page::checkConnectBtnIsEnabled()
return false;
}
- if (gateWayEdit->text().isEmpty() || !getIpv6EditState(gateWayEdit->text())) {
- qDebug() << "ipv6 gateway empty or invalid";
+// if (gateWayEdit->text().isEmpty() || !getIpv6EditState(gateWayEdit->text())) {
+// qDebug() << "ipv6 gateway empty or invalid";
+// return false;
+// }
+
+ if (firstDnsEdit->text().isEmpty() && !secondDnsEdit->text().isEmpty()) {
+ qDebug() << "ipv6 dns sort invalid";
+ return false;
+ }
+
+ if (!getIpv6EditState(firstDnsEdit->text())) {
+ qDebug() << "ipv6 first dns invalid";
+ return false;
+ }
+
+ if (!getIpv6EditState(secondDnsEdit->text())) {
+ qDebug() << "ipv6 second dns invalid";
return false;
}
}
diff --git a/src/frontend/netdetails/ipv6page.h b/src/frontend/netdetails/ipv6page.h
index 8097b6f5..a36265df 100644
--- a/src/frontend/netdetails/ipv6page.h
+++ b/src/frontend/netdetails/ipv6page.h
@@ -33,7 +33,6 @@
//#include "kylinconnectsetting.h"
#include "coninfo.h"
-#include "multiplednswidget.h"
class Ipv6Page : public QFrame
{
@@ -43,9 +42,8 @@ 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 setMulDns(const QList &dns);
+ void setIpv6FirDns(const QString &ipv6FirDns);
+ void setIpv6SecDns(const QString &ipv6SecDns);
void setGateWay(const QString &gateWay);
bool checkIsChanged(const ConInfo info, KyConnectSetting &setting);
@@ -56,28 +54,27 @@ public:
void stopLoading();
void showIpv6AddressConflict(bool isConflict);
-private:
+public:
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;
QLabel *m_configEmptyLabel;
QLabel *m_addressHintLabel;
QLabel *m_subnetEmptyLabel;
QLabel *m_gateWayHintLabel;
-
- MultipleDnsWidget *m_dnsWidget = nullptr;
+ QLabel *m_firstDnsEmptyLabel;
QLabel *m_statusLabel = nullptr;
QList m_loadIcons;
@@ -86,7 +83,6 @@ private:
QLabel *m_iconLabel;
QLabel *m_textLabel;
-
private:
void initUI();
void initComponent();
diff --git a/src/frontend/netdetails/joinhiddenwifipage.cpp b/src/frontend/netdetails/joinhiddenwifipage.cpp
index 9363dd45..4581e84f 100644
--- a/src/frontend/netdetails/joinhiddenwifipage.cpp
+++ b/src/frontend/netdetails/joinhiddenwifipage.cpp
@@ -33,12 +33,13 @@
#define BOTTOM_LAYOUT_MARGINS 24, 24, 24, 24
#define LAYOUT_SPACING 16
#define LABEL_MIN_WIDTH 146
+#define LABEL_MAX_WIDTH 434
#define MAX_NAME_LENGTH 32
-#define SCROAREA_WIDTH 480
+#define PSK_SCRO_HEIGHT 182
+#define PEAP_SCRO_HEIGHT 340
+#define TLS_SCRO_HEIGHT 560
#define MEDIUM_WEIGHT_VALUE 57
-bool LaunchApp(QString desktopFile);
-
JoinHiddenWiFiPage::JoinHiddenWiFiPage(QString devName, KDialog *parent)
:m_devName(devName),
KDialog(parent)
@@ -48,6 +49,7 @@ JoinHiddenWiFiPage::JoinHiddenWiFiPage(QString devName, KDialog *parent)
initUI();
initComponent();
+ setFixedWidth(WINDOW_WIDTH);
setAttribute(Qt::WA_DeleteOnClose);
setJoinBtnEnable();
@@ -58,19 +60,9 @@ JoinHiddenWiFiPage::~JoinHiddenWiFiPage()
}
-void JoinHiddenWiFiPage::setJoinHiddenWiFiShowed(bool state)
-{
- m_joinHiddenWiFiShowed = state;
-}
-
void JoinHiddenWiFiPage::closeEvent(QCloseEvent *event)
{
Q_EMIT this->hiddenWiFiPageClose(m_devName);
-
- if (m_joinHiddenWiFiShowed) {
- LaunchApp("ukui-control-center.desktop");
- m_joinHiddenWiFiShowed = false;
- }
return QWidget::closeEvent(event);
}
@@ -82,7 +74,8 @@ void JoinHiddenWiFiPage::initUI()
m_secuWidget = new SecurityPage(false, this);
m_secuWidget->setSecurity(KySecuType::WPA_AND_WPA2_PERSONAL);
- m_descriptionLabel = new QLabel(this);
+ m_descriptionLabel = new FixLabel(this);
+ m_descriptionLabel->setFixedWidth(LABEL_MAX_WIDTH);
m_nameLabel = new FixLabel(this);
m_nameLabel->setFixedWidth(LABEL_MIN_WIDTH);
m_nameEdit =new LineEdit(this);
@@ -128,11 +121,8 @@ void JoinHiddenWiFiPage::initUI()
m_centerVBoxLayout->addWidget(ssidWidget);
m_centerVBoxLayout->addSpacing(LAYOUT_SPACING);
m_centerVBoxLayout->addWidget(m_secuWidget);
-
- m_centerWidget->setFixedWidth(SCROAREA_WIDTH);
- m_hiddenWifiScrollArea->setFixedWidth(SCROAREA_WIDTH);
+ m_centerVBoxLayout->addStretch();
m_hiddenWifiScrollArea->setWidget(m_centerWidget);
- m_hiddenWifiScrollArea->setWidgetResizable(true);
//底部按钮
m_bottomLayout = new QHBoxLayout(m_bottomWidget);
@@ -144,7 +134,7 @@ void JoinHiddenWiFiPage::initUI()
m_bottomLayout->addWidget(m_joinBtn);
//请输入您想要加入网络的名称和安全类型
- m_descriptionLabel->setText(tr("Please enter the network name and security type"));
+ m_descriptionLabel->setLabelText(tr("Please enter the network name and security type"));
QFont font = m_descriptionLabel->font();
font.setWeight(MEDIUM_WEIGHT_VALUE);
m_descriptionLabel->setFont(font);
@@ -159,8 +149,9 @@ void JoinHiddenWiFiPage::initUI()
this->setWindowTitle(tr("Find and Join Wi-Fi"));
this->setWindowIcon(QIcon::fromTheme("kylin-network"));
- this->setFixedWidth(WINDOW_WIDTH);
+
this->setFixedHeight(MIN_WINDOW_HEIGHT);
+ onPaletteChanged();
}
void JoinHiddenWiFiPage::initComponent()
@@ -245,6 +236,7 @@ void JoinHiddenWiFiPage::onSecuTypeChanged(const KySecuType &type)
{
if (type != KySecuType::WPA_AND_WPA2_ENTERPRISE) {
this->setFixedHeight(MIN_WINDOW_HEIGHT);
+ m_centerWidget->setFixedSize(WINDOW_WIDTH, PSK_SCRO_HEIGHT);
}
}
@@ -252,8 +244,10 @@ void JoinHiddenWiFiPage::onEapTypeChanged(const KyEapMethodType &type)
{
if (type == KyEapMethodType::TLS) {
this->setFixedHeight(TLS_WINDOW_HEIGHT);
+ m_centerWidget->setFixedSize(WINDOW_WIDTH, TLS_SCRO_HEIGHT);
} else if (type == KyEapMethodType::PEAP || type == KyEapMethodType::TTLS) {
this->setFixedHeight(PEAP_WINDOW_HEIGHT);
+ m_centerWidget->setFixedSize(WINDOW_WIDTH, PEAP_SCRO_HEIGHT);
}
}
@@ -262,14 +256,14 @@ void JoinHiddenWiFiPage::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);
-// }
-// }
+ 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);
setFramePalette(m_secuWidget, pal);
setFramePalette(m_hiddenWifiScrollArea, pal);
@@ -279,3 +273,4 @@ void JoinHiddenWiFiPage::onPaletteChanged()
styleGsettings = nullptr;
}
}
+
diff --git a/src/frontend/netdetails/joinhiddenwifipage.h b/src/frontend/netdetails/joinhiddenwifipage.h
index bea8be80..1a9806d1 100644
--- a/src/frontend/netdetails/joinhiddenwifipage.h
+++ b/src/frontend/netdetails/joinhiddenwifipage.h
@@ -43,8 +43,6 @@ public:
JoinHiddenWiFiPage(QString devName, KDialog *parent = nullptr);
~JoinHiddenWiFiPage();
- void setJoinHiddenWiFiShowed(bool state);
-
protected:
void closeEvent(QCloseEvent *event);
@@ -63,7 +61,7 @@ private:
QWidget *m_bottomWidget;
SecurityPage *m_secuWidget;
- QLabel *m_descriptionLabel;
+ FixLabel *m_descriptionLabel;
FixLabel *m_nameLabel;
LineEdit *m_nameEdit;
@@ -80,7 +78,6 @@ private:
bool m_isJoinBtnEnable = false;
bool m_isSecuOk = false;
- bool m_joinHiddenWiFiShowed = false;
ConInfo m_info;
private Q_SLOTS:
diff --git a/src/frontend/netdetails/netdetail.cpp b/src/frontend/netdetails/netdetail.cpp
index fa12a26b..9d727c8f 100644
--- a/src/frontend/netdetails/netdetail.cpp
+++ b/src/frontend/netdetails/netdetail.cpp
@@ -21,8 +21,6 @@
#include "backend/kylinipv4arping.h"
#include "backend/kylinipv6arping.h"
//#include "xatom/xatom-helper.h"
-#include "networkmodeconfig.h"
-
#define THEME_SCHAME "org.ukui.style"
#define COLOR_THEME "styleName"
@@ -41,6 +39,7 @@
#define CENTER_LAYOUT_MARGINS 24,0,0,0
#define BOTTOM_LAYOUT_MARGINS 24,0,24,0
#define BOTTOM_LAYOUT_SPACING 16
+#define PAGE_LAYOUT_SPACING 1
#define DETAIL_PAGE_NUM 0
#define IPV4_PAGE_NUM 1
#define IPV6_PAGE_NUM 2
@@ -48,36 +47,15 @@
#define CONFIG_PAGE_NUM 4
#define CREATE_NET_PAGE_NUM 5
#define PAGE_MIN_HEIGHT 40
-#define PAGE_WIDTH 472
#define LAN_TAB_WIDTH 180
#define WLAN_TAB_WIDTH 240
-#define SCRO_WIDTH 496
-#define SCRO_HEIGHT 600
+#define SCRO_WIDTH 472
#define PEAP_SCRO_HEIGHT 300
#define TLS_SCRO_HEIGHT 480
#define MAX_TAB_TEXT_LENGTH 44
-#define KYLIN_APP_MANAGER_NAME "com.kylin.AppManager"
-#define KYLIN_APP_MANAGER_PATH "/com/kylin/AppManager"
-#define KYLIN_APP_MANAGER_INTERFACE "com.kylin.AppManager"
//extern void qt_blurImage(QImage &blurImage, qreal radius, bool quality, int transposed);
-bool LaunchApp(QString desktopFile)
-{
- QDBusInterface m_appManagerDbusInterface(KYLIN_APP_MANAGER_NAME,
- KYLIN_APP_MANAGER_PATH,
- KYLIN_APP_MANAGER_INTERFACE,
- QDBusConnection::sessionBus());//局部变量
-
- if (!m_appManagerDbusInterface.isValid()) {
- qWarning()<<"m_appManagerDbusInterface init error";
- return false;
- } else {
- QDBusReply reply =m_appManagerDbusInterface.call("LaunchApp",desktopFile);
- return reply;
- }
-}
-
void NetDetail::showDesktopNotify(const QString &message, QString soundName)
{
QDBusInterface iface("org.freedesktop.Notifications",
@@ -189,7 +167,7 @@ NetDetail::NetDetail(QString interface, QString name, QString uuid, bool isActiv
getConInfo(m_info);
startObjectThread();
pagePadding(name,isWlan);
-
+ setSecuPageHeight();
connect(qApp, &QApplication::paletteChanged, this, &NetDetail::onPaletteChanged);
isCreateOk = !(m_isCreateNet && !isWlan);
@@ -218,16 +196,16 @@ void NetDetail::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);
-// }
-// }
-
+ 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);
+ }
+ }
+ pal.setColor(QPalette::Background, pal.base().color());
this->setPalette(pal);
setFramePalette(detailPage, pal);
@@ -238,18 +216,15 @@ void NetDetail::onPaletteChanged()
QToolTip::setPalette(pal);
QPalette listwidget_pal(detailPage->m_listWidget->palette());
- listwidget_pal.setColor(QPalette::Base, this->palette().base().color());
- listwidget_pal.setColor(QPalette::AlternateBase, this->palette().alternateBase().color());
+ listwidget_pal.setColor(QPalette::Base, pal.base().color());
+ listwidget_pal.setColor(QPalette::AlternateBase, pal.alternateBase().color());
detailPage->m_listWidget->setAlternatingRowColors(true);
detailPage->m_listWidget->setPalette(listwidget_pal);
-// if (styleGsettings != nullptr) {
-// delete styleGsettings;
-// styleGsettings = nullptr;
-// }
-
- QColor colorTabBar = pal.color(QPalette::Disabled, QPalette::Highlight);
- m_netTabBar->setBackgroundColor(colorTabBar);
+ if (styleGsettings != nullptr) {
+ delete styleGsettings;
+ styleGsettings = nullptr;
+ }
}
void NetDetail::currentRowChangeSlot(int row)
@@ -271,24 +246,19 @@ void NetDetail::currentRowChangeSlot(int row)
void NetDetail::paintEvent(QPaintEvent *event)
{
- QPalette pal = qApp->palette();
- QPainter painter(this);
- painter.setBrush(pal.color(QPalette::Base));
- painter.drawRect(this->rect());
- painter.fillRect(rect(), QBrush(pal.color(QPalette::Base)));
+// QPalette pal = qApp->palette();
+// QPainter painter(this);
+// painter.setBrush(pal.color(QPalette::Base));
+// painter.drawRect(this->rect());
+// painter.fillRect(rect(), QBrush(pal.color(QPalette::Base)));
return QWidget::paintEvent(event);
}
void NetDetail::closeEvent(QCloseEvent *event)
{
- Q_EMIT this->detailPageClose(false);
+ Q_EMIT this->detailPageClose(m_deviceName, m_name, m_uuid);
Q_EMIT this->createPageClose(m_deviceName);
-
- if (m_hasDetailPageShowed) {
- LaunchApp("ukui-control-center.desktop");
- m_hasDetailPageShowed = false;
- }
return QWidget::closeEvent(event);
}
@@ -311,79 +281,69 @@ void NetDetail::initUI()
{
QVBoxLayout *mainLayout = new QVBoxLayout(this);
mainLayout->setContentsMargins(0,9,0,24);
- mainLayout->setSpacing(22);
-
- this->installEventFilter(this);
- pageFrame = new QFrame(this);
- centerWidget = new QWidget(this);
- bottomWidget = new QWidget(this);
+ mainLayout->setSpacing(24);
detailPage = new DetailPage(isWlan, m_name.isEmpty(), this);
+
ipv4Page = new Ipv4Page(this);
ipv6Page = new Ipv6Page(this);
securityPage = new SecurityPage(this);
createNetPage = new CreatNetPage(this);
configPage = new ConfigPage(this);
- detailPage->setFixedWidth(PAGE_WIDTH);
- ipv4Page->setFixedWidth(PAGE_WIDTH);
- ipv6Page->setFixedWidth(PAGE_WIDTH);
- securityPage->setFixedWidth(PAGE_WIDTH);
- createNetPage->setFixedWidth(PAGE_WIDTH);
- configPage->setFixedWidth(PAGE_WIDTH);
+ this->installEventFilter(this);
+ centerWidget = new QWidget(this);
+ bottomWidget = new QWidget(this);
- // 滚动区域
- m_secuPageScrollArea = new QScrollArea(centerWidget);
- m_secuPageScrollArea->setFixedWidth(SCRO_WIDTH);
+ m_secuPageScrollArea = new QScrollArea(this);
m_secuPageScrollArea->setFrameShape(QFrame::NoFrame);
m_secuPageScrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
m_secuPageScrollArea->setWidget(securityPage);
- m_secuPageScrollArea->setWidgetResizable(true);
-
- m_ipv4ScrollArea = new QScrollArea(centerWidget);
- m_ipv4ScrollArea->setFixedWidth(SCRO_WIDTH);
- m_ipv4ScrollArea->setFrameShape(QFrame::NoFrame);
- m_ipv4ScrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
- m_ipv4ScrollArea->setWidget(ipv4Page);
- m_ipv4ScrollArea->setWidgetResizable(true);
-
- m_ipv6ScrollArea = new QScrollArea(centerWidget);
- m_ipv6ScrollArea->setFixedWidth(SCRO_WIDTH);
- m_ipv6ScrollArea->setFrameShape(QFrame::NoFrame);
- m_ipv6ScrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
- m_ipv6ScrollArea->setWidget(ipv6Page);
- m_ipv6ScrollArea->setWidgetResizable(true);
-
QPalette pal = m_secuPageScrollArea->palette();
- pal.setBrush(QPalette::Window, Qt::transparent);
+ pal.setBrush(QPalette::Base, QColor(0,0,0,0));
m_secuPageScrollArea->setPalette(pal);
- m_ipv4ScrollArea->setPalette(pal);
- m_ipv6ScrollArea->setPalette(pal);
+
+ detailPage->setFixedWidth(SCRO_WIDTH);
+ ipv4Page->setFixedWidth(SCRO_WIDTH);
+ ipv6Page->setFixedWidth(SCRO_WIDTH);
+ createNetPage->setFixedWidth(SCRO_WIDTH);
+ configPage->setFixedWidth(SCRO_WIDTH);
stackWidget = new QStackedWidget(centerWidget);
stackWidget->addWidget(detailPage);
- stackWidget->addWidget(m_ipv4ScrollArea);
- stackWidget->addWidget(m_ipv6ScrollArea);
+ stackWidget->addWidget(ipv4Page);
+ stackWidget->addWidget(ipv6Page);
stackWidget->addWidget(m_secuPageScrollArea);
stackWidget->addWidget(configPage);
stackWidget->addWidget(createNetPage);
+ mainLayout->addWidget(centerWidget);
+ mainLayout->addWidget(bottomWidget);
+
+ bottomWidget->setMinimumHeight(PAGE_MIN_HEIGHT);
+
+ pageFrame = new QFrame(this);
+ QHBoxLayout *pageLayout = new QHBoxLayout(pageFrame);
+// pageLayout->setSpacing(PAGE_LAYOUT_SPACING);
+
// TabBar
+ onPaletteChanged();
+ m_networkMode = NetworkModeType(NetworkModeConfig::getInstance()->getNetworkModeConfig(m_uuid));
m_netTabBar = new NetTabBar(this);
m_netTabBar->addTab(tr("Detail")); //详情
m_netTabBar->addTab(tr("IPv4"));//Ipv4
m_netTabBar->addTab(tr("IPv6"));//Ipv6
if (isWlan) {
m_netTabBar->addTab(tr("Security"));//安全
- if (isActive) {
+ if (isActive && m_networkMode != DBUS_INVAILD && m_networkMode != NO_CONFIG) {
m_netTabBar->addTab(tr("Config")); //配置
m_netTabBar->setFixedWidth(WLAN_TAB_WIDTH + TAB_WIDTH);
} else {
m_netTabBar->setFixedWidth(WLAN_TAB_WIDTH);
}
} else {
- if (isActive) {
+ if (isActive && m_networkMode != DBUS_INVAILD && m_networkMode != NO_CONFIG) {
m_netTabBar->addTab(tr("Config")); //配置
m_netTabBar->setFixedWidth(LAN_TAB_WIDTH + TAB_WIDTH);
} else {
@@ -391,26 +351,27 @@ void NetDetail::initUI()
}
}
+ pageLayout->addWidget(m_netTabBar, Qt::AlignCenter);
+ pageLayout->addSpacing(24);
+
// TabBar关联选项卡页面
connect(m_netTabBar, SIGNAL(currentChanged(int)), this, SLOT(currentRowChangeSlot(int)));
setNetTabToolTip();
confimBtn = new QPushButton(this);
confimBtn->setText(tr("Confirm"));
+
cancelBtn = new QPushButton(this);
cancelBtn->setText(tr("Cancel"));
- forgetBtn = new QPushButton(this);
- QHBoxLayout *pageLayout = new QHBoxLayout(pageFrame);
- pageLayout->setContentsMargins(0, 0, 0, 0);
- pageLayout->addWidget(m_netTabBar, Qt::AlignCenter);
+ forgetBtn = new QPushButton(this);
QVBoxLayout *centerlayout = new QVBoxLayout(centerWidget);
centerlayout->setContentsMargins(CENTER_LAYOUT_MARGINS); // 右边距为0,为安全页滚动区域留出空间
+ centerlayout->addWidget(pageFrame);
+ centerlayout->addSpacing(4);
centerlayout->addWidget(stackWidget);
-// centerWidget->setStyleSheet("QWidget{border:1px solid rgba(255,0,0,1);}");//测试用, 画出边界线
-
QHBoxLayout *bottomLayout = new QHBoxLayout(bottomWidget);
bottomLayout->setContentsMargins(BOTTOM_LAYOUT_MARGINS);
bottomLayout->setSpacing(BOTTOM_LAYOUT_SPACING);
@@ -418,14 +379,11 @@ void NetDetail::initUI()
bottomLayout->addStretch();
bottomLayout->addWidget(cancelBtn);
bottomLayout->addWidget(confimBtn);
- bottomWidget->setMinimumHeight(PAGE_MIN_HEIGHT);
-
- mainLayout->addWidget(pageFrame);
- mainLayout->addWidget(centerWidget);
- mainLayout->addWidget(bottomWidget);
+// QPalette pal(this->palette());
+// pal.setColor(QPalette::Background, qApp->palette().base().color());
this->setAutoFillBackground(true);
- onPaletteChanged();
+// this->setPalette(pal);
}
void NetDetail::loadPage()
@@ -434,13 +392,12 @@ void NetDetail::loadPage()
if (m_isCreateNet && !isWlan) {
pageFrame->hide();
stackWidget->setCurrentIndex(CREATE_NET_PAGE_NUM);
- this->setWindowTitle(tr("Add Lan Connect"));
- setDetailPageShowed(true);
+ this->setWindowTitle(tr("Add LAN Connect"));
} else {
stackWidget->setCurrentIndex(DETAIL_PAGE_NUM);
this->setWindowTitle(m_name);
if (isWlan && m_name.isEmpty()) {
- this->setWindowTitle(tr("connect hiddin wlan"));
+ this->setWindowTitle(tr("Connect Hidden WLAN"));
}
}
}
@@ -489,6 +446,13 @@ void NetDetail::initComponent()
setConfirmEnable();
});
+ connect(securityPage, &SecurityPage::secuTypeChanged, this, [=]() {
+ setSecuPageHeight();
+ });
+ connect(securityPage, &SecurityPage::eapTypeChanged, this, [=]() {
+ setSecuPageHeight();
+ });
+
const QByteArray id(THEME_SCHAME);
if(QGSettings::isSchemaInstalled(id)){
QGSettings * fontSetting = new QGSettings(id, QByteArray(), this);
@@ -527,9 +491,8 @@ 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->setMulDns(m_info.ipv4DnsList);
+ ipv4Page->setIpv4FirDns(m_info.strIPV4FirDns);
+ ipv4Page->setIpv4SecDns(m_info.strIPV4SecDns);
ipv4Page->setGateWay(m_info.strIPV4GateWay);
} else {
ipv4Page->setIpv4Config(m_info.ipv4ConfigType);
@@ -540,9 +503,8 @@ 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->setMulDns(m_info.ipv6DnsList);
+ ipv6Page->setIpv6FirDns(m_info.strIPV6FirDns);
+ ipv6Page->setIpv6SecDns(m_info.strIPV6SecDns);
ipv6Page->setGateWay(m_info.strIPV6GateWay);
} else {
ipv6Page->setIpv6Config(m_info.ipv6ConfigType);
@@ -564,8 +526,8 @@ void NetDetail::pagePadding(QString netName, bool isWlan)
}
//配置页面
- if (isActive) {
- configPage->setConfigState(NetworkModeConfig::getInstance()->getNetworkModeConfig(m_uuid));
+ if (isActive && m_networkMode != DBUS_INVAILD && m_networkMode != NO_CONFIG) {
+ configPage->setConfigState(m_networkMode);
}
}
@@ -689,16 +651,22 @@ void NetDetail::getStaticIpInfo(ConInfo &conInfo, bool bActived)
kyConnectResourse->getConnectionSetting(m_uuid,connetSetting);
connetSetting.dumpInfo();
-// conInfo.ipv4ConfigType = connetSetting.m_ipv4ConfigIpType;
+ conInfo.ipv4ConfigType = connetSetting.m_ipv4ConfigIpType;
conInfo.ipv6ConfigType = connetSetting.m_ipv6ConfigIpType;
conInfo.isAutoConnect = connetSetting.m_isAutoConnect;
- //openkylin从第三方库读取有问题 改为ipv4信息直接通过dbus获取
- KyConnectItem* item = kyConnectResourse->getConnectionItemByUuidWithoutActivateChecking(m_uuid);
- if (item == nullptr) {
- conInfo.ipv4ConfigType = CONFIG_IP_DHCP;
- } else {
- getIpv4Info(item->m_connectPath, conInfo);
+ if (connetSetting.m_ipv4ConfigIpType == CONFIG_IP_MANUAL) {
+ if (connetSetting.m_ipv4Address.size() > 0) {
+ conInfo.strIPV4Address = connetSetting.m_ipv4Address.at(0).ip().toString();
+ conInfo.strIPV4NetMask = connetSetting.m_ipv4Address.at(0).netmask().toString();
+ conInfo.strIPV4GateWay = connetSetting.m_ipv4Address.at(0).gateway().toString();
+ }
+ if (connetSetting.m_ipv4Dns.size() == 1) {
+ conInfo.strIPV4FirDns = connetSetting.m_ipv4Dns.at(0).toString();
+ } else if (connetSetting.m_ipv4Dns.size() > 1) {
+ conInfo.strIPV4FirDns = connetSetting.m_ipv4Dns.at(0).toString();
+ conInfo.strIPV4SecDns = connetSetting.m_ipv4Dns.at(1).toString();
+ }
}
if (connetSetting.m_ipv6ConfigIpType == CONFIG_IP_MANUAL) {
@@ -707,29 +675,19 @@ void NetDetail::getStaticIpInfo(ConInfo &conInfo, bool bActived)
conInfo.iIPV6Prefix = ipv6Page->getPerfixLength(connetSetting.m_ipv6Address.at(0).netmask().toString());
conInfo.strIPV6GateWay = connetSetting.m_ipv6Address.at(0).gateway().toString();
}
-#if 0
+
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();
}
-#endif
-
- 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;
- QString dns(" ");
- for (int i = 0; i < conInfo.ipv4DnsList.size(); ++i) {
- dns.append(conInfo.ipv4DnsList.at(i).toString());
- if (i != conInfo.ipv4DnsList.size()-1) {
- dns.append(" ");
- }
- }
- conInfo.strDynamicIpv4Dns = dns.isEmpty() ? tr("Auto") : dns;
+ conInfo.strDynamicIpv4Dns = conInfo.strIPV4FirDns.isEmpty() ? tr("Auto") : conInfo.strIPV4FirDns;
}
}
@@ -769,6 +727,22 @@ void NetDetail::initSecuData()
}
}
+void NetDetail::setSecuPageHeight()
+{
+ KySecuType secuType;
+ KyEapMethodType eapType;
+ securityPage->getSecuType(secuType, eapType);
+ if (secuType == WPA_AND_WPA2_ENTERPRISE) {
+ if (eapType == TLS) {
+ securityPage->setFixedSize(SCRO_WIDTH, TLS_SCRO_HEIGHT);
+ } else {
+ securityPage->setFixedSize(SCRO_WIDTH, PEAP_SCRO_HEIGHT);
+ }
+ } else {
+ securityPage->setFixedSize(SCRO_WIDTH, PEAP_SCRO_HEIGHT);
+ }
+}
+
void NetDetail::initTlsInfo(ConInfo &conInfo)
{
m_resource->getEnterPriseInfoTls(m_uuid, conInfo.tlsInfo);
@@ -1087,7 +1061,7 @@ bool NetDetail::updateConnect()
}
}
- if (configPage != nullptr) {
+ if (m_networkMode != DBUS_INVAILD && m_networkMode != NO_CONFIG) {
int configType = NetworkModeConfig::getInstance()->getNetworkModeConfig(m_uuid);
bool configPageChange = configPage->checkIsChanged(configType);
int currentConfigType = configPage->getConfigState();
@@ -1144,11 +1118,6 @@ bool NetDetail::eventFilter(QObject *w, QEvent *event)
return QWidget::eventFilter(w, event);
}
-void NetDetail::setDetailPageShowed(bool state)
-{
- m_hasDetailPageShowed = state;
-}
-
void NetDetail::setNetTabToolTip()
{
int tabCount = m_netTabBar->count();
@@ -1166,26 +1135,7 @@ void NetDetail::setNetTabToolTip()
NetTabBar::NetTabBar(QWidget *parent)
:KTabBar(KTabBarStyle::SegmentDark, parent)
{
- //模式切换
- QDBusConnection::sessionBus().connect(QString("com.kylin.statusmanager.interface"),
- QString("/"),
- QString("com.kylin.statusmanager.interface"),
- QString("mode_change_signal"), this, SLOT(onModeChanged(bool)));
- //模式获取
- QDBusInterface interface(QString("com.kylin.statusmanager.interface"),
- QString("/"),
- QString("com.kylin.statusmanager.interface"),
- QDBusConnection::sessionBus());
- if(!interface.isValid()) {
- this->setFixedHeight(TAB_HEIGHT);
- return;
- }
- QDBusReply reply = interface.call("get_current_tabletmode");
- if (!reply.isValid()) {
- this->setFixedHeight(TAB_HEIGHT);
- return;
- }
- onModeChanged(reply.value());
+
}
NetTabBar::~NetTabBar()
@@ -1195,27 +1145,15 @@ NetTabBar::~NetTabBar()
QSize NetTabBar::sizeHint() const
{
- QSize size = KTabBar::sizeHint();
- size.setWidth(TAB_WIDTH);
- return size;
+ return QSize(TAB_WIDTH, TAB_HEIGHT);
}
QSize NetTabBar::minimumTabSizeHint(int index) const
{
Q_UNUSED(index)
- QSize size = KTabBar::minimumTabSizeHint(index);
- size.setWidth(TAB_WIDTH);
- return size;
+ return QSize(TAB_WIDTH, TAB_HEIGHT);
}
-void NetTabBar::onModeChanged(bool mode)
-{
- if (mode) {
- this->setFixedHeight(TAB_HEIGHT_TABLET); // 平板模式
- } else {
- this->setFixedHeight(TAB_HEIGHT); // PC模式
- }
-}
ThreadObject::ThreadObject(QString deviceName, QObject *parent)
:m_devName(deviceName), QObject(parent)
@@ -1242,6 +1180,24 @@ void ThreadObject::checkIpv4ConflictThread(const QString &ipv4Address)
KyIpv4Arping* ipv4Arping = new KyIpv4Arping(m_devName, ipv4Address);
if (ipv4Arping->ipv4ConflictCheck() >= 0) {
isConflict = ipv4Arping->ipv4IsConflict();
+ if (isConflict) {
+ QString mac = ipv4Arping->getMacAddress();
+ qDebug() << "conflict mac" << mac;
+ KyNetworkDeviceResourse resource;
+ QStringList devList,devList1,devList2;
+ resource.getNetworkDeviceList(NetworkManager::Device::Type::Ethernet, devList1);
+ resource.getNetworkDeviceList(NetworkManager::Device::Type::Wifi, devList2);
+ devList << devList1 << devList2;
+ for(int i = 0; i < devList.size(); ++i){
+ QString hardAddress;
+ int band;
+ resource.getHardwareInfo(devList.at(i), hardAddress, band);
+ if (hardAddress == mac) {
+ qDebug() << "conflict local card" << devList.at(i);
+ isConflict = false;
+ }
+ }
+ }
} else {
qWarning() << "checkIpv4Conflict internal error";
}
@@ -1258,7 +1214,6 @@ void ThreadObject::checkIpv6ConflictThread(const QString &ipv6Address)
}
bool isConflict = false;
KyIpv6Arping* ipv6rping = new KyIpv6Arping(m_devName, ipv6Address);
-
if (ipv6rping->ipv6ConflictCheck() >= 0) {
isConflict = ipv6rping->ipv6IsConflict();
} else {
@@ -1269,88 +1224,3 @@ void ThreadObject::checkIpv6ConflictThread(const QString &ipv6Address)
ipv6rping = nullptr;
Q_EMIT ipv6IsConflict(isConflict);
}
-
-void NetDetail::getIpv4Info(QString objPath, ConInfo &conInfo)
-{
- QDBusInterface m_interface("org.freedesktop.NetworkManager",
- objPath,
- "org.freedesktop.NetworkManager.Settings.Connection",
- QDBusConnection::systemBus());
- QDBusMessage result = m_interface.call("GetSettings");
-
- if (result.arguments().isEmpty()) { return; }
- const QDBusArgument &dbusArg1st = result.arguments().at( 0 ).value();
- QMap> map;
- dbusArg1st >> map;
-
- for (QString key : map.keys() ) {
- QMap innerMap = map.value(key);
- if (key == "ipv4") {
- for (QString inner_key : innerMap.keys()) {
- if (inner_key == "address-data") {
- //ipv4地址 ipv4子网掩码
- const QDBusArgument &dbusArg2nd = innerMap.value(inner_key).value();
- QVector> addressVector;
-
- dbusArg2nd.beginArray();
-
- while (!dbusArg2nd.atEnd()) {
- QMap tempMap;
- dbusArg2nd >> tempMap;
- addressVector.append(tempMap);
- }
- dbusArg2nd.endArray();
- if (addressVector.size() >= 1) {
- conInfo.strIPV4Address = addressVector.at(0).value("address").toString();
- conInfo.strIPV4NetMask = ipv4Page->getNetMaskText(addressVector.at(0).value("prefix").toString());
- }
- } else if (inner_key == "method") {
- //ipv4 method
- if (innerMap.value(inner_key).toString() == "auto")
- conInfo.ipv4ConfigType = CONFIG_IP_DHCP;
- else {
- conInfo.ipv4ConfigType = CONFIG_IP_MANUAL;
- }
- } else if (inner_key == "dns") {
- //dns
- const QDBusArgument &dbusArg2nd = innerMap.value(inner_key).value();
- QList addressVector;
-
- dbusArg2nd.beginArray();
- while (!dbusArg2nd.atEnd()) {
- uint tempMap;
- dbusArg2nd >> tempMap;
- addressVector.append(tempMap);
- }
- dbusArg2nd.endArray();
- for (int i = 0; i < addressVector.size(); ++i) {
- QString dns(inet_ntoa(*(struct in_addr *)&addressVector.at(i)));
- conInfo.ipv4DnsList << QHostAddress(dns);
- }
-
- } else if (inner_key == "gateway") {
- //gateway
- conInfo.strIPV4GateWay = innerMap.value(inner_key).toString();
- }
- }
- }
- // if (key == "ipv6") {
- // for (QString inner_key : innerMap.keys()) {
- // if (inner_key == "address-data"){
- // const QDBusArgument &dbusArg2nd = innerMap.value(inner_key).value();
- // QMap m_map;
-
- // dbusArg2nd.beginArray();
- // while (!dbusArg2nd.atEnd()) {
- // dbusArg2nd >> m_map;// append map to a vector here if you want to keep it
- // }
- // dbusArg2nd.endArray();
-
- // dbusWifiIpv6 = m_map.value("address").toString();
- // } else if (inner_key == "method") {
- // dbusWifiIpv6Method = innerMap.value(inner_key).toString();
- // }
- // }
- // }
- }
-}
diff --git a/src/frontend/netdetails/netdetail.h b/src/frontend/netdetails/netdetail.h
index 6e6b2d32..b7db854b 100644
--- a/src/frontend/netdetails/netdetail.h
+++ b/src/frontend/netdetails/netdetail.h
@@ -50,13 +50,12 @@
#include "tab-pages/tabpage.h"
#include "kwidget.h"
#include "ktabbar.h"
+#include "networkmodeconfig.h"
-#include
using namespace kdk;
#define TAB_WIDTH 60
#define TAB_HEIGHT 36
-#define TAB_HEIGHT_TABLET 48
class NetTabBar : public KTabBar
{
@@ -64,15 +63,10 @@ class NetTabBar : public KTabBar
public:
explicit NetTabBar(QWidget *parent = nullptr);
~NetTabBar();
-protected:
+
QSize sizeHint() const;
QSize minimumTabSizeHint(int index) const;
-
-private Q_SLOTS:
- void onModeChanged(bool mode);
-
};
-
class ThreadObject : public QObject
{
Q_OBJECT
@@ -105,8 +99,6 @@ public:
void closeEvent(QCloseEvent *event);
bool eventFilter(QObject *w, QEvent *event);
- void setDetailPageShowed(bool state);
-
private:
void initUI();
void centerToScreen();
@@ -115,6 +107,7 @@ private:
void loadPage();
void pagePadding(QString netName, bool isWlan);
void initSecuData();
+ void setSecuPageHeight();
void initTlsInfo(ConInfo &conInfo);
void initPeapInfo(ConInfo &conInfo);
@@ -147,7 +140,6 @@ private:
void startObjectThread();
void setNetTabToolTip();
- void getIpv4Info(QString objPath, ConInfo &conInfo);
private:
KyNetworkDeviceResourse *m_netDeviceResource = nullptr;
KyConnectOperation* m_connectOperation = nullptr;
@@ -167,8 +159,6 @@ private:
QWidget * centerWidget;
QWidget * bottomWidget;
QScrollArea * m_secuPageScrollArea;
- QScrollArea * m_ipv4ScrollArea;
- QScrollArea * m_ipv6ScrollArea;
QPushButton * cancelBtn;
QPushButton * forgetBtn;
@@ -192,11 +182,12 @@ private:
bool isIpv6Ok;
bool isSecuOk;
bool isConfirmBtnEnable;
- bool m_hasDetailPageShowed = false;
+
ConInfo m_info;
ThreadObject *m_object;
QThread *m_objectThread;
+ NetworkModeType m_networkMode = DBUS_INVAILD;
private Q_SLOTS:
void on_btnConfirm_clicked();
@@ -207,7 +198,7 @@ protected Q_SLOTS:
void currentRowChangeSlot(int row);
Q_SIGNALS:
- void detailPageClose(bool on);
+ void detailPageClose(QString, QString, QString);
void createPageClose(QString);
void currentChanged(int);
void checkCurrentIpv4Conflict(const QString &address);
diff --git a/src/frontend/netdetails/netdetails.pri b/src/frontend/netdetails/netdetails.pri
index f06fe245..75657d5d 100644
--- a/src/frontend/netdetails/netdetails.pri
+++ b/src/frontend/netdetails/netdetails.pri
@@ -10,7 +10,6 @@ HEADERS += \
$$PWD/ipv4page.h \
$$PWD/ipv6page.h \
$$PWD/joinhiddenwifipage.h \
- $$PWD/multiplednswidget.h \
$$PWD/netdetail.h \
$$PWD/securitypage.h
@@ -23,6 +22,5 @@ SOURCES += \
$$PWD/ipv4page.cpp \
$$PWD/ipv6page.cpp \
$$PWD/joinhiddenwifipage.cpp \
- $$PWD/multiplednswidget.cpp \
$$PWD/netdetail.cpp \
$$PWD/securitypage.cpp
diff --git a/src/frontend/netdetails/securitypage.cpp b/src/frontend/netdetails/securitypage.cpp
index ddcf1d13..f4968ec2 100644
--- a/src/frontend/netdetails/securitypage.cpp
+++ b/src/frontend/netdetails/securitypage.cpp
@@ -25,7 +25,7 @@
#define DETAIL_MIN_LABEL_WIDTH 80
#define DETAIL_MIN_EDIT_WIDTH 390
#define MIN_LABEL_WIDTH 146
-#define MIN_EDIT_WIDTH 286
+#define MIN_EDIT_WIDTH 278
SecurityPage::SecurityPage(bool isNetDetailPage, QWidget *parent) : isDetailPage(isNetDetailPage), QFrame(parent)
{
@@ -223,7 +223,7 @@ void SecurityPage::initUI()
//PEAP TTLS共有
eapMethodLabel->setLabelText(tr("Ineer authentication"));
- userNameLabel->setText(tr("Usename"));
+ userNameLabel->setText(tr("Username"));
userPwdLabel->setText(tr("Password"));
userPwdFlagLabel->setText(tr("Ask pwd each query"));
userNameEdit->setPlaceholderText(tr("Required"));
@@ -467,6 +467,12 @@ void SecurityPage::getSecuType(KySecuType &secuType, KyEapMethodType &enterprise
enterpriseType = (KyEapMethodType)eapTypeCombox->currentData().toInt();
}
+bool SecurityPage::getAutoConnectState()
+{
+ bool state = m_rememberCheckBox->isChecked();
+ return state;
+}
+
bool SecurityPage::checkIsChanged(const ConInfo info)
{
if (info.secType != secuTypeCombox->currentData().toInt()) {
diff --git a/src/frontend/netdetails/securitypage.h b/src/frontend/netdetails/securitypage.h
index 294880e9..0bc2b84e 100644
--- a/src/frontend/netdetails/securitypage.h
+++ b/src/frontend/netdetails/securitypage.h
@@ -28,7 +28,7 @@
#include
#include "coninfo.h"
-#include "detailwidget.h"
+#include "kylable.h"
#include "kwidget.h"
#include "kpasswordedit.h"
@@ -54,6 +54,7 @@ public:
void updateTtlsChange(KyEapMethodTtlsInfo &info);
void getSecuType(KySecuType &secuType, KyEapMethodType &enterpriseType);
+ bool getAutoConnectState();
private:
bool isDetailPage;
diff --git a/src/frontend/networkmode/firewalldialog.cpp b/src/frontend/networkmode/firewalldialog.cpp
index 4f02c024..749d4efb 100644
--- a/src/frontend/networkmode/firewalldialog.cpp
+++ b/src/frontend/networkmode/firewalldialog.cpp
@@ -19,6 +19,10 @@
*/
#include "firewalldialog.h"
+#include
+
+#define THEME_SCHAME "org.ukui.style"
+#define COLOR_THEME "styleName"
#define ICON_SIZE 16,16
FirewallDialog::FirewallDialog(QWidget *parent): KDialog(parent)
@@ -28,6 +32,7 @@ FirewallDialog::FirewallDialog(QWidget *parent): KDialog(parent)
this->setFixedSize(480, 204);
setAttribute(Qt::WA_DeleteOnClose);
// centerToScreen();
+ connect(qApp, &QApplication::paletteChanged, this, &FirewallDialog::onPaletteChanged);
}
FirewallDialog::~FirewallDialog()
@@ -38,29 +43,33 @@ FirewallDialog::~FirewallDialog()
void FirewallDialog::initUI()
{
m_iconLabel = new QLabel(this);
- m_contentLabel = new QLabel(this);
- m_suggestLabel = new QLabel(this);
- m_YesBtn = new QPushButton(this);
- m_NoBtn = new QPushButton(this);
+ m_contentLabel = new FixLabel(this);
+ m_suggestLabel = new FixLabel(this);
+ m_PublicBtn = new QPushButton(this);
+ m_PrivateBtn = new QPushButton(this);
m_dialogLayout = new QVBoxLayout(this);
+ m_contentLabel->setFixedWidth(405);
+ m_suggestLabel->setFixedWidth(405);
+
QWidget *contentWidget = new QWidget(this);
QGridLayout *contentLayout = new QGridLayout(contentWidget);
+ contentLayout->setHorizontalSpacing(0);
contentLayout->setContentsMargins(0, 0, 0, 0);
- contentLayout->addWidget(m_iconLabel, 0, 0, Qt::AlignVCenter);
+ contentLayout->addWidget(m_iconLabel, 0, 0);
contentLayout->addWidget(m_contentLabel, 0, 1);
contentLayout->addWidget(m_suggestLabel, 1, 1);
- m_iconLabel->setFixedWidth(16);
+ m_iconLabel->setFixedWidth(24);
QWidget *btnWidget = new QWidget(this);
QHBoxLayout *btnLayout = new QHBoxLayout(btnWidget);
btnLayout->setContentsMargins(0, 0, 0, 0);
btnLayout->setSpacing(16);
btnLayout->addStretch();
- btnLayout->addWidget(m_YesBtn);
- btnLayout->addWidget(m_NoBtn);
+ btnLayout->addWidget(m_PublicBtn);
+ btnLayout->addWidget(m_PrivateBtn);
- m_dialogLayout->setContentsMargins(24, 16, 24, 24);
+ m_dialogLayout->setContentsMargins(22, 16, 22, 24);
m_dialogLayout->setSpacing(0);
m_dialogLayout->addWidget(contentWidget);
m_dialogLayout->addStretch();
@@ -73,20 +82,19 @@ void FirewallDialog::initUI()
font.setWeight(57);
m_contentLabel->setFont(font);
//是否允许此网络上的其他设备发现这台电脑?
- m_contentLabel->setText(tr("Allow other devices on this network to discover this computer?"));
- m_contentLabel->setWordWrap(true);
+ m_contentLabel->setLabelText(tr("Allow other devices on this network to discover this computer?"));
//不建议在公共网络上开启此功能
- m_suggestLabel->setText(tr("It is not recommended to enable this feature on public networks"));
- m_suggestLabel->setWordWrap(true);
+ m_suggestLabel->setLabelText(tr("It is not recommended to enable this feature on public networks"));
- m_YesBtn->setText(tr("Not allowed (recommended)"));
- m_NoBtn->setText(tr("Allowed"));
+ m_PublicBtn->setText(tr("Not allowed (recommended)"));
+ m_PrivateBtn->setText(tr("Allowed"));
this->closeButton();
this->mainWidget()->setLayout(m_dialogLayout);
+ onPaletteChanged();
- connect(m_YesBtn, &QPushButton::clicked, this, &FirewallDialog::setPublicNetMode);
- connect(m_NoBtn, &QPushButton::clicked, this, &FirewallDialog::setPrivateNetMode);
+ connect(m_PublicBtn, &QPushButton::clicked, this, &FirewallDialog::setPublicNetMode);
+ connect(m_PrivateBtn, &QPushButton::clicked, this, &FirewallDialog::setPrivateNetMode);
}
void FirewallDialog::centerToScreen()
@@ -99,3 +107,24 @@ void FirewallDialog::centerToScreen()
int y = this->height();
this->move(desk_x / 2 - x / 2 + desk_rect.left(), desk_y / 2 - y / 2 + desk_rect.top());
}
+
+void FirewallDialog::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);
+
+ if (styleGsettings != nullptr) {
+ delete styleGsettings;
+ styleGsettings = nullptr;
+ }
+}
diff --git a/src/frontend/networkmode/firewalldialog.h b/src/frontend/networkmode/firewalldialog.h
index b832498f..4a16d315 100644
--- a/src/frontend/networkmode/firewalldialog.h
+++ b/src/frontend/networkmode/firewalldialog.h
@@ -26,8 +26,11 @@
#include
#include
#include
+
+#include "coninfo.h"
#include "kwidget.h"
#include "kdialog.h"
+#include "kylable.h"
using namespace kdk;
@@ -48,16 +51,20 @@ private:
QString m_uuid;
QLabel * m_iconLabel = nullptr;
- QLabel * m_contentLabel = nullptr;
- QLabel * m_suggestLabel = nullptr;
+ FixLabel * m_contentLabel = nullptr;
+ FixLabel * m_suggestLabel = nullptr;
QVBoxLayout *m_dialogLayout = nullptr;
- QPushButton *m_YesBtn = nullptr;
- QPushButton *m_NoBtn = nullptr;
+ QPushButton *m_PublicBtn = nullptr;
+ QPushButton *m_PrivateBtn = nullptr;
Q_SIGNALS:
void setPublicNetMode();
void setPrivateNetMode();
+private Q_SLOTS:
+ void onPaletteChanged();
+
+
public Q_SLOTS:
void closeMyself(QString uuid, int status) {
if (uuid == m_uuid && status == 4) {
diff --git a/src/frontend/networkmode/networkmodeconfig.cpp b/src/frontend/networkmode/networkmodeconfig.cpp
index fa19cc6c..d5ca8a57 100644
--- a/src/frontend/networkmode/networkmodeconfig.cpp
+++ b/src/frontend/networkmode/networkmodeconfig.cpp
@@ -18,8 +18,11 @@
*
*/
#include "networkmodeconfig.h"
+#include "firewalldialog.h"
#include
+#define LOG_FLAG "[NetworkMode]"
+
NetworkModeConfig *NetworkModeConfig::m_netModeInstance = nullptr;
NetworkModeConfig *NetworkModeConfig::getInstance()
@@ -37,17 +40,21 @@ NetworkModeConfig::NetworkModeConfig(QObject *parent) : QObject(parent)
"/firewall",
"com.ksc.defender.firewall",
QDBusConnection::systemBus());
+ if(!m_dbusInterface->isValid()) {
+ qWarning() << qPrintable(QDBusConnection::sessionBus().lastError().message());
+ }
}
int NetworkModeConfig::getNetworkModeConfig(QString uuid)
{
if (uuid.isEmpty()) {
qWarning()<< /*LOG_FLAG <<*/ "uuid is empty, so can not get network mode config";
- return -1;
+ return NO_CONFIG;
}
- if(!m_dbusInterface->isValid()) {
- qWarning ()<< "init com.ksc.defender dbus error";
+ if(m_dbusInterface == nullptr || !m_dbusInterface->isValid()) {
+ qWarning () << "com.ksc.defender dbus is invalid";
+ return DBUS_INVAILD;
}
QDBusReply reply = m_dbusInterface->call("get_networkModeConfig", uuid);
@@ -56,13 +63,14 @@ int NetworkModeConfig::getNetworkModeConfig(QString uuid)
} else {
qWarning() << "call get_networkModeConfig failed" << reply.error().message();
}
- return -1;
+ return NO_CONFIG;
}
void NetworkModeConfig::setNetworkModeConfig(QString uuid, QString cardName, QString ssid, int mode)
{
- if(!m_dbusInterface->isValid()) {
- qWarning ()<< "init com.ksc.defender dbus error";
+ if(m_dbusInterface == nullptr || !m_dbusInterface->isValid()) {
+ qWarning () << "com.ksc.defender dbus is invalid";
+ return;
}
QDBusReply reply = m_dbusInterface->call("set_networkModeConfig", uuid, cardName, ssid, mode);
@@ -75,8 +83,9 @@ void NetworkModeConfig::setNetworkModeConfig(QString uuid, QString cardName, QSt
int NetworkModeConfig::breakNetworkConnect(QString uuid, QString cardName, QString ssid)
{
- if(!m_dbusInterface->isValid()) {
- qWarning ()<< "init com.ksc.defender dbus error";
+ if(m_dbusInterface == nullptr || !m_dbusInterface->isValid()) {
+ qWarning () << "com.ksc.defender dbus is invalid";
+ return -1;
}
QDBusReply reply = m_dbusInterface->call("break_networkConnect", uuid, cardName, ssid);
@@ -88,3 +97,157 @@ int NetworkModeConfig::breakNetworkConnect(QString uuid, QString cardName, QStri
return -1;
}
}
+
+//安全中心-网络防火墙模式配置
+NetworkMode::NetworkMode(QObject *parent)
+ :QObject(parent)
+{
+ qRegisterMetaType("NetworkManager::Device::State");
+ qRegisterMetaType("NetworkManager::Device::StateChangeReason");
+ m_deviceResource = new KyNetworkDeviceResourse(this);
+ m_activatedConnectResource = new KyActiveConnectResourse(this);
+ m_connectResource = new KyConnectResourse(this);
+ m_wirelessNetResource = new KyWirelessNetResource(this);
+ connect(m_activatedConnectResource, &KyActiveConnectResourse::stateChangeReason,
+ this, &NetworkMode::onConnectionStateChanged);
+}
+
+void NetworkMode::initWiredNetworkMode()
+{
+ qDebug()<< LOG_FLAG << "initWiredNetworkMode";
+ QStringList wiredDevList;
+ m_deviceResource->getNetworkDeviceList(NetworkManager::Device::Type::Ethernet, wiredDevList);
+ if (wiredDevList.isEmpty()) {
+ return;
+ }
+
+ for (auto devName : wiredDevList) {
+ QList activedList;
+ m_activatedConnectResource->getActiveConnectionList(devName,
+ NetworkManager::ConnectionSettings::Wired,
+ activedList);
+ if (activedList.isEmpty()) {
+ continue;
+ }
+
+ int configType = NetworkModeConfig::getInstance()->getNetworkModeConfig(activedList.at(0)->m_connectUuid);
+ if (configType == DBUS_INVAILD) {
+ return;
+ } else if (configType == NO_CONFIG) {
+ //已连接网络无配置 默认公有配置
+ NetworkModeConfig::getInstance()->setNetworkModeConfig(activedList.at(0)->m_connectUuid, devName,
+ activedList.at(0)->m_connectName, KSC_FIREWALL_PUBLIC);
+ } else {
+ NetworkModeConfig::getInstance()->setNetworkModeConfig(activedList.at(0)->m_connectUuid, devName,
+ activedList.at(0)->m_connectName, configType);
+ }
+ }
+}
+
+void NetworkMode::initWirelessNetworkMode()
+{
+ qDebug()<< LOG_FLAG << "initWirelessNetworkMode";
+ QStringList wirelessDevList;
+ m_deviceResource->getNetworkDeviceList(NetworkManager::Device::Type::Wifi, wirelessDevList);
+ if (wirelessDevList.isEmpty()) {
+ return;
+ }
+
+ for (auto devName : wirelessDevList) {
+ KyWirelessNetItem wirelessNetItem;
+ bool ret = m_wirelessNetResource->getActiveWirelessNetItem(devName, wirelessNetItem);
+
+ if (ret == true) {
+ int configType = NetworkModeConfig::getInstance()->getNetworkModeConfig(wirelessNetItem.m_connectUuid);
+ if (configType == DBUS_INVAILD) {
+ return;
+ } else if (configType == NO_CONFIG) {
+ //已连接网络无配置 默认公有配置
+ NetworkModeConfig::getInstance()->setNetworkModeConfig(wirelessNetItem.m_connectUuid, devName,
+ wirelessNetItem.m_connName, KSC_FIREWALL_PUBLIC);
+ } else {
+ NetworkModeConfig::getInstance()->setNetworkModeConfig(wirelessNetItem.m_connectUuid, devName,
+ wirelessNetItem.m_connName, configType);
+ }
+ }
+ }
+}
+
+void NetworkMode::setFirstConnectNetworkMode(QString uuid, QString deviceName, QString ssid)
+{
+ NetworkModeConfig::getInstance()->setNetworkModeConfig(uuid, deviceName, ssid, KSC_FIREWALL_PUBLIC); //默认公有配置
+ FirewallDialog *fireWallDialog = new FirewallDialog();
+ fireWallDialog->setUuid(uuid);
+ fireWallDialog->setWindowTitle(ssid);
+
+ connect(fireWallDialog, &FirewallDialog::setPrivateNetMode, this, [=](){
+ fireWallDialog->hide();
+ NetworkModeConfig::getInstance()->setNetworkModeConfig(uuid, deviceName, ssid, KSC_FIREWALL_PRIVATE);
+ });
+
+ connect(fireWallDialog, &FirewallDialog::setPublicNetMode, this, [=](){
+ fireWallDialog->hide();
+ NetworkModeConfig::getInstance()->setNetworkModeConfig(uuid, deviceName, ssid, KSC_FIREWALL_PUBLIC);
+ });
+
+ connect(m_activatedConnectResource, &KyActiveConnectResourse::stateChangeReason, fireWallDialog, &FirewallDialog::closeMyself);
+
+ fireWallDialog->show();
+ fireWallDialog->centerToScreen();
+}
+
+void NetworkMode::onConnectionStateChanged(QString uuid,
+ NetworkManager::ActiveConnection::State state,
+ NetworkManager::ActiveConnection::Reason reason)
+{
+ if (state == NetworkManager::ActiveConnection::State::Activated) {
+ QString deviceName = "";
+ QString ssid = "";
+
+ int configType = NetworkModeConfig::getInstance()->getNetworkModeConfig(uuid);
+
+ //有线网络连接
+ if (m_connectResource->isWiredConnection(uuid)) {
+ KyConnectItem *p_newItem = nullptr;
+ p_newItem = m_activatedConnectResource->getActiveConnectionByUuid(uuid);
+ if (nullptr == p_newItem) {
+ //删除此网络
+ qDebug()<< LOG_FLAG << "delete wired connect:" << uuid << ", call break_networkConnect";
+ NetworkModeConfig::getInstance()->breakNetworkConnect(uuid, "", "");
+ return;
+ }
+
+ deviceName = p_newItem->m_ifaceName;
+ ssid = p_newItem->m_connectName;
+ if (configType == NO_CONFIG) {
+ //首次连接的网络
+ setFirstConnectNetworkMode(uuid, deviceName, ssid);
+ } else if (configType == KSC_FIREWALL_PUBLIC) {
+ NetworkModeConfig::getInstance()->setNetworkModeConfig(uuid, deviceName, ssid, KSC_FIREWALL_PUBLIC);
+ } else if (configType == KSC_FIREWALL_PRIVATE) {
+ NetworkModeConfig::getInstance()->setNetworkModeConfig(uuid, deviceName, ssid, KSC_FIREWALL_PRIVATE);
+ }
+ }
+ //无线网络连接
+ if (m_connectResource->isWirelessConnection(uuid)) {
+ m_wirelessNetResource->getSsidByUuid(uuid, ssid);
+ m_wirelessNetResource->getDeviceByUuid(uuid, deviceName);
+ if (ssid.isEmpty()) {
+ //忘记此网络
+ qDebug()<< LOG_FLAG << "forgrt wireless connect:" << uuid <<", call break_networkConnect";
+ NetworkModeConfig::getInstance()->breakNetworkConnect(uuid, "", "");
+ }
+
+ if (configType == NO_CONFIG) {
+ setFirstConnectNetworkMode(uuid, deviceName, ssid);
+ } else if (configType == KSC_FIREWALL_PUBLIC) {
+ NetworkModeConfig::getInstance()->setNetworkModeConfig(uuid, deviceName, ssid, KSC_FIREWALL_PUBLIC);
+ } else if (configType == KSC_FIREWALL_PRIVATE) {
+ NetworkModeConfig::getInstance()->setNetworkModeConfig(uuid, deviceName, ssid, KSC_FIREWALL_PRIVATE);
+ }
+ }
+
+ } else if (state == NetworkManager::ActiveConnection::State::Deactivated) {
+ NetworkModeConfig::getInstance()->breakNetworkConnect(uuid, "", "");
+ }
+}
diff --git a/src/frontend/networkmode/networkmodeconfig.h b/src/frontend/networkmode/networkmodeconfig.h
index e3ed69f2..c4af58ee 100644
--- a/src/frontend/networkmode/networkmodeconfig.h
+++ b/src/frontend/networkmode/networkmodeconfig.h
@@ -23,6 +23,16 @@
#include
#include
#include
+#include "kylinactiveconnectresource.h"
+#include "kylinconnectresource.h"
+#include "kywirelessnetresource.h"
+
+enum NetworkModeType {
+ DBUS_INVAILD = -2,
+ NO_CONFIG = -1,
+ KSC_FIREWALL_PUBLIC = 0,
+ KSC_FIREWALL_PRIVATE
+};
class NetworkModeConfig : public QObject
{
@@ -43,4 +53,27 @@ private:
QDBusInterface *m_dbusInterface = nullptr;
};
+
+class NetworkMode : public QObject
+{
+ Q_OBJECT
+public:
+ NetworkMode(QObject *parent = 0);
+ ~NetworkMode() = default;
+ void initWiredNetworkMode();
+ void initWirelessNetworkMode();
+
+private:
+ KyNetworkDeviceResourse *m_deviceResource = nullptr;
+ KyActiveConnectResourse *m_activatedConnectResource = nullptr;
+ KyConnectResourse * m_connectResource = nullptr;
+ KyWirelessNetResource *m_wirelessNetResource = nullptr;
+ void setFirstConnectNetworkMode(QString uuid, QString deviceName, QString ssid);
+
+private Q_SLOTS:
+ void onConnectionStateChanged(QString uuid,
+ NetworkManager::ActiveConnection::State state,
+ NetworkManager::ActiveConnection::Reason reason);
+};
+
#endif // NETWORKMODECONFIG_H
diff --git a/src/frontend/tab-pages/lanpage.cpp b/src/frontend/tab-pages/lanpage.cpp
index 39b4225a..0fbacef9 100644
--- a/src/frontend/tab-pages/lanpage.cpp
+++ b/src/frontend/tab-pages/lanpage.cpp
@@ -18,7 +18,8 @@
*
*/
#include "lanpage.h"
-#include "networkmodeconfig.h"
+#include "kwindowsystem.h"
+#include "kwindowsystem_export.h"
#include
#include
@@ -77,6 +78,7 @@ LanPage::LanPage(QWidget *parent) : TabPage(parent)
m_netSwitch->setChecked(!checked);
m_wiredConnectOperation->setWiredEnabled(checked);
});
+ m_lanPagePtrMap.clear();
}
LanPage::~LanPage()
@@ -138,28 +140,28 @@ void LanPage::initLanDeviceState()
void LanPage::initNetSwitch()
{
- bool wiredSwitch = true;
+ bool wiredGsetting = true;
bool wiredEnable = m_wiredConnectOperation->getWiredEnabled();
if (QGSettings::isSchemaInstalled(GSETTINGS_SCHEMA)) {
m_switchGsettings = new QGSettings(GSETTINGS_SCHEMA);
if (m_switchGsettings->keys().contains(WIRED_SWITCH)) {
- wiredSwitch = m_switchGsettings->get(WIRED_SWITCH).toBool();
+ wiredGsetting = m_switchGsettings->get(WIRED_SWITCH).toBool();
connect(m_switchGsettings, &QGSettings::changed, this, &LanPage::onSwithGsettingsChanged);
+ if (wiredEnable != wiredGsetting) {
+ wiredEnable = wiredGsetting;
+ m_wiredConnectOperation->setWiredEnabled(wiredGsetting);
+ }
}
} else {
qDebug()<<"[LanPage] org.ukui.kylin-nm.switch is not installed!";
}
- if (m_switchGsettings != nullptr
- &&wiredSwitch != wiredEnable) {
- m_switchGsettings->set(WIRED_SWITCH, wiredEnable);
- }
-
//从3.0升级上来 先读取老的配置文件来保证和升级前状态一致
- bool oldVersionState;
+ bool oldVersionState = true;
if (getOldVersionWiredSwitchState(oldVersionState)) {
if (wiredEnable != oldVersionState) {
+ wiredEnable = oldVersionState;
m_wiredConnectOperation->setWiredEnabled(oldVersionState);
}
}
@@ -342,22 +344,10 @@ void LanPage::constructActiveConnectionArea()
QListWidgetItem *p_listWidgetItem = addNewItem(p_activeConnectionItem, m_activatedLanListWidget);
m_activeConnectionMap.insert(p_activeConnectionItem->m_connectUuid, p_listWidgetItem);
- int configType = NetworkModeConfig::getInstance()->getNetworkModeConfig(p_activeConnectionItem->m_connectUuid);
- if (configType == -1) {
- NetworkModeConfig::getInstance()->setNetworkModeConfig(p_activeConnectionItem->m_connectUuid,
- m_currentDeviceName,
- p_activeConnectionItem->m_connectName,
- KSC_FIREWALL_PUBLIC);
- } else {
- NetworkModeConfig::getInstance()->setNetworkModeConfig(p_activeConnectionItem->m_connectUuid,
- m_currentDeviceName,
- p_activeConnectionItem->m_connectName,
- configType);
- }
-
delete p_activeConnectionItem;
p_activeConnectionItem = nullptr;
}
+ setNetSpeed->start(REFRESH_NETWORKSPEED_TIMER);
} else {
qDebug()<<"[LanPage] there is not active";
addEmptyConnectItem(m_activeConnectionMap, m_activatedLanListWidget);
@@ -452,6 +442,13 @@ void LanPage::onRemoveConnection(QString path) //删除时后端会
qDebug() << "[LanPage] Q_EMIT lanRemove because onRemoveConnection " << path;
Q_EMIT lanRemove(path);
+ if (m_lanPagePtrMap.contains(path)) {
+ if (m_lanPagePtrMap[path] != nullptr) {
+ delete m_lanPagePtrMap[path];
+ m_lanPagePtrMap[path] = nullptr;
+ }
+ }
+
if (removeConnectionItem(m_inactiveConnectionMap, m_inactivatedLanListWidget, path)) {
return;
} else {
@@ -459,7 +456,7 @@ void LanPage::onRemoveConnection(QString path) //删除时后端会
if (m_activeConnectionMap.count() <= 0) {
addEmptyConnectItem(m_activeConnectionMap, m_activatedLanListWidget);
}
-
+ setNetSpeed->stop();
return;
}
}
@@ -758,6 +755,12 @@ void LanPage::initUI()
m_inactivatedLanListWidget->setProperty("needTranslucent", true);
m_inactivatedAreaLayout->addWidget(m_inactivatedLanListWidget);
+ connect(m_inactivatedLanListWidget, &QListWidget::currentItemChanged, this, [=]() {
+ if (m_inactivatedLanListWidget->currentItem() != nullptr) {
+ m_inactivatedLanListWidget->currentItem()->setSelected(false);
+ }
+ });
+
QPalette pal = m_activatedLanListWidget->palette();
pal.setBrush(QPalette::Base, QColor(0,0,0,0)); //背景透明
m_activatedLanListWidget->setPalette(pal);
@@ -765,6 +768,10 @@ void LanPage::initUI()
m_settingsLabel->installEventFilter(this);
m_netSwitch->installEventFilter(this);
+ m_activatedLanListWidget->installEventFilter(this);
+ m_inactivatedLanListWidget->installEventFilter(this);
+
+ showRate();
}
QListWidgetItem *LanPage::insertNewItem(KyConnectItem *itemData, QListWidget *listWidget)
@@ -782,7 +789,7 @@ QListWidgetItem *LanPage::insertNewItem(KyConnectItem *itemData, QListWidget *li
}
QListWidgetItem *p_sortListWidgetItem = new QListWidgetItem();
- p_sortListWidgetItem->setFlags(p_sortListWidgetItem->flags() & (~Qt::ItemIsSelectable)); //设置不可被选中
+// p_sortListWidgetItem->setFlags(p_sortListWidgetItem->flags() & (~Qt::ItemIsSelectable)); //设置不可被选中
p_sortListWidgetItem->setSizeHint(QSize(listWidget->width(),ITEM_HEIGHT));
listWidget->insertItem(index, p_sortListWidgetItem);
@@ -790,14 +797,14 @@ QListWidgetItem *LanPage::insertNewItem(KyConnectItem *itemData, QListWidget *li
LanListItem *p_sortLanItem = nullptr;
p_sortLanItem = new LanListItem(itemData, m_currentDeviceName);
listWidget->setItemWidget(p_sortListWidgetItem, p_sortLanItem);
-
+ connect(p_sortLanItem, &LanListItem::detailShow, this, &LanPage::showDetailPage);
return p_sortListWidgetItem;
}
QListWidgetItem *LanPage::addNewItem(KyConnectItem *itemData, QListWidget *listWidget)
{
QListWidgetItem *p_listWidgetItem = new QListWidgetItem();
- p_listWidgetItem->setFlags(p_listWidgetItem->flags() & (~Qt::ItemIsSelectable));
+// p_listWidgetItem->setFlags(p_listWidgetItem->flags() & (~Qt::ItemIsSelectable));
p_listWidgetItem->setSizeHint(QSize(listWidget->width(), ITEM_HEIGHT));
listWidget->addItem(p_listWidgetItem);
LanListItem *p_lanItem = nullptr;
@@ -811,6 +818,7 @@ QListWidgetItem *LanPage::addNewItem(KyConnectItem *itemData, QListWidget *listW
}
listWidget->setItemWidget(p_listWidgetItem, p_lanItem);
+ connect(p_lanItem, &LanListItem::detailShow, this, &LanPage::showDetailPage);
return p_listWidgetItem;
}
@@ -921,7 +929,6 @@ void LanPage::onConnectionStateChange(QString uuid,
KyConnectItem *p_newItem = nullptr;
QString deviceName = "";
- QString ssid = "";
if (state == NetworkManager::ActiveConnection::State::Activated) {
p_newItem = m_activeResourse->getActiveConnectionByUuid(uuid);
@@ -929,41 +936,10 @@ void LanPage::onConnectionStateChange(QString uuid,
qWarning()<<"[LanPage] get active connection failed, connection uuid" << uuid;
return;
}
-
- deviceName = p_newItem->m_ifaceName;
- ssid = p_newItem->m_connectName;
-
- int configType = NetworkModeConfig::getInstance()->getNetworkModeConfig(uuid);
-
- if (configType == -1) {
- NetworkModeConfig::getInstance()->setNetworkModeConfig(uuid, deviceName, ssid, KSC_FIREWALL_PUBLIC); //默认公有配置
- FirewallDialog *fireWallDialog = new FirewallDialog();
- fireWallDialog->setUuid(uuid);
- fireWallDialog->setWindowTitle(ssid);
-
- connect(fireWallDialog, &FirewallDialog::setPrivateNetMode, this, [=](){
- fireWallDialog->hide();
- NetworkModeConfig::getInstance()->setNetworkModeConfig(uuid, deviceName, ssid, KSC_FIREWALL_PRIVATE);
- });
-
- connect(fireWallDialog, &FirewallDialog::setPublicNetMode, this, [=](){
- fireWallDialog->hide();
- NetworkModeConfig::getInstance()->setNetworkModeConfig(uuid, deviceName, ssid, KSC_FIREWALL_PUBLIC);
- });
-
- connect(m_activeResourse, &KyActiveConnectResourse::stateChangeReason, fireWallDialog, &FirewallDialog::closeMyself);
-
- fireWallDialog->show();
- fireWallDialog->centerToScreen();
-
- } else if (configType == KSC_FIREWALL_PUBLIC) {
- NetworkModeConfig::getInstance()->setNetworkModeConfig(uuid, deviceName, ssid, KSC_FIREWALL_PUBLIC);
- } else if (configType == KSC_FIREWALL_PRIVATE) {
- NetworkModeConfig::getInstance()->setNetworkModeConfig(uuid, deviceName, ssid, KSC_FIREWALL_PRIVATE);
- }
-
updateActivatedConnectionArea(p_newItem);
updateConnectionState(m_activeConnectionMap, m_activatedLanListWidget, uuid, (ConnectState)state);
+ deviceName = p_newItem->m_ifaceName;
+ setNetSpeed->start(REFRESH_NETWORKSPEED_TIMER);
} else if (state == NetworkManager::ActiveConnection::State::Deactivated) {
p_newItem = m_connectResourse->getConnectionItemByUuidWithoutActivateChecking(uuid);
qDebug() << "[LanPage] deactivated reason" << reason;
@@ -973,10 +949,9 @@ void LanPage::onConnectionStateChange(QString uuid,
}
deviceName = p_newItem->m_ifaceName;
- ssid = p_newItem->m_connectName;
updateConnectionArea(p_newItem);
updateConnectionState(m_inactiveConnectionMap, m_inactivatedLanListWidget, uuid, (ConnectState)state);
- NetworkModeConfig::getInstance()->breakNetworkConnect(uuid, deviceName, ssid);
+ setNetSpeed->stop();
} else if (state == NetworkManager::ActiveConnection::State::Activating) {
deviceName = getConnectionDevice(uuid);
if (deviceName == m_currentDeviceName) {
@@ -1204,20 +1179,25 @@ bool LanPage::eventFilter(QObject *watched, QEvent *event)
}
}
+ } else if (watched == m_activatedLanListWidget) {
+ //去掉无右键菜单显示时的选中效果
+ if (event->type() == QEvent::FocusIn) {
+ if (m_activatedLanListWidget->currentItem() != nullptr) {
+ m_activatedLanListWidget->currentItem()->setSelected(false);
+ }
+ }
+ } else if (watched == m_inactivatedLanListWidget) {
+ //去掉无右键菜单显示时的选中效果
+ if (event->type() == QEvent::FocusIn) {
+ if (m_inactivatedLanListWidget->currentItem() != nullptr) {
+ m_inactivatedLanListWidget->currentItem()->setSelected(false);
+ }
+ }
}
return QWidget::eventFilter(watched, event);
}
-void LanPage::deleteWired(const QString &connUuid)
-{
- qDebug() << "[LanPage] deleteWired" << connUuid;
- if (connUuid == nullptr) {
- return;
- }
- m_wiredConnectOperation->deleteWiredConnect(connUuid);
-}
-
void LanPage::onWiredEnabledChanged(bool enabled)
{
if (m_devList.isEmpty()) {
@@ -1270,9 +1250,38 @@ void LanPage::showDetailPage(QString devName, QString uuid)
return;
}
+ if (m_lanPagePtrMap.contains(p_item->m_connectPath)) {
+ if (m_lanPagePtrMap[p_item->m_connectPath] != nullptr) {
+ qDebug() << "[LanPage] ShowLanDetailPage" << uuid << "already create,just raise";
+ KWindowSystem::activateWindow(m_lanPagePtrMap[p_item->m_connectPath]->winId());
+ KWindowSystem::raiseWindow(m_lanPagePtrMap[p_item->m_connectPath]->winId());
+ return;
+ }
+ }
+
NetDetail *netDetail = new NetDetail(devName, p_item->m_connectName, uuid, isActive, false, false);
+ m_lanPagePtrMap.insert(p_item->m_connectPath, netDetail);
netDetail->show();
- netDetail->setDetailPageShowed(true);
+
+ connect(netDetail, &NetDetail::detailPageClose, [&](QString deviceName, QString lanName, QString lanUuid){
+ if (lanUuid.isEmpty()) {
+ return;
+ }
+ KyConnectItem *currentItem = nullptr;
+ if (m_connectResourse->isActivatedConnection(lanUuid)) {
+ currentItem = m_activeResourse->getActiveConnectionByUuid(lanUuid);
+ } else {
+ currentItem = m_connectResourse->getConnectionItemByUuid(lanUuid);
+ }
+ if (currentItem == nullptr) {
+ return;
+ }
+ if (m_lanPagePtrMap.contains(currentItem->m_connectPath)) {
+ m_lanPagePtrMap[currentItem->m_connectPath] = nullptr;
+ }
+ delete currentItem;
+ currentItem = nullptr;
+ });
delete p_item;
p_item = nullptr;
@@ -1287,3 +1296,13 @@ bool LanPage::lanIsConnected()
}
}
+void LanPage::showRate()
+{
+ //定时获取网速
+ setNetSpeed = new QTimer(this);
+ setNetSpeed->setTimerType(Qt::PreciseTimer);
+ connect(setNetSpeed, &QTimer::timeout, [&]() {
+ onSetNetSpeed(m_activatedLanListWidget, m_activeConnectionMap.contains(EMPTY_SSID), m_currentDeviceName);
+ });
+}
+
diff --git a/src/frontend/tab-pages/lanpage.h b/src/frontend/tab-pages/lanpage.h
index 5b6ecade..d8ed6eba 100644
--- a/src/frontend/tab-pages/lanpage.h
+++ b/src/frontend/tab-pages/lanpage.h
@@ -44,7 +44,6 @@ public:
//for dbus
void getWiredList(QMap > &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);
@@ -99,6 +98,7 @@ private:
QListWidget *lanListWidget, QString uuid);
void updateCurrentDevice(QString deviceName);
+ void showRate();
Q_SIGNALS:
void lanAdd(QString devName, QStringList info);
@@ -108,6 +108,8 @@ Q_SIGNALS:
void lanActiveConnectionStateChanged(QString interface, QString uuid, int status);
void lanConnectChanged(int state);
+ void showLanRate(QListWidget *widget, QMap &map, QString dev, bool isLan);
+
private Q_SLOTS:
void onConnectionStateChange(QString uuid, NetworkManager::ActiveConnection::State state,
NetworkManager::ActiveConnection::Reason reason);
@@ -150,6 +152,7 @@ private:
QStringList m_disableDeviceList;
QGSettings *m_switchGsettings = nullptr;
+ QMap m_lanPagePtrMap;
};
diff --git a/src/frontend/tab-pages/tabpage.cpp b/src/frontend/tab-pages/tabpage.cpp
index 342e8f67..03d4f92c 100644
--- a/src/frontend/tab-pages/tabpage.cpp
+++ b/src/frontend/tab-pages/tabpage.cpp
@@ -23,6 +23,12 @@
#include
#include
#include
+#include
+#include
+
+#include"listitem.h"
+
+#define LOG_FLAG "[tabPage]"
TabPage::TabPage(QWidget *parent) : QWidget(parent)
{
@@ -167,6 +173,141 @@ void TabPage::onPaletteChanged()
}
}
+int TabPage::getCurrentLoadRate(QString dev, long *save_rate, long *tx_rate)
+{
+ FILE * net_dev_file; //文件指针
+ char buffer[1024]; //文件中的内容暂存在字符缓冲区里
+ //size_t bytes_read; //实际读取的内容大小
+ char * match; //用以保存所匹配字符串及之后的内容
+ char * device;//将QString转为Char *
+ QByteArray ba = dev.toLatin1(); // must
+ device = ba.data();
+ int counter = 0;
+ //int i = 0;
+ char tmp_value[128];
+
+ if ((NULL == device) || (NULL == save_rate) || (NULL == tx_rate)) {
+ qDebug() << LOG_FLAG << "parameter pass error" ;
+ return -1;
+ }
+
+ if ((net_dev_file = fopen("/proc/net/dev", "r")) == NULL) {
+ //打开文件/pro/net/dev/,从中读取流量数据
+ qDebug() << LOG_FLAG << "error occurred when try to open file /proc/net/dev/";
+ return -1;
+ }
+ memset(buffer, 0, sizeof(buffer));
+
+ while (fgets(buffer, sizeof(buffer), net_dev_file) != NULL) {
+ match = strstr(buffer, device);
+
+ if (NULL == match) {
+ // qDebug()<<"No eth0 keyword to find!";
+ continue;
+ } else {
+ match = match + strlen(device) + strlen(":"); //地址偏移到冒号
+ sscanf(match, "%ld ", save_rate);
+ memset(tmp_value, 0, sizeof(tmp_value));
+ sscanf(match, "%s ", tmp_value);
+ match = match + strlen(tmp_value);
+ for (size_t i=0; iitem(0);
+ ListItem *p_item = (ListItem *)m_activatedNetListWidget->itemWidget(activeitem);
+ if (isEmpty) {
+ p_item->m_lbLoadUp->hide();
+ p_item->m_lbLoadDown->hide();
+ p_item->m_lbLoadDownImg->hide();
+ p_item->m_lbLoadUpImg->hide();
+ return;
+ }
+
+ if (this->isVisible()) {
+
+ if (getCurrentLoadRate(dev, &start_rcv_rates, &start_tx_rates) == -1) {
+ start_rcv_rates = end_rcv_rates;
+ return;
+ }
+
+ long int delta_rcv = (start_rcv_rates - end_rcv_rates) / 1024;
+ long int delta_tx = (start_tx_rates - end_tx_rates) / 1024;
+
+ //简易滤波
+ if (delta_rcv < 0 || delta_tx < 0) {
+ delta_rcv = 0;
+ delta_tx = 0;
+ }
+ else if (end_rcv_rates == 0 || end_tx_rates == 0){
+ delta_rcv = 0;
+ delta_tx = 0;
+ }
+
+ end_rcv_rates = start_rcv_rates;
+ end_tx_rates = start_tx_rates;
+
+ int rcv_num = delta_rcv;
+ int tx_num = delta_tx;
+
+ QString str_rcv = 0;
+ QString str_tx = 0;
+
+ if (rcv_num < 1024) {
+ str_rcv = QString::number(rcv_num) + "KB/s";
+ } else {
+ int remainder;
+ if (rcv_num % 1024 < 100) {
+ remainder = 0;
+ } else {
+ remainder = (rcv_num % 1024) / 100;
+ }
+ str_rcv = QString::number(rcv_num / 1024) + "." + QString::number(remainder) + "MB/s";
+ }
+
+ if (tx_num < 1024) {
+ str_tx = QString::number(tx_num) + "KB/s";
+ } else {
+ int remainder;
+ if (tx_num % 1024 < 100) {
+ remainder = 0;
+ } else {
+ remainder = (tx_num % 1024)/100;
+ }
+ str_tx = QString::number(tx_num / 1024) + "." + QString::number(remainder) + "MB/s";
+ }
+ p_item->m_lbLoadDown->setText(str_rcv);
+ p_item->m_lbLoadUp->setText(str_tx);
+ if (!p_item->m_hoverButton->isVisible()) {
+ p_item->m_lbLoadDown->show();
+ p_item->m_lbLoadUp->show();
+ p_item->m_lbLoadDownImg->show();
+ p_item->m_lbLoadUpImg->show();
+ }
+ }
+}
+
void TabPage::showDesktopNotify(const QString &message, QString soundName)
{
QDBusInterface iface("org.freedesktop.Notifications",
@@ -302,7 +443,7 @@ void getDeviceEnableState(int type, QMap &map)
kdr = nullptr;
}
-bool getOldVersionWiredSwitchState(bool state)
+bool getOldVersionWiredSwitchState(bool &state)
{
QSettings * m_settings = new QSettings(CONFIG_FILE_PATH, QSettings::IniFormat);
QVariant value = m_settings->value("lan_switch_opened");
diff --git a/src/frontend/tab-pages/tabpage.h b/src/frontend/tab-pages/tabpage.h
index 97a981df..1fc76eea 100644
--- a/src/frontend/tab-pages/tabpage.h
+++ b/src/frontend/tab-pages/tabpage.h
@@ -34,17 +34,15 @@
#include
#include
#include "kylinnetworkdeviceresource.h"
-#include "firewalldialog.h"
#include "kwidget.h"
#include "kswitchbutton.h"
//#include "kborderlessbutton.h"
-using namespace kdk;
+#define EMPTY_SSID "emptyssid"
-enum network_mode {
- KSC_FIREWALL_PUBLIC = 0,
- KSC_FIREWALL_PRIVATE
-};
+#define REFRESH_NETWORKSPEED_TIMER 1000
+
+using namespace kdk;
#define MAIN_LAYOUT_MARGINS 0,0,0,0
#define MAIN_LAYOUT_SPACING 0
@@ -81,7 +79,7 @@ bool checkDeviceExist(KyDeviceType deviceType, QString deviceName);
QString getDefaultDeviceName(KyDeviceType deviceType);
void setDefaultDevice(KyDeviceType deviceType, QString deviceName);
void getDeviceEnableState(int type, QMap &map);
-bool getOldVersionWiredSwitchState(bool state);
+bool getOldVersionWiredSwitchState(bool &state);
class TabPage : public QWidget
{
@@ -117,8 +115,10 @@ Q_SIGNALS:
protected:
void initUI();
+ int getCurrentLoadRate(QString dev, long *save_rate, long *tx_rate);
// virtual void initDevice() = 0;//初始化默认设备
virtual void initDeviceCombox() = 0;//初始化设备选择下拉框
+ QTimer *setNetSpeed = nullptr;
QVBoxLayout * m_mainLayout = nullptr;
QFrame * m_titleFrame = nullptr;
QHBoxLayout * m_titleLayout = nullptr;
@@ -152,10 +152,17 @@ protected:
QComboBox * m_deviceComboBox = nullptr;
QLabel * m_tipsLabel = nullptr;
+ long int start_rcv_rates = 0; //保存开始时的流量计数
+ long int end_rcv_rates = 0; //保存结束时的流量计数
+ long int start_tx_rates = 0; //保存开始时的流量计数
+ long int end_tx_rates = 0; //保存结束时的流量计数
+
public Q_SLOTS:
virtual void onDeviceComboxIndexChanged(int currentIndex) = 0;
void onPaletteChanged();
+protected Q_SLOTS:
+ void onSetNetSpeed(QListWidget* m_activatedNetListWidget, bool isActive, QString dev);
};
#endif // TABPAGE_H
diff --git a/src/frontend/tab-pages/wlanpage.cpp b/src/frontend/tab-pages/wlanpage.cpp
index c55f7ba2..9b241d3e 100644
--- a/src/frontend/tab-pages/wlanpage.cpp
+++ b/src/frontend/tab-pages/wlanpage.cpp
@@ -19,7 +19,8 @@
*/
#include "wlanpage.h"
#include "kywirelessnetitem.h"
-#include "networkmodeconfig.h"
+#include "kwindowsystem.h"
+#include "kwindowsystem_export.h"
#include
#include
#include
@@ -28,7 +29,6 @@
#define AP_SCAN_INTERVAL (20*1000)
#define ICON_REFRESH_INTERVAL (5*1000)
-#define EMPTY_SSID "emptyssid"
#define LOG_FLAG "[WlanPage]"
#define LAN_PAGE_INDEX 0
@@ -79,9 +79,14 @@ WlanPage::WlanPage(QWidget *parent) : TabPage(parent)
connect(m_connectResource, &KyConnectResourse::connectivityChanged, this, &WlanPage::connectivityChanged);
connect(m_netSwitch, &KSwitchButton::clicked, this, [=](bool checked) {
- m_netSwitch->setChecked(!checked);
- setWirelessEnable(checked);
+ //解决 switchBtn不支持点击的情况下,点击按钮,有无线网卡后不自动开启的问题
+ if (getSwitchBtnEnable()) {
+ setSwitchBtnState(!checked);
+ setWirelessEnable(checked);
+ }
});
+ m_wlanPagePtrMap.clear();
+ m_joinHiddenWiFiPagePtrMap.clear();
}
bool WlanPage::eventFilter(QObject *w, QEvent *e)
@@ -99,6 +104,20 @@ bool WlanPage::eventFilter(QObject *w, QEvent *e)
//检测不到无线网卡不再触发click信号
}
}
+ } else if (w == m_activatedNetListWidget) {
+ //去掉无右键菜单显示时的选中效果
+ if (e->type() == QEvent::FocusIn) {
+ if (m_activatedNetListWidget->currentItem() != nullptr) {
+ m_activatedNetListWidget->currentItem()->setSelected(false);
+ }
+ }
+ } else if (w == m_inactivatedNetListWidget) {
+ //去掉无右键菜单显示时的选中效果
+ if (e->type() == QEvent::FocusIn) {
+ if (m_inactivatedNetListWidget->currentItem() != nullptr) {
+ m_inactivatedNetListWidget->currentItem()->setSelected(false);
+ }
+ }
}
return QWidget::eventFilter(w,e);
}
@@ -133,6 +152,12 @@ void WlanPage::initWlanUI()
addWlanMoreItem();
m_inactivatedAreaLayout->addWidget(m_inactivatedNetListWidget);
+ connect(m_inactivatedNetListWidget, &QListWidget::currentItemChanged, this, [=]() {
+ if (m_inactivatedNetListWidget->currentItem() != nullptr) {
+ m_inactivatedNetListWidget->currentItem()->setSelected(false);
+ }
+ });
+
QPalette pal = m_activatedNetListWidget->palette();
pal.setBrush(QPalette::Base, QColor(0,0,0,0)); //背景透明
m_activatedNetListWidget->setPalette(pal);
@@ -140,6 +165,10 @@ void WlanPage::initWlanUI()
m_settingsLabel->installEventFilter(this);
m_netSwitch->installEventFilter(this);
+ m_activatedNetListWidget->installEventFilter(this);
+ m_inactivatedNetListWidget->installEventFilter(this);
+
+ showRate();
}
bool WlanPage::getWirelessDevieceUseable()
@@ -235,8 +264,9 @@ void WlanPage::initDeviceCombox()
}
} else {
m_deviceFrame->hide();
- m_currentDevice = "";
- setDefaultDevice(WIRELESS, m_currentDevice);
+ //解决因m_currentDevice被置空,安全中心网络显示BUG
+// m_currentDevice = "";
+// setDefaultDevice(WIRELESS, m_currentDevice);
}
connect(m_deviceComboBox, QOverload::of(&QComboBox::currentIndexChanged),
@@ -248,7 +278,7 @@ QListWidgetItem *WlanPage::addEmptyItem(QListWidget *wirelessListWidget)
{
WlanListItem *p_wlanItem = new WlanListItem();
QListWidgetItem *p_listWidgetItem = new QListWidgetItem();
- p_listWidgetItem->setFlags(p_listWidgetItem->flags() & (~Qt::ItemIsSelectable)); //设置不可被选中
+// p_listWidgetItem->setFlags(p_listWidgetItem->flags() & (~Qt::ItemIsSelectable)); //设置不可被选中
p_listWidgetItem->setSizeHint(QSize(wirelessListWidget->width(), p_wlanItem->height()));
wirelessListWidget->addItem(p_listWidgetItem);
wirelessListWidget->setItemWidget(p_listWidgetItem, p_wlanItem);
@@ -264,9 +294,10 @@ QListWidgetItem *WlanPage::addNewItem(KyWirelessNetItem &wirelessNetItem,
m_currentDevice,
m_connectResource->isApConnection(wirelessNetItem.m_connectUuid));
connect(p_wlanItem, &WlanListItem::itemHeightChanged, this, &WlanPage::onItemHeightChanged);
+ connect(p_wlanItem, &WlanListItem::detailShow, this, &WlanPage::showDetailPage);
QListWidgetItem *p_listWidgetItem = new QListWidgetItem();
- p_listWidgetItem->setFlags(p_listWidgetItem->flags() & (~Qt::ItemIsSelectable));
+// p_listWidgetItem->setFlags(p_listWidgetItem->flags() & (~Qt::ItemIsSelectable));
p_listWidgetItem->setSizeHint(QSize(wirelessListWidget->width(), p_wlanItem->height()));
wirelessListWidget->addItem(p_listWidgetItem);
wirelessListWidget->setItemWidget(p_listWidgetItem, p_wlanItem);
@@ -280,9 +311,10 @@ QListWidgetItem *WlanPage::insertNewItem(KyWirelessNetItem &wirelessNetItem,
{
WlanListItem *p_wlanItem = new WlanListItem(wirelessNetItem, m_currentDevice);
connect(p_wlanItem, &WlanListItem::itemHeightChanged, this, &WlanPage::onItemHeightChanged);
+ connect(p_wlanItem, &WlanListItem::detailShow, this, &WlanPage::showDetailPage);
QListWidgetItem *p_listWidgetItem = new QListWidgetItem();
- p_listWidgetItem->setFlags(p_listWidgetItem->flags() & (~Qt::ItemIsSelectable));
+// p_listWidgetItem->setFlags(p_listWidgetItem->flags() & (~Qt::ItemIsSelectable));
p_listWidgetItem->setSizeHint(QSize(wirelessListWidget->width(), p_wlanItem->height()));
wirelessListWidget->insertItem(row, p_listWidgetItem);
wirelessListWidget->setItemWidget(p_listWidgetItem, p_wlanItem);
@@ -300,9 +332,10 @@ QListWidgetItem *WlanPage::insertNewItemWithSort(KyWirelessNetItem &wirelessNetI
// << "signal strength" << wirelessNetItem.m_signalStrength;
WlanListItem *p_sortWlanItem = new WlanListItem(wirelessNetItem, m_currentDevice);
connect(p_sortWlanItem, &WlanListItem::itemHeightChanged, this, &WlanPage::onItemHeightChanged);
+ connect(p_sortWlanItem, &WlanListItem::detailShow, this, &WlanPage::showDetailPage);
QListWidgetItem *p_sortListWidgetItem = new QListWidgetItem();
- p_sortListWidgetItem->setFlags(p_sortListWidgetItem->flags() & (~Qt::ItemIsSelectable));
+// p_sortListWidgetItem->setFlags(p_sortListWidgetItem->flags() & (~Qt::ItemIsSelectable));
p_sortListWidgetItem->setSizeHint(QSize(p_ListWidget->width(), p_sortWlanItem->height()));
// qDebug() << "insertNewItemWithSort, count" << p_ListWidget->count();
@@ -353,10 +386,8 @@ void WlanPage::clearWirelessNetItemMap(QMap &wireless
wirelessListWidget->removeItemWidget(p_listWidgetItem);
delete p_wlanItem;
- p_wlanItem = nullptr;
delete p_listWidgetItem;
- p_listWidgetItem = nullptr;
iter = wirelessNetItem.erase(iter);
}
@@ -384,10 +415,8 @@ void WlanPage::deleteWirelessItemFormMap(QMap &wirele
wirelessListWidget->takeItem(wirelessListWidget->row(p_listWidgetItem));
delete p_wlanItem;
- p_wlanItem = nullptr;
delete p_listWidgetItem;
- p_listWidgetItem = nullptr;
if (m_inactivatedNetListWidget->count() <= MAX_ITEMS) {
m_inactivatedNetListWidget->setFixedWidth(MIN_WIDTH);
@@ -421,20 +450,8 @@ void WlanPage::constructActivateConnectionArea()
m_activateConnectionItemMap.insert(wirelessNetItem.m_NetSsid, p_listWidgetItem);
updateWlanItemState(m_activatedNetListWidget, p_listWidgetItem, Activated);
- int configType = NetworkModeConfig::getInstance()->getNetworkModeConfig(wirelessNetItem.m_connectUuid);
- if (configType == -1) {
- NetworkModeConfig::getInstance()->setNetworkModeConfig(wirelessNetItem.m_connectUuid,
- m_currentDevice,
- wirelessNetItem.m_connName,
- KSC_FIREWALL_PUBLIC);
- } else {
- NetworkModeConfig::getInstance()->setNetworkModeConfig(wirelessNetItem.m_connectUuid,
- m_currentDevice,
- wirelessNetItem.m_connName,
- configType);
- }
-
height += p_listWidgetItem->sizeHint().height();
+ setNetSpeed->start(REFRESH_NETWORKSPEED_TIMER);
}
}
@@ -545,6 +562,12 @@ void WlanPage::onWlanRemoved(QString interface, QString ssid)
{
Q_EMIT wlanRemove(interface, ssid);
+ if (m_wlanPagePtrMap.contains(interface) && m_wlanPagePtrMap[interface].contains(ssid)) {
+ if (m_wlanPagePtrMap[interface][ssid] != nullptr) {
+ m_wlanPagePtrMap[interface][ssid]->close();
+ }
+ }
+
if (interface != m_currentDevice) {
qDebug()<<"[WlanPage] the device is not current device,"
<<"current device" << m_currentDevice
@@ -740,6 +763,12 @@ void WlanPage::onDeviceRemove(QString deviceName)
QString originalDeviceName = m_currentDevice;
+ if (m_joinHiddenWiFiPagePtrMap.contains(deviceName)) {
+ if (m_joinHiddenWiFiPagePtrMap[deviceName] != nullptr) {
+ m_joinHiddenWiFiPagePtrMap[deviceName]->close();
+ }
+ }
+
m_devList.removeOne(deviceName);
deleteDeviceFromCombox(deviceName);
@@ -797,6 +826,7 @@ void WlanPage::onWlanStateChanged(NetworkManager::Device::State newstate, Networ
if (getSwitchBtnState() == getWirelessDevieceUseable()) {
return ;
}
+ setSwitchBtnEnable(true);
setSwitchBtnState(getWirelessDevieceUseable());
initDeviceCombox();
initWlanArea();
@@ -932,11 +962,6 @@ void WlanPage::onConnectionStateChanged(QString uuid,
NetworkManager::ActiveConnection::State state,
NetworkManager::ActiveConnection::Reason reason)
{
- if (!m_connectResource->isWirelessConnection(uuid)) {
- qDebug()<< LOG_FLAG << "it is not wireless connection" << uuid;
- return;
- }
-
QString devName, ssid;
m_wirelessNetResource->getSsidByUuid(uuid, ssid);
m_wirelessNetResource->getDeviceByUuid(uuid, devName);
@@ -944,10 +969,8 @@ void WlanPage::onConnectionStateChanged(QString uuid,
qDebug()<< LOG_FLAG << "Q_EMIT wlanActiveConnectionStateChanged" << devName << ssid << state;
Q_EMIT wlanActiveConnectionStateChanged(devName, ssid, uuid, state);
- //解决通过高级设置添加的未指定网卡的无线连接无法断开的问题,去掉设备为空的判断
- if (ssid.isEmpty()) {
- qDebug()<< LOG_FLAG << "ssid or devicename is empty"
- << "devicename"<< devName <<"ssid"<isWirelessConnection(uuid)) {
+ qDebug()<< LOG_FLAG << "it is not wireless connection" << uuid;
return;
}
@@ -974,38 +997,8 @@ void WlanPage::onConnectionStateChanged(QString uuid,
<< "; state = " << state << "; reason = " << reason << Q_FUNC_INFO <<__LINE__;
if (state == NetworkManager::ActiveConnection::State::Activated) {
m_updateStrength = true;
-
- if (!isApConnection) {
- int configType = NetworkModeConfig::getInstance()->getNetworkModeConfig(uuid);
- if (configType == -1) {
- NetworkModeConfig::getInstance()->setNetworkModeConfig(uuid, devName, ssid, KSC_FIREWALL_PUBLIC); //默认公有配置
- FirewallDialog *fireWallDialog = new FirewallDialog(); //弹窗 供用户配置
- fireWallDialog->setUuid(uuid);
- fireWallDialog->setWindowTitle(ssid);
-
- connect(fireWallDialog, &FirewallDialog::setPrivateNetMode, this, [=](){
- fireWallDialog->hide();
- NetworkModeConfig::getInstance()->setNetworkModeConfig(uuid, devName, ssid, KSC_FIREWALL_PRIVATE);
- });
-
- connect(fireWallDialog, &FirewallDialog::setPublicNetMode, this, [=](){
- fireWallDialog->hide();
- NetworkModeConfig::getInstance()->setNetworkModeConfig(uuid, devName, ssid, KSC_FIREWALL_PUBLIC);
- });
-
- connect(m_activatedConnectResource, &KyActiveConnectResourse::stateChangeReason, fireWallDialog, &FirewallDialog::closeMyself);
-
- fireWallDialog->show();
- fireWallDialog->centerToScreen();
-
- } else if (configType == KSC_FIREWALL_PUBLIC) {
- NetworkModeConfig::getInstance()->setNetworkModeConfig(uuid, devName, ssid, KSC_FIREWALL_PUBLIC);
- } else if (configType == KSC_FIREWALL_PRIVATE) {
- NetworkModeConfig::getInstance()->setNetworkModeConfig(uuid, devName, ssid, KSC_FIREWALL_PRIVATE);
- }
- }
-
updateActivatedArea(uuid, ssid, devName);
+ setNetSpeed->start(REFRESH_NETWORKSPEED_TIMER);
if (m_activateConnectionItemMap.contains(ssid)) {
QListWidgetItem *p_listWidgetItem = m_activateConnectionItemMap.value(ssid);
updateWlanItemState(m_activatedNetListWidget, p_listWidgetItem, Activated);
@@ -1017,12 +1010,12 @@ void WlanPage::onConnectionStateChanged(QString uuid,
}
updateWirelessNetArea(uuid, ssid, devName,"");
+ setNetSpeed->stop();
if (m_wirelessNetItemMap.contains(ssid)) {
QListWidgetItem *p_listWidgetItem = m_wirelessNetItemMap.value(ssid);
updateWlanItemState(m_inactivatedNetListWidget, p_listWidgetItem, Deactivated);
}
- NetworkModeConfig::getInstance()->breakNetworkConnect(uuid, devName, ssid);
} else if (state == NetworkManager::ActiveConnection::State::Deactivating){
m_updateStrength = false;
if (m_activateConnectionItemMap.contains(ssid)) {
@@ -1104,23 +1097,7 @@ void WlanPage::requestScan()
void WlanPage::onHiddenWlanClicked()
{
qDebug() << "[wlanPage] AddHideWifi Clicked! " << Q_FUNC_INFO << __LINE__ ;
-// NetDetail *netDetail = new NetDetail(m_currentDevice, "", "", false, true, true);
-// netDetail->show();
- if(m_hiddenWiFi != nullptr){
- m_hiddenWiFi->activateWindow();
- return;
- }
-
- m_hiddenWiFi = new JoinHiddenWiFiPage(m_currentDevice);
-
- connect(m_hiddenWiFi, &JoinHiddenWiFiPage::showWlanList, this, &WlanPage::showMainWindow);
- connect(m_hiddenWiFi, &JoinHiddenWiFiPage::destroyed, [&](){
- if (m_hiddenWiFi != nullptr) {
- m_hiddenWiFi = nullptr;
- }
- });
-
- m_hiddenWiFi->show();
+ showHiddenWlanPage(m_currentDevice);
}
void WlanPage::showControlCenter()
@@ -1175,7 +1152,10 @@ void WlanPage::onRefreshIconTimer()
return;
}
-
+ //解决没有无线设备且m_currentDevice不清空的情况下,m_activateConnectionItemMap为空造成的段错误
+ if (m_activateConnectionItemMap.isEmpty()) {
+ return ;
+ }
QString activateSsid = m_activateConnectionItemMap.firstKey();
int sortRow = 0;
for (int index = 0; index < wlanList.length(); index++) {
@@ -1226,6 +1206,7 @@ void WlanPage::onRefreshIconTimer()
WlanListItem *p_sortWlanItem = new WlanListItem(sortItem, m_currentDevice);
connect(p_sortWlanItem, &WlanListItem::itemHeightChanged, this, &WlanPage::onItemHeightChanged);
+ connect(p_sortWlanItem, &WlanListItem::detailShow, this, &WlanPage::showDetailPage);
m_inactivatedNetListWidget->insertItem(sortRow, p_sortListWidgetItem);
m_inactivatedNetListWidget->setItemWidget(p_sortListWidgetItem, p_sortWlanItem);
updateWlanItemState(m_inactivatedNetListWidget, p_sortListWidgetItem, Deactivated);
@@ -1438,7 +1419,8 @@ void WlanPage::deactivateWirelessConnection(const QString& devName, const QStrin
void WlanPage::onMainWindowVisibleChanged(const bool &visible)
{
qDebug() << "[WlanPage] Received signal of mainwindow visible changed. cur_state = " << visible << Q_FUNC_INFO << __LINE__;
- if (visible) {
+ //开关关闭状态不刷新
+ if (visible && getSwitchBtnState()) {
//打开页面时先触发一次扫描,然后定时扫描wifi热点和刷新icon
requestScan();
m_scanTimer->start(AP_SCAN_INTERVAL);
@@ -1478,6 +1460,40 @@ void WlanPage::showNonePwd()
return;
}
+
+void WlanPage::showRate()
+{
+ //定时获取网速
+ setNetSpeed = new QTimer(this);
+ setNetSpeed->setTimerType(Qt::PreciseTimer);
+ connect(setNetSpeed, &QTimer::timeout, [&](){
+ onSetNetSpeed(m_activatedNetListWidget, m_activateConnectionItemMap.contains(EMPTY_SSID), m_currentDevice);
+ });
+}
+
+void WlanPage::showHiddenWlanPage(QString devName)
+{
+ if (m_joinHiddenWiFiPagePtrMap.contains(devName)) {
+ if (m_joinHiddenWiFiPagePtrMap[devName] != nullptr) {
+ qDebug() << "[WlanPage] showAddOtherWlanWidget" << devName << "already create,just raise";
+ KWindowSystem::activateWindow(m_joinHiddenWiFiPagePtrMap[devName]->winId());
+ KWindowSystem::raiseWindow(m_joinHiddenWiFiPagePtrMap[devName]->winId());
+ return;
+ }
+ }
+
+ JoinHiddenWiFiPage *hiddenWiFi =new JoinHiddenWiFiPage(devName);
+ connect(hiddenWiFi, &JoinHiddenWiFiPage::hiddenWiFiPageClose, [&](QString interfaceName){
+ if (m_joinHiddenWiFiPagePtrMap.contains(interfaceName)) {
+ m_joinHiddenWiFiPagePtrMap[interfaceName] = nullptr;
+ }
+ });
+ connect(hiddenWiFi, &JoinHiddenWiFiPage::showWlanList, this, &WlanPage::showMainWindow);
+
+ m_joinHiddenWiFiPagePtrMap.insert(devName, hiddenWiFi);
+ hiddenWiFi->show();
+}
+
void WlanPage::showDetailPage(QString devName, QString ssid)
{
KyWirelessNetItem wirelessNetItem;
@@ -1488,12 +1504,32 @@ void WlanPage::showDetailPage(QString devName, QString ssid)
bool isActive = m_connectResource->isActivatedConnection(wirelessNetItem.m_connectUuid);
+ if (m_wlanPagePtrMap.contains(devName) && m_wlanPagePtrMap[devName].contains(ssid)) {
+ if (m_wlanPagePtrMap[devName][ssid] != nullptr) {
+ qDebug() << "[WlanPage] ShowWlanDetailPage" << ssid << "already create,just raise";
+ KWindowSystem::activateWindow(m_wlanPagePtrMap[devName][ssid]->winId());
+ KWindowSystem::raiseWindow(m_wlanPagePtrMap[devName][ssid]->winId());
+ return;
+ }
+ }
+
NetDetail *netDetail = new NetDetail(devName, ssid, wirelessNetItem.m_connectUuid, isActive, true, !wirelessNetItem.m_isConfigured);
+ m_wlanPagePtrMap[devName].insert(ssid, netDetail);
+ connect(netDetail, &NetDetail::detailPageClose, [&](QString deviceName, QString wlanSsid){
+ if (m_wlanPagePtrMap.contains(deviceName) && m_wlanPagePtrMap[deviceName].contains(wlanSsid)) {
+ m_wlanPagePtrMap[deviceName][wlanSsid] = nullptr;
+ }
+ });
netDetail->show();
- netDetail->setDetailPageShowed(true);
+
return;
}
+void WlanPage::showAddOtherPage(QString devName)
+{
+ showHiddenWlanPage(devName);
+}
+
bool WlanPage::checkWlanStatus(NetworkManager::ActiveConnection::State state)
{
if (m_activatedConnectResource->checkWirelessStatus(state)) {
@@ -1550,5 +1586,11 @@ void WlanPage::addWlanMoreItem()
m_hiddenItem->setSizeHint(QSize(m_inactivatedNetListWidget->width(), m_hiddenWlanWidget->height()));
m_inactivatedNetListWidget->addItem(m_hiddenItem);
m_inactivatedNetListWidget->setItemWidget(m_hiddenItem, m_hiddenWlanWidget);
+ m_hiddenWlanWidget->m_freq->hide();
return;
}
+
+int WlanPage::getAcivateWifiSignal()
+{
+ return m_activatedConnectResource->getAcivateWifiSignal();
+}
diff --git a/src/frontend/tab-pages/wlanpage.h b/src/frontend/tab-pages/wlanpage.h
index 95450ca1..d7453722 100644
--- a/src/frontend/tab-pages/wlanpage.h
+++ b/src/frontend/tab-pages/wlanpage.h
@@ -66,6 +66,7 @@ public:
void deactivateWirelessConnection(const QString& devName, const QString& ssid);
void showDetailPage(QString devName, QString uuid);
+ void showAddOtherPage(QString devName);
bool checkWlanStatus(NetworkManager::ActiveConnection::State state);
@@ -78,6 +79,8 @@ public:
bool getWirelessSwitchBtnState();
+ int getAcivateWifiSignal();
+
Q_SIGNALS:
void oneItemExpanded(const QString &ssid);
void wlanAdd(QString devName, QStringList info);
@@ -143,6 +146,10 @@ private:
void showNonePwd();
+ void showRate();
+
+ void showHiddenWlanPage(QString devName);
+
QListWidgetItem *addEmptyItem(QListWidget *wirelessListWidget);
QListWidgetItem *addNewItem(KyWirelessNetItem &wirelessNetItem,
QListWidget *wirelessListWidget);
@@ -194,12 +201,12 @@ private:
}
inline void setSwitchBtnEnable(bool state) {
if (m_netSwitch != nullptr) {
- m_netSwitch->setCheckable(state);
+ m_netSwitch->setEnabled(state);
}
}
inline bool getSwitchBtnEnable() {
if (m_netSwitch != nullptr) {
- return m_netSwitch->isCheckable();
+ return m_netSwitch->isEnabled();
}
}
@@ -229,7 +236,8 @@ private:
QTimer *m_scanTimer = nullptr;
QTimer *m_refreshIconTimer = nullptr;
- JoinHiddenWiFiPage *m_hiddenWiFi = nullptr;
+ QMap> m_wlanPagePtrMap;
+ QMap m_joinHiddenWiFiPagePtrMap;
};
#endif // WLANPAGE_H
diff --git a/src/frontend/tools/kylable.cpp b/src/frontend/tools/kylable.cpp
index a734877b..b821dbca 100644
--- a/src/frontend/tools/kylable.cpp
+++ b/src/frontend/tools/kylable.cpp
@@ -21,6 +21,8 @@
#include
#include
#include
+#include
+#include
#define FOREGROUND_COLOR_NORMAL qApp->palette().text().color()
@@ -50,6 +52,44 @@ QColor mixColor(const QColor &c1, const QColor &c2, qreal bias)
return QColor::fromRgbF(r, g, b, a);
}
+FixLabel::FixLabel(QWidget *parent) :
+ QLabel(parent)
+{
+ const QByteArray id("org.ukui.style");
+ QGSettings * fontSetting = new QGSettings(id, QByteArray(), this);
+ if(QGSettings::isSchemaInstalled(id)){
+ connect(fontSetting, &QGSettings::changed,[=](QString key) {
+ if ("systemFont" == key || "systemFontSize" ==key) {
+ changedLabelSlot();
+ }
+ });
+ }
+}
+
+
+void FixLabel::setLabelText(QString text) {
+
+ mStr = text;
+ changedLabelSlot();
+}
+
+QString FixLabel::getText(){
+ return mStr;
+}
+
+void FixLabel::changedLabelSlot() {
+ QFontMetrics fontMetrics(this->font());
+ int fontSize = fontMetrics.width(mStr);
+ if (fontSize > this->width()) {
+ setText(fontMetrics.elidedText(mStr, Qt::ElideRight, this->width()));
+ setToolTip(mStr);
+ } else {
+ setText(mStr);
+ setToolTip("");
+ }
+}
+
+
KyLable::KyLable(QWidget *parent) : QLabel(parent)
{
connect(qApp, &QApplication::paletteChanged, this, &KyLable::onPaletteChanged);
diff --git a/src/frontend/tools/kylable.h b/src/frontend/tools/kylable.h
index 3a3cb24a..c45eb8bd 100644
--- a/src/frontend/tools/kylable.h
+++ b/src/frontend/tools/kylable.h
@@ -23,6 +23,23 @@
#include
#include
+class FixLabel : public QLabel
+{
+ Q_OBJECT
+public:
+ explicit FixLabel(QWidget *parent = 0);
+
+public:
+ void setLabelText(QString text);
+ QString getText();
+
+private Q_SLOTS:
+ void changedLabelSlot();
+private:
+ QString mStr;
+
+};
+
class KyLable : public QLabel
{
Q_OBJECT
diff --git a/src/frontend/tools/radioitembutton.cpp b/src/frontend/tools/radioitembutton.cpp
index 02cd9a70..981e7569 100644
--- a/src/frontend/tools/radioitembutton.cpp
+++ b/src/frontend/tools/radioitembutton.cpp
@@ -231,7 +231,7 @@ void RadioItemButton::refreshButtonIcon()
m_iconLabel->setPixmap(loadSvg(m_pixmap, PixmapColor::WHITE));
} else {
m_backgroundColor = COLOR_BRIGHT_TEXT;
- m_backgroundColor.setAlphaF(0.18);
+ m_backgroundColor.setAlphaF(0.12);
if (qApp->palette().base().color().red() > MIDDLE_COLOR) {
m_iconLabel->setPixmap(m_pixmap);
} else {
diff --git a/src/frontend/tools/tools.pri b/src/frontend/tools/tools.pri
index 9c261260..7863428b 100644
--- a/src/frontend/tools/tools.pri
+++ b/src/frontend/tools/tools.pri
@@ -3,7 +3,6 @@ INCLUDEPATH += $$PWD
HEADERS += \
$$PWD/divider.h \
$$PWD/infobutton.h \
- $$PWD/listitemedit.h \
$$PWD/loadingdiv.h \
$$PWD/radioitembutton.h \
$$PWD/switchbutton.h \
@@ -13,7 +12,6 @@ HEADERS += \
SOURCES += \
$$PWD/divider.cpp \
$$PWD/infobutton.cpp \
- $$PWD/listitemedit.cpp \
$$PWD/loadingdiv.cpp \
$$PWD/radioitembutton.cpp \
$$PWD/switchbutton.cpp \
diff --git a/src/main.cpp b/src/main.cpp
index 0b6bd839..e8660476 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -16,10 +16,9 @@
*
*/
+//#include "mainwindow.h"
#include "mainwindow.h"
-#include "vpnmainwindow.h"
#include "dbusadaptor.h"
-#include "vpndbusadaptor.h"
#include
#include
#include "qt-single-application.h"
@@ -81,7 +80,7 @@ void messageOutput(QtMsgType type, const QMessageLogContext &context, const QStr
int main(int argc, char *argv[])
{
-// initUkuiLog4qt("kylin-nm");
+ initUkuiLog4qt("kylin-nm");
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
@@ -128,7 +127,7 @@ int main(int argc, char *argv[])
QString locale = QLocale::system().name();
QTranslator trans_global;
qDebug() << "QLocale " << QLocale();
- if (trans_global.load(QLocale(), "kylin-nm", "_", ":/translations/"))
+ if (trans_global.load(QLocale(), "kylin-nm", "_", "/usr/share/kylin-nm/kylin-nm/"))
{
a.installTranslator(&trans_global);
qDebug()<<"Translations load success";
@@ -145,13 +144,19 @@ int main(int argc, char *argv[])
qWarning() << "QtBase Translations load fail";
}
+ QTranslator sdkTranslator;
+ if (sdkTranslator.load(QLocale(), "gui", "_", ":/translations/"))
+ {
+ a.installTranslator(&sdkTranslator);
+ qDebug()<<"SDK Translations load success";
+ } else {
+ qWarning() << "SDK Translations load fail";
+ }
+
while (!p_networkResource->NetworkManagerIsInited()) {
::usleep(1000);
}
- vpnMainWindow vpnwindow;
- vpnwindow.setProperty("useStyleWindowManager", false); //禁用拖动
-
MainWindow w;
a.setActivationWindow(&w);
w.setProperty("useStyleWindowManager", false); //禁用拖动
@@ -170,13 +175,8 @@ int main(int argc, char *argv[])
DbusAdaptor adaptor(&w);
Q_UNUSED(adaptor);
- VpnDbusAdaptor vpnAdaptor(&vpnwindow);
- Q_UNUSED(vpnAdaptor);
-
auto connection = QDBusConnection::sessionBus();
- if (!connection.registerService("com.kylin.network")
- || !connection.registerObject("/com/kylin/network", &w)
- || !connection.registerObject("/com/kylin/vpnTool", &vpnwindow)) {
+ if (!connection.registerService("com.kylin.network") || !connection.registerObject("/com/kylin/network", &w)) {
qCritical() << "QDbus register service failed reason:" << connection.lastError();
}
diff --git a/src/org.ukui.kylin-nm.switch.gschema.xml b/src/org.ukui.kylin-nm.switch.gschema.xml
index f7fa75de..544f2cd0 100644
--- a/src/org.ukui.kylin-nm.switch.gschema.xml
+++ b/src/org.ukui.kylin-nm.switch.gschema.xml
@@ -11,11 +11,4 @@
Wired switch.true is open,false is close.
-
-
- false
- vpnicon visible
- vpnicon visible.true is visible,false is invisible.
-
-
diff --git a/translate_generation.sh b/translate_generation.sh
new file mode 100755
index 00000000..72f748b9
--- /dev/null
+++ b/translate_generation.sh
@@ -0,0 +1,15 @@
+#!/bin/bash
+
+ts_list=(`ls translations/*.ts`)
+source /etc/os-release
+version=(`echo $ID`)
+
+for ts in "${ts_list[@]}"
+do
+ printf "\nprocess ${ts}\n"
+ if [ "$version" == "fedora" ] || [ "$version" == "opensuse-leap" ] || [ "$version" == "opensuse-tumbleweed" ];then
+ lrelease-qt5 "${ts}"
+ else
+ lrelease "${ts}"
+ fi
+done
diff --git a/translations/kylin-nm_bo.ts b/translations/kylin-nm_bo.ts
index 82bbeb73..fa557feb 100644
--- a/translations/kylin-nm_bo.ts
+++ b/translations/kylin-nm_bo.ts
@@ -27,43 +27,47 @@
CreatNetPage
-
+
-
-
+
+
-
+
-
+
-
+
-
-
-
+
+
-
+
+
+
+
+
+
-
+
@@ -71,82 +75,82 @@
DetailPage
-
+
-
-
+
+
-
+
-
+
-
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
-
-
-
-
-
+
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
@@ -182,22 +186,22 @@
FirewallDialog
-
+
-
+
-
+
-
+
@@ -205,23 +209,33 @@
Ipv4Page
-
+
+
+
+
+
+
-
+
-
+
-
-
+
+
+
+
+
+
+
@@ -235,23 +249,23 @@
-
+
-
+
-
-
+
+
-
+
@@ -259,54 +273,64 @@
Ipv6Page
-
+
+
+
+
+
+
-
+
-
+
-
-
+
+
-
+
+
+
+
+
+
-
+
-
-
-
+
+
+
-
+
-
+
-
+
@@ -377,27 +401,27 @@
LanPage
-
+
-
+
-
+
-
+
-
+
@@ -405,12 +429,12 @@
ListItem
-
+
-
+
@@ -418,153 +442,140 @@
MainWindow
-
+
-
+
-
+
-
+
-
+
-
+
-
- MultipleDnsWidget
-
-
-
-
-
-
NetDetail
-
+
-
+
-
+
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
+
+
+
-
-
-
+
+
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -755,24 +766,6 @@
-
- SinglePage
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
TabPage
@@ -786,51 +779,36 @@
-
+
-
+
-
+
-
- VpnListItem
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
VpnPage
-
-
+
+
-
-
+
+
+
+
+
+
+
@@ -880,31 +858,31 @@
WlanListItem
-
+
-
-
+
+
-
-
-
+
+
+
-
-
+
+
-
+
@@ -953,17 +931,17 @@
main
-
+
-
+
-
+
@@ -971,12 +949,12 @@
vpnMainWindow
-
+
-
+
diff --git a/translations/kylin-nm_bo_CN.ts b/translations/kylin-nm_bo_CN.ts
index e418f289..85826f43 100644
--- a/translations/kylin-nm_bo_CN.ts
+++ b/translations/kylin-nm_bo_CN.ts
@@ -46,17 +46,9 @@
-
+
ཆེད་སྤྱོད། དྲ་རྒྱའི་སྒྲིག་ཆས་ཀྱིས་གློག་ཀླད་འདི་མཐོང་ཐུབ། སྤྱིར་བཏང་གི་གནས་ཚུལ་འོག་ཁྱིམ་ཚང་ངམ་ལས་དོན་ཚན་པའི་དྲ་བ་དང་འཚམ་པས།ཁྱེད་ཀྱིས་དྲ་ཐོག་གི་མི་སྒེར་དང་སྒྲིག་ཆས་ལ་ངོས་འཛིན་དང་ཡིད་ཆེས་བྱེད་དགོས།.
-
-
- སྤྱི་སྤྱོད་(འོས་སྦྱོར་)དྲ་རྒྱའི་ཐོག་ནས་ཁྱོད་ཀྱི་སྒྲིག་ཆས་རྙེད་མི་ཐུབ། གནས་ཚུལ་མང་ཆེ་བའི་འོག་ཏུ་ཁྱིམ་ཚང་དང་བྱ་བ་འམ་ཡང་ན་སྤྱི་པའི་གོ་གནས་སུ་དྲ་རྒྱའི་དུས་སུ་ནུས་པ་འདི་བཀོལ་སྤྱོད་བྱེད་དགོས།.
-
-
-
- ཆེད་སྤྱོད་དྲ་རྒྱའི་སྟེང་ནས་ཁྱོད་ཀྱི་སྒྲིག་ཆས་རྙེད་ཐུབ། གལ་ཏེ་ཡིག་ཆ་མཉམ་སྤྱོད་བྱེད་དགོས་པའམ་ཡང་ན་དྲ་རྒྱའི་འཕྲིན་གཏོང་བཀོལ་སྤྱོད་བྱེད་པར་བརྟེན་ནས་རྣམ་གྲངས་འདི་འདེམས་རོགས་གནང། ཁྱོད་ཀྱིས་དྲ་རྒྱའི་སྟེང་གི་མི་སྣ་དང་སྒྲིག་ཆས་ལ་རྒྱུས་ལོན་དང་ཡིད་ཆེས་བྱེད་དགོས།.
-
@@ -81,51 +73,63 @@
CreatNetPage
-
+
འབྲེལ་མཐུད་ཀྱི་མིང་།
-
+
IPv4ཁུང་ཙི།
-
+
སྡོད་གནས།
-
+
དྲ་རྒྱའི་མ་ལག
-
+
ཁ་ཆད་བཞག་པའི་སྒོ་ཆེན།
+
- སྔོན་གྲབས་DNS
+ སྔོན་གྲབས་DNS
+
- ཚབ་བྱེད་རང་བཞིན་གྱི་DNS
+ ཚབ་བྱེད་རང་བཞིན་གྱི་DNS
-
+
རང་འགུལ་(DHCP)
-
+
ལག་དེབ།
-
-
+
+
+ རྩིས་འགྲོ་མེད་པའི་ས་གནས།
+
+
+
+
+ རྩིས་འགྲོ་མེད་པའི་དྲ་བ་འགེབས་སྲུང་བྱེད་པ།
+
+
+
+
ངེས་པར་དུ་སྐོང་དགོས།
@@ -133,82 +137,82 @@
DetailPage
-
+
རང་འགུལ་གྱིས་འབྲེལ་མཐུད་བྱེད
-
-
+
+
SSID:
-
+
འདྲ་བཟོ་བྱས་ནས་གྲུབ་འབྲས་ཐོབ་!
-
+
ཚང་མ་འདྲ་བཤུས་བྱེད་
-
+
SSID:ནང་འཇུག་གནང་རོགས།:
-
-
+
+
གྲོས་ཆོད་ནང་དུ།:
-
-
+
+
བདེ་འཇགས་ཀྱི་རིགས་དབྱིབས་ནི།:
-
-
+
+
དྲ་རྒྱའི་འཕྲིན་ལམ།:
-
-
+
+
དྲ་བའི་བགྲོད་ལམ།:
-
-
+
+
ཞེང་ཆེ་བ།:
-
-
+
+
IPv6:
-
-
+
+
IPv4:
-
-
-
- IPv4 Dns:
+
+
+
+ IPv4 DNS:
-
-
+
+
ཨའོ་མོན་ནི།:
@@ -498,22 +502,22 @@
དེ་ལྟར་མ་བྱས་
-
+
དྲ་རྒྱའི་སྟེང་གི་སྒྲིག་ཆས་གཞན་པས་གློག་ཀླད་འདི་རྙེད་དུ་འཇུག་གམ།?
-
+
བསམ་འཆར་མེད་།སྤྱི་པའི་དྲ་རྒྱའི་སྟེང་ནས་ནུས་པ་འདི་མགོ་བརྩམས་།
-
+
- མི་ཆོག་(འོས་སྦྱོར་)།
+ མི་ཆོག་པ་(འོས་སྦྱོར།)
-
+
ཆོག་པ་
@@ -521,32 +525,34 @@
Ipv4Page
-
+
IPv4ཁུང་ཙི།
-
+
སྡོད་གནས།
-
+
དྲ་རྒྱའི་མ་ལག
-
+
ཁ་ཆད་བཞག་པའི་སྒོ་ཆེན།
+
- སྔོན་གྲབས་DNS
+ སྔོན་གྲབས་DNS
+
- ཚབ་བྱེད་རང་བཞིན་གྱི་DNS
+ ཚབ་བྱེད་རང་བཞིན་གྱི་DNS
@@ -559,23 +565,23 @@
ལག་དེབ།
-
+
རྩིས་འགྲོ་མེད་པའི་ས་གནས།
-
+
རྩིས་འགྲོ་མེད་པའི་དྲ་བ་འགེབས་སྲུང་བྱེད་པ།
-
-
+
+
ངེས་པར་དུ་སྐོང་དགོས།
-
+
ཤག་གནས་གདོང་གཏུག་
@@ -583,62 +589,64 @@
Ipv6Page
-
+
IPv6ཁུང་ཙི།
-
+
སྡོད་གནས།
-
+
ཡན་ལག་དྲ་རྒྱའི་སྔོན་སྒྲིག་གི་རིང་ཚད།
-
+
ཁ་ཆད་བཞག་པའི་སྒོ་ཆེན།
+
- སྔོན་གྲབས་DNS
+ སྔོན་གྲབས་DNS
+
- ཚབ་བྱེད་རང་བཞིན་གྱི་DNS
+ ཚབ་བྱེད་རང་བཞིན་གྱི་DNS
-
+
རང་འགུལ་(DHCP)
-
+
ལག་དེབ།
-
-
-
+
+
+
ངེས་པར་དུ་སྐོང་དགོས།
-
+
རྩིས་འགྲོ་མེད་པའི་ས་གནས།
-
+
རྩིས་འགྲོ་མེད་པའི་དྲ་བའི་འགག་སྒོ།
-
+
ཤག་གནས་གདོང་གཏུག་
@@ -709,26 +717,34 @@
སྦྲེལ་མཐུད་བྱེད་པ
+
+
+ ངོ་བོ།
+
+
+
+ དྲ་རྒྱ་དེ་བསུབ་དགོས།
+
LanPage
-
+
ཨེ་ཙི་དྲ་རྒྱའི་སྒྲིག་ཆས་ལ་བཙན་འཛུལ་བྱས་མི་ཆོག།
-
+
སྐུད་ཡོད་དྲ་བ།
-
+
ངའི་དྲ་རྒྱ།
-
+
དྲ་བ་གཞན་དག
@@ -737,7 +753,7 @@
སྐུད་ཡོད་དྲ་བ་ཆད་སོང་།
-
+
སྐུད་ཡོད་སྒྲིག་ཆས་འཁྱེར་མེད་པ།
@@ -749,12 +765,12 @@
ListItem
-
+
དྲ་རྒྱའི་ཡོ་བྱད།
-
+
དྲ་རྒྱའི་གསལ་འདེབས་གནས་ཚུལ།
@@ -762,76 +778,68 @@
MainWindow
-
+
དྲ་རྒྱའི་ཡོ་བྱད།
-
+
有线网络
སྐུད་ཡོད་དྲ་བ།
-
+
无线局域网
སྐུད་མེད་ཅུས་ཁོངས་ཀྱི་དྲ་བ།
-
+
རླུང་གཙོ་བོ་མངོན་པར་བྱས་ཡོད།
-
+
设置网络项
སྒྲིག་བཀོད།
-
+
དྲ་རྒྱའི་ལག་ཆ་
-
- MultipleDnsWidget
-
-
-
- DNSཞབས་ཞུ་བ།:
-
-
NetDetail
-
+
ཅིན་ལིན་NM
-
+
དྲ་རྒྱའི་གསལ་འདེབས་གནས་ཚུལ།
-
+
ཞིབ་ཕྲའི་གནས་ཚུལ།
-
+
IPv4
-
+
IPv6
-
+
བདེ་འཇགས།
@@ -840,62 +848,61 @@
关闭
-
-
+
+
བཀོད་སྒྲིག་བཅས་བྱ་དགོས།
-
+
གཏན་འཁེལ་བྱ་དགོས།
-
+
ཕྱིར་འཐེན།
-
+
དྲ་རྒྱ་འདི་བརྗེད་སོང་།
-
དྲ་རྒྱ་དེ་བསུབ་དགོས།
-
-
+
+
སྐུད་ཡོད་དྲ་བ་ཁ་སྣོན་བྱ་དགོས།
-
-
+
+
ཧའེ་ཏེན་ཝེ་ལན་དང་འབྲེལ་མཐུད་བྱེད་པ།
-
-
-
+
+
+
གཅིག་ཀྱང་མེད།
-
-
-
+
+
+
རང་འགུལ་གྱིས་རླངས་
-
+
ipv4ས་གནས་ཀྱི་འགལ་བ་ལ་ཞིབ་བཤེར་བྱེད་འགོ་ཚུགས།
-
+
ipv6གནས་ཡུལ་དང་འགལ་བར་ཞིབ་བཤེར་བྱེད་འགོ་ཚུགས།
@@ -908,22 +915,22 @@
ipv6ཐག་གཅོད་གདོང་གཏུག་བྱུང་བ་རེད།!
-
+
wifiལ་རྒྱབ་སྐྱོར་མེད་པའི་ཁེ་ལས་ཀྱི་རིགས་དབྱིབས།
-
+
wifiལ་རྒྱབ་སྐྱོར་མི་བྱེད་པར་རིགས་དབྱིབས་གཅིག་ཀྱང་མེད།
-
+
wifiལ་རྒྱབ་སྐྱོར་མི་བྱེད་པའི་WPA2རིགས་དབྱིབས་
-
+
wifiལ་རྒྱབ་སྐྱོར་མི་བྱེད་པའི་WPA3རིགས་དབྱིབས་
@@ -952,7 +959,7 @@
IPv4地址:
-
+
IPv4 DNS服务器:
@@ -1108,13 +1115,8 @@
-
- བཀོལ་སྤྱོད་ཀྱི་མིང་།
-
-
- Usename
- 用户名
+ བཀོལ་སྤྱོད་ཀྱི་མིང་།
@@ -1206,24 +1208,6 @@
-
- SinglePage
-
-
-
- སྒྲིག་བཀོད།
-
-
-
-
-
-
-
-
-
-
-
-
TabPage
@@ -1237,56 +1221,37 @@
སྒྲིག་ཆས་སྒོ་རྒྱག་པ།!
-
+
སྒྲིག་བཀོད།
-
+
ཅིན་ལིན་NM
-
+
kylinདྲ་རྒྱའི་ཀུ་ཤུའི་ཅོག་ཙེའི་ཆ་འཕྲིན།
-
- VpnListItem
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
VpnPage
+
+
+
+
+
+
+
+
+
+
+
- སྐུད་ཡོད་སྒྲིག་ཆས་འཁྱེར་མེད་པ།
-
-
-
-
-
-
-
-
-
-
+ སྐུད་ཡོད་སྒྲིག་ཆས་འཁྱེར་མེད་པ།
@@ -1335,31 +1300,35 @@
WlanListItem
-
+
འབྲེལ་མཐུད་མི་བྱེད་པ།
-
-
+
+
འབྲེལ་ཐག་ཆད་པ།
-
-
-
+
+
+
སྦྲེལ་མཐུད་བྱེད་པ
-
-
+
+
བརྗེད་པ།
+
+
+
+ ངོ་བོ།
-
+
རང་འགུལ་གྱིས་སྦྲེལ་མཐུད་
@@ -1471,17 +1440,17 @@
main
-
+
-
+
སྐུད་མེད་དྲ་རྒྱའི་ངོས་མངོན་པར་བྱས་ཡོད།
-
+
སྐུད་ཡོད་དྲ་རྒྱའི་ཤོག་ངོས་མངོན་པར་བྱས་ཡོད།
@@ -1489,12 +1458,12 @@
vpnMainWindow
-
+
-
+
diff --git a/translations/kylin-nm_tr.ts b/translations/kylin-nm_tr.ts
index 5009f886..bca72f95 100644
--- a/translations/kylin-nm_tr.ts
+++ b/translations/kylin-nm_tr.ts
@@ -125,43 +125,47 @@
CreatNetPage
-
+
-
-
+
+
-
+
-
+
-
+
-
-
-
+
+
-
+
+
+
+
+
+
Oto(DHCP)
-
+
Elle
@@ -169,82 +173,82 @@
DetailPage
-
+
-
-
+
+
-
+
-
+
-
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
-
- IPv6 adresi: {4:?}
-
-
-
+
-
+
-
-
-
- IPv6 adresi: {6:?}
+
+
+
+
-
-
+
+
+
+
+
+
+
+
@@ -1201,22 +1205,22 @@
FirewallDialog
-
+
-
+
-
+
-
+
@@ -1224,23 +1228,33 @@
Ipv4Page
-
+
+
+
+
+
+
-
+
-
+
-
-
+
+
+
+
+
+
+
@@ -1254,23 +1268,23 @@
Elle
-
+
-
+
-
-
+
+
-
+
@@ -1278,54 +1292,64 @@
Ipv6Page
-
+
+
+
+
+
+
-
+
-
+
-
-
+
+
-
+
+
+
+
+
+
Oto(DHCP)
-
+
Elle
-
-
-
+
+
+
-
+
-
+
-
+
@@ -1403,27 +1427,27 @@
LanPage
-
+
-
+
-
+
-
+
-
+
@@ -1431,12 +1455,12 @@
ListItem
-
+
-
+
Kylin ağ uygulaması masaüstü mesajı
@@ -1444,7 +1468,7 @@
MainWindow
-
+
@@ -1465,22 +1489,22 @@
Gizli Ağı Bağlan
-
+
-
+
WLAN
-
+
-
+
@@ -1497,7 +1521,7 @@
HotSpot
-
+
Ana Pencereyi Göster
@@ -1590,123 +1614,110 @@
WLAN Bağlantısı Başarılı
-
- MultipleDnsWidget
-
-
-
-
-
-
NetDetail
-
+
-
+
-
+
-
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
Ayar
-
+
-
+
-
+
-
+
-
-
- IPv6 adresi: {4?}
-
-
-
-
- IPv6 adresi: {6?}
-
-
-
+
-
-
-
-
-
-
-
-
+
+
+
Yok
-
-
-
+
+
+
Oto
-
+
-
+
-
+
-
+
-
+
-
+
@@ -2095,24 +2106,6 @@
-
- SinglePage
-
-
-
-
-
-
-
-
-
-
-
-
-
- Kylin ağ uygulaması masaüstü mesajı
-
-
TabPage
@@ -2126,17 +2119,17 @@
-
+
-
+
-
+
Kylin ağ uygulaması masaüstü mesajı
@@ -2148,36 +2141,21 @@
Kylin ağ uygulaması masaüstü mesajı
-
- VpnListItem
-
-
-
- Bağlanamadı
-
-
-
-
-
- Bağlantıyı Kes
-
-
-
-
-
-
-
-
VpnPage
-
-
+
+
-
-
+
+
+
+
+
+
+
@@ -2227,31 +2205,31 @@
WlanListItem
-
+
Bağlanamadı
-
-
+
+
Bağlantıyı Kes
-
-
-
+
+
+
-
-
+
+
-
+
@@ -2315,17 +2293,17 @@
main
-
+
-
+
-
+
@@ -2333,12 +2311,12 @@
vpnMainWindow
-
+
-
+
diff --git a/translations/kylin-nm_zh_CN.ts b/translations/kylin-nm_zh_CN.ts
index 9fb0d6df..d78db51d 100644
--- a/translations/kylin-nm_zh_CN.ts
+++ b/translations/kylin-nm_zh_CN.ts
@@ -42,21 +42,13 @@
- 公用(推荐) 网络中的设备不可发现此电脑。一般情况下适用于公共场所中的网络,如机场或咖啡店等等。
+ 公用(推荐) 网络中的设备不可发现此电脑。一般情况下适用于公共场所中的网络,如机场或咖啡店等等。
-
+
专用 网络中的设备可发现此电脑。一般情况下适用于家庭或工作单位的网络,您认识并信任网络上的个人和设备。
-
-
- 公用(推荐)无法在网络上发现你的设备。在大多数情况下,在家庭、工作或公共位置连接到网络时使用此功能。
-
-
-
- 专用 可在网络上发现你的设备。如果需要文件共享或使用通过此网络通信的应用,请选择此项。你应该了解并信任网络上的人员和设备。
-
@@ -81,51 +73,63 @@
CreatNetPage
-
+
网络名称
-
+
IPv4配置
-
+
IPv4地址
-
+
子网掩码
-
+
默认网关
+
- 首选DNS
+ 首选DNS
+
- 备选DNS
+ 备选DNS
-
+
自动(DHCP)
-
+
手动
-
-
+
+
+ 无效地址
+
+
+
+
+ 无效子网掩码
+
+
+
+
必填
@@ -133,82 +137,82 @@
DetailPage
-
+
自动连接
-
-
+
+
SSID:
-
+
复制成功!
-
+
复制全部
-
+
请输入SSID:
-
-
+
+
协议:
-
-
+
+
安全类型:
-
-
+
+
网络频带:
-
-
+
+
网络通道:
-
-
+
+
带宽:
-
-
+
+
本地链接IPv6地址:
-
-
+
+
IPv4地址:
-
-
-
+
+
+
IPv4 DNS服务器:
-
-
+
+
物理地址:
@@ -498,22 +502,22 @@
否
-
+
是否允许此网络上的其他设备发现这台电脑?
-
+
不建议在公共网络上开启此功能
-
+
不允许(推荐)
-
+
允许
@@ -521,32 +525,34 @@
Ipv4Page
-
+
IPv4配置
-
+
地址
-
+
子网掩码
-
+
默认网关
+
- 首选DNS
+ 首选DNS
+
- 备选DNS
+ 备选DNS
@@ -559,23 +565,23 @@
手动
-
+
无效地址
-
+
无效子网掩码
-
-
+
+
必填
-
+
地址冲突
@@ -583,62 +589,64 @@
Ipv6Page
-
+
IPv6配置
-
+
地址
-
+
子网前缀长度
-
+
默认网关
+
- 首选DNS
+ 首选DNS
+
- 备选DNS
+ 备选DNS
-
+
自动
-
+
手动
-
-
-
+
+
+
必填
-
+
无效地址
-
+
无效网关
-
+
地址冲突
@@ -709,26 +717,34 @@
连接
+
+
+ 属性
+
+
+
+ 删除此网络
+
LanPage
-
+
未检测到有线设备
-
+
有线网络
-
+
我的网络
-
+
其他网络
@@ -737,7 +753,7 @@
有线网络已断开
-
+
未插入网线
@@ -749,12 +765,12 @@
ListItem
-
+
麒麟网络设置工具
-
+
网络提示消息
@@ -762,76 +778,68 @@
MainWindow
-
+
网络工具
-
+
有线网络
有线网络
-
+
无线局域网
无线局域网
-
+
打开网络工具
-
+
设置网络项
设置网络项
-
+
网络工具
-
- MultipleDnsWidget
-
-
-
- DNS服务器:
-
-
NetDetail
-
+
麒麟网络设置工具
-
+
网络提示消息
-
+
详情
-
+
IPv4
-
+
IPv6
-
+
安全
@@ -840,62 +848,61 @@
关闭
-
-
+
+
配置
-
+
确定
-
+
取消
-
+
忘记此网络
-
-
+
删除此网络
-
-
+
+
添加有线网络
-
-
+
+
连接到隐藏WLAN
-
-
-
+
+
+
无
-
-
-
+
+
+
自动
-
+
开始检测ipv4地址冲突
-
+
开始检测ipv6地址冲突
@@ -908,22 +915,22 @@
ipv6地址冲突!
-
+
此wifi不支持企业网类型
-
+
此wifi不支持空类型
-
+
此wifi不支持WPA2类型
-
+
此wifi不支持WPA3类型
@@ -952,7 +959,7 @@
IPv4地址:
-
+
IPv4 DNS服务器:
@@ -1108,13 +1115,8 @@
-
- 用户名
-
-
- Usename
- 用户名
+ 用户名
@@ -1206,24 +1208,6 @@
-
- SinglePage
-
-
-
- 设置
-
-
-
-
- 网络工具
-
-
-
-
- 网络提示消息
-
-
TabPage
@@ -1237,56 +1221,37 @@
设备关闭!
-
+
网络设置
-
+
麒麟网络设置工具
-
+
网络提示消息
-
- VpnListItem
-
-
-
- 未连接
-
-
-
-
-
- 断开
-
-
-
-
-
- 连接
-
-
VpnPage
+
+
+
+
+
+
+
+
+
+
+
- 未插入网线
-
-
-
-
- VPN连接
-
-
-
-
- VPN设置
+ 未插入网线
@@ -1335,31 +1300,35 @@
WlanListItem
-
+
未连接
-
-
+
+
断开
-
-
-
+
+
+
连接
-
-
+
+
忘记此网络
+
+
+
+ 属性
-
+
自动加入该网络
@@ -1471,17 +1440,17 @@
main
-
+
-
+
-
+
@@ -1489,14 +1458,14 @@
vpnMainWindow
-
+
- VPN工具
+
-
+
- VPN工具
+
From bc2276f64643e1f88e1bbfa4c6cd64373df34cfb Mon Sep 17 00:00:00 2001
From: jzxc95 <907297917@qq.com>
Date: Fri, 7 Apr 2023 10:03:38 +0800
Subject: [PATCH 02/10] =?UTF-8?q?openkylin=20=E6=94=B9=E5=8A=A8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/backend/vpndbusadaptor.cpp | 72 --
src/backend/vpndbusadaptor.h | 71 --
src/frontend/list-items/vpnlistitem.cpp | 244 -------
src/frontend/list-items/vpnlistitem.h | 77 ---
src/frontend/mainwindow.cpp | 29 +-
src/frontend/mainwindow.h | 4 +
src/frontend/netdetails/ipv4page.h | 3 +-
.../netdetails/joinhiddenwifipage.cpp | 14 +
src/frontend/netdetails/joinhiddenwifipage.h | 3 +
src/frontend/netdetails/netdetail.cpp | 134 +++-
src/frontend/netdetails/netdetail.h | 6 +-
src/frontend/single-pages/single-pages.pri | 10 -
src/frontend/single-pages/singlepage.cpp | 108 ---
src/frontend/single-pages/singlepage.h | 109 ---
src/frontend/single-pages/vpnpage.cpp | 645 ------------------
src/frontend/single-pages/vpnpage.h | 126 ----
src/frontend/tab-pages/lanpage.cpp | 1 +
src/frontend/tab-pages/wlanpage.cpp | 2 +
src/frontend/vpnmainwindow.cpp | 495 --------------
src/frontend/vpnmainwindow.h | 127 ----
src/main.cpp | 2 +-
21 files changed, 174 insertions(+), 2108 deletions(-)
delete mode 100644 src/backend/vpndbusadaptor.cpp
delete mode 100644 src/backend/vpndbusadaptor.h
delete mode 100644 src/frontend/list-items/vpnlistitem.cpp
delete mode 100644 src/frontend/list-items/vpnlistitem.h
delete mode 100644 src/frontend/single-pages/single-pages.pri
delete mode 100644 src/frontend/single-pages/singlepage.cpp
delete mode 100644 src/frontend/single-pages/singlepage.h
delete mode 100644 src/frontend/single-pages/vpnpage.cpp
delete mode 100644 src/frontend/single-pages/vpnpage.h
delete mode 100644 src/frontend/vpnmainwindow.cpp
delete mode 100644 src/frontend/vpnmainwindow.h
diff --git a/src/backend/vpndbusadaptor.cpp b/src/backend/vpndbusadaptor.cpp
deleted file mode 100644
index 1b43deb0..00000000
--- a/src/backend/vpndbusadaptor.cpp
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * This file was generated by qdbusxml2cpp version 0.8
- * Command line was: qdbusxml2cpp com.kylin.weather.xml -a VpnDbusAdaptor -c VpnDbusAdaptor -l MainWindow
- *
- * qdbusxml2cpp is Copyright (C) 2015 The Qt Company Ltd.
- *
- * This is an auto-generated file.
- * Do not edit! All changes made to it will be lost.
- */
-
-#include "vpndbusadaptor.h"
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-/*
- * Implementation of adaptor class VpnDbusAdaptor
- */
-
-VpnDbusAdaptor::VpnDbusAdaptor(vpnMainWindow *parent)
- : QDBusAbstractAdaptor(parent)
-{
- // constructor
- qDBusRegisterMetaType >();
- qDBusRegisterMetaType >();
- qDBusRegisterMetaType >();
- //setAutoRelaySignals(true)后会自动转发mainwindow发出的同名信号,因此不必再额外写一个转发
- setAutoRelaySignals(true);
-}
-
-VpnDbusAdaptor::~VpnDbusAdaptor()
-{
- // destructor
-}
-
-//虚拟连接列表
-QVector VpnDbusAdaptor::getVirtualList()
-{
- QVector vector;
- parent()->getVirtualList(vector);
- return vector;
-}
-
-//删除
-void VpnDbusAdaptor::deleteVpn(QString uuid)
-{
- qDebug() << "delete vpn" << uuid;
- parent()->deleteVpn(uuid);
-}
-
-//连接 根据网卡类型 参数1 0:lan 1:wlan 参数3 为ssid/uuid
-void VpnDbusAdaptor::activateVpn(const QString& connUuid)
-{
- qDebug() << "activate vpn" << connUuid;
- parent()->activateVpn(connUuid);
-}
-
-//断开连接 根据网卡类型 参数1 0:lan 1:wlan 参数3 为ssid/uuid
-void VpnDbusAdaptor::deactivateVpn(const QString& connUuid)
-{
- qDebug() << "deactivate vpn" << connUuid;
- parent()->deactivateVpn(connUuid);
-}
-
-void VpnDbusAdaptor::showKylinVpn()
-{
- parent()->onShowMainWindow();
-}
diff --git a/src/backend/vpndbusadaptor.h b/src/backend/vpndbusadaptor.h
deleted file mode 100644
index 2fba0c84..00000000
--- a/src/backend/vpndbusadaptor.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * This file was generated by qdbusxml2cpp version 0.8
- * Command line was: qdbusxml2cpp com.kylin.weather.xml -a dbusadaptor -c DbusAdaptor -l MainWindow
- *
- * qdbusxml2cpp is Copyright (C) 2015 The Qt Company Ltd.
- *
- * This is an auto-generated file.
- * This file may have been hand-edited. Look for HAND-EDIT comments
- * before re-generating it.
- */
-
-#ifndef VPNDBUSADAPTOR_H
-#define VPNDBUSADAPTOR_H
-
-#include
-#include
-#include
-
-#include "singlepage.h"
-#include "../dbus-interface/kylinnetworkdeviceresource.h"
-QT_BEGIN_NAMESPACE
-class QByteArray;
-//template class QList;
-template class QMap;
-class QString;
-class QStringList;
-class QVariant;
-template class QVector;
-QT_END_NAMESPACE
-
-/*
- * Adaptor class for interface com.kylin.weather
- */
-
-#include "vpnmainwindow.h"
-
-class VpnDbusAdaptor: public QDBusAbstractAdaptor
-{
- Q_OBJECT
- Q_CLASSINFO("D-Bus Interface", "com.kylin.vpnTool")
-public:
- VpnDbusAdaptor(vpnMainWindow *parent);
- virtual ~VpnDbusAdaptor();
-
- inline vpnMainWindow *parent() const
- { return static_cast(QObject::parent()); }
-
-public: // PROPERTIES
-public Q_SLOTS: // METHODS
- //虚拟连接列表
- QVector getVirtualList();
- //刪除 根据网络名称 参数1 0:lan 1:wlan 参数2 为ssid/uuid
- Q_NOREPLY void deleteVpn(QString uuid);
- //连接 根据网卡类型 参数1 0:lan 1:wlan 参数3 为ssid/uuid
- Q_NOREPLY void activateVpn(const QString& connUuid);
- //断开连接 根据网卡类型 参数1 0:lan 1:wlan 参数3 为ssid/uuid
- Q_NOREPLY void deactivateVpn(const QString& connUuid);
- //just show
- void showKylinVpn();
-
-Q_SIGNALS: // SIGNALS
- void vpnAdd(QStringList info);
- void vpnRemove(QString dbusPath);
- void vpnUpdate(QStringList info);
- void vpnActiveConnectionStateChanged(QString uuid, int status);
-
- void activateFailed(QString errorMessage);
- void deactivateFailed(QString errorMessage);
-};
-
-#endif
diff --git a/src/frontend/list-items/vpnlistitem.cpp b/src/frontend/list-items/vpnlistitem.cpp
deleted file mode 100644
index 0a1541d1..00000000
--- a/src/frontend/list-items/vpnlistitem.cpp
+++ /dev/null
@@ -1,244 +0,0 @@
-/* -*- 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 "vpnlistitem.h"
-#include "backend/dbus-interface/kylinconnectitem.h"
-
-#include
-
-#define LOG_FLAG "[VpnListItem]"
-
-VpnListItem::VpnListItem(const KyConnectItem *lanConnectItem, QWidget *parent):ListItem(parent)
-{
- m_connectOperation = new KyWiredConnectOperation(this);
- m_deviceResource = new KyNetworkDeviceResourse(this);
-
- connectItemCopy(lanConnectItem);
-
- m_nameLabel->setLabelText(m_vpnConnectItem.m_connectName);
- m_netButton->setButtonIcon(QIcon::fromTheme("ukui-vpn-symbolic"));
-
- qDebug() << "VpnListItem init:" << m_vpnConnectItem.m_connectName << m_vpnConnectItem.m_connectState << m_vpnConnectItem.m_ifaceName;
-
- if (Deactivated == m_vpnConnectItem.m_connectState || Activated == m_vpnConnectItem.m_connectState) {
- m_netButton->stopLoading();
- if (m_vpnConnectItem.m_connectState == Activated) {
- setIcon(true);
- } else {
- setIcon(false);
- }
- } else {
- m_netButton->startLoading();
- }
-
- m_itemFrame->installEventFilter(this);
- connect(this->m_infoButton, &InfoButton::clicked, this, &VpnListItem::onInfoButtonClicked);
- connect(m_menu, &QMenu::triggered, this, &VpnListItem::onMenuTriggered);
-}
-
-
-VpnListItem::VpnListItem(QWidget *parent) : ListItem(parent)
-{
- m_isActive = false;
- m_netButton->setButtonIcon(QIcon::fromTheme("ukui-vpn-symbolic"));
- setIcon(false);
- const QString str=tr("Not connected");
- m_nameLabel->setLabelText(str);
- this->m_infoButton->hide();
-}
-
-VpnListItem::~VpnListItem()
-{
- qDebug()<<"[LanPage] lan list item is deleted." << m_vpnConnectItem.m_connectName;
-}
-
-void VpnListItem::setIcon(bool isOn)
-{
- if (isOn) {
- m_netButton->setActive(true); //设置图标显示不同颜色
- } else {
- m_netButton->setActive(false);
- }
-}
-
-void VpnListItem::connectItemCopy(const KyConnectItem *lanConnectItem)
-{
- if (lanConnectItem) {
- m_vpnConnectItem.m_connectName = lanConnectItem->m_connectName;
- m_vpnConnectItem.m_connectPath = lanConnectItem->m_connectPath;
- m_vpnConnectItem.m_connectState = lanConnectItem->m_connectState;
- m_vpnConnectItem.m_connectUuid = lanConnectItem->m_connectUuid;
- m_vpnConnectItem.m_ifaceName = lanConnectItem->m_ifaceName;
- m_vpnConnectItem.m_itemType = lanConnectItem->m_itemType;
- } else {
- qDebug() << LOG_FLAG <<"the connect item is nullptr";
- m_vpnConnectItem.m_connectName = "";
- m_vpnConnectItem.m_connectPath = "";
- m_vpnConnectItem.m_connectState = NetworkManager::ActiveConnection::State::Unknown;
- m_vpnConnectItem.m_connectUuid = "";
- m_vpnConnectItem.m_ifaceName = "";
- m_vpnConnectItem.m_itemType = NetworkManager::ConnectionSettings::ConnectionType::Unknown;
- }
-
- return;
-}
-
-//void VpnListItem::changeState(QString uuid,
-// NetworkManager::ActiveConnection::State state,
-// NetworkManager::ActiveConnection::Reason reason)
-//{
-
-//}
-
-void VpnListItem::activeConnection()
-{
- if (m_vpnConnectItem.m_connectUuid.isEmpty()) {
- qDebug() << LOG_FLAG << "connect is empty, so can not connect or disconnect.";
- return;
- }
-
- if (Deactivated == m_vpnConnectItem.m_connectState) {
- //断开的连接,点击激活连接
- m_connectOperation->activateVpnConnection(m_vpnConnectItem.m_connectUuid);
- qDebug() << LOG_FLAG << "it will activate connection" << m_vpnConnectItem.m_connectName;
- m_netButton->startLoading();
- } else {
- qDebug() << LOG_FLAG <<"the connection" << m_vpnConnectItem.m_connectName
- << "is not deactived, so it can not be operation.";
- }
-
- return;
-}
-
-void VpnListItem::onNetButtonClicked()
-{
- if (m_vpnConnectItem.m_connectUuid.isEmpty()) {
- qDebug() << LOG_FLAG << "connect is empty, so can not connect or disconnect.";
- return;
- }
-
- if (Deactivated == m_vpnConnectItem.m_connectState) {
- //断开的连接,点击激活连接
- m_connectOperation->activateVpnConnection(m_vpnConnectItem.m_connectUuid);
- qDebug() << LOG_FLAG << "it will activate connection" << m_vpnConnectItem.m_connectName;
- m_netButton->startLoading();
- } else {
- qDebug() << LOG_FLAG <<"the connection" << m_vpnConnectItem.m_connectName
- << "is not deactived, so it can not be operation.";
- }
-
- return;
-
-}
-
-void VpnListItem::onRightButtonClicked()
-{
- //右键点击事件
- qDebug()<< LOG_FLAG <<"onRightButtonClicked";
- if (!m_menu) {
- return;
- }
-
- m_menu->clear();
- if (Activated == m_vpnConnectItem.m_connectState || Activating == m_vpnConnectItem.m_connectState) {
- m_menu->addAction(new QAction(tr("Disconnect"), this));
- } else if (Deactivated == m_vpnConnectItem.m_connectState) {
- m_menu->addAction(new QAction(tr("Connect"), this));
- } else {
- return;
- }
-
- m_menu->move(cursor().pos());
- m_menu->show();
- return;
-}
-
-void VpnListItem::onMenuTriggered(QAction *action)
-{
- if (action->text() == tr("Connect")) {
- this->onNetButtonClicked();
- } else if (action->text() == tr("Disconnect")) {
- m_connectOperation->deactivateWiredConnection(m_vpnConnectItem.m_connectName, m_vpnConnectItem.m_connectUuid);
- qDebug() << LOG_FLAG << "it will disconnect connection" << m_vpnConnectItem.m_connectName;
- m_netButton->startLoading();
- }
- return;
-}
-
-bool VpnListItem::launchApp(QString desktopFile)
-{
- QDBusInterface appManagerDbusInterface(KYLIN_APP_MANAGER_NAME,
- KYLIN_APP_MANAGER_PATH,
- KYLIN_APP_MANAGER_INTERFACE,
- QDBusConnection::sessionBus());
-
- if (!appManagerDbusInterface.isValid()) {
- qWarning()<<"appManagerDbusInterface init error";
- return false;
- } else {
- QDBusReply reply = appManagerDbusInterface.call("LaunchApp", desktopFile);
- return reply;
- }
-}
-
-void VpnListItem::onInfoButtonClicked()
-{
- launchApp("nm-connection-editor.desktop");
- return;
-}
-
-void VpnListItem::updateConnectionState(ConnectState state)
-{
- m_vpnConnectItem.m_connectState = (NetworkManager::ActiveConnection::State)state;
-
- if (Deactivated == state || Activated == state) {
- m_netButton->stopLoading();
- if (state == Activated) {
- setIcon(true);
- } else {
- setIcon(false);
- }
- } else {
- m_netButton->startLoading();
- }
-
- return;
-}
-
-QString VpnListItem::getConnectionName()
-{
- return m_vpnConnectItem.m_connectName;
-}
-
-void VpnListItem::updateConnectionName(QString connectionName)
-{
- m_vpnConnectItem.m_connectName = connectionName;
- m_nameLabel->setLabelText(m_vpnConnectItem.m_connectName);
- return;
-}
-
-QString VpnListItem::getConnectionPath()
-{
- return m_vpnConnectItem.m_connectPath;
-}
-
-void VpnListItem::updateConnectionPath(QString connectionPath)
-{
- m_vpnConnectItem.m_connectPath = connectionPath;
-}
diff --git a/src/frontend/list-items/vpnlistitem.h b/src/frontend/list-items/vpnlistitem.h
deleted file mode 100644
index b65d22dc..00000000
--- a/src/frontend/list-items/vpnlistitem.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/* -*- 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 VPNLISTITEM_H
-#define VPNLISTITEM_H
-#include "listitem.h"
-#include "kylinactiveconnectresource.h"
-
-#include
-#include
-#include
-
-#define KYLIN_APP_MANAGER_NAME "com.kylin.AppManager"
-#define KYLIN_APP_MANAGER_PATH "/com/kylin/AppManager"
-#define KYLIN_APP_MANAGER_INTERFACE "com.kylin.AppManager"
-
-class VpnListItem : public ListItem
-{
- Q_OBJECT
-
-public:
- VpnListItem(const KyConnectItem *lanConnectItem, QWidget *parent = nullptr);
- VpnListItem(QWidget *parent = nullptr);
-
- ~VpnListItem();
-
-public:
- void updateConnectionState(ConnectState state);
-
- QString getConnectionName();
- void updateConnectionName(QString connectionName);
-
- QString getConnectionPath();
- void updateConnectionPath(QString connectionPath);
-
- void activeConnection();
-
-protected:
- void setIcon(bool isOn);
- void onRightButtonClicked();
- bool launchApp(QString desktopFile);
-
-private:
- void connectItemCopy(const KyConnectItem *lanConnectItem);
-
-private Q_SLOTS:
- void onInfoButtonClicked();
- void onNetButtonClicked();
- void onMenuTriggered(QAction *action);
-
-private:
- KyConnectItem m_vpnConnectItem;
-// QDBusInterface m_appManagerDbusInterface;
-
- KyWiredConnectOperation *m_connectOperation = nullptr;
- KyNetworkDeviceResourse *m_deviceResource = nullptr;
-
- QString m_deviceName = "";
-};
-
-#endif // VPNLISTITEM_H
diff --git a/src/frontend/mainwindow.cpp b/src/frontend/mainwindow.cpp
index 56fcf996..19a0ff29 100644
--- a/src/frontend/mainwindow.cpp
+++ b/src/frontend/mainwindow.cpp
@@ -153,6 +153,7 @@ void MainWindow::firstlyStart()
{
initWindowProperties();
initTransparency();
+ registerTrayIcon();
initUI();
initDbusConnnect();
initWindowTheme();
@@ -228,6 +229,30 @@ void MainWindow::initWindowProperties()
}
}
+/**
+ * @brief MainWindow::registerTrayIcon 注册托盘图标
+ */
+void MainWindow::registerTrayIcon()
+{
+ m_registerCount++;
+ if (QSystemTrayIcon::isSystemTrayAvailable() || m_registerCount > 10) {
+ m_trayIcon = new QSystemTrayIcon();
+ if (nullptr == m_trayIcon) {
+ qWarning()<< "分配空间trayIcon失败";
+ return ;
+ }
+ m_trayIcon->setIcon(QIcon::fromTheme("network-wired-signal-excellent-symbolic"));
+ m_trayIcon->setToolTip(QString(tr("kylin-nm")));
+
+ } else {
+ if (m_registerCount <= 10) {
+ QTimer::singleShot(m_intervalTime,[this] {
+ registerTrayIcon();
+ });
+ }
+ }
+}
+
void MainWindow::paintEvent(QPaintEvent *event)
{
QPainter painter(this);
@@ -323,17 +348,14 @@ void MainWindow::initTrayIcon()
iconTimer = new QTimer(this);
connect(iconTimer, &QTimer::timeout, this, &MainWindow::onSetTrayIconLoading);
- m_trayIcon = new QSystemTrayIcon();
m_trayIconMenu = new QMenu();
m_showMainwindowAction = new QAction(tr("Show MainWindow"),this);
m_showSettingsAction = new QAction(tr("Settings"),this);
- m_trayIcon->setToolTip(QString(tr("Network tool")));
m_showSettingsAction->setIcon(QIcon::fromTheme("document-page-setup-symbolic", QIcon(":/res/x/setup.png")) );
// m_trayIconMenu->addAction(m_showMainwindowAction);
m_trayIconMenu->addAction(m_showSettingsAction);
m_trayIcon->setContextMenu(m_trayIconMenu);
- m_trayIcon->setIcon(QIcon::fromTheme("network-wired-signal-excellent-symbolic"));
iconStatus = IconActiveType::LAN_CONNECTED;
onRefreshTrayIcon();
@@ -875,6 +897,7 @@ void MainWindow::showCreateWiredConnectWidget(const QString devName)
});
m_createPagePtrMap.insert(devName, netDetail);
netDetail->show();
+ netDetail->centerToScreen();
}
void MainWindow::showAddOtherWlanWidget(QString devName)
diff --git a/src/frontend/mainwindow.h b/src/frontend/mainwindow.h
index b7bcb591..d16533b8 100644
--- a/src/frontend/mainwindow.h
+++ b/src/frontend/mainwindow.h
@@ -153,6 +153,7 @@ private:
void paintWithTrans();
void initUI();
void initDbusConnnect();
+ void registerTrayIcon();
void initTrayIcon();
void resetTrayIconTool();
@@ -200,6 +201,9 @@ private:
NetworkMode *m_networkMode;
+ uint m_intervalTime = 100;
+ uint m_registerCount = 0;
+
public Q_SLOTS:
void onShowMainWindow(int type);
diff --git a/src/frontend/netdetails/ipv4page.h b/src/frontend/netdetails/ipv4page.h
index f5e9a779..55c2be09 100644
--- a/src/frontend/netdetails/ipv4page.h
+++ b/src/frontend/netdetails/ipv4page.h
@@ -52,6 +52,8 @@ public:
void stopLoading();
void showIpv4AddressConflict(bool isConflict);
+ QString getNetMaskText(QString text);
+
private:
QComboBox *ipv4ConfigCombox;
LineEdit *ipv4addressEdit;
@@ -90,7 +92,6 @@ private:
void configSave();
bool getTextEditState(QString text);
bool netMaskIsValide(QString text);
- QString getNetMaskText(QString text);
bool checkConnectBtnIsEnabled();
void initConflictHintLable();
void initLoadingIcon();
diff --git a/src/frontend/netdetails/joinhiddenwifipage.cpp b/src/frontend/netdetails/joinhiddenwifipage.cpp
index 4581e84f..51c0900b 100644
--- a/src/frontend/netdetails/joinhiddenwifipage.cpp
+++ b/src/frontend/netdetails/joinhiddenwifipage.cpp
@@ -274,3 +274,17 @@ void JoinHiddenWiFiPage::onPaletteChanged()
}
}
+void JoinHiddenWiFiPage::centerToScreen()
+{
+ QDesktopWidget* m = QApplication::desktop();
+ QRect desk_rect = m->screenGeometry(m->screenNumber(QCursor::pos()));
+ int desk_x = desk_rect.width();
+ int desk_y = desk_rect.height();
+ int x = this->width();
+ int y = this->height();
+// this->move(desk_x / 2 - x / 2 + desk_rect.left(), desk_y / 2 - y / 2 + desk_rect.top());
+ kdk::WindowManager::setGeometry(this->windowHandle(), QRect(desk_x / 2 - x / 2 + desk_rect.left(),
+ desk_y / 2 - y / 2 + desk_rect.top(),
+ this->width(),
+ this->height()));
+}
diff --git a/src/frontend/netdetails/joinhiddenwifipage.h b/src/frontend/netdetails/joinhiddenwifipage.h
index 1a9806d1..5f97b56b 100644
--- a/src/frontend/netdetails/joinhiddenwifipage.h
+++ b/src/frontend/netdetails/joinhiddenwifipage.h
@@ -24,7 +24,9 @@
#include
#include
#include
+#include
+#include "windowmanager/windowmanager.h"
#include "coninfo.h"
#include "kywirelessconnectoperation.h"
#include "securitypage.h"
@@ -43,6 +45,7 @@ public:
JoinHiddenWiFiPage(QString devName, KDialog *parent = nullptr);
~JoinHiddenWiFiPage();
+ void centerToScreen();
protected:
void closeEvent(QCloseEvent *event);
diff --git a/src/frontend/netdetails/netdetail.cpp b/src/frontend/netdetails/netdetail.cpp
index 9d727c8f..d470b264 100644
--- a/src/frontend/netdetails/netdetail.cpp
+++ b/src/frontend/netdetails/netdetail.cpp
@@ -270,11 +270,11 @@ void NetDetail::centerToScreen()
int desk_y = desk_rect.height();
int x = this->width();
int y = this->height();
- this->move(desk_x / 2 - x / 2 + desk_rect.left(), desk_y / 2 - y / 2 + desk_rect.top());
-// kdk::WindowManager::setGeometry(this->windowHandle(), QRect(desk_x / 2 - x / 2 + desk_rect.left(),
-// desk_y / 2 - y / 2 + desk_rect.top(),
-// this->width(),
-// this->height()));
+// this->move(desk_x / 2 - x / 2 + desk_rect.left(), desk_y / 2 - y / 2 + desk_rect.top());
+ kdk::WindowManager::setGeometry(this->windowHandle(), QRect(desk_x / 2 - x / 2 + desk_rect.left(),
+ desk_y / 2 - y / 2 + desk_rect.top(),
+ this->width(),
+ this->height()));
}
void NetDetail::initUI()
@@ -651,22 +651,29 @@ void NetDetail::getStaticIpInfo(ConInfo &conInfo, bool bActived)
kyConnectResourse->getConnectionSetting(m_uuid,connetSetting);
connetSetting.dumpInfo();
- conInfo.ipv4ConfigType = connetSetting.m_ipv4ConfigIpType;
+// conInfo.ipv4ConfigType = connetSetting.m_ipv4ConfigIpType;
conInfo.ipv6ConfigType = connetSetting.m_ipv6ConfigIpType;
conInfo.isAutoConnect = connetSetting.m_isAutoConnect;
- if (connetSetting.m_ipv4ConfigIpType == CONFIG_IP_MANUAL) {
- if (connetSetting.m_ipv4Address.size() > 0) {
- conInfo.strIPV4Address = connetSetting.m_ipv4Address.at(0).ip().toString();
- conInfo.strIPV4NetMask = connetSetting.m_ipv4Address.at(0).netmask().toString();
- conInfo.strIPV4GateWay = connetSetting.m_ipv4Address.at(0).gateway().toString();
- }
- if (connetSetting.m_ipv4Dns.size() == 1) {
- conInfo.strIPV4FirDns = connetSetting.m_ipv4Dns.at(0).toString();
- } else if (connetSetting.m_ipv4Dns.size() > 1) {
- conInfo.strIPV4FirDns = connetSetting.m_ipv4Dns.at(0).toString();
- conInfo.strIPV4SecDns = connetSetting.m_ipv4Dns.at(1).toString();
- }
+// if (connetSetting.m_ipv4ConfigIpType == CONFIG_IP_MANUAL) {
+// if (connetSetting.m_ipv4Address.size() > 0) {
+// conInfo.strIPV4Address = connetSetting.m_ipv4Address.at(0).ip().toString();
+// conInfo.strIPV4NetMask = connetSetting.m_ipv4Address.at(0).netmask().toString();
+// conInfo.strIPV4GateWay = connetSetting.m_ipv4Address.at(0).gateway().toString();
+// }
+// if (connetSetting.m_ipv4Dns.size() == 1) {
+// conInfo.strIPV4FirDns = connetSetting.m_ipv4Dns.at(0).toString();
+// } else if (connetSetting.m_ipv4Dns.size() > 1) {
+// conInfo.strIPV4FirDns = connetSetting.m_ipv4Dns.at(0).toString();
+// conInfo.strIPV4SecDns = connetSetting.m_ipv4Dns.at(1).toString();
+// }
+// }
+ //openkylin从第三方库读取有问题 改为ipv4信息直接通过dbus获取
+ KyConnectItem* item = kyConnectResourse->getConnectionItemByUuidWithoutActivateChecking(m_uuid);
+ if (item == nullptr) {
+ conInfo.ipv4ConfigType = CONFIG_IP_DHCP;
+ } else {
+ getIpv4Info(item->m_connectPath, conInfo);
}
if (connetSetting.m_ipv6ConfigIpType == CONFIG_IP_MANUAL) {
@@ -1224,3 +1231,94 @@ void ThreadObject::checkIpv6ConflictThread(const QString &ipv6Address)
ipv6rping = nullptr;
Q_EMIT ipv6IsConflict(isConflict);
}
+
+void NetDetail::getIpv4Info(QString objPath, ConInfo &conInfo)
+{
+ QDBusInterface m_interface("org.freedesktop.NetworkManager",
+ objPath,
+ "org.freedesktop.NetworkManager.Settings.Connection",
+ QDBusConnection::systemBus());
+ QDBusMessage result = m_interface.call("GetSettings");
+
+ if (result.arguments().isEmpty()) { return; }
+ const QDBusArgument &dbusArg1st = result.arguments().at( 0 ).value();
+ QMap> map;
+ dbusArg1st >> map;
+
+ for (QString key : map.keys() ) {
+ QMap innerMap = map.value(key);
+ if (key == "ipv4") {
+ for (QString inner_key : innerMap.keys()) {
+ if (inner_key == "address-data") {
+ //ipv4地址 ipv4子网掩码
+ const QDBusArgument &dbusArg2nd = innerMap.value(inner_key).value();
+ QVector> addressVector;
+
+ dbusArg2nd.beginArray();
+
+ while (!dbusArg2nd.atEnd()) {
+ QMap tempMap;
+ dbusArg2nd >> tempMap;
+ addressVector.append(tempMap);
+ }
+ dbusArg2nd.endArray();
+ if (addressVector.size() >= 1) {
+ conInfo.strIPV4Address = addressVector.at(0).value("address").toString();
+ conInfo.strIPV4NetMask = ipv4Page->getNetMaskText(addressVector.at(0).value("prefix").toString());
+ }
+ } else if (inner_key == "method") {
+ //ipv4 method
+ if (innerMap.value(inner_key).toString() == "auto")
+ conInfo.ipv4ConfigType = CONFIG_IP_DHCP;
+ else {
+ conInfo.ipv4ConfigType = CONFIG_IP_MANUAL;
+ }
+ } else if (inner_key == "dns") {
+ //dns
+ const QDBusArgument &dbusArg2nd = innerMap.value(inner_key).value();
+ QList addressVector;
+
+ dbusArg2nd.beginArray();
+ while (!dbusArg2nd.atEnd()) {
+ uint tempMap;
+ dbusArg2nd >> tempMap;
+ addressVector.append(tempMap);
+ }
+ 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();
+ }
+ }
+ }
+ // if (key == "ipv6") {
+ // for (QString inner_key : innerMap.keys()) {
+ // if (inner_key == "address-data"){
+ // const QDBusArgument &dbusArg2nd = innerMap.value(inner_key).value();
+ // QMap