解决VPN崩溃问题和部分BUG,删除部分多与代码

This commit is contained in:
chenxuechao 2022-11-02 17:42:31 +08:00
parent f490fe0ff0
commit c00f505479
15 changed files with 191 additions and 100 deletions

View File

@ -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" 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 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.

View File

@ -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>

View File

@ -52,11 +52,19 @@
#define KVpnSymbolic "ukui-vpn-symbolic" #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 QString VISIBLE = "visible";
const QByteArray GSETTINGS_SCHEMA = "org.ukui.kylin-nm.vpnicon"; const QByteArray GSETTINGS_SCHEMA = "org.ukui.kylin-nm.vpnicon";
Vpn::Vpn() : mFirstLoad(true) 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"); pluginName = tr("Vpn");
pluginType = NETWORK; pluginType = NETWORK;
} }
@ -308,8 +316,6 @@ void Vpn::addOneVirtualItem(QStringList infoList)
int status = infoList.at(3).toInt(); //1-连接中 2-已连接 3-断开中 4-已断开 int status = infoList.at(3).toInt(); //1-连接中 2-已连接 3-断开中 4-已断开
VpnItem * item = new VpnItem(pluginWidget); VpnItem * item = new VpnItem(pluginWidget);
item->statusLabel->setText(tr("not connected"));
QIcon searchIcon = QIcon::fromTheme(KVpnSymbolic); QIcon searchIcon = QIcon::fromTheme(KVpnSymbolic);
item->iconLabel->setPixmap(searchIcon.pixmap(searchIcon.actualSize(QSize(ICON_SIZE)))); item->iconLabel->setPixmap(searchIcon.pixmap(searchIcon.actualSize(QSize(ICON_SIZE))));
item->titileLabel->setText(connName); item->titileLabel->setText(connName);
@ -321,19 +327,28 @@ void Vpn::addOneVirtualItem(QStringList infoList)
item->startLoading(); item->startLoading();
} }
// connect(lanItem->infoLabel, &GrayInfoButton::clicked, this, [=]{ connect(item->infoLabel, &GrayInfoButton::clicked, this, [=]{
// // open landetail page QDBusInterface appManagerDbusInterface(KYLIN_APP_MANAGER_NAME,
// if (!m_interface->isValid()) { KYLIN_APP_MANAGER_PATH,
// return; KYLIN_APP_MANAGER_INTERFACE,
// } QDBusConnection::sessionBus());
// qDebug() << "[NetConnect]call showPropertyWidget" << deviceName << connUuid << __LINE__;
// m_interface->call(QStringLiteral("showPropertyWidget"), deviceName, connUuid); if (!appManagerDbusInterface.isValid()) {
// qDebug() << "[NetConnect]call showPropertyWidget respond" << __LINE__; qWarning()<<"appManagerDbusInterface init error";
// }); } else {
QDBusReply<bool> reply = appManagerDbusInterface.call("LaunchApp", "nm-connection-editor.desktop");
}
});
item->isAcitve = (status == 2); item->isAcitve = (status == 2);
item->setConnectActionText(item->isAcitve); item->setConnectActionText(item->isAcitve);
if (item->isAcitve) {
item->statusLabel->setText(tr("connected"));
} else {
item->statusLabel->setText(tr("not connected"));
}
connect(item, &QPushButton::clicked, this, [=] { connect(item, &QPushButton::clicked, this, [=] {
if (item->isAcitve || item->loading) { if (item->isAcitve || item->loading) {
deActiveConnect(item->uuid); deActiveConnect(item->uuid);

View File

@ -19,6 +19,8 @@ PKGCONFIG += gsettings-qt \
TARGET = $$qtLibraryTarget(vpn) TARGET = $$qtLibraryTarget(vpn)
DESTDIR = ../.. DESTDIR = ../..
target.path = $$[QT_INSTALL_LIBS]/ukui-control-center target.path = $$[QT_INSTALL_LIBS]/ukui-control-center
trans.files = translations/*
trans.path = /usr/share/kylin-nm/vpn/
INCLUDEPATH += \ INCLUDEPATH += \
$$PROJECT_COMPONENTSOURCE \ $$PROJECT_COMPONENTSOURCE \
@ -41,4 +43,8 @@ HEADERS += \
FORMS += \ FORMS += \
vpn.ui vpn.ui
INSTALLS += target INSTALLS += target \
trans
TRANSLATIONS += \
translations/zh_CN.ts

View File

@ -46,7 +46,7 @@ VpnItem::VpnItem(bool bAcitve, QWidget *parent)
titileLabel = new FixLabel(this); titileLabel = new FixLabel(this);
statusLabel = new QLabel(this); statusLabel = new QLabel(this);
statusLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter); statusLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
// infoLabel = new GrayInfoButton(this); infoLabel = new GrayInfoButton(this);
m_moreButton = new QToolButton(this); m_moreButton = new QToolButton(this);
m_moreButton->setProperty("useButtonPalette", true); m_moreButton->setProperty("useButtonPalette", true);
@ -66,7 +66,7 @@ VpnItem::VpnItem(bool bAcitve, QWidget *parent)
mLanLyt->addWidget(titileLabel,Qt::AlignLeft); mLanLyt->addWidget(titileLabel,Qt::AlignLeft);
mLanLyt->addStretch(); mLanLyt->addStretch();
mLanLyt->addWidget(statusLabel); mLanLyt->addWidget(statusLabel);
// mLanLyt->addWidget(infoLabel); mLanLyt->addWidget(infoLabel);
mLanLyt->addWidget(m_moreButton); mLanLyt->addWidget(m_moreButton);
loadIcons.append(QIcon::fromTheme("ukui-loading-1-symbolic")); loadIcons.append(QIcon::fromTheme("ukui-loading-1-symbolic"));

View File

@ -42,7 +42,7 @@ public:
VpnItem(bool bAcitve, QWidget *parent = nullptr); VpnItem(bool bAcitve, QWidget *parent = nullptr);
public: public:
QLabel * iconLabel = nullptr; QLabel * iconLabel = nullptr;
// GrayInfoButton * infoLabel = nullptr; GrayInfoButton * infoLabel = nullptr;
FixLabel * titileLabel = nullptr; FixLabel * titileLabel = nullptr;
QLabel * statusLabel = nullptr; QLabel * statusLabel = nullptr;
QToolButton* m_moreButton = nullptr; QToolButton* m_moreButton = nullptr;

View File

@ -26,7 +26,6 @@
VpnListItem::VpnListItem(const KyConnectItem *lanConnectItem, QWidget *parent):ListItem(parent) VpnListItem::VpnListItem(const KyConnectItem *lanConnectItem, QWidget *parent):ListItem(parent)
{ {
m_infoButton->setVisible(false);
m_connectOperation = new KyWiredConnectOperation(this); m_connectOperation = new KyWiredConnectOperation(this);
m_deviceResource = new KyNetworkDeviceResourse(this); m_deviceResource = new KyNetworkDeviceResourse(this);
@ -182,40 +181,25 @@ void VpnListItem::onMenuTriggered(QAction *action)
return; 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() void VpnListItem::onInfoButtonClicked()
{ {
// if (m_vpnConnectItem.m_connectUuid.isEmpty()) { launchApp("nm-connection-editor.desktop");
// 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);
return; return;
} }

View File

@ -26,6 +26,10 @@
#include <QEvent> #include <QEvent>
#include <QAction> #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 class VpnListItem : public ListItem
{ {
Q_OBJECT Q_OBJECT
@ -50,6 +54,7 @@ public:
protected: protected:
void setIcon(bool isOn); void setIcon(bool isOn);
void onRightButtonClicked(); void onRightButtonClicked();
bool launchApp(QString desktopFile);
private: private:
void connectItemCopy(const KyConnectItem *lanConnectItem); void connectItemCopy(const KyConnectItem *lanConnectItem);
@ -61,6 +66,7 @@ private Q_SLOTS:
private: private:
KyConnectItem m_vpnConnectItem; KyConnectItem m_vpnConnectItem;
// QDBusInterface m_appManagerDbusInterface;
KyWiredConnectOperation *m_connectOperation = nullptr; KyWiredConnectOperation *m_connectOperation = nullptr;
KyNetworkDeviceResourse *m_deviceResource = nullptr; KyNetworkDeviceResourse *m_deviceResource = nullptr;

View File

@ -42,7 +42,7 @@ void SinglePage::initUI()
this->setLayout(m_mainLayout); this->setLayout(m_mainLayout);
m_netFrame = new QFrame(this); 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 = new QVBoxLayout(m_netFrame);
m_netLayout->setContentsMargins(NET_LAYOUT_MARGINS); m_netLayout->setContentsMargins(NET_LAYOUT_MARGINS);
m_netFrame->setLayout(m_netLayout); m_netFrame->setLayout(m_netLayout);
@ -79,7 +79,6 @@ void SinglePage::initUI()
m_mainLayout->addStretch(); m_mainLayout->addStretch();
m_mainLayout->addWidget(m_netDivider); m_mainLayout->addWidget(m_netDivider);
m_mainLayout->addWidget(m_settingsFrame); m_mainLayout->addWidget(m_settingsFrame);
} }
void SinglePage::showDesktopNotify(const QString &message, QString soundName) void SinglePage::showDesktopNotify(const QString &message, QString soundName)

View File

@ -44,10 +44,6 @@ using namespace kdk;
#define MAIN_LAYOUT_MARGINS 0,0,0,0 #define MAIN_LAYOUT_MARGINS 0,0,0,0
#define MAIN_LAYOUT_SPACING 0 #define MAIN_LAYOUT_SPACING 0
#define TITLE_FRAME_HEIGHT 50 //TabWidget的tab和widget有间隙和设计稿看起来一致就不能设为设计稿里的高度 #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_MARGINS 8,8,0,1
#define NET_LAYOUT_SPACING 8 #define NET_LAYOUT_SPACING 8
#define NET_LIST_SPACING 0 #define NET_LIST_SPACING 0
@ -57,7 +53,6 @@ using namespace kdk;
#define SETTINGS_LAYOUT_MARGINS 23,0,24,0 #define SETTINGS_LAYOUT_MARGINS 23,0,24,0
#define TRANSPARENT_COLOR QColor(0,0,0,0) #define TRANSPARENT_COLOR QColor(0,0,0,0)
#define INACTIVE_AREA_MIN_HEIGHT 170 #define INACTIVE_AREA_MIN_HEIGHT 170
#define ACTIVE_AREA_MAX_HEIGHT 92
#define MAX_ITEMS 4 #define MAX_ITEMS 4
#define MAX_WIDTH 412 #define MAX_WIDTH 412

View File

@ -22,14 +22,7 @@
#include <QDebug> #include <QDebug>
#include <QScrollBar> #include <QScrollBar>
#define MAIN_LAYOUT_MARGINS 0,0,0,0 #define VPN_LIST_SPACING 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 ITEM_HEIGHT 48
@ -49,7 +42,7 @@ VpnPage::VpnPage(QWidget *parent) : SinglePage(parent)
initUI(); initUI();
initVpnArea(); 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) { connect(m_activeResourse, &KyActiveConnectResourse::activeConnectRemove, this, [=] (QString activeConnectUuid) {
sendVpnStateChangeSignal(activeConnectUuid,Deactivated); sendVpnStateChangeSignal(activeConnectUuid,Deactivated);
} ); } );
@ -115,6 +108,7 @@ void VpnPage::constructActiveConnectionArea()
{ {
QList<KyConnectItem *> activedList; QList<KyConnectItem *> activedList;
QList<KyConnectItem *> netList; QList<KyConnectItem *> netList;
QGSettings vpnGsettings(GSETTINGS_VPNICON_VISIBLE);
activedList.clear(); activedList.clear();
netList.clear(); netList.clear();
@ -136,7 +130,6 @@ void VpnPage::constructActiveConnectionArea()
if (m_activeConnectionMap.contains(p_netConnectionItem->m_connectUuid)) { if (m_activeConnectionMap.contains(p_netConnectionItem->m_connectUuid)) {
qDebug()<<LOG_FLAG << "has contain uuid" << 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); QListWidgetItem *p_listWidgetItem = addNewItem(p_newItem, m_vpnListWidget);
m_activeConnectionMap.insert(p_netConnectionItem->m_connectUuid, p_listWidgetItem); m_activeConnectionMap.insert(p_netConnectionItem->m_connectUuid, p_listWidgetItem);
} }
@ -144,21 +137,29 @@ void VpnPage::constructActiveConnectionArea()
delete p_netConnectionItem; delete p_netConnectionItem;
p_netConnectionItem = nullptr; 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) { if (m_vpnListWidget->count() <= MAX_ITEMS) {
m_vpnListWidget->setFixedWidth(MIN_WIDTH); m_vpnListWidget->setFixedWidth(MIN_WIDTH);
m_netListArea->setFixedHeight(m_vpnListWidget->count() * ITEM_HEIGHT);
} else { } else {
m_vpnListWidget->setFixedWidth(MAX_WIDTH); m_vpnListWidget->setFixedWidth(MAX_WIDTH);
m_netListArea->setFixedHeight(MAX_ITEMS * ITEM_HEIGHT);
} }
return; m_netFrame->setFixedHeight(37 + m_netListArea->height());
} }
void VpnPage::initVpnArea() void VpnPage::initVpnArea()
{ {
m_netFrame->show(); m_netFrame->show();
constructActiveConnectionArea(); constructActiveConnectionArea();
return;
} }
bool VpnPage::removeConnectionItem(QMap<QString, QListWidgetItem *> &connectMap, bool VpnPage::removeConnectionItem(QMap<QString, QListWidgetItem *> &connectMap,
@ -182,6 +183,7 @@ bool VpnPage::removeConnectionItem(QMap<QString, QListWidgetItem *> &connectMap,
iter = connectMap.erase(iter); iter = connectMap.erase(iter);
if (m_vpnListWidget->count() <= MAX_ITEMS) { if (m_vpnListWidget->count() <= MAX_ITEMS) {
m_vpnListWidget->setFixedWidth(MIN_WIDTH); m_vpnListWidget->setFixedWidth(MIN_WIDTH);
m_netListArea->setFixedHeight(m_vpnListWidget->count() * ITEM_HEIGHT);
} }
return true; return true;
} }
@ -197,6 +199,7 @@ void VpnPage::onRemoveConnection(QString path) //删除时后端会
Q_EMIT vpnRemove(path); Q_EMIT vpnRemove(path);
if (removeConnectionItem(m_netConnectionMap, m_vpnListWidget, path)) { if (removeConnectionItem(m_netConnectionMap, m_vpnListWidget, path)) {
m_netFrame->setFixedHeight(37 + m_netListArea->height());
return; return;
} }
} }
@ -224,9 +227,13 @@ void VpnPage::onAddConnection(QString uuid) //新增一个有线
delete p_newItem; delete p_newItem;
p_newItem = nullptr; p_newItem = nullptr;
if (m_vpnListWidget->count() > MAX_ITEMS) { if (m_vpnListWidget->count() >= MAX_ITEMS) {
m_vpnListWidget->setFixedWidth(MAX_WIDTH); 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; return;
} }
@ -241,13 +248,14 @@ void VpnPage::initUI()
m_netLabel->setText(tr("VPN Connection")); m_netLabel->setText(tr("VPN Connection"));
m_vpnListWidget = new QListWidget(m_netListArea); m_vpnListWidget = new QListWidget(m_netListArea);
m_vpnListWidget->setFrameShape(QFrame::Shape::NoFrame); 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->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
m_vpnListWidget->setVerticalScrollMode(QAbstractItemView::ScrollMode::ScrollPerPixel); m_vpnListWidget->setVerticalScrollMode(QAbstractItemView::ScrollMode::ScrollPerPixel);
m_vpnListWidget->verticalScrollBar()->setProperty("drawScrollBarGroove",false); //去除滚动条的外侧黑框 m_vpnListWidget->verticalScrollBar()->setProperty("drawScrollBarGroove",false); //去除滚动条的外侧黑框
m_vpnListWidget->verticalScrollBar()->setSingleStep(SCROLL_STEP); m_vpnListWidget->verticalScrollBar()->setSingleStep(SCROLL_STEP);
m_vpnListWidget->verticalScrollBar()->setContextMenuPolicy(Qt::NoContextMenu); m_vpnListWidget->verticalScrollBar()->setContextMenuPolicy(Qt::NoContextMenu);
m_netAreaLayout->addWidget(m_vpnListWidget); m_netAreaLayout->addWidget(m_vpnListWidget);
m_netListArea->setFixedHeight(0);
QPalette pal = m_vpnListWidget->palette(); QPalette pal = m_vpnListWidget->palette();
pal.setBrush(QPalette::Base, QColor(0,0,0,0)); //背景透明 pal.setBrush(QPalette::Base, QColor(0,0,0,0)); //背景透明
@ -337,8 +345,6 @@ void VpnPage::updateConnectionArea(KyConnectItem *p_newItem)
} else { } else {
m_vpnListWidget->setFixedWidth(MAX_WIDTH); m_vpnListWidget->setFixedWidth(MAX_WIDTH);
} }
return;
} }
void VpnPage::updateConnectionState(QMap<QString, QListWidgetItem *> &connectMap, void VpnPage::updateConnectionState(QMap<QString, QListWidgetItem *> &connectMap,
@ -352,12 +358,11 @@ void VpnPage::updateConnectionState(QMap<QString, QListWidgetItem *> &connectMap
p_lanItem->updateConnectionState(state); p_lanItem->updateConnectionState(state);
} }
return;
} }
void VpnPage::onConnectionStateChange(QString uuid, void VpnPage::onConnectionStateChange(QString uuid,
NetworkManager::VpnConnection::State state, NetworkManager::ActiveConnection::State state,
NetworkManager::VpnConnection::StateChangeReason reason) NetworkManager::ActiveConnection::Reason reason)
{ {
//VpnPage函数内持续监听连接状态的变化并记录供其他函数调用获取状态 //VpnPage函数内持续监听连接状态的变化并记录供其他函数调用获取状态
if (!m_connectResourse->isVirtualConncection(uuid)) { if (!m_connectResourse->isVirtualConncection(uuid)) {
@ -416,7 +421,6 @@ void VpnPage::onConnectionStateChange(QString uuid,
return; return;
} }
void VpnPage::getVirtualList(QVector<QStringList> &vector) void VpnPage::getVirtualList(QVector<QStringList> &vector)
{ {
QList<KyConnectItem *> netConnectList; QList<KyConnectItem *> netConnectList;
@ -424,10 +428,17 @@ void VpnPage::getVirtualList(QVector<QStringList> &vector)
m_connectResourse->getVpnAndVirtualConnections(netConnectList); //未激活列表的显示 m_connectResourse->getVpnAndVirtualConnections(netConnectList); //未激活列表的显示
if (!netConnectList.isEmpty()) { if (!netConnectList.isEmpty()) {
for (int i = 0; i < netConnectList.size(); i++) { 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 vector.append(QStringList() << netConnectList.at(i)->m_connectName
<< netConnectList.at(i)->m_connectUuid << netConnectList.at(i)->m_connectUuid
<< netConnectList.at(i)->m_connectPath << netConnectList.at(i)->m_connectPath
<< QString::number(netConnectList.at(i)->m_connectState)); << QString::number(state));
} }
} }
return; return;
@ -445,10 +456,16 @@ void VpnPage::sendVpnUpdateSignal(KyConnectItem *p_connectItem)
void VpnPage::sendVpnAddSignal(KyConnectItem *p_connectItem) void VpnPage::sendVpnAddSignal(KyConnectItem *p_connectItem)
{ {
QStringList info; 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 info << p_connectItem->m_connectName
<< p_connectItem->m_connectUuid << p_connectItem->m_connectUuid
<< p_connectItem->m_connectPath << p_connectItem->m_connectPath
<< QString::number(p_connectItem->m_connectState); << QString::number(state);
qDebug() << "[VpnPage] emit vpnAdd because addConnection "; qDebug() << "[VpnPage] emit vpnAdd because addConnection ";
Q_EMIT vpnAdd(info); Q_EMIT vpnAdd(info);
@ -521,7 +538,7 @@ void VpnPage::updateActiveConnectionProperty(KyConnectItem *p_connectItem)
void VpnPage::onUpdateConnection(QString uuid) void VpnPage::onUpdateConnection(QString uuid)
{ {
if (!m_connectResourse->isWiredConnection(uuid)) { if (!m_connectResourse->isVirtualConncection(uuid)) {
return; return;
} }

View File

@ -35,6 +35,9 @@
#define VPNPAGE_LAYOUT_MARGINS 0,0,0,0 #define VPNPAGE_LAYOUT_MARGINS 0,0,0,0
#define VISIBLE "visible"
const QByteArray GSETTINGS_VPNICON_VISIBLE = "org.ukui.kylin-nm.vpnicon";
class VpnListItem; class VpnListItem;
class VpnPage : public SinglePage class VpnPage : public SinglePage
@ -65,7 +68,6 @@ private:
bool removeConnectionItem(QMap<QString, QListWidgetItem *> &connectMap, bool removeConnectionItem(QMap<QString, QListWidgetItem *> &connectMap,
QListWidget *lanListWidget, QString path); QListWidget *lanListWidget, QString path);
void constructConnectionArea();
void constructActiveConnectionArea(); void constructActiveConnectionArea();
void updateConnectionArea(KyConnectItem *p_newItem); void updateConnectionArea(KyConnectItem *p_newItem);
@ -95,8 +97,8 @@ Q_SIGNALS:
private Q_SLOTS: private Q_SLOTS:
void onConnectionStateChange(QString uuid, void onConnectionStateChange(QString uuid,
NetworkManager::VpnConnection::State state, NetworkManager::ActiveConnection::State state,
NetworkManager::VpnConnection::StateChangeReason reason); NetworkManager::ActiveConnection::Reason reason);
void onAddConnection(QString uuid); void onAddConnection(QString uuid);
void onRemoveConnection(QString path); void onRemoveConnection(QString path);

View File

@ -73,23 +73,10 @@ void vpnMainWindow::showMainwindow()
KWindowSystem::setState(this->winId(), NET::SkipTaskbar | NET::SkipPager); KWindowSystem::setState(this->winId(), NET::SkipTaskbar | NET::SkipPager);
} }
} }
this->showByWaylandHelper(); this->showByWaylandHelper();
this->raise(); this->raise();
this->activateWindow(); this->activateWindow();
Q_EMIT this->mainWindowVisibleChanged(true); // 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
} }
/** /**
@ -98,7 +85,7 @@ void vpnMainWindow::showMainwindow()
void vpnMainWindow::hideMainwindow() void vpnMainWindow::hideMainwindow()
{ {
this->hide(); 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::vpnRemove, this, &vpnMainWindow::vpnRemove);
connect(m_vpnPage, &VpnPage::vpnUpdate, this, &vpnMainWindow::vpnUpdate); connect(m_vpnPage, &VpnPage::vpnUpdate, this, &vpnMainWindow::vpnUpdate);
connect(m_vpnPage, &VpnPage::vpnActiveConnectionStateChanged, this, &vpnMainWindow::vpnActiveConnectionStateChanged); connect(m_vpnPage, &VpnPage::vpnActiveConnectionStateChanged, this, &vpnMainWindow::vpnActiveConnectionStateChanged);
//模式切换 //模式切换
QDBusConnection::sessionBus().connect(QString("com.kylin.statusmanager.interface"), QDBusConnection::sessionBus().connect(QString("com.kylin.statusmanager.interface"),
QString("/"), QString("/"),
@ -499,7 +485,7 @@ void vpnMainWindow::initVpnIconVisible()
{ {
if(QGSettings::isSchemaInstalled(GSETTINGS_VPNICON_VISIBLE)) { if(QGSettings::isSchemaInstalled(GSETTINGS_VPNICON_VISIBLE)) {
m_vpnGsettings = new QGSettings(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); connect(m_vpnGsettings, &QGSettings::changed, this, &vpnMainWindow::onVpnIconVisibleChanged);
m_vpnTrayIcon->setVisible(m_vpnGsettings->get("visible").toBool()); m_vpnTrayIcon->setVisible(m_vpnGsettings->get("visible").toBool());
} }

View File

@ -33,8 +33,6 @@
#include "vpnpage.h" #include "vpnpage.h"
#include "mainwindow.h" #include "mainwindow.h"
const QByteArray GSETTINGS_VPNICON_VISIBLE = "org.ukui.kylin-nm.vpnicon";
class VpnPage; class VpnPage;
class vpnMainWindow : public QMainWindow class vpnMainWindow : public QMainWindow