From 4b8ad410a9b21f1a9298f31f041b24cd8ed99450 Mon Sep 17 00:00:00 2001 From: chenxuechao Date: Thu, 20 Oct 2022 19:25:33 +0800 Subject: [PATCH] vpn merge --- debian/changelog | 6 + debian/control | 2 + .../dbus-interface/kylinconnectresource.cpp | 78 ++ .../dbus-interface/kylinconnectresource.h | 2 + src/frontend/frontend.pri | 3 + src/frontend/list-items/list-items.pri | 6 +- src/frontend/list-items/vpnlistitem.cpp | 241 ++++++ src/frontend/list-items/vpnlistitem.h | 69 ++ src/frontend/mainwindow.cpp | 16 +- src/frontend/mainwindow.h | 1 - src/frontend/single-pages/single-pages.pri | 10 + src/frontend/single-pages/singlepage.cpp | 109 +++ src/frontend/single-pages/singlepage.h | 113 +++ src/frontend/single-pages/vpnpage.cpp | 656 ++++++++++++++++ src/frontend/single-pages/vpnpage.h | 124 +++ src/frontend/vpnmainwindow.cpp | 717 ++++++++++++++++++ src/frontend/vpnmainwindow.h | 167 ++++ src/main.cpp | 5 +- src/src.pro | 3 +- translations/kylin-nm_bo.ts | 338 +++++---- translations/kylin-nm_tr.ts | 338 +++++---- translations/kylin-nm_zh_CN.qm | Bin 7868 -> 8102 bytes translations/kylin-nm_zh_CN.ts | 337 ++++---- 23 files changed, 2928 insertions(+), 413 deletions(-) create mode 100644 src/frontend/list-items/vpnlistitem.cpp create mode 100644 src/frontend/list-items/vpnlistitem.h create mode 100644 src/frontend/single-pages/single-pages.pri create mode 100644 src/frontend/single-pages/singlepage.cpp create mode 100644 src/frontend/single-pages/singlepage.h create mode 100644 src/frontend/single-pages/vpnpage.cpp create mode 100644 src/frontend/single-pages/vpnpage.h create mode 100644 src/frontend/vpnmainwindow.cpp create mode 100644 src/frontend/vpnmainwindow.h diff --git a/debian/changelog b/debian/changelog index 61a25d01..f02d28ed 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +kylin-nm (3.14.0.0+0512-2k10) v101; urgency=medium + + * 托盘vpn需求 + + -- zhaoshixu Thu, 20 Oct 2022 20:21:39 +0800 + kylin-nm (3.14.0.0+0512-1k10) yangtz; urgency=medium * 同步3.22需求 diff --git a/debian/control b/debian/control index 605fa781..4f8b3798 100644 --- a/debian/control +++ b/debian/control @@ -10,6 +10,7 @@ Build-Depends: debhelper (>=9), libkf5networkmanagerqt-dev (>= 5.36.0), libkf5windowsystem-dev, libkysdk-qtwidgets-dev(>= 1.2.0), + libkysdk-sysinfo-dev, libkysdk-waylandhelper-dev(>= 1.2.0kylin2), libnm-dev, libnma-dev, @@ -39,6 +40,7 @@ Depends: libkysdk-qtwidgets(>= 1.2.0), network-manager (>=1.2.6), ukui-control-center (>= 3.1.1+1217), dpkg-dev, + libkysdk-sysinfo, ${shlibs:Depends}, ${misc:Depends} Description: Gui Applet tool for display and edit network simply diff --git a/src/backend/dbus-interface/kylinconnectresource.cpp b/src/backend/dbus-interface/kylinconnectresource.cpp index deebf692..3b59d0ad 100644 --- a/src/backend/dbus-interface/kylinconnectresource.cpp +++ b/src/backend/dbus-interface/kylinconnectresource.cpp @@ -162,6 +162,55 @@ 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() && !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; + } +} + void KyConnectResourse::getConnectionList(QString deviceName, NetworkManager::ConnectionSettings::ConnectionType connectionType, QList &connectItemList) @@ -694,6 +743,35 @@ 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 d0db17b3..fb8ece0a 100644 --- a/src/backend/dbus-interface/kylinconnectresource.h +++ b/src/backend/dbus-interface/kylinconnectresource.h @@ -20,6 +20,7 @@ public: public: KyConnectItem *getConnectionItemByUuid(QString connectUuid, bool checkActive = true); KyConnectItem *getConnectionItemByUuid(QString connectUuid, QString deviceName); + void getVpnAndVirtualConnections(QList &connectItemList); void getConnectionList(QString deviceName, NetworkManager::ConnectionSettings::ConnectionType connectionType, QList &connectItemList); @@ -33,6 +34,7 @@ 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/frontend/frontend.pri b/src/frontend/frontend.pri index ec60ca6c..02e96103 100644 --- a/src/frontend/frontend.pri +++ b/src/frontend/frontend.pri @@ -5,6 +5,7 @@ include(tab-pages/tab-pages.pri) include(list-items/list-items.pri) include(netdetails/netdetails.pri) include(enterprise-wlan/enterprise-wlan.pri) +include(single-pages/single-pages.pri) FORMS += \ $$PWD/wificonfigdialog.ui @@ -12,9 +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 diff --git a/src/frontend/list-items/list-items.pri b/src/frontend/list-items/list-items.pri index 8fdc468e..42550113 100644 --- a/src/frontend/list-items/list-items.pri +++ b/src/frontend/list-items/list-items.pri @@ -8,11 +8,13 @@ HEADERS += \ $$PWD/lanlistitem.h \ $$PWD/listitem.h \ $$PWD/wlanlistitem.h \ - $$PWD/wlanmoreitem.h + $$PWD/wlanmoreitem.h \ + $$PWD/vpnlistitem.h SOURCES += \ $$PWD/lanlistitem.cpp \ $$PWD/listitem.cpp \ $$PWD/wlanlistitem.cpp \ - $$PWD/wlanmoreitem.cpp + $$PWD/wlanmoreitem.cpp \ + $$PWD/vpnlistitem.cpp diff --git a/src/frontend/list-items/vpnlistitem.cpp b/src/frontend/list-items/vpnlistitem.cpp new file mode 100644 index 00000000..39de84b5 --- /dev/null +++ b/src/frontend/list-items/vpnlistitem.cpp @@ -0,0 +1,241 @@ +/* -*- 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_infoButton->setVisible(false); + m_connectOperation = new KyWiredConnectOperation(this); + m_deviceResource = new KyNetworkDeviceResourse(this); + + connectItemCopy(lanConnectItem); + + m_nameLabel->setText(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->setText(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::onNetButtonClicked() +{ + if (m_vpnConnectItem.m_connectUuid.isEmpty()) { + qDebug()<<"--cxc--"<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; +} + + +void VpnListItem::onInfoButtonClicked() +{ +// if (m_vpnConnectItem.m_connectUuid.isEmpty()) { +// qDebug() << LOG_FLAG << "connect is empty, so can not show detail info."; +// return; +// } + +// if(netDetail != nullptr){ +// netDetail->activateWindow(); +// return; +// } + +// qDebug()<< LOG_FLAG << "the info button of lan is clicked! uuid = " +// << m_vpnConnectItem.m_connectUuid << "; name = " << m_vpnConnectItem.m_connectName +// << "." <show(); +// Q_EMIT this->detailShow(true); + + 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->setText(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 new file mode 100644 index 00000000..f0e13169 --- /dev/null +++ b/src/frontend/list-items/vpnlistitem.h @@ -0,0 +1,69 @@ +/* -*- 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 + +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); + +protected: + void setIcon(bool isOn); + void onRightButtonClicked(); + +private: + void connectItemCopy(const KyConnectItem *lanConnectItem); + +private Q_SLOTS: + void onInfoButtonClicked(); + void onNetButtonClicked(); + void onMenuTriggered(QAction *action); + +private: + KyConnectItem m_vpnConnectItem; + + 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 b3947d61..ef4e98ff 100644 --- a/src/frontend/mainwindow.cpp +++ b/src/frontend/mainwindow.cpp @@ -30,6 +30,7 @@ const QString intel = "V10SP1-edu"; #include #include +#include "kysdk/kysdk-system/libkysysinfo.h" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { @@ -148,16 +149,19 @@ void MainWindow::secondaryStart() */ void MainWindow::initPlatform() { - if(v10Sp1.compare(KDKGetPrjCodeName().c_str(),Qt::CaseInsensitive) == 0) { - QString feature = KDKGetOSRelease(KEY_PRODUCT_FEATURES).c_str(); - if (feature.toInt() == 3) { + 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(KDKGetPrjCodeName().c_str(),Qt::CaseInsensitive) == 0) { + } else if (intel.compare(strProjectName,Qt::CaseInsensitive) == 0) { m_isShowInCenter = true; } - - qDebug() << KDKGetPrjCodeName().c_str() << KDKGetOSRelease(KEY_PRODUCT_FEATURES).c_str() << "m_isShowInCenter" << m_isShowInCenter; + qDebug() << "projectName" << projectName << m_isShowInCenter; } /** diff --git a/src/frontend/mainwindow.h b/src/frontend/mainwindow.h index 35035d30..3eea80ec 100644 --- a/src/frontend/mainwindow.h +++ b/src/frontend/mainwindow.h @@ -14,7 +14,6 @@ #include "lanpage.h" #include "wlanpage.h" #include "netdetails/netdetail.h" -#include #ifdef WITHKYSEC #include diff --git a/src/frontend/single-pages/single-pages.pri b/src/frontend/single-pages/single-pages.pri new file mode 100644 index 00000000..96c70dc5 --- /dev/null +++ b/src/frontend/single-pages/single-pages.pri @@ -0,0 +1,10 @@ +INCLUDEPATH += $$PWD + +HEADERS += \ + $$PWD/vpnpage.h \ + $$PWD/singlepage.h + +SOURCES += \ + $$PWD/vpnpage.cpp \ + $$PWD/singlepage.cpp + diff --git a/src/frontend/single-pages/singlepage.cpp b/src/frontend/single-pages/singlepage.cpp new file mode 100644 index 00000000..2e059cac --- /dev/null +++ b/src/frontend/single-pages/singlepage.cpp @@ -0,0 +1,109 @@ +/* -*- 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 "singlepage.h" +#include +#include +#include +#include +#include + +SinglePage::SinglePage(QWidget *parent) : QWidget(parent) +{ + initUI(); +} + +SinglePage::~SinglePage() +{ + delete m_netDivider; +} + +void SinglePage::initUI() +{ + m_mainLayout = new QVBoxLayout(this); + m_mainLayout->setContentsMargins(MAIN_LAYOUT_MARGINS); + m_mainLayout->setSpacing(MAIN_LAYOUT_SPACING); + this->setLayout(m_mainLayout); + + m_netFrame = new QFrame(this); + m_netFrame->setMinimumHeight(INACTIVE_AREA_MIN_HEIGHT); + m_netLayout = new QVBoxLayout(m_netFrame); + m_netLayout->setContentsMargins(NET_LAYOUT_MARGINS); + m_netFrame->setLayout(m_netLayout); + + m_netLabel = new QLabel(m_netFrame); + m_netLabel->setContentsMargins(TEXT_MARGINS); + m_netLabel->setFixedHeight(TEXT_HEIGHT); + + m_netListArea = new QWidget(m_netFrame); + m_netAreaLayout = new QVBoxLayout(m_netListArea); + m_netAreaLayout->setSpacing(MAIN_LAYOUT_SPACING); + m_netAreaLayout->setContentsMargins(MAIN_LAYOUT_MARGINS); + + m_netLayout->addWidget(m_netLabel); + m_netLayout->addWidget(m_netListArea); + + m_netDivider = new Divider(this); + m_settingsFrame = new QFrame(this); + m_settingsFrame->setFixedHeight(TITLE_FRAME_HEIGHT); + + m_settingsLayout = new QHBoxLayout(m_settingsFrame); + m_settingsLayout->setContentsMargins(SETTINGS_LAYOUT_MARGINS); + + m_settingsLabel = new KyLable(m_settingsFrame); + m_settingsLabel->setCursor(Qt::PointingHandCursor); + m_settingsLabel->setText(tr("Settings")); + m_settingsLabel->setScaledContents(true); + + m_settingsLayout->addWidget(m_settingsLabel); + m_settingsLayout->addStretch(); + m_settingsFrame->setLayout(m_settingsLayout); + + m_mainLayout->addWidget(m_netFrame); + m_mainLayout->addStretch(); + m_mainLayout->addWidget(m_netDivider); + m_mainLayout->addWidget(m_settingsFrame); + +} + +void SinglePage::showDesktopNotify(const QString &message, QString soundName) +{ + QDBusInterface iface("org.freedesktop.Notifications", + "/org/freedesktop/Notifications", + "org.freedesktop.Notifications", + QDBusConnection::sessionBus()); + QStringList actions; //跳转动作 + actions.append("kylin-nm"); + actions.append("default"); //默认动作:点击消息体时打开麒麟录音 + QMap hints; + if (!soundName.isEmpty()) { + hints.insert("sound-name",soundName); //添加声音 + } + QList args; + args<<(tr("Kylin NM")) + <<((unsigned int) 0) + < +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "kylinnetworkdeviceresource.h" +#include "kwidget.h" +#include "kswitchbutton.h" +//#include "kborderlessbutton.h" + +using namespace kdk; + +#define MAIN_LAYOUT_MARGINS 0,0,0,0 +#define MAIN_LAYOUT_SPACING 0 +#define TITLE_FRAME_HEIGHT 50 //TabWidget的tab和widget有间隙,和设计稿看起来一致就不能设为设计稿里的高度 +#define TITLE_LAYOUT_MARGINS 24,0,24,0 +#define DEVICE_LAYOUT_MARGINS 24,0,24,8 +#define DEVICE_COMBOBOX_WIDTH 180 +#define ACTIVE_NET_LAYOUT_MARGINS 8,8,8,8 +#define NET_LAYOUT_MARGINS 8,8,0,1 +#define NET_LAYOUT_SPACING 8 +#define NET_LIST_SPACING 0 +#define TEXT_MARGINS 16,0,0,0 +#define TEXT_HEIGHT 20 +//#define SCROLL_AREA_HEIGHT 200 +#define SETTINGS_LAYOUT_MARGINS 23,0,24,0 +#define TRANSPARENT_COLOR QColor(0,0,0,0) +#define INACTIVE_AREA_MIN_HEIGHT 170 +#define ACTIVE_AREA_MAX_HEIGHT 92 + +#define MAX_ITEMS 4 +#define MAX_WIDTH 412 +#define MIN_WIDTH 404 + +#define SCROLL_STEP 4 + +class SinglePage : public QWidget +{ + Q_OBJECT +public: + explicit SinglePage(QWidget *parent = nullptr); + ~SinglePage(); + + static void showDesktopNotify(const QString &message, QString soundName); + + void hideSetting() { + if (nullptr != m_settingsFrame) { + m_settingsFrame->hide(); + m_netDivider->hide(); + m_netFrame->setMinimumHeight(INACTIVE_AREA_MIN_HEIGHT + 100); + } + } + void showSetting() { + if (nullptr != m_settingsFrame) { + m_netFrame->setMinimumHeight(INACTIVE_AREA_MIN_HEIGHT); + m_settingsFrame->show(); + m_netDivider->show(); + } + } + +Q_SIGNALS: + void activateFailed(QString errorMessage); + void deactivateFailed(QString errorMessage); + +protected: + void initUI(); + QVBoxLayout * m_mainLayout = nullptr; + + QFrame * m_netFrame = nullptr; + QVBoxLayout * m_netLayout = nullptr; + QLabel * m_netLabel = nullptr; + QWidget * m_netListArea = nullptr; + QVBoxLayout * m_netAreaLayout = nullptr; + + Divider * m_netDivider = nullptr; + + QFrame * m_settingsFrame = nullptr; + QHBoxLayout * m_settingsLayout = nullptr; + KyLable * m_settingsLabel = nullptr; + +}; + +#endif // TABPAGE_H diff --git a/src/frontend/single-pages/vpnpage.cpp b/src/frontend/single-pages/vpnpage.cpp new file mode 100644 index 00000000..8272d9e9 --- /dev/null +++ b/src/frontend/single-pages/vpnpage.cpp @@ -0,0 +1,656 @@ +/* -*- 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 "vpnpage.h" +#include +#include + +#define MAIN_LAYOUT_MARGINS 0,0,0,0 +#define MAIN_LAYOUT_SPACING 0 +#define TITLE_FRAME_HEIGHT 52 +#define TITLE_LAYOUT_MARGINS 24,0,24,0 +#define LAN_LIST_SPACING 0 +#define TEXT_MARGINS 16,0,0,0 +#define SETTINGS_LAYOUT_MARGINS 24,16,24,16 +#define TRANSPARENT_COLOR QColor(0,0,0,0) +#define ITEM_HEIGHT 48 + + +#define LOG_FLAG "[VpnPage]" + +const QString EMPTY_CONNECT_UUID = "emptyconnect"; + +const QString WIRED_SWITCH = "wiredswitch"; + +VpnPage::VpnPage(QWidget *parent) : SinglePage(parent) +{ + m_activeResourse = new KyActiveConnectResourse(this); + m_connectResourse = new KyConnectResourse(this); +// m_deviceResource = new KyNetworkDeviceResourse(this); +// m_wiredConnectOperation = new KyWiredConnectOperation(this); + + initUI(); + initVpnArea(); + + connect(m_activeResourse, &KyActiveConnectResourse::stateChangeReason, this, &VpnPage::onConnectionStateChange); + connect(m_activeResourse, &KyActiveConnectResourse::activeConnectRemove, this, [=] (QString activeConnectUuid) { + sendVpnStateChangeSignal(activeConnectUuid,Deactivated); + } ); + + connect(m_connectResourse, &KyConnectResourse::connectionAdd, this, &VpnPage::onAddConnection); + connect(m_connectResourse, &KyConnectResourse::connectionRemove, this, &VpnPage::onRemoveConnection); + connect(m_connectResourse, &KyConnectResourse::connectionUpdate, this, &VpnPage::onUpdateConnection); + +// connect(m_wiredConnectOperation, &KyWiredConnectOperation::activateConnectionError, this, &VpnPage::activateFailed); +// connect(m_wiredConnectOperation, &KyWiredConnectOperation::deactivateConnectionError, this, &VpnPage::deactivateFailed); +} + +VpnPage::~VpnPage() +{ + +} + +void VpnPage::deleteConnectionMapItem(QMap &connectMap, + QListWidget *lanListWidget, QString uuid) +{ + QListWidgetItem *p_listWidgetItem = connectMap.value(uuid); + if (p_listWidgetItem) { + connectMap.remove(uuid); + VpnListItem *p_lanItem = (VpnListItem *)lanListWidget->itemWidget(p_listWidgetItem); + lanListWidget->removeItemWidget(p_listWidgetItem); + + delete p_lanItem; + p_lanItem = nullptr; + + delete p_listWidgetItem; + p_listWidgetItem = nullptr; + } + + return; +} + +void VpnPage::clearConnectionMap(QMap &connectMap, + QListWidget *lanListWidget) +{ + QMap::iterator iter; + + iter = connectMap.begin(); + while (iter != connectMap.end()) { + qDebug()<<"[VpnPage] clear connection map item"<< iter.key(); + + QListWidgetItem *p_widgetItem = iter.value(); + VpnListItem *p_lanItem = (VpnListItem *)lanListWidget->itemWidget(p_widgetItem); + lanListWidget->removeItemWidget(p_widgetItem); + + delete p_lanItem; + p_lanItem = nullptr; + + delete p_widgetItem; + p_widgetItem = nullptr; + + iter = connectMap.erase(iter); + } + + return; +} + +void VpnPage::constructActiveConnectionArea() +{ + QList activedList; + QList netList; + + activedList.clear(); + netList.clear(); + clearConnectionMap(m_activeConnectionMap, m_vpnListWidget); + + m_connectResourse->getVpnAndVirtualConnections(netList); + KyConnectItem *p_newItem = nullptr; + if (!netList.isEmpty()) { + for (int index = 0; index < netList.size(); index++) { + KyConnectItem *p_netConnectionItem = netList.at(index); + p_newItem = m_activeResourse->getActiveConnectionByUuid(p_netConnectionItem->m_connectUuid); + if (p_newItem == nullptr) { + qDebug()<<"---cxc---"<m_connectUuid<m_connectName<m_connectState; + if (m_netConnectionMap.contains(p_netConnectionItem->m_connectUuid)) { + qDebug()<m_connectUuid; + } + QListWidgetItem *p_listWidgetItem = addNewItem(p_netConnectionItem, m_vpnListWidget); + m_netConnectionMap.insert(p_netConnectionItem->m_connectUuid, p_listWidgetItem); + } else { + qDebug()<<"---cxc---"<m_connectUuid<m_connectName<m_connectState; + if (m_activeConnectionMap.contains(p_netConnectionItem->m_connectUuid)) { + qDebug()<m_connectUuid; + } +// p_netConnectionItem->m_connectState = NetworkManager::ActiveConnection::Activated; + QListWidgetItem *p_listWidgetItem = addNewItem(p_newItem, m_vpnListWidget); + m_activeConnectionMap.insert(p_netConnectionItem->m_connectUuid, p_listWidgetItem); + } + + delete p_netConnectionItem; + p_netConnectionItem = nullptr; + } + } + if (m_vpnListWidget->count() <= MAX_ITEMS) { + m_vpnListWidget->setFixedWidth(MIN_WIDTH); + } else { + m_vpnListWidget->setFixedWidth(MAX_WIDTH); + } + return; +} + +void VpnPage::constructConnectionArea() +{ + QList netList; + + netList.clear(); + clearConnectionMap(m_netConnectionMap, m_vpnListWidget); + + m_connectResourse->getVpnAndVirtualConnections(netList); + qDebug() << "[VpnPage]construct connection area get connection list size:" << netList.size(); + if (!netList.isEmpty()) { + for (int index = 0; index < netList.size(); index++) { + KyConnectItem *p_netConnectionItem = netList.at(index); + qDebug()<<"[VpnPage] construct connection area add deactive item"<m_connectName; + QListWidgetItem *p_listWidgetItem = addNewItem(p_netConnectionItem, m_vpnListWidget); + if (m_netConnectionMap.contains(p_netConnectionItem->m_connectUuid)) { + qDebug()<m_connectUuid; + } + m_netConnectionMap.insert(p_netConnectionItem->m_connectUuid, p_listWidgetItem); + + delete p_netConnectionItem; + p_netConnectionItem = nullptr; + + } + } + if (m_vpnListWidget->count() <= MAX_ITEMS) { + m_vpnListWidget->setFixedWidth(MIN_WIDTH); + } else { + m_vpnListWidget->setFixedWidth(MAX_WIDTH); + } + return; +} + +void VpnPage::initVpnArea() +{ + m_netFrame->show(); + constructActiveConnectionArea(); +// constructConnectionArea(); + + return; +} + +bool VpnPage::removeConnectionItem(QMap &connectMap, + QListWidget *lanListWidget, QString path) +{ + QMap::iterator iter; + for (iter = connectMap.begin(); iter != connectMap.end(); ++iter) { + QListWidgetItem *p_listWidgetItem = iter.value(); + VpnListItem *p_lanItem = (VpnListItem*)lanListWidget->itemWidget(p_listWidgetItem); + if (p_lanItem->getConnectionPath() == path) { + qDebug()<<"[VpnPage] Remove a connection from list"; + + lanListWidget->removeItemWidget(p_listWidgetItem); + + delete p_lanItem; + p_lanItem = nullptr; + + delete p_listWidgetItem; + p_listWidgetItem = nullptr; + + iter = connectMap.erase(iter); + if (m_vpnListWidget->count() <= MAX_ITEMS) { + m_vpnListWidget->setFixedWidth(MIN_WIDTH); + } + return true; + } + } + + return false; +} + +void VpnPage::onRemoveConnection(QString path) //删除时后端会自动断开激活,将其从未激活列表中删除 +{ + //for dbus + qDebug() << "[VpnPage] emit lanRemove because onRemoveConnection " << path; + Q_EMIT vpnRemove(path); + + if (removeConnectionItem(m_netConnectionMap, m_vpnListWidget, path)) { + return; + } +} + +void VpnPage::onAddConnection(QString uuid) //新增一个有线连接,将其加入到激活列表 +{ + if (!m_connectResourse->isVirtualConncection(uuid)) { + return; + } + + KyConnectItem *p_newItem = nullptr; + p_newItem = m_connectResourse->getConnectionItemByUuid(uuid); + if (nullptr == p_newItem) { + return; + } + + sendVpnAddSignal(p_newItem); + + qDebug()<<"[VpnPage] Add a new connection, name:"<m_connectName; + QListWidgetItem *p_listWidgetItem = insertNewItem(p_newItem, m_vpnListWidget); + if (m_netConnectionMap.contains(p_newItem->m_connectUuid)) { + qDebug()<m_connectUuid; + } + m_netConnectionMap.insert(p_newItem->m_connectUuid, p_listWidgetItem); + + delete p_newItem; + p_newItem = nullptr; + if (m_vpnListWidget->count() > MAX_ITEMS) { + m_vpnListWidget->setFixedWidth(MAX_WIDTH); + } + return; +} + +void VpnPage::onShowControlCenter() +{ + QProcess process; + process.startDetached("ukui-control-center -m vpn"); +} + +void VpnPage::initUI() +{ + m_netLabel->setText(tr("VPN Connection")); + m_vpnListWidget = new QListWidget(m_netListArea); + m_vpnListWidget->setFrameShape(QFrame::Shape::NoFrame); + m_vpnListWidget->setSpacing(LAN_LIST_SPACING); + m_vpnListWidget->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + m_vpnListWidget->setVerticalScrollMode(QAbstractItemView::ScrollMode::ScrollPerPixel); + m_vpnListWidget->verticalScrollBar()->setProperty("drawScrollBarGroove",false); //去除滚动条的外侧黑框 + m_vpnListWidget->verticalScrollBar()->setSingleStep(SCROLL_STEP); + m_vpnListWidget->verticalScrollBar()->setContextMenuPolicy(Qt::NoContextMenu); + m_netAreaLayout->addWidget(m_vpnListWidget); + + QPalette pal = m_vpnListWidget->palette(); + pal.setBrush(QPalette::Base, QColor(0,0,0,0)); //背景透明 + m_vpnListWidget->setPalette(pal); + + m_settingsLabel->setText(tr("VPN Settings")); + m_settingsLabel->installEventFilter(this); +} + +QListWidgetItem *VpnPage::insertNewItem(KyConnectItem *itemData, QListWidget *listWidget) +{ + int index = 0; + + for(index = 0; index < m_vpnListWidget->count(); index++) { + QListWidgetItem *p_listWidgetItem = m_vpnListWidget->item(index); + VpnListItem *p_lanItem = (VpnListItem *)m_vpnListWidget->itemWidget(p_listWidgetItem); + QString name1 = p_lanItem->getConnectionName(); + QString name2 = itemData->m_connectName; + if (QString::compare(name1, name2, Qt::CaseInsensitive) > 0) { + break; + } + } + + QListWidgetItem *p_sortListWidgetItem = new QListWidgetItem(); + p_sortListWidgetItem->setFlags(p_sortListWidgetItem->flags() & (~Qt::ItemIsSelectable)); //设置不可被选中 + p_sortListWidgetItem->setSizeHint(QSize(listWidget->width(),ITEM_HEIGHT)); + + listWidget->insertItem(index, p_sortListWidgetItem); + + VpnListItem *p_sortLanItem = nullptr; + p_sortLanItem = new VpnListItem(itemData); + listWidget->setItemWidget(p_sortListWidgetItem, p_sortLanItem); + + return p_sortListWidgetItem; +} + +QListWidgetItem *VpnPage::addNewItem(KyConnectItem *itemData, QListWidget *listWidget) +{ + QListWidgetItem *p_listWidgetItem = new QListWidgetItem(); + p_listWidgetItem->setFlags(p_listWidgetItem->flags() & (~Qt::ItemIsSelectable)); + p_listWidgetItem->setSizeHint(QSize(listWidget->width(), ITEM_HEIGHT)); + listWidget->addItem(p_listWidgetItem); + VpnListItem *p_lanItem = nullptr; + if (itemData != nullptr) { + p_lanItem = new VpnListItem(itemData); + qDebug() << "[VpnPage] addNewItem, connection: " << itemData->m_connectName; + } else { + p_lanItem = new VpnListItem(); + qDebug() << "[VpnPage] Add nullItem!"; + } + + listWidget->setItemWidget(p_listWidgetItem, p_lanItem); + return p_listWidgetItem; +} + +void VpnPage::updateActivatedConnectionArea(KyConnectItem *p_newItem) +{ + if (m_activeConnectionMap.contains(p_newItem->m_connectUuid)) { + return; + } + + deleteConnectionMapItem(m_netConnectionMap, m_vpnListWidget, p_newItem->m_connectUuid); + qDebug()<<"[VpnPage]update active connection item"<m_connectName; + deleteConnectionMapItem(m_activeConnectionMap, m_vpnListWidget, p_newItem->m_connectUuid); + QListWidgetItem *p_listWidgetItem = addNewItem(p_newItem, m_vpnListWidget); + m_activeConnectionMap.insert(p_newItem->m_connectUuid, p_listWidgetItem); + if (m_vpnListWidget->count() <= MAX_ITEMS) { + m_vpnListWidget->setFixedWidth(MIN_WIDTH); + } + + return; +} + +void VpnPage::updateConnectionArea(KyConnectItem *p_newItem) +{ + if (m_netConnectionMap.contains(p_newItem->m_connectUuid)) { + return; + } + + deleteConnectionMapItem(m_activeConnectionMap, m_vpnListWidget, p_newItem->m_connectUuid); + qDebug()<<"[VpnPage] update connection item"<m_connectName; + QListWidgetItem *p_listWidgetItem = insertNewItem(p_newItem, m_vpnListWidget); + m_netConnectionMap.insert(p_newItem->m_connectUuid, p_listWidgetItem); + + if (m_vpnListWidget->count() <= MAX_ITEMS) { + m_vpnListWidget->setFixedWidth(MIN_WIDTH); + } else { + m_vpnListWidget->setFixedWidth(MAX_WIDTH); + } + + return; +} + +void VpnPage::updateConnectionState(QMap &connectMap, + QListWidget *lanListWidget, QString uuid, ConnectState state) +{ + qDebug() << LOG_FLAG << "update connection state"; + + QListWidgetItem *p_listWidgetItem = connectMap.value(uuid); + if (p_listWidgetItem) { + VpnListItem *p_lanItem = (VpnListItem *)lanListWidget->itemWidget(p_listWidgetItem); + p_lanItem->updateConnectionState(state); + } + + return; +} + +void VpnPage::onConnectionStateChange(QString uuid, + NetworkManager::ActiveConnection::State state, + NetworkManager::ActiveConnection::Reason reason) +{ + qDebug()<<"--cxc--"<isVirtualConncection(uuid)) { + qDebug() << "[VpnPage] connection state change signal but not wired"; + return; + } + + sendVpnStateChangeSignal(uuid, (ConnectState)state); + + if (m_activeConnectionMap.keys().contains(uuid) && state == NetworkManager::ActiveConnection::State::Activated) { + qDebug()<<"--cxc--"<getActiveConnectionByUuid(uuid); + if (nullptr == p_newItem) { + qWarning()<<"[VpnPage] get active connection failed, connection uuid" << uuid; + return; + } + + ssid = p_newItem->m_connectName; + updateActivatedConnectionArea(p_newItem); + updateConnectionState(m_activeConnectionMap, m_vpnListWidget, uuid, (ConnectState)state); + } else if (state == NetworkManager::ActiveConnection::State::Deactivated) { + p_newItem = m_connectResourse->getConnectionItemByUuid(uuid); + qDebug() << "[VpnPage] deactivated reason" << reason; + if (nullptr == p_newItem) { + qWarning()<<"[VpnPage] get active connection failed, connection uuid" << uuid; + return; + } + + ssid = p_newItem->m_connectName; + updateConnectionArea(p_newItem); + updateConnectionState(m_netConnectionMap, m_vpnListWidget, uuid, (ConnectState)state); + } else if (state == NetworkManager::ActiveConnection::State::Activating) { + updateConnectionState(m_netConnectionMap, m_vpnListWidget, uuid, (ConnectState)state); + } else if (state == NetworkManager::ActiveConnection::State::Deactivating) { + updateConnectionState(m_activeConnectionMap, m_vpnListWidget, uuid, (ConnectState)state); + } + + Q_EMIT vpnActiveConnectionStateChanged(deviceName, uuid, state); + + if (p_newItem) { + delete p_newItem; + p_newItem = nullptr; + } + + return; +} + + +void VpnPage::getVirtualList(QMap > &map) +{ + QList netConnectList; + QVector vector; + m_connectResourse->getVpnAndVirtualConnections(netConnectList); //未激活列表的显示 + if (!netConnectList.isEmpty()) { + for (int i = 0; i < netConnectList.size(); i++) { + vector.clear(); + vector.append(QStringList()<m_connectName<m_connectUuid << netConnectList.at(i)->m_connectPath); + map.insert(netConnectList.at(i)->m_connectUuid, vector); + } + } + return; +} + +void VpnPage::sendVpnUpdateSignal(KyConnectItem *p_connectItem) +{ + QStringList info; + info << p_connectItem->m_connectName << p_connectItem->m_connectUuid << p_connectItem->m_connectPath; + Q_EMIT vpnUpdate(p_connectItem->m_ifaceName, info); + + return; +} + +void VpnPage::sendVpnAddSignal(KyConnectItem *p_connectItem) +{ + QStringList info; + info << p_connectItem->m_connectName << p_connectItem->m_connectUuid << p_connectItem->m_connectPath; + qDebug() << "[VpnPage] emit vpnAdd because addConnection "; + Q_EMIT vpnAdd(p_connectItem->m_ifaceName, info); + + return; +} + +void VpnPage::sendVpnStateChangeSignal(QString uuid, ConnectState state) +{ + if (state == Activating || state == Deactivating) { + if (m_activeResourse->connectionIsVirtual(uuid)) { + return; + } + } + + Q_EMIT this->vpnConnectChanged(state); + + return; +} + +void VpnPage::updateConnectionProperty(KyConnectItem *p_connectItem) +{ + QString newUuid = p_connectItem->m_connectUuid; + + if (m_netConnectionMap.contains(newUuid)) { + QListWidgetItem *p_listWidgetItem = m_netConnectionMap.value(newUuid); + VpnListItem *p_lanItem = (VpnListItem*)m_vpnListWidget->itemWidget(p_listWidgetItem); + if (p_connectItem->m_connectName != p_lanItem->getConnectionName()){ + //只要名字改变就要删除,重新插入,主要是为了排序 + deleteConnectionMapItem(m_netConnectionMap, m_vpnListWidget, newUuid); + QListWidgetItem *p_sortListWidgetItem = insertNewItem(p_connectItem, m_vpnListWidget); + if (m_netConnectionMap.contains(newUuid)) { + qDebug()<m_connectPath != p_lanItem->getConnectionPath()) { + p_lanItem->updateConnectionPath(p_connectItem->m_connectPath); + } + } else if (!m_activeConnectionMap.contains(newUuid)){ + if (p_connectItem->m_ifaceName.isEmpty()) { + QListWidgetItem *p_listWidgetItem = insertNewItem(p_connectItem, m_vpnListWidget); + if (m_netConnectionMap.contains(newUuid)) { + qDebug()<m_connectUuid; + + if (m_activeConnectionMap.contains(newUuid)) { + QListWidgetItem *p_listWidgetItem = m_activeConnectionMap.value(newUuid); + VpnListItem *p_lanItem = (VpnListItem *)m_vpnListWidget->itemWidget(p_listWidgetItem); + if (p_lanItem->getConnectionName() != p_connectItem->m_connectName) { + p_lanItem->updateConnectionName(p_connectItem->m_connectName); + } + + if (p_lanItem->getConnectionName() != p_connectItem->m_connectPath) { + p_lanItem->updateConnectionPath(p_connectItem->m_connectPath); + } + } + return; +} + +void VpnPage::onUpdateConnection(QString uuid) +{ + if (!m_connectResourse->isWiredConnection(uuid)) { + return; + } + + qDebug() << "[VpnPage]:Connection property Changed." << Q_FUNC_INFO << __LINE__; + + KyConnectItem *p_newItem = nullptr; + if (m_connectResourse->isActivatedConnection(uuid)) { + p_newItem = m_activeResourse->getActiveConnectionByUuid(uuid); + if (nullptr == p_newItem) { + qWarning()<<"[VpnPage] get item failed, when update activate connection." + <<"connection uuid" << uuid; + return; + } + + updateActiveConnectionProperty(p_newItem); + } else { + p_newItem = m_connectResourse->getConnectionItemByUuid(uuid); + if (nullptr == p_newItem) { + qWarning()<<"[VpnPage] get item failed, when update connection." + <<"connection uuid"<type() == QEvent::MouseButtonRelease) { + onShowControlCenter(); + } + } + + return QWidget::eventFilter(watched, event); +} + +void VpnPage::activateVpn(const QString& connUuid) +{ +// qDebug() << "[VpnPage] activateVpn" << connUuid; +// if (!m_deviceResource->wiredDeviceIsCarriered(devName)) { +// qDebug() << LOG_FLAG << devName << "is not carried, so can not activate connection"; +// this->showDesktopNotify(tr("Wired Device not carried"), "networkwrong"); +// } else { +// m_wiredConnectOperation->activateConnection(connUuid, devName); +// } +} + +void VpnPage::deactivateVpn(const QString& connUuid) +{ + qDebug() << "[VpnPage] deactivateVpn" << connUuid; + QString name(""); +// m_wiredConnectOperation->deactivateWiredConnection(name, connUuid); +} + +void VpnPage::showDetailPage(QString devName, QString uuid) +{ +#ifdef VPN_DETAIL + KyConnectItem *p_item = nullptr; + bool isActive = true; + + if (m_connectResourse->isActivatedConnection(uuid)) { + p_item = m_activeResourse->getActiveConnectionByUuid(uuid); + isActive = true; + } else { + p_item = m_connectResourse->getConnectionItemByUuid(uuid); + isActive = false; + } + + if (nullptr == p_item) { + qWarning()<<"[VpnPage] GetConnectionItemByUuid is empty when showDetailPage." + <<"device name"<m_connectName, uuid, isActive, false, false); + netDetail->show(); + + delete p_item; + p_item = nullptr; +#endif +} + +bool VpnPage::vpnIsConnected() +{ + if (m_activeResourse->wiredConnectIsActived()) { + return true; + } else { + return false; + } +} + diff --git a/src/frontend/single-pages/vpnpage.h b/src/frontend/single-pages/vpnpage.h new file mode 100644 index 00000000..ddb212ff --- /dev/null +++ b/src/frontend/single-pages/vpnpage.h @@ -0,0 +1,124 @@ +/* -*- 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 VPNPAGE_H +#define VPNPAGE_H + +#include "divider.h" +#include +#include +#include +#include +#include +#include +#include + +#include "list-items/listitem.h" +#include "list-items/vpnlistitem.h" +#include "single-pages/singlepage.h" + +#define VPNPAGE_LAYOUT_MARGINS 0,0,0,0 + +class VpnListItem; + +class VpnPage : public SinglePage +{ + Q_OBJECT +public: + explicit VpnPage(QWidget *parent = nullptr); + ~VpnPage(); + + //for dbus + void getVirtualList(QMap > &map); + void activateVpn(const QString& connUuid); + void deactivateVpn(const QString& connUuid); + void showDetailPage(QString devName, QString uuid); + + bool vpnIsConnected(); + +protected: + bool eventFilter(QObject *watched, QEvent *event); + +private: + void initUI(); + void initVpnArea(); + + inline void initDeviceCombox() { return; } + + QListWidgetItem *insertNewItem(KyConnectItem *itemData, QListWidget *listWidget); + QListWidgetItem *addNewItem(KyConnectItem *itemData, QListWidget *listWidget); + bool removeConnectionItem(QMap &connectMap, + QListWidget *lanListWidget, QString path); + + void constructConnectionArea(); + void constructActiveConnectionArea(); + + void updateConnectionArea(KyConnectItem *p_newItem); + void updateActivatedConnectionArea(KyConnectItem *p_newItem); + void updateConnectionState(QMap &connectMap, + QListWidget *lanListWidget, QString uuid, ConnectState state); + + void updateActiveConnectionProperty(KyConnectItem *p_connectItem); + void updateConnectionProperty(KyConnectItem *p_connectItem); + + void sendVpnUpdateSignal(KyConnectItem *p_connectItem); + void sendVpnAddSignal(KyConnectItem *p_connectItem); + void sendVpnStateChangeSignal(QString uuid, ConnectState state); + + void clearConnectionMap(QMap &connectMap, + QListWidget *lanListWidget); + void deleteConnectionMapItem(QMap &connectMap, + QListWidget *lanListWidget, QString uuid); + +Q_SIGNALS: + void vpnAdd(QString devName, QStringList info); + void vpnRemove(QString dbusPath); + void vpnUpdate(QString devName, QStringList info); + + void vpnActiveConnectionStateChanged(QString interface, QString uuid, int status); + void vpnConnectChanged(int state); + +private Q_SLOTS: + void onConnectionStateChange(QString uuid, NetworkManager::ActiveConnection::State state, + NetworkManager::ActiveConnection::Reason reason); + + void onAddConnection(QString uuid); + void onRemoveConnection(QString path); + void onUpdateConnection(QString uuid); + + void onShowControlCenter(); + +// void onStateChange(); + +private: + QListWidget * m_vpnListWidget = nullptr; + +// KyNetworkDeviceResourse *m_deviceResource = nullptr; +// KyWiredConnectOperation *m_wiredConnectOperation = nullptr; + KyActiveConnectResourse *m_activeResourse = nullptr; //激活的连接 + KyConnectResourse *m_connectResourse = nullptr; //未激活的连接 + + QMap m_netConnectionMap; + QMap m_activeConnectionMap; + +public Q_SLOTS: + inline void onDeviceComboxIndexChanged(int currentIndex) { return; } +}; + +#endif // LANPAGE_H diff --git a/src/frontend/vpnmainwindow.cpp b/src/frontend/vpnmainwindow.cpp new file mode 100644 index 00000000..e9c9b591 --- /dev/null +++ b/src/frontend/vpnmainwindow.cpp @@ -0,0 +1,717 @@ +/* -*- 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 "vpnmainwindow.h" +#include "customstyle.h" +#include +#include +#include +#include +#include +#include + +#include "kylinnetworkdeviceresource.h" +#include "../backend/dbus-interface/kylinagentinterface.h" + +#include "ukuistylehelper/ukuistylehelper.h" +#include "windowmanager/windowmanager.h" +#include "kysdk/kysdk-system/libkysysinfo.h" + +#define MAINWINDOW_WIDTH 420 +#define MAINWINDOW_HEIGHT 300 +#define VPN_LAYOUT_MARGINS 0,12,0,12 +#define THEME_SCHAME "org.ukui.style" +#define COLOR_THEME "styleName" + +const QString v10Sp1 = "V10SP1"; +const QString intel = "V10SP1-edu"; + +#define KEY_PRODUCT_FEATURES "PRODUCT_FEATURES" + +#include +#include + +vpnMainWindow::vpnMainWindow(QWidget *parent): QMainWindow(parent) +{ + firstlyStart(); +} + +/** + * @brief vpnMainWindow::showMainwindow show主窗口,同时也作为dbus接口提供给外部组件调用 + */ +void vpnMainWindow::showMainwindow() +{ + if (!m_loadFinished) { + m_secondaryStartTimer->stop(); + secondaryStart(); + } + + /** + * 设置主界面跳过任务栏和分页器的属性,隐藏再次展示有可能辉冲刷掉该属性,需要展示时重新设置 + */ + QString platform = QGuiApplication::platformName(); + if(!platform.startsWith(QLatin1String("wayland"),Qt::CaseInsensitive)) + { + const KWindowInfo info(this->winId(), NET::WMState); + if (!info.hasState(NET::SkipTaskbar) || !info.hasState(NET::SkipPager)) { + KWindowSystem::setState(this->winId(), NET::SkipTaskbar | NET::SkipPager); + } + } + + this->showByWaylandHelper(); + this->raise(); + this->activateWindow(); + Q_EMIT this->mainWindowVisibleChanged(true); +#ifdef WITHKYSEC +// if (!kysec_is_disabled() && kysec_get_3adm_status() && (getuid() || geteuid())){ +// if (nullptr != m_vpnPage) { +// m_vpnPage->hideSetting(); +// } +// } else { +// if (nullptr != m_vpnPage) { +// m_vpnPage->showSetting(); +// } +// } +#endif + +} + +/** + * @brief MainWindow::hideMainwindow 隐藏主页面时要进行的操作,后续可以添加到此函数 + */ +void vpnMainWindow::hideMainwindow() +{ + this->hide(); + Q_EMIT this->mainWindowVisibleChanged(false); +} + +///** +// * @brief MainWindow::setWiredDefaultDevice 设置有线设备默认网卡 +// */ +//void MainWindow::setWiredDefaultDevice(QString deviceName) +//{ +//// m_vpnPage->updateDefaultDevice(deviceName); +//} + +/** + * @brief MainWindow::firstlyStart 一级启动,执行重要且不耗时的启动操作 + */ +void vpnMainWindow::firstlyStart() +{ + initWindowProperties(); + initTransparency(); + initUI(); + initDbusConnnect(); + initWindowTheme(); + initTrayIcon(); + initPlatform(); + installEventFilter(this); + m_secondaryStartTimer = new QTimer(this); + connect(m_secondaryStartTimer, &QTimer::timeout, this, [ = ]() { + m_secondaryStartTimer->stop(); + secondaryStart();//满足条件后执行比较耗时的二级启动 + }); + m_secondaryStartTimer->start(5 * 1000); + + m_createPagePtrMap.clear(); +} + +/** + * @brief vpnMainWindow::secondaryStart 二级启动,可以将较耗时的初始化操作放到此处执行 + */ +void vpnMainWindow::secondaryStart() +{ + if (m_loadFinished) + return; + m_loadFinished = true; +} + +/** + * @brief vpnMainWindow::initPlatform 初始化平台信息 + */ +void vpnMainWindow::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; +} + +/** + * @brief vpnMainWindow::initWindowProperties 初始化一些窗口属性 + */ +void vpnMainWindow::initWindowProperties() +{ + this->setWindowTitle(tr("kylin-vpn")); +// this->setFixedSize(MAINWINDOW_WIDTH, MAINWINDOW_HEIGHT); +// //绘制毛玻璃特效 +// this->setAttribute(Qt::WA_TranslucentBackground, true); //透明 + this->setFocusPolicy(Qt::NoFocus); + + QString platform = QGuiApplication::platformName(); + if(!platform.startsWith(QLatin1String("wayland"),Qt::CaseInsensitive)) + { + QPainterPath path; + auto rect = this->rect(); + // path.addRoundedRect(rect, 12, 12); + path.addRect(rect); + KWindowEffects::enableBlurBehind(this->winId(), true, QRegion(path.toFillPolygon().toPolygon())); //背景模糊 + } +} + +void vpnMainWindow::paintEvent(QPaintEvent *event) +{ + QPainter painter(this); + painter.setRenderHint(QPainter::Antialiasing); // 反锯齿; + painter.setPen(Qt::transparent); +// auto rect = this->rect(); +// painter.drawRoundedRect(rect, 12, 12); //窗口圆角 +} + +void vpnMainWindow::initTransparency() +{ + if(QGSettings::isSchemaInstalled(TRANSPARENCY_GSETTINGS)) { + m_transGsettings = new QGSettings(TRANSPARENCY_GSETTINGS); + if(m_transGsettings->keys().contains(QString("transparency"))) { + m_transparency = m_transGsettings->get("transparency").toDouble() + 0.15; + m_transparency = (m_transparency > 1) ? 1 : m_transparency; + connect(m_transGsettings, &QGSettings::changed, this, &vpnMainWindow::onTransChanged); + } + } +} + +void vpnMainWindow::onTransChanged() +{ + m_transparency = m_transGsettings->get("transparency").toDouble() + 0.15; + m_transparency = (m_transparency > 1) ? 1 : m_transparency; + paintWithTrans(); +} + +void vpnMainWindow::paintWithTrans() +{ + QPalette pal = this->palette(); + QColor color = qApp->palette().base().color(); + color.setAlphaF(m_transparency); + pal.setColor(QPalette::Window, color); + this->setPalette(pal); +} + +/** + * @brief vpnMainWindow::initUI 初始化窗口内控件 + */ +void vpnMainWindow::initUI() +{ + m_vpnWidget = new QWidget(this); + this->setCentralWidget(m_vpnWidget); + m_vpnLayout = new QVBoxLayout(m_vpnWidget); + m_vpnLayout->setContentsMargins(VPN_LAYOUT_MARGINS); + m_vpnWidget->setLayout(m_vpnLayout); + m_vpnWidget->setAttribute(Qt::WA_TranslucentBackground, true); // 背景透明 解决切换黑屏问题 + + m_vpnPage = new VpnPage(m_vpnWidget); + m_vpnLayout->addWidget(m_vpnPage); + + paintWithTrans(); +} + +/** + * @brief vpnMainWindow::initTrayIcon 初始化托盘图标和托盘右键菜单 + */ +void vpnMainWindow::initTrayIcon() +{ + m_vpnTrayIcon = new QSystemTrayIcon(this); + m_vpnTrayIconMenu = new QMenu(); +// m_showMainwindowAction = new QAction(tr("Show MainWindow"),this); +// m_showSettingsAction = new QAction(tr("Settings"),this); + + m_vpnTrayIcon->setToolTip(QString(tr("vpn tool"))); + m_vpnTrayIcon->setIcon(QIcon::fromTheme("ukui-vpn-symbolic")); +// m_showSettingsAction->setIcon(QIcon::fromTheme("document-page-setup-symbolic", QIcon(":/res/x/setup.png")) ); +//// m_vpnTrayIconMenu->addAction(m_showMainwindowAction); +// m_vpnTrayIconMenu->addAction(m_showSettingsAction); +// m_vpnTrayIcon->setContextMenu(m_vpnTrayIconMenu); +// m_vpnTrayIcon->setIcon(QIcon::fromTheme("network-wired-signal-excellent-symbolic")); +// m_iconStatus = IconActiveType::LAN_CONNECTED; +// onRefreshTrayIcon(); + + connect(m_vpnTrayIcon, &QSystemTrayIcon::activated, this, &vpnMainWindow::onTrayIconActivated); +//// connect(m_showMainwindowAction, &QAction::triggered, this, &MainWindow::onShowMainwindowActionTriggled); +// connect(m_showSettingsAction, &QAction::triggered, this, &MainWindow::onShowSettingsActionTriggled); + m_vpnTrayIcon->show(); +} + +void vpnMainWindow::initDbusConnnect() +{ +// connect(m_vpnPage, &LanPage::deviceStatusChanged, this, &MainWindow::deviceStatusChanged); +// connect(m_vpnPage, &LanPage::deviceNameChanged, this, &MainWindow::deviceNameChanged); +// connect(m_vpnPage, &LanPage::activateFailed, this, &MainWindow::activateFailed); +// connect(m_vpnPage, &LanPage::deactivateFailed, this, &MainWindow::deactivateFailed); + + connect(m_vpnPage, &VpnPage::vpnAdd, this, &vpnMainWindow::vpnAdd); + connect(m_vpnPage, &VpnPage::vpnRemove, this, &vpnMainWindow::vpnRemove); + connect(m_vpnPage, &VpnPage::vpnUpdate, this, &vpnMainWindow::vpnUpdate); + connect(m_vpnPage, &VpnPage::vpnActiveConnectionStateChanged, this, &vpnMainWindow::vpnActiveConnectionStateChanged); +// connect(m_vpnPage, &LanPage::lanConnectChanged, this, &MainWindow::onLanConnectStatusToChangeTrayIcon); + +// //模式切换 +// QDBusConnection::sessionBus().connect(QString("com.kylin.statusmanager.interfacer"), +// QString("/"), +// QString("com.kylin.statusmanager.interface"), +// QString("mode_change_signal"), this, SLOT(onTabletModeChanged(bool))); +} + +/** + * @brief vpnMainWindow::resetWindowPosition 重新计算窗口位置 + */ +void vpnMainWindow::resetWindowPosition() +{ + + if (m_isShowInCenter) { + QRect availableGeometry = qApp->primaryScreen()->availableGeometry(); + QRect rect((availableGeometry.width() - this->width())/2, (availableGeometry.height() - this->height())/2, + this->width(), this->height()); + kdk::WindowManager::setGeometry(this->windowHandle(), rect); + + return; + } + +#define MARGIN 4 +#define PANEL_TOP 1 +#define PANEL_LEFT 2 +#define PANEL_RIGHT 3 +//#define PANEL_BOTTOM 4 + if (!m_positionInterface) { + m_positionInterface = new QDBusInterface("org.ukui.panel", + "/panel/position", + "org.ukui.panel", + QDBusConnection::sessionBus()); + } + QRect rect; + QDBusReply reply = m_positionInterface->call("GetPrimaryScreenGeometry"); + //reply获取的参数共5个,分别是 主屏可用区域的起点x坐标,主屏可用区域的起点y坐标,主屏可用区域的宽度,主屏可用区域高度,任务栏位置 + if (!m_positionInterface->isValid() || !reply.isValid() || reply.value().size() < 5) { + qCritical() << QDBusConnection::sessionBus().lastError().message(); + kdk::WindowManager::setGeometry(this->windowHandle(), QRect(0, 0, this->width(), this->height())); + return; + } + QVariantList position_list = reply.value(); + int position = position_list.at(4).toInt(); + switch(position){ + case PANEL_TOP: + //任务栏位于上方 + rect = QRect(position_list.at(0).toInt() + position_list.at(2).toInt() - this->width() - MARGIN, + position_list.at(1).toInt() + MARGIN, + this->width(), this->height()); + break; + //任务栏位于左边 + case PANEL_LEFT: + rect = QRect(position_list.at(0).toInt() + MARGIN, + position_list.at(1).toInt() + reply.value().at(3).toInt() - this->height() - MARGIN, + this->width(), this->height()); + break; + //任务栏位于右边 + case PANEL_RIGHT: + rect = QRect(position_list.at(0).toInt() + position_list.at(2).toInt() - this->width() - MARGIN, + position_list.at(1).toInt() + reply.value().at(3).toInt() - this->height() - MARGIN, + this->width(), this->height()); + break; + //任务栏位于下方 + default: + rect = QRect(position_list.at(0).toInt() + position_list.at(2).toInt() - this->width() - MARGIN, + position_list.at(1).toInt() + reply.value().at(3).toInt() - this->height() - MARGIN, + this->width(), this->height()); + break; + } + kdk::WindowManager::setGeometry(this->windowHandle(), rect); + qDebug() << " Position of ukui-panel is " << position << "; Position of mainwindow is " << this->geometry() << "." << Q_FUNC_INFO << __LINE__; +} + +///** +// * @brief MainWindow::resetTrayIconTool 重新获取网络连接状态并重新设置图标和tooltip +// */ +//void MainWindow::resetTrayIconTool() +//{ +// //ZJP_TODO 检测当前连接的是有线还是无线,是否可用,设置图标和tooltip,图标最好提前define +//// int connectivity = objKyDBus->getNetworkConectivity(); +//// qDebug() << "Value of current network Connectivity property : "<< connectivity; +//// switch (connectivity) { +//// case UnknownConnectivity: +//// case Portal: +//// case Limited: +//// setTrayIcon(iconLanOnlineNoInternet); +//// trayIcon->setToolTip(QString(tr("Network Connected But Can Not Access Internet"))); +//// break; +//// case NoConnectivity: +//// case Full: +//// setTrayIcon(iconLanOnline); +//// trayIcon->setToolTip(QString(tr("kylin-nm"))); +//// break; +//// } +// qDebug() << "Has set tray icon to be XXX." << Q_FUNC_INFO << __LINE__; +//} + + +/** + * @brief vpnMainWindow::initWindowTheme 初始化窗口主题并创建信号槽 + */ +void vpnMainWindow::initWindowTheme() +{ + const QByteArray style_id(THEME_SCHAME); + if (QGSettings::isSchemaInstalled(style_id)) { + m_styleGsettings = new QGSettings(style_id); + connect(m_styleGsettings, &QGSettings::changed, this, &vpnMainWindow::onThemeChanged); + } else { + qWarning() << "Gsettings interface \"org.ukui.style\" is not exist!" << Q_FUNC_INFO << __LINE__; + } +} + +///** +// * @brief MainWindow::resetWindowTheme 读取和设置窗口主题 +// */ +//void MainWindow::resetWindowTheme() +//{ +// if (!m_styleGsettings) { return; } +// QString currentTheme = m_styleGsettings->get(COLOR_THEME).toString(); +// auto app = static_cast(QCoreApplication::instance()); +// if(currentTheme == "ukui-dark" || currentTheme == "ukui-black"){ +// app->setStyle(new CustomStyle("ukui-dark")); +// qDebug() << "Has set color theme to ukui-dark." << Q_FUNC_INFO << __LINE__; +// Q_EMIT qApp->paletteChanged(qApp->palette()); +// return; +// } +// app->setStyle(new CustomStyle("ukui-light")); +// qDebug() << "Has set color theme to " << currentTheme << Q_FUNC_INFO << __LINE__; +// Q_EMIT qApp->paletteChanged(qApp->palette()); +// return; +//} + +///** +// * @brief MainWindow::showControlCenter 打开控制面板网络界面 +// */ +//void MainWindow::showControlCenter() +//{ +// QProcess process; +// if (!m_vpnPage->lanIsConnected() && m_wlanWidget->checkWlanStatus(NetworkManager::ActiveConnection::State::Activated)){ +// process.startDetached("ukui-control-center -m wlanconnect"); +// } else { +// process.startDetached("ukui-control-center -m netconnect"); +// } +//} + +void vpnMainWindow::showByWaylandHelper() +{ + //去除窗管标题栏,传入参数为QWidget* + kdk::UkuiStyleHelper::self()->removeHeader(this); + this->show(); + resetWindowPosition(); + //设置窗体位置,传入参数为QWindow*,QRect + +} + +void vpnMainWindow::setCentralWidgetType(IconActiveType iconStatus) +{ + if (iconStatus == WLAN_CONNECTED || iconStatus == WLAN_CONNECTED_LIMITED) { +// m_vpnWidget->setCurrentIndex(WLAN_PAGE_INDEX); + } else if (iconStatus == ACTIVATING) { +// if (m_wlanWidget->checkWlanStatus(NetworkManager::ActiveConnection::State::Activating)) { +// m_vpnWidget->setCurrentIndex(WLAN_PAGE_INDEX); +// } else { +// m_vpnWidget->setCurrentIndex(LAN_PAGE_INDEX); +// } + } else { +// m_vpnWidget->setCurrentIndex(LAN_PAGE_INDEX); + } +} + +/** + * @brief vpnMainWindow::onTrayIconActivated 点击托盘图标的槽函数 + */ +void vpnMainWindow::onTrayIconActivated(QSystemTrayIcon::ActivationReason reason) +{ + setCentralWidgetType(m_iconStatus); + switch(reason) { + case QSystemTrayIcon::Context: + m_vpnTrayIconMenu->popup(QCursor::pos()); + break; + case QSystemTrayIcon::Trigger: + if (this->isVisible()) { + qDebug() << "Received signal of tray icon activated, will hide mainwindow." << Q_FUNC_INFO << __LINE__; + hideMainwindow(); + return; + } + qDebug() << "Received signal of tray icon activated, will show mainwindow." << Q_FUNC_INFO << __LINE__; + this->showMainwindow(); + break; + + default: + break; + } +// if (reason == QSystemTrayIcon::ActivationReason::Context) { +// m_vpnTrayIconMenu->popup(QCursor::pos()); +// } else { +// if (this->isVisible()) { +// qDebug() << "Received signal of tray icon activated, will hide mainwindow." << Q_FUNC_INFO << __LINE__; +// hideMainwindow(); +// return; +// } +// qDebug() << "Received signal of tray icon activated, will show mainwindow." << Q_FUNC_INFO << __LINE__; +// this->showMainwindow(); +// } +} + +//void MainWindow::onShowMainwindowActionTriggled() +//{ +// showMainwindow(); +//} + +//void MainWindow::onShowSettingsActionTriggled() +//{ +// showControlCenter(); +//} + +void vpnMainWindow::onThemeChanged(const QString &key) +{ + if (key == COLOR_THEME) { + qDebug() << "Received signal of theme changed, will reset theme." << Q_FUNC_INFO << __LINE__; + paintWithTrans(); + Q_EMIT qApp->paletteChanged(qApp->palette()); + } else { + qDebug() << "Received signal of theme changed, key=" << key << " will do nothing." << Q_FUNC_INFO << __LINE__; + } +} + +void vpnMainWindow::onRefreshTrayIcon() +{ + //更新托盘图标显示 +// m_iconTimer->stop(); +// if (m_vpnPage->lanIsConnected()) { +// m_vpnTrayIcon->setIcon(QIcon::fromTheme("network-wired-connected-symbolic")); +// m_iconStatus = IconActiveType::LAN_CONNECTED; +// } else { +// m_vpnTrayIcon->setIcon(QIcon::fromTheme("network-wired-disconnected-symbolic")); +// m_iconStatus = IconActiveType::NOT_CONNECTED; +// } + + NetworkManager::Connectivity connecttivity; + if (connecttivity != NetworkManager::Connectivity::Full) { + if (m_iconStatus == IconActiveType::LAN_CONNECTED) { + m_vpnTrayIcon->setIcon(QIcon::fromTheme("network-error-symbolic")); + m_iconStatus = IconActiveType::LAN_CONNECTED_LIMITED; + } + } +} + +//void vpnMainWindow::onSetTrayIconLoading() +//{ +// if (m_currentIconIndex > 11) { +// m_currentIconIndex = 0; +// } +// m_vpnTrayIcon->setIcon(m_loadIcons.at(m_currentIconIndex)); +// m_iconStatus = IconActiveType::ACTIVATING; +// m_currentIconIndex ++; +//} + +//void MainWindow::onLanConnectStatusToChangeTrayIcon(int state) +//{ +// qDebug() << "lan state:" << state << Q_FUNC_INFO << __LINE__; +// if (state==1 || state==3){ +// m_lanIsLoading = true; +// m_iconTimer->start(LOADING_TRAYICON_TIMER_MS); +// } else { +// m_lanIsLoading = false; +// if (m_wlanIsLoading == false) { +// onRefreshTrayIcon(); +// } +// } +//} + +//void MainWindow::onTabletModeChanged(bool mode) +//{ +// qDebug() << "TabletMode change" << mode; +// Q_UNUSED(mode) +// //模式切换时,隐藏主界面 +// hideMainwindow(); +//} + +//void MainWindow::onShowMainWindow(int type) +//{ +// m_vpnWidget->setCurrentIndex(type); + +// if(QApplication::activeWindow() != this) { +// this->showMainwindow(); +// } +//} + +//void MainWindow::onConnectivityChanged(NetworkManager::Connectivity connectivity) +//{ +// if (!m_vpnTrayIcon) { +// return; +// } + +// if (m_iconStatus == ACTIVATING) { +// return; +// } + +// onRefreshTrayIcon(); +//} + +///** +// * @brief MainWindow::keyPressEvent 按esc键关闭主界面 +// * @param event +// */ +//void MainWindow::keyPressEvent(QKeyEvent *event) +//{ +// if (event->key() == Qt::Key_Escape) { +// hideMainwindow(); +// } +// return QWidget::keyPressEvent(event); +//} + +///** +// * @brief MainWindow::eventFilter 事件过滤器 +// * @param watched +// * @param event +// * @return +// */ +bool vpnMainWindow::eventFilter(QObject *watched, QEvent *event) +{ + if (event->type() == QEvent::ActivationChange) { + if(QApplication::activeWindow() != this) { + hideMainwindow(); + } + } + return QMainWindow::eventFilter(watched,event); +} + +void vpnMainWindow::getVirtualList(QMap> &map) +{ + map.clear(); + if (nullptr != m_vpnPage) { + m_vpnPage->getVirtualList(map); + } +} + +//void MainWindow::setWiredDeviceEnable(const QString& devName, bool enable) +//{ +// m_vpnPage->setWiredDeviceEnable(devName, enable); +//} +//void MainWindow::showPropertyWidget(QString devName, QString ssid) +//{ +// KyNetworkDeviceResourse *devResourse = new KyNetworkDeviceResourse(); +// QStringList wiredDeviceList; +// wiredDeviceList.clear(); +// devResourse->getNetworkDeviceList(NetworkManager::Device::Type::Ethernet, wiredDeviceList); +// if (wiredDeviceList.contains(devName)) { +// qDebug() << "showPropertyWidget device type wired device name " << devName << " uuid " << ssid; +// m_vpnPage->showDetailPage(devName, ssid); +// delete devResourse; +// devResourse = nullptr; +// return; +// } + +// QStringList wirelessDeviceList; +// wirelessDeviceList.clear(); +// devResourse->getNetworkDeviceList(NetworkManager::Device::Type::Wifi, wirelessDeviceList); +// if (wirelessDeviceList.contains(devName)) { +// qDebug() << "showPropertyWidget device type wireless device name " << devName << " ssid " << ssid; +// m_wlanWidget->showDetailPage(devName, ssid); +// delete devResourse; +// devResourse = nullptr; +// return; +// } + +// qWarning() << "showPropertyWidget no such device " << devName; +// delete devResourse; +// devResourse = nullptr; +//} + +//void MainWindow::showCreateWiredConnectWidget(const QString devName) +//{ +// qDebug() << "showCreateWiredConnectWidget! devName = " << devName; +// if (m_createPagePtrMap.contains(devName)) { +// if (m_createPagePtrMap[devName] != nullptr) { +// qDebug() << "showCreateWiredConnectWidget" << devName << "already create,just raise"; + +// KWindowSystem::raiseWindow(m_createPagePtrMap[devName]->winId()); +// return; +// } +// } +// NetDetail *netDetail = new NetDetail(devName, "", "", false, false, true, this); +// connect(netDetail, &NetDetail::createPageClose, [&](QString interfaceName){ +// if (m_createPagePtrMap.contains(interfaceName)) { +// m_createPagePtrMap[interfaceName] = nullptr; +// } +// }); +// m_createPagePtrMap.insert(devName, netDetail); +// netDetail->show(); +//} + +//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(); +//} + +//有线连接断开 +void vpnMainWindow::activateVpn(const QString& connUuid) +{ + m_vpnPage->activateVpn(connUuid); +} +void vpnMainWindow::deactivateVpn(const QString& connUuid) +{ + m_vpnPage->deactivateVpn(connUuid); +} + diff --git a/src/frontend/vpnmainwindow.h b/src/frontend/vpnmainwindow.h new file mode 100644 index 00000000..4a898413 --- /dev/null +++ b/src/frontend/vpnmainwindow.h @@ -0,0 +1,167 @@ +/* -*- 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 VPNMAINWINDOW_H +#define VPNMAINWINDOW_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "vpnpage.h" +#include "mainwindow.h" + +#ifdef WITHKYSEC +#include +#include +#endif + +//enum IconActiveType { +// NOT_CONNECTED = 0, +// LAN_CONNECTED, +// WLAN_CONNECTED, +// LAN_CONNECTED_LIMITED, +// WLAN_CONNECTED_LIMITED, +// ACTIVATING, +//}; + +//const QByteArray TRANSPARENCY_GSETTINGS = "org.ukui.control-center.personalise"; + +class VpnPage; + +class vpnMainWindow : public QMainWindow +{ + Q_OBJECT +public: + explicit vpnMainWindow(QWidget *parent = nullptr); + void showMainwindow(); + void hideMainwindow(); + + void getVirtualList(QMap> &map); + +// void setWiredDefaultDevice(QString deviceName); + +// //有线连接断开 + void activateVpn(const QString& connUuid); + void deactivateVpn(const QString& connUuid); + +// //唤起属性页 根据网卡类型 参数2 为ssid/uuid +// void showPropertyWidget(QString devName, QString ssid); +// //唤起新建有线连接界面 +// void showCreateWiredConnectWidget(const QString devName); + +Q_SIGNALS: +// //设备插拔 +// void deviceStatusChanged(); +// //设备名称变化 +// void deviceNameChanged(QString oldName, QString newName, int type); + void vpnAdd(QString devName, QStringList info); + void vpnRemove(QString dbusPath); + void vpnUpdate(QString devName, QStringList info); + void vpnActiveConnectionStateChanged(QString devName, QString uuid, int status); +// void activateFailed(QString errorMessage); +// void deactivateFailed(QString errorMessage); + void mainWindowVisibleChanged(const bool &visible); +// //列表排序 +// void timeToUpdate(); +public Q_SLOTS: + +protected: +// void keyPressEvent(QKeyEvent *event); + bool eventFilter(QObject *watched, QEvent *event) override; + void paintEvent(QPaintEvent *event); + +private: + void firstlyStart(); //一级启动 + void secondaryStart(); //二级启动 + bool m_loadFinished = false; //是否二级启动已执行完 + QTimer * m_secondaryStartTimer = nullptr; //执行二级启动的倒计时 + void initPlatform(); + void initWindowProperties(); + void initTransparency(); + void paintWithTrans(); + void initUI(); + void initDbusConnnect(); + void initTrayIcon(); +// void resetTrayIconTool(); + void initWindowTheme(); +// void resetWindowTheme(); +// void showControlCenter(); + void showByWaylandHelper(); + void setCentralWidgetType(IconActiveType iconStatus); + double m_transparency=1.0; //透明度 + QGSettings * m_transGsettings; //透明度配置文件 + int m_currentIconIndex = 0; + QList m_loadIcons; + QTimer *m_iconTimer = nullptr; + +// //主窗口的主要构成控件 + QWidget * m_vpnWidget = nullptr; +// QHBoxLayout * m_tabBarLayout = nullptr; + QLabel * m_lanLabel = nullptr; + VpnPage * m_vpnPage = nullptr; + QVBoxLayout * m_vpnLayout = nullptr; + + //监听主题的Gsettings + QGSettings * m_styleGsettings = nullptr; + +// //获取和重置窗口位置 + void resetWindowPosition(); + QDBusInterface * m_positionInterface = nullptr; + +// //托盘图标,托盘图标右键菜单 + QSystemTrayIcon * m_vpnTrayIcon = nullptr; + QMenu * m_vpnTrayIconMenu = nullptr; +// QAction * m_showMainwindowAction = nullptr; +// QAction * m_showSettingsAction = nullptr; + +// bool m_lanIsLoading = false; + + bool m_isShowInCenter = false; + + IconActiveType m_iconStatus = IconActiveType::NOT_CONNECTED; + + QMap m_createPagePtrMap; +//// QMap m_addOtherPagePtrMap; +// QMap m_addOtherPagePtrMap; + +public Q_SLOTS: +// void onShowMainWindow(int type); + +private Q_SLOTS: + void onTransChanged(); + void onTrayIconActivated(QSystemTrayIcon::ActivationReason reason); +// void onShowMainwindowActionTriggled(); +// void onShowSettingsActionTriggled(); + void onThemeChanged(const QString &key); + void onRefreshTrayIcon(); +// void onSetTrayIconLoading(); +// void onLanConnectStatusToChangeTrayIcon(int state); +// void onWlanConnectStatusToChangeTrayIcon(int state); +// void onConnectivityChanged(NetworkManager::Connectivity connectivity); +// void onTabletModeChanged(bool mode); +}; + +#endif // MAINWINDOW_H diff --git a/src/main.cpp b/src/main.cpp index f8d71220..bf2a23bf 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -16,8 +16,8 @@ * */ -//#include "mainwindow.h" #include "mainwindow.h" +#include "vpnmainwindow.h" #include "dbusadaptor.h" #include #include @@ -148,6 +148,9 @@ int main(int argc, char *argv[]) ::usleep(1000); } + vpnMainWindow vpnwindow; + vpnwindow.setProperty("useStyleWindowManager", false); //禁用拖动 + MainWindow w; a.setActivationWindow(&w); w.setProperty("useStyleWindowManager", false); //禁用拖动 diff --git a/src/src.pro b/src/src.pro index dd6be2ba..8453443e 100644 --- a/src/src.pro +++ b/src/src.pro @@ -15,10 +15,11 @@ CONFIG += c++14 qt warn_on link_pkgconfig #CONFIG += release PKGCONFIG +=gio-2.0 glib-2.0 gio-unix-2.0 libnm libnma libsecret-1 gtk+-3.0 gsettings-qt libcap kysdk-qtwidgets kysdk-waylandhelper +PKGCONFIG +=kysdk-sysinfo INCLUDEPATH += /usr/include/KF5/NetworkManagerQt -LIBS += -L/usr/lib/ -lgsettings-qt -lX11 -lKF5NetworkManagerQt -lukui-log4qt -lukui-com4c -lukui-com4cxx +LIBS += -L/usr/lib/ -lgsettings-qt -lX11 -lKF5NetworkManagerQt -lukui-log4qt #LIBS += -lkysec target.path = /usr/bin target.source += $$TARGET diff --git a/translations/kylin-nm_bo.ts b/translations/kylin-nm_bo.ts index 50074520..a8ee3040 100644 --- a/translations/kylin-nm_bo.ts +++ b/translations/kylin-nm_bo.ts @@ -29,22 +29,18 @@ - - Prefs DNS + + + Required - - Alternative DNS - - - - + Auto(DHCP) - + Manual @@ -52,82 +48,82 @@ DetailPage - + Auto Connection - - + + SSID: - + Copied successfully! - + Copy all - + Please input SSID: - - + + Protocol: - - + + Security Type: - - + + Hz: - - + + Chan: - - + + BandWidth: - - + + IPV6: - - + + IPV4: - - + + IPV4 Dns: - - + + Mac: @@ -173,22 +169,12 @@ - - Prefs DNS - - - - - Alternative DNS - - - - + Auto(DHCP) - + Manual @@ -196,42 +182,32 @@ Ipv6Page - + Ipv6Config - + Address - + Subnet prefix Length - + Default Gateway - - Prefs DNS - - - - - Alternative DNS - - - - + Auto(DHCP) - + Manual @@ -264,37 +240,37 @@ LanPage - + No ethernet device avaliable - + LAN - + Activated LAN - + Inactivated LAN - + LAN Connected Successfully - + LAN Disconnected Successfully - + Wired Device not carried @@ -302,12 +278,12 @@ ListItem - + Kylin NM - + kylin network applet desktop message @@ -315,143 +291,151 @@ MainWindow - - + + kylin-nm - + LAN - + WLAN - + Settings - + Show MainWindow + + MultipleDnsWidget + + + DNS server: + + + NetDetail - + Kylin NM - + kylin network desktop message - + Detail - + Ipv4 - + Ipv6 - + Security - + Confirm - + Cancel - + Forget this network - + Add Lan Connect - + connect hiddin wlan - - - + + + None + + - - Auto - + start check ipv4 address conflict - + start check ipv6 address conflict - - - + + + ipv4 address conflict! - - + + ipv6 address conflict! - + this wifi no support enterprise type - + this wifi no support None type - + this wifi no support WPA2 type - + this wifi no support WPA3 type @@ -545,11 +529,11 @@ - - - - - + + + + + None @@ -576,20 +560,38 @@ - - - + + + Choose a CA certificate - - - + + + CA Files (*.pem *.der *.p12 *.crt *.cer *.pfx) + + SinglePage + + + Settings + + + + + Kylin NM + + + + + kylin network applet desktop message + + + TabPage @@ -608,16 +610,49 @@ - + Kylin NM - + kylin network applet desktop message + + VpnListItem + + + Not connected + + + + + + Disconnect + + + + + + Connect + + + + + VpnPage + + + VPN Connection + + + + + VPN Settings + + + WiFiConfigDialog @@ -626,37 +661,37 @@ - + WLAN Authentication - + Input WLAN Information Please - + WLAN ID: - + WLAN Name: - + Password: - + Cancl - + Ok @@ -664,31 +699,31 @@ WlanListItem - + Not connected - + Disconnect - - + + Connect - + Forget - + Auto Connect @@ -704,35 +739,66 @@ WlanPage - + WLAN - + Activated WLAN - + Other WLAN - + No wireless network card detected - + WLAN Connected Successfully - - + + WLAN Disconnected Successfully + + main + + + kylinnm + + + + + show kylin-nm wifi page + + + + + show kylin-nm lan page + + + + + vpnMainWindow + + + kylin-vpn + + + + + vpn tool + + + diff --git a/translations/kylin-nm_tr.ts b/translations/kylin-nm_tr.ts index 82e901c0..c87a65ca 100644 --- a/translations/kylin-nm_tr.ts +++ b/translations/kylin-nm_tr.ts @@ -127,22 +127,18 @@ - - Prefs DNS + + + Required - - Alternative DNS - - - - + Auto(DHCP) Oto(DHCP) - + Manual Elle @@ -150,82 +146,82 @@ DetailPage - + Auto Connection - - + + SSID: - + Copied successfully! - + Copy all - + Please input SSID: - - + + Protocol: - - + + Security Type: - - + + Hz: - - + + Chan: - - + + BandWidth: - - + + IPV6: - - + + IPV4: - - + + IPV4 Dns: - - + + Mac: @@ -1192,22 +1188,12 @@ - - Prefs DNS - - - - - Alternative DNS - - - - + Auto(DHCP) Oto(DHCP) - + Manual Elle @@ -1215,42 +1201,32 @@ Ipv6Page - + Ipv6Config - + Address - + Subnet prefix Length - + Default Gateway - - Prefs DNS - - - - - Alternative DNS - - - - + Auto(DHCP) Oto(DHCP) - + Manual Elle @@ -1290,37 +1266,37 @@ LanPage - + No ethernet device avaliable - + LAN - + Activated LAN - + Inactivated LAN - + LAN Connected Successfully - + LAN Disconnected Successfully - + Wired Device not carried @@ -1328,12 +1304,12 @@ ListItem - + Kylin NM - + kylin network applet desktop message Kylin ağ uygulaması masaüstü mesajı @@ -1341,8 +1317,8 @@ MainWindow - - + + kylin-nm @@ -1363,17 +1339,17 @@ Gizli Ağı Bağlan - + LAN - + WLAN WLAN - + Settings @@ -1390,7 +1366,7 @@ HotSpot - + Show MainWindow Ana Pencereyi Göster @@ -1483,117 +1459,125 @@ WLAN Bağlantısı Başarılı + + MultipleDnsWidget + + + DNS server: + + + NetDetail - + Kylin NM - + kylin network desktop message - + Detail - + Ipv4 - + Ipv6 - + Security - + Confirm - + Cancel - + Forget this network - + Add Lan Connect - + connect hiddin wlan - - - + + + None Yok + + - - Auto Oto - + start check ipv4 address conflict - + start check ipv6 address conflict - - - + + + ipv4 address conflict! - - + + ipv6 address conflict! - + this wifi no support enterprise type - + this wifi no support None type - + this wifi no support WPA2 type - + this wifi no support WPA3 type @@ -1885,11 +1869,11 @@ - - - - - + + + + + None Yok @@ -1916,20 +1900,38 @@ - - - + + + Choose a CA certificate - - - + + + CA Files (*.pem *.der *.p12 *.crt *.cer *.pfx) + + SinglePage + + + Settings + + + + + Kylin NM + + + + + kylin network applet desktop message + Kylin ağ uygulaması masaüstü mesajı + + TabPage @@ -1948,12 +1950,12 @@ - + Kylin NM - + kylin network applet desktop message Kylin ağ uygulaması masaüstü mesajı @@ -1965,6 +1967,39 @@ Kylin ağ uygulaması masaüstü mesajı + + VpnListItem + + + Not connected + Bağlanamadı + + + + + Disconnect + Bağlantıyı Kes + + + + + Connect + + + + + VpnPage + + + VPN Connection + + + + + VPN Settings + + + WiFiConfigDialog @@ -1973,37 +2008,37 @@ - + WLAN Authentication - + Input WLAN Information Please - + WLAN ID: - + WLAN Name: - + Password: - + Cancl - + Ok Tamam @@ -2011,31 +2046,31 @@ WlanListItem - + Not connected Bağlanamadı - + Disconnect Bağlantıyı Kes - - + + Connect - + Forget - + Auto Connect @@ -2051,33 +2086,33 @@ WlanPage - + WLAN WLAN - + Activated WLAN - + Other WLAN - + No wireless network card detected - + WLAN Connected Successfully - - + + WLAN Disconnected Successfully @@ -2097,4 +2132,35 @@ Yok + + main + + + kylinnm + + + + + show kylin-nm wifi page + + + + + show kylin-nm lan page + + + + + vpnMainWindow + + + kylin-vpn + + + + + vpn tool + + + diff --git a/translations/kylin-nm_zh_CN.qm b/translations/kylin-nm_zh_CN.qm index 97e9fc857b33b5ae7ea2ae07c9495ce61b644716..7a16c8397423bd8060e9171f8f09a4fd8c30e03d 100644 GIT binary patch delta 1382 zcmZ9Le@v8h9LGP;J->h40~g#KcjpOz1$kgD$ zYK3{4>p_r2on;X}l-gy>Nla36%xJB|wIoc)rjwxvI1hC44DT{$Uf$^m83EdmOsXUGGG;ltejdtU((BcKq#eT9-MhNYP2_0X+ zLVE)`02Ewtqd*#p)^5f`BJy42Bk*hkels?B^@U!5)Suye+cqrV28`KO0ob!3Zgk`M za*F$8699A)vYQFHH!0soyFmvCQ#)Gi0OCzT2T$nqQUfYh;GCqsezF|{m9#Q@3i?s`MnZX*>FxX*TRofUd#w~8Z5{L3k~0EJf z`41S@E(UHtj6#OQu=6?!-73~)vN*Db#HK0ioV-9B5>R-OSG=(37FK*tywYcWpAq8; zhNX(zIT)vb(Ah$mc1_X)-wtDdNhw%}0+=pB{wYFdh%jwXN+{-zOQ%0Az>3evd2Po4 z+~abf3vazWAiuxoG#2oy+`D@&j&uQG$~NV(-v-cbg%Y)*0BVEMksn06&z0k5fzpdQ zS=dJj9XFMc{2{ypBx$2F!BDRj}PCE9T+1N8P3adI$&EV*E+x#sbVz zDmKE7(Z*HrvT;YsGRov*v6V`@%IL+7qeijEZIenuT4i<6S5X6JbpYu8)Mm8jo8%`rXYs?X!JA*Y5f#rcX&Q5$;&x~Dc%5%~ZGNn%k xDZgA?KXV9T)u!r@Hh*JHBBvF(x+0{NhO|Jq{=aJPaT3rhBN7f*n_2(o^Di;rS(^X= delta 1279 zcma)*Yiv_x9LArsp8GjHZM9o3p<^Fd2#RqoGg~G^AcIh6N_9$^w`|J_nU^69L`CdG zO;C!N)@{rfjEYLP!8CPVG9(z;2b?0&Y(XKKIu=n;6R%^a@#$XU7eBy<=J)>lzUO(L z|MNfR)oTwf?((Nj0IR+LTow?&127H=TK7Xv4*_-_^29E{H~cR@hoU_TxJSqyatccI zoqT>0%If8Svs}=>9?D_r*>1tG7XkYw*831xbQR#4gNmXEkTQQ43&$fEh@ql*8xPhZ zdL|4MZ9uH?L0+(he2&aw%{JC@3fo%-fs!yLdY=Hy1^Ci;J?j=sXZpFnUsB(A06<<) zEfv(Bmg4)m`F~d0)l-ZVtjlK?2po_;s_WxMyP)!mpte>TPd^2Onu@MCycf`?1cPT? z^@(A2(&Fkp#fyA@xqe8n<4c=myQ7pzWaJgkTt*{axhq=^6d#v&M-Q?-E$G(d!Povw zF~T+S(4z?;FeATJ{Wk?(k;iJr0BNhBI>-qe0fHln6M3JByr9(F`VjZyg6iXf+O$$% zz6G#8Q`SX7z$J^6&LhPy2&Q88T{mGxFfsnSd z|6#yisSTtjnFIutZb41g?M@1Mp;tLKGwN^j_;d_V>h%}v*U?Z&P`y#_pFB;S9{p_L zyeDg1eLLSXeU;IAzLq1bHr5Azq_Hw%b85cA+1+b&o?}#Yn{ia9Q*XjJSvf<8%ZxKa ztbLL(U7$B>I?)V$RS7EZ32GH)^Z6=X@U~zuZMGi&n8{vgChKWL2?*+G!C;d)YgijK zQ=@N2=~S{-^u7y(AF*1qe2Yu=STFA$<;=>g!R`f|Wt*V?18cl2$4&默认网关 - Prefs DNS - 首选DNS + 首选DNS - Alternative DNS - 备选DNS + 备选DNS - + Auto(DHCP) 自动(DHCP) - + Manual 手动 - + + Required 必填 - - MultipleDnsWidget - - - DNS server: - DNS服务器: - - DetailPage - + Auto Connection 自动连接 - - + + SSID: SSID: - + Copied successfully! 复制成功! - + Copy all 复制全部 - + Please input SSID: 请输入SSID: - - + + Protocol: 协议: - - + + Security Type: 安全类型: - - + + Hz: 网络频带: - - + + Chan: 网络通道: - - + + BandWidth: 带宽: - - + + IPV6: 本地链接IPV6地址: - - + + IPV4: IPV4地址: - - + + IPV4 Dns: IPV4 DNS服务器: - - + + Mac: 物理地址: @@ -466,22 +457,20 @@ 默认网关 - Prefs DNS - 首选DNS + 首选DNS - Alternative DNS - 备选DNS + 备选DNS - + Auto(DHCP) 自动 - + Manual 手动 @@ -489,42 +478,40 @@ Ipv6Page - + Ipv6Config Ipv6配置 - + Address 地址 - + Subnet prefix Length 子网前缀长度 - + Default Gateway 默认网关 - Prefs DNS - 首选DNS + 首选DNS - Alternative DNS - 备选DNS + 备选DNS - + Auto(DHCP) 自动 - + Manual 手动 @@ -557,37 +544,37 @@ LanPage - + No ethernet device avaliable 未检测到有线设备 - + LAN 有线网络 - + Activated LAN 我的网络 - + Inactivated LAN 其他网络 - + LAN Disconnected Successfully 有线网络已断开 - + Wired Device not carried 未插入网线 - + LAN Connected Successfully 有线网络已连接 @@ -595,12 +582,12 @@ ListItem - + Kylin NM 麒麟网络设置工具 - + kylin network applet desktop message 网络提示消息 @@ -608,64 +595,72 @@ MainWindow - - + + kylin-nm 网络工具 - + LAN 有线网络 有线网络 - + WLAN 无线局域网 无线局域网 - + Show MainWindow 打开网络工具 - + Settings 设置网络项 设置网络项 + + MultipleDnsWidget + + + DNS server: + DNS服务器: + + NetDetail - + Kylin NM 麒麟网络设置工具 - + kylin network desktop message 网络提示消息 - + Detail 详情 - + Ipv4 Ipv4 - + Ipv6 Ipv6 - + Security 安全 @@ -674,84 +669,84 @@ 关闭 - + Confirm 确定 - + Cancel 取消 - + Forget this network 忘记此网络 - + Add Lan Connect 添加有线网络 - + connect hiddin wlan 连接到隐藏WLAN - - - + + + None + + - - Auto 自动 - + start check ipv4 address conflict 开始检测ipv4地址冲突 - + start check ipv6 address conflict 开始检测ipv6地址冲突 - - - + + + ipv4 address conflict! ipv4地址冲突! - - + + ipv6 address conflict! ipv6地址冲突! - + this wifi no support enterprise type 此wifi不支持企业网类型 - + this wifi no support None type 此wifi不支持空类型 - + this wifi no support WPA2 type 此wifi不支持WPA2类型 - + this wifi no support WPA3 type 此wifi不支持WPA3类型 @@ -937,11 +932,11 @@ - - - - - + + + + + None @@ -968,20 +963,38 @@ 从文件选择... - - - + + + Choose a CA certificate 选择一个CA证书 - - - + + + CA Files (*.pem *.der *.p12 *.crt *.cer *.pfx) CA 证书 (*.pem *.der *.p12 *.crt *.cer *.pfx) + + SinglePage + + + Settings + 设置 + + + + Kylin NM + 网络工具 + + + + kylin network applet desktop message + 网络提示消息 + + TabPage @@ -1000,16 +1013,49 @@ 网络设置 - + Kylin NM 麒麟网络设置工具 - + kylin network applet desktop message 网络提示消息 + + VpnListItem + + + Not connected + 未连接 + + + + + Disconnect + 断开 + + + + + Connect + 连接 + + + + VpnPage + + + VPN Connection + VPN连接 + + + + VPN Settings + VPN设置 + + WiFiConfigDialog @@ -1018,37 +1064,37 @@ - + WLAN Authentication - + Input WLAN Information Please - + WLAN ID: - + WLAN Name: - + Password: - + Cancl - + Ok @@ -1056,31 +1102,31 @@ WlanListItem - + Not connected 未连接 - + Disconnect 断开 - - + + Connect 连接 - + Forget 忘记此网络 - + Auto Connect 自动加入该网络 @@ -1100,22 +1146,22 @@ WlanPage - + WLAN 无线局域网 - + No wireless network card detected 未检测到无线网卡 - + Activated WLAN 我的网络 - + Other WLAN 其他网络 @@ -1124,13 +1170,13 @@ 更多... - + WLAN Connected Successfully 无线网络已连接 - - + + WLAN Disconnected Successfully 无线网络已断开 @@ -1190,4 +1236,35 @@ 不需要CA证书 + + main + + + kylinnm + + + + + show kylin-nm wifi page + + + + + show kylin-nm lan page + + + + + vpnMainWindow + + + kylin-vpn + VPN工具 + + + + vpn tool + VPN工具 + +