解决VPN崩溃问题和部分BUG,删除部分多与代码
This commit is contained in:
parent
f490fe0ff0
commit
c00f505479
|
@ -7,3 +7,6 @@ dpkg-divert --package kylin-nm --rename --divert "$path"".old" --add $path
|
|||
|
||||
path2="/usr/lib/`/usr/bin/dpkg-architecture -qDEB_TARGET_MULTIARCH`/ukui-control-center/libproxy.so"
|
||||
dpkg-divert --package kylin-nm --rename --divert "$path2"".old" --add $path2
|
||||
|
||||
path3="/usr/lib/`/usr/bin/dpkg-architecture -qDEB_TARGET_MULTIARCH`/ukui-control-center/libvpn.so"
|
||||
dpkg-divert --package kylin-nm --rename --divert "$path3"".old" --add $path3
|
||||
|
|
Binary file not shown.
|
@ -0,0 +1,80 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS>
|
||||
<TS version="2.1" language="zh_CN" sourcelanguage="en">
|
||||
<context>
|
||||
<name>AddNetBtn</name>
|
||||
<message>
|
||||
<location filename="../../component/AddBtn/addnetbtn.cpp" line="47"/>
|
||||
<source>Add Others</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../component/AddBtn/addnetbtn.cpp" line="51"/>
|
||||
<source>Add WiredNetork</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>ItemFrame</name>
|
||||
<message>
|
||||
<location filename="../itemframe.cpp" line="38"/>
|
||||
<source>Add Vpn</source>
|
||||
<translation>添加VPN</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>Vpn</name>
|
||||
<message>
|
||||
<location filename="../vpn.ui" line="53"/>
|
||||
<source>VPN</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../vpn.ui" line="68"/>
|
||||
<source>import</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../vpn.cpp" line="68"/>
|
||||
<source>Vpn</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../vpn.cpp" line="151"/>
|
||||
<source>Show on Taskbar</source>
|
||||
<translation>在任务栏显示图标</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../vpn.cpp" line="347"/>
|
||||
<location filename="../vpn.cpp" line="454"/>
|
||||
<source>connected</source>
|
||||
<translation>已连接</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../vpn.cpp" line="349"/>
|
||||
<location filename="../vpn.cpp" line="464"/>
|
||||
<source>not connected</source>
|
||||
<translation>未连接</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>VpnItem</name>
|
||||
<message>
|
||||
<location filename="../vpnitem.cpp" line="58"/>
|
||||
<source>Delete</source>
|
||||
<translation>删除</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../vpnitem.cpp" line="111"/>
|
||||
<location filename="../vpnitem.cpp" line="124"/>
|
||||
<source>Disconnect</source>
|
||||
<translation>断开</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../vpnitem.cpp" line="113"/>
|
||||
<location filename="../vpnitem.cpp" line="122"/>
|
||||
<source>Connect</source>
|
||||
<translation>连接</translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
|
@ -52,11 +52,19 @@
|
|||
|
||||
#define KVpnSymbolic "ukui-vpn-symbolic"
|
||||
|
||||
#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 VISIBLE = "visible";
|
||||
const QByteArray GSETTINGS_SCHEMA = "org.ukui.kylin-nm.vpnicon";
|
||||
|
||||
Vpn::Vpn() : mFirstLoad(true)
|
||||
{
|
||||
QTranslator* translator = new QTranslator(this);
|
||||
translator->load("/usr/share/kylin-nm/vpn/" + QLocale::system().name());
|
||||
QApplication::installTranslator(translator);
|
||||
|
||||
pluginName = tr("Vpn");
|
||||
pluginType = NETWORK;
|
||||
}
|
||||
|
@ -308,8 +316,6 @@ void Vpn::addOneVirtualItem(QStringList infoList)
|
|||
int status = infoList.at(3).toInt(); //1-连接中 2-已连接 3-断开中 4-已断开
|
||||
VpnItem * item = new VpnItem(pluginWidget);
|
||||
|
||||
item->statusLabel->setText(tr("not connected"));
|
||||
|
||||
QIcon searchIcon = QIcon::fromTheme(KVpnSymbolic);
|
||||
item->iconLabel->setPixmap(searchIcon.pixmap(searchIcon.actualSize(QSize(ICON_SIZE))));
|
||||
item->titileLabel->setText(connName);
|
||||
|
@ -321,19 +327,28 @@ void Vpn::addOneVirtualItem(QStringList infoList)
|
|||
item->startLoading();
|
||||
}
|
||||
|
||||
// connect(lanItem->infoLabel, &GrayInfoButton::clicked, this, [=]{
|
||||
// // open landetail page
|
||||
// if (!m_interface->isValid()) {
|
||||
// return;
|
||||
// }
|
||||
// qDebug() << "[NetConnect]call showPropertyWidget" << deviceName << connUuid << __LINE__;
|
||||
// m_interface->call(QStringLiteral("showPropertyWidget"), deviceName, connUuid);
|
||||
// qDebug() << "[NetConnect]call showPropertyWidget respond" << __LINE__;
|
||||
// });
|
||||
connect(item->infoLabel, &GrayInfoButton::clicked, this, [=]{
|
||||
QDBusInterface appManagerDbusInterface(KYLIN_APP_MANAGER_NAME,
|
||||
KYLIN_APP_MANAGER_PATH,
|
||||
KYLIN_APP_MANAGER_INTERFACE,
|
||||
QDBusConnection::sessionBus());
|
||||
|
||||
if (!appManagerDbusInterface.isValid()) {
|
||||
qWarning()<<"appManagerDbusInterface init error";
|
||||
} else {
|
||||
QDBusReply<bool> reply = appManagerDbusInterface.call("LaunchApp", "nm-connection-editor.desktop");
|
||||
}
|
||||
});
|
||||
|
||||
item->isAcitve = (status == 2);
|
||||
item->setConnectActionText(item->isAcitve);
|
||||
|
||||
if (item->isAcitve) {
|
||||
item->statusLabel->setText(tr("connected"));
|
||||
} else {
|
||||
item->statusLabel->setText(tr("not connected"));
|
||||
}
|
||||
|
||||
connect(item, &QPushButton::clicked, this, [=] {
|
||||
if (item->isAcitve || item->loading) {
|
||||
deActiveConnect(item->uuid);
|
||||
|
|
|
@ -19,6 +19,8 @@ PKGCONFIG += gsettings-qt \
|
|||
TARGET = $$qtLibraryTarget(vpn)
|
||||
DESTDIR = ../..
|
||||
target.path = $$[QT_INSTALL_LIBS]/ukui-control-center
|
||||
trans.files = translations/*
|
||||
trans.path = /usr/share/kylin-nm/vpn/
|
||||
|
||||
INCLUDEPATH += \
|
||||
$$PROJECT_COMPONENTSOURCE \
|
||||
|
@ -41,4 +43,8 @@ HEADERS += \
|
|||
FORMS += \
|
||||
vpn.ui
|
||||
|
||||
INSTALLS += target
|
||||
INSTALLS += target \
|
||||
trans
|
||||
|
||||
TRANSLATIONS += \
|
||||
translations/zh_CN.ts
|
||||
|
|
|
@ -46,7 +46,7 @@ VpnItem::VpnItem(bool bAcitve, QWidget *parent)
|
|||
titileLabel = new FixLabel(this);
|
||||
statusLabel = new QLabel(this);
|
||||
statusLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
||||
// infoLabel = new GrayInfoButton(this);
|
||||
infoLabel = new GrayInfoButton(this);
|
||||
|
||||
m_moreButton = new QToolButton(this);
|
||||
m_moreButton->setProperty("useButtonPalette", true);
|
||||
|
@ -66,7 +66,7 @@ VpnItem::VpnItem(bool bAcitve, QWidget *parent)
|
|||
mLanLyt->addWidget(titileLabel,Qt::AlignLeft);
|
||||
mLanLyt->addStretch();
|
||||
mLanLyt->addWidget(statusLabel);
|
||||
// mLanLyt->addWidget(infoLabel);
|
||||
mLanLyt->addWidget(infoLabel);
|
||||
mLanLyt->addWidget(m_moreButton);
|
||||
|
||||
loadIcons.append(QIcon::fromTheme("ukui-loading-1-symbolic"));
|
||||
|
|
|
@ -42,7 +42,7 @@ public:
|
|||
VpnItem(bool bAcitve, QWidget *parent = nullptr);
|
||||
public:
|
||||
QLabel * iconLabel = nullptr;
|
||||
// GrayInfoButton * infoLabel = nullptr;
|
||||
GrayInfoButton * infoLabel = nullptr;
|
||||
FixLabel * titileLabel = nullptr;
|
||||
QLabel * statusLabel = nullptr;
|
||||
QToolButton* m_moreButton = nullptr;
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
|
||||
VpnListItem::VpnListItem(const KyConnectItem *lanConnectItem, QWidget *parent):ListItem(parent)
|
||||
{
|
||||
m_infoButton->setVisible(false);
|
||||
m_connectOperation = new KyWiredConnectOperation(this);
|
||||
m_deviceResource = new KyNetworkDeviceResourse(this);
|
||||
|
||||
|
@ -182,40 +181,25 @@ void VpnListItem::onMenuTriggered(QAction *action)
|
|||
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<bool> reply = appManagerDbusInterface.call("LaunchApp", desktopFile);
|
||||
return reply;
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
// << "." <<Q_FUNC_INFO << __LINE__;
|
||||
|
||||
// bool isActivated = false;
|
||||
// if (Activated == m_vpnConnectItem.m_connectState) {
|
||||
// isActivated = true;
|
||||
// }
|
||||
|
||||
// netDetail = new NetDetail(m_deviceName, m_vpnConnectItem.m_connectName,
|
||||
// m_vpnConnectItem.m_connectUuid, isActivated,false, false);
|
||||
|
||||
// connect(netDetail, &NetDetail::destroyed, [&](){
|
||||
// if (netDetail != nullptr) {
|
||||
// netDetail = nullptr;
|
||||
// }
|
||||
// });
|
||||
|
||||
// netDetail->show();
|
||||
// Q_EMIT this->detailShow(true);
|
||||
|
||||
launchApp("nm-connection-editor.desktop");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -26,6 +26,10 @@
|
|||
#include <QEvent>
|
||||
#include <QAction>
|
||||
|
||||
#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
|
||||
|
@ -50,6 +54,7 @@ public:
|
|||
protected:
|
||||
void setIcon(bool isOn);
|
||||
void onRightButtonClicked();
|
||||
bool launchApp(QString desktopFile);
|
||||
|
||||
private:
|
||||
void connectItemCopy(const KyConnectItem *lanConnectItem);
|
||||
|
@ -61,6 +66,7 @@ private Q_SLOTS:
|
|||
|
||||
private:
|
||||
KyConnectItem m_vpnConnectItem;
|
||||
// QDBusInterface m_appManagerDbusInterface;
|
||||
|
||||
KyWiredConnectOperation *m_connectOperation = nullptr;
|
||||
KyNetworkDeviceResourse *m_deviceResource = nullptr;
|
||||
|
|
|
@ -42,7 +42,7 @@ void SinglePage::initUI()
|
|||
this->setLayout(m_mainLayout);
|
||||
|
||||
m_netFrame = new QFrame(this);
|
||||
m_netFrame->setMinimumHeight(INACTIVE_AREA_MIN_HEIGHT);
|
||||
m_netFrame->setMinimumHeight(TEXT_HEIGHT + 17);
|
||||
m_netLayout = new QVBoxLayout(m_netFrame);
|
||||
m_netLayout->setContentsMargins(NET_LAYOUT_MARGINS);
|
||||
m_netFrame->setLayout(m_netLayout);
|
||||
|
@ -79,7 +79,6 @@ void SinglePage::initUI()
|
|||
m_mainLayout->addStretch();
|
||||
m_mainLayout->addWidget(m_netDivider);
|
||||
m_mainLayout->addWidget(m_settingsFrame);
|
||||
|
||||
}
|
||||
|
||||
void SinglePage::showDesktopNotify(const QString &message, QString soundName)
|
||||
|
|
|
@ -44,10 +44,6 @@ 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
|
||||
|
@ -57,7 +53,6 @@ using namespace kdk;
|
|||
#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
|
||||
|
|
|
@ -22,14 +22,7 @@
|
|||
#include <QDebug>
|
||||
#include <QScrollBar>
|
||||
|
||||
#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 VPN_LIST_SPACING 0
|
||||
#define ITEM_HEIGHT 48
|
||||
|
||||
|
||||
|
@ -49,7 +42,7 @@ VpnPage::VpnPage(QWidget *parent) : SinglePage(parent)
|
|||
initUI();
|
||||
initVpnArea();
|
||||
|
||||
connect(m_activeResourse, &KyActiveConnectResourse::vpnConnectChangeReason, this, &VpnPage::onConnectionStateChange);
|
||||
connect(m_activeResourse, &KyActiveConnectResourse::stateChangeReason, this, &VpnPage::onConnectionStateChange);
|
||||
connect(m_activeResourse, &KyActiveConnectResourse::activeConnectRemove, this, [=] (QString activeConnectUuid) {
|
||||
sendVpnStateChangeSignal(activeConnectUuid,Deactivated);
|
||||
} );
|
||||
|
@ -115,6 +108,7 @@ void VpnPage::constructActiveConnectionArea()
|
|||
{
|
||||
QList<KyConnectItem *> activedList;
|
||||
QList<KyConnectItem *> netList;
|
||||
QGSettings vpnGsettings(GSETTINGS_VPNICON_VISIBLE);
|
||||
|
||||
activedList.clear();
|
||||
netList.clear();
|
||||
|
@ -136,7 +130,6 @@ void VpnPage::constructActiveConnectionArea()
|
|||
if (m_activeConnectionMap.contains(p_netConnectionItem->m_connectUuid)) {
|
||||
qDebug()<<LOG_FLAG << "has contain uuid" << p_netConnectionItem->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);
|
||||
}
|
||||
|
@ -144,21 +137,29 @@ void VpnPage::constructActiveConnectionArea()
|
|||
delete p_netConnectionItem;
|
||||
p_netConnectionItem = nullptr;
|
||||
}
|
||||
if (vpnGsettings.keys().contains(QString(VISIBLE))) {
|
||||
vpnGsettings.set(VISIBLE, true);
|
||||
}
|
||||
} else {
|
||||
if (vpnGsettings.keys().contains(QString(VISIBLE))) {
|
||||
vpnGsettings.set(VISIBLE, false);
|
||||
}
|
||||
}
|
||||
|
||||
if (m_vpnListWidget->count() <= MAX_ITEMS) {
|
||||
m_vpnListWidget->setFixedWidth(MIN_WIDTH);
|
||||
m_netListArea->setFixedHeight(m_vpnListWidget->count() * ITEM_HEIGHT);
|
||||
} else {
|
||||
m_vpnListWidget->setFixedWidth(MAX_WIDTH);
|
||||
m_netListArea->setFixedHeight(MAX_ITEMS * ITEM_HEIGHT);
|
||||
}
|
||||
return;
|
||||
m_netFrame->setFixedHeight(37 + m_netListArea->height());
|
||||
}
|
||||
|
||||
void VpnPage::initVpnArea()
|
||||
{
|
||||
m_netFrame->show();
|
||||
constructActiveConnectionArea();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
bool VpnPage::removeConnectionItem(QMap<QString, QListWidgetItem *> &connectMap,
|
||||
|
@ -182,6 +183,7 @@ bool VpnPage::removeConnectionItem(QMap<QString, QListWidgetItem *> &connectMap,
|
|||
iter = connectMap.erase(iter);
|
||||
if (m_vpnListWidget->count() <= MAX_ITEMS) {
|
||||
m_vpnListWidget->setFixedWidth(MIN_WIDTH);
|
||||
m_netListArea->setFixedHeight(m_vpnListWidget->count() * ITEM_HEIGHT);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -197,6 +199,7 @@ void VpnPage::onRemoveConnection(QString path) //删除时后端会
|
|||
Q_EMIT vpnRemove(path);
|
||||
|
||||
if (removeConnectionItem(m_netConnectionMap, m_vpnListWidget, path)) {
|
||||
m_netFrame->setFixedHeight(37 + m_netListArea->height());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -224,9 +227,13 @@ void VpnPage::onAddConnection(QString uuid) //新增一个有线
|
|||
|
||||
delete p_newItem;
|
||||
p_newItem = nullptr;
|
||||
if (m_vpnListWidget->count() > MAX_ITEMS) {
|
||||
if (m_vpnListWidget->count() >= MAX_ITEMS) {
|
||||
m_vpnListWidget->setFixedWidth(MAX_WIDTH);
|
||||
m_netListArea->setFixedHeight(MAX_ITEMS * ITEM_HEIGHT);
|
||||
} else {
|
||||
m_netListArea->setFixedHeight(m_vpnListWidget->count() * ITEM_HEIGHT);
|
||||
}
|
||||
m_netFrame->setFixedHeight(37 + m_netListArea->height());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -241,13 +248,14 @@ 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->setSpacing(VPN_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);
|
||||
m_netListArea->setFixedHeight(0);
|
||||
|
||||
QPalette pal = m_vpnListWidget->palette();
|
||||
pal.setBrush(QPalette::Base, QColor(0,0,0,0)); //背景透明
|
||||
|
@ -337,8 +345,6 @@ void VpnPage::updateConnectionArea(KyConnectItem *p_newItem)
|
|||
} else {
|
||||
m_vpnListWidget->setFixedWidth(MAX_WIDTH);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void VpnPage::updateConnectionState(QMap<QString, QListWidgetItem *> &connectMap,
|
||||
|
@ -352,12 +358,11 @@ void VpnPage::updateConnectionState(QMap<QString, QListWidgetItem *> &connectMap
|
|||
p_lanItem->updateConnectionState(state);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void VpnPage::onConnectionStateChange(QString uuid,
|
||||
NetworkManager::VpnConnection::State state,
|
||||
NetworkManager::VpnConnection::StateChangeReason reason)
|
||||
NetworkManager::ActiveConnection::State state,
|
||||
NetworkManager::ActiveConnection::Reason reason)
|
||||
{
|
||||
//VpnPage函数内持续监听连接状态的变化并记录供其他函数调用获取状态
|
||||
if (!m_connectResourse->isVirtualConncection(uuid)) {
|
||||
|
@ -416,7 +421,6 @@ void VpnPage::onConnectionStateChange(QString uuid,
|
|||
return;
|
||||
}
|
||||
|
||||
|
||||
void VpnPage::getVirtualList(QVector<QStringList> &vector)
|
||||
{
|
||||
QList<KyConnectItem *> netConnectList;
|
||||
|
@ -424,10 +428,17 @@ void VpnPage::getVirtualList(QVector<QStringList> &vector)
|
|||
m_connectResourse->getVpnAndVirtualConnections(netConnectList); //未激活列表的显示
|
||||
if (!netConnectList.isEmpty()) {
|
||||
for (int i = 0; i < netConnectList.size(); i++) {
|
||||
KyConnectItem *p_newItem = nullptr;
|
||||
KyConnectItem *p_netConnectionItem = netConnectList.at(i);
|
||||
p_newItem = m_activeResourse->getActiveConnectionByUuid(p_netConnectionItem->m_connectUuid);
|
||||
NetworkManager::ActiveConnection::State state = p_netConnectionItem->m_connectState;
|
||||
if (p_newItem != nullptr) {
|
||||
state = NetworkManager::ActiveConnection::Activated;
|
||||
}
|
||||
vector.append(QStringList() << netConnectList.at(i)->m_connectName
|
||||
<< netConnectList.at(i)->m_connectUuid
|
||||
<< netConnectList.at(i)->m_connectPath
|
||||
<< QString::number(netConnectList.at(i)->m_connectState));
|
||||
<< QString::number(state));
|
||||
}
|
||||
}
|
||||
return;
|
||||
|
@ -445,10 +456,16 @@ void VpnPage::sendVpnUpdateSignal(KyConnectItem *p_connectItem)
|
|||
void VpnPage::sendVpnAddSignal(KyConnectItem *p_connectItem)
|
||||
{
|
||||
QStringList info;
|
||||
KyConnectItem *p_newItem = nullptr;
|
||||
p_newItem = m_activeResourse->getActiveConnectionByUuid(p_connectItem->m_connectUuid);
|
||||
NetworkManager::ActiveConnection::State state = p_connectItem->m_connectState;
|
||||
if (p_newItem != nullptr) {
|
||||
state = NetworkManager::ActiveConnection::Activated;
|
||||
}
|
||||
info << p_connectItem->m_connectName
|
||||
<< p_connectItem->m_connectUuid
|
||||
<< p_connectItem->m_connectPath
|
||||
<< QString::number(p_connectItem->m_connectState);
|
||||
<< QString::number(state);
|
||||
qDebug() << "[VpnPage] emit vpnAdd because addConnection ";
|
||||
Q_EMIT vpnAdd(info);
|
||||
|
||||
|
@ -521,7 +538,7 @@ void VpnPage::updateActiveConnectionProperty(KyConnectItem *p_connectItem)
|
|||
|
||||
void VpnPage::onUpdateConnection(QString uuid)
|
||||
{
|
||||
if (!m_connectResourse->isWiredConnection(uuid)) {
|
||||
if (!m_connectResourse->isVirtualConncection(uuid)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -35,6 +35,9 @@
|
|||
|
||||
#define VPNPAGE_LAYOUT_MARGINS 0,0,0,0
|
||||
|
||||
#define VISIBLE "visible"
|
||||
const QByteArray GSETTINGS_VPNICON_VISIBLE = "org.ukui.kylin-nm.vpnicon";
|
||||
|
||||
class VpnListItem;
|
||||
|
||||
class VpnPage : public SinglePage
|
||||
|
@ -65,7 +68,6 @@ private:
|
|||
bool removeConnectionItem(QMap<QString, QListWidgetItem *> &connectMap,
|
||||
QListWidget *lanListWidget, QString path);
|
||||
|
||||
void constructConnectionArea();
|
||||
void constructActiveConnectionArea();
|
||||
|
||||
void updateConnectionArea(KyConnectItem *p_newItem);
|
||||
|
@ -95,8 +97,8 @@ Q_SIGNALS:
|
|||
|
||||
private Q_SLOTS:
|
||||
void onConnectionStateChange(QString uuid,
|
||||
NetworkManager::VpnConnection::State state,
|
||||
NetworkManager::VpnConnection::StateChangeReason reason);
|
||||
NetworkManager::ActiveConnection::State state,
|
||||
NetworkManager::ActiveConnection::Reason reason);
|
||||
|
||||
void onAddConnection(QString uuid);
|
||||
void onRemoveConnection(QString path);
|
||||
|
|
|
@ -73,23 +73,10 @@ void vpnMainWindow::showMainwindow()
|
|||
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
|
||||
|
||||
// Q_EMIT this->mainWindowVisibleChanged(true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -98,7 +85,7 @@ void vpnMainWindow::showMainwindow()
|
|||
void vpnMainWindow::hideMainwindow()
|
||||
{
|
||||
this->hide();
|
||||
Q_EMIT this->mainWindowVisibleChanged(false);
|
||||
// Q_EMIT this->mainWindowVisibleChanged(false);
|
||||
}
|
||||
|
||||
///**
|
||||
|
@ -258,7 +245,6 @@ void vpnMainWindow::initDbusConnnect()
|
|||
connect(m_vpnPage, &VpnPage::vpnRemove, this, &vpnMainWindow::vpnRemove);
|
||||
connect(m_vpnPage, &VpnPage::vpnUpdate, this, &vpnMainWindow::vpnUpdate);
|
||||
connect(m_vpnPage, &VpnPage::vpnActiveConnectionStateChanged, this, &vpnMainWindow::vpnActiveConnectionStateChanged);
|
||||
|
||||
//模式切换
|
||||
QDBusConnection::sessionBus().connect(QString("com.kylin.statusmanager.interface"),
|
||||
QString("/"),
|
||||
|
@ -499,7 +485,7 @@ void vpnMainWindow::initVpnIconVisible()
|
|||
{
|
||||
if(QGSettings::isSchemaInstalled(GSETTINGS_VPNICON_VISIBLE)) {
|
||||
m_vpnGsettings = new QGSettings(GSETTINGS_VPNICON_VISIBLE);
|
||||
if(m_vpnGsettings->keys().contains(QString("visible"))) {
|
||||
if(m_vpnGsettings->keys().contains(QString(VISIBLE))) {
|
||||
connect(m_vpnGsettings, &QGSettings::changed, this, &vpnMainWindow::onVpnIconVisibleChanged);
|
||||
m_vpnTrayIcon->setVisible(m_vpnGsettings->get("visible").toBool());
|
||||
}
|
||||
|
|
|
@ -33,8 +33,6 @@
|
|||
#include "vpnpage.h"
|
||||
#include "mainwindow.h"
|
||||
|
||||
const QByteArray GSETTINGS_VPNICON_VISIBLE = "org.ukui.kylin-nm.vpnicon";
|
||||
|
||||
class VpnPage;
|
||||
|
||||
class vpnMainWindow : public QMainWindow
|
||||
|
|
Loading…
Reference in New Issue