1541 lines
68 KiB
Diff
1541 lines
68 KiB
Diff
From 48a78fb158d5f87d123ab8ff0a6358d71aa1eec2 Mon Sep 17 00:00:00 2001
|
||
From: luoqing <luoqing@kylinsec.com.cn>
|
||
Date: Fri, 19 Aug 2022 09:20:18 +0800
|
||
Subject: [PATCH 2/7] fix(network):fix crash and wireless network disable
|
||
function defects
|
||
MIME-Version: 1.0
|
||
Content-Type: text/plain; charset=UTF-8
|
||
Content-Transfer-Encoding: 8bit
|
||
|
||
- 修复网络页面与其他插件页面快速切换导致崩溃的问题
|
||
修复无线网络禁用的缺陷
|
||
---
|
||
plugins/network/src/connection-show-page.cpp | 60 +++--
|
||
plugins/network/src/connection-show-page.h | 4 +-
|
||
.../src/plugin/cpanel-network-widget.cpp | 150 +++++++-----
|
||
.../src/plugin/cpanel-network-widget.h | 11 +-
|
||
plugins/network/src/plugin/details-page.cpp | 5 +-
|
||
.../src/plugin/manager/vpn-manager.cpp | 134 +++++------
|
||
.../src/plugin/manager/wired-manager.cpp | 11 +-
|
||
.../src/plugin/manager/wireless-manager.cpp | 58 +++--
|
||
.../src/plugin/setting-widget/vpn/vpn-ppp.cpp | 6 +-
|
||
plugins/network/src/tray/network-tray.cpp | 218 ++++++++++--------
|
||
plugins/network/src/tray/network-tray.h | 2 +-
|
||
plugins/network/src/tray/tray-page.cpp | 17 +-
|
||
.../network/src/tray/wireless-tray-widget.cpp | 35 ++-
|
||
13 files changed, 392 insertions(+), 319 deletions(-)
|
||
|
||
diff --git a/plugins/network/src/connection-show-page.cpp b/plugins/network/src/connection-show-page.cpp
|
||
index 71ae95c..ae50b06 100644
|
||
--- a/plugins/network/src/connection-show-page.cpp
|
||
+++ b/plugins/network/src/connection-show-page.cpp
|
||
@@ -27,13 +27,10 @@ using namespace NetworkManager;
|
||
ConnectionShowPage::ConnectionShowPage(QWidget* parent) : QWidget(parent), ui(new Ui::ConnectionShowPage)
|
||
{
|
||
ui->setupUi(this);
|
||
- initUI();
|
||
- initConnect();
|
||
}
|
||
|
||
ConnectionShowPage::~ConnectionShowPage()
|
||
{
|
||
- KLOG_DEBUG() << "ConnectionShowPage::~ConnectionShowPage()";
|
||
delete ui;
|
||
}
|
||
|
||
@@ -42,14 +39,36 @@ void ConnectionShowPage::setTitle(QString title)
|
||
ui->title->setText(title);
|
||
}
|
||
|
||
+void ConnectionShowPage::init(NetworkManager::ConnectionSettings::ConnectionType connectionType, const QString& devicePath)
|
||
+{
|
||
+ m_connectionType = connectionType;
|
||
+ m_devicePath = devicePath;
|
||
+ ui->connectionLists->setDevicePath(devicePath);
|
||
+ ui->connectionLists->setItemWidgetType(ITEM_WIDGET_TYPE_PLUGIN);
|
||
+
|
||
+ initUI();
|
||
+ initConnect();
|
||
+}
|
||
+
|
||
+// TODO:增加判断设备是否可用的逻辑,unmanager 和 unavalibale的处理
|
||
void ConnectionShowPage::initUI()
|
||
{
|
||
+ // switchButton Checked 默认为false
|
||
m_switchButton = new KiranSwitchButton(this);
|
||
+ initSwitchButton();
|
||
|
||
ui->titleLayout->addWidget(m_switchButton);
|
||
ui->connectionLists->setMaximumHeight(ui->connectionLists->sizeHintForRow(0) * ui->connectionLists->count() + (2 * ui->connectionLists->frameWidth()));
|
||
Kiran::StylePropertyHelper::setButtonType(ui->createConnectionButton, Kiran::BUTTON_Default);
|
||
ui->createConnectionButton->setIcon(QIcon(":/kcp-network-images/connection-add.svg"));
|
||
+
|
||
+ if (m_connectionType == ConnectionSettings::Wireless)
|
||
+ {
|
||
+ ui->connectionLists->showWirelessNetworkLists();
|
||
+ ui->connectionLists->setVisible(isWirelessEnabled());
|
||
+ }
|
||
+ else
|
||
+ ui->connectionLists->showConnectionLists(m_connectionType);
|
||
}
|
||
|
||
void ConnectionShowPage::initConnect()
|
||
@@ -66,31 +85,35 @@ void ConnectionShowPage::initConnect()
|
||
|
||
connect(ui->connectionLists, &ConnectionLists::sendSsidToWireless, this, &ConnectionShowPage::sendSsidToWireless);
|
||
|
||
- connect(m_switchButton, &KiranSwitchButton::toggled, this, &ConnectionShowPage::handleToggledSwitchButton);
|
||
+ connect(m_switchButton, &KiranSwitchButton::toggled, this, &ConnectionShowPage::handleToggledSwitchButton, Qt::UniqueConnection);
|
||
|
||
/**
|
||
*如果频繁的打开/禁用网络,会频繁发送信号,使用定时器进行处理
|
||
* */
|
||
- m_timer.setInterval(100);
|
||
- m_timer.setSingleShot(true);
|
||
- connect(notifier(), &Notifier::wirelessEnabledChanged, [=](bool enable)
|
||
- {
|
||
- m_wirlessNetworkEnable = enable;
|
||
- m_timer.start(); });
|
||
+ // m_timer.setInterval(200);
|
||
+ // m_timer.setSingleShot(true);
|
||
+ // connect(notifier(), &Notifier::wirelessEnabledChanged, this, [this](bool enable)
|
||
+ // {
|
||
+ // m_wirlessNetworkEnable = enable;
|
||
+ // m_timer.start(); });
|
||
+
|
||
+ // connect(&m_timer, &QTimer::timeout, this, [this]()
|
||
+ // { handleWirelessEnabledChanged(m_wirlessNetworkEnable); });
|
||
|
||
- connect(&m_timer, &QTimer::timeout, [=]()
|
||
- { handleWirelessEnabledChanged(m_wirlessNetworkEnable); });
|
||
+ if (m_connectionType == ConnectionSettings::Wireless)
|
||
+ {
|
||
+ connect(notifier(), &Notifier::wirelessEnabledChanged, this, &ConnectionShowPage::handleWirelessEnabledChanged, Qt::UniqueConnection);
|
||
+ }
|
||
|
||
- // connect(notifier(), &Notifier::wirelessEnabledChanged, this, &ConnectionShowPage::handleWirelessEnabledChanged);
|
||
connect(notifier(), &Notifier::networkingEnabledChanged, [=]() {});
|
||
}
|
||
|
||
+//弃用
|
||
void ConnectionShowPage::setConnectionType(ConnectionSettings::ConnectionType connectionType)
|
||
{
|
||
m_connectionType = connectionType;
|
||
}
|
||
|
||
-// XXX:该函数有待修改
|
||
void ConnectionShowPage::initSwitchButton()
|
||
{
|
||
switch (m_connectionType)
|
||
@@ -109,6 +132,7 @@ void ConnectionShowPage::initSwitchButton()
|
||
|
||
void ConnectionShowPage::handleToggledSwitchButton(bool toggled)
|
||
{
|
||
+ KLOG_DEBUG() << "--------------------------------handleToggledSwitchButton:" << toggled;
|
||
switch (m_connectionType)
|
||
{
|
||
case ConnectionSettings::Wired:
|
||
@@ -125,14 +149,17 @@ void ConnectionShowPage::handleToggledSwitchButton(bool toggled)
|
||
}
|
||
}
|
||
|
||
-//TODO:控制无线网络设备开关
|
||
void ConnectionShowPage::handleWirelessEnabledChanged(bool enabled)
|
||
{
|
||
+ KLOG_DEBUG() << "*****************************handleWirelessEnabledChanged:" << enabled;
|
||
+ //处理通过命令行等其他方式禁用无线网络的情况
|
||
+ m_switchButton->blockSignals(true);
|
||
m_switchButton->setChecked(enabled);
|
||
+ m_switchButton->blockSignals(false);
|
||
ui->connectionLists->setVisible(enabled);
|
||
- // ui->createConnectionButton->setVisible(enabled);
|
||
}
|
||
|
||
+//弃用
|
||
void ConnectionShowPage::setDevicePath(const QString& devicePath)
|
||
{
|
||
m_devicePath = devicePath;
|
||
@@ -209,6 +236,7 @@ void ConnectionShowPage::updateItemActivatedStatus(const QString& activatedPath)
|
||
ui->connectionLists->updateItemActivatedStatus(activatedPath);
|
||
}
|
||
|
||
+//弃用
|
||
void ConnectionShowPage::setItemWidgetType(ItemWidgetType itemType)
|
||
{
|
||
ui->connectionLists->setItemWidgetType(itemType);
|
||
diff --git a/plugins/network/src/connection-show-page.h b/plugins/network/src/connection-show-page.h
|
||
index 9b618c2..308e5dc 100644
|
||
--- a/plugins/network/src/connection-show-page.h
|
||
+++ b/plugins/network/src/connection-show-page.h
|
||
@@ -19,8 +19,8 @@
|
||
#include <NetworkManagerQt/Manager>
|
||
#include <NetworkManagerQt/WirelessNetwork>
|
||
#include <QListWidgetItem>
|
||
-#include <QWidget>
|
||
#include <QTimer>
|
||
+#include <QWidget>
|
||
|
||
QT_BEGIN_NAMESPACE
|
||
namespace Ui
|
||
@@ -39,6 +39,8 @@ class ConnectionShowPage : public QWidget
|
||
public:
|
||
explicit ConnectionShowPage(QWidget *parent = nullptr);
|
||
~ConnectionShowPage() override;
|
||
+
|
||
+ void init(NetworkManager::ConnectionSettings::ConnectionType connectionType, const QString &devicePath);
|
||
void initUI();
|
||
void initConnect();
|
||
|
||
diff --git a/plugins/network/src/plugin/cpanel-network-widget.cpp b/plugins/network/src/plugin/cpanel-network-widget.cpp
|
||
index daf3c33..cb0ec10 100644
|
||
--- a/plugins/network/src/plugin/cpanel-network-widget.cpp
|
||
+++ b/plugins/network/src/plugin/cpanel-network-widget.cpp
|
||
@@ -13,6 +13,7 @@
|
||
*/
|
||
|
||
#include "cpanel-network-widget.h"
|
||
+#include <kiran-sidebar-item.h>
|
||
#include <qt5-log-i.h>
|
||
#include "plugin/details-page.h"
|
||
#include "ui_cpanel-network-widget.h"
|
||
@@ -48,52 +49,63 @@ void CPanelNetworkWidget::init()
|
||
initConnect();
|
||
}
|
||
|
||
-//TODO:增加sidebarItem与设备的对应关系
|
||
+// TODO:增加sidebarItem与设备的对应关系
|
||
void CPanelNetworkWidget::initPage()
|
||
{
|
||
getAvailableDeviceList();
|
||
int row = 0;
|
||
for (int i = 0; i < m_wiredDeviceList.count(); ++i)
|
||
{
|
||
- auto device = m_wiredDeviceList.value(i);
|
||
+ Device::Ptr device = m_wiredDeviceList.value(i);
|
||
+ connect(device.data(), &Device::managedChanged, this, &CPanelNetworkWidget::handleManagedChanged, Qt::UniqueConnection);
|
||
+
|
||
QString devicePath = device->uni();
|
||
QString deviceName = device->interfaceName();
|
||
WiredManager *wiredManager = new WiredManager(devicePath, this);
|
||
- ui->stackedWidget->insertWidget(row,wiredManager);
|
||
+ ui->stackedWidget->insertWidget(row, wiredManager);
|
||
|
||
QString subItemName = tr("Wired Network %1");
|
||
QString subItemNameStr = subItemName.arg(i + 1);
|
||
- if(m_wiredDeviceList.count() == 1)
|
||
- ui->sidebar->insertItem(row, tr("Wired Network"));
|
||
+
|
||
+ KiranSidebarItem *sidebarItem = new KiranSidebarItem();
|
||
+ if (m_wiredDeviceList.count() == 1)
|
||
+ sidebarItem->setText(tr("Wired Network"));
|
||
else
|
||
- ui->sidebar->insertItem(row, subItemNameStr);
|
||
- ui->sidebar->item(row)->setData(Qt::UserRole, row);
|
||
- ui->sidebar->item(row)->setIcon(trayIconColorSwitch(":/kcp-network-images/wired.svg"));
|
||
+ sidebarItem->setText(subItemNameStr);
|
||
+
|
||
+ ui->sidebar->insertItem(row, sidebarItem);
|
||
+ sidebarItem->setData(Qt::UserRole, row);
|
||
+ sidebarItem->setIcon(trayIconColorSwitch(":/kcp-network-images/wired.svg"));
|
||
row++;
|
||
}
|
||
|
||
for (int i = 0; i < m_wirelessDeviceList.count(); ++i)
|
||
{
|
||
- auto device = m_wirelessDeviceList.value(i);
|
||
+ Device::Ptr device = m_wirelessDeviceList.value(i);
|
||
+ connect(device.data(), &Device::managedChanged, this, &CPanelNetworkWidget::handleManagedChanged, Qt::UniqueConnection);
|
||
+
|
||
QString devicePath = device->uni();
|
||
QString deviceName = device->interfaceName();
|
||
WirelessManager *wirelessManager = new WirelessManager(devicePath, this);
|
||
- ui->stackedWidget->insertWidget(row,wirelessManager);
|
||
+ ui->stackedWidget->insertWidget(row, wirelessManager);
|
||
|
||
QString subItemName = tr("Wireless Network %1");
|
||
- QString subItemNameStr = subItemName.arg(i+1);
|
||
- if(m_wirelessDeviceList.count() == 1)
|
||
- ui->sidebar->insertItem(row, tr("Wireless Network"));
|
||
+ QString subItemNameStr = subItemName.arg(i + 1);
|
||
+
|
||
+ KiranSidebarItem *sidebarItem = new KiranSidebarItem();
|
||
+ if (m_wirelessDeviceList.count() == 1)
|
||
+ sidebarItem->setText(tr("Wireless Network"));
|
||
else
|
||
- ui->sidebar->insertItem(row, subItemNameStr);
|
||
+ sidebarItem->setText(subItemNameStr);
|
||
|
||
- ui->sidebar->item(row)->setData(Qt::UserRole, row);
|
||
- ui->sidebar->item(row)->setIcon(trayIconColorSwitch(":/kcp-network-images/wireless.svg"));
|
||
+ ui->sidebar->insertItem(row, sidebarItem);
|
||
+ sidebarItem->setData(Qt::UserRole, row);
|
||
+ sidebarItem->setIcon(trayIconColorSwitch(":/kcp-network-images/wireless.svg"));
|
||
row++;
|
||
}
|
||
|
||
VpnManager *vpnManager = new VpnManager(this);
|
||
- ui->stackedWidget->insertWidget(row,vpnManager);
|
||
+ ui->stackedWidget->insertWidget(row, vpnManager);
|
||
|
||
ui->sidebar->insertItem(row, tr("VPN"));
|
||
ui->sidebar->item(row)->setData(Qt::UserRole, row);
|
||
@@ -101,7 +113,7 @@ void CPanelNetworkWidget::initPage()
|
||
row++;
|
||
|
||
DetailsPage *networkDetails = new DetailsPage(this);
|
||
- ui->stackedWidget->insertWidget(row,networkDetails);
|
||
+ ui->stackedWidget->insertWidget(row, networkDetails);
|
||
ui->sidebar->insertItem(row, tr("Network Details"));
|
||
ui->sidebar->item(row)->setData(Qt::UserRole, row);
|
||
ui->sidebar->item(row)->setIcon(trayIconColorSwitch(":/kcp-network-images/network-details.svg"));
|
||
@@ -115,7 +127,7 @@ void CPanelNetworkWidget::getAvailableDeviceList()
|
||
const Device::List deviceList = networkInterfaces();
|
||
for (Device::Ptr dev : deviceList)
|
||
{
|
||
- if (dev->state() == Device::Unavailable)
|
||
+ if (dev->state() == Device::Unmanaged)
|
||
continue;
|
||
|
||
switch (dev->type())
|
||
@@ -174,71 +186,89 @@ void CPanelNetworkWidget::initConnect()
|
||
{
|
||
m_Timer.setInterval(500);
|
||
m_Timer.setSingleShot(true);
|
||
- waitCounts = 1;
|
||
- connect(&m_Timer, &QTimer::timeout, [=]()
|
||
+ m_waitCounts = 1;
|
||
+ // Note:新设备插入后,需要等待一段时间,Device::List networkInterfaces() 来不及更新
|
||
+ // Note:DeviceAdded signal is emitted when a new network interface is available.
|
||
+
|
||
+ // XXX:当发出deviceAdded信号时,应该已经managed,需要修改并重新测试
|
||
+ connect(notifier(), &Notifier::deviceAdded, this, [this](const QString &uni)
|
||
{
|
||
+ m_addDevicePath = uni;
|
||
Device::Ptr device = findNetworkInterface(m_addDevicePath);
|
||
- if(device->managed())
|
||
+ if(device.isNull())
|
||
+ {
|
||
+ KLOG_DEBUG() << "this device interface is not found";
|
||
+ return;
|
||
+ }
|
||
+ if(device->isValid())
|
||
{
|
||
handleDeviceAdded(m_addDevicePath);
|
||
- m_Timer.stop();
|
||
}
|
||
else
|
||
{
|
||
- KLOG_INFO() << "this device interface is not ready";
|
||
+ KLOG_INFO() << "this device interface is invalid!";
|
||
m_Timer.start();
|
||
- }
|
||
- waitCounts++;
|
||
- if(waitCounts > MAX_WAIT_COUNTS)
|
||
- {
|
||
- KLOG_INFO() << "This device is not currently managed by NetworkManager";
|
||
- m_Timer.stop();
|
||
+ KLOG_INFO() << "wait counts:" << m_waitCounts;
|
||
} });
|
||
|
||
- // Note:新设备插入后,需要等待一段时间,Device::List networkInterfaces() 来不及更新
|
||
- connect(notifier(), &Notifier::deviceAdded, [=](const QString &uni)
|
||
+ connect(&m_Timer, &QTimer::timeout, this, [this]()
|
||
{
|
||
- m_addDevicePath = uni;
|
||
Device::Ptr device = findNetworkInterface(m_addDevicePath);
|
||
- KLOG_DEBUG() << "device->availableConnections().isEmpty():" << device->availableConnections().isEmpty();
|
||
- KLOG_DEBUG() << "device->managed():" << device->managed();
|
||
- if(!device->isValid())
|
||
+ if(device->isValid())
|
||
{
|
||
- KLOG_INFO() << "this device interface is invalid!";
|
||
- return ;
|
||
- }
|
||
- if(device->managed())
|
||
handleDeviceAdded(m_addDevicePath);
|
||
+ m_Timer.stop();
|
||
+ }
|
||
else
|
||
{
|
||
- KLOG_INFO() << "this device interface is not ready";
|
||
+ KLOG_INFO() << "this device interface is invalid!";
|
||
m_Timer.start();
|
||
- KLOG_INFO() << "wait counts:" << waitCounts;
|
||
+ }
|
||
+ m_waitCounts++;
|
||
+ if(m_waitCounts > MAX_WAIT_COUNTS)
|
||
+ {
|
||
+ KLOG_INFO() << "This device is currently invalid by NetworkManager";
|
||
+ m_Timer.stop();
|
||
} });
|
||
|
||
connect(notifier(), &Notifier::deviceRemoved, this, &CPanelNetworkWidget::handleDeviceRemoved);
|
||
|
||
- connect(ui->sidebar, &QListWidget::itemClicked, this,&CPanelNetworkWidget::handleSideBarItemClicked);
|
||
+ connect(notifier(), &Notifier::wirelessEnabledChanged, this, &CPanelNetworkWidget::handleWirelessEnabledChanged);
|
||
+ connect(notifier(), &Notifier::networkingEnabledChanged, this, &CPanelNetworkWidget::handleNetworkingEnabledChanged);
|
||
+
|
||
+ connect(ui->sidebar, &QListWidget::itemClicked, this, &CPanelNetworkWidget::handleSideBarItemClicked);
|
||
|
||
connect(Kiran::StylePalette::instance(), &Kiran::StylePalette::themeChanged, this, &CPanelNetworkWidget::handleThemeChanged);
|
||
}
|
||
|
||
-// XXX:暂时全部item重新加载有待优化
|
||
-void CPanelNetworkWidget::handleDeviceAdded(const QString &devicePath)
|
||
+// XXX:需要优化,改成动态增减侧边栏subItems,而不是全部重新加载
|
||
+void CPanelNetworkWidget::handleManagedChanged()
|
||
{
|
||
+ auto device = qobject_cast<Device *>(sender());
|
||
+ if (device != nullptr)
|
||
+ {
|
||
+ if (device->managed())
|
||
+ {
|
||
+ }
|
||
+ }
|
||
reload();
|
||
emit subItemsChanged();
|
||
}
|
||
|
||
+// TODO:侧边栏标签显示设备可用或禁用
|
||
+void CPanelNetworkWidget::handleDeviceAdded(const QString &devicePath)
|
||
+{
|
||
+ KLOG_DEBUG() << "--------------------DeviceAdded :" << devicePath;
|
||
+}
|
||
+
|
||
void CPanelNetworkWidget::handleDeviceRemoved(const QString &devicePath)
|
||
{
|
||
- reload();
|
||
- emit subItemsChanged();
|
||
+ KLOG_DEBUG() << "---------------------DeviceRemoved: " << devicePath;
|
||
}
|
||
|
||
void CPanelNetworkWidget::reload()
|
||
{
|
||
- for (int i = 0; i < ui->stackedWidget->count(); ++i)
|
||
+ for (int i = 0; i < ui->stackedWidget->count(); i++)
|
||
{
|
||
auto widget = ui->stackedWidget->widget(i);
|
||
ui->stackedWidget->removeWidget(widget);
|
||
@@ -255,10 +285,10 @@ void CPanelNetworkWidget::reload()
|
||
|
||
QPixmap CPanelNetworkWidget::trayIconColorSwitch(const QString &iconPath)
|
||
{
|
||
- //icon原本为浅色
|
||
+ // icon原本为浅色
|
||
QIcon icon(iconPath);
|
||
- QPixmap pixmap = icon.pixmap(16,16);
|
||
- if( Kiran::StylePalette::instance()->paletteType() != Kiran::PALETTE_DARK )
|
||
+ QPixmap pixmap = icon.pixmap(16, 16);
|
||
+ if (Kiran::StylePalette::instance()->paletteType() != Kiran::PALETTE_DARK)
|
||
{
|
||
QImage image = pixmap.toImage();
|
||
image.invertPixels(QImage::InvertRgb);
|
||
@@ -272,7 +302,7 @@ void CPanelNetworkWidget::handleThemeChanged(Kiran::PaletteType paletteType)
|
||
for (int i = 0; i < ui->sidebar->count(); ++i)
|
||
{
|
||
auto icon = ui->sidebar->item(i)->icon();
|
||
- QPixmap pixmap = icon.pixmap(16,16);
|
||
+ QPixmap pixmap = icon.pixmap(16, 16);
|
||
QImage image = pixmap.toImage();
|
||
image.invertPixels(QImage::InvertRgb);
|
||
pixmap = QPixmap::fromImage(image);
|
||
@@ -283,10 +313,10 @@ void CPanelNetworkWidget::handleThemeChanged(Kiran::PaletteType paletteType)
|
||
void CPanelNetworkWidget::handleSideBarItemClicked(QListWidgetItem *item)
|
||
{
|
||
ui->stackedWidget->setCurrentIndex(item->data(Qt::UserRole).toInt());
|
||
-
|
||
- QString itemText = item->text();
|
||
- KLOG_DEBUG() << "item clicked:" << item->text();
|
||
- if(itemText.contains(tr("Wireless Network")))
|
||
+
|
||
+ QString itemText = item->text();
|
||
+ KLOG_DEBUG() << "item clicked:" << item->text();
|
||
+ if (itemText.contains(tr("Wireless Network")))
|
||
{
|
||
KLOG_DEBUG() << "item clicked wireless";
|
||
for (auto device : m_wirelessDeviceList)
|
||
@@ -305,4 +335,12 @@ void CPanelNetworkWidget::handleSideBarItemClicked(QListWidgetItem *item)
|
||
}
|
||
}
|
||
}
|
||
+}
|
||
+
|
||
+void CPanelNetworkWidget::handleWirelessEnabledChanged(bool enable)
|
||
+{
|
||
+}
|
||
+
|
||
+void CPanelNetworkWidget::handleNetworkingEnabledChanged(bool enable)
|
||
+{
|
||
}
|
||
\ No newline at end of file
|
||
diff --git a/plugins/network/src/plugin/cpanel-network-widget.h b/plugins/network/src/plugin/cpanel-network-widget.h
|
||
index 112cab8..03c7350 100644
|
||
--- a/plugins/network/src/plugin/cpanel-network-widget.h
|
||
+++ b/plugins/network/src/plugin/cpanel-network-widget.h
|
||
@@ -15,11 +15,11 @@
|
||
#ifndef KIRAN_CPANEL_NETWORK_CPANEL_NETWORK_WIDGET_H
|
||
#define KIRAN_CPANEL_NETWORK_CPANEL_NETWORK_WIDGET_H
|
||
|
||
-#include <QWidget>
|
||
#include <NetworkManagerQt/Device>
|
||
+#include <QTimer>
|
||
+#include <QWidget>
|
||
#include "kiran-sidebar-widget.h"
|
||
#include "style-palette.h"
|
||
-#include <QTimer>
|
||
|
||
QT_BEGIN_NAMESPACE
|
||
namespace Ui
|
||
@@ -51,6 +51,9 @@ public slots:
|
||
void handleDeviceRemoved(const QString &devicePath);
|
||
void handleThemeChanged(Kiran::PaletteType paletteType);
|
||
void handleSideBarItemClicked(QListWidgetItem *item);
|
||
+ void handleManagedChanged();
|
||
+ void handleWirelessEnabledChanged(bool enable);
|
||
+ void handleNetworkingEnabledChanged(bool enable);
|
||
|
||
signals:
|
||
void subItemsChanged();
|
||
@@ -63,7 +66,7 @@ private:
|
||
|
||
QTimer m_Timer;
|
||
QString m_addDevicePath;
|
||
- int waitCounts;
|
||
+ int m_waitCounts;
|
||
};
|
||
|
||
-#endif //KIRAN_CPANEL_NETWORK_CPANEL_NETWORK_WIDGET_H
|
||
+#endif // KIRAN_CPANEL_NETWORK_CPANEL_NETWORK_WIDGET_H
|
||
diff --git a/plugins/network/src/plugin/details-page.cpp b/plugins/network/src/plugin/details-page.cpp
|
||
index a585a68..dfee3f6 100644
|
||
--- a/plugins/network/src/plugin/details-page.cpp
|
||
+++ b/plugins/network/src/plugin/details-page.cpp
|
||
@@ -58,7 +58,7 @@ void DetailsPage::initUI()
|
||
QWidget *widget = new ConnectionDetailsWidget(m_deviceList.at(0), this);
|
||
ui->stackedWidget->addWidget(widget);
|
||
}
|
||
- else if(m_deviceList.count() == 0)
|
||
+ else if (m_deviceList.count() == 0)
|
||
{
|
||
QWidget *widget = new ConnectionDetailsWidget(nullptr, this);
|
||
ui->stackedWidget->addWidget(widget);
|
||
@@ -105,12 +105,13 @@ void DetailsPage::handleDeviceRemoved(const QString &devicePath)
|
||
|
||
void DetailsPage::handleActiveConnectionChanged()
|
||
{
|
||
+ reload();
|
||
}
|
||
|
||
void DetailsPage::handleActiveConnectionAdded(const QString &activeConnectionPath)
|
||
{
|
||
ActiveConnection::Ptr activeConnection = findActiveConnection(activeConnectionPath);
|
||
- connect(activeConnection.data(), &ActiveConnection::stateChanged, this, &DetailsPage::handleActiveConnectionStateChanged);
|
||
+ connect(activeConnection.data(), &ActiveConnection::stateChanged, this, &DetailsPage::handleActiveConnectionStateChanged, Qt::UniqueConnection);
|
||
}
|
||
|
||
void DetailsPage::handleActiveConnectionRemoved(const QString &activeConnectionPath)
|
||
diff --git a/plugins/network/src/plugin/manager/vpn-manager.cpp b/plugins/network/src/plugin/manager/vpn-manager.cpp
|
||
index 96d6baa..cd858b5 100644
|
||
--- a/plugins/network/src/plugin/manager/vpn-manager.cpp
|
||
+++ b/plugins/network/src/plugin/manager/vpn-manager.cpp
|
||
@@ -14,17 +14,17 @@
|
||
|
||
#include "vpn-manager.h"
|
||
#include <qt5-log-i.h>
|
||
+#include <style-property.h>
|
||
#include <NetworkManagerQt/Manager>
|
||
#include <NetworkManagerQt/Settings>
|
||
#include <NetworkManagerQt/VpnConnection>
|
||
#include <QDialog>
|
||
#include <QPointer>
|
||
#include <QScrollBar>
|
||
+#include "connection-name-widget.h"
|
||
+#include "status-notification.h"
|
||
#include "text-input-dialog.h"
|
||
#include "ui_vpn-manager.h"
|
||
-#include "status-notification.h"
|
||
-#include "connection-name-widget.h"
|
||
-#include <style-property.h>
|
||
using namespace NetworkManager;
|
||
|
||
Q_DECLARE_METATYPE(VpnType)
|
||
@@ -43,21 +43,20 @@ VpnManager::~VpnManager()
|
||
|
||
void VpnManager::initUI()
|
||
{
|
||
- ui->connectionShowPage->setConnectionType(ConnectionSettings::Vpn);
|
||
- ui->connectionShowPage->setItemWidgetType(ITEM_WIDGET_TYPE_PLUGIN);
|
||
+ ui->connectionShowPage->init(ConnectionSettings::Vpn, "");
|
||
ui->connectionShowPage->setTitle(tr("VPN"));
|
||
ui->connectionShowPage->setSwitchButtonVisible(false);
|
||
- ui->connectionShowPage->showConnectionLists(ConnectionSettings::Vpn);
|
||
|
||
-// ui->vpnType->addItem(tr("L2TP"), VPN_TYPE_L2TP);
|
||
+ // ui->vpnType->addItem(tr("L2TP"), VPN_TYPE_L2TP);
|
||
ui->vpnType->addItem(tr("PPTP"), VPN_TYPE_PPTP);
|
||
- Kiran::StylePropertyHelper::setButtonType(ui->saveButton,Kiran::BUTTON_Default);
|
||
+ Kiran::StylePropertyHelper::setButtonType(ui->saveButton, Kiran::BUTTON_Default);
|
||
}
|
||
|
||
-//XXX:是否使用模板提升通用性
|
||
+// XXX:是否使用模板提升通用性
|
||
void VpnManager::initConnection()
|
||
{
|
||
- connect(ui->connectionShowPage, &ConnectionShowPage::requestCreatConnection, [=]() {
|
||
+ connect(ui->connectionShowPage, &ConnectionShowPage::requestCreatConnection, [=]()
|
||
+ {
|
||
//默认创建vpn类型:L2TP
|
||
ui->vpnTypeWidget->setVisible(true);
|
||
ui->vpnType->setCurrentIndex(0);
|
||
@@ -66,13 +65,13 @@ void VpnManager::initConnection()
|
||
|
||
QPointer<QScrollBar> scrollBar = ui->scrollArea->verticalScrollBar();
|
||
scrollBar->setValue(0);
|
||
- ui->stackedWidget->setCurrentIndex(PAGE_SETTING);
|
||
- });
|
||
+ ui->stackedWidget->setCurrentIndex(PAGE_SETTING); });
|
||
|
||
connect(ui->connectionShowPage, &ConnectionShowPage::requestEditConnection, this, &VpnManager::handleRequestEditConnection);
|
||
connect(ui->connectionShowPage, &ConnectionShowPage::requestActivateCurrentItemConnection, this, &VpnManager::handleRequestActivateConnection);
|
||
|
||
- connect(ui->vpnType, QOverload<int>::of(&QComboBox::currentIndexChanged), [=](int index) {
|
||
+ connect(ui->vpnType, QOverload<int>::of(&QComboBox::currentIndexChanged), [=](int index)
|
||
+ {
|
||
VpnType type = ui->vpnType->currentData().value<VpnType>();
|
||
ui->vpnTypeStacked->setCurrentIndex(VPN_TYPE_PPTP);
|
||
switch (type)
|
||
@@ -85,49 +84,47 @@ void VpnManager::initConnection()
|
||
break;
|
||
default:
|
||
break;
|
||
- }
|
||
- });
|
||
+ } });
|
||
|
||
connect(ui->returnButton, &QPushButton::clicked, this, &VpnManager::handleReturnPreviousPage);
|
||
connect(ui->l2tpSetting, &VpnL2tpSetting::returnPreviousPage, this, &VpnManager::handleReturnPreviousPage);
|
||
connect(ui->pptpSetting, &VpnPptpSetting::returnPreviousPage, this, &VpnManager::handleReturnPreviousPage);
|
||
|
||
- connect(ui->saveButton, &QPushButton::clicked, [=]() {
|
||
- int index = ui->vpnTypeStacked->currentIndex();
|
||
- switch (index)
|
||
- {
|
||
- case VPN_TYPE_L2TP:
|
||
- if(ui->l2tpSetting->isInputValid())
|
||
+ connect(ui->saveButton, &QPushButton::clicked, [=]()
|
||
{
|
||
- ui->l2tpSetting->handleSaveButtonClicked(ConnectionSettings::ConnectionType::Vpn);
|
||
- handleReturnPreviousPage();
|
||
- }
|
||
- break;
|
||
- case VPN_TYPE_PPTP:
|
||
- if(ui->pptpSetting->isInputValid())
|
||
+ int index = ui->vpnTypeStacked->currentIndex();
|
||
+ switch (index)
|
||
+ {
|
||
+ case VPN_TYPE_L2TP:
|
||
+ if(ui->l2tpSetting->isInputValid())
|
||
+ {
|
||
+ ui->l2tpSetting->handleSaveButtonClicked(ConnectionSettings::ConnectionType::Vpn);
|
||
+ handleReturnPreviousPage();
|
||
+ }
|
||
+ break;
|
||
+ case VPN_TYPE_PPTP:
|
||
+ if(ui->pptpSetting->isInputValid())
|
||
+ {
|
||
+ ui->pptpSetting->handleSaveButtonClicked(ConnectionSettings::ConnectionType::Vpn);
|
||
+ handleReturnPreviousPage();
|
||
+ }
|
||
+ break;
|
||
+ default:
|
||
+ break;
|
||
+ } });
|
||
+
|
||
+ connect(ui->connectionShowPage, &ConnectionShowPage::connectionUpdated, [=](const QString &path)
|
||
{
|
||
- ui->pptpSetting->handleSaveButtonClicked(ConnectionSettings::ConnectionType::Vpn);
|
||
- handleReturnPreviousPage();
|
||
- }
|
||
- break;
|
||
- default:
|
||
- break;
|
||
- }
|
||
- });
|
||
-
|
||
- connect(ui->connectionShowPage,&ConnectionShowPage::connectionUpdated,[=](const QString &path){
|
||
- KLOG_DEBUG() << "Connection::updated:" << path;
|
||
- //移除后再加载进来以更新信息
|
||
- ui->connectionShowPage->removeConnectionFromLists(path);
|
||
- Connection::Ptr updateConnection = findConnection(path);
|
||
- ui->connectionShowPage->addConnectionToLists(updateConnection,"");
|
||
- handleReturnPreviousPage();
|
||
- });
|
||
+ KLOG_DEBUG() << "Connection::updated:" << path;
|
||
+ //移除后再加载进来以更新信息
|
||
+ ui->connectionShowPage->removeConnectionFromLists(path);
|
||
+ Connection::Ptr updateConnection = findConnection(path);
|
||
+ ui->connectionShowPage->addConnectionToLists(updateConnection,"");
|
||
+ handleReturnPreviousPage(); });
|
||
|
||
initNotifierConnection();
|
||
}
|
||
|
||
-
|
||
void VpnManager::handleRequestEditConnection(const QString &uuid, QString activeConnectionPath)
|
||
{
|
||
//隐藏选择VPN类型
|
||
@@ -158,7 +155,7 @@ void VpnManager::handleRequestEditConnection(const QString &uuid, QString active
|
||
}
|
||
else
|
||
{
|
||
- //other type
|
||
+ // other type
|
||
}
|
||
|
||
QPointer<QScrollBar> scrollBar = ui->scrollArea->verticalScrollBar();
|
||
@@ -167,7 +164,7 @@ void VpnManager::handleRequestEditConnection(const QString &uuid, QString active
|
||
}
|
||
|
||
//考虑弹窗输入密码的情况
|
||
-void VpnManager::handleRequestActivateConnection(const QString &connectionPath,const QString &connectionParameter)
|
||
+void VpnManager::handleRequestActivateConnection(const QString &connectionPath, const QString &connectionParameter)
|
||
{
|
||
Connection::Ptr connection = findConnection(connectionPath);
|
||
ConnectionSettings::Ptr settings = connection->settings();
|
||
@@ -190,19 +187,19 @@ void VpnManager::handleRequestActivateConnection(const QString &connectionPath,c
|
||
QString tips = QString(tr("Password required to connect to %1.")).arg(settings->id());
|
||
inputDialog.setText(tips);
|
||
|
||
- connect(&inputDialog, &TextInputDialog::password, [=](const QString &password) {
|
||
+ connect(&inputDialog, &TextInputDialog::password, [=](const QString &password)
|
||
+ {
|
||
NMStringMap secretsMap = vpnSetting->secrets();
|
||
secretsMap.insert("password", password);
|
||
vpnSetting->setSecrets(secretsMap);
|
||
activateVPNConnection(connectionPath, connectionParameter);
|
||
- connection->clearSecrets();
|
||
- });
|
||
+ connection->clearSecrets(); });
|
||
|
||
inputDialog.exec();
|
||
}
|
||
}
|
||
|
||
-void VpnManager::activateVPNConnection(const QString &connectionPath,const QString &connectionParameter)
|
||
+void VpnManager::activateVPNConnection(const QString &connectionPath, const QString &connectionParameter)
|
||
{
|
||
QDBusPendingReply<QDBusObjectPath> reply =
|
||
NetworkManager::activateConnection(connectionPath, "", connectionParameter);
|
||
@@ -222,11 +219,10 @@ void VpnManager::activateVPNConnection(const QString &connectionPath,const QStri
|
||
|
||
void VpnManager::handleNotifierConnectionAdded(const QString &path)
|
||
{
|
||
- Connection::Ptr connection = findConnection(path);
|
||
- if ((connection->settings()->connectionType() == ConnectionSettings::ConnectionType::Vpn)
|
||
- && (!connection->name().isEmpty()))
|
||
+ Connection::Ptr connection = findConnection(path);
|
||
+ if ((connection->settings()->connectionType() == ConnectionSettings::ConnectionType::Vpn) && (!connection->name().isEmpty()))
|
||
{
|
||
- ui->connectionShowPage->addConnectionToLists(connection,"");
|
||
+ ui->connectionShowPage->addConnectionToLists(connection, "");
|
||
}
|
||
}
|
||
|
||
@@ -238,10 +234,10 @@ void VpnManager::handleNotifierConnectionRemoved(const QString &path)
|
||
void VpnManager::handleActiveConnectionAdded(const QString &activePath)
|
||
{
|
||
ActiveConnection::Ptr activatedConnection = findActiveConnection(activePath);
|
||
- if(activatedConnection == nullptr)
|
||
+ if (activatedConnection == nullptr)
|
||
{
|
||
KLOG_DEBUG() << "activatedConnection == nullptr";
|
||
- return ;
|
||
+ return;
|
||
}
|
||
if (activatedConnection->type() == ConnectionSettings::ConnectionType::Vpn)
|
||
{
|
||
@@ -249,10 +245,9 @@ void VpnManager::handleActiveConnectionAdded(const QString &activePath)
|
||
QString uuid = vpnConnection->uuid();
|
||
KLOG_DEBUG() << "vpn uuid:" << uuid;
|
||
QListWidgetItem *activeItem = ui->connectionShowPage->findItemByUuid(uuid);
|
||
- ui->connectionShowPage->updateItemActivatedPath(activeItem,activePath);
|
||
- connect(vpnConnection.data(), &VpnConnection::stateChanged, [=](VpnConnection::State state, VpnConnection::StateChangeReason reason) {
|
||
- handleVpnConnectionStateChanged(state, reason, activePath);
|
||
- });
|
||
+ ui->connectionShowPage->updateItemActivatedPath(activeItem, activePath);
|
||
+ connect(vpnConnection.data(), &VpnConnection::stateChanged, [=](VpnConnection::State state, VpnConnection::StateChangeReason reason)
|
||
+ { handleVpnConnectionStateChanged(state, reason, activePath); });
|
||
//加载等待动画
|
||
auto item = ui->connectionShowPage->findItemByActivatedPath(activePath);
|
||
ui->connectionShowPage->updateItemActivatingStatus(item);
|
||
@@ -263,13 +258,13 @@ void VpnManager::handleActiveConnectionRemoved(const QString &activePath)
|
||
{
|
||
}
|
||
|
||
-//TODO:若没有安装VPN插件则需要提示
|
||
+// TODO:若没有安装VPN插件则需要提示
|
||
void VpnManager::handleVpnConnectionStateChanged(VpnConnection::State state, VpnConnection::StateChangeReason reason, const QString &activePath)
|
||
{
|
||
auto activeConnection = findActiveConnection(activePath);
|
||
- KLOG_DEBUG() << " activeConnection->id():" << activeConnection->id();
|
||
+ KLOG_DEBUG() << " activeConnection->id():" << activeConnection->id();
|
||
QString id = "";
|
||
- if(activeConnection != nullptr)
|
||
+ if (activeConnection != nullptr)
|
||
id = activeConnection->id();
|
||
switch (state)
|
||
{
|
||
@@ -294,13 +289,13 @@ void VpnManager::handleVpnConnectionStateChanged(VpnConnection::State state, Vpn
|
||
break;
|
||
case VpnConnection::State::Failed:
|
||
KLOG_DEBUG() << "VpnConnection::State::Failed";
|
||
- if(!id.isEmpty())
|
||
+ if (!id.isEmpty())
|
||
StatusNotification::ActiveConnectionDeactivatedNotify(id);
|
||
handleVpnStateFailed(activePath);
|
||
break;
|
||
case VpnConnection::State::Disconnected:
|
||
KLOG_DEBUG() << "VpnConnection::State::Disconnected";
|
||
- if(!id.isEmpty())
|
||
+ if (!id.isEmpty())
|
||
StatusNotification::ActiveConnectionDeactivatedNotify(id);
|
||
handleVpnStateDisconnected(activePath);
|
||
break;
|
||
@@ -354,9 +349,9 @@ void VpnManager::handleVpnConnectionStateChanged(VpnConnection::State state, Vpn
|
||
void VpnManager::handleVpnStateActivated(const QString &activePath)
|
||
{
|
||
ActiveConnection::Ptr activeConnection = findActiveConnection(activePath);
|
||
- if(activeConnection.isNull())
|
||
- return ;
|
||
- if( activeConnection->type() == ConnectionSettings::Vpn)
|
||
+ if (activeConnection.isNull())
|
||
+ return;
|
||
+ if (activeConnection->type() == ConnectionSettings::Vpn)
|
||
{
|
||
ui->connectionShowPage->updateItemActivatedStatus(activePath);
|
||
auto item = ui->connectionShowPage->findItemByActivatedPath(activePath);
|
||
@@ -398,4 +393,3 @@ void VpnManager::clearVpnSetting()
|
||
break;
|
||
}
|
||
}
|
||
-
|
||
diff --git a/plugins/network/src/plugin/manager/wired-manager.cpp b/plugins/network/src/plugin/manager/wired-manager.cpp
|
||
index dfccd25..cfd11b2 100644
|
||
--- a/plugins/network/src/plugin/manager/wired-manager.cpp
|
||
+++ b/plugins/network/src/plugin/manager/wired-manager.cpp
|
||
@@ -40,25 +40,22 @@ WiredManager::~WiredManager()
|
||
|
||
void WiredManager::initUI()
|
||
{
|
||
- ui->connectionShowPage->setConnectionType(ConnectionSettings::Wired);
|
||
- ui->connectionShowPage->setDevicePath(m_devicePath);
|
||
- ui->connectionShowPage->setItemWidgetType(ITEM_WIDGET_TYPE_PLUGIN);
|
||
+ ui->connectionShowPage->init(ConnectionSettings::Wired, m_devicePath);
|
||
ui->connectionShowPage->setTitle(tr("Wired Network Adapter"));
|
||
ui->connectionShowPage->setSwitchButtonVisible(false);
|
||
- ui->connectionShowPage->showConnectionLists(ConnectionSettings::ConnectionType::Wired);
|
||
Kiran::StylePropertyHelper::setButtonType(ui->saveButton, Kiran::BUTTON_Default);
|
||
}
|
||
|
||
void WiredManager::initConnection()
|
||
{
|
||
- connect(ui->connectionShowPage, &ConnectionShowPage::requestCreatConnection, [=]()
|
||
+ connect(ui->connectionShowPage, &ConnectionShowPage::requestCreatConnection, this, [this]()
|
||
{
|
||
ui->wiredSettingPage->showSettingPage();
|
||
QPointer<QScrollBar> scrollBar = ui->scrollArea->verticalScrollBar();
|
||
scrollBar->setValue(0);
|
||
ui->stackedWidget->setCurrentIndex(PAGE_SETTING); });
|
||
|
||
- connect(ui->connectionShowPage, &ConnectionShowPage::requestEditConnection, [=](const QString &uuid, QString activeConnectionPath)
|
||
+ connect(ui->connectionShowPage, &ConnectionShowPage::requestEditConnection, this, [this](const QString &uuid, QString activeConnectionPath)
|
||
{
|
||
ui->wiredSettingPage->initConnectionSettings(ConnectionSettings::ConnectionType::Wired, uuid);
|
||
ui->wiredSettingPage->initSettingPage();
|
||
@@ -73,7 +70,7 @@ void WiredManager::initConnection()
|
||
|
||
connect(ui->wiredSettingPage, &WiredSettingPage::returnPreviousPage, this, &WiredManager::handleReturnPreviousPage);
|
||
|
||
- connect(ui->connectionShowPage, &ConnectionShowPage::connectionUpdated, this,&WiredManager::handleConnectionUpdated);
|
||
+ connect(ui->connectionShowPage, &ConnectionShowPage::connectionUpdated, this, &WiredManager::handleConnectionUpdated);
|
||
|
||
connect(ui->connectionShowPage, &ConnectionShowPage::requestActivateCurrentItemConnection,
|
||
this, &WiredManager::handleRequestActivateConnection);
|
||
diff --git a/plugins/network/src/plugin/manager/wireless-manager.cpp b/plugins/network/src/plugin/manager/wireless-manager.cpp
|
||
index 7c2eabb..2596c39 100644
|
||
--- a/plugins/network/src/plugin/manager/wireless-manager.cpp
|
||
+++ b/plugins/network/src/plugin/manager/wireless-manager.cpp
|
||
@@ -11,6 +11,7 @@
|
||
*
|
||
* Author: luoqing <luoqing@kylinos.com.cn>
|
||
*/
|
||
+#include "wireless-manager.h"
|
||
#include <qt5-log-i.h>
|
||
#include <style-property.h>
|
||
#include <NetworkManagerQt/Settings>
|
||
@@ -20,7 +21,6 @@
|
||
#include <QScrollBar>
|
||
#include "text-input-dialog.h"
|
||
#include "ui_wireless-manager.h"
|
||
-#include "wireless-manager.h"
|
||
|
||
using namespace NetworkManager;
|
||
|
||
@@ -41,14 +41,10 @@ WirelessManager::~WirelessManager()
|
||
|
||
void WirelessManager::initUI()
|
||
{
|
||
- ui->connectionShowPage->setConnectionType(ConnectionSettings::Wireless);
|
||
- ui->connectionShowPage->setDevicePath(m_devicePath);
|
||
- ui->connectionShowPage->setItemWidgetType(ITEM_WIDGET_TYPE_PLUGIN);
|
||
+ ui->connectionShowPage->init(ConnectionSettings::Wireless, m_devicePath);
|
||
ui->connectionShowPage->setTitle(tr("Wireless Network Adapter"));
|
||
- ui->connectionShowPage->initSwitchButton();
|
||
ui->connectionShowPage->setSwitchButtonVisible(true);
|
||
ui->connectionShowPage->setCreateButtonVisible(false);
|
||
- ui->connectionShowPage->showWirelessNetworkLists();
|
||
Kiran::StylePropertyHelper::setButtonType(ui->saveButton, Kiran::BUTTON_Default);
|
||
|
||
// XXX:由于存在switchButton,所以特别修改一下topMargin
|
||
@@ -57,38 +53,38 @@ void WirelessManager::initUI()
|
||
|
||
void WirelessManager::initConnection()
|
||
{
|
||
- connect(ui->connectionShowPage, &ConnectionShowPage::requestCreatConnection, [=]()
|
||
+ connect(ui->connectionShowPage, &ConnectionShowPage::requestCreatConnection, this, [this]()
|
||
{
|
||
- ui->wirelessSettingPage->showSettingPage();
|
||
- QPointer<QScrollBar> scrollBar = ui->scrollArea->verticalScrollBar();
|
||
- scrollBar->setValue(0);
|
||
- ui->stackedWidget->setCurrentIndex(PAGE_SETTING); });
|
||
+ ui->wirelessSettingPage->showSettingPage();
|
||
+ QPointer<QScrollBar> scrollBar = ui->scrollArea->verticalScrollBar();
|
||
+ scrollBar->setValue(0);
|
||
+ ui->stackedWidget->setCurrentIndex(PAGE_SETTING); });
|
||
|
||
- connect(ui->connectionShowPage, &ConnectionShowPage::requestEditConnection, [=](const QString &uuid, QString activeConnectionPath)
|
||
+ connect(ui->connectionShowPage, &ConnectionShowPage::requestEditConnection, this, [this](const QString &uuid, QString activeConnectionPath)
|
||
{
|
||
- ActiveConnection::Ptr activeConnection = findActiveConnection(activeConnectionPath);
|
||
- ConnectionSettings::Ptr connectionSettings = activeConnection->connection()->settings();
|
||
- ui->wirelessSettingPage->setConnection(activeConnection->connection());
|
||
- ui->wirelessSettingPage->setConnectionSettings(connectionSettings);
|
||
- ui->wirelessSettingPage->initSettingPage();
|
||
- ui->wirelessSettingPage->showSettingPage(activeConnectionPath);
|
||
- QPointer<QScrollBar> scrollBar = ui->scrollArea->verticalScrollBar();
|
||
- scrollBar->setValue(0);
|
||
- ui->stackedWidget->setCurrentIndex(PAGE_SETTING); });
|
||
+ ActiveConnection::Ptr activeConnection = findActiveConnection(activeConnectionPath);
|
||
+ ConnectionSettings::Ptr connectionSettings = activeConnection->connection()->settings();
|
||
+ ui->wirelessSettingPage->setConnection(activeConnection->connection());
|
||
+ ui->wirelessSettingPage->setConnectionSettings(connectionSettings);
|
||
+ ui->wirelessSettingPage->initSettingPage();
|
||
+ ui->wirelessSettingPage->showSettingPage(activeConnectionPath);
|
||
+ QPointer<QScrollBar> scrollBar = ui->scrollArea->verticalScrollBar();
|
||
+ scrollBar->setValue(0);
|
||
+ ui->stackedWidget->setCurrentIndex(PAGE_SETTING); });
|
||
|
||
connect(ui->returnButton, &QPushButton::clicked, this, &WirelessManager::handleReturnPreviousPage);
|
||
- connect(ui->saveButton, &QPushButton::clicked, [=]()
|
||
+ connect(ui->saveButton, &QPushButton::clicked, this, [this]()
|
||
{
|
||
- ui->wirelessSettingPage->handleSaveButtonClicked(ConnectionSettings::ConnectionType::Wireless);
|
||
- handleReturnPreviousPage(); });
|
||
+ ui->wirelessSettingPage->handleSaveButtonClicked(ConnectionSettings::ConnectionType::Wireless);
|
||
+ handleReturnPreviousPage(); });
|
||
|
||
connect(ui->wirelessSettingPage, &WirelessSettingPage::returnPreviousPage, this, &WirelessManager::handleReturnPreviousPage);
|
||
// XXX:更改信号
|
||
- connect(ui->wirelessSettingPage, &WirelessSettingPage::settingUpdated, [=]()
|
||
+ connect(ui->wirelessSettingPage, &WirelessSettingPage::settingUpdated, this, [this]()
|
||
{
|
||
- KLOG_DEBUG() << "WiredSettingPage::settingUpdated";
|
||
- handleReturnPreviousPage();
|
||
- refreshConnectionLists(); });
|
||
+ KLOG_DEBUG() << "WiredSettingPage::settingUpdated";
|
||
+ handleReturnPreviousPage();
|
||
+ refreshConnectionLists(); });
|
||
|
||
connect(ui->connectionShowPage, &ConnectionShowPage::requestConnectWirelessNetwork,
|
||
this, &WirelessManager::handleRequestConnectWirelessNetwork);
|
||
@@ -99,8 +95,8 @@ void WirelessManager::initConnection()
|
||
connect(m_wirelessDevice.data(), &WirelessDevice::networkDisappeared, this, &WirelessManager::handleNetworkDisappeared, Qt::QueuedConnection);
|
||
connect(m_wirelessDevice.data(), &WirelessDevice::networkAppeared, this, &WirelessManager::handleNetworkAppeared);
|
||
|
||
- //Note:插件与托盘都对该设备的信号进行了连接,容易干扰重复,因此,插件暂未实现该函数
|
||
- connect(m_devicePtr.data(), &Device::stateChanged, this, &WirelessManager::handleDeviceStateChanged,Qt::UniqueConnection);
|
||
+ // Note:插件与托盘都对该设备的信号进行了连接,容易干扰重复,因此,插件暂未实现该函数
|
||
+ connect(m_devicePtr.data(), &Device::stateChanged, this, &WirelessManager::handleDeviceStateChanged, Qt::UniqueConnection);
|
||
}
|
||
|
||
//在已存在WirelessSetting配置的情况下,激活连接.(连接过一次后会创建WirelessSetting配置)
|
||
@@ -203,7 +199,7 @@ void WirelessManager::handleActiveConnectionAdded(const QString &path)
|
||
auto item = ui->connectionShowPage->item(row);
|
||
ui->connectionShowPage->itemSimpleStatus(item);
|
||
}
|
||
- connect(activatedConnection.data(), &ActiveConnection::stateChanged, this, &WirelessManager::handleActiveConnectionStateChanged,Qt::UniqueConnection);
|
||
+ connect(activatedConnection.data(), &ActiveConnection::stateChanged, this, &WirelessManager::handleActiveConnectionStateChanged, Qt::UniqueConnection);
|
||
}
|
||
}
|
||
|
||
diff --git a/plugins/network/src/plugin/setting-widget/vpn/vpn-ppp.cpp b/plugins/network/src/plugin/setting-widget/vpn/vpn-ppp.cpp
|
||
index c195235..383d3e4 100644
|
||
--- a/plugins/network/src/plugin/setting-widget/vpn/vpn-ppp.cpp
|
||
+++ b/plugins/network/src/plugin/setting-widget/vpn/vpn-ppp.cpp
|
||
@@ -63,11 +63,11 @@ void VpnPpp::initOptionsButton(const QStringList &supportOptions)
|
||
switchButton->setProperty("option", option);
|
||
m_optionsButtonMap[option] = switchButton;
|
||
|
||
- QHBoxLayout *horizontalLayout = new QHBoxLayout(this);
|
||
+ QHBoxLayout *horizontalLayout = new QHBoxLayout();
|
||
horizontalLayout->addWidget(strLabel);
|
||
horizontalLayout->addStretch();
|
||
horizontalLayout->addWidget(switchButton);
|
||
- horizontalLayout->setContentsMargins(0,0,0,0);
|
||
+ horizontalLayout->setContentsMargins(0, 0, 0, 0);
|
||
ui->optionsLayout->addLayout(horizontalLayout);
|
||
}
|
||
else
|
||
@@ -156,7 +156,7 @@ void VpnPpp::saveSettings()
|
||
m_vpnSetting->setInitialized(true);
|
||
}
|
||
|
||
-//XXX:优化流程
|
||
+// XXX:优化流程
|
||
void VpnPpp::showSettings()
|
||
{
|
||
if (m_vpnSetting != nullptr)
|
||
diff --git a/plugins/network/src/tray/network-tray.cpp b/plugins/network/src/tray/network-tray.cpp
|
||
index 5aeb35d..232882b 100644
|
||
--- a/plugins/network/src/tray/network-tray.cpp
|
||
+++ b/plugins/network/src/tray/network-tray.cpp
|
||
@@ -74,7 +74,7 @@ void NetworkTray::initConnect()
|
||
|
||
// TODO:优化deviceAdded的逻辑
|
||
// 需要等待一段时间,Device::List networkInterfaces() 来不及更新
|
||
- connect(notifier(), &Notifier::deviceAdded, [this](const QString &uni)
|
||
+ connect(notifier(), &Notifier::deviceAdded, this, [this](const QString &uni)
|
||
{
|
||
m_addDevicePath = uni;
|
||
Device::Ptr device = findNetworkInterface(m_addDevicePath);
|
||
@@ -83,18 +83,17 @@ void NetworkTray::initConnect()
|
||
KLOG_DEBUG() << "this device interface is not found";
|
||
return;
|
||
}
|
||
-
|
||
- KLOG_DEBUG() << "device->managed():" << device->managed();
|
||
- if(!device->isValid())
|
||
+ KLOG_DEBUG() << "device->uni():" << device->uni();
|
||
+ KLOG_DEBUG() << "device->interfaceName():" << device->interfaceName();
|
||
+ KLOG_DEBUG() << "device->state():" << device->state();
|
||
+ KLOG_DEBUG() << "device->isValid():" << device->isValid();
|
||
+ if(device->isValid())
|
||
{
|
||
- KLOG_INFO() << "this device interface is invalid!";
|
||
- return ;
|
||
- }
|
||
- if(device->managed())
|
||
handleDeviceAdded(m_addDevicePath);
|
||
+ }
|
||
else
|
||
{
|
||
- KLOG_INFO() << "this device interface is not ready";
|
||
+ KLOG_INFO() << "this device interface is invalid!";
|
||
m_Timer.start();
|
||
KLOG_INFO() << "wait counts:" << m_waitCounts;
|
||
} });
|
||
@@ -102,7 +101,7 @@ void NetworkTray::initConnect()
|
||
m_Timer.setInterval(500);
|
||
m_Timer.setSingleShot(true);
|
||
m_waitCounts = 1;
|
||
- connect(&m_Timer, &QTimer::timeout, [this]()
|
||
+ connect(&m_Timer, &QTimer::timeout, this, [this]()
|
||
{
|
||
Device::Ptr device = findNetworkInterface(m_addDevicePath);
|
||
if(device.isNull())
|
||
@@ -132,6 +131,8 @@ void NetworkTray::initConnect()
|
||
|
||
connect(notifier(), &Notifier::primaryConnectionChanged, this, &NetworkTray::handlePrimaryConnectionChanged);
|
||
|
||
+ connect(notifier(), &Notifier::wirelessEnabledChanged, this, &NetworkTray::handleWirelessEnabledChanged, Qt::UniqueConnection);
|
||
+
|
||
// 无线网络如果一下消失多个网络,短时间会触发多次SizeHint变更的信号
|
||
m_wirelessTimer.setInterval(100);
|
||
m_wirelessTimer.setSingleShot(true);
|
||
@@ -184,8 +185,8 @@ void NetworkTray::getAvailableDeviceList()
|
||
for (Device::Ptr dev : deviceList)
|
||
{
|
||
KLOG_DEBUG() << "dev->interfaceName():" << dev->interfaceName();
|
||
- KLOG_DEBUG() << "dev->availableConnections():" << dev->availableConnections();
|
||
KLOG_DEBUG() << "dev->state():" << dev->state();
|
||
+ KLOG_DEBUG() << "dev->isValid():" << dev->isValid();
|
||
|
||
if (dev->state() == Device::Unavailable)
|
||
continue;
|
||
@@ -295,103 +296,50 @@ void NetworkTray::getTrayGeometry()
|
||
// TODO:增加其他状态图标
|
||
void NetworkTray::setTrayIcon(NetworkManager::Status status)
|
||
{
|
||
- // 判断主连接类型,托盘网络图标以主连接类型为准
|
||
- // NetworkManager::primaryConnectionType() 更新不及时,暂时不用
|
||
- ActiveConnection::Ptr primaryActiveConnection = primaryConnection();
|
||
- if (primaryActiveConnection != nullptr)
|
||
+ if (status == NetworkManager::Status::Connected)
|
||
{
|
||
- auto primaryConnectionType = primaryActiveConnection->connection()->settings()->connectionType();
|
||
- if (primaryConnectionType == ConnectionSettings::Wireless)
|
||
+ // 判断主连接类型,托盘网络图标以主连接类型为准
|
||
+ // NetworkManager::primaryConnectionType() 更新不及时,暂时不用
|
||
+ ActiveConnection::Ptr primaryActiveConnection = primaryConnection();
|
||
+ if (primaryActiveConnection != nullptr)
|
||
{
|
||
- // ActiveConnection::Ptr primaryActiveConnection = primaryConnection();
|
||
- // WirelessSetting::Ptr wirelessSetting = primaryActiveConnection->connection()->settings()->setting(Setting::Wireless).dynamicCast<WirelessSetting>();
|
||
- // QString ssid = QString(wirelessSetting->ssid());
|
||
+ auto primaryConnectionType = primaryActiveConnection->connection()->settings()->connectionType();
|
||
+ if (primaryConnectionType == ConnectionSettings::Wireless)
|
||
+ {
|
||
+ // ActiveConnection::Ptr primaryActiveConnection = primaryConnection();
|
||
+ // WirelessSetting::Ptr wirelessSetting = primaryActiveConnection->connection()->settings()->setting(Setting::Wireless).dynamicCast<WirelessSetting>();
|
||
+ // QString ssid = QString(wirelessSetting->ssid());
|
||
|
||
- // QString devicePath = primaryActiveConnection->devices().value(0);
|
||
- // Device::Ptr device = findNetworkInterface(devicePath);
|
||
- // WirelessDevice::Ptr wirelessDevice = qobject_cast<WirelessDevice*>(device);
|
||
- // WirelessNetwork::Ptr wirelessNetwork = wirelessDevice->findNetwork(ssid);
|
||
- // int signalStrength = wirelessNetwork->signalStrength();
|
||
+ // QString devicePath = primaryActiveConnection->devices().value(0);
|
||
+ // Device::Ptr device = findNetworkInterface(devicePath);
|
||
+ // WirelessDevice::Ptr wirelessDevice = qobject_cast<WirelessDevice*>(device);
|
||
+ // WirelessNetwork::Ptr wirelessNetwork = wirelessDevice->findNetwork(ssid);
|
||
+ // int signalStrength = wirelessNetwork->signalStrength();
|
||
|
||
- switch (status)
|
||
- {
|
||
- case NetworkManager::Status::Unknown:
|
||
- // 未知
|
||
- m_systemTray->setIcon(trayIconColorSwitch(":/kcp-network-images/wired-disconnected.svg"));
|
||
- break;
|
||
- case NetworkManager::Status::Asleep:
|
||
- // 不可用
|
||
- m_systemTray->setIcon(trayIconColorSwitch(":/kcp-network-images/wired-disconnected.svg"));
|
||
- break;
|
||
- case NetworkManager::Status::Disconnected:
|
||
- // 不可用
|
||
- m_systemTray->setIcon(trayIconColorSwitch(":/kcp-network-images/wired-disconnected.svg"));
|
||
- break;
|
||
- case NetworkManager::Status::Disconnecting:
|
||
- break;
|
||
- case NetworkManager::Status::Connecting:
|
||
- // 加载动画
|
||
- break;
|
||
- case NetworkManager::Status::ConnectedLinkLocal:
|
||
- m_systemTray->setIcon(trayIconColorSwitch(":/kcp-network-images/wired-disconnected.svg"));
|
||
- // 不可用
|
||
- break;
|
||
- case NetworkManager::Status::ConnectedSiteOnly:
|
||
- // 未知
|
||
- m_systemTray->setIcon(trayIconColorSwitch(":/kcp-network-images/wired-disconnected.svg"));
|
||
- break;
|
||
- case NetworkManager::Status::Connected:
|
||
- // 可用
|
||
m_systemTray->setIcon(trayIconColorSwitch(":/kcp-network-images/wireless-4.svg"));
|
||
- break;
|
||
- default:
|
||
- break;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
- switch (status)
|
||
- {
|
||
- case NetworkManager::Status::Unknown:
|
||
- // 未知
|
||
- m_systemTray->setIcon(trayIconColorSwitch(":/kcp-network-images/wired-disconnected.svg"));
|
||
- break;
|
||
- case NetworkManager::Status::Asleep:
|
||
- // 不可用
|
||
- m_systemTray->setIcon(trayIconColorSwitch(":/kcp-network-images/wired-disconnected.svg"));
|
||
- break;
|
||
- case NetworkManager::Status::Disconnected:
|
||
- // 不可用
|
||
- m_systemTray->setIcon(trayIconColorSwitch(":/kcp-network-images/wired-disconnected.svg"));
|
||
- break;
|
||
- case NetworkManager::Status::Disconnecting:
|
||
- break;
|
||
- case NetworkManager::Status::Connecting:
|
||
- // 加载动画
|
||
- break;
|
||
- case NetworkManager::Status::ConnectedLinkLocal:
|
||
- m_systemTray->setIcon(trayIconColorSwitch(":/kcp-network-images/wired-disconnected.svg"));
|
||
- // 不可用
|
||
- break;
|
||
- case NetworkManager::Status::ConnectedSiteOnly:
|
||
- // 未知
|
||
- m_systemTray->setIcon(trayIconColorSwitch(":/kcp-network-images/wired-disconnected.svg"));
|
||
- break;
|
||
- case NetworkManager::Status::Connected:
|
||
- // 可用
|
||
- m_systemTray->setIcon(trayIconColorSwitch(":/kcp-network-images/wired-connection.svg"));
|
||
- break;
|
||
- default:
|
||
- break;
|
||
- }
|
||
+ // 可用
|
||
+ m_systemTray->setIcon(trayIconColorSwitch(":/kcp-network-images/wired-connection.svg"));
|
||
}
|
||
}
|
||
+ else if (status == NetworkManager::Status::Disconnecting || NetworkManager::Status::Connecting)
|
||
+ {
|
||
+ // TODO:加载动画
|
||
+ }
|
||
+ else
|
||
+ {
|
||
+ m_systemTray->setIcon(trayIconColorSwitch(":/kcp-network-images/wired-disconnected.svg"));
|
||
+ }
|
||
}
|
||
|
||
// 重新获取device、初始化,刷新
|
||
// XXX:可以优化
|
||
void NetworkTray::handleDeviceAdded(const QString &devicePath)
|
||
{
|
||
+ KLOG_DEBUG() << "---------------------handleDeviceAdded:" << devicePath;
|
||
Device::Ptr device = findNetworkInterface(devicePath);
|
||
if (device->type() == Device::Ethernet)
|
||
{
|
||
@@ -406,6 +354,7 @@ void NetworkTray::handleDeviceAdded(const QString &devicePath)
|
||
// XXX:当device被移除时,由于设备对象可能已经被删除,所以并不能通过findNetworkInterface(path)找到该设备接口,进而知道被删除的设备类型
|
||
void NetworkTray::handleDeviceRemoved(const QString &devicePath)
|
||
{
|
||
+ KLOG_DEBUG() << "handle Device Removed :" << devicePath;
|
||
if (m_wiredTrayPage != nullptr)
|
||
{
|
||
if (m_wiredTrayPage->devicePathList().contains(devicePath))
|
||
@@ -424,12 +373,76 @@ void NetworkTray::handleDeviceStateChanged(NetworkManager::Device::State newstat
|
||
NetworkManager::Device::State oldstate,
|
||
NetworkManager::Device::StateChangeReason reason)
|
||
{
|
||
+ if ((oldstate == Device::Unavailable) &&
|
||
+ (newstate != Device::Unmanaged && newstate != Device::UnknownState))
|
||
+ {
|
||
+ }
|
||
+
|
||
+ if (newstate == Device::State::Unavailable)
|
||
+ {
|
||
+ Device *device = qobject_cast<Device *>(sender());
|
||
+ // KLOG_DEBUG() << "Device::State::Unavailable";
|
||
+ // KLOG_DEBUG() << "device->uni():" << device->uni();
|
||
+ // KLOG_DEBUG() << "device->interfaceName():" << device->interfaceName();
|
||
+ }
|
||
}
|
||
|
||
void NetworkTray::handleDeviceManagedChanged()
|
||
{
|
||
}
|
||
|
||
+// TODO:托盘对不可用状态进行提示
|
||
+/**
|
||
+ * XXX:由于在禁用和开启wifi时,并没有发出Wireless设备的deviceRemoved和deviceAdded信号
|
||
+ * 并且当WirelessEnabledChanged信号发送时,device state 还处在unavailbel 不可用状态,需要处理
|
||
+ */
|
||
+
|
||
+// TODO:托盘对不可用状态进行提示
|
||
+void NetworkTray::handleWirelessEnabledChanged(bool enable)
|
||
+{
|
||
+ KLOG_DEBUG() << "-----------------------handleWirelessEnabledChanged:" << enable;
|
||
+
|
||
+ if (m_wirelessTrayPage != nullptr)
|
||
+ {
|
||
+ m_verticalLayout->removeWidget(m_wirelessTrayPage);
|
||
+ delete m_wirelessTrayPage;
|
||
+ m_wirelessTrayPage = nullptr;
|
||
+ }
|
||
+ m_wirelessDeviceList.clear();
|
||
+
|
||
+ if (enable)
|
||
+ {
|
||
+ // networkInterfaces() 是否及时更新,需验证
|
||
+ const Device::List deviceList = networkInterfaces();
|
||
+ for (Device::Ptr dev : deviceList)
|
||
+ {
|
||
+ KLOG_DEBUG() << "dev->interfaceName():" << dev->interfaceName();
|
||
+ KLOG_DEBUG() << "dev->state():" << dev->state();
|
||
+ KLOG_DEBUG() << "dev->isValid():" << dev->isValid();
|
||
+
|
||
+ if ((dev->state() == Device::Unmanaged) || (dev->state() == Device::UnknownState))
|
||
+ continue;
|
||
+
|
||
+ if (dev->type() == Device::Wifi)
|
||
+ {
|
||
+ // Note:此时WirelessDevice状态还处在Unavailable,但还是将该设备加载
|
||
+ if (dev->state() == Device::Unavailable)
|
||
+ {
|
||
+ }
|
||
+ m_wirelessDeviceList << dev;
|
||
+ }
|
||
+ }
|
||
+
|
||
+ if (m_wirelessDeviceList.count() != 0)
|
||
+ {
|
||
+ m_wirelessTrayPage = new TrayPage(m_wirelessDeviceList, this);
|
||
+ m_verticalLayout->insertWidget(-1, m_wirelessTrayPage);
|
||
+ m_verticalLayout->setMargin(0);
|
||
+ update();
|
||
+ }
|
||
+ }
|
||
+}
|
||
+
|
||
void NetworkTray::handleNetworkManagerStatusChanged(NetworkManager::Status status)
|
||
{
|
||
setTrayIcon(status);
|
||
@@ -446,14 +459,15 @@ void NetworkTray::reloadWiredTrayPage()
|
||
delete m_wiredTrayPage;
|
||
m_wiredTrayPage = nullptr;
|
||
m_wiredDeviceList.clear();
|
||
+
|
||
getAvailableDeviceList();
|
||
if (m_wiredDeviceList.count() != 0)
|
||
+ {
|
||
m_wiredTrayPage = new TrayPage(m_wiredDeviceList, this);
|
||
-
|
||
- // XXX:待修改,使有线widget一直在最上层
|
||
- m_verticalLayout->insertWidget(0, m_wiredTrayPage);
|
||
- m_verticalLayout->setMargin(0);
|
||
- update();
|
||
+ m_verticalLayout->insertWidget(0, m_wiredTrayPage);
|
||
+ m_verticalLayout->setMargin(0);
|
||
+ update();
|
||
+ }
|
||
}
|
||
|
||
void NetworkTray::reloadWirelessTrayPage()
|
||
@@ -465,10 +479,12 @@ void NetworkTray::reloadWirelessTrayPage()
|
||
|
||
getAvailableDeviceList();
|
||
if (m_wirelessDeviceList.count() != 0)
|
||
+ {
|
||
m_wirelessTrayPage = new TrayPage(m_wirelessDeviceList, this);
|
||
- m_verticalLayout->insertWidget(-1, m_wirelessTrayPage);
|
||
- m_verticalLayout->setMargin(0);
|
||
- update();
|
||
+ m_verticalLayout->insertWidget(-1, m_wirelessTrayPage);
|
||
+ m_verticalLayout->setMargin(0);
|
||
+ update();
|
||
+ }
|
||
}
|
||
|
||
void NetworkTray::handleAdjustedTraySize(QSize sizeHint)
|
||
@@ -476,8 +492,8 @@ void NetworkTray::handleAdjustedTraySize(QSize sizeHint)
|
||
// this->sizeHint() 更新不及时,需要等一段时间
|
||
QTimer::singleShot(100, this, [=]()
|
||
{
|
||
- adjustSize();
|
||
- setTrayPagePos(); });
|
||
+ adjustSize();
|
||
+ setTrayPagePos(); });
|
||
}
|
||
|
||
void NetworkTray::handleThemeChanged(Kiran::PaletteType paletteType)
|
||
diff --git a/plugins/network/src/tray/network-tray.h b/plugins/network/src/tray/network-tray.h
|
||
index 7601e4f..23a0a9b 100644
|
||
--- a/plugins/network/src/tray/network-tray.h
|
||
+++ b/plugins/network/src/tray/network-tray.h
|
||
@@ -23,7 +23,6 @@
|
||
#include <QWidget>
|
||
#include "kiran-rounded-tray-popup/kiran-rounded-tray-popup.h"
|
||
|
||
-
|
||
class WiredTrayWidget;
|
||
class WirelessTrayWidget;
|
||
class StatusNotifierManagerInterface;
|
||
@@ -65,6 +64,7 @@ public slots:
|
||
NetworkManager::Device::State oldstate,
|
||
NetworkManager::Device::StateChangeReason reason);
|
||
void handleDeviceManagedChanged();
|
||
+ void handleWirelessEnabledChanged(bool enable);
|
||
|
||
void handleAdjustedTraySize(QSize sizeHint);
|
||
|
||
diff --git a/plugins/network/src/tray/tray-page.cpp b/plugins/network/src/tray/tray-page.cpp
|
||
index 7415dc8..c854d36 100644
|
||
--- a/plugins/network/src/tray/tray-page.cpp
|
||
+++ b/plugins/network/src/tray/tray-page.cpp
|
||
@@ -33,11 +33,15 @@ TrayPage::~TrayPage()
|
||
|
||
void TrayPage::init()
|
||
{
|
||
- Device::Type deviceType = m_deviceList.at(0)->type();
|
||
- initUI(deviceType);
|
||
- initConnection();
|
||
+ if (m_deviceList.count() != 0)
|
||
+ {
|
||
+ Device::Type deviceType = m_deviceList.value(0)->type();
|
||
+ initUI(deviceType);
|
||
+ initConnection();
|
||
+ }
|
||
}
|
||
|
||
+// XXX:修改初始化
|
||
void TrayPage::initUI(Device::Type deviceType)
|
||
{
|
||
setFixedWidth(240);
|
||
@@ -50,7 +54,7 @@ void TrayPage::initUI(Device::Type deviceType)
|
||
// {
|
||
// setSingleDeviceWidget(deviceType);
|
||
// }
|
||
- if(m_deviceList.count() != 0)
|
||
+ if (m_deviceList.count() != 0)
|
||
{
|
||
setMultiDeviceWidget(deviceType);
|
||
}
|
||
@@ -133,12 +137,9 @@ void TrayPage::handleDeviceComboBoxChanged(int index)
|
||
QStringList TrayPage::devicePathList()
|
||
{
|
||
QStringList devicePathList;
|
||
- KLOG_DEBUG() << "m_deviceList:" << m_deviceList;
|
||
for (Device::Ptr device : m_deviceList)
|
||
{
|
||
- if (device == nullptr)
|
||
- KLOG_DEBUG() << "device == nullptr";
|
||
- else
|
||
+ if (device != nullptr)
|
||
devicePathList << device->uni();
|
||
}
|
||
KLOG_DEBUG() << "devicePathList:" << devicePathList;
|
||
diff --git a/plugins/network/src/tray/wireless-tray-widget.cpp b/plugins/network/src/tray/wireless-tray-widget.cpp
|
||
index 2a480b1..32a9791 100644
|
||
--- a/plugins/network/src/tray/wireless-tray-widget.cpp
|
||
+++ b/plugins/network/src/tray/wireless-tray-widget.cpp
|
||
@@ -43,10 +43,9 @@ void WirelessTrayWidget::init()
|
||
initUI();
|
||
initConnection();
|
||
|
||
- ActiveConnection::Ptr activatedConnection = m_wirelessDevice->activeConnection();
|
||
- if(!activatedConnection.isNull())
|
||
+ ActiveConnection::Ptr activatedConnection = m_wirelessDevice->activeConnection();
|
||
+ if (!activatedConnection.isNull())
|
||
connect(activatedConnection.data(), &ActiveConnection::stateChanged, this, &WirelessTrayWidget::handleActiveConnectionStateChanged, Qt::UniqueConnection);
|
||
-
|
||
}
|
||
|
||
void WirelessTrayWidget::initUI()
|
||
@@ -70,7 +69,7 @@ void WirelessTrayWidget::initConnection()
|
||
connect(m_connectionLists, &ConnectionLists::sendPasswordToWirelessSetting, this, &WirelessTrayWidget::setSecurityPskAndActivateWirelessConnection);
|
||
connect(m_connectionLists, &ConnectionLists::sendSsidToWireless, this, &WirelessTrayWidget::handleRequestConnectHiddenNetwork);
|
||
|
||
- connect(m_devicePtr.data(), &Device::stateChanged, this, &WirelessTrayWidget::handleDeviceStateChanged,Qt::UniqueConnection);
|
||
+ connect(m_devicePtr.data(), &Device::stateChanged, this, &WirelessTrayWidget::handleDeviceStateChanged, Qt::UniqueConnection);
|
||
connect(m_connectionLists, &ConnectionLists::adjustedTraySize, this, &WirelessTrayWidget::adjustedTraySize);
|
||
}
|
||
|
||
@@ -110,7 +109,7 @@ void WirelessTrayWidget::handleRequestConnectHiddenNetwork(const QString &ssid)
|
||
{
|
||
KLOG_DEBUG() << "Hidden networks have been explicitly detected,return";
|
||
StatusNotification::connectitonHiddenNetworkFailedNotify(ssid);
|
||
-
|
||
+
|
||
QListWidgetItem *item = m_connectionLists->getHiddenNetworkItem();
|
||
m_connectionLists->itemSimpleStatus(item);
|
||
return;
|
||
@@ -148,7 +147,7 @@ void WirelessTrayWidget::getWirelessAvailableConnections(const QString &devicePa
|
||
}
|
||
|
||
// 在已存在WirelessSetting配置的情况下,激活连接.(连接过一次后会创建WirelessSetting配置)
|
||
-//Note:不存在的无线网络或者配置,能activate成功,但是返回的ActivateConnection可能会空,从而导致错误
|
||
+// Note:不存在的无线网络或者配置,能activate成功,但是返回的ActivateConnection可能会空,从而导致错误
|
||
void WirelessTrayWidget::activateWirelessConnection(const QString &connectionPath, const QString &devicePath, const QString &accessPointPath)
|
||
{
|
||
if (!connectionPath.isEmpty())
|
||
@@ -164,7 +163,7 @@ void WirelessTrayWidget::activateWirelessConnection(const QString &connectionPat
|
||
StatusNotification::connectitonFailedNotify(connectionPath);
|
||
}
|
||
else
|
||
- KLOG_DEBUG() << "reply.reply():" << reply.reply();
|
||
+ KLOG_DEBUG() << "reply.reply():" << reply.reply();
|
||
}
|
||
}
|
||
|
||
@@ -226,13 +225,13 @@ void WirelessTrayWidget::createConnectionSettings(const QString &ssid, const QSt
|
||
}
|
||
}
|
||
|
||
-//Note:不存在的无线网络或者配置,activate成功,但是返回的ActivateConnection可能会空,从而导致错误
|
||
+// Note:不存在的无线网络或者配置,activate成功,但是返回的ActivateConnection可能会空,从而导致错误
|
||
void WirelessTrayWidget::addAndActivateWirelessConnection(ConnectionSettings::Ptr connectionSettings)
|
||
{
|
||
const QString ssid = m_connectionInfo.wirelessInfo.ssid;
|
||
const QString accessPointPath = m_connectionInfo.wirelessInfo.accessPointPath;
|
||
KLOG_DEBUG() << "accessPointPath" << accessPointPath;
|
||
- KLOG_DEBUG() << "wireless device path:" << m_devicePath;
|
||
+ KLOG_DEBUG() << "wireless device path:" << m_devicePath;
|
||
QDBusPendingReply<QDBusObjectPath, QDBusObjectPath> reply =
|
||
NetworkManager::addAndActivateConnection(connectionSettings->toMap(), m_devicePath, accessPointPath);
|
||
|
||
@@ -260,9 +259,9 @@ void WirelessTrayWidget::handleRequestDisconnect(const QString &activatedConnect
|
||
}
|
||
|
||
/*FIX:
|
||
-*由于ActiveConnection为空,暂时无法获得有效的连接信息
|
||
-*存在多个网卡时,由于无法确定是那个该ActiveConnection来自那个设备,则多个设备都会发送通知
|
||
-*/
|
||
+ *由于ActiveConnection为空,暂时无法获得有效的连接信息
|
||
+ *存在多个网卡时,由于无法确定是那个该ActiveConnection来自那个设备,则多个设备都会发送通知
|
||
+ */
|
||
void WirelessTrayWidget::handleActiveConnectionAdded(const QString &path)
|
||
{
|
||
//多个网卡,还需要判断设备
|
||
@@ -270,12 +269,12 @@ void WirelessTrayWidget::handleActiveConnectionAdded(const QString &path)
|
||
ActiveConnection::Ptr activatedConnection = findActiveConnection(path);
|
||
if (activatedConnection == nullptr)
|
||
{
|
||
- //Note:目前已知连接一个不存在的无线网络时,activatedConnection为空
|
||
+ // Note:目前已知连接一个不存在的无线网络时,activatedConnection为空
|
||
StatusNotification::connectitonFailedNotify();
|
||
KLOG_DEBUG() << "new add activatedConnection is nullptr";
|
||
return;
|
||
}
|
||
-
|
||
+
|
||
QStringList deviceList = activatedConnection->devices();
|
||
if ((activatedConnection->type() == ConnectionSettings::ConnectionType::Wireless) && deviceList.contains(m_devicePath))
|
||
{
|
||
@@ -296,7 +295,7 @@ void WirelessTrayWidget::handleActiveConnectionAdded(const QString &path)
|
||
m_connectionLists->itemSimpleStatus(item);
|
||
}
|
||
connect(activatedConnection.data(), &ActiveConnection::stateChanged, this, &WirelessTrayWidget::handleActiveConnectionStateChanged, Qt::UniqueConnection);
|
||
- }
|
||
+ }
|
||
}
|
||
|
||
void WirelessTrayWidget::handleActiveConnectionRemoved(const QString &path)
|
||
@@ -310,7 +309,7 @@ void WirelessTrayWidget::handleStateActivating(const QString &activatedPath)
|
||
ActiveConnection::Ptr activatedConnection = findActiveConnection(activatedPath);
|
||
if (activatedConnection == nullptr)
|
||
{
|
||
- //Note:目前已知连接一个不存在的无线网络时,activatedConnection为空
|
||
+ // Note:目前已知连接一个不存在的无线网络时,activatedConnection为空
|
||
StatusNotification::connectitonFailedNotify();
|
||
KLOG_DEBUG() << "activatedConnection == nullptr";
|
||
return;
|
||
@@ -357,7 +356,6 @@ void WirelessTrayWidget::handleStateActivated(const QString &activatedPath)
|
||
//连接成功后手动rescan
|
||
QDBusPendingReply<> replyRequestScan = m_wirelessDevice->requestScan();
|
||
replyRequestScan.waitForFinished();
|
||
- KLOG_DEBUG() << "--------------------------StateActivated requestScan";
|
||
if (replyRequestScan.isError())
|
||
{
|
||
KLOG_DEBUG() << "StateActivated requestScan error:" << replyRequestScan.error();
|
||
@@ -447,8 +445,7 @@ void WirelessTrayWidget::handleRequestIgnore(const QString &activatedConnectionP
|
||
QDBusPendingReply<> replyRemove = connection->remove();
|
||
replyRemove.waitForFinished();
|
||
if (replyRemove.isError())
|
||
- KLOG_INFO() << "Remove connection failed:" << replyRemove.error();
|
||
- });
|
||
+ KLOG_INFO() << "Remove connection failed:" << replyRemove.error(); });
|
||
}
|
||
|
||
void WirelessTrayWidget::setSecurityPskAndActivateWirelessConnection(const QString &password)
|
||
--
|
||
2.33.0
|
||
|