新增VPN dbus接口,删除多余代码
This commit is contained in:
parent
1cf2aeb8ca
commit
dfd834fafb
|
@ -4,6 +4,7 @@ include(dbus-interface/dbus-interface.pri)
|
|||
|
||||
HEADERS += \
|
||||
$$PWD/dbusadaptor.h \
|
||||
$$PWD/vpndbusadaptor.h \
|
||||
$$PWD/kylinarping.h \
|
||||
$$PWD/kylinipv4arping.h \
|
||||
$$PWD/kylinipv6arping.h \
|
||||
|
@ -13,6 +14,7 @@ HEADERS += \
|
|||
|
||||
SOURCES += \
|
||||
$$PWD/dbusadaptor.cpp \
|
||||
$$PWD/vpndbusadaptor.cpp \
|
||||
$$PWD/kylinipv4arping.cpp \
|
||||
$$PWD/kylinipv6arping.cpp \
|
||||
$$PWD/sysdbusregister.cpp \
|
||||
|
|
|
@ -0,0 +1,73 @@
|
|||
/*
|
||||
* 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> >();
|
||||
qDBusRegisterMetaType<QMap<QString, QVector<QStringList> >>();
|
||||
//setAutoRelaySignals(true)后会自动转发mainwindow发出的同名信号,因此不必再额外写一个转发
|
||||
setAutoRelaySignals(true);
|
||||
}
|
||||
|
||||
VpnDbusAdaptor::~VpnDbusAdaptor()
|
||||
{
|
||||
// destructor
|
||||
}
|
||||
|
||||
//虚拟连接列表
|
||||
QMap<QString, QVector<QStringList>> VpnDbusAdaptor::getVirtualList()
|
||||
{
|
||||
QMap<QString, QVector<QStringList>> map;
|
||||
parent()->getVirtualList(map);
|
||||
return map;
|
||||
}
|
||||
|
||||
//删除
|
||||
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
|
||||
//虚拟连接列表
|
||||
QMap<QString, 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
|
|
@ -107,10 +107,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()
|
||||
{
|
||||
if (m_vpnConnectItem.m_connectUuid.isEmpty()) {
|
||||
qDebug()<<"--cxc--"<<Q_FUNC_INFO<<__LINE__;
|
||||
qDebug() << LOG_FLAG << "connect is empty, so can not connect or disconnect.";
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -45,6 +45,8 @@ public:
|
|||
QString getConnectionPath();
|
||||
void updateConnectionPath(QString connectionPath);
|
||||
|
||||
void activeConnection();
|
||||
|
||||
protected:
|
||||
void setIcon(bool isOn);
|
||||
void onRightButtonClicked();
|
||||
|
|
|
@ -44,7 +44,7 @@ VpnPage::VpnPage(QWidget *parent) : SinglePage(parent)
|
|||
m_activeResourse = new KyActiveConnectResourse(this);
|
||||
m_connectResourse = new KyConnectResourse(this);
|
||||
// m_deviceResource = new KyNetworkDeviceResourse(this);
|
||||
// m_wiredConnectOperation = new KyWiredConnectOperation(this);
|
||||
m_wiredConnectOperation = new KyWiredConnectOperation(this);
|
||||
|
||||
initUI();
|
||||
initVpnArea();
|
||||
|
@ -58,8 +58,8 @@ VpnPage::VpnPage(QWidget *parent) : SinglePage(parent)
|
|||
connect(m_connectResourse, &KyConnectResourse::connectionRemove, this, &VpnPage::onRemoveConnection);
|
||||
connect(m_connectResourse, &KyConnectResourse::connectionUpdate, this, &VpnPage::onUpdateConnection);
|
||||
|
||||
// connect(m_wiredConnectOperation, &KyWiredConnectOperation::activateConnectionError, this, &VpnPage::activateFailed);
|
||||
// connect(m_wiredConnectOperation, &KyWiredConnectOperation::deactivateConnectionError, this, &VpnPage::deactivateFailed);
|
||||
connect(m_wiredConnectOperation, &KyWiredConnectOperation::activateConnectionError, this, &VpnPage::activateFailed);
|
||||
connect(m_wiredConnectOperation, &KyWiredConnectOperation::deactivateConnectionError, this, &VpnPage::deactivateFailed);
|
||||
}
|
||||
|
||||
VpnPage::~VpnPage()
|
||||
|
@ -127,14 +127,12 @@ void VpnPage::constructActiveConnectionArea()
|
|||
KyConnectItem *p_netConnectionItem = netList.at(index);
|
||||
p_newItem = m_activeResourse->getActiveConnectionByUuid(p_netConnectionItem->m_connectUuid);
|
||||
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)) {
|
||||
qDebug()<<LOG_FLAG << "has contain uuid" << p_netConnectionItem->m_connectUuid;
|
||||
}
|
||||
QListWidgetItem *p_listWidgetItem = addNewItem(p_netConnectionItem, m_vpnListWidget);
|
||||
m_netConnectionMap.insert(p_netConnectionItem->m_connectUuid, p_listWidgetItem);
|
||||
} 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)) {
|
||||
qDebug()<<LOG_FLAG << "has contain uuid" << p_netConnectionItem->m_connectUuid;
|
||||
}
|
||||
|
@ -155,43 +153,10 @@ void VpnPage::constructActiveConnectionArea()
|
|||
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) {
|
||||
m_vpnListWidget->setFixedWidth(MIN_WIDTH);
|
||||
} else {
|
||||
m_vpnListWidget->setFixedWidth(MAX_WIDTH);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void VpnPage::initVpnArea()
|
||||
{
|
||||
m_netFrame->show();
|
||||
constructActiveConnectionArea();
|
||||
// constructConnectionArea();
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -394,7 +359,6 @@ void VpnPage::onConnectionStateChange(QString uuid,
|
|||
NetworkManager::ActiveConnection::State state,
|
||||
NetworkManager::ActiveConnection::Reason reason)
|
||||
{
|
||||
qDebug()<<"--cxc--"<<Q_FUNC_INFO<<__LINE__<<uuid<<state<<reason;
|
||||
//VpnPage函数内持续监听连接状态的变化并记录供其他函数调用获取状态
|
||||
if (!m_connectResourse->isVirtualConncection(uuid)) {
|
||||
qDebug() << "[VpnPage] connection state change signal but not wired";
|
||||
|
@ -404,7 +368,6 @@ void VpnPage::onConnectionStateChange(QString uuid,
|
|||
sendVpnStateChangeSignal(uuid, (ConnectState)state);
|
||||
|
||||
if (m_activeConnectionMap.keys().contains(uuid) && state == NetworkManager::ActiveConnection::State::Activated) {
|
||||
qDebug()<<"--cxc--"<<Q_FUNC_INFO<<__LINE__<<uuid<<state;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -443,7 +406,7 @@ void VpnPage::onConnectionStateChange(QString uuid,
|
|||
updateConnectionState(m_activeConnectionMap, m_vpnListWidget, uuid, (ConnectState)state);
|
||||
}
|
||||
|
||||
Q_EMIT vpnActiveConnectionStateChanged(deviceName, uuid, state);
|
||||
Q_EMIT vpnActiveConnectionStateChanged(uuid, state);
|
||||
|
||||
if (p_newItem) {
|
||||
delete p_newItem;
|
||||
|
@ -473,7 +436,7 @@ void VpnPage::sendVpnUpdateSignal(KyConnectItem *p_connectItem)
|
|||
{
|
||||
QStringList info;
|
||||
info << p_connectItem->m_connectName << p_connectItem->m_connectUuid << p_connectItem->m_connectPath;
|
||||
Q_EMIT vpnUpdate(p_connectItem->m_ifaceName, info);
|
||||
Q_EMIT vpnUpdate(info);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -483,7 +446,7 @@ void VpnPage::sendVpnAddSignal(KyConnectItem *p_connectItem)
|
|||
QStringList info;
|
||||
info << p_connectItem->m_connectName << p_connectItem->m_connectUuid << p_connectItem->m_connectPath;
|
||||
qDebug() << "[VpnPage] emit vpnAdd because addConnection ";
|
||||
Q_EMIT vpnAdd(p_connectItem->m_ifaceName, info);
|
||||
Q_EMIT vpnAdd(info);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -600,22 +563,28 @@ bool VpnPage::eventFilter(QObject *watched, QEvent *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)
|
||||
{
|
||||
// qDebug() << "[VpnPage] activateVpn" << connUuid;
|
||||
// if (!m_deviceResource->wiredDeviceIsCarriered(devName)) {
|
||||
// qDebug() << LOG_FLAG << devName << "is not carried, so can not activate connection";
|
||||
// this->showDesktopNotify(tr("Wired Device not carried"), "networkwrong");
|
||||
// } else {
|
||||
// m_wiredConnectOperation->activateConnection(connUuid, devName);
|
||||
// }
|
||||
if (m_netConnectionMap.contains(connUuid)) {
|
||||
qDebug() << "[VpnPage] activateVpn" << connUuid;
|
||||
m_wiredConnectOperation->activateVpnConnection(connUuid);
|
||||
}
|
||||
}
|
||||
|
||||
void VpnPage::deactivateVpn(const QString& connUuid)
|
||||
{
|
||||
qDebug() << "[VpnPage] deactivateVpn" << connUuid;
|
||||
QString name("");
|
||||
// m_wiredConnectOperation->deactivateWiredConnection(name, connUuid);
|
||||
m_wiredConnectOperation->deactivateWiredConnection(name, connUuid);
|
||||
}
|
||||
|
||||
void VpnPage::showDetailPage(QString devName, QString uuid)
|
||||
|
@ -646,13 +615,3 @@ void VpnPage::showDetailPage(QString devName, QString uuid)
|
|||
p_item = nullptr;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool VpnPage::vpnIsConnected()
|
||||
{
|
||||
if (m_activeResourse->wiredConnectIsActived()) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -46,12 +46,11 @@ public:
|
|||
|
||||
//for dbus
|
||||
void getVirtualList(QMap<QString, QVector<QStringList> > &map);
|
||||
void deleteVpn(const QString &connUuid);
|
||||
void activateVpn(const QString& connUuid);
|
||||
void deactivateVpn(const QString& connUuid);
|
||||
void showDetailPage(QString devName, QString uuid);
|
||||
|
||||
bool vpnIsConnected();
|
||||
|
||||
protected:
|
||||
bool eventFilter(QObject *watched, QEvent *event);
|
||||
|
||||
|
@ -87,11 +86,11 @@ private:
|
|||
QListWidget *lanListWidget, QString uuid);
|
||||
|
||||
Q_SIGNALS:
|
||||
void vpnAdd(QString devName, QStringList info);
|
||||
void vpnAdd(QStringList info);
|
||||
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);
|
||||
|
||||
private Q_SLOTS:
|
||||
|
@ -110,7 +109,7 @@ private:
|
|||
QListWidget * m_vpnListWidget = nullptr;
|
||||
|
||||
// KyNetworkDeviceResourse *m_deviceResource = nullptr;
|
||||
// KyWiredConnectOperation *m_wiredConnectOperation = nullptr;
|
||||
KyWiredConnectOperation *m_wiredConnectOperation = nullptr;
|
||||
KyActiveConnectResourse *m_activeResourse = nullptr; //激活的连接
|
||||
KyConnectResourse *m_connectResourse = nullptr; //未激活的连接
|
||||
|
||||
|
|
|
@ -93,7 +93,7 @@ void vpnMainWindow::showMainwindow()
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief MainWindow::hideMainwindow 隐藏主页面时要进行的操作,后续可以添加到此函数
|
||||
* @brief vpnMainWindow::hideMainwindow 隐藏主页面时要进行的操作,后续可以添加到此函数
|
||||
*/
|
||||
void vpnMainWindow::hideMainwindow()
|
||||
{
|
||||
|
@ -102,9 +102,9 @@ void vpnMainWindow::hideMainwindow()
|
|||
}
|
||||
|
||||
///**
|
||||
// * @brief MainWindow::setWiredDefaultDevice 设置有线设备默认网卡
|
||||
// * @brief vpnMainWindow::setWiredDefaultDevice 设置有线设备默认网卡
|
||||
// */
|
||||
//void MainWindow::setWiredDefaultDevice(QString deviceName)
|
||||
//void vpnMainWindow::setWiredDefaultDevice(QString deviceName)
|
||||
//{
|
||||
//// m_vpnPage->updateDefaultDevice(deviceName);
|
||||
//}
|
||||
|
@ -170,6 +170,7 @@ void vpnMainWindow::initWindowProperties()
|
|||
// this->setFixedSize(MAINWINDOW_WIDTH, MAINWINDOW_HEIGHT);
|
||||
// //绘制毛玻璃特效
|
||||
// this->setAttribute(Qt::WA_TranslucentBackground, true); //透明
|
||||
this->setProperty("needTranslucent", true);
|
||||
this->setFocusPolicy(Qt::NoFocus);
|
||||
|
||||
QString platform = QGuiApplication::platformName();
|
||||
|
@ -188,8 +189,6 @@ void vpnMainWindow::paintEvent(QPaintEvent *event)
|
|||
QPainter painter(this);
|
||||
painter.setRenderHint(QPainter::Antialiasing); // 反锯齿;
|
||||
painter.setPen(Qt::transparent);
|
||||
// auto rect = this->rect();
|
||||
// painter.drawRoundedRect(rect, 12, 12); //窗口圆角
|
||||
}
|
||||
|
||||
void vpnMainWindow::initTransparency()
|
||||
|
@ -244,44 +243,27 @@ void vpnMainWindow::initUI()
|
|||
void vpnMainWindow::initTrayIcon()
|
||||
{
|
||||
m_vpnTrayIcon = new QSystemTrayIcon(this);
|
||||
m_vpnTrayIconMenu = new QMenu();
|
||||
// m_showMainwindowAction = new QAction(tr("Show MainWindow"),this);
|
||||
// m_showSettingsAction = new QAction(tr("Settings"),this);
|
||||
|
||||
m_vpnTrayIcon->setToolTip(QString(tr("vpn tool")));
|
||||
m_vpnTrayIcon->setIcon(QIcon::fromTheme("ukui-vpn-symbolic"));
|
||||
// m_showSettingsAction->setIcon(QIcon::fromTheme("document-page-setup-symbolic", QIcon(":/res/x/setup.png")) );
|
||||
//// m_vpnTrayIconMenu->addAction(m_showMainwindowAction);
|
||||
// m_vpnTrayIconMenu->addAction(m_showSettingsAction);
|
||||
// m_vpnTrayIcon->setContextMenu(m_vpnTrayIconMenu);
|
||||
// m_vpnTrayIcon->setIcon(QIcon::fromTheme("network-wired-signal-excellent-symbolic"));
|
||||
// m_iconStatus = IconActiveType::LAN_CONNECTED;
|
||||
// onRefreshTrayIcon();
|
||||
|
||||
initVpnIconVisible();
|
||||
connect(m_vpnTrayIcon, &QSystemTrayIcon::activated, this, &vpnMainWindow::onTrayIconActivated);
|
||||
//// connect(m_showMainwindowAction, &QAction::triggered, this, &MainWindow::onShowMainwindowActionTriggled);
|
||||
// connect(m_showSettingsAction, &QAction::triggered, this, &MainWindow::onShowSettingsActionTriggled);
|
||||
m_vpnTrayIcon->show();
|
||||
}
|
||||
|
||||
void vpnMainWindow::initDbusConnnect()
|
||||
{
|
||||
// connect(m_vpnPage, &LanPage::deviceStatusChanged, this, &MainWindow::deviceStatusChanged);
|
||||
// connect(m_vpnPage, &LanPage::deviceNameChanged, this, &MainWindow::deviceNameChanged);
|
||||
// connect(m_vpnPage, &LanPage::activateFailed, this, &MainWindow::activateFailed);
|
||||
// connect(m_vpnPage, &LanPage::deactivateFailed, this, &MainWindow::deactivateFailed);
|
||||
connect(m_vpnPage, &VpnPage::activateFailed, this, &vpnMainWindow::activateFailed);
|
||||
connect(m_vpnPage, &VpnPage::deactivateFailed, this, &vpnMainWindow::deactivateFailed);
|
||||
|
||||
connect(m_vpnPage, &VpnPage::vpnAdd, this, &vpnMainWindow::vpnAdd);
|
||||
connect(m_vpnPage, &VpnPage::vpnRemove, this, &vpnMainWindow::vpnRemove);
|
||||
connect(m_vpnPage, &VpnPage::vpnUpdate, this, &vpnMainWindow::vpnUpdate);
|
||||
connect(m_vpnPage, &VpnPage::vpnActiveConnectionStateChanged, this, &vpnMainWindow::vpnActiveConnectionStateChanged);
|
||||
// connect(m_vpnPage, &LanPage::lanConnectChanged, this, &MainWindow::onLanConnectStatusToChangeTrayIcon);
|
||||
|
||||
// //模式切换
|
||||
// QDBusConnection::sessionBus().connect(QString("com.kylin.statusmanager.interface"),
|
||||
// QString("/"),
|
||||
// QString("com.kylin.statusmanager.interface"),
|
||||
// QString("mode_change_signal"), this, SLOT(onTabletModeChanged(bool)));
|
||||
//模式切换
|
||||
QDBusConnection::sessionBus().connect(QString("com.kylin.statusmanager.interface"),
|
||||
QString("/"),
|
||||
QString("com.kylin.statusmanager.interface"),
|
||||
QString("mode_change_signal"), this, SLOT(onTabletModeChanged(bool)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -350,31 +332,6 @@ void vpnMainWindow::resetWindowPosition()
|
|||
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 初始化窗口主题并创建信号槽
|
||||
*/
|
||||
|
@ -390,29 +347,9 @@ void vpnMainWindow::initWindowTheme()
|
|||
}
|
||||
|
||||
///**
|
||||
// * @brief MainWindow::resetWindowTheme 读取和设置窗口主题
|
||||
// * @brief vpnMainWindow::showControlCenter 打开控制面板网络界面
|
||||
// */
|
||||
//void MainWindow::resetWindowTheme()
|
||||
//{
|
||||
// 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()
|
||||
//void vpnMainWindow::showControlCenter()
|
||||
//{
|
||||
// QProcess process;
|
||||
// if (!m_vpnPage->lanIsConnected() && m_wlanWidget->checkWlanStatus(NetworkManager::ActiveConnection::State::Activated)){
|
||||
|
@ -433,21 +370,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()
|
||||
{
|
||||
QDBusInterface interface(QString("com.kylin.statusmanager.interface"),
|
||||
|
@ -471,11 +393,10 @@ void vpnMainWindow::getTabletMode()
|
|||
*/
|
||||
void vpnMainWindow::onTrayIconActivated(QSystemTrayIcon::ActivationReason reason)
|
||||
{
|
||||
setCentralWidgetType(m_iconStatus);
|
||||
switch(reason) {
|
||||
case QSystemTrayIcon::Context:
|
||||
m_vpnTrayIconMenu->popup(QCursor::pos());
|
||||
break;
|
||||
// case QSystemTrayIcon::Context:
|
||||
// m_vpnTrayIconMenu->popup(QCursor::pos());
|
||||
// break;
|
||||
case QSystemTrayIcon::Trigger:
|
||||
if (this->isVisible()) {
|
||||
qDebug() << "Received signal of tray icon activated, will hide mainwindow." << Q_FUNC_INFO << __LINE__;
|
||||
|
@ -489,29 +410,8 @@ void vpnMainWindow::onTrayIconActivated(QSystemTrayIcon::ActivationReason reason
|
|||
default:
|
||||
break;
|
||||
}
|
||||
// if (reason == QSystemTrayIcon::ActivationReason::Context) {
|
||||
// m_vpnTrayIconMenu->popup(QCursor::pos());
|
||||
// } else {
|
||||
// if (this->isVisible()) {
|
||||
// qDebug() << "Received signal of tray icon activated, will hide mainwindow." << Q_FUNC_INFO << __LINE__;
|
||||
// hideMainwindow();
|
||||
// return;
|
||||
// }
|
||||
// qDebug() << "Received signal of tray icon activated, will show mainwindow." << Q_FUNC_INFO << __LINE__;
|
||||
// this->showMainwindow();
|
||||
// }
|
||||
}
|
||||
|
||||
//void MainWindow::onShowMainwindowActionTriggled()
|
||||
//{
|
||||
// showMainwindow();
|
||||
//}
|
||||
|
||||
//void MainWindow::onShowSettingsActionTriggled()
|
||||
//{
|
||||
// showControlCenter();
|
||||
//}
|
||||
|
||||
void vpnMainWindow::onThemeChanged(const QString &key)
|
||||
{
|
||||
if (key == COLOR_THEME) {
|
||||
|
@ -523,99 +423,39 @@ void vpnMainWindow::onThemeChanged(const QString &key)
|
|||
}
|
||||
}
|
||||
|
||||
void vpnMainWindow::onRefreshTrayIcon()
|
||||
void vpnMainWindow::onTabletModeChanged(bool mode)
|
||||
{
|
||||
//更新托盘图标显示
|
||||
// m_iconTimer->stop();
|
||||
// if (m_vpnPage->lanIsConnected()) {
|
||||
// m_vpnTrayIcon->setIcon(QIcon::fromTheme("network-wired-connected-symbolic"));
|
||||
// m_iconStatus = IconActiveType::LAN_CONNECTED;
|
||||
// } else {
|
||||
// m_vpnTrayIcon->setIcon(QIcon::fromTheme("network-wired-disconnected-symbolic"));
|
||||
// m_iconStatus = IconActiveType::NOT_CONNECTED;
|
||||
// }
|
||||
qDebug() << "TabletMode change" << mode;
|
||||
Q_UNUSED(mode)
|
||||
//模式切换时,隐藏主界面
|
||||
hideMainwindow();
|
||||
}
|
||||
|
||||
NetworkManager::Connectivity connecttivity;
|
||||
if (connecttivity != NetworkManager::Connectivity::Full) {
|
||||
if (m_iconStatus == IconActiveType::LAN_CONNECTED) {
|
||||
m_vpnTrayIcon->setIcon(QIcon::fromTheme("network-error-symbolic"));
|
||||
m_iconStatus = IconActiveType::LAN_CONNECTED_LIMITED;
|
||||
}
|
||||
void vpnMainWindow::onShowMainWindow()
|
||||
{
|
||||
if(QApplication::activeWindow() != this) {
|
||||
this->showMainwindow();
|
||||
}
|
||||
}
|
||||
|
||||
//void vpnMainWindow::onSetTrayIconLoading()
|
||||
//{
|
||||
// if (m_currentIconIndex > 11) {
|
||||
// m_currentIconIndex = 0;
|
||||
// }
|
||||
// m_vpnTrayIcon->setIcon(m_loadIcons.at(m_currentIconIndex));
|
||||
// m_iconStatus = IconActiveType::ACTIVATING;
|
||||
// m_currentIconIndex ++;
|
||||
//}
|
||||
/**
|
||||
* @brief vpnMainWindow::keyPressEvent 按esc键关闭主界面
|
||||
* @param event
|
||||
*/
|
||||
void vpnMainWindow::keyPressEvent(QKeyEvent *event)
|
||||
{
|
||||
if (event->key() == Qt::Key_Escape) {
|
||||
hideMainwindow();
|
||||
}
|
||||
return QWidget::keyPressEvent(event);
|
||||
}
|
||||
|
||||
//void MainWindow::onLanConnectStatusToChangeTrayIcon(int state)
|
||||
//{
|
||||
// qDebug() << "lan state:" << state << Q_FUNC_INFO << __LINE__;
|
||||
// if (state==1 || state==3){
|
||||
// m_lanIsLoading = true;
|
||||
// m_iconTimer->start(LOADING_TRAYICON_TIMER_MS);
|
||||
// } else {
|
||||
// m_lanIsLoading = false;
|
||||
// if (m_wlanIsLoading == false) {
|
||||
// onRefreshTrayIcon();
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
//void MainWindow::onTabletModeChanged(bool mode)
|
||||
//{
|
||||
// qDebug() << "TabletMode change" << mode;
|
||||
// Q_UNUSED(mode)
|
||||
// //模式切换时,隐藏主界面
|
||||
// hideMainwindow();
|
||||
//}
|
||||
|
||||
//void MainWindow::onShowMainWindow(int type)
|
||||
//{
|
||||
// m_vpnWidget->setCurrentIndex(type);
|
||||
|
||||
// if(QApplication::activeWindow() != this) {
|
||||
// this->showMainwindow();
|
||||
// }
|
||||
//}
|
||||
|
||||
//void MainWindow::onConnectivityChanged(NetworkManager::Connectivity connectivity)
|
||||
//{
|
||||
// if (!m_vpnTrayIcon) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
// if (m_iconStatus == ACTIVATING) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
// onRefreshTrayIcon();
|
||||
//}
|
||||
|
||||
///**
|
||||
// * @brief MainWindow::keyPressEvent 按esc键关闭主界面
|
||||
// * @param event
|
||||
// */
|
||||
//void MainWindow::keyPressEvent(QKeyEvent *event)
|
||||
//{
|
||||
// if (event->key() == Qt::Key_Escape) {
|
||||
// hideMainwindow();
|
||||
// }
|
||||
// return QWidget::keyPressEvent(event);
|
||||
//}
|
||||
|
||||
///**
|
||||
// * @brief MainWindow::eventFilter 事件过滤器
|
||||
// * @param watched
|
||||
// * @param event
|
||||
// * @return
|
||||
// */
|
||||
/**
|
||||
* @brief vpnMainWindow::eventFilter 事件过滤器
|
||||
* @param watched
|
||||
* @param event
|
||||
* @return
|
||||
*/
|
||||
bool vpnMainWindow::eventFilter(QObject *watched, QEvent *event)
|
||||
{
|
||||
if (event->type() == QEvent::ActivationChange) {
|
||||
|
@ -634,96 +474,13 @@ void vpnMainWindow::getVirtualList(QMap<QString, QVector<QStringList>> &map)
|
|||
}
|
||||
}
|
||||
|
||||
//void MainWindow::setWiredDeviceEnable(const QString& devName, bool enable)
|
||||
//{
|
||||
// m_vpnPage->setWiredDeviceEnable(devName, enable);
|
||||
//}
|
||||
//void MainWindow::showPropertyWidget(QString devName, QString ssid)
|
||||
//{
|
||||
// KyNetworkDeviceResourse *devResourse = new KyNetworkDeviceResourse();
|
||||
// QStringList wiredDeviceList;
|
||||
// wiredDeviceList.clear();
|
||||
// devResourse->getNetworkDeviceList(NetworkManager::Device::Type::Ethernet, wiredDeviceList);
|
||||
// if (wiredDeviceList.contains(devName)) {
|
||||
// qDebug() << "showPropertyWidget device type wired device name " << devName << " uuid " << ssid;
|
||||
// m_vpnPage->showDetailPage(devName, ssid);
|
||||
// delete devResourse;
|
||||
// devResourse = nullptr;
|
||||
// return;
|
||||
// }
|
||||
//Vpn连接删除
|
||||
void vpnMainWindow::deleteVpn(const QString &connUuid)
|
||||
{
|
||||
m_vpnPage->deleteVpn(connUuid);
|
||||
}
|
||||
|
||||
// QStringList wirelessDeviceList;
|
||||
// wirelessDeviceList.clear();
|
||||
// devResourse->getNetworkDeviceList(NetworkManager::Device::Type::Wifi, wirelessDeviceList);
|
||||
// if (wirelessDeviceList.contains(devName)) {
|
||||
// qDebug() << "showPropertyWidget device type wireless device name " << devName << " ssid " << ssid;
|
||||
// m_wlanWidget->showDetailPage(devName, ssid);
|
||||
// delete devResourse;
|
||||
// devResourse = nullptr;
|
||||
// return;
|
||||
// }
|
||||
|
||||
// qWarning() << "showPropertyWidget no such device " << devName;
|
||||
// delete devResourse;
|
||||
// devResourse = nullptr;
|
||||
//}
|
||||
|
||||
//void MainWindow::showCreateWiredConnectWidget(const QString devName)
|
||||
//{
|
||||
// qDebug() << "showCreateWiredConnectWidget! devName = " << devName;
|
||||
// if (m_createPagePtrMap.contains(devName)) {
|
||||
// if (m_createPagePtrMap[devName] != nullptr) {
|
||||
// qDebug() << "showCreateWiredConnectWidget" << devName << "already create,just raise";
|
||||
|
||||
// KWindowSystem::raiseWindow(m_createPagePtrMap[devName]->winId());
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
// NetDetail *netDetail = new NetDetail(devName, "", "", false, false, true, this);
|
||||
// connect(netDetail, &NetDetail::createPageClose, [&](QString interfaceName){
|
||||
// if (m_createPagePtrMap.contains(interfaceName)) {
|
||||
// m_createPagePtrMap[interfaceName] = nullptr;
|
||||
// }
|
||||
// });
|
||||
// m_createPagePtrMap.insert(devName, netDetail);
|
||||
// netDetail->show();
|
||||
//}
|
||||
|
||||
//void MainWindow::showAddOtherWlanWidget(QString devName)
|
||||
//{
|
||||
// qDebug() << "showAddOtherWlanWidget! devName = " << devName;
|
||||
// if (m_addOtherPagePtrMap.contains(devName)) {
|
||||
// if (m_addOtherPagePtrMap[devName] != nullptr) {
|
||||
// qDebug() << "showAddOtherWlanWidget" << devName << "already create,just raise";
|
||||
|
||||
// KWindowSystem::raiseWindow(m_addOtherPagePtrMap[devName]->winId());
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
|
||||
//#if 0
|
||||
// NetDetail *netDetail = new NetDetail(devName, "", "", false, true, true, this);
|
||||
// connect(netDetail, &NetDetail::createPageClose, [&](QString interfaceName){
|
||||
// if (m_addOtherPagePtrMap.contains(interfaceName)) {
|
||||
// m_addOtherPagePtrMap[interfaceName] = nullptr;
|
||||
// }
|
||||
// });
|
||||
// m_addOtherPagePtrMap.insert(devName, netDetail);
|
||||
// netDetail->show();
|
||||
//#endif
|
||||
|
||||
// JoinHiddenWiFiPage *hiddenWiFi =new JoinHiddenWiFiPage(devName);
|
||||
// connect(hiddenWiFi, &JoinHiddenWiFiPage::hiddenWiFiPageClose, [&](QString interfaceName){
|
||||
// if (m_addOtherPagePtrMap.contains(interfaceName)) {
|
||||
// m_addOtherPagePtrMap[interfaceName] = nullptr;
|
||||
// }
|
||||
// });
|
||||
// m_addOtherPagePtrMap.insert(devName, hiddenWiFi);
|
||||
// connect(hiddenWiFi, &JoinHiddenWiFiPage::showWlanList, this, &MainWindow::onShowMainWindow);
|
||||
// hiddenWiFi->show();
|
||||
//}
|
||||
|
||||
//有线连接断开
|
||||
//Vpn连接断开
|
||||
void vpnMainWindow::activateVpn(const QString& connUuid)
|
||||
{
|
||||
m_vpnPage->activateVpn(connUuid);
|
||||
|
@ -733,3 +490,20 @@ void vpnMainWindow::deactivateVpn(const QString& 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,21 +33,7 @@
|
|||
#include "vpnpage.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";
|
||||
const QByteArray GSETTINGS_VPNICON_VISIBLE = "org.ukui.kylin-nm.vpnicon";
|
||||
|
||||
class VpnPage;
|
||||
|
||||
|
@ -61,35 +47,29 @@ public:
|
|||
|
||||
void getVirtualList(QMap<QString, QVector<QStringList>> &map);
|
||||
|
||||
// void setWiredDefaultDevice(QString deviceName);
|
||||
|
||||
//Vpn连接删除
|
||||
void deleteVpn(const QString &connUuid);
|
||||
// //有线连接断开
|
||||
void activateVpn(const QString& connUuid);
|
||||
void deactivateVpn(const QString& connUuid);
|
||||
|
||||
// //唤起属性页 根据网卡类型 参数2 为ssid/uuid
|
||||
// void showPropertyWidget(QString devName, QString ssid);
|
||||
// //唤起新建有线连接界面
|
||||
void initVpnIconVisible();
|
||||
|
||||
//唤起新建有线连接界面
|
||||
// void showCreateWiredConnectWidget(const QString devName);
|
||||
|
||||
Q_SIGNALS:
|
||||
// //设备插拔
|
||||
// void deviceStatusChanged();
|
||||
// //设备名称变化
|
||||
// void deviceNameChanged(QString oldName, QString newName, int type);
|
||||
void vpnAdd(QString devName, QStringList info);
|
||||
void vpnAdd(QStringList info);
|
||||
void vpnRemove(QString dbusPath);
|
||||
void vpnUpdate(QString devName, QStringList info);
|
||||
void vpnActiveConnectionStateChanged(QString devName, QString uuid, int status);
|
||||
// void activateFailed(QString errorMessage);
|
||||
// void deactivateFailed(QString errorMessage);
|
||||
void vpnUpdate(QStringList info);
|
||||
void vpnActiveConnectionStateChanged(QString uuid, int status);
|
||||
void activateFailed(QString errorMessage);
|
||||
void deactivateFailed(QString errorMessage);
|
||||
void mainWindowVisibleChanged(const bool &visible);
|
||||
// //列表排序
|
||||
// void timeToUpdate();
|
||||
public Q_SLOTS:
|
||||
|
||||
protected:
|
||||
// void keyPressEvent(QKeyEvent *event);
|
||||
void keyPressEvent(QKeyEvent *event);
|
||||
bool eventFilter(QObject *watched, QEvent *event) override;
|
||||
void paintEvent(QPaintEvent *event);
|
||||
|
||||
|
@ -105,23 +85,16 @@ private:
|
|||
void initUI();
|
||||
void initDbusConnnect();
|
||||
void initTrayIcon();
|
||||
// void resetTrayIconTool();
|
||||
void initWindowTheme();
|
||||
// void resetWindowTheme();
|
||||
// void showControlCenter();
|
||||
void showByWaylandHelper();
|
||||
void setCentralWidgetType(IconActiveType iconStatus);
|
||||
void getTabletMode();
|
||||
|
||||
double m_transparency=1.0; //透明度
|
||||
QGSettings * m_transGsettings; //透明度配置文件
|
||||
int m_currentIconIndex = 0;
|
||||
QList<QIcon> m_loadIcons;
|
||||
QTimer *m_iconTimer = nullptr;
|
||||
QGSettings * m_vpnGsettings; //VPN配置文件
|
||||
|
||||
// //主窗口的主要构成控件
|
||||
QWidget * m_vpnWidget = nullptr;
|
||||
// QHBoxLayout * m_tabBarLayout = nullptr;
|
||||
QLabel * m_lanLabel = nullptr;
|
||||
VpnPage * m_vpnPage = nullptr;
|
||||
QVBoxLayout * m_vpnLayout = nullptr;
|
||||
|
||||
|
@ -135,34 +108,22 @@ private:
|
|||
// //托盘图标,托盘图标右键菜单
|
||||
QSystemTrayIcon * m_vpnTrayIcon = nullptr;
|
||||
QMenu * m_vpnTrayIconMenu = nullptr;
|
||||
// QAction * m_showMainwindowAction = nullptr;
|
||||
// QAction * m_showSettingsAction = nullptr;
|
||||
|
||||
// bool m_lanIsLoading = false;
|
||||
|
||||
bool m_isShowInCenter = false;
|
||||
|
||||
IconActiveType m_iconStatus = IconActiveType::NOT_CONNECTED;
|
||||
|
||||
QMap<QString, NetDetail*> m_createPagePtrMap;
|
||||
//// QMap<QString, NetDetail*> m_addOtherPagePtrMap;
|
||||
// QMap<QString, JoinHiddenWiFiPage*> m_addOtherPagePtrMap;
|
||||
|
||||
public Q_SLOTS:
|
||||
// void onShowMainWindow(int type);
|
||||
void onShowMainWindow();
|
||||
|
||||
private Q_SLOTS:
|
||||
void onTransChanged();
|
||||
void onTrayIconActivated(QSystemTrayIcon::ActivationReason reason);
|
||||
// void onShowMainwindowActionTriggled();
|
||||
// void onShowSettingsActionTriggled();
|
||||
void onThemeChanged(const QString &key);
|
||||
void onRefreshTrayIcon();
|
||||
// void onSetTrayIconLoading();
|
||||
// void onLanConnectStatusToChangeTrayIcon(int state);
|
||||
// void onWlanConnectStatusToChangeTrayIcon(int state);
|
||||
// void onConnectivityChanged(NetworkManager::Connectivity connectivity);
|
||||
// void onTabletModeChanged(bool mode);
|
||||
void onTabletModeChanged(bool mode);
|
||||
void onVpnIconVisibleChanged();
|
||||
};
|
||||
|
||||
#endif // MAINWINDOW_H
|
||||
|
|
10
src/main.cpp
10
src/main.cpp
|
@ -19,6 +19,7 @@
|
|||
#include "mainwindow.h"
|
||||
#include "vpnmainwindow.h"
|
||||
#include "dbusadaptor.h"
|
||||
#include "vpndbusadaptor.h"
|
||||
#include <QTranslator>
|
||||
#include <QLocale>
|
||||
#include "qt-single-application.h"
|
||||
|
@ -80,7 +81,7 @@ void messageOutput(QtMsgType type, const QMessageLogContext &context, const QStr
|
|||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
initUkuiLog4qt("kylin-nm");
|
||||
// initUkuiLog4qt("kylin-nm");
|
||||
|
||||
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||
QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
|
||||
|
@ -169,8 +170,13 @@ int main(int argc, char *argv[])
|
|||
DbusAdaptor adaptor(&w);
|
||||
Q_UNUSED(adaptor);
|
||||
|
||||
VpnDbusAdaptor vpnAdaptor(&vpnwindow);
|
||||
Q_UNUSED(vpnAdaptor);
|
||||
|
||||
auto connection = QDBusConnection::sessionBus();
|
||||
if (!connection.registerService("com.kylin.network") || !connection.registerObject("/com/kylin/network", &w)) {
|
||||
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();
|
||||
}
|
||||
|
||||
|
|
|
@ -11,4 +11,11 @@
|
|||
<description>Wired switch.true is open,false is close.</description>
|
||||
</key>
|
||||
</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>
|
||||
|
|
Loading…
Reference in New Issue