Merge branch 'yhkylin/v101-tablet-new' into 'yhkylin/v101-tablet'
解决VPN崩溃问题和部分BUG,删除部分多余代码 See merge request kylinos-src/kylin-nm!28
This commit is contained in:
commit
09b1335ba2
|
@ -1,3 +1,18 @@
|
||||||
|
kylin-nm (3.20.1.6-ok9) v101; urgency=medium
|
||||||
|
|
||||||
|
* BUG号:
|
||||||
|
- #145719 【VPN】在任务栏虚拟连接界面点击连接VPN,任务栏网络图标消失后重新显示,概率性不恢复显示
|
||||||
|
- #145710 【VPN】没有添加虚拟连接,任务栏仍显示虚拟连接图标
|
||||||
|
- #145491 【设计】【网络】网络属性界面显示不全
|
||||||
|
- #145699 【平板】【网络连接】编辑网络连接时,添加DNS后点击“+”,会清空当前输入,而不是在下方增加DNS
|
||||||
|
- #144990 【控制面板】【无线网络】打开设置网络子窗口并关闭后控制面板主窗口被最小化
|
||||||
|
- #145707 【平板】【网络连接】打开网络高级设置界面,新建一个有线连接并保存,无法再次打开高级设置界面
|
||||||
|
- #146541 【平板】【网络连接】平板模式下点击侧边栏网络图标,网络连接界面显示在屏幕中央
|
||||||
|
- #145681 【平板】【VPN】未实现控制面板VPN界面功能
|
||||||
|
- #145687 【VPN】任务栏虚拟连接界面不显示详情按钮
|
||||||
|
|
||||||
|
-- chenxuechao <chenxuechao@kylinos.cn> Wed, 02 Nov 2022 17:57:45 +0800
|
||||||
|
|
||||||
kylin-nm (3.20.1.6-ok8) v101; urgency=medium
|
kylin-nm (3.20.1.6-ok8) v101; urgency=medium
|
||||||
|
|
||||||
* BUG号:
|
* BUG号:
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -20,7 +20,6 @@
|
||||||
#include "addnetbtn.h"
|
#include "addnetbtn.h"
|
||||||
#include <QEvent>
|
#include <QEvent>
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QLabel>
|
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QPainterPath>
|
#include <QPainterPath>
|
||||||
|
@ -39,10 +38,10 @@ AddNetBtn::AddNetBtn(bool isWlan, QWidget *parent) : QPushButton(parent)
|
||||||
color.setAlphaF(0.5);
|
color.setAlphaF(0.5);
|
||||||
pal.setColor(QPalette::Button, color);
|
pal.setColor(QPalette::Button, color);
|
||||||
this->setPalette(pal);
|
this->setPalette(pal);
|
||||||
QHBoxLayout *addLyt = new QHBoxLayout;
|
QHBoxLayout *addLyt = new QHBoxLayout(this);
|
||||||
|
|
||||||
QLabel *iconLabel = new QLabel();
|
QLabel *iconLabel = new QLabel(this);
|
||||||
QLabel *textLabel = new QLabel();
|
textLabel = new QLabel(this);
|
||||||
|
|
||||||
if (isWlan) {
|
if (isWlan) {
|
||||||
textLabel->setText(tr("Add Others"));
|
textLabel->setText(tr("Add Others"));
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QTranslator>
|
#include <QTranslator>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
#include <QLabel>
|
||||||
|
|
||||||
class AddNetBtn : public QPushButton
|
class AddNetBtn : public QPushButton
|
||||||
{
|
{
|
||||||
|
@ -33,11 +34,18 @@ public:
|
||||||
AddNetBtn(bool isWlan, QWidget *parent = nullptr);
|
AddNetBtn(bool isWlan, QWidget *parent = nullptr);
|
||||||
~AddNetBtn();
|
~AddNetBtn();
|
||||||
|
|
||||||
|
void setTextLabel(QString str) {
|
||||||
|
textLabel->setText(str);
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void leaveEvent(QEvent * event);
|
virtual void leaveEvent(QEvent * event);
|
||||||
virtual void enterEvent(QEvent * event);
|
virtual void enterEvent(QEvent * event);
|
||||||
void paintEvent(QPaintEvent *event);
|
void paintEvent(QPaintEvent *event);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QLabel* textLabel;
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void enterWidget();
|
void enterWidget();
|
||||||
void leaveWidget();
|
void leaveWidget();
|
||||||
|
|
|
@ -3,4 +3,5 @@ SUBDIRS = \
|
||||||
netconnect \
|
netconnect \
|
||||||
wlanconnect \
|
wlanconnect \
|
||||||
mobilehotspot \
|
mobilehotspot \
|
||||||
proxy
|
proxy \
|
||||||
|
vpn
|
||||||
|
|
|
@ -0,0 +1,63 @@
|
||||||
|
/* -*- 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 "itemframe.h"
|
||||||
|
#include <QPainter>
|
||||||
|
|
||||||
|
#define LAYOUT_MARGINS 0,0,0,0
|
||||||
|
#define MAIN_LAYOUT_MARGINS 0,0,0,0
|
||||||
|
ItemFrame::ItemFrame(QWidget *parent)
|
||||||
|
:QFrame(parent)
|
||||||
|
{
|
||||||
|
deviceLanLayout = new QVBoxLayout(this);
|
||||||
|
deviceLanLayout->setContentsMargins(MAIN_LAYOUT_MARGINS);
|
||||||
|
lanItemFrame = new QFrame(this);
|
||||||
|
lanItemFrame->setFrameShape(QFrame::Shape::NoFrame);
|
||||||
|
lanItemFrame->setContentsMargins(LAYOUT_MARGINS);
|
||||||
|
|
||||||
|
lanItemLayout = new QVBoxLayout(this);
|
||||||
|
lanItemLayout->setContentsMargins(LAYOUT_MARGINS);
|
||||||
|
lanItemLayout->setSpacing(1);
|
||||||
|
addWlanWidget = new AddNetBtn(false, this);
|
||||||
|
addWlanWidget->setTextLabel(tr("Add Vpn"));
|
||||||
|
|
||||||
|
deviceLanLayout->setSpacing(1);
|
||||||
|
setLayout(deviceLanLayout);
|
||||||
|
lanItemFrame->setLayout(lanItemLayout);
|
||||||
|
|
||||||
|
deviceLanLayout->addWidget(lanItemFrame);
|
||||||
|
deviceLanLayout->addWidget(addWlanWidget);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ItemFrame::filletStyleChange()
|
||||||
|
{
|
||||||
|
if (lanItemLayout->isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < lanItemLayout->count(); ++i) {
|
||||||
|
QLayoutItem *it = lanItemLayout->itemAt(i);
|
||||||
|
VpnItem *itemFrame = (VpnItem*)(it->widget());
|
||||||
|
if (i != lanItemLayout->count()-1) {
|
||||||
|
itemFrame->setHalfFillet(false);
|
||||||
|
} else {
|
||||||
|
itemFrame->setHalfFillet(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,47 @@
|
||||||
|
/* -*- 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 ITEMFRAME_H
|
||||||
|
#define ITEMFRAME_H
|
||||||
|
#include <QFrame>
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
#include "../component/AddBtn/addnetbtn.h"
|
||||||
|
#include "vpnitem.h"
|
||||||
|
|
||||||
|
class ItemFrame : public QFrame
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
ItemFrame(QWidget *parent = nullptr);
|
||||||
|
//单设备整体layout
|
||||||
|
QVBoxLayout * deviceLanLayout = nullptr;
|
||||||
|
//单设备列表Frame
|
||||||
|
QFrame * lanItemFrame = nullptr;
|
||||||
|
//单设备列表layout
|
||||||
|
QVBoxLayout * lanItemLayout = nullptr;
|
||||||
|
//item列表
|
||||||
|
QMap<QString, VpnItem *> itemMap;
|
||||||
|
// //已激活uuid
|
||||||
|
// QString uuid = "";
|
||||||
|
//新建无线连接
|
||||||
|
AddNetBtn * addWlanWidget = nullptr;
|
||||||
|
void filletStyleChange();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // ITEMFRAME_H
|
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>
|
|
@ -0,0 +1,497 @@
|
||||||
|
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||||
|
*
|
||||||
|
* Copyright (C) 2019 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 "vpn.h"
|
||||||
|
#include "ui_vpn.h"
|
||||||
|
|
||||||
|
#include <QProcess>
|
||||||
|
#include <QMouseEvent>
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QtDBus>
|
||||||
|
#include <QDBusArgument>
|
||||||
|
|
||||||
|
#define ACTIVATING 1
|
||||||
|
#define ACTIVATED 2
|
||||||
|
#define DEACTIVATING 3
|
||||||
|
#define DEACTIVATED 4
|
||||||
|
|
||||||
|
#define LABEL_RECT 17, 0, 105, 23
|
||||||
|
#define CONTENTS_MARGINS 0, 0, 0, 0
|
||||||
|
#define ITEM_MARGINS 16, 0, 16, 0
|
||||||
|
#define FRAME_MIN_SIZE 550, 60
|
||||||
|
#define FRAME_MAX_SIZE 16777215, 16777215
|
||||||
|
#define CONTECT_FRAME_MAX_SIZE 16777215, 60
|
||||||
|
#define HINT_TEXT_MARGINS 8, 0, 0, 0
|
||||||
|
#define FRAME_MIN_SIZE 550, 60
|
||||||
|
#define LABLE_MIN_WIDTH 188
|
||||||
|
#define COMBOBOX_MIN_WIDTH 200
|
||||||
|
#define LINE_MAX_SIZE 16777215, 1
|
||||||
|
#define LINE_MIN_SIZE 0, 1
|
||||||
|
#define ICON_SIZE 24,24
|
||||||
|
#define PASSWORD_FRAME_MIN_HIGHT 60
|
||||||
|
#define PASSWORD_FRAME_FIX_HIGHT 80
|
||||||
|
#define PASSWORD_FRAME_MIN_SIZE 550, 60
|
||||||
|
#define PASSWORD_FRAME_MAX_SIZE 16777215, 86
|
||||||
|
#define PASSWORD_ITEM_MARGINS 16, 12, 16, 14
|
||||||
|
|
||||||
|
#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;
|
||||||
|
}
|
||||||
|
|
||||||
|
Vpn::~Vpn()
|
||||||
|
{
|
||||||
|
if (!mFirstLoad) {
|
||||||
|
delete ui;
|
||||||
|
ui = nullptr;
|
||||||
|
delete m_interface;
|
||||||
|
delete m_switchGsettings;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QString Vpn::plugini18nName(){
|
||||||
|
return pluginName;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Vpn::pluginTypes(){
|
||||||
|
return pluginType;
|
||||||
|
}
|
||||||
|
|
||||||
|
QWidget *Vpn::pluginUi(){
|
||||||
|
if (mFirstLoad) {
|
||||||
|
mFirstLoad = false;
|
||||||
|
ui = new Ui::Vpn;
|
||||||
|
pluginWidget = new QWidget;
|
||||||
|
pluginWidget->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
ui->setupUi(pluginWidget);
|
||||||
|
|
||||||
|
qDBusRegisterMetaType<QVector<QStringList>>();
|
||||||
|
m_interface = new QDBusInterface("com.kylin.network",
|
||||||
|
"/com/kylin/vpnTool",
|
||||||
|
"com.kylin.vpnTool",
|
||||||
|
QDBusConnection::sessionBus());
|
||||||
|
if(!m_interface->isValid()) {
|
||||||
|
qWarning() << qPrintable(QDBusConnection::sessionBus().lastError().message());
|
||||||
|
}
|
||||||
|
|
||||||
|
initComponent();
|
||||||
|
initConnect();
|
||||||
|
initNet();
|
||||||
|
}
|
||||||
|
return pluginWidget;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString Vpn::name() const {
|
||||||
|
|
||||||
|
return QStringLiteral("Vpn");
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Vpn::isShowOnHomePage() const
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
QIcon Vpn::icon() const
|
||||||
|
{
|
||||||
|
return QIcon::fromTheme("ukui-vpn-symbolic");
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Vpn::isEnable() const
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Vpn::initComponent(){
|
||||||
|
//在任务栏上显示图标
|
||||||
|
//显示已连接时间
|
||||||
|
m_topFrame = new QFrame(pluginWidget);
|
||||||
|
m_topFrame->setMinimumSize(FRAME_MIN_SIZE);
|
||||||
|
m_topFrame->setMaximumSize(FRAME_MAX_SIZE);
|
||||||
|
m_topFrame->setFrameShape(QFrame::Box);
|
||||||
|
|
||||||
|
QVBoxLayout *hotspotLyt = new QVBoxLayout(pluginWidget);
|
||||||
|
hotspotLyt->setContentsMargins(0, 0, 0, 0);
|
||||||
|
m_topFrame->setLayout(hotspotLyt);
|
||||||
|
|
||||||
|
m_showFrame = new QFrame(m_topFrame);
|
||||||
|
m_showFrame->setFrameShape(QFrame::Shape::NoFrame);
|
||||||
|
m_showFrame->setMinimumSize(FRAME_MIN_SIZE);
|
||||||
|
m_showFrame->setMaximumSize(CONTECT_FRAME_MAX_SIZE);
|
||||||
|
QHBoxLayout *showLayout = new QHBoxLayout(m_showFrame);
|
||||||
|
m_showLabel = new QLabel(tr("Show on Taskbar"), m_showFrame);
|
||||||
|
m_showLabel->setMinimumWidth(LABLE_MIN_WIDTH);
|
||||||
|
m_showBtn = new KSwitchButton(m_showFrame);
|
||||||
|
showLayout->setContentsMargins(ITEM_MARGINS);
|
||||||
|
showLayout->addWidget(m_showLabel);
|
||||||
|
showLayout->addStretch();
|
||||||
|
showLayout->addWidget(m_showBtn);
|
||||||
|
|
||||||
|
m_showFrame->setLayout(showLayout);
|
||||||
|
|
||||||
|
// m_Line = myLine();
|
||||||
|
|
||||||
|
// m_timeFrame = new QFrame(m_topFrame);
|
||||||
|
// m_timeFrame->setFrameShape(QFrame::Shape::NoFrame);
|
||||||
|
// m_timeFrame->setMinimumSize(FRAME_MIN_SIZE);
|
||||||
|
// m_timeFrame->setMaximumSize(CONTECT_FRAME_MAX_SIZE);
|
||||||
|
// QHBoxLayout *timeLayout = new QHBoxLayout(m_timeFrame);
|
||||||
|
// m_timeLabel = new QLabel(tr("Open"), m_timeFrame);
|
||||||
|
// m_timeLabel->setMinimumWidth(LABLE_MIN_WIDTH);
|
||||||
|
// m_timeBtn = new KSwitchButton(m_timeFrame);
|
||||||
|
// timeLayout->setContentsMargins(ITEM_MARGINS);
|
||||||
|
// timeLayout->addWidget(m_timeLabel);
|
||||||
|
// timeLayout->addStretch();
|
||||||
|
// timeLayout->addWidget(m_timeBtn);
|
||||||
|
|
||||||
|
// m_timeFrame->setLayout(timeLayout);
|
||||||
|
|
||||||
|
hotspotLyt->addWidget(m_showFrame);
|
||||||
|
// hotspotLyt->addWidget(m_Line);
|
||||||
|
// hotspotLyt->addWidget(m_timeFrame);
|
||||||
|
hotspotLyt->setSpacing(0);
|
||||||
|
|
||||||
|
//列表
|
||||||
|
m_listFrame = new ItemFrame(pluginWidget);
|
||||||
|
|
||||||
|
ui->verticalLayout_4->addWidget(m_topFrame);
|
||||||
|
ui->verticalLayout_3->addWidget(m_listFrame);
|
||||||
|
|
||||||
|
connect(m_listFrame->addWlanWidget, &AddNetBtn::clicked, this, [=]() {
|
||||||
|
runExternalApp();
|
||||||
|
});
|
||||||
|
|
||||||
|
if (QGSettings::isSchemaInstalled(GSETTINGS_SCHEMA)) {
|
||||||
|
m_switchGsettings = new QGSettings(GSETTINGS_SCHEMA);
|
||||||
|
setShowSwitchStatus();
|
||||||
|
|
||||||
|
connect(m_switchGsettings, &QGSettings::changed, this, [=] (const QString &key) {
|
||||||
|
if (key == VISIBLE) {
|
||||||
|
setShowSwitchStatus();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
m_showBtn->setChecked(false);
|
||||||
|
m_showBtn->setCheckable(false);
|
||||||
|
qDebug()<<"[Vpn] org.ukui.kylin-nm.visible is not installed!";
|
||||||
|
}
|
||||||
|
|
||||||
|
connect(m_showBtn, &KSwitchButton::stateChanged, this, [=](bool state){
|
||||||
|
if (m_switchGsettings != nullptr) {
|
||||||
|
m_switchGsettings->set(VISIBLE, state);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// connect(m_timeBtn, &KSwitchButton::stateChanged, this, [=](bool state){
|
||||||
|
// if (m_switchGsettings != nullptr) {
|
||||||
|
// m_switchGsettings->set(VISIBLE, state);
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
ui->pushButton->hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Vpn::initConnect()
|
||||||
|
{
|
||||||
|
connect(m_interface, SIGNAL(vpnAdd(QStringList)), this, SLOT(onVpnAdd(QStringList)));
|
||||||
|
connect(m_interface, SIGNAL(vpnRemove(QString)), this, SLOT(onVpnRemove(QString)));
|
||||||
|
connect(m_interface, SIGNAL(vpnUpdate(QStringList)), this, SLOT(onVpnUpdate(QStringList)));
|
||||||
|
connect(m_interface, SIGNAL(vpnActiveConnectionStateChanged(QString, int)),
|
||||||
|
this, SLOT(onVpnActiveConnectionStateChanged(QString, int)));
|
||||||
|
}
|
||||||
|
|
||||||
|
//初始化列表
|
||||||
|
void Vpn::initNet()
|
||||||
|
{
|
||||||
|
qDebug() << "[Vpn]initNet";
|
||||||
|
if (!m_interface->isValid()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
QDBusMessage result = m_interface->call(QStringLiteral("getVirtualList"));
|
||||||
|
if(result.type() == QDBusMessage::ErrorMessage)
|
||||||
|
{
|
||||||
|
qWarning() << "getVirtualList error:" << result.errorMessage();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
auto dbusArg = result.arguments().at(0).value<QDBusArgument>();
|
||||||
|
QVector<QStringList> variantList;
|
||||||
|
dbusArg >> variantList;
|
||||||
|
if (variantList.size() == 0) {
|
||||||
|
qDebug() << "[Vpn]initNet list empty";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < variantList.size(); ++i) {
|
||||||
|
QStringList vpnInfo = variantList.at(i);
|
||||||
|
addOneVirtualItem(vpnInfo);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Vpn::setShowSwitchStatus()
|
||||||
|
{
|
||||||
|
if (QGSettings::isSchemaInstalled(GSETTINGS_SCHEMA)) {
|
||||||
|
bool status = m_switchGsettings->get(VISIBLE).toBool();
|
||||||
|
m_showBtn->setChecked(status);
|
||||||
|
} else {
|
||||||
|
qDebug()<<"[Vpn] org.ukui.kylin-nm.switch is not installed!";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Vpn::runExternalApp(){
|
||||||
|
QString cmd = "nm-connection-editor";
|
||||||
|
QProcess process(this);
|
||||||
|
process.startDetached(cmd);
|
||||||
|
}
|
||||||
|
|
||||||
|
QFrame* Vpn::myLine()
|
||||||
|
{
|
||||||
|
QFrame *line = new QFrame(pluginWidget);
|
||||||
|
line->setMinimumSize(QSize(LINE_MIN_SIZE));
|
||||||
|
line->setMaximumSize(QSize(LINE_MAX_SIZE));
|
||||||
|
line->setLineWidth(0);
|
||||||
|
line->setFrameShape(QFrame::HLine);
|
||||||
|
line->setFrameShadow(QFrame::Sunken);
|
||||||
|
|
||||||
|
return line;
|
||||||
|
}
|
||||||
|
|
||||||
|
//刪除
|
||||||
|
void Vpn::deleteVpn(QString uuid)
|
||||||
|
{
|
||||||
|
m_interface->call(QStringLiteral("deleteVpn"), uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
//激活
|
||||||
|
void Vpn::activeConnect(QString uuid) {
|
||||||
|
m_interface->call(QStringLiteral("activateVpn"), uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
//断开
|
||||||
|
void Vpn::deActiveConnect(QString uuid) {
|
||||||
|
m_interface->call(QStringLiteral("deactivateVpn"), uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//增加一项
|
||||||
|
void Vpn::addOneVirtualItem(QStringList infoList)
|
||||||
|
{
|
||||||
|
if (m_listFrame->itemMap.contains(infoList.at(1))) {
|
||||||
|
qDebug() << "[Vpn]Already exist a virtual " << infoList.at(1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
qDebug() << "[Vpn]addOneVitualItem" << infoList.at(0) << infoList.at(3) ;
|
||||||
|
QString connName = infoList.at(0);
|
||||||
|
QString connUuid = infoList.at(1);
|
||||||
|
QString connDbusPath = infoList.at(2);
|
||||||
|
int status = infoList.at(3).toInt(); //1-连接中 2-已连接 3-断开中 4-已断开
|
||||||
|
VpnItem * item = new VpnItem(pluginWidget);
|
||||||
|
|
||||||
|
QIcon searchIcon = QIcon::fromTheme(KVpnSymbolic);
|
||||||
|
item->iconLabel->setPixmap(searchIcon.pixmap(searchIcon.actualSize(QSize(ICON_SIZE))));
|
||||||
|
item->titileLabel->setText(connName);
|
||||||
|
|
||||||
|
item->uuid = connUuid;
|
||||||
|
item->dbusPath = connDbusPath;
|
||||||
|
|
||||||
|
if (status == 1 || status == 3) {
|
||||||
|
item->startLoading();
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
} else {
|
||||||
|
activeConnect(item->uuid);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
connect(item, &VpnItem::connectActionTriggered, this, [=] {
|
||||||
|
activeConnect(item->uuid);
|
||||||
|
});
|
||||||
|
connect(item, &VpnItem::disconnectActionTriggered, this, [=] {
|
||||||
|
deActiveConnect(item->uuid);
|
||||||
|
});
|
||||||
|
connect(item, &VpnItem::deleteActionTriggered, this, [=] {
|
||||||
|
deleteVpn(item->uuid);
|
||||||
|
});
|
||||||
|
|
||||||
|
//记录到deviceFrame的itemMap中
|
||||||
|
m_listFrame->itemMap.insert(connUuid, item);
|
||||||
|
int index = getInsertPos(connName);
|
||||||
|
qDebug()<<"[Vpn]addOneVirtualItem " << connName << " at pos:" << index;
|
||||||
|
m_listFrame->lanItemLayout->insertWidget(index, item);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Vpn::removeOneVirtualItem(QString dbusPath)
|
||||||
|
{
|
||||||
|
qDebug()<<"[Vpn]vpn remove dbus path:" << dbusPath;
|
||||||
|
|
||||||
|
QMap<QString, VpnItem *>::iterator itemIter;
|
||||||
|
for (itemIter = m_listFrame->itemMap.begin(); itemIter != m_listFrame->itemMap.end(); itemIter++) {
|
||||||
|
if (itemIter.value()->dbusPath == dbusPath) {
|
||||||
|
qDebug()<<"[Vpn]vpn remove " << dbusPath << " find in " << itemIter.value()->titileLabel->text();
|
||||||
|
QString key = itemIter.key();
|
||||||
|
m_listFrame->lanItemLayout->removeWidget(itemIter.value());
|
||||||
|
delete itemIter.value();
|
||||||
|
m_listFrame->itemMap.remove(key);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//增加
|
||||||
|
void Vpn::onVpnAdd(QStringList infoList)
|
||||||
|
{
|
||||||
|
addOneVirtualItem(infoList);
|
||||||
|
}
|
||||||
|
|
||||||
|
//移出
|
||||||
|
void Vpn::onVpnRemove(QString uuid)
|
||||||
|
{
|
||||||
|
removeOneVirtualItem(uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
//名称变化
|
||||||
|
void Vpn::onVpnUpdate(QStringList info)
|
||||||
|
{
|
||||||
|
if (m_listFrame->itemMap.contains(info.at(1))) {
|
||||||
|
qDebug() << "[Vpn]" << m_listFrame->itemMap[info.at(1)]->titileLabel->text() << "change to" << info.at(0);
|
||||||
|
if (m_listFrame->itemMap[info.at(1)]->titileLabel->text() != info.at(0)) {
|
||||||
|
m_listFrame->itemMap[info.at(1)]->titileLabel->setText(info.at(0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Vpn::onVpnActiveConnectionStateChanged(QString uuid, int status)
|
||||||
|
{
|
||||||
|
if (uuid.isEmpty()) {
|
||||||
|
qDebug() << "[Vpn]onActiveConnectionChanged but uuid is empty";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
qDebug() << "[Vpn]onActiveConnectionChanged " << uuid << status;
|
||||||
|
VpnItem * item= nullptr;
|
||||||
|
|
||||||
|
if (m_listFrame->itemMap.contains(uuid)) {
|
||||||
|
item = m_listFrame->itemMap[uuid];
|
||||||
|
if (status == ACTIVATED) {
|
||||||
|
//为已连接则放到第一个
|
||||||
|
m_listFrame->lanItemLayout->removeWidget(item);
|
||||||
|
m_listFrame->lanItemLayout->insertWidget(0,item);
|
||||||
|
} else if (status == DEACTIVATED) {
|
||||||
|
//为断开则重新插入
|
||||||
|
int index = getInsertPos(item->titileLabel->text());
|
||||||
|
qDebug() << "[Vpn]reinsert" << item->titileLabel->text() << "pos" << index << "because status changes to deactive";
|
||||||
|
m_listFrame->lanItemLayout->removeWidget(item);
|
||||||
|
m_listFrame->lanItemLayout->insertWidget(index,item);
|
||||||
|
}
|
||||||
|
itemActiveConnectionStatusChanged(item, status);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Vpn::itemActiveConnectionStatusChanged(VpnItem *item, int status)
|
||||||
|
{
|
||||||
|
// QString iconPath = NoNetSymbolic;
|
||||||
|
if (status == ACTIVATING) {
|
||||||
|
item->startLoading();
|
||||||
|
} else if (status == ACTIVATED) {
|
||||||
|
item->stopLoading();
|
||||||
|
// iconPath = KLanSymbolic;
|
||||||
|
item->statusLabel->clear();
|
||||||
|
item->statusLabel->setMinimumSize(36,36);
|
||||||
|
item->statusLabel->setMaximumSize(16777215,16777215);
|
||||||
|
item->statusLabel->setText(tr("connected"));
|
||||||
|
item->isAcitve = true;
|
||||||
|
} else if (status == DEACTIVATING) {
|
||||||
|
item->startLoading();
|
||||||
|
} else {
|
||||||
|
item->stopLoading();
|
||||||
|
item->statusLabel->setMinimumSize(36,36);
|
||||||
|
item->statusLabel->setMaximumSize(16777215,16777215);
|
||||||
|
item->statusLabel->clear();
|
||||||
|
item->isAcitve = false;
|
||||||
|
item->statusLabel->setText(tr("not connected"));
|
||||||
|
}
|
||||||
|
item->setConnectActionText(item->isAcitve);
|
||||||
|
}
|
||||||
|
|
||||||
|
int Vpn::getInsertPos(QString connName)
|
||||||
|
{
|
||||||
|
qDebug() << "[Vpn]getInsertPos" << connName;
|
||||||
|
int index = 0;
|
||||||
|
if(!m_interface->isValid()) {
|
||||||
|
index = 0;
|
||||||
|
} else {
|
||||||
|
QDBusMessage result = m_interface->call(QStringLiteral("getVirtualList"));
|
||||||
|
if(result.type() == QDBusMessage::ErrorMessage)
|
||||||
|
{
|
||||||
|
qWarning() << "getVirtualList error:" << result.errorMessage();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
auto dbusArg = result.arguments().at(0).value<QDBusArgument>();
|
||||||
|
QVector<QStringList> variantList;
|
||||||
|
dbusArg >> variantList;
|
||||||
|
for (int i = 0; i < variantList.size(); ++i ) {
|
||||||
|
if (variantList.at(i).at(0) == connName) {
|
||||||
|
qDebug() << "pos in kylin-nm is " << i;
|
||||||
|
index = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (variantList.at(0).size() == 1) {
|
||||||
|
index--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return index;
|
||||||
|
}
|
|
@ -0,0 +1,119 @@
|
||||||
|
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||||
|
*
|
||||||
|
* Copyright (C) 2019 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 VPN_H
|
||||||
|
#define VPN_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QtPlugin>
|
||||||
|
#include <QtDBus/QDBusInterface>
|
||||||
|
#include <QFrame>
|
||||||
|
#include <QLabel>
|
||||||
|
|
||||||
|
#include "interface.h"
|
||||||
|
#include "addbtn.h"
|
||||||
|
#include "imageutil.h"
|
||||||
|
#include "kwidget.h"
|
||||||
|
#include "kswitchbutton.h"
|
||||||
|
#include "itemframe.h"
|
||||||
|
|
||||||
|
using namespace kdk;
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class Vpn;
|
||||||
|
}
|
||||||
|
|
||||||
|
class Vpn : public QObject, CommonInterface
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PLUGIN_METADATA(IID "org.ukcc.CommonInterface")
|
||||||
|
Q_INTERFACES(CommonInterface)
|
||||||
|
|
||||||
|
public:
|
||||||
|
Vpn();
|
||||||
|
~Vpn();
|
||||||
|
|
||||||
|
QString plugini18nName() Q_DECL_OVERRIDE;
|
||||||
|
int pluginTypes() Q_DECL_OVERRIDE;
|
||||||
|
QWidget * pluginUi() Q_DECL_OVERRIDE;
|
||||||
|
const QString name() const Q_DECL_OVERRIDE;
|
||||||
|
bool isShowOnHomePage() const Q_DECL_OVERRIDE;
|
||||||
|
QIcon icon() const Q_DECL_OVERRIDE;
|
||||||
|
bool isEnable() const Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
|
public:
|
||||||
|
void initComponent();
|
||||||
|
void initConnect();
|
||||||
|
|
||||||
|
void runExternalApp();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// bool eventFilter(QObject *watched, QEvent *event);
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui::Vpn *ui;
|
||||||
|
|
||||||
|
QString pluginName;
|
||||||
|
int pluginType;
|
||||||
|
QWidget * pluginWidget;
|
||||||
|
|
||||||
|
QDBusInterface *m_interface = nullptr;
|
||||||
|
|
||||||
|
QFrame *m_topFrame;
|
||||||
|
QFrame *m_showFrame;
|
||||||
|
QLabel *m_showLabel;
|
||||||
|
KSwitchButton *m_showBtn;
|
||||||
|
QFrame *m_Line;
|
||||||
|
QFrame *m_timeFrame;
|
||||||
|
QLabel *m_timeLabel;
|
||||||
|
KSwitchButton *m_timeBtn;
|
||||||
|
ItemFrame *m_listFrame;
|
||||||
|
|
||||||
|
bool mFirstLoad;
|
||||||
|
QGSettings *m_switchGsettings;
|
||||||
|
|
||||||
|
QFrame* myLine();
|
||||||
|
|
||||||
|
int getInsertPos(QString connName);
|
||||||
|
|
||||||
|
void deleteVpn(QString uuid);
|
||||||
|
void activeConnect(QString uuid);
|
||||||
|
void deActiveConnect(QString uuid);
|
||||||
|
|
||||||
|
//获取设备列表
|
||||||
|
void initNet();
|
||||||
|
//增加一项
|
||||||
|
void addOneVirtualItem(QStringList infoList);
|
||||||
|
//减少一项
|
||||||
|
void removeOneVirtualItem(QString uuid);
|
||||||
|
//单个lan连接状态变化
|
||||||
|
void itemActiveConnectionStatusChanged(VpnItem *item, int status);
|
||||||
|
|
||||||
|
|
||||||
|
void setShowSwitchStatus();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void onVpnAdd(QStringList);
|
||||||
|
void onVpnRemove(QString);
|
||||||
|
void onVpnUpdate(QStringList);
|
||||||
|
void onVpnActiveConnectionStateChanged(QString, int);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // VPN_H
|
|
@ -0,0 +1,50 @@
|
||||||
|
#-------------------------------------------------
|
||||||
|
#
|
||||||
|
# Project created by QtCreator 2019-06-29T13:53:10
|
||||||
|
#
|
||||||
|
#-------------------------------------------------
|
||||||
|
|
||||||
|
QT += widgets dbus
|
||||||
|
|
||||||
|
TEMPLATE = lib
|
||||||
|
CONFIG += plugin \
|
||||||
|
c++11 \
|
||||||
|
link_pkgconfig
|
||||||
|
|
||||||
|
include(../component/addbtn.pri)
|
||||||
|
|
||||||
|
PKGCONFIG += gsettings-qt \
|
||||||
|
kysdk-qtwidgets \
|
||||||
|
|
||||||
|
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 \
|
||||||
|
$$PROJECT_ROOTDIR \
|
||||||
|
/usr/include/ukcc/interface \
|
||||||
|
/usr/include/ukcc/widgets
|
||||||
|
|
||||||
|
LIBS += -L$$[QT_INSTALL_LIBS] -lukcc
|
||||||
|
|
||||||
|
SOURCES += \
|
||||||
|
vpn.cpp \
|
||||||
|
itemframe.cpp \
|
||||||
|
vpnitem.cpp
|
||||||
|
|
||||||
|
HEADERS += \
|
||||||
|
vpn.h \
|
||||||
|
itemframe.h \
|
||||||
|
vpnitem.h
|
||||||
|
|
||||||
|
FORMS += \
|
||||||
|
vpn.ui
|
||||||
|
|
||||||
|
INSTALLS += target \
|
||||||
|
trans
|
||||||
|
|
||||||
|
TRANSLATIONS += \
|
||||||
|
translations/zh_CN.ts
|
|
@ -0,0 +1,112 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>Vpn</class>
|
||||||
|
<widget class="QWidget" name="Vpn">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>800</width>
|
||||||
|
<height>710</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>16777215</width>
|
||||||
|
<height>16777215</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string notr="true">Vpn</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>8</number>
|
||||||
|
</property>
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="TitleLabel" name="titleLabel">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>VPN</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_4"/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_3"/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="pushButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>import</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="verticalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<layoutdefault spacing="6" margin="11"/>
|
||||||
|
<customwidgets>
|
||||||
|
<customwidget>
|
||||||
|
<class>TitleLabel</class>
|
||||||
|
<extends>QLabel</extends>
|
||||||
|
<header location="global">titlelabel.h</header>
|
||||||
|
</customwidget>
|
||||||
|
</customwidgets>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
|
@ -0,0 +1,187 @@
|
||||||
|
/* -*- 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 "vpnitem.h"
|
||||||
|
#include <QPainter>
|
||||||
|
#define FRAME_SPEED 150
|
||||||
|
#define LIMIT_TIME 60*1000
|
||||||
|
#define TOTAL_PAGE 8
|
||||||
|
#define RADIUS 6.0
|
||||||
|
|
||||||
|
#define THEME_QT_SCHEMA "org.ukui.style"
|
||||||
|
#define MODE_QT_KEY "style-name"
|
||||||
|
|
||||||
|
VpnItem::VpnItem(bool bAcitve, QWidget *parent)
|
||||||
|
: isAcitve(bAcitve), QPushButton(parent)
|
||||||
|
{
|
||||||
|
this->setMinimumSize(550, 58);
|
||||||
|
this->setProperty("useButtonPalette", true);
|
||||||
|
this->setFlat(true);
|
||||||
|
QPalette pal = this->palette();
|
||||||
|
QColor color = pal.color(QPalette::Button);
|
||||||
|
color.setAlphaF(0.5);
|
||||||
|
pal.setColor(QPalette::Button, color);
|
||||||
|
this->setPalette(pal);
|
||||||
|
QHBoxLayout *mLanLyt = new QHBoxLayout(this);
|
||||||
|
mLanLyt->setContentsMargins(16,0,16,0);
|
||||||
|
mLanLyt->setSpacing(16);
|
||||||
|
iconLabel = new QLabel(this);
|
||||||
|
iconLabel->setProperty("useIconHighlightEffect", 0x2);
|
||||||
|
titileLabel = new FixLabel(this);
|
||||||
|
statusLabel = new QLabel(this);
|
||||||
|
statusLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
||||||
|
infoLabel = new GrayInfoButton(this);
|
||||||
|
|
||||||
|
m_moreButton = new QToolButton(this);
|
||||||
|
m_moreButton->setProperty("useButtonPalette", true);
|
||||||
|
m_moreButton->setPopupMode(QToolButton::InstantPopup);
|
||||||
|
m_moreButton->setAutoRaise(true);
|
||||||
|
m_moreButton->setIcon(QIcon::fromTheme("view-more-horizontal-symbolic"));
|
||||||
|
m_moreMenu = new QMenu(m_moreButton);
|
||||||
|
m_connectAction = new QAction(m_moreMenu);
|
||||||
|
m_deleteAction = new QAction(tr("Delete"), m_moreMenu);
|
||||||
|
setConnectActionText(isAcitve);
|
||||||
|
|
||||||
|
m_moreMenu->addAction(m_connectAction);
|
||||||
|
m_moreMenu->addAction(m_deleteAction);
|
||||||
|
m_moreButton->setMenu(m_moreMenu);
|
||||||
|
|
||||||
|
mLanLyt->addWidget(iconLabel);
|
||||||
|
mLanLyt->addWidget(titileLabel,Qt::AlignLeft);
|
||||||
|
mLanLyt->addStretch();
|
||||||
|
mLanLyt->addWidget(statusLabel);
|
||||||
|
mLanLyt->addWidget(infoLabel);
|
||||||
|
mLanLyt->addWidget(m_moreButton);
|
||||||
|
|
||||||
|
loadIcons.append(QIcon::fromTheme("ukui-loading-1-symbolic"));
|
||||||
|
loadIcons.append(QIcon::fromTheme("ukui-loading-2-symbolic"));
|
||||||
|
loadIcons.append(QIcon::fromTheme("ukui-loading-3-symbolic"));
|
||||||
|
loadIcons.append(QIcon::fromTheme("ukui-loading-4-symbolic"));
|
||||||
|
loadIcons.append(QIcon::fromTheme("ukui-loading-5-symbolic"));
|
||||||
|
loadIcons.append(QIcon::fromTheme("ukui-loading-6-symbolic"));
|
||||||
|
loadIcons.append(QIcon::fromTheme("ukui-loading-7-symbolic"));
|
||||||
|
|
||||||
|
waitTimer = new QTimer(this);
|
||||||
|
connect(waitTimer, &QTimer::timeout, this, &VpnItem::updateIcon);
|
||||||
|
|
||||||
|
connect(m_connectAction, &QAction::triggered, this, &VpnItem::onConnectTriggered);
|
||||||
|
connect(m_deleteAction, &QAction::triggered, this, &VpnItem::onDeletetTriggered);
|
||||||
|
m_moreMenu->installEventFilter(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void VpnItem::updateIcon()
|
||||||
|
{
|
||||||
|
if (currentIconIndex > 6) {
|
||||||
|
currentIconIndex = 0;
|
||||||
|
}
|
||||||
|
statusLabel->setPixmap(loadIcons.at(currentIconIndex).pixmap(16,16));
|
||||||
|
currentIconIndex ++;
|
||||||
|
}
|
||||||
|
|
||||||
|
void VpnItem::startLoading()
|
||||||
|
{
|
||||||
|
waitTimer->start(FRAME_SPEED);
|
||||||
|
loading = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void VpnItem::stopLoading(){
|
||||||
|
waitTimer->stop();
|
||||||
|
loading = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void VpnItem::setConnectActionText(bool isAcitve)
|
||||||
|
{
|
||||||
|
if (isAcitve) {
|
||||||
|
m_connectAction->setText(tr("Disconnect"));
|
||||||
|
} else {
|
||||||
|
m_connectAction->setText(tr("Connect"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void VpnItem::onConnectTriggered()
|
||||||
|
{
|
||||||
|
if (!m_connectAction) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (m_connectAction->text() == tr("Connect")) {
|
||||||
|
Q_EMIT connectActionTriggered();
|
||||||
|
} else if (m_connectAction->text() == tr("Disconnect")) {
|
||||||
|
Q_EMIT disconnectActionTriggered();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void VpnItem::onDeletetTriggered()
|
||||||
|
{
|
||||||
|
if (!m_deleteAction) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Q_EMIT deleteActionTriggered();
|
||||||
|
}
|
||||||
|
|
||||||
|
void VpnItem::paintEvent(QPaintEvent *event)
|
||||||
|
{
|
||||||
|
QPalette pal = this->palette();
|
||||||
|
|
||||||
|
QPainter painter(this);
|
||||||
|
painter.setRenderHint(QPainter:: Antialiasing, true); //设置渲染,启动反锯齿
|
||||||
|
painter.setPen(Qt::NoPen);
|
||||||
|
painter.setBrush(pal.color(QPalette::Base));
|
||||||
|
|
||||||
|
QRect rect = this->rect();
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
if (!useHalfFillet) {
|
||||||
|
painter.drawRect(rect);
|
||||||
|
} else {
|
||||||
|
QPainterPath path;
|
||||||
|
// path.addRoundedRect (rect, RADIUS, RADIUS);
|
||||||
|
// QRect temp_rect(rect.left(), rect.top(), rect.width(), rect.height()/2);
|
||||||
|
// path.addRect(temp_rect);
|
||||||
|
//设置起点
|
||||||
|
path.moveTo(rect.topLeft().x(), rect.topLeft().y());
|
||||||
|
path.lineTo(rect.bottomLeft().x(), rect.bottomLeft().y() - RADIUS);
|
||||||
|
//绘制圆角 圆弧以外切圆的270度位置为起点,逆时针画圆弧运行90度结束
|
||||||
|
path.arcTo(QRect(QPoint(rect.bottomLeft().x(), rect.bottomLeft().y() - (RADIUS * 2)), QSize(RADIUS * 2, RADIUS * 2)), 180, 90);
|
||||||
|
path.lineTo(rect.bottomRight().x() - RADIUS, rect.bottomRight().y());
|
||||||
|
//画圆弧
|
||||||
|
path.arcTo(QRect(QPoint(rect.bottomRight().x() - (RADIUS * 2), rect.bottomRight().y() - (RADIUS * 2)), QSize(RADIUS * 2, RADIUS * 2)), 270, 90);
|
||||||
|
path.lineTo(rect.topRight());
|
||||||
|
path.lineTo(rect.topLeft());
|
||||||
|
painter.drawPath(path);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
painter.drawRect(rect);
|
||||||
|
QPushButton::paintEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool VpnItem::eventFilter(QObject *watched, QEvent *event)
|
||||||
|
{
|
||||||
|
//菜单右边界与按钮右边界对齐
|
||||||
|
if (event->type() == QEvent::Show && watched == m_moreMenu) {
|
||||||
|
int menuXPos = m_moreMenu->pos().x();
|
||||||
|
int menuWidth = m_moreMenu->size().width();
|
||||||
|
int btnWidth = m_moreButton->size().width();
|
||||||
|
|
||||||
|
QPoint pos = QPoint (menuXPos - menuWidth + btnWidth, m_moreMenu->pos().y());
|
||||||
|
m_moreMenu->move(pos);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
|
@ -0,0 +1,88 @@
|
||||||
|
/* -*- 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 VPNITEM_H
|
||||||
|
#define VPNITEM_H
|
||||||
|
#include <QWidget>
|
||||||
|
#include <QPushButton>
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QVariantMap>
|
||||||
|
#include <QTimer>
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QGSettings>
|
||||||
|
#include <QImage>
|
||||||
|
#include <QPainter>
|
||||||
|
#include <QToolButton>
|
||||||
|
#include <QMenu>
|
||||||
|
#include <QEvent>
|
||||||
|
#include "fixlabel.h"
|
||||||
|
#include "../component/AddBtn/grayinfobutton.h"
|
||||||
|
|
||||||
|
class VpnItem : public QPushButton
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
VpnItem(bool bAcitve, QWidget *parent = nullptr);
|
||||||
|
public:
|
||||||
|
QLabel * iconLabel = nullptr;
|
||||||
|
GrayInfoButton * infoLabel = nullptr;
|
||||||
|
FixLabel * titileLabel = nullptr;
|
||||||
|
QLabel * statusLabel = nullptr;
|
||||||
|
QToolButton* m_moreButton = nullptr;
|
||||||
|
QMenu* m_moreMenu = nullptr;
|
||||||
|
QAction* m_connectAction = nullptr;
|
||||||
|
QAction* m_deleteAction = nullptr;
|
||||||
|
|
||||||
|
QString uuid = "";
|
||||||
|
QString dbusPath = "";
|
||||||
|
|
||||||
|
void setHalfFillet(bool flag) {useHalfFillet = flag; repaint();}
|
||||||
|
public:
|
||||||
|
void startLoading();
|
||||||
|
void stopLoading();
|
||||||
|
void setConnectActionText(bool isAcitve);
|
||||||
|
|
||||||
|
bool isAcitve = false;
|
||||||
|
bool loading = false;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void paintEvent(QPaintEvent *event);
|
||||||
|
bool eventFilter(QObject *watched, QEvent *event);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QTimer *waitTimer = nullptr;
|
||||||
|
QGSettings *themeGsettings = nullptr;
|
||||||
|
bool useHalfFillet = false;
|
||||||
|
QList<QIcon> loadIcons;
|
||||||
|
int currentIconIndex=0;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void updateIcon();
|
||||||
|
void onConnectTriggered();
|
||||||
|
void onDeletetTriggered();
|
||||||
|
|
||||||
|
Q_SIGNALS:
|
||||||
|
void connectActionTriggered();
|
||||||
|
void disconnectActionTriggered();
|
||||||
|
void deleteActionTriggered();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // VPNITEM_H
|
|
@ -184,7 +184,7 @@
|
||||||
<customwidget>
|
<customwidget>
|
||||||
<class>TitleLabel</class>
|
<class>TitleLabel</class>
|
||||||
<extends>QLabel</extends>
|
<extends>QLabel</extends>
|
||||||
<header>titlelabel.h</header>
|
<header location="global">titlelabel.h</header>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<resources/>
|
<resources/>
|
||||||
|
|
|
@ -4,6 +4,7 @@ include(dbus-interface/dbus-interface.pri)
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
$$PWD/dbusadaptor.h \
|
$$PWD/dbusadaptor.h \
|
||||||
|
$$PWD/vpndbusadaptor.h \
|
||||||
$$PWD/kylinarping.h \
|
$$PWD/kylinarping.h \
|
||||||
$$PWD/kylinipv4arping.h \
|
$$PWD/kylinipv4arping.h \
|
||||||
$$PWD/kylinipv6arping.h \
|
$$PWD/kylinipv6arping.h \
|
||||||
|
@ -13,6 +14,7 @@ HEADERS += \
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
$$PWD/dbusadaptor.cpp \
|
$$PWD/dbusadaptor.cpp \
|
||||||
|
$$PWD/vpndbusadaptor.cpp \
|
||||||
$$PWD/kylinipv4arping.cpp \
|
$$PWD/kylinipv4arping.cpp \
|
||||||
$$PWD/kylinipv6arping.cpp \
|
$$PWD/kylinipv6arping.cpp \
|
||||||
$$PWD/sysdbusregister.cpp \
|
$$PWD/sysdbusregister.cpp \
|
||||||
|
|
|
@ -212,14 +212,6 @@ wifi_get_secrets (SecretsRequest *req, GError **error)
|
||||||
|
|
||||||
g_return_val_if_fail (!info->dialog, FALSE);
|
g_return_val_if_fail (!info->dialog, FALSE);
|
||||||
|
|
||||||
#if GTK_CHECK_VERSION(3,90,0)
|
|
||||||
gtk_init ();
|
|
||||||
#else
|
|
||||||
int argc = 0;
|
|
||||||
char ***argv = NULL;
|
|
||||||
gtk_init (&argc, &argv);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
NMClient *nm_client = nm_client_new (NULL, NULL);
|
NMClient *nm_client = nm_client_new (NULL, NULL);
|
||||||
if (!nm_client) {
|
if (!nm_client) {
|
||||||
g_set_error (error,
|
g_set_error (error,
|
||||||
|
@ -409,6 +401,14 @@ void agent_init()
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
kylinAgent = applet_agent_new (&error);
|
kylinAgent = applet_agent_new (&error);
|
||||||
|
|
||||||
|
#if GTK_CHECK_VERSION(3,90,0)
|
||||||
|
gtk_init ();
|
||||||
|
#else
|
||||||
|
int argc = 0;
|
||||||
|
char ***argv = NULL;
|
||||||
|
gtk_init (&argc, &argv);
|
||||||
|
#endif
|
||||||
|
|
||||||
g_signal_connect (kylinAgent, APPLET_AGENT_GET_SECRETS,
|
g_signal_connect (kylinAgent, APPLET_AGENT_GET_SECRETS,
|
||||||
G_CALLBACK (applet_agent_get_secrets_cb), NULL);
|
G_CALLBACK (applet_agent_get_secrets_cb), NULL);
|
||||||
g_signal_connect (kylinAgent, APPLET_AGENT_CANCEL_SECRETS,
|
g_signal_connect (kylinAgent, APPLET_AGENT_CANCEL_SECRETS,
|
||||||
|
|
|
@ -42,11 +42,36 @@ static bool subLanListSort(const KyConnectItem* info1, const KyConnectItem* info
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool subVpnListSort(const KyConnectItem* info1, const KyConnectItem* info2)
|
||||||
|
{
|
||||||
|
if (info1->m_connectState != info2->m_connectState) {
|
||||||
|
if (info1->m_connectState == 2) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (info2->m_connectState == 2) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
QString name1 = info1->m_connectName;
|
||||||
|
QString name2 = info2->m_connectName;
|
||||||
|
bool result = true;
|
||||||
|
if (QString::compare(name1, name2, Qt::CaseInsensitive) > 0) {
|
||||||
|
result = false;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
static void lanListSort(QList<KyConnectItem *> &list)
|
static void lanListSort(QList<KyConnectItem *> &list)
|
||||||
{
|
{
|
||||||
qSort(list.begin(), list.end(), subLanListSort);
|
qSort(list.begin(), list.end(), subLanListSort);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void vpnListSort(QList<KyConnectItem *> &list)
|
||||||
|
{
|
||||||
|
qSort(list.begin(), list.end(), subVpnListSort);
|
||||||
|
}
|
||||||
|
|
||||||
KyConnectResourse::KyConnectResourse(QObject *parent) : QObject(parent)
|
KyConnectResourse::KyConnectResourse(QObject *parent) : QObject(parent)
|
||||||
{
|
{
|
||||||
m_networkResourceInstance = KyNetworkResourceManager::getInstance();
|
m_networkResourceInstance = KyNetworkResourceManager::getInstance();
|
||||||
|
@ -249,6 +274,10 @@ void KyConnectResourse::getVpnAndVirtualConnections(QList<KyConnectItem *> &conn
|
||||||
|
|
||||||
connectPtr = nullptr;
|
connectPtr = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (connectItemList.size() > 1) {
|
||||||
|
vpnListSort(connectItemList);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void KyConnectResourse::getConnectionList(QString deviceName,
|
void KyConnectResourse::getConnectionList(QString deviceName,
|
||||||
|
|
|
@ -52,6 +52,8 @@ KyNetworkResourceManager::KyNetworkResourceManager(QObject *parent) : QObject(pa
|
||||||
qRegisterMetaType<NetworkManager::Device::Type>("NetworkManager::Device::Type");
|
qRegisterMetaType<NetworkManager::Device::Type>("NetworkManager::Device::Type");
|
||||||
qRegisterMetaType<NetworkManager::Device::State>("NetworkManager::Device::State");
|
qRegisterMetaType<NetworkManager::Device::State>("NetworkManager::Device::State");
|
||||||
qRegisterMetaType<NetworkManager::Device::StateChangeReason>("NetworkManager::Device::StateChangeReason");
|
qRegisterMetaType<NetworkManager::Device::StateChangeReason>("NetworkManager::Device::StateChangeReason");
|
||||||
|
qRegisterMetaType<NetworkManager::VpnConnection::State>("NetworkManager::VpnConnection::State");
|
||||||
|
qRegisterMetaType<NetworkManager::VpnConnection::StateChangeReason>("NetworkManager::VpnConnection::StateChangeReason");
|
||||||
|
|
||||||
QDBusConnection::systemBus().connect(QString("org.freedesktop.DBus"),
|
QDBusConnection::systemBus().connect(QString("org.freedesktop.DBus"),
|
||||||
QString("/org/freedesktop/DBus"),
|
QString("/org/freedesktop/DBus"),
|
||||||
|
|
|
@ -0,0 +1,72 @@
|
||||||
|
/*
|
||||||
|
* This file was generated by qdbusxml2cpp version 0.8
|
||||||
|
* Command line was: qdbusxml2cpp com.kylin.weather.xml -a VpnDbusAdaptor -c VpnDbusAdaptor -l MainWindow
|
||||||
|
*
|
||||||
|
* qdbusxml2cpp is Copyright (C) 2015 The Qt Company Ltd.
|
||||||
|
*
|
||||||
|
* This is an auto-generated file.
|
||||||
|
* Do not edit! All changes made to it will be lost.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "vpndbusadaptor.h"
|
||||||
|
#include <QtCore/QMetaObject>
|
||||||
|
#include <QtCore/QByteArray>
|
||||||
|
#include <QtCore/QList>
|
||||||
|
#include <QtCore/QMap>
|
||||||
|
#include <QtCore/QString>
|
||||||
|
#include <QtCore/QStringList>
|
||||||
|
#include <QtCore/QVariant>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Implementation of adaptor class VpnDbusAdaptor
|
||||||
|
*/
|
||||||
|
|
||||||
|
VpnDbusAdaptor::VpnDbusAdaptor(vpnMainWindow *parent)
|
||||||
|
: QDBusAbstractAdaptor(parent)
|
||||||
|
{
|
||||||
|
// constructor
|
||||||
|
qDBusRegisterMetaType<QMap<QString, bool> >();
|
||||||
|
qDBusRegisterMetaType<QMap<QString, int> >();
|
||||||
|
qDBusRegisterMetaType<QVector<QStringList> >();
|
||||||
|
//setAutoRelaySignals(true)后会自动转发mainwindow发出的同名信号,因此不必再额外写一个转发
|
||||||
|
setAutoRelaySignals(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
VpnDbusAdaptor::~VpnDbusAdaptor()
|
||||||
|
{
|
||||||
|
// destructor
|
||||||
|
}
|
||||||
|
|
||||||
|
//虚拟连接列表
|
||||||
|
QVector<QStringList> VpnDbusAdaptor::getVirtualList()
|
||||||
|
{
|
||||||
|
QVector<QStringList> vector;
|
||||||
|
parent()->getVirtualList(vector);
|
||||||
|
return vector;
|
||||||
|
}
|
||||||
|
|
||||||
|
//删除
|
||||||
|
void VpnDbusAdaptor::deleteVpn(QString uuid)
|
||||||
|
{
|
||||||
|
qDebug() << "delete vpn" << uuid;
|
||||||
|
parent()->deleteVpn(uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
//连接 根据网卡类型 参数1 0:lan 1:wlan 参数3 为ssid/uuid
|
||||||
|
void VpnDbusAdaptor::activateVpn(const QString& connUuid)
|
||||||
|
{
|
||||||
|
qDebug() << "activate vpn" << connUuid;
|
||||||
|
parent()->activateVpn(connUuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
//断开连接 根据网卡类型 参数1 0:lan 1:wlan 参数3 为ssid/uuid
|
||||||
|
void VpnDbusAdaptor::deactivateVpn(const QString& connUuid)
|
||||||
|
{
|
||||||
|
qDebug() << "deactivate vpn" << connUuid;
|
||||||
|
parent()->deactivateVpn(connUuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
void VpnDbusAdaptor::showKylinVpn()
|
||||||
|
{
|
||||||
|
parent()->onShowMainWindow();
|
||||||
|
}
|
|
@ -0,0 +1,71 @@
|
||||||
|
/*
|
||||||
|
* This file was generated by qdbusxml2cpp version 0.8
|
||||||
|
* Command line was: qdbusxml2cpp com.kylin.weather.xml -a dbusadaptor -c DbusAdaptor -l MainWindow
|
||||||
|
*
|
||||||
|
* qdbusxml2cpp is Copyright (C) 2015 The Qt Company Ltd.
|
||||||
|
*
|
||||||
|
* This is an auto-generated file.
|
||||||
|
* This file may have been hand-edited. Look for HAND-EDIT comments
|
||||||
|
* before re-generating it.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef VPNDBUSADAPTOR_H
|
||||||
|
#define VPNDBUSADAPTOR_H
|
||||||
|
|
||||||
|
#include <QtCore/QObject>
|
||||||
|
#include <QtDBus/QtDBus>
|
||||||
|
#include <QtDBus/QDBusMetaType>
|
||||||
|
|
||||||
|
#include "singlepage.h"
|
||||||
|
#include "../dbus-interface/kylinnetworkdeviceresource.h"
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
class QByteArray;
|
||||||
|
//template<class T> class QList;
|
||||||
|
template<class Key, class Value> class QMap;
|
||||||
|
class QString;
|
||||||
|
class QStringList;
|
||||||
|
class QVariant;
|
||||||
|
template<class T> class QVector;
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Adaptor class for interface com.kylin.weather
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "vpnmainwindow.h"
|
||||||
|
|
||||||
|
class VpnDbusAdaptor: public QDBusAbstractAdaptor
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_CLASSINFO("D-Bus Interface", "com.kylin.vpnTool")
|
||||||
|
public:
|
||||||
|
VpnDbusAdaptor(vpnMainWindow *parent);
|
||||||
|
virtual ~VpnDbusAdaptor();
|
||||||
|
|
||||||
|
inline vpnMainWindow *parent() const
|
||||||
|
{ return static_cast<vpnMainWindow *>(QObject::parent()); }
|
||||||
|
|
||||||
|
public: // PROPERTIES
|
||||||
|
public Q_SLOTS: // METHODS
|
||||||
|
//虚拟连接列表
|
||||||
|
QVector<QStringList> getVirtualList();
|
||||||
|
//刪除 根据网络名称 参数1 0:lan 1:wlan 参数2 为ssid/uuid
|
||||||
|
Q_NOREPLY void deleteVpn(QString uuid);
|
||||||
|
//连接 根据网卡类型 参数1 0:lan 1:wlan 参数3 为ssid/uuid
|
||||||
|
Q_NOREPLY void activateVpn(const QString& connUuid);
|
||||||
|
//断开连接 根据网卡类型 参数1 0:lan 1:wlan 参数3 为ssid/uuid
|
||||||
|
Q_NOREPLY void deactivateVpn(const QString& connUuid);
|
||||||
|
//just show
|
||||||
|
void showKylinVpn();
|
||||||
|
|
||||||
|
Q_SIGNALS: // SIGNALS
|
||||||
|
void vpnAdd(QStringList info);
|
||||||
|
void vpnRemove(QString dbusPath);
|
||||||
|
void vpnUpdate(QStringList info);
|
||||||
|
void vpnActiveConnectionStateChanged(QString uuid, int status);
|
||||||
|
|
||||||
|
void activateFailed(QString errorMessage);
|
||||||
|
void deactivateFailed(QString errorMessage);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
|
@ -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);
|
||||||
|
|
||||||
|
@ -107,10 +106,29 @@ void VpnListItem::connectItemCopy(const KyConnectItem *lanConnectItem)
|
||||||
|
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
void VpnListItem::activeConnection()
|
||||||
|
{
|
||||||
|
if (m_vpnConnectItem.m_connectUuid.isEmpty()) {
|
||||||
|
qDebug() << LOG_FLAG << "connect is empty, so can not connect or disconnect.";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Deactivated == m_vpnConnectItem.m_connectState) {
|
||||||
|
//断开的连接,点击激活连接
|
||||||
|
m_connectOperation->activateVpnConnection(m_vpnConnectItem.m_connectUuid);
|
||||||
|
qDebug() << LOG_FLAG << "it will activate connection" << m_vpnConnectItem.m_connectName;
|
||||||
|
m_netButton->startLoading();
|
||||||
|
} else {
|
||||||
|
qDebug() << LOG_FLAG <<"the connection" << m_vpnConnectItem.m_connectName
|
||||||
|
<< "is not deactived, so it can not be operation.";
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
void VpnListItem::onNetButtonClicked()
|
void VpnListItem::onNetButtonClicked()
|
||||||
{
|
{
|
||||||
if (m_vpnConnectItem.m_connectUuid.isEmpty()) {
|
if (m_vpnConnectItem.m_connectUuid.isEmpty()) {
|
||||||
qDebug()<<"--cxc--"<<Q_FUNC_INFO<<__LINE__;
|
|
||||||
qDebug() << LOG_FLAG << "connect is empty, so can not connect or disconnect.";
|
qDebug() << LOG_FLAG << "connect is empty, so can not connect or disconnect.";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -163,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
@ -45,9 +49,12 @@ public:
|
||||||
QString getConnectionPath();
|
QString getConnectionPath();
|
||||||
void updateConnectionPath(QString connectionPath);
|
void updateConnectionPath(QString connectionPath);
|
||||||
|
|
||||||
|
void activeConnection();
|
||||||
|
|
||||||
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);
|
||||||
|
@ -59,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;
|
||||||
|
|
|
@ -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)
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
||||||
|
|
||||||
|
@ -44,7 +37,7 @@ VpnPage::VpnPage(QWidget *parent) : SinglePage(parent)
|
||||||
m_activeResourse = new KyActiveConnectResourse(this);
|
m_activeResourse = new KyActiveConnectResourse(this);
|
||||||
m_connectResourse = new KyConnectResourse(this);
|
m_connectResourse = new KyConnectResourse(this);
|
||||||
// m_deviceResource = new KyNetworkDeviceResourse(this);
|
// m_deviceResource = new KyNetworkDeviceResourse(this);
|
||||||
// m_wiredConnectOperation = new KyWiredConnectOperation(this);
|
m_wiredConnectOperation = new KyWiredConnectOperation(this);
|
||||||
|
|
||||||
initUI();
|
initUI();
|
||||||
initVpnArea();
|
initVpnArea();
|
||||||
|
@ -58,8 +51,8 @@ VpnPage::VpnPage(QWidget *parent) : SinglePage(parent)
|
||||||
connect(m_connectResourse, &KyConnectResourse::connectionRemove, this, &VpnPage::onRemoveConnection);
|
connect(m_connectResourse, &KyConnectResourse::connectionRemove, this, &VpnPage::onRemoveConnection);
|
||||||
connect(m_connectResourse, &KyConnectResourse::connectionUpdate, this, &VpnPage::onUpdateConnection);
|
connect(m_connectResourse, &KyConnectResourse::connectionUpdate, this, &VpnPage::onUpdateConnection);
|
||||||
|
|
||||||
// connect(m_wiredConnectOperation, &KyWiredConnectOperation::activateConnectionError, this, &VpnPage::activateFailed);
|
connect(m_wiredConnectOperation, &KyWiredConnectOperation::activateConnectionError, this, &VpnPage::activateFailed);
|
||||||
// connect(m_wiredConnectOperation, &KyWiredConnectOperation::deactivateConnectionError, this, &VpnPage::deactivateFailed);
|
connect(m_wiredConnectOperation, &KyWiredConnectOperation::deactivateConnectionError, this, &VpnPage::deactivateFailed);
|
||||||
}
|
}
|
||||||
|
|
||||||
VpnPage::~VpnPage()
|
VpnPage::~VpnPage()
|
||||||
|
@ -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();
|
||||||
|
@ -127,18 +121,15 @@ void VpnPage::constructActiveConnectionArea()
|
||||||
KyConnectItem *p_netConnectionItem = netList.at(index);
|
KyConnectItem *p_netConnectionItem = netList.at(index);
|
||||||
p_newItem = m_activeResourse->getActiveConnectionByUuid(p_netConnectionItem->m_connectUuid);
|
p_newItem = m_activeResourse->getActiveConnectionByUuid(p_netConnectionItem->m_connectUuid);
|
||||||
if (p_newItem == nullptr) {
|
if (p_newItem == nullptr) {
|
||||||
qDebug()<<"---cxc---"<<Q_FUNC_INFO<<__LINE__<<p_netConnectionItem->m_connectUuid<<p_netConnectionItem->m_connectName<<p_netConnectionItem->m_connectState;
|
|
||||||
if (m_netConnectionMap.contains(p_netConnectionItem->m_connectUuid)) {
|
if (m_netConnectionMap.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;
|
||||||
}
|
}
|
||||||
QListWidgetItem *p_listWidgetItem = addNewItem(p_netConnectionItem, m_vpnListWidget);
|
QListWidgetItem *p_listWidgetItem = addNewItem(p_netConnectionItem, m_vpnListWidget);
|
||||||
m_netConnectionMap.insert(p_netConnectionItem->m_connectUuid, p_listWidgetItem);
|
m_netConnectionMap.insert(p_netConnectionItem->m_connectUuid, p_listWidgetItem);
|
||||||
} else {
|
} else {
|
||||||
qDebug()<<"---cxc---"<<Q_FUNC_INFO<<__LINE__<<p_netConnectionItem->m_connectUuid<<p_netConnectionItem->m_connectName<<p_netConnectionItem->m_connectState;
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
@ -146,54 +137,29 @@ void VpnPage::constructActiveConnectionArea()
|
||||||
delete p_netConnectionItem;
|
delete p_netConnectionItem;
|
||||||
p_netConnectionItem = nullptr;
|
p_netConnectionItem = nullptr;
|
||||||
}
|
}
|
||||||
}
|
if (vpnGsettings.keys().contains(QString(VISIBLE))) {
|
||||||
if (m_vpnListWidget->count() <= MAX_ITEMS) {
|
vpnGsettings.set(VISIBLE, true);
|
||||||
m_vpnListWidget->setFixedWidth(MIN_WIDTH);
|
}
|
||||||
} else {
|
} else {
|
||||||
m_vpnListWidget->setFixedWidth(MAX_WIDTH);
|
if (vpnGsettings.keys().contains(QString(VISIBLE))) {
|
||||||
}
|
vpnGsettings.set(VISIBLE, false);
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
void VpnPage::constructConnectionArea()
|
|
||||||
{
|
|
||||||
QList<KyConnectItem *> 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"<<p_netConnectionItem->m_connectName;
|
|
||||||
QListWidgetItem *p_listWidgetItem = addNewItem(p_netConnectionItem, m_vpnListWidget);
|
|
||||||
if (m_netConnectionMap.contains(p_netConnectionItem->m_connectUuid)) {
|
|
||||||
qDebug()<<LOG_FLAG << "has contain uuid" << p_netConnectionItem->m_connectUuid;
|
|
||||||
}
|
|
||||||
m_netConnectionMap.insert(p_netConnectionItem->m_connectUuid, p_listWidgetItem);
|
|
||||||
|
|
||||||
delete p_netConnectionItem;
|
|
||||||
p_netConnectionItem = nullptr;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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();
|
||||||
// constructConnectionArea();
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VpnPage::removeConnectionItem(QMap<QString, QListWidgetItem *> &connectMap,
|
bool VpnPage::removeConnectionItem(QMap<QString, QListWidgetItem *> &connectMap,
|
||||||
|
@ -217,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;
|
||||||
}
|
}
|
||||||
|
@ -232,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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -259,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -276,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)); //背景透明
|
||||||
|
@ -372,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,
|
||||||
|
@ -387,24 +358,21 @@ 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::ActiveConnection::State state,
|
NetworkManager::ActiveConnection::State state,
|
||||||
NetworkManager::ActiveConnection::Reason reason)
|
NetworkManager::ActiveConnection::Reason reason)
|
||||||
{
|
{
|
||||||
qDebug()<<"--cxc--"<<Q_FUNC_INFO<<__LINE__<<uuid<<state<<reason;
|
|
||||||
//VpnPage函数内持续监听连接状态的变化并记录供其他函数调用获取状态
|
//VpnPage函数内持续监听连接状态的变化并记录供其他函数调用获取状态
|
||||||
if (!m_connectResourse->isVirtualConncection(uuid)) {
|
if (!m_connectResourse->isVirtualConncection(uuid)) {
|
||||||
qDebug() << "[VpnPage] connection state change signal but not wired";
|
qDebug() << "[VpnPage] connection state change signal but not vpn";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
sendVpnStateChangeSignal(uuid, (ConnectState)state);
|
sendVpnStateChangeSignal(uuid, (ConnectState)state);
|
||||||
|
|
||||||
if (m_activeConnectionMap.keys().contains(uuid) && state == NetworkManager::ActiveConnection::State::Activated) {
|
if (m_activeConnectionMap.keys().contains(uuid) && state == NetworkManager::ActiveConnection::State::Activated) {
|
||||||
qDebug()<<"--cxc--"<<Q_FUNC_INFO<<__LINE__<<uuid<<state;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -443,7 +411,7 @@ void VpnPage::onConnectionStateChange(QString uuid,
|
||||||
updateConnectionState(m_activeConnectionMap, m_vpnListWidget, uuid, (ConnectState)state);
|
updateConnectionState(m_activeConnectionMap, m_vpnListWidget, uuid, (ConnectState)state);
|
||||||
}
|
}
|
||||||
|
|
||||||
Q_EMIT vpnActiveConnectionStateChanged(deviceName, uuid, state);
|
Q_EMIT vpnActiveConnectionStateChanged(uuid, state);
|
||||||
|
|
||||||
if (p_newItem) {
|
if (p_newItem) {
|
||||||
delete p_newItem;
|
delete p_newItem;
|
||||||
|
@ -453,17 +421,24 @@ void VpnPage::onConnectionStateChange(QString uuid,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VpnPage::getVirtualList(QVector<QStringList> &vector)
|
||||||
void VpnPage::getVirtualList(QMap<QString, QVector<QStringList> > &map)
|
|
||||||
{
|
{
|
||||||
QList<KyConnectItem *> netConnectList;
|
QList<KyConnectItem *> netConnectList;
|
||||||
QVector<QStringList> vector;
|
vector.clear();
|
||||||
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++) {
|
||||||
vector.clear();
|
KyConnectItem *p_newItem = nullptr;
|
||||||
vector.append(QStringList()<<netConnectList.at(i)->m_connectName<<netConnectList.at(i)->m_connectUuid << netConnectList.at(i)->m_connectPath);
|
KyConnectItem *p_netConnectionItem = netConnectList.at(i);
|
||||||
map.insert(netConnectList.at(i)->m_connectUuid, vector);
|
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(state));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
@ -473,7 +448,7 @@ void VpnPage::sendVpnUpdateSignal(KyConnectItem *p_connectItem)
|
||||||
{
|
{
|
||||||
QStringList info;
|
QStringList info;
|
||||||
info << p_connectItem->m_connectName << p_connectItem->m_connectUuid << p_connectItem->m_connectPath;
|
info << p_connectItem->m_connectName << p_connectItem->m_connectUuid << p_connectItem->m_connectPath;
|
||||||
Q_EMIT vpnUpdate(p_connectItem->m_ifaceName, info);
|
Q_EMIT vpnUpdate(info);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -481,9 +456,18 @@ void VpnPage::sendVpnUpdateSignal(KyConnectItem *p_connectItem)
|
||||||
void VpnPage::sendVpnAddSignal(KyConnectItem *p_connectItem)
|
void VpnPage::sendVpnAddSignal(KyConnectItem *p_connectItem)
|
||||||
{
|
{
|
||||||
QStringList info;
|
QStringList info;
|
||||||
info << p_connectItem->m_connectName << p_connectItem->m_connectUuid << p_connectItem->m_connectPath;
|
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(state);
|
||||||
qDebug() << "[VpnPage] emit vpnAdd because addConnection ";
|
qDebug() << "[VpnPage] emit vpnAdd because addConnection ";
|
||||||
Q_EMIT vpnAdd(p_connectItem->m_ifaceName, info);
|
Q_EMIT vpnAdd(info);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -554,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -600,22 +584,28 @@ bool VpnPage::eventFilter(QObject *watched, QEvent *event)
|
||||||
return QWidget::eventFilter(watched, event);
|
return QWidget::eventFilter(watched, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VpnPage::deleteVpn(const QString &connUuid)
|
||||||
|
{
|
||||||
|
qDebug() << "[VpnPage] deleteVpn" << connUuid;
|
||||||
|
if (connUuid == nullptr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
m_wiredConnectOperation->deleteWiredConnect(connUuid);
|
||||||
|
}
|
||||||
|
|
||||||
void VpnPage::activateVpn(const QString& connUuid)
|
void VpnPage::activateVpn(const QString& connUuid)
|
||||||
{
|
{
|
||||||
// qDebug() << "[VpnPage] activateVpn" << connUuid;
|
if (m_netConnectionMap.contains(connUuid)) {
|
||||||
// if (!m_deviceResource->wiredDeviceIsCarriered(devName)) {
|
qDebug() << "[VpnPage] activateVpn" << connUuid;
|
||||||
// qDebug() << LOG_FLAG << devName << "is not carried, so can not activate connection";
|
m_wiredConnectOperation->activateVpnConnection(connUuid);
|
||||||
// this->showDesktopNotify(tr("Wired Device not carried"), "networkwrong");
|
}
|
||||||
// } else {
|
|
||||||
// m_wiredConnectOperation->activateConnection(connUuid, devName);
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void VpnPage::deactivateVpn(const QString& connUuid)
|
void VpnPage::deactivateVpn(const QString& connUuid)
|
||||||
{
|
{
|
||||||
qDebug() << "[VpnPage] deactivateVpn" << connUuid;
|
qDebug() << "[VpnPage] deactivateVpn" << connUuid;
|
||||||
QString name("");
|
QString name("");
|
||||||
// m_wiredConnectOperation->deactivateWiredConnection(name, connUuid);
|
m_wiredConnectOperation->deactivateWiredConnection(name, connUuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VpnPage::showDetailPage(QString devName, QString uuid)
|
void VpnPage::showDetailPage(QString devName, QString uuid)
|
||||||
|
@ -646,13 +636,3 @@ void VpnPage::showDetailPage(QString devName, QString uuid)
|
||||||
p_item = nullptr;
|
p_item = nullptr;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VpnPage::vpnIsConnected()
|
|
||||||
{
|
|
||||||
if (m_activeResourse->wiredConnectIsActived()) {
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
@ -45,13 +48,12 @@ public:
|
||||||
~VpnPage();
|
~VpnPage();
|
||||||
|
|
||||||
//for dbus
|
//for dbus
|
||||||
void getVirtualList(QMap<QString, QVector<QStringList> > &map);
|
void getVirtualList(QVector<QStringList> &vector);
|
||||||
|
void deleteVpn(const QString &connUuid);
|
||||||
void activateVpn(const QString& connUuid);
|
void activateVpn(const QString& connUuid);
|
||||||
void deactivateVpn(const QString& connUuid);
|
void deactivateVpn(const QString& connUuid);
|
||||||
void showDetailPage(QString devName, QString uuid);
|
void showDetailPage(QString devName, QString uuid);
|
||||||
|
|
||||||
bool vpnIsConnected();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool eventFilter(QObject *watched, QEvent *event);
|
bool eventFilter(QObject *watched, QEvent *event);
|
||||||
|
|
||||||
|
@ -66,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);
|
||||||
|
@ -87,15 +88,16 @@ private:
|
||||||
QListWidget *lanListWidget, QString uuid);
|
QListWidget *lanListWidget, QString uuid);
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void vpnAdd(QString devName, QStringList info);
|
void vpnAdd(QStringList info);
|
||||||
void vpnRemove(QString dbusPath);
|
void vpnRemove(QString dbusPath);
|
||||||
void vpnUpdate(QString devName, QStringList info);
|
void vpnUpdate(QStringList info);
|
||||||
|
|
||||||
void vpnActiveConnectionStateChanged(QString interface, QString uuid, int status);
|
void vpnActiveConnectionStateChanged(QString uuid, int status);
|
||||||
void vpnConnectChanged(int state);
|
void vpnConnectChanged(int state);
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void onConnectionStateChange(QString uuid, NetworkManager::ActiveConnection::State state,
|
void onConnectionStateChange(QString uuid,
|
||||||
|
NetworkManager::ActiveConnection::State state,
|
||||||
NetworkManager::ActiveConnection::Reason reason);
|
NetworkManager::ActiveConnection::Reason reason);
|
||||||
|
|
||||||
void onAddConnection(QString uuid);
|
void onAddConnection(QString uuid);
|
||||||
|
@ -110,7 +112,7 @@ private:
|
||||||
QListWidget * m_vpnListWidget = nullptr;
|
QListWidget * m_vpnListWidget = nullptr;
|
||||||
|
|
||||||
// KyNetworkDeviceResourse *m_deviceResource = nullptr;
|
// KyNetworkDeviceResourse *m_deviceResource = nullptr;
|
||||||
// KyWiredConnectOperation *m_wiredConnectOperation = nullptr;
|
KyWiredConnectOperation *m_wiredConnectOperation = nullptr;
|
||||||
KyActiveConnectResourse *m_activeResourse = nullptr; //激活的连接
|
KyActiveConnectResourse *m_activeResourse = nullptr; //激活的连接
|
||||||
KyConnectResourse *m_connectResourse = nullptr; //未激活的连接
|
KyConnectResourse *m_connectResourse = nullptr; //未激活的连接
|
||||||
|
|
||||||
|
|
|
@ -928,6 +928,11 @@ void WlanPage::onConnectionStateChanged(QString uuid,
|
||||||
NetworkManager::ActiveConnection::State state,
|
NetworkManager::ActiveConnection::State state,
|
||||||
NetworkManager::ActiveConnection::Reason reason)
|
NetworkManager::ActiveConnection::Reason reason)
|
||||||
{
|
{
|
||||||
|
if (!m_connectResource->isWirelessConnection(uuid)) {
|
||||||
|
qDebug()<< LOG_FLAG << "it is not wireless connection" << uuid;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
QString devName, ssid;
|
QString devName, ssid;
|
||||||
m_wirelessNetResource->getSsidByUuid(uuid, ssid);
|
m_wirelessNetResource->getSsidByUuid(uuid, ssid);
|
||||||
m_wirelessNetResource->getDeviceByUuid(uuid, devName);
|
m_wirelessNetResource->getDeviceByUuid(uuid, devName);
|
||||||
|
@ -942,11 +947,6 @@ void WlanPage::onConnectionStateChanged(QString uuid,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_connectResource->isWirelessConnection(uuid)) {
|
|
||||||
qDebug()<< LOG_FLAG << "it is not wireless connection" << uuid;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Q_EMIT this->wlanConnectChanged(state);
|
Q_EMIT this->wlanConnectChanged(state);
|
||||||
|
|
||||||
bool isApConnection = m_connectResource->isApConnection(uuid);
|
bool isApConnection = m_connectResource->isApConnection(uuid);
|
||||||
|
|
|
@ -73,38 +73,25 @@ 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
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief MainWindow::hideMainwindow 隐藏主页面时要进行的操作,后续可以添加到此函数
|
* @brief vpnMainWindow::hideMainwindow 隐藏主页面时要进行的操作,后续可以添加到此函数
|
||||||
*/
|
*/
|
||||||
void vpnMainWindow::hideMainwindow()
|
void vpnMainWindow::hideMainwindow()
|
||||||
{
|
{
|
||||||
this->hide();
|
this->hide();
|
||||||
Q_EMIT this->mainWindowVisibleChanged(false);
|
// Q_EMIT this->mainWindowVisibleChanged(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
///**
|
///**
|
||||||
// * @brief MainWindow::setWiredDefaultDevice 设置有线设备默认网卡
|
// * @brief vpnMainWindow::setWiredDefaultDevice 设置有线设备默认网卡
|
||||||
// */
|
// */
|
||||||
//void MainWindow::setWiredDefaultDevice(QString deviceName)
|
//void vpnMainWindow::setWiredDefaultDevice(QString deviceName)
|
||||||
//{
|
//{
|
||||||
//// m_vpnPage->updateDefaultDevice(deviceName);
|
//// m_vpnPage->updateDefaultDevice(deviceName);
|
||||||
//}
|
//}
|
||||||
|
@ -170,6 +157,7 @@ void vpnMainWindow::initWindowProperties()
|
||||||
// this->setFixedSize(MAINWINDOW_WIDTH, MAINWINDOW_HEIGHT);
|
// this->setFixedSize(MAINWINDOW_WIDTH, MAINWINDOW_HEIGHT);
|
||||||
// //绘制毛玻璃特效
|
// //绘制毛玻璃特效
|
||||||
// this->setAttribute(Qt::WA_TranslucentBackground, true); //透明
|
// this->setAttribute(Qt::WA_TranslucentBackground, true); //透明
|
||||||
|
this->setProperty("needTranslucent", true);
|
||||||
this->setFocusPolicy(Qt::NoFocus);
|
this->setFocusPolicy(Qt::NoFocus);
|
||||||
|
|
||||||
QString platform = QGuiApplication::platformName();
|
QString platform = QGuiApplication::platformName();
|
||||||
|
@ -188,8 +176,6 @@ void vpnMainWindow::paintEvent(QPaintEvent *event)
|
||||||
QPainter painter(this);
|
QPainter painter(this);
|
||||||
painter.setRenderHint(QPainter::Antialiasing); // 反锯齿;
|
painter.setRenderHint(QPainter::Antialiasing); // 反锯齿;
|
||||||
painter.setPen(Qt::transparent);
|
painter.setPen(Qt::transparent);
|
||||||
// auto rect = this->rect();
|
|
||||||
// painter.drawRoundedRect(rect, 12, 12); //窗口圆角
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void vpnMainWindow::initTransparency()
|
void vpnMainWindow::initTransparency()
|
||||||
|
@ -244,44 +230,26 @@ void vpnMainWindow::initUI()
|
||||||
void vpnMainWindow::initTrayIcon()
|
void vpnMainWindow::initTrayIcon()
|
||||||
{
|
{
|
||||||
m_vpnTrayIcon = new QSystemTrayIcon(this);
|
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->setToolTip(QString(tr("vpn tool")));
|
||||||
m_vpnTrayIcon->setIcon(QIcon::fromTheme("ukui-vpn-symbolic"));
|
m_vpnTrayIcon->setIcon(QIcon::fromTheme("ukui-vpn-symbolic"));
|
||||||
// m_showSettingsAction->setIcon(QIcon::fromTheme("document-page-setup-symbolic", QIcon(":/res/x/setup.png")) );
|
initVpnIconVisible();
|
||||||
//// 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_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()
|
void vpnMainWindow::initDbusConnnect()
|
||||||
{
|
{
|
||||||
// connect(m_vpnPage, &LanPage::deviceStatusChanged, this, &MainWindow::deviceStatusChanged);
|
connect(m_vpnPage, &VpnPage::activateFailed, this, &vpnMainWindow::activateFailed);
|
||||||
// connect(m_vpnPage, &LanPage::deviceNameChanged, this, &MainWindow::deviceNameChanged);
|
connect(m_vpnPage, &VpnPage::deactivateFailed, this, &vpnMainWindow::deactivateFailed);
|
||||||
// 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::vpnAdd, this, &vpnMainWindow::vpnAdd);
|
||||||
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);
|
||||||
// connect(m_vpnPage, &LanPage::lanConnectChanged, this, &MainWindow::onLanConnectStatusToChangeTrayIcon);
|
//模式切换
|
||||||
|
QDBusConnection::sessionBus().connect(QString("com.kylin.statusmanager.interface"),
|
||||||
// //模式切换
|
QString("/"),
|
||||||
// QDBusConnection::sessionBus().connect(QString("com.kylin.statusmanager.interface"),
|
QString("com.kylin.statusmanager.interface"),
|
||||||
// QString("/"),
|
QString("mode_change_signal"), this, SLOT(onTabletModeChanged(bool)));
|
||||||
// QString("com.kylin.statusmanager.interface"),
|
|
||||||
// QString("mode_change_signal"), this, SLOT(onTabletModeChanged(bool)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -350,31 +318,6 @@ void vpnMainWindow::resetWindowPosition()
|
||||||
qDebug() << " Position of ukui-panel is " << position << "; Position of mainwindow is " << this->geometry() << "." << Q_FUNC_INFO << __LINE__;
|
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 初始化窗口主题并创建信号槽
|
* @brief vpnMainWindow::initWindowTheme 初始化窗口主题并创建信号槽
|
||||||
*/
|
*/
|
||||||
|
@ -390,29 +333,9 @@ void vpnMainWindow::initWindowTheme()
|
||||||
}
|
}
|
||||||
|
|
||||||
///**
|
///**
|
||||||
// * @brief MainWindow::resetWindowTheme 读取和设置窗口主题
|
// * @brief vpnMainWindow::showControlCenter 打开控制面板网络界面
|
||||||
// */
|
// */
|
||||||
//void MainWindow::resetWindowTheme()
|
//void vpnMainWindow::showControlCenter()
|
||||||
//{
|
|
||||||
// if (!m_styleGsettings) { return; }
|
|
||||||
// QString currentTheme = m_styleGsettings->get(COLOR_THEME).toString();
|
|
||||||
// auto app = static_cast<QApplication*>(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;
|
// QProcess process;
|
||||||
// if (!m_vpnPage->lanIsConnected() && m_wlanWidget->checkWlanStatus(NetworkManager::ActiveConnection::State::Activated)){
|
// if (!m_vpnPage->lanIsConnected() && m_wlanWidget->checkWlanStatus(NetworkManager::ActiveConnection::State::Activated)){
|
||||||
|
@ -433,21 +356,6 @@ void vpnMainWindow::showByWaylandHelper()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void vpnMainWindow::getTabletMode()
|
void vpnMainWindow::getTabletMode()
|
||||||
{
|
{
|
||||||
// QDBusInterface interface(QString("com.kylin.statusmanager.interface"),
|
// QDBusInterface interface(QString("com.kylin.statusmanager.interface"),
|
||||||
|
@ -471,11 +379,10 @@ void vpnMainWindow::getTabletMode()
|
||||||
*/
|
*/
|
||||||
void vpnMainWindow::onTrayIconActivated(QSystemTrayIcon::ActivationReason reason)
|
void vpnMainWindow::onTrayIconActivated(QSystemTrayIcon::ActivationReason reason)
|
||||||
{
|
{
|
||||||
setCentralWidgetType(m_iconStatus);
|
|
||||||
switch(reason) {
|
switch(reason) {
|
||||||
case QSystemTrayIcon::Context:
|
// case QSystemTrayIcon::Context:
|
||||||
m_vpnTrayIconMenu->popup(QCursor::pos());
|
// m_vpnTrayIconMenu->popup(QCursor::pos());
|
||||||
break;
|
// break;
|
||||||
case QSystemTrayIcon::Trigger:
|
case QSystemTrayIcon::Trigger:
|
||||||
if (this->isVisible()) {
|
if (this->isVisible()) {
|
||||||
qDebug() << "Received signal of tray icon activated, will hide mainwindow." << Q_FUNC_INFO << __LINE__;
|
qDebug() << "Received signal of tray icon activated, will hide mainwindow." << Q_FUNC_INFO << __LINE__;
|
||||||
|
@ -489,29 +396,8 @@ void vpnMainWindow::onTrayIconActivated(QSystemTrayIcon::ActivationReason reason
|
||||||
default:
|
default:
|
||||||
break;
|
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)
|
void vpnMainWindow::onThemeChanged(const QString &key)
|
||||||
{
|
{
|
||||||
if (key == COLOR_THEME) {
|
if (key == COLOR_THEME) {
|
||||||
|
@ -523,99 +409,39 @@ void vpnMainWindow::onThemeChanged(const QString &key)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void vpnMainWindow::onRefreshTrayIcon()
|
void vpnMainWindow::onTabletModeChanged(bool mode)
|
||||||
{
|
{
|
||||||
//更新托盘图标显示
|
qDebug() << "TabletMode change" << mode;
|
||||||
// m_iconTimer->stop();
|
Q_UNUSED(mode)
|
||||||
// if (m_vpnPage->lanIsConnected()) {
|
//模式切换时,隐藏主界面
|
||||||
// m_vpnTrayIcon->setIcon(QIcon::fromTheme("network-wired-connected-symbolic"));
|
hideMainwindow();
|
||||||
// m_iconStatus = IconActiveType::LAN_CONNECTED;
|
}
|
||||||
// } else {
|
|
||||||
// m_vpnTrayIcon->setIcon(QIcon::fromTheme("network-wired-disconnected-symbolic"));
|
|
||||||
// m_iconStatus = IconActiveType::NOT_CONNECTED;
|
|
||||||
// }
|
|
||||||
|
|
||||||
NetworkManager::Connectivity connecttivity;
|
void vpnMainWindow::onShowMainWindow()
|
||||||
if (connecttivity != NetworkManager::Connectivity::Full) {
|
{
|
||||||
if (m_iconStatus == IconActiveType::LAN_CONNECTED) {
|
if(QApplication::activeWindow() != this) {
|
||||||
m_vpnTrayIcon->setIcon(QIcon::fromTheme("network-error-symbolic"));
|
this->showMainwindow();
|
||||||
m_iconStatus = IconActiveType::LAN_CONNECTED_LIMITED;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//void vpnMainWindow::onSetTrayIconLoading()
|
/**
|
||||||
//{
|
* @brief vpnMainWindow::keyPressEvent 按esc键关闭主界面
|
||||||
// if (m_currentIconIndex > 11) {
|
* @param event
|
||||||
// m_currentIconIndex = 0;
|
*/
|
||||||
// }
|
void vpnMainWindow::keyPressEvent(QKeyEvent *event)
|
||||||
// m_vpnTrayIcon->setIcon(m_loadIcons.at(m_currentIconIndex));
|
{
|
||||||
// m_iconStatus = IconActiveType::ACTIVATING;
|
if (event->key() == Qt::Key_Escape) {
|
||||||
// m_currentIconIndex ++;
|
hideMainwindow();
|
||||||
//}
|
}
|
||||||
|
return QWidget::keyPressEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
//void MainWindow::onLanConnectStatusToChangeTrayIcon(int state)
|
/**
|
||||||
//{
|
* @brief vpnMainWindow::eventFilter 事件过滤器
|
||||||
// qDebug() << "lan state:" << state << Q_FUNC_INFO << __LINE__;
|
* @param watched
|
||||||
// if (state==1 || state==3){
|
* @param event
|
||||||
// m_lanIsLoading = true;
|
* @return
|
||||||
// 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)
|
bool vpnMainWindow::eventFilter(QObject *watched, QEvent *event)
|
||||||
{
|
{
|
||||||
if (event->type() == QEvent::ActivationChange) {
|
if (event->type() == QEvent::ActivationChange) {
|
||||||
|
@ -626,104 +452,21 @@ bool vpnMainWindow::eventFilter(QObject *watched, QEvent *event)
|
||||||
return QMainWindow::eventFilter(watched,event);
|
return QMainWindow::eventFilter(watched,event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void vpnMainWindow::getVirtualList(QMap<QString, QVector<QStringList>> &map)
|
void vpnMainWindow::getVirtualList(QVector<QStringList> &vector)
|
||||||
{
|
{
|
||||||
map.clear();
|
vector.clear();
|
||||||
if (nullptr != m_vpnPage) {
|
if (nullptr != m_vpnPage) {
|
||||||
m_vpnPage->getVirtualList(map);
|
m_vpnPage->getVirtualList(vector);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//void MainWindow::setWiredDeviceEnable(const QString& devName, bool enable)
|
//Vpn连接删除
|
||||||
//{
|
void vpnMainWindow::deleteVpn(const QString &connUuid)
|
||||||
// m_vpnPage->setWiredDeviceEnable(devName, enable);
|
{
|
||||||
//}
|
m_vpnPage->deleteVpn(connUuid);
|
||||||
//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;
|
//Vpn连接断开
|
||||||
// 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)
|
void vpnMainWindow::activateVpn(const QString& connUuid)
|
||||||
{
|
{
|
||||||
m_vpnPage->activateVpn(connUuid);
|
m_vpnPage->activateVpn(connUuid);
|
||||||
|
@ -733,3 +476,20 @@ void vpnMainWindow::deactivateVpn(const QString& connUuid)
|
||||||
m_vpnPage->deactivateVpn(connUuid);
|
m_vpnPage->deactivateVpn(connUuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void vpnMainWindow::onVpnIconVisibleChanged()
|
||||||
|
{
|
||||||
|
m_vpnTrayIcon->setVisible(m_vpnGsettings->get("visible").toBool());
|
||||||
|
}
|
||||||
|
|
||||||
|
void vpnMainWindow::initVpnIconVisible()
|
||||||
|
{
|
||||||
|
if(QGSettings::isSchemaInstalled(GSETTINGS_VPNICON_VISIBLE)) {
|
||||||
|
m_vpnGsettings = new QGSettings(GSETTINGS_VPNICON_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,22 +33,6 @@
|
||||||
#include "vpnpage.h"
|
#include "vpnpage.h"
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
|
|
||||||
#ifdef WITHKYSEC
|
|
||||||
#include <kysec/libkysec.h>
|
|
||||||
#include <kysec/status.h>
|
|
||||||
#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 VpnPage;
|
||||||
|
|
||||||
class vpnMainWindow : public QMainWindow
|
class vpnMainWindow : public QMainWindow
|
||||||
|
@ -59,37 +43,31 @@ public:
|
||||||
void showMainwindow();
|
void showMainwindow();
|
||||||
void hideMainwindow();
|
void hideMainwindow();
|
||||||
|
|
||||||
void getVirtualList(QMap<QString, QVector<QStringList>> &map);
|
void getVirtualList(QVector<QStringList> &vector);
|
||||||
|
|
||||||
// void setWiredDefaultDevice(QString deviceName);
|
|
||||||
|
|
||||||
|
//Vpn连接删除
|
||||||
|
void deleteVpn(const QString &connUuid);
|
||||||
// //有线连接断开
|
// //有线连接断开
|
||||||
void activateVpn(const QString& connUuid);
|
void activateVpn(const QString& connUuid);
|
||||||
void deactivateVpn(const QString& connUuid);
|
void deactivateVpn(const QString& connUuid);
|
||||||
|
|
||||||
// //唤起属性页 根据网卡类型 参数2 为ssid/uuid
|
void initVpnIconVisible();
|
||||||
// void showPropertyWidget(QString devName, QString ssid);
|
|
||||||
// //唤起新建有线连接界面
|
//唤起新建有线连接界面
|
||||||
// void showCreateWiredConnectWidget(const QString devName);
|
// void showCreateWiredConnectWidget(const QString devName);
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
// //设备插拔
|
void vpnAdd(QStringList info);
|
||||||
// void deviceStatusChanged();
|
|
||||||
// //设备名称变化
|
|
||||||
// void deviceNameChanged(QString oldName, QString newName, int type);
|
|
||||||
void vpnAdd(QString devName, QStringList info);
|
|
||||||
void vpnRemove(QString dbusPath);
|
void vpnRemove(QString dbusPath);
|
||||||
void vpnUpdate(QString devName, QStringList info);
|
void vpnUpdate(QStringList info);
|
||||||
void vpnActiveConnectionStateChanged(QString devName, QString uuid, int status);
|
void vpnActiveConnectionStateChanged(QString uuid, int status);
|
||||||
// void activateFailed(QString errorMessage);
|
void activateFailed(QString errorMessage);
|
||||||
// void deactivateFailed(QString errorMessage);
|
void deactivateFailed(QString errorMessage);
|
||||||
void mainWindowVisibleChanged(const bool &visible);
|
void mainWindowVisibleChanged(const bool &visible);
|
||||||
// //列表排序
|
|
||||||
// void timeToUpdate();
|
|
||||||
public Q_SLOTS:
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// void keyPressEvent(QKeyEvent *event);
|
void keyPressEvent(QKeyEvent *event);
|
||||||
bool eventFilter(QObject *watched, QEvent *event) override;
|
bool eventFilter(QObject *watched, QEvent *event) override;
|
||||||
void paintEvent(QPaintEvent *event);
|
void paintEvent(QPaintEvent *event);
|
||||||
|
|
||||||
|
@ -105,23 +83,16 @@ private:
|
||||||
void initUI();
|
void initUI();
|
||||||
void initDbusConnnect();
|
void initDbusConnnect();
|
||||||
void initTrayIcon();
|
void initTrayIcon();
|
||||||
// void resetTrayIconTool();
|
|
||||||
void initWindowTheme();
|
void initWindowTheme();
|
||||||
// void resetWindowTheme();
|
|
||||||
// void showControlCenter();
|
|
||||||
void showByWaylandHelper();
|
void showByWaylandHelper();
|
||||||
void setCentralWidgetType(IconActiveType iconStatus);
|
|
||||||
void getTabletMode();
|
void getTabletMode();
|
||||||
|
|
||||||
double m_transparency=1.0; //透明度
|
double m_transparency=1.0; //透明度
|
||||||
QGSettings * m_transGsettings; //透明度配置文件
|
QGSettings * m_transGsettings; //透明度配置文件
|
||||||
int m_currentIconIndex = 0;
|
QGSettings * m_vpnGsettings; //VPN配置文件
|
||||||
QList<QIcon> m_loadIcons;
|
|
||||||
QTimer *m_iconTimer = nullptr;
|
|
||||||
|
|
||||||
// //主窗口的主要构成控件
|
// //主窗口的主要构成控件
|
||||||
QWidget * m_vpnWidget = nullptr;
|
QWidget * m_vpnWidget = nullptr;
|
||||||
// QHBoxLayout * m_tabBarLayout = nullptr;
|
|
||||||
QLabel * m_lanLabel = nullptr;
|
|
||||||
VpnPage * m_vpnPage = nullptr;
|
VpnPage * m_vpnPage = nullptr;
|
||||||
QVBoxLayout * m_vpnLayout = nullptr;
|
QVBoxLayout * m_vpnLayout = nullptr;
|
||||||
|
|
||||||
|
@ -135,34 +106,22 @@ private:
|
||||||
// //托盘图标,托盘图标右键菜单
|
// //托盘图标,托盘图标右键菜单
|
||||||
QSystemTrayIcon * m_vpnTrayIcon = nullptr;
|
QSystemTrayIcon * m_vpnTrayIcon = nullptr;
|
||||||
QMenu * m_vpnTrayIconMenu = nullptr;
|
QMenu * m_vpnTrayIconMenu = nullptr;
|
||||||
// QAction * m_showMainwindowAction = nullptr;
|
|
||||||
// QAction * m_showSettingsAction = nullptr;
|
|
||||||
|
|
||||||
// bool m_lanIsLoading = false;
|
|
||||||
|
|
||||||
bool m_isShowInCenter = false;
|
bool m_isShowInCenter = false;
|
||||||
|
|
||||||
IconActiveType m_iconStatus = IconActiveType::NOT_CONNECTED;
|
IconActiveType m_iconStatus = IconActiveType::NOT_CONNECTED;
|
||||||
|
|
||||||
QMap<QString, NetDetail*> m_createPagePtrMap;
|
QMap<QString, NetDetail*> m_createPagePtrMap;
|
||||||
//// QMap<QString, NetDetail*> m_addOtherPagePtrMap;
|
|
||||||
// QMap<QString, JoinHiddenWiFiPage*> m_addOtherPagePtrMap;
|
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
// void onShowMainWindow(int type);
|
void onShowMainWindow();
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void onTransChanged();
|
void onTransChanged();
|
||||||
void onTrayIconActivated(QSystemTrayIcon::ActivationReason reason);
|
void onTrayIconActivated(QSystemTrayIcon::ActivationReason reason);
|
||||||
// void onShowMainwindowActionTriggled();
|
|
||||||
// void onShowSettingsActionTriggled();
|
|
||||||
void onThemeChanged(const QString &key);
|
void onThemeChanged(const QString &key);
|
||||||
void onRefreshTrayIcon();
|
void onTabletModeChanged(bool mode);
|
||||||
// void onSetTrayIconLoading();
|
void onVpnIconVisibleChanged();
|
||||||
// void onLanConnectStatusToChangeTrayIcon(int state);
|
|
||||||
// void onWlanConnectStatusToChangeTrayIcon(int state);
|
|
||||||
// void onConnectivityChanged(NetworkManager::Connectivity connectivity);
|
|
||||||
// void onTabletModeChanged(bool mode);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MAINWINDOW_H
|
#endif // MAINWINDOW_H
|
||||||
|
|
10
src/main.cpp
10
src/main.cpp
|
@ -19,6 +19,7 @@
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "vpnmainwindow.h"
|
#include "vpnmainwindow.h"
|
||||||
#include "dbusadaptor.h"
|
#include "dbusadaptor.h"
|
||||||
|
#include "vpndbusadaptor.h"
|
||||||
#include <QTranslator>
|
#include <QTranslator>
|
||||||
#include <QLocale>
|
#include <QLocale>
|
||||||
#include "qt-single-application.h"
|
#include "qt-single-application.h"
|
||||||
|
@ -80,7 +81,7 @@ void messageOutput(QtMsgType type, const QMessageLogContext &context, const QStr
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
initUkuiLog4qt("kylin-nm");
|
// initUkuiLog4qt("kylin-nm");
|
||||||
|
|
||||||
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||||
QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
|
QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
|
||||||
|
@ -169,8 +170,13 @@ int main(int argc, char *argv[])
|
||||||
DbusAdaptor adaptor(&w);
|
DbusAdaptor adaptor(&w);
|
||||||
Q_UNUSED(adaptor);
|
Q_UNUSED(adaptor);
|
||||||
|
|
||||||
|
VpnDbusAdaptor vpnAdaptor(&vpnwindow);
|
||||||
|
Q_UNUSED(vpnAdaptor);
|
||||||
|
|
||||||
auto connection = QDBusConnection::sessionBus();
|
auto connection = QDBusConnection::sessionBus();
|
||||||
if (!connection.registerService("com.kylin.network") || !connection.registerObject("/com/kylin/network", &w)) {
|
if (!connection.registerService("com.kylin.network")
|
||||||
|
|| !connection.registerObject("/com/kylin/network", &w)
|
||||||
|
|| !connection.registerObject("/com/kylin/vpnTool", &vpnwindow)) {
|
||||||
qCritical() << "QDbus register service failed reason:" << connection.lastError();
|
qCritical() << "QDbus register service failed reason:" << connection.lastError();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,4 +11,11 @@
|
||||||
<description>Wired switch.true is open,false is close.</description>
|
<description>Wired switch.true is open,false is close.</description>
|
||||||
</key>
|
</key>
|
||||||
</schema>
|
</schema>
|
||||||
|
<schema id="org.ukui.kylin-nm.vpnicon" path="/org/ukui/kylin-nm/vpnicon/">
|
||||||
|
<key type="b" name="visible">
|
||||||
|
<default>false</default>
|
||||||
|
<summary>vpnicon visible</summary>
|
||||||
|
<description>vpnicon visible.true is visible,false is invisible.</description>
|
||||||
|
</key>
|
||||||
|
</schema>
|
||||||
</schemalist>
|
</schemalist>
|
||||||
|
|
Loading…
Reference in New Issue